Comparing version 4.0.0-beta.5 to 4.0.0-beta.6
@@ -1,4 +0,5 @@ | ||
import type { Plugin } from '@glightbox/plugin-core'; | ||
import { ApiEvent, GLightboxOptions, SlideConfig } from './types'; | ||
import { EventType } from '@glightbox/utils'; | ||
import type { ApiEvent, GLightboxOptions, SlideConfig } from './types'; | ||
import { Plugin } from '@glightbox/plugin-core'; | ||
export default class GLightbox { | ||
@@ -5,0 +6,0 @@ options: GLightboxOptions; |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=(l,...e)=>{if(!e.length)return l;const t=e.shift();return t===void 0?l:(E(l)&&E(t)&&Object.keys(t).forEach(function(i){E(t[i])?(l[i]||(l[i]={}),C(l[i],t[i])):l[i]=t[i]}),C(l,...e))};function p(l,e){l.classList.add(...e.split(" "))}function v(l,e){l.classList.remove(...e.split(" "))}function w(l,e){return l.classList.contains(e)}function S(l,{element:e,callback:t,preventDefault:i=!0,once:s=!1,useCapture:o=!1},r){let c=[];const n=t.toString().trim().replace(/\s/g,""),d=typeof e=="string";if(!d)c=[e];else if(d){const h=document.querySelectorAll(e);h&&(c=[...h])}const a=function(h){typeof t=="function"&&(i&&h.preventDefault(),t.call(r,this,h)),s&&a.destroy()};return a.destroy=function(){c.forEach(h=>{h==null||h.removeEventListener(l,a,o)})},c.forEach(h=>{h&&h.attachedEvent!==n&&(h.addEventListener(l,a,o),h.attachedEvent=n)}),a}function H(l,e){return new Promise(t=>{l.addEventListener("animationend",()=>{t(!0)}),p(l,e)})}function P(l){return new Promise((e,t)=>{l||t("url must be defined");let i="";typeof l!="string"?i=l.src:i=l;let s;if((i.includes(".css")?"css":"js")=="css"){if(s=document.querySelectorAll('link[href="'+i+'"]'),s&&s.length>0){e(!0);return}const r=document.getElementsByTagName("head")[0],c=r.querySelectorAll('link[rel="stylesheet"]'),n=document.createElement("link");n.rel="stylesheet",n.type="text/css",n.href=i,n.media="all",c?r.insertBefore(n,c[0]):r.appendChild(n),e(!0);return}if(s=document.querySelectorAll('script[src="'+i+'"]'),s&&s.length>0){e(!0);return}const o=document.createElement("script");o.type="text/javascript",o.src=i,typeof l!="string"&&l!=null&&l.module&&(o.type="module"),o.onload=()=>{e(!0)},document.body.appendChild(o)})}function $(l){return!!(l&&l.nodeType&&l.nodeType==1)}const j=l=>l!==null&&typeof l=="object",E=l=>j(l)&&!Array.isArray(l),D={root:null,autoGallery:!0,setClickEvent:!0,dataAttributesPrefix:"",items:[],plugins:[],appearance:{slideEffect:"fade",openEffect:"zoom",moreText:"See more",moreLength:60,lightboxHTML:`<div id="gl-body" class="gl-lightbox gl-container" tabindex="0" role="dialog" aria-hidden="false"> | ||
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=(r,...t)=>{if(!t.length)return r;const e=t.shift();return e===void 0?r:(E(r)&&E(e)&&Object.keys(e).forEach(function(i){E(e[i])?(r[i]||(r[i]={}),C(r[i],e[i])):r[i]=e[i]}),C(r,...t))};function p(r,t){r.classList.add(...t.split(" "))}function v(r,t){r.classList.remove(...t.split(" "))}function w(r,t){return r.classList.contains(t)}function x(r,{element:t,callback:e,preventDefault:i=!0,once:s=!1,useCapture:o=!1},l){let c=[];const n=e.toString().trim().replace(/\s/g,""),h=typeof t=="string";if(!h)c=[t];else if(h){const d=document.querySelectorAll(t);d&&(c=[...d])}const a=function(d){typeof e=="function"&&(i&&d.preventDefault(),e.call(l,this,d)),s&&a.destroy()};return a.destroy=function(){c.forEach(d=>{d==null||d.removeEventListener(r,a,o)})},c.forEach(d=>{d&&d.attachedEvent!==n&&(d.addEventListener(r,a,o),d.attachedEvent=n)}),a}function j(r,t){return new Promise(e=>{r.addEventListener("animationend",()=>{e(!0)}),p(r,t)})}function $(r){return new Promise((t,e)=>{r||e("url must be defined");let i="";typeof r!="string"?i=r.src:i=r;let s;if((i.includes(".css")?"css":"js")=="css"){if(s=document.querySelectorAll('link[href="'+i+'"]'),s&&s.length>0){t(!0);return}const l=document.getElementsByTagName("head")[0],c=l.querySelectorAll('link[rel="stylesheet"]'),n=document.createElement("link");n.rel="stylesheet",n.type="text/css",n.href=i,n.media="all",c?l.insertBefore(n,c[0]):l.appendChild(n),t(!0);return}if(s=document.querySelectorAll('script[src="'+i+'"]'),s&&s.length>0){t(!0);return}const o=document.createElement("script");o.type="text/javascript",o.src=i,typeof r!="string"&&r!=null&&r.module&&(o.type="module"),o.onload=()=>{t(!0)},document.body.appendChild(o)})}function H(r){return!!(r&&r.nodeType&&r.nodeType==1)}const P=r=>r!==null&&typeof r=="object",E=r=>P(r)&&!Array.isArray(r),D={root:null,autoGallery:!0,setClickEvent:!0,dataAttributesPrefix:"",items:[],plugins:[],appearance:{slideEffect:"fade",openEffect:"zoom",moreText:"See more",moreLength:60,lightboxHTML:`<div id="gl-body" class="gl-lightbox gl-container" tabindex="0" role="dialog" aria-hidden="false"> | ||
<div id="gl-slider" class="gl-slider"></div> | ||
@@ -7,3 +7,3 @@ <button class="gl-close gl-btn" aria-label="Close" tabindex="3" aria-hidden="false" data-glightbox-close-svg></button> | ||
<div class="gl-overlay"></div> | ||
</div>`,slideHTML:"",svg:{close:'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 512 512" xml:space="preserve"><g><g><path d="M505.943,6.058c-8.077-8.077-21.172-8.077-29.249,0L6.058,476.693c-8.077,8.077-8.077,21.172,0,29.249C10.096,509.982,15.39,512,20.683,512c5.293,0,10.586-2.019,14.625-6.059L505.943,35.306C514.019,27.23,514.019,14.135,505.943,6.058z"/></g></g><g><g><path d="M505.942,476.694L35.306,6.059c-8.076-8.077-21.172-8.077-29.248,0c-8.077,8.076-8.077,21.171,0,29.248l470.636,470.636c4.038,4.039,9.332,6.058,14.625,6.058c5.293,0,10.587-2.019,14.624-6.057C514.018,497.866,514.018,484.771,505.942,476.694z"/></g></g></svg>',next:'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 477.175 477.175" xml:space="preserve"> <g><path d="M360.731,229.075l-225.1-225.1c-5.3-5.3-13.8-5.3-19.1,0s-5.3,13.8,0,19.1l215.5,215.5l-215.5,215.5c-5.3,5.3-5.3,13.8,0,19.1c2.6,2.6,6.1,4,9.5,4c3.4,0,6.9-1.3,9.5-4l225.1-225.1C365.931,242.875,365.931,234.275,360.731,229.075z"/></g></svg>',prev:'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 477.175 477.175" xml:space="preserve"><g><path d="M145.188,238.575l215.5-215.5c5.3-5.3,5.3-13.8,0-19.1s-13.8-5.3-19.1,0l-225.1,225.1c-5.3,5.3-5.3,13.8,0,19.1l225.1,225c2.6,2.6,6.1,4,9.5,4s6.9-1.3,9.5-4c5.3-5.3,5.3-13.8,0-19.1L145.188,238.575z"/></g></svg>',loader:'<svg aria-hidden="true" class="w-8 h-8 mr-2 text-gray-200 animate-spin dark:text-gray-600 fill-blue-600" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/><path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/></svg>'}},startAt:0,customDataAttributes:[],preload:!0,loop:!0,closeOnOutsideClick:!0};class z{constructor(e={}){var i;this.apiEvents=new Set,this.events=new Map,this.state=new Map,this.plugins=new Map,this.items=new Set,this.modal=null,this.prevButton=null,this.nextButton=null,this.overlay=null,this.slidesContainer=null,this.options=C(D,e);const t=window.matchMedia("(prefers-reduced-motion: reduce)");(!t||t.matches)&&((i=this.options.appearance)!=null&&i.slideEffect)&&(this.options.appearance.slideEffect=!1,this.options.appearance.openEffect=!1),this.init()}init(e=!0){if(e)for(const t of this.options.plugins)this.registerPlugin(t);this.options.setClickEvent&&this.events.set("gallery",S("click",{element:"*[data-glightbox]",callback:t=>{this.open(t)}}))}open(e){var i;if(this.state.get("open"))return;if(!this.plugins.has("slide"))throw new Error("No slide types registered");this.items.size===0&&$(e)&&this.setItemsFromNode(e);let t=this.options.startAt;this.options.autoGallery?typeof e=="number"?t=e:$(e)&&(t=this.getElementIndex(e)):t=0,this.state.set("focused",document.activeElement),this.build(),this.trigger("before_open"),this.initPlugins(),this.showSlide(t,!0),this.trigger("open"),this.state.set("open",!0),(i=this.modal)==null||i.focus(),p(document.body,"gl-open")}prevSlide(){this.goToSlide(this.getActiveSlideIndex()-1)}nextSlide(){this.goToSlide(this.getActiveSlideIndex()+1)}goToSlide(e=0){const t=this.getTotalSlides()-1;!this.options.loop&&(e<0||e>this.getTotalSlides()-1)||(e<0?e=t:e>t&&(e=0),this.showSlide(e))}async showSlide(e=0,t=!1){var d,a,h,f;const i=(d=this.slidesContainer)==null?void 0:d.querySelector(".current");i&&v(i,"current");const s=(a=this.slidesContainer)==null?void 0:a.querySelectorAll(".gl-slide")[e],o=s.querySelector(".gl-media");if(!s||!o)return;t||this.trigger("slide_before_change",{current:this.state.get("prevActiveSlideIndex"),next:e}),await this.preloadSlide(e,!t);const r=(h=this.options.appearance)==null?void 0:h.slideEffect,c=(f=this.options.appearance)==null?void 0:f.openEffect,n=r!=="slide"||t?"instant":"smooth";s.scrollIntoView({behavior:n,block:"start",inline:"start"}),v(o,"gl-animation-ended"),t&&c?(p(o,"gl-invisible"),c&&await H(o,`gl-${c}-in`),p(o,"gl-animation-ended"),v(o,`gl-invisible gl-${c}-in`)):v(o,"gl-invisible"),this.setActiveSlideState(s,e),this.trigger("slide_changed",{prev:this.state.get("prevActiveSlideIndex"),current:e}),this.options.preload&&(this.preloadSlide(e+1),this.preloadSlide(e-1))}setActiveSlideState(e,t){this.state.set("prevActiveSlide",this.state.get("activeSlide")??!1),this.state.set("prevActiveSlideIndex",this.getActiveSlideIndex()),this.state.set("activeSlide",e),this.state.set("activeSlideIndex",t),this.updateNavigationButtons()}async preloadSlide(e,t=!0){var n,d;if(e<0||e>this.items.size-1)return!1;const i=(n=this.slidesContainer)==null?void 0:n.querySelectorAll(".gl-slide")[e];if(i&&(w(i,"loaded")||w(i,"preloading")))return!0;const s=this.getSlideData(e),o=s==null?void 0:s.type,r=this.getRegisteredSlideType(o);let c="";if((!o||!r)&&(c=`Unable to handle URL: ${s==null?void 0:s.url}`),c)throw this.setSlideError(i,c),new Error(c);if(s!=null&&s.url&&r&&i&&(r!=null&&r.build)){p(i,"preloading");try{this.trigger("slide_before_load",s),await r.build({index:e,slide:i.querySelector(".gl-media"),config:{...s,isPreload:t}}),(d=i.querySelector(".gl-slide-loader"))==null||d.remove(),this.afterSlideLoaded(i);const a=i.querySelector(".gl-media");return a&&(p(a,`gl-type-${o}`),t&&v(a,"gl-invisible")),i}catch(a){this.afterSlideLoaded(i),this.setSlideError(i,a)}}return!1}build(){var c,n,d,a,h,f,x,b,A,k,L,I,M,T,q,B;if(this.state.get("build"))return;this.trigger("before_build");const e=document.body.querySelectorAll(":scope > *");e&&[...e].forEach(g=>{g.parentNode==document.body&&g.nodeName.charAt(0)!=="#"&&g.hasAttribute&&!g.hasAttribute("aria-hidden")&&(g.ariaHidden="true",g.dataset.glHidden="true")});const t=((c=this.options)==null?void 0:c.root)??document.body,i=((d=(n=this.options)==null?void 0:n.appearance)==null?void 0:d.lightboxHTML)??"";if(t.insertAdjacentHTML("beforeend",i),this.modal=document.getElementById("gl-body"),!this.modal)throw new Error("modal body not found");const s=this.modal.querySelector(".gl-close");if(this.prevButton=this.modal.querySelector(".gl-prev"),this.nextButton=this.modal.querySelector(".gl-next"),this.overlay=this.modal.querySelector(".gl-overlay"),this.slidesContainer=document.getElementById("gl-slider"),p(this.modal,"gl-theme-"+(((h=(a=this.options)==null?void 0:a.appearance)==null?void 0:h.theme)??"base")),p(this.modal,"gl-slide-effect-"+(((x=(f=this.options)==null?void 0:f.appearance)==null?void 0:x.slideEffect)||"none")),(A=(b=this.options)==null?void 0:b.appearance)!=null&&A.cssVariables)for(const[g,u]of Object.entries(this.options.appearance.cssVariables))this.modal.style.setProperty(`--gl-${g}`,u);s&&this.events.set("close",S("click",{element:s,callback:()=>this.close()})),this.nextButton&&this.events.set("next",S("click",{element:this.nextButton,callback:()=>this.nextSlide()})),this.prevButton&&this.events.set("prev",S("click",{element:this.prevButton,callback:()=>this.prevSlide()})),this.options.closeOnOutsideClick&&this.events.set("outClose",S("click",{element:this.modal,callback:(g,u)=>{var m;g&&(u!=null&&u.target)&&!((m=u==null?void 0:u.target)!=null&&m.closest(".gl-media"))&&(u.target.closest(".gl-btn")||this.close())}})),this.processVariables(this.modal);const o=new IntersectionObserver(g=>{g.forEach(u=>{var m;if(v(u.target,"visible"),u.isIntersecting&&this.state.get("open")){const y=parseInt(((m=u.target)==null?void 0:m.getAttribute("data-index"))??"0");p(u.target,"visible"),y!==this.state.get("activeSlideIndex")&&this.setActiveSlideState(u.target,y),!w(u.target,"loaded")&&!w(u.target,"preloading")&&(this.preloadSlide(y),this.preloadSlide(y+1),this.preloadSlide(y-1))}})},{root:this.modal,rootMargin:"0px",threshold:.2});let r=0;for(const g of this.items){const u=this.getRegisteredSlideType(g==null?void 0:g.type);if(g!=null&&g.url&&u){let m=(L=(k=this.options)==null?void 0:k.appearance)==null?void 0:L.slideHTML;const y=(T=(M=(I=this.options)==null?void 0:I.appearance)==null?void 0:M.svg)==null?void 0:T.loader;m||(m=`<div class="gl-slide" data-index="${r}" style="--gl-index: ${r}"> | ||
</div>`,slideHTML:"",svg:{close:'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 512 512" xml:space="preserve"><g><g><path d="M505.943,6.058c-8.077-8.077-21.172-8.077-29.249,0L6.058,476.693c-8.077,8.077-8.077,21.172,0,29.249C10.096,509.982,15.39,512,20.683,512c5.293,0,10.586-2.019,14.625-6.059L505.943,35.306C514.019,27.23,514.019,14.135,505.943,6.058z"/></g></g><g><g><path d="M505.942,476.694L35.306,6.059c-8.076-8.077-21.172-8.077-29.248,0c-8.077,8.076-8.077,21.171,0,29.248l470.636,470.636c4.038,4.039,9.332,6.058,14.625,6.058c5.293,0,10.587-2.019,14.624-6.057C514.018,497.866,514.018,484.771,505.942,476.694z"/></g></g></svg>',next:'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 477.175 477.175" xml:space="preserve"> <g><path d="M360.731,229.075l-225.1-225.1c-5.3-5.3-13.8-5.3-19.1,0s-5.3,13.8,0,19.1l215.5,215.5l-215.5,215.5c-5.3,5.3-5.3,13.8,0,19.1c2.6,2.6,6.1,4,9.5,4c3.4,0,6.9-1.3,9.5-4l225.1-225.1C365.931,242.875,365.931,234.275,360.731,229.075z"/></g></svg>',prev:'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 477.175 477.175" xml:space="preserve"><g><path d="M145.188,238.575l215.5-215.5c5.3-5.3,5.3-13.8,0-19.1s-13.8-5.3-19.1,0l-225.1,225.1c-5.3,5.3-5.3,13.8,0,19.1l225.1,225c2.6,2.6,6.1,4,9.5,4s6.9-1.3,9.5-4c5.3-5.3,5.3-13.8,0-19.1L145.188,238.575z"/></g></svg>',loader:'<svg aria-hidden="true" class="w-8 h-8 mr-2 text-gray-200 animate-spin dark:text-gray-600 fill-blue-600" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/><path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/></svg>'}},startAt:0,customDataAttributes:[],preload:!0,loop:!0,closeOnOutsideClick:!0};class z{constructor(t={}){var i;this.apiEvents=new Set,this.events=new Map,this.state=new Map,this.plugins=new Map,this.items=new Set,this.modal=null,this.prevButton=null,this.nextButton=null,this.overlay=null,this.slidesContainer=null,this.options=C(D,t);const e=window.matchMedia("(prefers-reduced-motion: reduce)");(!e||e.matches)&&((i=this.options.appearance)!=null&&i.slideEffect)&&(this.options.appearance.slideEffect=!1,this.options.appearance.openEffect=!1),this.init()}init(t=!0){if(t)for(const e of this.options.plugins)this.registerPlugin(e);this.options.setClickEvent&&this.events.set("gallery",x("click",{element:"*[data-glightbox]",callback:e=>{this.open(e)}}))}open(t){var i;if(this.state.get("open"))return;if(!this.plugins.has("slide"))throw new Error("No slide types registered");this.items.size===0&&H(t)&&this.setItemsFromNode(t);let e=this.options.startAt;this.options.autoGallery?typeof t=="number"?e=t:H(t)&&(e=this.getElementIndex(t)):e=0,this.state.set("focused",document.activeElement),this.build(),this.trigger("before_open"),this.initPlugins(),this.showSlide(e,!0),this.trigger("open"),this.state.set("open",!0),(i=this.modal)==null||i.focus(),p(document.body,"gl-open")}prevSlide(){this.goToSlide(this.getActiveSlideIndex()-1)}nextSlide(){this.goToSlide(this.getActiveSlideIndex()+1)}goToSlide(t=0){const e=this.getTotalSlides()-1;!this.options.loop&&(t<0||t>this.getTotalSlides()-1)||(t<0?t=e:t>e&&(t=0),this.showSlide(t))}async showSlide(t=0,e=!1){var h,a,d,f;const i=(h=this.slidesContainer)==null?void 0:h.querySelector(".current");i&&v(i,"current");const s=(a=this.slidesContainer)==null?void 0:a.querySelectorAll(".gl-slide")[t],o=s.querySelector(".gl-media");if(!s||!o)return;e||this.trigger("slide_before_change",{current:this.state.get("prevActiveSlideIndex"),next:t}),await this.preloadSlide(t,!e);const l=(d=this.options.appearance)==null?void 0:d.slideEffect,c=(f=this.options.appearance)==null?void 0:f.openEffect,n=l!=="slide"||e?"instant":"smooth";s.scrollIntoView({behavior:n,block:"start",inline:"start"}),v(o,"gl-animation-ended"),e&&c?(p(o,"gl-invisible"),c&&await j(o,`gl-${c}-in`),p(o,"gl-animation-ended"),v(o,`gl-invisible gl-${c}-in`)):v(o,"gl-invisible"),this.setActiveSlideState(s,t),this.trigger("slide_changed",{prev:this.state.get("prevActiveSlideIndex"),current:t}),this.options.preload&&(this.preloadSlide(t+1),this.preloadSlide(t-1))}setActiveSlideState(t,e){this.state.set("prevActiveSlide",this.state.get("activeSlide")??!1),this.state.set("prevActiveSlideIndex",this.getActiveSlideIndex()),this.state.set("activeSlide",t),this.state.set("activeSlideIndex",e),this.updateNavigationButtons()}async preloadSlide(t,e=!0){var n,h;if(t<0||t>this.items.size-1)return!1;const i=(n=this.slidesContainer)==null?void 0:n.querySelectorAll(".gl-slide")[t];if(i&&(w(i,"loaded")||w(i,"preloading")))return!0;const s=this.getSlideData(t),o=s==null?void 0:s.type,l=this.getRegisteredSlideType(o);let c="";if((!o||!l)&&(c=`Unable to handle URL: ${s==null?void 0:s.url}`),c)throw this.setSlideError(i,c),new Error(c);if(s!=null&&s.url&&l&&i&&(l!=null&&l.build)){p(i,"preloading");try{if(l!=null&&l.assets&&typeof(l==null?void 0:l.assets)=="function"){const d=l.assets();if(d){const f=(d==null?void 0:d.css)||[],b=(d==null?void 0:d.js)||[];await this.injectAssets([...f,...b])}}this.trigger("slide_before_load",s),await l.build({index:t,slide:i.querySelector(".gl-media"),config:{...s,isPreload:e}}),(h=i.querySelector(".gl-slide-loader"))==null||h.remove(),this.afterSlideLoaded(i);const a=i.querySelector(".gl-media");return a&&(p(a,`gl-type-${o}`),e&&v(a,"gl-invisible")),i}catch(a){this.afterSlideLoaded(i),this.setSlideError(i,a)}}return!1}build(){var c,n,h,a,d,f,b,S,A,k,L,I,M,q,B,T;if(this.state.get("build"))return;this.trigger("before_build");const t=document.body.querySelectorAll(":scope > *");t&&[...t].forEach(g=>{g.parentNode==document.body&&g.nodeName.charAt(0)!=="#"&&g.hasAttribute&&!g.hasAttribute("aria-hidden")&&(g.ariaHidden="true",g.dataset.glHidden="true")});const e=((c=this.options)==null?void 0:c.root)??document.body,i=((h=(n=this.options)==null?void 0:n.appearance)==null?void 0:h.lightboxHTML)??"";if(e.insertAdjacentHTML("beforeend",i),this.modal=document.getElementById("gl-body"),!this.modal)throw new Error("modal body not found");const s=this.modal.querySelector(".gl-close");if(this.prevButton=this.modal.querySelector(".gl-prev"),this.nextButton=this.modal.querySelector(".gl-next"),this.overlay=this.modal.querySelector(".gl-overlay"),this.slidesContainer=document.getElementById("gl-slider"),p(this.modal,"gl-theme-"+(((d=(a=this.options)==null?void 0:a.appearance)==null?void 0:d.theme)??"base")),p(this.modal,"gl-slide-effect-"+(((b=(f=this.options)==null?void 0:f.appearance)==null?void 0:b.slideEffect)||"none")),(A=(S=this.options)==null?void 0:S.appearance)!=null&&A.cssVariables)for(const[g,u]of Object.entries(this.options.appearance.cssVariables))this.modal.style.setProperty(`--gl-${g}`,u);s&&this.events.set("close",x("click",{element:s,callback:()=>this.close()})),this.nextButton&&this.events.set("next",x("click",{element:this.nextButton,callback:()=>this.nextSlide()})),this.prevButton&&this.events.set("prev",x("click",{element:this.prevButton,callback:()=>this.prevSlide()})),this.options.closeOnOutsideClick&&this.events.set("outClose",x("click",{element:this.modal,callback:(g,u)=>{var m;g&&(u!=null&&u.target)&&!((m=u==null?void 0:u.target)!=null&&m.closest(".gl-media"))&&(u.target.closest(".gl-btn")||this.close())}})),this.processVariables(this.modal);const o=new IntersectionObserver(g=>{g.forEach(u=>{var m;if(v(u.target,"visible"),u.isIntersecting&&this.state.get("open")){const y=parseInt(((m=u.target)==null?void 0:m.getAttribute("data-index"))??"0");p(u.target,"visible"),y!==this.state.get("activeSlideIndex")&&this.setActiveSlideState(u.target,y),!w(u.target,"loaded")&&!w(u.target,"preloading")&&(this.preloadSlide(y),this.preloadSlide(y+1),this.preloadSlide(y-1))}})},{root:this.modal,rootMargin:"0px",threshold:.2});let l=0;for(const g of this.items){const u=this.getRegisteredSlideType(g==null?void 0:g.type);if(g!=null&&g.url&&u){let m=(L=(k=this.options)==null?void 0:k.appearance)==null?void 0:L.slideHTML;const y=(q=(M=(I=this.options)==null?void 0:I.appearance)==null?void 0:M.svg)==null?void 0:q.loader;m||(m=`<div class="gl-slide" data-index="${l}" style="--gl-index: ${l}"> | ||
<div class="gl-slide-loader" role="status"> | ||
@@ -15,2 +15,2 @@ ${y} | ||
</div> | ||
</div>`),(q=this.slidesContainer)==null||q.insertAdjacentHTML("beforeend",m);const N=(B=this.slidesContainer)==null?void 0:B.querySelectorAll(".gl-slide")[r];N&&o.observe(N),r++}}this.overlay&&p(this.overlay,"gl-overlay-in"),this.state.set("build",!0),this.trigger("build")}async close(){var s,o,r,c;if(!this.state.get("open")||!this.modal)return;this.runPluginsMethod("destroy"),v(document.body,"gl-open gl-crollbar-fixer");const e=document.querySelectorAll('*[data-gl-hidden="true"]');if(e&&e.forEach(n=>{n.ariaHidden="false",delete n.dataset.glHidden}),((s=this.options.appearance)==null?void 0:s.slideEffect)==="none")(o=this.modal.parentNode)==null||o.removeChild(this.modal);else{const d=this.state.get("activeSlide").querySelector(".gl-media"),a=(r=this.options.appearance)==null?void 0:r.openEffect;d&&(p(this.modal,"gl-closing"),a&&(v(d,"gl-animation-ended"),await H(d,`gl-${a}-out`))),(c=this.modal.parentNode)==null||c.removeChild(this.modal)}this.state.clear(),this.modal=null,this.prevButton=null,this.nextButton=null,this.clearAllEvents(),this.setItems([]);const t=document.querySelectorAll(".gl-css");t&&t.forEach(n=>{var d;return(d=n==null?void 0:n.parentNode)==null?void 0:d.removeChild(n)}),this.trigger("close");const i=this.state.get("focused");i==null||i.focus()}destroy(){this.close(),this.clearAllEvents(!0)}reload(){this.init(!1)}setItems(e){var i,s;if(!e||(this.items=new Set,!e.length))return;const t=this.plugins.get("slide");if(!t)throw new Error("No slide types registered");for(const o of e){if(o!=null&&o.type){if(!t.has(o.type))throw new Error(`Unknown slide type: ${o.type}`);continue}let r=!1;for(const[c,n]of t){if(n.name==="iframe"){r=n;continue}let d=!1;if(n!=null&&n.match&&n.match(o.url.toLowerCase())&&(o.type=c,d=!0),n!=null&&n.options&&typeof((i=n.options)==null?void 0:i.matchFn)=="function"&&(s=n.options)!=null&&s.matchFn(d,o.url.toLowerCase())&&(o.type=c,d=!0),d)break}o!=null&&o.type||r&&(o.type=r.name),this.getItems().add(o)}}setItemsFromNode(e){if(!this.options.autoGallery){this.setItems([this.parseConfigFromNode(e)]);return}let t="*[data-glightbox]";const i=e.getAttribute("data-glightbox");i&&(t=`*[data-glightbox="${i}"]`);const s=document.querySelectorAll(t);if(!s)return;const o=[];[...s].forEach(r=>{const c=this.parseConfigFromNode(r);o.push(c)}),this.setItems(o)}getSettings(){return this.options}getElementIndex(e){let t=0,i=0;for(const s of this.items){if((s==null?void 0:s.node)===e){t=i;break}i++}return t}getActiveSlide(){if(this.state.has("activeSlide"))return this.state.get("activeSlide")}getActiveSlideIndex(){return this.state.has("activeSlideIndex")?this.state.get("activeSlideIndex"):0}getTotalSlides(){return this.items.size}getItems(){return this.items}updateNavigationButtons(){if(this.items.size===1){this.modal&&p(this.modal,"gl-single-slide");return}if(!this.nextButton||!this.prevButton)return;const e=this.options.loop,t=this.getActiveSlideIndex(),i=this.getTotalSlides()-1;this.prevButton.disabled=!1,this.nextButton.disabled=!1,t===0&&!e?this.prevButton.disabled=!0:t===i&&!e&&(this.nextButton.disabled=!0)}setSlideError(e,t){var s;(s=e.querySelector(".gl-slide-loader"))==null||s.remove();const i=e.querySelector(".gl-media");i&&(p(i,"gl-load-error"),v(i,"gl-invisible"),i.innerHTML=`<div class="gl-error">${t}</div>`)}afterSlideLoaded(e){p(e,"loaded"),v(e,"preloading")}on(e,t,i=!1){if(!e||typeof t!="function")throw new TypeError("Event name and callback must be defined");this.apiEvents.add({evt:e,once:i,callback:t})}once(e,t){this.on(e,t,!0)}trigger(e,t=null){for(const i of this.apiEvents){const{evt:s,once:o,callback:r}=i;s===e&&(r(t),o&&this.apiEvents.delete(i))}}parseConfigFromNode(e){var r,c,n,d;const t={node:null,url:"",title:"",description:"",width:"",height:"",content:"",type:""};let i="";const s={url:"",type:""},o=e.nodeName.toLowerCase();o==="a"&&(i=e.getAttribute("href")||""),o==="img"&&(i=e.getAttribute("src")||""),o==="figure"&&(i=((r=e.querySelector("img"))==null?void 0:r.getAttribute("src"))||""),s.node=e,s.url=i;for(const a in t){let h="data";(c=this.options)!=null&&c.dataAttributesPrefix&&(h+=`-${(n=this.options)==null?void 0:n.dataAttributesPrefix}`);let f=e.getAttribute(`${h}-${a}`);f&&((f==="true"||f==="false")&&(f=f==="true"),s[a]=f)}if(!s.title){const a=e==null?void 0:e.getAttribute("title");a&&(s.title=a)}if(s!=null&&s.description&&s.description.startsWith(".")){const a=(d=document.querySelector(s.description))==null?void 0:d.innerHTML;a&&(s.description=a)}if(!s.description){const a=e.querySelector(".gl-inline-desc");a&&(s.description=a.innerHTML)}return s}getRegisteredSlideType(e){if(this.plugins.has("slide")){const t=this.plugins.get("slide");if(t&&t.has(e))return t.get(e)}return!1}getSlideData(e){return[...this.items][e]}processVariables(e){var i,s,o,r,c,n,d,a,h;const t={"current-slide":"","total-slides":"","close-svg":((o=(s=(i=this.options)==null?void 0:i.appearance)==null?void 0:s.svg)==null?void 0:o.close)??"","next-svg":((n=(c=(r=this.options)==null?void 0:r.appearance)==null?void 0:c.svg)==null?void 0:n.next)??"","prev-svg":((h=(a=(d=this.options)==null?void 0:d.appearance)==null?void 0:a.svg)==null?void 0:h.prev)??""};for(const[f,x]of Object.entries(t)){const b=e.querySelector(`*[data-glightbox-${f}]`);b&&(b.innerHTML=x)}}registerPlugin(e){this.plugins.has(e.type)||this.plugins.set(e.type,new Map);const t=this.plugins.get(e.type);e.instance=this,t==null||t.set(e.name,e)}initPlugins(){this.pluginsRunEach(e=>{if(typeof e.init=="function"&&e.init(),typeof e.cssStyle=="function"){const t=e==null?void 0:e.cssStyle();this.injectCSS(t)}})}runPluginsMethod(e){this.pluginsRunEach(t=>{if(typeof t[e]=="function"){const i=t[e];typeof i=="function"&&(i==null||i.apply(t))}})}pluginsRunEach(e){for(const[t,i]of this.plugins)for(const[s,o]of i)e(o)}injectCSS(e){if(!e)return;const t=document.createElement("style");t.type="text/css",t.className="gl-css",t.innerText=e,document.head.appendChild(t)}async injectAssets(e){typeof e=="string"&&(e=[e]),e.map(async t=>{let i=t;i=t,await P(i)})}clearAllEvents(e=!1){for(const[t,i]of this.events)!e&&t==="gallery"||(i==null||i.destroy(),this.events.delete(t));e&&this.events.clear(),this.apiEvents.clear()}}exports.GLightbox=z; | ||
</div>`),(B=this.slidesContainer)==null||B.insertAdjacentHTML("beforeend",m);const N=(T=this.slidesContainer)==null?void 0:T.querySelectorAll(".gl-slide")[l];N&&o.observe(N),l++}}this.overlay&&p(this.overlay,"gl-overlay-in"),this.state.set("build",!0),this.trigger("build")}async close(){var s,o,l,c;if(!this.state.get("open")||!this.modal)return;this.runPluginsMethod("destroy"),v(document.body,"gl-open gl-crollbar-fixer");const t=document.querySelectorAll('*[data-gl-hidden="true"]');if(t&&t.forEach(n=>{n.ariaHidden="false",delete n.dataset.glHidden}),((s=this.options.appearance)==null?void 0:s.slideEffect)==="none")(o=this.modal.parentNode)==null||o.removeChild(this.modal);else{const h=this.state.get("activeSlide").querySelector(".gl-media"),a=(l=this.options.appearance)==null?void 0:l.openEffect;h&&(p(this.modal,"gl-closing"),a&&(v(h,"gl-animation-ended"),await j(h,`gl-${a}-out`))),(c=this.modal.parentNode)==null||c.removeChild(this.modal)}this.state.clear(),this.modal=null,this.prevButton=null,this.nextButton=null,this.clearAllEvents(),this.setItems([]);const e=document.querySelectorAll(".gl-css");e&&e.forEach(n=>{var h;return(h=n==null?void 0:n.parentNode)==null?void 0:h.removeChild(n)}),this.trigger("close");const i=this.state.get("focused");i==null||i.focus()}destroy(){this.close(),this.clearAllEvents(!0)}reload(){this.init(!1)}setItems(t){var i,s;if(!t||(this.items=new Set,!t.length))return;const e=this.plugins.get("slide");if(!e)throw new Error("No slide types registered");for(const o of t){if(o!=null&&o.type){if(!e.has(o.type))throw new Error(`Unknown slide type: ${o.type}`);continue}let l=!1;for(const[c,n]of e){if(n.name==="iframe"){l=n;continue}let h=!1;if(n!=null&&n.match&&n.match(o.url.toLowerCase())&&(o.type=c,h=!0),n!=null&&n.options&&typeof((i=n.options)==null?void 0:i.matchFn)=="function"&&(s=n.options)!=null&&s.matchFn(h,o.url.toLowerCase())&&(o.type=c,h=!0),h)break}o!=null&&o.type||l&&(o.type=l.name),this.getItems().add(o)}}setItemsFromNode(t){if(!this.options.autoGallery){this.setItems([this.parseConfigFromNode(t)]);return}let e="*[data-glightbox]";const i=t.getAttribute("data-glightbox");i&&(e=`*[data-glightbox="${i}"]`);const s=document.querySelectorAll(e);if(!s)return;const o=[];[...s].forEach(l=>{const c=this.parseConfigFromNode(l);o.push(c)}),this.setItems(o)}getSettings(){return this.options}getElementIndex(t){let e=0,i=0;for(const s of this.items){if((s==null?void 0:s.node)===t){e=i;break}i++}return e}getActiveSlide(){if(this.state.has("activeSlide"))return this.state.get("activeSlide")}getActiveSlideIndex(){return this.state.has("activeSlideIndex")?this.state.get("activeSlideIndex"):0}getTotalSlides(){return this.items.size}getItems(){return this.items}updateNavigationButtons(){if(this.items.size===1){this.modal&&p(this.modal,"gl-single-slide");return}if(!this.nextButton||!this.prevButton)return;const t=this.options.loop,e=this.getActiveSlideIndex(),i=this.getTotalSlides()-1;this.prevButton.disabled=!1,this.nextButton.disabled=!1,e===0&&!t?this.prevButton.disabled=!0:e===i&&!t&&(this.nextButton.disabled=!0)}setSlideError(t,e){var s;(s=t.querySelector(".gl-slide-loader"))==null||s.remove();const i=t.querySelector(".gl-media");i&&(p(i,"gl-load-error"),v(i,"gl-invisible"),i.innerHTML=`<div class="gl-error">${e}</div>`)}afterSlideLoaded(t){p(t,"loaded"),v(t,"preloading")}on(t,e,i=!1){if(!t||typeof e!="function")throw new TypeError("Event name and callback must be defined");this.apiEvents.add({evt:t,once:i,callback:e})}once(t,e){this.on(t,e,!0)}trigger(t,e=null){for(const i of this.apiEvents){const{evt:s,once:o,callback:l}=i;s===t&&(l(e),o&&this.apiEvents.delete(i))}}parseConfigFromNode(t){var l,c,n,h;const e={node:null,url:"",title:"",description:"",width:"",height:"",content:"",type:""};let i="";const s={url:"",type:""},o=t.nodeName.toLowerCase();o==="a"&&(i=t.getAttribute("href")||""),o==="img"&&(i=t.getAttribute("src")||""),o==="figure"&&(i=((l=t.querySelector("img"))==null?void 0:l.getAttribute("src"))||""),s.node=t,s.url=i;for(const a in e){let d="data";(c=this.options)!=null&&c.dataAttributesPrefix&&(d+=`-${(n=this.options)==null?void 0:n.dataAttributesPrefix}`);let f=t.getAttribute(`${d}-${a}`);f&&((f==="true"||f==="false")&&(f=f==="true"),s[a]=f)}if(!s.title){const a=t==null?void 0:t.getAttribute("title");a&&(s.title=a)}if(s!=null&&s.description&&s.description.startsWith(".")){const a=(h=document.querySelector(s.description))==null?void 0:h.innerHTML;a&&(s.description=a)}if(!s.description){const a=t.querySelector(".gl-inline-desc");a&&(s.description=a.innerHTML)}return s}getRegisteredSlideType(t){if(this.plugins.has("slide")){const e=this.plugins.get("slide");if(e&&e.has(t))return e.get(t)}return!1}getSlideData(t){return[...this.items][t]}processVariables(t){var i,s,o,l,c,n,h,a,d;const e={"current-slide":"","total-slides":"","close-svg":((o=(s=(i=this.options)==null?void 0:i.appearance)==null?void 0:s.svg)==null?void 0:o.close)??"","next-svg":((n=(c=(l=this.options)==null?void 0:l.appearance)==null?void 0:c.svg)==null?void 0:n.next)??"","prev-svg":((d=(a=(h=this.options)==null?void 0:h.appearance)==null?void 0:a.svg)==null?void 0:d.prev)??""};for(const[f,b]of Object.entries(e)){const S=t.querySelector(`*[data-glightbox-${f}]`);S&&(S.innerHTML=b)}}registerPlugin(t){this.plugins.has(t.type)||this.plugins.set(t.type,new Map);const e=this.plugins.get(t.type);t.instance=this,e==null||e.set(t.name,t)}initPlugins(){this.pluginsRunEach(t=>{if(typeof t.init=="function"&&t.init(),typeof t.cssStyle=="function"){const e=t==null?void 0:t.cssStyle();this.injectCSS(e)}})}runPluginsMethod(t){this.pluginsRunEach(e=>{if(typeof e[t]=="function"){const i=e[t];typeof i=="function"&&(i==null||i.apply(e))}})}pluginsRunEach(t){for(const[e,i]of this.plugins)for(const[s,o]of i)t(o)}injectCSS(t){if(!t)return;const e=document.createElement("style");e.type="text/css",e.className="gl-css",e.innerText=t,document.head.appendChild(e)}async injectAssets(t){typeof t=="string"&&(t=[t]),t.map(async e=>{let i=e;i=e,await $(i)})}clearAllEvents(t=!1){for(const[e,i]of this.events)!t&&e==="gallery"||(i==null||i.destroy(),this.events.delete(e));t&&this.events.clear(),this.apiEvents.clear()}}exports.GLightbox=z; |
@@ -1,80 +0,80 @@ | ||
const C = (l, ...e) => { | ||
if (!e.length) | ||
return l; | ||
const t = e.shift(); | ||
return t === void 0 ? l : (E(l) && E(t) && Object.keys(t).forEach(function(i) { | ||
E(t[i]) ? (l[i] || (l[i] = {}), C(l[i], t[i])) : l[i] = t[i]; | ||
}), C(l, ...e)); | ||
const C = (r, ...t) => { | ||
if (!t.length) | ||
return r; | ||
const e = t.shift(); | ||
return e === void 0 ? r : (E(r) && E(e) && Object.keys(e).forEach(function(i) { | ||
E(e[i]) ? (r[i] || (r[i] = {}), C(r[i], e[i])) : r[i] = e[i]; | ||
}), C(r, ...t)); | ||
}; | ||
function p(l, e) { | ||
l.classList.add(...e.split(" ")); | ||
function p(r, t) { | ||
r.classList.add(...t.split(" ")); | ||
} | ||
function v(l, e) { | ||
l.classList.remove(...e.split(" ")); | ||
function v(r, t) { | ||
r.classList.remove(...t.split(" ")); | ||
} | ||
function w(l, e) { | ||
return l.classList.contains(e); | ||
function w(r, t) { | ||
return r.classList.contains(t); | ||
} | ||
function S(l, { | ||
element: e, | ||
callback: t, | ||
function x(r, { | ||
element: t, | ||
callback: e, | ||
preventDefault: i = !0, | ||
once: s = !1, | ||
useCapture: o = !1 | ||
}, r) { | ||
}, l) { | ||
let c = []; | ||
const n = t.toString().trim().replace(/\s/g, ""), d = typeof e == "string"; | ||
if (!d) | ||
c = [e]; | ||
else if (d) { | ||
const h = document.querySelectorAll(e); | ||
h && (c = [...h]); | ||
const n = e.toString().trim().replace(/\s/g, ""), h = typeof t == "string"; | ||
if (!h) | ||
c = [t]; | ||
else if (h) { | ||
const d = document.querySelectorAll(t); | ||
d && (c = [...d]); | ||
} | ||
const a = function(h) { | ||
typeof t == "function" && (i && h.preventDefault(), t.call(r, this, h)), s && a.destroy(); | ||
const a = function(d) { | ||
typeof e == "function" && (i && d.preventDefault(), e.call(l, this, d)), s && a.destroy(); | ||
}; | ||
return a.destroy = function() { | ||
c.forEach((h) => { | ||
h == null || h.removeEventListener(l, a, o); | ||
c.forEach((d) => { | ||
d == null || d.removeEventListener(r, a, o); | ||
}); | ||
}, c.forEach((h) => { | ||
h && h.attachedEvent !== n && (h.addEventListener(l, a, o), h.attachedEvent = n); | ||
}, c.forEach((d) => { | ||
d && d.attachedEvent !== n && (d.addEventListener(r, a, o), d.attachedEvent = n); | ||
}), a; | ||
} | ||
function H(l, e) { | ||
return new Promise((t) => { | ||
l.addEventListener("animationend", () => { | ||
t(!0); | ||
}), p(l, e); | ||
function H(r, t) { | ||
return new Promise((e) => { | ||
r.addEventListener("animationend", () => { | ||
e(!0); | ||
}), p(r, t); | ||
}); | ||
} | ||
function P(l) { | ||
return new Promise((e, t) => { | ||
l || t("url must be defined"); | ||
function j(r) { | ||
return new Promise((t, e) => { | ||
r || e("url must be defined"); | ||
let i = ""; | ||
typeof l != "string" ? i = l.src : i = l; | ||
typeof r != "string" ? i = r.src : i = r; | ||
let s; | ||
if ((i.includes(".css") ? "css" : "js") == "css") { | ||
if (s = document.querySelectorAll('link[href="' + i + '"]'), s && s.length > 0) { | ||
e(!0); | ||
t(!0); | ||
return; | ||
} | ||
const r = document.getElementsByTagName("head")[0], c = r.querySelectorAll('link[rel="stylesheet"]'), n = document.createElement("link"); | ||
n.rel = "stylesheet", n.type = "text/css", n.href = i, n.media = "all", c ? r.insertBefore(n, c[0]) : r.appendChild(n), e(!0); | ||
const l = document.getElementsByTagName("head")[0], c = l.querySelectorAll('link[rel="stylesheet"]'), n = document.createElement("link"); | ||
n.rel = "stylesheet", n.type = "text/css", n.href = i, n.media = "all", c ? l.insertBefore(n, c[0]) : l.appendChild(n), t(!0); | ||
return; | ||
} | ||
if (s = document.querySelectorAll('script[src="' + i + '"]'), s && s.length > 0) { | ||
e(!0); | ||
t(!0); | ||
return; | ||
} | ||
const o = document.createElement("script"); | ||
o.type = "text/javascript", o.src = i, typeof l != "string" && l != null && l.module && (o.type = "module"), o.onload = () => { | ||
e(!0); | ||
o.type = "text/javascript", o.src = i, typeof r != "string" && r != null && r.module && (o.type = "module"), o.onload = () => { | ||
t(!0); | ||
}, document.body.appendChild(o); | ||
}); | ||
} | ||
function $(l) { | ||
return !!(l && l.nodeType && l.nodeType == 1); | ||
function $(r) { | ||
return !!(r && r.nodeType && r.nodeType == 1); | ||
} | ||
const j = (l) => l !== null && typeof l == "object", E = (l) => j(l) && !Array.isArray(l), D = { | ||
const P = (r) => r !== null && typeof r == "object", E = (r) => P(r) && !Array.isArray(r), D = { | ||
root: null, | ||
@@ -113,20 +113,20 @@ autoGallery: !0, | ||
class z { | ||
constructor(e = {}) { | ||
constructor(t = {}) { | ||
var i; | ||
this.apiEvents = /* @__PURE__ */ new Set(), this.events = /* @__PURE__ */ new Map(), this.state = /* @__PURE__ */ new Map(), this.plugins = /* @__PURE__ */ new Map(), this.items = /* @__PURE__ */ new Set(), this.modal = null, this.prevButton = null, this.nextButton = null, this.overlay = null, this.slidesContainer = null, this.options = C(D, e); | ||
const t = window.matchMedia("(prefers-reduced-motion: reduce)"); | ||
(!t || t.matches) && ((i = this.options.appearance) != null && i.slideEffect) && (this.options.appearance.slideEffect = !1, this.options.appearance.openEffect = !1), this.init(); | ||
this.apiEvents = /* @__PURE__ */ new Set(), this.events = /* @__PURE__ */ new Map(), this.state = /* @__PURE__ */ new Map(), this.plugins = /* @__PURE__ */ new Map(), this.items = /* @__PURE__ */ new Set(), this.modal = null, this.prevButton = null, this.nextButton = null, this.overlay = null, this.slidesContainer = null, this.options = C(D, t); | ||
const e = window.matchMedia("(prefers-reduced-motion: reduce)"); | ||
(!e || e.matches) && ((i = this.options.appearance) != null && i.slideEffect) && (this.options.appearance.slideEffect = !1, this.options.appearance.openEffect = !1), this.init(); | ||
} | ||
init(e = !0) { | ||
if (e) | ||
for (const t of this.options.plugins) | ||
this.registerPlugin(t); | ||
this.options.setClickEvent && this.events.set("gallery", S("click", { | ||
init(t = !0) { | ||
if (t) | ||
for (const e of this.options.plugins) | ||
this.registerPlugin(e); | ||
this.options.setClickEvent && this.events.set("gallery", x("click", { | ||
element: "*[data-glightbox]", | ||
callback: (t) => { | ||
this.open(t); | ||
callback: (e) => { | ||
this.open(e); | ||
} | ||
})); | ||
} | ||
open(e) { | ||
open(t) { | ||
var i; | ||
@@ -137,5 +137,5 @@ if (this.state.get("open")) | ||
throw new Error("No slide types registered"); | ||
this.items.size === 0 && $(e) && this.setItemsFromNode(e); | ||
let t = this.options.startAt; | ||
this.options.autoGallery ? typeof e == "number" ? t = e : $(e) && (t = this.getElementIndex(e)) : t = 0, this.state.set("focused", document.activeElement), this.build(), this.trigger("before_open"), this.initPlugins(), this.showSlide(t, !0), this.trigger("open"), this.state.set("open", !0), (i = this.modal) == null || i.focus(), p(document.body, "gl-open"); | ||
this.items.size === 0 && $(t) && this.setItemsFromNode(t); | ||
let e = this.options.startAt; | ||
this.options.autoGallery ? typeof t == "number" ? e = t : $(t) && (e = this.getElementIndex(t)) : e = 0, this.state.set("focused", document.activeElement), this.build(), this.trigger("before_open"), this.initPlugins(), this.showSlide(e, !0), this.trigger("open"), this.state.set("open", !0), (i = this.modal) == null || i.focus(), p(document.body, "gl-open"); | ||
} | ||
@@ -148,41 +148,48 @@ prevSlide() { | ||
} | ||
goToSlide(e = 0) { | ||
const t = this.getTotalSlides() - 1; | ||
!this.options.loop && (e < 0 || e > this.getTotalSlides() - 1) || (e < 0 ? e = t : e > t && (e = 0), this.showSlide(e)); | ||
goToSlide(t = 0) { | ||
const e = this.getTotalSlides() - 1; | ||
!this.options.loop && (t < 0 || t > this.getTotalSlides() - 1) || (t < 0 ? t = e : t > e && (t = 0), this.showSlide(t)); | ||
} | ||
async showSlide(e = 0, t = !1) { | ||
var d, a, h, f; | ||
const i = (d = this.slidesContainer) == null ? void 0 : d.querySelector(".current"); | ||
async showSlide(t = 0, e = !1) { | ||
var h, a, d, f; | ||
const i = (h = this.slidesContainer) == null ? void 0 : h.querySelector(".current"); | ||
i && v(i, "current"); | ||
const s = (a = this.slidesContainer) == null ? void 0 : a.querySelectorAll(".gl-slide")[e], o = s.querySelector(".gl-media"); | ||
const s = (a = this.slidesContainer) == null ? void 0 : a.querySelectorAll(".gl-slide")[t], o = s.querySelector(".gl-media"); | ||
if (!s || !o) | ||
return; | ||
t || this.trigger("slide_before_change", { current: this.state.get("prevActiveSlideIndex"), next: e }), await this.preloadSlide(e, !t); | ||
const r = (h = this.options.appearance) == null ? void 0 : h.slideEffect, c = (f = this.options.appearance) == null ? void 0 : f.openEffect, n = r !== "slide" || t ? "instant" : "smooth"; | ||
s.scrollIntoView({ behavior: n, block: "start", inline: "start" }), v(o, "gl-animation-ended"), t && c ? (p(o, "gl-invisible"), c && await H(o, `gl-${c}-in`), p(o, "gl-animation-ended"), v(o, `gl-invisible gl-${c}-in`)) : v(o, "gl-invisible"), this.setActiveSlideState(s, e), this.trigger("slide_changed", { prev: this.state.get("prevActiveSlideIndex"), current: e }), this.options.preload && (this.preloadSlide(e + 1), this.preloadSlide(e - 1)); | ||
e || this.trigger("slide_before_change", { current: this.state.get("prevActiveSlideIndex"), next: t }), await this.preloadSlide(t, !e); | ||
const l = (d = this.options.appearance) == null ? void 0 : d.slideEffect, c = (f = this.options.appearance) == null ? void 0 : f.openEffect, n = l !== "slide" || e ? "instant" : "smooth"; | ||
s.scrollIntoView({ behavior: n, block: "start", inline: "start" }), v(o, "gl-animation-ended"), e && c ? (p(o, "gl-invisible"), c && await H(o, `gl-${c}-in`), p(o, "gl-animation-ended"), v(o, `gl-invisible gl-${c}-in`)) : v(o, "gl-invisible"), this.setActiveSlideState(s, t), this.trigger("slide_changed", { prev: this.state.get("prevActiveSlideIndex"), current: t }), this.options.preload && (this.preloadSlide(t + 1), this.preloadSlide(t - 1)); | ||
} | ||
setActiveSlideState(e, t) { | ||
this.state.set("prevActiveSlide", this.state.get("activeSlide") ?? !1), this.state.set("prevActiveSlideIndex", this.getActiveSlideIndex()), this.state.set("activeSlide", e), this.state.set("activeSlideIndex", t), this.updateNavigationButtons(); | ||
setActiveSlideState(t, e) { | ||
this.state.set("prevActiveSlide", this.state.get("activeSlide") ?? !1), this.state.set("prevActiveSlideIndex", this.getActiveSlideIndex()), this.state.set("activeSlide", t), this.state.set("activeSlideIndex", e), this.updateNavigationButtons(); | ||
} | ||
async preloadSlide(e, t = !0) { | ||
var n, d; | ||
if (e < 0 || e > this.items.size - 1) | ||
async preloadSlide(t, e = !0) { | ||
var n, h; | ||
if (t < 0 || t > this.items.size - 1) | ||
return !1; | ||
const i = (n = this.slidesContainer) == null ? void 0 : n.querySelectorAll(".gl-slide")[e]; | ||
const i = (n = this.slidesContainer) == null ? void 0 : n.querySelectorAll(".gl-slide")[t]; | ||
if (i && (w(i, "loaded") || w(i, "preloading"))) | ||
return !0; | ||
const s = this.getSlideData(e), o = s == null ? void 0 : s.type, r = this.getRegisteredSlideType(o); | ||
const s = this.getSlideData(t), o = s == null ? void 0 : s.type, l = this.getRegisteredSlideType(o); | ||
let c = ""; | ||
if ((!o || !r) && (c = `Unable to handle URL: ${s == null ? void 0 : s.url}`), c) | ||
if ((!o || !l) && (c = `Unable to handle URL: ${s == null ? void 0 : s.url}`), c) | ||
throw this.setSlideError(i, c), new Error(c); | ||
if (s != null && s.url && r && i && (r != null && r.build)) { | ||
if (s != null && s.url && l && i && (l != null && l.build)) { | ||
p(i, "preloading"); | ||
try { | ||
this.trigger("slide_before_load", s), await r.build({ | ||
index: e, | ||
if (l != null && l.assets && typeof (l == null ? void 0 : l.assets) == "function") { | ||
const d = l.assets(); | ||
if (d) { | ||
const f = (d == null ? void 0 : d.css) || [], b = (d == null ? void 0 : d.js) || []; | ||
await this.injectAssets([...f, ...b]); | ||
} | ||
} | ||
this.trigger("slide_before_load", s), await l.build({ | ||
index: t, | ||
slide: i.querySelector(".gl-media"), | ||
config: { ...s, isPreload: t } | ||
}), (d = i.querySelector(".gl-slide-loader")) == null || d.remove(), this.afterSlideLoaded(i); | ||
config: { ...s, isPreload: e } | ||
}), (h = i.querySelector(".gl-slide-loader")) == null || h.remove(), this.afterSlideLoaded(i); | ||
const a = i.querySelector(".gl-media"); | ||
return a && (p(a, `gl-type-${o}`), t && v(a, "gl-invisible")), i; | ||
return a && (p(a, `gl-type-${o}`), e && v(a, "gl-invisible")), i; | ||
} catch (a) { | ||
@@ -195,27 +202,27 @@ this.afterSlideLoaded(i), this.setSlideError(i, a); | ||
build() { | ||
var c, n, d, a, h, f, x, b, A, k, I, L, M, T, q, B; | ||
var c, n, h, a, d, f, b, S, A, k, I, L, M, q, B, T; | ||
if (this.state.get("build")) | ||
return; | ||
this.trigger("before_build"); | ||
const e = document.body.querySelectorAll(":scope > *"); | ||
e && [...e].forEach((g) => { | ||
const t = document.body.querySelectorAll(":scope > *"); | ||
t && [...t].forEach((g) => { | ||
g.parentNode == document.body && g.nodeName.charAt(0) !== "#" && g.hasAttribute && !g.hasAttribute("aria-hidden") && (g.ariaHidden = "true", g.dataset.glHidden = "true"); | ||
}); | ||
const t = ((c = this.options) == null ? void 0 : c.root) ?? document.body, i = ((d = (n = this.options) == null ? void 0 : n.appearance) == null ? void 0 : d.lightboxHTML) ?? ""; | ||
if (t.insertAdjacentHTML("beforeend", i), this.modal = document.getElementById("gl-body"), !this.modal) | ||
const e = ((c = this.options) == null ? void 0 : c.root) ?? document.body, i = ((h = (n = this.options) == null ? void 0 : n.appearance) == null ? void 0 : h.lightboxHTML) ?? ""; | ||
if (e.insertAdjacentHTML("beforeend", i), this.modal = document.getElementById("gl-body"), !this.modal) | ||
throw new Error("modal body not found"); | ||
const s = this.modal.querySelector(".gl-close"); | ||
if (this.prevButton = this.modal.querySelector(".gl-prev"), this.nextButton = this.modal.querySelector(".gl-next"), this.overlay = this.modal.querySelector(".gl-overlay"), this.slidesContainer = document.getElementById("gl-slider"), p(this.modal, "gl-theme-" + (((h = (a = this.options) == null ? void 0 : a.appearance) == null ? void 0 : h.theme) ?? "base")), p(this.modal, "gl-slide-effect-" + (((x = (f = this.options) == null ? void 0 : f.appearance) == null ? void 0 : x.slideEffect) || "none")), (A = (b = this.options) == null ? void 0 : b.appearance) != null && A.cssVariables) | ||
if (this.prevButton = this.modal.querySelector(".gl-prev"), this.nextButton = this.modal.querySelector(".gl-next"), this.overlay = this.modal.querySelector(".gl-overlay"), this.slidesContainer = document.getElementById("gl-slider"), p(this.modal, "gl-theme-" + (((d = (a = this.options) == null ? void 0 : a.appearance) == null ? void 0 : d.theme) ?? "base")), p(this.modal, "gl-slide-effect-" + (((b = (f = this.options) == null ? void 0 : f.appearance) == null ? void 0 : b.slideEffect) || "none")), (A = (S = this.options) == null ? void 0 : S.appearance) != null && A.cssVariables) | ||
for (const [g, u] of Object.entries(this.options.appearance.cssVariables)) | ||
this.modal.style.setProperty(`--gl-${g}`, u); | ||
s && this.events.set("close", S("click", { | ||
s && this.events.set("close", x("click", { | ||
element: s, | ||
callback: () => this.close() | ||
})), this.nextButton && this.events.set("next", S("click", { | ||
})), this.nextButton && this.events.set("next", x("click", { | ||
element: this.nextButton, | ||
callback: () => this.nextSlide() | ||
})), this.prevButton && this.events.set("prev", S("click", { | ||
})), this.prevButton && this.events.set("prev", x("click", { | ||
element: this.prevButton, | ||
callback: () => this.prevSlide() | ||
})), this.options.closeOnOutsideClick && this.events.set("outClose", S("click", { | ||
})), this.options.closeOnOutsideClick && this.events.set("outClose", x("click", { | ||
element: this.modal, | ||
@@ -240,3 +247,3 @@ callback: (g, u) => { | ||
}); | ||
let r = 0; | ||
let l = 0; | ||
for (const g of this.items) { | ||
@@ -246,4 +253,4 @@ const u = this.getRegisteredSlideType(g == null ? void 0 : g.type); | ||
let m = (I = (k = this.options) == null ? void 0 : k.appearance) == null ? void 0 : I.slideHTML; | ||
const y = (T = (M = (L = this.options) == null ? void 0 : L.appearance) == null ? void 0 : M.svg) == null ? void 0 : T.loader; | ||
m || (m = `<div class="gl-slide" data-index="${r}" style="--gl-index: ${r}"> | ||
const y = (q = (M = (L = this.options) == null ? void 0 : L.appearance) == null ? void 0 : M.svg) == null ? void 0 : q.loader; | ||
m || (m = `<div class="gl-slide" data-index="${l}" style="--gl-index: ${l}"> | ||
<div class="gl-slide-loader" role="status"> | ||
@@ -255,5 +262,5 @@ ${y} | ||
</div> | ||
</div>`), (q = this.slidesContainer) == null || q.insertAdjacentHTML("beforeend", m); | ||
const N = (B = this.slidesContainer) == null ? void 0 : B.querySelectorAll(".gl-slide")[r]; | ||
N && o.observe(N), r++; | ||
</div>`), (B = this.slidesContainer) == null || B.insertAdjacentHTML("beforeend", m); | ||
const N = (T = this.slidesContainer) == null ? void 0 : T.querySelectorAll(".gl-slide")[l]; | ||
N && o.observe(N), l++; | ||
} | ||
@@ -264,8 +271,8 @@ } | ||
async close() { | ||
var s, o, r, c; | ||
var s, o, l, c; | ||
if (!this.state.get("open") || !this.modal) | ||
return; | ||
this.runPluginsMethod("destroy"), v(document.body, "gl-open gl-crollbar-fixer"); | ||
const e = document.querySelectorAll('*[data-gl-hidden="true"]'); | ||
if (e && e.forEach((n) => { | ||
const t = document.querySelectorAll('*[data-gl-hidden="true"]'); | ||
if (t && t.forEach((n) => { | ||
n.ariaHidden = "false", delete n.dataset.glHidden; | ||
@@ -275,10 +282,10 @@ }), ((s = this.options.appearance) == null ? void 0 : s.slideEffect) === "none") | ||
else { | ||
const d = this.state.get("activeSlide").querySelector(".gl-media"), a = (r = this.options.appearance) == null ? void 0 : r.openEffect; | ||
d && (p(this.modal, "gl-closing"), a && (v(d, "gl-animation-ended"), await H(d, `gl-${a}-out`))), (c = this.modal.parentNode) == null || c.removeChild(this.modal); | ||
const h = this.state.get("activeSlide").querySelector(".gl-media"), a = (l = this.options.appearance) == null ? void 0 : l.openEffect; | ||
h && (p(this.modal, "gl-closing"), a && (v(h, "gl-animation-ended"), await H(h, `gl-${a}-out`))), (c = this.modal.parentNode) == null || c.removeChild(this.modal); | ||
} | ||
this.state.clear(), this.modal = null, this.prevButton = null, this.nextButton = null, this.clearAllEvents(), this.setItems([]); | ||
const t = document.querySelectorAll(".gl-css"); | ||
t && t.forEach((n) => { | ||
var d; | ||
return (d = n == null ? void 0 : n.parentNode) == null ? void 0 : d.removeChild(n); | ||
const e = document.querySelectorAll(".gl-css"); | ||
e && e.forEach((n) => { | ||
var h; | ||
return (h = n == null ? void 0 : n.parentNode) == null ? void 0 : h.removeChild(n); | ||
}), this.trigger("close"); | ||
@@ -294,42 +301,42 @@ const i = this.state.get("focused"); | ||
} | ||
setItems(e) { | ||
setItems(t) { | ||
var i, s; | ||
if (!e || (this.items = /* @__PURE__ */ new Set(), !e.length)) | ||
if (!t || (this.items = /* @__PURE__ */ new Set(), !t.length)) | ||
return; | ||
const t = this.plugins.get("slide"); | ||
if (!t) | ||
const e = this.plugins.get("slide"); | ||
if (!e) | ||
throw new Error("No slide types registered"); | ||
for (const o of e) { | ||
for (const o of t) { | ||
if (o != null && o.type) { | ||
if (!t.has(o.type)) | ||
if (!e.has(o.type)) | ||
throw new Error(`Unknown slide type: ${o.type}`); | ||
continue; | ||
} | ||
let r = !1; | ||
for (const [c, n] of t) { | ||
let l = !1; | ||
for (const [c, n] of e) { | ||
if (n.name === "iframe") { | ||
r = n; | ||
l = n; | ||
continue; | ||
} | ||
let d = !1; | ||
if (n != null && n.match && n.match(o.url.toLowerCase()) && (o.type = c, d = !0), n != null && n.options && typeof ((i = n.options) == null ? void 0 : i.matchFn) == "function" && (s = n.options) != null && s.matchFn(d, o.url.toLowerCase()) && (o.type = c, d = !0), d) | ||
let h = !1; | ||
if (n != null && n.match && n.match(o.url.toLowerCase()) && (o.type = c, h = !0), n != null && n.options && typeof ((i = n.options) == null ? void 0 : i.matchFn) == "function" && (s = n.options) != null && s.matchFn(h, o.url.toLowerCase()) && (o.type = c, h = !0), h) | ||
break; | ||
} | ||
o != null && o.type || r && (o.type = r.name), this.getItems().add(o); | ||
o != null && o.type || l && (o.type = l.name), this.getItems().add(o); | ||
} | ||
} | ||
setItemsFromNode(e) { | ||
setItemsFromNode(t) { | ||
if (!this.options.autoGallery) { | ||
this.setItems([this.parseConfigFromNode(e)]); | ||
this.setItems([this.parseConfigFromNode(t)]); | ||
return; | ||
} | ||
let t = "*[data-glightbox]"; | ||
const i = e.getAttribute("data-glightbox"); | ||
i && (t = `*[data-glightbox="${i}"]`); | ||
const s = document.querySelectorAll(t); | ||
let e = "*[data-glightbox]"; | ||
const i = t.getAttribute("data-glightbox"); | ||
i && (e = `*[data-glightbox="${i}"]`); | ||
const s = document.querySelectorAll(e); | ||
if (!s) | ||
return; | ||
const o = []; | ||
[...s].forEach((r) => { | ||
const c = this.parseConfigFromNode(r); | ||
[...s].forEach((l) => { | ||
const c = this.parseConfigFromNode(l); | ||
o.push(c); | ||
@@ -341,7 +348,7 @@ }), this.setItems(o); | ||
} | ||
getElementIndex(e) { | ||
let t = 0, i = 0; | ||
getElementIndex(t) { | ||
let e = 0, i = 0; | ||
for (const s of this.items) { | ||
if ((s == null ? void 0 : s.node) === e) { | ||
t = i; | ||
if ((s == null ? void 0 : s.node) === t) { | ||
e = i; | ||
break; | ||
@@ -351,3 +358,3 @@ } | ||
} | ||
return t; | ||
return e; | ||
} | ||
@@ -374,31 +381,31 @@ getActiveSlide() { | ||
return; | ||
const e = this.options.loop, t = this.getActiveSlideIndex(), i = this.getTotalSlides() - 1; | ||
this.prevButton.disabled = !1, this.nextButton.disabled = !1, t === 0 && !e ? this.prevButton.disabled = !0 : t === i && !e && (this.nextButton.disabled = !0); | ||
const t = this.options.loop, e = this.getActiveSlideIndex(), i = this.getTotalSlides() - 1; | ||
this.prevButton.disabled = !1, this.nextButton.disabled = !1, e === 0 && !t ? this.prevButton.disabled = !0 : e === i && !t && (this.nextButton.disabled = !0); | ||
} | ||
setSlideError(e, t) { | ||
setSlideError(t, e) { | ||
var s; | ||
(s = e.querySelector(".gl-slide-loader")) == null || s.remove(); | ||
const i = e.querySelector(".gl-media"); | ||
i && (p(i, "gl-load-error"), v(i, "gl-invisible"), i.innerHTML = `<div class="gl-error">${t}</div>`); | ||
(s = t.querySelector(".gl-slide-loader")) == null || s.remove(); | ||
const i = t.querySelector(".gl-media"); | ||
i && (p(i, "gl-load-error"), v(i, "gl-invisible"), i.innerHTML = `<div class="gl-error">${e}</div>`); | ||
} | ||
afterSlideLoaded(e) { | ||
p(e, "loaded"), v(e, "preloading"); | ||
afterSlideLoaded(t) { | ||
p(t, "loaded"), v(t, "preloading"); | ||
} | ||
on(e, t, i = !1) { | ||
if (!e || typeof t != "function") | ||
on(t, e, i = !1) { | ||
if (!t || typeof e != "function") | ||
throw new TypeError("Event name and callback must be defined"); | ||
this.apiEvents.add({ evt: e, once: i, callback: t }); | ||
this.apiEvents.add({ evt: t, once: i, callback: e }); | ||
} | ||
once(e, t) { | ||
this.on(e, t, !0); | ||
once(t, e) { | ||
this.on(t, e, !0); | ||
} | ||
trigger(e, t = null) { | ||
trigger(t, e = null) { | ||
for (const i of this.apiEvents) { | ||
const { evt: s, once: o, callback: r } = i; | ||
s === e && (r(t), o && this.apiEvents.delete(i)); | ||
const { evt: s, once: o, callback: l } = i; | ||
s === t && (l(e), o && this.apiEvents.delete(i)); | ||
} | ||
} | ||
parseConfigFromNode(e) { | ||
var r, c, n, d; | ||
const t = { | ||
parseConfigFromNode(t) { | ||
var l, c, n, h; | ||
const e = { | ||
node: null, | ||
@@ -414,20 +421,20 @@ url: "", | ||
let i = ""; | ||
const s = { url: "", type: "" }, o = e.nodeName.toLowerCase(); | ||
o === "a" && (i = e.getAttribute("href") || ""), o === "img" && (i = e.getAttribute("src") || ""), o === "figure" && (i = ((r = e.querySelector("img")) == null ? void 0 : r.getAttribute("src")) || ""), s.node = e, s.url = i; | ||
for (const a in t) { | ||
let h = "data"; | ||
(c = this.options) != null && c.dataAttributesPrefix && (h += `-${(n = this.options) == null ? void 0 : n.dataAttributesPrefix}`); | ||
let f = e.getAttribute(`${h}-${a}`); | ||
const s = { url: "", type: "" }, o = t.nodeName.toLowerCase(); | ||
o === "a" && (i = t.getAttribute("href") || ""), o === "img" && (i = t.getAttribute("src") || ""), o === "figure" && (i = ((l = t.querySelector("img")) == null ? void 0 : l.getAttribute("src")) || ""), s.node = t, s.url = i; | ||
for (const a in e) { | ||
let d = "data"; | ||
(c = this.options) != null && c.dataAttributesPrefix && (d += `-${(n = this.options) == null ? void 0 : n.dataAttributesPrefix}`); | ||
let f = t.getAttribute(`${d}-${a}`); | ||
f && ((f === "true" || f === "false") && (f = f === "true"), s[a] = f); | ||
} | ||
if (!s.title) { | ||
const a = e == null ? void 0 : e.getAttribute("title"); | ||
const a = t == null ? void 0 : t.getAttribute("title"); | ||
a && (s.title = a); | ||
} | ||
if (s != null && s.description && s.description.startsWith(".")) { | ||
const a = (d = document.querySelector(s.description)) == null ? void 0 : d.innerHTML; | ||
const a = (h = document.querySelector(s.description)) == null ? void 0 : h.innerHTML; | ||
a && (s.description = a); | ||
} | ||
if (!s.description) { | ||
const a = e.querySelector(".gl-inline-desc"); | ||
const a = t.querySelector(".gl-inline-desc"); | ||
a && (s.description = a.innerHTML); | ||
@@ -437,69 +444,69 @@ } | ||
} | ||
getRegisteredSlideType(e) { | ||
getRegisteredSlideType(t) { | ||
if (this.plugins.has("slide")) { | ||
const t = this.plugins.get("slide"); | ||
if (t && t.has(e)) | ||
return t.get(e); | ||
const e = this.plugins.get("slide"); | ||
if (e && e.has(t)) | ||
return e.get(t); | ||
} | ||
return !1; | ||
} | ||
getSlideData(e) { | ||
return [...this.items][e]; | ||
getSlideData(t) { | ||
return [...this.items][t]; | ||
} | ||
processVariables(e) { | ||
var i, s, o, r, c, n, d, a, h; | ||
const t = { | ||
processVariables(t) { | ||
var i, s, o, l, c, n, h, a, d; | ||
const e = { | ||
"current-slide": "", | ||
"total-slides": "", | ||
"close-svg": ((o = (s = (i = this.options) == null ? void 0 : i.appearance) == null ? void 0 : s.svg) == null ? void 0 : o.close) ?? "", | ||
"next-svg": ((n = (c = (r = this.options) == null ? void 0 : r.appearance) == null ? void 0 : c.svg) == null ? void 0 : n.next) ?? "", | ||
"prev-svg": ((h = (a = (d = this.options) == null ? void 0 : d.appearance) == null ? void 0 : a.svg) == null ? void 0 : h.prev) ?? "" | ||
"next-svg": ((n = (c = (l = this.options) == null ? void 0 : l.appearance) == null ? void 0 : c.svg) == null ? void 0 : n.next) ?? "", | ||
"prev-svg": ((d = (a = (h = this.options) == null ? void 0 : h.appearance) == null ? void 0 : a.svg) == null ? void 0 : d.prev) ?? "" | ||
}; | ||
for (const [f, x] of Object.entries(t)) { | ||
const b = e.querySelector(`*[data-glightbox-${f}]`); | ||
b && (b.innerHTML = x); | ||
for (const [f, b] of Object.entries(e)) { | ||
const S = t.querySelector(`*[data-glightbox-${f}]`); | ||
S && (S.innerHTML = b); | ||
} | ||
} | ||
registerPlugin(e) { | ||
this.plugins.has(e.type) || this.plugins.set(e.type, /* @__PURE__ */ new Map()); | ||
const t = this.plugins.get(e.type); | ||
e.instance = this, t == null || t.set(e.name, e); | ||
registerPlugin(t) { | ||
this.plugins.has(t.type) || this.plugins.set(t.type, /* @__PURE__ */ new Map()); | ||
const e = this.plugins.get(t.type); | ||
t.instance = this, e == null || e.set(t.name, t); | ||
} | ||
initPlugins() { | ||
this.pluginsRunEach((e) => { | ||
if (typeof e.init == "function" && e.init(), typeof e.cssStyle == "function") { | ||
const t = e == null ? void 0 : e.cssStyle(); | ||
this.injectCSS(t); | ||
this.pluginsRunEach((t) => { | ||
if (typeof t.init == "function" && t.init(), typeof t.cssStyle == "function") { | ||
const e = t == null ? void 0 : t.cssStyle(); | ||
this.injectCSS(e); | ||
} | ||
}); | ||
} | ||
runPluginsMethod(e) { | ||
this.pluginsRunEach((t) => { | ||
if (typeof t[e] == "function") { | ||
const i = t[e]; | ||
typeof i == "function" && (i == null || i.apply(t)); | ||
runPluginsMethod(t) { | ||
this.pluginsRunEach((e) => { | ||
if (typeof e[t] == "function") { | ||
const i = e[t]; | ||
typeof i == "function" && (i == null || i.apply(e)); | ||
} | ||
}); | ||
} | ||
pluginsRunEach(e) { | ||
for (const [t, i] of this.plugins) | ||
pluginsRunEach(t) { | ||
for (const [e, i] of this.plugins) | ||
for (const [s, o] of i) | ||
e(o); | ||
t(o); | ||
} | ||
injectCSS(e) { | ||
if (!e) | ||
injectCSS(t) { | ||
if (!t) | ||
return; | ||
const t = document.createElement("style"); | ||
t.type = "text/css", t.className = "gl-css", t.innerText = e, document.head.appendChild(t); | ||
const e = document.createElement("style"); | ||
e.type = "text/css", e.className = "gl-css", e.innerText = t, document.head.appendChild(e); | ||
} | ||
async injectAssets(e) { | ||
typeof e == "string" && (e = [e]), e.map(async (t) => { | ||
let i = t; | ||
i = t, await P(i); | ||
async injectAssets(t) { | ||
typeof t == "string" && (t = [t]), t.map(async (e) => { | ||
let i = e; | ||
i = e, await j(i); | ||
}); | ||
} | ||
clearAllEvents(e = !1) { | ||
for (const [t, i] of this.events) | ||
!e && t === "gallery" || (i == null || i.destroy(), this.events.delete(t)); | ||
e && this.events.clear(), this.apiEvents.clear(); | ||
clearAllEvents(t = !1) { | ||
for (const [e, i] of this.events) | ||
!t && e === "gallery" || (i == null || i.destroy(), this.events.delete(e)); | ||
t && this.events.clear(), this.apiEvents.clear(); | ||
} | ||
@@ -506,0 +513,0 @@ } |
@@ -1,2 +0,2 @@ | ||
(function(S,y){typeof exports=="object"&&typeof module<"u"?y(exports):typeof define=="function"&&define.amd?define(["exports"],y):(S=typeof globalThis<"u"?globalThis:S||self,y(S.GLightBox={}))})(this,function(S){"use strict";const y=(l,...e)=>{if(!e.length)return l;const t=e.shift();return t===void 0?l:(A(l)&&A(t)&&Object.keys(t).forEach(function(i){A(t[i])?(l[i]||(l[i]={}),y(l[i],t[i])):l[i]=t[i]}),y(l,...e))};function f(l,e){l.classList.add(...e.split(" "))}function v(l,e){l.classList.remove(...e.split(" "))}function E(l,e){return l.classList.contains(e)}function x(l,{element:e,callback:t,preventDefault:i=!0,once:s=!1,useCapture:o=!1},r){let d=[];const n=t.toString().trim().replace(/\s/g,""),c=typeof e=="string";if(!c)d=[e];else if(c){const h=document.querySelectorAll(e);h&&(d=[...h])}const a=function(h){typeof t=="function"&&(i&&h.preventDefault(),t.call(r,this,h)),s&&a.destroy()};return a.destroy=function(){d.forEach(h=>{h==null||h.removeEventListener(l,a,o)})},d.forEach(h=>{h&&h.attachedEvent!==n&&(h.addEventListener(l,a,o),h.attachedEvent=n)}),a}function k(l,e){return new Promise(t=>{l.addEventListener("animationend",()=>{t(!0)}),f(l,e)})}function j(l){return new Promise((e,t)=>{l||t("url must be defined");let i="";typeof l!="string"?i=l.src:i=l;let s;if((i.includes(".css")?"css":"js")=="css"){if(s=document.querySelectorAll('link[href="'+i+'"]'),s&&s.length>0){e(!0);return}const r=document.getElementsByTagName("head")[0],d=r.querySelectorAll('link[rel="stylesheet"]'),n=document.createElement("link");n.rel="stylesheet",n.type="text/css",n.href=i,n.media="all",d?r.insertBefore(n,d[0]):r.appendChild(n),e(!0);return}if(s=document.querySelectorAll('script[src="'+i+'"]'),s&&s.length>0){e(!0);return}const o=document.createElement("script");o.type="text/javascript",o.src=i,typeof l!="string"&&l!=null&&l.module&&(o.type="module"),o.onload=()=>{e(!0)},document.body.appendChild(o)})}function L(l){return!!(l&&l.nodeType&&l.nodeType==1)}const D=l=>l!==null&&typeof l=="object",A=l=>D(l)&&!Array.isArray(l),z={root:null,autoGallery:!0,setClickEvent:!0,dataAttributesPrefix:"",items:[],plugins:[],appearance:{slideEffect:"fade",openEffect:"zoom",moreText:"See more",moreLength:60,lightboxHTML:`<div id="gl-body" class="gl-lightbox gl-container" tabindex="0" role="dialog" aria-hidden="false"> | ||
(function(S,y){typeof exports=="object"&&typeof module<"u"?y(exports):typeof define=="function"&&define.amd?define(["exports"],y):(S=typeof globalThis<"u"?globalThis:S||self,y(S.GLightBox={}))})(this,function(S){"use strict";const y=(r,...e)=>{if(!e.length)return r;const t=e.shift();return t===void 0?r:(A(r)&&A(t)&&Object.keys(t).forEach(function(i){A(t[i])?(r[i]||(r[i]={}),y(r[i],t[i])):r[i]=t[i]}),y(r,...e))};function p(r,e){r.classList.add(...e.split(" "))}function v(r,e){r.classList.remove(...e.split(" "))}function C(r,e){return r.classList.contains(e)}function w(r,{element:e,callback:t,preventDefault:i=!0,once:s=!1,useCapture:o=!1},l){let c=[];const n=t.toString().trim().replace(/\s/g,""),h=typeof e=="string";if(!h)c=[e];else if(h){const d=document.querySelectorAll(e);d&&(c=[...d])}const a=function(d){typeof t=="function"&&(i&&d.preventDefault(),t.call(l,this,d)),s&&a.destroy()};return a.destroy=function(){c.forEach(d=>{d==null||d.removeEventListener(r,a,o)})},c.forEach(d=>{d&&d.attachedEvent!==n&&(d.addEventListener(r,a,o),d.attachedEvent=n)}),a}function k(r,e){return new Promise(t=>{r.addEventListener("animationend",()=>{t(!0)}),p(r,e)})}function P(r){return new Promise((e,t)=>{r||t("url must be defined");let i="";typeof r!="string"?i=r.src:i=r;let s;if((i.includes(".css")?"css":"js")=="css"){if(s=document.querySelectorAll('link[href="'+i+'"]'),s&&s.length>0){e(!0);return}const l=document.getElementsByTagName("head")[0],c=l.querySelectorAll('link[rel="stylesheet"]'),n=document.createElement("link");n.rel="stylesheet",n.type="text/css",n.href=i,n.media="all",c?l.insertBefore(n,c[0]):l.appendChild(n),e(!0);return}if(s=document.querySelectorAll('script[src="'+i+'"]'),s&&s.length>0){e(!0);return}const o=document.createElement("script");o.type="text/javascript",o.src=i,typeof r!="string"&&r!=null&&r.module&&(o.type="module"),o.onload=()=>{e(!0)},document.body.appendChild(o)})}function L(r){return!!(r&&r.nodeType&&r.nodeType==1)}const D=r=>r!==null&&typeof r=="object",A=r=>D(r)&&!Array.isArray(r),z={root:null,autoGallery:!0,setClickEvent:!0,dataAttributesPrefix:"",items:[],plugins:[],appearance:{slideEffect:"fade",openEffect:"zoom",moreText:"See more",moreLength:60,lightboxHTML:`<div id="gl-body" class="gl-lightbox gl-container" tabindex="0" role="dialog" aria-hidden="false"> | ||
<div id="gl-slider" class="gl-slider"></div> | ||
@@ -7,3 +7,3 @@ <button class="gl-close gl-btn" aria-label="Close" tabindex="3" aria-hidden="false" data-glightbox-close-svg></button> | ||
<div class="gl-overlay"></div> | ||
</div>`,slideHTML:"",svg:{close:'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 512 512" xml:space="preserve"><g><g><path d="M505.943,6.058c-8.077-8.077-21.172-8.077-29.249,0L6.058,476.693c-8.077,8.077-8.077,21.172,0,29.249C10.096,509.982,15.39,512,20.683,512c5.293,0,10.586-2.019,14.625-6.059L505.943,35.306C514.019,27.23,514.019,14.135,505.943,6.058z"/></g></g><g><g><path d="M505.942,476.694L35.306,6.059c-8.076-8.077-21.172-8.077-29.248,0c-8.077,8.076-8.077,21.171,0,29.248l470.636,470.636c4.038,4.039,9.332,6.058,14.625,6.058c5.293,0,10.587-2.019,14.624-6.057C514.018,497.866,514.018,484.771,505.942,476.694z"/></g></g></svg>',next:'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 477.175 477.175" xml:space="preserve"> <g><path d="M360.731,229.075l-225.1-225.1c-5.3-5.3-13.8-5.3-19.1,0s-5.3,13.8,0,19.1l215.5,215.5l-215.5,215.5c-5.3,5.3-5.3,13.8,0,19.1c2.6,2.6,6.1,4,9.5,4c3.4,0,6.9-1.3,9.5-4l225.1-225.1C365.931,242.875,365.931,234.275,360.731,229.075z"/></g></svg>',prev:'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 477.175 477.175" xml:space="preserve"><g><path d="M145.188,238.575l215.5-215.5c5.3-5.3,5.3-13.8,0-19.1s-13.8-5.3-19.1,0l-225.1,225.1c-5.3,5.3-5.3,13.8,0,19.1l225.1,225c2.6,2.6,6.1,4,9.5,4s6.9-1.3,9.5-4c5.3-5.3,5.3-13.8,0-19.1L145.188,238.575z"/></g></svg>',loader:'<svg aria-hidden="true" class="w-8 h-8 mr-2 text-gray-200 animate-spin dark:text-gray-600 fill-blue-600" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/><path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/></svg>'}},startAt:0,customDataAttributes:[],preload:!0,loop:!0,closeOnOutsideClick:!0};class O{constructor(e={}){var i;this.apiEvents=new Set,this.events=new Map,this.state=new Map,this.plugins=new Map,this.items=new Set,this.modal=null,this.prevButton=null,this.nextButton=null,this.overlay=null,this.slidesContainer=null,this.options=y(z,e);const t=window.matchMedia("(prefers-reduced-motion: reduce)");(!t||t.matches)&&((i=this.options.appearance)!=null&&i.slideEffect)&&(this.options.appearance.slideEffect=!1,this.options.appearance.openEffect=!1),this.init()}init(e=!0){if(e)for(const t of this.options.plugins)this.registerPlugin(t);this.options.setClickEvent&&this.events.set("gallery",x("click",{element:"*[data-glightbox]",callback:t=>{this.open(t)}}))}open(e){var i;if(this.state.get("open"))return;if(!this.plugins.has("slide"))throw new Error("No slide types registered");this.items.size===0&&L(e)&&this.setItemsFromNode(e);let t=this.options.startAt;this.options.autoGallery?typeof e=="number"?t=e:L(e)&&(t=this.getElementIndex(e)):t=0,this.state.set("focused",document.activeElement),this.build(),this.trigger("before_open"),this.initPlugins(),this.showSlide(t,!0),this.trigger("open"),this.state.set("open",!0),(i=this.modal)==null||i.focus(),f(document.body,"gl-open")}prevSlide(){this.goToSlide(this.getActiveSlideIndex()-1)}nextSlide(){this.goToSlide(this.getActiveSlideIndex()+1)}goToSlide(e=0){const t=this.getTotalSlides()-1;!this.options.loop&&(e<0||e>this.getTotalSlides()-1)||(e<0?e=t:e>t&&(e=0),this.showSlide(e))}async showSlide(e=0,t=!1){var c,a,h,p;const i=(c=this.slidesContainer)==null?void 0:c.querySelector(".current");i&&v(i,"current");const s=(a=this.slidesContainer)==null?void 0:a.querySelectorAll(".gl-slide")[e],o=s.querySelector(".gl-media");if(!s||!o)return;t||this.trigger("slide_before_change",{current:this.state.get("prevActiveSlideIndex"),next:e}),await this.preloadSlide(e,!t);const r=(h=this.options.appearance)==null?void 0:h.slideEffect,d=(p=this.options.appearance)==null?void 0:p.openEffect,n=r!=="slide"||t?"instant":"smooth";s.scrollIntoView({behavior:n,block:"start",inline:"start"}),v(o,"gl-animation-ended"),t&&d?(f(o,"gl-invisible"),d&&await k(o,`gl-${d}-in`),f(o,"gl-animation-ended"),v(o,`gl-invisible gl-${d}-in`)):v(o,"gl-invisible"),this.setActiveSlideState(s,e),this.trigger("slide_changed",{prev:this.state.get("prevActiveSlideIndex"),current:e}),this.options.preload&&(this.preloadSlide(e+1),this.preloadSlide(e-1))}setActiveSlideState(e,t){this.state.set("prevActiveSlide",this.state.get("activeSlide")??!1),this.state.set("prevActiveSlideIndex",this.getActiveSlideIndex()),this.state.set("activeSlide",e),this.state.set("activeSlideIndex",t),this.updateNavigationButtons()}async preloadSlide(e,t=!0){var n,c;if(e<0||e>this.items.size-1)return!1;const i=(n=this.slidesContainer)==null?void 0:n.querySelectorAll(".gl-slide")[e];if(i&&(E(i,"loaded")||E(i,"preloading")))return!0;const s=this.getSlideData(e),o=s==null?void 0:s.type,r=this.getRegisteredSlideType(o);let d="";if((!o||!r)&&(d=`Unable to handle URL: ${s==null?void 0:s.url}`),d)throw this.setSlideError(i,d),new Error(d);if(s!=null&&s.url&&r&&i&&(r!=null&&r.build)){f(i,"preloading");try{this.trigger("slide_before_load",s),await r.build({index:e,slide:i.querySelector(".gl-media"),config:{...s,isPreload:t}}),(c=i.querySelector(".gl-slide-loader"))==null||c.remove(),this.afterSlideLoaded(i);const a=i.querySelector(".gl-media");return a&&(f(a,`gl-type-${o}`),t&&v(a,"gl-invisible")),i}catch(a){this.afterSlideLoaded(i),this.setSlideError(i,a)}}return!1}build(){var d,n,c,a,h,p,C,w,I,T,M,B,q,N,H,$;if(this.state.get("build"))return;this.trigger("before_build");const e=document.body.querySelectorAll(":scope > *");e&&[...e].forEach(g=>{g.parentNode==document.body&&g.nodeName.charAt(0)!=="#"&&g.hasAttribute&&!g.hasAttribute("aria-hidden")&&(g.ariaHidden="true",g.dataset.glHidden="true")});const t=((d=this.options)==null?void 0:d.root)??document.body,i=((c=(n=this.options)==null?void 0:n.appearance)==null?void 0:c.lightboxHTML)??"";if(t.insertAdjacentHTML("beforeend",i),this.modal=document.getElementById("gl-body"),!this.modal)throw new Error("modal body not found");const s=this.modal.querySelector(".gl-close");if(this.prevButton=this.modal.querySelector(".gl-prev"),this.nextButton=this.modal.querySelector(".gl-next"),this.overlay=this.modal.querySelector(".gl-overlay"),this.slidesContainer=document.getElementById("gl-slider"),f(this.modal,"gl-theme-"+(((h=(a=this.options)==null?void 0:a.appearance)==null?void 0:h.theme)??"base")),f(this.modal,"gl-slide-effect-"+(((C=(p=this.options)==null?void 0:p.appearance)==null?void 0:C.slideEffect)||"none")),(I=(w=this.options)==null?void 0:w.appearance)!=null&&I.cssVariables)for(const[g,u]of Object.entries(this.options.appearance.cssVariables))this.modal.style.setProperty(`--gl-${g}`,u);s&&this.events.set("close",x("click",{element:s,callback:()=>this.close()})),this.nextButton&&this.events.set("next",x("click",{element:this.nextButton,callback:()=>this.nextSlide()})),this.prevButton&&this.events.set("prev",x("click",{element:this.prevButton,callback:()=>this.prevSlide()})),this.options.closeOnOutsideClick&&this.events.set("outClose",x("click",{element:this.modal,callback:(g,u)=>{var m;g&&(u!=null&&u.target)&&!((m=u==null?void 0:u.target)!=null&&m.closest(".gl-media"))&&(u.target.closest(".gl-btn")||this.close())}})),this.processVariables(this.modal);const o=new IntersectionObserver(g=>{g.forEach(u=>{var m;if(v(u.target,"visible"),u.isIntersecting&&this.state.get("open")){const b=parseInt(((m=u.target)==null?void 0:m.getAttribute("data-index"))??"0");f(u.target,"visible"),b!==this.state.get("activeSlideIndex")&&this.setActiveSlideState(u.target,b),!E(u.target,"loaded")&&!E(u.target,"preloading")&&(this.preloadSlide(b),this.preloadSlide(b+1),this.preloadSlide(b-1))}})},{root:this.modal,rootMargin:"0px",threshold:.2});let r=0;for(const g of this.items){const u=this.getRegisteredSlideType(g==null?void 0:g.type);if(g!=null&&g.url&&u){let m=(M=(T=this.options)==null?void 0:T.appearance)==null?void 0:M.slideHTML;const b=(N=(q=(B=this.options)==null?void 0:B.appearance)==null?void 0:q.svg)==null?void 0:N.loader;m||(m=`<div class="gl-slide" data-index="${r}" style="--gl-index: ${r}"> | ||
</div>`,slideHTML:"",svg:{close:'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 512 512" xml:space="preserve"><g><g><path d="M505.943,6.058c-8.077-8.077-21.172-8.077-29.249,0L6.058,476.693c-8.077,8.077-8.077,21.172,0,29.249C10.096,509.982,15.39,512,20.683,512c5.293,0,10.586-2.019,14.625-6.059L505.943,35.306C514.019,27.23,514.019,14.135,505.943,6.058z"/></g></g><g><g><path d="M505.942,476.694L35.306,6.059c-8.076-8.077-21.172-8.077-29.248,0c-8.077,8.076-8.077,21.171,0,29.248l470.636,470.636c4.038,4.039,9.332,6.058,14.625,6.058c5.293,0,10.587-2.019,14.624-6.057C514.018,497.866,514.018,484.771,505.942,476.694z"/></g></g></svg>',next:'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 477.175 477.175" xml:space="preserve"> <g><path d="M360.731,229.075l-225.1-225.1c-5.3-5.3-13.8-5.3-19.1,0s-5.3,13.8,0,19.1l215.5,215.5l-215.5,215.5c-5.3,5.3-5.3,13.8,0,19.1c2.6,2.6,6.1,4,9.5,4c3.4,0,6.9-1.3,9.5-4l225.1-225.1C365.931,242.875,365.931,234.275,360.731,229.075z"/></g></svg>',prev:'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 477.175 477.175" xml:space="preserve"><g><path d="M145.188,238.575l215.5-215.5c5.3-5.3,5.3-13.8,0-19.1s-13.8-5.3-19.1,0l-225.1,225.1c-5.3,5.3-5.3,13.8,0,19.1l225.1,225c2.6,2.6,6.1,4,9.5,4s6.9-1.3,9.5-4c5.3-5.3,5.3-13.8,0-19.1L145.188,238.575z"/></g></svg>',loader:'<svg aria-hidden="true" class="w-8 h-8 mr-2 text-gray-200 animate-spin dark:text-gray-600 fill-blue-600" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/><path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/></svg>'}},startAt:0,customDataAttributes:[],preload:!0,loop:!0,closeOnOutsideClick:!0};class O{constructor(e={}){var i;this.apiEvents=new Set,this.events=new Map,this.state=new Map,this.plugins=new Map,this.items=new Set,this.modal=null,this.prevButton=null,this.nextButton=null,this.overlay=null,this.slidesContainer=null,this.options=y(z,e);const t=window.matchMedia("(prefers-reduced-motion: reduce)");(!t||t.matches)&&((i=this.options.appearance)!=null&&i.slideEffect)&&(this.options.appearance.slideEffect=!1,this.options.appearance.openEffect=!1),this.init()}init(e=!0){if(e)for(const t of this.options.plugins)this.registerPlugin(t);this.options.setClickEvent&&this.events.set("gallery",w("click",{element:"*[data-glightbox]",callback:t=>{this.open(t)}}))}open(e){var i;if(this.state.get("open"))return;if(!this.plugins.has("slide"))throw new Error("No slide types registered");this.items.size===0&&L(e)&&this.setItemsFromNode(e);let t=this.options.startAt;this.options.autoGallery?typeof e=="number"?t=e:L(e)&&(t=this.getElementIndex(e)):t=0,this.state.set("focused",document.activeElement),this.build(),this.trigger("before_open"),this.initPlugins(),this.showSlide(t,!0),this.trigger("open"),this.state.set("open",!0),(i=this.modal)==null||i.focus(),p(document.body,"gl-open")}prevSlide(){this.goToSlide(this.getActiveSlideIndex()-1)}nextSlide(){this.goToSlide(this.getActiveSlideIndex()+1)}goToSlide(e=0){const t=this.getTotalSlides()-1;!this.options.loop&&(e<0||e>this.getTotalSlides()-1)||(e<0?e=t:e>t&&(e=0),this.showSlide(e))}async showSlide(e=0,t=!1){var h,a,d,u;const i=(h=this.slidesContainer)==null?void 0:h.querySelector(".current");i&&v(i,"current");const s=(a=this.slidesContainer)==null?void 0:a.querySelectorAll(".gl-slide")[e],o=s.querySelector(".gl-media");if(!s||!o)return;t||this.trigger("slide_before_change",{current:this.state.get("prevActiveSlideIndex"),next:e}),await this.preloadSlide(e,!t);const l=(d=this.options.appearance)==null?void 0:d.slideEffect,c=(u=this.options.appearance)==null?void 0:u.openEffect,n=l!=="slide"||t?"instant":"smooth";s.scrollIntoView({behavior:n,block:"start",inline:"start"}),v(o,"gl-animation-ended"),t&&c?(p(o,"gl-invisible"),c&&await k(o,`gl-${c}-in`),p(o,"gl-animation-ended"),v(o,`gl-invisible gl-${c}-in`)):v(o,"gl-invisible"),this.setActiveSlideState(s,e),this.trigger("slide_changed",{prev:this.state.get("prevActiveSlideIndex"),current:e}),this.options.preload&&(this.preloadSlide(e+1),this.preloadSlide(e-1))}setActiveSlideState(e,t){this.state.set("prevActiveSlide",this.state.get("activeSlide")??!1),this.state.set("prevActiveSlideIndex",this.getActiveSlideIndex()),this.state.set("activeSlide",e),this.state.set("activeSlideIndex",t),this.updateNavigationButtons()}async preloadSlide(e,t=!0){var n,h;if(e<0||e>this.items.size-1)return!1;const i=(n=this.slidesContainer)==null?void 0:n.querySelectorAll(".gl-slide")[e];if(i&&(C(i,"loaded")||C(i,"preloading")))return!0;const s=this.getSlideData(e),o=s==null?void 0:s.type,l=this.getRegisteredSlideType(o);let c="";if((!o||!l)&&(c=`Unable to handle URL: ${s==null?void 0:s.url}`),c)throw this.setSlideError(i,c),new Error(c);if(s!=null&&s.url&&l&&i&&(l!=null&&l.build)){p(i,"preloading");try{if(l!=null&&l.assets&&typeof(l==null?void 0:l.assets)=="function"){const d=l.assets();if(d){const u=(d==null?void 0:d.css)||[],x=(d==null?void 0:d.js)||[];await this.injectAssets([...u,...x])}}this.trigger("slide_before_load",s),await l.build({index:e,slide:i.querySelector(".gl-media"),config:{...s,isPreload:t}}),(h=i.querySelector(".gl-slide-loader"))==null||h.remove(),this.afterSlideLoaded(i);const a=i.querySelector(".gl-media");return a&&(p(a,`gl-type-${o}`),t&&v(a,"gl-invisible")),i}catch(a){this.afterSlideLoaded(i),this.setSlideError(i,a)}}return!1}build(){var c,n,h,a,d,u,x,E,I,M,B,q,T,N,j,H;if(this.state.get("build"))return;this.trigger("before_build");const e=document.body.querySelectorAll(":scope > *");e&&[...e].forEach(f=>{f.parentNode==document.body&&f.nodeName.charAt(0)!=="#"&&f.hasAttribute&&!f.hasAttribute("aria-hidden")&&(f.ariaHidden="true",f.dataset.glHidden="true")});const t=((c=this.options)==null?void 0:c.root)??document.body,i=((h=(n=this.options)==null?void 0:n.appearance)==null?void 0:h.lightboxHTML)??"";if(t.insertAdjacentHTML("beforeend",i),this.modal=document.getElementById("gl-body"),!this.modal)throw new Error("modal body not found");const s=this.modal.querySelector(".gl-close");if(this.prevButton=this.modal.querySelector(".gl-prev"),this.nextButton=this.modal.querySelector(".gl-next"),this.overlay=this.modal.querySelector(".gl-overlay"),this.slidesContainer=document.getElementById("gl-slider"),p(this.modal,"gl-theme-"+(((d=(a=this.options)==null?void 0:a.appearance)==null?void 0:d.theme)??"base")),p(this.modal,"gl-slide-effect-"+(((x=(u=this.options)==null?void 0:u.appearance)==null?void 0:x.slideEffect)||"none")),(I=(E=this.options)==null?void 0:E.appearance)!=null&&I.cssVariables)for(const[f,g]of Object.entries(this.options.appearance.cssVariables))this.modal.style.setProperty(`--gl-${f}`,g);s&&this.events.set("close",w("click",{element:s,callback:()=>this.close()})),this.nextButton&&this.events.set("next",w("click",{element:this.nextButton,callback:()=>this.nextSlide()})),this.prevButton&&this.events.set("prev",w("click",{element:this.prevButton,callback:()=>this.prevSlide()})),this.options.closeOnOutsideClick&&this.events.set("outClose",w("click",{element:this.modal,callback:(f,g)=>{var m;f&&(g!=null&&g.target)&&!((m=g==null?void 0:g.target)!=null&&m.closest(".gl-media"))&&(g.target.closest(".gl-btn")||this.close())}})),this.processVariables(this.modal);const o=new IntersectionObserver(f=>{f.forEach(g=>{var m;if(v(g.target,"visible"),g.isIntersecting&&this.state.get("open")){const b=parseInt(((m=g.target)==null?void 0:m.getAttribute("data-index"))??"0");p(g.target,"visible"),b!==this.state.get("activeSlideIndex")&&this.setActiveSlideState(g.target,b),!C(g.target,"loaded")&&!C(g.target,"preloading")&&(this.preloadSlide(b),this.preloadSlide(b+1),this.preloadSlide(b-1))}})},{root:this.modal,rootMargin:"0px",threshold:.2});let l=0;for(const f of this.items){const g=this.getRegisteredSlideType(f==null?void 0:f.type);if(f!=null&&f.url&&g){let m=(B=(M=this.options)==null?void 0:M.appearance)==null?void 0:B.slideHTML;const b=(N=(T=(q=this.options)==null?void 0:q.appearance)==null?void 0:T.svg)==null?void 0:N.loader;m||(m=`<div class="gl-slide" data-index="${l}" style="--gl-index: ${l}"> | ||
<div class="gl-slide-loader" role="status"> | ||
@@ -15,2 +15,2 @@ ${b} | ||
</div> | ||
</div>`),(H=this.slidesContainer)==null||H.insertAdjacentHTML("beforeend",m);const P=($=this.slidesContainer)==null?void 0:$.querySelectorAll(".gl-slide")[r];P&&o.observe(P),r++}}this.overlay&&f(this.overlay,"gl-overlay-in"),this.state.set("build",!0),this.trigger("build")}async close(){var s,o,r,d;if(!this.state.get("open")||!this.modal)return;this.runPluginsMethod("destroy"),v(document.body,"gl-open gl-crollbar-fixer");const e=document.querySelectorAll('*[data-gl-hidden="true"]');if(e&&e.forEach(n=>{n.ariaHidden="false",delete n.dataset.glHidden}),((s=this.options.appearance)==null?void 0:s.slideEffect)==="none")(o=this.modal.parentNode)==null||o.removeChild(this.modal);else{const c=this.state.get("activeSlide").querySelector(".gl-media"),a=(r=this.options.appearance)==null?void 0:r.openEffect;c&&(f(this.modal,"gl-closing"),a&&(v(c,"gl-animation-ended"),await k(c,`gl-${a}-out`))),(d=this.modal.parentNode)==null||d.removeChild(this.modal)}this.state.clear(),this.modal=null,this.prevButton=null,this.nextButton=null,this.clearAllEvents(),this.setItems([]);const t=document.querySelectorAll(".gl-css");t&&t.forEach(n=>{var c;return(c=n==null?void 0:n.parentNode)==null?void 0:c.removeChild(n)}),this.trigger("close");const i=this.state.get("focused");i==null||i.focus()}destroy(){this.close(),this.clearAllEvents(!0)}reload(){this.init(!1)}setItems(e){var i,s;if(!e||(this.items=new Set,!e.length))return;const t=this.plugins.get("slide");if(!t)throw new Error("No slide types registered");for(const o of e){if(o!=null&&o.type){if(!t.has(o.type))throw new Error(`Unknown slide type: ${o.type}`);continue}let r=!1;for(const[d,n]of t){if(n.name==="iframe"){r=n;continue}let c=!1;if(n!=null&&n.match&&n.match(o.url.toLowerCase())&&(o.type=d,c=!0),n!=null&&n.options&&typeof((i=n.options)==null?void 0:i.matchFn)=="function"&&(s=n.options)!=null&&s.matchFn(c,o.url.toLowerCase())&&(o.type=d,c=!0),c)break}o!=null&&o.type||r&&(o.type=r.name),this.getItems().add(o)}}setItemsFromNode(e){if(!this.options.autoGallery){this.setItems([this.parseConfigFromNode(e)]);return}let t="*[data-glightbox]";const i=e.getAttribute("data-glightbox");i&&(t=`*[data-glightbox="${i}"]`);const s=document.querySelectorAll(t);if(!s)return;const o=[];[...s].forEach(r=>{const d=this.parseConfigFromNode(r);o.push(d)}),this.setItems(o)}getSettings(){return this.options}getElementIndex(e){let t=0,i=0;for(const s of this.items){if((s==null?void 0:s.node)===e){t=i;break}i++}return t}getActiveSlide(){if(this.state.has("activeSlide"))return this.state.get("activeSlide")}getActiveSlideIndex(){return this.state.has("activeSlideIndex")?this.state.get("activeSlideIndex"):0}getTotalSlides(){return this.items.size}getItems(){return this.items}updateNavigationButtons(){if(this.items.size===1){this.modal&&f(this.modal,"gl-single-slide");return}if(!this.nextButton||!this.prevButton)return;const e=this.options.loop,t=this.getActiveSlideIndex(),i=this.getTotalSlides()-1;this.prevButton.disabled=!1,this.nextButton.disabled=!1,t===0&&!e?this.prevButton.disabled=!0:t===i&&!e&&(this.nextButton.disabled=!0)}setSlideError(e,t){var s;(s=e.querySelector(".gl-slide-loader"))==null||s.remove();const i=e.querySelector(".gl-media");i&&(f(i,"gl-load-error"),v(i,"gl-invisible"),i.innerHTML=`<div class="gl-error">${t}</div>`)}afterSlideLoaded(e){f(e,"loaded"),v(e,"preloading")}on(e,t,i=!1){if(!e||typeof t!="function")throw new TypeError("Event name and callback must be defined");this.apiEvents.add({evt:e,once:i,callback:t})}once(e,t){this.on(e,t,!0)}trigger(e,t=null){for(const i of this.apiEvents){const{evt:s,once:o,callback:r}=i;s===e&&(r(t),o&&this.apiEvents.delete(i))}}parseConfigFromNode(e){var r,d,n,c;const t={node:null,url:"",title:"",description:"",width:"",height:"",content:"",type:""};let i="";const s={url:"",type:""},o=e.nodeName.toLowerCase();o==="a"&&(i=e.getAttribute("href")||""),o==="img"&&(i=e.getAttribute("src")||""),o==="figure"&&(i=((r=e.querySelector("img"))==null?void 0:r.getAttribute("src"))||""),s.node=e,s.url=i;for(const a in t){let h="data";(d=this.options)!=null&&d.dataAttributesPrefix&&(h+=`-${(n=this.options)==null?void 0:n.dataAttributesPrefix}`);let p=e.getAttribute(`${h}-${a}`);p&&((p==="true"||p==="false")&&(p=p==="true"),s[a]=p)}if(!s.title){const a=e==null?void 0:e.getAttribute("title");a&&(s.title=a)}if(s!=null&&s.description&&s.description.startsWith(".")){const a=(c=document.querySelector(s.description))==null?void 0:c.innerHTML;a&&(s.description=a)}if(!s.description){const a=e.querySelector(".gl-inline-desc");a&&(s.description=a.innerHTML)}return s}getRegisteredSlideType(e){if(this.plugins.has("slide")){const t=this.plugins.get("slide");if(t&&t.has(e))return t.get(e)}return!1}getSlideData(e){return[...this.items][e]}processVariables(e){var i,s,o,r,d,n,c,a,h;const t={"current-slide":"","total-slides":"","close-svg":((o=(s=(i=this.options)==null?void 0:i.appearance)==null?void 0:s.svg)==null?void 0:o.close)??"","next-svg":((n=(d=(r=this.options)==null?void 0:r.appearance)==null?void 0:d.svg)==null?void 0:n.next)??"","prev-svg":((h=(a=(c=this.options)==null?void 0:c.appearance)==null?void 0:a.svg)==null?void 0:h.prev)??""};for(const[p,C]of Object.entries(t)){const w=e.querySelector(`*[data-glightbox-${p}]`);w&&(w.innerHTML=C)}}registerPlugin(e){this.plugins.has(e.type)||this.plugins.set(e.type,new Map);const t=this.plugins.get(e.type);e.instance=this,t==null||t.set(e.name,e)}initPlugins(){this.pluginsRunEach(e=>{if(typeof e.init=="function"&&e.init(),typeof e.cssStyle=="function"){const t=e==null?void 0:e.cssStyle();this.injectCSS(t)}})}runPluginsMethod(e){this.pluginsRunEach(t=>{if(typeof t[e]=="function"){const i=t[e];typeof i=="function"&&(i==null||i.apply(t))}})}pluginsRunEach(e){for(const[t,i]of this.plugins)for(const[s,o]of i)e(o)}injectCSS(e){if(!e)return;const t=document.createElement("style");t.type="text/css",t.className="gl-css",t.innerText=e,document.head.appendChild(t)}async injectAssets(e){typeof e=="string"&&(e=[e]),e.map(async t=>{let i=t;i=t,await j(i)})}clearAllEvents(e=!1){for(const[t,i]of this.events)!e&&t==="gallery"||(i==null||i.destroy(),this.events.delete(t));e&&this.events.clear(),this.apiEvents.clear()}}S.GLightbox=O,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})}); | ||
</div>`),(j=this.slidesContainer)==null||j.insertAdjacentHTML("beforeend",m);const $=(H=this.slidesContainer)==null?void 0:H.querySelectorAll(".gl-slide")[l];$&&o.observe($),l++}}this.overlay&&p(this.overlay,"gl-overlay-in"),this.state.set("build",!0),this.trigger("build")}async close(){var s,o,l,c;if(!this.state.get("open")||!this.modal)return;this.runPluginsMethod("destroy"),v(document.body,"gl-open gl-crollbar-fixer");const e=document.querySelectorAll('*[data-gl-hidden="true"]');if(e&&e.forEach(n=>{n.ariaHidden="false",delete n.dataset.glHidden}),((s=this.options.appearance)==null?void 0:s.slideEffect)==="none")(o=this.modal.parentNode)==null||o.removeChild(this.modal);else{const h=this.state.get("activeSlide").querySelector(".gl-media"),a=(l=this.options.appearance)==null?void 0:l.openEffect;h&&(p(this.modal,"gl-closing"),a&&(v(h,"gl-animation-ended"),await k(h,`gl-${a}-out`))),(c=this.modal.parentNode)==null||c.removeChild(this.modal)}this.state.clear(),this.modal=null,this.prevButton=null,this.nextButton=null,this.clearAllEvents(),this.setItems([]);const t=document.querySelectorAll(".gl-css");t&&t.forEach(n=>{var h;return(h=n==null?void 0:n.parentNode)==null?void 0:h.removeChild(n)}),this.trigger("close");const i=this.state.get("focused");i==null||i.focus()}destroy(){this.close(),this.clearAllEvents(!0)}reload(){this.init(!1)}setItems(e){var i,s;if(!e||(this.items=new Set,!e.length))return;const t=this.plugins.get("slide");if(!t)throw new Error("No slide types registered");for(const o of e){if(o!=null&&o.type){if(!t.has(o.type))throw new Error(`Unknown slide type: ${o.type}`);continue}let l=!1;for(const[c,n]of t){if(n.name==="iframe"){l=n;continue}let h=!1;if(n!=null&&n.match&&n.match(o.url.toLowerCase())&&(o.type=c,h=!0),n!=null&&n.options&&typeof((i=n.options)==null?void 0:i.matchFn)=="function"&&(s=n.options)!=null&&s.matchFn(h,o.url.toLowerCase())&&(o.type=c,h=!0),h)break}o!=null&&o.type||l&&(o.type=l.name),this.getItems().add(o)}}setItemsFromNode(e){if(!this.options.autoGallery){this.setItems([this.parseConfigFromNode(e)]);return}let t="*[data-glightbox]";const i=e.getAttribute("data-glightbox");i&&(t=`*[data-glightbox="${i}"]`);const s=document.querySelectorAll(t);if(!s)return;const o=[];[...s].forEach(l=>{const c=this.parseConfigFromNode(l);o.push(c)}),this.setItems(o)}getSettings(){return this.options}getElementIndex(e){let t=0,i=0;for(const s of this.items){if((s==null?void 0:s.node)===e){t=i;break}i++}return t}getActiveSlide(){if(this.state.has("activeSlide"))return this.state.get("activeSlide")}getActiveSlideIndex(){return this.state.has("activeSlideIndex")?this.state.get("activeSlideIndex"):0}getTotalSlides(){return this.items.size}getItems(){return this.items}updateNavigationButtons(){if(this.items.size===1){this.modal&&p(this.modal,"gl-single-slide");return}if(!this.nextButton||!this.prevButton)return;const e=this.options.loop,t=this.getActiveSlideIndex(),i=this.getTotalSlides()-1;this.prevButton.disabled=!1,this.nextButton.disabled=!1,t===0&&!e?this.prevButton.disabled=!0:t===i&&!e&&(this.nextButton.disabled=!0)}setSlideError(e,t){var s;(s=e.querySelector(".gl-slide-loader"))==null||s.remove();const i=e.querySelector(".gl-media");i&&(p(i,"gl-load-error"),v(i,"gl-invisible"),i.innerHTML=`<div class="gl-error">${t}</div>`)}afterSlideLoaded(e){p(e,"loaded"),v(e,"preloading")}on(e,t,i=!1){if(!e||typeof t!="function")throw new TypeError("Event name and callback must be defined");this.apiEvents.add({evt:e,once:i,callback:t})}once(e,t){this.on(e,t,!0)}trigger(e,t=null){for(const i of this.apiEvents){const{evt:s,once:o,callback:l}=i;s===e&&(l(t),o&&this.apiEvents.delete(i))}}parseConfigFromNode(e){var l,c,n,h;const t={node:null,url:"",title:"",description:"",width:"",height:"",content:"",type:""};let i="";const s={url:"",type:""},o=e.nodeName.toLowerCase();o==="a"&&(i=e.getAttribute("href")||""),o==="img"&&(i=e.getAttribute("src")||""),o==="figure"&&(i=((l=e.querySelector("img"))==null?void 0:l.getAttribute("src"))||""),s.node=e,s.url=i;for(const a in t){let d="data";(c=this.options)!=null&&c.dataAttributesPrefix&&(d+=`-${(n=this.options)==null?void 0:n.dataAttributesPrefix}`);let u=e.getAttribute(`${d}-${a}`);u&&((u==="true"||u==="false")&&(u=u==="true"),s[a]=u)}if(!s.title){const a=e==null?void 0:e.getAttribute("title");a&&(s.title=a)}if(s!=null&&s.description&&s.description.startsWith(".")){const a=(h=document.querySelector(s.description))==null?void 0:h.innerHTML;a&&(s.description=a)}if(!s.description){const a=e.querySelector(".gl-inline-desc");a&&(s.description=a.innerHTML)}return s}getRegisteredSlideType(e){if(this.plugins.has("slide")){const t=this.plugins.get("slide");if(t&&t.has(e))return t.get(e)}return!1}getSlideData(e){return[...this.items][e]}processVariables(e){var i,s,o,l,c,n,h,a,d;const t={"current-slide":"","total-slides":"","close-svg":((o=(s=(i=this.options)==null?void 0:i.appearance)==null?void 0:s.svg)==null?void 0:o.close)??"","next-svg":((n=(c=(l=this.options)==null?void 0:l.appearance)==null?void 0:c.svg)==null?void 0:n.next)??"","prev-svg":((d=(a=(h=this.options)==null?void 0:h.appearance)==null?void 0:a.svg)==null?void 0:d.prev)??""};for(const[u,x]of Object.entries(t)){const E=e.querySelector(`*[data-glightbox-${u}]`);E&&(E.innerHTML=x)}}registerPlugin(e){this.plugins.has(e.type)||this.plugins.set(e.type,new Map);const t=this.plugins.get(e.type);e.instance=this,t==null||t.set(e.name,e)}initPlugins(){this.pluginsRunEach(e=>{if(typeof e.init=="function"&&e.init(),typeof e.cssStyle=="function"){const t=e==null?void 0:e.cssStyle();this.injectCSS(t)}})}runPluginsMethod(e){this.pluginsRunEach(t=>{if(typeof t[e]=="function"){const i=t[e];typeof i=="function"&&(i==null||i.apply(t))}})}pluginsRunEach(e){for(const[t,i]of this.plugins)for(const[s,o]of i)e(o)}injectCSS(e){if(!e)return;const t=document.createElement("style");t.type="text/css",t.className="gl-css",t.innerText=e,document.head.appendChild(t)}async injectAssets(e){typeof e=="string"&&(e=[e]),e.map(async t=>{let i=t;i=t,await P(i)})}clearAllEvents(e=!1){for(const[t,i]of this.events)!e&&t==="gallery"||(i==null||i.destroy(),this.events.delete(t));e&&this.events.clear(),this.apiEvents.clear()}}S.GLightbox=O,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})}); |
@@ -1,2 +0,3 @@ | ||
import type { GLightboxOptions } from './types'; | ||
import { GLightboxOptions } from './types'; | ||
export declare const GLightboxDefaults: GLightboxOptions; |
@@ -1,2 +0,3 @@ | ||
import type { Plugin } from '@glightbox/plugin-core'; | ||
import { Plugin } from '@glightbox/plugin-core'; | ||
export interface AppearaceOptions { | ||
@@ -3,0 +4,0 @@ /** |
{ | ||
"name": "glightbox", | ||
"version": "4.0.0-beta.5", | ||
"version": "4.0.0-beta.6", | ||
"description": "Beautiful Pure Javascript Lightbox", | ||
@@ -55,3 +55,3 @@ "homepage": "https://biati-digital.github.io/glightbox/", | ||
"@glightbox/utils": "1.0.0-beta.1", | ||
"@glightbox/plugin-core": "1.0.0-beta.2" | ||
"@glightbox/plugin-core": "1.0.0-beta.3" | ||
}, | ||
@@ -58,0 +58,0 @@ "devDependencies": { |
@@ -182,3 +182,13 @@ import type { Plugin } from '@glightbox/plugin-core'; | ||
try { | ||
if (slideType?.assets && typeof slideType?.assets === 'function') { | ||
const slideAssets = slideType.assets(); | ||
if (slideAssets) { | ||
const cssAssets = slideAssets?.css || []; | ||
const jsAssets = slideAssets?.js || []; | ||
await this.injectAssets([...cssAssets, ...jsAssets]); | ||
} | ||
} | ||
this.trigger('slide_before_load', slide); | ||
await slideType.build({ | ||
@@ -704,3 +714,2 @@ index: index, | ||
} | ||
// plugin[method as (keyof typeof plugin)]?.apply(plugin); | ||
} | ||
@@ -707,0 +716,0 @@ }); |
115888
2492
+ Added@glightbox/plugin-core@1.0.0-beta.3(transitive)
- Removed@glightbox/plugin-core@1.0.0-beta.2(transitive)