/*! * Lightbox for Bootstrap 5 v1.8.3 (https://trvswgnr.github.io/bs5-lightbox/) * Copyright 2023 Travis Aaron Wagner (https://github.com/trvswgnr/) * Licensed under MIT (https://github.com/trvswgnr/bs5-lightbox/blob/main/LICENSE) */!function () { "use strict"; var t = { d: function (e, s) { for (var a in s) t.o(s, a) && !t.o(e, a) && Object.defineProperty(e, a, { enumerable: !0, get: s[a] }) }, o: function (t, e) { return Object.prototype.hasOwnProperty.call(t, e) } }, e = {}; t.d(e, { default: function () { return i } }); var s = window.bootstrap; const a = { Modal: s.Modal, Carousel: s.Carousel }; class o { constructor(t) { let e = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}; this.hash = this.randomHash(), this.settings = Object.assign(Object.assign(Object.assign({}, a.Modal.Default), a.Carousel.Default), { interval: !1, target: '[data-toggle="lightbox"]', gallery: "", size: "xl", constrain: !0 }), this.settings = Object.assign(Object.assign({}, this.settings), e), this.modalOptions = (() => this.setOptionsFromSettings(a.Modal.Default))(), this.carouselOptions = (() => this.setOptionsFromSettings(a.Carousel.Default))(), "string" == typeof t && (this.settings.target = t, t = document.querySelector(this.settings.target)), this.el = t, this.type = t.dataset.type || "", this.src = this.getSrc(t), this.sources = this.getGalleryItems(), this.createCarousel(), this.createModal() } show() { document.body.appendChild(this.modalElement), this.modal.show() } hide() { this.modal.hide() } setOptionsFromSettings(t) { return Object.keys(t).reduce(((t, e) => Object.assign(t, { [e]: this.settings[e] })), {}) } getSrc(t) { let e = t.dataset.src || t.dataset.remote || t.href || "http://via.placeholder.com/1600x900"; if ("html" === t.dataset.type) return e; /\:\/\//.test(e) || (e = window.location.origin + e); const s = new URL(e); return (t.dataset.footer || t.dataset.caption) && s.searchParams.set("caption", t.dataset.footer || t.dataset.caption), s.toString() } getGalleryItems() { let t; if (this.settings.gallery) { if (Array.isArray(this.settings.gallery)) return this.settings.gallery; t = this.settings.gallery } else this.el.dataset.gallery && (t = this.el.dataset.gallery); return t ? [...new Set(Array.from(document.querySelectorAll('[data-gallery="'.concat(t, '"]')), (t => "".concat(t.dataset.type ? t.dataset.type : "").concat(this.getSrc(t)))))] : ["".concat(this.type ? this.type : "").concat(this.src)] } getYoutubeId(t) { if (!t) return !1; const e = t.match(/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/); return !(!e || 11 !== e[2].length) && e[2] } getYoutubeLink(t) { const e = this.getYoutubeId(t); if (!e) return !1; const s = t.split("?"); let a = s.length > 1 ? "?" + s[1] : ""; return "https://www.youtube.com/embed/".concat(e).concat(a) } getInstagramEmbed(t) { if (/instagram/.test(t)) return t += /\/embed$/.test(t) ? "" : "/embed", '') } isEmbed(t) { const e = new RegExp("(" + o.allowedEmbedTypes.join("|") + ")").test(t), s = /\.(png|jpe?g|gif|svg|webp)/i.test(t) || "image" === this.el.dataset.type; return e || !s } createCarousel() { const t = document.createElement("template"), e = o.allowedMediaTypes.join("|"), s = this.sources.map(((t, s) => { t = t.replace(/\/$/, ""); const a = new RegExp("^(".concat(e, ")"), "i"), o = /^html/.test(t), i = /^image/.test(t); a.test(t) && (t = t.replace(a, "")); const n = this.settings.constrain ? "mw-100 mh-100 h-auto w-auto m-auto top-0 end-0 bottom-0 start-0" : "h-100 w-100", l = new URLSearchParams(t.split("?")[1]); let r = "", c = t; if (l.get("caption")) { try { c = new URL(t), c.searchParams.delete("caption"), c = c.toString() } catch (e) { c = t } r = '") } let d = ''), h = ""; const u = this.getInstagramEmbed(t), m = this.getYoutubeLink(t); this.isEmbed(t) && !i && (m && (t = m, h = 'title="YouTube video player" frameborder="0" allow="accelerometer autoplay clipboard-write encrypted-media gyroscope picture-in-picture"'), d = u || '")), o && (d = t); return '\n\t\t\t\t") })).join(""), i = this.sources.length < 2 ? "" : '\n\t\t\t\n\t\t\t'); let n = "lightbox-carousel carousel slide"; "fullscreen" === this.settings.size && (n += " position-absolute w-100 translate-middle top-50 start-50"); const l = '\n\t\t\t
\n\t\t\t\t\n\t\t\t\t").concat(i, "\n\t\t\t
"); t.innerHTML = l.trim(), this.carouselElement = t.content.firstChild; const r = Object.assign(Object.assign({}, this.carouselOptions), { keyboard: !1 }); this.carousel = new a.Carousel(this.carouselElement, r); const c = this.type && "image" !== this.type ? this.type + this.src : this.src; return this.carousel.to(this.findGalleryItemIndex(this.sources, c)), !0 === this.carouselOptions.keyboard && document.addEventListener("keydown", (t => { if ("ArrowLeft" === t.code) { const t = document.getElementById("#lightboxCarousel-".concat(this.hash, "-prev")); return t && t.click(), !1 } if ("ArrowRight" === t.code) { const t = document.getElementById("#lightboxCarousel-".concat(this.hash, "-next")); return t && t.click(), !1 } })), this.carousel } findGalleryItemIndex(t, e) { let s = 0; for (const a of t) { if (a.includes(e)) return s; s++ } return 0 } createModal() { const t = document.createElement("template"), e = '\n\t\t\t"); return t.innerHTML = e.trim(), this.modalElement = t.content.firstChild, this.modalElement.querySelector(".modal-body").appendChild(this.carouselElement), this.modalElement.addEventListener("hidden.bs.modal", (() => this.modalElement.remove())), this.modalElement.querySelector("[data-bs-dismiss]").addEventListener("click", (() => this.modal.hide())), this.modal = new a.Modal(this.modalElement, this.modalOptions), this.modal } randomHash() { let t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 8; return Array.from({ length: t }, (() => Math.floor(36 * Math.random()).toString(36))).join("") } } o.allowedEmbedTypes = ["embed", "youtube", "vimeo", "instagram", "url"], o.allowedMediaTypes = [...o.allowedEmbedTypes, "image", "html"], o.defaultSelector = '[data-toggle="lightbox"]', o.initialize = function (t) { t.preventDefault(); new o(this).show() }, document.querySelectorAll(o.defaultSelector).forEach((t => t.addEventListener("click", o.initialize))), "undefined" != typeof window && window.bootstrap && (window.bootstrap.Lightbox = o); var i = o; window.Lightbox = e.default }(); //# sourceMappingURL=index.bundle.min.js.map