vistaview 0.3.11 → 0.3.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -7
- package/dist/lib/defaults.d.ts.map +1 -1
- package/dist/lib/types.d.ts +1 -6
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/vista-view.d.ts +1 -2
- package/dist/lib/vista-view.d.ts.map +1 -1
- package/dist/vistaview.cjs +4 -4
- package/dist/vistaview.js +271 -288
- package/dist/vistaview.umd.js +4 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -290,25 +290,25 @@ dist/svelte.js 0.54 kB │ gzip: 0.27 kB
|
|
|
290
290
|
dist/solid.js 1.11 kB │ gzip: 0.52 kB
|
|
291
291
|
dist/vue.js 1.29 kB │ gzip: 0.56 kB
|
|
292
292
|
dist/react.js 1.54 kB │ gzip: 0.57 kB
|
|
293
|
-
dist/vistaview.js
|
|
294
|
-
[vite:dts] Declaration files built in
|
|
293
|
+
dist/vistaview.js 37.98 kB │ gzip: 9.60 kB
|
|
294
|
+
[vite:dts] Declaration files built in 650ms.
|
|
295
295
|
|
|
296
296
|
dist/vistaview.css 10.11 kB │ gzip: 1.78 kB
|
|
297
297
|
dist/svelte.cjs 0.48 kB │ gzip: 0.29 kB
|
|
298
298
|
dist/solid.cjs 0.92 kB │ gzip: 0.50 kB
|
|
299
299
|
dist/vue.cjs 1.00 kB │ gzip: 0.51 kB
|
|
300
300
|
dist/react.cjs 1.25 kB │ gzip: 0.52 kB
|
|
301
|
-
dist/vistaview.cjs
|
|
302
|
-
✓ built in
|
|
301
|
+
dist/vistaview.cjs 29.56 kB │ gzip: 8.30 kB
|
|
302
|
+
✓ built in 765ms
|
|
303
303
|
vite v6.4.1 building for production...
|
|
304
304
|
✓ 6 modules transformed.
|
|
305
305
|
|
|
306
306
|
[vite:dts] Start generate declaration files...
|
|
307
307
|
dist/vistaview.css 10.11 kB │ gzip: 1.78 kB
|
|
308
|
-
dist/vistaview.umd.js
|
|
309
|
-
[vite:dts] Declaration files built in
|
|
308
|
+
dist/vistaview.umd.js 29.71 kB │ gzip: 8.41 kB
|
|
309
|
+
[vite:dts] Declaration files built in 645ms.
|
|
310
310
|
|
|
311
|
-
✓ built in
|
|
311
|
+
✓ built in 731ms
|
|
312
312
|
```
|
|
313
313
|
|
|
314
314
|
## License
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/lib/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,sBAAsB,EACtB,sBAAsB,EACtB,2BAA2B,EAC5B,MAAM,SAAS,CAAC;AAEjB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAU9C,wBAAgB,eAAe,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/lib/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,sBAAsB,EACtB,sBAAsB,EACtB,2BAA2B,EAC5B,MAAM,SAAS,CAAC;AAEjB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAU9C,wBAAgB,eAAe,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,CAuJ1D;AAED,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,CAQ7D;AAMD,eAAO,MAAM,WAAW,GAAI,WAAW,SAAS,SAE/C,CAAC;AAKF,eAAO,MAAM,YAAY,EAAE,sBAsB1B,CAAC;AAIF,eAAO,MAAM,iBAAiB,EAAE,2BA2D/B,CAAC;AAKF,eAAO,MAAM,YAAY,EAAE,sBAK1B,CAAC"}
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -70,12 +70,7 @@ export type VistaViewData = {
|
|
|
70
70
|
next: boolean;
|
|
71
71
|
prev: boolean;
|
|
72
72
|
};
|
|
73
|
-
|
|
74
|
-
elements: NodeListOf<HTMLElement> | VistaViewImage[];
|
|
75
|
-
isReducedMotion: boolean;
|
|
76
|
-
navActive: boolean;
|
|
77
|
-
isZoomed: HTMLImageElement | false;
|
|
78
|
-
options: VistaViewOptions;
|
|
73
|
+
vistaView: VistaView;
|
|
79
74
|
};
|
|
80
75
|
export type VistaViewTransitionFunction = (params: VistaViewData, abortSignal: AbortSignal) => Promise<void>;
|
|
81
76
|
export type VistaViewSetupFunction = (params: VistaViewData) => void;
|
package/dist/lib/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,MAAM,iBAAiB,GAAG;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,SAAS,CAAC,EAAE,iBAAiB,CAAC;CAC/B,GAAG,cAAc,CAAC;AAEnB,MAAM,MAAM,gBAAgB,GAAG;IAC7B,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,aAAa,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a,KAAK,IAAI,CAAC;AACrE,MAAM,MAAM,sBAAsB,GAAG,CAAC,SAAS,EAAE,SAAS,KAAK,IAAI,CAAC;AACpE,MAAM,MAAM,qBAAqB,GAAG,CAAC,SAAS,EAAE,SAAS,KAAK,IAAI,CAAC"}
|
package/dist/lib/vista-view.d.ts
CHANGED
|
@@ -41,7 +41,6 @@ export declare class VistaView {
|
|
|
41
41
|
};
|
|
42
42
|
currentImages: VistaViewImageIndexed[] | null;
|
|
43
43
|
currentItems: HTMLDivElement[] | null;
|
|
44
|
-
navActive: boolean;
|
|
45
44
|
isZoomed: HTMLImageElement | false;
|
|
46
45
|
private onClickElements;
|
|
47
46
|
private defaultOnClickHandler;
|
|
@@ -56,8 +55,8 @@ export declare class VistaView {
|
|
|
56
55
|
private onZoomedPointerUp;
|
|
57
56
|
private transitionAbortControllers;
|
|
58
57
|
constructor(elements: NodeListOf<HTMLElement> | VistaViewImage[], options?: VistaViewOptions);
|
|
59
|
-
private loadImageTimeout;
|
|
60
58
|
private setFullSizeImageDim;
|
|
59
|
+
private loadImageTimeout;
|
|
61
60
|
private swap;
|
|
62
61
|
private setZoomed;
|
|
63
62
|
zoomIn(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vista-view.d.ts","sourceRoot":"","sources":["../../src/lib/vista-view.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAIV,sBAAsB,EACtB,cAAc,EACd,qBAAqB,EACrB,gBAAgB,EAEjB,MAAM,SAAS,CAAC;AAIjB,qBAAa,+BAAgC,SAAQ,KAAK;gBAC5C,OAAO,EAAE,MAAM;CAI5B;AAED,eAAO,MAAM,cAAc;;;;;;;;;cAepB,gBAAgB,CAAC,UAAU,CAAC;CAClC,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE;IAAE,eAAe,EAAE,SAAS,GAAG,IAAI,CAAA;CAEjE,CAAC;AAEF,qBAAa,SAAS;IACpB,OAAO,EAAE,gBAAgB,CAAC;IAC1B,QA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AO,CAAC,iBAAiB;IA2BzB,OAAO,CAAC,oBAAoB;IA6B5B,OAAO,CAAC,kBAAkB;IAqB1B,IAAI,CAAC,UAAU,GAAE,MAAU,GAAG,IAAI;IAwJ5B,KAAK,CAAC,IAAI,UAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IA+DvC,OAAO,IAAI,IAAI;IAWf,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE;QAAE,IAAI,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI;IAWnE,IAAI,IAAI,IAAI;IAKZ,IAAI,IAAI,IAAI;IAKZ,eAAe,IAAI,MAAM;CAG1B"}
|
package/dist/vistaview.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"use strict";var N=Object.defineProperty;var U=(s,t,i)=>t in s?N(s,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):s[t]=i;var
|
|
2
|
-
style="${n?`object-fit:${n};`:""}${
|
|
1
|
+
"use strict";var N=Object.defineProperty;var U=(s,t,i)=>t in s?N(s,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):s[t]=i;var m=(s,t,i)=>U(s,typeof t!="symbol"?t+"":t,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function R(s){const t=getComputedStyle(s),i=s.getBoundingClientRect();return{objectFit:t.objectFit,borderRadius:t.borderRadius,objectPosition:t.objectPosition,overflow:t.overflow,top:i.top,left:i.left,width:i.width,height:i.height,naturalWidth:s.naturalWidth,naturalHeight:s.naturalHeight}}let P=null;function j(){return P||(window.trustedTypes||(window.trustedTypes={createPolicy:(s,t)=>t}),P=window.trustedTypes.createPolicy("vistaView-policy",{createHTML:s=>s,createScript:()=>{throw new Error("Not implemented")},createScriptURL:()=>{throw new Error("Not implemented")}}),P)}function W(s){const i=j().createHTML(s),n=document.createElement("template");n.innerHTML=i;const e=n.content;return n.remove(),e}function H(s){return s&&!/^0(px|%|r?em|vw|vh|vmin|vmax|cm|mm|in|pt|pc|ex|ch)?$/i.test(s.trim())&&s}function K(s){const i=window.getComputedStyle(s).objectFit||"",{width:n,height:e}=s.getBoundingClientRect(),r=s.naturalWidth,a=s.naturalHeight;if(!i)return{width:n,height:e};if(!r||!a)return{width:n,height:e};const o=r/a,l=n/e;switch(i){case"fill":return{width:n,height:e};case"none":return{width:r,height:a};case"contain":return o>l?{width:n,height:n/o}:{width:e*o,height:e};case"cover":return o<l?{width:n,height:n/o}:{width:e*o,height:e};case"scale-down":{const c={width:r,height:a},d=o>l?{width:n,height:n/o}:{width:e*o,height:e};return d.width<=c.width&&d.height<=c.height?d:c}}return{width:n,height:e}}function q(s){const t=window.innerWidth,i=window.innerHeight,n=s.naturalWidth,e=s.naturalHeight;if(!n||!e)throw console.error("Error",s),new Error("Image natural dimensions are zero");if(n<t&&e<i)return{width:n,height:e};const r=n/e,a=t/i;let o,l;return r>a?(o=t,l=t/r):(l=i,o=i*r),{width:o,height:l}}function k(s,t){const i=window.innerHeight,n=window.innerWidth,e=s,r=t,a=Math.max(0,(e-n)/2)+n/2,o=Math.max(0,(r-i)/2)+i/2,l=-a,c=-o;return{maxDiffX:a,minDiffY:c,maxDiffY:o,minDiffX:l}}const G='<svg viewBox="0 0 24 24"><path d="m15 18-6-6 6-6"/></svg>',J='<svg viewBox="0 0 24 24"><path d="m9 18 6-6-6-6"/></svg>',Q='<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><line x1="21" x2="16.65" y1="21" y2="16.65"/><line x1="11" x2="11" y1="8" y2="14"/><line x1="8" x2="14" y1="11" y2="11"/></svg>',tt='<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><line x1="21" x2="16.65" y1="21" y2="16.65"/><line x1="8" x2="14" y1="11" y2="11"/></svg>',et='<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>',it='<svg viewBox="0 0 24 24"><path d="M12 15V3"/><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><path d="m7 10 5 5 5-5"/></svg>';function X(){return{name:"download",icon:it,onClick:async s=>{var r;const t=await fetch(s.src),i=await t.blob(),n=t.url,e=document.createElement("a");e.href=URL.createObjectURL(i),e.download=((r=n.split("/").pop())==null?void 0:r.split("?")[0].split("#")[0])||"download",document.body.appendChild(e),e.click(),document.body.removeChild(e)}}}function nt(s){if(typeof s=="string")switch(s){case"zoomIn":return`<button class="vistaview-zoom-in-btn">${Q}</button>`;case"zoomOut":return`<button disabled class="vistaview-zoom-out-btn">${tt}</button>`;case"close":return`<button class="vistaview-close-btn">${et}</button>`;case"indexDisplay":return'<div class="vistaview-index-display"></div>';case"description":return'<div class="vistaview-description"></div>';default:return""}return`<button data-vistaview-custom-control="${s.name}">${s.icon}</button>`}function O(s,t){var d,h;const i=s.imageElm?getComputedStyle(s.imageElm):null,n=(i==null?void 0:i.objectFit)||"",e=((d=s.imageElm)==null?void 0:d.naturalWidth)||"",r=((h=s.imageElm)==null?void 0:h.naturalHeight)||"",a=(i==null?void 0:i.width)||"",o=(i==null?void 0:i.height)||"",l=document.createElement("div");l.className="vistaview-item",l.dataset.vistaviewPos=`${t!==void 0?t:""}`,l.dataset.vistaviewIndex=s.index.toString();const c=W(`<img class="vistaview-image-lowres"
|
|
2
|
+
style="${n?`object-fit:${n};`:""}${a?`width:${a};`:""}${o?`height:${o};`:""}"
|
|
3
3
|
src="${s.thumb||s.src}"
|
|
4
4
|
alt="${s.alt||""}"
|
|
5
5
|
${e?`width="${e}"`:""}
|
|
6
6
|
${r?`height="${r}"`:""}
|
|
7
7
|
/>
|
|
8
|
-
<img class="vistaview-image-highres" src="${s.src}" alt="${s.alt||""}" />`);return
|
|
8
|
+
<img class="vistaview-image-highres" src="${s.src}" alt="${s.alt||""}" />`);return l.appendChild(c),l}function st({controls:s,isReducedMotion:t}){const i=e=>e?e.map(nt).join(""):"";return W(`<div class="vistaview-root${t?" vistaview--reduced-motion":""}" id="vistaview-root">
|
|
9
9
|
<div class="vistaview-container">
|
|
10
10
|
<div class="vistaview-image-container"></div>
|
|
11
11
|
<div class="vistaview-top-bar vistaview-ui"><div>${i(s==null?void 0:s.topLeft)}</div><div>${i(s==null?void 0:s.topCenter)}</div><div>${i(s==null?void 0:s.topRight)}</div></div>
|
|
@@ -13,4 +13,4 @@
|
|
|
13
13
|
<div class="vistaview-prev-btn vistaview-ui"><button>${G}</button></div>
|
|
14
14
|
<div class="vistaview-next-btn vistaview-ui"><button>${J}</button></div>
|
|
15
15
|
</div>
|
|
16
|
-
</div>`)}let A=null,M=null,$=null,Z=null;function X(s){T(s);const t=s.imageContainerElm,i=s.elements.length;if(!t)return;let n=0,e=0,r=0,d=0,o=null,a=0,c=!1;A=l=>{l.preventDefault(),l.stopPropagation(),s.isZoomed===!1&&(c=!0,n=l.pageX,e=l.pageY,r=l.pageX,d=l.pageY,a=Date.now(),o=null,t.setPointerCapture(l.pointerId))},M=l=>{if(l.preventDefault(),l.stopPropagation(),s.isZoomed!==!1||!c)return;const h=l.pageX-n,m=l.pageY-e;r=l.pageX,d=l.pageY,Math.abs(h)>=Math.abs(m)&&(o===null||o===!0)?(t.style.setProperty("--vistaview-pointer-diff-x",`${h}px`),o=!0):Math.abs(m)>Math.abs(h)&&(o===null||o===!1)&&(t.style.setProperty("--vistaview-pointer-diff-y",`${m}px`),o=!1)},Z=l=>{if(l.preventDefault(),l.stopPropagation(),t.releasePointerCapture(l.pointerId),s.isZoomed!==!1||!c)return;c=!1,o=null;const h=Array.from(t.querySelectorAll(".vistaview-item"));t.style.removeProperty("--vistaview-pointer-diff-x"),t.style.removeProperty("--vistaview-pointer-diff-y"),h.forEach(m=>{m.style.transition="",m.style.translate=""})},$=l=>{if(l.preventDefault(),l.stopPropagation(),t.releasePointerCapture(l.pointerId),s.isZoomed!==!1||!c)return;c=!1;const h=Array.from(t.querySelectorAll(".vistaview-item")),m=r-n,v=d-e,w=Date.now()-a,u=m/w,p=v/w,f=s.options.touchSpeedThreshold||.5,b=h.find(E=>E.dataset.vistaviewPos==="0"),I=Number(b.dataset.vistaviewIndex);function y(){h[0].removeEventListener("transitionend",y),t.style.removeProperty("--vistaview-pointer-diff-x"),t.style.removeProperty("--vistaview-pointer-diff-y"),h.forEach(E=>{E.style.transition="",E.style.translate=""})}function x(E="0%",L="0%"){h.forEach(D=>{D.style.transition=`translate ${s.options.animationDurationBase*.5}ms ease-out`,D.style.translate=`${E} ${L}`})}if(u<-f||u>f){let E=function(){h[0].removeEventListener("transitionend",E),setTimeout(()=>{const L=s.isReducedMotion;s.isReducedMotion=!0,y(),s.view(u<-f?(I+1)%i:(I-1+i)%i,{next:u<-f,prev:u>f}),s.isReducedMotion=L},100)};x(u<-f?"-100%":"100%"),h[0].addEventListener("transitionend",E)}else p<-f||p>f?(s.close(),x("0%","0%")):(h[0].addEventListener("transitionend",y),x("0%"),u===0&&p===0&&s.zoomIn())},t.addEventListener("pointermove",M),t.addEventListener("pointerup",$),t.addEventListener("pointerdown",A),t.addEventListener("pointercancel",Z)}function T(s){const t=s.imageContainerElm;t&&(M&&t.removeEventListener("pointermove",M),$&&t.removeEventListener("pointerup",$),A&&t.removeEventListener("pointerdown",A),Z&&t.removeEventListener("pointercancel",Z))}const Y=s=>{X(s)},B=({htmlElements:{to:s},index:{to:t},elements:i})=>{i instanceof NodeList&&t!==null&&(i.forEach(n=>n.style.opacity="1"),i[t].style.opacity="0"),s&&s.forEach(n=>{const e=Number(n.dataset.vistaviewPos);e!==0?(n.style.zIndex="1",n.style.left=100*e+"%"):n.style.zIndex="2"})},F=async({htmlElements:{from:s,to:t},images:{to:i},via:{next:n,prev:e},options:r,isReducedMotion:d},o)=>{if(!i)throw new Error("VistaView: images is null in defaultTransition()");if(d)return;const a=s.filter(c=>c.dataset.vistaviewPos==="0"||(n?c.dataset.vistaviewPos==="1":c.dataset.vistaviewPos==="-1"));await new Promise((c,l)=>{let h=0;if(o.aborted){l(new S("Transition aborted"));return}const m=v=>{if(o.aborted)return l(new S("Transition aborted"));if(v.currentTarget.removeEventListener("transitionend",m),h++,h<a.length)return;const w=t==null?void 0:t.find(y=>y.dataset.vistaviewPos==="0"),u=w?Number(w.dataset.vistaviewIndex):0,p=a.find(y=>Number(y.dataset.vistaviewIndex)===u),f=p==null?void 0:p.querySelector(".vistaview-image-highres");if(!f)return l(new Error("current image element not found"));if(!f.classList.contains("vistaview-image-loaded")||f.classList.contains("vistaview-image-settled"))return c(0);let b=0;const I=setInterval(()=>{if(o.aborted)return clearInterval(I),l(new S("Transition aborted"));if(b++,b>r.animationDurationBase/20*1.5)return clearInterval(I),c(0);if(f.classList.contains("vistaview-image-settled"))return w==null||w.classList.add("vistaview-image-settled"),clearInterval(I),c(0)},20)};a.forEach(v=>{v.style.transition=`translate ${r.animationDurationBase*.5}ms ease-out`,v.style.translate=n?"-100%":e?"100%":"0%",v.addEventListener("transitionend",m)})})},_=s=>{s.elements instanceof NodeList&&s.elements.forEach(t=>t.style.opacity="1"),T(s)};class S extends Error{constructor(t){super(t),this.name="VistaViewTransitionAbortedError"}}const z={detectReducedMotion:!0,animationDurationBase:333,zoomStep:500,maxZoomLevel:2,touchSpeedThreshold:.5,preloads:1,keyboardListeners:!0,arrowOnSmallScreens:!1,controls:{topLeft:["indexDisplay"],topRight:["zoomIn","zoomOut",V(),"close"],bottomCenter:["description"]}},C={somethingOpened:null};class ot{constructor(t,i){g(this,"options");g(this,"elements");g(this,"isReducedMotion");g(this,"currentIndex",{_value:null,_vistaView:null,_via:{next:!1,prev:!1},set value(t){var n,e,r;const i=this._value;this._value=t;for(const d in(n=this._vistaView)==null?void 0:n.transitionAbortControllers)(e=this._vistaView)==null||e.transitionAbortControllers[d].abort();(r=this._vistaView)==null||r.swap(i,this._value)},get value(){return this._value},get via(){return this._via},set via(t){this._via=t}});g(this,"rootElm",null);g(this,"imageContainerElm",null);g(this,"customControls",{});g(this,"currentImages",null);g(this,"currentItems",null);g(this,"navActive",!0);g(this,"isZoomed",!1);g(this,"onClickElements",t=>{t.preventDefault();const i=t.currentTarget;i.dataset.vistaviewIndex&&this.open(parseInt(i.dataset.vistaviewIndex))});g(this,"defaultOnClickHandler",t=>t.preventDefault());g(this,"onResizeHandler",null);g(this,"onKeyDown",null);g(this,"userSetup",B);g(this,"userTransition",F);g(this,"userClose",_);g(this,"userInit",Y);g(this,"onZoomedPointerDown",null);g(this,"onZoomedPointerMove",null);g(this,"onZoomedPointerUp",null);g(this,"transitionAbortControllers",{});g(this,"loadImageTimeout",null);this.elements=t,this.currentIndex._vistaView=this,this.options={...z,...i||{},controls:{...z.controls,...(i==null?void 0:i.controls)||{}}},this.options.initFunction&&(this.userInit=this.options.initFunction),this.options.transitionFunction&&(this.userTransition=this.options.transitionFunction),this.options.closeFunction&&(this.userClose=this.options.closeFunction),this.options.initFunction&&(this.userInit=this.options.initFunction),this.isReducedMotion=window.matchMedia("(prefers-reduced-motion: reduce)").matches,this.elements instanceof NodeList&&this.elements.forEach((n,e)=>{n.dataset.vistaviewIndex=e.toString(),n.addEventListener("click",this.defaultOnClickHandler),n.addEventListener("pointerup",this.onClickElements)})}setFullSizeImageDim(t){var r,d;const i=t.getBoundingClientRect(),{width:n,height:e}=q(t);if(n===i.width&&e===i.height)(d=(r=t.parentElement)==null?void 0:r.querySelector(".vistaview-image-lowres"))==null||d.classList.add("vistaview-image--hidden"),t.classList.add("vistaview-image-settled");else{let o=0;const a=()=>{var c,l;o++,!(o<3)&&(t.removeEventListener("transitionend",a),(l=(c=t.parentElement)==null?void 0:c.querySelector(".vistaview-image-lowres"))==null||l.classList.add("vistaview-image--hidden"),t.classList.add("vistaview-image-settled"))};requestAnimationFrame(()=>{t.addEventListener("transitionend",a),t.style.width=`${n}px`,t.style.height=`${e}px`})}}async swap(t,i){var l,h,m;if(!C.somethingOpened||t===i||t===null)return;if(!this.imageContainerElm)throw new Error("VistaView: imageContainerElm is null in swap()");this.setIndexDisplay(),this.clearZoom();const{images:n,positions:e}=this.getCurrentIndexes(i),r=this.getImages(n),d=r.map((v,w)=>W(v,e[w])),o={htmlElements:{from:this.currentItems,to:d},images:{from:this.currentImages,to:r},index:{from:t,to:i},via:this.currentIndex.via,container:this.imageContainerElm,elements:this.elements,isReducedMotion:this.isReducedMotion,navActive:this.navActive,isZoomed:this.isZoomed,options:this.options};this.userSetup(o),(l=this.currentItems)==null||l.forEach(v=>{v.classList.add("vistaview-image--ending")});const a=Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15);this.transitionAbortControllers[a]=new AbortController;try{await this.userTransition(o,this.transitionAbortControllers[a].signal)}catch(v){v instanceof S||console.warn(v)}delete this.transitionAbortControllers[a];const c=d.find(v=>v.dataset.vistaviewPos==="0");if(c){const v=c.dataset.vistaviewIndex,w=this.currentItems.find(p=>p.dataset.vistaviewIndex===v),u=w==null?void 0:w.querySelector(".vistaview-image-highres");if(u){const p=c.querySelector(".vistaview-image-highres");if(p.setAttribute("class",u.getAttribute("class")||""),p.setAttribute("style",u.getAttribute("style")||""),p.classList.remove("vistaview-image--zooming"),u.classList.contains("vistaview-image-loaded")&&!u.classList.contains("vistaview-image-settled")){const f=u.getBoundingClientRect();p.dataset.vistaviewCurrentWidth=f.width.toString(),p.dataset.vistaviewCurrentHeight=f.height.toString(),p.style.width=`${f.width}px`,p.style.height=`${f.height}px`}}}this.imageContainerElm.innerHTML="",d.forEach(v=>{var f;const w=v.querySelector(".vistaview-image-highres"),u=!!w.classList.contains("vistaview-image-loaded"),p=!!w.classList.contains("vistaview-image-settled");this.imageContainerElm.appendChild(v),u&&!p?this.setFullSizeImageDim(w):u&&p&&((f=v==null?void 0:v.querySelector(".vistaview-image-lowres"))==null||f.classList.add("vistaview-image--hidden"))}),this.setInitialDimPos(),this.currentImages=r,this.currentItems=d,this.setCurrentDescription(),this.updateZoomButtonsVisibility(),(m=(h=this.options).onImageView)==null||m.call(h,o),this.loadImageTimeout&&clearTimeout(this.loadImageTimeout),this.loadImageTimeout=setTimeout(()=>{this.loadImages()},333)}setZoomed(t){var i,n,e,r,d,o;if(this.isZoomed!==t){if(this.isZoomed){let a=this.isZoomed;if(a.classList.remove("vistaview-image--zooming"),this.onZoomedPointerDown&&((i=a.parentElement)==null||i.removeEventListener("pointerdown",this.onZoomedPointerDown),this.onZoomedPointerDown=null),this.onZoomedPointerMove&&((n=a.parentElement)==null||n.removeEventListener("pointermove",this.onZoomedPointerMove),this.onZoomedPointerMove=null),this.onZoomedPointerUp&&((e=a.parentElement)==null||e.removeEventListener("pointerup",this.onZoomedPointerUp),this.onZoomedPointerUp=null),a==null||a.style.removeProperty("--pointer-diff-x"),a==null||a.style.removeProperty("--pointer-diff-y"),setTimeout(()=>{a==null||a.classList.remove("vistaview-image--zooming")},500),this.isZoomed=!1,!t)return}if(t){this.isZoomed=t,t.classList.add("vistaview-image--zooming"),t==null||t.style.setProperty("--pointer-diff-x","0px"),t==null||t.style.setProperty("--pointer-diff-y","0px");let a=!1,c=0,l=0,h=0,m=0,v=0,w=0;this.onZoomedPointerDown=u=>{u.preventDefault(),u.stopPropagation(),a=!0,c=u.pageX,l=u.pageY,t.setPointerCapture(u.pointerId)},this.onZoomedPointerMove=u=>{if(!a)return;u.preventDefault(),v=u.pageX-c,w=u.pageY-l;const p=parseInt((t==null?void 0:t.dataset.vistaviewCurrentWidth)||"0"),f=parseInt((t==null?void 0:t.dataset.vistaviewCurrentHeight)||"0"),{maxDiffX:b,minDiffY:I,maxDiffY:y,minDiffX:x}=k(p,f),E=Math.min(b,Math.max(x,h+v)),L=Math.min(y,Math.max(I,m+w));v=E-h,w=L-m,t==null||t.style.setProperty("--pointer-diff-x",`${E}px`),t==null||t.style.setProperty("--pointer-diff-y",`${L}px`)},this.onZoomedPointerUp=u=>{a=!1,t.releasePointerCapture(u.pointerId),h+=v,m+=w,v=0,w=0},(r=t==null?void 0:t.parentElement)==null||r.addEventListener("pointerdown",this.onZoomedPointerDown),(d=t==null?void 0:t.parentElement)==null||d.addEventListener("pointermove",this.onZoomedPointerMove),(o=t==null?void 0:t.parentElement)==null||o.addEventListener("pointerup",this.onZoomedPointerUp);return}}}zoomIn(){var r,d,o,a,c;const t=(r=this.rootElm)==null?void 0:r.querySelector('[data-vistaview-pos="0"] .vistaview-image-highres'),i=t.width,n=t.height;t.dataset.vistaviewInitialWidth||(t.dataset.vistaviewInitialWidth=i.toString()),t.dataset.vistaviewInitialHeight||(t.dataset.vistaviewInitialHeight=n.toString()),this.setZoomed(t);const e=(t.naturalWidth||0)*this.options.maxZoomLevel;if(i&&e&&i<e){const l=Math.min(i+this.options.zoomStep,e);t.style.width=`${l}px`;const h=l/i*n;t.style.height=`${h}px`,(o=(d=this.rootElm)==null?void 0:d.querySelector("button.vistaview-zoom-out-btn"))==null||o.removeAttribute("disabled"),t.dataset.vistaviewCurrentWidth=l.toString(),t.dataset.vistaviewCurrentHeight=h.toString(),l===e&&((c=(a=this.rootElm)==null?void 0:a.querySelector("button.vistaview-zoom-in-btn"))==null||c.setAttribute("disabled","true"))}}zoomOut(){var d,o,a,c,l;const t=(d=this.rootElm)==null?void 0:d.querySelector('[data-vistaview-pos="0"] .vistaview-image-highres'),i=t.width,n=t.height,e=t.dataset.vistaviewInitialWidth?parseInt(t.dataset.vistaviewInitialWidth):0,r=h=>{h.target===t&&(t.classList.remove("vistaview-image--zooming-out"),t.removeEventListener("transitionend",r))};if(t.addEventListener("transitionend",r),t.classList.add("vistaview-image--zooming-out"),i&&e&&i>e){const h=Math.max(i-this.options.zoomStep,e);t.style.width=`${h}px`;const m=h/i*n;t.style.height=`${m}px`,(a=(o=this.rootElm)==null?void 0:o.querySelector("button.vistaview-zoom-in-btn"))==null||a.removeAttribute("disabled"),t.dataset.vistaviewCurrentWidth=h.toString(),t.dataset.vistaviewCurrentHeight=m.toString();const{maxDiffX:v,minDiffY:w,maxDiffY:u,minDiffX:p}=k(h,m);let f=parseInt((t==null?void 0:t.style.getPropertyValue("--pointer-diff-x").replace("px",""))||"0"),b=parseInt((t==null?void 0:t.style.getPropertyValue("--pointer-diff-y").replace("px",""))||"0");f=Math.min(v,Math.max(p,f)),b=Math.min(u,Math.max(w,b)),t==null||t.style.setProperty("--pointer-diff-x",`${f}px`),t==null||t.style.setProperty("--pointer-diff-y",`${b}px`),h===e&&((l=(c=this.rootElm)==null?void 0:c.querySelector("button.vistaview-zoom-out-btn"))==null||l.setAttribute("disabled","true"),t.removeAttribute("data-vistaview-current-width"),t.removeAttribute("data-vistaview-current-height"),t.removeAttribute("data-vistaview-initial-width"),t.removeAttribute("data-vistaview-initial-height"),this.setZoomed(!1))}}clearZoom(){}getImages(t){return t.map((i,n)=>{const e=this.elements[i];if(e instanceof HTMLElement){const r=e.querySelector("img"),d=e.getAttribute("href")||"",o=e.getAttribute("src")||"",a=e.dataset.vistaviewSrc||d||o||(r==null?void 0:r.src)||"",c=e.dataset.vistaviewAlt||e.getAttribute("alt")||(r==null?void 0:r.alt)||"",l=e.dataset.vistaviewThumb||(r==null?void 0:r.src)||d||o||"";return{index:t[n],src:a,alt:c,thumb:l,imageElm:e instanceof HTMLImageElement?e:r,anchorElm:e instanceof HTMLAnchorElement?e:void 0}}else return{index:t[n],...e}})}setInitialDimPos(){var c,l;if(!this.rootElm)return;const t=(c=this.rootElm.querySelector('[data-vistaview-pos="0"]'))==null?void 0:c.dataset.vistaviewIndex,i=((l=this.currentImages)==null?void 0:l.find(h=>h.index===Number(t)))||null;if(!i)return;const n=i.imageElm?R(i.imageElm):void 0,e=i.anchorElm?R(i.anchorElm):void 0,r=(e==null?void 0:e.width)||(n==null?void 0:n.width)||0,d=(e==null?void 0:e.height)||(n==null?void 0:n.height)||0,o=((e==null?void 0:e.left)||(n==null?void 0:n.left)||0)+r/2,a=((e==null?void 0:e.top)||(n==null?void 0:n.top)||0)+d/2;this.rootElm.style.setProperty("--vistaview-container-initial-width",r+"px"),this.rootElm.style.setProperty("--vistaview-container-initial-height",d+"px"),this.rootElm.style.setProperty("--vistaview-container-initial-top",a+"px"),this.rootElm.style.setProperty("--vistaview-container-initial-left",o+"px"),this.rootElm.style.setProperty("--vistaview-image-border-radius",H(e==null?void 0:e.borderRadius)||H(n==null?void 0:n.borderRadius)||"0px")}updateZoomButtonsVisibility(){var e;const t=(e=this.rootElm)==null?void 0:e.querySelector('[data-vistaview-pos="0"] img.vistaview-image-highres');if(!t)return;const i=this;function n(){var l,h;const r=(l=i.rootElm)==null?void 0:l.querySelector("button.vistaview-zoom-in-btn"),d=(h=i.rootElm)==null?void 0:h.querySelector("button.vistaview-zoom-out-btn"),o=parseInt(t.style.width)||t.width,a=t.naturalWidth*i.options.maxZoomLevel,c=o<a&&a>0;r&&(r.style.display=c?"":"none"),d&&(d.style.display=c?"":"none")}t.complete&&t.naturalWidth>0?n():t.addEventListener("load",n)}loadImages(){if(!this.rootElm)return;this.rootElm.querySelectorAll(".vistaview-image-highres:not(.vistaview-image-loaded)").forEach((i,n)=>{const e=i,d=this.currentImages[n].imageElm,o={w:0,h:0};if(d){const{width:c,height:l}=j(d);o.w=Math.min(d.width,c),o.h=Math.min(d.height,l)}const a=()=>{var l,h;if((l=e.parentElement)!=null&&l.classList.contains("vistaview-image--ending"))return;const c=()=>{var m;o.w&&o.h&&(e.style.width=`${o.w}px`,e.style.height=`${o.h}px`,e.style.setProperty("--vistaview-fitted-width",`${o.w}px`),e.style.setProperty("--vistaview-fitted-height",`${o.h}px`)),e.classList.add("vistaview-image-loaded"),e.width=e.naturalWidth,e.height=e.naturalHeight,setTimeout(()=>{var v;(v=e.parentElement)!=null&&v.classList.contains("vistaview-image--ending")||this.setFullSizeImageDim(e)},100),(m=i.parentElement)!=null&&m.matches('[data-vistaview-pos="0"]')&&this.updateZoomButtonsVisibility()};if((h=this.rootElm)!=null&&h.classList.contains("vistaview--opened"))c();else{const m=setInterval(()=>{var v;(v=this.rootElm)!=null&&v.classList.contains("vistaview--opened")&&(clearInterval(m),c())},50)}};e.complete&&e.naturalWidth>0?a():e.onload=a})}setIndexDisplay(){this.elements.length!==1&&(this.rootElm.querySelector(".vistaview-index-display").textContent=`${this.currentIndex.value+1} / ${this.elements.length}`)}setCurrentDescription(){this.rootElm.querySelector(".vistaview-description").textContent=(this.currentImages[1]||this.currentImages[0]).alt||""}getCurrentIndexes(t){const i=this.options.preloads,n=this.elements.length,e=n<1||!i?[t]:[...new Set([...Array.from({length:i},(d,o)=>((t-i+o)%n+n)%n),t,...Array.from({length:i},(d,o)=>(t+1+o)%n)])],r=n<1||!i?[0]:e.map((d,o)=>o-Math.floor(e.length/2));return{images:e,positions:r}}setKeyboardListeners(){this.onKeyDown=t=>{switch(t.key){case"ArrowLeft":t.preventDefault(),this.prev();break;case"ArrowRight":t.preventDefault(),this.next();break;case"ArrowUp":t.preventDefault(),this.zoomIn();break;case"ArrowDown":t.preventDefault(),this.zoomOut();break;case"Escape":t.preventDefault(),this.close();break}},window.addEventListener("keydown",this.onKeyDown)}setResizeListeners(){this.onResizeHandler=()=>{var i;this.setInitialDimPos();const t=(i=this.rootElm)==null?void 0:i.querySelectorAll(".vistaview-image-highres.vistaview-image-loaded");t==null||t.forEach(n=>{const e=n,{width:r,height:d}=q(e);e.classList.contains("vistaview-image--zooming")?(e.dataset.vistaviewInitialWidth=r.toString(),e.dataset.vistaviewInitialHeight=d.toString()):(e.style.width=`${r}px`,e.style.height=`${d}px`)})},window.addEventListener("resize",this.onResizeHandler)}open(t=0){var o,a,c,l,h,m,v,w,u,p,f,b,I;if(C.somethingOpened){console.error("VistaView: another instance is already opened. Returning.");return}if(C.somethingOpened=this,this.currentIndex._value=t,document.body.prepend(st({controls:this.options.controls,isReducedMotion:this.isReducedMotion})),this.rootElm=document.querySelector("#vistaview-root"),this.imageContainerElm=((o=this.rootElm)==null?void 0:o.querySelector(".vistaview-image-container"))||null,!this.rootElm||!this.imageContainerElm)throw C.somethingOpened=null,new Error("Failed to create VistaView element");this.options.arrowOnSmallScreens||this.rootElm.classList.add("vistaview-no-arrows-sm");const{images:i,positions:n}=this.getCurrentIndexes(t);this.currentImages=this.getImages(i);const e=this.currentImages.map((y,x)=>W(y,n[x]));this.currentItems=e;const r={htmlElements:{from:null,to:this.currentItems},images:{from:null,to:this.currentImages},index:{from:null,to:t},via:this.currentIndex.via,container:this.imageContainerElm,elements:this.elements,isReducedMotion:this.isReducedMotion,navActive:this.navActive,isZoomed:this.isZoomed,options:this.options};this.userSetup(r),this.imageContainerElm.innerHTML="",this.currentItems.forEach(y=>{this.imageContainerElm.appendChild(y)});let d=0;this.rootElm.addEventListener("animationend",y=>{var x;y.currentTarget===this.rootElm&&(d++,d>=2&&((x=this.rootElm)==null||x.classList.add("vistaview--opened")))}),(a=this.rootElm.querySelector(".vistaview-close-btn"))==null||a.addEventListener("click",()=>this.close()),(c=this.rootElm.querySelector(".vistaview-zoom-in-btn"))==null||c.addEventListener("click",()=>this.zoomIn()),(l=this.rootElm.querySelector(".vistaview-zoom-out-btn"))==null||l.addEventListener("click",()=>this.zoomOut()),(h=this.rootElm.querySelector(".vistaview-prev-btn>button"))==null||h.addEventListener("click",()=>this.prev()),(m=this.rootElm.querySelector(".vistaview-next-btn>button"))==null||m.addEventListener("click",()=>this.next()),[...this.options.controls.topLeft||[],...this.options.controls.topRight||[],...this.options.controls.topCenter||[],...this.options.controls.bottomCenter||[],...this.options.controls.bottomLeft||[],...this.options.controls.bottomRight||[]].forEach(y=>{typeof y!="string"&&(this.customControls[y.name]=y)}),this.rootElm.querySelectorAll("button[data-vistaview-custom-control]").forEach(y=>{y.addEventListener("click",x=>{const E=this.customControls[x.currentTarget.dataset.vistaviewCustomControl],L=this.currentImages.find(D=>D.index===this.currentIndex.value);E&&L&&(E.onClick.constructor.name==="AsyncFunction"?(y.classList.add("vistaview-button--loading"),E.onClick(L).finally(()=>{y.classList.remove("vistaview-button--loading")})):E.onClick(L))})}),this.options.animationDurationBase&&this.rootElm.style.setProperty("--vistaview-animation-duration",`${this.options.animationDurationBase}`),this.options.initialZIndex!==void 0&&this.rootElm.style.setProperty("--vistaview-initial-z-index",`${this.options.initialZIndex}`),this.setInitialDimPos(),this.setResizeListeners(),this.options.keyboardListeners&&this.setKeyboardListeners(),this.elements.length===1&&((v=this.rootElm.querySelector(".vistaview-prev-btn"))==null||v.classList.add("vistaview-ui--none"),(w=this.rootElm.querySelector(".vistaview-next-btn"))==null||w.classList.add("vistaview-ui--none"),(u=this.rootElm.querySelector(".vistaview-index-display"))==null||u.classList.add("vistaview-ui--none")),this.rootElm&&this.rootElm.classList.add("vistaview--initialized"),this.loadImages(),this.setCurrentDescription(),this.setIndexDisplay(),this.userInit(this),(f=(p=this.options).onOpen)==null||f.call(p,r),(I=(b=this.options).onImageView)==null||I.call(b,r)}async close(t=!0){var n,e,r;if(C.somethingOpened!==this)return;t&&((n=this.rootElm)==null||n.classList.add("vistaview--closing"),await new Promise(d=>{var a;let o;(a=this.rootElm)==null||a.addEventListener("transitionend",c=>{c.currentTarget===this.rootElm&&(o&&clearTimeout(o),o=setTimeout(()=>{d()},333))})}));const i={htmlElements:{from:this.currentItems,to:null},images:{from:this.currentImages,to:null},index:{from:this.currentIndex.value,to:null},container:this.imageContainerElm,elements:this.elements,via:{prev:!1,next:!1},isReducedMotion:this.isReducedMotion,navActive:this.navActive,isZoomed:this.isZoomed,options:this.options};this.userClose(this),(r=(e=this.options).onClose)==null||r.call(e,i),document.body.removeChild(this.rootElm),this.currentIndex._value=null,this.currentIndex._via={next:!1,prev:!1},this.rootElm=null,this.imageContainerElm=null,this.currentImages=null,this.currentItems=null,this.navActive=!0,this.onResizeHandler&&(window.removeEventListener("resize",this.onResizeHandler),this.onResizeHandler=null),this.onKeyDown&&(window.removeEventListener("keydown",this.onKeyDown),this.onKeyDown=null),(this.onZoomedPointerDown||this.onZoomedPointerMove||this.onZoomedPointerUp)&&(this.setZoomed(!1),this.onZoomedPointerDown=null,this.onZoomedPointerMove=null,this.onZoomedPointerUp=null);for(const d in this.transitionAbortControllers)this.transitionAbortControllers[d].abort();this.transitionAbortControllers={},C.somethingOpened=null}destroy(){this.close(!1),this.elements instanceof NodeList&&this.elements.forEach(t=>{t.dataset.vistaviewIndex&&delete t.dataset.vistaviewIndex,t.removeEventListener("click",this.defaultOnClickHandler),t.removeEventListener("pointerup",this.onClickElements)})}view(t,i){C.somethingOpened===this&&this.navActive&&(t<0&&(t=this.elements.length-1),t>=this.elements.length&&(t=0),this.currentIndex.via=i||{next:!1,prev:!1},this.currentIndex.value=t)}next(){C.somethingOpened===this&&this.view(this.currentIndex.value+1,{next:!0,prev:!1})}prev(){C.somethingOpened===this&&this.view(this.currentIndex.value-1,{next:!1,prev:!0})}getCurrentIndex(){return C.somethingOpened===this?this.currentIndex.value:-1}}function rt(s){let t=null;if(typeof s=="string"?t=document.querySelectorAll(s):s instanceof NodeList&&(t=s),t)for(let i=0;i<t.length;i++){const n=t[i];if(!(n.dataset.vistaviewSrc||n.getAttribute("href")||n.getAttribute("src")||""))return`Element at index ${i} is missing 'src' / 'data-vistaview-src' / 'href' attribute.`}else{const i=s;for(let n=0;n<i.length;n++)if(!i[n].src)return`Element at index ${n} is missing 'src' attribute.`}return t||s}function at({elements:s,...t}){if(!s)throw new Error("No elements");let i=rt(s);if(typeof i=="string")return console.error(i),console.warn("VistaView: silently returning."),null;const n=new ot(i,t);return{open:(e=0)=>n.open(e),close:()=>n.close(),next:()=>n.next(),prev:()=>n.prev(),destroy:()=>n.destroy(),getCurrentIndex:()=>n.getCurrentIndex(),view:e=>{n.view(e)}}}exports.DefaultOptions=z;exports.VistaViewTransitionAbortedError=S;exports.defaultClose=_;exports.defaultInit=Y;exports.defaultSetup=B;exports.defaultTransition=F;exports.removeTouchActions=T;exports.setTouchActions=X;exports.vistaView=at;exports.vistaViewDownload=V;
|
|
16
|
+
</div>`)}let M=null,$=null,z=null,A=null;function Y(s){T(s);const t=s.imageContainerElm,i=s.elements.length;if(!t)return;let n=0,e=0,r=0,a=0,o=null,l=0,c=!1;M=d=>{d.preventDefault(),d.stopPropagation(),s.isZoomed===!1&&(c=!0,n=d.pageX,e=d.pageY,r=d.pageX,a=d.pageY,l=Date.now(),o=null,t.setPointerCapture(d.pointerId))},$=d=>{if(d.preventDefault(),d.stopPropagation(),s.isZoomed!==!1||!c)return;const h=d.pageX-n,u=d.pageY-e;r=d.pageX,a=d.pageY,Math.abs(h)>=Math.abs(u)&&(o===null||o===!0)?(t.style.setProperty("--vistaview-pointer-diff-x",`${h}px`),o=!0):Math.abs(u)>Math.abs(h)&&(o===null||o===!1)&&(t.style.setProperty("--vistaview-pointer-diff-y",`${u}px`),o=!1)},A=d=>{if(d.preventDefault(),d.stopPropagation(),t.releasePointerCapture(d.pointerId),s.isZoomed!==!1||!c)return;c=!1,o=null;const h=Array.from(t.querySelectorAll(".vistaview-item"));t.style.removeProperty("--vistaview-pointer-diff-x"),t.style.removeProperty("--vistaview-pointer-diff-y"),h.forEach(u=>{u.style.transition="",u.style.translate=""})},z=d=>{if(d.preventDefault(),d.stopPropagation(),t.releasePointerCapture(d.pointerId),s.isZoomed!==!1||!c)return;c=!1;const h=Array.from(t.querySelectorAll(".vistaview-item")),u=r-n,p=a-e,f=Date.now()-l,v=u/f,E=p/f,g=s.options.touchSpeedThreshold||.5,x=h.find(y=>y.dataset.vistaviewPos==="0"),C=Number(x.dataset.vistaviewIndex);function w(){h[0].removeEventListener("transitionend",w),t.style.removeProperty("--vistaview-pointer-diff-x"),t.style.removeProperty("--vistaview-pointer-diff-y"),h.forEach(y=>{y.style.transition="",y.style.translate=""})}function b(y="0%",I="0%"){h.forEach(S=>{S.style.transition=`translate ${s.options.animationDurationBase*.5}ms ease-out`,S.style.translate=`${y} ${I}`})}if(v<-g||v>g){let y=function(){h[0].removeEventListener("transitionend",y),setTimeout(()=>{const I=s.isReducedMotion,S=s.options.detectReducedMotion;s.isReducedMotion=!0,s.options.detectReducedMotion=!0,w(),s.view(v<-g?(C+1)%i:(C-1+i)%i,{next:v<-g,prev:v>g}),s.isReducedMotion=I,s.options.detectReducedMotion=S},100)};b(v<-g?"-100%":"100%"),h[0].addEventListener("transitionend",y)}else E<-g||E>g?(s.close(),b("0%","0%")):(h[0].addEventListener("transitionend",w),b("0%"),v===0&&E===0&&s.zoomIn())},t.addEventListener("pointermove",$),t.addEventListener("pointerup",z),t.addEventListener("pointerdown",M),t.addEventListener("pointercancel",A)}function T(s){const t=s.imageContainerElm;t&&($&&t.removeEventListener("pointermove",$),z&&t.removeEventListener("pointerup",z),M&&t.removeEventListener("pointerdown",M),A&&t.removeEventListener("pointercancel",A))}const F=s=>{Y(s)},_=({htmlElements:{to:s},index:{to:t},vistaView:i})=>{i.elements instanceof NodeList&&t!==null&&(i.elements.forEach(n=>n.style.opacity="1"),i.elements[t].style.opacity="0"),s&&s.forEach(n=>{const e=Number(n.dataset.vistaviewPos);e!==0?(n.style.zIndex="1",n.style.left=100*e+"%"):n.style.zIndex="2"})},B=async({htmlElements:{from:s},via:{next:t,prev:i},vistaView:n},e)=>{if(n.options.detectReducedMotion&&n.isReducedMotion)return;const r=s.filter(a=>a.dataset.vistaviewPos==="0"||(t?a.dataset.vistaviewPos==="1":a.dataset.vistaviewPos==="-1"));await new Promise((a,o)=>{let l=0,c=!1;if(e.aborted){o(new D("Transition aborted"));return}const d=h=>{if(c)return o(new D("Transition aborted"));if(e.aborted)return c||(c=!0),o(new D("Transition aborted"));h.currentTarget.removeEventListener("transitionend",d),l++,l>=r.length&&a(0)};r.forEach(h=>{h.style.transition=`translate ${n.options.animationDurationBase*.5}ms ease-out`,h.style.translate=t?"-100%":i?"100%":"0%",h.addEventListener("transitionend",d)})})},V=s=>{s.elements instanceof NodeList&&s.elements.forEach(t=>t.style.opacity="1"),T(s)};class D extends Error{constructor(t){super(t),this.name="VistaViewTransitionAbortedError"}}const Z={detectReducedMotion:!0,animationDurationBase:333,zoomStep:500,maxZoomLevel:2,touchSpeedThreshold:.5,preloads:1,keyboardListeners:!0,arrowOnSmallScreens:!1,controls:{topLeft:["indexDisplay"],topRight:["zoomIn","zoomOut",X(),"close"],bottomCenter:["description"]}},L={somethingOpened:null};class ot{constructor(t,i){m(this,"options");m(this,"elements");m(this,"isReducedMotion");m(this,"currentIndex",{_value:null,_vistaView:null,_via:{next:!1,prev:!1},set value(t){var n,e,r;const i=this._value;this._value=t;for(const a in(n=this._vistaView)==null?void 0:n.transitionAbortControllers)(e=this._vistaView)==null||e.transitionAbortControllers[a].abort();(r=this._vistaView)==null||r.swap(i,this._value)},get value(){return this._value},get via(){return this._via},set via(t){this._via=t}});m(this,"rootElm",null);m(this,"imageContainerElm",null);m(this,"customControls",{});m(this,"currentImages",null);m(this,"currentItems",null);m(this,"isZoomed",!1);m(this,"onClickElements",t=>{t.preventDefault();const i=t.currentTarget;i.dataset.vistaviewIndex&&this.open(parseInt(i.dataset.vistaviewIndex))});m(this,"defaultOnClickHandler",t=>t.preventDefault());m(this,"onResizeHandler",null);m(this,"onKeyDown",null);m(this,"userSetup",_);m(this,"userTransition",B);m(this,"userClose",V);m(this,"userInit",F);m(this,"onZoomedPointerDown",null);m(this,"onZoomedPointerMove",null);m(this,"onZoomedPointerUp",null);m(this,"transitionAbortControllers",{});m(this,"loadImageTimeout",null);this.elements=t,this.currentIndex._vistaView=this,this.options={...Z,...i||{},controls:{...Z.controls,...(i==null?void 0:i.controls)||{}}},this.options.initFunction&&(this.userInit=this.options.initFunction),this.options.transitionFunction&&(this.userTransition=this.options.transitionFunction),this.options.closeFunction&&(this.userClose=this.options.closeFunction),this.options.initFunction&&(this.userInit=this.options.initFunction),this.isReducedMotion=window.matchMedia("(prefers-reduced-motion: reduce)").matches,this.elements instanceof NodeList&&this.elements.forEach((n,e)=>{n.dataset.vistaviewIndex=e.toString(),n.addEventListener("click",this.defaultOnClickHandler),n.addEventListener("pointerup",this.onClickElements)})}setFullSizeImageDim(t){var r,a;const i=t.getBoundingClientRect(),{width:n,height:e}=q(t);if(n===i.width&&e===i.height)(a=(r=t.parentElement)==null?void 0:r.querySelector(".vistaview-image-lowres"))==null||a.classList.add("vistaview-image--hidden"),t.classList.add("vistaview-image-settled");else{let o=0;const l=()=>{var c,d;o++,!(o<3)&&(t.removeEventListener("transitionend",l),(d=(c=t.parentElement)==null?void 0:c.querySelector(".vistaview-image-lowres"))==null||d.classList.add("vistaview-image--hidden"),t.classList.add("vistaview-image-settled"))};requestAnimationFrame(()=>{t.addEventListener("transitionend",l),t.style.width=`${n}px`,t.style.height=`${e}px`})}}async swap(t,i){var d,h;if(!L.somethingOpened||t===i||t===null)return;if(!this.imageContainerElm)throw new Error("VistaView: imageContainerElm is null in swap()");this.setIndexDisplay(),this.clearZoom();const{images:n,positions:e}=this.getCurrentIndexes(i),r=this.getImages(n),a=r.map((u,p)=>O(u,e[p])),o={htmlElements:{from:this.currentItems,to:a},images:{from:this.currentImages,to:r},index:{from:t,to:i},via:this.currentIndex.via,vistaView:this};this.userSetup(o);const l=Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15);this.transitionAbortControllers[l]=new AbortController;try{await this.userTransition(o,this.transitionAbortControllers[l].signal)}catch(u){u instanceof D||console.warn(u)}const c=a.find(u=>u.dataset.vistaviewPos==="0");if(c){const u=c.dataset.vistaviewIndex,p=this.currentItems.find(v=>v.dataset.vistaviewIndex===u),f=p==null?void 0:p.querySelector(".vistaview-image-highres");if(f){const v=c.querySelector(".vistaview-image-highres");if(v.setAttribute("class",f.getAttribute("class")||""),v.setAttribute("style",f.getAttribute("style")||""),v.classList.remove("vistaview-image--zooming"),f.classList.contains("vistaview-image-loaded")&&!f.classList.contains("vistaview-image-settled")){const E=f.getBoundingClientRect();v.style.width=`${E.width}px`,v.style.height=`${E.height}px`}}}delete this.transitionAbortControllers[l],this.imageContainerElm.innerHTML="",a.forEach(u=>{var E;const p=u.querySelector(".vistaview-image-highres"),f=!!p.classList.contains("vistaview-image-loaded"),v=!!p.classList.contains("vistaview-image-settled");this.imageContainerElm.appendChild(u),f&&!v?this.setFullSizeImageDim(p):f&&v&&((E=u==null?void 0:u.querySelector(".vistaview-image-lowres"))==null||E.classList.add("vistaview-image--hidden"))}),this.setInitialDimPos(),this.currentImages=r,this.currentItems=a,this.setCurrentDescription(),this.updateZoomButtonsVisibility(),(h=(d=this.options).onImageView)==null||h.call(d,o),this.loadImageTimeout&&clearTimeout(this.loadImageTimeout),this.loadImageTimeout=setTimeout(()=>{this.loadImages()},333)}setZoomed(t){var i,n,e,r,a,o;if(this.isZoomed!==t){if(this.isZoomed){let l=this.isZoomed;if(l.classList.remove("vistaview-image--zooming"),this.onZoomedPointerDown&&((i=l.parentElement)==null||i.removeEventListener("pointerdown",this.onZoomedPointerDown),this.onZoomedPointerDown=null),this.onZoomedPointerMove&&((n=l.parentElement)==null||n.removeEventListener("pointermove",this.onZoomedPointerMove),this.onZoomedPointerMove=null),this.onZoomedPointerUp&&((e=l.parentElement)==null||e.removeEventListener("pointerup",this.onZoomedPointerUp),this.onZoomedPointerUp=null),l==null||l.style.removeProperty("--pointer-diff-x"),l==null||l.style.removeProperty("--pointer-diff-y"),setTimeout(()=>{l==null||l.classList.remove("vistaview-image--zooming")},500),this.isZoomed=!1,!t)return}if(t){this.isZoomed=t,t.classList.add("vistaview-image--zooming"),t==null||t.style.setProperty("--pointer-diff-x","0px"),t==null||t.style.setProperty("--pointer-diff-y","0px");let l=!1,c=0,d=0,h=0,u=0,p=0,f=0;this.onZoomedPointerDown=v=>{v.preventDefault(),v.stopPropagation(),l=!0,c=v.pageX,d=v.pageY,t.setPointerCapture(v.pointerId)},this.onZoomedPointerMove=v=>{if(!l)return;v.preventDefault(),p=v.pageX-c,f=v.pageY-d;const E=parseInt((t==null?void 0:t.dataset.vistaviewCurrentWidth)||"0"),g=parseInt((t==null?void 0:t.dataset.vistaviewCurrentHeight)||"0"),{maxDiffX:x,minDiffY:C,maxDiffY:w,minDiffX:b}=k(E,g),y=Math.min(x,Math.max(b,h+p)),I=Math.min(w,Math.max(C,u+f));p=y-h,f=I-u,t==null||t.style.setProperty("--pointer-diff-x",`${y}px`),t==null||t.style.setProperty("--pointer-diff-y",`${I}px`)},this.onZoomedPointerUp=v=>{l=!1,t.releasePointerCapture(v.pointerId),h+=p,u+=f,p=0,f=0},(r=t==null?void 0:t.parentElement)==null||r.addEventListener("pointerdown",this.onZoomedPointerDown),(a=t==null?void 0:t.parentElement)==null||a.addEventListener("pointermove",this.onZoomedPointerMove),(o=t==null?void 0:t.parentElement)==null||o.addEventListener("pointerup",this.onZoomedPointerUp);return}}}zoomIn(){var r,a,o,l,c;const t=(r=this.rootElm)==null?void 0:r.querySelector('[data-vistaview-pos="0"] .vistaview-image-highres'),i=t.width,n=t.height;t.dataset.vistaviewInitialWidth||(t.dataset.vistaviewInitialWidth=i.toString()),t.dataset.vistaviewInitialHeight||(t.dataset.vistaviewInitialHeight=n.toString()),this.setZoomed(t);const e=(t.naturalWidth||0)*this.options.maxZoomLevel;if(i&&e&&i<e){const d=Math.min(i+this.options.zoomStep,e);t.style.width=`${d}px`;const h=d/i*n;t.style.height=`${h}px`,(o=(a=this.rootElm)==null?void 0:a.querySelector("button.vistaview-zoom-out-btn"))==null||o.removeAttribute("disabled"),t.dataset.vistaviewCurrentWidth=d.toString(),t.dataset.vistaviewCurrentHeight=h.toString(),d===e&&((c=(l=this.rootElm)==null?void 0:l.querySelector("button.vistaview-zoom-in-btn"))==null||c.setAttribute("disabled","true"))}}zoomOut(){var a,o,l,c,d;const t=(a=this.rootElm)==null?void 0:a.querySelector('[data-vistaview-pos="0"] .vistaview-image-highres'),i=t.width,n=t.height,e=t.dataset.vistaviewInitialWidth?parseInt(t.dataset.vistaviewInitialWidth):0,r=h=>{h.target===t&&(t.classList.remove("vistaview-image--zooming-out"),t.removeEventListener("transitionend",r))};if(t.addEventListener("transitionend",r),t.classList.add("vistaview-image--zooming-out"),i&&e&&i>e){const h=Math.max(i-this.options.zoomStep,e);t.style.width=`${h}px`;const u=h/i*n;t.style.height=`${u}px`,(l=(o=this.rootElm)==null?void 0:o.querySelector("button.vistaview-zoom-in-btn"))==null||l.removeAttribute("disabled"),t.dataset.vistaviewCurrentWidth=h.toString(),t.dataset.vistaviewCurrentHeight=u.toString();const{maxDiffX:p,minDiffY:f,maxDiffY:v,minDiffX:E}=k(h,u);let g=parseInt((t==null?void 0:t.style.getPropertyValue("--pointer-diff-x").replace("px",""))||"0"),x=parseInt((t==null?void 0:t.style.getPropertyValue("--pointer-diff-y").replace("px",""))||"0");g=Math.min(p,Math.max(E,g)),x=Math.min(v,Math.max(f,x)),t==null||t.style.setProperty("--pointer-diff-x",`${g}px`),t==null||t.style.setProperty("--pointer-diff-y",`${x}px`),h===e&&((d=(c=this.rootElm)==null?void 0:c.querySelector("button.vistaview-zoom-out-btn"))==null||d.setAttribute("disabled","true"),t.removeAttribute("data-vistaview-current-width"),t.removeAttribute("data-vistaview-current-height"),t.removeAttribute("data-vistaview-initial-width"),t.removeAttribute("data-vistaview-initial-height"),this.setZoomed(!1))}}clearZoom(){}getImages(t){return t.map((i,n)=>{const e=this.elements[i];if(e instanceof HTMLElement){const r=e.querySelector("img"),a=e.getAttribute("href")||"",o=e.getAttribute("src")||"",l=e.dataset.vistaviewSrc||a||o||(r==null?void 0:r.src)||"",c=e.dataset.vistaviewAlt||e.getAttribute("alt")||(r==null?void 0:r.alt)||"",d=e.dataset.vistaviewThumb||(r==null?void 0:r.src)||a||o||"";return{index:t[n],src:l,alt:c,thumb:d,imageElm:e instanceof HTMLImageElement?e:r,anchorElm:e instanceof HTMLAnchorElement?e:void 0}}else return{index:t[n],...e}})}setInitialDimPos(){var c,d;if(!this.rootElm)return;const t=(c=this.rootElm.querySelector('[data-vistaview-pos="0"]'))==null?void 0:c.dataset.vistaviewIndex,i=((d=this.currentImages)==null?void 0:d.find(h=>h.index===Number(t)))||null;if(!i)return;const n=i.imageElm?R(i.imageElm):void 0,e=i.anchorElm?R(i.anchorElm):void 0,r=(e==null?void 0:e.width)||(n==null?void 0:n.width)||0,a=(e==null?void 0:e.height)||(n==null?void 0:n.height)||0,o=((e==null?void 0:e.left)||(n==null?void 0:n.left)||0)+r/2,l=((e==null?void 0:e.top)||(n==null?void 0:n.top)||0)+a/2;this.rootElm.style.setProperty("--vistaview-container-initial-width",r+"px"),this.rootElm.style.setProperty("--vistaview-container-initial-height",a+"px"),this.rootElm.style.setProperty("--vistaview-container-initial-top",l+"px"),this.rootElm.style.setProperty("--vistaview-container-initial-left",o+"px"),this.rootElm.style.setProperty("--vistaview-image-border-radius",H(e==null?void 0:e.borderRadius)||H(n==null?void 0:n.borderRadius)||"0px")}updateZoomButtonsVisibility(){var e;const t=(e=this.rootElm)==null?void 0:e.querySelector('[data-vistaview-pos="0"] img.vistaview-image-highres');if(!t)return;const i=this;function n(){var d,h;const r=(d=i.rootElm)==null?void 0:d.querySelector("button.vistaview-zoom-in-btn"),a=(h=i.rootElm)==null?void 0:h.querySelector("button.vistaview-zoom-out-btn"),o=parseInt(t.style.width)||t.width,l=t.naturalWidth*i.options.maxZoomLevel,c=o<l&&l>0;r&&(r.style.display=c?"":"none"),a&&(a.style.display=c?"":"none")}t.complete&&t.naturalWidth>0?n():t.addEventListener("load",n)}loadImages(){if(!this.rootElm)return;this.rootElm.querySelectorAll(".vistaview-image-highres:not(.vistaview-image-loaded)").forEach((i,n)=>{const e=i,a=this.currentImages[n].imageElm,o={w:0,h:0};if(a){const{width:c,height:d}=K(a);o.w=Math.min(a.width,c),o.h=Math.min(a.height,d)}const l=()=>{var d;const c=()=>{var h;o.w&&o.h&&(e.style.width=`${o.w}px`,e.style.height=`${o.h}px`,e.style.setProperty("--vistaview-fitted-width",`${o.w}px`),e.style.setProperty("--vistaview-fitted-height",`${o.h}px`)),e.classList.add("vistaview-image-loaded"),e.width=e.naturalWidth,e.height=e.naturalHeight,setTimeout(()=>{this.setFullSizeImageDim(e)},100),(h=i.parentElement)!=null&&h.matches('[data-vistaview-pos="0"]')&&this.updateZoomButtonsVisibility()};if((d=this.rootElm)!=null&&d.classList.contains("vistaview--opened"))c();else{const h=setInterval(()=>{var u;(u=this.rootElm)!=null&&u.classList.contains("vistaview--opened")&&(clearInterval(h),c())},50)}};e.complete&&e.naturalWidth>0?l():e.onload=l})}setIndexDisplay(){this.elements.length!==1&&(this.rootElm.querySelector(".vistaview-index-display").textContent=`${this.currentIndex.value+1} / ${this.elements.length}`)}setCurrentDescription(){this.rootElm.querySelector(".vistaview-description").textContent=(this.currentImages[1]||this.currentImages[0]).alt||""}getCurrentIndexes(t){const i=this.options.preloads,n=this.elements.length,e=n<1||!i?[t]:[...new Set([...Array.from({length:i},(a,o)=>((t-i+o)%n+n)%n),t,...Array.from({length:i},(a,o)=>(t+1+o)%n)])],r=n<1||!i?[0]:e.map((a,o)=>o-Math.floor(e.length/2));return{images:e,positions:r}}setKeyboardListeners(){this.onKeyDown=t=>{switch(t.key){case"ArrowLeft":t.preventDefault(),this.prev();break;case"ArrowRight":t.preventDefault(),this.next();break;case"ArrowUp":t.preventDefault(),this.zoomIn();break;case"ArrowDown":t.preventDefault(),this.zoomOut();break;case"Escape":t.preventDefault(),this.close();break}},window.addEventListener("keydown",this.onKeyDown)}setResizeListeners(){this.onResizeHandler=()=>{var i;this.setInitialDimPos();const t=(i=this.rootElm)==null?void 0:i.querySelectorAll(".vistaview-image-highres.vistaview-image-loaded");t==null||t.forEach(n=>{const e=n,{width:r,height:a}=q(e);e.classList.contains("vistaview-image--zooming")?(e.dataset.vistaviewInitialWidth=r.toString(),e.dataset.vistaviewInitialHeight=a.toString()):(e.style.width=`${r}px`,e.style.height=`${a}px`)})},window.addEventListener("resize",this.onResizeHandler)}open(t=0){var o,l,c,d,h,u,p,f,v,E,g,x,C;if(L.somethingOpened){console.error("VistaView: another instance is already opened. Returning.");return}if(L.somethingOpened=this,this.currentIndex._value=t,document.body.prepend(st({controls:this.options.controls,isReducedMotion:this.isReducedMotion})),this.rootElm=document.querySelector("#vistaview-root"),this.imageContainerElm=((o=this.rootElm)==null?void 0:o.querySelector(".vistaview-image-container"))||null,!this.rootElm||!this.imageContainerElm)throw L.somethingOpened=null,new Error("Failed to create VistaView element");this.options.arrowOnSmallScreens||this.rootElm.classList.add("vistaview-no-arrows-sm");const{images:i,positions:n}=this.getCurrentIndexes(t);this.currentImages=this.getImages(i);const e=this.currentImages.map((w,b)=>O(w,n[b]));this.currentItems=e;const r={htmlElements:{from:null,to:this.currentItems},images:{from:null,to:this.currentImages},index:{from:null,to:t},via:this.currentIndex.via,vistaView:this};this.userSetup(r),this.imageContainerElm.innerHTML="",this.currentItems.forEach(w=>{this.imageContainerElm.appendChild(w)});let a=0;this.rootElm.addEventListener("animationend",w=>{var b;w.currentTarget===this.rootElm&&(a++,a>=2&&((b=this.rootElm)==null||b.classList.add("vistaview--opened")))}),(l=this.rootElm.querySelector(".vistaview-close-btn"))==null||l.addEventListener("click",()=>this.close()),(c=this.rootElm.querySelector(".vistaview-zoom-in-btn"))==null||c.addEventListener("click",()=>this.zoomIn()),(d=this.rootElm.querySelector(".vistaview-zoom-out-btn"))==null||d.addEventListener("click",()=>this.zoomOut()),(h=this.rootElm.querySelector(".vistaview-prev-btn>button"))==null||h.addEventListener("click",()=>this.prev()),(u=this.rootElm.querySelector(".vistaview-next-btn>button"))==null||u.addEventListener("click",()=>this.next()),[...this.options.controls.topLeft||[],...this.options.controls.topRight||[],...this.options.controls.topCenter||[],...this.options.controls.bottomCenter||[],...this.options.controls.bottomLeft||[],...this.options.controls.bottomRight||[]].forEach(w=>{typeof w!="string"&&(this.customControls[w.name]=w)}),this.rootElm.querySelectorAll("button[data-vistaview-custom-control]").forEach(w=>{w.addEventListener("click",b=>{const y=this.customControls[b.currentTarget.dataset.vistaviewCustomControl],I=this.currentImages.find(S=>S.index===this.currentIndex.value);y&&I&&(y.onClick.constructor.name==="AsyncFunction"?(w.classList.add("vistaview-button--loading"),y.onClick(I).finally(()=>{w.classList.remove("vistaview-button--loading")})):y.onClick(I))})}),this.options.animationDurationBase&&this.rootElm.style.setProperty("--vistaview-animation-duration",`${this.options.animationDurationBase}`),this.options.initialZIndex!==void 0&&this.rootElm.style.setProperty("--vistaview-initial-z-index",`${this.options.initialZIndex}`),this.setInitialDimPos(),this.setResizeListeners(),this.options.keyboardListeners&&this.setKeyboardListeners(),this.elements.length===1&&((p=this.rootElm.querySelector(".vistaview-prev-btn"))==null||p.classList.add("vistaview-ui--none"),(f=this.rootElm.querySelector(".vistaview-next-btn"))==null||f.classList.add("vistaview-ui--none"),(v=this.rootElm.querySelector(".vistaview-index-display"))==null||v.classList.add("vistaview-ui--none")),this.rootElm&&this.rootElm.classList.add("vistaview--initialized"),this.loadImages(),this.setCurrentDescription(),this.setIndexDisplay(),this.userInit(this),(g=(E=this.options).onOpen)==null||g.call(E,r),(C=(x=this.options).onImageView)==null||C.call(x,r)}async close(t=!0){var n,e,r;if(L.somethingOpened!==this)return;t&&((n=this.rootElm)==null||n.classList.add("vistaview--closing"),await new Promise(a=>{var l;let o;(l=this.rootElm)==null||l.addEventListener("transitionend",c=>{c.currentTarget===this.rootElm&&(o&&clearTimeout(o),o=setTimeout(()=>{a()},333))})}));const i={htmlElements:{from:this.currentItems,to:null},images:{from:this.currentImages,to:null},index:{from:this.currentIndex.value,to:null},via:{prev:!1,next:!1},vistaView:this};this.userClose(this),(r=(e=this.options).onClose)==null||r.call(e,i),document.body.removeChild(this.rootElm),this.currentIndex._value=null,this.currentIndex._via={next:!1,prev:!1},this.rootElm=null,this.imageContainerElm=null,this.currentImages=null,this.currentItems=null,this.onResizeHandler&&(window.removeEventListener("resize",this.onResizeHandler),this.onResizeHandler=null),this.onKeyDown&&(window.removeEventListener("keydown",this.onKeyDown),this.onKeyDown=null),(this.onZoomedPointerDown||this.onZoomedPointerMove||this.onZoomedPointerUp)&&(this.setZoomed(!1),this.onZoomedPointerDown=null,this.onZoomedPointerMove=null,this.onZoomedPointerUp=null);for(const a in this.transitionAbortControllers)this.transitionAbortControllers[a].abort();this.transitionAbortControllers={},L.somethingOpened=null}destroy(){this.close(!1),this.elements instanceof NodeList&&this.elements.forEach(t=>{t.dataset.vistaviewIndex&&delete t.dataset.vistaviewIndex,t.removeEventListener("click",this.defaultOnClickHandler),t.removeEventListener("pointerup",this.onClickElements)})}view(t,i){L.somethingOpened===this&&(t<0&&(t=this.elements.length-1),t>=this.elements.length&&(t=0),this.currentIndex.via=i||{next:!1,prev:!1},this.currentIndex.value=t)}next(){L.somethingOpened===this&&this.view(this.currentIndex.value+1,{next:!0,prev:!1})}prev(){L.somethingOpened===this&&this.view(this.currentIndex.value-1,{next:!1,prev:!0})}getCurrentIndex(){return L.somethingOpened===this?this.currentIndex.value:-1}}function rt(s){let t=null;if(typeof s=="string"?t=document.querySelectorAll(s):s instanceof NodeList&&(t=s),t)for(let i=0;i<t.length;i++){const n=t[i];if(!(n.dataset.vistaviewSrc||n.getAttribute("href")||n.getAttribute("src")||""))return`Element at index ${i} is missing 'src' / 'data-vistaview-src' / 'href' attribute.`}else{const i=s;for(let n=0;n<i.length;n++)if(!i[n].src)return`Element at index ${n} is missing 'src' attribute.`}return t||s}function at({elements:s,...t}){if(!s)throw new Error("No elements");let i=rt(s);if(typeof i=="string")return console.error(i),console.warn("VistaView: silently returning."),null;const n=new ot(i,t);return{open:(e=0)=>n.open(e),close:()=>n.close(),next:()=>n.next(),prev:()=>n.prev(),destroy:()=>n.destroy(),getCurrentIndex:()=>n.getCurrentIndex(),view:e=>{n.view(e)}}}exports.DefaultOptions=Z;exports.VistaViewTransitionAbortedError=D;exports.defaultClose=V;exports.defaultInit=F;exports.defaultSetup=_;exports.defaultTransition=B;exports.removeTouchActions=T;exports.setTouchActions=Y;exports.vistaView=at;exports.vistaViewDownload=X;
|