(()=>{"use strict";function e(e){const t=e.querySelector(".flexa-before-after__frame"),r=e.querySelector(".flexa-before-after__handle");if(!t||!r)return;const n=e.querySelector(".flexa-before-after__label--before"),a=e.querySelector(".flexa-before-after__label--after"),i="vertical"===e.getAttribute("data-orientation"),o="hover"===e.getAttribute("data-interaction"),l=Number(e.getAttribute("data-position"));let c=Number.isFinite(l)?l:50;const d=e=>Math.max(0,Math.min(1,e)),s=e=>{var i;i=e,c=Math.max(0,Math.min(100,i)),t.style.setProperty("--flexa-ba-pos",`${c}%`),r.setAttribute("aria-valuenow",String(Math.round(c))),n&&(n.style.opacity=String(d((c-3)/10))),a&&(a.style.opacity=String(d((97-c)/10)))},f=(e,r)=>{const n=t.getBoundingClientRect();return i?n.height?(r-n.top)/n.height*100:50:n.width?(e-n.left)/n.width*100:50};if(s(c),o)t.addEventListener("pointermove",e=>s(f(e.clientX,e.clientY)));else{let e=!1;const r=t=>{e&&s(f(t.clientX,t.clientY))},n=()=>{e=!1};t.addEventListener("pointerdown",t=>{e=!0,s(f(t.clientX,t.clientY)),t.preventDefault()}),window.addEventListener("pointermove",r),window.addEventListener("pointerup",n),window.addEventListener("pointercancel",n)}r.addEventListener("keydown",e=>{let t=!0;switch(e.key){case"ArrowLeft":case"ArrowDown":s(c-1);break;case"ArrowRight":case"ArrowUp":s(c+1);break;case"Home":s(0);break;case"End":s(100);break;default:t=!1}t&&e.preventDefault()})}function t(){document.querySelectorAll(".flexa-before-after").forEach(e)}"loading"===document.readyState?document.addEventListener("DOMContentLoaded",t):t()})();