!function(){var e={d:function(t,i){for(var r in i)e.o(i,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:i[r]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};!function(){"use strict";var i,r;e.r(t),e.d(t,{AnimationBlocker:function(){return a}});class a{constructor(){r.set(this,i.createImageAddedObserver()),i.hideAllAnimations()}static createImageAddedObserver(){const e=document.querySelector("body"),t=new MutationObserver((e=>{for(const t of e)if("childList"===t.type){if(t.addedNodes)for(const e of t.addedNodes)"IMG"===e.nodeName&&this.couldBeAnimated(e)&&this.hideAnimation(e);t.removedNodes.length>0&&t.removedNodes.forEach((e=>{"IMG"===e.nodeName&&this.couldBeAnimated(e)&&this.removeBlockerUI(t.target)}))}}));return t.observe(e,{attributes:!0,childList:!0,subtree:!0}),t}static async waitForImage(e){return new Promise((t=>{if(e.complete)return t();e.onload=()=>t(),e.onerror=()=>t()}))}static imageSizeChanged(e){const t=e.clientWidth,i=e.clientHeight,r=e.dataset.width,a=e.dataset.height;if(r&&a)return t!==parseInt(r,10)||i!==parseInt(a,10)}static createCover(e){if(this.getCover(e))return;const t=e.clientWidth,i=e.clientHeight,r=e.parentElement,a=document.createElement("canvas");a.width=t,a.height=i,a.setAttribute("aria-hidden","true"),a.setAttribute("role","presentation"),a.setAttribute("data-image-cover","true"),a.style.position="absolute",a.style.top="50%",a.style.left="50%",a.style.transform="translate(-50%, -50%)",a.getContext("2d").drawImage(e,0,0,t,i),r.style.position="relative",r.insertBefore(a,e)}static getCover(e){var t;return null===(t=e.parentElement)||void 0===t?void 0:t.querySelector("[data-image-cover]")}static removeCover(e){const t=this.getCover(e);t.parentElement.removeChild(t)}static removeBlockerUI(e){var t;null===(t=e.querySelector("[data-image-cover]"))||void 0===t||t.remove()}static async hideAnimation(e){if(e.dataset.animationController)return;await this.waitForImage(e);let t=e.parentElement.querySelector("[data-image-cover]");const i=e.clientWidth,r=e.clientHeight;e.setAttribute("data-animation-state","paused"),t?t&&this.imageSizeChanged(e)&&(this.removeCover(e),this.createCover(e)):(e.setAttribute("data-width",i.toString()),e.setAttribute("data-height",r.toString()),this.createCover(e)),e.dataset.animationController=JSON.stringify(this)}static hideAllAnimations(){const e=this.getAllPotentiallyAnimated();for(let t=0;t<e.length;t++)this.hideAnimation(e[t])}static filterImages(e){return Array.from(e).filter((e=>this.couldBeAnimated(e)))}static couldBeAnimated(e){const t=e.src,i=e.srcset;return this.extensions.some((e=>t.includes(e)||i.includes(e)))||e.hasAttribute("data-animated")}static getAllPotentiallyAnimated(){const e=document.querySelectorAll("img");return this.filterImages(e)}}i=a,r=new WeakMap,a.extensions=[".gif",".webp"]}();var i=Craft="undefined"==typeof Craft?{}:Craft;for(var r in t)i[r]=t[r];t.__esModule&&Object.defineProperty(i,"__esModule",{value:!0})}();
//# sourceMappingURL=AnimationBlocker.js.map