@redot-src/glare 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -51
- package/dist/core/animation.d.ts +12 -1
- package/dist/core/dom.d.ts +17 -3
- package/dist/core/glare.d.ts +2 -2
- package/dist/glare.css +1 -1
- package/dist/glare.esm.js +460 -470
- package/dist/glare.esm.js.map +1 -1
- package/dist/glare.js +4 -17
- package/dist/glare.js.map +1 -1
- package/dist/icons.d.ts +0 -1
- package/dist/index.d.ts +1 -1
- package/dist/templates.d.ts +0 -1
- package/dist/types.d.ts +23 -14
- package/package.json +11 -7
- package/dist/modules/share.d.ts +0 -17
package/dist/glare.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(S,
|
|
1
|
+
(function(S,M){typeof exports=="object"&&typeof module<"u"?module.exports=M():typeof define=="function"&&define.amd?define(M):(S=typeof globalThis<"u"?globalThis:S||self,S.Glare=M())})(this,(function(){"use strict";const S={CLOSE:"Close",NEXT:"Next",PREV:"Previous",ERROR:"The requested content cannot be loaded.<br/>Please try again later.",LOADING:"Loading",LIGHTBOX:"Media lightbox",GO_TO_SLIDE:"Go to slide {{index}}",VIDEO_UNSUPPORTED:"Your browser does not support HTML5 video.",PLAY_START:"Start slideshow",PLAY_STOP:"Pause slideshow",FULL_SCREEN:"Full screen",FULL_SCREEN_EXIT:"Exit full screen",THUMBS:"Thumbnails",DOWNLOAD:"Download",MORE:"More options",ZOOM:"Zoom",ZOOM_OUT:"Zoom out"};function M(e){const t=e.lang??"en";return{...S,...e.i18n?.en,...e.i18n?.[t]}}function g(e,t){return e.replace(/\{\{(\w+)\}\}/g,(s,i)=>t[i]??"")}function vt(e){return Object.entries(e).map(([t,s])=>`${encodeURIComponent(t)}=${encodeURIComponent(String(s))}`).join("&")}function xt(e,t){return e.replace(/\$(\d+)/g,(s,i)=>t[Number(i)]??"")}const wt={youtube:{matcher:/(?:youtube\.com|youtu\.be|youtube-nocookie\.com)\/(?:watch\?(?:.*&)?v=|v\/|u\/\w\/|embed\/|shorts\/)?([\w-]{11})/i,type:"embed",url:"https://www.youtube-nocookie.com/embed/$1",thumb:"https://img.youtube.com/vi/$1/hqdefault.jpg",params:{autoplay:1,rel:0,modestbranding:1,playsinline:1}},vimeo:{matcher:/vimeo\.com\/(?:video\/)?(\d+)/i,type:"embed",url:"https://player.vimeo.com/video/$1",params:{autoplay:1,title:0,byline:0,portrait:0}},gmap:{matcher:/(?:maps\.)?google\.([a-z]{2,3}(?:\.[a-z]{2})?)\/(?:maps\/(?:place\/[^/]+\/)?@([^/]+)|maps\?q=([^&]+)|maps\/search\/([^/?]+))/i,type:"iframe",url:e=>{const[,t,s,i,n]=e;if(s){const[r,a,l]=s.split(","),d=l?Math.floor(parseFloat(l)):14;return`https://maps.google.${t}/maps?ll=${r},${a}&z=${d}&output=embed`}const o=encodeURIComponent(decodeURIComponent(i||n||""));return`https://maps.google.${t}/maps?q=${o}&output=embed`}}};function B(e,t,s){if(typeof e=="function")return e(t,s);if(typeof e=="string")return xt(e,t)}function Et(e,t){for(const s of Object.values(t??{})){const i=e.match(s.matcher);if(!i)continue;let n=B(s.url,i,e)??e;return s.params&&(n+=(n.includes("?")?"&":"?")+vt(s.params)),{src:n,type:s.type??"iframe",thumb:B(s.thumb,i,e)}}return null}const f=e=>`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${e}</svg>`,u={close:f('<path d="M18 6 6 18"/><path d="m6 6 12 12"/>'),next:f('<path d="m9 18 6-6-6-6"/>'),prev:f('<path d="m15 18-6-6 6-6"/>'),zoomIn:f('<circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/><path d="M11 8v6"/><path d="M8 11h6"/>'),zoomOut:f('<circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/><path d="M8 11h6"/>'),download:f('<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/>'),thumbs:f('<rect width="18" height="18" x="3" y="3" rx="2"/><path d="M3 9h18"/><path d="M9 21V9"/>'),play:f('<polygon points="6 3 20 12 6 21 6 3"/>'),pause:f('<rect width="4" height="16" x="6" y="4"/><rect width="4" height="16" x="14" y="4"/>'),fullscreen:f('<path d="M8 3H5a2 2 0 0 0-2 2v3"/><path d="M21 8V5a2 2 0 0 0-2-2h-3"/><path d="M3 16v3a2 2 0 0 0 2 2h3"/><path d="M16 21h3a2 2 0 0 0 2-2v-3"/>'),fullscreenExit:f('<path d="M8 3v3a2 2 0 0 1-2 2H3"/><path d="M21 8h-3a2 2 0 0 1-2-2V3"/><path d="M3 16h3a2 2 0 0 1 2 2v3"/><path d="M16 21v-3a2 2 0 0 1 2-2h3"/>'),more:f('<circle cx="5" cy="12" r="1" fill="currentColor" stroke="none"/><circle cx="12" cy="12" r="1" fill="currentColor" stroke="none"/><circle cx="19" cy="12" r="1" fill="currentColor" stroke="none"/>')},y=(e,t,s,i="")=>`<button type="button" class="glare-button glare-button--${e}" data-glare-${e} title="{{${t}}}" aria-label="{{${t}}}"${i}>${s}</button>`,Tt=`
|
|
2
2
|
<div class="glare-container" role="dialog" aria-modal="true" tabindex="-1">
|
|
3
3
|
<div class="glare-bg"></div>
|
|
4
4
|
<div class="glare-progress" hidden></div>
|
|
@@ -7,24 +7,11 @@
|
|
|
7
7
|
<div class="glare-infobar"><span class="glare-infobar-index"></span></div>
|
|
8
8
|
<div class="glare-toolbar"></div>
|
|
9
9
|
<div class="glare-navigation">
|
|
10
|
-
${
|
|
11
|
-
${
|
|
10
|
+
${y("prev","PREV",u.prev)}
|
|
11
|
+
${y("next","NEXT",u.next)}
|
|
12
12
|
</div>
|
|
13
13
|
<div class="glare-stage"></div>
|
|
14
14
|
<div class="glare-caption"></div>
|
|
15
15
|
</div>
|
|
16
|
-
</div>`,xt={zoom:b("zoom","ZOOM",u.zoomIn),slideshow:b("slideshow","PLAY_START",u.play),thumbs:b("thumbs","THUMBS",u.thumbs,' aria-expanded="false"'),share:b("share","SHARE",u.share),fullscreen:b("fullscreen","FULL_SCREEN",u.fullscreen),more:b("more","MORE",u.more,' aria-expanded="false" aria-haspopup="true"'),close:b("close","CLOSE",u.close),download:`<a class="glare-button glare-button--download" data-glare-download download target="_blank" rel="noopener" title="{{DOWNLOAD}}" aria-label="{{DOWNLOAD}}">${u.download}</a>`,smallBtn:`<button type="button" class="glare-button glare-close-small" data-glare-close title="{{CLOSE}}" aria-label="{{CLOSE}}">${u.close}</button>`},wt='<div class="glare-spinner" role="status" aria-label="{{LOADING}}"></div>',Et='<div class="glare-error"><p>{{ERROR}}</p></div>',Tt='<video class="glare-video" controls playsinline controlsList="nodownload" poster="{{poster}}"><source src="{{src}}" type="{{format}}"/>{{VIDEO_UNSUPPORTED}}</video>',St='<iframe class="glare-iframe"></iframe>',Lt=`
|
|
17
|
-
<div class="glare-share" role="dialog" aria-label="{{SHARE}}">
|
|
18
|
-
<div class="glare-share-head">
|
|
19
|
-
<h4 class="glare-share-title">{{SHARE}}</h4>
|
|
20
|
-
<button type="button" class="glare-button glare-share-close" data-glare-share-close title="{{CLOSE}}" aria-label="{{CLOSE}}">${u.close}</button>
|
|
21
|
-
</div>
|
|
22
|
-
<p><a class="glare-share-link" href="{{url_facebook}}" target="_blank" rel="noopener">Facebook</a></p>
|
|
23
|
-
<p><a class="glare-share-link" href="{{url_twitter}}" target="_blank" rel="noopener">X / Twitter</a></p>
|
|
24
|
-
<p><a class="glare-share-link" href="{{url_pinterest}}" target="_blank" rel="noopener">Pinterest</a></p>
|
|
25
|
-
<div class="glare-share-row">
|
|
26
|
-
<input class="glare-share-input" type="text" value="{{url_direct}}" readonly />
|
|
27
|
-
<button type="button" class="glare-share-copy" data-glare-share-copy>{{COPY}}</button>
|
|
28
|
-
</div>
|
|
29
|
-
</div>`,j={autoStart:!1,axis:"x"},k={autoStart:!1,speed:3e3},W={autoStart:!1},B={closeExisting:!1,loop:!1,keyboard:!0,protect:!1,modal:!1,idleTime:3,hideScrollbar:!0,autoFocus:!0,backFocus:!0,trapFocus:!0,defaultType:"image",parentEl:"body",baseClass:"",slideClass:"",arrows:!0,infobar:!0,toolbar:"auto",smallBtn:"auto",buttons:["zoom","slideshow","thumbs","share","download","fullscreen","close"],animationEffect:"zoom",animationDuration:366,zoomOpacity:!0,transitionEffect:"fade",transitionDuration:366,clickContent:e=>e.type==="image"?"zoom":!1,clickSlide:"close",dblclickContent:!1,dblclickSlide:!1,wheel:"auto",touch:{vertical:!0,momentum:!0},mobile:{idleTime:!1,clickContent:e=>e.type==="image"?"toggleControls":!1,clickSlide:e=>e.type==="image"?"toggleControls":"close",dblclickContent:e=>e.type==="image"?"zoom":!1,dblclickSlide:e=>e.type==="image"?"zoom":!1},image:{preload:!1},video:{tpl:Tt,format:"",autoStart:!0},iframe:{preload:!0,css:{},attr:{allowfullscreen:"true",allow:"autoplay; fullscreen; picture-in-picture"},tpl:St},ajax:{settings:{headers:{"X-Requested-With":"XMLHttpRequest"}}},media:yt,hash:!0,slideshow:k,thumbs:j,fullscreen:W,share:!0,lang:"en",i18n:{en:S},baseTpl:vt,btnTpl:xt,spinnerTpl:wt,errorTpl:Et},Ct=/\.(avif|bmp|gif|jpe?g|png|svg|webp|ico)(\?.*)?$/i,Mt=/\.(mp4|webm|ogg|ogv|mov|m4v)(\?.*)?$/i,$t=/\.pdf(\?.*)?$/i,Ot=/^(#[\w-]+|\.[\w-]+)$/;function At(e,t="image"){return e?Ot.test(e)?"inline":Ct.test(e)?"image":Mt.test(e)?"video":$t.test(e)?"iframe":t:"html"}function It(e){const t=e.match(/\.(\w+)(?:\?|$)/)?.[1]?.toLowerCase();return t?`video/${t==="ogv"?"ogg":t}`:"video/mp4"}function X(e,t,s){const i=typeof e=="string"?{src:e}:{...e};let r=i.src??"",o=i.type,n=i.thumb;const a=r?bt(r,s.media):null;return a&&(r=a.src??r,o??=a.type,n??=a.thumb),o||(o=i.html||i.content?"html":At(r,s.defaultType)),{...i,index:t,src:r,type:o,thumb:n,caption:i.caption??i.title??"",isLoaded:!1,hasError:!1}}const p=(e,t)=>e.getAttribute(t)||void 0;function Dt(e,t){return e.map((s,i)=>{const r=s.querySelector("img"),o=p(s,"data-caption")??p(s,"title")??"";return X({src:p(s,"data-src")??p(s,"href")??"",type:p(s,"data-type"),caption:o,alt:r?.getAttribute("alt")||o,thumb:p(s,"data-thumb")??r?.getAttribute("src")??void 0,width:p(s,"data-width"),height:p(s,"data-height"),ratio:p(s,"data-ratio"),poster:p(s,"data-poster"),downloadSrc:p(s,"data-download-src"),html:p(s,"data-html"),$trigger:s},i,t)})}function kt(e,t){return e.length&&e[0]instanceof HTMLElement?Dt(e,t):e.map((s,i)=>X(s,i,t))}function c(e,t=document){return t.querySelector(e)}function M(e,t=document){return Array.from(t.querySelectorAll(e))}function g(e,t="",s=""){const i=document.createElement(e);return t&&(i.className=t),s&&(i.innerHTML=s),i}function Rt(e){return g("div","",e.trim()).firstElementChild}function $(e){return/[<&]/.test(e)?new DOMParser().parseFromString(e,"text/html").body.textContent?.trim()??"":e.trim()}function _t(e,t=document){return e?typeof e!="string"?e:c(e,t)??c(e):null}function Y(e){return typeof e=="number"?`${e}px`:e}function h(e,t,s,i){return e.addEventListener(t,s,i),()=>e.removeEventListener(t,s,i)}function G(e){requestAnimationFrame(()=>requestAnimationFrame(e))}function Ft(e,t,s){let i=!1;const r=()=>{i||(i=!0,clearTimeout(n),e.removeEventListener("transitionend",o),s())},o=a=>{a.target===e&&r()};e.addEventListener("transitionend",o);const n=setTimeout(r,t+50)}function Ht(){return navigator.maxTouchPoints>0&&window.matchMedia("(pointer: coarse)").matches}function O(){return window.matchMedia("(prefers-reduced-motion: reduce)").matches}function V(){const e=document;return!!(e.fullscreenEnabled??e.webkitFullscreenEnabled)}const K="glare-lock";function Q(e){const t=document.documentElement;if(e){const s=window.innerWidth-t.clientWidth;t.classList.add(K),s>0&&(t.style.marginRight=`${s}px`)}else t.classList.remove(K),t.style.marginRight=""}const T="glare-hidden";function Pt(e,t,s,i){const r=Rt(y(e.baseTpl,t));r.dataset.glareId=String(s),e.baseClass&&r.classList.add(e.baseClass),e.modal&&r.classList.add("glare-is-modal");const o=c(".glare-stage",r);if(!o)throw new Error("baseTpl must contain a .glare-stage element");const n={container:r,bg:c(".glare-bg",r),inner:c(".glare-inner",r),stage:o,caption:c(".glare-caption",r),toolbar:c(".glare-toolbar",r),infobar:c(".glare-infobar",r),navigation:c(".glare-navigation",r)},a=i<2;return n.navigation?.classList.toggle(T,!e.arrows||a),n.infobar?.classList.toggle(T,!e.infobar||a),n.toolbar&&zt(n.toolbar,e,t,a),n}function zt(e,t,s,i){if(t.toolbar===!1){e.classList.add(T);return}const r=g("div","glare-toolbar-menu");r.id=`glare-toolbar-menu-${e.closest(".glare-container")?.dataset.glareId??""}`;for(const o of t.buttons){if(i&&(o==="thumbs"||o==="slideshow")||o==="fullscreen"&&!V()||o==="more"||o==="close")continue;const n=t.btnTpl[o];n&&r.insertAdjacentHTML("beforeend",y(n,s))}if(r.childElementCount){e.appendChild(r);const o=t.btnTpl.more;o&&(e.insertAdjacentHTML("beforeend",y(o,s)),e.querySelector("[data-glare-more]")?.setAttribute("aria-controls",r.id))}if(t.buttons.includes("close")){const o=t.btnTpl.close;o&&e.insertAdjacentHTML("beforeend",y(o,s))}}function Nt(e,t,s){const i=g("div",`glare-slide glare-slide--${t.type}`);s.slideClass&&i.classList.add(s.slideClass);const r=g("div","glare-content");return i.appendChild(r),e.appendChild(i),t.$slide=i,t.$content=r,i}function Zt(e,t){t&&(e.style.transition="none"),e.offsetWidth,e.classList.add("glare-slide--current"),t&&(e.offsetWidth,e.style.transition="")}function qt(e,t,s){for(const i of M(".glare-slide",e))i!==t&&(i.classList.remove("glare-slide--current"),i.classList.add("glare-slide--out"),setTimeout(()=>i.remove(),s))}function Ut(e,t,s){e.insertAdjacentHTML("beforeend",y(t.btnTpl.smallBtn??"",s))}function jt(e,t,s){e.querySelector(":scope > .glare-spinner")||e.insertAdjacentHTML("beforeend",y(t.spinnerTpl,s))}function Wt(e){e.querySelector(":scope > .glare-spinner")?.remove()}function Bt(e,t,s,i){e.hasError=!0,e.error=t,e.$content&&(e.$content.className="glare-content glare-content--error",e.$content.innerHTML=y(s.errorTpl,i))}function J(e,t){return typeof e.toolbar=="boolean"?e.toolbar:t.type==="image"}function Xt(e,t){return typeof e.smallBtn=="boolean"?e.smallBtn:!J(e,t)}function Yt(e,t,s,i,r,o){const{container:n,toolbar:a,infobar:l}=e;ee(n,i.type),a&&Gt(a,t,i),Vt(n,i),l&&Kt(l,i.index,r),e.caption&&Qt(e.caption,o),Jt(n,t,i.index,r),te(n,s,i,r)}function Gt(e,t,s){if(t.toolbar===!1)return;e.classList.remove("glare-toolbar--expanded"),e.querySelector("[data-glare-more]")?.setAttribute("aria-expanded","false");const i=J(t,s);if(e.classList.toggle(T,!i),!i)return;const r=s.type==="image";c("[data-glare-zoom]",e)?.classList.toggle(T,!r)}function Vt(e,t){const s=e.querySelector("[data-glare-download]");if(!s)return;const i=t.downloadSrc||(t.type==="image"?t.src:"");s.classList.toggle(T,!i),i&&(s.href=i)}function Kt(e,t,s){const i=c(".glare-infobar-index",e);i&&(i.textContent=`${t+1} / ${s}`)}function Qt(e,t){e.innerHTML=t,e.classList.toggle(T,!t)}function Jt(e,t,s,i){const r=!t.loop&&s===0,o=!t.loop&&s===i-1;tt(c("[data-glare-prev]",e),r),tt(c("[data-glare-next]",e),o)}function tt(e,t){e&&(e.classList.toggle("glare-is-disabled",t),e.setAttribute("aria-disabled",String(t)))}function te(e,t,s,i){const r=$(s.caption)||s.alt||t.LIGHTBOX,o=i>1?`${r} (${s.index+1} of ${i})`:r;e.setAttribute("aria-label",o);const n=c(".glare-live",e);n&&(n.textContent=o)}function ee(e,t){const s=e.dataset.type;s&&e.classList.remove(`glare-type-${s}`),e.dataset.type=t,e.classList.add(`glare-type-${t}`)}function se(e,t,s,i){e.classList.toggle("glare-can-zoom-out",s),e.classList.toggle("glare-can-zoom-in",!s&&i);const r=c("[data-glare-zoom]",e),o=s?"out":"in";!r||r.dataset.state===o||(r.dataset.state=o,R(r,s,s?t.ZOOM_OUT:t.ZOOM,s?u.zoomOut:u.zoomIn))}function R(e,t,s,i){e.setAttribute("title",s),e.setAttribute("aria-label",s),e.innerHTML=i,e.classList.toggle("glare-is-active",t)}class ie{constructor(t,s,i){this.glare=t,this.container=s,this.offs=[h(document,"fullscreenchange",()=>this.sync()),h(document,"webkitfullscreenchange",()=>this.sync())],i.autoStart&&this.request()}isFullscreen(){const t=document;return!!(t.fullscreenElement??t.webkitFullscreenElement)}request(){const t=this.container;(t.requestFullscreen??t.webkitRequestFullscreen)?.call(t)}exit(){if(!this.isFullscreen())return;const t=document;(t.exitFullscreen??t.webkitExitFullscreen)?.call(document)}toggle(){this.isFullscreen()?this.exit():this.request()}destroy(){this.exit(),this.offs.forEach(t=>t())}sync(){const t=this.isFullscreen();this.container.classList.toggle("glare-is-fullscreen",t);const s=c("[data-glare-fullscreen]",this.container);if(!s)return;const{dict:i}=this.glare;R(s,t,t?i.FULL_SCREEN_EXIT:i.FULL_SCREEN,t?u.fullscreenExit:u.fullscreen)}}function et(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function _(...e){const t={};for(const s of e)if(s)for(const[i,r]of Object.entries(s)){if(r===void 0)continue;const o=t[i];t[i]=et(r)?_(et(o)?o:{},r):r}return t}function x(e,t,s){return Math.min(s,Math.max(t,e))}const L=1,F=5,re=1.01;class oe{constructor(t){this.target=t,this.scale=L,this.x=0,this.y=0}get isZoomed(){return this.scale>re}get state(){return{scale:this.scale,x:this.x,y:this.y}}center(){const t=this.target.image();if(!t)return null;const s=t.getBoundingClientRect();return{x:s.left+s.width/2-this.x,y:s.top+s.height/2-this.y}}apply(t,s,i,r=0){const o=this.target.image();if(!o)return;this.scale=x(t,L,F);const n=this.isZoomed?this.bounded(s,i):{x:0,y:0};this.x=n.x,this.y=n.y,o.style.transitionDuration=`${r}ms`,o.style.transform=`translate3d(${this.x}px, ${this.y}px, 0) scale(${this.scale})`,this.target.onChange(this.isZoomed)}toFit(t=300){this.apply(L,0,0,t)}toActual(t,s=300){const i=this.target.image(),r=this.center();if(!i||!r)return;const o=i.naturalWidth/Math.max(i.offsetWidth,1),n=x(Math.max(o,1.5),L,F),a=t?.x??r.x,l=t?.y??r.y;this.apply(n,(r.x-a)*(n-1),(r.y-l)*(n-1),s)}reset(){const t=this.target.image();t&&(t.style.transform="",t.style.transitionDuration=""),this.scale=L,this.x=0,this.y=0,this.target.onChange(!1)}bounded(t,s){const i=this.target.image(),r=this.target.stage();if(!i||!r)return{x:t,y:s};const o=Math.max(0,(i.offsetWidth*this.scale-r.clientWidth)/2),n=Math.max(0,(i.offsetHeight*this.scale-r.clientHeight)/2);return{x:x(t,-o,o),y:x(s,-n,n)}}}const ne=6,st=120,ae=100,le=.5,ce=80,he=.4,ue="a, button, input, textarea, select, video, .glare-thumbs",it=(e,t)=>Math.hypot(e.x-t.x,e.y-t.y),rt=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),H=e=>({x:e.clientX,y:e.clientY});class de{constructor(t,s){this.stage=t,this.host=s,this.pointers=new Map,this.mode="idle",this.moved=!1,this.start=[],this.startTime=0,this.startZoom={scale:1,x:0,y:0},this.startMid={x:0,y:0},this.startDistance=0,this.offs=[h(t,"pointerdown",i=>this.onDown(i)),h(window,"pointermove",i=>this.onMove(i),{passive:!1}),h(window,"pointerup",i=>this.onUp(i)),h(window,"pointercancel",i=>this.onUp(i))]}destroy(){this.offs.forEach(t=>t()),this.pointers.clear()}consumeMoved(){const t=this.moved;return this.moved=!1,t}onDown(t){t.pointerType==="mouse"&&t.button!==0||t.target.closest(ue)||(this.pointers.set(t.pointerId,H(t)),this.pointers.size<=2&&this.begin())}onMove(t){this.pointers.has(t.pointerId)&&(this.pointers.set(t.pointerId,H(t)),this.move(t))}onUp(t){this.pointers.has(t.pointerId)&&(this.pointers.delete(t.pointerId),this.pointers.size===0?this.end(H(t)):this.begin())}begin(){this.mode==="swipe"&&this.releaseStage();const t=[...this.pointers.values()];this.start=t,this.startTime=performance.now(),this.startZoom=this.host.zoom.state,this.mode=t.length>=2?"pinch":"idle",t.length>=2&&(this.startDistance=it(t[0],t[1]),this.startMid=rt(t[0],t[1]))}move(t){const s=[...this.pointers.values()];if(!this.start.length||!s.length)return;if(this.mode==="pinch"&&s.length>=2){t.preventDefault(),this.moved=!0,this.pinch(s[0],s[1]);return}const i=s[0].x-this.start[0].x,r=s[0].y-this.start[0].y;if(!(!this.moved&&Math.hypot(i,r)<ne)){if(this.moved=!0,this.mode==="idle"&&(this.mode=this.host.zoom.isZoomed&&this.host.canPan()?"pan":"swipe"),this.mode==="pan")t.preventDefault(),this.host.zoom.apply(this.startZoom.scale,this.startZoom.x+i,this.startZoom.y+r);else if(this.mode==="swipe"){const o=this.host.touch.vertical!==!1;if(!o&&Math.abs(r)>Math.abs(i))return;t.preventDefault(),this.dragStage(i,o?r:0)}}}pinch(t,s){const{zoom:i}=this.host,r=rt(t,s),o=i.center()??r,n=x(this.startZoom.scale*it(t,s)/(this.startDistance||1),L,F),a=(this.startMid.x-o.x-this.startZoom.x)/this.startZoom.scale,l=(this.startMid.y-o.y-this.startZoom.y)/this.startZoom.scale;i.apply(n,r.x-o.x-n*a,r.y-o.y-n*l)}end(t){if(!this.start.length)return;const s=Math.max(performance.now()-this.startTime,1),i=t.x-this.start[0].x,r=t.y-this.start[0].y,o={x:i/s,y:r/s};if(this.mode==="swipe")this.releaseStage(),this.finishSwipe(i,r,o);else if(this.mode==="pan"&&this.host.touch.momentum!==!1){const{zoom:n}=this.host;n.apply(n.scale,n.x+o.x*st,n.y+o.y*st,250)}this.mode="idle",this.start=[],this.moved&&setTimeout(()=>this.moved=!1,0)}dragStage(t,s){this.stage.style.transitionDuration="0ms",this.stage.style.transform=`translate3d(${t}px, ${s}px, 0)`;const{bg:i}=this.host;i&&(i.style.transitionDuration="0ms",i.style.opacity=String(x(1-Math.abs(s)/400,.35,1)))}releaseStage(){this.stage.style.transitionDuration="",this.stage.style.transform="";const{bg:t}=this.host;t&&(t.style.transitionDuration="",t.style.opacity="")}finishSwipe(t,s,i){if(Math.abs(s)>Math.abs(t)){(Math.abs(s)>ae||Math.abs(i.y)>le)&&this.host.close();return}(Math.abs(t)>ce||Math.abs(i.x)>he)&&(t<0?this.host.next():this.host.prev())}}const fe=/^(.+)-(\d+)$/;function P(e=window.location.hash){const t=e.replace(/^#/,"").match(fe);return t?{gallery:t[1],index:Math.max(0,parseInt(t[2],10)-1)}:null}function ot(e,t){return`${e}-${t+1}`}class pe{constructor(t,s){this.glare=t,this.gallery=s,this.pushed=!1,this.off=h(window,"hashchange",()=>this.onHashChange());const i=ot(s,t.currIndex);nt()!==i&&(window.history.pushState(null,"",`#${i}`),this.pushed=!0)}update(t=this.glare.currIndex){const s=ot(this.gallery,t);nt()!==s&&this.replace(`#${s}`)}destroy(){this.off(),P()?.gallery===this.gallery&&(this.pushed?window.history.back():this.replace(""))}onHashChange(){const t=P();!t||t.gallery!==this.gallery?(this.pushed=!1,this.glare.close()):t.index!==this.glare.currIndex&&this.glare.jumpTo(t.index)}replace(t){const{pathname:s,search:i}=window.location;window.history.replaceState(null,"",`${s}${i}${t}`)}}const nt=()=>window.location.hash.replace(/^#/,"");class me{constructor(t,s,i){this.glare=t,this.container=s,this.opts=i,this.overlay=null,this.off=null}get isOpen(){return this.overlay!==null}open(){const{current:t,dict:s}=this.glare;if(!t)return;this.close();const i=this.resolveUrl(t),r=encodeURIComponent(i),o=encodeURIComponent(t.thumb||t.src||i),n=encodeURIComponent($(t.caption)),a=y(this.opts.tpl??Lt,{...s,url_direct:i,url_facebook:`https://www.facebook.com/sharer/sharer.php?u=${r}`,url_twitter:`https://twitter.com/intent/tweet?url=${r}&text=${n}`,url_pinterest:`https://pinterest.com/pin/create/button/?url=${r}&media=${o}&description=${n}`});this.overlay=g("div","glare-share-overlay",a),this.container.appendChild(this.overlay);const l=c(".glare-share-input",this.overlay);l?.select(),this.off=h(this.overlay,"click",d=>{const m=d.target;m===this.overlay||m.closest("[data-glare-share-close]")?this.close():m.closest("[data-glare-share-copy]")&&this.copy(i,l)})}close(){if(!this.overlay)return;const t=this.overlay.contains(document.activeElement);if(this.off?.(),this.off=null,this.overlay.remove(),this.overlay=null,!t)return;const s=c("[data-glare-share]",this.container);s?s.focus():this.glare.focus()}destroy(){this.close()}async copy(t,s){try{await navigator.clipboard.writeText(t)}catch{s?.select(),document.execCommand("copy")}s?.select()}resolveUrl(t){const{url:s}=this.opts;return typeof s=="function"?s(t):s||(/^https?:\/\//i.test(t.src)?t.src:window.location.href)}}class ge{constructor(t,s,i){this.glare=t,this.container=s,this.opts=i,this.timer=null,this.active=!1,this.bar=c(".glare-progress",s),this.button=c("[data-glare-slideshow]",s),i.autoStart&&this.start()}isActive(){return this.active}start(){this.glare.group.length<2||(this.active=!0,this.container.classList.add("glare-is-slideshow"),this.syncButton(),this.schedule())}stop(){this.active=!1,this.clearTimer(),this.setProgress(0,!0),this.container.classList.remove("glare-is-slideshow"),this.syncButton()}toggle(){this.active?this.stop():this.start()}onIndexChange(){this.active&&this.schedule()}destroy(){this.stop()}get speed(){return this.opts.speed??k.speed}get atEnd(){return!this.glare.opts.loop&&this.glare.currIndex===this.glare.group.length-1}schedule(){this.clearTimer(),this.setProgress(0),O()||(this.bar?.offsetWidth,this.setProgress(1)),this.timer=setTimeout(()=>this.atEnd?this.stop():this.glare.next(),this.speed)}clearTimer(){this.timer&&clearTimeout(this.timer),this.timer=null}setProgress(t,s=!1){this.bar&&(this.bar.hidden=s,this.bar.style.transitionDuration=t?`${this.speed}ms`:"0ms",this.bar.style.transform=`scaleX(${t})`)}syncButton(){if(!this.button)return;const{dict:t}=this.glare;R(this.button,this.active,this.active?t.PLAY_STOP:t.PLAY_START,this.active?u.pause:u.play)}}class ye{constructor(t,s,i){this.glare=t,this.container=s,this.opts=i,this.isActive=!1,this.offs=[],this.axis=i.axis==="y"?"y":"x",this.list=g("div","glare-thumbs-list"),this.strip=g("div",`glare-thumbs glare-thumbs--${this.axis}`),this.strip.appendChild(this.list),this.build()}show(){this.setActive(!0)}hide(){this.setActive(!1)}toggle(){this.setActive(!this.isActive)}focus(t=this.glare.currIndex){for(const s of M(".glare-thumbs-item",this.list))s.classList.toggle("glare-is-active",Number(s.dataset.index)===t);this.list.querySelector(".glare-is-active")?.scrollIntoView({block:"nearest",inline:"nearest",behavior:"smooth"})}destroy(){this.offs.forEach(t=>t()),this.offs=[],this.container.classList.remove(`glare-thumbs-axis-${this.axis}`),this.strip.remove()}setActive(t){this.isActive=t,this.strip.classList.toggle("glare-thumbs--active",t),this.container.classList.toggle("glare-show-thumbs",t);const s=c("[data-glare-thumbs]",this.container);s?.classList.toggle("glare-is-active",t),s?.setAttribute("aria-expanded",String(t))}build(){const{group:t,dict:s}=this.glare;if(t.length<2)return;this.container.classList.add(`glare-thumbs-axis-${this.axis}`);for(const r of t){const o=g("button","glare-thumbs-item");o.type="button",o.dataset.index=String(r.index),o.setAttribute("aria-label",y(s.GO_TO_SLIDE,{index:String(r.index+1)}));const n=r.thumb||(r.type==="image"?r.src:"");if(n){const a=g("img");a.src=n,a.alt=r.alt||$(r.caption),a.loading="lazy",o.appendChild(a)}else o.textContent=String(r.index+1);this.list.appendChild(o),this.offs.push(h(o,"click",()=>this.glare.jumpTo(r.index)))}(_t(this.opts.parentEl,this.container)??this.container).appendChild(this.strip),this.opts.autoStart&&this.show(),this.focus()}}const be=40,ve=150,xe=16;class we{constructor(t,s){this.distance=0,this.fired=!1,this.settle=null,this.off=h(t,"wheel",i=>{const r=s.current();!r||i.deltaY===0||s.mode==="auto"&&r.type!=="image"||r.type==="image"&&s.isZoomed()||(i.preventDefault(),this.restartSettle(),!this.fired&&(this.distance+=Ee(i,t),!(Math.abs(this.distance)<be)&&(this.fired=!0,this.distance>0?s.next():s.prev())))},{passive:!1})}destroy(){this.settle&&clearTimeout(this.settle),this.off()}restartSettle(){this.settle&&clearTimeout(this.settle),this.settle=setTimeout(()=>{this.distance=0,this.fired=!1},ve)}}function Ee(e,t){return e.deltaMode===WheelEvent.DOM_DELTA_LINE?e.deltaY*xe:e.deltaMode===WheelEvent.DOM_DELTA_PAGE?e.deltaY*t.clientHeight:e.deltaY}function Te(e,t){const s=O(),i=s?!1:t.animationEffect,r=s?!1:t.transitionEffect;e.dataset.animation=i||"none",e.style.setProperty("--glare-duration",`${i?t.animationDuration:0}ms`),e.style.setProperty("--glare-transition-duration",`${r?t.transitionDuration:0}ms`)}function Se(e,t){const s=O()?!1:t.transitionEffect;e.dataset.transition=s||"none"}function Le(e,t,s){const i=t.$image,r=t.$trigger;if(e.dataset.animation!=="zoom"||!i||!r)return;const o=r.getBoundingClientRect(),n=i.getBoundingClientRect(),a=Math.max(o.width/Math.max(n.width,1),o.height/Math.max(n.height,1)),l=o.left+o.width/2-(n.left+n.width/2),d=o.top+o.height/2-(n.top+n.height/2);Object.assign(i.style,{transform:`translate3d(${l}px, ${d}px, 0) scale(${a})`,opacity:s.zoomOpacity?"0.2":"1",transitionDuration:"0ms"}),G(()=>{Object.assign(i.style,{transform:"",opacity:"",transitionDuration:""})})}function at(e){const t=_(B,e);return Ht()&&t.mobile?_(t,t.mobile):t}function A(e,t){return e?e===!0?{...t}:{...t,...e}:null}const I=[],z=e=>e.getAttribute("data-glare")??"";function Ce(e){return typeof e=="string"?M(e):e instanceof HTMLElement?[e]:Array.from(e)}function Me(e,t,s){const i=Ce(e),r=a=>{const l=z(a),d=l?i.filter(m=>z(m)===l):[a];s(d,d.indexOf(a),l)},o=i.map(a=>h(a,"click",l=>{l.preventDefault(),r(a)})),n={elements:i,destroy(){o.forEach(l=>l());const a=I.indexOf(n);a>=0&&I.splice(a,1)}};return I.push(n),at(t).hash&&Oe(i,r),n}function $e(){for(const e of[...I])e.destroy()}function Oe(e,t){const s=P();if(!s)return;const r=e.filter(o=>z(o)===s.gallery)[s.index];r&&t(r)}class Ae{constructor(t,s){this.seconds=t,this.onIdle=s,this.timer=null}reset(){this.stop(),this.seconds&&(this.timer=setTimeout(this.onIdle,this.seconds*1e3))}stop(){this.timer&&clearTimeout(this.timer),this.timer=null}}const w=[],v={add(e){w.push(e)},remove(e){const t=w.indexOf(e);t>=0&&w.splice(t,1)},top(){return w[w.length-1]??null},get(e){return w.find(t=>t.id===e)??null},all(){return[...w]},get size(){return w.length}},Ie=[["[data-glare-close]",e=>e.close()],["[data-glare-next]",e=>e.next()],["[data-glare-prev]",e=>e.prev()],["[data-glare-zoom]",e=>e.toggleZoom()],["[data-glare-slideshow]",e=>e.slideshow?.toggle()],["[data-glare-thumbs]",e=>e.thumbs?.toggle()],["[data-glare-fullscreen]",e=>e.fullscreen?.toggle()],["[data-glare-share]",e=>e.share?.open()]],De=".glare-content",ke=".glare-slide, .glare-stage",Re='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])',_e=new Set(["INPUT","TEXTAREA","SELECT"]),Fe=300;function He(e,t,s){let i=null;const r=()=>{i&&clearTimeout(i),i=null},o=[h(t,"click",n=>{if(e.consumeGesture())return;const a=n.target,l=a.closest("[data-glare-more]");if(l){const D=l.closest(".glare-toolbar"),pt=!D?.classList.contains("glare-toolbar--expanded");D?.classList.toggle("glare-toolbar--expanded",pt),l.setAttribute("aria-expanded",String(pt));return}ct(t);const d=Ie.find(([D])=>a.closest(D));if(d)return d[1](e);if(a.closest(".glare-button"))return;const m=N(e,a,"click");if(m){if(!lt(e,N(e,a,"dblclick"),n))return Z(e,m,n);r(),i=setTimeout(()=>Z(e,m,n),Fe)}}),h(t,"dblclick",n=>{r();const a=n.target;a.closest(".glare-button")||Z(e,N(e,a,"dblclick"),n)}),h(document,"keydown",n=>Pe(e,n)),h(document,"keydown",s),h(document,"mousemove",s),h(document,"touchstart",s,{passive:!0})];return e.opts.trapFocus&&o.push(h(t,"keydown",n=>ze(t,n))),e.opts.protect&&o.push(h(t,"contextmenu",n=>n.preventDefault()),h(t,"dragstart",n=>{n.target.tagName==="IMG"&&n.preventDefault()})),()=>{r(),o.forEach(n=>n())}}function N(e,t,s){const{opts:i}=e;if(t.closest(De))return s==="click"?i.clickContent:i.dblclickContent;if(!(i.modal||!t.closest(ke)))return s==="click"?i.clickSlide:i.dblclickSlide}function lt(e,t,s){return!t||!e.current?!1:typeof t=="function"?t(e.current,s):t}function Z(e,t,s){switch(lt(e,t,s)){case"close":return e.close();case"next":return e.next();case"nextOrClose":return e.currIndex===e.group.length-1&&!e.opts.loop?e.close():e.next();case"toggleControls":return e.toggleControls();case"zoom":{const i=s instanceof MouseEvent?{x:s.clientX,y:s.clientY}:void 0;return e.toggleZoom(i)}}}function Pe(e,t){if(v.top()!==e)return;if(t.key==="Escape"&&ct(e.$refs?.container??null)){t.preventDefault();return}if(t.key==="Escape"&&e.share?.isOpen)return t.preventDefault(),e.share.close();if(!e.opts.keyboard||e.opts.modal)return;const s=t.target;if(!_e.has(s.tagName)&&!(t.key===" "&&s.closest("button")))switch(t.key){case"Escape":return t.preventDefault(),e.close();case"ArrowRight":case"ArrowDown":return t.preventDefault(),e.next();case"ArrowLeft":case"ArrowUp":return t.preventDefault(),e.prev();case" ":return t.preventDefault(),e.slideshow?.toggle();case"f":case"F":return e.fullscreen?.toggle()}}function ct(e){const t=e?.querySelector(".glare-toolbar--expanded");return t?(t.classList.remove("glare-toolbar--expanded"),t.querySelector("[data-glare-more]")?.setAttribute("aria-expanded","false"),!0):!1}function ze(e,t){if(t.key!=="Tab")return;const s=M(Re,e).filter(o=>!o.hasAttribute("disabled")&&o.offsetParent!==null&&getComputedStyle(o).visibility!=="hidden");if(!s.length)return;const i=s[0],r=s[s.length-1];t.shiftKey&&document.activeElement===i?(t.preventDefault(),r.focus()):!t.shiftKey&&document.activeElement===r&&(t.preventDefault(),i.focus())}const Ne=1200,ht=16/9;function Ze(e,t,s){if(t&&s)return t/s;const i=String(e.ratio||ht).replace(":","/"),[r,o="1"]=i.split("/").map(l=>l.trim()),n=parseFloat(r),a=parseFloat(o);return n>0&&a>0?n/a:ht}function ut(e,t,s){if(!e)return 0;if(typeof e=="number")return e;const i=e.trim(),r=parseFloat(i);return r>0?i.endsWith("%")?t*r/100:i.endsWith("vw")||i.endsWith("vh")?s*r/100:r:0}function dt(e,t){const s=t.parentElement;if(!s)return;const i=getComputedStyle(s),r=s.clientWidth-parseFloat(i.paddingLeft)-parseFloat(i.paddingRight),o=s.clientHeight-parseFloat(i.paddingTop)-parseFloat(i.paddingBottom);if(!(r>0&&o>0))return;const n=e.width!==void 0&&e.height!==void 0;let a=n?ut(e.width,r,innerWidth):r,l=n?ut(e.height,o,innerHeight):o;const d=Ze(e,n?a:void 0,n?l:void 0),m=Math.min(1,r/a,o/l);a*=m,l*=m,l>a/d?l=a/d:a>l*d&&(a=l*d),t.style.width=`${a}px`,t.style.height=`${l}px`,t.style.aspectRatio=String(d)}function qe(e,t){if(dt(e,t),typeof ResizeObserver>"u"||!t.parentElement)return;const s=new ResizeObserver(()=>{if(!t.isConnected)return s.disconnect();dt(e,t)});s.observe(t.parentElement)}const Ue=(e,t,s)=>new Promise((i,r)=>{const o=g("img","glare-image");o.alt=e.alt||$(e.caption),o.decoding="async",o.draggable=!1,s.protect&&(o.style.pointerEvents="none"),o.onload=()=>{e.$image=o,e.contentWidth=o.naturalWidth,e.contentHeight=o.naturalHeight,t.appendChild(o),i()},o.onerror=()=>r(new Error(`Failed to load image: ${e.src}`)),o.src=e.src}),je=(e,t,s,i)=>{const r=e.format||s.video.format||It(e.src);t.innerHTML=y(s.video.tpl,{...i,src:e.src,format:r,poster:e.poster??""});const o=t.querySelector("video");o&&(e.autoStart??s.video.autoStart)&&o.play().catch(()=>{})},ft=(e,t,s)=>new Promise(i=>{const r=s.iframe,o=g("div","glare-iframe-wrap",r.tpl),n=o.querySelector("iframe");if(!n)throw new Error("Iframe template must contain an <iframe>");for(const[a,l]of Object.entries(r.attr))n.setAttribute(a,l);if(Object.assign(n.style,r.css),t.appendChild(o),e.type==="embed"?qe(e,t):(e.width&&(o.style.width=Y(e.width)),e.height&&(o.style.height=Y(e.height))),!r.preload){n.src=e.src,i();return}n.onload=()=>i(),n.src=e.src,setTimeout(i,Ne)}),We={image:Ue,video:je,embed:ft,iframe:ft,inline:(e,t)=>{const s=e.src?c(e.src):null;if(!s)throw new Error(`Inline target not found: ${e.src}`);const i=s.cloneNode(!0);i.removeAttribute("id"),i.hidden=!1,i.style.display="",t.appendChild(i)},ajax:async(e,t,s)=>{const i=await fetch(e.src,s.ajax.settings);if(!i.ok)throw new Error(`Request failed: ${i.status} ${e.src}`);t.innerHTML=await i.text()},html:(e,t)=>{e.content instanceof HTMLElement?t.appendChild(e.content):t.innerHTML=e.html??e.content??e.src}};async function Be(e,t,s,i){t.innerHTML="",t.className=`glare-content glare-content--${e.type}`,await We[e.type](e,t,s,i),e.isLoaded=!0}function Xe(e,t){for(const s of[e[t-1],e[t+1]])s?.type==="image"&&s.src&&(new Image().src=s.src)}let Ye=0;const E=class E{constructor(t,s={},i=0,r=""){this.id=++Ye,this.current=null,this.currIndex=0,this.prevIndex=0,this.isActive=!1,this.isClosing=!1,this.isIdle=!1,this.$refs=null,this.hash=null,this.gestures=null,this.wheel=null,this.cleanups=[],this.previouslyFocused=null,this.opts=at(s),this.dict=C(this.opts),this.group=kt(t,this.opts),this.galleryName=r,this.currIndex=this.clampIndex(i),this.zoom=new oe({image:()=>this.current?.$image??null,stage:()=>this.$refs?.stage??null,onChange:o=>this.syncZoomState(o)}),this.idle=new Ae(this.opts.modal?!1:this.opts.idleTime,()=>this.toggleControls(!0))}open(t=this.currIndex){if(this.isActive)return this.jumpTo(t);if(!this.group.length)return;this.opts.closeExisting&&E.close(!0),this.currIndex=this.clampIndex(t),this.current=this.group[this.currIndex],this.previouslyFocused=document.activeElement instanceof HTMLElement?document.activeElement:null,this.emit("onInit");const s=Pt(this.opts,this.dict,this.id,this.group.length),{container:i}=s;this.$refs=s,Te(i,this.opts),this.syncChrome(),this.resolveParent().appendChild(i),this.isActive=!0,v.add(this),this.opts.hideScrollbar&&Q(!0),this.emit("onActivate"),this.emitSlide("beforeShow",this.current),G(()=>{this.isActive&&(i.classList.add("glare-is-open"),this.showSlide(this.currIndex,!0),this.cleanups.push(He(this,i,()=>this.onActivity())),this.startModules(s),this.opts.autoFocus&&this.focus(),this.idle.reset())})}close(){if(!this.isActive||this.isClosing||!this.current||!this.$refs||this.emitSlide("beforeClose",this.current)===!1)return;this.isClosing=!0,this.slideshow?.stop(),this.idle.stop();const{container:t,bg:s}=this.$refs,i=O()?0:this.opts.animationDuration;if(i===0)return this.teardown();t.classList.remove("glare-is-open"),t.classList.add("glare-is-closing"),Ft(s??t,i,()=>this.teardown())}next(){this.jumpTo(this.currIndex+1)}prev(){this.jumpTo(this.currIndex-1)}jumpTo(t){if(!this.isActive||this.isClosing)return;const s=this.group.length,i=this.opts.loop?(t%s+s)%s:x(t,0,s-1);i!==this.currIndex&&(this.prevIndex=this.currIndex,this.currIndex=i,this.zoom.reset(),this.current=this.group[i],this.syncChrome(),this.showSlide(i,!1),this.thumbs?.focus(i),this.hash?.update(i),this.slideshow?.onIndexChange(),this.emitSlide("onUpdate",this.current))}toggleZoom(t){this.current?.type==="image"&&(this.zoom.isZoomed?this.zoom.toFit():this.zoom.toActual(t))}update(){this.syncChrome()}focus(){this.$refs?.container.focus({preventScroll:!0})}toggleControls(t){this.$refs&&(this.isIdle=t??!this.isIdle,this.$refs.container.classList.toggle("glare-is-idle",this.isIdle))}consumeGesture(){return this.gestures?.consumeMoved()??!1}async showSlide(t,s){const i=this.group[t];if(!this.$refs||!i)return;const{container:r,stage:o}=this.$refs,n=Nt(o,i,this.opts);Xt(this.opts,i)&&Ut(n,this.opts,this.dict),jt(o,this.opts,this.dict),this.emitSlide("beforeLoad",i),this.opts.image.preload&&Xe(this.group,t);let a=!1;try{await Be(i,i.$content,this.opts,this.dict)}catch(l){a=!0,Bt(i,l,this.opts,this.dict),this.emitSlide("onError",i),this.opts.onError||console.warn("[glare]",l)}if(!this.isActive||this.currIndex!==t)return n.remove();a||this.emitSlide("afterLoad",i),Wt(o),s||Se(r,this.opts),Zt(n,s),qt(o,n,this.opts.transitionDuration),this.syncZoomState(this.zoom.isZoomed),!a&&(s&&Le(r,i,this.opts),this.emitSlide("afterShow",i))}syncChrome(){!this.$refs||!this.current||(Yt(this.$refs,this.opts,this.dict,this.current,this.group.length,this.captionFor(this.current)),this.syncZoomState(this.zoom.isZoomed))}captionFor(t){const{caption:s}=this.opts;return typeof s=="function"?s(this,t):s??t.caption}syncZoomState(t){this.$refs&&se(this.$refs.container,this.dict,t,!!this.current?.$image)}resolveParent(){const{parentEl:t}=this.opts;return(typeof t=="string"?document.querySelector(t):t)??document.body}startModules({container:t,stage:s,bg:i}){const r=this.opts,o=A(r.thumbs,j);o&&(this.thumbs=new ye(this,t,o));const n=A(r.slideshow,k);n&&(this.slideshow=new ge(this,t,n));const a=A(r.fullscreen,W);a&&V()&&(this.fullscreen=new ie(this,t,a));const l=A(r.share,{});l&&(this.share=new me(this,t,l)),r.hash&&this.galleryName&&(this.hash=new pe(this,this.galleryName)),r.wheel&&(this.wheel=new we(s,{mode:r.wheel,current:()=>this.current,isZoomed:()=>this.zoom.isZoomed,next:()=>this.next(),prev:()=>this.prev()})),r.touch&&(this.gestures=new de(s,{zoom:this.zoom,touch:r.touch,bg:i,canPan:()=>this.current?.type==="image",close:()=>this.close(),next:()=>this.next(),prev:()=>this.prev()}))}onActivity(){this.isIdle&&this.toggleControls(!1),this.idle.reset()}teardown(){for(const t of[this.gestures,this.wheel,this.hash,this.share,this.thumbs,this.slideshow,this.fullscreen])t?.destroy();this.gestures=this.wheel=this.hash=null,this.share=this.thumbs=this.slideshow=this.fullscreen=void 0,this.cleanups.forEach(t=>t()),this.cleanups=[],this.$refs?.container.remove(),this.$refs=null,v.remove(this),this.opts.hideScrollbar&&v.size===0&&Q(!1),this.opts.backFocus&&(this.current?.$trigger??this.previouslyFocused)?.focus({preventScroll:!0}),this.isActive=!1,this.isClosing=!1,this.current&&this.emitSlide("afterClose",this.current)}emit(t){return this.opts[t]?.(this)}emitSlide(t,s){return this.opts[t]?.(this,s)}clampIndex(t){return x(t,0,Math.max(0,this.group.length-1))}static open(t,s={},i=0){const r=new E(t,s,i);return r.open(),r}static bind(t,s={}){return Me(t,s,(i,r,o)=>{new E(i,s,r,o).open()})}static close(t=!1){t?v.all().reverse().forEach(s=>s.close()):v.top()?.close()}static getInstance(t){return t==null?v.top():v.get(t)}static getInstances(){return v.all()}static destroy(){E.close(!0),$e()}static autoBind(t={}){const s=()=>E.bind("[data-glare]",t);document.readyState==="loading"?document.addEventListener("DOMContentLoaded",s,{once:!0}):s()}};E.defaults=B;let q=E;return q}));
|
|
16
|
+
</div>`,St={zoom:y("zoom","ZOOM",u.zoomIn),slideshow:y("slideshow","PLAY_START",u.play),thumbs:y("thumbs","THUMBS",u.thumbs,' aria-expanded="false"'),fullscreen:y("fullscreen","FULL_SCREEN",u.fullscreen),more:y("more","MORE",u.more,' aria-expanded="false" aria-haspopup="true"'),close:y("close","CLOSE",u.close),download:`<a class="glare-button glare-button--download" data-glare-download download target="_blank" rel="noopener" title="{{DOWNLOAD}}" aria-label="{{DOWNLOAD}}">${u.download}</a>`,smallBtn:`<button type="button" class="glare-button glare-close-small" data-glare-close title="{{CLOSE}}" aria-label="{{CLOSE}}">${u.close}</button>`},Lt='<div class="glare-spinner" role="status" aria-label="{{LOADING}}"></div>',Mt='<div class="glare-error"><p>{{ERROR}}</p></div>',Ct='<video class="glare-video" controls playsinline controlsList="nodownload" poster="{{poster}}"><source src="{{src}}" type="{{format}}"/>{{VIDEO_UNSUPPORTED}}</video>',$t='<iframe class="glare-iframe"></iframe>',W={autoStart:!1,axis:"x",fit:"cover"},A={autoStart:!1,speed:3e3},U={autoStart:!1},X={closeExisting:!1,loop:!1,keyboard:!0,protect:!1,modal:!1,idleTime:3,hideScrollbar:!0,autoFocus:!0,backFocus:!0,trapFocus:!0,defaultType:"image",parentEl:"body",baseClass:"",slideClass:"",arrows:!0,infobar:!0,toolbar:"auto",smallBtn:"auto",buttons:["zoom","slideshow","thumbs","download","fullscreen","close"],animationEffect:"zoom",animationDuration:366,anchor:"trigger",zoomOpacity:!0,transitionEffect:"fade",transitionDuration:366,clickContent:e=>e.type==="image"?"zoom":!1,clickSlide:"close",dblclickContent:!1,dblclickSlide:!1,wheel:"auto",touch:{vertical:!0,momentum:!0},mobile:{idleTime:!1,clickContent:e=>e.type==="image"?"toggleControls":!1,clickSlide:e=>e.type==="image"?"toggleControls":"close",dblclickContent:e=>e.type==="image"?"zoom":!1,dblclickSlide:e=>e.type==="image"?"zoom":!1},image:{preload:!1},video:{tpl:Ct,format:"",autoStart:!0},iframe:{preload:!0,css:{},attr:{allowfullscreen:"true",allow:"autoplay; fullscreen; picture-in-picture"},tpl:$t},ajax:{settings:{headers:{"X-Requested-With":"XMLHttpRequest"}}},media:wt,hash:!0,slideshow:A,thumbs:W,fullscreen:U,lang:"en",i18n:{en:S},baseTpl:Tt,btnTpl:St,spinnerTpl:Lt,errorTpl:Mt},Ot=/\.(avif|bmp|gif|jpe?g|png|svg|webp|ico)(\?.*)?$/i,It=/\.(mp4|webm|ogg|ogv|mov|m4v)(\?.*)?$/i,At=/\.pdf(\?.*)?$/i,Dt=/^(#[\w-]+|\.[\w-]+)$/;function kt(e,t="image"){return e?Dt.test(e)?"inline":Ot.test(e)?"image":It.test(e)?"video":At.test(e)?"iframe":t:"html"}function Rt(e){const t=e.match(/\.(\w+)(?:\?|$)/)?.[1]?.toLowerCase();return t?`video/${t==="ogv"?"ogg":t}`:"video/mp4"}function G(e,t,s){const i=typeof e=="string"?{src:e}:{...e};let n=i.src??"",o=i.type,r=i.thumb;const a=n?Et(n,s.media):null;return a&&(n=a.src??n,o??=a.type,r??=a.thumb),o||(o=i.html||i.content?"html":kt(n,s.defaultType)),{...i,index:t,src:n,type:o,thumb:r,caption:i.caption??i.title??"",isLoaded:!1,hasError:!1}}const p=(e,t)=>e.getAttribute(t)||void 0;function Ft(e,t){return e.map((s,i)=>{const n=s.querySelector("img"),o=p(s,"data-caption")??p(s,"title")??"";return G({src:p(s,"data-src")??p(s,"href")??"",type:p(s,"data-type"),caption:o,alt:n?.getAttribute("alt")||o,thumb:p(s,"data-thumb")??n?.getAttribute("src")??void 0,width:p(s,"data-width"),height:p(s,"data-height"),ratio:p(s,"data-ratio"),poster:p(s,"data-poster"),downloadSrc:p(s,"data-download-src"),html:p(s,"data-html"),$trigger:s},i,t)})}function Ht(e,t){return e.length&&e[0]instanceof HTMLElement?Ft(e,t):e.map((s,i)=>G(s,i,t))}function c(e,t=document){return t.querySelector(e)}function C(e,t=document){return Array.from(t.querySelectorAll(e))}function m(e,t="",s=""){const i=document.createElement(e);return t&&(i.className=t),s&&(i.innerHTML=s),i}function Pt(e){return m("div","",e.trim()).firstElementChild}function D(e){return/[<&]/.test(e)?new DOMParser().parseFromString(e,"text/html").body.textContent?.trim()??"":e.trim()}function V(e,t=document){return e?typeof e!="string"?e:c(e,t)??c(e):null}function Y(e){return typeof e=="number"?`${e}px`:e}function h(e,t,s,i){return e.addEventListener(t,s,i),()=>e.removeEventListener(t,s,i)}function K(e){requestAnimationFrame(()=>requestAnimationFrame(e))}function zt(e,t,s){let i=!1;const n=()=>{i||(i=!0,clearTimeout(r),e.removeEventListener("transitionend",o),s())},o=a=>{a.target===e&&n()};e.addEventListener("transitionend",o);const r=setTimeout(n,t+50)}function _t(){return navigator.maxTouchPoints>0&&window.matchMedia("(pointer: coarse)").matches}function Q(){return window.matchMedia("(prefers-reduced-motion: reduce)").matches}function J(){const e=document;return!!(e.fullscreenEnabled??e.webkitFullscreenEnabled)}const tt="glare-lock";function et(e){const t=document.documentElement;if(e){const s=window.innerWidth-t.clientWidth;t.classList.add(tt),s>0&&(t.style.marginRight=`${s}px`)}else t.classList.remove(tt),t.style.marginRight=""}const E="glare-hidden";function Nt(e,t,s,i){const n=Pt(g(e.baseTpl,t));n.dataset.glareId=String(s),e.baseClass&&n.classList.add(e.baseClass),e.modal&&n.classList.add("glare-is-modal");const o=c(".glare-stage",n);if(!o)throw new Error("baseTpl must contain a .glare-stage element");const r={container:n,bg:c(".glare-bg",n),inner:c(".glare-inner",n),stage:o,caption:c(".glare-caption",n),toolbar:c(".glare-toolbar",n),infobar:c(".glare-infobar",n),navigation:c(".glare-navigation",n)},a=i<2;return r.navigation?.classList.toggle(E,!e.arrows||a),r.infobar?.classList.toggle(E,!e.infobar||a),r.toolbar&&Zt(r.toolbar,e,t,a),r}function Zt(e,t,s,i){if(t.toolbar===!1){e.classList.add(E);return}const n=m("div","glare-toolbar-menu");n.id=`glare-toolbar-menu-${e.closest(".glare-container")?.dataset.glareId??""}`;for(const o of t.buttons){if(typeof o!="string"){n.appendChild(jt(o));continue}if(i&&(o==="thumbs"||o==="slideshow")||o==="fullscreen"&&!J()||o==="more"||o==="close")continue;const r=t.btnTpl[o];r&&n.insertAdjacentHTML("beforeend",g(r,s))}if(n.childElementCount){e.appendChild(n);const o=t.btnTpl.more;o&&(e.insertAdjacentHTML("beforeend",g(o,s)),e.querySelector("[data-glare-more]")?.setAttribute("aria-controls",n.id))}if(t.buttons.includes("close")){const o=t.btnTpl.close;o&&e.insertAdjacentHTML("beforeend",g(o,s))}}function jt({name:e,label:t,icon:s}){const i=m("button",`glare-button glare-button--${e}`,s);return i.type="button",i.title=t,i.dataset.glareCustom=e,i.setAttribute("aria-label",t),i}function qt(e,t){let s=0;for(let i=e;i instanceof HTMLElement&&i!==t;i=i.offsetParent)s+=i.offsetTop;return s}function Bt({container:e,caption:t}){let s=null;const i=()=>{if(!t)return;e.style.setProperty("--glare-caption-inset",`${t.offsetHeight}px`);const o=s&&c(".glare-content",s);o&&Object.assign(t.style,{top:`${qt(o,t.offsetParent)+o.offsetHeight}px`,bottom:"auto"})},n=new ResizeObserver(i);return t&&n.observe(t),i(),{follow(o){if(s)for(const r of[s,c(".glare-content",s)])r&&n.unobserve(r);s=o;for(const r of[o,c(".glare-content",o)])r&&n.observe(r);i()},destroy:()=>n.disconnect()}}function Wt(e,t,s){const i=m("div",`glare-slide glare-slide--${t.type}`);s.slideClass&&i.classList.add(s.slideClass);const n=m("div","glare-content");return i.appendChild(n),e.appendChild(i),t.$slide=i,t.$content=n,i}function Ut(e,t,s){e.style.setProperty("--glare-direction",String(s)),e.classList.add(t?"glare-slide--opening":"glare-slide--in"),t&&(e.style.transition="none"),e.offsetWidth,e.classList.add("glare-slide--current"),t&&(e.offsetWidth,e.style.transition="")}function Xt(e,t,s,i){for(const n of C(".glare-slide",e))n!==t&&(n.classList.contains("glare-slide--out")||n.style.setProperty("--glare-direction",String(i)),n.classList.remove("glare-slide--current","glare-slide--in","glare-slide--opening"),n.classList.add("glare-slide--out"),setTimeout(()=>n.remove(),s))}function Gt(e,t,s){e.insertAdjacentHTML("beforeend",g(t.btnTpl.smallBtn??"",s))}function Vt(e,t,s){e.querySelector(":scope > .glare-spinner")||e.insertAdjacentHTML("beforeend",g(t.spinnerTpl,s))}function Yt(e){e.querySelector(":scope > .glare-spinner")?.remove()}function Kt(e,t,s,i){e.hasError=!0,e.error=t,e.$content&&(e.$content.className="glare-content glare-content--error",e.$content.innerHTML=g(s.errorTpl,i))}function st(e,t){return typeof e.toolbar=="boolean"?e.toolbar:t.type==="image"}function Qt(e,t){return typeof e.smallBtn=="boolean"?e.smallBtn:!st(e,t)}function Jt(e,t,s,i,n,o){const{container:r,toolbar:a,infobar:l}=e;re(r,i.type),a&&te(a,t,i),ee(r,i),l&&se(l,i.index,n),e.caption&&ie(e.caption,o),ne(r,t,i.index,n),oe(r,s,i,n)}function te(e,t,s){if(t.toolbar===!1)return;e.classList.remove("glare-toolbar--expanded"),e.querySelector("[data-glare-more]")?.setAttribute("aria-expanded","false");const i=st(t,s);if(e.classList.toggle(E,!i),!i)return;const n=s.type==="image";c("[data-glare-zoom]",e)?.classList.toggle(E,!n)}function ee(e,t){const s=e.querySelector("[data-glare-download]");if(!s)return;const i=t.downloadSrc||(t.type==="image"?t.src:"");s.classList.toggle(E,!i),i&&(s.href=i)}function se(e,t,s){const i=c(".glare-infobar-index",e);i&&(i.textContent=`${t+1} / ${s}`)}function ie(e,t){e.innerHTML=t,e.classList.toggle(E,!t)}function ne(e,t,s,i){const n=!t.loop&&s===0,o=!t.loop&&s===i-1;it(c("[data-glare-prev]",e),n),it(c("[data-glare-next]",e),o)}function it(e,t){e&&(e.classList.toggle("glare-is-disabled",t),e.setAttribute("aria-disabled",String(t)))}function oe(e,t,s,i){const n=D(s.caption)||s.alt||t.LIGHTBOX,o=i>1?`${n} (${s.index+1} of ${i})`:n;e.setAttribute("aria-label",o);const r=c(".glare-live",e);r&&(r.textContent=o)}function re(e,t){const s=e.dataset.type;s&&e.classList.remove(`glare-type-${s}`),e.dataset.type=t,e.classList.add(`glare-type-${t}`)}function ae(e,t,s,i){e.classList.toggle("glare-can-zoom-out",s),e.classList.toggle("glare-can-zoom-in",!s&&i);const n=c("[data-glare-zoom]",e),o=s?"out":"in";!n||n.dataset.state===o||(n.dataset.state=o,k(n,s,s?t.ZOOM_OUT:t.ZOOM,s?u.zoomOut:u.zoomIn))}function k(e,t,s,i){e.setAttribute("title",s),e.setAttribute("aria-label",s),e.innerHTML=i,e.classList.toggle("glare-is-active",t)}class le{constructor(t,s,i){this.glare=t,this.container=s,this.offs=[h(document,"fullscreenchange",()=>this.sync()),h(document,"webkitfullscreenchange",()=>this.sync())],i.autoStart&&this.request()}isFullscreen(){const t=document;return!!(t.fullscreenElement??t.webkitFullscreenElement)}request(){const t=this.container;(t.requestFullscreen??t.webkitRequestFullscreen)?.call(t)}exit(){if(!this.isFullscreen())return;const t=document;(t.exitFullscreen??t.webkitExitFullscreen)?.call(document)}toggle(){this.isFullscreen()?this.exit():this.request()}destroy(){this.exit(),this.offs.forEach(t=>t())}sync(){const t=this.isFullscreen();this.container.classList.toggle("glare-is-fullscreen",t);const s=c("[data-glare-fullscreen]",this.container);if(!s)return;const{dict:i}=this.glare;k(s,t,t?i.FULL_SCREEN_EXIT:i.FULL_SCREEN,t?u.fullscreenExit:u.fullscreen)}}function nt(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function R(...e){const t={};for(const s of e)if(s)for(const[i,n]of Object.entries(s)){if(n===void 0)continue;const o=t[i];t[i]=nt(n)?R(nt(o)?o:{},n):n}return t}function v(e,t,s){return Math.min(s,Math.max(t,e))}const L=1,F=5,ce=1.01;class he{constructor(t){this.target=t,this.scale=L,this.x=0,this.y=0}get isZoomed(){return this.scale>ce}get state(){return{scale:this.scale,x:this.x,y:this.y}}center(){const t=this.target.image();if(!t)return null;const s=t.getBoundingClientRect();return{x:s.left+s.width/2-this.x,y:s.top+s.height/2-this.y}}apply(t,s,i,n=0){const o=this.target.image();if(!o)return;this.scale=v(t,L,F);const r=this.isZoomed?this.bounded(s,i):{x:0,y:0};this.x=r.x,this.y=r.y,o.style.transitionDuration=`${n}ms`,o.style.transform=`translate3d(${this.x}px, ${this.y}px, 0) scale(${this.scale})`,this.target.onChange(this.isZoomed)}toFit(t=300){this.apply(L,0,0,t)}toActual(t,s=300){const i=this.target.image(),n=this.center();if(!i||!n)return;const o=i.naturalWidth/Math.max(i.offsetWidth,1),r=v(Math.max(o,1.5),L,F),a=t?.x??n.x,l=t?.y??n.y;this.apply(r,(n.x-a)*(r-1),(n.y-l)*(r-1),s)}reset(){const t=this.target.image();t&&(t.style.transform="",t.style.transitionDuration=""),this.scale=L,this.x=0,this.y=0,this.target.onChange(!1)}bounded(t,s){const i=this.target.image(),n=this.target.stage();if(!i||!n)return{x:t,y:s};const o=Math.max(0,(i.offsetWidth*this.scale-n.clientWidth)/2),r=Math.max(0,(i.offsetHeight*this.scale-n.clientHeight)/2);return{x:v(t,-o,o),y:v(s,-r,r)}}}const ue=6,ot=120,de=100,fe=.5,pe=80,me=.4,ge="a, button, input, textarea, select, video, .glare-thumbs",rt=(e,t)=>Math.hypot(e.x-t.x,e.y-t.y),at=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),H=e=>({x:e.clientX,y:e.clientY});class be{constructor(t,s){this.stage=t,this.host=s,this.pointers=new Map,this.mode="idle",this.moved=!1,this.start=[],this.startTime=0,this.startZoom={scale:1,x:0,y:0},this.startMid={x:0,y:0},this.startDistance=0,this.offs=[h(t,"pointerdown",i=>this.onDown(i)),h(window,"pointermove",i=>this.onMove(i),{passive:!1}),h(window,"pointerup",i=>this.onUp(i)),h(window,"pointercancel",i=>this.onUp(i))]}destroy(){this.offs.forEach(t=>t()),this.pointers.clear()}consumeMoved(){const t=this.moved;return this.moved=!1,t}onDown(t){t.pointerType==="mouse"&&t.button!==0||t.target.closest(ge)||(this.pointers.set(t.pointerId,H(t)),this.pointers.size<=2&&this.begin())}onMove(t){this.pointers.has(t.pointerId)&&(this.pointers.set(t.pointerId,H(t)),this.move(t))}onUp(t){this.pointers.has(t.pointerId)&&(this.pointers.delete(t.pointerId),this.pointers.size===0?this.end(H(t)):this.begin())}begin(){this.mode==="swipe"&&this.releaseStage();const t=[...this.pointers.values()];this.start=t,this.startTime=performance.now(),this.startZoom=this.host.zoom.state,this.mode=t.length>=2?"pinch":"idle",t.length>=2&&(this.startDistance=rt(t[0],t[1]),this.startMid=at(t[0],t[1]))}move(t){const s=[...this.pointers.values()];if(!this.start.length||!s.length)return;if(this.mode==="pinch"&&s.length>=2){t.preventDefault(),this.moved=!0,this.pinch(s[0],s[1]);return}const i=s[0].x-this.start[0].x,n=s[0].y-this.start[0].y;if(!(!this.moved&&Math.hypot(i,n)<ue)){if(this.moved=!0,this.mode==="idle"&&(this.mode=this.host.zoom.isZoomed&&this.host.canPan()?"pan":"swipe"),this.mode==="pan")t.preventDefault(),this.host.zoom.apply(this.startZoom.scale,this.startZoom.x+i,this.startZoom.y+n);else if(this.mode==="swipe"){const o=this.host.touch.vertical!==!1;if(!o&&Math.abs(n)>Math.abs(i))return;t.preventDefault(),this.dragStage(i,o?n:0)}}}pinch(t,s){const{zoom:i}=this.host,n=at(t,s),o=i.center()??n,r=v(this.startZoom.scale*rt(t,s)/(this.startDistance||1),L,F),a=(this.startMid.x-o.x-this.startZoom.x)/this.startZoom.scale,l=(this.startMid.y-o.y-this.startZoom.y)/this.startZoom.scale;i.apply(r,n.x-o.x-r*a,n.y-o.y-r*l)}end(t){if(!this.start.length)return;const s=Math.max(performance.now()-this.startTime,1),i=t.x-this.start[0].x,n=t.y-this.start[0].y,o={x:i/s,y:n/s};if(this.mode==="swipe")this.releaseStage(),this.finishSwipe(i,n,o);else if(this.mode==="pan"&&this.host.touch.momentum!==!1){const{zoom:r}=this.host;r.apply(r.scale,r.x+o.x*ot,r.y+o.y*ot,250)}this.mode="idle",this.start=[],this.moved&&setTimeout(()=>this.moved=!1,0)}dragStage(t,s){this.stage.style.transitionDuration="0ms",this.stage.style.transform=`translate3d(${t}px, ${s}px, 0)`;const{bg:i}=this.host;i&&(i.style.transitionDuration="0ms",i.style.opacity=String(v(1-Math.abs(s)/400,.35,1)))}releaseStage(){this.stage.style.transitionDuration="",this.stage.style.transform="";const{bg:t}=this.host;t&&(t.style.transitionDuration="",t.style.opacity="")}finishSwipe(t,s,i){if(Math.abs(s)>Math.abs(t)){(Math.abs(s)>de||Math.abs(i.y)>fe)&&this.host.close();return}(Math.abs(t)>pe||Math.abs(i.x)>me)&&(t<0?this.host.next():this.host.prev())}}const ye=/^(.+)-(\d+)$/;function P(e=window.location.hash){const t=e.replace(/^#/,"").match(ye);return t?{gallery:t[1],index:Math.max(0,parseInt(t[2],10)-1)}:null}function lt(e,t){return`${e}-${t+1}`}class ve{constructor(t,s){this.glare=t,this.gallery=s,this.pushed=!1,this.off=h(window,"hashchange",()=>this.onHashChange());const i=lt(s,t.currIndex);ct()!==i&&(window.history.pushState(null,"",`#${i}`),this.pushed=!0)}update(t=this.glare.currIndex){const s=lt(this.gallery,t);ct()!==s&&this.replace(`#${s}`)}destroy(){this.off(),P()?.gallery===this.gallery&&(this.pushed?window.history.back():this.replace(""))}onHashChange(){const t=P();!t||t.gallery!==this.gallery?(this.pushed=!1,this.glare.close()):t.index!==this.glare.currIndex&&this.glare.jumpTo(t.index)}replace(t){const{pathname:s,search:i}=window.location;window.history.replaceState(null,"",`${s}${i}${t}`)}}const ct=()=>window.location.hash.replace(/^#/,"");class xe{constructor(t,s,i){this.glare=t,this.container=s,this.opts=i,this.timer=null,this.active=!1,this.bar=c(".glare-progress",s),this.button=c("[data-glare-slideshow]",s),i.autoStart&&this.start()}isActive(){return this.active}start(){this.glare.group.length<2||(this.active=!0,this.container.classList.add("glare-is-slideshow"),this.syncButton(),this.schedule())}stop(){this.active=!1,this.clearTimer(),this.setProgress(0,!0),this.container.classList.remove("glare-is-slideshow"),this.syncButton()}toggle(){this.active?this.stop():this.start()}onIndexChange(){this.active&&this.schedule()}destroy(){this.stop()}get speed(){return this.opts.speed??A.speed}get atEnd(){return!this.glare.opts.loop&&this.glare.currIndex===this.glare.group.length-1}schedule(){this.clearTimer(),this.setProgress(0),Q()||(this.bar?.offsetWidth,this.setProgress(1)),this.timer=setTimeout(()=>this.atEnd?this.stop():this.glare.next(),this.speed)}clearTimer(){this.timer&&clearTimeout(this.timer),this.timer=null}setProgress(t,s=!1){this.bar&&(this.bar.hidden=s,this.bar.style.transitionDuration=t?`${this.speed}ms`:"0ms",this.bar.style.transform=`scaleX(${t})`)}syncButton(){if(!this.button)return;const{dict:t}=this.glare;k(this.button,this.active,this.active?t.PLAY_STOP:t.PLAY_START,this.active?u.pause:u.play)}}class we{constructor(t,s,i){this.glare=t,this.container=s,this.opts=i,this.isActive=!1,this.offs=[],this.axis=i.axis==="y"?"y":"x",this.list=m("div","glare-thumbs-list"),this.strip=m("div",`glare-thumbs glare-thumbs--${this.axis}`),this.strip.style.setProperty("--glare-thumbs-fit",i.fit??"cover"),this.strip.appendChild(this.list),this.build()}show(){this.setActive(!0)}hide(){this.setActive(!1)}toggle(){this.setActive(!this.isActive)}focus(t=this.glare.currIndex){for(const s of C(".glare-thumbs-item",this.list))s.classList.toggle("glare-is-active",Number(s.dataset.index)===t);this.list.querySelector(".glare-is-active")?.scrollIntoView({block:"nearest",inline:"nearest",behavior:"smooth"})}destroy(){this.offs.forEach(t=>t()),this.offs=[],this.container.classList.remove(`glare-thumbs-axis-${this.axis}`),this.strip.remove()}setActive(t){this.isActive=t,this.strip.classList.toggle("glare-thumbs--active",t),this.container.classList.toggle("glare-show-thumbs",t);const s=c("[data-glare-thumbs]",this.container);s?.classList.toggle("glare-is-active",t),s?.setAttribute("aria-expanded",String(t))}build(){const{group:t,dict:s}=this.glare;if(t.length<2)return;this.container.classList.add(`glare-thumbs-axis-${this.axis}`);for(const n of t){const o=m("button","glare-thumbs-item");o.type="button",o.dataset.index=String(n.index),o.setAttribute("aria-label",g(s.GO_TO_SLIDE,{index:String(n.index+1)}));const r=n.thumb||(n.type==="image"?n.src:"");if(r){const a=m("img");a.src=r,a.alt=n.alt||D(n.caption),a.loading="lazy",o.appendChild(a)}else o.textContent=String(n.index+1);this.list.appendChild(o),this.offs.push(h(o,"click",()=>this.glare.jumpTo(n.index)))}(V(this.opts.parentEl,this.container)??this.container).appendChild(this.strip),this.opts.autoStart&&this.show(),this.focus()}}const Ee=40,Te=150,Se=16;class Le{constructor(t,s){this.distance=0,this.fired=!1,this.settle=null,this.off=h(t,"wheel",i=>{const n=s.current();!n||i.deltaY===0||s.mode==="auto"&&n.type!=="image"||n.type==="image"&&s.isZoomed()||(i.preventDefault(),this.restartSettle(),!this.fired&&(this.distance+=Me(i,t),!(Math.abs(this.distance)<Ee)&&(this.fired=!0,this.distance>0?s.next():s.prev())))},{passive:!1})}destroy(){this.settle&&clearTimeout(this.settle),this.off()}restartSettle(){this.settle&&clearTimeout(this.settle),this.settle=setTimeout(()=>{this.distance=0,this.fired=!1},Te)}}function Me(e,t){return e.deltaMode===WheelEvent.DOM_DELTA_LINE?e.deltaY*Se:e.deltaMode===WheelEvent.DOM_DELTA_PAGE?e.deltaY*t.clientHeight:e.deltaY}function $(e){const t=Q(),s=t||!e.animationEffect?0:Math.max(0,e.animationDuration),i=t||!e.transitionEffect?0:Math.max(0,e.transitionDuration);return{animationEffect:s?e.animationEffect:!1,animationDuration:s,transitionEffect:i?e.transitionEffect:!1,transitionDuration:i}}function Ce(e,t){const s=$(t);e.dataset.animation=s.animationEffect||"none",e.style.setProperty("--glare-duration",`${s.animationDuration}ms`),e.style.setProperty("--glare-transition-duration",`${s.transitionDuration}ms`)}function $e(e,t){e.dataset.transition=$(t).transitionEffect||"none"}const Oe=/^(top|center|bottom)-(left|center|right)$/,ht={top:0,left:0,center:.5,bottom:1,right:1};function Ie(e,t,s){const i=typeof s=="string"?Oe.exec(s):null;if(i){const r=e.getBoundingClientRect(),a=r.left+r.width*ht[i[2]],l=r.top+r.height*ht[i[1]];return new DOMRect(a,l,0,0)}const n=r=>r?.getClientRects().length?r:null,o=s!=="trigger"&&n(V(s))||n(t.$trigger);return o?o.getBoundingClientRect():null}function Ae(e,t,s){const i=t.$image;if(e.dataset.animation!=="zoom"||!i)return;const n=Ie(e,t,s.anchor);if(!n)return;const o=i.getBoundingClientRect(),r=Math.max(n.width/Math.max(o.width,1),n.height/Math.max(o.height,1)),a=n.left+n.width/2-(o.left+o.width/2),l=n.top+n.height/2-(o.top+o.height/2);Object.assign(i.style,{transform:`translate3d(${a}px, ${l}px, 0) scale(${r})`,opacity:s.zoomOpacity?"0.2":"1",transitionDuration:"0ms"}),K(()=>{Object.assign(i.style,{transform:"",opacity:"",transitionDuration:""})})}function ut(e){const t=R(X,e);return _t()&&t.mobile?R(t,t.mobile):t}function z(e,t){return e?e===!0?{...t}:{...t,...e}:null}const O=[],_=e=>e.getAttribute("data-glare")??"";function De(e){return typeof e=="string"?C(e):e instanceof HTMLElement?[e]:Array.from(e)}function ke(e,t,s){const i=De(e),n=a=>{const l=_(a),d=l?i.filter(T=>_(T)===l):[a];s(d,d.indexOf(a),l)},o=i.map(a=>h(a,"click",l=>{l.preventDefault(),n(a)})),r={elements:i,destroy(){o.forEach(l=>l());const a=O.indexOf(r);a>=0&&O.splice(a,1)}};return O.push(r),ut(t).hash&&Fe(i,n),r}function Re(){for(const e of[...O])e.destroy()}function Fe(e,t){const s=P();if(!s)return;const n=e.filter(o=>_(o)===s.gallery)[s.index];n&&t(n)}class He{constructor(t,s){this.seconds=t,this.onIdle=s,this.timer=null}reset(){this.stop(),this.seconds&&(this.timer=setTimeout(this.onIdle,this.seconds*1e3))}stop(){this.timer&&clearTimeout(this.timer),this.timer=null}}const x=[],b={add(e){x.push(e)},remove(e){const t=x.indexOf(e);t>=0&&x.splice(t,1)},top(){return x[x.length-1]??null},get(e){return x.find(t=>t.id===e)??null},all(){return[...x]},get size(){return x.length}},Pe=[["[data-glare-close]",e=>e.close()],["[data-glare-next]",e=>e.next()],["[data-glare-prev]",e=>e.prev()],["[data-glare-zoom]",e=>e.toggleZoom()],["[data-glare-slideshow]",e=>e.slideshow?.toggle()],["[data-glare-thumbs]",e=>e.thumbs?.toggle()],["[data-glare-fullscreen]",e=>e.fullscreen?.toggle()]],ze=".glare-content",_e=".glare-slide, .glare-stage",Ne='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])',Ze=new Set(["INPUT","TEXTAREA","SELECT"]),je=300;function qe(e,t,s){let i=null;const n=()=>{i&&clearTimeout(i),i=null},o=[h(t,"click",r=>{if(e.consumeGesture())return;const a=r.target,l=a.closest("[data-glare-more]");if(l){const I=l.closest(".glare-toolbar"),yt=!I?.classList.contains("glare-toolbar--expanded");I?.classList.toggle("glare-toolbar--expanded",yt),l.setAttribute("aria-expanded",String(yt));return}ft(t);const d=a.closest("[data-glare-custom]");if(d)return Be(e,d.dataset.glareCustom,r);const T=Pe.find(([I])=>a.closest(I));if(T)return T[1](e);if(a.closest(".glare-button"))return;const q=N(e,a,"click");if(q){if(!dt(e,N(e,a,"dblclick"),r))return Z(e,q,r);n(),i=setTimeout(()=>Z(e,q,r),je)}}),h(t,"dblclick",r=>{n();const a=r.target;a.closest(".glare-button")||Z(e,N(e,a,"dblclick"),r)}),h(document,"keydown",r=>We(e,r)),h(document,"keydown",s),h(document,"click",s,{capture:!0}),h(document,"mousemove",s),h(document,"touchstart",s,{passive:!0})];return e.opts.trapFocus&&o.push(h(t,"keydown",r=>Ue(t,r))),e.opts.protect&&o.push(h(t,"contextmenu",r=>r.preventDefault()),h(t,"dragstart",r=>{r.target.tagName==="IMG"&&r.preventDefault()})),()=>{n(),o.forEach(r=>r())}}function Be(e,t,s){const i=e.opts.buttons.find(n=>typeof n!="string"&&n.name===t);i&&e.current&&i.click(e,e.current,s)}function N(e,t,s){const{opts:i}=e;if(t.closest(ze))return s==="click"?i.clickContent:i.dblclickContent;if(!(i.modal||!t.closest(_e)))return s==="click"?i.clickSlide:i.dblclickSlide}function dt(e,t,s){return!t||!e.current?!1:typeof t=="function"?t(e.current,s):t}function Z(e,t,s){switch(dt(e,t,s)){case"close":return e.close();case"next":return e.next();case"nextOrClose":return e.currIndex===e.group.length-1&&!e.opts.loop?e.close():e.next();case"toggleControls":return e.toggleControls();case"zoom":{const i=s instanceof MouseEvent?{x:s.clientX,y:s.clientY}:void 0;return e.toggleZoom(i)}}}function We(e,t){if(b.top()!==e)return;if(t.key==="Escape"&&ft(e.$refs?.container??null)){t.preventDefault();return}if(!e.opts.keyboard||e.opts.modal)return;const s=t.target;if(!Ze.has(s.tagName)&&!(t.key===" "&&s.closest("button")))switch(t.key){case"Escape":return t.preventDefault(),e.close();case"ArrowRight":case"ArrowDown":return t.preventDefault(),e.next();case"ArrowLeft":case"ArrowUp":return t.preventDefault(),e.prev();case" ":return t.preventDefault(),e.slideshow?.toggle();case"f":case"F":return e.fullscreen?.toggle()}}function ft(e){const t=e?.querySelector(".glare-toolbar--expanded");return t?(t.classList.remove("glare-toolbar--expanded"),t.querySelector("[data-glare-more]")?.setAttribute("aria-expanded","false"),!0):!1}function Ue(e,t){if(t.key!=="Tab")return;const s=C(Ne,e).filter(o=>!o.hasAttribute("disabled")&&o.offsetParent!==null&&getComputedStyle(o).visibility!=="hidden");if(!s.length)return;const i=s[0],n=s[s.length-1];t.shiftKey&&document.activeElement===i?(t.preventDefault(),n.focus()):!t.shiftKey&&document.activeElement===n&&(t.preventDefault(),i.focus())}const Xe=1200,pt=16/9;function Ge(e,t,s){if(t&&s)return t/s;const i=String(e.ratio||pt).replace(":","/"),[n,o="1"]=i.split("/").map(l=>l.trim()),r=parseFloat(n),a=parseFloat(o);return r>0&&a>0?r/a:pt}function mt(e,t,s){if(!e)return 0;if(typeof e=="number")return e;const i=e.trim(),n=parseFloat(i);return n>0?i.endsWith("%")?t*n/100:i.endsWith("vw")||i.endsWith("vh")?s*n/100:n:0}function gt(e,t){const s=t.parentElement;if(!s)return;const i=getComputedStyle(s),n=s.clientWidth-parseFloat(i.paddingLeft)-parseFloat(i.paddingRight),o=s.clientHeight-parseFloat(i.paddingTop)-parseFloat(i.paddingBottom);if(!(n>0&&o>0))return;const r=e.width!==void 0&&e.height!==void 0;let a=r?mt(e.width,n,innerWidth):n,l=r?mt(e.height,o,innerHeight):o;const d=Ge(e,r?a:void 0,r?l:void 0),T=Math.min(1,n/a,o/l);a*=T,l*=T,l>a/d?l=a/d:a>l*d&&(a=l*d),t.style.width=`${a}px`,t.style.height=`${l}px`,t.style.aspectRatio=String(d)}function Ve(e,t){if(gt(e,t),typeof ResizeObserver>"u"||!t.parentElement)return;const s=new ResizeObserver(()=>{if(!t.isConnected)return s.disconnect();gt(e,t)});s.observe(t.parentElement)}const Ye=(e,t,s)=>new Promise((i,n)=>{const o=m("img","glare-image");o.alt=e.alt||D(e.caption),o.decoding="async",o.draggable=!1,s.protect&&(o.style.pointerEvents="none"),o.onload=()=>{e.$image=o,e.contentWidth=o.naturalWidth,e.contentHeight=o.naturalHeight,t.appendChild(o),i()},o.onerror=()=>n(new Error(`Failed to load image: ${e.src}`)),o.src=e.src}),Ke=(e,t,s,i)=>{const n=e.format||s.video.format||Rt(e.src);t.innerHTML=g(s.video.tpl,{...i,src:e.src,format:n,poster:e.poster??""});const o=t.querySelector("video");o&&(e.autoStart??s.video.autoStart)&&o.play().catch(()=>{})},bt=(e,t,s)=>new Promise(i=>{const n=s.iframe,o=m("div","glare-iframe-wrap",n.tpl),r=o.querySelector("iframe");if(!r)throw new Error("Iframe template must contain an <iframe>");for(const[a,l]of Object.entries(n.attr))r.setAttribute(a,l);if(Object.assign(r.style,n.css),t.appendChild(o),e.type==="embed"?Ve(e,t):(e.width&&(o.style.width=Y(e.width)),e.height&&(o.style.height=Y(e.height))),!n.preload){r.src=e.src,i();return}r.onload=()=>i(),r.src=e.src,setTimeout(i,Xe)}),Qe={image:Ye,video:Ke,embed:bt,iframe:bt,inline:(e,t)=>{const s=e.src?c(e.src):null;if(!s)throw new Error(`Inline target not found: ${e.src}`);const i=s.cloneNode(!0);i.removeAttribute("id"),i.hidden=!1,i.style.display="",t.appendChild(i)},ajax:async(e,t,s)=>{const i=await fetch(e.src,s.ajax.settings);if(!i.ok)throw new Error(`Request failed: ${i.status} ${e.src}`);t.innerHTML=await i.text()},html:(e,t)=>{e.content instanceof HTMLElement?t.appendChild(e.content):t.innerHTML=e.html??e.content??e.src}};async function Je(e,t,s,i){t.innerHTML="",t.className=`glare-content glare-content--${e.type}`,await Qe[e.type](e,t,s,i),e.isLoaded=!0}function ts(e,t){for(const s of[e[t-1],e[t+1]])s?.type==="image"&&s.src&&(new Image().src=s.src)}let es=0;const w=class w{constructor(t,s={},i=0,n=""){this.id=++es,this.current=null,this.currIndex=0,this.prevIndex=0,this.isActive=!1,this.isClosing=!1,this.isIdle=!1,this.$refs=null,this.hash=null,this.gestures=null,this.wheel=null,this.cleanups=[],this.captionTracker=null,this.previouslyFocused=null,this.direction=1,this.opts=ut(s),this.dict=M(this.opts),this.group=Ht(t,this.opts),this.galleryName=n,this.currIndex=this.clampIndex(i),this.zoom=new he({image:()=>this.current?.$image??null,stage:()=>this.$refs?.stage??null,onChange:o=>this.syncZoomState(o)}),this.idle=new He(this.opts.modal?!1:this.opts.idleTime,()=>this.toggleControls(!0))}open(t=this.currIndex){if(this.isActive)return this.jumpTo(t);if(!this.group.length)return;this.opts.closeExisting&&w.close(!0),this.currIndex=this.clampIndex(t),this.current=this.group[this.currIndex],this.previouslyFocused=document.activeElement instanceof HTMLElement?document.activeElement:null,this.emit("onInit");const s=Nt(this.opts,this.dict,this.id,this.group.length),{container:i}=s;this.$refs=s,Ce(i,this.opts),this.syncChrome(),this.resolveParent().appendChild(i),this.captionTracker=Bt(s),this.cleanups.push(()=>this.captionTracker?.destroy()),this.isActive=!0,b.add(this),this.opts.hideScrollbar&&et(!0),this.emit("onActivate"),this.emitSlide("beforeShow",this.current),K(()=>{this.isActive&&(i.classList.add("glare-is-open"),this.showSlide(this.currIndex,!0),this.cleanups.push(qe(this,i,()=>this.onActivity())),this.startModules(s),this.opts.autoFocus&&this.focus(),this.idle.reset())})}close(){if(!this.isActive||this.isClosing||!this.current||!this.$refs||this.emitSlide("beforeClose",this.current)===!1)return;this.isClosing=!0,this.slideshow?.stop(),this.idle.stop();const{container:t,bg:s}=this.$refs,i=$(this.opts).animationDuration;if(i===0)return this.teardown();t.classList.remove("glare-is-open"),t.classList.add("glare-is-closing"),zt(s??t,i,()=>this.teardown())}next(){this.jumpTo(this.currIndex+1)}prev(){this.jumpTo(this.currIndex-1)}jumpTo(t){if(!this.isActive||this.isClosing)return;const s=this.group.length,i=this.opts.loop?(t%s+s)%s:v(t,0,s-1);i!==this.currIndex&&(this.direction=t>this.currIndex?1:-1,this.prevIndex=this.currIndex,this.currIndex=i,this.zoom.reset(),this.current=this.group[i],this.syncChrome(),this.showSlide(i,!1),this.thumbs?.focus(i),this.hash?.update(i),this.slideshow?.onIndexChange(),this.emitSlide("onUpdate",this.current))}toggleZoom(t){this.current?.type==="image"&&(this.zoom.isZoomed?this.zoom.toFit():this.zoom.toActual(t))}update(){this.syncChrome()}focus(){this.$refs?.container.focus({preventScroll:!0})}toggleControls(t){this.$refs&&(this.isIdle=t??!this.isIdle,this.$refs.container.classList.toggle("glare-is-idle",this.isIdle))}consumeGesture(){return this.gestures?.consumeMoved()??!1}async showSlide(t,s){const i=this.group[t];if(!this.$refs||!i)return;const{container:n,stage:o}=this.$refs,r=Wt(o,i,this.opts);Qt(this.opts,i)&&Gt(r,this.opts,this.dict),Vt(o,this.opts,this.dict),this.emitSlide("beforeLoad",i),this.opts.image.preload&&ts(this.group,t);let a=!1;try{await Je(i,i.$content,this.opts,this.dict)}catch(l){a=!0,Kt(i,l,this.opts,this.dict),this.emitSlide("onError",i),this.opts.onError||console.warn("[glare]",l)}if(!this.isActive||this.currIndex!==t)return r.remove();a||this.emitSlide("afterLoad",i),Yt(o),s||$e(n,this.opts),Ut(r,s,this.direction),this.captionTracker?.follow(r),Xt(o,r,$(this.opts).transitionDuration,this.direction),this.syncZoomState(this.zoom.isZoomed),!a&&(s&&Ae(n,i,this.opts),this.emitSlide("afterShow",i))}syncChrome(){!this.$refs||!this.current||(Jt(this.$refs,this.opts,this.dict,this.current,this.group.length,this.captionFor(this.current)),this.syncZoomState(this.zoom.isZoomed))}captionFor(t){const{caption:s}=this.opts;return typeof s=="function"?s(this,t):s??t.caption}syncZoomState(t){this.$refs&&ae(this.$refs.container,this.dict,t,!!this.current?.$image)}resolveParent(){const{parentEl:t}=this.opts;return(typeof t=="string"?document.querySelector(t):t)??document.body}startModules({container:t,stage:s,bg:i}){const n=this.opts,o=z(n.thumbs,W);o&&(this.thumbs=new we(this,t,o));const r=z(n.slideshow,A);r&&(this.slideshow=new xe(this,t,r));const a=z(n.fullscreen,U);a&&J()&&(this.fullscreen=new le(this,t,a)),n.hash&&this.galleryName&&(this.hash=new ve(this,this.galleryName)),n.wheel&&(this.wheel=new Le(s,{mode:n.wheel,current:()=>this.current,isZoomed:()=>this.zoom.isZoomed,next:()=>this.next(),prev:()=>this.prev()})),n.touch&&(this.gestures=new be(s,{zoom:this.zoom,touch:n.touch,bg:i,canPan:()=>this.current?.type==="image",close:()=>this.close(),next:()=>this.next(),prev:()=>this.prev()}))}onActivity(){this.isIdle&&this.toggleControls(!1),this.idle.reset()}teardown(){for(const t of[this.gestures,this.wheel,this.hash,this.thumbs,this.slideshow,this.fullscreen])t?.destroy();this.gestures=this.wheel=this.hash=null,this.thumbs=this.slideshow=this.fullscreen=void 0,this.cleanups.forEach(t=>t()),this.cleanups=[],this.$refs?.container.remove(),this.$refs=null,b.remove(this),this.opts.hideScrollbar&&b.size===0&&et(!1),this.opts.backFocus&&(this.current?.$trigger??this.previouslyFocused)?.focus({preventScroll:!0}),this.isActive=!1,this.isClosing=!1,this.current&&this.emitSlide("afterClose",this.current)}emit(t){return this.opts[t]?.(this)}emitSlide(t,s){return this.opts[t]?.(this,s)}clampIndex(t){return v(t,0,Math.max(0,this.group.length-1))}static open(t,s={},i=0){const n=new w(t,s,i);return n.open(),n}static bind(t,s={}){return ke(t,s,(i,n,o)=>{new w(i,s,n,o).open()})}static close(t=!1){t?b.all().reverse().forEach(s=>s.close()):b.top()?.close()}static getInstance(t){return t==null?b.top():b.get(t)}static getInstances(){return b.all()}static destroy(){w.close(!0),Re()}static autoBind(t={}){const s=()=>w.bind("[data-glare]",t);document.readyState==="loading"?document.addEventListener("DOMContentLoaded",s,{once:!0}):s()}};w.defaults=X;let j=w;return j}));
|
|
30
17
|
//# sourceMappingURL=glare.js.map
|