class d extends HTMLElement{constructor(){super(),this.currentImage=null}static register(a){console.log("Registering image-gallery-bs4"),"customElements"in window&&customElements.define(a||"image-gallery-bs4",d)}replaceImage(a){if(this.currentImage){const r=this.currentImage.getAttribute(a);if(r==="false")return;const t=this.querySelector("#"+r);t&&this.setModalImage(t)}}setModalImage(a){this.currentImage=a;const r=a.parentNode,t=r.parentNode.getAttribute("data-full"),o=r.querySelector("source"),c=this.querySelector(".modal-body"),u=this.querySelector(".modal-footer"),p=[{attr:"data-modal-srcset",prop:"srcset"},{attr:"data-modal-src",prop:"src"},{attr:"type",prop:"type"},{attr:"data-modal-sizes",prop:"sizes"}],m=c.querySelector("source");for(const{attr:i,prop:l}of p){const s=o.getAttribute(i);s&&m.setAttribute(l,s)}const b=[{attr:"alt",prop:"alt"},{attr:"data-prev",prop:"data-prev"},{attr:"data-next",prop:"data-next"},{attr:"data-fullsrc",prop:"src"},{attr:"data-modal-srcset",prop:"srcset"},{attr:"data-modal-sizes",prop:"sizes"},{attr:"data-modal-height",prop:"height"},{attr:"data-modal-width",prop:"width"}],n=c.querySelector("img");n.parentNode.parentNode.setAttribute("href",t);for(const{attr:i,prop:l}of b){const s=a.getAttribute(i);s&&n.setAttribute(l,s)}let e="";n.getAttribute("data-prev")!=="false"?e=e+'<button id="data-prev" type="button" class="btn btn-primary">Prev</button>':e=e+'<button id="data-prev" type="button" class="btn btn-primary disabled">Prev</button>',n.getAttribute("data-next")!=="false"?e=e+'<button id="data-next" type="button" class="btn btn-primary">Next</button>':e=e+'<button id="data-next" type="button" class="btn btn-primary disabled">Next</button>',u.innerHTML=e}connectedCallback(){this.querySelectorAll(".cast-gallery-container > a").forEach(t=>{t.classList.contains("event-added")||(t.addEventListener("click",o=>{o.preventDefault(),this.setModalImage(o.target)}),t.classList.add("event-added"))});const r=this.querySelector(".modal-footer");r&&r.addEventListener("click",t=>{t.target.matches("#data-prev, #data-next")&&this.replaceImage(t.target.id)}),this.addEventListener("keydown",function(t){t.keyCode===37&&this.replaceImage("data-prev"),t.keyCode===39&&this.replaceImage("data-next")})}}d.register("image-gallery-bs4");
