smartphoto 2.1.15 → 2.1.16
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 +5 -0
- package/js/jquery-smartphoto.js +93 -36
- package/js/jquery-smartphoto.min.js +2 -2
- package/js/smartphoto.js +93 -36
- package/js/smartphoto.min.js +2 -2
- package/lib/smartphoto.js +92 -35
- package/lib/smartphoto.mjs +92 -35
- package/lib/types/core/types.d.ts +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -196,6 +196,11 @@ Slide fields:
|
|
|
196
196
|
<td>close the viewer on a downward swipe</td>
|
|
197
197
|
<td>true</td>
|
|
198
198
|
</tr>
|
|
199
|
+
<tr>
|
|
200
|
+
<td>pinchToClose</td>
|
|
201
|
+
<td>close the viewer when the photo is pinched in clearly below its base scale (fit/fill)</td>
|
|
202
|
+
<td>true</td>
|
|
203
|
+
</tr>
|
|
199
204
|
<tr>
|
|
200
205
|
<td>swipeOffset</td>
|
|
201
206
|
<td>minimum swipe distance (px) to trigger navigation/close</td>
|
package/js/jquery-smartphoto.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* SmartPhoto v2.1.
|
|
2
|
+
* SmartPhoto v2.1.16
|
|
3
3
|
* (c) appleple
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -154,6 +154,7 @@
|
|
|
154
154
|
useViewTransitionApi: true,
|
|
155
155
|
swipeTopToClose: false,
|
|
156
156
|
swipeBottomToClose: true,
|
|
157
|
+
pinchToClose: true,
|
|
157
158
|
swipeOffset: 100,
|
|
158
159
|
swipeVelocity: 0.5,
|
|
159
160
|
headerHeight: 60,
|
|
@@ -413,7 +414,7 @@
|
|
|
413
414
|
return Math.round(val * digit) / digit;
|
|
414
415
|
}
|
|
415
416
|
function getPos(e) {
|
|
416
|
-
return { x: e.
|
|
417
|
+
return { x: e.clientX, y: e.clientY };
|
|
417
418
|
}
|
|
418
419
|
function distance(p1, p2) {
|
|
419
420
|
const x = p1.x - p2.x;
|
|
@@ -446,7 +447,8 @@
|
|
|
446
447
|
let photoVX = 0;
|
|
447
448
|
let photoVY = 0;
|
|
448
449
|
let pinching = false;
|
|
449
|
-
let
|
|
450
|
+
let pinchStartDistance = 0;
|
|
451
|
+
let pinchStartScale = 1;
|
|
450
452
|
let pinchMoveFrame = null;
|
|
451
453
|
let vx = 0;
|
|
452
454
|
let vy = 0;
|
|
@@ -461,6 +463,14 @@
|
|
|
461
463
|
const { width, height } = windowSize();
|
|
462
464
|
return scaleBorder(item, width, height, isSmartPhone2());
|
|
463
465
|
}
|
|
466
|
+
function baselineOf(item) {
|
|
467
|
+
return state.options.resizeStyle === "fill" && isSmartPhone2() ? borderOf(item) : 1;
|
|
468
|
+
}
|
|
469
|
+
const MAX_PINCH_SCALE = 4;
|
|
470
|
+
function maxScaleOf(item) {
|
|
471
|
+
return Math.max(MAX_PINCH_SCALE, borderOf(item));
|
|
472
|
+
}
|
|
473
|
+
const PINCH_CLOSE_RATIO = 0.75;
|
|
464
474
|
function registerElasticForce(flagX, flagY) {
|
|
465
475
|
const item = currentItem(state);
|
|
466
476
|
const bound = boundOf(item);
|
|
@@ -508,7 +518,7 @@
|
|
|
508
518
|
}
|
|
509
519
|
const power = getForceAndTheta(vx, vy);
|
|
510
520
|
const force = power.force - state.options.registance;
|
|
511
|
-
if (
|
|
521
|
+
if (force < 0.5) {
|
|
512
522
|
return;
|
|
513
523
|
}
|
|
514
524
|
vx = Math.cos(power.theta) * force;
|
|
@@ -551,16 +561,23 @@
|
|
|
551
561
|
{ signal }
|
|
552
562
|
);
|
|
553
563
|
}
|
|
554
|
-
function
|
|
555
|
-
pinching = true;
|
|
556
|
-
swiping = false;
|
|
557
|
-
photoSwipable = false;
|
|
564
|
+
function rebasePinch() {
|
|
558
565
|
const points = Array.from(activePointers.values());
|
|
559
|
-
|
|
566
|
+
pinchStartDistance = distance(
|
|
560
567
|
points[0],
|
|
561
568
|
points[1]
|
|
562
569
|
);
|
|
570
|
+
pinchStartScale = state.viewer.scaleSize;
|
|
571
|
+
}
|
|
572
|
+
function startPinch() {
|
|
573
|
+
pinching = true;
|
|
574
|
+
swiping = false;
|
|
575
|
+
photoSwipable = false;
|
|
576
|
+
rebasePinch();
|
|
577
|
+
vx = 0;
|
|
578
|
+
vy = 0;
|
|
563
579
|
state.viewer.scale = true;
|
|
580
|
+
state.viewer.hideUi = true;
|
|
564
581
|
callbacks.onGestureStart();
|
|
565
582
|
}
|
|
566
583
|
function startSwipe(e) {
|
|
@@ -614,28 +631,36 @@
|
|
|
614
631
|
}
|
|
615
632
|
function movePinch() {
|
|
616
633
|
const points = Array.from(activePointers.values());
|
|
617
|
-
const
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
)
|
|
621
|
-
|
|
634
|
+
const p0 = points[0];
|
|
635
|
+
const p1 = points[1];
|
|
636
|
+
const dist = distance(p0, p1);
|
|
637
|
+
if (pinchStartDistance === 0) {
|
|
638
|
+
pinchStartDistance = dist;
|
|
639
|
+
pinchStartScale = state.viewer.scaleSize;
|
|
640
|
+
scheduleGestureMove();
|
|
641
|
+
return;
|
|
642
|
+
}
|
|
622
643
|
const oldScaleSize = state.viewer.scaleSize;
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
644
|
+
state.viewer.scaleSize = round2(
|
|
645
|
+
pinchStartScale * dist / pinchStartDistance,
|
|
646
|
+
6
|
|
647
|
+
);
|
|
626
648
|
if (state.viewer.scaleSize < 0.2) {
|
|
627
649
|
state.viewer.scaleSize = 0.2;
|
|
628
650
|
}
|
|
629
|
-
if (state.viewer.scaleSize < oldScaleSize) {
|
|
630
|
-
state.viewer.photoPosX = (1 + state.viewer.scaleSize - oldScaleSize) * posX;
|
|
631
|
-
state.viewer.photoPosY = (1 + state.viewer.scaleSize - oldScaleSize) * posY;
|
|
632
|
-
}
|
|
633
651
|
const item = currentItem(state);
|
|
634
|
-
if (item) {
|
|
635
|
-
const
|
|
636
|
-
|
|
652
|
+
if (item && state.viewer.scaleSize !== oldScaleSize) {
|
|
653
|
+
const { width: winW, height: winH } = windowSize();
|
|
654
|
+
const cx = winW / 2;
|
|
655
|
+
const cy = state.options.headerHeight + (winH - state.options.headerHeight - state.options.footerHeight) / 2;
|
|
656
|
+
const k = item.scale;
|
|
657
|
+
const mid = { x: (p0.x + p1.x) / 2, y: (p0.y + p1.y) / 2 };
|
|
658
|
+
const ratio = state.viewer.scaleSize / oldScaleSize;
|
|
659
|
+
const dx = mid.x - (cx + state.viewer.photoPosX * k);
|
|
660
|
+
const dy = mid.y - (cy + state.viewer.photoPosY * k);
|
|
661
|
+
state.viewer.photoPosX = round2((mid.x - dx * ratio - cx) / k, 6);
|
|
662
|
+
state.viewer.photoPosY = round2((mid.y - dy * ratio - cy) / k, 6);
|
|
637
663
|
}
|
|
638
|
-
oldDistance = dist;
|
|
639
664
|
scheduleGestureMove();
|
|
640
665
|
}
|
|
641
666
|
function moveSwipe(e) {
|
|
@@ -690,15 +715,39 @@
|
|
|
690
715
|
if (!item) {
|
|
691
716
|
return;
|
|
692
717
|
}
|
|
693
|
-
const
|
|
694
|
-
if (state.viewer.scaleSize
|
|
718
|
+
const base = baselineOf(item);
|
|
719
|
+
if (state.viewer.scaleSize <= base) {
|
|
720
|
+
if (state.options.pinchToClose && state.viewer.scaleSize < base * PINCH_CLOSE_RATIO) {
|
|
721
|
+
callbacks.onPinchClose();
|
|
722
|
+
return;
|
|
723
|
+
}
|
|
724
|
+
state.viewer.photoPosX = 0;
|
|
725
|
+
state.viewer.photoPosY = 0;
|
|
726
|
+
state.viewer.scaleSize = base;
|
|
727
|
+
state.viewer.scale = base > 1;
|
|
728
|
+
state.viewer.hideUi = base > 1;
|
|
729
|
+
callbacks.onGestureEnd();
|
|
695
730
|
return;
|
|
696
731
|
}
|
|
697
|
-
state.viewer.
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
state.viewer.
|
|
732
|
+
state.viewer.scaleSize = Math.min(state.viewer.scaleSize, maxScaleOf(item));
|
|
733
|
+
const bound = boundOf(item);
|
|
734
|
+
let flagX = 0;
|
|
735
|
+
let flagY = 0;
|
|
736
|
+
if (state.viewer.photoPosX > bound.maxX) {
|
|
737
|
+
flagX = -1;
|
|
738
|
+
} else if (state.viewer.photoPosX < bound.minX) {
|
|
739
|
+
flagX = 1;
|
|
740
|
+
}
|
|
741
|
+
if (state.viewer.photoPosY > bound.maxY) {
|
|
742
|
+
flagY = -1;
|
|
743
|
+
} else if (state.viewer.photoPosY < bound.minY) {
|
|
744
|
+
flagY = 1;
|
|
745
|
+
}
|
|
746
|
+
if (flagX !== 0 || flagY !== 0) {
|
|
747
|
+
registerElasticForce(flagX, flagY);
|
|
748
|
+
}
|
|
749
|
+
state.viewer.scale = true;
|
|
750
|
+
state.viewer.hideUi = true;
|
|
702
751
|
callbacks.onGestureEnd();
|
|
703
752
|
}
|
|
704
753
|
function endSwipe() {
|
|
@@ -789,6 +838,9 @@
|
|
|
789
838
|
if (pinching) {
|
|
790
839
|
if (activePointers.size < 2) {
|
|
791
840
|
endPinch();
|
|
841
|
+
activePointers.clear();
|
|
842
|
+
} else {
|
|
843
|
+
rebasePinch();
|
|
792
844
|
}
|
|
793
845
|
return;
|
|
794
846
|
}
|
|
@@ -1515,9 +1567,11 @@
|
|
|
1515
1567
|
) > 1;
|
|
1516
1568
|
}
|
|
1517
1569
|
zoomOutPhoto() {
|
|
1518
|
-
this.state
|
|
1519
|
-
this.state.
|
|
1520
|
-
this.state.viewer.
|
|
1570
|
+
const item = currentItem(this.state);
|
|
1571
|
+
const base = this.state.options.resizeStyle === "fill" && this.isSmartPhoneFlag && item ? scaleBorder(item, getWindowWidth2(), getWindowHeight2(), true) : 1;
|
|
1572
|
+
this.state.viewer.scaleSize = base;
|
|
1573
|
+
this.state.viewer.hideUi = base > 1;
|
|
1574
|
+
this.state.viewer.scale = base > 1;
|
|
1521
1575
|
this.state.viewer.photoPosX = 0;
|
|
1522
1576
|
this.state.viewer.photoPosY = 0;
|
|
1523
1577
|
this.view.updatePhotoTransform(this.state);
|
|
@@ -1982,7 +2036,7 @@
|
|
|
1982
2036
|
});
|
|
1983
2037
|
}
|
|
1984
2038
|
openPhoto(item, trigger) {
|
|
1985
|
-
const groupChanged = this.
|
|
2039
|
+
const groupChanged = this.resyncGroupFromDom(item.groupId);
|
|
1986
2040
|
this.lastTriggerElement = trigger;
|
|
1987
2041
|
this.state.viewer.currentGroup = item.groupId;
|
|
1988
2042
|
this.state.viewer.currentIndex = item.index;
|
|
@@ -2217,6 +2271,9 @@
|
|
|
2217
2271
|
this.fireEvent("gestureend");
|
|
2218
2272
|
this.view.updatePhotoTransform(this.state);
|
|
2219
2273
|
},
|
|
2274
|
+
// ピンチで基準倍率よりはっきり小さく縮めて離した = 閉じたい操作
|
|
2275
|
+
// (PhotoSwipe の pinchToClose 相当)
|
|
2276
|
+
onPinchClose: () => this.hidePhoto(),
|
|
2220
2277
|
onPhotoDragMove: () => this.view.updatePhotoTransform(this.state),
|
|
2221
2278
|
onPhotoDragEnd: (result) => {
|
|
2222
2279
|
if (result === "zoom-out") {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* SmartPhoto v2.1.
|
|
2
|
+
* SmartPhoto v2.1.16
|
|
3
3
|
* (c) appleple
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
"use strict";(()=>{var K=()=>{let t=navigator.userAgent;return t.indexOf("iPhone")>0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0},Ie=()=>typeof window.webkitConvertPointFromNodeToPage=="function";function Le(t,...e){var i;t=t||{};for(let o=0;o<e.length;o++){let r=e[o];if(r){for(let s in r)if(Object.hasOwn(r,s)){let n=r[s];n&&typeof n=="object"?t[s]=Le((i=t[s])!=null?i:{},n):t[s]=n}}}return t}var Te=Le,Ce=(t,e,i)=>{let o;window.CustomEvent?o=new CustomEvent(e,{cancelable:!0}):(o=document.createEvent("CustomEvent"),o.initCustomEvent(e,!1,!1,i)),t.dispatchEvent(o)},Ae=t=>{let e={};for(let i of t.split("&")){let o=i.split("="),r=o[0],s=o.length>1?o.slice(1).join("="):r;e[r]=decodeURIComponent(s)}return e},Z=()=>document.documentElement.clientWidth,ee=()=>{let t=window.visualViewport;return t?t.height*t.scale:document.documentElement.clientHeight},He=t=>({left:t.getBoundingClientRect().left,top:t.getBoundingClientRect().top});var xe=t=>{let e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*[\d.]+\s*)?\)/);return e?[Number(e[1]),Number(e[2]),Number(e[3])]:null},Ue=.179,je=([t,e,i])=>{let[o,r,s]=[t,e,i].map(n=>{let m=n/255;return m<=.03928?m/12.92:((m+.055)/1.055)**2.4});return .2126*o+.7152*r+.0722*s},Me=t=>{let e=t.trim(),i=xe(e);if(!i){let o=document.createElement("div");if(o.style.color=e,!o.style.color)return"#fff";document.body.appendChild(o),i=xe(getComputedStyle(o).color),document.body.removeChild(o)}return i&&je(i)>Ue?"#000":"#fff"};var qe={classNames:{smartPhoto:"smartphoto",smartPhotoClose:"smartphoto-close",smartPhotoBody:"smartphoto-body",smartPhotoInner:"smartphoto-inner",smartPhotoContent:"smartphoto-content",smartPhotoImg:"smartphoto-img",smartPhotoImgOnMove:"smartphoto-img-onmove",smartPhotoImgElasticMove:"smartphoto-img-elasticmove",smartPhotoImgWrap:"smartphoto-img-wrap",smartPhotoArrows:"smartphoto-arrows",smartPhotoNav:"smartphoto-nav",smartPhotoArrowRight:"smartphoto-arrow-right",smartPhotoArrowLeft:"smartphoto-arrow-left",smartPhotoArrowHideIcon:"smartphoto-arrow-hide",smartPhotoImgLeft:"smartphoto-img-left",smartPhotoImgRight:"smartphoto-img-right",smartPhotoList:"smartphoto-list",smartPhotoListOnMove:"smartphoto-list-onmove",smartPhotoHeader:"smartphoto-header",smartPhotoCount:"smartphoto-count",smartPhotoCaption:"smartphoto-caption",smartPhotoDismiss:"smartphoto-dismiss",smartPhotoLoader:"smartphoto-loader",smartPhotoLoaderWrap:"smartphoto-loader-wrap",smartPhotoImgClone:"smartphoto-img-clone"},message:{gotoNextImage:"go to the next image",gotoPrevImage:"go to the previous image",closeDialog:"close the image dialog",carouselLabel:"Images"},arrows:!0,nav:!0,showAnimation:!0,verticalGravity:!1,useOrientationApi:!1,useHistoryApi:!0,useViewTransitionApi:!0,swipeTopToClose:!1,swipeBottomToClose:!0,swipeOffset:100,swipeVelocity:.5,headerHeight:60,footerHeight:60,forceInterval:10,registance:.5,loadOffset:2,resizeStyle:"fit",lazyAttribute:"data-src",animationSpeed:300};function Ve(t){return Object.keys(t).forEach(e=>{let i=t[e];i&&typeof i=="object"&&!Object.isFrozen(i)&&Ve(i)}),Object.freeze(t)}function ze(t){return{options:Ve(Te({},qe,t)),viewer:{isOpen:!1,currentGroup:null,currentIndex:0,oldIndex:0,total:0,translateX:0,translateY:0,photoPosX:0,photoPosY:0,scaleSize:1,scale:!1,elastic:!1,hideUi:!1,onMove:!1,appear:!1,appearEffect:null,prev:-1,next:-1,showPrevArrow:!1,showNextArrow:!1},groups:new Map}}function j(t){return t.getAttribute("data-group")||"nogroup"}function pe(t){return t.group||"nogroup"}function fe(t,e,i,o){let r=j(t),s=t.getAttribute("href"),n=t.querySelector("img"),m=s;n&&(n.getAttribute(e.lazyAttribute)?m=n.getAttribute(e.lazyAttribute):n.currentSrc?m=n.currentSrc:m=n.src);let p="";n!=null&&n.getAttribute("alt")?p=n.getAttribute("alt"):t.getAttribute("data-caption")?p=t.getAttribute("data-caption"):p=s!=null?s:"";let u=t.getAttribute("data-id");return{src:s,thumb:m,caption:t.getAttribute("data-caption"),alt:p,groupId:r,translateX:o*i,translateY:0,index:i,width:50,height:50,scale:1,x:0,y:0,id:u||i,loaded:!1,processed:!1,element:t}}function Oe(t,e,i){var u,f,P,b,H;let o=pe(t),r=t.src,s=(u=t.thumb)!=null?u:r,n=(f=t.caption)!=null?f:null,m=(b=(P=t.alt)!=null?P:n)!=null?b:r,p=typeof t.width=="number"&&typeof t.height=="number";return{src:r,thumb:s,caption:n,alt:m,groupId:o,translateX:i*e,translateY:0,index:e,width:p?t.width:50,height:p?t.height:50,scale:1,x:0,y:0,id:(H=t.id)!=null?H:e,loaded:p,processed:!1,element:null}}function ve(t,e){t.groups.has(e.groupId)||t.groups.set(e.groupId,[]),t.groups.get(e.groupId).push(e),t.viewer.currentGroup=e.groupId}function L(t){var e;return t.viewer.currentGroup===null?null:(e=t.groups.get(t.viewer.currentGroup))!=null?e:null}function C(t){var i;let e=L(t);return e&&(i=e[t.viewer.currentIndex])!=null?i:null}function we(t){let e=L(t);if(!e)return;let i=e.length,o=t.viewer.currentIndex+1,r=t.viewer.currentIndex-1;t.viewer.showNextArrow=!1,t.viewer.showPrevArrow=!1,o!==i&&(t.viewer.next=o,t.viewer.showNextArrow=!0),r!==-1&&(t.viewer.prev=r,t.viewer.showPrevArrow=!0)}function ge(t,e){t.forEach((i,o)=>{i.translateX=e*o})}function te(t,e){let i=10**e;return Math.round(t*i)/i}function G(t,e,i,o){return o?t.width>t.height?i/(t.height*t.scale):e/(t.width*t.scale):1/t.scale}function Ne(t,e,i,o){let r=t.width*t.scale*e.scaleSize,s=t.height*t.scale*e.scaleSize,n,m,p,u;return i>r?(p=(i-r)/2,n=-1*p):(p=(r-i)/2,n=-1*p),o>s?(u=(o-s)/2,m=-1*u):(u=(s-o)/2,m=-1*u),{minX:te(n,6)/t.scale,minY:te(m,6)/t.scale,maxX:te(p,6)/t.scale,maxY:te(u,6)/t.scale}}function Be(t,e,i,o,r){let s=i-(o+r);t.forEach(n=>{n.loaded&&(n.processed=!0,n.scale=s/n.height,n.height<s&&(n.scale=1),n.x=(n.scale-1)/2*n.width+(e-n.width*n.scale)/2,n.y=(n.scale-1)/2*n.height+(i-n.height*n.scale)/2,n.width*n.scale>e&&(n.scale=e/n.width,n.x=(n.scale-1)/2*n.width))})}function De(t){let e=C(t);return e?`group=${t.viewer.currentGroup}&photo=${e.id}`:""}function Re(t,e){let i=null;return t.groups.forEach(o=>{o.forEach(r=>{e.group===r.groupId&&e.photo===r.id&&(i=r)})}),i}function ye(t,e){let i=10**e;return Math.round(t*i)/i}function U(t){return{x:t.pageX,y:t.pageY}}function Xe(t,e){let i=t.x-e.x,o=t.y-e.y;return Math.sqrt(i*i+o*o)}var Qe=10;function _e(t,e){return{force:Math.sqrt(t*t+e*e),theta:Math.atan2(e,t)}}function Ye(){return{width:Z(),height:ee()}}function Fe({state:t,callbacks:e},{signal:i}){let o=new Map,r=Date.now(),s=!1,n=!1,m=null,p=null,u=null,f=0,P=null,b=!1,H=null,T=null,z=0,Y=0,V=!1,R=0,x=null,O=0,c=0;function Q(){return K()}function k(a){let{width:h,height:E}=Ye();return Ne(a,t.viewer,h,E)}function _(a){let{width:h,height:E}=Ye();return G(a,h,E,Q())}function oe(a,h){let E=C(t),y=k(E);t.viewer.elastic=!0,a===1?t.viewer.photoPosX=y.minX:a===-1&&(t.viewer.photoPosX=y.maxX),h===1?t.viewer.photoPosY=y.minY:h===-1&&(t.viewer.photoPosY=y.maxY),e.onPhotoDragMove(),setTimeout(()=>{t.viewer.elastic=!1,e.onPhotoDragMove()},300)}let F=setInterval(()=>{if(V||s||b||t.viewer.elastic||!t.viewer.scale)return;t.viewer.photoPosX+=O,t.viewer.photoPosY+=c;let a=C(t);if(!a)return;let h=k(a);t.viewer.photoPosX<h.minX?(t.viewer.photoPosX=h.minX,O*=-.2):t.viewer.photoPosX>h.maxX&&(t.viewer.photoPosX=h.maxX,O*=-.2),t.viewer.photoPosY<h.minY?(t.viewer.photoPosY=h.minY,c*=-.2):t.viewer.photoPosY>h.maxY&&(t.viewer.photoPosY=h.maxY,c*=-.2);let E=_e(O,c),y=E.force-t.options.registance;Math.abs(y)<.5||(O=Math.cos(E.theta)*y,c=Math.sin(E.theta)*y,e.onPhotoDragMove())},t.options.forceInterval);function W(a,h){(a>5||a<-5)&&(O+=a*.05),t.options.verticalGravity&&(h>5||h<-5)&&(c+=h*.05)}function re(a){if(!(a!=null&&a.gamma)||t.viewer.appearEffect||V||s||b||t.viewer.elastic||!t.viewer.scale)return;let{orientation:h}=window;h===0?W(a.gamma,a.beta):h===90?W(a.beta,a.gamma):h===-90?W(-a.beta,-a.gamma):h===180&&W(-a.gamma,-a.beta)}t.options.useOrientationApi&&window.addEventListener("deviceorientation",re,{signal:i});function ne(){V=!0,s=!1,b=!1;let a=Array.from(o.values());R=Xe(a[0],a[1]),t.viewer.scale=!0,e.onGestureStart()}function se(a){let h=U(a);s=!0,n=!0,m=h,p=h,f=Date.now(),P=a.target}function ae(a){b=!0;let h=U(a);T=h,H=h}function le(a){var h,E;try{(E=(h=a.currentTarget).setPointerCapture)==null||E.call(h,a.pointerId)}catch(y){}if(o.set(a.pointerId,U(a)),o.size>1){ne();return}if(t.viewer.scale){ae(a);return}se(a)}function he(){x===null&&(x=requestAnimationFrame(()=>{x=null,e.onGestureMove()}))}function ue(){x!==null&&(cancelAnimationFrame(x),x=null,e.onGestureMove())}function ce(){let a=Array.from(o.values()),h=Xe(a[0],a[1]),E=(h-R)/100,y=t.viewer.scaleSize,I=t.viewer.photoPosX,M=t.viewer.photoPosY;t.viewer.scaleSize+=ye(E,6),t.viewer.scaleSize<.2&&(t.viewer.scaleSize=.2),t.viewer.scaleSize<y&&(t.viewer.photoPosX=(1+t.viewer.scaleSize-y)*I,t.viewer.photoPosY=(1+t.viewer.scaleSize-y)*M);let D=C(t);if(D){let de=_(D);t.viewer.hideUi=t.viewer.scaleSize<1||t.viewer.scaleSize>de}R=h,he()}function d(a){let h=U(a),E=h.x-p.x,y=h.y-m.y;n&&(e.onSwipeStart(),n=!1,u=Math.abs(E)>Math.abs(y)?"horizontal":"vertical"),u==="horizontal"?t.viewer.translateX+=E:t.viewer.translateY=y,p=h,e.onSwipeMove()}function l(a){let h=U(a),E=h.x-T.x,y=h.y-T.y,I=ye(t.viewer.scaleSize*E,6),M=ye(t.viewer.scaleSize*y,6);t.viewer.photoPosX+=I,z=I,t.viewer.photoPosY+=M,Y=M,T=h,e.onPhotoDragMove()}function g(a){if(o.has(a.pointerId)){if(o.set(a.pointerId,U(a)),V){ce();return}if(b){l(a);return}d(a)}}function v(){V=!1,ue();let a=C(t);if(!a)return;let h=_(a);t.viewer.scaleSize>h||(t.viewer.photoPosX=0,t.viewer.photoPosY=0,t.viewer.scale=!1,t.viewer.scaleSize=1,t.viewer.hideUi=!1,e.onGestureEnd())}function w(){var Pe;s=!1;let a=m,h=p,E=Date.now(),y=r-E,I=h.x-a.x,M=h.y-a.y,D=I===0&&M===0;if(!Q()&&D){e.onTap(P);return}if(Math.abs(y)<=500&&D){e.onTap(P);return}r=E;let de=(Pe=L(t))!=null?Pe:[];if(u==="horizontal"){let $="stay",Ge=Math.max(E-f,1),Se=Math.abs(I)>=Qe&&Math.abs(I)/Ge>=t.options.swipeVelocity;(I>=t.options.swipeOffset||Se&&I>0)&&t.viewer.currentIndex!==0?$="prev":(I<=-t.options.swipeOffset||Se&&I<0)&&t.viewer.currentIndex!==de.length-1&&($="next"),e.onSwipeEnd($)}else{let $="stay";t.options.swipeBottomToClose&&M>=t.options.swipeOffset?$="close-bottom":t.options.swipeTopToClose&&M<=-t.options.swipeOffset&&($="close-top"),e.onSwipeEnd($)}}function S(){b=!1;let a=T,h=H;if(a.x===h.x&&a.y===h.y){e.onPhotoDragEnd("zoom-out");return}let E=C(t);if(!E){e.onPhotoDragEnd(null);return}let y=k(E),I=t.options.swipeOffset*t.viewer.scaleSize,M=0,D=0;if(t.viewer.photoPosX>y.maxX?M=-1:t.viewer.photoPosX<y.minX&&(M=1),t.viewer.photoPosY>y.maxY?D=-1:t.viewer.photoPosY<y.minY&&(D=1),t.viewer.photoPosX-y.maxX>I&&t.viewer.currentIndex!==0){e.onPhotoDragEnd("prev");return}if(y.minX-t.viewer.photoPosX>I&&t.viewer.currentIndex+1!==t.viewer.total){e.onPhotoDragEnd("next");return}M===0&&D===0?(O=z/5,c=Y/5):oe(M,D),e.onPhotoDragEnd(null)}function N(a){if(o.delete(a.pointerId),V){o.size<2&&v();return}if(b){S();return}s&&w()}function J(...a){for(let h of a)h.addEventListener("pointerdown",le,{signal:i}),h.addEventListener("pointermove",g,{signal:i}),h.addEventListener("pointerup",N,{signal:i}),h.addEventListener("pointercancel",N,{signal:i})}function B(){clearInterval(F),x!==null&&(cancelAnimationFrame(x),x=null)}return{attach:J,detach:B}}function ie(t){let e=document.createElement("span");return e.className="smartphoto-sr-only",e.textContent=t,e}function Ee(){let t=document.createElement("button");return t.type="button",t}function Je(t){return t.replace(/"/g,'\\"')}function We({id:t,options:e},i,{signal:o}){let{classNames:r,message:s}=e,n=document.createElement("div");n.setAttribute("data-id",t);let m=document.createElement("dialog");m.className=r.smartPhoto,m.setAttribute("aria-labelledby",`smartphoto-${t}-title`),m.style.display="none",m.style.setProperty("--smartphoto-animation-speed",`${e.animationSpeed}ms`);let p=document.createElement("div");p.className=r.smartPhotoBody;let u=document.createElement("div");u.className=r.smartPhotoInner;let f=document.createElement("div");f.className=r.smartPhotoHeader;let P=document.createElement("span");P.className=r.smartPhotoCount;let b=document.createElement("h1");b.id=`smartphoto-${t}-title`,b.className=r.smartPhotoCaption,b.setAttribute("tabindex","-1");let H=document.createElement("button");H.className=r.smartPhotoDismiss,H.appendChild(ie(s.closeDialog)),H.addEventListener("click",()=>i.onDismiss(),{signal:o}),f.append(P,b,H);let T=document.createElement("div");T.className=r.smartPhotoContent,T.addEventListener("click",d=>{d.target===T&&i.onBackdropClick()},{signal:o});let z=document.createElement("ul");z.className=r.smartPhotoList,z.setAttribute("role","region"),z.setAttribute("aria-roledescription","carousel"),z.setAttribute("aria-label",s.carouselLabel),z.setAttribute("aria-live","polite"),z.setAttribute("aria-atomic","false"),u.append(f,T,z);let Y=null,V=null,R=null;if(e.arrows){Y=document.createElement("ul"),Y.className=r.smartPhotoArrows,V=document.createElement("li"),V.className=r.smartPhotoArrowLeft;let d=Ee();d.appendChild(ie(s.gotoPrevImage)),d.addEventListener("click",()=>i.onPrev(),{signal:o}),V.appendChild(d),R=document.createElement("li"),R.className=r.smartPhotoArrowRight;let l=Ee();l.appendChild(ie(s.gotoNextImage)),l.addEventListener("click",()=>i.onNext(),{signal:o}),R.appendChild(l),Y.append(V,R),u.appendChild(Y)}let x=null,O=null;e.nav&&(x=document.createElement("nav"),x.className=r.smartPhotoNav,x.setAttribute("aria-label","Choose slide to display"),O=document.createElement("ul"),x.appendChild(O),u.appendChild(x)),p.appendChild(u),m.appendChild(p),n.appendChild(m);let c={dialog:m,count:P,caption:b,dismiss:H,content:T,list:z,arrows:Y,arrowLeft:V,arrowRight:R,nav:x,navList:O,slides:new Map,imgClone:null};function Q(){let d=document.createElement("div");d.className=r.smartPhotoLoaderWrap;let l=document.createElement("span");return l.className=r.smartPhotoLoader,d.appendChild(l),d}function k(d){var v,w;let l=document.createElement("div");l.className=r.smartPhotoImgWrap;let g=document.createElement("img");return g.className=r.smartPhotoImg,g.src=(v=d.src)!=null?v:"",g.alt=(w=d.alt)!=null?w:"",g.addEventListener("dragstart",S=>S.preventDefault(),{signal:o}),l.appendChild(g),{imgWrap:l,img:g}}function _(d,l){var g;c.list.replaceChildren(),(g=c.navList)==null||g.replaceChildren(),c.slides=new Map,d.forEach(v=>{var N,J;let w=document.createElement("li");w.setAttribute("role","group"),w.setAttribute("aria-roledescription","slide"),w.setAttribute("aria-label",`${v.index+1} of ${d.length}`);let S={li:w,loaderWrap:null,imgWrap:null,img:null,navLink:null};if(v.processed){let{imgWrap:B,img:a}=k(v);w.appendChild(B),S.imgWrap=B,S.img=a}else{let B=Q();w.appendChild(B),S.loaderWrap=B}if(c.list.appendChild(w),c.slides.set(v,S),c.navList){let B=document.createElement("li"),a=Ee();a.style.backgroundImage=`url("${Je((N=v.thumb)!=null?N:"")}")`;let h=v.index;a.addEventListener("click",()=>i.onNavigate(h),{signal:o}),a.appendChild(ie(`go to ${(J=v.caption)!=null?J:""}`)),B.appendChild(a),c.navList.appendChild(B),S.navLink=a}}),W(l)}function oe(d,l){var w;if(l.imgWrap||!d.processed)return l;let{imgWrap:g,img:v}=k(d);return(w=l.loaderWrap)==null||w.replaceWith(g),l.loaderWrap=null,l.imgWrap=g,l.img=v,l}function F(d){d&&document.activeElement&&d.contains(document.activeElement)&&c.caption.focus()}function W(d){let{viewer:l}=d;c.count.textContent=`${l.currentIndex+1}/${l.total}`,c.slides.forEach((g,v)=>{var N;let w=oe(v,g),S=v.index===l.currentIndex;w.li.style.transform=`translate(${v.translateX}px,${v.translateY}px)`,w.li.classList.toggle("current",S),S?w.li.removeAttribute("aria-hidden"):w.li.setAttribute("aria-hidden","true"),S&&(c.caption.textContent=(N=v.caption)!=null?N:""),w.imgWrap&&w.img&&(w.imgWrap.style.transform=`translate(${v.x}px,${v.y}px) scale(${v.scale})`,w.img.style.width=`${v.width}px`,S||(w.img.style.transform="translate(0px,0px) scale(1)"),w.img.classList.toggle("active",l.appear),w.img.classList.toggle(r.smartPhotoImgOnMove,l.scale),w.img.classList.toggle(r.smartPhotoImgElasticMove,l.elastic)),w.navLink&&(w.navLink.classList.toggle("current",S),S?w.navLink.setAttribute("aria-current","true"):w.navLink.removeAttribute("aria-current"))}),c.arrowLeft&&(l.showPrevArrow?c.arrowLeft.removeAttribute("aria-hidden"):(F(c.arrowLeft),c.arrowLeft.setAttribute("aria-hidden","true"))),c.arrowRight&&(l.showNextArrow?c.arrowRight.removeAttribute("aria-hidden"):(F(c.arrowRight),c.arrowRight.setAttribute("aria-hidden","true"))),c.arrows&&(l.hideUi&&F(c.arrows),c.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false")),c.nav&&(l.hideUi&&F(c.nav),c.nav.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function re(d){for(let[l,g]of c.slides)if(l.index===d.viewer.currentIndex)return g;return null}function ne(d){let{viewer:l}=d,g=re(d),v=g==null?void 0:g.img;v&&(v.style.transform=`translate(${l.photoPosX}px,${l.photoPosY}px) scale(${l.scaleSize})`,v.classList.toggle(r.smartPhotoImgOnMove,l.scale),v.classList.toggle(r.smartPhotoImgElasticMove,l.elastic)),c.nav&&(l.hideUi&&F(c.nav),c.nav.setAttribute("aria-hidden",l.hideUi?"true":"false")),c.arrows&&(l.hideUi&&F(c.arrows),c.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function se(d){let{viewer:l}=d;c.list.style.transform=`translate(${l.translateX}px,${l.translateY}px)`,c.list.classList.toggle(r.smartPhotoListOnMove,l.onMove)}function ae(d){for(let[l,g]of c.slides){if(l.index!==d.viewer.currentIndex)continue;let{img:v,imgWrap:w}=g;if(!v||!w||!l.width||!l.scale||l.scale>=1)return;let S=v.getBoundingClientRect();v.style.width=`${l.width*l.scale}px`,w.style.transform=`translate(${l.x}px,${l.y}px) scale(1)`;let N=v.getBoundingClientRect();w.style.transform=`translate(${l.x+S.left-N.left}px,${l.y+S.top-N.top}px) scale(1)`;return}}function le(){for(let[d,l]of c.slides){let{img:g,imgWrap:v}=l;g&&v&&(v.style.transform=`translate(${d.x}px,${d.y}px) scale(${d.scale})`,g.style.width=`${d.width}px`)}}function he(d){let l=document.createElement("img");l.className=r.smartPhotoImgClone,l.src=d.img,l.style.width=`${d.width}px`,l.style.height=`${d.height}px`,l.style.transform=`translate(${d.left}px,${d.top}px) scale(1)`,p.appendChild(l),c.imgClone=l}function ue(){var d;(d=c.imgClone)==null||d.remove(),c.imgClone=null}function ce(){n.remove()}return{root:n,refs:c,render:W,syncSlides:_,updatePhotoTransform:ne,applyViewTransitionLayout:ae,resetViewTransitionLayout:le,updateListTransform:se,showAppearEffect:he,removeAppearEffect:ue,destroy:ce}}var A=Z,X=ee;function Ke(t){return t.length>0&&t[0]instanceof Element}function Ze(){return(Date.now().toString(36)+Math.random().toString(36).substring(2,7)).toUpperCase()}function $e(){return{x:window.pageXOffset!==void 0?window.pageXOffset:document.documentElement.scrollLeft,y:window.pageYOffset!==void 0?window.pageYOffset:document.documentElement.scrollTop}}var q=class{constructor(e,i){this.id=Ze();this.abortController=new AbortController;this.isSmartPhoneFlag=K();this.lastTriggerElement=null;this.isFiringPublicCloseEvent=!1;this.finishHideEffect=null;this.isViewTransitionActive=!1;this.pendingViewTransitionResync=!1;this.timeouts=[];this.loadAllFired=new Set;this.syncedGroupId=null;this.rootSelector=null;this.itemsByElement=new Map;this.handleDocumentClick=e=>{if(!(e.target instanceof Element))return;let i=e;if(i.__smartphotoClaimed)return;let o=this.findRegisteredAncestor(e.target);if(!o&&this.rootSelector&&(o=e.target.closest(this.rootSelector)),!o)return;if(e.preventDefault(),i.__smartphotoClaimed=!0,!this.itemsByElement.has(o)&&this.rootSelector){let s=j(o);this.resyncGroupFromDom(s)&&this.syncCurrentGroupView()}let r=this.itemsByElement.get(o);r&&this.openPhoto(r,o)};this.updateViewportHeight=()=>{this.view.refs.dialog.style.setProperty("--smartphoto-vh",`${X()}px`)};this.handleVisualViewportResize=()=>{if(this.updateViewportHeight(),!(!this.isSmartPhoneFlag||!this.state.viewer.isOpen||!L(this.state))){if(this.isViewTransitionActive){this.pendingViewTransitionResync=!0;return}this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit()}};this.handleResize=()=>{if(!(!this.state.viewer.isOpen||!L(this.state))){if(this.updateViewportHeight(),this.isViewTransitionActive){this.pendingViewTransitionResync=!0;return}this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit()}};this.handleKeydown=e=>{if(!this.state.viewer.isOpen)return;let i=e.keyCode||e.which;i===37?this.gotoSlide(this.state.viewer.prev):i===39?this.gotoSlide(this.state.viewer.next):i===27&&this.hidePhoto()};this.handleOrientationChange=()=>{if(!this.state.viewer.isOpen||!L(this.state))return;if(this.isViewTransitionActive){this.pendingViewTransitionResync=!0;return}this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit();let e=A(),i=500,o=r=>{this.scheduleTimeout(()=>{this.state.viewer.isOpen&&(e!==A()?(this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit()):r<=i&&o(r+25))},25)};o(0)};this.rootSelector=typeof e=="string"?e:null,this.state=ze(i!=null?i:{}),this.view=We({id:this.id,options:this.state.options},this.buildViewHandlers(),{signal:this.abortController.signal}),document.body.appendChild(this.view.root),this.gestures=Fe({state:this.state,callbacks:this.buildGestureCallbacks()},{signal:this.abortController.signal}),this.gestures.attach(this.view.refs.content,this.view.refs.list),this.view.refs.dialog.addEventListener("close",()=>{!this.isFiringPublicCloseEvent&&this.state.viewer.isOpen&&this.hidePhoto()},{signal:this.abortController.signal}),document.addEventListener("click",this.handleDocumentClick,{signal:this.abortController.signal}),this.ingestSource(e),this.syncCurrentGroupView();let o=this.restoreFromHash();if(o&&this.openPhoto(o,o.element),this.updateViewportHeight(),this.applyAutoIconContrast(),window.visualViewport?window.visualViewport.addEventListener("resize",this.handleVisualViewportResize,{signal:this.abortController.signal}):window.addEventListener("resize",this.updateViewportHeight,{signal:this.abortController.signal}),!this.isSmartPhoneFlag){window.addEventListener("resize",this.handleResize,{signal:this.abortController.signal}),window.addEventListener("keydown",this.handleKeydown,{signal:this.abortController.signal});return}window.addEventListener("orientationchange",this.handleOrientationChange,{signal:this.abortController.signal})}on(e,i){let o=this.view.refs.dialog,r=s=>i.call(o,s);o.addEventListener(e,r,{signal:this.abortController.signal})}destroy(){this.state.viewer.isOpen=!1,this.view.refs.dialog.open&&this.view.refs.dialog.close(),this.abortController.abort(),this.timeouts.forEach(e=>{clearTimeout(e)}),this.timeouts=[],this.itemsByElement.clear(),this.gestures.detach(),this.view.destroy()}[Symbol.dispose](){this.destroy()}gotoSlide(e){var s,n;let i=Number.parseInt(String(e),10),o=Number.isNaN(i)?0:i,r=(n=(s=L(this.state))==null?void 0:s.length)!=null?n:0;o<0||o>=r||(this.state.viewer.currentIndex=o,this.slideList())}hidePhoto(e="bottom"){var o;if(!this.state.viewer.isOpen)return;this.state.viewer.isOpen=!1,this.state.viewer.appear=!1,this.state.viewer.appearEffect=null,this.view.removeAppearEffect(),this.state.viewer.hideUi=!1,this.state.viewer.scale=!1,this.state.viewer.scaleSize=1;let i=$e();location.hash&&this.setHash(""),window.scroll(i.x,i.y),this.syncDialog(),(o=this.lastTriggerElement)!=null&&o.isConnected&&this.lastTriggerElement.focus(),this.lastTriggerElement=null,this.doHideEffect(e).then(()=>{this.view.render(this.state),this.isFiringPublicCloseEvent=!0,this.fireEvent("close"),this.isFiringPublicCloseEvent=!1})}zoomPhoto(){let e=C(this.state);e&&(this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=G(e,A(),X(),this.isSmartPhoneFlag),!(this.state.viewer.scaleSize<=1)&&(this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.view.updatePhotoTransform(this.state),this.scheduleTimeout(()=>{this.state.viewer.isOpen&&(this.state.viewer.scale=!0,this.view.updatePhotoTransform(this.state),this.fireEvent("zoomin"))},this.state.options.animationSpeed)))}canZoomCurrentPhoto(){let e=C(this.state);return!!e&&G(e,A(),X(),this.isSmartPhoneFlag)>1}zoomOutPhoto(){this.state.viewer.scaleSize=1,this.state.viewer.hideUi=!1,this.state.viewer.scale=!1,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.view.updatePhotoTransform(this.state),this.fireEvent("zoomout")}addNewItem(e){return this.addItem(e)}show(e=0,i={}){var p,u,f;let o=(p=i.group)!=null?p:this.state.viewer.currentGroup;if(o===null)return;let r=this.state.groups.get(o);if(!(r!=null&&r.length))return;let s=typeof e=="number"?r[e]:r.find(P=>P.id===e);if(!s)return;let n=document.activeElement instanceof HTMLElement?document.activeElement:null,m=(f=(u=i.trigger)!=null?u:s.element)!=null?f:n;this.openPhoto(s,m)}hide(){this.hidePhoto()}next(){this.state.viewer.showNextArrow&&this.gotoSlide(this.state.viewer.next)}prev(){this.state.viewer.showPrevArrow&&this.gotoSlide(this.state.viewer.prev)}addItem(e){let i=e instanceof HTMLElement?this.addElementItem(e):this.addSlideItem(e);return this.syncCurrentGroupView(),i}get currentIndex(){return this.state.viewer.currentIndex}ingestSource(e){if(Array.isArray(e)&&!Ke(e)){e.forEach(o=>{this.addSlideItem(o)});return}Array.from(typeof e=="string"?document.querySelectorAll(e):e).forEach(o=>{this.addElementItem(o)})}addElementItem(e){var s,n;let i=j(e),o=(n=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?n:0,r=fe(e,this.state.options,o,A());return ve(this.state,r),this.loadAllFired.delete(i),this.itemsByElement.set(e,r),r}addSlideItem(e){var s,n;let i=pe(e),o=(n=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?n:0,r=Oe(e,o,A());return ve(this.state,r),this.loadAllFired.delete(i),r}findRegisteredAncestor(e){let i=e;for(;i;){if(this.itemsByElement.has(i))return i;i=i.parentElement}return null}resyncGroupFromDom(e){var p;if(!this.rootSelector)return!1;let i=Array.from(document.querySelectorAll(this.rootSelector)).filter(u=>j(u)===e),o=new Set(i),r=(p=this.state.groups.get(e))!=null?p:[],s=new Map;r.forEach(u=>{u.element&&s.set(u.element,u)});let n=i.length!==r.length,m=i.map((u,f)=>{let P=s.get(u);if(P)return P.index!==f&&(n=!0,P.index=f),P;n=!0;let b=fe(u,this.state.options,f,A());return this.itemsByElement.set(u,b),b});return r.forEach(u=>{u.element&&!o.has(u.element)&&this.itemsByElement.delete(u.element)}),ge(m,A()),this.state.groups.set(e,m),n&&this.loadAllFired.delete(e),n}syncCurrentGroupView(){let e=L(this.state);e&&(this.view.syncSlides(e,this.state),this.syncedGroupId=this.state.viewer.currentGroup)}setHash(e){var o;if(!((o=window.history)!=null&&o.pushState)||!this.state.options.useHistoryApi)return;let i=`${location.pathname}${location.search}`;window.history.replaceState(null,"",e?`${i}#${e}`:i)}setHashByCurrentIndex(){let e=$e();this.setHash(De(this.state)),window.scroll(e.x,e.y)}restoreFromHash(){let e=location.hash.substring(1);return e?Re(this.state,Ae(e)):null}setPosByCurrentIndex(){let e=C(this.state);e&&(this.state.viewer.translateX=-e.translateX,this.state.viewer.translateY=0,this.view.updateListTransform(this.state))}setSizeByScreen(){let e=L(this.state);e&&(Be(e,A(),X(),this.state.options.headerHeight,this.state.options.footerHeight),this.syncFillScale())}resetTranslateCurrent(){ge(L(this.state),A())}currentImgElement(){for(let[e,i]of this.view.refs.slides)if(e.index===this.state.viewer.currentIndex)return i.img;return null}currentLiElement(){for(let[e,i]of this.view.refs.slides)if(e.index===this.state.viewer.currentIndex)return i.li;return null}syncDialog(){let{dialog:e,caption:i}=this.view.refs;e.style.transition=this.state.options.showAnimation===!1?"none":"",this.state.viewer.isOpen&&!e.open?(e.style.removeProperty("display"),e.showModal(),i.focus()):!this.state.viewer.isOpen&&e.open&&(e.close(),e.style.display="none")}commit(){this.view.render(this.state),this.view.updatePhotoTransform(this.state),this.syncDialog()}initPhoto(){var i;(i=this.finishHideEffect)==null||i.call(this),this.updateViewportHeight(),this.view.refs.dialog.style.opacity="";let e=L(this.state);this.state.viewer.total=e.length,this.state.viewer.isOpen=!0,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.setPosByCurrentIndex(),this.setSizeByScreen(),we(this.state)}syncFillScale(){if(this.state.options.resizeStyle!=="fill"||!this.isSmartPhoneFlag)return;let e=C(this.state);e&&(this.state.viewer.scale=!0,this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=G(e,A(),X(),this.isSmartPhoneFlag))}supportsViewTransition(){return this.state.options.useViewTransitionApi&&typeof document.startViewTransition=="function"&&!Ie()}openPhotoWithViewTransition(e){var n,m;document.documentElement.style.setProperty("--smartphoto-animation-speed",`${this.state.options.animationSpeed}ms`);let i="smartphoto-hero",o=(n=e==null?void 0:e.querySelector("img"))!=null?n:null;o&&(o.style.viewTransitionName=i);let r=()=>{this.isViewTransitionActive=!1,o&&(o.style.viewTransitionName="");let p=this.currentImgElement();if(p&&(p.style.viewTransitionName=""),!this.state.viewer.isOpen){this.pendingViewTransitionResync=!1;return}if(this.pendingViewTransitionResync&&L(this.state)){this.pendingViewTransitionResync=!1,this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit();return}this.pendingViewTransitionResync=!1,this.view.resetViewTransitionLayout()},s=(m=document.startViewTransition)==null?void 0:m.call(document,()=>{this.initPhoto(),this.state.viewer.appear=!0,this.commit(),o&&(o.style.viewTransitionName=""),this.currentImgElement().style.viewTransitionName=i,this.view.applyViewTransitionLayout(this.state)});s&&(this.isViewTransitionActive=!0,s.ready.catch(()=>{r()}),s.finished.then(r,r))}addAppearEffect(e,i){var T;let o=(T=e==null?void 0:e.querySelector("img"))!=null?T:null;if(!o){this.state.viewer.appear=!0;return}let r=He(o),s=o.offsetWidth,n=o.offsetHeight,m=A(),p=X(),u=p-this.state.options.headerHeight-this.state.options.footerHeight,f=1;this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag?s>n?f=p/n:f=m/s:(s>=n?i.height<u?f=i.width/s:f=u/n:i.height<u?f=i.height/n:f=u/n,s*f>m&&(f=m/s));let P=(f-1)/2*s+(m-s*f)/2,b=(f-1)/2*n+(p-n*f)/2,H=o.getAttribute(this.state.options.lazyAttribute);this.state.viewer.appearEffect={width:s,height:n,top:r.top,left:r.left,once:!0,img:H||i.src||"",afterX:P,afterY:b,scale:f}}runAppearEffect(e){this.view.showAppearEffect(e);let i=this.view.refs.imgClone;return new Promise(o=>{let r=()=>{i.removeEventListener("transitionend",r,!0),o()};i.addEventListener("transitionend",r,!0),this.scheduleTimeout(()=>{i.style.transform=`translate(${e.afterX}px, ${e.afterY}px) scale(${e.scale})`},10)})}doOpen(e,i){if(this.state.options.showAnimation!==!1&&this.supportsViewTransition())this.openPhotoWithViewTransition(e);else if(this.state.options.showAnimation===!1)this.initPhoto(),this.state.viewer.appear=!0,this.commit();else{this.initPhoto(),this.addAppearEffect(e,i),this.commit();let o=this.state.viewer.appearEffect;o&&this.runAppearEffect(o).then(()=>{this.state.viewer.appearEffect=null,this.view.removeAppearEffect(),this.state.viewer.appear=!0,this.commit()})}this.fireEvent("open"),this.resyncSizeAfterOpen()}resyncSizeAfterOpen(){let e=A(),i=X();requestAnimationFrame(()=>{if(this.state.viewer.isOpen&&!(A()===e&&X()===i)){if(this.isViewTransitionActive){this.pendingViewTransitionResync=!0;return}this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit()}})}openPhoto(e,i){let o=this.rootSelector?this.resyncGroupFromDom(e.groupId):!1;this.lastTriggerElement=i,this.state.viewer.currentGroup=e.groupId,this.state.viewer.currentIndex=e.index,(this.syncedGroupId!==e.groupId||o)&&this.syncCurrentGroupView(),this.setHashByCurrentIndex(),e.loaded?this.doOpen(i,e):this.loadItem(e).then(()=>{this.doOpen(i,e)})}doHideEffect(e){return new Promise(i=>{if(this.state.options.showAnimation===!1){i();return}let o=this.view.refs.dialog,r=C(this.state),s=r?this.currentLiElement():null,n=X(),m=this.currentImgElement(),p=null;if(m){let f=getComputedStyle(m).transform;f&&f!=="none"&&(m.style.transform=f,p=m.style.transform)}if(s&&r){let f=e==="top"?-n:n;s.style.transform=`translate(${r.translateX}px,${r.translateY+f}px)`}let u=f=>{this.finishHideEffect===u&&(f&&f.target!==o||(this.finishHideEffect=null,o.removeEventListener("transitionend",u,!0),m&&p&&m.style.transform===p&&(m.style.transform=""),i()))};this.finishHideEffect=u,o.addEventListener("transitionend",u,!0),this.scheduleTimeout(u,this.state.options.animationSpeed+100)})}loadItem(e){return new Promise(i=>{var r;let o=new Image;o.onload=()=>{e.width=o.width,e.height=o.height,e.loaded=!0,this.checkLoadAll(e.groupId),i()},o.onerror=()=>i(),o.src=(r=e.src)!=null?r:""})}checkLoadAll(e){if(this.loadAllFired.has(e))return;let i=this.state.groups.get(e);i!=null&&i.length&&i.every(o=>o.loaded)&&(this.loadAllFired.add(e),this.fireEvent("loadall"))}loadNeighborItems(){let e=L(this.state);if(!e)return;let{currentIndex:i}=this.state.viewer,{loadOffset:o}=this.state.options,r=[];for(let s=i-o;s<i+o;s++){let n=e[s];n&&!n.loaded&&r.push(this.loadItem(n))}r.length&&Promise.all(r).then(()=>{this.state.viewer.isOpen&&(this.initPhoto(),this.commit())})}slideList(){this.state.viewer.scaleSize=1,this.state.viewer.hideUi=!1,this.state.viewer.scale=!1,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.state.viewer.onMove=!0,this.updateViewportHeight(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.scheduleTimeout(()=>{let e=C(this.state);this.state.viewer.onMove=!1,we(this.state),this.state.viewer.isOpen&&this.commit(),this.state.viewer.oldIndex!==this.state.viewer.currentIndex&&this.fireEvent("change"),this.state.viewer.oldIndex=this.state.viewer.currentIndex,this.loadNeighborItems(),e&&!e.loaded&&this.loadItem(e).then(()=>{this.state.viewer.isOpen&&(this.initPhoto(),this.commit())})},200)}scheduleTimeout(e,i){let o=window.setTimeout(()=>{this.timeouts=this.timeouts.filter(r=>r!==o),e()},i);return this.timeouts.push(o),o}applyAutoIconContrast(){let e=this.view.refs.dialog,i=getComputedStyle(e);if(i.getPropertyValue("--smartphoto-icon-color").trim())return;let o=i.getPropertyValue("--smartphoto-backdrop-color").trim();o&&e.style.setProperty("--smartphoto-icon-color",Me(o))}fireEvent(e){Ce(this.view.refs.dialog,e)}buildViewHandlers(){return{onDismiss:()=>this.hidePhoto(),onPrev:()=>this.prev(),onNext:()=>this.next(),onNavigate:e=>this.gotoSlide(e),onBackdropClick:()=>this.hidePhoto()}}buildGestureCallbacks(){return{onSwipeStart:()=>this.fireEvent("swipestart"),onSwipeMove:()=>this.view.updateListTransform(this.state),onSwipeEnd:e=>{if(this.fireEvent("swipeend"),e==="close-bottom"){this.hidePhoto("bottom");return}if(e==="close-top"){this.hidePhoto("top");return}e==="prev"?this.state.viewer.currentIndex-=1:e==="next"&&(this.state.viewer.currentIndex+=1),this.slideList()},onTap:e=>{let i=this.currentImgElement();!!i&&e instanceof Node&&i.contains(e)&&this.canZoomCurrentPhoto()?this.zoomPhoto():this.hidePhoto()},onGestureStart:()=>{this.fireEvent("gesturestart"),this.view.updatePhotoTransform(this.state)},onGestureMove:()=>this.view.updatePhotoTransform(this.state),onGestureEnd:()=>{this.fireEvent("gestureend"),this.view.updatePhotoTransform(this.state)},onPhotoDragMove:()=>this.view.updatePhotoTransform(this.state),onPhotoDragEnd:e=>{if(e==="zoom-out"){this.zoomOutPhoto();return}if(e==="prev"){this.gotoSlide(this.state.viewer.prev);return}if(e==="next"){this.gotoSlide(this.state.viewer.next);return}this.view.updatePhotoTransform(this.state)}}}};var ke=q;var be=t=>{t.fn.SmartPhoto=function(e){return typeof e=="string"||new ke(this,e),this}};if(typeof define=="function"&&define.amd)define(["jquery"],be);else{let t=window,e=t.jQuery?t.jQuery:t.$;typeof e!="undefined"&&be(e)}var ct=be;})();
|
|
6
|
+
"use strict";(()=>{var ae=()=>{let t=navigator.userAgent;return t.indexOf("iPhone")>0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0},Me=()=>typeof window.webkitConvertPointFromNodeToPage=="function";function Ve(t,...e){var i;t=t||{};for(let o=0;o<e.length;o++){let n=e[o];if(n){for(let s in n)if(Object.hasOwn(n,s)){let r=n[s];r&&typeof r=="object"?t[s]=Ve((i=t[s])!=null?i:{},r):t[s]=r}}}return t}var ze=Ve,Oe=(t,e,i)=>{let o;window.CustomEvent?o=new CustomEvent(e,{cancelable:!0}):(o=document.createEvent("CustomEvent"),o.initCustomEvent(e,!1,!1,i)),t.dispatchEvent(o)},Ne=t=>{let e={};for(let i of t.split("&")){let o=i.split("="),n=o[0],s=o.length>1?o.slice(1).join("="):n;e[n]=decodeURIComponent(s)}return e},le=()=>document.documentElement.clientWidth,he=()=>{let t=window.visualViewport;return t?t.height*t.scale:document.documentElement.clientHeight},Be=t=>({left:t.getBoundingClientRect().left,top:t.getBoundingClientRect().top});var He=t=>{let e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*[\d.]+\s*)?\)/);return e?[Number(e[1]),Number(e[2]),Number(e[3])]:null},tt=.179,it=([t,e,i])=>{let[o,n,s]=[t,e,i].map(r=>{let m=r/255;return m<=.03928?m/12.92:((m+.055)/1.055)**2.4});return .2126*o+.7152*n+.0722*s},De=t=>{let e=t.trim(),i=He(e);if(!i){let o=document.createElement("div");if(o.style.color=e,!o.style.color)return"#fff";document.body.appendChild(o),i=He(getComputedStyle(o).color),document.body.removeChild(o)}return i&&it(i)>tt?"#000":"#fff"};var ot={classNames:{smartPhoto:"smartphoto",smartPhotoClose:"smartphoto-close",smartPhotoBody:"smartphoto-body",smartPhotoInner:"smartphoto-inner",smartPhotoContent:"smartphoto-content",smartPhotoImg:"smartphoto-img",smartPhotoImgOnMove:"smartphoto-img-onmove",smartPhotoImgElasticMove:"smartphoto-img-elasticmove",smartPhotoImgWrap:"smartphoto-img-wrap",smartPhotoArrows:"smartphoto-arrows",smartPhotoNav:"smartphoto-nav",smartPhotoArrowRight:"smartphoto-arrow-right",smartPhotoArrowLeft:"smartphoto-arrow-left",smartPhotoArrowHideIcon:"smartphoto-arrow-hide",smartPhotoImgLeft:"smartphoto-img-left",smartPhotoImgRight:"smartphoto-img-right",smartPhotoList:"smartphoto-list",smartPhotoListOnMove:"smartphoto-list-onmove",smartPhotoHeader:"smartphoto-header",smartPhotoCount:"smartphoto-count",smartPhotoCaption:"smartphoto-caption",smartPhotoDismiss:"smartphoto-dismiss",smartPhotoLoader:"smartphoto-loader",smartPhotoLoaderWrap:"smartphoto-loader-wrap",smartPhotoImgClone:"smartphoto-img-clone"},message:{gotoNextImage:"go to the next image",gotoPrevImage:"go to the previous image",closeDialog:"close the image dialog",carouselLabel:"Images"},arrows:!0,nav:!0,showAnimation:!0,verticalGravity:!1,useOrientationApi:!1,useHistoryApi:!0,useViewTransitionApi:!0,swipeTopToClose:!1,swipeBottomToClose:!0,pinchToClose:!0,swipeOffset:100,swipeVelocity:.5,headerHeight:60,footerHeight:60,forceInterval:10,registance:.5,loadOffset:2,resizeStyle:"fit",lazyAttribute:"data-src",animationSpeed:300};function Xe(t){return Object.keys(t).forEach(e=>{let i=t[e];i&&typeof i=="object"&&!Object.isFrozen(i)&&Xe(i)}),Object.freeze(t)}function Re(t){return{options:Xe(ze({},ot,t)),viewer:{isOpen:!1,currentGroup:null,currentIndex:0,oldIndex:0,total:0,translateX:0,translateY:0,photoPosX:0,photoPosY:0,scaleSize:1,scale:!1,elastic:!1,hideUi:!1,onMove:!1,appear:!1,appearEffect:null,prev:-1,next:-1,showPrevArrow:!1,showNextArrow:!1},groups:new Map}}function Z(t){return t.getAttribute("data-group")||"nogroup"}function Ee(t){return t.group||"nogroup"}function Pe(t,e,i,o){let n=Z(t),s=t.getAttribute("href"),r=t.querySelector("img"),m=s;r&&(r.getAttribute(e.lazyAttribute)?m=r.getAttribute(e.lazyAttribute):r.currentSrc?m=r.currentSrc:m=r.src);let p="";r!=null&&r.getAttribute("alt")?p=r.getAttribute("alt"):t.getAttribute("data-caption")?p=t.getAttribute("data-caption"):p=s!=null?s:"";let c=t.getAttribute("data-id");return{src:s,thumb:m,caption:t.getAttribute("data-caption"),alt:p,groupId:n,translateX:o*i,translateY:0,index:i,width:50,height:50,scale:1,x:0,y:0,id:c||i,loaded:!1,processed:!1,element:t}}function Ye(t,e,i){var c,f,S,P,H;let o=Ee(t),n=t.src,s=(c=t.thumb)!=null?c:n,r=(f=t.caption)!=null?f:null,m=(P=(S=t.alt)!=null?S:r)!=null?P:n,p=typeof t.width=="number"&&typeof t.height=="number";return{src:n,thumb:s,caption:r,alt:m,groupId:o,translateX:i*e,translateY:0,index:e,width:p?t.width:50,height:p?t.height:50,scale:1,x:0,y:0,id:(H=t.id)!=null?H:e,loaded:p,processed:!1,element:null}}function be(t,e){t.groups.has(e.groupId)||t.groups.set(e.groupId,[]),t.groups.get(e.groupId).push(e),t.viewer.currentGroup=e.groupId}function I(t){var e;return t.viewer.currentGroup===null?null:(e=t.groups.get(t.viewer.currentGroup))!=null?e:null}function L(t){var i;let e=I(t);return e&&(i=e[t.viewer.currentIndex])!=null?i:null}function Se(t){let e=I(t);if(!e)return;let i=e.length,o=t.viewer.currentIndex+1,n=t.viewer.currentIndex-1;t.viewer.showNextArrow=!1,t.viewer.showPrevArrow=!1,o!==i&&(t.viewer.next=o,t.viewer.showNextArrow=!0),n!==-1&&(t.viewer.prev=n,t.viewer.showPrevArrow=!0)}function xe(t,e){t.forEach((i,o)=>{i.translateX=e*o})}function ue(t,e){let i=10**e;return Math.round(t*i)/i}function U(t,e,i,o){return o?t.width>t.height?i/(t.height*t.scale):e/(t.width*t.scale):1/t.scale}function Fe(t,e,i,o){let n=t.width*t.scale*e.scaleSize,s=t.height*t.scale*e.scaleSize,r,m,p,c;return i>n?(p=(i-n)/2,r=-1*p):(p=(n-i)/2,r=-1*p),o>s?(c=(o-s)/2,m=-1*c):(c=(s-o)/2,m=-1*c),{minX:ue(r,6)/t.scale,minY:ue(m,6)/t.scale,maxX:ue(p,6)/t.scale,maxY:ue(c,6)/t.scale}}function We(t,e,i,o,n){let s=i-(o+n);t.forEach(r=>{r.loaded&&(r.processed=!0,r.scale=s/r.height,r.height<s&&(r.scale=1),r.x=(r.scale-1)/2*r.width+(e-r.width*r.scale)/2,r.y=(r.scale-1)/2*r.height+(i-r.height*r.scale)/2,r.width*r.scale>e&&(r.scale=e/r.width,r.x=(r.scale-1)/2*r.width))})}function Ge(t){let e=L(t);return e?`group=${t.viewer.currentGroup}&photo=${e.id}`:""}function $e(t,e){let i=null;return t.groups.forEach(o=>{o.forEach(n=>{e.group===n.groupId&&e.photo===n.id&&(i=n)})}),i}function ee(t,e){let i=10**e;return Math.round(t*i)/i}function J(t){return{x:t.clientX,y:t.clientY}}function ke(t,e){let i=t.x-e.x,o=t.y-e.y;return Math.sqrt(i*i+o*o)}var nt=10;function rt(t,e){return{force:Math.sqrt(t*t+e*e),theta:Math.atan2(e,t)}}function Ie(){return{width:le(),height:he()}}function Ue({state:t,callbacks:e},{signal:i}){let o=new Map,n=Date.now(),s=!1,r=!1,m=null,p=null,c=null,f=0,S=null,P=!1,H=null,C=null,z=0,G=0,V=!1,O=0,N=1,M=null,u=0,B=0;function _(){return ae()}function j(l){let{width:h,height:g}=Ie();return Fe(l,t.viewer,h,g)}function ie(l){let{width:h,height:g}=Ie();return U(l,h,g,_())}function $(l){return t.options.resizeStyle==="fill"&&_()?ie(l):1}let oe=4;function de(l){return Math.max(oe,ie(l))}let me=.75;function ne(l,h){let g=L(t),y=j(g);t.viewer.elastic=!0,l===1?t.viewer.photoPosX=y.minX:l===-1&&(t.viewer.photoPosX=y.maxX),h===1?t.viewer.photoPosY=y.minY:h===-1&&(t.viewer.photoPosY=y.maxY),e.onPhotoDragMove(),setTimeout(()=>{t.viewer.elastic=!1,e.onPhotoDragMove()},300)}let pe=setInterval(()=>{if(V||s||P||t.viewer.elastic||!t.viewer.scale)return;t.viewer.photoPosX+=u,t.viewer.photoPosY+=B;let l=L(t);if(!l)return;let h=j(l);t.viewer.photoPosX<h.minX?(t.viewer.photoPosX=h.minX,u*=-.2):t.viewer.photoPosX>h.maxX&&(t.viewer.photoPosX=h.maxX,u*=-.2),t.viewer.photoPosY<h.minY?(t.viewer.photoPosY=h.minY,B*=-.2):t.viewer.photoPosY>h.maxY&&(t.viewer.photoPosY=h.maxY,B*=-.2);let g=rt(u,B),y=g.force-t.options.registance;y<.5||(u=Math.cos(g.theta)*y,B=Math.sin(g.theta)*y,e.onPhotoDragMove())},t.options.forceInterval);function q(l,h){(l>5||l<-5)&&(u+=l*.05),t.options.verticalGravity&&(h>5||h<-5)&&(B+=h*.05)}function fe(l){if(!(l!=null&&l.gamma)||t.viewer.appearEffect||V||s||P||t.viewer.elastic||!t.viewer.scale)return;let{orientation:h}=window;h===0?q(l.gamma,l.beta):h===90?q(l.beta,l.gamma):h===-90?q(-l.beta,-l.gamma):h===180&&q(-l.gamma,-l.beta)}t.options.useOrientationApi&&window.addEventListener("deviceorientation",fe,{signal:i});function re(){let l=Array.from(o.values());O=ke(l[0],l[1]),N=t.viewer.scaleSize}function ve(){V=!0,s=!1,P=!1,re(),u=0,B=0,t.viewer.scale=!0,t.viewer.hideUi=!0,e.onGestureStart()}function d(l){let h=J(l);s=!0,r=!0,m=h,p=h,f=Date.now(),S=l.target}function a(l){P=!0;let h=J(l);C=h,H=h}function E(l){var h,g;try{(g=(h=l.currentTarget).setPointerCapture)==null||g.call(h,l.pointerId)}catch(y){}if(o.set(l.pointerId,J(l)),o.size>1){ve();return}if(t.viewer.scale){a(l);return}d(l)}function v(){M===null&&(M=requestAnimationFrame(()=>{M=null,e.onGestureMove()}))}function w(){M!==null&&(cancelAnimationFrame(M),M=null,e.onGestureMove())}function x(){let l=Array.from(o.values()),h=l[0],g=l[1],y=ke(h,g);if(O===0){O=y,N=t.viewer.scaleSize,v();return}let b=t.viewer.scaleSize;t.viewer.scaleSize=ee(N*y/O,6),t.viewer.scaleSize<.2&&(t.viewer.scaleSize=.2);let A=L(t);if(A&&t.viewer.scaleSize!==b){let{width:W,height:ge}=Ie(),K=W/2,R=t.options.headerHeight+(ge-t.options.headerHeight-t.options.footerHeight)/2,Q=A.scale,k={x:(h.x+g.x)/2,y:(h.y+g.y)/2},Ae=t.viewer.scaleSize/b,Ze=k.x-(K+t.viewer.photoPosX*Q),et=k.y-(R+t.viewer.photoPosY*Q);t.viewer.photoPosX=ee((k.x-Ze*Ae-K)/Q,6),t.viewer.photoPosY=ee((k.y-et*Ae-R)/Q,6)}v()}function D(l){let h=J(l),g=h.x-p.x,y=h.y-m.y;r&&(e.onSwipeStart(),r=!1,c=Math.abs(g)>Math.abs(y)?"horizontal":"vertical"),c==="horizontal"?t.viewer.translateX+=g:t.viewer.translateY=y,p=h,e.onSwipeMove()}function se(l){let h=J(l),g=h.x-C.x,y=h.y-C.y,b=ee(t.viewer.scaleSize*g,6),A=ee(t.viewer.scaleSize*y,6);t.viewer.photoPosX+=b,z=b,t.viewer.photoPosY+=A,G=A,C=h,e.onPhotoDragMove()}function X(l){if(o.has(l.pointerId)){if(o.set(l.pointerId,J(l)),V){x();return}if(P){se(l);return}D(l)}}function F(){V=!1,w();let l=L(t);if(!l)return;let h=$(l);if(t.viewer.scaleSize<=h){if(t.options.pinchToClose&&t.viewer.scaleSize<h*me){e.onPinchClose();return}t.viewer.photoPosX=0,t.viewer.photoPosY=0,t.viewer.scaleSize=h,t.viewer.scale=h>1,t.viewer.hideUi=h>1,e.onGestureEnd();return}t.viewer.scaleSize=Math.min(t.viewer.scaleSize,de(l));let g=j(l),y=0,b=0;t.viewer.photoPosX>g.maxX?y=-1:t.viewer.photoPosX<g.minX&&(y=1),t.viewer.photoPosY>g.maxY?b=-1:t.viewer.photoPosY<g.minY&&(b=1),(y!==0||b!==0)&&ne(y,b),t.viewer.scale=!0,t.viewer.hideUi=!0,e.onGestureEnd()}function we(){var K;s=!1;let l=m,h=p,g=Date.now(),y=n-g,b=h.x-l.x,A=h.y-l.y,W=b===0&&A===0;if(!_()&&W){e.onTap(S);return}if(Math.abs(y)<=500&&W){e.onTap(S);return}n=g;let ge=(K=I(t))!=null?K:[];if(c==="horizontal"){let R="stay",Q=Math.max(g-f,1),k=Math.abs(b)>=nt&&Math.abs(b)/Q>=t.options.swipeVelocity;(b>=t.options.swipeOffset||k&&b>0)&&t.viewer.currentIndex!==0?R="prev":(b<=-t.options.swipeOffset||k&&b<0)&&t.viewer.currentIndex!==ge.length-1&&(R="next"),e.onSwipeEnd(R)}else{let R="stay";t.options.swipeBottomToClose&&A>=t.options.swipeOffset?R="close-bottom":t.options.swipeTopToClose&&A<=-t.options.swipeOffset&&(R="close-top"),e.onSwipeEnd(R)}}function Qe(){P=!1;let l=C,h=H;if(l.x===h.x&&l.y===h.y){e.onPhotoDragEnd("zoom-out");return}let g=L(t);if(!g){e.onPhotoDragEnd(null);return}let y=j(g),b=t.options.swipeOffset*t.viewer.scaleSize,A=0,W=0;if(t.viewer.photoPosX>y.maxX?A=-1:t.viewer.photoPosX<y.minX&&(A=1),t.viewer.photoPosY>y.maxY?W=-1:t.viewer.photoPosY<y.minY&&(W=1),t.viewer.photoPosX-y.maxX>b&&t.viewer.currentIndex!==0){e.onPhotoDragEnd("prev");return}if(y.minX-t.viewer.photoPosX>b&&t.viewer.currentIndex+1!==t.viewer.total){e.onPhotoDragEnd("next");return}A===0&&W===0?(u=z/5,B=G/5):ne(A,W),e.onPhotoDragEnd(null)}function Ce(l){if(o.delete(l.pointerId),V){o.size<2?(F(),o.clear()):re();return}if(P){Qe();return}s&&we()}function Je(...l){for(let h of l)h.addEventListener("pointerdown",E,{signal:i}),h.addEventListener("pointermove",X,{signal:i}),h.addEventListener("pointerup",Ce,{signal:i}),h.addEventListener("pointercancel",Ce,{signal:i})}function Ke(){clearInterval(pe),M!==null&&(cancelAnimationFrame(M),M=null)}return{attach:Je,detach:Ke}}function ce(t){let e=document.createElement("span");return e.className="smartphoto-sr-only",e.textContent=t,e}function Le(){let t=document.createElement("button");return t.type="button",t}function st(t){return t.replace(/"/g,'\\"')}function _e({id:t,options:e},i,{signal:o}){let{classNames:n,message:s}=e,r=document.createElement("div");r.setAttribute("data-id",t);let m=document.createElement("dialog");m.className=n.smartPhoto,m.setAttribute("aria-labelledby",`smartphoto-${t}-title`),m.style.display="none",m.style.setProperty("--smartphoto-animation-speed",`${e.animationSpeed}ms`);let p=document.createElement("div");p.className=n.smartPhotoBody;let c=document.createElement("div");c.className=n.smartPhotoInner;let f=document.createElement("div");f.className=n.smartPhotoHeader;let S=document.createElement("span");S.className=n.smartPhotoCount;let P=document.createElement("h1");P.id=`smartphoto-${t}-title`,P.className=n.smartPhotoCaption,P.setAttribute("tabindex","-1");let H=document.createElement("button");H.className=n.smartPhotoDismiss,H.appendChild(ce(s.closeDialog)),H.addEventListener("click",()=>i.onDismiss(),{signal:o}),f.append(S,P,H);let C=document.createElement("div");C.className=n.smartPhotoContent,C.addEventListener("click",d=>{d.target===C&&i.onBackdropClick()},{signal:o});let z=document.createElement("ul");z.className=n.smartPhotoList,z.setAttribute("role","region"),z.setAttribute("aria-roledescription","carousel"),z.setAttribute("aria-label",s.carouselLabel),z.setAttribute("aria-live","polite"),z.setAttribute("aria-atomic","false"),c.append(f,C,z);let G=null,V=null,O=null;if(e.arrows){G=document.createElement("ul"),G.className=n.smartPhotoArrows,V=document.createElement("li"),V.className=n.smartPhotoArrowLeft;let d=Le();d.appendChild(ce(s.gotoPrevImage)),d.addEventListener("click",()=>i.onPrev(),{signal:o}),V.appendChild(d),O=document.createElement("li"),O.className=n.smartPhotoArrowRight;let a=Le();a.appendChild(ce(s.gotoNextImage)),a.addEventListener("click",()=>i.onNext(),{signal:o}),O.appendChild(a),G.append(V,O),c.appendChild(G)}let N=null,M=null;e.nav&&(N=document.createElement("nav"),N.className=n.smartPhotoNav,N.setAttribute("aria-label","Choose slide to display"),M=document.createElement("ul"),N.appendChild(M),c.appendChild(N)),p.appendChild(c),m.appendChild(p),r.appendChild(m);let u={dialog:m,count:S,caption:P,dismiss:H,content:C,list:z,arrows:G,arrowLeft:V,arrowRight:O,nav:N,navList:M,slides:new Map,imgClone:null};function B(){let d=document.createElement("div");d.className=n.smartPhotoLoaderWrap;let a=document.createElement("span");return a.className=n.smartPhotoLoader,d.appendChild(a),d}function _(d){var v,w;let a=document.createElement("div");a.className=n.smartPhotoImgWrap;let E=document.createElement("img");return E.className=n.smartPhotoImg,E.src=(v=d.src)!=null?v:"",E.alt=(w=d.alt)!=null?w:"",E.addEventListener("dragstart",x=>x.preventDefault(),{signal:o}),a.appendChild(E),{imgWrap:a,img:E}}function j(d,a){var E;u.list.replaceChildren(),(E=u.navList)==null||E.replaceChildren(),u.slides=new Map,d.forEach(v=>{var D,se;let w=document.createElement("li");w.setAttribute("role","group"),w.setAttribute("aria-roledescription","slide"),w.setAttribute("aria-label",`${v.index+1} of ${d.length}`);let x={li:w,loaderWrap:null,imgWrap:null,img:null,navLink:null};if(v.processed){let{imgWrap:X,img:F}=_(v);w.appendChild(X),x.imgWrap=X,x.img=F}else{let X=B();w.appendChild(X),x.loaderWrap=X}if(u.list.appendChild(w),u.slides.set(v,x),u.navList){let X=document.createElement("li"),F=Le();F.style.backgroundImage=`url("${st((D=v.thumb)!=null?D:"")}")`;let we=v.index;F.addEventListener("click",()=>i.onNavigate(we),{signal:o}),F.appendChild(ce(`go to ${(se=v.caption)!=null?se:""}`)),X.appendChild(F),u.navList.appendChild(X),x.navLink=F}}),oe(a)}function ie(d,a){var w;if(a.imgWrap||!d.processed)return a;let{imgWrap:E,img:v}=_(d);return(w=a.loaderWrap)==null||w.replaceWith(E),a.loaderWrap=null,a.imgWrap=E,a.img=v,a}function $(d){d&&document.activeElement&&d.contains(document.activeElement)&&u.caption.focus()}function oe(d){let{viewer:a}=d;u.count.textContent=`${a.currentIndex+1}/${a.total}`,u.slides.forEach((E,v)=>{var D;let w=ie(v,E),x=v.index===a.currentIndex;w.li.style.transform=`translate(${v.translateX}px,${v.translateY}px)`,w.li.classList.toggle("current",x),x?w.li.removeAttribute("aria-hidden"):w.li.setAttribute("aria-hidden","true"),x&&(u.caption.textContent=(D=v.caption)!=null?D:""),w.imgWrap&&w.img&&(w.imgWrap.style.transform=`translate(${v.x}px,${v.y}px) scale(${v.scale})`,w.img.style.width=`${v.width}px`,x||(w.img.style.transform="translate(0px,0px) scale(1)"),w.img.classList.toggle("active",a.appear),w.img.classList.toggle(n.smartPhotoImgOnMove,a.scale),w.img.classList.toggle(n.smartPhotoImgElasticMove,a.elastic)),w.navLink&&(w.navLink.classList.toggle("current",x),x?w.navLink.setAttribute("aria-current","true"):w.navLink.removeAttribute("aria-current"))}),u.arrowLeft&&(a.showPrevArrow?u.arrowLeft.removeAttribute("aria-hidden"):($(u.arrowLeft),u.arrowLeft.setAttribute("aria-hidden","true"))),u.arrowRight&&(a.showNextArrow?u.arrowRight.removeAttribute("aria-hidden"):($(u.arrowRight),u.arrowRight.setAttribute("aria-hidden","true"))),u.arrows&&(a.hideUi&&$(u.arrows),u.arrows.setAttribute("aria-hidden",a.hideUi?"true":"false")),u.nav&&(a.hideUi&&$(u.nav),u.nav.setAttribute("aria-hidden",a.hideUi?"true":"false"))}function de(d){for(let[a,E]of u.slides)if(a.index===d.viewer.currentIndex)return E;return null}function me(d){let{viewer:a}=d,E=de(d),v=E==null?void 0:E.img;v&&(v.style.transform=`translate(${a.photoPosX}px,${a.photoPosY}px) scale(${a.scaleSize})`,v.classList.toggle(n.smartPhotoImgOnMove,a.scale),v.classList.toggle(n.smartPhotoImgElasticMove,a.elastic)),u.nav&&(a.hideUi&&$(u.nav),u.nav.setAttribute("aria-hidden",a.hideUi?"true":"false")),u.arrows&&(a.hideUi&&$(u.arrows),u.arrows.setAttribute("aria-hidden",a.hideUi?"true":"false"))}function ne(d){let{viewer:a}=d;u.list.style.transform=`translate(${a.translateX}px,${a.translateY}px)`,u.list.classList.toggle(n.smartPhotoListOnMove,a.onMove)}function pe(d){for(let[a,E]of u.slides){if(a.index!==d.viewer.currentIndex)continue;let{img:v,imgWrap:w}=E;if(!v||!w||!a.width||!a.scale||a.scale>=1)return;let x=v.getBoundingClientRect();v.style.width=`${a.width*a.scale}px`,w.style.transform=`translate(${a.x}px,${a.y}px) scale(1)`;let D=v.getBoundingClientRect();w.style.transform=`translate(${a.x+x.left-D.left}px,${a.y+x.top-D.top}px) scale(1)`;return}}function q(){for(let[d,a]of u.slides){let{img:E,imgWrap:v}=a;E&&v&&(v.style.transform=`translate(${d.x}px,${d.y}px) scale(${d.scale})`,E.style.width=`${d.width}px`)}}function fe(d){let a=document.createElement("img");a.className=n.smartPhotoImgClone,a.src=d.img,a.style.width=`${d.width}px`,a.style.height=`${d.height}px`,a.style.transform=`translate(${d.left}px,${d.top}px) scale(1)`,p.appendChild(a),u.imgClone=a}function re(){var d;(d=u.imgClone)==null||d.remove(),u.imgClone=null}function ve(){r.remove()}return{root:r,refs:u,render:oe,syncSlides:j,updatePhotoTransform:me,applyViewTransitionLayout:pe,resetViewTransitionLayout:q,updateListTransform:ne,showAppearEffect:fe,removeAppearEffect:re,destroy:ve}}var T=le,Y=he;function at(t){return t.length>0&&t[0]instanceof Element}function lt(){return(Date.now().toString(36)+Math.random().toString(36).substring(2,7)).toUpperCase()}function je(){return{x:window.pageXOffset!==void 0?window.pageXOffset:document.documentElement.scrollLeft,y:window.pageYOffset!==void 0?window.pageYOffset:document.documentElement.scrollTop}}var te=class{constructor(e,i){this.id=lt();this.abortController=new AbortController;this.isSmartPhoneFlag=ae();this.lastTriggerElement=null;this.isFiringPublicCloseEvent=!1;this.finishHideEffect=null;this.isViewTransitionActive=!1;this.pendingViewTransitionResync=!1;this.timeouts=[];this.loadAllFired=new Set;this.syncedGroupId=null;this.rootSelector=null;this.itemsByElement=new Map;this.handleDocumentClick=e=>{if(!(e.target instanceof Element))return;let i=e;if(i.__smartphotoClaimed)return;let o=this.findRegisteredAncestor(e.target);if(!o&&this.rootSelector&&(o=e.target.closest(this.rootSelector)),!o)return;if(e.preventDefault(),i.__smartphotoClaimed=!0,!this.itemsByElement.has(o)&&this.rootSelector){let s=Z(o);this.resyncGroupFromDom(s)&&this.syncCurrentGroupView()}let n=this.itemsByElement.get(o);n&&this.openPhoto(n,o)};this.updateViewportHeight=()=>{this.view.refs.dialog.style.setProperty("--smartphoto-vh",`${Y()}px`)};this.handleVisualViewportResize=()=>{if(this.updateViewportHeight(),!(!this.isSmartPhoneFlag||!this.state.viewer.isOpen||!I(this.state))){if(this.isViewTransitionActive){this.pendingViewTransitionResync=!0;return}this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit()}};this.handleResize=()=>{if(!(!this.state.viewer.isOpen||!I(this.state))){if(this.updateViewportHeight(),this.isViewTransitionActive){this.pendingViewTransitionResync=!0;return}this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit()}};this.handleKeydown=e=>{if(!this.state.viewer.isOpen)return;let i=e.keyCode||e.which;i===37?this.gotoSlide(this.state.viewer.prev):i===39?this.gotoSlide(this.state.viewer.next):i===27&&this.hidePhoto()};this.handleOrientationChange=()=>{if(!this.state.viewer.isOpen||!I(this.state))return;if(this.isViewTransitionActive){this.pendingViewTransitionResync=!0;return}this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit();let e=T(),i=500,o=n=>{this.scheduleTimeout(()=>{this.state.viewer.isOpen&&(e!==T()?(this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit()):n<=i&&o(n+25))},25)};o(0)};this.rootSelector=typeof e=="string"?e:null,this.state=Re(i!=null?i:{}),this.view=_e({id:this.id,options:this.state.options},this.buildViewHandlers(),{signal:this.abortController.signal}),document.body.appendChild(this.view.root),this.gestures=Ue({state:this.state,callbacks:this.buildGestureCallbacks()},{signal:this.abortController.signal}),this.gestures.attach(this.view.refs.content,this.view.refs.list),this.view.refs.dialog.addEventListener("close",()=>{!this.isFiringPublicCloseEvent&&this.state.viewer.isOpen&&this.hidePhoto()},{signal:this.abortController.signal}),document.addEventListener("click",this.handleDocumentClick,{signal:this.abortController.signal}),this.ingestSource(e),this.syncCurrentGroupView();let o=this.restoreFromHash();if(o&&this.openPhoto(o,o.element),this.updateViewportHeight(),this.applyAutoIconContrast(),window.visualViewport?window.visualViewport.addEventListener("resize",this.handleVisualViewportResize,{signal:this.abortController.signal}):window.addEventListener("resize",this.updateViewportHeight,{signal:this.abortController.signal}),!this.isSmartPhoneFlag){window.addEventListener("resize",this.handleResize,{signal:this.abortController.signal}),window.addEventListener("keydown",this.handleKeydown,{signal:this.abortController.signal});return}window.addEventListener("orientationchange",this.handleOrientationChange,{signal:this.abortController.signal})}on(e,i){let o=this.view.refs.dialog,n=s=>i.call(o,s);o.addEventListener(e,n,{signal:this.abortController.signal})}destroy(){this.state.viewer.isOpen=!1,this.view.refs.dialog.open&&this.view.refs.dialog.close(),this.abortController.abort(),this.timeouts.forEach(e=>{clearTimeout(e)}),this.timeouts=[],this.itemsByElement.clear(),this.gestures.detach(),this.view.destroy()}[Symbol.dispose](){this.destroy()}gotoSlide(e){var s,r;let i=Number.parseInt(String(e),10),o=Number.isNaN(i)?0:i,n=(r=(s=I(this.state))==null?void 0:s.length)!=null?r:0;o<0||o>=n||(this.state.viewer.currentIndex=o,this.slideList())}hidePhoto(e="bottom"){var o;if(!this.state.viewer.isOpen)return;this.state.viewer.isOpen=!1,this.state.viewer.appear=!1,this.state.viewer.appearEffect=null,this.view.removeAppearEffect(),this.state.viewer.hideUi=!1,this.state.viewer.scale=!1,this.state.viewer.scaleSize=1;let i=je();location.hash&&this.setHash(""),window.scroll(i.x,i.y),this.syncDialog(),(o=this.lastTriggerElement)!=null&&o.isConnected&&this.lastTriggerElement.focus(),this.lastTriggerElement=null,this.doHideEffect(e).then(()=>{this.view.render(this.state),this.isFiringPublicCloseEvent=!0,this.fireEvent("close"),this.isFiringPublicCloseEvent=!1})}zoomPhoto(){let e=L(this.state);e&&(this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=U(e,T(),Y(),this.isSmartPhoneFlag),!(this.state.viewer.scaleSize<=1)&&(this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.view.updatePhotoTransform(this.state),this.scheduleTimeout(()=>{this.state.viewer.isOpen&&(this.state.viewer.scale=!0,this.view.updatePhotoTransform(this.state),this.fireEvent("zoomin"))},this.state.options.animationSpeed)))}canZoomCurrentPhoto(){let e=L(this.state);return!!e&&U(e,T(),Y(),this.isSmartPhoneFlag)>1}zoomOutPhoto(){let e=L(this.state),i=this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag&&e?U(e,T(),Y(),!0):1;this.state.viewer.scaleSize=i,this.state.viewer.hideUi=i>1,this.state.viewer.scale=i>1,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.view.updatePhotoTransform(this.state),this.fireEvent("zoomout")}addNewItem(e){return this.addItem(e)}show(e=0,i={}){var p,c,f;let o=(p=i.group)!=null?p:this.state.viewer.currentGroup;if(o===null)return;let n=this.state.groups.get(o);if(!(n!=null&&n.length))return;let s=typeof e=="number"?n[e]:n.find(S=>S.id===e);if(!s)return;let r=document.activeElement instanceof HTMLElement?document.activeElement:null,m=(f=(c=i.trigger)!=null?c:s.element)!=null?f:r;this.openPhoto(s,m)}hide(){this.hidePhoto()}next(){this.state.viewer.showNextArrow&&this.gotoSlide(this.state.viewer.next)}prev(){this.state.viewer.showPrevArrow&&this.gotoSlide(this.state.viewer.prev)}addItem(e){let i=e instanceof HTMLElement?this.addElementItem(e):this.addSlideItem(e);return this.syncCurrentGroupView(),i}get currentIndex(){return this.state.viewer.currentIndex}ingestSource(e){if(Array.isArray(e)&&!at(e)){e.forEach(o=>{this.addSlideItem(o)});return}Array.from(typeof e=="string"?document.querySelectorAll(e):e).forEach(o=>{this.addElementItem(o)})}addElementItem(e){var s,r;let i=Z(e),o=(r=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?r:0,n=Pe(e,this.state.options,o,T());return be(this.state,n),this.loadAllFired.delete(i),this.itemsByElement.set(e,n),n}addSlideItem(e){var s,r;let i=Ee(e),o=(r=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?r:0,n=Ye(e,o,T());return be(this.state,n),this.loadAllFired.delete(i),n}findRegisteredAncestor(e){let i=e;for(;i;){if(this.itemsByElement.has(i))return i;i=i.parentElement}return null}resyncGroupFromDom(e){var p;if(!this.rootSelector)return!1;let i=Array.from(document.querySelectorAll(this.rootSelector)).filter(c=>Z(c)===e),o=new Set(i),n=(p=this.state.groups.get(e))!=null?p:[],s=new Map;n.forEach(c=>{c.element&&s.set(c.element,c)});let r=i.length!==n.length,m=i.map((c,f)=>{let S=s.get(c);if(S)return S.index!==f&&(r=!0,S.index=f),S;r=!0;let P=Pe(c,this.state.options,f,T());return this.itemsByElement.set(c,P),P});return n.forEach(c=>{c.element&&!o.has(c.element)&&this.itemsByElement.delete(c.element)}),xe(m,T()),this.state.groups.set(e,m),r&&this.loadAllFired.delete(e),r}syncCurrentGroupView(){let e=I(this.state);e&&(this.view.syncSlides(e,this.state),this.syncedGroupId=this.state.viewer.currentGroup)}setHash(e){var o;if(!((o=window.history)!=null&&o.pushState)||!this.state.options.useHistoryApi)return;let i=`${location.pathname}${location.search}`;window.history.replaceState(null,"",e?`${i}#${e}`:i)}setHashByCurrentIndex(){let e=je();this.setHash(Ge(this.state)),window.scroll(e.x,e.y)}restoreFromHash(){let e=location.hash.substring(1);return e?$e(this.state,Ne(e)):null}setPosByCurrentIndex(){let e=L(this.state);e&&(this.state.viewer.translateX=-e.translateX,this.state.viewer.translateY=0,this.view.updateListTransform(this.state))}setSizeByScreen(){let e=I(this.state);e&&(We(e,T(),Y(),this.state.options.headerHeight,this.state.options.footerHeight),this.syncFillScale())}resetTranslateCurrent(){xe(I(this.state),T())}currentImgElement(){for(let[e,i]of this.view.refs.slides)if(e.index===this.state.viewer.currentIndex)return i.img;return null}currentLiElement(){for(let[e,i]of this.view.refs.slides)if(e.index===this.state.viewer.currentIndex)return i.li;return null}syncDialog(){let{dialog:e,caption:i}=this.view.refs;e.style.transition=this.state.options.showAnimation===!1?"none":"",this.state.viewer.isOpen&&!e.open?(e.style.removeProperty("display"),e.showModal(),i.focus()):!this.state.viewer.isOpen&&e.open&&(e.close(),e.style.display="none")}commit(){this.view.render(this.state),this.view.updatePhotoTransform(this.state),this.syncDialog()}initPhoto(){var i;(i=this.finishHideEffect)==null||i.call(this),this.updateViewportHeight(),this.view.refs.dialog.style.opacity="";let e=I(this.state);this.state.viewer.total=e.length,this.state.viewer.isOpen=!0,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.setPosByCurrentIndex(),this.setSizeByScreen(),Se(this.state)}syncFillScale(){if(this.state.options.resizeStyle!=="fill"||!this.isSmartPhoneFlag)return;let e=L(this.state);e&&(this.state.viewer.scale=!0,this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=U(e,T(),Y(),this.isSmartPhoneFlag))}supportsViewTransition(){return this.state.options.useViewTransitionApi&&typeof document.startViewTransition=="function"&&!Me()}openPhotoWithViewTransition(e){var r,m;document.documentElement.style.setProperty("--smartphoto-animation-speed",`${this.state.options.animationSpeed}ms`);let i="smartphoto-hero",o=(r=e==null?void 0:e.querySelector("img"))!=null?r:null;o&&(o.style.viewTransitionName=i);let n=()=>{this.isViewTransitionActive=!1,o&&(o.style.viewTransitionName="");let p=this.currentImgElement();if(p&&(p.style.viewTransitionName=""),!this.state.viewer.isOpen){this.pendingViewTransitionResync=!1;return}if(this.pendingViewTransitionResync&&I(this.state)){this.pendingViewTransitionResync=!1,this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit();return}this.pendingViewTransitionResync=!1,this.view.resetViewTransitionLayout()},s=(m=document.startViewTransition)==null?void 0:m.call(document,()=>{this.initPhoto(),this.state.viewer.appear=!0,this.commit(),o&&(o.style.viewTransitionName=""),this.currentImgElement().style.viewTransitionName=i,this.view.applyViewTransitionLayout(this.state)});s&&(this.isViewTransitionActive=!0,s.ready.catch(()=>{n()}),s.finished.then(n,n))}addAppearEffect(e,i){var C;let o=(C=e==null?void 0:e.querySelector("img"))!=null?C:null;if(!o){this.state.viewer.appear=!0;return}let n=Be(o),s=o.offsetWidth,r=o.offsetHeight,m=T(),p=Y(),c=p-this.state.options.headerHeight-this.state.options.footerHeight,f=1;this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag?s>r?f=p/r:f=m/s:(s>=r?i.height<c?f=i.width/s:f=c/r:i.height<c?f=i.height/r:f=c/r,s*f>m&&(f=m/s));let S=(f-1)/2*s+(m-s*f)/2,P=(f-1)/2*r+(p-r*f)/2,H=o.getAttribute(this.state.options.lazyAttribute);this.state.viewer.appearEffect={width:s,height:r,top:n.top,left:n.left,once:!0,img:H||i.src||"",afterX:S,afterY:P,scale:f}}runAppearEffect(e){this.view.showAppearEffect(e);let i=this.view.refs.imgClone;return new Promise(o=>{let n=()=>{i.removeEventListener("transitionend",n,!0),o()};i.addEventListener("transitionend",n,!0),this.scheduleTimeout(()=>{i.style.transform=`translate(${e.afterX}px, ${e.afterY}px) scale(${e.scale})`},10)})}doOpen(e,i){if(this.state.options.showAnimation!==!1&&this.supportsViewTransition())this.openPhotoWithViewTransition(e);else if(this.state.options.showAnimation===!1)this.initPhoto(),this.state.viewer.appear=!0,this.commit();else{this.initPhoto(),this.addAppearEffect(e,i),this.commit();let o=this.state.viewer.appearEffect;o&&this.runAppearEffect(o).then(()=>{this.state.viewer.appearEffect=null,this.view.removeAppearEffect(),this.state.viewer.appear=!0,this.commit()})}this.fireEvent("open"),this.resyncSizeAfterOpen()}resyncSizeAfterOpen(){let e=T(),i=Y();requestAnimationFrame(()=>{if(this.state.viewer.isOpen&&!(T()===e&&Y()===i)){if(this.isViewTransitionActive){this.pendingViewTransitionResync=!0;return}this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit()}})}openPhoto(e,i){let o=this.resyncGroupFromDom(e.groupId);this.lastTriggerElement=i,this.state.viewer.currentGroup=e.groupId,this.state.viewer.currentIndex=e.index,(this.syncedGroupId!==e.groupId||o)&&this.syncCurrentGroupView(),this.setHashByCurrentIndex(),e.loaded?this.doOpen(i,e):this.loadItem(e).then(()=>{this.doOpen(i,e)})}doHideEffect(e){return new Promise(i=>{if(this.state.options.showAnimation===!1){i();return}let o=this.view.refs.dialog,n=L(this.state),s=n?this.currentLiElement():null,r=Y(),m=this.currentImgElement(),p=null;if(m){let f=getComputedStyle(m).transform;f&&f!=="none"&&(m.style.transform=f,p=m.style.transform)}if(s&&n){let f=e==="top"?-r:r;s.style.transform=`translate(${n.translateX}px,${n.translateY+f}px)`}let c=f=>{this.finishHideEffect===c&&(f&&f.target!==o||(this.finishHideEffect=null,o.removeEventListener("transitionend",c,!0),m&&p&&m.style.transform===p&&(m.style.transform=""),i()))};this.finishHideEffect=c,o.addEventListener("transitionend",c,!0),this.scheduleTimeout(c,this.state.options.animationSpeed+100)})}loadItem(e){return new Promise(i=>{var n;let o=new Image;o.onload=()=>{e.width=o.width,e.height=o.height,e.loaded=!0,this.checkLoadAll(e.groupId),i()},o.onerror=()=>i(),o.src=(n=e.src)!=null?n:""})}checkLoadAll(e){if(this.loadAllFired.has(e))return;let i=this.state.groups.get(e);i!=null&&i.length&&i.every(o=>o.loaded)&&(this.loadAllFired.add(e),this.fireEvent("loadall"))}loadNeighborItems(){let e=I(this.state);if(!e)return;let{currentIndex:i}=this.state.viewer,{loadOffset:o}=this.state.options,n=[];for(let s=i-o;s<i+o;s++){let r=e[s];r&&!r.loaded&&n.push(this.loadItem(r))}n.length&&Promise.all(n).then(()=>{this.state.viewer.isOpen&&(this.initPhoto(),this.commit())})}slideList(){this.state.viewer.scaleSize=1,this.state.viewer.hideUi=!1,this.state.viewer.scale=!1,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.state.viewer.onMove=!0,this.updateViewportHeight(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.scheduleTimeout(()=>{let e=L(this.state);this.state.viewer.onMove=!1,Se(this.state),this.state.viewer.isOpen&&this.commit(),this.state.viewer.oldIndex!==this.state.viewer.currentIndex&&this.fireEvent("change"),this.state.viewer.oldIndex=this.state.viewer.currentIndex,this.loadNeighborItems(),e&&!e.loaded&&this.loadItem(e).then(()=>{this.state.viewer.isOpen&&(this.initPhoto(),this.commit())})},200)}scheduleTimeout(e,i){let o=window.setTimeout(()=>{this.timeouts=this.timeouts.filter(n=>n!==o),e()},i);return this.timeouts.push(o),o}applyAutoIconContrast(){let e=this.view.refs.dialog,i=getComputedStyle(e);if(i.getPropertyValue("--smartphoto-icon-color").trim())return;let o=i.getPropertyValue("--smartphoto-backdrop-color").trim();o&&e.style.setProperty("--smartphoto-icon-color",De(o))}fireEvent(e){Oe(this.view.refs.dialog,e)}buildViewHandlers(){return{onDismiss:()=>this.hidePhoto(),onPrev:()=>this.prev(),onNext:()=>this.next(),onNavigate:e=>this.gotoSlide(e),onBackdropClick:()=>this.hidePhoto()}}buildGestureCallbacks(){return{onSwipeStart:()=>this.fireEvent("swipestart"),onSwipeMove:()=>this.view.updateListTransform(this.state),onSwipeEnd:e=>{if(this.fireEvent("swipeend"),e==="close-bottom"){this.hidePhoto("bottom");return}if(e==="close-top"){this.hidePhoto("top");return}e==="prev"?this.state.viewer.currentIndex-=1:e==="next"&&(this.state.viewer.currentIndex+=1),this.slideList()},onTap:e=>{let i=this.currentImgElement();!!i&&e instanceof Node&&i.contains(e)&&this.canZoomCurrentPhoto()?this.zoomPhoto():this.hidePhoto()},onGestureStart:()=>{this.fireEvent("gesturestart"),this.view.updatePhotoTransform(this.state)},onGestureMove:()=>this.view.updatePhotoTransform(this.state),onGestureEnd:()=>{this.fireEvent("gestureend"),this.view.updatePhotoTransform(this.state)},onPinchClose:()=>this.hidePhoto(),onPhotoDragMove:()=>this.view.updatePhotoTransform(this.state),onPhotoDragEnd:e=>{if(e==="zoom-out"){this.zoomOutPhoto();return}if(e==="prev"){this.gotoSlide(this.state.viewer.prev);return}if(e==="next"){this.gotoSlide(this.state.viewer.next);return}this.view.updatePhotoTransform(this.state)}}}};var qe=te;var Te=t=>{t.fn.SmartPhoto=function(e){return typeof e=="string"||new qe(this,e),this}};if(typeof define=="function"&&define.amd)define(["jquery"],Te);else{let t=window,e=t.jQuery?t.jQuery:t.$;typeof e!="undefined"&&Te(e)}var Et=Te;})();
|
package/js/smartphoto.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* SmartPhoto v2.1.
|
|
2
|
+
* SmartPhoto v2.1.16
|
|
3
3
|
* (c) appleple
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -178,6 +178,7 @@ var SmartPhoto = (() => {
|
|
|
178
178
|
useViewTransitionApi: true,
|
|
179
179
|
swipeTopToClose: false,
|
|
180
180
|
swipeBottomToClose: true,
|
|
181
|
+
pinchToClose: true,
|
|
181
182
|
swipeOffset: 100,
|
|
182
183
|
swipeVelocity: 0.5,
|
|
183
184
|
headerHeight: 60,
|
|
@@ -437,7 +438,7 @@ var SmartPhoto = (() => {
|
|
|
437
438
|
return Math.round(val * digit) / digit;
|
|
438
439
|
}
|
|
439
440
|
function getPos(e) {
|
|
440
|
-
return { x: e.
|
|
441
|
+
return { x: e.clientX, y: e.clientY };
|
|
441
442
|
}
|
|
442
443
|
function distance(p1, p2) {
|
|
443
444
|
const x = p1.x - p2.x;
|
|
@@ -470,7 +471,8 @@ var SmartPhoto = (() => {
|
|
|
470
471
|
let photoVX = 0;
|
|
471
472
|
let photoVY = 0;
|
|
472
473
|
let pinching = false;
|
|
473
|
-
let
|
|
474
|
+
let pinchStartDistance = 0;
|
|
475
|
+
let pinchStartScale = 1;
|
|
474
476
|
let pinchMoveFrame = null;
|
|
475
477
|
let vx = 0;
|
|
476
478
|
let vy = 0;
|
|
@@ -485,6 +487,14 @@ var SmartPhoto = (() => {
|
|
|
485
487
|
const { width, height } = windowSize();
|
|
486
488
|
return scaleBorder(item, width, height, isSmartPhone2());
|
|
487
489
|
}
|
|
490
|
+
function baselineOf(item) {
|
|
491
|
+
return state.options.resizeStyle === "fill" && isSmartPhone2() ? borderOf(item) : 1;
|
|
492
|
+
}
|
|
493
|
+
const MAX_PINCH_SCALE = 4;
|
|
494
|
+
function maxScaleOf(item) {
|
|
495
|
+
return Math.max(MAX_PINCH_SCALE, borderOf(item));
|
|
496
|
+
}
|
|
497
|
+
const PINCH_CLOSE_RATIO = 0.75;
|
|
488
498
|
function registerElasticForce(flagX, flagY) {
|
|
489
499
|
const item = currentItem(state);
|
|
490
500
|
const bound = boundOf(item);
|
|
@@ -532,7 +542,7 @@ var SmartPhoto = (() => {
|
|
|
532
542
|
}
|
|
533
543
|
const power = getForceAndTheta(vx, vy);
|
|
534
544
|
const force = power.force - state.options.registance;
|
|
535
|
-
if (
|
|
545
|
+
if (force < 0.5) {
|
|
536
546
|
return;
|
|
537
547
|
}
|
|
538
548
|
vx = Math.cos(power.theta) * force;
|
|
@@ -575,16 +585,23 @@ var SmartPhoto = (() => {
|
|
|
575
585
|
{ signal }
|
|
576
586
|
);
|
|
577
587
|
}
|
|
578
|
-
function
|
|
579
|
-
pinching = true;
|
|
580
|
-
swiping = false;
|
|
581
|
-
photoSwipable = false;
|
|
588
|
+
function rebasePinch() {
|
|
582
589
|
const points = Array.from(activePointers.values());
|
|
583
|
-
|
|
590
|
+
pinchStartDistance = distance(
|
|
584
591
|
points[0],
|
|
585
592
|
points[1]
|
|
586
593
|
);
|
|
594
|
+
pinchStartScale = state.viewer.scaleSize;
|
|
595
|
+
}
|
|
596
|
+
function startPinch() {
|
|
597
|
+
pinching = true;
|
|
598
|
+
swiping = false;
|
|
599
|
+
photoSwipable = false;
|
|
600
|
+
rebasePinch();
|
|
601
|
+
vx = 0;
|
|
602
|
+
vy = 0;
|
|
587
603
|
state.viewer.scale = true;
|
|
604
|
+
state.viewer.hideUi = true;
|
|
588
605
|
callbacks.onGestureStart();
|
|
589
606
|
}
|
|
590
607
|
function startSwipe(e) {
|
|
@@ -638,28 +655,36 @@ var SmartPhoto = (() => {
|
|
|
638
655
|
}
|
|
639
656
|
function movePinch() {
|
|
640
657
|
const points = Array.from(activePointers.values());
|
|
641
|
-
const
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
)
|
|
645
|
-
|
|
658
|
+
const p0 = points[0];
|
|
659
|
+
const p1 = points[1];
|
|
660
|
+
const dist = distance(p0, p1);
|
|
661
|
+
if (pinchStartDistance === 0) {
|
|
662
|
+
pinchStartDistance = dist;
|
|
663
|
+
pinchStartScale = state.viewer.scaleSize;
|
|
664
|
+
scheduleGestureMove();
|
|
665
|
+
return;
|
|
666
|
+
}
|
|
646
667
|
const oldScaleSize = state.viewer.scaleSize;
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
668
|
+
state.viewer.scaleSize = round2(
|
|
669
|
+
pinchStartScale * dist / pinchStartDistance,
|
|
670
|
+
6
|
|
671
|
+
);
|
|
650
672
|
if (state.viewer.scaleSize < 0.2) {
|
|
651
673
|
state.viewer.scaleSize = 0.2;
|
|
652
674
|
}
|
|
653
|
-
if (state.viewer.scaleSize < oldScaleSize) {
|
|
654
|
-
state.viewer.photoPosX = (1 + state.viewer.scaleSize - oldScaleSize) * posX;
|
|
655
|
-
state.viewer.photoPosY = (1 + state.viewer.scaleSize - oldScaleSize) * posY;
|
|
656
|
-
}
|
|
657
675
|
const item = currentItem(state);
|
|
658
|
-
if (item) {
|
|
659
|
-
const
|
|
660
|
-
|
|
676
|
+
if (item && state.viewer.scaleSize !== oldScaleSize) {
|
|
677
|
+
const { width: winW, height: winH } = windowSize();
|
|
678
|
+
const cx = winW / 2;
|
|
679
|
+
const cy = state.options.headerHeight + (winH - state.options.headerHeight - state.options.footerHeight) / 2;
|
|
680
|
+
const k = item.scale;
|
|
681
|
+
const mid = { x: (p0.x + p1.x) / 2, y: (p0.y + p1.y) / 2 };
|
|
682
|
+
const ratio = state.viewer.scaleSize / oldScaleSize;
|
|
683
|
+
const dx = mid.x - (cx + state.viewer.photoPosX * k);
|
|
684
|
+
const dy = mid.y - (cy + state.viewer.photoPosY * k);
|
|
685
|
+
state.viewer.photoPosX = round2((mid.x - dx * ratio - cx) / k, 6);
|
|
686
|
+
state.viewer.photoPosY = round2((mid.y - dy * ratio - cy) / k, 6);
|
|
661
687
|
}
|
|
662
|
-
oldDistance = dist;
|
|
663
688
|
scheduleGestureMove();
|
|
664
689
|
}
|
|
665
690
|
function moveSwipe(e) {
|
|
@@ -714,15 +739,39 @@ var SmartPhoto = (() => {
|
|
|
714
739
|
if (!item) {
|
|
715
740
|
return;
|
|
716
741
|
}
|
|
717
|
-
const
|
|
718
|
-
if (state.viewer.scaleSize
|
|
742
|
+
const base = baselineOf(item);
|
|
743
|
+
if (state.viewer.scaleSize <= base) {
|
|
744
|
+
if (state.options.pinchToClose && state.viewer.scaleSize < base * PINCH_CLOSE_RATIO) {
|
|
745
|
+
callbacks.onPinchClose();
|
|
746
|
+
return;
|
|
747
|
+
}
|
|
748
|
+
state.viewer.photoPosX = 0;
|
|
749
|
+
state.viewer.photoPosY = 0;
|
|
750
|
+
state.viewer.scaleSize = base;
|
|
751
|
+
state.viewer.scale = base > 1;
|
|
752
|
+
state.viewer.hideUi = base > 1;
|
|
753
|
+
callbacks.onGestureEnd();
|
|
719
754
|
return;
|
|
720
755
|
}
|
|
721
|
-
state.viewer.
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
state.viewer.
|
|
756
|
+
state.viewer.scaleSize = Math.min(state.viewer.scaleSize, maxScaleOf(item));
|
|
757
|
+
const bound = boundOf(item);
|
|
758
|
+
let flagX = 0;
|
|
759
|
+
let flagY = 0;
|
|
760
|
+
if (state.viewer.photoPosX > bound.maxX) {
|
|
761
|
+
flagX = -1;
|
|
762
|
+
} else if (state.viewer.photoPosX < bound.minX) {
|
|
763
|
+
flagX = 1;
|
|
764
|
+
}
|
|
765
|
+
if (state.viewer.photoPosY > bound.maxY) {
|
|
766
|
+
flagY = -1;
|
|
767
|
+
} else if (state.viewer.photoPosY < bound.minY) {
|
|
768
|
+
flagY = 1;
|
|
769
|
+
}
|
|
770
|
+
if (flagX !== 0 || flagY !== 0) {
|
|
771
|
+
registerElasticForce(flagX, flagY);
|
|
772
|
+
}
|
|
773
|
+
state.viewer.scale = true;
|
|
774
|
+
state.viewer.hideUi = true;
|
|
726
775
|
callbacks.onGestureEnd();
|
|
727
776
|
}
|
|
728
777
|
function endSwipe() {
|
|
@@ -813,6 +862,9 @@ var SmartPhoto = (() => {
|
|
|
813
862
|
if (pinching) {
|
|
814
863
|
if (activePointers.size < 2) {
|
|
815
864
|
endPinch();
|
|
865
|
+
activePointers.clear();
|
|
866
|
+
} else {
|
|
867
|
+
rebasePinch();
|
|
816
868
|
}
|
|
817
869
|
return;
|
|
818
870
|
}
|
|
@@ -1539,9 +1591,11 @@ var SmartPhoto = (() => {
|
|
|
1539
1591
|
) > 1;
|
|
1540
1592
|
}
|
|
1541
1593
|
zoomOutPhoto() {
|
|
1542
|
-
this.state
|
|
1543
|
-
this.state.
|
|
1544
|
-
this.state.viewer.
|
|
1594
|
+
const item = currentItem(this.state);
|
|
1595
|
+
const base = this.state.options.resizeStyle === "fill" && this.isSmartPhoneFlag && item ? scaleBorder(item, getWindowWidth2(), getWindowHeight2(), true) : 1;
|
|
1596
|
+
this.state.viewer.scaleSize = base;
|
|
1597
|
+
this.state.viewer.hideUi = base > 1;
|
|
1598
|
+
this.state.viewer.scale = base > 1;
|
|
1545
1599
|
this.state.viewer.photoPosX = 0;
|
|
1546
1600
|
this.state.viewer.photoPosY = 0;
|
|
1547
1601
|
this.view.updatePhotoTransform(this.state);
|
|
@@ -2006,7 +2060,7 @@ var SmartPhoto = (() => {
|
|
|
2006
2060
|
});
|
|
2007
2061
|
}
|
|
2008
2062
|
openPhoto(item, trigger) {
|
|
2009
|
-
const groupChanged = this.
|
|
2063
|
+
const groupChanged = this.resyncGroupFromDom(item.groupId);
|
|
2010
2064
|
this.lastTriggerElement = trigger;
|
|
2011
2065
|
this.state.viewer.currentGroup = item.groupId;
|
|
2012
2066
|
this.state.viewer.currentIndex = item.index;
|
|
@@ -2241,6 +2295,9 @@ var SmartPhoto = (() => {
|
|
|
2241
2295
|
this.fireEvent("gestureend");
|
|
2242
2296
|
this.view.updatePhotoTransform(this.state);
|
|
2243
2297
|
},
|
|
2298
|
+
// ピンチで基準倍率よりはっきり小さく縮めて離した = 閉じたい操作
|
|
2299
|
+
// (PhotoSwipe の pinchToClose 相当)
|
|
2300
|
+
onPinchClose: () => this.hidePhoto(),
|
|
2244
2301
|
onPhotoDragMove: () => this.view.updatePhotoTransform(this.state),
|
|
2245
2302
|
onPhotoDragEnd: (result) => {
|
|
2246
2303
|
if (result === "zoom-out") {
|