smartphoto 2.1.7 → 2.1.9

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 CHANGED
@@ -397,6 +397,11 @@ photo.on('zoomout',function(){
397
397
  <td>header color</td>
398
398
  <td>rgba(0, 0, 0, .2)</td>
399
399
  </tr>
400
+ <tr>
401
+ <td>--smartphoto-arrow-top</td>
402
+ <td>vertical position of the prev/next arrows, e.g. move them off the image on narrow screens with a media query</td>
403
+ <td>50%</td>
404
+ </tr>
400
405
  </table>
401
406
 
402
407
  Set these on `.smartphoto` (or `:root`) to override the defaults, no rebuild required:
@@ -408,8 +413,16 @@ Set these on `.smartphoto` (or `:root`) to override the defaults, no rebuild req
408
413
  --smartphoto-backdrop-color: rgba(0, 0, 0, 0.9);
409
414
  --smartphoto-header-color: rgba(0, 0, 0, 0.4);
410
415
  }
416
+
417
+ @media (max-width: 480px) {
418
+ .smartphoto {
419
+ --smartphoto-arrow-top: 85%;
420
+ }
421
+ }
411
422
  ```
412
423
 
424
+ The bottom thumbnail nav (`.smartphoto-nav`) also reserves `env(safe-area-inset-bottom)` automatically so it isn't hidden behind the iOS home indicator/toolbar.
425
+
413
426
 
414
427
  ## Download
415
428
  [Download ZIP](https://github.com/appleple/SmartPhoto/archive/master.zip)
@@ -152,7 +152,7 @@ dialog.smartphoto:not([open]) {
152
152
 
153
153
  .smartphoto-count {
154
154
  display: inline-block;
155
- color: #fff;
155
+ color: var(--smartphoto-icon-color, #fff);
156
156
  font-size: 16px;
157
157
  }
158
158
 
@@ -189,11 +189,16 @@ dialog.smartphoto:not([open]) {
189
189
  height: 20px;
190
190
  padding: 0;
191
191
  border: none;
192
- background-color: transparent;
193
- background-image: url(data:image/svg+xml;base64,PHN2ZyBpZD0i44Os44Kk44Ok44O8XzEiIGRhdGEtbmFtZT0i44Os44Kk44Ok44O8IDEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDI4MzQuNjUgMjgzNC42NSIgZmlsbD0iI0ZGRiI+PHRpdGxlPmljb248L3RpdGxlPjxwYXRoIGQ9Ik0xNTc2LjQyLDE0MDYuNzYsMjc4NCwxOTkuMTlhNTYuODYsNTYuODYsMCwwLDAsMC04MC4xOGwtNzguOTItNzguOTJhNTYuODYsNTYuODYsMCwwLDAtODAuMTgsMEwxNDE3LjMyLDEyNDcuNjYsMjA5Ljc1LDQwLjA5YTU2Ljg2LDU2Ljg2LDAsMCwwLTgwLjE4LDBMNTAuNjUsMTE5YTU2Ljg2LDU2Ljg2LDAsMCwwLDAsODAuMThMMTI1OC4yMywxNDA2Ljc2LDUwLjY1LDI2MTQuMzRhNTYuODYsNTYuODYsMCwwLDAsMCw4MC4xOGw3OC45Miw3OC45MmE1Ni44Niw1Ni44NiwwLDAsMCw4MC4xOCwwTDE0MTcuMzIsMTU2NS44NiwyNjI0LjksMjc3My40NGE1Ni44Niw1Ni44NiwwLDAsMCw4MC4xOCwwbDc4LjkyLTc4LjkyYTU2Ljg2LDU2Ljg2LDAsMCwwLDAtODAuMThaIi8+PC9zdmc+);
194
- text-shadow: 0 1px 0 #fff;
195
- color: #fff;
196
- font-size: 30px;
192
+ /* アイコンは mask 化し、塗り色を --smartphoto-icon-color(自動算出される
193
+ * コントラストカラー、既定は白)で指定する。mask はアルファ形状のみを
194
+ * 使うため、元 SVG fill 値自体は見た目に影響しない */
195
+ background-color: var(--smartphoto-icon-color, #fff);
196
+ mask-image: url(data:image/svg+xml;base64,PHN2ZyBpZD0i44Os44Kk44Ok44O8XzEiIGRhdGEtbmFtZT0i44Os44Kk44Ok44O8IDEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDI4MzQuNjUgMjgzNC42NSIgZmlsbD0iI0ZGRiI+PHRpdGxlPmljb248L3RpdGxlPjxwYXRoIGQ9Ik0xNTc2LjQyLDE0MDYuNzYsMjc4NCwxOTkuMTlhNTYuODYsNTYuODYsMCwwLDAsMC04MC4xOGwtNzguOTItNzguOTJhNTYuODYsNTYuODYsMCwwLDAtODAuMTgsMEwxNDE3LjMyLDEyNDcuNjYsMjA5Ljc1LDQwLjA5YTU2Ljg2LDU2Ljg2LDAsMCwwLTgwLjE4LDBMNTAuNjUsMTE5YTU2Ljg2LDU2Ljg2LDAsMCwwLDAsODAuMThMMTI1OC4yMywxNDA2Ljc2LDUwLjY1LDI2MTQuMzRhNTYuODYsNTYuODYsMCwwLDAsMCw4MC4xOGw3OC45Miw3OC45MmE1Ni44Niw1Ni44NiwwLDAsMCw4MC4xOCwwTDE0MTcuMzIsMTU2NS44NiwyNjI0LjksMjc3My40NGE1Ni44Niw1Ni44NiwwLDAsMCw4MC4xOCwwbDc4LjkyLTc4LjkyYTU2Ljg2LDU2Ljg2LDAsMCwwLDAtODAuMThaIi8+PC9zdmc+);
197
+ -webkit-mask-image: url(data:image/svg+xml;base64,PHN2ZyBpZD0i44Os44Kk44Ok44O8XzEiIGRhdGEtbmFtZT0i44Os44Kk44Ok44O8IDEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDI4MzQuNjUgMjgzNC42NSIgZmlsbD0iI0ZGRiI+PHRpdGxlPmljb248L3RpdGxlPjxwYXRoIGQ9Ik0xNTc2LjQyLDE0MDYuNzYsMjc4NCwxOTkuMTlhNTYuODYsNTYuODYsMCwwLDAsMC04MC4xOGwtNzguOTItNzguOTJhNTYuODYsNTYuODYsMCwwLDAtODAuMTgsMEwxNDE3LjMyLDEyNDcuNjYsMjA5Ljc1LDQwLjA5YTU2Ljg2LDU2Ljg2LDAsMCwwLTgwLjE4LDBMNTAuNjUsMTE5YTU2Ljg2LDU2Ljg2LDAsMCwwLDAsODAuMThMMTI1OC4yMywxNDA2Ljc2LDUwLjY1LDI2MTQuMzRhNTYuODYsNTYuODYsMCwwLDAsMCw4MC4xOGw3OC45Miw3OC45MmE1Ni44Niw1Ni44NiwwLDAsMCw4MC4xOCwwTDE0MTcuMzIsMTU2NS44NiwyNjI0LjksMjc3My40NGE1Ni44Niw1Ni44NiwwLDAsMCw4MC4xOCwwbDc4LjkyLTc4LjkyYTU2Ljg2LDU2Ljg2LDAsMCwwLDAtODAuMThaIi8+PC9zdmc+);
198
+ mask-repeat: no-repeat;
199
+ -webkit-mask-repeat: no-repeat;
200
+ mask-size: contain;
201
+ -webkit-mask-size: contain;
197
202
  text-decoration: none;
198
203
  cursor: pointer;
199
204
  line-height: 1;
@@ -288,7 +293,7 @@ dialog.smartphoto:not([open]) {
288
293
  .smartphoto-arrows li {
289
294
  display: block;
290
295
  position: absolute;
291
- top: 50%;
296
+ top: var(--smartphoto-arrow-top, 50%);
292
297
  width: 30px;
293
298
  height: 30px;
294
299
  margin-top: -20px;
@@ -350,6 +355,10 @@ dialog.smartphoto:not([open]) {
350
355
  bottom: 0;
351
356
  left: 0;
352
357
  width: 100%;
358
+ /* iOS Safari 等ではホームインジケーター/ツールバーの分だけ底面が隠れる
359
+ * ため、その領域を避けてサムネイルを表示する(§Issue #96) */
360
+ padding-bottom: env(safe-area-inset-bottom, 0px);
361
+ box-sizing: border-box;
353
362
  opacity: 1;
354
363
  animation-name: smartphoto-appear;
355
364
  animation-duration: var(--smartphoto-animation-speed, 0.45s);
@@ -448,7 +457,7 @@ dialog.smartphoto:not([open]) {
448
457
  width: 100%;
449
458
  height: 50px;
450
459
  padding: 0 50px;
451
- color: #fff;
460
+ color: var(--smartphoto-icon-color, #fff);
452
461
  font-size: 12px;
453
462
  text-align: center;
454
463
  line-height: 50px;
@@ -1 +1 @@
1
- @keyframes smartphoto{0%{opacity:0}to{opacity:1}}@keyframes smartphoto-img-wrap{0%{opacity:0}to{opacity:1}}@keyframes smartphoto-inner{0%{transform:translateY(100px)}to{transform:translate(0)}}@keyframes smartphoto-loader{0%{opacity:.4;transform:rotate(0deg)}50%{opacity:1;transform:rotate(180deg)}to{opacity:.4;transform:rotate(1turn)}}@keyframes smartphoto-appear{0%{opacity:0}to{opacity:1}}@keyframes smartphoto-hide{0%{opacity:1}to{opacity:0}}:root:has(dialog.smartphoto[open]){overflow:hidden}.smartphoto{border:none;background:transparent;padding:0;margin:0;outline:none;position:fixed;inset:0;width:100%;height:100%;max-width:100%;max-height:100%;overflow:hidden;height:var(--smartphoto-vh,100dvh);max-height:var(--smartphoto-vh,100dvh);background-color:var(--smartphoto-backdrop-color,#000);opacity:1;font-family:sans-serif;cursor:pointer;transition:opacity var(--smartphoto-animation-speed,.45s) var(--smartphoto-animation-function,ease-out),display var(--smartphoto-animation-speed,.45s) var(--smartphoto-animation-function,ease-out) allow-discrete,overlay var(--smartphoto-animation-speed,.45s) var(--smartphoto-animation-function,ease-out) allow-discrete}.smartphoto:not([open]){opacity:0}dialog.smartphoto:not([open]){display:none!important}.smartphoto::backdrop{background-color:var(--smartphoto-backdrop-color,#000)}::view-transition-group(smartphoto-hero),::view-transition-new(smartphoto-hero),::view-transition-old(smartphoto-hero){animation-duration:var(--smartphoto-animation-speed,.45s);animation-timing-function:var(--smartphoto-animation-function,ease-out)}.smartphoto-close{opacity:0}.smartphoto-count{display:inline-block;color:#fff;font-size:16px}.smartphoto-header{display:block;box-sizing:border-box;position:fixed;z-index:102;top:0;left:0;width:100%;height:50px;padding:15px;background-color:var(--smartphoto-header-color,rgba(0,0,0,.2))}.smartphoto-content{display:block;position:absolute;top:0;left:0;width:100%;height:100%;touch-action:none}.smartphoto-dismiss{display:block;position:absolute;top:15px;right:10px;width:20px;height:20px;padding:0;border:none;background-color:transparent;background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9IiNmZmYiIGRhdGEtbmFtZT0i44Os44Kk44Ok44O8IDEiIHZpZXdCb3g9IjAgMCAyODM0LjY1IDI4MzQuNjUiPjx0aXRsZT5pY29uPC90aXRsZT48cGF0aCBkPSJNMTU3Ni40MiAxNDA2Ljc2IDI3ODQgMTk5LjE5YTU2Ljg2IDU2Ljg2IDAgMCAwIDAtODAuMThsLTc4LjkyLTc4LjkyYTU2Ljg2IDU2Ljg2IDAgMCAwLTgwLjE4IDBMMTQxNy4zMiAxMjQ3LjY2IDIwOS43NSA0MC4wOWE1Ni44NiA1Ni44NiAwIDAgMC04MC4xOCAwTDUwLjY1IDExOWE1Ni44NiA1Ni44NiAwIDAgMCAwIDgwLjE4bDEyMDcuNTggMTIwNy41OEw1MC42NSAyNjE0LjM0YTU2Ljg2IDU2Ljg2IDAgMCAwIDAgODAuMThsNzguOTIgNzguOTJhNTYuODYgNTYuODYgMCAwIDAgODAuMTggMGwxMjA3LjU3LTEyMDcuNThMMjYyNC45IDI3NzMuNDRhNTYuODYgNTYuODYgMCAwIDAgODAuMTggMGw3OC45Mi03OC45MmE1Ni44NiA1Ni44NiAwIDAgMCAwLTgwLjE4WiIvPjwvc3ZnPg==);text-shadow:0 1px 0 #fff;color:#fff;font-size:30px;text-decoration:none;cursor:pointer;line-height:1}.smartphoto-body{z-index:102;margin:0 auto}.smartphoto-body,.smartphoto-inner{position:relative;width:100%;height:100%}.smartphoto-inner{vertical-align:top}.smartphoto-img{display:none;max-width:none;width:auto;height:auto;cursor:zoom-in;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;transition:transform var(--smartphoto-animation-speed,.45s) var(--smartphoto-animation-function,ease-out);-webkit-user-drag:none}.smartphoto-img.active{display:block}.smartphoto-img-onmove{cursor:grab;cursor:-webkit-grab;transition:none}.smartphoto-img-elasticmove{transition:transform var(--smartphoto-animation-speed,.45s) var(--smartphoto-animation-function,ease-out)}.smartphoto-img-wrap{display:inline-block;opacity:1;touch-action:none;-webkit-transition:opacity var(--smartphoto-animation-speed,.45s) var(--smartphoto-animation-function,ease-out);-moz-transition:opacity var(--smartphoto-animation-speed,.45s) var(--smartphoto-animation-function,ease-out);-ms-transition:opacity var(--smartphoto-animation-speed,.45s) var(--smartphoto-animation-function,ease-out);-o-transition:opacity var(--smartphoto-animation-speed,.45s) var(--smartphoto-animation-function,ease-out);transition:opacity var(--smartphoto-animation-speed,.45s) var(--smartphoto-animation-function,ease-out);animation-name:smartphoto-img-wrap;animation-duration:var(--smartphoto-animation-speed,.45s);animation-timing-function:var(--smartphoto-animation-function,ease-out)}.smartphoto-img-left{transform:translateX(150%)!important}.smartphoto-img-right{transform:translateX(-150%)!important}.smartphoto-arrows{list-style-type:none;margin:0;padding:0;position:relative;z-index:1002;top:50%;left:0;opacity:1;animation-name:smartphoto-appear;animation-duration:var(--smartphoto-animation-speed,.45s);animation-timing-function:var(--smartphoto-animation-function,ease-out)}.smartphoto-arrows[aria-hidden=true]{animation-name:smartphoto-hide;display:none}.smartphoto-arrows li{display:block;position:absolute;top:50%;width:30px;height:30px;margin-top:-20px;box-sizing:content-box;animation-duration:var(--smartphoto-animation-speed,.45s);animation-timing-function:var(--smartphoto-animation-function,ease-out);animation-name:smartphoto-appear}.smartphoto-arrows li:focus{outline:none}.smartphoto-arrows [aria-hidden=true]{animation-name:smartphoto-hide;display:none}.smartphoto-arrows button{appearance:none;display:block;width:100%;height:100%;margin:0;padding:0;border:none;background-color:transparent;cursor:pointer}.smartphoto-arrow-right{right:0;padding:5px 0;background-color:rgba(0,0,0,.5)}.smartphoto-arrow-right button{background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9IiNmZmYiIGRhdGEtbmFtZT0i44Os44Kk44Ok44O8IDEiIHZpZXdCb3g9IjAgMCAyODM0LjY1IDI4MzQuNjUiPjx0aXRsZT5pY29uPC90aXRsZT48cGF0aCBkPSJNMTgzNy44OCAxNDE3LjMyIDY0My41OSAyMjNhNzIuMjEgNzIuMjEgMCAwIDEgMC0xMDEuODJMNzQzLjgyIDIxYTcyLjIxIDcyLjIxIDAgMCAxIDEwMS44MiAwbDEyNDUuMTkgMTI0NS4xOSAxMDAuMjMgMTAwLjIzYTcyLjIxIDcyLjIxIDAgMCAxIDAgMTAxLjgyTDg0NS42NCAyODEzLjY1YTcyLjIxIDcyLjIxIDAgMCAxLTEwMS44MiAwbC0xMDAuMjMtMTAwLjIzYTcyLjIxIDcyLjIxIDAgMCAxIDAtMTAxLjgyWiIvPjwvc3ZnPg==)}.smartphoto-arrow-left{left:0;padding:5px 0;background-color:rgba(0,0,0,.5)}.smartphoto-arrow-left button{background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9IiNmZmYiIGRhdGEtbmFtZT0i44Os44Kk44Ok44O8IDEiIHZpZXdCb3g9IjAgMCAyODM0LjY1IDI4MzQuNjUiPjx0aXRsZT5pY29uPC90aXRsZT48cGF0aCBkPSJNOTk2Ljc3IDE0MTcuMzIgMjE5MS4wNiAyMjNhNzIuMjEgNzIuMjEgMCAwIDAgMC0xMDEuODJMMjA5MC44MyAyMUE3Mi4yMSA3Mi4yMSAwIDAgMCAxOTg5IDIxTDc0My44MiAxMjY2LjE5bC0xMDAuMjMgMTAwLjIzYTcyLjIxIDcyLjIxIDAgMCAwIDAgMTAxLjgyTDE5ODkgMjgxMy42NWE3Mi4yMSA3Mi4yMSAwIDAgMCAxMDEuODIgMGwxMDAuMjMtMTAwLjIzYTcyLjIxIDcyLjIxIDAgMCAwIDAtMTAxLjgyWiIvPjwvc3ZnPg==)}.smartPhotoArrowHideIcon{display:none}.smartphoto-nav{position:absolute;bottom:0;left:0;width:100%;opacity:1;animation-name:smartphoto-appear;animation-duration:var(--smartphoto-animation-speed,.45s);animation-timing-function:var(--smartphoto-animation-function,ease-out)}.smartphoto-nav[aria-hidden=true]{animation-name:smartphoto-hide;display:none}.smartphoto-nav ul{display:block;overflow-x:auto;list-style:none;margin:0;padding:0;text-align:center;white-space:nowrap;-webkit-overflow-scrolling:touch}.smartphoto-nav li{display:inline-block;overflow:hidden;width:50px;height:50px}.smartphoto-nav button{appearance:none;display:block;width:100%;height:100%;margin:0;padding:0;border:none;background-color:#fff;background-position:50%;background-size:cover;opacity:.5;cursor:pointer}.smartphoto-nav button:focus{opacity:.8}.smartphoto-nav button.current{opacity:1}.smartphoto-nav img{width:auto;height:100%}.smartphoto-list{list-style-type:none;position:absolute;z-index:101;top:0;left:0;margin:0;padding:0;white-space:nowrap}.smartphoto-list li{display:block;position:absolute;top:0;left:0;width:100%;height:100%;transition:all var(--smartphoto-animation-speed,.45s) var(--smartphoto-animation-function,ease-out)}.smartphoto-list li:focus{outline:none}.smartphoto-list-onmove{transition:all .3s var(--smartphoto-animation-function,ease-out)}.smartphoto-caption{overflow:hidden;box-sizing:border-box;position:absolute;top:0;left:0;width:100%;height:50px;padding:0 50px;color:#fff;font-size:12px;text-align:center;line-height:50px;white-space:nowrap;text-overflow:ellipsis;margin:0;font-weight:400}.smartphoto-caption:focus{outline:none}.smartphoto-loader-wrap{display:block;position:relative;z-index:103;width:0;height:0;transform:translate(50vw,50vh);transform:translate(50vw,50dvh);transform:translate(50vw,calc(var(--smartphoto-vh, 100dvh)/2))}.smartphoto-loader{position:absolute;z-index:101;top:0;left:0;width:30px;height:30px;margin-top:-25px;margin-left:-25px;border:8px solid #17cddd;border-right-color:transparent;border-radius:50%;animation:smartphoto-loader .5s linear infinite}.smartphoto-img-clone{position:fixed;z-index:100;top:0;left:0;transition:all var(--smartphoto-animation-speed,.45s) var(--smartphoto-animation-function,ease-out)}.smartphoto-sr-only{overflow:hidden;position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;clip:rect(0,0,0,0)}
1
+ @keyframes smartphoto{0%{opacity:0}to{opacity:1}}@keyframes smartphoto-img-wrap{0%{opacity:0}to{opacity:1}}@keyframes smartphoto-inner{0%{transform:translateY(100px)}to{transform:translate(0)}}@keyframes smartphoto-loader{0%{opacity:.4;transform:rotate(0deg)}50%{opacity:1;transform:rotate(180deg)}to{opacity:.4;transform:rotate(1turn)}}@keyframes smartphoto-appear{0%{opacity:0}to{opacity:1}}@keyframes smartphoto-hide{0%{opacity:1}to{opacity:0}}:root:has(dialog.smartphoto[open]){overflow:hidden}.smartphoto{border:none;background:transparent;padding:0;margin:0;outline:none;position:fixed;inset:0;width:100%;height:100%;max-width:100%;max-height:100%;overflow:hidden;height:var(--smartphoto-vh,100dvh);max-height:var(--smartphoto-vh,100dvh);background-color:var(--smartphoto-backdrop-color,#000);opacity:1;font-family:sans-serif;cursor:pointer;transition:opacity var(--smartphoto-animation-speed,.45s) var(--smartphoto-animation-function,ease-out),display var(--smartphoto-animation-speed,.45s) var(--smartphoto-animation-function,ease-out) allow-discrete,overlay var(--smartphoto-animation-speed,.45s) var(--smartphoto-animation-function,ease-out) allow-discrete}.smartphoto:not([open]){opacity:0}dialog.smartphoto:not([open]){display:none!important}.smartphoto::backdrop{background-color:var(--smartphoto-backdrop-color,#000)}::view-transition-group(smartphoto-hero),::view-transition-new(smartphoto-hero),::view-transition-old(smartphoto-hero){animation-duration:var(--smartphoto-animation-speed,.45s);animation-timing-function:var(--smartphoto-animation-function,ease-out)}.smartphoto-close{opacity:0}.smartphoto-count{display:inline-block;color:var(--smartphoto-icon-color,#fff);font-size:16px}.smartphoto-header{display:block;box-sizing:border-box;position:fixed;z-index:102;top:0;left:0;width:100%;height:50px;padding:15px;background-color:var(--smartphoto-header-color,rgba(0,0,0,.2))}.smartphoto-content{display:block;position:absolute;top:0;left:0;width:100%;height:100%;touch-action:none}.smartphoto-dismiss{display:block;position:absolute;top:15px;right:10px;width:20px;height:20px;padding:0;border:none;background-color:var(--smartphoto-icon-color,#fff);mask-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9IiNmZmYiIGRhdGEtbmFtZT0i44Os44Kk44Ok44O8IDEiIHZpZXdCb3g9IjAgMCAyODM0LjY1IDI4MzQuNjUiPjx0aXRsZT5pY29uPC90aXRsZT48cGF0aCBkPSJNMTU3Ni40MiAxNDA2Ljc2IDI3ODQgMTk5LjE5YTU2Ljg2IDU2Ljg2IDAgMCAwIDAtODAuMThsLTc4LjkyLTc4LjkyYTU2Ljg2IDU2Ljg2IDAgMCAwLTgwLjE4IDBMMTQxNy4zMiAxMjQ3LjY2IDIwOS43NSA0MC4wOWE1Ni44NiA1Ni44NiAwIDAgMC04MC4xOCAwTDUwLjY1IDExOWE1Ni44NiA1Ni44NiAwIDAgMCAwIDgwLjE4bDEyMDcuNTggMTIwNy41OEw1MC42NSAyNjE0LjM0YTU2Ljg2IDU2Ljg2IDAgMCAwIDAgODAuMThsNzguOTIgNzguOTJhNTYuODYgNTYuODYgMCAwIDAgODAuMTggMGwxMjA3LjU3LTEyMDcuNThMMjYyNC45IDI3NzMuNDRhNTYuODYgNTYuODYgMCAwIDAgODAuMTggMGw3OC45Mi03OC45MmE1Ni44NiA1Ni44NiAwIDAgMCAwLTgwLjE4WiIvPjwvc3ZnPg==);-webkit-mask-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9IiNmZmYiIGRhdGEtbmFtZT0i44Os44Kk44Ok44O8IDEiIHZpZXdCb3g9IjAgMCAyODM0LjY1IDI4MzQuNjUiPjx0aXRsZT5pY29uPC90aXRsZT48cGF0aCBkPSJNMTU3Ni40MiAxNDA2Ljc2IDI3ODQgMTk5LjE5YTU2Ljg2IDU2Ljg2IDAgMCAwIDAtODAuMThsLTc4LjkyLTc4LjkyYTU2Ljg2IDU2Ljg2IDAgMCAwLTgwLjE4IDBMMTQxNy4zMiAxMjQ3LjY2IDIwOS43NSA0MC4wOWE1Ni44NiA1Ni44NiAwIDAgMC04MC4xOCAwTDUwLjY1IDExOWE1Ni44NiA1Ni44NiAwIDAgMCAwIDgwLjE4bDEyMDcuNTggMTIwNy41OEw1MC42NSAyNjE0LjM0YTU2Ljg2IDU2Ljg2IDAgMCAwIDAgODAuMThsNzguOTIgNzguOTJhNTYuODYgNTYuODYgMCAwIDAgODAuMTggMGwxMjA3LjU3LTEyMDcuNThMMjYyNC45IDI3NzMuNDRhNTYuODYgNTYuODYgMCAwIDAgODAuMTggMGw3OC45Mi03OC45MmE1Ni44NiA1Ni44NiAwIDAgMCAwLTgwLjE4WiIvPjwvc3ZnPg==);mask-repeat:no-repeat;-webkit-mask-repeat:no-repeat;mask-size:contain;-webkit-mask-size:contain;text-decoration:none;cursor:pointer;line-height:1}.smartphoto-body{z-index:102;margin:0 auto}.smartphoto-body,.smartphoto-inner{position:relative;width:100%;height:100%}.smartphoto-inner{vertical-align:top}.smartphoto-img{display:none;max-width:none;width:auto;height:auto;cursor:zoom-in;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;transition:transform var(--smartphoto-animation-speed,.45s) var(--smartphoto-animation-function,ease-out);-webkit-user-drag:none}.smartphoto-img.active{display:block}.smartphoto-img-onmove{cursor:grab;cursor:-webkit-grab;transition:none}.smartphoto-img-elasticmove{transition:transform var(--smartphoto-animation-speed,.45s) var(--smartphoto-animation-function,ease-out)}.smartphoto-img-wrap{display:inline-block;opacity:1;touch-action:none;-webkit-transition:opacity var(--smartphoto-animation-speed,.45s) var(--smartphoto-animation-function,ease-out);-moz-transition:opacity var(--smartphoto-animation-speed,.45s) var(--smartphoto-animation-function,ease-out);-ms-transition:opacity var(--smartphoto-animation-speed,.45s) var(--smartphoto-animation-function,ease-out);-o-transition:opacity var(--smartphoto-animation-speed,.45s) var(--smartphoto-animation-function,ease-out);transition:opacity var(--smartphoto-animation-speed,.45s) var(--smartphoto-animation-function,ease-out);animation-name:smartphoto-img-wrap;animation-duration:var(--smartphoto-animation-speed,.45s);animation-timing-function:var(--smartphoto-animation-function,ease-out)}.smartphoto-img-left{transform:translateX(150%)!important}.smartphoto-img-right{transform:translateX(-150%)!important}.smartphoto-arrows{list-style-type:none;margin:0;padding:0;position:relative;z-index:1002;top:50%;left:0;opacity:1;animation-name:smartphoto-appear;animation-duration:var(--smartphoto-animation-speed,.45s);animation-timing-function:var(--smartphoto-animation-function,ease-out)}.smartphoto-arrows[aria-hidden=true]{animation-name:smartphoto-hide;display:none}.smartphoto-arrows li{display:block;position:absolute;top:var(--smartphoto-arrow-top,50%);width:30px;height:30px;margin-top:-20px;box-sizing:content-box;animation-duration:var(--smartphoto-animation-speed,.45s);animation-timing-function:var(--smartphoto-animation-function,ease-out);animation-name:smartphoto-appear}.smartphoto-arrows li:focus{outline:none}.smartphoto-arrows [aria-hidden=true]{animation-name:smartphoto-hide;display:none}.smartphoto-arrows button{appearance:none;display:block;width:100%;height:100%;margin:0;padding:0;border:none;background-color:transparent;cursor:pointer}.smartphoto-arrow-right{right:0;padding:5px 0;background-color:rgba(0,0,0,.5)}.smartphoto-arrow-right button{background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9IiNmZmYiIGRhdGEtbmFtZT0i44Os44Kk44Ok44O8IDEiIHZpZXdCb3g9IjAgMCAyODM0LjY1IDI4MzQuNjUiPjx0aXRsZT5pY29uPC90aXRsZT48cGF0aCBkPSJNMTgzNy44OCAxNDE3LjMyIDY0My41OSAyMjNhNzIuMjEgNzIuMjEgMCAwIDEgMC0xMDEuODJMNzQzLjgyIDIxYTcyLjIxIDcyLjIxIDAgMCAxIDEwMS44MiAwbDEyNDUuMTkgMTI0NS4xOSAxMDAuMjMgMTAwLjIzYTcyLjIxIDcyLjIxIDAgMCAxIDAgMTAxLjgyTDg0NS42NCAyODEzLjY1YTcyLjIxIDcyLjIxIDAgMCAxLTEwMS44MiAwbC0xMDAuMjMtMTAwLjIzYTcyLjIxIDcyLjIxIDAgMCAxIDAtMTAxLjgyWiIvPjwvc3ZnPg==)}.smartphoto-arrow-left{left:0;padding:5px 0;background-color:rgba(0,0,0,.5)}.smartphoto-arrow-left button{background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9IiNmZmYiIGRhdGEtbmFtZT0i44Os44Kk44Ok44O8IDEiIHZpZXdCb3g9IjAgMCAyODM0LjY1IDI4MzQuNjUiPjx0aXRsZT5pY29uPC90aXRsZT48cGF0aCBkPSJNOTk2Ljc3IDE0MTcuMzIgMjE5MS4wNiAyMjNhNzIuMjEgNzIuMjEgMCAwIDAgMC0xMDEuODJMMjA5MC44MyAyMUE3Mi4yMSA3Mi4yMSAwIDAgMCAxOTg5IDIxTDc0My44MiAxMjY2LjE5bC0xMDAuMjMgMTAwLjIzYTcyLjIxIDcyLjIxIDAgMCAwIDAgMTAxLjgyTDE5ODkgMjgxMy42NWE3Mi4yMSA3Mi4yMSAwIDAgMCAxMDEuODIgMGwxMDAuMjMtMTAwLjIzYTcyLjIxIDcyLjIxIDAgMCAwIDAtMTAxLjgyWiIvPjwvc3ZnPg==)}.smartPhotoArrowHideIcon{display:none}.smartphoto-nav{position:absolute;bottom:0;left:0;width:100%;padding-bottom:env(safe-area-inset-bottom,0);box-sizing:border-box;opacity:1;animation-name:smartphoto-appear;animation-duration:var(--smartphoto-animation-speed,.45s);animation-timing-function:var(--smartphoto-animation-function,ease-out)}.smartphoto-nav[aria-hidden=true]{animation-name:smartphoto-hide;display:none}.smartphoto-nav ul{display:block;overflow-x:auto;list-style:none;margin:0;padding:0;text-align:center;white-space:nowrap;-webkit-overflow-scrolling:touch}.smartphoto-nav li{display:inline-block;overflow:hidden;width:50px;height:50px}.smartphoto-nav button{appearance:none;display:block;width:100%;height:100%;margin:0;padding:0;border:none;background-color:#fff;background-position:50%;background-size:cover;opacity:.5;cursor:pointer}.smartphoto-nav button:focus{opacity:.8}.smartphoto-nav button.current{opacity:1}.smartphoto-nav img{width:auto;height:100%}.smartphoto-list{list-style-type:none;position:absolute;z-index:101;top:0;left:0;margin:0;padding:0;white-space:nowrap}.smartphoto-list li{display:block;position:absolute;top:0;left:0;width:100%;height:100%;transition:all var(--smartphoto-animation-speed,.45s) var(--smartphoto-animation-function,ease-out)}.smartphoto-list li:focus{outline:none}.smartphoto-list-onmove{transition:all .3s var(--smartphoto-animation-function,ease-out)}.smartphoto-caption{overflow:hidden;box-sizing:border-box;position:absolute;top:0;left:0;width:100%;height:50px;padding:0 50px;color:var(--smartphoto-icon-color,#fff);font-size:12px;text-align:center;line-height:50px;white-space:nowrap;text-overflow:ellipsis;margin:0;font-weight:400}.smartphoto-caption:focus{outline:none}.smartphoto-loader-wrap{display:block;position:relative;z-index:103;width:0;height:0;transform:translate(50vw,50vh);transform:translate(50vw,50dvh);transform:translate(50vw,calc(var(--smartphoto-vh, 100dvh)/2))}.smartphoto-loader{position:absolute;z-index:101;top:0;left:0;width:30px;height:30px;margin-top:-25px;margin-left:-25px;border:8px solid #17cddd;border-right-color:transparent;border-radius:50%;animation:smartphoto-loader .5s linear infinite}.smartphoto-img-clone{position:fixed;z-index:100;top:0;left:0;transition:all var(--smartphoto-animation-speed,.45s) var(--smartphoto-animation-function,ease-out)}.smartphoto-sr-only{overflow:hidden;position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;clip:rect(0,0,0,0)}
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * SmartPhoto v2.1.7
2
+ * SmartPhoto v2.1.9
3
3
  * (c) appleple
4
4
  * Released under the MIT License.
5
5
  */
@@ -61,6 +61,41 @@
61
61
  top: element.getBoundingClientRect().top
62
62
  };
63
63
  };
64
+ var parseRgb = (value) => {
65
+ const match = value.match(
66
+ /rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*[\d.]+\s*)?\)/
67
+ );
68
+ if (!match) {
69
+ return null;
70
+ }
71
+ return [Number(match[1]), Number(match[2]), Number(match[3])];
72
+ };
73
+ var CONTRAST_LUMINANCE_THRESHOLD = 0.179;
74
+ var relativeLuminance = ([r, g, b]) => {
75
+ const [rl, gl, bl] = [r, g, b].map((c) => {
76
+ const v = c / 255;
77
+ return v <= 0.03928 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4;
78
+ });
79
+ return 0.2126 * rl + 0.7152 * gl + 0.0722 * bl;
80
+ };
81
+ var getContrastColor = (colorValue) => {
82
+ const trimmed = colorValue.trim();
83
+ let rgb = parseRgb(trimmed);
84
+ if (!rgb) {
85
+ const probe = document.createElement("div");
86
+ probe.style.color = trimmed;
87
+ if (!probe.style.color) {
88
+ return "#fff";
89
+ }
90
+ document.body.appendChild(probe);
91
+ rgb = parseRgb(getComputedStyle(probe).color);
92
+ document.body.removeChild(probe);
93
+ }
94
+ if (!rgb) {
95
+ return "#fff";
96
+ }
97
+ return relativeLuminance(rgb) > CONTRAST_LUMINANCE_THRESHOLD ? "#000" : "#fff";
98
+ };
64
99
 
65
100
  // src/core/state.ts
66
101
  var defaults = {
@@ -1182,13 +1217,28 @@
1182
1217
  this.openPhoto(item, matched);
1183
1218
  }
1184
1219
  };
1185
- // ---- 内部: window イベント ----
1186
1220
  this.updateViewportHeight = () => {
1187
1221
  this.view.refs.dialog.style.setProperty(
1188
1222
  "--smartphoto-vh",
1189
1223
  `${getWindowHeight()}px`
1190
1224
  );
1191
1225
  };
1226
+ // iOS Safari 等ではアドレスバーの表示/非表示に伴う visualViewport の変化が
1227
+ // orientationchange を伴わず resize としてのみ発火する。スマートフォンでは
1228
+ // window の resize を購読していない(§コンストラクタ)ため、ここで拾わないと
1229
+ // 開いている間ずっと古い高さで計算された item.x/y がインラインスタイルに
1230
+ // 残り続け、表示中のスライドだけ位置がずれて見える(§Issue #95: スワイプ
1231
+ // ダウンで閉じて再度開いた際、閉じた瞬間表示していたスライドだけ縦位置がずれる)
1232
+ this.handleVisualViewportResize = () => {
1233
+ this.updateViewportHeight();
1234
+ if (!this.isSmartPhoneFlag || !this.state.viewer.isOpen || !currentItems(this.state)) {
1235
+ return;
1236
+ }
1237
+ this.resetTranslateCurrent();
1238
+ this.setPosByCurrentIndex();
1239
+ this.setSizeByScreen();
1240
+ this.commit();
1241
+ };
1192
1242
  this.handleResize = () => {
1193
1243
  if (!currentItems(this.state)) {
1194
1244
  return;
@@ -1272,10 +1322,11 @@
1272
1322
  this.openPhoto(restored, restored.element);
1273
1323
  }
1274
1324
  this.updateViewportHeight();
1325
+ this.applyAutoIconContrast();
1275
1326
  if (window.visualViewport) {
1276
1327
  window.visualViewport.addEventListener(
1277
1328
  "resize",
1278
- this.updateViewportHeight,
1329
+ this.handleVisualViewportResize,
1279
1330
  { signal: this.abortController.signal }
1280
1331
  );
1281
1332
  } else {
@@ -1626,6 +1677,7 @@
1626
1677
  initPhoto() {
1627
1678
  var _a;
1628
1679
  (_a = this.finishHideEffect) == null ? void 0 : _a.call(this);
1680
+ this.updateViewportHeight();
1629
1681
  this.view.refs.dialog.style.opacity = "";
1630
1682
  const items = currentItems(this.state);
1631
1683
  this.state.viewer.total = items.length;
@@ -1926,6 +1978,30 @@
1926
1978
  this.timeouts.push(id);
1927
1979
  return id;
1928
1980
  }
1981
+ // ---- 内部: window イベント ----
1982
+ // --smartphoto-backdrop-color をホスト側 CSS が明示指定している場合のみ、
1983
+ // その背景色に対してコントラストの高い文字色/アイコン色(#000 or #fff)を
1984
+ // --smartphoto-icon-color として自動算出する。未指定(デフォルトの黒背景)の
1985
+ // ときは何もせず、CSS 側のフォールバック(既存の白固定)のままにする。
1986
+ // ホスト側 CSS が --smartphoto-icon-color 自体を明示指定している場合は、
1987
+ // 自動判定が誤検知したときの最終防衛ラインとしてその指定を必ず優先し、
1988
+ // 自動算出では上書きしない(dialog 要素へインラインスタイルで設定すると、
1989
+ // 後から通常の CSS ルールで !important なしに上書きできなくなるため)
1990
+ applyAutoIconContrast() {
1991
+ const dialog = this.view.refs.dialog;
1992
+ const computed = getComputedStyle(dialog);
1993
+ if (computed.getPropertyValue("--smartphoto-icon-color").trim()) {
1994
+ return;
1995
+ }
1996
+ const backdropColor = computed.getPropertyValue("--smartphoto-backdrop-color").trim();
1997
+ if (!backdropColor) {
1998
+ return;
1999
+ }
2000
+ dialog.style.setProperty(
2001
+ "--smartphoto-icon-color",
2002
+ getContrastColor(backdropColor)
2003
+ );
2004
+ }
1929
2005
  // ---- 内部: イベント発火 ----
1930
2006
  fireEvent(eventName) {
1931
2007
  triggerEvent(this.view.refs.dialog, eventName);
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * SmartPhoto v2.1.7
2
+ * SmartPhoto v2.1.9
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};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"),d=s;n&&(n.getAttribute(e.lazyAttribute)?d=n.getAttribute(e.lazyAttribute):n.currentSrc?d=n.currentSrc:d=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:d,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,d=(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:d,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,d,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,d=-1*u):(u=(s-o)/2,d=-1*u),{minX:Z(n,6)*e.scaleSize,minY:Z(d,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,d=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 c(){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,c())}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,d=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 m(){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-d.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){m();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=d,h=p,E=Date.now(),g=r-E,L=h.x-a.x,T=h.y-a.y,Y=L===0&&T===0;if(!c()&&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 d=document.createElement("dialog");d.className=r.smartPhoto,d.setAttribute("aria-labelledby",`smartphoto-${t}-title`),d.style.display="none",d.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",m=>{m.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 m=we();m.appendChild(ee(s.gotoPrevImage)),m.addEventListener("click",()=>i.onPrev(),{signal:o}),V.appendChild(m),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),d.appendChild(p),n.appendChild(d);let c={dialog:d,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 m=document.createElement("div");m.className=r.smartPhotoLoaderWrap;let l=document.createElement("span");return l.className=r.smartPhotoLoader,m.appendChild(l),m}function U(m){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=m.src)!=null?w:"",y.alt=(f=m.alt)!=null?f:"",y.addEventListener("dragstart",I=>I.preventDefault(),{signal:o}),l.appendChild(y),{imgWrap:l,img:y}}function te(m,l){var y;c.list.replaceChildren(),(y=c.navList)==null||y.replaceChildren(),c.slides=new Map,m.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 ${m.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(c.list.appendChild(f),c.slides.set(w,I),c.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),c.navList.appendChild(N),I.navLink=G}}),J(l)}function ie(m,l){var f;if(l.imgWrap||!m.processed)return l;let{imgWrap:y,img:w}=U(m);return(f=l.loaderWrap)==null||f.replaceWith(y),l.loaderWrap=null,l.imgWrap=y,l.img=w,l}function X(m){m&&document.activeElement&&m.contains(document.activeElement)&&c.caption.focus()}function J(m){let{viewer:l}=m;c.count.textContent=`${l.currentIndex+1}/${l.total}`,c.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&&(c.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"))}),c.arrowLeft&&(l.showPrevArrow?c.arrowLeft.removeAttribute("aria-hidden"):(X(c.arrowLeft),c.arrowLeft.setAttribute("aria-hidden","true"))),c.arrowRight&&(l.showNextArrow?c.arrowRight.removeAttribute("aria-hidden"):(X(c.arrowRight),c.arrowRight.setAttribute("aria-hidden","true"))),c.arrows&&(l.hideUi&&X(c.arrows),c.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false")),c.nav&&(l.hideUi&&X(c.nav),c.nav.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function oe(m){for(let[l,y]of c.slides)if(l.index===m.viewer.currentIndex)return y;return null}function re(m){let{viewer:l}=m,y=oe(m),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)),c.nav&&(l.hideUi&&X(c.nav),c.nav.setAttribute("aria-hidden",l.hideUi?"true":"false")),c.arrows&&(l.hideUi&&X(c.arrows),c.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function ne(m){let{viewer:l}=m;c.list.style.transform=`translate(${l.translateX}px,${l.translateY}px)`,c.list.classList.toggle(r.smartPhotoListOnMove,l.onMove)}function se(m){let l=document.createElement("img");l.className=r.smartPhotoImgClone,l.src=m.img,l.style.width=`${m.width}px`,l.style.height=`${m.height}px`,l.style.transform=`translate(${m.left}px,${m.top}px) scale(1)`,p.appendChild(l),c.imgClone=l}function ae(){var m;(m=c.imgClone)==null||m.remove(),c.imgClone=null}function le(){n.remove()}return{root:n,refs:c,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,d=(v=(u=i.trigger)!=null?u:s.element)!=null?v:n;this.openPhoto(s,d)}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,d=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(d,A()),this.state.groups.set(e,d),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.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.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,d;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=(d=document.startViewTransition)==null?void 0:d.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,d=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=d/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>d&&(v=d/s));let P=(v-1)/2*s+(d-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)`,d=()=>{this.finishHideEffect===d&&(this.finishHideEffect=null,o.removeEventListener("transitionend",d,!0),r&&r.style.transform===n&&(r.style.transform=""),i())};this.finishHideEffect=d,r&&(r.style.transform=n),o.addEventListener("transitionend",d,!0),this.scheduleTimeout(d,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;})();
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 Pe(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]=Pe((i=t[s])!=null?i:{},n):t[s]=n}}}return t}var Se=Pe,xe=(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)},Ie=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},Le=t=>({left:t.getBoundingClientRect().left,top:t.getBoundingClientRect().top});var be=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},Fe=.179,Re=([t,e,i])=>{let[o,r,s]=[t,e,i].map(n=>{let u=n/255;return u<=.03928?u/12.92:((u+.055)/1.055)**2.4});return .2126*o+.7152*r+.0722*s},Ce=t=>{let e=t.trim(),i=be(e);if(!i){let o=document.createElement("div");if(o.style.color=e,!o.style.color)return"#fff";document.body.appendChild(o),i=be(getComputedStyle(o).color),document.body.removeChild(o)}return i&&Re(i)>Fe?"#000":"#fff"};var $e={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 Te(t){return Object.keys(t).forEach(e=>{let i=t[e];i&&typeof i=="object"&&!Object.isFrozen(i)&&Te(i)}),Object.freeze(t)}function Ae(t){return{options:Te(Se({},$e,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"),u=s;n&&(n.getAttribute(e.lazyAttribute)?u=n.getAttribute(e.lazyAttribute):n.currentSrc?u=n.currentSrc:u=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 d=t.getAttribute("data-id");return{src:s,thumb:u,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:d||i,loaded:!1,processed:!1,element:t}}function Me(t,e,i){var d,v,y,P,S;let o=de(t),r=t.src,s=(d=t.thumb)!=null?d:r,n=(v=t.caption)!=null?v:null,u=(P=(y=t.alt)!=null?y:n)!=null?P:r,p=typeof t.width=="number"&&typeof t.height=="number";return{src:r,thumb:s,caption:n,alt:u,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 A(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=A(t);return e&&(i=e[t.viewer.currentIndex])!=null?i:null}function pe(t){let e=A(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 He(t,e,i,o){let r=t.width*t.scale*e.scaleSize,s=t.height*t.scale*e.scaleSize,n,u,p,d;return i>r?(p=(i-r)/2,n=-1*p):(p=(r-i)/2,n=-1*p),o>s?(d=(o-s)/2,u=-1*d):(d=(s-o)/2,u=-1*d),{minX:Z(n,6)*e.scaleSize,minY:Z(u,6)*e.scaleSize,maxX:Z(p,6)*e.scaleSize,maxY:Z(d,6)*e.scaleSize}}function ze(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 Oe(t){let e=z(t);return e?`group=${t.viewer.currentGroup}&photo=${e.id}`:""}function De(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 $(t){return{x:t.pageX,y:t.pageY}}function Ne(t,e){let i=t.x-e.x,o=t.y-e.y;return Math.sqrt(i*i+o*o)}var We=10;function Ue(t,e){return{force:Math.sqrt(t*t+e*e),theta:Math.atan2(e,t)}}function Ve(){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,u=null,p=null,d=null,v=0,y=!1,P=null,S=null,O=0,D=0,H=!1,Y=0,x=null,C=0,N=0;function c(){return K()}function W(a){let{width:h,height:E}=Ve();return He(a,t.viewer,h,E)}function U(a){let{width:h,height:E}=Ve();return Q(a,h,E,c())}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(H||s||y||t.viewer.elastic||!t.viewer.scale)return;t.viewer.photoPosX+=C,t.viewer.photoPosY+=N;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,N*=-.2):t.viewer.photoPosY>h.maxY&&(t.viewer.photoPosY=h.maxY,N*=-.2);let E=Ue(C,N),g=E.force-t.options.registance;Math.abs(g)<.5||(C=Math.cos(E.theta)*g,N=Math.sin(E.theta)*g,e.onPhotoDragMove())},t.options.forceInterval);function V(a,h){(a>5||a<-5)&&(C+=a*.05),t.options.verticalGravity&&(h>5||h<-5)&&(N+=h*.05)}function J(a){if(!(a!=null&&a.gamma)||t.viewer.appearEffect||H||s||y||t.viewer.elastic||!t.viewer.scale)return;let{orientation:h}=window;h===0?V(a.gamma,a.beta):h===90?V(a.beta,a.gamma):h===-90?V(-a.beta,-a.gamma):h===180&&V(-a.gamma,-a.beta)}t.options.useOrientationApi&&window.addEventListener("deviceorientation",J,{signal:i});function oe(){H=!0,s=!1,y=!1;let a=Array.from(o.values());Y=Ne(a[0],a[1]),t.viewer.scale=!0,e.onGestureStart()}function re(a){let h=$(a);s=!0,n=!0,u=h,p=h,v=Date.now()}function ne(a){y=!0;let h=$(a);S=h,P=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,$(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 m(){let a=Array.from(o.values()),h=Ne(a[0],a[1]),E=(h-Y)/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 X=z(t);if(X){let he=U(X);t.viewer.hideUi=t.viewer.scaleSize<1||t.viewer.scaleSize>he}Y=h,ae()}function l(a){let h=$(a),E=h.x-p.x,g=h.y-u.y;n&&(e.onSwipeStart(),n=!1,d=Math.abs(E)>Math.abs(g)?"horizontal":"vertical"),d==="horizontal"?t.viewer.translateX+=E:t.viewer.translateY=g,p=h,e.onSwipeMove()}function b(a){let h=$(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,$(a)),H){m();return}if(y){b(a);return}l(a)}}function f(){H=!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=u,h=p,E=Date.now(),g=r-E,L=h.x-a.x,T=h.y-a.y,X=L===0&&T===0;if(!c()&&X){e.onTap();return}if(Math.abs(g)<=500&&X){e.onTap();return}r=E;let he=(Ee=A(t))!=null?Ee:[];if(d==="horizontal"){let R="stay",ke=Math.max(E-v,1),ye=Math.abs(L)>=We&&Math.abs(L)/ke>=t.options.swipeVelocity;(L>=t.options.swipeOffset||ye&&L>0)&&t.viewer.currentIndex!==0?R="prev":(L<=-t.options.swipeOffset||ye&&L<0)&&t.viewer.currentIndex!==he.length-1&&(R="next"),e.onSwipeEnd(R)}else{let R="stay";t.options.swipeBottomToClose&&T>=t.options.swipeOffset?R="close-bottom":t.options.swipeTopToClose&&T<=-t.options.swipeOffset&&(R="close-top"),e.onSwipeEnd(R)}}function F(){y=!1;let a=S,h=P;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,X=0;if(t.viewer.photoPosX>g.maxX?T=-1:t.viewer.photoPosX<g.minX&&(T=1),t.viewer.photoPosY>g.maxY?X=-1:t.viewer.photoPosY<g.minY&&(X=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&&X===0?(C=O/5,N=D/5):te(T,X),e.onPhotoDragEnd(null)}function j(a){if(o.delete(a.pointerId),H){o.size<2&&f();return}if(y){F();return}s&&I()}function B(...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:B,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 je(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 u=document.createElement("dialog");u.className=r.smartPhoto,u.setAttribute("aria-labelledby",`smartphoto-${t}-title`),u.style.display="none",u.style.setProperty("--smartphoto-animation-speed",`${e.animationSpeed}ms`);let p=document.createElement("div");p.className=r.smartPhotoBody;let d=document.createElement("div");d.className=r.smartPhotoInner;let v=document.createElement("div");v.className=r.smartPhotoHeader;let y=document.createElement("span");y.className=r.smartPhotoCount;let P=document.createElement("h1");P.id=`smartphoto-${t}-title`,P.className=r.smartPhotoCaption,P.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(y,P,S);let O=document.createElement("div");O.className=r.smartPhotoContent,O.addEventListener("click",m=>{m.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"),d.append(v,O,D);let H=null,Y=null,x=null;if(e.arrows){H=document.createElement("ul"),H.className=r.smartPhotoArrows,Y=document.createElement("li"),Y.className=r.smartPhotoArrowLeft;let m=we();m.appendChild(ee(s.gotoPrevImage)),m.addEventListener("click",()=>i.onPrev(),{signal:o}),Y.appendChild(m),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),H.append(Y,x),d.appendChild(H)}let C=null,N=null;e.nav&&(C=document.createElement("nav"),C.className=r.smartPhotoNav,C.setAttribute("aria-label","Choose slide to display"),N=document.createElement("ul"),C.appendChild(N),d.appendChild(C)),p.appendChild(d),u.appendChild(p),n.appendChild(u);let c={dialog:u,count:y,caption:P,dismiss:S,content:O,list:D,arrows:H,arrowLeft:Y,arrowRight:x,nav:C,navList:N,slides:new Map,imgClone:null};function W(){let m=document.createElement("div");m.className=r.smartPhotoLoaderWrap;let l=document.createElement("span");return l.className=r.smartPhotoLoader,m.appendChild(l),m}function U(m){var w,f;let l=document.createElement("div");l.className=r.smartPhotoImgWrap;let b=document.createElement("img");return b.className=r.smartPhotoImg,b.src=(w=m.src)!=null?w:"",b.alt=(f=m.alt)!=null?f:"",b.addEventListener("dragstart",I=>I.preventDefault(),{signal:o}),l.appendChild(b),{imgWrap:l,img:b}}function te(m,l){var b;c.list.replaceChildren(),(b=c.navList)==null||b.replaceChildren(),c.slides=new Map,m.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 ${m.length}`);let I={li:f,loaderWrap:null,imgWrap:null,img:null,navLink:null};if(w.processed){let{imgWrap:B,img:G}=U(w);f.appendChild(B),I.imgWrap=B,I.img=G}else{let B=W();f.appendChild(B),I.loaderWrap=B}if(c.list.appendChild(f),c.slides.set(w,I),c.navList){let B=document.createElement("li"),G=we();G.style.backgroundImage=`url("${je((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:""}`)),B.appendChild(G),c.navList.appendChild(B),I.navLink=G}}),J(l)}function ie(m,l){var f;if(l.imgWrap||!m.processed)return l;let{imgWrap:b,img:w}=U(m);return(f=l.loaderWrap)==null||f.replaceWith(b),l.loaderWrap=null,l.imgWrap=b,l.img=w,l}function V(m){m&&document.activeElement&&m.contains(document.activeElement)&&c.caption.focus()}function J(m){let{viewer:l}=m;c.count.textContent=`${l.currentIndex+1}/${l.total}`,c.slides.forEach((b,w)=>{var F;let f=ie(w,b),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&&(c.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"))}),c.arrowLeft&&(l.showPrevArrow?c.arrowLeft.removeAttribute("aria-hidden"):(V(c.arrowLeft),c.arrowLeft.setAttribute("aria-hidden","true"))),c.arrowRight&&(l.showNextArrow?c.arrowRight.removeAttribute("aria-hidden"):(V(c.arrowRight),c.arrowRight.setAttribute("aria-hidden","true"))),c.arrows&&(l.hideUi&&V(c.arrows),c.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false")),c.nav&&(l.hideUi&&V(c.nav),c.nav.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function oe(m){for(let[l,b]of c.slides)if(l.index===m.viewer.currentIndex)return b;return null}function re(m){let{viewer:l}=m,b=oe(m),w=b==null?void 0:b.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)),c.nav&&(l.hideUi&&V(c.nav),c.nav.setAttribute("aria-hidden",l.hideUi?"true":"false")),c.arrows&&(l.hideUi&&V(c.arrows),c.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function ne(m){let{viewer:l}=m;c.list.style.transform=`translate(${l.translateX}px,${l.translateY}px)`,c.list.classList.toggle(r.smartPhotoListOnMove,l.onMove)}function se(m){let l=document.createElement("img");l.className=r.smartPhotoImgClone,l.src=m.img,l.style.width=`${m.width}px`,l.style.height=`${m.height}px`,l.style.transform=`translate(${m.left}px,${m.top}px) scale(1)`,p.appendChild(l),c.imgClone=l}function ae(){var m;(m=c.imgClone)==null||m.remove(),c.imgClone=null}function le(){n.remove()}return{root:n,refs:c,render:J,syncSlides:te,updatePhotoTransform:re,updateListTransform:ne,showAppearEffect:se,removeAppearEffect:ae,destroy:le}}function M(){return document.documentElement.clientWidth}function k(){let t=window.visualViewport;return t?t.height*t.scale:document.documentElement.clientHeight}function qe(t){return t.length>0&&t[0]instanceof Element}function Qe(){return(Date.now().toString(36)+Math.random().toString(36).substring(2,7)).toUpperCase()}function Ye(){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=Qe();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.handleVisualViewportResize=()=>{this.updateViewportHeight(),!(!this.isSmartPhoneFlag||!this.state.viewer.isOpen||!A(this.state))&&(this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit())};this.handleResize=()=>{A(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(!A(this.state))return;this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit();let e=M(),i=500,o=r=>{this.scheduleTimeout(()=>{e!==M()?(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=Ae(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(),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){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=Ye();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,M(),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,d,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(y=>y.id===e);if(!s)return;let n=document.activeElement instanceof HTMLElement?document.activeElement:null,u=(v=(d=i.trigger)!=null?d:s.element)!=null?v:n;this.openPhoto(s,u)}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)&&!qe(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,M());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=Me(e,o,M());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(d=>q(d)===e),o=new Set(i),r=(p=this.state.groups.get(e))!=null?p:[],s=new Map;r.forEach(d=>{d.element&&s.set(d.element,d)});let n=i.length!==r.length,u=i.map((d,v)=>{let y=s.get(d);if(y)return y.index!==v&&(n=!0,y.index=v),y;n=!0;let P=ce(d,this.state.options,v,M());return this.itemsByElement.set(d,P),P});return r.forEach(d=>{d.element&&!o.has(d.element)&&this.itemsByElement.delete(d.element)}),fe(u,M()),this.state.groups.set(e,u),n&&this.loadAllFired.delete(e),n}syncCurrentGroupView(){let e=A(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=Ye();this.setHash(Oe(this.state)),window.scroll(e.x,e.y)}restoreFromHash(){let e=location.hash.substring(1);return e?De(this.state,Ie(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=A(this.state);e&&ze(e,M(),k(),this.state.options.headerHeight,this.state.options.footerHeight)}resetTranslateCurrent(){fe(A(this.state),M())}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.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.syncDialog()}initPhoto(){var i;(i=this.finishHideEffect)==null||i.call(this),this.updateViewportHeight(),this.view.refs.dialog.style.opacity="";let e=A(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,M(),k(),this.isSmartPhoneFlag)}}supportsViewTransition(){return typeof document.startViewTransition=="function"}openPhotoWithViewTransition(e){var n,u;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=(u=document.startViewTransition)==null?void 0:u.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=Le(o),s=o.offsetWidth,n=o.offsetHeight,u=M(),p=k(),d=p-this.state.options.headerHeight-this.state.options.footerHeight,v=1;this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag?s>n?v=p/n:v=u/s:(s>=n?i.height<d?v=i.width/s:v=d/n:i.height<d?v=i.height/n:v=d/n,s*v>u&&(v=u/s));let y=(v-1)/2*s+(u-s*v)/2,P=(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:y,afterY:P,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=M(),i=k();requestAnimationFrame(()=>{this.state.viewer.isOpen&&(M()===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)`,u=()=>{this.finishHideEffect===u&&(this.finishHideEffect=null,o.removeEventListener("transitionend",u,!0),r&&r.style.transform===n&&(r.style.transform=""),i())};this.finishHideEffect=u,r&&(r.style.transform=n),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=A(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}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",Ce(o))}fireEvent(e){xe(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 Ge=_;var ge=t=>{t.fn.SmartPhoto=function(e){return typeof e=="string"||new Ge(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 at=ge;})();
package/js/smartphoto.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * SmartPhoto v2.1.7
2
+ * SmartPhoto v2.1.9
3
3
  * (c) appleple
4
4
  * Released under the MIT License.
5
5
  */
@@ -85,6 +85,41 @@ var SmartPhoto = (() => {
85
85
  top: element.getBoundingClientRect().top
86
86
  };
87
87
  };
88
+ var parseRgb = (value) => {
89
+ const match = value.match(
90
+ /rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*[\d.]+\s*)?\)/
91
+ );
92
+ if (!match) {
93
+ return null;
94
+ }
95
+ return [Number(match[1]), Number(match[2]), Number(match[3])];
96
+ };
97
+ var CONTRAST_LUMINANCE_THRESHOLD = 0.179;
98
+ var relativeLuminance = ([r, g, b]) => {
99
+ const [rl, gl, bl] = [r, g, b].map((c) => {
100
+ const v = c / 255;
101
+ return v <= 0.03928 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4;
102
+ });
103
+ return 0.2126 * rl + 0.7152 * gl + 0.0722 * bl;
104
+ };
105
+ var getContrastColor = (colorValue) => {
106
+ const trimmed = colorValue.trim();
107
+ let rgb = parseRgb(trimmed);
108
+ if (!rgb) {
109
+ const probe = document.createElement("div");
110
+ probe.style.color = trimmed;
111
+ if (!probe.style.color) {
112
+ return "#fff";
113
+ }
114
+ document.body.appendChild(probe);
115
+ rgb = parseRgb(getComputedStyle(probe).color);
116
+ document.body.removeChild(probe);
117
+ }
118
+ if (!rgb) {
119
+ return "#fff";
120
+ }
121
+ return relativeLuminance(rgb) > CONTRAST_LUMINANCE_THRESHOLD ? "#000" : "#fff";
122
+ };
88
123
 
89
124
  // src/core/state.ts
90
125
  var defaults = {
@@ -1206,13 +1241,28 @@ var SmartPhoto = (() => {
1206
1241
  this.openPhoto(item, matched);
1207
1242
  }
1208
1243
  };
1209
- // ---- 内部: window イベント ----
1210
1244
  this.updateViewportHeight = () => {
1211
1245
  this.view.refs.dialog.style.setProperty(
1212
1246
  "--smartphoto-vh",
1213
1247
  `${getWindowHeight()}px`
1214
1248
  );
1215
1249
  };
1250
+ // iOS Safari 等ではアドレスバーの表示/非表示に伴う visualViewport の変化が
1251
+ // orientationchange を伴わず resize としてのみ発火する。スマートフォンでは
1252
+ // window の resize を購読していない(§コンストラクタ)ため、ここで拾わないと
1253
+ // 開いている間ずっと古い高さで計算された item.x/y がインラインスタイルに
1254
+ // 残り続け、表示中のスライドだけ位置がずれて見える(§Issue #95: スワイプ
1255
+ // ダウンで閉じて再度開いた際、閉じた瞬間表示していたスライドだけ縦位置がずれる)
1256
+ this.handleVisualViewportResize = () => {
1257
+ this.updateViewportHeight();
1258
+ if (!this.isSmartPhoneFlag || !this.state.viewer.isOpen || !currentItems(this.state)) {
1259
+ return;
1260
+ }
1261
+ this.resetTranslateCurrent();
1262
+ this.setPosByCurrentIndex();
1263
+ this.setSizeByScreen();
1264
+ this.commit();
1265
+ };
1216
1266
  this.handleResize = () => {
1217
1267
  if (!currentItems(this.state)) {
1218
1268
  return;
@@ -1296,10 +1346,11 @@ var SmartPhoto = (() => {
1296
1346
  this.openPhoto(restored, restored.element);
1297
1347
  }
1298
1348
  this.updateViewportHeight();
1349
+ this.applyAutoIconContrast();
1299
1350
  if (window.visualViewport) {
1300
1351
  window.visualViewport.addEventListener(
1301
1352
  "resize",
1302
- this.updateViewportHeight,
1353
+ this.handleVisualViewportResize,
1303
1354
  { signal: this.abortController.signal }
1304
1355
  );
1305
1356
  } else {
@@ -1650,6 +1701,7 @@ var SmartPhoto = (() => {
1650
1701
  initPhoto() {
1651
1702
  var _a;
1652
1703
  (_a = this.finishHideEffect) == null ? void 0 : _a.call(this);
1704
+ this.updateViewportHeight();
1653
1705
  this.view.refs.dialog.style.opacity = "";
1654
1706
  const items = currentItems(this.state);
1655
1707
  this.state.viewer.total = items.length;
@@ -1950,6 +2002,30 @@ var SmartPhoto = (() => {
1950
2002
  this.timeouts.push(id);
1951
2003
  return id;
1952
2004
  }
2005
+ // ---- 内部: window イベント ----
2006
+ // --smartphoto-backdrop-color をホスト側 CSS が明示指定している場合のみ、
2007
+ // その背景色に対してコントラストの高い文字色/アイコン色(#000 or #fff)を
2008
+ // --smartphoto-icon-color として自動算出する。未指定(デフォルトの黒背景)の
2009
+ // ときは何もせず、CSS 側のフォールバック(既存の白固定)のままにする。
2010
+ // ホスト側 CSS が --smartphoto-icon-color 自体を明示指定している場合は、
2011
+ // 自動判定が誤検知したときの最終防衛ラインとしてその指定を必ず優先し、
2012
+ // 自動算出では上書きしない(dialog 要素へインラインスタイルで設定すると、
2013
+ // 後から通常の CSS ルールで !important なしに上書きできなくなるため)
2014
+ applyAutoIconContrast() {
2015
+ const dialog = this.view.refs.dialog;
2016
+ const computed = getComputedStyle(dialog);
2017
+ if (computed.getPropertyValue("--smartphoto-icon-color").trim()) {
2018
+ return;
2019
+ }
2020
+ const backdropColor = computed.getPropertyValue("--smartphoto-backdrop-color").trim();
2021
+ if (!backdropColor) {
2022
+ return;
2023
+ }
2024
+ dialog.style.setProperty(
2025
+ "--smartphoto-icon-color",
2026
+ getContrastColor(backdropColor)
2027
+ );
2028
+ }
1953
2029
  // ---- 内部: イベント発火 ----
1954
2030
  fireEvent(eventName) {
1955
2031
  triggerEvent(this.view.refs.dialog, eventName);
@@ -1,7 +1,7 @@
1
1
  /*!
2
- * SmartPhoto v2.1.7
2
+ * SmartPhoto v2.1.9
3
3
  * (c) appleple
4
4
  * Released under the MIT License.
5
5
  */
6
- "use strict";var SmartPhoto=(()=>{var ue=Object.defineProperty;var Ve=Object.getOwnPropertyDescriptor;var Ge=Object.getOwnPropertyNames;var Fe=Object.prototype.hasOwnProperty;var Re=(t,e)=>{for(var i in e)ue(t,i,{get:e[i],enumerable:!0})},$e=(t,e,i,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Ge(e))!Fe.call(t,r)&&r!==i&&ue(t,r,{get:()=>e[r],enumerable:!(o=Ve(e,r))||o.enumerable});return t};var ke=t=>$e(ue({},"__esModule",{value:!0}),t);var Je={};Re(Je,{default:()=>Qe});var J=()=>{let t=navigator.userAgent;return t.indexOf("iPhone")>0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0};function be(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]=be((i=t[s])!=null?i:{},n):t[s]=n}}}return t}var ye=be,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 We={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(ye({},We,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 _(t){return t.getAttribute("data-group")||"nogroup"}function ce(t){return t.group||"nogroup"}function me(t,e,i,o){let r=_(t),s=t.getAttribute("href"),n=t.querySelector("img"),d=s;n&&(n.getAttribute(e.lazyAttribute)?d=n.getAttribute(e.lazyAttribute):n.currentSrc?d=n.currentSrc:d=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:d,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,y,S;let o=ce(t),r=t.src,s=(u=t.thumb)!=null?u:r,n=(v=t.caption)!=null?v:null,d=(y=(P=t.alt)!=null?P:n)!=null?y:r,p=typeof t.width=="number"&&typeof t.height=="number";return{src:r,thumb:s,caption:n,alt:d,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 pe(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 fe(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 ve(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 j(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,d,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,d=-1*u):(u=(s-o)/2,d=-1*u),{minX:Z(n,6)*e.scaleSize,minY:Z(d,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 we(t,e){let i=10**e;return Math.round(t*i)/i}function k(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 Ue=10;function qe(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,d=null,p=null,u=null,v=0,P=!1,y=null,S=null,O=0,D=0,M=!1,V=0,x=null,C=0,B=0;function c(){return J()}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 j(a,h,E,c())}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=qe(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 Q(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",Q,{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=k(a);s=!0,n=!0,d=h,p=h,v=Date.now()}function ne(a){P=!0;let h=k(a);S=h,y=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,k(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 m(){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+=we(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=k(a),E=h.x-p.x,g=h.y-d.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 b(a){let h=k(a),E=h.x-S.x,g=h.y-S.y,L=we(t.viewer.scaleSize*E,6),T=we(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,k(a)),M){m();return}if(P){b(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=d,h=p,E=Date.now(),g=r-E,L=h.x-a.x,T=h.y-a.y,Y=L===0&&T===0;if(!c()&&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",Ye=Math.max(E-v,1),Pe=Math.abs(L)>=Ue&&Math.abs(L)/Ye>=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 R(){P=!1;let a=S,h=y;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 q(a){if(o.delete(a.pointerId),M){o.size<2&&f();return}if(P){R();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",q,{signal:i}),h.addEventListener("pointercancel",q,{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 ge(){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 d=document.createElement("dialog");d.className=r.smartPhoto,d.setAttribute("aria-labelledby",`smartphoto-${t}-title`),d.style.display="none",d.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 y=document.createElement("h1");y.id=`smartphoto-${t}-title`,y.className=r.smartPhotoCaption,y.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,y,S);let O=document.createElement("div");O.className=r.smartPhotoContent,O.addEventListener("click",m=>{m.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 m=ge();m.appendChild(ee(s.gotoPrevImage)),m.addEventListener("click",()=>i.onPrev(),{signal:o}),V.appendChild(m),x=document.createElement("li"),x.className=r.smartPhotoArrowRight;let l=ge();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),d.appendChild(p),n.appendChild(d);let c={dialog:d,count:P,caption:y,dismiss:S,content:O,list:D,arrows:M,arrowLeft:V,arrowRight:x,nav:C,navList:B,slides:new Map,imgClone:null};function W(){let m=document.createElement("div");m.className=r.smartPhotoLoaderWrap;let l=document.createElement("span");return l.className=r.smartPhotoLoader,m.appendChild(l),m}function U(m){var w,f;let l=document.createElement("div");l.className=r.smartPhotoImgWrap;let b=document.createElement("img");return b.className=r.smartPhotoImg,b.src=(w=m.src)!=null?w:"",b.alt=(f=m.alt)!=null?f:"",b.addEventListener("dragstart",I=>I.preventDefault(),{signal:o}),l.appendChild(b),{imgWrap:l,img:b}}function te(m,l){var b;c.list.replaceChildren(),(b=c.navList)==null||b.replaceChildren(),c.slides=new Map,m.forEach(w=>{var R,q;let f=document.createElement("li");f.setAttribute("role","group"),f.setAttribute("aria-roledescription","slide"),f.setAttribute("aria-label",`${w.index+1} of ${m.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(c.list.appendChild(f),c.slides.set(w,I),c.navList){let N=document.createElement("li"),G=ge();G.style.backgroundImage=`url("${_e((R=w.thumb)!=null?R:"")}")`;let a=w.index;G.addEventListener("click",()=>i.onNavigate(a),{signal:o}),G.appendChild(ee(`go to ${(q=w.caption)!=null?q:""}`)),N.appendChild(G),c.navList.appendChild(N),I.navLink=G}}),Q(l)}function ie(m,l){var f;if(l.imgWrap||!m.processed)return l;let{imgWrap:b,img:w}=U(m);return(f=l.loaderWrap)==null||f.replaceWith(b),l.loaderWrap=null,l.imgWrap=b,l.img=w,l}function X(m){m&&document.activeElement&&m.contains(document.activeElement)&&c.caption.focus()}function Q(m){let{viewer:l}=m;c.count.textContent=`${l.currentIndex+1}/${l.total}`,c.slides.forEach((b,w)=>{var R;let f=ie(w,b),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&&(c.caption.textContent=(R=w.caption)!=null?R:""),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"))}),c.arrowLeft&&(l.showPrevArrow?c.arrowLeft.removeAttribute("aria-hidden"):(X(c.arrowLeft),c.arrowLeft.setAttribute("aria-hidden","true"))),c.arrowRight&&(l.showNextArrow?c.arrowRight.removeAttribute("aria-hidden"):(X(c.arrowRight),c.arrowRight.setAttribute("aria-hidden","true"))),c.arrows&&(l.hideUi&&X(c.arrows),c.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false")),c.nav&&(l.hideUi&&X(c.nav),c.nav.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function oe(m){for(let[l,b]of c.slides)if(l.index===m.viewer.currentIndex)return b;return null}function re(m){let{viewer:l}=m,b=oe(m),w=b==null?void 0:b.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)),c.nav&&(l.hideUi&&X(c.nav),c.nav.setAttribute("aria-hidden",l.hideUi?"true":"false")),c.arrows&&(l.hideUi&&X(c.arrows),c.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function ne(m){let{viewer:l}=m;c.list.style.transform=`translate(${l.translateX}px,${l.translateY}px)`,c.list.classList.toggle(r.smartPhotoListOnMove,l.onMove)}function se(m){let l=document.createElement("img");l.className=r.smartPhotoImgClone,l.src=m.img,l.style.width=`${m.width}px`,l.style.height=`${m.height}px`,l.style.transform=`translate(${m.left}px,${m.top}px) scale(1)`,p.appendChild(l),c.imgClone=l}function ae(){var m;(m=c.imgClone)==null||m.remove(),c.imgClone=null}function le(){n.remove()}return{root:n,refs:c,render:Q,syncSlides:te,updatePhotoTransform:re,updateListTransform:ne,showAppearEffect:se,removeAppearEffect:ae,destroy:le}}function A(){return document.documentElement.clientWidth}function F(){let t=window.visualViewport;return t?t.height*t.scale:document.documentElement.clientHeight}function je(t){return t.length>0&&t[0]instanceof Element}function Ke(){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 K=class{constructor(e,i){this.id=Ke();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.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=_(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",`${F()}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=j(e,A(),F(),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,d=(v=(u=i.trigger)!=null?u:s.element)!=null?v:n;this.openPhoto(s,d)}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)&&!je(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=_(e),o=(n=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?n:0,r=me(e,this.state.options,o,A());return pe(this.state,r),this.loadAllFired.delete(i),this.itemsByElement.set(e,r),r}addSlideItem(e){var s,n;let i=ce(e),o=(n=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?n:0,r=Te(e,o,A());return pe(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=>_(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,d=i.map((u,v)=>{let P=s.get(u);if(P)return P.index!==v&&(n=!0,P.index=v),P;n=!0;let y=me(u,this.state.options,v,A());return this.itemsByElement.set(u,y),y});return r.forEach(u=>{u.element&&!o.has(u.element)&&this.itemsByElement.delete(u.element)}),ve(d,A()),this.state.groups.set(e,d),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(),F(),this.state.options.headerHeight,this.state.options.footerHeight)}resetTranslateCurrent(){ve(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.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.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(),fe(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=j(o,A(),F(),this.isSmartPhoneFlag)}}supportsViewTransition(){return typeof document.startViewTransition=="function"}openPhotoWithViewTransition(e){var n,d;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=(d=document.startViewTransition)==null?void 0:d.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,d=A(),p=F(),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=d/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>d&&(v=d/s));let P=(v-1)/2*s+(d-s*v)/2,y=(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:y,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=F();requestAnimationFrame(()=>{this.state.viewer.isOpen&&(A()===e&&F()===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=F(),n=e==="top"?`translateY(-${s}px)`:`translateY(${s}px)`,d=()=>{this.finishHideEffect===d&&(this.finishHideEffect=null,o.removeEventListener("transitionend",d,!0),r&&r.style.transform===n&&(r.style.transform=""),i())};this.finishHideEffect=d,r&&(r.style.transform=n),o.addEventListener("transitionend",d,!0),this.scheduleTimeout(d,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,fe(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 Qe=K;return ke(Je);})();
6
+ "use strict";var SmartPhoto=(()=>{var ue=Object.defineProperty;var Fe=Object.getOwnPropertyDescriptor;var Re=Object.getOwnPropertyNames;var ke=Object.prototype.hasOwnProperty;var $e=(t,e)=>{for(var i in e)ue(t,i,{get:e[i],enumerable:!0})},We=(t,e,i,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Re(e))!ke.call(t,r)&&r!==i&&ue(t,r,{get:()=>e[r],enumerable:!(o=Fe(e,r))||o.enumerable});return t};var Ue=t=>We(ue({},"__esModule",{value:!0}),t);var it={};$e(it,{default:()=>tt});var J=()=>{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 Se=ye,Ie=(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},Le=t=>({left:t.getBoundingClientRect().left,top:t.getBoundingClientRect().top});var Pe=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},_e=.179,qe=([t,e,i])=>{let[o,r,s]=[t,e,i].map(n=>{let u=n/255;return u<=.03928?u/12.92:((u+.055)/1.055)**2.4});return .2126*o+.7152*r+.0722*s},Ce=t=>{let e=t.trim(),i=Pe(e);if(!i){let o=document.createElement("div");if(o.style.color=e,!o.style.color)return"#fff";document.body.appendChild(o),i=Pe(getComputedStyle(o).color),document.body.removeChild(o)}return i&&qe(i)>_e?"#000":"#fff"};var je={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 Te(t){return Object.keys(t).forEach(e=>{let i=t[e];i&&typeof i=="object"&&!Object.isFrozen(i)&&Te(i)}),Object.freeze(t)}function Ae(t){return{options:Te(Se({},je,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 me(t,e,i,o){let r=q(t),s=t.getAttribute("href"),n=t.querySelector("img"),u=s;n&&(n.getAttribute(e.lazyAttribute)?u=n.getAttribute(e.lazyAttribute):n.currentSrc?u=n.currentSrc:u=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 c=t.getAttribute("data-id");return{src:s,thumb:u,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:c||i,loaded:!1,processed:!1,element:t}}function Me(t,e,i){var c,v,b,y,S;let o=de(t),r=t.src,s=(c=t.thumb)!=null?c:r,n=(v=t.caption)!=null?v:null,u=(y=(b=t.alt)!=null?b:n)!=null?y:r,p=typeof t.width=="number"&&typeof t.height=="number";return{src:r,thumb:s,caption:n,alt:u,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 pe(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 A(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=A(t);return e&&(i=e[t.viewer.currentIndex])!=null?i:null}function fe(t){let e=A(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 ve(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 j(t,e,i,o){return o?t.width>t.height?i/(t.height*t.scale):e/(t.width*t.scale):1/t.scale}function He(t,e,i,o){let r=t.width*t.scale*e.scaleSize,s=t.height*t.scale*e.scaleSize,n,u,p,c;return i>r?(p=(i-r)/2,n=-1*p):(p=(r-i)/2,n=-1*p),o>s?(c=(o-s)/2,u=-1*c):(c=(s-o)/2,u=-1*c),{minX:Z(n,6)*e.scaleSize,minY:Z(u,6)*e.scaleSize,maxX:Z(p,6)*e.scaleSize,maxY:Z(c,6)*e.scaleSize}}function ze(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 Oe(t){let e=z(t);return e?`group=${t.viewer.currentGroup}&photo=${e.id}`:""}function De(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 we(t,e){let i=10**e;return Math.round(t*i)/i}function $(t){return{x:t.pageX,y:t.pageY}}function Ne(t,e){let i=t.x-e.x,o=t.y-e.y;return Math.sqrt(i*i+o*o)}var Ke=10;function Qe(t,e){return{force:Math.sqrt(t*t+e*e),theta:Math.atan2(e,t)}}function Ve(){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,u=null,p=null,c=null,v=0,b=!1,y=null,S=null,O=0,D=0,H=!1,Y=0,I=null,C=0,N=0;function d(){return J()}function W(a){let{width:h,height:E}=Ve();return He(a,t.viewer,h,E)}function U(a){let{width:h,height:E}=Ve();return j(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(H||s||b||t.viewer.elastic||!t.viewer.scale)return;t.viewer.photoPosX+=C,t.viewer.photoPosY+=N;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,N*=-.2):t.viewer.photoPosY>h.maxY&&(t.viewer.photoPosY=h.maxY,N*=-.2);let E=Qe(C,N),g=E.force-t.options.registance;Math.abs(g)<.5||(C=Math.cos(E.theta)*g,N=Math.sin(E.theta)*g,e.onPhotoDragMove())},t.options.forceInterval);function V(a,h){(a>5||a<-5)&&(C+=a*.05),t.options.verticalGravity&&(h>5||h<-5)&&(N+=h*.05)}function Q(a){if(!(a!=null&&a.gamma)||t.viewer.appearEffect||H||s||b||t.viewer.elastic||!t.viewer.scale)return;let{orientation:h}=window;h===0?V(a.gamma,a.beta):h===90?V(a.beta,a.gamma):h===-90?V(-a.beta,-a.gamma):h===180&&V(-a.gamma,-a.beta)}t.options.useOrientationApi&&window.addEventListener("deviceorientation",Q,{signal:i});function oe(){H=!0,s=!1,b=!1;let a=Array.from(o.values());Y=Ne(a[0],a[1]),t.viewer.scale=!0,e.onGestureStart()}function re(a){let h=$(a);s=!0,n=!0,u=h,p=h,v=Date.now()}function ne(a){b=!0;let h=$(a);S=h,y=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,$(a)),o.size>1){oe();return}if(t.viewer.scale){ne(a);return}re(a)}function ae(){I===null&&(I=requestAnimationFrame(()=>{I=null,e.onGestureMove()}))}function le(){I!==null&&(cancelAnimationFrame(I),I=null,e.onGestureMove())}function m(){let a=Array.from(o.values()),h=Ne(a[0],a[1]),E=(h-Y)/100,g=t.viewer.scaleSize,L=t.viewer.photoPosX,T=t.viewer.photoPosY;t.viewer.scaleSize+=we(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 X=z(t);if(X){let he=U(X);t.viewer.hideUi=t.viewer.scaleSize<1||t.viewer.scaleSize>he}Y=h,ae()}function l(a){let h=$(a),E=h.x-p.x,g=h.y-u.y;n&&(e.onSwipeStart(),n=!1,c=Math.abs(E)>Math.abs(g)?"horizontal":"vertical"),c==="horizontal"?t.viewer.translateX+=E:t.viewer.translateY=g,p=h,e.onSwipeMove()}function P(a){let h=$(a),E=h.x-S.x,g=h.y-S.y,L=we(t.viewer.scaleSize*E,6),T=we(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,$(a)),H){m();return}if(b){P(a);return}l(a)}}function f(){H=!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 x(){var Ee;s=!1;let a=u,h=p,E=Date.now(),g=r-E,L=h.x-a.x,T=h.y-a.y,X=L===0&&T===0;if(!d()&&X){e.onTap();return}if(Math.abs(g)<=500&&X){e.onTap();return}r=E;let he=(Ee=A(t))!=null?Ee:[];if(c==="horizontal"){let k="stay",Ge=Math.max(E-v,1),be=Math.abs(L)>=Ke&&Math.abs(L)/Ge>=t.options.swipeVelocity;(L>=t.options.swipeOffset||be&&L>0)&&t.viewer.currentIndex!==0?k="prev":(L<=-t.options.swipeOffset||be&&L<0)&&t.viewer.currentIndex!==he.length-1&&(k="next"),e.onSwipeEnd(k)}else{let k="stay";t.options.swipeBottomToClose&&T>=t.options.swipeOffset?k="close-bottom":t.options.swipeTopToClose&&T<=-t.options.swipeOffset&&(k="close-top"),e.onSwipeEnd(k)}}function R(){b=!1;let a=S,h=y;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,X=0;if(t.viewer.photoPosX>g.maxX?T=-1:t.viewer.photoPosX<g.minX&&(T=1),t.viewer.photoPosY>g.maxY?X=-1:t.viewer.photoPosY<g.minY&&(X=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&&X===0?(C=O/5,N=D/5):te(T,X),e.onPhotoDragEnd(null)}function _(a){if(o.delete(a.pointerId),H){o.size<2&&f();return}if(b){R();return}s&&x()}function B(...a){for(let h of a)h.addEventListener("pointerdown",se,{signal:i}),h.addEventListener("pointermove",w,{signal:i}),h.addEventListener("pointerup",_,{signal:i}),h.addEventListener("pointercancel",_,{signal:i})}function G(){clearInterval(ie),I!==null&&(cancelAnimationFrame(I),I=null)}return{attach:B,detach:G}}function ee(t){let e=document.createElement("span");return e.className="smartphoto-sr-only",e.textContent=t,e}function ge(){let t=document.createElement("button");return t.type="button",t}function Je(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 u=document.createElement("dialog");u.className=r.smartPhoto,u.setAttribute("aria-labelledby",`smartphoto-${t}-title`),u.style.display="none",u.style.setProperty("--smartphoto-animation-speed",`${e.animationSpeed}ms`);let p=document.createElement("div");p.className=r.smartPhotoBody;let c=document.createElement("div");c.className=r.smartPhotoInner;let v=document.createElement("div");v.className=r.smartPhotoHeader;let b=document.createElement("span");b.className=r.smartPhotoCount;let y=document.createElement("h1");y.id=`smartphoto-${t}-title`,y.className=r.smartPhotoCaption,y.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(b,y,S);let O=document.createElement("div");O.className=r.smartPhotoContent,O.addEventListener("click",m=>{m.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"),c.append(v,O,D);let H=null,Y=null,I=null;if(e.arrows){H=document.createElement("ul"),H.className=r.smartPhotoArrows,Y=document.createElement("li"),Y.className=r.smartPhotoArrowLeft;let m=ge();m.appendChild(ee(s.gotoPrevImage)),m.addEventListener("click",()=>i.onPrev(),{signal:o}),Y.appendChild(m),I=document.createElement("li"),I.className=r.smartPhotoArrowRight;let l=ge();l.appendChild(ee(s.gotoNextImage)),l.addEventListener("click",()=>i.onNext(),{signal:o}),I.appendChild(l),H.append(Y,I),c.appendChild(H)}let C=null,N=null;e.nav&&(C=document.createElement("nav"),C.className=r.smartPhotoNav,C.setAttribute("aria-label","Choose slide to display"),N=document.createElement("ul"),C.appendChild(N),c.appendChild(C)),p.appendChild(c),u.appendChild(p),n.appendChild(u);let d={dialog:u,count:b,caption:y,dismiss:S,content:O,list:D,arrows:H,arrowLeft:Y,arrowRight:I,nav:C,navList:N,slides:new Map,imgClone:null};function W(){let m=document.createElement("div");m.className=r.smartPhotoLoaderWrap;let l=document.createElement("span");return l.className=r.smartPhotoLoader,m.appendChild(l),m}function U(m){var w,f;let l=document.createElement("div");l.className=r.smartPhotoImgWrap;let P=document.createElement("img");return P.className=r.smartPhotoImg,P.src=(w=m.src)!=null?w:"",P.alt=(f=m.alt)!=null?f:"",P.addEventListener("dragstart",x=>x.preventDefault(),{signal:o}),l.appendChild(P),{imgWrap:l,img:P}}function te(m,l){var P;d.list.replaceChildren(),(P=d.navList)==null||P.replaceChildren(),d.slides=new Map,m.forEach(w=>{var R,_;let f=document.createElement("li");f.setAttribute("role","group"),f.setAttribute("aria-roledescription","slide"),f.setAttribute("aria-label",`${w.index+1} of ${m.length}`);let x={li:f,loaderWrap:null,imgWrap:null,img:null,navLink:null};if(w.processed){let{imgWrap:B,img:G}=U(w);f.appendChild(B),x.imgWrap=B,x.img=G}else{let B=W();f.appendChild(B),x.loaderWrap=B}if(d.list.appendChild(f),d.slides.set(w,x),d.navList){let B=document.createElement("li"),G=ge();G.style.backgroundImage=`url("${Je((R=w.thumb)!=null?R:"")}")`;let a=w.index;G.addEventListener("click",()=>i.onNavigate(a),{signal:o}),G.appendChild(ee(`go to ${(_=w.caption)!=null?_:""}`)),B.appendChild(G),d.navList.appendChild(B),x.navLink=G}}),Q(l)}function ie(m,l){var f;if(l.imgWrap||!m.processed)return l;let{imgWrap:P,img:w}=U(m);return(f=l.loaderWrap)==null||f.replaceWith(P),l.loaderWrap=null,l.imgWrap=P,l.img=w,l}function V(m){m&&document.activeElement&&m.contains(document.activeElement)&&d.caption.focus()}function Q(m){let{viewer:l}=m;d.count.textContent=`${l.currentIndex+1}/${l.total}`,d.slides.forEach((P,w)=>{var R;let f=ie(w,P),x=w.index===l.currentIndex;f.li.style.transform=`translate(${w.translateX}px,${w.translateY}px)`,f.li.classList.toggle("current",x),x?f.li.removeAttribute("aria-hidden"):f.li.setAttribute("aria-hidden","true"),x&&(d.caption.textContent=(R=w.caption)!=null?R:""),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",x),x?f.navLink.setAttribute("aria-current","true"):f.navLink.removeAttribute("aria-current"))}),d.arrowLeft&&(l.showPrevArrow?d.arrowLeft.removeAttribute("aria-hidden"):(V(d.arrowLeft),d.arrowLeft.setAttribute("aria-hidden","true"))),d.arrowRight&&(l.showNextArrow?d.arrowRight.removeAttribute("aria-hidden"):(V(d.arrowRight),d.arrowRight.setAttribute("aria-hidden","true"))),d.arrows&&(l.hideUi&&V(d.arrows),d.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false")),d.nav&&(l.hideUi&&V(d.nav),d.nav.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function oe(m){for(let[l,P]of d.slides)if(l.index===m.viewer.currentIndex)return P;return null}function re(m){let{viewer:l}=m,P=oe(m),w=P==null?void 0:P.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&&V(d.nav),d.nav.setAttribute("aria-hidden",l.hideUi?"true":"false")),d.arrows&&(l.hideUi&&V(d.arrows),d.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function ne(m){let{viewer:l}=m;d.list.style.transform=`translate(${l.translateX}px,${l.translateY}px)`,d.list.classList.toggle(r.smartPhotoListOnMove,l.onMove)}function se(m){let l=document.createElement("img");l.className=r.smartPhotoImgClone,l.src=m.img,l.style.width=`${m.width}px`,l.style.height=`${m.height}px`,l.style.transform=`translate(${m.left}px,${m.top}px) scale(1)`,p.appendChild(l),d.imgClone=l}function ae(){var m;(m=d.imgClone)==null||m.remove(),d.imgClone=null}function le(){n.remove()}return{root:n,refs:d,render:Q,syncSlides:te,updatePhotoTransform:re,updateListTransform:ne,showAppearEffect:se,removeAppearEffect:ae,destroy:le}}function M(){return document.documentElement.clientWidth}function F(){let t=window.visualViewport;return t?t.height*t.scale:document.documentElement.clientHeight}function Ze(t){return t.length>0&&t[0]instanceof Element}function et(){return(Date.now().toString(36)+Math.random().toString(36).substring(2,7)).toUpperCase()}function Ye(){return{x:window.pageXOffset!==void 0?window.pageXOffset:document.documentElement.scrollLeft,y:window.pageYOffset!==void 0?window.pageYOffset:document.documentElement.scrollTop}}var K=class{constructor(e,i){this.id=et();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.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",`${F()}px`)};this.handleVisualViewportResize=()=>{this.updateViewportHeight(),!(!this.isSmartPhoneFlag||!this.state.viewer.isOpen||!A(this.state))&&(this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit())};this.handleResize=()=>{A(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(!A(this.state))return;this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit();let e=M(),i=500,o=r=>{this.scheduleTimeout(()=>{e!==M()?(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=Ae(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(),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){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=Ye();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=j(e,M(),F(),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,c,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(b=>b.id===e);if(!s)return;let n=document.activeElement instanceof HTMLElement?document.activeElement:null,u=(v=(c=i.trigger)!=null?c:s.element)!=null?v:n;this.openPhoto(s,u)}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)&&!Ze(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=me(e,this.state.options,o,M());return pe(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=Me(e,o,M());return pe(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(c=>q(c)===e),o=new Set(i),r=(p=this.state.groups.get(e))!=null?p:[],s=new Map;r.forEach(c=>{c.element&&s.set(c.element,c)});let n=i.length!==r.length,u=i.map((c,v)=>{let b=s.get(c);if(b)return b.index!==v&&(n=!0,b.index=v),b;n=!0;let y=me(c,this.state.options,v,M());return this.itemsByElement.set(c,y),y});return r.forEach(c=>{c.element&&!o.has(c.element)&&this.itemsByElement.delete(c.element)}),ve(u,M()),this.state.groups.set(e,u),n&&this.loadAllFired.delete(e),n}syncCurrentGroupView(){let e=A(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=Ye();this.setHash(Oe(this.state)),window.scroll(e.x,e.y)}restoreFromHash(){let e=location.hash.substring(1);return e?De(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=A(this.state);e&&ze(e,M(),F(),this.state.options.headerHeight,this.state.options.footerHeight)}resetTranslateCurrent(){ve(A(this.state),M())}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.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.syncDialog()}initPhoto(){var i;(i=this.finishHideEffect)==null||i.call(this),this.updateViewportHeight(),this.view.refs.dialog.style.opacity="";let e=A(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(),fe(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=j(o,M(),F(),this.isSmartPhoneFlag)}}supportsViewTransition(){return typeof document.startViewTransition=="function"}openPhotoWithViewTransition(e){var n,u;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=(u=document.startViewTransition)==null?void 0:u.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=Le(o),s=o.offsetWidth,n=o.offsetHeight,u=M(),p=F(),c=p-this.state.options.headerHeight-this.state.options.footerHeight,v=1;this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag?s>n?v=p/n:v=u/s:(s>=n?i.height<c?v=i.width/s:v=c/n:i.height<c?v=i.height/n:v=c/n,s*v>u&&(v=u/s));let b=(v-1)/2*s+(u-s*v)/2,y=(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:b,afterY:y,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=M(),i=F();requestAnimationFrame(()=>{this.state.viewer.isOpen&&(M()===e&&F()===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=F(),n=e==="top"?`translateY(-${s}px)`:`translateY(${s}px)`,u=()=>{this.finishHideEffect===u&&(this.finishHideEffect=null,o.removeEventListener("transitionend",u,!0),r&&r.style.transform===n&&(r.style.transform=""),i())};this.finishHideEffect=u,r&&(r.style.transform=n),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=A(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,fe(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}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",Ce(o))}fireEvent(e){Ie(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 tt=K;return Ue(it);})();
7
7
  SmartPhoto = SmartPhoto.default;
package/lib/smartphoto.js CHANGED
@@ -79,6 +79,41 @@ var getViewPos = (element) => {
79
79
  top: element.getBoundingClientRect().top
80
80
  };
81
81
  };
82
+ var parseRgb = (value) => {
83
+ const match = value.match(
84
+ /rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*[\d.]+\s*)?\)/
85
+ );
86
+ if (!match) {
87
+ return null;
88
+ }
89
+ return [Number(match[1]), Number(match[2]), Number(match[3])];
90
+ };
91
+ var CONTRAST_LUMINANCE_THRESHOLD = 0.179;
92
+ var relativeLuminance = ([r, g, b]) => {
93
+ const [rl, gl, bl] = [r, g, b].map((c) => {
94
+ const v = c / 255;
95
+ return v <= 0.03928 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4;
96
+ });
97
+ return 0.2126 * rl + 0.7152 * gl + 0.0722 * bl;
98
+ };
99
+ var getContrastColor = (colorValue) => {
100
+ const trimmed = colorValue.trim();
101
+ let rgb = parseRgb(trimmed);
102
+ if (!rgb) {
103
+ const probe = document.createElement("div");
104
+ probe.style.color = trimmed;
105
+ if (!probe.style.color) {
106
+ return "#fff";
107
+ }
108
+ document.body.appendChild(probe);
109
+ rgb = parseRgb(getComputedStyle(probe).color);
110
+ document.body.removeChild(probe);
111
+ }
112
+ if (!rgb) {
113
+ return "#fff";
114
+ }
115
+ return relativeLuminance(rgb) > CONTRAST_LUMINANCE_THRESHOLD ? "#000" : "#fff";
116
+ };
82
117
 
83
118
  // src/core/state.ts
84
119
  var defaults = {
@@ -1189,13 +1224,28 @@ var SmartPhoto = class {
1189
1224
  this.openPhoto(item, matched);
1190
1225
  }
1191
1226
  };
1192
- // ---- 内部: window イベント ----
1193
1227
  this.updateViewportHeight = () => {
1194
1228
  this.view.refs.dialog.style.setProperty(
1195
1229
  "--smartphoto-vh",
1196
1230
  `${getWindowHeight()}px`
1197
1231
  );
1198
1232
  };
1233
+ // iOS Safari 等ではアドレスバーの表示/非表示に伴う visualViewport の変化が
1234
+ // orientationchange を伴わず resize としてのみ発火する。スマートフォンでは
1235
+ // window の resize を購読していない(§コンストラクタ)ため、ここで拾わないと
1236
+ // 開いている間ずっと古い高さで計算された item.x/y がインラインスタイルに
1237
+ // 残り続け、表示中のスライドだけ位置がずれて見える(§Issue #95: スワイプ
1238
+ // ダウンで閉じて再度開いた際、閉じた瞬間表示していたスライドだけ縦位置がずれる)
1239
+ this.handleVisualViewportResize = () => {
1240
+ this.updateViewportHeight();
1241
+ if (!this.isSmartPhoneFlag || !this.state.viewer.isOpen || !currentItems(this.state)) {
1242
+ return;
1243
+ }
1244
+ this.resetTranslateCurrent();
1245
+ this.setPosByCurrentIndex();
1246
+ this.setSizeByScreen();
1247
+ this.commit();
1248
+ };
1199
1249
  this.handleResize = () => {
1200
1250
  if (!currentItems(this.state)) {
1201
1251
  return;
@@ -1279,10 +1329,11 @@ var SmartPhoto = class {
1279
1329
  this.openPhoto(restored, restored.element);
1280
1330
  }
1281
1331
  this.updateViewportHeight();
1332
+ this.applyAutoIconContrast();
1282
1333
  if (window.visualViewport) {
1283
1334
  window.visualViewport.addEventListener(
1284
1335
  "resize",
1285
- this.updateViewportHeight,
1336
+ this.handleVisualViewportResize,
1286
1337
  { signal: this.abortController.signal }
1287
1338
  );
1288
1339
  } else {
@@ -1626,6 +1677,7 @@ var SmartPhoto = class {
1626
1677
  // (doOpen/loadNeighborItems/slideList のいずれも呼び出し前に確認済み)
1627
1678
  initPhoto() {
1628
1679
  this.finishHideEffect?.();
1680
+ this.updateViewportHeight();
1629
1681
  this.view.refs.dialog.style.opacity = "";
1630
1682
  const items = currentItems(this.state);
1631
1683
  this.state.viewer.total = items.length;
@@ -1923,6 +1975,30 @@ var SmartPhoto = class {
1923
1975
  this.timeouts.push(id);
1924
1976
  return id;
1925
1977
  }
1978
+ // ---- 内部: window イベント ----
1979
+ // --smartphoto-backdrop-color をホスト側 CSS が明示指定している場合のみ、
1980
+ // その背景色に対してコントラストの高い文字色/アイコン色(#000 or #fff)を
1981
+ // --smartphoto-icon-color として自動算出する。未指定(デフォルトの黒背景)の
1982
+ // ときは何もせず、CSS 側のフォールバック(既存の白固定)のままにする。
1983
+ // ホスト側 CSS が --smartphoto-icon-color 自体を明示指定している場合は、
1984
+ // 自動判定が誤検知したときの最終防衛ラインとしてその指定を必ず優先し、
1985
+ // 自動算出では上書きしない(dialog 要素へインラインスタイルで設定すると、
1986
+ // 後から通常の CSS ルールで !important なしに上書きできなくなるため)
1987
+ applyAutoIconContrast() {
1988
+ const dialog = this.view.refs.dialog;
1989
+ const computed = getComputedStyle(dialog);
1990
+ if (computed.getPropertyValue("--smartphoto-icon-color").trim()) {
1991
+ return;
1992
+ }
1993
+ const backdropColor = computed.getPropertyValue("--smartphoto-backdrop-color").trim();
1994
+ if (!backdropColor) {
1995
+ return;
1996
+ }
1997
+ dialog.style.setProperty(
1998
+ "--smartphoto-icon-color",
1999
+ getContrastColor(backdropColor)
2000
+ );
2001
+ }
1926
2002
  // ---- 内部: イベント発火 ----
1927
2003
  fireEvent(eventName) {
1928
2004
  triggerEvent(this.view.refs.dialog, eventName);
@@ -53,6 +53,41 @@ var getViewPos = (element) => {
53
53
  top: element.getBoundingClientRect().top
54
54
  };
55
55
  };
56
+ var parseRgb = (value) => {
57
+ const match = value.match(
58
+ /rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*[\d.]+\s*)?\)/
59
+ );
60
+ if (!match) {
61
+ return null;
62
+ }
63
+ return [Number(match[1]), Number(match[2]), Number(match[3])];
64
+ };
65
+ var CONTRAST_LUMINANCE_THRESHOLD = 0.179;
66
+ var relativeLuminance = ([r, g, b]) => {
67
+ const [rl, gl, bl] = [r, g, b].map((c) => {
68
+ const v = c / 255;
69
+ return v <= 0.03928 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4;
70
+ });
71
+ return 0.2126 * rl + 0.7152 * gl + 0.0722 * bl;
72
+ };
73
+ var getContrastColor = (colorValue) => {
74
+ const trimmed = colorValue.trim();
75
+ let rgb = parseRgb(trimmed);
76
+ if (!rgb) {
77
+ const probe = document.createElement("div");
78
+ probe.style.color = trimmed;
79
+ if (!probe.style.color) {
80
+ return "#fff";
81
+ }
82
+ document.body.appendChild(probe);
83
+ rgb = parseRgb(getComputedStyle(probe).color);
84
+ document.body.removeChild(probe);
85
+ }
86
+ if (!rgb) {
87
+ return "#fff";
88
+ }
89
+ return relativeLuminance(rgb) > CONTRAST_LUMINANCE_THRESHOLD ? "#000" : "#fff";
90
+ };
56
91
 
57
92
  // src/core/state.ts
58
93
  var defaults = {
@@ -1163,13 +1198,28 @@ var SmartPhoto = class {
1163
1198
  this.openPhoto(item, matched);
1164
1199
  }
1165
1200
  };
1166
- // ---- 内部: window イベント ----
1167
1201
  this.updateViewportHeight = () => {
1168
1202
  this.view.refs.dialog.style.setProperty(
1169
1203
  "--smartphoto-vh",
1170
1204
  `${getWindowHeight()}px`
1171
1205
  );
1172
1206
  };
1207
+ // iOS Safari 等ではアドレスバーの表示/非表示に伴う visualViewport の変化が
1208
+ // orientationchange を伴わず resize としてのみ発火する。スマートフォンでは
1209
+ // window の resize を購読していない(§コンストラクタ)ため、ここで拾わないと
1210
+ // 開いている間ずっと古い高さで計算された item.x/y がインラインスタイルに
1211
+ // 残り続け、表示中のスライドだけ位置がずれて見える(§Issue #95: スワイプ
1212
+ // ダウンで閉じて再度開いた際、閉じた瞬間表示していたスライドだけ縦位置がずれる)
1213
+ this.handleVisualViewportResize = () => {
1214
+ this.updateViewportHeight();
1215
+ if (!this.isSmartPhoneFlag || !this.state.viewer.isOpen || !currentItems(this.state)) {
1216
+ return;
1217
+ }
1218
+ this.resetTranslateCurrent();
1219
+ this.setPosByCurrentIndex();
1220
+ this.setSizeByScreen();
1221
+ this.commit();
1222
+ };
1173
1223
  this.handleResize = () => {
1174
1224
  if (!currentItems(this.state)) {
1175
1225
  return;
@@ -1253,10 +1303,11 @@ var SmartPhoto = class {
1253
1303
  this.openPhoto(restored, restored.element);
1254
1304
  }
1255
1305
  this.updateViewportHeight();
1306
+ this.applyAutoIconContrast();
1256
1307
  if (window.visualViewport) {
1257
1308
  window.visualViewport.addEventListener(
1258
1309
  "resize",
1259
- this.updateViewportHeight,
1310
+ this.handleVisualViewportResize,
1260
1311
  { signal: this.abortController.signal }
1261
1312
  );
1262
1313
  } else {
@@ -1600,6 +1651,7 @@ var SmartPhoto = class {
1600
1651
  // (doOpen/loadNeighborItems/slideList のいずれも呼び出し前に確認済み)
1601
1652
  initPhoto() {
1602
1653
  this.finishHideEffect?.();
1654
+ this.updateViewportHeight();
1603
1655
  this.view.refs.dialog.style.opacity = "";
1604
1656
  const items = currentItems(this.state);
1605
1657
  this.state.viewer.total = items.length;
@@ -1897,6 +1949,30 @@ var SmartPhoto = class {
1897
1949
  this.timeouts.push(id);
1898
1950
  return id;
1899
1951
  }
1952
+ // ---- 内部: window イベント ----
1953
+ // --smartphoto-backdrop-color をホスト側 CSS が明示指定している場合のみ、
1954
+ // その背景色に対してコントラストの高い文字色/アイコン色(#000 or #fff)を
1955
+ // --smartphoto-icon-color として自動算出する。未指定(デフォルトの黒背景)の
1956
+ // ときは何もせず、CSS 側のフォールバック(既存の白固定)のままにする。
1957
+ // ホスト側 CSS が --smartphoto-icon-color 自体を明示指定している場合は、
1958
+ // 自動判定が誤検知したときの最終防衛ラインとしてその指定を必ず優先し、
1959
+ // 自動算出では上書きしない(dialog 要素へインラインスタイルで設定すると、
1960
+ // 後から通常の CSS ルールで !important なしに上書きできなくなるため)
1961
+ applyAutoIconContrast() {
1962
+ const dialog = this.view.refs.dialog;
1963
+ const computed = getComputedStyle(dialog);
1964
+ if (computed.getPropertyValue("--smartphoto-icon-color").trim()) {
1965
+ return;
1966
+ }
1967
+ const backdropColor = computed.getPropertyValue("--smartphoto-backdrop-color").trim();
1968
+ if (!backdropColor) {
1969
+ return;
1970
+ }
1971
+ dialog.style.setProperty(
1972
+ "--smartphoto-icon-color",
1973
+ getContrastColor(backdropColor)
1974
+ );
1975
+ }
1900
1976
  // ---- 内部: イベント発火 ----
1901
1977
  fireEvent(eventName) {
1902
1978
  triggerEvent(this.view.refs.dialog, eventName);
@@ -63,7 +63,9 @@ export default class SmartPhoto {
63
63
  private loadNeighborItems;
64
64
  private slideList;
65
65
  private scheduleTimeout;
66
+ private applyAutoIconContrast;
66
67
  private updateViewportHeight;
68
+ private handleVisualViewportResize;
67
69
  private handleResize;
68
70
  private handleKeydown;
69
71
  private handleOrientationChange;
@@ -8,4 +8,5 @@ export declare const getViewPos: (element: Element) => {
8
8
  top: number;
9
9
  };
10
10
  export declare const removeElement: (element?: Element | null) => void;
11
+ export declare const getContrastColor: (colorValue: string) => string;
11
12
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smartphoto",
3
- "version": "2.1.7",
3
+ "version": "2.1.9",
4
4
  "description": "smartphoto",
5
5
  "homepage": "https://developer.a-blogcms.jp",
6
6
  "main": "./lib/smartphoto.js",