smartphoto 2.1.3 → 2.1.6
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 +18 -5
- package/css/smartphoto.css +82 -22
- package/css/smartphoto.min.css +1 -1
- package/js/jquery-smartphoto.js +163 -25
- package/js/jquery-smartphoto.min.js +2 -2
- package/js/smartphoto.js +163 -25
- package/js/smartphoto.min.js +2 -2
- package/lib/smartphoto.js +161 -23
- package/lib/smartphoto.mjs +161 -23
- package/lib/types/core/index.d.ts +9 -5
- package/lib/types/core/state.d.ts +6 -6
- package/lib/types/core/types.d.ts +14 -11
- package/lib/types/core/view.d.ts +2 -2
- package/lib/types/index.d.ts +1 -0
- package/package.json +10 -8
- package/css/smartphoto.css.map +0 -1
package/js/jquery-smartphoto.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* SmartPhoto v2.1.
|
|
2
|
+
* SmartPhoto v2.1.6
|
|
3
3
|
* (c) appleple
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -106,6 +106,7 @@
|
|
|
106
106
|
swipeTopToClose: false,
|
|
107
107
|
swipeBottomToClose: true,
|
|
108
108
|
swipeOffset: 100,
|
|
109
|
+
swipeVelocity: 0.5,
|
|
109
110
|
headerHeight: 60,
|
|
110
111
|
footerHeight: 60,
|
|
111
112
|
forceInterval: 10,
|
|
@@ -113,7 +114,7 @@
|
|
|
113
114
|
loadOffset: 2,
|
|
114
115
|
resizeStyle: "fit",
|
|
115
116
|
lazyAttribute: "data-src",
|
|
116
|
-
animationSpeed:
|
|
117
|
+
animationSpeed: 450
|
|
117
118
|
};
|
|
118
119
|
function deepFreeze(obj) {
|
|
119
120
|
Object.keys(obj).forEach((key) => {
|
|
@@ -127,7 +128,11 @@
|
|
|
127
128
|
function createState(settings) {
|
|
128
129
|
return {
|
|
129
130
|
options: deepFreeze(
|
|
130
|
-
extend(
|
|
131
|
+
extend(
|
|
132
|
+
{},
|
|
133
|
+
defaults,
|
|
134
|
+
settings
|
|
135
|
+
)
|
|
131
136
|
),
|
|
132
137
|
viewer: {
|
|
133
138
|
isOpen: false,
|
|
@@ -366,6 +371,7 @@
|
|
|
366
371
|
const y = p1.y - p2.y;
|
|
367
372
|
return Math.sqrt(x * x + y * y);
|
|
368
373
|
}
|
|
374
|
+
var MIN_FLICK_DISTANCE = 10;
|
|
369
375
|
function getForceAndTheta(x, y) {
|
|
370
376
|
return { force: Math.sqrt(x * x + y * y), theta: Math.atan2(y, x) };
|
|
371
377
|
}
|
|
@@ -383,6 +389,7 @@
|
|
|
383
389
|
let firstPos = null;
|
|
384
390
|
let oldPos = null;
|
|
385
391
|
let moveDir = null;
|
|
392
|
+
let swipeStartTime = 0;
|
|
386
393
|
let photoSwipable = false;
|
|
387
394
|
let firstPhotoPos = null;
|
|
388
395
|
let oldPhotoPos = null;
|
|
@@ -390,6 +397,7 @@
|
|
|
390
397
|
let photoVY = 0;
|
|
391
398
|
let pinching = false;
|
|
392
399
|
let oldDistance = 0;
|
|
400
|
+
let pinchMoveFrame = null;
|
|
393
401
|
let vx = 0;
|
|
394
402
|
let vy = 0;
|
|
395
403
|
function isSmartPhone2() {
|
|
@@ -511,6 +519,7 @@
|
|
|
511
519
|
dragStart = true;
|
|
512
520
|
firstPos = pos;
|
|
513
521
|
oldPos = pos;
|
|
522
|
+
swipeStartTime = Date.now();
|
|
514
523
|
}
|
|
515
524
|
function startPhotoDrag(e) {
|
|
516
525
|
photoSwipable = true;
|
|
@@ -535,6 +544,23 @@
|
|
|
535
544
|
}
|
|
536
545
|
startSwipe(e);
|
|
537
546
|
}
|
|
547
|
+
function scheduleGestureMove() {
|
|
548
|
+
if (pinchMoveFrame !== null) {
|
|
549
|
+
return;
|
|
550
|
+
}
|
|
551
|
+
pinchMoveFrame = requestAnimationFrame(() => {
|
|
552
|
+
pinchMoveFrame = null;
|
|
553
|
+
callbacks.onGestureMove();
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
function flushGestureMove() {
|
|
557
|
+
if (pinchMoveFrame === null) {
|
|
558
|
+
return;
|
|
559
|
+
}
|
|
560
|
+
cancelAnimationFrame(pinchMoveFrame);
|
|
561
|
+
pinchMoveFrame = null;
|
|
562
|
+
callbacks.onGestureMove();
|
|
563
|
+
}
|
|
538
564
|
function movePinch() {
|
|
539
565
|
const points = Array.from(activePointers.values());
|
|
540
566
|
const dist = distance(
|
|
@@ -559,7 +585,7 @@
|
|
|
559
585
|
state.viewer.hideUi = state.viewer.scaleSize < 1 || state.viewer.scaleSize > border;
|
|
560
586
|
}
|
|
561
587
|
oldDistance = dist;
|
|
562
|
-
|
|
588
|
+
scheduleGestureMove();
|
|
563
589
|
}
|
|
564
590
|
function moveSwipe(e) {
|
|
565
591
|
const pos = getPos(e);
|
|
@@ -608,6 +634,7 @@
|
|
|
608
634
|
}
|
|
609
635
|
function endPinch() {
|
|
610
636
|
pinching = false;
|
|
637
|
+
flushGestureMove();
|
|
611
638
|
const item = currentItem(state);
|
|
612
639
|
if (!item) {
|
|
613
640
|
return;
|
|
@@ -645,9 +672,11 @@
|
|
|
645
672
|
const items = (_a = currentItems(state)) != null ? _a : [];
|
|
646
673
|
if (moveDir === "horizontal") {
|
|
647
674
|
let result = "stay";
|
|
648
|
-
|
|
675
|
+
const elapsedMs = Math.max(now - swipeStartTime, 1);
|
|
676
|
+
const isFlick = Math.abs(swipeWidth) >= MIN_FLICK_DISTANCE && Math.abs(swipeWidth) / elapsedMs >= state.options.swipeVelocity;
|
|
677
|
+
if ((swipeWidth >= state.options.swipeOffset || isFlick && swipeWidth > 0) && state.viewer.currentIndex !== 0) {
|
|
649
678
|
result = "prev";
|
|
650
|
-
} else if (swipeWidth <= -state.options.swipeOffset && state.viewer.currentIndex !== items.length - 1) {
|
|
679
|
+
} else if ((swipeWidth <= -state.options.swipeOffset || isFlick && swipeWidth < 0) && state.viewer.currentIndex !== items.length - 1) {
|
|
651
680
|
result = "next";
|
|
652
681
|
}
|
|
653
682
|
callbacks.onSwipeEnd(result);
|
|
@@ -738,6 +767,10 @@
|
|
|
738
767
|
}
|
|
739
768
|
function detach() {
|
|
740
769
|
clearInterval(interval);
|
|
770
|
+
if (pinchMoveFrame !== null) {
|
|
771
|
+
cancelAnimationFrame(pinchMoveFrame);
|
|
772
|
+
pinchMoveFrame = null;
|
|
773
|
+
}
|
|
741
774
|
}
|
|
742
775
|
return { attach, detach };
|
|
743
776
|
}
|
|
@@ -1075,8 +1108,11 @@
|
|
|
1075
1108
|
return document.documentElement.clientWidth;
|
|
1076
1109
|
}
|
|
1077
1110
|
function getWindowHeight() {
|
|
1078
|
-
|
|
1079
|
-
|
|
1111
|
+
const visualViewport = window.visualViewport;
|
|
1112
|
+
if (visualViewport) {
|
|
1113
|
+
return visualViewport.height * visualViewport.scale;
|
|
1114
|
+
}
|
|
1115
|
+
return document.documentElement.clientHeight;
|
|
1080
1116
|
}
|
|
1081
1117
|
function isElementArray(source) {
|
|
1082
1118
|
return source.length > 0 && source[0] instanceof Element;
|
|
@@ -1107,6 +1143,44 @@
|
|
|
1107
1143
|
this.timeouts = [];
|
|
1108
1144
|
this.loadAllFired = /* @__PURE__ */ new Set();
|
|
1109
1145
|
this.syncedGroupId = null;
|
|
1146
|
+
// 文字列セレクタで構築された場合のみ設定される。Ajax等で後から追加された
|
|
1147
|
+
// 要素をクリック時に動的検出するための再スキャン起点(§discoverGroupElements)
|
|
1148
|
+
this.rootSelector = null;
|
|
1149
|
+
// クリックされた要素(またはその祖先)から登録済み Item を逆引きするための
|
|
1150
|
+
// キャッシュ。documentへのイベントデリゲーションで祖先チェーンを辿る際に使う
|
|
1151
|
+
this.itemsByElement = /* @__PURE__ */ new Map();
|
|
1152
|
+
// サムネイルクリックはこの1本の document デリゲーションリスナーだけで処理する
|
|
1153
|
+
// (個別バインドは廃止)。同じクリックイベントを複数の SmartPhoto インスタンスが
|
|
1154
|
+
// 二重処理しないよう、処理済みマーカーをイベント自体に立てて後続インスタンスに
|
|
1155
|
+
// 早期returnさせる(セレクタが重複するインスタンスが同時に存在するケース)
|
|
1156
|
+
this.handleDocumentClick = (e) => {
|
|
1157
|
+
if (!(e.target instanceof Element)) {
|
|
1158
|
+
return;
|
|
1159
|
+
}
|
|
1160
|
+
const marker = e;
|
|
1161
|
+
if (marker.__smartphotoClaimed) {
|
|
1162
|
+
return;
|
|
1163
|
+
}
|
|
1164
|
+
let matched = this.findRegisteredAncestor(e.target);
|
|
1165
|
+
if (!matched && this.rootSelector) {
|
|
1166
|
+
matched = e.target.closest(this.rootSelector);
|
|
1167
|
+
}
|
|
1168
|
+
if (!matched) {
|
|
1169
|
+
return;
|
|
1170
|
+
}
|
|
1171
|
+
e.preventDefault();
|
|
1172
|
+
marker.__smartphotoClaimed = true;
|
|
1173
|
+
if (!this.itemsByElement.has(matched) && this.rootSelector) {
|
|
1174
|
+
const groupId = groupIdFromElement(matched);
|
|
1175
|
+
if (this.resyncGroupFromDom(groupId)) {
|
|
1176
|
+
this.syncCurrentGroupView();
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
const item = this.itemsByElement.get(matched);
|
|
1180
|
+
if (item) {
|
|
1181
|
+
this.openPhoto(item, matched);
|
|
1182
|
+
}
|
|
1183
|
+
};
|
|
1110
1184
|
// ---- 内部: window イベント ----
|
|
1111
1185
|
this.updateViewportHeight = () => {
|
|
1112
1186
|
this.view.refs.dialog.style.setProperty(
|
|
@@ -1118,6 +1192,7 @@
|
|
|
1118
1192
|
if (!currentItems(this.state)) {
|
|
1119
1193
|
return;
|
|
1120
1194
|
}
|
|
1195
|
+
this.updateViewportHeight();
|
|
1121
1196
|
this.resetTranslateCurrent();
|
|
1122
1197
|
this.setPosByCurrentIndex();
|
|
1123
1198
|
this.setSizeByScreen();
|
|
@@ -1140,6 +1215,7 @@
|
|
|
1140
1215
|
if (!currentItems(this.state)) {
|
|
1141
1216
|
return;
|
|
1142
1217
|
}
|
|
1218
|
+
this.updateViewportHeight();
|
|
1143
1219
|
this.resetTranslateCurrent();
|
|
1144
1220
|
this.setPosByCurrentIndex();
|
|
1145
1221
|
this.setHashByCurrentIndex();
|
|
@@ -1150,6 +1226,7 @@
|
|
|
1150
1226
|
const poll = (time) => {
|
|
1151
1227
|
this.scheduleTimeout(() => {
|
|
1152
1228
|
if (prevWidth !== getWindowWidth()) {
|
|
1229
|
+
this.updateViewportHeight();
|
|
1153
1230
|
this.resetTranslateCurrent();
|
|
1154
1231
|
this.setPosByCurrentIndex();
|
|
1155
1232
|
this.setHashByCurrentIndex();
|
|
@@ -1162,6 +1239,7 @@
|
|
|
1162
1239
|
};
|
|
1163
1240
|
poll(0);
|
|
1164
1241
|
};
|
|
1242
|
+
this.rootSelector = typeof source === "string" ? source : null;
|
|
1165
1243
|
this.state = createState(settings != null ? settings : {});
|
|
1166
1244
|
this.view = createView(
|
|
1167
1245
|
{ id: this.id, options: this.state.options },
|
|
@@ -1183,15 +1261,14 @@
|
|
|
1183
1261
|
},
|
|
1184
1262
|
{ signal: this.abortController.signal }
|
|
1185
1263
|
);
|
|
1264
|
+
document.addEventListener("click", this.handleDocumentClick, {
|
|
1265
|
+
signal: this.abortController.signal
|
|
1266
|
+
});
|
|
1186
1267
|
this.ingestSource(source);
|
|
1187
1268
|
this.syncCurrentGroupView();
|
|
1188
1269
|
const restored = this.restoreFromHash();
|
|
1189
1270
|
if (restored) {
|
|
1190
|
-
|
|
1191
|
-
triggerEvent(restored.element, "click");
|
|
1192
|
-
} else {
|
|
1193
|
-
this.openPhoto(restored, null);
|
|
1194
|
-
}
|
|
1271
|
+
this.openPhoto(restored, restored.element);
|
|
1195
1272
|
}
|
|
1196
1273
|
this.updateViewportHeight();
|
|
1197
1274
|
if (window.visualViewport) {
|
|
@@ -1236,6 +1313,7 @@
|
|
|
1236
1313
|
clearTimeout(id);
|
|
1237
1314
|
});
|
|
1238
1315
|
this.timeouts = [];
|
|
1316
|
+
this.itemsByElement.clear();
|
|
1239
1317
|
this.gestures.detach();
|
|
1240
1318
|
this.view.destroy();
|
|
1241
1319
|
}
|
|
@@ -1350,7 +1428,7 @@
|
|
|
1350
1428
|
this.gotoSlide(this.state.viewer.prev);
|
|
1351
1429
|
}
|
|
1352
1430
|
addItem(slideOrElement) {
|
|
1353
|
-
const item = slideOrElement instanceof
|
|
1431
|
+
const item = slideOrElement instanceof HTMLElement ? this.addElementItem(slideOrElement) : this.addSlideItem(slideOrElement);
|
|
1354
1432
|
this.syncCurrentGroupView();
|
|
1355
1433
|
return item;
|
|
1356
1434
|
}
|
|
@@ -1382,7 +1460,7 @@
|
|
|
1382
1460
|
);
|
|
1383
1461
|
addItemToGroup(this.state, item);
|
|
1384
1462
|
this.loadAllFired.delete(groupId);
|
|
1385
|
-
this.
|
|
1463
|
+
this.itemsByElement.set(element, item);
|
|
1386
1464
|
return item;
|
|
1387
1465
|
}
|
|
1388
1466
|
addSlideItem(slide) {
|
|
@@ -1394,15 +1472,73 @@
|
|
|
1394
1472
|
this.loadAllFired.delete(groupId);
|
|
1395
1473
|
return item;
|
|
1396
1474
|
}
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1475
|
+
// クリックされた要素(またはその祖先。<a><img></a> の img がクリックされる
|
|
1476
|
+
// ケースを含む)から、登録済み Item を持つ要素まで祖先チェーンを遡って探す
|
|
1477
|
+
findRegisteredAncestor(target) {
|
|
1478
|
+
let node = target;
|
|
1479
|
+
while (node) {
|
|
1480
|
+
if (this.itemsByElement.has(node)) {
|
|
1481
|
+
return node;
|
|
1482
|
+
}
|
|
1483
|
+
node = node.parentElement;
|
|
1484
|
+
}
|
|
1485
|
+
return null;
|
|
1486
|
+
}
|
|
1487
|
+
// rootSelector(文字列セレクタで構築した場合のみ設定される)を再スキャンし、
|
|
1488
|
+
// 指定グループを現在のDOM状態に合わせて丸ごと再構築する(追加・削除・並び順の
|
|
1489
|
+
// 変化を一度に反映)。既知要素は既存の Item オブジェクトをそのまま再利用する
|
|
1490
|
+
// ため loaded/width/height は保持され、DOM から消えた要素だけ itemsByElement
|
|
1491
|
+
// からも除去する。index/translateX は resetTranslate() で再計算する。
|
|
1492
|
+
// 呼び出し元(openPhoto)がこの結果を使い、変化があった場合のみ view を
|
|
1493
|
+
// 再同期する(§ダイアログを開く瞬間に整合を取る。開いている間の next()/prev()
|
|
1494
|
+
// では呼ばれないため、この間の追加/削除は次に開き直すまで反映されない)
|
|
1495
|
+
resyncGroupFromDom(groupId) {
|
|
1496
|
+
var _a;
|
|
1497
|
+
if (!this.rootSelector) {
|
|
1498
|
+
return false;
|
|
1499
|
+
}
|
|
1500
|
+
const domElements = Array.from(
|
|
1501
|
+
document.querySelectorAll(this.rootSelector)
|
|
1502
|
+
).filter((el) => groupIdFromElement(el) === groupId);
|
|
1503
|
+
const domElementSet = new Set(domElements);
|
|
1504
|
+
const previous = (_a = this.state.groups.get(groupId)) != null ? _a : [];
|
|
1505
|
+
const previousByElement = /* @__PURE__ */ new Map();
|
|
1506
|
+
previous.forEach((it) => {
|
|
1507
|
+
if (it.element) {
|
|
1508
|
+
previousByElement.set(it.element, it);
|
|
1509
|
+
}
|
|
1510
|
+
});
|
|
1511
|
+
let changed = domElements.length !== previous.length;
|
|
1512
|
+
const rebuilt = domElements.map((el, index) => {
|
|
1513
|
+
const existing = previousByElement.get(el);
|
|
1514
|
+
if (existing) {
|
|
1515
|
+
if (existing.index !== index) {
|
|
1516
|
+
changed = true;
|
|
1517
|
+
existing.index = index;
|
|
1518
|
+
}
|
|
1519
|
+
return existing;
|
|
1520
|
+
}
|
|
1521
|
+
changed = true;
|
|
1522
|
+
const item = itemFromElement(
|
|
1523
|
+
el,
|
|
1524
|
+
this.state.options,
|
|
1525
|
+
index,
|
|
1526
|
+
getWindowWidth()
|
|
1527
|
+
);
|
|
1528
|
+
this.itemsByElement.set(el, item);
|
|
1529
|
+
return item;
|
|
1530
|
+
});
|
|
1531
|
+
previous.forEach((it) => {
|
|
1532
|
+
if (it.element && !domElementSet.has(it.element)) {
|
|
1533
|
+
this.itemsByElement.delete(it.element);
|
|
1534
|
+
}
|
|
1535
|
+
});
|
|
1536
|
+
resetTranslate(rebuilt, getWindowWidth());
|
|
1537
|
+
this.state.groups.set(groupId, rebuilt);
|
|
1538
|
+
if (changed) {
|
|
1539
|
+
this.loadAllFired.delete(groupId);
|
|
1540
|
+
}
|
|
1541
|
+
return changed;
|
|
1406
1542
|
}
|
|
1407
1543
|
syncCurrentGroupView() {
|
|
1408
1544
|
const items = currentItems(this.state);
|
|
@@ -1660,10 +1796,11 @@
|
|
|
1660
1796
|
});
|
|
1661
1797
|
}
|
|
1662
1798
|
openPhoto(item, trigger) {
|
|
1799
|
+
const groupChanged = this.rootSelector ? this.resyncGroupFromDom(item.groupId) : false;
|
|
1663
1800
|
this.lastTriggerElement = trigger;
|
|
1664
1801
|
this.state.viewer.currentGroup = item.groupId;
|
|
1665
1802
|
this.state.viewer.currentIndex = item.index;
|
|
1666
|
-
if (this.syncedGroupId !== item.groupId) {
|
|
1803
|
+
if (this.syncedGroupId !== item.groupId || groupChanged) {
|
|
1667
1804
|
this.syncCurrentGroupView();
|
|
1668
1805
|
}
|
|
1669
1806
|
this.setHashByCurrentIndex();
|
|
@@ -1755,6 +1892,7 @@
|
|
|
1755
1892
|
this.state.viewer.photoPosX = 0;
|
|
1756
1893
|
this.state.viewer.photoPosY = 0;
|
|
1757
1894
|
this.state.viewer.onMove = true;
|
|
1895
|
+
this.updateViewportHeight();
|
|
1758
1896
|
this.setPosByCurrentIndex();
|
|
1759
1897
|
this.setHashByCurrentIndex();
|
|
1760
1898
|
this.setSizeByScreen();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* SmartPhoto v2.1.
|
|
2
|
+
* SmartPhoto v2.1.6
|
|
3
3
|
* (c) appleple
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
"use strict";(()=>{var j=()=>{let t=navigator.userAgent;return t.indexOf("iPhone")>0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0};function fe(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]=fe((i=t[s])!=null?i:{},n):t[s]=n}}}return t}var ve=fe,ne=(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)},we=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},ge=t=>({left:t.getBoundingClientRect().left,top:t.getBoundingClientRect().top});var Xe={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,swipeTopToClose:!1,swipeBottomToClose:!0,swipeOffset:100,headerHeight:60,footerHeight:60,forceInterval:10,registance:.5,loadOffset:2,resizeStyle:"fit",lazyAttribute:"data-src",animationSpeed:300};function Ee(t){return Object.keys(t).forEach(e=>{let i=t[e];i&&typeof i=="object"&&!Object.isFrozen(i)&&Ee(i)}),Object.freeze(t)}function Pe(t){return{options:Ee(ve({},Xe,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 ae(t){return t.getAttribute("data-group")||"nogroup"}function le(t){return t.group||"nogroup"}function be(t,e,i,o){let r=ae(t),s=t.getAttribute("href"),n=t.querySelector("img"),c=s;n&&(n.getAttribute(e.lazyAttribute)?c=n.getAttribute(e.lazyAttribute):n.currentSrc?c=n.currentSrc:c=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 E=t.getAttribute("data-id");return{src:s,thumb:c,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:E||i,loaded:!1,processed:!1,element:t}}function ye(t,e,i){var E,v,x,b,I;let o=le(t),r=t.src,s=(E=t.thumb)!=null?E:r,n=(v=t.caption)!=null?v:null,c=(b=(x=t.alt)!=null?x:n)!=null?b:r,p=typeof t.width=="number"&&typeof t.height=="number";return{src:r,thumb:s,caption:n,alt:c,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:(I=t.id)!=null?I:e,loaded:p,processed:!1,element:null}}function he(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 H(t){var e;return t.viewer.currentGroup===null?null:(e=t.groups.get(t.viewer.currentGroup))!=null?e:null}function M(t){var i;let e=H(t);return e&&(i=e[t.viewer.currentIndex])!=null?i:null}function ue(t){let e=H(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 Se(t,e){t.forEach((i,o)=>{i.translateX=e*o})}function Q(t,e){let i=10**e;return Math.round(t*i)/i}function W(t,e,i,o){return o?t.width>t.height?i/(t.height*t.scale):e/(t.width*t.scale):1/t.scale}function xe(t,e,i,o){let r=t.width*t.scale*e.scaleSize,s=t.height*t.scale*e.scaleSize,n,c,p,E;return i>r?(p=(i-r)/2,n=-1*p):(p=(r-i)/2,n=-1*p),o>s?(E=(o-s)/2,c=-1*E):(E=(s-o)/2,c=-1*E),{minX:Q(n,6)*e.scaleSize,minY:Q(c,6)*e.scaleSize,maxX:Q(p,6)*e.scaleSize,maxY:Q(E,6)*e.scaleSize}}function Ie(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 Le(t){let e=M(t);return e?`group=${t.viewer.currentGroup}&photo=${e.id}`:""}function Ce(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 de(t,e){let i=10**e;return Math.round(t*i)/i}function $(t){return{x:t.pageX,y:t.pageY}}function Te(t,e){let i=t.x-e.x,o=t.y-e.y;return Math.sqrt(i*i+o*o)}function Ye(t,e){return{force:Math.sqrt(t*t+e*e),theta:Math.atan2(e,t)}}function Ae(){return{width:document.documentElement.clientWidth,height:document.documentElement.clientHeight}}function He({state:t,callbacks:e},{signal:i}){let o=new Map,r=Date.now(),s=!1,n=!1,c=null,p=null,E=null,v=!1,x=null,b=null,I=0,z=0,y=!1,Y=0,L=0,C=0;function N(){return j()}function k(a){let{width:h,height:f}=Ae();return xe(a,t.viewer,h,f)}function u(a){let{width:h,height:f}=Ae();return W(a,h,f,N())}function J(a,h){let f=M(t),m=k(f);t.viewer.elastic=!0,a===1?t.viewer.photoPosX=m.minX:a===-1&&(t.viewer.photoPosX=m.maxX),h===1?t.viewer.photoPosY=m.minY:h===-1&&(t.viewer.photoPosY=m.maxY),e.onPhotoDragMove(),setTimeout(()=>{t.viewer.elastic=!1,e.onPhotoDragMove()},300)}let R=setInterval(()=>{if(y||s||v||t.viewer.elastic||!t.viewer.scale)return;t.viewer.photoPosX+=L,t.viewer.photoPosY+=C;let a=M(t);if(!a)return;let h=k(a);t.viewer.photoPosX<h.minX?(t.viewer.photoPosX=h.minX,L*=-.2):t.viewer.photoPosX>h.maxX&&(t.viewer.photoPosX=h.maxX,L*=-.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 f=Ye(L,C),m=f.force-t.options.registance;Math.abs(m)<.5||(L=Math.cos(f.theta)*m,C=Math.sin(f.theta)*m,e.onPhotoDragMove())},t.options.forceInterval);function G(a,h){(a>5||a<-5)&&(L+=a*.05),t.options.verticalGravity&&(h>5||h<-5)&&(C+=h*.05)}function K(a){if(!(a!=null&&a.gamma)||t.viewer.appearEffect||y||s||v||t.viewer.elastic||!t.viewer.scale)return;let{orientation:h}=window;h===0?G(a.gamma,a.beta):h===90?G(a.beta,a.gamma):h===-90?G(-a.beta,-a.gamma):h===180&&G(-a.gamma,-a.beta)}t.options.useOrientationApi&&window.addEventListener("deviceorientation",K,{signal:i});function B(){y=!0,s=!1,v=!1;let a=Array.from(o.values());Y=Te(a[0],a[1]),t.viewer.scale=!0,e.onGestureStart()}function U(a){let h=$(a);s=!0,n=!0,c=h,p=h}function _(a){v=!0;let h=$(a);b=h,x=h}function Z(a){var h,f;try{(f=(h=a.currentTarget).setPointerCapture)==null||f.call(h,a.pointerId)}catch(m){}if(o.set(a.pointerId,$(a)),o.size>1){B();return}if(t.viewer.scale){_(a);return}U(a)}function ee(){let a=Array.from(o.values()),h=Te(a[0],a[1]),f=(h-Y)/100,m=t.viewer.scaleSize,T=t.viewer.photoPosX,A=t.viewer.photoPosY;t.viewer.scaleSize+=de(f,6),t.viewer.scaleSize<.2&&(t.viewer.scaleSize=.2),t.viewer.scaleSize<m&&(t.viewer.photoPosX=(1+t.viewer.scaleSize-m)*T,t.viewer.photoPosY=(1+t.viewer.scaleSize-m)*A);let X=M(t);if(X){let re=u(X);t.viewer.hideUi=t.viewer.scaleSize<1||t.viewer.scaleSize>re}Y=h,e.onGestureMove()}function te(a){let h=$(a),f=h.x-p.x,m=h.y-c.y;n&&(e.onSwipeStart(),n=!1,E=Math.abs(f)>Math.abs(m)?"horizontal":"vertical"),E==="horizontal"?t.viewer.translateX+=f:t.viewer.translateY=m,p=h,e.onSwipeMove()}function ie(a){let h=$(a),f=h.x-b.x,m=h.y-b.y,T=de(t.viewer.scaleSize*f,6),A=de(t.viewer.scaleSize*m,6);t.viewer.photoPosX+=T,I=T,t.viewer.photoPosY+=A,z=A,b=h,e.onPhotoDragMove()}function oe(a){if(o.has(a.pointerId)){if(o.set(a.pointerId,$(a)),y){ee();return}if(v){ie(a);return}te(a)}}function d(){y=!1;let a=M(t);if(!a)return;let h=u(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 l(){var pe;s=!1;let a=c,h=p,f=Date.now(),m=r-f,T=h.x-a.x,A=h.y-a.y,X=T===0&&A===0;if(!N()&&X){e.onTap();return}if(Math.abs(m)<=500&&X){e.onTap();return}r=f;let re=(pe=H(t))!=null?pe:[];if(E==="horizontal"){let V="stay";T>=t.options.swipeOffset&&t.viewer.currentIndex!==0?V="prev":T<=-t.options.swipeOffset&&t.viewer.currentIndex!==re.length-1&&(V="next"),e.onSwipeEnd(V)}else{let V="stay";t.options.swipeBottomToClose&&A>=t.options.swipeOffset?V="close-bottom":t.options.swipeTopToClose&&A<=-t.options.swipeOffset&&(V="close-top"),e.onSwipeEnd(V)}}function P(){v=!1;let a=b,h=x;if(a.x===h.x){e.onPhotoDragEnd("zoom-out");return}let f=M(t);if(!f){e.onPhotoDragEnd(null);return}let m=k(f),T=t.options.swipeOffset*t.viewer.scaleSize,A=0,X=0;if(t.viewer.photoPosX>m.maxX?A=-1:t.viewer.photoPosX<m.minX&&(A=1),t.viewer.photoPosY>m.maxY?X=-1:t.viewer.photoPosY<m.minY&&(X=1),t.viewer.photoPosX-m.maxX>T&&t.viewer.currentIndex!==0){e.onPhotoDragEnd("prev");return}if(m.minX-t.viewer.photoPosX>T&&t.viewer.currentIndex+1!==t.viewer.total){e.onPhotoDragEnd("next");return}A===0&&X===0?(L=I/5,C=z/5):J(A,X),e.onPhotoDragEnd(null)}function g(a){if(o.delete(a.pointerId),y){o.size<2&&d();return}if(v){P();return}s&&l()}function w(...a){for(let h of a)h.addEventListener("pointerdown",Z,{signal:i}),h.addEventListener("pointermove",oe,{signal:i}),h.addEventListener("pointerup",g,{signal:i}),h.addEventListener("pointercancel",g,{signal:i})}function S(){clearInterval(R)}return{attach:w,detach:S}}function q(t){let e=document.createElement("span");return e.className="smartphoto-sr-only",e.textContent=t,e}function ce(){let t=document.createElement("button");return t.type="button",t}function Ne(t){return t.replace(/"/g,'\\"')}function Me({id:t,options:e},i,{signal:o}){let{classNames:r,message:s}=e,n=document.createElement("div");n.setAttribute("data-id",t);let c=document.createElement("dialog");c.className=r.smartPhoto,c.setAttribute("aria-labelledby",`smartphoto-${t}-title`),c.style.setProperty("--smartphoto-animation-speed",`${e.animationSpeed}ms`);let p=document.createElement("div");p.className=r.smartPhotoBody;let E=document.createElement("div");E.className=r.smartPhotoInner;let v=document.createElement("div");v.className=r.smartPhotoHeader;let x=document.createElement("span");x.className=r.smartPhotoCount;let b=document.createElement("h1");b.id=`smartphoto-${t}-title`,b.className=r.smartPhotoCaption,b.setAttribute("tabindex","-1");let I=document.createElement("button");I.className=r.smartPhotoDismiss,I.appendChild(q(s.closeDialog)),I.addEventListener("click",()=>i.onDismiss(),{signal:o}),v.append(x,b,I);let z=document.createElement("div");z.className=r.smartPhotoContent,z.addEventListener("click",d=>{d.target===z&&i.onBackdropClick()},{signal:o});let y=document.createElement("ul");y.className=r.smartPhotoList,y.setAttribute("role","region"),y.setAttribute("aria-roledescription","carousel"),y.setAttribute("aria-label",s.carouselLabel),y.setAttribute("aria-live","polite"),y.setAttribute("aria-atomic","false"),E.append(v,z,y);let Y=null,L=null,C=null;if(e.arrows){Y=document.createElement("ul"),Y.className=r.smartPhotoArrows,L=document.createElement("li"),L.className=r.smartPhotoArrowLeft;let d=ce();d.appendChild(q(s.gotoPrevImage)),d.addEventListener("click",()=>i.onPrev(),{signal:o}),L.appendChild(d),C=document.createElement("li"),C.className=r.smartPhotoArrowRight;let l=ce();l.appendChild(q(s.gotoNextImage)),l.addEventListener("click",()=>i.onNext(),{signal:o}),C.appendChild(l),Y.append(L,C),E.appendChild(Y)}let N=null,k=null;e.nav&&(N=document.createElement("nav"),N.className=r.smartPhotoNav,N.setAttribute("aria-label","Choose slide to display"),k=document.createElement("ul"),N.appendChild(k),E.appendChild(N)),p.appendChild(E),c.appendChild(p),n.appendChild(c);let u={dialog:c,count:x,caption:b,dismiss:I,content:z,list:y,arrows:Y,arrowLeft:L,arrowRight:C,nav:N,navList:k,slides:new Map,imgClone:null};function J(){let d=document.createElement("div");d.className=r.smartPhotoLoaderWrap;let l=document.createElement("span");return l.className=r.smartPhotoLoader,d.appendChild(l),d}function R(d){var g,w;let l=document.createElement("div");l.className=r.smartPhotoImgWrap;let P=document.createElement("img");return P.className=r.smartPhotoImg,P.src=(g=d.src)!=null?g:"",P.alt=(w=d.alt)!=null?w:"",P.addEventListener("dragstart",S=>S.preventDefault(),{signal:o}),l.appendChild(P),{imgWrap:l,img:P}}function G(d,l){var P;u.list.replaceChildren(),(P=u.navList)==null||P.replaceChildren(),u.slides=new Map,d.forEach(g=>{var a,h;let w=document.createElement("li");w.setAttribute("role","group"),w.setAttribute("aria-roledescription","slide"),w.setAttribute("aria-label",`${g.index+1} of ${d.length}`);let S={li:w,loaderWrap:null,imgWrap:null,img:null,navLink:null};if(g.processed){let{imgWrap:f,img:m}=R(g);w.appendChild(f),S.imgWrap=f,S.img=m}else{let f=J();w.appendChild(f),S.loaderWrap=f}if(u.list.appendChild(w),u.slides.set(g,S),u.navList){let f=document.createElement("li"),m=ce();m.style.backgroundImage=`url("${Ne((a=g.thumb)!=null?a:"")}")`;let T=g.index;m.addEventListener("click",()=>i.onNavigate(T),{signal:o}),m.appendChild(q(`go to ${(h=g.caption)!=null?h:""}`)),f.appendChild(m),u.navList.appendChild(f),S.navLink=m}}),U(l)}function K(d,l){var w;if(l.imgWrap||!d.processed)return l;let{imgWrap:P,img:g}=R(d);return(w=l.loaderWrap)==null||w.replaceWith(P),l.loaderWrap=null,l.imgWrap=P,l.img=g,l}function B(d){d&&document.activeElement&&d.contains(document.activeElement)&&u.caption.focus()}function U(d){let{viewer:l}=d;u.count.textContent=`${l.currentIndex+1}/${l.total}`,u.slides.forEach((P,g)=>{var a;let w=K(g,P),S=g.index===l.currentIndex;w.li.style.transform=`translate(${g.translateX}px,${g.translateY}px)`,w.li.classList.toggle("current",S),S?w.li.removeAttribute("aria-hidden"):w.li.setAttribute("aria-hidden","true"),S&&(u.caption.textContent=(a=g.caption)!=null?a:""),w.imgWrap&&w.img&&(w.imgWrap.style.transform=`translate(${g.x}px,${g.y}px) scale(${g.scale})`,w.img.style.width=`${g.width}px`,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"))}),u.arrowLeft&&(l.showPrevArrow?u.arrowLeft.removeAttribute("aria-hidden"):(B(u.arrowLeft),u.arrowLeft.setAttribute("aria-hidden","true"))),u.arrowRight&&(l.showNextArrow?u.arrowRight.removeAttribute("aria-hidden"):(B(u.arrowRight),u.arrowRight.setAttribute("aria-hidden","true"))),u.arrows&&(l.hideUi&&B(u.arrows),u.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false")),u.nav&&(l.hideUi&&B(u.nav),u.nav.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function _(d){for(let[l,P]of u.slides)if(l.index===d.viewer.currentIndex)return P;return null}function Z(d){let{viewer:l}=d,P=_(d),g=P==null?void 0:P.img;g&&(g.style.transform=`translate(${l.photoPosX}px,${l.photoPosY}px) scale(${l.scaleSize})`,g.classList.toggle(r.smartPhotoImgOnMove,l.scale),g.classList.toggle(r.smartPhotoImgElasticMove,l.elastic)),u.nav&&(l.hideUi&&B(u.nav),u.nav.setAttribute("aria-hidden",l.hideUi?"true":"false")),u.arrows&&(l.hideUi&&B(u.arrows),u.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function ee(d){let{viewer:l}=d;u.list.style.transform=`translate(${l.translateX}px,${l.translateY}px)`,u.list.classList.toggle(r.smartPhotoListOnMove,l.onMove)}function te(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),u.imgClone=l}function ie(){var d;(d=u.imgClone)==null||d.remove(),u.imgClone=null}function oe(){n.remove()}return{root:n,refs:u,render:U,syncSlides:G,updatePhotoTransform:Z,updateListTransform:ee,showAppearEffect:te,removeAppearEffect:ie,destroy:oe}}function O(){return document.documentElement.clientWidth}function D(){var t,e;return(e=(t=window.visualViewport)==null?void 0:t.height)!=null?e:document.documentElement.clientHeight}function Be(t){return t.length>0&&t[0]instanceof Element}function De(){return(Date.now().toString(36)+Math.random().toString(36).substring(2,7)).toUpperCase()}function ze(){return{x:window.pageXOffset!==void 0?window.pageXOffset:document.documentElement.scrollLeft,y:window.pageYOffset!==void 0?window.pageYOffset:document.documentElement.scrollTop}}var F=class{constructor(e,i){this.id=De();this.abortController=new AbortController;this.isSmartPhoneFlag=j();this.lastTriggerElement=null;this.isFiringPublicCloseEvent=!1;this.finishHideEffect=null;this.timeouts=[];this.loadAllFired=new Set;this.syncedGroupId=null;this.updateViewportHeight=()=>{this.view.refs.dialog.style.setProperty("--smartphoto-vh",`${D()}px`)};this.handleResize=()=>{H(this.state)&&(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(!H(this.state))return;this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit();let e=O(),i=500,o=r=>{this.scheduleTimeout(()=>{e!==O()?(this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit()):r<=i&&o(r+25)},25)};o(0)};this.state=Pe(i!=null?i:{}),this.view=Me({id:this.id,options:this.state.options},this.buildViewHandlers(),{signal:this.abortController.signal}),document.body.appendChild(this.view.root),this.gestures=He({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}),this.ingestSource(e),this.syncCurrentGroupView();let o=this.restoreFromHash();if(o&&(o.element?ne(o.element,"click"):this.openPhoto(o,null)),this.updateViewportHeight(),window.visualViewport?window.visualViewport.addEventListener("resize",this.updateViewportHeight,{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.gestures.detach(),this.view.destroy()}[Symbol.dispose](){this.destroy()}gotoSlide(e){this.state.viewer.currentIndex=Number.parseInt(String(e),10),this.state.viewer.currentIndex||(this.state.viewer.currentIndex=0),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=ze();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=M(this.state);e&&(this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=W(e,O(),D(),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.scale=!0,this.view.updatePhotoTransform(this.state),this.fireEvent("zoomin")},300)))}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,E,v;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(x=>x.id===e);if(!s)return;let n=document.activeElement instanceof HTMLElement?document.activeElement:null,c=(v=(E=i.trigger)!=null?E:s.element)!=null?v:n;this.openPhoto(s,c)}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 Element?this.addElementItem(e):this.addSlideItem(e);return this.syncCurrentGroupView(),i}get currentIndex(){return this.state.viewer.currentIndex}ingestSource(e){if(Array.isArray(e)&&!Be(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=ae(e),o=(n=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?n:0,r=be(e,this.state.options,o,O());return he(this.state,r),this.loadAllFired.delete(i),this.bindThumbnailClick(e,r),r}addSlideItem(e){var s,n;let i=le(e),o=(n=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?n:0,r=ye(e,o,O());return he(this.state,r),this.loadAllFired.delete(i),r}bindThumbnailClick(e,i){e.addEventListener("click",o=>{o.preventDefault(),this.openPhoto(i,e)},{signal:this.abortController.signal})}syncCurrentGroupView(){let e=H(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=ze();this.setHash(Le(this.state)),window.scroll(e.x,e.y)}restoreFromHash(){let e=location.hash.substring(1);return e?Ce(this.state,we(e)):null}setPosByCurrentIndex(){let e=M(this.state);e&&(this.state.viewer.translateX=-e.translateX,this.state.viewer.translateY=0,this.view.updateListTransform(this.state))}setSizeByScreen(){let e=H(this.state);e&&Ie(e,O(),D(),this.state.options.headerHeight,this.state.options.footerHeight)}resetTranslateCurrent(){Se(H(this.state),O())}currentImgElement(){for(let[e,i]of this.view.refs.slides)if(e.index===this.state.viewer.currentIndex)return i.img;return null}syncDialog(){let{dialog:e,caption:i}=this.view.refs;this.state.viewer.isOpen&&!e.open?(e.showModal(),i.focus()):!this.state.viewer.isOpen&&e.open&&e.close()}commit(){this.view.render(this.state),this.syncDialog()}initPhoto(){var i;(i=this.finishHideEffect)==null||i.call(this),this.view.refs.dialog.style.opacity="";let e=H(this.state);if(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(),ue(this.state),this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag){let o=M(this.state);this.state.viewer.scale=!0,this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=W(o,O(),D(),this.isSmartPhoneFlag)}}supportsViewTransition(){return typeof document.startViewTransition=="function"}openPhotoWithViewTransition(e){var n,c;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=()=>{o&&(o.style.viewTransitionName="");let p=this.currentImgElement();p&&(p.style.viewTransitionName="")},s=(c=document.startViewTransition)==null?void 0:c.call(document,()=>{this.initPhoto(),this.state.viewer.appear=!0,this.commit(),o&&(o.style.viewTransitionName=""),this.currentImgElement().style.viewTransitionName=i});s==null||s.ready.catch(()=>{r()}),s==null||s.finished.then(r,r)}addAppearEffect(e,i){var z;let o=(z=e==null?void 0:e.querySelector("img"))!=null?z:null;if(!o){this.state.viewer.appear=!0;return}let r=ge(o),s=o.offsetWidth,n=o.offsetHeight,c=O(),p=D(),E=p-this.state.options.headerHeight-this.state.options.footerHeight,v=1;this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag?s>n?v=p/n:v=c/s:(s>=n?i.height<E?v=i.width/s:v=E/n:i.height<E?v=i.height/n:v=E/n,s*v>c&&(v=c/s));let x=(v-1)/2*s+(c-s*v)/2,b=(v-1)/2*n+(p-n*v)/2,I=o.getAttribute(this.state.options.lazyAttribute);this.state.viewer.appearEffect={width:s,height:n,top:r.top,left:r.left,once:!0,img:I||i.src||"",afterX:x,afterY:b,scale:v}}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=O(),i=D();requestAnimationFrame(()=>{this.state.viewer.isOpen&&(O()===e&&D()===i||(this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.view.render(this.state)))})}openPhoto(e,i){this.lastTriggerElement=i,this.state.viewer.currentGroup=e.groupId,this.state.viewer.currentIndex=e.index,this.syncedGroupId!==e.groupId&&this.syncCurrentGroupView(),this.setHashByCurrentIndex(),e.loaded?this.doOpen(i,e):this.loadItem(e).then(()=>{this.doOpen(i,e)})}doHideEffect(e){return new Promise(i=>{let o=this.view.refs.dialog,r=this.currentImgElement(),s=D(),n=e==="top"?`translateY(-${s}px)`:`translateY(${s}px)`,c=()=>{this.finishHideEffect===c&&(this.finishHideEffect=null,o.removeEventListener("transitionend",c,!0),r&&r.style.transform===n&&(r.style.transform=""),i())};this.finishHideEffect=c,r&&(r.style.transform=n),o.addEventListener("transitionend",c,!0),this.scheduleTimeout(c,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=H(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.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.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.scheduleTimeout(()=>{let e=M(this.state);this.state.viewer.onMove=!1,ue(this.state),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.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}fireEvent(e){ne(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:()=>this.zoomPhoto(),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 Oe=F;var me=t=>{t.fn.SmartPhoto=function(e){return typeof e=="string"||new Oe(this,e),this}};if(typeof define=="function"&&define.amd)define(["jquery"],me);else{let t=window,e=t.jQuery?t.jQuery:t.$;typeof e!="undefined"&&me(e)}var Je=me;})();
|
|
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};function ye(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]=ye((i=t[s])!=null?i:{},n):t[s]=n}}}return t}var be=ye,Se=(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)},xe=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},Ie=t=>({left:t.getBoundingClientRect().left,top:t.getBoundingClientRect().top});var Ge={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,swipeTopToClose:!1,swipeBottomToClose:!0,swipeOffset:100,swipeVelocity:.5,headerHeight:60,footerHeight:60,forceInterval:10,registance:.5,loadOffset:2,resizeStyle:"fit",lazyAttribute:"data-src",animationSpeed:450};function Le(t){return Object.keys(t).forEach(e=>{let i=t[e];i&&typeof i=="object"&&!Object.isFrozen(i)&&Le(i)}),Object.freeze(t)}function Ce(t){return{options:Le(be({},Ge,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 q(t){return t.getAttribute("data-group")||"nogroup"}function de(t){return t.group||"nogroup"}function ce(t,e,i,o){let r=q(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 Te(t,e,i){var u,v,P,b,S;let o=de(t),r=t.src,s=(u=t.thumb)!=null?u:r,n=(v=t.caption)!=null?v: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:(S=t.id)!=null?S:e,loaded:p,processed:!1,element:null}}function me(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 H(t){var e;return t.viewer.currentGroup===null?null:(e=t.groups.get(t.viewer.currentGroup))!=null?e:null}function z(t){var i;let e=H(t);return e&&(i=e[t.viewer.currentIndex])!=null?i:null}function pe(t){let e=H(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 fe(t,e){t.forEach((i,o)=>{i.translateX=e*o})}function Z(t,e){let i=10**e;return Math.round(t*i)/i}function Q(t,e,i,o){return o?t.width>t.height?i/(t.height*t.scale):e/(t.width*t.scale):1/t.scale}function Ae(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:Z(n,6)*e.scaleSize,minY:Z(m,6)*e.scaleSize,maxX:Z(p,6)*e.scaleSize,maxY:Z(u,6)*e.scaleSize}}function Me(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 He(t){let e=z(t);return e?`group=${t.viewer.currentGroup}&photo=${e.id}`:""}function ze(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 ve(t,e){let i=10**e;return Math.round(t*i)/i}function R(t){return{x:t.pageX,y:t.pageY}}function Oe(t,e){let i=t.x-e.x,o=t.y-e.y;return Math.sqrt(i*i+o*o)}var ke=10;function Fe(t,e){return{force:Math.sqrt(t*t+e*e),theta:Math.atan2(e,t)}}function De(){return{width:document.documentElement.clientWidth,height:document.documentElement.clientHeight}}function Be({state:t,callbacks:e},{signal:i}){let o=new Map,r=Date.now(),s=!1,n=!1,m=null,p=null,u=null,v=0,P=!1,b=null,S=null,O=0,D=0,M=!1,V=0,x=null,C=0,B=0;function d(){return K()}function W(a){let{width:h,height:E}=De();return Ae(a,t.viewer,h,E)}function U(a){let{width:h,height:E}=De();return Q(a,h,E,d())}function te(a,h){let E=z(t),g=W(E);t.viewer.elastic=!0,a===1?t.viewer.photoPosX=g.minX:a===-1&&(t.viewer.photoPosX=g.maxX),h===1?t.viewer.photoPosY=g.minY:h===-1&&(t.viewer.photoPosY=g.maxY),e.onPhotoDragMove(),setTimeout(()=>{t.viewer.elastic=!1,e.onPhotoDragMove()},300)}let ie=setInterval(()=>{if(M||s||P||t.viewer.elastic||!t.viewer.scale)return;t.viewer.photoPosX+=C,t.viewer.photoPosY+=B;let a=z(t);if(!a)return;let h=W(a);t.viewer.photoPosX<h.minX?(t.viewer.photoPosX=h.minX,C*=-.2):t.viewer.photoPosX>h.maxX&&(t.viewer.photoPosX=h.maxX,C*=-.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 E=Fe(C,B),g=E.force-t.options.registance;Math.abs(g)<.5||(C=Math.cos(E.theta)*g,B=Math.sin(E.theta)*g,e.onPhotoDragMove())},t.options.forceInterval);function X(a,h){(a>5||a<-5)&&(C+=a*.05),t.options.verticalGravity&&(h>5||h<-5)&&(B+=h*.05)}function J(a){if(!(a!=null&&a.gamma)||t.viewer.appearEffect||M||s||P||t.viewer.elastic||!t.viewer.scale)return;let{orientation:h}=window;h===0?X(a.gamma,a.beta):h===90?X(a.beta,a.gamma):h===-90?X(-a.beta,-a.gamma):h===180&&X(-a.gamma,-a.beta)}t.options.useOrientationApi&&window.addEventListener("deviceorientation",J,{signal:i});function oe(){M=!0,s=!1,P=!1;let a=Array.from(o.values());V=Oe(a[0],a[1]),t.viewer.scale=!0,e.onGestureStart()}function re(a){let h=R(a);s=!0,n=!0,m=h,p=h,v=Date.now()}function ne(a){P=!0;let h=R(a);S=h,b=h}function se(a){var h,E;try{(E=(h=a.currentTarget).setPointerCapture)==null||E.call(h,a.pointerId)}catch(g){}if(o.set(a.pointerId,R(a)),o.size>1){oe();return}if(t.viewer.scale){ne(a);return}re(a)}function ae(){x===null&&(x=requestAnimationFrame(()=>{x=null,e.onGestureMove()}))}function le(){x!==null&&(cancelAnimationFrame(x),x=null,e.onGestureMove())}function c(){let a=Array.from(o.values()),h=Oe(a[0],a[1]),E=(h-V)/100,g=t.viewer.scaleSize,L=t.viewer.photoPosX,T=t.viewer.photoPosY;t.viewer.scaleSize+=ve(E,6),t.viewer.scaleSize<.2&&(t.viewer.scaleSize=.2),t.viewer.scaleSize<g&&(t.viewer.photoPosX=(1+t.viewer.scaleSize-g)*L,t.viewer.photoPosY=(1+t.viewer.scaleSize-g)*T);let Y=z(t);if(Y){let he=U(Y);t.viewer.hideUi=t.viewer.scaleSize<1||t.viewer.scaleSize>he}V=h,ae()}function l(a){let h=R(a),E=h.x-p.x,g=h.y-m.y;n&&(e.onSwipeStart(),n=!1,u=Math.abs(E)>Math.abs(g)?"horizontal":"vertical"),u==="horizontal"?t.viewer.translateX+=E:t.viewer.translateY=g,p=h,e.onSwipeMove()}function y(a){let h=R(a),E=h.x-S.x,g=h.y-S.y,L=ve(t.viewer.scaleSize*E,6),T=ve(t.viewer.scaleSize*g,6);t.viewer.photoPosX+=L,O=L,t.viewer.photoPosY+=T,D=T,S=h,e.onPhotoDragMove()}function w(a){if(o.has(a.pointerId)){if(o.set(a.pointerId,R(a)),M){c();return}if(P){y(a);return}l(a)}}function f(){M=!1,le();let a=z(t);if(!a)return;let h=U(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 I(){var Ee;s=!1;let a=m,h=p,E=Date.now(),g=r-E,L=h.x-a.x,T=h.y-a.y,Y=L===0&&T===0;if(!d()&&Y){e.onTap();return}if(Math.abs(g)<=500&&Y){e.onTap();return}r=E;let he=(Ee=H(t))!=null?Ee:[];if(u==="horizontal"){let $="stay",Ve=Math.max(E-v,1),Pe=Math.abs(L)>=ke&&Math.abs(L)/Ve>=t.options.swipeVelocity;(L>=t.options.swipeOffset||Pe&&L>0)&&t.viewer.currentIndex!==0?$="prev":(L<=-t.options.swipeOffset||Pe&&L<0)&&t.viewer.currentIndex!==he.length-1&&($="next"),e.onSwipeEnd($)}else{let $="stay";t.options.swipeBottomToClose&&T>=t.options.swipeOffset?$="close-bottom":t.options.swipeTopToClose&&T<=-t.options.swipeOffset&&($="close-top"),e.onSwipeEnd($)}}function F(){P=!1;let a=S,h=b;if(a.x===h.x){e.onPhotoDragEnd("zoom-out");return}let E=z(t);if(!E){e.onPhotoDragEnd(null);return}let g=W(E),L=t.options.swipeOffset*t.viewer.scaleSize,T=0,Y=0;if(t.viewer.photoPosX>g.maxX?T=-1:t.viewer.photoPosX<g.minX&&(T=1),t.viewer.photoPosY>g.maxY?Y=-1:t.viewer.photoPosY<g.minY&&(Y=1),t.viewer.photoPosX-g.maxX>L&&t.viewer.currentIndex!==0){e.onPhotoDragEnd("prev");return}if(g.minX-t.viewer.photoPosX>L&&t.viewer.currentIndex+1!==t.viewer.total){e.onPhotoDragEnd("next");return}T===0&&Y===0?(C=O/5,B=D/5):te(T,Y),e.onPhotoDragEnd(null)}function j(a){if(o.delete(a.pointerId),M){o.size<2&&f();return}if(P){F();return}s&&I()}function N(...a){for(let h of a)h.addEventListener("pointerdown",se,{signal:i}),h.addEventListener("pointermove",w,{signal:i}),h.addEventListener("pointerup",j,{signal:i}),h.addEventListener("pointercancel",j,{signal:i})}function G(){clearInterval(ie),x!==null&&(cancelAnimationFrame(x),x=null)}return{attach:N,detach:G}}function ee(t){let e=document.createElement("span");return e.className="smartphoto-sr-only",e.textContent=t,e}function we(){let t=document.createElement("button");return t.type="button",t}function $e(t){return t.replace(/"/g,'\\"')}function Xe({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.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 v=document.createElement("div");v.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 S=document.createElement("button");S.className=r.smartPhotoDismiss,S.appendChild(ee(s.closeDialog)),S.addEventListener("click",()=>i.onDismiss(),{signal:o}),v.append(P,b,S);let O=document.createElement("div");O.className=r.smartPhotoContent,O.addEventListener("click",c=>{c.target===O&&i.onBackdropClick()},{signal:o});let D=document.createElement("ul");D.className=r.smartPhotoList,D.setAttribute("role","region"),D.setAttribute("aria-roledescription","carousel"),D.setAttribute("aria-label",s.carouselLabel),D.setAttribute("aria-live","polite"),D.setAttribute("aria-atomic","false"),u.append(v,O,D);let M=null,V=null,x=null;if(e.arrows){M=document.createElement("ul"),M.className=r.smartPhotoArrows,V=document.createElement("li"),V.className=r.smartPhotoArrowLeft;let c=we();c.appendChild(ee(s.gotoPrevImage)),c.addEventListener("click",()=>i.onPrev(),{signal:o}),V.appendChild(c),x=document.createElement("li"),x.className=r.smartPhotoArrowRight;let l=we();l.appendChild(ee(s.gotoNextImage)),l.addEventListener("click",()=>i.onNext(),{signal:o}),x.appendChild(l),M.append(V,x),u.appendChild(M)}let C=null,B=null;e.nav&&(C=document.createElement("nav"),C.className=r.smartPhotoNav,C.setAttribute("aria-label","Choose slide to display"),B=document.createElement("ul"),C.appendChild(B),u.appendChild(C)),p.appendChild(u),m.appendChild(p),n.appendChild(m);let d={dialog:m,count:P,caption:b,dismiss:S,content:O,list:D,arrows:M,arrowLeft:V,arrowRight:x,nav:C,navList:B,slides:new Map,imgClone:null};function W(){let c=document.createElement("div");c.className=r.smartPhotoLoaderWrap;let l=document.createElement("span");return l.className=r.smartPhotoLoader,c.appendChild(l),c}function U(c){var w,f;let l=document.createElement("div");l.className=r.smartPhotoImgWrap;let y=document.createElement("img");return y.className=r.smartPhotoImg,y.src=(w=c.src)!=null?w:"",y.alt=(f=c.alt)!=null?f:"",y.addEventListener("dragstart",I=>I.preventDefault(),{signal:o}),l.appendChild(y),{imgWrap:l,img:y}}function te(c,l){var y;d.list.replaceChildren(),(y=d.navList)==null||y.replaceChildren(),d.slides=new Map,c.forEach(w=>{var F,j;let f=document.createElement("li");f.setAttribute("role","group"),f.setAttribute("aria-roledescription","slide"),f.setAttribute("aria-label",`${w.index+1} of ${c.length}`);let I={li:f,loaderWrap:null,imgWrap:null,img:null,navLink:null};if(w.processed){let{imgWrap:N,img:G}=U(w);f.appendChild(N),I.imgWrap=N,I.img=G}else{let N=W();f.appendChild(N),I.loaderWrap=N}if(d.list.appendChild(f),d.slides.set(w,I),d.navList){let N=document.createElement("li"),G=we();G.style.backgroundImage=`url("${$e((F=w.thumb)!=null?F:"")}")`;let a=w.index;G.addEventListener("click",()=>i.onNavigate(a),{signal:o}),G.appendChild(ee(`go to ${(j=w.caption)!=null?j:""}`)),N.appendChild(G),d.navList.appendChild(N),I.navLink=G}}),J(l)}function ie(c,l){var f;if(l.imgWrap||!c.processed)return l;let{imgWrap:y,img:w}=U(c);return(f=l.loaderWrap)==null||f.replaceWith(y),l.loaderWrap=null,l.imgWrap=y,l.img=w,l}function X(c){c&&document.activeElement&&c.contains(document.activeElement)&&d.caption.focus()}function J(c){let{viewer:l}=c;d.count.textContent=`${l.currentIndex+1}/${l.total}`,d.slides.forEach((y,w)=>{var F;let f=ie(w,y),I=w.index===l.currentIndex;f.li.style.transform=`translate(${w.translateX}px,${w.translateY}px)`,f.li.classList.toggle("current",I),I?f.li.removeAttribute("aria-hidden"):f.li.setAttribute("aria-hidden","true"),I&&(d.caption.textContent=(F=w.caption)!=null?F:""),f.imgWrap&&f.img&&(f.imgWrap.style.transform=`translate(${w.x}px,${w.y}px) scale(${w.scale})`,f.img.style.width=`${w.width}px`,f.img.classList.toggle("active",l.appear),f.img.classList.toggle(r.smartPhotoImgOnMove,l.scale),f.img.classList.toggle(r.smartPhotoImgElasticMove,l.elastic)),f.navLink&&(f.navLink.classList.toggle("current",I),I?f.navLink.setAttribute("aria-current","true"):f.navLink.removeAttribute("aria-current"))}),d.arrowLeft&&(l.showPrevArrow?d.arrowLeft.removeAttribute("aria-hidden"):(X(d.arrowLeft),d.arrowLeft.setAttribute("aria-hidden","true"))),d.arrowRight&&(l.showNextArrow?d.arrowRight.removeAttribute("aria-hidden"):(X(d.arrowRight),d.arrowRight.setAttribute("aria-hidden","true"))),d.arrows&&(l.hideUi&&X(d.arrows),d.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false")),d.nav&&(l.hideUi&&X(d.nav),d.nav.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function oe(c){for(let[l,y]of d.slides)if(l.index===c.viewer.currentIndex)return y;return null}function re(c){let{viewer:l}=c,y=oe(c),w=y==null?void 0:y.img;w&&(w.style.transform=`translate(${l.photoPosX}px,${l.photoPosY}px) scale(${l.scaleSize})`,w.classList.toggle(r.smartPhotoImgOnMove,l.scale),w.classList.toggle(r.smartPhotoImgElasticMove,l.elastic)),d.nav&&(l.hideUi&&X(d.nav),d.nav.setAttribute("aria-hidden",l.hideUi?"true":"false")),d.arrows&&(l.hideUi&&X(d.arrows),d.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function ne(c){let{viewer:l}=c;d.list.style.transform=`translate(${l.translateX}px,${l.translateY}px)`,d.list.classList.toggle(r.smartPhotoListOnMove,l.onMove)}function se(c){let l=document.createElement("img");l.className=r.smartPhotoImgClone,l.src=c.img,l.style.width=`${c.width}px`,l.style.height=`${c.height}px`,l.style.transform=`translate(${c.left}px,${c.top}px) scale(1)`,p.appendChild(l),d.imgClone=l}function ae(){var c;(c=d.imgClone)==null||c.remove(),d.imgClone=null}function le(){n.remove()}return{root:n,refs:d,render:J,syncSlides:te,updatePhotoTransform:re,updateListTransform:ne,showAppearEffect:se,removeAppearEffect:ae,destroy:le}}function A(){return document.documentElement.clientWidth}function k(){let t=window.visualViewport;return t?t.height*t.scale:document.documentElement.clientHeight}function Re(t){return t.length>0&&t[0]instanceof Element}function We(){return(Date.now().toString(36)+Math.random().toString(36).substring(2,7)).toUpperCase()}function Ne(){return{x:window.pageXOffset!==void 0?window.pageXOffset:document.documentElement.scrollLeft,y:window.pageYOffset!==void 0?window.pageYOffset:document.documentElement.scrollTop}}var _=class{constructor(e,i){this.id=We();this.abortController=new AbortController;this.isSmartPhoneFlag=K();this.lastTriggerElement=null;this.isFiringPublicCloseEvent=!1;this.finishHideEffect=null;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=q(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",`${k()}px`)};this.handleResize=()=>{H(this.state)&&(this.updateViewportHeight(),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(!H(this.state))return;this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit();let e=A(),i=500,o=r=>{this.scheduleTimeout(()=>{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=Ce(i!=null?i:{}),this.view=Xe({id:this.id,options:this.state.options},this.buildViewHandlers(),{signal:this.abortController.signal}),document.body.appendChild(this.view.root),this.gestures=Be({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(),window.visualViewport?window.visualViewport.addEventListener("resize",this.updateViewportHeight,{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){this.state.viewer.currentIndex=Number.parseInt(String(e),10),this.state.viewer.currentIndex||(this.state.viewer.currentIndex=0),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=Ne();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=z(this.state);e&&(this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=Q(e,A(),k(),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.scale=!0,this.view.updatePhotoTransform(this.state),this.fireEvent("zoomin")},300)))}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,v;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=(v=(u=i.trigger)!=null?u:s.element)!=null?v: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)&&!Re(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=q(e),o=(n=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?n:0,r=ce(e,this.state.options,o,A());return me(this.state,r),this.loadAllFired.delete(i),this.itemsByElement.set(e,r),r}addSlideItem(e){var s,n;let i=de(e),o=(n=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?n:0,r=Te(e,o,A());return me(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=>q(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,v)=>{let P=s.get(u);if(P)return P.index!==v&&(n=!0,P.index=v),P;n=!0;let b=ce(u,this.state.options,v,A());return this.itemsByElement.set(u,b),b});return r.forEach(u=>{u.element&&!o.has(u.element)&&this.itemsByElement.delete(u.element)}),fe(m,A()),this.state.groups.set(e,m),n&&this.loadAllFired.delete(e),n}syncCurrentGroupView(){let e=H(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=Ne();this.setHash(He(this.state)),window.scroll(e.x,e.y)}restoreFromHash(){let e=location.hash.substring(1);return e?ze(this.state,xe(e)):null}setPosByCurrentIndex(){let e=z(this.state);e&&(this.state.viewer.translateX=-e.translateX,this.state.viewer.translateY=0,this.view.updateListTransform(this.state))}setSizeByScreen(){let e=H(this.state);e&&Me(e,A(),k(),this.state.options.headerHeight,this.state.options.footerHeight)}resetTranslateCurrent(){fe(H(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}syncDialog(){let{dialog:e,caption:i}=this.view.refs;this.state.viewer.isOpen&&!e.open?(e.showModal(),i.focus()):!this.state.viewer.isOpen&&e.open&&e.close()}commit(){this.view.render(this.state),this.syncDialog()}initPhoto(){var i;(i=this.finishHideEffect)==null||i.call(this),this.view.refs.dialog.style.opacity="";let e=H(this.state);if(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(),pe(this.state),this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag){let o=z(this.state);this.state.viewer.scale=!0,this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=Q(o,A(),k(),this.isSmartPhoneFlag)}}supportsViewTransition(){return typeof document.startViewTransition=="function"}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=()=>{o&&(o.style.viewTransitionName="");let p=this.currentImgElement();p&&(p.style.viewTransitionName="")},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});s==null||s.ready.catch(()=>{r()}),s==null||s.finished.then(r,r)}addAppearEffect(e,i){var O;let o=(O=e==null?void 0:e.querySelector("img"))!=null?O:null;if(!o){this.state.viewer.appear=!0;return}let r=Ie(o),s=o.offsetWidth,n=o.offsetHeight,m=A(),p=k(),u=p-this.state.options.headerHeight-this.state.options.footerHeight,v=1;this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag?s>n?v=p/n:v=m/s:(s>=n?i.height<u?v=i.width/s:v=u/n:i.height<u?v=i.height/n:v=u/n,s*v>m&&(v=m/s));let P=(v-1)/2*s+(m-s*v)/2,b=(v-1)/2*n+(p-n*v)/2,S=o.getAttribute(this.state.options.lazyAttribute);this.state.viewer.appearEffect={width:s,height:n,top:r.top,left:r.left,once:!0,img:S||i.src||"",afterX:P,afterY:b,scale:v}}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=k();requestAnimationFrame(()=>{this.state.viewer.isOpen&&(A()===e&&k()===i||(this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.view.render(this.state)))})}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=>{let o=this.view.refs.dialog,r=this.currentImgElement(),s=k(),n=e==="top"?`translateY(-${s}px)`:`translateY(${s}px)`,m=()=>{this.finishHideEffect===m&&(this.finishHideEffect=null,o.removeEventListener("transitionend",m,!0),r&&r.style.transform===n&&(r.style.transform=""),i())};this.finishHideEffect=m,r&&(r.style.transform=n),o.addEventListener("transitionend",m,!0),this.scheduleTimeout(m,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=H(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.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=z(this.state);this.state.viewer.onMove=!1,pe(this.state),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.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}fireEvent(e){Se(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:()=>this.zoomPhoto(),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 Ye=_;var ge=t=>{t.fn.SmartPhoto=function(e){return typeof e=="string"||new Ye(this,e),this}};if(typeof define=="function"&&define.amd)define(["jquery"],ge);else{let t=window,e=t.jQuery?t.jQuery:t.$;typeof e!="undefined"&&ge(e)}var ot=ge;})();
|