@divclass/lightbox 1.1.2 → 1.1.4

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/CHANGELOG.md CHANGED
@@ -2,6 +2,19 @@
2
2
 
3
3
  ---
4
4
 
5
+ ## [1.1.4] - 2026-05-22
6
+ ### Fixed
7
+ - Prevent crash when `this.limits` is undefined
8
+
9
+ ---
10
+
11
+ ## [1.1.3] - 2026-05-22
12
+
13
+ ### Changed
14
+ - Improve zoomed image drag threshold and movement logic
15
+
16
+ ---
17
+
5
18
  ## [1.1.2] - 2026-05-21
6
19
  ### Added
7
20
  - **Image zoom functionality**
@@ -1,8 +1,8 @@
1
1
  /*!
2
- * @divclass/lightbox v1.1.2 | May 21st 2026
2
+ * @divclass/lightbox v1.1.4 | May 22nd 2026
3
3
  * Source: https://github.com/divclass-org/lightbox.git
4
4
  * Homepage: https://lightbox.divclass.org/
5
5
  * (c) 2026 Taras Bilinskyi | Released under the MIT License
6
6
  */
7
7
 
8
- class t{constructor(){this.events={}}on(t,i){return this.events[t]||(this.events[t]=[]),this.events[t].push(i),this}off(t,i){return this.events[t]?(this.events[t]=this.events[t].filter(t=>t!==i),this):this}once(t,i){const e=(...n)=>{this.off(t,e),i(...n)};return this.on(t,e),this}emit(t,...i){return this.events[t]&&[...this.events[t]].forEach(t=>t(...i)),this}clear(){this.events={}}}class i{constructor(t={},i=null){this.data=t,this.events=i}set(t,i){const e=this.data[t];e!==i&&(this.data[t]=i,this.events&&(this.events.emit(`state:${t}`,i,e),this.events.emit("state:change",t,i,e)))}get(t){return this.data[t]}merge(t,i=!0){const e={...this.data};this.data={...this.data,...t},!i&&this.events&&this.events.emit("state:change","multiple",this.data,e)}}const e={icon:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1"><path d="M6 6L18 18M18 6L6 18"/></svg>',iconZoom:'<svg class="icon" viewBox="0 0 21 21" xmlns="http://www.w3.org/2000/svg"><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" transform="translate(3 3)"><circle cx="5.5" cy="5.5" r="5"></circle><path d="M3.5 5.5h4"></path><path class="dc-lightbox__button-zoom-line" d="M5.5 3.5v4"></path><path d="M14.5 14.5l-5.367-5.367"></path></g></svg>',maxZoom:3,thumbnailsIcon:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="11" rx="2"/><rect x="3" y="17" width="4" height="4" rx="1"/><rect x="10" y="17" width="4" height="4" rx="1"/><rect x="17" y="17" width="4" height="4" rx="1"/></svg>',showThumbnailsOnOpen:!0,arrowIcon:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M15 4L7 12L15 20"/></svg>',backdropClick:"close",closeExisting:!1,parentContainer:"body",hideScrollbar:!0,effect:"fadeInDown",zoomImageFromOrigin:!0,animationDuration:400,autoClose:!1,type:"inline",caption:!1,slideChangeDuration:280,slideOffset:.1,beforeLayoutOpen:()=>{},layoutReady:()=>{},layoutOpened:()=>{},beforeLayoutClose:()=>{},layoutClosed:()=>{},extensions:{}},n="data-close",s="data-type",o="data-caption",l="data-gallery",a="prev",r="next",c="active",h={fallbackBase64:"data:image/svg+xml;base64,"+btoa('\n <svg xmlns="http://www.w3.org/2000/svg" width="10" height="10">\n <rect width="100%" height="100%" fill="#ddd"/>\n </svg>\n '),openedCounter:0,timer:[0],backdrop_actions:["close"],openEffects:["fadeInDown","fadeIn","fadeInUp","zoomIn"],closeAllPopup:"close-all",timingFunc:"cubic-bezier(0.4, 0, 0.22, 1)",timingFuncInvert:"cubic-bezier(0.78, 0, 0.6, 1)"},u="body--hidden",d="dc-lightbox",m="dc-lightbox--visible",f="dc-lightbox--animating",g="dc-lightbox--opened",p="dc-lightbox--closing",x="dc-lightbox--gallery",b="dc-lightbox--scale-from-origin-in",_="dc-lightbox--scale-to-origin-out",w="dc-lightbox--scaled-from-origin",y="dc-lightbox__close-area",v="dc-lightbox__wrapper",M="dc-lightbox__overlay",$="dc-lightbox__overlay--show",T="dc-lightbox__overlay--prevent-anim",k="dc-lightbox__viewport",A="dc-lightbox__thumbnails",C="dc-lightbox__thumbnails--hide",I="dc-lightbox__thumbnails-viewport",O="dc-lightbox__thumbnails-slider",F="dc-lightbox__thumbnails-slide",q="dc-lightbox__thumbnails-slide--active",D="dc-lightbox__toolbar",P="dc-lightbox__counter",S="dc-lightbox__counter-current",z="dc-lightbox__counter-all",L="dc-lightbox__button-close",R="dc-lightbox__button-zoom",j="dc-lightbox__button-zoom--in",E="dc-lightbox__button-zoom--disabled",X="dc-lightbox__button-thumbnails",Y="dc-lightbox__wrapper--slider",B="dc-lightbox__wrapper--has-thumbnails",N="dc-lightbox__arrow",Z="dc-lightbox__slides",H="dc-lightbox__slide",G="dc-lightbox__slide--active",U="dc-lightbox__slide--prev",K="dc-lightbox__slide--next",V="dc-lightbox__slide--has-spinner",W="dc-lightbox__spinner",J="dc-lightbox__slide-content",Q="dc-lightbox__img-large",tt="dc-lightbox__img-large--loading",it="dc-lightbox__img-large--loaded",et="dc-lightbox__img-zoomable",nt="dc-lightbox__img-grabbing",st="dc-lightbox__slide-content--zoomIn",ot="dc-lightbox__img-small",lt="dc-lightbox__slide-content--prevent-anim",at="dc-lightbox__img-placeholder",rt="dc-lightbox__info",ct="dc-lightbox__info--hide",ht="dc-lightbox__caption",ut="dc-lightbox__caption-data",dt="dc-lightbox__crtl",mt="dc-lightbox__crbr",ft="dc-lightbox__crimg",gt="dc-lightbox__inner",pt="dc-lightbox__close";function xt(t,i="",e=null,n=null){const s=document.createElement(t);i&&(s.className=i),n&&Object.entries(n).forEach(([t,i])=>{!1===i||null===i?s.removeAttribute(t):s.setAttribute(t,String(i))});const o=t=>{t instanceof Node?s.append(t):null!=t&&s.insertAdjacentHTML("beforeend",String(t))};return Array.isArray(e)?e.forEach(o):o(e),s}function bt(t,i){const e={...t};return i&&"object"==typeof i&&Object.keys(i).forEach(n=>{i[n]&&"object"==typeof i[n]&&!Array.isArray(i[n])?e[n]=bt(t[n]||{},i[n]):e[n]=i[n]}),e}const _t=new WeakMap,wt=new Map,yt=new Map,vt=new Map;let Mt=!1,$t=!1;class Tt{constructor(n,s={}){if(s.src){const t=s.src;if(wt.has(t))return wt.get(t);wt.set(s.src,this)}else{if(_t.has(n))return _t.get(n);_t.set(n,this)}this.el=n,this.options=bt(e,s),this.events=new t,this.state=new i({active:!1},this.events),this.extensions={};let o=n.getAttribute("href")||n.getAttribute("data-src")||"",a=this.t(o,n),r=null;"inline"===a&&(r=document.querySelector(o)),this.targetData={href:o,type:a,id:r?.getAttribute("id")||"",style:r?.getAttribute("style")||"",class:r?.getAttribute("class")||"",timer:h.timer};let c=n.getAttribute(l);if(this.galleryName=c&&"image"===a?c:null,this.galleryData=null,this.galleryName){this.smallSrc=this.el?.querySelector("img")?.src||this.targetData?.href||!1,vt.has(this.galleryName)||vt.set(this.galleryName,{instances:[],urls:[],count:0,o:[]});const t=vt.get(this.galleryName);if(t&&(this.galleryData=t,t.instances.push(this),this.smallSrc)){t.urls.push(this.smallSrc);const i=document.createElement("img");i.src=this.smallSrc,i.loading="eager",i.decoding="async",i.alt="",t.o.push(i),t.count++}}this.clickedImgRect=null}init(){if(this.state.get("active"))return;if(this.state.set("active",!0),this.options.silent)this.l();else{let t=this.el;this.h=new Map;const i=this.u.bind(this,t);this.h.set(t,i),t.addEventListener("click",i)}this.emit("before:mount"),this.options.extensions&&this.mount(this.options.extensions),this.emit("mounted"),this.m=new MutationObserver(t=>{t.forEach(t=>{t.removedNodes.forEach(t=>{(t===this.el||t.contains(this.el))&&this.destroy()})})});const t=this.el.parentElement||document.body;this.m.observe(t,{childList:!0})}p(t,i){i.preventDefault();let e=this.targetData;e.timer[0]&&clearTimeout(e.timer[0]);t.getAttribute(n)===h.closeAllPopup||this.options.closeExisting?kt.closeAll():this.closeModal()}async closeModal(){let t=this.options,i=this.targetData;if(!this.state.get("opened"))return;const{animationDuration:e}=t,{type:n}=i;if(i.readyLayout&&!i.readyLayout.classList.contains(p)){this.state.set("layout-ready",!1),Mt=!0;let s=null,o=i.readyLayout.querySelector(`.${M}`);const l=()=>new Promise(requestAnimationFrame);"image"===i.type&&(s=i.readyLayout.querySelector(`.${G} .${J}`),s&&(s.classList.remove(lt),o.classList.remove(T)),await new Promise(requestAnimationFrame),await new Promise(requestAnimationFrame)),o.classList.remove($),this.emit("beforeLayoutClose",{modalRef:i.readyLayout}),i.readyLayout.classList.remove(g),i.readyLayout.classList.remove(x),i.readyLayout.offsetWidth,i.readyLayout.classList.add(f,p);const a=this.el?.querySelector("img")?.getBoundingClientRect()||null;a||i.readyLayout.classList.remove(w);const r=()=>{c&&clearTimeout(c),i.readyLayout&&i.readyLayout.classList.remove(m,p,f);let e=null;"image"!==n?e=this._():this.el&&(e=this.el),"image"===n&&(i.originTarget?.remove(),i.originTarget=null,t.silent&&(this.caption&&(this.caption=null),this.options?.caption&&(this.options.caption=null),this.el=null)),this.v&&(this.v.forEach((t,i)=>{i.removeEventListener("click",t)}),this.v.clear()),kt.M&&(kt.M.forEach((t,i)=>{i.removeEventListener("click",t)}),kt.M.clear()),i.readyLayout?.remove(),i.readyLayout=null,this.placeholder&&(this.placeholder?.remove(),this.placeholder=null),this.emit("layoutClosed",{modalRef:e}),this.state.set("opened",!1),this.openedNumb=0,kt.hasAnyOpen||(kt.$(),document.documentElement.classList.remove("dc-lightbox-scroll"))};let c=0;if(t.zoomImageFromOrigin&&!t.silent&&a&&"image"===i.type){let t=s?.querySelector("img")?.getBoundingClientRect()||null,n=null;if(t&&(n=this.T(a,t),s.style.width=`${t.width}px`,s.style.height=`${t.height}px`,s.style.transform=`translate3d(${t.left}px, ${t.top}px, 0px)`),i.readyLayout.classList.add(_),await l(),await l(),n&&!n.isRatioCorrect){let i=s.querySelector("."+dt),e=s.querySelector("."+mt),o=e.querySelector("."+ft);this.k(a,t,n.scale,i,e,o),await l(),await l()}t&&(s.style.transition=`transform ${e}ms ${h.timingFunc}`,s.style.transform=`translate3d(${n.x}px, ${n.y}px, 0px) scale(${n.scale})`),s.addEventListener("transitionend",r,{once:!0}),c=setTimeout(()=>{r()},e+1e3)}else setTimeout(()=>{r()},e)}}u(t,i){i.preventDefault();const e=t.querySelector("img");this.clickedImgRect=e?e.getBoundingClientRect():null,this.l()}async A(t){return new Promise((i,e)=>{const n=new Image;let s;const o=()=>{s&&clearInterval(s)},l=()=>{o(),i({width:n.naturalWidth,height:n.naturalHeight,imgElement:n})};if(n.onload=l,n.onerror=()=>{o(),e(new Error(`Не вдалося завантажити: ${t}`))},n.loading="eager",n.decoding="async",n.src=t,n.complete&&n.naturalWidth)return l();s=setInterval(()=>{n.naturalWidth&&n.naturalHeight&&l()},10)})}async l(){kt.C();let t=this.options,i=this.targetData,{parentContainer:e,hideScrollbar:n,autoClose:s,animationDuration:o,zoomImageFromOrigin:l,silent:c}=t;const{href:u,type:d}=i,{clickedImgRect:p}=this;if(i.originTarget=this.I(u,d),u&&i.originTarget){let u=this.O();if(!this.state.get("layout-ready"))return;if(u instanceof Node){document.querySelector(e).append(u),kt.hasAnyOpen||n&&kt.F(),kt.q(t,u,d,p);let x=this.existGallery,_=u.querySelector("."+M);if(Mt=!1,"image"===d){let t=kt.D(u),i=u.querySelectorAll("."+N);i.length&&(kt.M=new Map,i.forEach(t=>{const i=kt.P.bind(this,{arrow:t,isClick:!0});kt.M.set(t,i),t.addEventListener("click",i)}));let e=t.querySelector("img"),n=l&&!c&&p,s=-1;if(n){let i=e.src;yt.has(i)&&(e.src=yt.get(i).src);let l=this.el.querySelector("img").cloneNode(!0),c=await kt.S(t,"show",n,this.el,this.clickedImgRect,!0);await new Promise(requestAnimationFrame),await new Promise(requestAnimationFrame),u.classList.add(m),setTimeout(()=>{_.classList.add($)},7);const{width:d,height:g}=await this.A(e.src);if(d&&g){let n=kt.L(d,g,t),m=this.R(d,n.width,e);this.j(u,m),e.classList.add(Q,tt),e.style.width=n.width+"px",e.style.height=n.height+"px",l.classList.add(ot);let _=this.T(p,n),y=null,v=null,M=null;_.isRatioCorrect?t.append(l):(y=xt("div",dt),v=xt("div",mt),M=xt("div",ft),M.append(e,l),y.append(M),v.append(y),t.append(v),this.k(p,n,_.scale,y,v,M)),t.style.width=`${n.width}px`,t.style.height=`${n.height}px`,t.style.transform=`translate3d(${_.x}px, ${_.y}px, 0px) scale(${_.scale})`,t.style.transformOrigin="0 0",u.classList.add(b,w),t.offsetWidth,_.isRatioCorrect||[y,v,M].forEach(t=>{t.style.transition=`transform ${o-.25*o}ms ${h.timingFunc}`}),t.style.transition=`transform ${o}ms ${h.timingFunc}`,requestAnimationFrame(()=>{requestAnimationFrame(()=>{t.style.transform=`translate3d(${n.left}px, ${n.top}px, 0) scale(1)`,_.isRatioCorrect||[y,v,M].forEach(t=>{t.style.transform="translate3d(0,0,0)"}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{c.remove(),c=null})});const d=async n=>{if(n.target===t&&"transform"===n.propertyName){if(t.removeEventListener("transitionend",d),!yt.has(i))try{await e.decode()}catch(n){await new Promise((t,i)=>{e.complete?t():(e.addEventListener("load",t,{once:!0}),e.addEventListener("error",i,{once:!0}))})}_.isRatioCorrect||[y,v,M].forEach(t=>{t.style.transition=`transform ${o}ms ${h.timingFuncInvert}`});let c=!1,m=0;requestAnimationFrame(()=>{requestAnimationFrame(()=>{e.classList.add(it);const i=n=>{if(n.target===e&&"opacity"===n.propertyName&&!c&&(c=!0,clearTimeout(m),m=null,l.src="",l.remove(),e.classList.remove(tt),e.removeAttribute("style"),e.removeEventListener("transitionend",i),t.removeAttribute("style"),u.classList.remove(b),yt.set(e.src,e),kt.X(yt,3),this.state.set("opened",!0),this.openedNumb=++h.openedCounter,this.Y(t),x&&(this.B(u),s=this.galleryData.instances.indexOf(this),-1!==s))){const t=[a,r],i={gallery:this.galleryData.instances,instance:this};t.forEach(t=>{kt.N({...i,direction:t,i:t===a?s-1:s+1})}),$t=!0}};e.addEventListener("transitionend",i),m=setTimeout(()=>{i({target:e,propertyName:"opacity"})},2500)})}),u.classList.remove(f),this.emit("layoutOpened",{modalRef:u})}};t.addEventListener("transitionend",d)})})}}else{const i=i=>{p||(i.style.opacity=1),kt.S(t,"hide",!1,null,null,!1);let e=i.getBoundingClientRect(),n=this.R(i.naturalWidth,e.width,i);this.j(u,n),setTimeout(()=>{if(u.classList.remove(f),l&&u.classList.add(w),this.state.set("opened",!0),this.openedNumb=++h.openedCounter,this.emit("layoutOpened",{modalRef:u}),this.Y(t),x&&(this.B(u),s=this.galleryData.instances.indexOf(this),-1!==s)){const t=[a,r],i={gallery:this.galleryData.instances,instance:this};t.forEach(t=>{kt.N({...i,direction:t,i:t===a?s-1:s+1})}),$t=!0}},o)};u.classList.add(m),setTimeout(()=>{_.classList.add($)},1),this.Z(e,(i,e)=>{kt.S(t,i,n,this.el,this.clickedImgRect,e)}).then(async()=>{await new Promise(requestAnimationFrame),await new Promise(requestAnimationFrame),i(e)})}}else u.classList.add(m),setTimeout(()=>{_.classList.add($)},1);this.emit("layoutReady",{modalRef:u}),u.classList.add(g,f),i.readyLayout=u,setTimeout(()=>{"image"!==d&&(this.state.set("opened",!0),this.openedNumb=++h.openedCounter,u.classList.remove(f),this.emit("layoutOpened",{modalRef:u})),this.H(),t&&s&&(i.timer[0]=setTimeout(()=>{this.closeModal()},s))},o)}}}O(){let t=this.targetData;const{id:i,style:e,class:n,type:s}=t;this.emit("beforeLayoutOpen",{modalRef:t.originTarget});let o=document.createElement("div"),l=this.G();if(o.append(l),o.classList.add(d),"image"!==s){const t=o.querySelector(`.${gt}`);t&&Array.from(t.children).filter(t=>!t.classList.contains(pt)).forEach(t=>{i&&(t.id=i),e&&t.setAttribute("style",e),n&&(t.className=n),t.style.display="block"})}return this.state.set("layout-ready",!0),o}G(){const t=this.targetData,{type:i,id:e}=t,{backdropClick:s,icon:o,iconZoom:l,thumbnailsIcon:a,showThumbnailsOnOpen:r,zoomImageFromOrigin:c}=this.options,u=document.createDocumentFragment();["id","style","class"].forEach(i=>t.originTarget.removeAttribute(i));const d=s&&Array.isArray(h.backdrop_actions)&&h.backdrop_actions.includes(s)?s:null,m=d&&"image"!==i?{[n]:d}:null;if("image"===i){let i=xt("button",R,l),e=xt("div",D,[i,xt("button",L,o,{[n]:""})]);i.addEventListener("click",t=>{this.U(t,t.currentTarget,!1)});let s=xt("div",M),h=xt("div",`${v} ${Y}`,null,m),d=xt("div",Z),f=xt("div",`${H} ${G}`,null,m);d.append(f);let g=xt("div",k,null),p=xt("div",J);t.originTarget instanceof Node?(c&&(t.originTarget.style.opacity=0),p.append(t.originTarget)):p.innerHTML=t.originTarget,g.append(p),f.append(g),this.K(f),h.append(d);if(this.existGallery){const t=this.galleryData.instances.indexOf(this);let i=xt("div",P),n=xt("span",S,t+1),s=xt("span",z,this.galleryData.count);i.append(n,s),e.prepend(i);let o=xt("div",`${H} ${U}`,null,m),l=xt("div",`${H} ${K}`,null,m);d.prepend(o),d.append(l),h.prepend(xt("div",`${N} ${N}--prev`,this.options.arrowIcon)),h.append(xt("div",`${N} ${N}--next`,this.options.arrowIcon));let c=xt("button",X,a);i.after(c);let u=xt("div",A),f=xt("div",I),g=xt("div",O);f.append(g),u.append(f),h.append(u);const p=localStorage.getItem("dcThumbnails");(null!==p?"true"===p:r)&&h.classList.add(B),c.addEventListener("click",()=>{const t=h.classList.toggle(B);localStorage.setItem("dcThumbnails",t)})}return u.append(e,s,h),u}let f=xt("div",M),g=xt("div",v),p=xt("span",y,null,m),x=xt("div",gt),b=xt("button",pt,o,{[n]:""});return x.append(b),t.originTarget instanceof Node?(this.placeholder=document.createComment(`placeholder-for-${e||"element"}`),t.originTarget.before(this.placeholder),x.append(t.originTarget)):x.innerHTML+=t.originTarget,g.append(p,x),u.append(f,g),u}_(){if(this.placeholder?.parentNode){let t=this.targetData.readyLayout.querySelector("#"+this.targetData.id);if(t)return t.style.display="none",this.placeholder.replaceWith(t),t}return!1}I(t,i=this.options.type){return"image"===i?this.V(t):this.W(t)}R(t,i,e=null){const n=t/i;let s=Math.min(n,this.options.maxZoom)>1;return s&&e&&(e.classList.add(et),e.setAttribute("draggable","false")),s}j(t,i){if(!t)return;const e=t.querySelector("."+R);e&&(e.classList.remove(j),e.classList.toggle(E,!i))}J(t,i,e){return Math.max(i,Math.min(e,t))}tt(t,i){const e=getComputedStyle(t),n=new DOMMatrix(e.transform),{minX:s,maxX:o,minY:l,maxY:a}=i,r=this.J(n.m41,s,o),c=this.J(n.m42,l,a);if(n.m41===r&&n.m42===c)return;t.style.transition="transform 0.48s cubic-bezier(0.25, 0.82, 0.15, 1)",t.style.transform=`translate3d(${Math.round(r)}px, ${Math.round(c)}px, 0) scale(${n.a})`;const h=()=>{t.style.transition="",t.removeEventListener("transitionend",h)};t.addEventListener("transitionend",h)}U(t,i,e=!0){let n=kt.lastOpenedInstance;if(!n)return;let s=n.state.get("opened"),o=n.targetData.readyLayout.querySelector(`.${G} .${J} img`);if(s&&o){let s=n.options.maxZoom,l=o.getBoundingClientRect(),a=l.width,r=o.naturalWidth/a,c=Math.min(r,s);if(c){let s=o.closest("."+J);const a=s.classList.contains(st),r=t=>{if(t.target!==o||"transform"!==t.propertyName)return;o.removeEventListener("transitionend",r);let i=o.getBoundingClientRect(),e=Math.round(i.width),s=Math.round(i.height),l=0,a=0;const h=getComputedStyle(o).transform;if(h&&"none"!==h){const t=new DOMMatrixReadOnly(h);l=t.m41,a=t.m42}l=Math.round(l),a=Math.round(a),o.style.willChange="transform",o.style.transition="none",o.style.width=e+"px",o.style.height=s+"px",o.style.maxWidth="none",o.style.maxHeight="none",o.style.transform=`translate(${l}px, ${a}px) scale(1)`,n.targetData.imgScaleVal=c,requestAnimationFrame(()=>{requestAnimationFrame(()=>{o.style.transition=""})})},h=t=>{t.target===o&&"transform"===t.propertyName&&(s.classList.remove(st),i.classList.remove(j),o.classList.remove(nt),o.style.transformOrigin="center center",o.style.width="",o.style.height="",o.style.maxWidth="",o.style.maxHeight="",o.style.transform="",o.style.willChange="",o.removeEventListener("transitionend",h))};if(a||n.targetData.imgScaleVal)n.targetData.imgScaleVal&&(o.style.transition="",o.style.transform=`scale(${1/n.targetData.imgScaleVal})`,n.targetData.imgScaleVal=!1,n.it(),o.addEventListener("transitionend",h));else if(c>1){if(i.classList.add(j),s.classList.add(st),e){const i=window.innerWidth,e=window.innerHeight,n=l.left+l.width/2,s=l.top+l.height/2,a=t.clientX-n,r=t.clientY-s;let h=-a*(c-1),u=-r*(c-1);const d=l.width*c,m=l.height*c,f=Math.max(0,(d-i)/2),g=Math.max(0,(m-e)/2);h=Math.max(-f,Math.min(f,h)),u=Math.max(-g,Math.min(g,u)),o.style.transform=`translate(${Math.round(h)}px, ${Math.round(u)}px) scale(${c})`}else o.style.transform=`scale(${c})`;o.addEventListener("transitionend",r),o.style.transformOrigin=""}}}return!1}V(t){if(!t)return!1;let i=document.createElement("img");return i.src=t,i.alt="",i}et(){let t=this.options.caption;if(this.el){const i=this.el.getAttribute(o);i&&"false"!==i&&(t=i)}return t&&(t=t.trim()),t}W(t){if(!t||!t.startsWith("#")||t.length<=1)return!1;const i=document.querySelector(t);return!!i&&(!this.state.get("opened")&&i)}t(t,i=null){if(i){const t=i.getAttribute(s);if(t&&"false"!==t)return t}let e=this?.options?.type||"inline";return t&&/(^data:image\/[a-z0-9+\/=]*,)|\.(jpe?g|gif|png|bmp|webp|svg|ico)([\?#].*)?$/i.test(t)&&(e="image"),e}mount(t){for(const[i,e]of Object.entries(t)){let t=e;if("object"==typeof t&&null!==t&&("function"==typeof t[i]?t=t[i]:"function"==typeof t.default&&(t=t.default)),"function"!=typeof t)continue;const n=new t(this);this.extensions[i]=n,"function"==typeof n.mount&&n.mount()}}on(t,i){return this.events.on(t,i),this}off(t,i){return this.events.off(t,i),this}emit(t,i){return this.events.emit(t,i),this}destroy(){this.state.get("active")&&(this.emit("before:destroy"),this.m&&(this.m.disconnect(),this.m=null),Object.keys(this.extensions).forEach(t=>{this.extensions[t].destroy?.(),this.extensions[t]=null}),this.extensions={},this.el&&(_t.delete(this.el),kt.instances.delete(this),this.el=null),this.targetData&&(this.targetData=null),this.placeholder&&(this.placeholder=null),this.openedNumb&&(this.openedNumb=null),this.galleryData&&(vt.delete(this.galleryName),this.galleryData=null),yt&&yt.clear(),this?.options?.src&&wt.delete(this.options.src),this.h&&(this.h.forEach((t,i)=>{i.removeEventListener("click",t)}),this.h.clear()),this.v&&(this.v.forEach((t,i)=>{i.removeEventListener("click",t)}),this.v.clear()),h.openedCounter=0,this.state.set("active",!1),this.state.set("layout-ready",!1),this.emit("destroyed"),this.events.clear())}k(t,i,e,n,s,o){const l=2*e,a=.5*i.width-t.width/l,r=.5*i.height-t.height/l,c=(t,i,e)=>{const n=Math.round(1e4*i)/1e4,s=Math.round(1e4*e)/1e4;t.style.transform=`translate3d(${n}px, ${s}px, 0)`};c(n,2*a,2*r),c(s,-a,-r),c(o,-a,-r)}T(t,i){if(!t||!i)return;const e=t.width/i.width,n=t.height/i.height,s=e.toFixed(2)===n.toFixed(2),o=Math.max(e,n);return{isRatioCorrect:s,scale:o,x:.5*t.width+t.left-i.width*o*.5,y:.5*t.height+t.top-i.height*o*.5}}Z(t,i){const e=!t.complete||0===t.naturalWidth;let n=!1;const s=(t=!1)=>{n||(n=!0,i("show",t))};return(e?new Promise(i=>{s(),t.addEventListener("load",i,{once:!0}),t.addEventListener("error",i,{once:!0})}):Promise.resolve()).then(()=>{if(t.decode)return s(!0),t.decode().catch(t=>{})}).finally(()=>{})}H(){let t=this.targetData.readyLayout.querySelectorAll(`[${n}]`);t.length&&(this.v=new Map,t.forEach(t=>{const i=this.p.bind(this,t);this.v.set(t,i),t.addEventListener("click",i)}))}K(t){const i=this.et();if(t?.querySelector("."+rt)?.remove(),i){this.caption=i;const e=xt("div",rt),n=xt("div",ht),s=xt("div",ut,i);n.append(s),e.append(n),t.append(e),e.addEventListener("click",t=>{t.stopPropagation()})}}it(){this.frame&&cancelAnimationFrame(this.frame),this.frame=null}nt(t,i){const e=t.getBoundingClientRect(),n=i.getBoundingClientRect();this.limits={minX:Math.min(0,(e.width-n.width)/2),maxX:Math.max(0,(n.width-e.width)/2),minY:Math.min(0,(e.height-n.height)/2),maxY:Math.max(0,(n.height-e.height)/2)};const s=new DOMMatrix(getComputedStyle(i).transform);this.zoomedScale=s.a}Y(t){let i={activeSlide:t.closest("."+G),pSlide:null,nSlide:null},e=t.closest("."+k),n=null,s=!0,o=null,l=!0,c=0,u=0,d=null,m=0,f=0,g=!1,p=!1;let x=this.options.animationDuration||100,b=this.options.zoomImageFromOrigin,_=null,w=null,y=!1,v=!1,$=null,I=null,O=null,F=!1,q=!1,D=null,P=null,S=0,z=0,L=0,j=null,E=t.closest("."+Z),X=null,Y=null,H=null,U=!1,K=0,V=0,W=0,J=0,Q=0;this.frame=null,this.targetData.imgScaleVal=null;let tt=0,it=0;const ot=x=>{if(x.pointerId===j&&g){if(!p&&X){if(H&&!U){let t=this.targetData.readyLayout.querySelector("."+R);this.U(x,t)}if(H&&Y&&U){this.frame&&cancelAnimationFrame(this.frame);const{minX:t,maxX:i,minY:e,maxY:n}=this.limits,s=getComputedStyle(H),o=new DOMMatrix(s.transform);let l=o.m41,a=o.m42;const r=o.a,c=.9,h=()=>{l<t?(K*=.68,l+=.12*(t-l)):l>i&&(K*=.68,l+=.12*(i-l)),a<e?(V*=.68,a+=.12*(e-a)):a>n&&(V*=.68,a+=.12*(n-a)),l+=K,a+=V,K*=c,V*=c,H.style.transform=`translate3d(${Math.round(l)}px, ${a}px, 0) scale(${r})`,H.classList.remove(nt);if(Math.hypot(K,V)<.25)return K=0,V=0,this.tt(H,{minX:t,maxX:i,minY:e,maxY:n}),void(this.frame=null);this.frame=requestAnimationFrame(h)};this.frame=requestAnimationFrame(h)}U=!1}if(g=!1,E.style.transition="","x"===d){const t=f-u,i=e.clientWidth;let n=Math.abs(S);n<30&&(n*=1e3);const s=.32*i,o=650,l=t+.2*S;if(p&&_&&(Math.abs(t)>s||n>o||Math.abs(l)>.48*i)){const t=this.state.get("opened"),i=l>0?a:r;let e=document.querySelector("."+N+"--"+i);e&&t&&kt.P.call(this,{arrow:e,isClick:!1})}else p&&(E.style.transform="",setTimeout(()=>{E.style.willChange="auto"},this.options.slideChangeDuration))}if("y"===d){const a=m-c,r=Math.min(100,.2*D);p&&Math.abs(a)>r?(I.style.opacity=0,I=null,b||(t.style.opacity=0),Mt=!0,this.closeModal()):p&&(t.style.transition=`transform 0.3s ${h.timingFunc}`,t.style.transform="",I.style.transition=`opacity 0.3s ${h.timingFunc}`,I.style.opacity=1,P=setTimeout(()=>{t.style.transition="",I.style.transition="",I.style.opacity="",I.classList.remove(T),t.style.willChange="",n&&(n.classList.remove(ct),s=!0),o&&(o.classList.remove(C),l=!0,i.activeSlide.style.overflow="",e.style.overflow=""),n=null,o=null},300),b||(t.style.animation="",t.classList.add(lt)))}c=0,u=0,m=0,f=0,$=null,D=null,p=!1,d=null,e.releasePointerCapture(j),j=null}},at=(t,i)=>{if(d)return d;const e=Math.abs(t),n=Math.abs(i);return e<24&&n<24?null:(d=e>n?"x":"y",d)};e.addEventListener("pointerdown",e=>{if(null!==j)return;if(j=e.pointerId,H=e.target.closest("img"),!this.state.get("layout-ready"))return;P&&clearTimeout(P),c=e.clientY,u=e.clientX,m=c,f=u,$=document.documentElement.clientWidth,D=document.documentElement.clientHeight,_=this.existGallery,I=this.targetData.readyLayout.querySelector("."+M),I.style.willChange="opacity",I.classList.add(T),d=null,g=!0,p=!1,n=i.activeSlide.querySelector("."+rt),o=i.activeSlide.closest("."+B)?.querySelector("."+A),b?(t.style.transition="",t.style.willChange="transform"):(t.style.opacity=1,t.style.transition=`opacity ${x}ms ${h.timingFunc}`,t.style.willChange="transform, opacity"),_&&(i.pSlide=kt.st(this,a),i.nSlide=kt.st(this,r)),E.style.transition="none",E.style.willChange="transform";let s=t.querySelector("img");if(s&&s.classList.contains(et)&&(X=!0,Y=!!t.classList.contains(st),Y&&H&&this.targetData.imgScaleVal)){s.classList.add(nt);const i=getComputedStyle(s),e=new DOMMatrix(i.transform);this.it(),s.style.transition="",this.nt(t,s),tt=e.m41,it=e.m42,K=V=0,J=tt,Q=it}}),e.addEventListener("pointermove",a=>{if(a.pointerId!==j)return;if(!g)return;m=a.clientY,f=a.clientX;const r=m-c,h=f-u;if(Y&&H&&this.targetData.imgScaleVal){let i=t.querySelector("img");let e=tt+(h-20*w),n=it+(r-40*O);const{minX:s,maxX:o,minY:l,maxY:a}=this.limits,c=.25;e>o?e=o+(e-o)*c:e<s&&(e=s+(e-s)*c),n>a?n=a+(n-a)*c:n<l&&(n=l+(n-l)*c),i.style.transition="none",i.style.transform=`translate3d(${Math.round(e)}px, ${Math.round(n)}px, 0) scale(${this.zoomedScale})`,(Math.abs(h)>20||Math.abs(r)>40)&&(U=!0);const u=performance.now(),d=u-W;if(d>8&&d<100){K=(e-(J||tt))/d*16,V=(n-(Q||it))/d*16}J=e,Q=n,W=u}if(at(h,r),"x"===d&&!Y){const i=performance.now(),e=i-L;if(e>8&&e<120){S=.65*S+.35*((f-z)/e*1e3)}if(z=f,L=i,!p){if(Math.abs(h)<20)return;p=!0,w=h>0?1:-1,t.style.willChange=""}const n=h-20*w;n>0&&!y?(y=!0,v=!1):n<0&&!v&&(v=!0,y=!1);const s=n/$*100;E.style.transform=`translate3d(${s}%, 0, 0)`}if("y"===d&&!Y){if(!p){if(Math.abs(r)<40)return;p=!0,E.style.willChange="",O=r>0?1:-1}const a=r-40*O;a>0&&!q?(q=!0,F=!1):a<0&&!F&&(F=!0,q=!1);const c=a/D*100,h=Math.abs(c+(q?-100:100));I.style.opacity=h+"%",b&&this.clickedImgRect||(t.style.animation="none"),t.style.transform=`translate3d(0, ${a}px, 0)`,n&&s&&(s=!1,n.classList.add(ct)),o&&l&&(l=!1,o.classList.add(C),i.activeSlide.style.overflow="visible",e.style.overflow="visible")}(p||Y)&&e.setPointerCapture(j),a.cancelable&&a.preventDefault()}),e.addEventListener("pointerup",ot),e.addEventListener("pointercancel",ot)}get existGallery(){return this.galleryData?.urls.length>1||!1}B(t){if(this.existGallery){let i=this.galleryData,e=t,n=t.querySelector("."+A),s=e.querySelector("."+I),o=e.querySelector("."+O),l=null,c=i.instances.indexOf(this);if(this.galleryData.o.length>1){const t=document.createDocumentFragment();this.galleryData.o.forEach((i,e)=>{let n=document.createElement("div");n.className=F,n.dataset.index=e,n.appendChild(i.cloneNode(!0)),t.appendChild(n)}),o.appendChild(t)}l=o.querySelectorAll("."+F),n.addEventListener("click",t=>{if(t.target.closest(`.${q}`))return;const i=t.target.closest(`.${F}`);if(!i)return;const e=i.parentNode.children;let n=-1,l=null,c=0;for(const t of e)t.classList.contains(q)&&(n=c),c++;if(l=this.galleryData.instances[n],!l||!l.state.get("opened")||!$t)return;o.style.transition="",e[n].classList.remove(q),i.classList.add(q);let h=parseInt(i.getAttribute("data-index")),u=h>n?r:a,d=document.querySelector("."+N+"--"+u);kt.P.call(l,{arrow:d,isClick:!1,isThumbnailClick:!0,targetIndex:h}),kt.ot({viewportThumbnail:s,sliderThumbnails:o,activeThumbnail:i})});const h=n.querySelector("."+I);if(kt.lt(h),-1!==c){const t=l[c];t&&(t.classList.add(q),kt.ot({viewportThumbnail:s,sliderThumbnails:o,activeThumbnail:t,silent:!0}))}}}}class kt{static instances=new Map;static Extensions={};constructor(t=null,i={}){let e=null;if(null===t){i.silent=!0;let t=xt("a","","",{href:i?.src||"",caption:i?.caption||""});e=kt.rt(t)}else e=kt.rt(t);if(!e.length)return null;const n=e.map(e=>{if(null===t){let t=i?.src||"";if(wt.has(t))return wt.get(t)}else if(_t.has(e))return _t.get(e);const n=new Tt(e,i);return kt.instances.set(n,n),n}),s=1===n.length?n[0]:n;return Array.isArray(s)&&(s.on=(t,i)=>(s.forEach(e=>e.on(t,i)),s)),setTimeout(()=>{Array.isArray(s)?s.forEach(t=>t.init()):s.init()},0),s}static rt(t){return"string"==typeof t?Array.from(document.querySelectorAll(t)):t instanceof HTMLElement?[t]:Array.isArray(t)?t.filter(t=>t instanceof HTMLElement):[]}static destroyAll(){Array.from(this.instances.values()).forEach(t=>{t.destroy()}),this.instances.clear()}static closeAll(){this.allOpened.forEach(t=>{t.closeModal()}),h.openedCounter=0}static get allOpened(){return Array.from(this.instances.values()).filter(t=>t.state.get("opened")).sort((t,i)=>i.openedNumb-t.openedNumb)}static get hasAnyOpen(){for(const t of this.instances.values())if(t.state.get("opened"))return!0;return!1}static get lastOpenedInstance(){let t=null,i=-1;for(const e of this.instances.values())e.state.get("opened")&&e.openedNumb>i&&(i=e.openedNumb,t=e);return t}static q(t,i,e,n){let{animationDuration:s=0,effect:o="fadeInDown",zoomImageFromOrigin:l}=t;l&&!t.silent&&"image"===e&&n&&(o="fadeIn");const a=h.openEffects.includes(o)?o:"fadeInDown",r={fadeInDown:-40,fadeInUp:40}[a]??0,c={"--animationDuration":`${Number(s)||0}ms`,"--animationEffect":a,"--imageInitPosition":`${r}px`,"--slideChangeDuration":t.slideChangeDuration+"ms","--slideOffset":t.slideOffset};Object.entries(c).forEach(([t,e])=>{i.style.setProperty(t,e)})}static async ct(t){await new Promise((i,e)=>{t.complete?i():(t.addEventListener("load",i,{once:!0}),t.addEventListener("error",e,{once:!0}))});try{await t.decode()}catch(t){}return t}static async S(t,i="show",e=!0,n=null,s=null,o=!1){const l="."+W,a="."+at,r="."+H,c=t.querySelector(l),h=t.closest(r),u=e&&n&&s;if("show"===i){if(!o&&!c&&(t.append(xt("div",W)),h?.classList.add(V)),u){const i=h?.querySelector(a);if(!i){const i=n.querySelector("img");if(i){const e=i.cloneNode(!1);return Object.assign(e.style,{width:s.width+"px",height:s.height+"px",top:s.top+"px",left:s.left+"px"}),e.classList.add(at),t.before(e),await kt.ct(e)}}}}else if("hide"===i){const t=h?.querySelector(a);t&&setTimeout(()=>{t.remove()},4),c?.remove(),h?.classList.remove(V)}}static show(t){if(t?.src||"")return new kt(null,t)}static st(t,i){const e={[a]:U,[r]:K,[c]:G}[i];return t.targetData.readyLayout.querySelector(`.${e}`)}static async N(t={}){const{gallery:i,i:e=0,direction:n="next",instance:s}=t;Mt=!1;const o=i[(e+i.length)%i.length];if(!s.targetData.readyLayout)return;let l=kt.st(s,n);l.innerHTML="";let a=xt("div",k),r=xt("div",J);a.append(r),l.append(a),kt.S(r,"show",!1,null,null,!1);let c=await(u=o.targetData.href,yt.has(u)?Promise.resolve(yt.get(u)):new Promise(t=>{const i=async()=>{try{const i=await async function(t){if(yt.has(t))return yt.get(t);const i=new Image;if(await new Promise((e,n)=>{i.onload=e,i.onerror=n,i.loading="eager",i.decoding="async",i.src=t}),i.decode)try{await i.decode()}catch(t){}return yt.set(t,i),kt.X(yt,3),i}(u);t(i)}catch(i){t(null)}};"requestIdleCallback"in window?requestIdleCallback(i,{timeout:200}):setTimeout(i,0)}));var u;let d=c.cloneNode(!1);return d&&d.decode&&d.decode().then(()=>{kt.S(r,"hide",!1,null,null,!1)}).catch(()=>{kt.S(r,"hide",!1,null,null,!1)}),Mt?void 0:(r.append(d),new Promise(t=>{let i=null,e=null,n=null;const s=kt.L(d.naturalWidth,d.naturalHeight,d.parentElement),l=o.el.querySelector("img")?.getBoundingClientRect();let a=o.T(l,s);a?.isRatioCorrect||(i=xt("div",dt),e=xt("div",mt),n=xt("div",ft),n.append(d),i.append(n),e.append(i),[i,e,n].forEach(t=>{t.style.transform="translate3d(0, 0, 0)",t.style.transition=`transform ${o.options.animationDuration}ms ${h.timingFuncInvert}`}),r.append(e)),t()}))}static P(t,i){let{arrow:e,isClick:n,isThumbnailClick:s=!1,targetIndex:o=-1}=t;!0===n&&(i.preventDefault(),i.stopPropagation());let l=!!e.classList.contains(`${N}--${r}`),h=this.galleryData.instances;const u=h.findIndex(t=>t.state.get("opened")),d=-1!==u?h[u]:null;if(!d)return;if(!$t)return;$t=!1;let m=d.state.get("layout-ready");if(-1!==u&&m){d.state.set("layout-ready",!1),d.state.set("opened",!1),d.openedNumb=0,d.targetData.readyLayout.classList.add(x);let t=kt.st(d,a),i=kt.st(d,r),e=kt.st(d,c),n=null,m=null,f=null,g=!0,p=null;if(s&&-1!==o){if(f=o,n=h[f],g=1===Math.abs(u-o),!g){let t=l?r:a;p=kt.N({gallery:h,instance:d,direction:t,i:f})}}else m=l?1:-1,f=(u+m+h.length)%h.length,n=h[f];const b=l?i:t;b.style.visibility="visible";const _=l?t:i;let w=null;w=""+(l?"to-left":"to-right");let y=e.closest("."+Z);if(y.style.transition="",y.style.willChange="transform",!s){let t=document.querySelector("."+A);if(t){let i=t.querySelector("."+I),e=t.querySelector("."+O),n=e.querySelectorAll("."+F),s=n[f];for(const t of n)t.classList.remove(q);s.classList.add(q),kt.ot({viewportThumbnail:i,sliderThumbnails:e,activeThumbnail:s})}}const v=async t=>{if(t.target===y&&"transform"===t.propertyName){y.style.transition="none",y.style.transform="",y.classList.remove("to-left","to-right"),n.targetData.readyLayout=d.targetData.readyLayout,n.state.set("layout-ready",!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>{y.style.transition="",n.state.set("opened",!0),n.openedNumb=1})}),n.H(),d.v&&(d.v.forEach((t,i)=>{i.removeEventListener("click",t)}),d.v.clear()),d.targetData.originTarget?.remove(),d.targetData.originTarget=null,d.targetData.readyLayout=null;const i={next:K,prev:U};let s=`${H} ${i[l?a:r]}`,o=`${H} ${i[l?r:a]}`,c=`${H} ${G}`;const u=(t,i)=>{t.className=i,t.innerHTML="",t.style.transform="",t.style.visibility=""};u(e,s),b.className=c,b.style.transform="",b.style.visibility="",y.removeEventListener("transitionend",v),u(_,o),document.querySelector("."+S).innerText=+f+1;let m=kt.D(n.targetData.readyLayout),x=this;function w(t){let i=t.getBoundingClientRect(),e=x.R(t.naturalWidth,i.width,t);t.removeAttribute("loading"),t.removeAttribute("decoding"),x.j(n.targetData.readyLayout,e)}function M(t){t.complete?w(t):t.addEventListener("load",()=>{w(t)},{once:!0})}const $=m.querySelector("img");if($)M($);else{new MutationObserver((t,i)=>{const e=m.querySelector("img");e&&(M(e),i.disconnect())}).observe(m,{childList:!0,subtree:!0})}let T=n.targetData.readyLayout.querySelector(`.${J}`);n.Y(T);const k=[a,r],A={gallery:h,instance:n};g||await p,k.forEach(t=>{kt.N({...A,direction:t,i:t===a?f-1:f+1})}),$t=!0}};requestAnimationFrame(()=>{y.classList.add(w),n.K(b)}),y.addEventListener("transitionend",v)}}static C(t=!1){this.ht||(document.addEventListener("keydown",t=>{let i=t.key;if("Escape"===i){const t=this.lastOpenedInstance;t&&(t?.options?.closeExisting?kt.closeAll():t.closeModal())}if("ArrowLeft"===i||"ArrowRight"===i){const t=this.lastOpenedInstance;let e="ArrowLeft"===i?a:r,n=document.querySelector("."+N+"--"+e);n&&t&&kt.P.call(t,{arrow:n,isClick:!1})}}),this.ht=!0)}static F(){const t=document.documentElement.scrollHeight>window.innerHeight;document.body.classList.contains(u)||(document.body.classList.add(u),t?document.documentElement.classList.add("dc-lightbox-scroll"):document.documentElement.classList.remove("dc-lightbox-scroll"))}static $(){document.body.classList.remove(u)}static D(t){const i=t.querySelector("."+G+" ."+J);return i?(i.addEventListener("click",function(t){t.stopPropagation()}),i):null}static ot(t){const{viewportThumbnail:i,sliderThumbnails:e,activeThumbnail:n,silent:s=!1}=t,o=i.clientWidth,l=e.scrollWidth,a=window.getComputedStyle(e),r=new DOMMatrixReadOnly(a.transform).m41;if(e.style.transition=s?"none":"",l<=o){const t=(o-l)/2;return void(e.style.transform=`translateX(${t}px)`)}const c=o/2,h=n.offsetLeft+n.offsetWidth/2,u=h+r;let d=r;(u<.3*o||u>.7*o)&&(d=c-h);const m=o-l;d=Math.max(m,Math.min(0,d)),Math.abs(d-r)<1||(e.style.transform=`translateX(${d}px)`)}static lt(t){const i=t.querySelector("."+O);if(!i)return;let e=0,n=0,s=0,o=!1,l=!1,a=0;let r=null,c=0,h=0,u=0,d=null;const m=()=>{const t=getComputedStyle(i);return new DOMMatrixReadOnly(t.transform).m41||0},f=()=>{const e=i.scrollWidth,n=t.clientWidth;if(e<=n){const t=(n-e)/2;return{min:t,max:t}}return{min:n-e,max:0}},g=e=>{if(e.pointerId===r&&o){if(o=!1,l)(()=>{let t=m();const{min:e,max:n}=f();c=Math.max(-85,Math.min(85,c));const s=()=>{if(t+=c,t>n?(t=n+.915*(t-n),c*=.72):t<e&&(t=e-.915*(e-t),c*=.72),c*=.935,i.style.transform=`translate3d(${t}px, 0, 0)`,Math.abs(c)>.15&&t>e-5&&t<n+5)d=requestAnimationFrame(s);else{const s=Math.max(e,Math.min(n,t));Math.abs(s-t)>.5&&(i.style.transition="transform 0.45s cubic-bezier(0.25, 0.8, 0.25, 1)",i.style.transform=`translate3d(${s}px, 0, 0)`),d=null}};d=requestAnimationFrame(s)})();else{const{min:t,max:e}=f(),n=m(),s=Math.max(t,Math.min(e,n));s!==n&&(i.style.transition="transform 0.4s ease-out",i.style.transform=`translate3d(${s}px, 0, 0)`)}try{t.releasePointerCapture(r)}catch(t){}r=null}},p={passive:!1};t.addEventListener("pointerdown",t=>{null===r&&("touch"!==t.pointerType||t.isPrimary)&&(d&&cancelAnimationFrame(d),d=null,r=t.pointerId,e=n=h=t.clientX,u=performance.now(),s=m(),c=0,o=!0,l=!1,a=0,i.style.transition="none")},p),t.addEventListener("pointermove",d=>{if(d.pointerId!==r||!o)return;n=d.clientX;const m=n-e;if(!l){if(Math.abs(m)<15)return;l=!0,a=m>0?1:-1,t.setPointerCapture(r),i.style.transition="none"}let g=s+(m-15*a);const{min:p,max:x}=f();g>x?g=x+.28*(g-x):g<p&&(g=p+.28*(g-p)),i.style.transform=`translate3d(${g}px, 0, 0)`;const b=performance.now(),_=b-u;if(_>8&&_<120){c=(g-(h!==n?h:s))/_*16.67}h=g,u=b,d.cancelable&&d.preventDefault()},p),t.addEventListener("pointerup",g,p),t.addEventListener("pointercancel",g,p)}static X(t,i){for(;t.size>i;){const i=t.keys().next().value;t.delete(i)}}static L(t,i,e){const n=i/t,s=e.getBoundingClientRect();let o=Math.min(t,s.width),l=o*n;l>s.height&&(l=s.height,o=l/n);return{width:o,height:l,left:s.left+(s.width-o)/2,top:s.top+(s.height-l)/2}}}export{kt as default};
8
+ class t{constructor(){this.events={}}on(t,i){return this.events[t]||(this.events[t]=[]),this.events[t].push(i),this}off(t,i){return this.events[t]?(this.events[t]=this.events[t].filter(t=>t!==i),this):this}once(t,i){const e=(...n)=>{this.off(t,e),i(...n)};return this.on(t,e),this}emit(t,...i){return this.events[t]&&[...this.events[t]].forEach(t=>t(...i)),this}clear(){this.events={}}}class i{constructor(t={},i=null){this.data=t,this.events=i}set(t,i){const e=this.data[t];e!==i&&(this.data[t]=i,this.events&&(this.events.emit(`state:${t}`,i,e),this.events.emit("state:change",t,i,e)))}get(t){return this.data[t]}merge(t,i=!0){const e={...this.data};this.data={...this.data,...t},!i&&this.events&&this.events.emit("state:change","multiple",this.data,e)}}const e={icon:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1"><path d="M6 6L18 18M18 6L6 18"/></svg>',iconZoom:'<svg class="icon" viewBox="0 0 21 21" xmlns="http://www.w3.org/2000/svg"><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" transform="translate(3 3)"><circle cx="5.5" cy="5.5" r="5"></circle><path d="M3.5 5.5h4"></path><path class="dc-lightbox__button-zoom-line" d="M5.5 3.5v4"></path><path d="M14.5 14.5l-5.367-5.367"></path></g></svg>',maxZoom:3,thumbnailsIcon:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="11" rx="2"/><rect x="3" y="17" width="4" height="4" rx="1"/><rect x="10" y="17" width="4" height="4" rx="1"/><rect x="17" y="17" width="4" height="4" rx="1"/></svg>',showThumbnailsOnOpen:!0,arrowIcon:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M15 4L7 12L15 20"/></svg>',backdropClick:"close",closeExisting:!1,parentContainer:"body",hideScrollbar:!0,effect:"fadeInDown",zoomImageFromOrigin:!0,animationDuration:400,autoClose:!1,type:"inline",caption:!1,slideChangeDuration:280,slideOffset:.1,beforeLayoutOpen:()=>{},layoutReady:()=>{},layoutOpened:()=>{},beforeLayoutClose:()=>{},layoutClosed:()=>{},extensions:{}},n="data-close",s="data-type",o="data-caption",l="data-gallery",a="prev",r="next",c="active",h={fallbackBase64:"data:image/svg+xml;base64,"+btoa('\n <svg xmlns="http://www.w3.org/2000/svg" width="10" height="10">\n <rect width="100%" height="100%" fill="#ddd"/>\n </svg>\n '),openedCounter:0,timer:[0],backdrop_actions:["close"],openEffects:["fadeInDown","fadeIn","fadeInUp","zoomIn"],closeAllPopup:"close-all",timingFunc:"cubic-bezier(0.4, 0, 0.22, 1)",timingFuncInvert:"cubic-bezier(0.78, 0, 0.6, 1)"},u="body--hidden",d="dc-lightbox",m="dc-lightbox--visible",f="dc-lightbox--animating",g="dc-lightbox--opened",p="dc-lightbox--closing",x="dc-lightbox--gallery",b="dc-lightbox--scale-from-origin-in",_="dc-lightbox--scale-to-origin-out",w="dc-lightbox--scaled-from-origin",y="dc-lightbox__close-area",v="dc-lightbox__wrapper",M="dc-lightbox__overlay",$="dc-lightbox__overlay--show",T="dc-lightbox__overlay--prevent-anim",k="dc-lightbox__viewport",A="dc-lightbox__thumbnails",C="dc-lightbox__thumbnails--hide",I="dc-lightbox__thumbnails-viewport",O="dc-lightbox__thumbnails-slider",F="dc-lightbox__thumbnails-slide",q="dc-lightbox__thumbnails-slide--active",D="dc-lightbox__toolbar",P="dc-lightbox__counter",S="dc-lightbox__counter-current",z="dc-lightbox__counter-all",L="dc-lightbox__button-close",R="dc-lightbox__button-zoom",j="dc-lightbox__button-zoom--in",E="dc-lightbox__button-zoom--disabled",X="dc-lightbox__button-thumbnails",Y="dc-lightbox__wrapper--slider",B="dc-lightbox__wrapper--has-thumbnails",N="dc-lightbox__arrow",Z="dc-lightbox__slides",H="dc-lightbox__slide",G="dc-lightbox__slide--active",U="dc-lightbox__slide--prev",K="dc-lightbox__slide--next",V="dc-lightbox__slide--has-spinner",W="dc-lightbox__spinner",J="dc-lightbox__slide-content",Q="dc-lightbox__img-large",tt="dc-lightbox__img-large--loading",it="dc-lightbox__img-large--loaded",et="dc-lightbox__img-zoomable",nt="dc-lightbox__img-grabbing",st="dc-lightbox__slide-content--zoomIn",ot="dc-lightbox__img-small",lt="dc-lightbox__slide-content--prevent-anim",at="dc-lightbox__img-placeholder",rt="dc-lightbox__info",ct="dc-lightbox__info--hide",ht="dc-lightbox__caption",ut="dc-lightbox__caption-data",dt="dc-lightbox__crtl",mt="dc-lightbox__crbr",ft="dc-lightbox__crimg",gt="dc-lightbox__inner",pt="dc-lightbox__close";function xt(t,i="",e=null,n=null){const s=document.createElement(t);i&&(s.className=i),n&&Object.entries(n).forEach(([t,i])=>{!1===i||null===i?s.removeAttribute(t):s.setAttribute(t,String(i))});const o=t=>{t instanceof Node?s.append(t):null!=t&&s.insertAdjacentHTML("beforeend",String(t))};return Array.isArray(e)?e.forEach(o):o(e),s}function bt(t,i){const e={...t};return i&&"object"==typeof i&&Object.keys(i).forEach(n=>{i[n]&&"object"==typeof i[n]&&!Array.isArray(i[n])?e[n]=bt(t[n]||{},i[n]):e[n]=i[n]}),e}const _t=new WeakMap,wt=new Map,yt=new Map,vt=new Map;let Mt=!1,$t=!1;class Tt{constructor(n,s={}){if(s.src){const t=s.src;if(wt.has(t))return wt.get(t);wt.set(s.src,this)}else{if(_t.has(n))return _t.get(n);_t.set(n,this)}this.el=n,this.options=bt(e,s),this.events=new t,this.state=new i({active:!1},this.events),this.extensions={};let o=n.getAttribute("href")||n.getAttribute("data-src")||"",a=this.t(o,n),r=null;"inline"===a&&(r=document.querySelector(o)),this.targetData={href:o,type:a,id:r?.getAttribute("id")||"",style:r?.getAttribute("style")||"",class:r?.getAttribute("class")||"",timer:h.timer};let c=n.getAttribute(l);if(this.galleryName=c&&"image"===a?c:null,this.galleryData=null,this.galleryName){this.smallSrc=this.el?.querySelector("img")?.src||this.targetData?.href||!1,vt.has(this.galleryName)||vt.set(this.galleryName,{instances:[],urls:[],count:0,o:[]});const t=vt.get(this.galleryName);if(t&&(this.galleryData=t,t.instances.push(this),this.smallSrc)){t.urls.push(this.smallSrc);const i=document.createElement("img");i.src=this.smallSrc,i.loading="eager",i.decoding="async",i.alt="",t.o.push(i),t.count++}}this.clickedImgRect=null}init(){if(this.state.get("active"))return;if(this.state.set("active",!0),this.options.silent)this.l();else{let t=this.el;this.h=new Map;const i=this.u.bind(this,t);this.h.set(t,i),t.addEventListener("click",i)}this.emit("before:mount"),this.options.extensions&&this.mount(this.options.extensions),this.emit("mounted"),this.m=new MutationObserver(t=>{t.forEach(t=>{t.removedNodes.forEach(t=>{(t===this.el||t.contains(this.el))&&this.destroy()})})});const t=this.el.parentElement||document.body;this.m.observe(t,{childList:!0})}p(t,i){i.preventDefault();let e=this.targetData;e.timer[0]&&clearTimeout(e.timer[0]);t.getAttribute(n)===h.closeAllPopup||this.options.closeExisting?kt.closeAll():this.closeModal()}async closeModal(){let t=this.options,i=this.targetData;if(!this.state.get("opened"))return;const{animationDuration:e}=t,{type:n}=i;if(i.readyLayout&&!i.readyLayout.classList.contains(p)){this.state.set("layout-ready",!1),Mt=!0;let s=null,o=i.readyLayout.querySelector(`.${M}`);const l=()=>new Promise(requestAnimationFrame);"image"===i.type&&(s=i.readyLayout.querySelector(`.${G} .${J}`),s&&(s.classList.remove(lt),o.classList.remove(T)),await new Promise(requestAnimationFrame),await new Promise(requestAnimationFrame)),o.classList.remove($),this.emit("beforeLayoutClose",{modalRef:i.readyLayout}),i.readyLayout.classList.remove(g),i.readyLayout.classList.remove(x),i.readyLayout.offsetWidth,i.readyLayout.classList.add(f,p);const a=this.el?.querySelector("img")?.getBoundingClientRect()||null;a||i.readyLayout.classList.remove(w);const r=()=>{c&&clearTimeout(c),i.readyLayout&&i.readyLayout.classList.remove(m,p,f);let e=null;"image"!==n?e=this._():this.el&&(e=this.el),"image"===n&&(i.originTarget?.remove(),i.originTarget=null,t.silent&&(this.caption&&(this.caption=null),this.options?.caption&&(this.options.caption=null),this.el=null)),this.v&&(this.v.forEach((t,i)=>{i.removeEventListener("click",t)}),this.v.clear()),kt.M&&(kt.M.forEach((t,i)=>{i.removeEventListener("click",t)}),kt.M.clear()),i.readyLayout?.remove(),i.readyLayout=null,this.placeholder&&(this.placeholder?.remove(),this.placeholder=null),this.emit("layoutClosed",{modalRef:e}),this.state.set("opened",!1),this.openedNumb=0,kt.hasAnyOpen||(kt.$(),document.documentElement.classList.remove("dc-lightbox-scroll"))};let c=0;if(t.zoomImageFromOrigin&&!t.silent&&a&&"image"===i.type){let t=s?.querySelector("img")?.getBoundingClientRect()||null,n=null;if(t&&(n=this.T(a,t),s.style.width=`${t.width}px`,s.style.height=`${t.height}px`,s.style.transform=`translate3d(${t.left}px, ${t.top}px, 0px)`),i.readyLayout.classList.add(_),await l(),await l(),n&&!n.isRatioCorrect){let i=s.querySelector("."+dt),e=s.querySelector("."+mt),o=e.querySelector("."+ft);this.k(a,t,n.scale,i,e,o),await l(),await l()}t&&(s.style.transition=`transform ${e}ms ${h.timingFunc}`,s.style.transform=`translate3d(${n.x}px, ${n.y}px, 0px) scale(${n.scale})`),s.addEventListener("transitionend",r,{once:!0}),c=setTimeout(()=>{r()},e+1e3)}else setTimeout(()=>{r()},e)}}u(t,i){i.preventDefault();const e=t.querySelector("img");this.clickedImgRect=e?e.getBoundingClientRect():null,this.l()}async A(t){return new Promise((i,e)=>{const n=new Image;let s;const o=()=>{s&&clearInterval(s)},l=()=>{o(),i({width:n.naturalWidth,height:n.naturalHeight,imgElement:n})};if(n.onload=l,n.onerror=()=>{o(),e(new Error(`Не вдалося завантажити: ${t}`))},n.loading="eager",n.decoding="async",n.src=t,n.complete&&n.naturalWidth)return l();s=setInterval(()=>{n.naturalWidth&&n.naturalHeight&&l()},10)})}async l(){kt.C();let t=this.options,i=this.targetData,{parentContainer:e,hideScrollbar:n,autoClose:s,animationDuration:o,zoomImageFromOrigin:l,silent:c}=t;const{href:u,type:d}=i,{clickedImgRect:p}=this;if(i.originTarget=this.I(u,d),u&&i.originTarget){let u=this.O();if(!this.state.get("layout-ready"))return;if(u instanceof Node){document.querySelector(e).append(u),kt.hasAnyOpen||n&&kt.F(),kt.q(t,u,d,p);let x=this.existGallery,_=u.querySelector("."+M);if(Mt=!1,"image"===d){let t=kt.D(u),i=u.querySelectorAll("."+N);i.length&&(kt.M=new Map,i.forEach(t=>{const i=kt.P.bind(this,{arrow:t,isClick:!0});kt.M.set(t,i),t.addEventListener("click",i)}));let e=t.querySelector("img"),n=l&&!c&&p,s=-1;if(n){let i=e.src;yt.has(i)&&(e.src=yt.get(i).src);let l=this.el.querySelector("img").cloneNode(!0),c=await kt.S(t,"show",n,this.el,this.clickedImgRect,!0);await new Promise(requestAnimationFrame),await new Promise(requestAnimationFrame),u.classList.add(m),setTimeout(()=>{_.classList.add($)},7);const{width:d,height:g}=await this.A(e.src);if(d&&g){let n=kt.L(d,g,t),m=this.R(d,n.width,e);this.j(u,m),e.classList.add(Q,tt),e.style.width=n.width+"px",e.style.height=n.height+"px",l.classList.add(ot);let _=this.T(p,n),y=null,v=null,M=null;_.isRatioCorrect?t.append(l):(y=xt("div",dt),v=xt("div",mt),M=xt("div",ft),M.append(e,l),y.append(M),v.append(y),t.append(v),this.k(p,n,_.scale,y,v,M)),t.style.width=`${n.width}px`,t.style.height=`${n.height}px`,t.style.transform=`translate3d(${_.x}px, ${_.y}px, 0px) scale(${_.scale})`,t.style.transformOrigin="0 0",u.classList.add(b,w),t.offsetWidth,_.isRatioCorrect||[y,v,M].forEach(t=>{t.style.transition=`transform ${o-.25*o}ms ${h.timingFunc}`}),t.style.transition=`transform ${o}ms ${h.timingFunc}`,requestAnimationFrame(()=>{requestAnimationFrame(()=>{t.style.transform=`translate3d(${n.left}px, ${n.top}px, 0) scale(1)`,_.isRatioCorrect||[y,v,M].forEach(t=>{t.style.transform="translate3d(0,0,0)"}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{c.remove(),c=null})});const d=async n=>{if(n.target===t&&"transform"===n.propertyName){if(t.removeEventListener("transitionend",d),!yt.has(i))try{await e.decode()}catch(n){await new Promise((t,i)=>{e.complete?t():(e.addEventListener("load",t,{once:!0}),e.addEventListener("error",i,{once:!0}))})}_.isRatioCorrect||[y,v,M].forEach(t=>{t.style.transition=`transform ${o}ms ${h.timingFuncInvert}`});let c=!1,m=0;requestAnimationFrame(()=>{requestAnimationFrame(()=>{e.classList.add(it);const i=n=>{if(n.target===e&&"opacity"===n.propertyName&&!c&&(c=!0,clearTimeout(m),m=null,l.src="",l.remove(),e.classList.remove(tt),e.removeAttribute("style"),e.removeEventListener("transitionend",i),t.removeAttribute("style"),u.classList.remove(b),yt.set(e.src,e),kt.X(yt,3),this.state.set("opened",!0),this.openedNumb=++h.openedCounter,this.Y(t),x&&(this.B(u),s=this.galleryData.instances.indexOf(this),-1!==s))){const t=[a,r],i={gallery:this.galleryData.instances,instance:this};t.forEach(t=>{kt.N({...i,direction:t,i:t===a?s-1:s+1})}),$t=!0}};e.addEventListener("transitionend",i),m=setTimeout(()=>{i({target:e,propertyName:"opacity"})},2500)})}),u.classList.remove(f),this.emit("layoutOpened",{modalRef:u})}};t.addEventListener("transitionend",d)})})}}else{const i=i=>{p||(i.style.opacity=1),kt.S(t,"hide",!1,null,null,!1);let e=i.getBoundingClientRect(),n=this.R(i.naturalWidth,e.width,i);this.j(u,n),setTimeout(()=>{if(u.classList.remove(f),l&&u.classList.add(w),this.state.set("opened",!0),this.openedNumb=++h.openedCounter,this.emit("layoutOpened",{modalRef:u}),this.Y(t),x&&(this.B(u),s=this.galleryData.instances.indexOf(this),-1!==s)){const t=[a,r],i={gallery:this.galleryData.instances,instance:this};t.forEach(t=>{kt.N({...i,direction:t,i:t===a?s-1:s+1})}),$t=!0}},o)};u.classList.add(m),setTimeout(()=>{_.classList.add($)},1),this.Z(e,(i,e)=>{kt.S(t,i,n,this.el,this.clickedImgRect,e)}).then(async()=>{await new Promise(requestAnimationFrame),await new Promise(requestAnimationFrame),i(e)})}}else u.classList.add(m),setTimeout(()=>{_.classList.add($)},1);this.emit("layoutReady",{modalRef:u}),u.classList.add(g,f),i.readyLayout=u,setTimeout(()=>{"image"!==d&&(this.state.set("opened",!0),this.openedNumb=++h.openedCounter,u.classList.remove(f),this.emit("layoutOpened",{modalRef:u})),this.H(),t&&s&&(i.timer[0]=setTimeout(()=>{this.closeModal()},s))},o)}}}O(){let t=this.targetData;const{id:i,style:e,class:n,type:s}=t;this.emit("beforeLayoutOpen",{modalRef:t.originTarget});let o=document.createElement("div"),l=this.G();if(o.append(l),o.classList.add(d),"image"!==s){const t=o.querySelector(`.${gt}`);t&&Array.from(t.children).filter(t=>!t.classList.contains(pt)).forEach(t=>{i&&(t.id=i),e&&t.setAttribute("style",e),n&&(t.className=n),t.style.display="block"})}return this.state.set("layout-ready",!0),o}G(){const t=this.targetData,{type:i,id:e}=t,{backdropClick:s,icon:o,iconZoom:l,thumbnailsIcon:a,showThumbnailsOnOpen:r,zoomImageFromOrigin:c}=this.options,u=document.createDocumentFragment();["id","style","class"].forEach(i=>t.originTarget.removeAttribute(i));const d=s&&Array.isArray(h.backdrop_actions)&&h.backdrop_actions.includes(s)?s:null,m=d&&"image"!==i?{[n]:d}:null;if("image"===i){let i=xt("button",R,l),e=xt("div",D,[i,xt("button",L,o,{[n]:""})]);i.addEventListener("click",t=>{this.U(t,t.currentTarget,!1)});let s=xt("div",M),h=xt("div",`${v} ${Y}`,null,m),d=xt("div",Z),f=xt("div",`${H} ${G}`,null,m);d.append(f);let g=xt("div",k,null),p=xt("div",J);t.originTarget instanceof Node?(c&&(t.originTarget.style.opacity=0),p.append(t.originTarget)):p.innerHTML=t.originTarget,g.append(p),f.append(g),this.K(f),h.append(d);if(this.existGallery){const t=this.galleryData.instances.indexOf(this);let i=xt("div",P),n=xt("span",S,t+1),s=xt("span",z,this.galleryData.count);i.append(n,s),e.prepend(i);let o=xt("div",`${H} ${U}`,null,m),l=xt("div",`${H} ${K}`,null,m);d.prepend(o),d.append(l),h.prepend(xt("div",`${N} ${N}--prev`,this.options.arrowIcon)),h.append(xt("div",`${N} ${N}--next`,this.options.arrowIcon));let c=xt("button",X,a);i.after(c);let u=xt("div",A),f=xt("div",I),g=xt("div",O);f.append(g),u.append(f),h.append(u);const p=localStorage.getItem("dcThumbnails");(null!==p?"true"===p:r)&&h.classList.add(B),c.addEventListener("click",()=>{const t=h.classList.toggle(B);localStorage.setItem("dcThumbnails",t)})}return u.append(e,s,h),u}let f=xt("div",M),g=xt("div",v),p=xt("span",y,null,m),x=xt("div",gt),b=xt("button",pt,o,{[n]:""});return x.append(b),t.originTarget instanceof Node?(this.placeholder=document.createComment(`placeholder-for-${e||"element"}`),t.originTarget.before(this.placeholder),x.append(t.originTarget)):x.innerHTML+=t.originTarget,g.append(p,x),u.append(f,g),u}_(){if(this.placeholder?.parentNode){let t=this.targetData.readyLayout.querySelector("#"+this.targetData.id);if(t)return t.style.display="none",this.placeholder.replaceWith(t),t}return!1}I(t,i=this.options.type){return"image"===i?this.V(t):this.W(t)}R(t,i,e=null){const n=t/i;let s=Math.min(n,this.options.maxZoom)>1;return s&&e&&(e.classList.add(et),e.setAttribute("draggable","false")),s}j(t,i){if(!t)return;const e=t.querySelector("."+R);e&&(e.classList.remove(j),e.classList.toggle(E,!i))}J(t,i,e){return Math.max(i,Math.min(e,t))}tt(t,i){const e=getComputedStyle(t),n=new DOMMatrix(e.transform),{minX:s,maxX:o,minY:l,maxY:a}=i,r=this.J(n.m41,s,o),c=this.J(n.m42,l,a);if(n.m41===r&&n.m42===c)return;t.style.transition="transform 0.48s cubic-bezier(0.25, 0.82, 0.15, 1)",t.style.transform=`translate3d(${Math.round(r)}px, ${Math.round(c)}px, 0) scale(${n.a})`;const h=()=>{t.style.transition="",t.removeEventListener("transitionend",h)};t.addEventListener("transitionend",h)}U(t,i,e=!0){let n=kt.lastOpenedInstance;if(!n)return;let s=n.state.get("opened"),o=n.targetData.readyLayout.querySelector(`.${G} .${J} img`);if(s&&o){let s=n.options.maxZoom,l=o.getBoundingClientRect(),a=l.width,r=o.naturalWidth/a,c=Math.min(r,s);if(c){let s=o.closest("."+J);const a=s.classList.contains(st),r=t=>{if(t.target!==o||"transform"!==t.propertyName)return;o.removeEventListener("transitionend",r);let i=o.getBoundingClientRect(),e=Math.round(i.width),s=Math.round(i.height),l=0,a=0;const h=getComputedStyle(o).transform;if(h&&"none"!==h){const t=new DOMMatrixReadOnly(h);l=t.m41,a=t.m42}l=Math.round(l),a=Math.round(a),o.style.willChange="transform",o.style.transition="none",o.style.width=e+"px",o.style.height=s+"px",o.style.maxWidth="none",o.style.maxHeight="none",o.style.transform=`translate(${l}px, ${a}px) scale(1)`,n.targetData.imgScaleVal=c,requestAnimationFrame(()=>{requestAnimationFrame(()=>{o.style.transition=""})})},h=t=>{t.target===o&&"transform"===t.propertyName&&(s.classList.remove(st),i.classList.remove(j),o.classList.remove(nt),o.style.transformOrigin="center center",o.style.width="",o.style.height="",o.style.maxWidth="",o.style.maxHeight="",o.style.transform="",o.style.willChange="",o.removeEventListener("transitionend",h))};if(a||n.targetData.imgScaleVal)n.targetData.imgScaleVal&&(o.style.transition="",o.style.transform=`scale(${1/n.targetData.imgScaleVal})`,n.targetData.imgScaleVal=!1,n.it(),o.addEventListener("transitionend",h));else if(c>1){if(i.classList.add(j),s.classList.add(st),e){const i=window.innerWidth,e=window.innerHeight,n=l.left+l.width/2,s=l.top+l.height/2,a=t.clientX-n,r=t.clientY-s;let h=-a*(c-1),u=-r*(c-1);const d=l.width*c,m=l.height*c,f=Math.max(0,(d-i)/2),g=Math.max(0,(m-e)/2);h=Math.max(-f,Math.min(f,h)),u=Math.max(-g,Math.min(g,u)),o.style.transform=`translate(${Math.round(h)}px, ${Math.round(u)}px) scale(${c})`}else o.style.transform=`scale(${c})`;o.addEventListener("transitionend",r),o.style.transformOrigin=""}}}return!1}V(t){if(!t)return!1;let i=document.createElement("img");return i.src=t,i.alt="",i}et(){let t=this.options.caption;if(this.el){const i=this.el.getAttribute(o);i&&"false"!==i&&(t=i)}return t&&(t=t.trim()),t}W(t){if(!t||!t.startsWith("#")||t.length<=1)return!1;const i=document.querySelector(t);return!!i&&(!this.state.get("opened")&&i)}t(t,i=null){if(i){const t=i.getAttribute(s);if(t&&"false"!==t)return t}let e=this?.options?.type||"inline";return t&&/(^data:image\/[a-z0-9+\/=]*,)|\.(jpe?g|gif|png|bmp|webp|svg|ico)([\?#].*)?$/i.test(t)&&(e="image"),e}mount(t){for(const[i,e]of Object.entries(t)){let t=e;if("object"==typeof t&&null!==t&&("function"==typeof t[i]?t=t[i]:"function"==typeof t.default&&(t=t.default)),"function"!=typeof t)continue;const n=new t(this);this.extensions[i]=n,"function"==typeof n.mount&&n.mount()}}on(t,i){return this.events.on(t,i),this}off(t,i){return this.events.off(t,i),this}emit(t,i){return this.events.emit(t,i),this}destroy(){this.state.get("active")&&(this.emit("before:destroy"),this.m&&(this.m.disconnect(),this.m=null),Object.keys(this.extensions).forEach(t=>{this.extensions[t].destroy?.(),this.extensions[t]=null}),this.extensions={},this.el&&(_t.delete(this.el),kt.instances.delete(this),this.el=null),this.targetData&&(this.targetData=null),this.placeholder&&(this.placeholder=null),this.openedNumb&&(this.openedNumb=null),this.galleryData&&(vt.delete(this.galleryName),this.galleryData=null),yt&&yt.clear(),this?.options?.src&&wt.delete(this.options.src),this.h&&(this.h.forEach((t,i)=>{i.removeEventListener("click",t)}),this.h.clear()),this.v&&(this.v.forEach((t,i)=>{i.removeEventListener("click",t)}),this.v.clear()),h.openedCounter=0,this.state.set("active",!1),this.state.set("layout-ready",!1),this.emit("destroyed"),this.events.clear())}k(t,i,e,n,s,o){const l=2*e,a=.5*i.width-t.width/l,r=.5*i.height-t.height/l,c=(t,i,e)=>{const n=Math.round(1e4*i)/1e4,s=Math.round(1e4*e)/1e4;t.style.transform=`translate3d(${n}px, ${s}px, 0)`};c(n,2*a,2*r),c(s,-a,-r),c(o,-a,-r)}T(t,i){if(!t||!i)return;const e=t.width/i.width,n=t.height/i.height,s=e.toFixed(2)===n.toFixed(2),o=Math.max(e,n);return{isRatioCorrect:s,scale:o,x:.5*t.width+t.left-i.width*o*.5,y:.5*t.height+t.top-i.height*o*.5}}Z(t,i){const e=!t.complete||0===t.naturalWidth;let n=!1;const s=(t=!1)=>{n||(n=!0,i("show",t))};return(e?new Promise(i=>{s(),t.addEventListener("load",i,{once:!0}),t.addEventListener("error",i,{once:!0})}):Promise.resolve()).then(()=>{if(t.decode)return s(!0),t.decode().catch(t=>{})}).finally(()=>{})}H(){let t=this.targetData.readyLayout.querySelectorAll(`[${n}]`);t.length&&(this.v=new Map,t.forEach(t=>{const i=this.p.bind(this,t);this.v.set(t,i),t.addEventListener("click",i)}))}K(t){const i=this.et();if(t?.querySelector("."+rt)?.remove(),i){this.caption=i;const e=xt("div",rt),n=xt("div",ht),s=xt("div",ut,i);n.append(s),e.append(n),t.append(e),e.addEventListener("click",t=>{t.stopPropagation()})}}it(){this.frame&&cancelAnimationFrame(this.frame),this.frame=null}nt(t,i){const e=t.getBoundingClientRect(),n=i.getBoundingClientRect();this.limits={minX:Math.min(0,(e.width-n.width)/2),maxX:Math.max(0,(n.width-e.width)/2),minY:Math.min(0,(e.height-n.height)/2),maxY:Math.max(0,(n.height-e.height)/2)};const s=new DOMMatrix(getComputedStyle(i).transform);this.zoomedScale=s.a}Y(t){let i={activeSlide:t.closest("."+G),pSlide:null,nSlide:null},e=t.closest("."+k),n=null,s=!0,o=null,l=!0,c=0,u=0,d=null,m=0,f=0,g=!1,p=!1;let x=this.options.animationDuration||100,b=this.options.zoomImageFromOrigin,_=null,w=null,y=!1,v=!1,$=null,I=null,O=null,F=!1,q=!1,D=null,P=null,S=0,z=0,L=0,j=null,E=t.closest("."+Z),X=null,Y=null,H=0,U=0,K=null,V=!1,W=0,J=0,Q=0,tt=0,it=0;this.frame=null,this.targetData.imgScaleVal=null;let ot=0,at=0;const ht=x=>{if(x.pointerId===j&&g){if(!p&&X){if(K&&!V){let t=this.targetData.readyLayout.querySelector("."+R);this.U(x,t)}if(K&&Y&&V){this.frame&&cancelAnimationFrame(this.frame);const{minX:t,maxX:i,minY:e,maxY:n}=this.limits,s=getComputedStyle(K),o=new DOMMatrix(s.transform);let l=o.m41,a=o.m42;const r=o.a,c=.9,h=()=>{l<t?(W*=.68,l+=.12*(t-l)):l>i&&(W*=.68,l+=.12*(i-l)),a<e?(J*=.68,a+=.12*(e-a)):a>n&&(J*=.68,a+=.12*(n-a)),l+=W,a+=J,W*=c,J*=c,K.style.transform=`translate3d(${Math.round(l)}px, ${a}px, 0) scale(${r})`,K.classList.remove(nt);if(Math.hypot(W,J)<.25)return W=0,J=0,this.tt(K,{minX:t,maxX:i,minY:e,maxY:n}),void(this.frame=null);this.frame=requestAnimationFrame(h)};this.frame=requestAnimationFrame(h)}V=!1}if(g=!1,E.style.transition="","x"===d){const t=f-u,i=e.clientWidth;let n=Math.abs(S);n<30&&(n*=1e3);const s=.32*i,o=650,l=t+.2*S;if(p&&_&&(Math.abs(t)>s||n>o||Math.abs(l)>.48*i)){const t=this.state.get("opened"),i=l>0?a:r;let e=document.querySelector("."+N+"--"+i);e&&t&&kt.P.call(this,{arrow:e,isClick:!1})}else p&&(E.style.transform="",setTimeout(()=>{E.style.willChange="auto"},this.options.slideChangeDuration))}if("y"===d){const a=m-c,r=Math.min(100,.2*D);p&&Math.abs(a)>r?(I.style.opacity=0,I=null,b||(t.style.opacity=0),Mt=!0,this.closeModal()):p&&(t.style.transition=`transform 0.3s ${h.timingFunc}`,t.style.transform="",I.style.transition=`opacity 0.3s ${h.timingFunc}`,I.style.opacity=1,P=setTimeout(()=>{t.style.transition="",I.style.transition="",I.style.opacity="",I.classList.remove(T),t.style.willChange="",n&&(n.classList.remove(ct),s=!0),o&&(o.classList.remove(C),l=!0,i.activeSlide.style.overflow="",e.style.overflow=""),n=null,o=null},300),b||(t.style.animation="",t.classList.add(lt)))}c=0,u=0,m=0,f=0,$=null,D=null,p=!1,d=null,e.releasePointerCapture(j),j=null}},ut=(t,i)=>{if(d)return d;const e=Math.abs(t),n=Math.abs(i);return e<24&&n<24?null:(d=e>n?"x":"y",d)};e.addEventListener("pointerdown",e=>{if(null!==j)return;if(j=e.pointerId,K=e.target.closest("img"),!this.state.get("layout-ready"))return;P&&clearTimeout(P),c=e.clientY,u=e.clientX,m=c,f=u,$=document.documentElement.clientWidth,D=document.documentElement.clientHeight,_=this.existGallery,I=this.targetData.readyLayout.querySelector("."+M),I.style.willChange="opacity",I.classList.add(T),d=null,g=!0,p=!1,n=i.activeSlide.querySelector("."+rt),o=i.activeSlide.closest("."+B)?.querySelector("."+A),b?(t.style.transition="",t.style.willChange="transform"):(t.style.opacity=1,t.style.transition=`opacity ${x}ms ${h.timingFunc}`,t.style.willChange="transform, opacity"),_&&(i.pSlide=kt.st(this,a),i.nSlide=kt.st(this,r)),E.style.transition="none",E.style.willChange="transform";let s=t.querySelector("img");if(s&&s.classList.contains(et)&&(X=!0,Y=!!t.classList.contains(st),Y&&K&&this.targetData.imgScaleVal)){s.classList.add(nt);const i=getComputedStyle(s),e=new DOMMatrix(i.transform);this.it(),s.style.transition="",this.nt(t,s),ot=e.m41,at=e.m42,W=J=0,tt=ot,it=at}}),e.addEventListener("pointermove",a=>{if(a.pointerId!==j)return;if(!g)return;m=a.clientY,f=a.clientX;const r=m-c,h=f-u;if(Y&&K&&this.targetData.imgScaleVal&&this.limits&&K.classList.contains(nt)){if(!V){const t=Math.hypot(h,r);if(t<12)return;V=!0;H=12*(h/t),U=12*(r/t)}let i=t.querySelector("img"),e=ot+h-H,n=at+r-U;const{minX:s,maxX:o,minY:l,maxY:a}=this.limits,c=.25;e>o?e=o+(e-o)*c:e<s&&(e=s+(e-s)*c),n>a?n=a+(n-a)*c:n<l&&(n=l+(n-l)*c),i.style.transition="none",i.style.transform=`translate3d(${Math.round(e)}px, ${Math.round(n)}px, 0) scale(${this.zoomedScale})`;const u=performance.now(),d=u-Q;if(d>8&&d<100){W=(e-(tt||ot))/d*16,J=(n-(it||at))/d*16}tt=e,it=n,Q=u}if(ut(h,r),"x"===d&&!Y){const i=performance.now(),e=i-L;if(e>8&&e<120){S=.65*S+.35*((f-z)/e*1e3)}if(z=f,L=i,!p){if(Math.abs(h)<20)return;p=!0,w=h>0?1:-1,t.style.willChange=""}const n=h-20*w;n>0&&!y?(y=!0,v=!1):n<0&&!v&&(v=!0,y=!1);const s=n/$*100;E.style.transform=`translate3d(${s}%, 0, 0)`}if("y"===d&&!Y){if(!p){if(Math.abs(r)<40)return;p=!0,E.style.willChange="",O=r>0?1:-1}const a=r-40*O;a>0&&!q?(q=!0,F=!1):a<0&&!F&&(F=!0,q=!1);const c=a/D*100,h=Math.abs(c+(q?-100:100));I.style.opacity=h+"%",b&&this.clickedImgRect||(t.style.animation="none"),t.style.transform=`translate3d(0, ${a}px, 0)`,n&&s&&(s=!1,n.classList.add(ct)),o&&l&&(l=!1,o.classList.add(C),i.activeSlide.style.overflow="visible",e.style.overflow="visible")}(p||Y)&&e.setPointerCapture(j),a.cancelable&&a.preventDefault()}),e.addEventListener("pointerup",ht),e.addEventListener("pointercancel",ht)}get existGallery(){return this.galleryData?.urls.length>1||!1}B(t){if(this.existGallery){let i=this.galleryData,e=t,n=t.querySelector("."+A),s=e.querySelector("."+I),o=e.querySelector("."+O),l=null,c=i.instances.indexOf(this);if(this.galleryData.o.length>1){const t=document.createDocumentFragment();this.galleryData.o.forEach((i,e)=>{let n=document.createElement("div");n.className=F,n.dataset.index=e,n.appendChild(i.cloneNode(!0)),t.appendChild(n)}),o.appendChild(t)}l=o.querySelectorAll("."+F),n.addEventListener("click",t=>{if(t.target.closest(`.${q}`))return;const i=t.target.closest(`.${F}`);if(!i)return;const e=i.parentNode.children;let n=-1,l=null,c=0;for(const t of e)t.classList.contains(q)&&(n=c),c++;if(l=this.galleryData.instances[n],!l||!l.state.get("opened")||!$t)return;o.style.transition="",e[n].classList.remove(q),i.classList.add(q);let h=parseInt(i.getAttribute("data-index")),u=h>n?r:a,d=document.querySelector("."+N+"--"+u);kt.P.call(l,{arrow:d,isClick:!1,isThumbnailClick:!0,targetIndex:h}),kt.ot({viewportThumbnail:s,sliderThumbnails:o,activeThumbnail:i})});const h=n.querySelector("."+I);if(kt.lt(h),-1!==c){const t=l[c];t&&(t.classList.add(q),kt.ot({viewportThumbnail:s,sliderThumbnails:o,activeThumbnail:t,silent:!0}))}}}}class kt{static instances=new Map;static Extensions={};constructor(t=null,i={}){let e=null;if(null===t){i.silent=!0;let t=xt("a","","",{href:i?.src||"",caption:i?.caption||""});e=kt.rt(t)}else e=kt.rt(t);if(!e.length)return null;const n=e.map(e=>{if(null===t){let t=i?.src||"";if(wt.has(t))return wt.get(t)}else if(_t.has(e))return _t.get(e);const n=new Tt(e,i);return kt.instances.set(n,n),n}),s=1===n.length?n[0]:n;return Array.isArray(s)&&(s.on=(t,i)=>(s.forEach(e=>e.on(t,i)),s)),setTimeout(()=>{Array.isArray(s)?s.forEach(t=>t.init()):s.init()},0),s}static rt(t){return"string"==typeof t?Array.from(document.querySelectorAll(t)):t instanceof HTMLElement?[t]:Array.isArray(t)?t.filter(t=>t instanceof HTMLElement):[]}static destroyAll(){Array.from(this.instances.values()).forEach(t=>{t.destroy()}),this.instances.clear()}static closeAll(){this.allOpened.forEach(t=>{t.closeModal()}),h.openedCounter=0}static get allOpened(){return Array.from(this.instances.values()).filter(t=>t.state.get("opened")).sort((t,i)=>i.openedNumb-t.openedNumb)}static get hasAnyOpen(){for(const t of this.instances.values())if(t.state.get("opened"))return!0;return!1}static get lastOpenedInstance(){let t=null,i=-1;for(const e of this.instances.values())e.state.get("opened")&&e.openedNumb>i&&(i=e.openedNumb,t=e);return t}static q(t,i,e,n){let{animationDuration:s=0,effect:o="fadeInDown",zoomImageFromOrigin:l}=t;l&&!t.silent&&"image"===e&&n&&(o="fadeIn");const a=h.openEffects.includes(o)?o:"fadeInDown",r={fadeInDown:-40,fadeInUp:40}[a]??0,c={"--animationDuration":`${Number(s)||0}ms`,"--animationEffect":a,"--imageInitPosition":`${r}px`,"--slideChangeDuration":t.slideChangeDuration+"ms","--slideOffset":t.slideOffset};Object.entries(c).forEach(([t,e])=>{i.style.setProperty(t,e)})}static async ct(t){await new Promise((i,e)=>{t.complete?i():(t.addEventListener("load",i,{once:!0}),t.addEventListener("error",e,{once:!0}))});try{await t.decode()}catch(t){}return t}static async S(t,i="show",e=!0,n=null,s=null,o=!1){const l="."+W,a="."+at,r="."+H,c=t.querySelector(l),h=t.closest(r),u=e&&n&&s;if("show"===i){if(!o&&!c&&(t.append(xt("div",W)),h?.classList.add(V)),u){const i=h?.querySelector(a);if(!i){const i=n.querySelector("img");if(i){const e=i.cloneNode(!1);return Object.assign(e.style,{width:s.width+"px",height:s.height+"px",top:s.top+"px",left:s.left+"px"}),e.classList.add(at),t.before(e),await kt.ct(e)}}}}else if("hide"===i){const t=h?.querySelector(a);t&&setTimeout(()=>{t.remove()},4),c?.remove(),h?.classList.remove(V)}}static show(t){if(t?.src||"")return new kt(null,t)}static st(t,i){const e={[a]:U,[r]:K,[c]:G}[i];return t.targetData.readyLayout.querySelector(`.${e}`)}static async N(t={}){const{gallery:i,i:e=0,direction:n="next",instance:s}=t;Mt=!1;const o=i[(e+i.length)%i.length];if(!s.targetData.readyLayout)return;let l=kt.st(s,n);l.innerHTML="";let a=xt("div",k),r=xt("div",J);a.append(r),l.append(a),kt.S(r,"show",!1,null,null,!1);let c=await(u=o.targetData.href,yt.has(u)?Promise.resolve(yt.get(u)):new Promise(t=>{const i=async()=>{try{const i=await async function(t){if(yt.has(t))return yt.get(t);const i=new Image;if(await new Promise((e,n)=>{i.onload=e,i.onerror=n,i.loading="eager",i.decoding="async",i.src=t}),i.decode)try{await i.decode()}catch(t){}return yt.set(t,i),kt.X(yt,3),i}(u);t(i)}catch(i){t(null)}};"requestIdleCallback"in window?requestIdleCallback(i,{timeout:200}):setTimeout(i,0)}));var u;let d=c.cloneNode(!1);return d&&d.decode&&d.decode().then(()=>{kt.S(r,"hide",!1,null,null,!1)}).catch(()=>{kt.S(r,"hide",!1,null,null,!1)}),Mt?void 0:(r.append(d),new Promise(t=>{let i=null,e=null,n=null;const s=kt.L(d.naturalWidth,d.naturalHeight,d.parentElement),l=o.el.querySelector("img")?.getBoundingClientRect();let a=o.T(l,s);a?.isRatioCorrect||(i=xt("div",dt),e=xt("div",mt),n=xt("div",ft),n.append(d),i.append(n),e.append(i),[i,e,n].forEach(t=>{t.style.transform="translate3d(0, 0, 0)",t.style.transition=`transform ${o.options.animationDuration}ms ${h.timingFuncInvert}`}),r.append(e)),t()}))}static P(t,i){let{arrow:e,isClick:n,isThumbnailClick:s=!1,targetIndex:o=-1}=t;!0===n&&(i.preventDefault(),i.stopPropagation());let l=!!e.classList.contains(`${N}--${r}`),h=this.galleryData.instances;const u=h.findIndex(t=>t.state.get("opened")),d=-1!==u?h[u]:null;if(!d)return;if(!$t)return;$t=!1;let m=d.state.get("layout-ready");if(-1!==u&&m){d.state.set("layout-ready",!1),d.state.set("opened",!1),d.openedNumb=0,d.targetData.readyLayout.classList.add(x);let t=kt.st(d,a),i=kt.st(d,r),e=kt.st(d,c),n=null,m=null,f=null,g=!0,p=null;if(s&&-1!==o){if(f=o,n=h[f],g=1===Math.abs(u-o),!g){let t=l?r:a;p=kt.N({gallery:h,instance:d,direction:t,i:f})}}else m=l?1:-1,f=(u+m+h.length)%h.length,n=h[f];const b=l?i:t;b.style.visibility="visible";const _=l?t:i;let w=null;w=""+(l?"to-left":"to-right");let y=e.closest("."+Z);if(y.style.transition="",y.style.willChange="transform",!s){let t=document.querySelector("."+A);if(t){let i=t.querySelector("."+I),e=t.querySelector("."+O),n=e.querySelectorAll("."+F),s=n[f];for(const t of n)t.classList.remove(q);s.classList.add(q),kt.ot({viewportThumbnail:i,sliderThumbnails:e,activeThumbnail:s})}}const v=async t=>{if(t.target===y&&"transform"===t.propertyName){y.style.transition="none",y.style.transform="",y.classList.remove("to-left","to-right"),n.targetData.readyLayout=d.targetData.readyLayout,n.state.set("layout-ready",!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>{y.style.transition="",n.state.set("opened",!0),n.openedNumb=1})}),n.H(),d.v&&(d.v.forEach((t,i)=>{i.removeEventListener("click",t)}),d.v.clear()),d.targetData.originTarget?.remove(),d.targetData.originTarget=null,d.targetData.readyLayout=null;const i={next:K,prev:U};let s=`${H} ${i[l?a:r]}`,o=`${H} ${i[l?r:a]}`,c=`${H} ${G}`;const u=(t,i)=>{t.className=i,t.innerHTML="",t.style.transform="",t.style.visibility=""};u(e,s),b.className=c,b.style.transform="",b.style.visibility="",y.removeEventListener("transitionend",v),u(_,o),document.querySelector("."+S).innerText=+f+1;let m=kt.D(n.targetData.readyLayout),x=this;function w(t){let i=t.getBoundingClientRect(),e=x.R(t.naturalWidth,i.width,t);t.removeAttribute("loading"),t.removeAttribute("decoding"),x.j(n.targetData.readyLayout,e)}function M(t){t.complete?w(t):t.addEventListener("load",()=>{w(t)},{once:!0})}const $=m.querySelector("img");if($)M($);else{new MutationObserver((t,i)=>{const e=m.querySelector("img");e&&(M(e),i.disconnect())}).observe(m,{childList:!0,subtree:!0})}let T=n.targetData.readyLayout.querySelector(`.${J}`);n.Y(T);const k=[a,r],A={gallery:h,instance:n};g||await p,k.forEach(t=>{kt.N({...A,direction:t,i:t===a?f-1:f+1})}),$t=!0}};requestAnimationFrame(()=>{y.classList.add(w),n.K(b)}),y.addEventListener("transitionend",v)}}static C(t=!1){this.ht||(document.addEventListener("keydown",t=>{let i=t.key;if("Escape"===i){const t=this.lastOpenedInstance;t&&(t?.options?.closeExisting?kt.closeAll():t.closeModal())}if("ArrowLeft"===i||"ArrowRight"===i){const t=this.lastOpenedInstance;let e="ArrowLeft"===i?a:r,n=document.querySelector("."+N+"--"+e);n&&t&&kt.P.call(t,{arrow:n,isClick:!1})}}),this.ht=!0)}static F(){const t=document.documentElement.scrollHeight>window.innerHeight;document.body.classList.contains(u)||(document.body.classList.add(u),t?document.documentElement.classList.add("dc-lightbox-scroll"):document.documentElement.classList.remove("dc-lightbox-scroll"))}static $(){document.body.classList.remove(u)}static D(t){const i=t.querySelector("."+G+" ."+J);return i?(i.addEventListener("click",function(t){t.stopPropagation()}),i):null}static ot(t){const{viewportThumbnail:i,sliderThumbnails:e,activeThumbnail:n,silent:s=!1}=t,o=i.clientWidth,l=e.scrollWidth,a=window.getComputedStyle(e),r=new DOMMatrixReadOnly(a.transform).m41;if(e.style.transition=s?"none":"",l<=o){const t=(o-l)/2;return void(e.style.transform=`translateX(${t}px)`)}const c=o/2,h=n.offsetLeft+n.offsetWidth/2,u=h+r;let d=r;(u<.3*o||u>.7*o)&&(d=c-h);const m=o-l;d=Math.max(m,Math.min(0,d)),Math.abs(d-r)<1||(e.style.transform=`translateX(${d}px)`)}static lt(t){const i=t.querySelector("."+O);if(!i)return;let e=0,n=0,s=0,o=!1,l=!1,a=0;let r=null,c=0,h=0,u=0,d=null;const m=()=>{const t=getComputedStyle(i);return new DOMMatrixReadOnly(t.transform).m41||0},f=()=>{const e=i.scrollWidth,n=t.clientWidth;if(e<=n){const t=(n-e)/2;return{min:t,max:t}}return{min:n-e,max:0}},g=e=>{if(e.pointerId===r&&o){if(o=!1,l)(()=>{let t=m();const{min:e,max:n}=f();c=Math.max(-85,Math.min(85,c));const s=()=>{if(t+=c,t>n?(t=n+.915*(t-n),c*=.72):t<e&&(t=e-.915*(e-t),c*=.72),c*=.935,i.style.transform=`translate3d(${t}px, 0, 0)`,Math.abs(c)>.15&&t>e-5&&t<n+5)d=requestAnimationFrame(s);else{const s=Math.max(e,Math.min(n,t));Math.abs(s-t)>.5&&(i.style.transition="transform 0.45s cubic-bezier(0.25, 0.8, 0.25, 1)",i.style.transform=`translate3d(${s}px, 0, 0)`),d=null}};d=requestAnimationFrame(s)})();else{const{min:t,max:e}=f(),n=m(),s=Math.max(t,Math.min(e,n));s!==n&&(i.style.transition="transform 0.4s ease-out",i.style.transform=`translate3d(${s}px, 0, 0)`)}try{t.releasePointerCapture(r)}catch(t){}r=null}},p={passive:!1};t.addEventListener("pointerdown",t=>{null===r&&("touch"!==t.pointerType||t.isPrimary)&&(d&&cancelAnimationFrame(d),d=null,r=t.pointerId,e=n=h=t.clientX,u=performance.now(),s=m(),c=0,o=!0,l=!1,a=0,i.style.transition="none")},p),t.addEventListener("pointermove",d=>{if(d.pointerId!==r||!o)return;n=d.clientX;const m=n-e;if(!l){if(Math.abs(m)<15)return;l=!0,a=m>0?1:-1,t.setPointerCapture(r),i.style.transition="none"}let g=s+(m-15*a);const{min:p,max:x}=f();g>x?g=x+.28*(g-x):g<p&&(g=p+.28*(g-p)),i.style.transform=`translate3d(${g}px, 0, 0)`;const b=performance.now(),_=b-u;if(_>8&&_<120){c=(g-(h!==n?h:s))/_*16.67}h=g,u=b,d.cancelable&&d.preventDefault()},p),t.addEventListener("pointerup",g,p),t.addEventListener("pointercancel",g,p)}static X(t,i){for(;t.size>i;){const i=t.keys().next().value;t.delete(i)}}static L(t,i,e){const n=i/t,s=e.getBoundingClientRect();let o=Math.min(t,s.width),l=o*n;l>s.height&&(l=s.height,o=l/n);return{width:o,height:l,left:s.left+(s.width-o)/2,top:s.top+(s.height-l)/2}}}export{kt as default};
@@ -1,8 +1,8 @@
1
1
  /*!
2
- * @divclass/lightbox v1.1.2 | May 21st 2026
2
+ * @divclass/lightbox v1.1.4 | May 22nd 2026
3
3
  * Source: https://github.com/divclass-org/lightbox.git
4
4
  * Homepage: https://lightbox.divclass.org/
5
5
  * (c) 2026 Taras Bilinskyi | Released under the MIT License
6
6
  */
7
7
 
8
- !function(t,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define(i):(t="undefined"!=typeof globalThis?globalThis:t||self).DivclassLightbox=i()}(this,function(){"use strict";class t{constructor(){this.events={}}on(t,i){return this.events[t]||(this.events[t]=[]),this.events[t].push(i),this}off(t,i){return this.events[t]?(this.events[t]=this.events[t].filter(t=>t!==i),this):this}once(t,i){const e=(...n)=>{this.off(t,e),i(...n)};return this.on(t,e),this}emit(t,...i){return this.events[t]&&[...this.events[t]].forEach(t=>t(...i)),this}clear(){this.events={}}}class i{constructor(t={},i=null){this.data=t,this.events=i}set(t,i){const e=this.data[t];e!==i&&(this.data[t]=i,this.events&&(this.events.emit(`state:${t}`,i,e),this.events.emit("state:change",t,i,e)))}get(t){return this.data[t]}merge(t,i=!0){const e={...this.data};this.data={...this.data,...t},!i&&this.events&&this.events.emit("state:change","multiple",this.data,e)}}const e={icon:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1"><path d="M6 6L18 18M18 6L6 18"/></svg>',iconZoom:'<svg class="icon" viewBox="0 0 21 21" xmlns="http://www.w3.org/2000/svg"><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" transform="translate(3 3)"><circle cx="5.5" cy="5.5" r="5"></circle><path d="M3.5 5.5h4"></path><path class="dc-lightbox__button-zoom-line" d="M5.5 3.5v4"></path><path d="M14.5 14.5l-5.367-5.367"></path></g></svg>',maxZoom:3,thumbnailsIcon:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="11" rx="2"/><rect x="3" y="17" width="4" height="4" rx="1"/><rect x="10" y="17" width="4" height="4" rx="1"/><rect x="17" y="17" width="4" height="4" rx="1"/></svg>',showThumbnailsOnOpen:!0,arrowIcon:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M15 4L7 12L15 20"/></svg>',backdropClick:"close",closeExisting:!1,parentContainer:"body",hideScrollbar:!0,effect:"fadeInDown",zoomImageFromOrigin:!0,animationDuration:400,autoClose:!1,type:"inline",caption:!1,slideChangeDuration:280,slideOffset:.1,beforeLayoutOpen:()=>{},layoutReady:()=>{},layoutOpened:()=>{},beforeLayoutClose:()=>{},layoutClosed:()=>{},extensions:{}},n="data-close",s="data-type",o="data-caption",l="data-gallery",a="prev",r="next",c="active",h={fallbackBase64:"data:image/svg+xml;base64,"+btoa('\n <svg xmlns="http://www.w3.org/2000/svg" width="10" height="10">\n <rect width="100%" height="100%" fill="#ddd"/>\n </svg>\n '),openedCounter:0,timer:[0],backdrop_actions:["close"],openEffects:["fadeInDown","fadeIn","fadeInUp","zoomIn"],closeAllPopup:"close-all",timingFunc:"cubic-bezier(0.4, 0, 0.22, 1)",timingFuncInvert:"cubic-bezier(0.78, 0, 0.6, 1)"},u="body--hidden",d="dc-lightbox",m="dc-lightbox--visible",f="dc-lightbox--animating",g="dc-lightbox--opened",p="dc-lightbox--closing",b="dc-lightbox--gallery",x="dc-lightbox--scale-from-origin-in",_="dc-lightbox--scale-to-origin-out",w="dc-lightbox--scaled-from-origin",y="dc-lightbox__close-area",v="dc-lightbox__wrapper",M="dc-lightbox__overlay",$="dc-lightbox__overlay--show",T="dc-lightbox__overlay--prevent-anim",k="dc-lightbox__viewport",A="dc-lightbox__thumbnails",C="dc-lightbox__thumbnails--hide",I="dc-lightbox__thumbnails-viewport",O="dc-lightbox__thumbnails-slider",F="dc-lightbox__thumbnails-slide",q="dc-lightbox__thumbnails-slide--active",D="dc-lightbox__toolbar",P="dc-lightbox__counter",S="dc-lightbox__counter-current",z="dc-lightbox__counter-all",L="dc-lightbox__button-close",R="dc-lightbox__button-zoom",j="dc-lightbox__button-zoom--in",E="dc-lightbox__button-zoom--disabled",X="dc-lightbox__button-thumbnails",Y="dc-lightbox__wrapper--slider",B="dc-lightbox__wrapper--has-thumbnails",N="dc-lightbox__arrow",Z="dc-lightbox__slides",H="dc-lightbox__slide",G="dc-lightbox__slide--active",U="dc-lightbox__slide--prev",K="dc-lightbox__slide--next",V="dc-lightbox__slide--has-spinner",W="dc-lightbox__spinner",J="dc-lightbox__slide-content",Q="dc-lightbox__img-large",tt="dc-lightbox__img-large--loading",it="dc-lightbox__img-large--loaded",et="dc-lightbox__img-zoomable",nt="dc-lightbox__img-grabbing",st="dc-lightbox__slide-content--zoomIn",ot="dc-lightbox__img-small",lt="dc-lightbox__slide-content--prevent-anim",at="dc-lightbox__img-placeholder",rt="dc-lightbox__info",ct="dc-lightbox__info--hide",ht="dc-lightbox__caption",ut="dc-lightbox__caption-data",dt="dc-lightbox__crtl",mt="dc-lightbox__crbr",ft="dc-lightbox__crimg",gt="dc-lightbox__inner",pt="dc-lightbox__close";function bt(t,i="",e=null,n=null){const s=document.createElement(t);i&&(s.className=i),n&&Object.entries(n).forEach(([t,i])=>{!1===i||null===i?s.removeAttribute(t):s.setAttribute(t,String(i))});const o=t=>{t instanceof Node?s.append(t):null!=t&&s.insertAdjacentHTML("beforeend",String(t))};return Array.isArray(e)?e.forEach(o):o(e),s}function xt(t,i){const e={...t};return i&&"object"==typeof i&&Object.keys(i).forEach(n=>{i[n]&&"object"==typeof i[n]&&!Array.isArray(i[n])?e[n]=xt(t[n]||{},i[n]):e[n]=i[n]}),e}const _t=new WeakMap,wt=new Map,yt=new Map,vt=new Map;let Mt=!1,$t=!1;class Tt{constructor(n,s={}){if(s.src){const t=s.src;if(wt.has(t))return wt.get(t);wt.set(s.src,this)}else{if(_t.has(n))return _t.get(n);_t.set(n,this)}this.el=n,this.options=xt(e,s),this.events=new t,this.state=new i({active:!1},this.events),this.extensions={};let o=n.getAttribute("href")||n.getAttribute("data-src")||"",a=this.t(o,n),r=null;"inline"===a&&(r=document.querySelector(o)),this.targetData={href:o,type:a,id:r?.getAttribute("id")||"",style:r?.getAttribute("style")||"",class:r?.getAttribute("class")||"",timer:h.timer};let c=n.getAttribute(l);if(this.galleryName=c&&"image"===a?c:null,this.galleryData=null,this.galleryName){this.smallSrc=this.el?.querySelector("img")?.src||this.targetData?.href||!1,vt.has(this.galleryName)||vt.set(this.galleryName,{instances:[],urls:[],count:0,o:[]});const t=vt.get(this.galleryName);if(t&&(this.galleryData=t,t.instances.push(this),this.smallSrc)){t.urls.push(this.smallSrc);const i=document.createElement("img");i.src=this.smallSrc,i.loading="eager",i.decoding="async",i.alt="",t.o.push(i),t.count++}}this.clickedImgRect=null}init(){if(this.state.get("active"))return;if(this.state.set("active",!0),this.options.silent)this.l();else{let t=this.el;this.h=new Map;const i=this.u.bind(this,t);this.h.set(t,i),t.addEventListener("click",i)}this.emit("before:mount"),this.options.extensions&&this.mount(this.options.extensions),this.emit("mounted"),this.m=new MutationObserver(t=>{t.forEach(t=>{t.removedNodes.forEach(t=>{(t===this.el||t.contains(this.el))&&this.destroy()})})});const t=this.el.parentElement||document.body;this.m.observe(t,{childList:!0})}p(t,i){i.preventDefault();let e=this.targetData;e.timer[0]&&clearTimeout(e.timer[0]);t.getAttribute(n)===h.closeAllPopup||this.options.closeExisting?kt.closeAll():this.closeModal()}async closeModal(){let t=this.options,i=this.targetData;if(!this.state.get("opened"))return;const{animationDuration:e}=t,{type:n}=i;if(i.readyLayout&&!i.readyLayout.classList.contains(p)){this.state.set("layout-ready",!1),Mt=!0;let s=null,o=i.readyLayout.querySelector(`.${M}`);const l=()=>new Promise(requestAnimationFrame);"image"===i.type&&(s=i.readyLayout.querySelector(`.${G} .${J}`),s&&(s.classList.remove(lt),o.classList.remove(T)),await new Promise(requestAnimationFrame),await new Promise(requestAnimationFrame)),o.classList.remove($),this.emit("beforeLayoutClose",{modalRef:i.readyLayout}),i.readyLayout.classList.remove(g),i.readyLayout.classList.remove(b),i.readyLayout.offsetWidth,i.readyLayout.classList.add(f,p);const a=this.el?.querySelector("img")?.getBoundingClientRect()||null;a||i.readyLayout.classList.remove(w);const r=()=>{c&&clearTimeout(c),i.readyLayout&&i.readyLayout.classList.remove(m,p,f);let e=null;"image"!==n?e=this._():this.el&&(e=this.el),"image"===n&&(i.originTarget?.remove(),i.originTarget=null,t.silent&&(this.caption&&(this.caption=null),this.options?.caption&&(this.options.caption=null),this.el=null)),this.v&&(this.v.forEach((t,i)=>{i.removeEventListener("click",t)}),this.v.clear()),kt.M&&(kt.M.forEach((t,i)=>{i.removeEventListener("click",t)}),kt.M.clear()),i.readyLayout?.remove(),i.readyLayout=null,this.placeholder&&(this.placeholder?.remove(),this.placeholder=null),this.emit("layoutClosed",{modalRef:e}),this.state.set("opened",!1),this.openedNumb=0,kt.hasAnyOpen||(kt.$(),document.documentElement.classList.remove("dc-lightbox-scroll"))};let c=0;if(t.zoomImageFromOrigin&&!t.silent&&a&&"image"===i.type){let t=s?.querySelector("img")?.getBoundingClientRect()||null,n=null;if(t&&(n=this.T(a,t),s.style.width=`${t.width}px`,s.style.height=`${t.height}px`,s.style.transform=`translate3d(${t.left}px, ${t.top}px, 0px)`),i.readyLayout.classList.add(_),await l(),await l(),n&&!n.isRatioCorrect){let i=s.querySelector("."+dt),e=s.querySelector("."+mt),o=e.querySelector("."+ft);this.k(a,t,n.scale,i,e,o),await l(),await l()}t&&(s.style.transition=`transform ${e}ms ${h.timingFunc}`,s.style.transform=`translate3d(${n.x}px, ${n.y}px, 0px) scale(${n.scale})`),s.addEventListener("transitionend",r,{once:!0}),c=setTimeout(()=>{r()},e+1e3)}else setTimeout(()=>{r()},e)}}u(t,i){i.preventDefault();const e=t.querySelector("img");this.clickedImgRect=e?e.getBoundingClientRect():null,this.l()}async A(t){return new Promise((i,e)=>{const n=new Image;let s;const o=()=>{s&&clearInterval(s)},l=()=>{o(),i({width:n.naturalWidth,height:n.naturalHeight,imgElement:n})};if(n.onload=l,n.onerror=()=>{o(),e(new Error(`Не вдалося завантажити: ${t}`))},n.loading="eager",n.decoding="async",n.src=t,n.complete&&n.naturalWidth)return l();s=setInterval(()=>{n.naturalWidth&&n.naturalHeight&&l()},10)})}async l(){kt.C();let t=this.options,i=this.targetData,{parentContainer:e,hideScrollbar:n,autoClose:s,animationDuration:o,zoomImageFromOrigin:l,silent:c}=t;const{href:u,type:d}=i,{clickedImgRect:p}=this;if(i.originTarget=this.I(u,d),u&&i.originTarget){let u=this.O();if(!this.state.get("layout-ready"))return;if(u instanceof Node){document.querySelector(e).append(u),kt.hasAnyOpen||n&&kt.F(),kt.q(t,u,d,p);let b=this.existGallery,_=u.querySelector("."+M);if(Mt=!1,"image"===d){let t=kt.D(u),i=u.querySelectorAll("."+N);i.length&&(kt.M=new Map,i.forEach(t=>{const i=kt.P.bind(this,{arrow:t,isClick:!0});kt.M.set(t,i),t.addEventListener("click",i)}));let e=t.querySelector("img"),n=l&&!c&&p,s=-1;if(n){let i=e.src;yt.has(i)&&(e.src=yt.get(i).src);let l=this.el.querySelector("img").cloneNode(!0),c=await kt.S(t,"show",n,this.el,this.clickedImgRect,!0);await new Promise(requestAnimationFrame),await new Promise(requestAnimationFrame),u.classList.add(m),setTimeout(()=>{_.classList.add($)},7);const{width:d,height:g}=await this.A(e.src);if(d&&g){let n=kt.L(d,g,t),m=this.R(d,n.width,e);this.j(u,m),e.classList.add(Q,tt),e.style.width=n.width+"px",e.style.height=n.height+"px",l.classList.add(ot);let _=this.T(p,n),y=null,v=null,M=null;_.isRatioCorrect?t.append(l):(y=bt("div",dt),v=bt("div",mt),M=bt("div",ft),M.append(e,l),y.append(M),v.append(y),t.append(v),this.k(p,n,_.scale,y,v,M)),t.style.width=`${n.width}px`,t.style.height=`${n.height}px`,t.style.transform=`translate3d(${_.x}px, ${_.y}px, 0px) scale(${_.scale})`,t.style.transformOrigin="0 0",u.classList.add(x,w),t.offsetWidth,_.isRatioCorrect||[y,v,M].forEach(t=>{t.style.transition=`transform ${o-.25*o}ms ${h.timingFunc}`}),t.style.transition=`transform ${o}ms ${h.timingFunc}`,requestAnimationFrame(()=>{requestAnimationFrame(()=>{t.style.transform=`translate3d(${n.left}px, ${n.top}px, 0) scale(1)`,_.isRatioCorrect||[y,v,M].forEach(t=>{t.style.transform="translate3d(0,0,0)"}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{c.remove(),c=null})});const d=async n=>{if(n.target===t&&"transform"===n.propertyName){if(t.removeEventListener("transitionend",d),!yt.has(i))try{await e.decode()}catch(n){await new Promise((t,i)=>{e.complete?t():(e.addEventListener("load",t,{once:!0}),e.addEventListener("error",i,{once:!0}))})}_.isRatioCorrect||[y,v,M].forEach(t=>{t.style.transition=`transform ${o}ms ${h.timingFuncInvert}`});let c=!1,m=0;requestAnimationFrame(()=>{requestAnimationFrame(()=>{e.classList.add(it);const i=n=>{if(n.target===e&&"opacity"===n.propertyName&&!c&&(c=!0,clearTimeout(m),m=null,l.src="",l.remove(),e.classList.remove(tt),e.removeAttribute("style"),e.removeEventListener("transitionend",i),t.removeAttribute("style"),u.classList.remove(x),yt.set(e.src,e),kt.X(yt,3),this.state.set("opened",!0),this.openedNumb=++h.openedCounter,this.Y(t),b&&(this.B(u),s=this.galleryData.instances.indexOf(this),-1!==s))){const t=[a,r],i={gallery:this.galleryData.instances,instance:this};t.forEach(t=>{kt.N({...i,direction:t,i:t===a?s-1:s+1})}),$t=!0}};e.addEventListener("transitionend",i),m=setTimeout(()=>{i({target:e,propertyName:"opacity"})},2500)})}),u.classList.remove(f),this.emit("layoutOpened",{modalRef:u})}};t.addEventListener("transitionend",d)})})}}else{const i=i=>{p||(i.style.opacity=1),kt.S(t,"hide",!1,null,null,!1);let e=i.getBoundingClientRect(),n=this.R(i.naturalWidth,e.width,i);this.j(u,n),setTimeout(()=>{if(u.classList.remove(f),l&&u.classList.add(w),this.state.set("opened",!0),this.openedNumb=++h.openedCounter,this.emit("layoutOpened",{modalRef:u}),this.Y(t),b&&(this.B(u),s=this.galleryData.instances.indexOf(this),-1!==s)){const t=[a,r],i={gallery:this.galleryData.instances,instance:this};t.forEach(t=>{kt.N({...i,direction:t,i:t===a?s-1:s+1})}),$t=!0}},o)};u.classList.add(m),setTimeout(()=>{_.classList.add($)},1),this.Z(e,(i,e)=>{kt.S(t,i,n,this.el,this.clickedImgRect,e)}).then(async()=>{await new Promise(requestAnimationFrame),await new Promise(requestAnimationFrame),i(e)})}}else u.classList.add(m),setTimeout(()=>{_.classList.add($)},1);this.emit("layoutReady",{modalRef:u}),u.classList.add(g,f),i.readyLayout=u,setTimeout(()=>{"image"!==d&&(this.state.set("opened",!0),this.openedNumb=++h.openedCounter,u.classList.remove(f),this.emit("layoutOpened",{modalRef:u})),this.H(),t&&s&&(i.timer[0]=setTimeout(()=>{this.closeModal()},s))},o)}}}O(){let t=this.targetData;const{id:i,style:e,class:n,type:s}=t;this.emit("beforeLayoutOpen",{modalRef:t.originTarget});let o=document.createElement("div"),l=this.G();if(o.append(l),o.classList.add(d),"image"!==s){const t=o.querySelector(`.${gt}`);t&&Array.from(t.children).filter(t=>!t.classList.contains(pt)).forEach(t=>{i&&(t.id=i),e&&t.setAttribute("style",e),n&&(t.className=n),t.style.display="block"})}return this.state.set("layout-ready",!0),o}G(){const t=this.targetData,{type:i,id:e}=t,{backdropClick:s,icon:o,iconZoom:l,thumbnailsIcon:a,showThumbnailsOnOpen:r,zoomImageFromOrigin:c}=this.options,u=document.createDocumentFragment();["id","style","class"].forEach(i=>t.originTarget.removeAttribute(i));const d=s&&Array.isArray(h.backdrop_actions)&&h.backdrop_actions.includes(s)?s:null,m=d&&"image"!==i?{[n]:d}:null;if("image"===i){let i=bt("button",R,l),e=bt("div",D,[i,bt("button",L,o,{[n]:""})]);i.addEventListener("click",t=>{this.U(t,t.currentTarget,!1)});let s=bt("div",M),h=bt("div",`${v} ${Y}`,null,m),d=bt("div",Z),f=bt("div",`${H} ${G}`,null,m);d.append(f);let g=bt("div",k,null),p=bt("div",J);t.originTarget instanceof Node?(c&&(t.originTarget.style.opacity=0),p.append(t.originTarget)):p.innerHTML=t.originTarget,g.append(p),f.append(g),this.K(f),h.append(d);if(this.existGallery){const t=this.galleryData.instances.indexOf(this);let i=bt("div",P),n=bt("span",S,t+1),s=bt("span",z,this.galleryData.count);i.append(n,s),e.prepend(i);let o=bt("div",`${H} ${U}`,null,m),l=bt("div",`${H} ${K}`,null,m);d.prepend(o),d.append(l),h.prepend(bt("div",`${N} ${N}--prev`,this.options.arrowIcon)),h.append(bt("div",`${N} ${N}--next`,this.options.arrowIcon));let c=bt("button",X,a);i.after(c);let u=bt("div",A),f=bt("div",I),g=bt("div",O);f.append(g),u.append(f),h.append(u);const p=localStorage.getItem("dcThumbnails");(null!==p?"true"===p:r)&&h.classList.add(B),c.addEventListener("click",()=>{const t=h.classList.toggle(B);localStorage.setItem("dcThumbnails",t)})}return u.append(e,s,h),u}let f=bt("div",M),g=bt("div",v),p=bt("span",y,null,m),b=bt("div",gt),x=bt("button",pt,o,{[n]:""});return b.append(x),t.originTarget instanceof Node?(this.placeholder=document.createComment(`placeholder-for-${e||"element"}`),t.originTarget.before(this.placeholder),b.append(t.originTarget)):b.innerHTML+=t.originTarget,g.append(p,b),u.append(f,g),u}_(){if(this.placeholder?.parentNode){let t=this.targetData.readyLayout.querySelector("#"+this.targetData.id);if(t)return t.style.display="none",this.placeholder.replaceWith(t),t}return!1}I(t,i=this.options.type){return"image"===i?this.V(t):this.W(t)}R(t,i,e=null){const n=t/i;let s=Math.min(n,this.options.maxZoom)>1;return s&&e&&(e.classList.add(et),e.setAttribute("draggable","false")),s}j(t,i){if(!t)return;const e=t.querySelector("."+R);e&&(e.classList.remove(j),e.classList.toggle(E,!i))}J(t,i,e){return Math.max(i,Math.min(e,t))}tt(t,i){const e=getComputedStyle(t),n=new DOMMatrix(e.transform),{minX:s,maxX:o,minY:l,maxY:a}=i,r=this.J(n.m41,s,o),c=this.J(n.m42,l,a);if(n.m41===r&&n.m42===c)return;t.style.transition="transform 0.48s cubic-bezier(0.25, 0.82, 0.15, 1)",t.style.transform=`translate3d(${Math.round(r)}px, ${Math.round(c)}px, 0) scale(${n.a})`;const h=()=>{t.style.transition="",t.removeEventListener("transitionend",h)};t.addEventListener("transitionend",h)}U(t,i,e=!0){let n=kt.lastOpenedInstance;if(!n)return;let s=n.state.get("opened"),o=n.targetData.readyLayout.querySelector(`.${G} .${J} img`);if(s&&o){let s=n.options.maxZoom,l=o.getBoundingClientRect(),a=l.width,r=o.naturalWidth/a,c=Math.min(r,s);if(c){let s=o.closest("."+J);const a=s.classList.contains(st),r=t=>{if(t.target!==o||"transform"!==t.propertyName)return;o.removeEventListener("transitionend",r);let i=o.getBoundingClientRect(),e=Math.round(i.width),s=Math.round(i.height),l=0,a=0;const h=getComputedStyle(o).transform;if(h&&"none"!==h){const t=new DOMMatrixReadOnly(h);l=t.m41,a=t.m42}l=Math.round(l),a=Math.round(a),o.style.willChange="transform",o.style.transition="none",o.style.width=e+"px",o.style.height=s+"px",o.style.maxWidth="none",o.style.maxHeight="none",o.style.transform=`translate(${l}px, ${a}px) scale(1)`,n.targetData.imgScaleVal=c,requestAnimationFrame(()=>{requestAnimationFrame(()=>{o.style.transition=""})})},h=t=>{t.target===o&&"transform"===t.propertyName&&(s.classList.remove(st),i.classList.remove(j),o.classList.remove(nt),o.style.transformOrigin="center center",o.style.width="",o.style.height="",o.style.maxWidth="",o.style.maxHeight="",o.style.transform="",o.style.willChange="",o.removeEventListener("transitionend",h))};if(a||n.targetData.imgScaleVal)n.targetData.imgScaleVal&&(o.style.transition="",o.style.transform=`scale(${1/n.targetData.imgScaleVal})`,n.targetData.imgScaleVal=!1,n.it(),o.addEventListener("transitionend",h));else if(c>1){if(i.classList.add(j),s.classList.add(st),e){const i=window.innerWidth,e=window.innerHeight,n=l.left+l.width/2,s=l.top+l.height/2,a=t.clientX-n,r=t.clientY-s;let h=-a*(c-1),u=-r*(c-1);const d=l.width*c,m=l.height*c,f=Math.max(0,(d-i)/2),g=Math.max(0,(m-e)/2);h=Math.max(-f,Math.min(f,h)),u=Math.max(-g,Math.min(g,u)),o.style.transform=`translate(${Math.round(h)}px, ${Math.round(u)}px) scale(${c})`}else o.style.transform=`scale(${c})`;o.addEventListener("transitionend",r),o.style.transformOrigin=""}}}return!1}V(t){if(!t)return!1;let i=document.createElement("img");return i.src=t,i.alt="",i}et(){let t=this.options.caption;if(this.el){const i=this.el.getAttribute(o);i&&"false"!==i&&(t=i)}return t&&(t=t.trim()),t}W(t){if(!t||!t.startsWith("#")||t.length<=1)return!1;const i=document.querySelector(t);return!!i&&(!this.state.get("opened")&&i)}t(t,i=null){if(i){const t=i.getAttribute(s);if(t&&"false"!==t)return t}let e=this?.options?.type||"inline";return t&&/(^data:image\/[a-z0-9+\/=]*,)|\.(jpe?g|gif|png|bmp|webp|svg|ico)([\?#].*)?$/i.test(t)&&(e="image"),e}mount(t){for(const[i,e]of Object.entries(t)){let t=e;if("object"==typeof t&&null!==t&&("function"==typeof t[i]?t=t[i]:"function"==typeof t.default&&(t=t.default)),"function"!=typeof t)continue;const n=new t(this);this.extensions[i]=n,"function"==typeof n.mount&&n.mount()}}on(t,i){return this.events.on(t,i),this}off(t,i){return this.events.off(t,i),this}emit(t,i){return this.events.emit(t,i),this}destroy(){this.state.get("active")&&(this.emit("before:destroy"),this.m&&(this.m.disconnect(),this.m=null),Object.keys(this.extensions).forEach(t=>{this.extensions[t].destroy?.(),this.extensions[t]=null}),this.extensions={},this.el&&(_t.delete(this.el),kt.instances.delete(this),this.el=null),this.targetData&&(this.targetData=null),this.placeholder&&(this.placeholder=null),this.openedNumb&&(this.openedNumb=null),this.galleryData&&(vt.delete(this.galleryName),this.galleryData=null),yt&&yt.clear(),this?.options?.src&&wt.delete(this.options.src),this.h&&(this.h.forEach((t,i)=>{i.removeEventListener("click",t)}),this.h.clear()),this.v&&(this.v.forEach((t,i)=>{i.removeEventListener("click",t)}),this.v.clear()),h.openedCounter=0,this.state.set("active",!1),this.state.set("layout-ready",!1),this.emit("destroyed"),this.events.clear())}k(t,i,e,n,s,o){const l=2*e,a=.5*i.width-t.width/l,r=.5*i.height-t.height/l,c=(t,i,e)=>{const n=Math.round(1e4*i)/1e4,s=Math.round(1e4*e)/1e4;t.style.transform=`translate3d(${n}px, ${s}px, 0)`};c(n,2*a,2*r),c(s,-a,-r),c(o,-a,-r)}T(t,i){if(!t||!i)return;const e=t.width/i.width,n=t.height/i.height,s=e.toFixed(2)===n.toFixed(2),o=Math.max(e,n);return{isRatioCorrect:s,scale:o,x:.5*t.width+t.left-i.width*o*.5,y:.5*t.height+t.top-i.height*o*.5}}Z(t,i){const e=!t.complete||0===t.naturalWidth;let n=!1;const s=(t=!1)=>{n||(n=!0,i("show",t))};return(e?new Promise(i=>{s(),t.addEventListener("load",i,{once:!0}),t.addEventListener("error",i,{once:!0})}):Promise.resolve()).then(()=>{if(t.decode)return s(!0),t.decode().catch(t=>{})}).finally(()=>{})}H(){let t=this.targetData.readyLayout.querySelectorAll(`[${n}]`);t.length&&(this.v=new Map,t.forEach(t=>{const i=this.p.bind(this,t);this.v.set(t,i),t.addEventListener("click",i)}))}K(t){const i=this.et();if(t?.querySelector("."+rt)?.remove(),i){this.caption=i;const e=bt("div",rt),n=bt("div",ht),s=bt("div",ut,i);n.append(s),e.append(n),t.append(e),e.addEventListener("click",t=>{t.stopPropagation()})}}it(){this.frame&&cancelAnimationFrame(this.frame),this.frame=null}nt(t,i){const e=t.getBoundingClientRect(),n=i.getBoundingClientRect();this.limits={minX:Math.min(0,(e.width-n.width)/2),maxX:Math.max(0,(n.width-e.width)/2),minY:Math.min(0,(e.height-n.height)/2),maxY:Math.max(0,(n.height-e.height)/2)};const s=new DOMMatrix(getComputedStyle(i).transform);this.zoomedScale=s.a}Y(t){let i={activeSlide:t.closest("."+G),pSlide:null,nSlide:null},e=t.closest("."+k),n=null,s=!0,o=null,l=!0,c=0,u=0,d=null,m=0,f=0,g=!1,p=!1;let b=this.options.animationDuration||100,x=this.options.zoomImageFromOrigin,_=null,w=null,y=!1,v=!1,$=null,I=null,O=null,F=!1,q=!1,D=null,P=null,S=0,z=0,L=0,j=null,E=t.closest("."+Z),X=null,Y=null,H=null,U=!1,K=0,V=0,W=0,J=0,Q=0;this.frame=null,this.targetData.imgScaleVal=null;let tt=0,it=0;const ot=b=>{if(b.pointerId===j&&g){if(!p&&X){if(H&&!U){let t=this.targetData.readyLayout.querySelector("."+R);this.U(b,t)}if(H&&Y&&U){this.frame&&cancelAnimationFrame(this.frame);const{minX:t,maxX:i,minY:e,maxY:n}=this.limits,s=getComputedStyle(H),o=new DOMMatrix(s.transform);let l=o.m41,a=o.m42;const r=o.a,c=.9,h=()=>{l<t?(K*=.68,l+=.12*(t-l)):l>i&&(K*=.68,l+=.12*(i-l)),a<e?(V*=.68,a+=.12*(e-a)):a>n&&(V*=.68,a+=.12*(n-a)),l+=K,a+=V,K*=c,V*=c,H.style.transform=`translate3d(${Math.round(l)}px, ${a}px, 0) scale(${r})`,H.classList.remove(nt);if(Math.hypot(K,V)<.25)return K=0,V=0,this.tt(H,{minX:t,maxX:i,minY:e,maxY:n}),void(this.frame=null);this.frame=requestAnimationFrame(h)};this.frame=requestAnimationFrame(h)}U=!1}if(g=!1,E.style.transition="","x"===d){const t=f-u,i=e.clientWidth;let n=Math.abs(S);n<30&&(n*=1e3);const s=.32*i,o=650,l=t+.2*S;if(p&&_&&(Math.abs(t)>s||n>o||Math.abs(l)>.48*i)){const t=this.state.get("opened"),i=l>0?a:r;let e=document.querySelector("."+N+"--"+i);e&&t&&kt.P.call(this,{arrow:e,isClick:!1})}else p&&(E.style.transform="",setTimeout(()=>{E.style.willChange="auto"},this.options.slideChangeDuration))}if("y"===d){const a=m-c,r=Math.min(100,.2*D);p&&Math.abs(a)>r?(I.style.opacity=0,I=null,x||(t.style.opacity=0),Mt=!0,this.closeModal()):p&&(t.style.transition=`transform 0.3s ${h.timingFunc}`,t.style.transform="",I.style.transition=`opacity 0.3s ${h.timingFunc}`,I.style.opacity=1,P=setTimeout(()=>{t.style.transition="",I.style.transition="",I.style.opacity="",I.classList.remove(T),t.style.willChange="",n&&(n.classList.remove(ct),s=!0),o&&(o.classList.remove(C),l=!0,i.activeSlide.style.overflow="",e.style.overflow=""),n=null,o=null},300),x||(t.style.animation="",t.classList.add(lt)))}c=0,u=0,m=0,f=0,$=null,D=null,p=!1,d=null,e.releasePointerCapture(j),j=null}},at=(t,i)=>{if(d)return d;const e=Math.abs(t),n=Math.abs(i);return e<24&&n<24?null:(d=e>n?"x":"y",d)};e.addEventListener("pointerdown",e=>{if(null!==j)return;if(j=e.pointerId,H=e.target.closest("img"),!this.state.get("layout-ready"))return;P&&clearTimeout(P),c=e.clientY,u=e.clientX,m=c,f=u,$=document.documentElement.clientWidth,D=document.documentElement.clientHeight,_=this.existGallery,I=this.targetData.readyLayout.querySelector("."+M),I.style.willChange="opacity",I.classList.add(T),d=null,g=!0,p=!1,n=i.activeSlide.querySelector("."+rt),o=i.activeSlide.closest("."+B)?.querySelector("."+A),x?(t.style.transition="",t.style.willChange="transform"):(t.style.opacity=1,t.style.transition=`opacity ${b}ms ${h.timingFunc}`,t.style.willChange="transform, opacity"),_&&(i.pSlide=kt.st(this,a),i.nSlide=kt.st(this,r)),E.style.transition="none",E.style.willChange="transform";let s=t.querySelector("img");if(s&&s.classList.contains(et)&&(X=!0,Y=!!t.classList.contains(st),Y&&H&&this.targetData.imgScaleVal)){s.classList.add(nt);const i=getComputedStyle(s),e=new DOMMatrix(i.transform);this.it(),s.style.transition="",this.nt(t,s),tt=e.m41,it=e.m42,K=V=0,J=tt,Q=it}}),e.addEventListener("pointermove",a=>{if(a.pointerId!==j)return;if(!g)return;m=a.clientY,f=a.clientX;const r=m-c,h=f-u;if(Y&&H&&this.targetData.imgScaleVal){let i=t.querySelector("img");let e=tt+(h-20*w),n=it+(r-40*O);const{minX:s,maxX:o,minY:l,maxY:a}=this.limits,c=.25;e>o?e=o+(e-o)*c:e<s&&(e=s+(e-s)*c),n>a?n=a+(n-a)*c:n<l&&(n=l+(n-l)*c),i.style.transition="none",i.style.transform=`translate3d(${Math.round(e)}px, ${Math.round(n)}px, 0) scale(${this.zoomedScale})`,(Math.abs(h)>20||Math.abs(r)>40)&&(U=!0);const u=performance.now(),d=u-W;if(d>8&&d<100){K=(e-(J||tt))/d*16,V=(n-(Q||it))/d*16}J=e,Q=n,W=u}if(at(h,r),"x"===d&&!Y){const i=performance.now(),e=i-L;if(e>8&&e<120){S=.65*S+.35*((f-z)/e*1e3)}if(z=f,L=i,!p){if(Math.abs(h)<20)return;p=!0,w=h>0?1:-1,t.style.willChange=""}const n=h-20*w;n>0&&!y?(y=!0,v=!1):n<0&&!v&&(v=!0,y=!1);const s=n/$*100;E.style.transform=`translate3d(${s}%, 0, 0)`}if("y"===d&&!Y){if(!p){if(Math.abs(r)<40)return;p=!0,E.style.willChange="",O=r>0?1:-1}const a=r-40*O;a>0&&!q?(q=!0,F=!1):a<0&&!F&&(F=!0,q=!1);const c=a/D*100,h=Math.abs(c+(q?-100:100));I.style.opacity=h+"%",x&&this.clickedImgRect||(t.style.animation="none"),t.style.transform=`translate3d(0, ${a}px, 0)`,n&&s&&(s=!1,n.classList.add(ct)),o&&l&&(l=!1,o.classList.add(C),i.activeSlide.style.overflow="visible",e.style.overflow="visible")}(p||Y)&&e.setPointerCapture(j),a.cancelable&&a.preventDefault()}),e.addEventListener("pointerup",ot),e.addEventListener("pointercancel",ot)}get existGallery(){return this.galleryData?.urls.length>1||!1}B(t){if(this.existGallery){let i=this.galleryData,e=t,n=t.querySelector("."+A),s=e.querySelector("."+I),o=e.querySelector("."+O),l=null,c=i.instances.indexOf(this);if(this.galleryData.o.length>1){const t=document.createDocumentFragment();this.galleryData.o.forEach((i,e)=>{let n=document.createElement("div");n.className=F,n.dataset.index=e,n.appendChild(i.cloneNode(!0)),t.appendChild(n)}),o.appendChild(t)}l=o.querySelectorAll("."+F),n.addEventListener("click",t=>{if(t.target.closest(`.${q}`))return;const i=t.target.closest(`.${F}`);if(!i)return;const e=i.parentNode.children;let n=-1,l=null,c=0;for(const t of e)t.classList.contains(q)&&(n=c),c++;if(l=this.galleryData.instances[n],!l||!l.state.get("opened")||!$t)return;o.style.transition="",e[n].classList.remove(q),i.classList.add(q);let h=parseInt(i.getAttribute("data-index")),u=h>n?r:a,d=document.querySelector("."+N+"--"+u);kt.P.call(l,{arrow:d,isClick:!1,isThumbnailClick:!0,targetIndex:h}),kt.ot({viewportThumbnail:s,sliderThumbnails:o,activeThumbnail:i})});const h=n.querySelector("."+I);if(kt.lt(h),-1!==c){const t=l[c];t&&(t.classList.add(q),kt.ot({viewportThumbnail:s,sliderThumbnails:o,activeThumbnail:t,silent:!0}))}}}}class kt{static instances=new Map;static Extensions={};constructor(t=null,i={}){let e=null;if(null===t){i.silent=!0;let t=bt("a","","",{href:i?.src||"",caption:i?.caption||""});e=kt.rt(t)}else e=kt.rt(t);if(!e.length)return null;const n=e.map(e=>{if(null===t){let t=i?.src||"";if(wt.has(t))return wt.get(t)}else if(_t.has(e))return _t.get(e);const n=new Tt(e,i);return kt.instances.set(n,n),n}),s=1===n.length?n[0]:n;return Array.isArray(s)&&(s.on=(t,i)=>(s.forEach(e=>e.on(t,i)),s)),setTimeout(()=>{Array.isArray(s)?s.forEach(t=>t.init()):s.init()},0),s}static rt(t){return"string"==typeof t?Array.from(document.querySelectorAll(t)):t instanceof HTMLElement?[t]:Array.isArray(t)?t.filter(t=>t instanceof HTMLElement):[]}static destroyAll(){Array.from(this.instances.values()).forEach(t=>{t.destroy()}),this.instances.clear()}static closeAll(){this.allOpened.forEach(t=>{t.closeModal()}),h.openedCounter=0}static get allOpened(){return Array.from(this.instances.values()).filter(t=>t.state.get("opened")).sort((t,i)=>i.openedNumb-t.openedNumb)}static get hasAnyOpen(){for(const t of this.instances.values())if(t.state.get("opened"))return!0;return!1}static get lastOpenedInstance(){let t=null,i=-1;for(const e of this.instances.values())e.state.get("opened")&&e.openedNumb>i&&(i=e.openedNumb,t=e);return t}static q(t,i,e,n){let{animationDuration:s=0,effect:o="fadeInDown",zoomImageFromOrigin:l}=t;l&&!t.silent&&"image"===e&&n&&(o="fadeIn");const a=h.openEffects.includes(o)?o:"fadeInDown",r={fadeInDown:-40,fadeInUp:40}[a]??0,c={"--animationDuration":`${Number(s)||0}ms`,"--animationEffect":a,"--imageInitPosition":`${r}px`,"--slideChangeDuration":t.slideChangeDuration+"ms","--slideOffset":t.slideOffset};Object.entries(c).forEach(([t,e])=>{i.style.setProperty(t,e)})}static async ct(t){await new Promise((i,e)=>{t.complete?i():(t.addEventListener("load",i,{once:!0}),t.addEventListener("error",e,{once:!0}))});try{await t.decode()}catch(t){}return t}static async S(t,i="show",e=!0,n=null,s=null,o=!1){const l="."+W,a="."+at,r="."+H,c=t.querySelector(l),h=t.closest(r),u=e&&n&&s;if("show"===i){if(!o&&!c&&(t.append(bt("div",W)),h?.classList.add(V)),u){const i=h?.querySelector(a);if(!i){const i=n.querySelector("img");if(i){const e=i.cloneNode(!1);return Object.assign(e.style,{width:s.width+"px",height:s.height+"px",top:s.top+"px",left:s.left+"px"}),e.classList.add(at),t.before(e),await kt.ct(e)}}}}else if("hide"===i){const t=h?.querySelector(a);t&&setTimeout(()=>{t.remove()},4),c?.remove(),h?.classList.remove(V)}}static show(t){if(t?.src||"")return new kt(null,t)}static st(t,i){const e={[a]:U,[r]:K,[c]:G}[i];return t.targetData.readyLayout.querySelector(`.${e}`)}static async N(t={}){const{gallery:i,i:e=0,direction:n="next",instance:s}=t;Mt=!1;const o=i[(e+i.length)%i.length];if(!s.targetData.readyLayout)return;let l=kt.st(s,n);l.innerHTML="";let a=bt("div",k),r=bt("div",J);a.append(r),l.append(a),kt.S(r,"show",!1,null,null,!1);let c=await(u=o.targetData.href,yt.has(u)?Promise.resolve(yt.get(u)):new Promise(t=>{const i=async()=>{try{const i=await async function(t){if(yt.has(t))return yt.get(t);const i=new Image;if(await new Promise((e,n)=>{i.onload=e,i.onerror=n,i.loading="eager",i.decoding="async",i.src=t}),i.decode)try{await i.decode()}catch(t){}return yt.set(t,i),kt.X(yt,3),i}(u);t(i)}catch(i){t(null)}};"requestIdleCallback"in window?requestIdleCallback(i,{timeout:200}):setTimeout(i,0)}));var u;let d=c.cloneNode(!1);return d&&d.decode&&d.decode().then(()=>{kt.S(r,"hide",!1,null,null,!1)}).catch(()=>{kt.S(r,"hide",!1,null,null,!1)}),Mt?void 0:(r.append(d),new Promise(t=>{let i=null,e=null,n=null;const s=kt.L(d.naturalWidth,d.naturalHeight,d.parentElement),l=o.el.querySelector("img")?.getBoundingClientRect();let a=o.T(l,s);a?.isRatioCorrect||(i=bt("div",dt),e=bt("div",mt),n=bt("div",ft),n.append(d),i.append(n),e.append(i),[i,e,n].forEach(t=>{t.style.transform="translate3d(0, 0, 0)",t.style.transition=`transform ${o.options.animationDuration}ms ${h.timingFuncInvert}`}),r.append(e)),t()}))}static P(t,i){let{arrow:e,isClick:n,isThumbnailClick:s=!1,targetIndex:o=-1}=t;!0===n&&(i.preventDefault(),i.stopPropagation());let l=!!e.classList.contains(`${N}--${r}`),h=this.galleryData.instances;const u=h.findIndex(t=>t.state.get("opened")),d=-1!==u?h[u]:null;if(!d)return;if(!$t)return;$t=!1;let m=d.state.get("layout-ready");if(-1!==u&&m){d.state.set("layout-ready",!1),d.state.set("opened",!1),d.openedNumb=0,d.targetData.readyLayout.classList.add(b);let t=kt.st(d,a),i=kt.st(d,r),e=kt.st(d,c),n=null,m=null,f=null,g=!0,p=null;if(s&&-1!==o){if(f=o,n=h[f],g=1===Math.abs(u-o),!g){let t=l?r:a;p=kt.N({gallery:h,instance:d,direction:t,i:f})}}else m=l?1:-1,f=(u+m+h.length)%h.length,n=h[f];const x=l?i:t;x.style.visibility="visible";const _=l?t:i;let w=null;w=""+(l?"to-left":"to-right");let y=e.closest("."+Z);if(y.style.transition="",y.style.willChange="transform",!s){let t=document.querySelector("."+A);if(t){let i=t.querySelector("."+I),e=t.querySelector("."+O),n=e.querySelectorAll("."+F),s=n[f];for(const t of n)t.classList.remove(q);s.classList.add(q),kt.ot({viewportThumbnail:i,sliderThumbnails:e,activeThumbnail:s})}}const v=async t=>{if(t.target===y&&"transform"===t.propertyName){y.style.transition="none",y.style.transform="",y.classList.remove("to-left","to-right"),n.targetData.readyLayout=d.targetData.readyLayout,n.state.set("layout-ready",!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>{y.style.transition="",n.state.set("opened",!0),n.openedNumb=1})}),n.H(),d.v&&(d.v.forEach((t,i)=>{i.removeEventListener("click",t)}),d.v.clear()),d.targetData.originTarget?.remove(),d.targetData.originTarget=null,d.targetData.readyLayout=null;const i={next:K,prev:U};let s=`${H} ${i[l?a:r]}`,o=`${H} ${i[l?r:a]}`,c=`${H} ${G}`;const u=(t,i)=>{t.className=i,t.innerHTML="",t.style.transform="",t.style.visibility=""};u(e,s),x.className=c,x.style.transform="",x.style.visibility="",y.removeEventListener("transitionend",v),u(_,o),document.querySelector("."+S).innerText=+f+1;let m=kt.D(n.targetData.readyLayout),b=this;function w(t){let i=t.getBoundingClientRect(),e=b.R(t.naturalWidth,i.width,t);t.removeAttribute("loading"),t.removeAttribute("decoding"),b.j(n.targetData.readyLayout,e)}function M(t){t.complete?w(t):t.addEventListener("load",()=>{w(t)},{once:!0})}const $=m.querySelector("img");if($)M($);else{new MutationObserver((t,i)=>{const e=m.querySelector("img");e&&(M(e),i.disconnect())}).observe(m,{childList:!0,subtree:!0})}let T=n.targetData.readyLayout.querySelector(`.${J}`);n.Y(T);const k=[a,r],A={gallery:h,instance:n};g||await p,k.forEach(t=>{kt.N({...A,direction:t,i:t===a?f-1:f+1})}),$t=!0}};requestAnimationFrame(()=>{y.classList.add(w),n.K(x)}),y.addEventListener("transitionend",v)}}static C(t=!1){this.ht||(document.addEventListener("keydown",t=>{let i=t.key;if("Escape"===i){const t=this.lastOpenedInstance;t&&(t?.options?.closeExisting?kt.closeAll():t.closeModal())}if("ArrowLeft"===i||"ArrowRight"===i){const t=this.lastOpenedInstance;let e="ArrowLeft"===i?a:r,n=document.querySelector("."+N+"--"+e);n&&t&&kt.P.call(t,{arrow:n,isClick:!1})}}),this.ht=!0)}static F(){const t=document.documentElement.scrollHeight>window.innerHeight;document.body.classList.contains(u)||(document.body.classList.add(u),t?document.documentElement.classList.add("dc-lightbox-scroll"):document.documentElement.classList.remove("dc-lightbox-scroll"))}static $(){document.body.classList.remove(u)}static D(t){const i=t.querySelector("."+G+" ."+J);return i?(i.addEventListener("click",function(t){t.stopPropagation()}),i):null}static ot(t){const{viewportThumbnail:i,sliderThumbnails:e,activeThumbnail:n,silent:s=!1}=t,o=i.clientWidth,l=e.scrollWidth,a=window.getComputedStyle(e),r=new DOMMatrixReadOnly(a.transform).m41;if(e.style.transition=s?"none":"",l<=o){const t=(o-l)/2;return void(e.style.transform=`translateX(${t}px)`)}const c=o/2,h=n.offsetLeft+n.offsetWidth/2,u=h+r;let d=r;(u<.3*o||u>.7*o)&&(d=c-h);const m=o-l;d=Math.max(m,Math.min(0,d)),Math.abs(d-r)<1||(e.style.transform=`translateX(${d}px)`)}static lt(t){const i=t.querySelector("."+O);if(!i)return;let e=0,n=0,s=0,o=!1,l=!1,a=0;let r=null,c=0,h=0,u=0,d=null;const m=()=>{const t=getComputedStyle(i);return new DOMMatrixReadOnly(t.transform).m41||0},f=()=>{const e=i.scrollWidth,n=t.clientWidth;if(e<=n){const t=(n-e)/2;return{min:t,max:t}}return{min:n-e,max:0}},g=e=>{if(e.pointerId===r&&o){if(o=!1,l)(()=>{let t=m();const{min:e,max:n}=f();c=Math.max(-85,Math.min(85,c));const s=()=>{if(t+=c,t>n?(t=n+.915*(t-n),c*=.72):t<e&&(t=e-.915*(e-t),c*=.72),c*=.935,i.style.transform=`translate3d(${t}px, 0, 0)`,Math.abs(c)>.15&&t>e-5&&t<n+5)d=requestAnimationFrame(s);else{const s=Math.max(e,Math.min(n,t));Math.abs(s-t)>.5&&(i.style.transition="transform 0.45s cubic-bezier(0.25, 0.8, 0.25, 1)",i.style.transform=`translate3d(${s}px, 0, 0)`),d=null}};d=requestAnimationFrame(s)})();else{const{min:t,max:e}=f(),n=m(),s=Math.max(t,Math.min(e,n));s!==n&&(i.style.transition="transform 0.4s ease-out",i.style.transform=`translate3d(${s}px, 0, 0)`)}try{t.releasePointerCapture(r)}catch(t){}r=null}},p={passive:!1};t.addEventListener("pointerdown",t=>{null===r&&("touch"!==t.pointerType||t.isPrimary)&&(d&&cancelAnimationFrame(d),d=null,r=t.pointerId,e=n=h=t.clientX,u=performance.now(),s=m(),c=0,o=!0,l=!1,a=0,i.style.transition="none")},p),t.addEventListener("pointermove",d=>{if(d.pointerId!==r||!o)return;n=d.clientX;const m=n-e;if(!l){if(Math.abs(m)<15)return;l=!0,a=m>0?1:-1,t.setPointerCapture(r),i.style.transition="none"}let g=s+(m-15*a);const{min:p,max:b}=f();g>b?g=b+.28*(g-b):g<p&&(g=p+.28*(g-p)),i.style.transform=`translate3d(${g}px, 0, 0)`;const x=performance.now(),_=x-u;if(_>8&&_<120){c=(g-(h!==n?h:s))/_*16.67}h=g,u=x,d.cancelable&&d.preventDefault()},p),t.addEventListener("pointerup",g,p),t.addEventListener("pointercancel",g,p)}static X(t,i){for(;t.size>i;){const i=t.keys().next().value;t.delete(i)}}static L(t,i,e){const n=i/t,s=e.getBoundingClientRect();let o=Math.min(t,s.width),l=o*n;l>s.height&&(l=s.height,o=l/n);return{width:o,height:l,left:s.left+(s.width-o)/2,top:s.top+(s.height-l)/2}}}return kt});
8
+ !function(t,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define(i):(t="undefined"!=typeof globalThis?globalThis:t||self).DivclassLightbox=i()}(this,function(){"use strict";class t{constructor(){this.events={}}on(t,i){return this.events[t]||(this.events[t]=[]),this.events[t].push(i),this}off(t,i){return this.events[t]?(this.events[t]=this.events[t].filter(t=>t!==i),this):this}once(t,i){const e=(...n)=>{this.off(t,e),i(...n)};return this.on(t,e),this}emit(t,...i){return this.events[t]&&[...this.events[t]].forEach(t=>t(...i)),this}clear(){this.events={}}}class i{constructor(t={},i=null){this.data=t,this.events=i}set(t,i){const e=this.data[t];e!==i&&(this.data[t]=i,this.events&&(this.events.emit(`state:${t}`,i,e),this.events.emit("state:change",t,i,e)))}get(t){return this.data[t]}merge(t,i=!0){const e={...this.data};this.data={...this.data,...t},!i&&this.events&&this.events.emit("state:change","multiple",this.data,e)}}const e={icon:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1"><path d="M6 6L18 18M18 6L6 18"/></svg>',iconZoom:'<svg class="icon" viewBox="0 0 21 21" xmlns="http://www.w3.org/2000/svg"><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" transform="translate(3 3)"><circle cx="5.5" cy="5.5" r="5"></circle><path d="M3.5 5.5h4"></path><path class="dc-lightbox__button-zoom-line" d="M5.5 3.5v4"></path><path d="M14.5 14.5l-5.367-5.367"></path></g></svg>',maxZoom:3,thumbnailsIcon:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="11" rx="2"/><rect x="3" y="17" width="4" height="4" rx="1"/><rect x="10" y="17" width="4" height="4" rx="1"/><rect x="17" y="17" width="4" height="4" rx="1"/></svg>',showThumbnailsOnOpen:!0,arrowIcon:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M15 4L7 12L15 20"/></svg>',backdropClick:"close",closeExisting:!1,parentContainer:"body",hideScrollbar:!0,effect:"fadeInDown",zoomImageFromOrigin:!0,animationDuration:400,autoClose:!1,type:"inline",caption:!1,slideChangeDuration:280,slideOffset:.1,beforeLayoutOpen:()=>{},layoutReady:()=>{},layoutOpened:()=>{},beforeLayoutClose:()=>{},layoutClosed:()=>{},extensions:{}},n="data-close",s="data-type",o="data-caption",l="data-gallery",a="prev",r="next",c="active",h={fallbackBase64:"data:image/svg+xml;base64,"+btoa('\n <svg xmlns="http://www.w3.org/2000/svg" width="10" height="10">\n <rect width="100%" height="100%" fill="#ddd"/>\n </svg>\n '),openedCounter:0,timer:[0],backdrop_actions:["close"],openEffects:["fadeInDown","fadeIn","fadeInUp","zoomIn"],closeAllPopup:"close-all",timingFunc:"cubic-bezier(0.4, 0, 0.22, 1)",timingFuncInvert:"cubic-bezier(0.78, 0, 0.6, 1)"},u="body--hidden",d="dc-lightbox",m="dc-lightbox--visible",f="dc-lightbox--animating",g="dc-lightbox--opened",p="dc-lightbox--closing",b="dc-lightbox--gallery",x="dc-lightbox--scale-from-origin-in",_="dc-lightbox--scale-to-origin-out",w="dc-lightbox--scaled-from-origin",y="dc-lightbox__close-area",v="dc-lightbox__wrapper",M="dc-lightbox__overlay",$="dc-lightbox__overlay--show",T="dc-lightbox__overlay--prevent-anim",k="dc-lightbox__viewport",A="dc-lightbox__thumbnails",C="dc-lightbox__thumbnails--hide",I="dc-lightbox__thumbnails-viewport",O="dc-lightbox__thumbnails-slider",F="dc-lightbox__thumbnails-slide",q="dc-lightbox__thumbnails-slide--active",D="dc-lightbox__toolbar",P="dc-lightbox__counter",S="dc-lightbox__counter-current",z="dc-lightbox__counter-all",L="dc-lightbox__button-close",R="dc-lightbox__button-zoom",j="dc-lightbox__button-zoom--in",E="dc-lightbox__button-zoom--disabled",X="dc-lightbox__button-thumbnails",Y="dc-lightbox__wrapper--slider",B="dc-lightbox__wrapper--has-thumbnails",N="dc-lightbox__arrow",Z="dc-lightbox__slides",H="dc-lightbox__slide",G="dc-lightbox__slide--active",U="dc-lightbox__slide--prev",K="dc-lightbox__slide--next",V="dc-lightbox__slide--has-spinner",W="dc-lightbox__spinner",J="dc-lightbox__slide-content",Q="dc-lightbox__img-large",tt="dc-lightbox__img-large--loading",it="dc-lightbox__img-large--loaded",et="dc-lightbox__img-zoomable",nt="dc-lightbox__img-grabbing",st="dc-lightbox__slide-content--zoomIn",ot="dc-lightbox__img-small",lt="dc-lightbox__slide-content--prevent-anim",at="dc-lightbox__img-placeholder",rt="dc-lightbox__info",ct="dc-lightbox__info--hide",ht="dc-lightbox__caption",ut="dc-lightbox__caption-data",dt="dc-lightbox__crtl",mt="dc-lightbox__crbr",ft="dc-lightbox__crimg",gt="dc-lightbox__inner",pt="dc-lightbox__close";function bt(t,i="",e=null,n=null){const s=document.createElement(t);i&&(s.className=i),n&&Object.entries(n).forEach(([t,i])=>{!1===i||null===i?s.removeAttribute(t):s.setAttribute(t,String(i))});const o=t=>{t instanceof Node?s.append(t):null!=t&&s.insertAdjacentHTML("beforeend",String(t))};return Array.isArray(e)?e.forEach(o):o(e),s}function xt(t,i){const e={...t};return i&&"object"==typeof i&&Object.keys(i).forEach(n=>{i[n]&&"object"==typeof i[n]&&!Array.isArray(i[n])?e[n]=xt(t[n]||{},i[n]):e[n]=i[n]}),e}const _t=new WeakMap,wt=new Map,yt=new Map,vt=new Map;let Mt=!1,$t=!1;class Tt{constructor(n,s={}){if(s.src){const t=s.src;if(wt.has(t))return wt.get(t);wt.set(s.src,this)}else{if(_t.has(n))return _t.get(n);_t.set(n,this)}this.el=n,this.options=xt(e,s),this.events=new t,this.state=new i({active:!1},this.events),this.extensions={};let o=n.getAttribute("href")||n.getAttribute("data-src")||"",a=this.t(o,n),r=null;"inline"===a&&(r=document.querySelector(o)),this.targetData={href:o,type:a,id:r?.getAttribute("id")||"",style:r?.getAttribute("style")||"",class:r?.getAttribute("class")||"",timer:h.timer};let c=n.getAttribute(l);if(this.galleryName=c&&"image"===a?c:null,this.galleryData=null,this.galleryName){this.smallSrc=this.el?.querySelector("img")?.src||this.targetData?.href||!1,vt.has(this.galleryName)||vt.set(this.galleryName,{instances:[],urls:[],count:0,o:[]});const t=vt.get(this.galleryName);if(t&&(this.galleryData=t,t.instances.push(this),this.smallSrc)){t.urls.push(this.smallSrc);const i=document.createElement("img");i.src=this.smallSrc,i.loading="eager",i.decoding="async",i.alt="",t.o.push(i),t.count++}}this.clickedImgRect=null}init(){if(this.state.get("active"))return;if(this.state.set("active",!0),this.options.silent)this.l();else{let t=this.el;this.h=new Map;const i=this.u.bind(this,t);this.h.set(t,i),t.addEventListener("click",i)}this.emit("before:mount"),this.options.extensions&&this.mount(this.options.extensions),this.emit("mounted"),this.m=new MutationObserver(t=>{t.forEach(t=>{t.removedNodes.forEach(t=>{(t===this.el||t.contains(this.el))&&this.destroy()})})});const t=this.el.parentElement||document.body;this.m.observe(t,{childList:!0})}p(t,i){i.preventDefault();let e=this.targetData;e.timer[0]&&clearTimeout(e.timer[0]);t.getAttribute(n)===h.closeAllPopup||this.options.closeExisting?kt.closeAll():this.closeModal()}async closeModal(){let t=this.options,i=this.targetData;if(!this.state.get("opened"))return;const{animationDuration:e}=t,{type:n}=i;if(i.readyLayout&&!i.readyLayout.classList.contains(p)){this.state.set("layout-ready",!1),Mt=!0;let s=null,o=i.readyLayout.querySelector(`.${M}`);const l=()=>new Promise(requestAnimationFrame);"image"===i.type&&(s=i.readyLayout.querySelector(`.${G} .${J}`),s&&(s.classList.remove(lt),o.classList.remove(T)),await new Promise(requestAnimationFrame),await new Promise(requestAnimationFrame)),o.classList.remove($),this.emit("beforeLayoutClose",{modalRef:i.readyLayout}),i.readyLayout.classList.remove(g),i.readyLayout.classList.remove(b),i.readyLayout.offsetWidth,i.readyLayout.classList.add(f,p);const a=this.el?.querySelector("img")?.getBoundingClientRect()||null;a||i.readyLayout.classList.remove(w);const r=()=>{c&&clearTimeout(c),i.readyLayout&&i.readyLayout.classList.remove(m,p,f);let e=null;"image"!==n?e=this._():this.el&&(e=this.el),"image"===n&&(i.originTarget?.remove(),i.originTarget=null,t.silent&&(this.caption&&(this.caption=null),this.options?.caption&&(this.options.caption=null),this.el=null)),this.v&&(this.v.forEach((t,i)=>{i.removeEventListener("click",t)}),this.v.clear()),kt.M&&(kt.M.forEach((t,i)=>{i.removeEventListener("click",t)}),kt.M.clear()),i.readyLayout?.remove(),i.readyLayout=null,this.placeholder&&(this.placeholder?.remove(),this.placeholder=null),this.emit("layoutClosed",{modalRef:e}),this.state.set("opened",!1),this.openedNumb=0,kt.hasAnyOpen||(kt.$(),document.documentElement.classList.remove("dc-lightbox-scroll"))};let c=0;if(t.zoomImageFromOrigin&&!t.silent&&a&&"image"===i.type){let t=s?.querySelector("img")?.getBoundingClientRect()||null,n=null;if(t&&(n=this.T(a,t),s.style.width=`${t.width}px`,s.style.height=`${t.height}px`,s.style.transform=`translate3d(${t.left}px, ${t.top}px, 0px)`),i.readyLayout.classList.add(_),await l(),await l(),n&&!n.isRatioCorrect){let i=s.querySelector("."+dt),e=s.querySelector("."+mt),o=e.querySelector("."+ft);this.k(a,t,n.scale,i,e,o),await l(),await l()}t&&(s.style.transition=`transform ${e}ms ${h.timingFunc}`,s.style.transform=`translate3d(${n.x}px, ${n.y}px, 0px) scale(${n.scale})`),s.addEventListener("transitionend",r,{once:!0}),c=setTimeout(()=>{r()},e+1e3)}else setTimeout(()=>{r()},e)}}u(t,i){i.preventDefault();const e=t.querySelector("img");this.clickedImgRect=e?e.getBoundingClientRect():null,this.l()}async A(t){return new Promise((i,e)=>{const n=new Image;let s;const o=()=>{s&&clearInterval(s)},l=()=>{o(),i({width:n.naturalWidth,height:n.naturalHeight,imgElement:n})};if(n.onload=l,n.onerror=()=>{o(),e(new Error(`Не вдалося завантажити: ${t}`))},n.loading="eager",n.decoding="async",n.src=t,n.complete&&n.naturalWidth)return l();s=setInterval(()=>{n.naturalWidth&&n.naturalHeight&&l()},10)})}async l(){kt.C();let t=this.options,i=this.targetData,{parentContainer:e,hideScrollbar:n,autoClose:s,animationDuration:o,zoomImageFromOrigin:l,silent:c}=t;const{href:u,type:d}=i,{clickedImgRect:p}=this;if(i.originTarget=this.I(u,d),u&&i.originTarget){let u=this.O();if(!this.state.get("layout-ready"))return;if(u instanceof Node){document.querySelector(e).append(u),kt.hasAnyOpen||n&&kt.F(),kt.q(t,u,d,p);let b=this.existGallery,_=u.querySelector("."+M);if(Mt=!1,"image"===d){let t=kt.D(u),i=u.querySelectorAll("."+N);i.length&&(kt.M=new Map,i.forEach(t=>{const i=kt.P.bind(this,{arrow:t,isClick:!0});kt.M.set(t,i),t.addEventListener("click",i)}));let e=t.querySelector("img"),n=l&&!c&&p,s=-1;if(n){let i=e.src;yt.has(i)&&(e.src=yt.get(i).src);let l=this.el.querySelector("img").cloneNode(!0),c=await kt.S(t,"show",n,this.el,this.clickedImgRect,!0);await new Promise(requestAnimationFrame),await new Promise(requestAnimationFrame),u.classList.add(m),setTimeout(()=>{_.classList.add($)},7);const{width:d,height:g}=await this.A(e.src);if(d&&g){let n=kt.L(d,g,t),m=this.R(d,n.width,e);this.j(u,m),e.classList.add(Q,tt),e.style.width=n.width+"px",e.style.height=n.height+"px",l.classList.add(ot);let _=this.T(p,n),y=null,v=null,M=null;_.isRatioCorrect?t.append(l):(y=bt("div",dt),v=bt("div",mt),M=bt("div",ft),M.append(e,l),y.append(M),v.append(y),t.append(v),this.k(p,n,_.scale,y,v,M)),t.style.width=`${n.width}px`,t.style.height=`${n.height}px`,t.style.transform=`translate3d(${_.x}px, ${_.y}px, 0px) scale(${_.scale})`,t.style.transformOrigin="0 0",u.classList.add(x,w),t.offsetWidth,_.isRatioCorrect||[y,v,M].forEach(t=>{t.style.transition=`transform ${o-.25*o}ms ${h.timingFunc}`}),t.style.transition=`transform ${o}ms ${h.timingFunc}`,requestAnimationFrame(()=>{requestAnimationFrame(()=>{t.style.transform=`translate3d(${n.left}px, ${n.top}px, 0) scale(1)`,_.isRatioCorrect||[y,v,M].forEach(t=>{t.style.transform="translate3d(0,0,0)"}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{c.remove(),c=null})});const d=async n=>{if(n.target===t&&"transform"===n.propertyName){if(t.removeEventListener("transitionend",d),!yt.has(i))try{await e.decode()}catch(n){await new Promise((t,i)=>{e.complete?t():(e.addEventListener("load",t,{once:!0}),e.addEventListener("error",i,{once:!0}))})}_.isRatioCorrect||[y,v,M].forEach(t=>{t.style.transition=`transform ${o}ms ${h.timingFuncInvert}`});let c=!1,m=0;requestAnimationFrame(()=>{requestAnimationFrame(()=>{e.classList.add(it);const i=n=>{if(n.target===e&&"opacity"===n.propertyName&&!c&&(c=!0,clearTimeout(m),m=null,l.src="",l.remove(),e.classList.remove(tt),e.removeAttribute("style"),e.removeEventListener("transitionend",i),t.removeAttribute("style"),u.classList.remove(x),yt.set(e.src,e),kt.X(yt,3),this.state.set("opened",!0),this.openedNumb=++h.openedCounter,this.Y(t),b&&(this.B(u),s=this.galleryData.instances.indexOf(this),-1!==s))){const t=[a,r],i={gallery:this.galleryData.instances,instance:this};t.forEach(t=>{kt.N({...i,direction:t,i:t===a?s-1:s+1})}),$t=!0}};e.addEventListener("transitionend",i),m=setTimeout(()=>{i({target:e,propertyName:"opacity"})},2500)})}),u.classList.remove(f),this.emit("layoutOpened",{modalRef:u})}};t.addEventListener("transitionend",d)})})}}else{const i=i=>{p||(i.style.opacity=1),kt.S(t,"hide",!1,null,null,!1);let e=i.getBoundingClientRect(),n=this.R(i.naturalWidth,e.width,i);this.j(u,n),setTimeout(()=>{if(u.classList.remove(f),l&&u.classList.add(w),this.state.set("opened",!0),this.openedNumb=++h.openedCounter,this.emit("layoutOpened",{modalRef:u}),this.Y(t),b&&(this.B(u),s=this.galleryData.instances.indexOf(this),-1!==s)){const t=[a,r],i={gallery:this.galleryData.instances,instance:this};t.forEach(t=>{kt.N({...i,direction:t,i:t===a?s-1:s+1})}),$t=!0}},o)};u.classList.add(m),setTimeout(()=>{_.classList.add($)},1),this.Z(e,(i,e)=>{kt.S(t,i,n,this.el,this.clickedImgRect,e)}).then(async()=>{await new Promise(requestAnimationFrame),await new Promise(requestAnimationFrame),i(e)})}}else u.classList.add(m),setTimeout(()=>{_.classList.add($)},1);this.emit("layoutReady",{modalRef:u}),u.classList.add(g,f),i.readyLayout=u,setTimeout(()=>{"image"!==d&&(this.state.set("opened",!0),this.openedNumb=++h.openedCounter,u.classList.remove(f),this.emit("layoutOpened",{modalRef:u})),this.H(),t&&s&&(i.timer[0]=setTimeout(()=>{this.closeModal()},s))},o)}}}O(){let t=this.targetData;const{id:i,style:e,class:n,type:s}=t;this.emit("beforeLayoutOpen",{modalRef:t.originTarget});let o=document.createElement("div"),l=this.G();if(o.append(l),o.classList.add(d),"image"!==s){const t=o.querySelector(`.${gt}`);t&&Array.from(t.children).filter(t=>!t.classList.contains(pt)).forEach(t=>{i&&(t.id=i),e&&t.setAttribute("style",e),n&&(t.className=n),t.style.display="block"})}return this.state.set("layout-ready",!0),o}G(){const t=this.targetData,{type:i,id:e}=t,{backdropClick:s,icon:o,iconZoom:l,thumbnailsIcon:a,showThumbnailsOnOpen:r,zoomImageFromOrigin:c}=this.options,u=document.createDocumentFragment();["id","style","class"].forEach(i=>t.originTarget.removeAttribute(i));const d=s&&Array.isArray(h.backdrop_actions)&&h.backdrop_actions.includes(s)?s:null,m=d&&"image"!==i?{[n]:d}:null;if("image"===i){let i=bt("button",R,l),e=bt("div",D,[i,bt("button",L,o,{[n]:""})]);i.addEventListener("click",t=>{this.U(t,t.currentTarget,!1)});let s=bt("div",M),h=bt("div",`${v} ${Y}`,null,m),d=bt("div",Z),f=bt("div",`${H} ${G}`,null,m);d.append(f);let g=bt("div",k,null),p=bt("div",J);t.originTarget instanceof Node?(c&&(t.originTarget.style.opacity=0),p.append(t.originTarget)):p.innerHTML=t.originTarget,g.append(p),f.append(g),this.K(f),h.append(d);if(this.existGallery){const t=this.galleryData.instances.indexOf(this);let i=bt("div",P),n=bt("span",S,t+1),s=bt("span",z,this.galleryData.count);i.append(n,s),e.prepend(i);let o=bt("div",`${H} ${U}`,null,m),l=bt("div",`${H} ${K}`,null,m);d.prepend(o),d.append(l),h.prepend(bt("div",`${N} ${N}--prev`,this.options.arrowIcon)),h.append(bt("div",`${N} ${N}--next`,this.options.arrowIcon));let c=bt("button",X,a);i.after(c);let u=bt("div",A),f=bt("div",I),g=bt("div",O);f.append(g),u.append(f),h.append(u);const p=localStorage.getItem("dcThumbnails");(null!==p?"true"===p:r)&&h.classList.add(B),c.addEventListener("click",()=>{const t=h.classList.toggle(B);localStorage.setItem("dcThumbnails",t)})}return u.append(e,s,h),u}let f=bt("div",M),g=bt("div",v),p=bt("span",y,null,m),b=bt("div",gt),x=bt("button",pt,o,{[n]:""});return b.append(x),t.originTarget instanceof Node?(this.placeholder=document.createComment(`placeholder-for-${e||"element"}`),t.originTarget.before(this.placeholder),b.append(t.originTarget)):b.innerHTML+=t.originTarget,g.append(p,b),u.append(f,g),u}_(){if(this.placeholder?.parentNode){let t=this.targetData.readyLayout.querySelector("#"+this.targetData.id);if(t)return t.style.display="none",this.placeholder.replaceWith(t),t}return!1}I(t,i=this.options.type){return"image"===i?this.V(t):this.W(t)}R(t,i,e=null){const n=t/i;let s=Math.min(n,this.options.maxZoom)>1;return s&&e&&(e.classList.add(et),e.setAttribute("draggable","false")),s}j(t,i){if(!t)return;const e=t.querySelector("."+R);e&&(e.classList.remove(j),e.classList.toggle(E,!i))}J(t,i,e){return Math.max(i,Math.min(e,t))}tt(t,i){const e=getComputedStyle(t),n=new DOMMatrix(e.transform),{minX:s,maxX:o,minY:l,maxY:a}=i,r=this.J(n.m41,s,o),c=this.J(n.m42,l,a);if(n.m41===r&&n.m42===c)return;t.style.transition="transform 0.48s cubic-bezier(0.25, 0.82, 0.15, 1)",t.style.transform=`translate3d(${Math.round(r)}px, ${Math.round(c)}px, 0) scale(${n.a})`;const h=()=>{t.style.transition="",t.removeEventListener("transitionend",h)};t.addEventListener("transitionend",h)}U(t,i,e=!0){let n=kt.lastOpenedInstance;if(!n)return;let s=n.state.get("opened"),o=n.targetData.readyLayout.querySelector(`.${G} .${J} img`);if(s&&o){let s=n.options.maxZoom,l=o.getBoundingClientRect(),a=l.width,r=o.naturalWidth/a,c=Math.min(r,s);if(c){let s=o.closest("."+J);const a=s.classList.contains(st),r=t=>{if(t.target!==o||"transform"!==t.propertyName)return;o.removeEventListener("transitionend",r);let i=o.getBoundingClientRect(),e=Math.round(i.width),s=Math.round(i.height),l=0,a=0;const h=getComputedStyle(o).transform;if(h&&"none"!==h){const t=new DOMMatrixReadOnly(h);l=t.m41,a=t.m42}l=Math.round(l),a=Math.round(a),o.style.willChange="transform",o.style.transition="none",o.style.width=e+"px",o.style.height=s+"px",o.style.maxWidth="none",o.style.maxHeight="none",o.style.transform=`translate(${l}px, ${a}px) scale(1)`,n.targetData.imgScaleVal=c,requestAnimationFrame(()=>{requestAnimationFrame(()=>{o.style.transition=""})})},h=t=>{t.target===o&&"transform"===t.propertyName&&(s.classList.remove(st),i.classList.remove(j),o.classList.remove(nt),o.style.transformOrigin="center center",o.style.width="",o.style.height="",o.style.maxWidth="",o.style.maxHeight="",o.style.transform="",o.style.willChange="",o.removeEventListener("transitionend",h))};if(a||n.targetData.imgScaleVal)n.targetData.imgScaleVal&&(o.style.transition="",o.style.transform=`scale(${1/n.targetData.imgScaleVal})`,n.targetData.imgScaleVal=!1,n.it(),o.addEventListener("transitionend",h));else if(c>1){if(i.classList.add(j),s.classList.add(st),e){const i=window.innerWidth,e=window.innerHeight,n=l.left+l.width/2,s=l.top+l.height/2,a=t.clientX-n,r=t.clientY-s;let h=-a*(c-1),u=-r*(c-1);const d=l.width*c,m=l.height*c,f=Math.max(0,(d-i)/2),g=Math.max(0,(m-e)/2);h=Math.max(-f,Math.min(f,h)),u=Math.max(-g,Math.min(g,u)),o.style.transform=`translate(${Math.round(h)}px, ${Math.round(u)}px) scale(${c})`}else o.style.transform=`scale(${c})`;o.addEventListener("transitionend",r),o.style.transformOrigin=""}}}return!1}V(t){if(!t)return!1;let i=document.createElement("img");return i.src=t,i.alt="",i}et(){let t=this.options.caption;if(this.el){const i=this.el.getAttribute(o);i&&"false"!==i&&(t=i)}return t&&(t=t.trim()),t}W(t){if(!t||!t.startsWith("#")||t.length<=1)return!1;const i=document.querySelector(t);return!!i&&(!this.state.get("opened")&&i)}t(t,i=null){if(i){const t=i.getAttribute(s);if(t&&"false"!==t)return t}let e=this?.options?.type||"inline";return t&&/(^data:image\/[a-z0-9+\/=]*,)|\.(jpe?g|gif|png|bmp|webp|svg|ico)([\?#].*)?$/i.test(t)&&(e="image"),e}mount(t){for(const[i,e]of Object.entries(t)){let t=e;if("object"==typeof t&&null!==t&&("function"==typeof t[i]?t=t[i]:"function"==typeof t.default&&(t=t.default)),"function"!=typeof t)continue;const n=new t(this);this.extensions[i]=n,"function"==typeof n.mount&&n.mount()}}on(t,i){return this.events.on(t,i),this}off(t,i){return this.events.off(t,i),this}emit(t,i){return this.events.emit(t,i),this}destroy(){this.state.get("active")&&(this.emit("before:destroy"),this.m&&(this.m.disconnect(),this.m=null),Object.keys(this.extensions).forEach(t=>{this.extensions[t].destroy?.(),this.extensions[t]=null}),this.extensions={},this.el&&(_t.delete(this.el),kt.instances.delete(this),this.el=null),this.targetData&&(this.targetData=null),this.placeholder&&(this.placeholder=null),this.openedNumb&&(this.openedNumb=null),this.galleryData&&(vt.delete(this.galleryName),this.galleryData=null),yt&&yt.clear(),this?.options?.src&&wt.delete(this.options.src),this.h&&(this.h.forEach((t,i)=>{i.removeEventListener("click",t)}),this.h.clear()),this.v&&(this.v.forEach((t,i)=>{i.removeEventListener("click",t)}),this.v.clear()),h.openedCounter=0,this.state.set("active",!1),this.state.set("layout-ready",!1),this.emit("destroyed"),this.events.clear())}k(t,i,e,n,s,o){const l=2*e,a=.5*i.width-t.width/l,r=.5*i.height-t.height/l,c=(t,i,e)=>{const n=Math.round(1e4*i)/1e4,s=Math.round(1e4*e)/1e4;t.style.transform=`translate3d(${n}px, ${s}px, 0)`};c(n,2*a,2*r),c(s,-a,-r),c(o,-a,-r)}T(t,i){if(!t||!i)return;const e=t.width/i.width,n=t.height/i.height,s=e.toFixed(2)===n.toFixed(2),o=Math.max(e,n);return{isRatioCorrect:s,scale:o,x:.5*t.width+t.left-i.width*o*.5,y:.5*t.height+t.top-i.height*o*.5}}Z(t,i){const e=!t.complete||0===t.naturalWidth;let n=!1;const s=(t=!1)=>{n||(n=!0,i("show",t))};return(e?new Promise(i=>{s(),t.addEventListener("load",i,{once:!0}),t.addEventListener("error",i,{once:!0})}):Promise.resolve()).then(()=>{if(t.decode)return s(!0),t.decode().catch(t=>{})}).finally(()=>{})}H(){let t=this.targetData.readyLayout.querySelectorAll(`[${n}]`);t.length&&(this.v=new Map,t.forEach(t=>{const i=this.p.bind(this,t);this.v.set(t,i),t.addEventListener("click",i)}))}K(t){const i=this.et();if(t?.querySelector("."+rt)?.remove(),i){this.caption=i;const e=bt("div",rt),n=bt("div",ht),s=bt("div",ut,i);n.append(s),e.append(n),t.append(e),e.addEventListener("click",t=>{t.stopPropagation()})}}it(){this.frame&&cancelAnimationFrame(this.frame),this.frame=null}nt(t,i){const e=t.getBoundingClientRect(),n=i.getBoundingClientRect();this.limits={minX:Math.min(0,(e.width-n.width)/2),maxX:Math.max(0,(n.width-e.width)/2),minY:Math.min(0,(e.height-n.height)/2),maxY:Math.max(0,(n.height-e.height)/2)};const s=new DOMMatrix(getComputedStyle(i).transform);this.zoomedScale=s.a}Y(t){let i={activeSlide:t.closest("."+G),pSlide:null,nSlide:null},e=t.closest("."+k),n=null,s=!0,o=null,l=!0,c=0,u=0,d=null,m=0,f=0,g=!1,p=!1;let b=this.options.animationDuration||100,x=this.options.zoomImageFromOrigin,_=null,w=null,y=!1,v=!1,$=null,I=null,O=null,F=!1,q=!1,D=null,P=null,S=0,z=0,L=0,j=null,E=t.closest("."+Z),X=null,Y=null,H=0,U=0,K=null,V=!1,W=0,J=0,Q=0,tt=0,it=0;this.frame=null,this.targetData.imgScaleVal=null;let ot=0,at=0;const ht=b=>{if(b.pointerId===j&&g){if(!p&&X){if(K&&!V){let t=this.targetData.readyLayout.querySelector("."+R);this.U(b,t)}if(K&&Y&&V){this.frame&&cancelAnimationFrame(this.frame);const{minX:t,maxX:i,minY:e,maxY:n}=this.limits,s=getComputedStyle(K),o=new DOMMatrix(s.transform);let l=o.m41,a=o.m42;const r=o.a,c=.9,h=()=>{l<t?(W*=.68,l+=.12*(t-l)):l>i&&(W*=.68,l+=.12*(i-l)),a<e?(J*=.68,a+=.12*(e-a)):a>n&&(J*=.68,a+=.12*(n-a)),l+=W,a+=J,W*=c,J*=c,K.style.transform=`translate3d(${Math.round(l)}px, ${a}px, 0) scale(${r})`,K.classList.remove(nt);if(Math.hypot(W,J)<.25)return W=0,J=0,this.tt(K,{minX:t,maxX:i,minY:e,maxY:n}),void(this.frame=null);this.frame=requestAnimationFrame(h)};this.frame=requestAnimationFrame(h)}V=!1}if(g=!1,E.style.transition="","x"===d){const t=f-u,i=e.clientWidth;let n=Math.abs(S);n<30&&(n*=1e3);const s=.32*i,o=650,l=t+.2*S;if(p&&_&&(Math.abs(t)>s||n>o||Math.abs(l)>.48*i)){const t=this.state.get("opened"),i=l>0?a:r;let e=document.querySelector("."+N+"--"+i);e&&t&&kt.P.call(this,{arrow:e,isClick:!1})}else p&&(E.style.transform="",setTimeout(()=>{E.style.willChange="auto"},this.options.slideChangeDuration))}if("y"===d){const a=m-c,r=Math.min(100,.2*D);p&&Math.abs(a)>r?(I.style.opacity=0,I=null,x||(t.style.opacity=0),Mt=!0,this.closeModal()):p&&(t.style.transition=`transform 0.3s ${h.timingFunc}`,t.style.transform="",I.style.transition=`opacity 0.3s ${h.timingFunc}`,I.style.opacity=1,P=setTimeout(()=>{t.style.transition="",I.style.transition="",I.style.opacity="",I.classList.remove(T),t.style.willChange="",n&&(n.classList.remove(ct),s=!0),o&&(o.classList.remove(C),l=!0,i.activeSlide.style.overflow="",e.style.overflow=""),n=null,o=null},300),x||(t.style.animation="",t.classList.add(lt)))}c=0,u=0,m=0,f=0,$=null,D=null,p=!1,d=null,e.releasePointerCapture(j),j=null}},ut=(t,i)=>{if(d)return d;const e=Math.abs(t),n=Math.abs(i);return e<24&&n<24?null:(d=e>n?"x":"y",d)};e.addEventListener("pointerdown",e=>{if(null!==j)return;if(j=e.pointerId,K=e.target.closest("img"),!this.state.get("layout-ready"))return;P&&clearTimeout(P),c=e.clientY,u=e.clientX,m=c,f=u,$=document.documentElement.clientWidth,D=document.documentElement.clientHeight,_=this.existGallery,I=this.targetData.readyLayout.querySelector("."+M),I.style.willChange="opacity",I.classList.add(T),d=null,g=!0,p=!1,n=i.activeSlide.querySelector("."+rt),o=i.activeSlide.closest("."+B)?.querySelector("."+A),x?(t.style.transition="",t.style.willChange="transform"):(t.style.opacity=1,t.style.transition=`opacity ${b}ms ${h.timingFunc}`,t.style.willChange="transform, opacity"),_&&(i.pSlide=kt.st(this,a),i.nSlide=kt.st(this,r)),E.style.transition="none",E.style.willChange="transform";let s=t.querySelector("img");if(s&&s.classList.contains(et)&&(X=!0,Y=!!t.classList.contains(st),Y&&K&&this.targetData.imgScaleVal)){s.classList.add(nt);const i=getComputedStyle(s),e=new DOMMatrix(i.transform);this.it(),s.style.transition="",this.nt(t,s),ot=e.m41,at=e.m42,W=J=0,tt=ot,it=at}}),e.addEventListener("pointermove",a=>{if(a.pointerId!==j)return;if(!g)return;m=a.clientY,f=a.clientX;const r=m-c,h=f-u;if(Y&&K&&this.targetData.imgScaleVal&&this.limits&&K.classList.contains(nt)){if(!V){const t=Math.hypot(h,r);if(t<12)return;V=!0;H=12*(h/t),U=12*(r/t)}let i=t.querySelector("img"),e=ot+h-H,n=at+r-U;const{minX:s,maxX:o,minY:l,maxY:a}=this.limits,c=.25;e>o?e=o+(e-o)*c:e<s&&(e=s+(e-s)*c),n>a?n=a+(n-a)*c:n<l&&(n=l+(n-l)*c),i.style.transition="none",i.style.transform=`translate3d(${Math.round(e)}px, ${Math.round(n)}px, 0) scale(${this.zoomedScale})`;const u=performance.now(),d=u-Q;if(d>8&&d<100){W=(e-(tt||ot))/d*16,J=(n-(it||at))/d*16}tt=e,it=n,Q=u}if(ut(h,r),"x"===d&&!Y){const i=performance.now(),e=i-L;if(e>8&&e<120){S=.65*S+.35*((f-z)/e*1e3)}if(z=f,L=i,!p){if(Math.abs(h)<20)return;p=!0,w=h>0?1:-1,t.style.willChange=""}const n=h-20*w;n>0&&!y?(y=!0,v=!1):n<0&&!v&&(v=!0,y=!1);const s=n/$*100;E.style.transform=`translate3d(${s}%, 0, 0)`}if("y"===d&&!Y){if(!p){if(Math.abs(r)<40)return;p=!0,E.style.willChange="",O=r>0?1:-1}const a=r-40*O;a>0&&!q?(q=!0,F=!1):a<0&&!F&&(F=!0,q=!1);const c=a/D*100,h=Math.abs(c+(q?-100:100));I.style.opacity=h+"%",x&&this.clickedImgRect||(t.style.animation="none"),t.style.transform=`translate3d(0, ${a}px, 0)`,n&&s&&(s=!1,n.classList.add(ct)),o&&l&&(l=!1,o.classList.add(C),i.activeSlide.style.overflow="visible",e.style.overflow="visible")}(p||Y)&&e.setPointerCapture(j),a.cancelable&&a.preventDefault()}),e.addEventListener("pointerup",ht),e.addEventListener("pointercancel",ht)}get existGallery(){return this.galleryData?.urls.length>1||!1}B(t){if(this.existGallery){let i=this.galleryData,e=t,n=t.querySelector("."+A),s=e.querySelector("."+I),o=e.querySelector("."+O),l=null,c=i.instances.indexOf(this);if(this.galleryData.o.length>1){const t=document.createDocumentFragment();this.galleryData.o.forEach((i,e)=>{let n=document.createElement("div");n.className=F,n.dataset.index=e,n.appendChild(i.cloneNode(!0)),t.appendChild(n)}),o.appendChild(t)}l=o.querySelectorAll("."+F),n.addEventListener("click",t=>{if(t.target.closest(`.${q}`))return;const i=t.target.closest(`.${F}`);if(!i)return;const e=i.parentNode.children;let n=-1,l=null,c=0;for(const t of e)t.classList.contains(q)&&(n=c),c++;if(l=this.galleryData.instances[n],!l||!l.state.get("opened")||!$t)return;o.style.transition="",e[n].classList.remove(q),i.classList.add(q);let h=parseInt(i.getAttribute("data-index")),u=h>n?r:a,d=document.querySelector("."+N+"--"+u);kt.P.call(l,{arrow:d,isClick:!1,isThumbnailClick:!0,targetIndex:h}),kt.ot({viewportThumbnail:s,sliderThumbnails:o,activeThumbnail:i})});const h=n.querySelector("."+I);if(kt.lt(h),-1!==c){const t=l[c];t&&(t.classList.add(q),kt.ot({viewportThumbnail:s,sliderThumbnails:o,activeThumbnail:t,silent:!0}))}}}}class kt{static instances=new Map;static Extensions={};constructor(t=null,i={}){let e=null;if(null===t){i.silent=!0;let t=bt("a","","",{href:i?.src||"",caption:i?.caption||""});e=kt.rt(t)}else e=kt.rt(t);if(!e.length)return null;const n=e.map(e=>{if(null===t){let t=i?.src||"";if(wt.has(t))return wt.get(t)}else if(_t.has(e))return _t.get(e);const n=new Tt(e,i);return kt.instances.set(n,n),n}),s=1===n.length?n[0]:n;return Array.isArray(s)&&(s.on=(t,i)=>(s.forEach(e=>e.on(t,i)),s)),setTimeout(()=>{Array.isArray(s)?s.forEach(t=>t.init()):s.init()},0),s}static rt(t){return"string"==typeof t?Array.from(document.querySelectorAll(t)):t instanceof HTMLElement?[t]:Array.isArray(t)?t.filter(t=>t instanceof HTMLElement):[]}static destroyAll(){Array.from(this.instances.values()).forEach(t=>{t.destroy()}),this.instances.clear()}static closeAll(){this.allOpened.forEach(t=>{t.closeModal()}),h.openedCounter=0}static get allOpened(){return Array.from(this.instances.values()).filter(t=>t.state.get("opened")).sort((t,i)=>i.openedNumb-t.openedNumb)}static get hasAnyOpen(){for(const t of this.instances.values())if(t.state.get("opened"))return!0;return!1}static get lastOpenedInstance(){let t=null,i=-1;for(const e of this.instances.values())e.state.get("opened")&&e.openedNumb>i&&(i=e.openedNumb,t=e);return t}static q(t,i,e,n){let{animationDuration:s=0,effect:o="fadeInDown",zoomImageFromOrigin:l}=t;l&&!t.silent&&"image"===e&&n&&(o="fadeIn");const a=h.openEffects.includes(o)?o:"fadeInDown",r={fadeInDown:-40,fadeInUp:40}[a]??0,c={"--animationDuration":`${Number(s)||0}ms`,"--animationEffect":a,"--imageInitPosition":`${r}px`,"--slideChangeDuration":t.slideChangeDuration+"ms","--slideOffset":t.slideOffset};Object.entries(c).forEach(([t,e])=>{i.style.setProperty(t,e)})}static async ct(t){await new Promise((i,e)=>{t.complete?i():(t.addEventListener("load",i,{once:!0}),t.addEventListener("error",e,{once:!0}))});try{await t.decode()}catch(t){}return t}static async S(t,i="show",e=!0,n=null,s=null,o=!1){const l="."+W,a="."+at,r="."+H,c=t.querySelector(l),h=t.closest(r),u=e&&n&&s;if("show"===i){if(!o&&!c&&(t.append(bt("div",W)),h?.classList.add(V)),u){const i=h?.querySelector(a);if(!i){const i=n.querySelector("img");if(i){const e=i.cloneNode(!1);return Object.assign(e.style,{width:s.width+"px",height:s.height+"px",top:s.top+"px",left:s.left+"px"}),e.classList.add(at),t.before(e),await kt.ct(e)}}}}else if("hide"===i){const t=h?.querySelector(a);t&&setTimeout(()=>{t.remove()},4),c?.remove(),h?.classList.remove(V)}}static show(t){if(t?.src||"")return new kt(null,t)}static st(t,i){const e={[a]:U,[r]:K,[c]:G}[i];return t.targetData.readyLayout.querySelector(`.${e}`)}static async N(t={}){const{gallery:i,i:e=0,direction:n="next",instance:s}=t;Mt=!1;const o=i[(e+i.length)%i.length];if(!s.targetData.readyLayout)return;let l=kt.st(s,n);l.innerHTML="";let a=bt("div",k),r=bt("div",J);a.append(r),l.append(a),kt.S(r,"show",!1,null,null,!1);let c=await(u=o.targetData.href,yt.has(u)?Promise.resolve(yt.get(u)):new Promise(t=>{const i=async()=>{try{const i=await async function(t){if(yt.has(t))return yt.get(t);const i=new Image;if(await new Promise((e,n)=>{i.onload=e,i.onerror=n,i.loading="eager",i.decoding="async",i.src=t}),i.decode)try{await i.decode()}catch(t){}return yt.set(t,i),kt.X(yt,3),i}(u);t(i)}catch(i){t(null)}};"requestIdleCallback"in window?requestIdleCallback(i,{timeout:200}):setTimeout(i,0)}));var u;let d=c.cloneNode(!1);return d&&d.decode&&d.decode().then(()=>{kt.S(r,"hide",!1,null,null,!1)}).catch(()=>{kt.S(r,"hide",!1,null,null,!1)}),Mt?void 0:(r.append(d),new Promise(t=>{let i=null,e=null,n=null;const s=kt.L(d.naturalWidth,d.naturalHeight,d.parentElement),l=o.el.querySelector("img")?.getBoundingClientRect();let a=o.T(l,s);a?.isRatioCorrect||(i=bt("div",dt),e=bt("div",mt),n=bt("div",ft),n.append(d),i.append(n),e.append(i),[i,e,n].forEach(t=>{t.style.transform="translate3d(0, 0, 0)",t.style.transition=`transform ${o.options.animationDuration}ms ${h.timingFuncInvert}`}),r.append(e)),t()}))}static P(t,i){let{arrow:e,isClick:n,isThumbnailClick:s=!1,targetIndex:o=-1}=t;!0===n&&(i.preventDefault(),i.stopPropagation());let l=!!e.classList.contains(`${N}--${r}`),h=this.galleryData.instances;const u=h.findIndex(t=>t.state.get("opened")),d=-1!==u?h[u]:null;if(!d)return;if(!$t)return;$t=!1;let m=d.state.get("layout-ready");if(-1!==u&&m){d.state.set("layout-ready",!1),d.state.set("opened",!1),d.openedNumb=0,d.targetData.readyLayout.classList.add(b);let t=kt.st(d,a),i=kt.st(d,r),e=kt.st(d,c),n=null,m=null,f=null,g=!0,p=null;if(s&&-1!==o){if(f=o,n=h[f],g=1===Math.abs(u-o),!g){let t=l?r:a;p=kt.N({gallery:h,instance:d,direction:t,i:f})}}else m=l?1:-1,f=(u+m+h.length)%h.length,n=h[f];const x=l?i:t;x.style.visibility="visible";const _=l?t:i;let w=null;w=""+(l?"to-left":"to-right");let y=e.closest("."+Z);if(y.style.transition="",y.style.willChange="transform",!s){let t=document.querySelector("."+A);if(t){let i=t.querySelector("."+I),e=t.querySelector("."+O),n=e.querySelectorAll("."+F),s=n[f];for(const t of n)t.classList.remove(q);s.classList.add(q),kt.ot({viewportThumbnail:i,sliderThumbnails:e,activeThumbnail:s})}}const v=async t=>{if(t.target===y&&"transform"===t.propertyName){y.style.transition="none",y.style.transform="",y.classList.remove("to-left","to-right"),n.targetData.readyLayout=d.targetData.readyLayout,n.state.set("layout-ready",!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>{y.style.transition="",n.state.set("opened",!0),n.openedNumb=1})}),n.H(),d.v&&(d.v.forEach((t,i)=>{i.removeEventListener("click",t)}),d.v.clear()),d.targetData.originTarget?.remove(),d.targetData.originTarget=null,d.targetData.readyLayout=null;const i={next:K,prev:U};let s=`${H} ${i[l?a:r]}`,o=`${H} ${i[l?r:a]}`,c=`${H} ${G}`;const u=(t,i)=>{t.className=i,t.innerHTML="",t.style.transform="",t.style.visibility=""};u(e,s),x.className=c,x.style.transform="",x.style.visibility="",y.removeEventListener("transitionend",v),u(_,o),document.querySelector("."+S).innerText=+f+1;let m=kt.D(n.targetData.readyLayout),b=this;function w(t){let i=t.getBoundingClientRect(),e=b.R(t.naturalWidth,i.width,t);t.removeAttribute("loading"),t.removeAttribute("decoding"),b.j(n.targetData.readyLayout,e)}function M(t){t.complete?w(t):t.addEventListener("load",()=>{w(t)},{once:!0})}const $=m.querySelector("img");if($)M($);else{new MutationObserver((t,i)=>{const e=m.querySelector("img");e&&(M(e),i.disconnect())}).observe(m,{childList:!0,subtree:!0})}let T=n.targetData.readyLayout.querySelector(`.${J}`);n.Y(T);const k=[a,r],A={gallery:h,instance:n};g||await p,k.forEach(t=>{kt.N({...A,direction:t,i:t===a?f-1:f+1})}),$t=!0}};requestAnimationFrame(()=>{y.classList.add(w),n.K(x)}),y.addEventListener("transitionend",v)}}static C(t=!1){this.ht||(document.addEventListener("keydown",t=>{let i=t.key;if("Escape"===i){const t=this.lastOpenedInstance;t&&(t?.options?.closeExisting?kt.closeAll():t.closeModal())}if("ArrowLeft"===i||"ArrowRight"===i){const t=this.lastOpenedInstance;let e="ArrowLeft"===i?a:r,n=document.querySelector("."+N+"--"+e);n&&t&&kt.P.call(t,{arrow:n,isClick:!1})}}),this.ht=!0)}static F(){const t=document.documentElement.scrollHeight>window.innerHeight;document.body.classList.contains(u)||(document.body.classList.add(u),t?document.documentElement.classList.add("dc-lightbox-scroll"):document.documentElement.classList.remove("dc-lightbox-scroll"))}static $(){document.body.classList.remove(u)}static D(t){const i=t.querySelector("."+G+" ."+J);return i?(i.addEventListener("click",function(t){t.stopPropagation()}),i):null}static ot(t){const{viewportThumbnail:i,sliderThumbnails:e,activeThumbnail:n,silent:s=!1}=t,o=i.clientWidth,l=e.scrollWidth,a=window.getComputedStyle(e),r=new DOMMatrixReadOnly(a.transform).m41;if(e.style.transition=s?"none":"",l<=o){const t=(o-l)/2;return void(e.style.transform=`translateX(${t}px)`)}const c=o/2,h=n.offsetLeft+n.offsetWidth/2,u=h+r;let d=r;(u<.3*o||u>.7*o)&&(d=c-h);const m=o-l;d=Math.max(m,Math.min(0,d)),Math.abs(d-r)<1||(e.style.transform=`translateX(${d}px)`)}static lt(t){const i=t.querySelector("."+O);if(!i)return;let e=0,n=0,s=0,o=!1,l=!1,a=0;let r=null,c=0,h=0,u=0,d=null;const m=()=>{const t=getComputedStyle(i);return new DOMMatrixReadOnly(t.transform).m41||0},f=()=>{const e=i.scrollWidth,n=t.clientWidth;if(e<=n){const t=(n-e)/2;return{min:t,max:t}}return{min:n-e,max:0}},g=e=>{if(e.pointerId===r&&o){if(o=!1,l)(()=>{let t=m();const{min:e,max:n}=f();c=Math.max(-85,Math.min(85,c));const s=()=>{if(t+=c,t>n?(t=n+.915*(t-n),c*=.72):t<e&&(t=e-.915*(e-t),c*=.72),c*=.935,i.style.transform=`translate3d(${t}px, 0, 0)`,Math.abs(c)>.15&&t>e-5&&t<n+5)d=requestAnimationFrame(s);else{const s=Math.max(e,Math.min(n,t));Math.abs(s-t)>.5&&(i.style.transition="transform 0.45s cubic-bezier(0.25, 0.8, 0.25, 1)",i.style.transform=`translate3d(${s}px, 0, 0)`),d=null}};d=requestAnimationFrame(s)})();else{const{min:t,max:e}=f(),n=m(),s=Math.max(t,Math.min(e,n));s!==n&&(i.style.transition="transform 0.4s ease-out",i.style.transform=`translate3d(${s}px, 0, 0)`)}try{t.releasePointerCapture(r)}catch(t){}r=null}},p={passive:!1};t.addEventListener("pointerdown",t=>{null===r&&("touch"!==t.pointerType||t.isPrimary)&&(d&&cancelAnimationFrame(d),d=null,r=t.pointerId,e=n=h=t.clientX,u=performance.now(),s=m(),c=0,o=!0,l=!1,a=0,i.style.transition="none")},p),t.addEventListener("pointermove",d=>{if(d.pointerId!==r||!o)return;n=d.clientX;const m=n-e;if(!l){if(Math.abs(m)<15)return;l=!0,a=m>0?1:-1,t.setPointerCapture(r),i.style.transition="none"}let g=s+(m-15*a);const{min:p,max:b}=f();g>b?g=b+.28*(g-b):g<p&&(g=p+.28*(g-p)),i.style.transform=`translate3d(${g}px, 0, 0)`;const x=performance.now(),_=x-u;if(_>8&&_<120){c=(g-(h!==n?h:s))/_*16.67}h=g,u=x,d.cancelable&&d.preventDefault()},p),t.addEventListener("pointerup",g,p),t.addEventListener("pointercancel",g,p)}static X(t,i){for(;t.size>i;){const i=t.keys().next().value;t.delete(i)}}static L(t,i,e){const n=i/t,s=e.getBoundingClientRect();let o=Math.min(t,s.width),l=o*n;l>s.height&&(l=s.height,o=l/n);return{width:o,height:l,left:s.left+(s.width-o)/2,top:s.top+(s.height-l)/2}}}return kt});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@divclass/lightbox",
3
- "version": "1.1.2",
4
- "description": "Divclass Lightbox — modern, lightweight lightbox for images and inline content. Only 32 KB (≈11 KB gzipped). Touch-friendly, cross-browser, swipe & drag gestures, virtual slides, inline HTML, zero dependency.",
3
+ "version": "1.1.4",
4
+ "description": "Divclass Lightbox — modern, lightweight lightbox for images and inline content. Touch-friendly, cross-browser, swipe & drag gestures, virtual slides, inline HTML, zero dependency.",
5
5
  "keywords": [
6
6
  "lightbox",
7
7
  "javascript lightbox",