@redot-src/glare 1.1.0 → 1.2.1
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 +1 -1
- package/dist/glare.css +1 -1
- package/dist/glare.esm.js +460 -398
- package/dist/glare.esm.js.map +1 -1
- package/dist/glare.js +3 -3
- package/dist/glare.js.map +1 -1
- package/dist/icons.d.ts +1 -0
- package/dist/types.d.ts +5 -2
- package/package.json +1 -1
package/dist/glare.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(S,C){typeof exports=="object"&&typeof module<"u"?module.exports=C():typeof define=="function"&&define.amd?define(C):(S=typeof globalThis<"u"?globalThis:S||self,S.Glare=C())})(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",SHARE:"Share",MORE:"More options",COPY:"Copy link",ZOOM:"Zoom",ZOOM_OUT:"Zoom out"};function C(e){const t=e.lang??"en";return{...S,...e.i18n?.en,...e.i18n?.[t]}}function y(e,t){return e.replace(/\{\{(\w+)\}\}/g,(s,i)=>t[i]??"")}function mt(e){return Object.entries(e).map(([t,s])=>`${encodeURIComponent(t)}=${encodeURIComponent(String(s))}`).join("&")}function gt(e,t){return e.replace(/\$(\d+)/g,(s,i)=>t[Number(i)]??"")}const yt={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,r]=e;if(s){const[n,a,l]=s.split(","),d=l?Math.floor(parseFloat(l)):14;return`https://maps.google.${t}/maps?ll=${n},${a}&z=${d}&output=embed`}const o=encodeURIComponent(decodeURIComponent(i||r||""));return`https://maps.google.${t}/maps?q=${o}&output=embed`}}};function U(e,t,s){if(typeof e=="function")return e(t,s);if(typeof e=="string")return gt(e,t)}function bt(e,t){for(const s of Object.values(t??{})){const i=e.match(s.matcher);if(!i)continue;let r=U(s.url,i,e)??e;return s.params&&(r+=(r.includes("?")?"&":"?")+mt(s.params)),{src:r,type:s.type??"iframe",thumb:U(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"/>'),share:f('<circle cx="18" cy="5" r="3"/><circle cx="6" cy="12" r="3"/><circle cx="18" cy="19" r="3"/><line x1="8.59" x2="15.42" y1="13.51" y2="17.49"/><line x1="15.41" x2="8.59" y1="6.51" y2="10.49"/>'),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"/>')},b=(e,t,s,i="")=>`<button type="button" class="glare-button glare-button--${e}" data-glare-${e} title="{{${t}}}" aria-label="{{${t}}}"${i}>${s}</button>`,vt=`
|
|
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>
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
<div class="glare-stage"></div>
|
|
14
14
|
<div class="glare-caption"></div>
|
|
15
15
|
</div>
|
|
16
|
-
</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
17
|
<div class="glare-share" role="dialog" aria-label="{{SHARE}}">
|
|
18
18
|
<div class="glare-share-head">
|
|
19
19
|
<h4 class="glare-share-title">{{SHARE}}</h4>
|
|
@@ -26,5 +26,5 @@
|
|
|
26
26
|
<input class="glare-share-input" type="text" value="{{url_direct}}" readonly />
|
|
27
27
|
<button type="button" class="glare-share-copy" data-glare-share-copy>{{COPY}}</button>
|
|
28
28
|
</div>
|
|
29
|
-
</div>`,j={autoStart:!1,axis:"x"},D={autoStart:!1,speed:3e3},q={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:gt,format:"",autoStart:!0},iframe:{preload:!0,css:{},attr:{allowfullscreen:"true",allow:"autoplay; fullscreen; picture-in-picture"},tpl:yt},ajax:{settings:{headers:{"X-Requested-With":"XMLHttpRequest"}}},media:ht,hash:!0,slideshow:D,thumbs:j,fullscreen:q,share:!0,lang:"en",i18n:{en:T},baseTpl:dt,btnTpl:ft,spinnerTpl:pt,errorTpl:mt},vt=/\.(avif|bmp|gif|jpe?g|png|svg|webp|ico)(\?.*)?$/i,wt=/\.(mp4|webm|ogg|ogv|mov|m4v)(\?.*)?$/i,xt=/\.pdf(\?.*)?$/i,Et=/^(#[\w-]+|\.[\w-]+)$/;function St(e,t="image"){return e?Et.test(e)?"inline":vt.test(e)?"image":wt.test(e)?"video":xt.test(e)?"iframe":t:"html"}function Tt(e){const t=e.match(/\.(\w+)(?:\?|$)/)?.[1]?.toLowerCase();return t?`video/${t==="ogv"?"ogg":t}`:"video/mp4"}function W(e,t,s){const i=typeof e=="string"?{src:e}:{...e};let o=i.src??"",n=i.type,r=i.thumb;const a=o?ut(o,s.media):null;return a&&(o=a.src??o,n??=a.type,r??=a.thumb),n||(n=i.html||i.content?"html":St(o,s.defaultType)),{...i,index:t,src:o,type:n,thumb:r,caption:i.caption??i.title??"",isLoaded:!1,hasError:!1}}const p=(e,t)=>e.getAttribute(t)||void 0;function Lt(e,t){return e.map((s,i)=>{const o=s.querySelector("img"),n=p(s,"data-caption")??p(s,"title")??"";return W({src:p(s,"data-src")??p(s,"href")??"",type:p(s,"data-type"),caption:n,alt:o?.getAttribute("alt")||n,thumb:p(s,"data-thumb")??o?.getAttribute("src")??void 0,width:p(s,"data-width"),height:p(s,"data-height"),poster:p(s,"data-poster"),downloadSrc:p(s,"data-download-src"),html:p(s,"data-html"),$trigger:s},i,t)})}function Ct(e,t){return e.length&&e[0]instanceof HTMLElement?Lt(e,t):e.map((s,i)=>W(s,i,t))}function c(e,t=document){return t.querySelector(e)}function $(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 $t(e){return m("div","",e.trim()).firstElementChild}function M(e){return/[<&]/.test(e)?new DOMParser().parseFromString(e,"text/html").body.textContent?.trim()??"":e.trim()}function Mt(e,t=document){return e?typeof e!="string"?e:c(e,t)??c(e):null}function X(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 Y(e){requestAnimationFrame(()=>requestAnimationFrame(e))}function Ot(e,t,s){let i=!1;const o=()=>{i||(i=!0,clearTimeout(r),e.removeEventListener("transitionend",n),s())},n=a=>{a.target===e&&o()};e.addEventListener("transitionend",n);const r=setTimeout(o,t+50)}function It(){return navigator.maxTouchPoints>0&&window.matchMedia("(pointer: coarse)").matches}function O(){return window.matchMedia("(prefers-reduced-motion: reduce)").matches}function G(){const e=document;return!!(e.fullscreenEnabled??e.webkitFullscreenEnabled)}const V="glare-lock";function K(e){const t=document.documentElement;if(e){const s=window.innerWidth-t.clientWidth;t.classList.add(V),s>0&&(t.style.marginRight=`${s}px`)}else t.classList.remove(V),t.style.marginRight=""}const E="glare-hidden";function At(e,t,s,i){const o=$t(y(e.baseTpl,t));o.dataset.glareId=String(s),e.baseClass&&o.classList.add(e.baseClass),e.modal&&o.classList.add("glare-is-modal");const n=c(".glare-stage",o);if(!n)throw new Error("baseTpl must contain a .glare-stage element");const r={container:o,bg:c(".glare-bg",o),inner:c(".glare-inner",o),stage:n,caption:c(".glare-caption",o),toolbar:c(".glare-toolbar",o),infobar:c(".glare-infobar",o),navigation:c(".glare-navigation",o)},a=i<2;return r.navigation?.classList.toggle(E,!e.arrows||a),r.infobar?.classList.toggle(E,!e.infobar||a),r.toolbar&&Dt(r.toolbar,e,t,a),r}function Dt(e,t,s,i){if(t.toolbar===!1){e.classList.add(E);return}for(const o of t.buttons){if(i&&(o==="thumbs"||o==="slideshow")||o==="fullscreen"&&!G())continue;const n=t.btnTpl[o];n&&e.insertAdjacentHTML("beforeend",y(n,s))}}function kt(e,t,s){const i=m("div",`glare-slide glare-slide--${t.type}`);s.slideClass&&i.classList.add(s.slideClass);const o=m("div","glare-content");return i.appendChild(o),e.appendChild(i),t.$slide=i,t.$content=o,i}function _t(e,t){t&&(e.style.transition="none"),e.offsetWidth,e.classList.add("glare-slide--current"),t&&(e.offsetWidth,e.style.transition="")}function Ht(e,t,s){for(const i of $(".glare-slide",e))i!==t&&(i.classList.remove("glare-slide--current"),i.classList.add("glare-slide--out"),setTimeout(()=>i.remove(),s))}function Rt(e,t,s){e.insertAdjacentHTML("beforeend",y(t.btnTpl.smallBtn??"",s))}function Ft(e,t,s){e.querySelector(":scope > .glare-spinner")||e.insertAdjacentHTML("beforeend",y(t.spinnerTpl,s))}function Pt(e){e.querySelector(":scope > .glare-spinner")?.remove()}function zt(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 Q(e,t){return typeof e.toolbar=="boolean"?e.toolbar:t.type==="image"}function Nt(e,t){return typeof e.smallBtn=="boolean"?e.smallBtn:!Q(e,t)}function Zt(e,t,s,i,o,n){const{container:r,toolbar:a,infobar:l}=e;Yt(r,i.type),a&&Ut(a,t,i),jt(r,i),l&&qt(l,i.index,o),e.caption&&Bt(e.caption,n),Wt(r,t,i.index,o),Xt(r,s,i,o)}function Ut(e,t,s){if(t.toolbar===!1)return;const i=Q(t,s);if(e.classList.toggle(E,!i),!i)return;const o=s.type==="image";c("[data-glare-zoom]",e)?.classList.toggle(E,!o)}function jt(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 qt(e,t,s){const i=c(".glare-infobar-index",e);i&&(i.textContent=`${t+1} / ${s}`)}function Bt(e,t){e.innerHTML=t,e.classList.toggle(E,!t)}function Wt(e,t,s,i){const o=!t.loop&&s===0,n=!t.loop&&s===i-1;J(c("[data-glare-prev]",e),o),J(c("[data-glare-next]",e),n)}function J(e,t){e&&(e.classList.toggle("glare-is-disabled",t),e.setAttribute("aria-disabled",String(t)))}function Xt(e,t,s,i){const o=M(s.caption)||s.alt||t.LIGHTBOX,n=i>1?`${o} (${s.index+1} of ${i})`:o;e.setAttribute("aria-label",n);const r=c(".glare-live",e);r&&(r.textContent=n)}function Yt(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 Gt(e,t,s,i){e.classList.toggle("glare-can-zoom-out",s),e.classList.toggle("glare-can-zoom-in",!s&&i);const o=c("[data-glare-zoom]",e),n=s?"out":"in";!o||o.dataset.state===n||(o.dataset.state=n,k(o,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 Vt{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 tt(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,o]of Object.entries(s)){if(o===void 0)continue;const n=t[i];t[i]=tt(o)?_(tt(n)?n:{},o):o}return t}function v(e,t,s){return Math.min(s,Math.max(t,e))}const L=1,H=5,Kt=1.01;class Qt{constructor(t){this.target=t,this.scale=L,this.x=0,this.y=0}get isZoomed(){return this.scale>Kt}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,o=0){const n=this.target.image();if(!n)return;this.scale=v(t,L,H);const r=this.isZoomed?this.bounded(s,i):{x:0,y:0};this.x=r.x,this.y=r.y,n.style.transitionDuration=`${o}ms`,n.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(),o=this.center();if(!i||!o)return;const n=i.naturalWidth/Math.max(i.offsetWidth,1),r=v(Math.max(n,1.5),L,H),a=t?.x??o.x,l=t?.y??o.y;this.apply(r,(o.x-a)*(r-1),(o.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(),o=this.target.stage();if(!i||!o)return{x:t,y:s};const n=Math.max(0,(i.offsetWidth*this.scale-o.clientWidth)/2),r=Math.max(0,(i.offsetHeight*this.scale-o.clientHeight)/2);return{x:v(t,-n,n),y:v(s,-r,r)}}}const Jt=6,et=120,te=100,ee=.5,se=80,ie=.4,oe="a, button, input, textarea, select, video, .glare-thumbs",st=(e,t)=>Math.hypot(e.x-t.x,e.y-t.y),it=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),R=e=>({x:e.clientX,y:e.clientY});class ne{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(oe)||(this.pointers.set(t.pointerId,R(t)),this.pointers.size<=2&&this.begin())}onMove(t){this.pointers.has(t.pointerId)&&(this.pointers.set(t.pointerId,R(t)),this.move(t))}onUp(t){this.pointers.has(t.pointerId)&&(this.pointers.delete(t.pointerId),this.pointers.size===0?this.end(R(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=st(t[0],t[1]),this.startMid=it(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,o=s[0].y-this.start[0].y;if(!(!this.moved&&Math.hypot(i,o)<Jt)){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+o);else if(this.mode==="swipe"){const n=this.host.touch.vertical!==!1;if(!n&&Math.abs(o)>Math.abs(i))return;t.preventDefault(),this.dragStage(i,n?o:0)}}}pinch(t,s){const{zoom:i}=this.host,o=it(t,s),n=i.center()??o,r=v(this.startZoom.scale*st(t,s)/(this.startDistance||1),L,H),a=(this.startMid.x-n.x-this.startZoom.x)/this.startZoom.scale,l=(this.startMid.y-n.y-this.startZoom.y)/this.startZoom.scale;i.apply(r,o.x-n.x-r*a,o.y-n.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,o=t.y-this.start[0].y,n={x:i/s,y:o/s};if(this.mode==="swipe")this.releaseStage(),this.finishSwipe(i,o,n);else if(this.mode==="pan"&&this.host.touch.momentum!==!1){const{zoom:r}=this.host;r.apply(r.scale,r.x+n.x*et,r.y+n.y*et,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)>te||Math.abs(i.y)>ee)&&this.host.close();return}(Math.abs(t)>se||Math.abs(i.x)>ie)&&(t<0?this.host.next():this.host.prev())}}const re=/^(.+)-(\d+)$/;function F(e=window.location.hash){const t=e.replace(/^#/,"").match(re);return t?{gallery:t[1],index:Math.max(0,parseInt(t[2],10)-1)}:null}function ot(e,t){return`${e}-${t+1}`}class ae{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(),F()?.gallery===this.gallery&&(this.pushed?window.history.back():this.replace(""))}onHashChange(){const t=F();!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 le{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),o=encodeURIComponent(i),n=encodeURIComponent(t.thumb||t.src||i),r=encodeURIComponent(M(t.caption)),a=y(this.opts.tpl??bt,{...s,url_direct:i,url_facebook:`https://www.facebook.com/sharer/sharer.php?u=${o}`,url_twitter:`https://twitter.com/intent/tweet?url=${o}&text=${r}`,url_pinterest:`https://pinterest.com/pin/create/button/?url=${o}&media=${n}&description=${r}`});this.overlay=m("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",f=>{const S=f.target;S===this.overlay||S.closest("[data-glare-share-close]")?this.close():S.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 ce{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??D.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;k(this.button,this.active,this.active?t.PLAY_STOP:t.PLAY_START,this.active?u.pause:u.play)}}class he{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.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 $(".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 o of t){const n=m("button","glare-thumbs-item");n.type="button",n.dataset.index=String(o.index),n.setAttribute("aria-label",y(s.GO_TO_SLIDE,{index:String(o.index+1)}));const r=o.thumb||(o.type==="image"?o.src:"");if(r){const a=m("img");a.src=r,a.alt=o.alt||M(o.caption),a.loading="lazy",n.appendChild(a)}else n.textContent=String(o.index+1);this.list.appendChild(n),this.offs.push(h(n,"click",()=>this.glare.jumpTo(o.index)))}(Mt(this.opts.parentEl,this.container)??this.container).appendChild(this.strip),this.opts.autoStart&&this.show(),this.focus()}}const ue=40,de=150,fe=16;class pe{constructor(t,s){this.distance=0,this.fired=!1,this.settle=null,this.off=h(t,"wheel",i=>{const o=s.current();!o||i.deltaY===0||s.mode==="auto"&&o.type!=="image"||o.type==="image"&&s.isZoomed()||(i.preventDefault(),this.restartSettle(),!this.fired&&(this.distance+=me(i,t),!(Math.abs(this.distance)<ue)&&(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},de)}}function me(e,t){return e.deltaMode===WheelEvent.DOM_DELTA_LINE?e.deltaY*fe:e.deltaMode===WheelEvent.DOM_DELTA_PAGE?e.deltaY*t.clientHeight:e.deltaY}function ge(e,t){const s=O(),i=s?!1:t.animationEffect,o=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",`${o?t.transitionDuration:0}ms`)}function ye(e,t){const s=O()?!1:t.transitionEffect;e.dataset.transition=s||"none"}function be(e,t,s){const i=t.$image,o=t.$trigger;if(e.dataset.animation!=="zoom"||!i||!o)return;const n=o.getBoundingClientRect(),r=i.getBoundingClientRect(),a=Math.max(n.width/Math.max(r.width,1),n.height/Math.max(r.height,1)),l=n.left+n.width/2-(r.left+r.width/2),f=n.top+n.height/2-(r.top+r.height/2);Object.assign(i.style,{transform:`translate3d(${l}px, ${f}px, 0) scale(${a})`,opacity:s.zoomOpacity?"0.2":"1",transitionDuration:"0ms"}),Y(()=>{Object.assign(i.style,{transform:"",opacity:"",transitionDuration:""})})}function rt(e){const t=_(B,e);return It()&&t.mobile?_(t,t.mobile):t}function I(e,t){return e?e===!0?{...t}:{...t,...e}:null}const A=[],P=e=>e.getAttribute("data-glare")??"";function ve(e){return typeof e=="string"?$(e):e instanceof HTMLElement?[e]:Array.from(e)}function we(e,t,s){const i=ve(e),o=a=>{const l=P(a),f=l?i.filter(S=>P(S)===l):[a];s(f,f.indexOf(a),l)},n=i.map(a=>h(a,"click",l=>{l.preventDefault(),o(a)})),r={elements:i,destroy(){n.forEach(l=>l());const a=A.indexOf(r);a>=0&&A.splice(a,1)}};return A.push(r),rt(t).hash&&Ee(i,o),r}function xe(){for(const e of[...A])e.destroy()}function Ee(e,t){const s=F();if(!s)return;const o=e.filter(n=>P(n)===s.gallery)[s.index];o&&t(o)}class Se{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=[],g={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}},Te=[["[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()]],Le=".glare-content",Ce=".glare-slide, .glare-stage",$e='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])',Me=new Set(["INPUT","TEXTAREA","SELECT"]),Oe=300;function Ie(e,t,s){let i=null;const o=()=>{i&&clearTimeout(i),i=null},n=[h(t,"click",r=>{if(e.consumeGesture())return;const a=r.target,l=Te.find(([S])=>a.closest(S));if(l)return l[1](e);if(a.closest(".glare-button"))return;const f=z(e,a,"click");if(f){if(!at(e,z(e,a,"dblclick"),r))return N(e,f,r);o(),i=setTimeout(()=>N(e,f,r),Oe)}}),h(t,"dblclick",r=>{o();const a=r.target;a.closest(".glare-button")||N(e,z(e,a,"dblclick"),r)}),h(document,"keydown",r=>Ae(e,r)),h(document,"keydown",s),h(document,"mousemove",s),h(document,"touchstart",s,{passive:!0})];return e.opts.trapFocus&&n.push(h(t,"keydown",r=>De(t,r))),e.opts.protect&&n.push(h(t,"contextmenu",r=>r.preventDefault()),h(t,"dragstart",r=>{r.target.tagName==="IMG"&&r.preventDefault()})),()=>{o(),n.forEach(r=>r())}}function z(e,t,s){const{opts:i}=e;if(t.closest(Le))return s==="click"?i.clickContent:i.dblclickContent;if(!(i.modal||!t.closest(Ce)))return s==="click"?i.clickSlide:i.dblclickSlide}function at(e,t,s){return!t||!e.current?!1:typeof t=="function"?t(e.current,s):t}function N(e,t,s){switch(at(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 Ae(e,t){if(g.top()!==e)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(!Me.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 De(e,t){if(t.key!=="Tab")return;const s=$($e,e).filter(n=>!n.hasAttribute("disabled")&&n.offsetParent!==null&&getComputedStyle(n).visibility!=="hidden");if(!s.length)return;const i=s[0],o=s[s.length-1];t.shiftKey&&document.activeElement===i?(t.preventDefault(),o.focus()):!t.shiftKey&&document.activeElement===o&&(t.preventDefault(),i.focus())}const ke=1200,_e={image:(e,t,s)=>new Promise((i,o)=>{const n=m("img","glare-image");n.alt=e.alt||M(e.caption),n.decoding="async",n.draggable=!1,s.protect&&(n.style.pointerEvents="none"),n.onload=()=>{e.$image=n,e.contentWidth=n.naturalWidth,e.contentHeight=n.naturalHeight,t.appendChild(n),i()},n.onerror=()=>o(new Error(`Failed to load image: ${e.src}`)),n.src=e.src}),video:(e,t,s,i)=>{const o=e.format||s.video.format||Tt(e.src);t.innerHTML=y(s.video.tpl,{...i,src:e.src,format:o,poster:e.poster??""});const n=t.querySelector("video");n&&(e.autoStart??s.video.autoStart)&&n.play().catch(()=>{})},iframe:(e,t,s)=>new Promise(i=>{const o=s.iframe,n=m("div","glare-iframe-wrap",o.tpl),r=n.querySelector("iframe");if(!r)throw new Error("Iframe template must contain an <iframe>");for(const[a,l]of Object.entries(o.attr))r.setAttribute(a,l);if(Object.assign(r.style,o.css),e.width&&(n.style.width=X(e.width)),e.height&&(n.style.height=X(e.height)),t.appendChild(n),!o.preload){r.src=e.src,i();return}r.onload=()=>i(),r.src=e.src,setTimeout(i,ke)}),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 He(e,t,s,i){t.innerHTML="",t.className=`glare-content glare-content--${e.type}`,await _e[e.type](e,t,s,i),e.isLoaded=!0}function Re(e,t){for(const s of[e[t-1],e[t+1]])s?.type==="image"&&s.src&&(new Image().src=s.src)}let Fe=0;const x=class x{constructor(t,s={},i=0,o=""){this.id=++Fe,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=rt(s),this.dict=C(this.opts),this.group=Ct(t,this.opts),this.galleryName=o,this.currIndex=this.clampIndex(i),this.zoom=new Qt({image:()=>this.current?.$image??null,stage:()=>this.$refs?.stage??null,onChange:n=>this.syncZoomState(n)}),this.idle=new Se(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&&x.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=At(this.opts,this.dict,this.id,this.group.length),{container:i}=s;this.$refs=s,ge(i,this.opts),this.syncChrome(),this.resolveParent().appendChild(i),this.isActive=!0,g.add(this),this.opts.hideScrollbar&&K(!0),this.emit("onActivate"),this.emitSlide("beforeShow",this.current),Y(()=>{this.isActive&&(i.classList.add("glare-is-open"),this.showSlide(this.currIndex,!0),this.cleanups.push(Ie(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"),Ot(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.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:o,stage:n}=this.$refs,r=kt(n,i,this.opts);Nt(this.opts,i)&&Rt(r,this.opts,this.dict),Ft(n,this.opts,this.dict),this.emitSlide("beforeLoad",i),this.opts.image.preload&&Re(this.group,t);let a=!1;try{await He(i,i.$content,this.opts,this.dict)}catch(l){a=!0,zt(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),Pt(n),s||ye(o,this.opts),_t(r,s),Ht(n,r,this.opts.transitionDuration),this.syncZoomState(this.zoom.isZoomed),!a&&(s&&be(o,i,this.opts),this.emitSlide("afterShow",i))}syncChrome(){!this.$refs||!this.current||(Zt(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&&Gt(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 o=this.opts,n=I(o.thumbs,j);n&&(this.thumbs=new he(this,t,n));const r=I(o.slideshow,D);r&&(this.slideshow=new ce(this,t,r));const a=I(o.fullscreen,q);a&&G()&&(this.fullscreen=new Vt(this,t,a));const l=I(o.share,{});l&&(this.share=new le(this,t,l)),o.hash&&this.galleryName&&(this.hash=new ae(this,this.galleryName)),o.wheel&&(this.wheel=new pe(s,{mode:o.wheel,current:()=>this.current,isZoomed:()=>this.zoom.isZoomed,next:()=>this.next(),prev:()=>this.prev()})),o.touch&&(this.gestures=new ne(s,{zoom:this.zoom,touch:o.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,g.remove(this),this.opts.hideScrollbar&&g.size===0&&K(!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 o=new x(t,s,i);return o.open(),o}static bind(t,s={}){return we(t,s,(i,o,n)=>{new x(i,s,o,n).open()})}static close(t=!1){t?g.all().reverse().forEach(s=>s.close()):g.top()?.close()}static getInstance(t){return t==null?g.top():g.get(t)}static getInstances(){return g.all()}static destroy(){x.close(!0),xe()}static autoBind(t={}){const s=()=>x.bind("[data-glare]",t);document.readyState==="loading"?document.addEventListener("DOMContentLoaded",s,{once:!0}):s()}};x.defaults=B;let Z=x;return Z}));
|
|
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,"click",s,{capture:!0}),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}));
|
|
30
30
|
//# sourceMappingURL=glare.js.map
|