smartphoto 2.1.12 → 2.1.14

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.
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * SmartPhoto v2.1.12
2
+ * SmartPhoto v2.1.14
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 xe(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]=xe((i=t[s])!=null?i:{},n):t[s]=n}}}return t}var Ie=xe,Le=(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)},Ce=t=>{let e={};for(let i of t.split("&")){let o=i.split("="),r=o[0],s=o.length>1?o.slice(1).join("="):r;e[r]=decodeURIComponent(s)}return e},Z=()=>document.documentElement.clientWidth,ee=()=>{let t=window.visualViewport;return t?t.height*t.scale:document.documentElement.clientHeight},Te=t=>({left:t.getBoundingClientRect().left,top:t.getBoundingClientRect().top});var Se=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},Re=.179,$e=([t,e,i])=>{let[o,r,s]=[t,e,i].map(n=>{let c=n/255;return c<=.03928?c/12.92:((c+.055)/1.055)**2.4});return .2126*o+.7152*r+.0722*s},Ae=t=>{let e=t.trim(),i=Se(e);if(!i){let o=document.createElement("div");if(o.style.color=e,!o.style.color)return"#fff";document.body.appendChild(o),i=Se(getComputedStyle(o).color),document.body.removeChild(o)}return i&&$e(i)>Re?"#000":"#fff"};var Ue={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 Me(t){return Object.keys(t).forEach(e=>{let i=t[e];i&&typeof i=="object"&&!Object.isFrozen(i)&&Me(i)}),Object.freeze(t)}function He(t){return{options:Me(Ie({},Ue,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 me(t){return t.group||"nogroup"}function pe(t,e,i,o){let r=q(t),s=t.getAttribute("href"),n=t.querySelector("img"),c=s;n&&(n.getAttribute(e.lazyAttribute)?c=n.getAttribute(e.lazyAttribute):n.currentSrc?c=n.currentSrc:c=n.src);let u="";n!=null&&n.getAttribute("alt")?u=n.getAttribute("alt"):t.getAttribute("data-caption")?u=t.getAttribute("data-caption"):u=s!=null?s:"";let d=t.getAttribute("data-id");return{src:s,thumb:c,caption:t.getAttribute("data-caption"),alt:u,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 ze(t,e,i){var d,v,y,P,S;let o=me(t),r=t.src,s=(d=t.thumb)!=null?d:r,n=(v=t.caption)!=null?v:null,c=(P=(y=t.alt)!=null?y:n)!=null?P:r,u=typeof t.width=="number"&&typeof t.height=="number";return{src:r,thumb:s,caption:n,alt:c,groupId:o,translateX:i*e,translateY:0,index:e,width:u?t.width:50,height:u?t.height:50,scale:1,x:0,y:0,id:(S=t.id)!=null?S:e,loaded:u,processed:!1,element:null}}function fe(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 ve(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 we(t,e){t.forEach((i,o)=>{i.translateX=e*o})}function te(t,e){let i=10**e;return Math.round(t*i)/i}function 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 Oe(t,e,i,o){let r=t.width*t.scale*e.scaleSize,s=t.height*t.scale*e.scaleSize,n,c,u,d;return i>r?(u=(i-r)/2,n=-1*u):(u=(r-i)/2,n=-1*u),o>s?(d=(o-s)/2,c=-1*d):(d=(s-o)/2,c=-1*d),{minX:te(n,6)*e.scaleSize,minY:te(c,6)*e.scaleSize,maxX:te(u,6)*e.scaleSize,maxY:te(d,6)*e.scaleSize}}function De(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 Ne(t){let e=z(t);return e?`group=${t.viewer.currentGroup}&photo=${e.id}`:""}function Ve(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 ge(t,e){let i=10**e;return Math.round(t*i)/i}function R(t){return{x:t.pageX,y:t.pageY}}function Be(t,e){let i=t.x-e.x,o=t.y-e.y;return Math.sqrt(i*i+o*o)}var je=10;function qe(t,e){return{force:Math.sqrt(t*t+e*e),theta:Math.atan2(e,t)}}function Xe(){return{width:Z(),height:ee()}}function Ye({state:t,callbacks:e},{signal:i}){let o=new Map,r=Date.now(),s=!1,n=!1,c=null,u=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 m(){return K()}function $(a){let{width:h,height:E}=Xe();return Oe(a,t.viewer,h,E)}function U(a){let{width:h,height:E}=Xe();return Q(a,h,E,m())}function oe(a,h){let E=z(t),g=$(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 re=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=$(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 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 ne(){H=!0,s=!1,y=!1;let a=Array.from(o.values());Y=Be(a[0],a[1]),t.viewer.scale=!0,e.onGestureStart()}function se(a){let h=R(a);s=!0,n=!0,c=h,u=h,v=Date.now()}function ae(a){y=!0;let h=R(a);S=h,P=h}function le(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){ne();return}if(t.viewer.scale){ae(a);return}se(a)}function he(){x===null&&(x=requestAnimationFrame(()=>{x=null,e.onGestureMove()}))}function ue(){x!==null&&(cancelAnimationFrame(x),x=null,e.onGestureMove())}function p(){let a=Array.from(o.values()),h=Be(a[0],a[1]),E=(h-Y)/100,g=t.viewer.scaleSize,L=t.viewer.photoPosX,T=t.viewer.photoPosY;t.viewer.scaleSize+=ge(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 de=U(X);t.viewer.hideUi=t.viewer.scaleSize<1||t.viewer.scaleSize>de}Y=h,he()}function l(a){let h=R(a),E=h.x-u.x,g=h.y-c.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,u=h,e.onSwipeMove()}function b(a){let h=R(a),E=h.x-S.x,g=h.y-S.y,L=ge(t.viewer.scaleSize*E,6),T=ge(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)),H){p();return}if(y){b(a);return}l(a)}}function f(){H=!1,ue();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 be;s=!1;let a=c,h=u,E=Date.now(),g=r-E,L=h.x-a.x,T=h.y-a.y,X=L===0&&T===0;if(!m()&&X){e.onTap();return}if(Math.abs(g)<=500&&X){e.onTap();return}r=E;let de=(be=A(t))!=null?be:[];if(d==="horizontal"){let F="stay",Fe=Math.max(E-v,1),Pe=Math.abs(L)>=je&&Math.abs(L)/Fe>=t.options.swipeVelocity;(L>=t.options.swipeOffset||Pe&&L>0)&&t.viewer.currentIndex!==0?F="prev":(L<=-t.options.swipeOffset||Pe&&L<0)&&t.viewer.currentIndex!==de.length-1&&(F="next"),e.onSwipeEnd(F)}else{let F="stay";t.options.swipeBottomToClose&&T>=t.options.swipeOffset?F="close-bottom":t.options.swipeTopToClose&&T<=-t.options.swipeOffset&&(F="close-top"),e.onSwipeEnd(F)}}function W(){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=$(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):oe(T,X),e.onPhotoDragEnd(null)}function j(a){if(o.delete(a.pointerId),H){o.size<2&&f();return}if(y){W();return}s&&I()}function B(...a){for(let h of a)h.addEventListener("pointerdown",le,{signal:i}),h.addEventListener("pointermove",w,{signal:i}),h.addEventListener("pointerup",j,{signal:i}),h.addEventListener("pointercancel",j,{signal:i})}function G(){clearInterval(re),x!==null&&(cancelAnimationFrame(x),x=null)}return{attach:B,detach:G}}function ie(t){let e=document.createElement("span");return e.className="smartphoto-sr-only",e.textContent=t,e}function Ee(){let t=document.createElement("button");return t.type="button",t}function Qe(t){return t.replace(/"/g,'\\"')}function Ge({id:t,options:e},i,{signal:o}){let{classNames:r,message:s}=e,n=document.createElement("div");n.setAttribute("data-id",t);let c=document.createElement("dialog");c.className=r.smartPhoto,c.setAttribute("aria-labelledby",`smartphoto-${t}-title`),c.style.display="none",c.style.setProperty("--smartphoto-animation-speed",`${e.animationSpeed}ms`);let u=document.createElement("div");u.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(ie(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",p=>{p.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 p=Ee();p.appendChild(ie(s.gotoPrevImage)),p.addEventListener("click",()=>i.onPrev(),{signal:o}),Y.appendChild(p),x=document.createElement("li"),x.className=r.smartPhotoArrowRight;let l=Ee();l.appendChild(ie(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)),u.appendChild(d),c.appendChild(u),n.appendChild(c);let m={dialog:c,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 $(){let p=document.createElement("div");p.className=r.smartPhotoLoaderWrap;let l=document.createElement("span");return l.className=r.smartPhotoLoader,p.appendChild(l),p}function U(p){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=p.src)!=null?w:"",b.alt=(f=p.alt)!=null?f:"",b.addEventListener("dragstart",I=>I.preventDefault(),{signal:o}),l.appendChild(b),{imgWrap:l,img:b}}function oe(p,l){var b;m.list.replaceChildren(),(b=m.navList)==null||b.replaceChildren(),m.slides=new Map,p.forEach(w=>{var W,j;let f=document.createElement("li");f.setAttribute("role","group"),f.setAttribute("aria-roledescription","slide"),f.setAttribute("aria-label",`${w.index+1} of ${p.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=$();f.appendChild(B),I.loaderWrap=B}if(m.list.appendChild(f),m.slides.set(w,I),m.navList){let B=document.createElement("li"),G=Ee();G.style.backgroundImage=`url("${Qe((W=w.thumb)!=null?W:"")}")`;let a=w.index;G.addEventListener("click",()=>i.onNavigate(a),{signal:o}),G.appendChild(ie(`go to ${(j=w.caption)!=null?j:""}`)),B.appendChild(G),m.navList.appendChild(B),I.navLink=G}}),J(l)}function re(p,l){var f;if(l.imgWrap||!p.processed)return l;let{imgWrap:b,img:w}=U(p);return(f=l.loaderWrap)==null||f.replaceWith(b),l.loaderWrap=null,l.imgWrap=b,l.img=w,l}function V(p){p&&document.activeElement&&p.contains(document.activeElement)&&m.caption.focus()}function J(p){let{viewer:l}=p;m.count.textContent=`${l.currentIndex+1}/${l.total}`,m.slides.forEach((b,w)=>{var W;let f=re(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&&(m.caption.textContent=(W=w.caption)!=null?W:""),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"))}),m.arrowLeft&&(l.showPrevArrow?m.arrowLeft.removeAttribute("aria-hidden"):(V(m.arrowLeft),m.arrowLeft.setAttribute("aria-hidden","true"))),m.arrowRight&&(l.showNextArrow?m.arrowRight.removeAttribute("aria-hidden"):(V(m.arrowRight),m.arrowRight.setAttribute("aria-hidden","true"))),m.arrows&&(l.hideUi&&V(m.arrows),m.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false")),m.nav&&(l.hideUi&&V(m.nav),m.nav.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function ne(p){for(let[l,b]of m.slides)if(l.index===p.viewer.currentIndex)return b;return null}function se(p){let{viewer:l}=p,b=ne(p),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)),m.nav&&(l.hideUi&&V(m.nav),m.nav.setAttribute("aria-hidden",l.hideUi?"true":"false")),m.arrows&&(l.hideUi&&V(m.arrows),m.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function ae(p){let{viewer:l}=p;m.list.style.transform=`translate(${l.translateX}px,${l.translateY}px)`,m.list.classList.toggle(r.smartPhotoListOnMove,l.onMove)}function le(p){let l=document.createElement("img");l.className=r.smartPhotoImgClone,l.src=p.img,l.style.width=`${p.width}px`,l.style.height=`${p.height}px`,l.style.transform=`translate(${p.left}px,${p.top}px) scale(1)`,u.appendChild(l),m.imgClone=l}function he(){var p;(p=m.imgClone)==null||p.remove(),m.imgClone=null}function ue(){n.remove()}return{root:n,refs:m,render:J,syncSlides:oe,updatePhotoTransform:se,updateListTransform:ae,showAppearEffect:le,removeAppearEffect:he,destroy:ue}}var M=Z,k=ee;function _e(t){return t.length>0&&t[0]instanceof Element}function Je(){return(Date.now().toString(36)+Math.random().toString(36).substring(2,7)).toUpperCase()}function ke(){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=Je();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=He(i!=null?i:{}),this.view=Ge({id:this.id,options:this.state.options},this.buildViewHandlers(),{signal:this.abortController.signal}),document.body.appendChild(this.view.root),this.gestures=Ye({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=ke();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 u,d,v;let o=(u=i.group)!=null?u: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,c=(v=(d=i.trigger)!=null?d:s.element)!=null?v:n;this.openPhoto(s,c)}hide(){this.hidePhoto()}next(){this.state.viewer.showNextArrow&&this.gotoSlide(this.state.viewer.next)}prev(){this.state.viewer.showPrevArrow&&this.gotoSlide(this.state.viewer.prev)}addItem(e){let i=e instanceof HTMLElement?this.addElementItem(e):this.addSlideItem(e);return this.syncCurrentGroupView(),i}get currentIndex(){return this.state.viewer.currentIndex}ingestSource(e){if(Array.isArray(e)&&!_e(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=pe(e,this.state.options,o,M());return fe(this.state,r),this.loadAllFired.delete(i),this.itemsByElement.set(e,r),r}addSlideItem(e){var s,n;let i=me(e),o=(n=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?n:0,r=ze(e,o,M());return fe(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 u;if(!this.rootSelector)return!1;let i=Array.from(document.querySelectorAll(this.rootSelector)).filter(d=>q(d)===e),o=new Set(i),r=(u=this.state.groups.get(e))!=null?u:[],s=new Map;r.forEach(d=>{d.element&&s.set(d.element,d)});let n=i.length!==r.length,c=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=pe(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)}),we(c,M()),this.state.groups.set(e,c),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=ke();this.setHash(Ne(this.state)),window.scroll(e.x,e.y)}restoreFromHash(){let e=location.hash.substring(1);return e?Ve(this.state,Ce(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&&De(e,M(),k(),this.state.options.headerHeight,this.state.options.footerHeight)}resetTranslateCurrent(){we(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(),ve(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,c;document.documentElement.style.setProperty("--smartphoto-animation-speed",`${this.state.options.animationSpeed}ms`);let i="smartphoto-hero",o=(n=e==null?void 0:e.querySelector("img"))!=null?n:null;o&&(o.style.viewTransitionName=i);let r=()=>{o&&(o.style.viewTransitionName="");let u=this.currentImgElement();u&&(u.style.viewTransitionName="")},s=(c=document.startViewTransition)==null?void 0:c.call(document,()=>{this.initPhoto(),this.state.viewer.appear=!0,this.commit(),o&&(o.style.viewTransitionName=""),this.currentImgElement().style.viewTransitionName=i});s==null||s.ready.catch(()=>{r()}),s==null||s.finished.then(r,r)}addAppearEffect(e,i){var O;let o=(O=e==null?void 0:e.querySelector("img"))!=null?O:null;if(!o){this.state.viewer.appear=!0;return}let r=Te(o),s=o.offsetWidth,n=o.offsetHeight,c=M(),u=k(),d=u-this.state.options.headerHeight-this.state.options.footerHeight,v=1;this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag?s>n?v=u/n:v=c/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>c&&(v=c/s));let y=(v-1)/2*s+(c-s*v)/2,P=(v-1)/2*n+(u-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)`;r&&(r.style.transform=n);let c=r?r.style.transform:"",u=()=>{this.finishHideEffect===u&&(this.finishHideEffect=null,o.removeEventListener("transitionend",u,!0),r&&r.style.transform===c&&(r.style.transform=""),i())};this.finishHideEffect=u,o.addEventListener("transitionend",u,!0),this.scheduleTimeout(u,this.state.options.animationSpeed+100)})}loadItem(e){return new Promise(i=>{var r;let o=new Image;o.onload=()=>{e.width=o.width,e.height=o.height,e.loaded=!0,this.checkLoadAll(e.groupId),i()},o.onerror=()=>i(),o.src=(r=e.src)!=null?r:""})}checkLoadAll(e){if(this.loadAllFired.has(e))return;let i=this.state.groups.get(e);i!=null&&i.length&&i.every(o=>o.loaded)&&(this.loadAllFired.add(e),this.fireEvent("loadall"))}loadNeighborItems(){let e=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.state.viewer.isOpen&&(this.initPhoto(),this.commit())})}slideList(){this.state.viewer.scaleSize=1,this.state.viewer.hideUi=!1,this.state.viewer.scale=!1,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.state.viewer.onMove=!0,this.updateViewportHeight(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.scheduleTimeout(()=>{let e=z(this.state);this.state.viewer.onMove=!1,ve(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.state.viewer.isOpen&&(this.initPhoto(),this.commit())})},200)}scheduleTimeout(e,i){let o=window.setTimeout(()=>{this.timeouts=this.timeouts.filter(r=>r!==o),e()},i);return this.timeouts.push(o),o}applyAutoIconContrast(){let e=this.view.refs.dialog,i=getComputedStyle(e);if(i.getPropertyValue("--smartphoto-icon-color").trim())return;let o=i.getPropertyValue("--smartphoto-backdrop-color").trim();o&&e.style.setProperty("--smartphoto-icon-color",Ae(o))}fireEvent(e){Le(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 We=_;var ye=t=>{t.fn.SmartPhoto=function(e){return typeof e=="string"||new We(this,e),this}};if(typeof define=="function"&&define.amd)define(["jquery"],ye);else{let t=window,e=t.jQuery?t.jQuery:t.$;typeof e!="undefined"&&ye(e)}var ht=ye;})();
6
+ "use strict";(()=>{var K=()=>{let t=navigator.userAgent;return t.indexOf("iPhone")>0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0},Ie=()=>typeof window.webkitConvertPointFromNodeToPage=="function";function Le(t,...e){var i;t=t||{};for(let o=0;o<e.length;o++){let r=e[o];if(r){for(let s in r)if(Object.hasOwn(r,s)){let n=r[s];n&&typeof n=="object"?t[s]=Le((i=t[s])!=null?i:{},n):t[s]=n}}}return t}var Te=Le,Ce=(t,e,i)=>{let o;window.CustomEvent?o=new CustomEvent(e,{cancelable:!0}):(o=document.createEvent("CustomEvent"),o.initCustomEvent(e,!1,!1,i)),t.dispatchEvent(o)},Ae=t=>{let e={};for(let i of t.split("&")){let o=i.split("="),r=o[0],s=o.length>1?o.slice(1).join("="):r;e[r]=decodeURIComponent(s)}return e},Z=()=>document.documentElement.clientWidth,ee=()=>{let t=window.visualViewport;return t?t.height*t.scale:document.documentElement.clientHeight},He=t=>({left:t.getBoundingClientRect().left,top:t.getBoundingClientRect().top});var xe=t=>{let e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*[\d.]+\s*)?\)/);return e?[Number(e[1]),Number(e[2]),Number(e[3])]:null},Ue=.179,je=([t,e,i])=>{let[o,r,s]=[t,e,i].map(n=>{let m=n/255;return m<=.03928?m/12.92:((m+.055)/1.055)**2.4});return .2126*o+.7152*r+.0722*s},Me=t=>{let e=t.trim(),i=xe(e);if(!i){let o=document.createElement("div");if(o.style.color=e,!o.style.color)return"#fff";document.body.appendChild(o),i=xe(getComputedStyle(o).color),document.body.removeChild(o)}return i&&je(i)>Ue?"#000":"#fff"};var qe={classNames:{smartPhoto:"smartphoto",smartPhotoClose:"smartphoto-close",smartPhotoBody:"smartphoto-body",smartPhotoInner:"smartphoto-inner",smartPhotoContent:"smartphoto-content",smartPhotoImg:"smartphoto-img",smartPhotoImgOnMove:"smartphoto-img-onmove",smartPhotoImgElasticMove:"smartphoto-img-elasticmove",smartPhotoImgWrap:"smartphoto-img-wrap",smartPhotoArrows:"smartphoto-arrows",smartPhotoNav:"smartphoto-nav",smartPhotoArrowRight:"smartphoto-arrow-right",smartPhotoArrowLeft:"smartphoto-arrow-left",smartPhotoArrowHideIcon:"smartphoto-arrow-hide",smartPhotoImgLeft:"smartphoto-img-left",smartPhotoImgRight:"smartphoto-img-right",smartPhotoList:"smartphoto-list",smartPhotoListOnMove:"smartphoto-list-onmove",smartPhotoHeader:"smartphoto-header",smartPhotoCount:"smartphoto-count",smartPhotoCaption:"smartphoto-caption",smartPhotoDismiss:"smartphoto-dismiss",smartPhotoLoader:"smartphoto-loader",smartPhotoLoaderWrap:"smartphoto-loader-wrap",smartPhotoImgClone:"smartphoto-img-clone"},message:{gotoNextImage:"go to the next image",gotoPrevImage:"go to the previous image",closeDialog:"close the image dialog",carouselLabel:"Images"},arrows:!0,nav:!0,showAnimation:!0,verticalGravity:!1,useOrientationApi:!1,useHistoryApi:!0,useViewTransitionApi:!0,swipeTopToClose:!1,swipeBottomToClose:!0,swipeOffset:100,swipeVelocity:.5,headerHeight:60,footerHeight:60,forceInterval:10,registance:.5,loadOffset:2,resizeStyle:"fit",lazyAttribute:"data-src",animationSpeed:450};function Ve(t){return Object.keys(t).forEach(e=>{let i=t[e];i&&typeof i=="object"&&!Object.isFrozen(i)&&Ve(i)}),Object.freeze(t)}function ze(t){return{options:Ve(Te({},qe,t)),viewer:{isOpen:!1,currentGroup:null,currentIndex:0,oldIndex:0,total:0,translateX:0,translateY:0,photoPosX:0,photoPosY:0,scaleSize:1,scale:!1,elastic:!1,hideUi:!1,onMove:!1,appear:!1,appearEffect:null,prev:-1,next:-1,showPrevArrow:!1,showNextArrow:!1},groups:new Map}}function j(t){return t.getAttribute("data-group")||"nogroup"}function pe(t){return t.group||"nogroup"}function fe(t,e,i,o){let r=j(t),s=t.getAttribute("href"),n=t.querySelector("img"),m=s;n&&(n.getAttribute(e.lazyAttribute)?m=n.getAttribute(e.lazyAttribute):n.currentSrc?m=n.currentSrc:m=n.src);let p="";n!=null&&n.getAttribute("alt")?p=n.getAttribute("alt"):t.getAttribute("data-caption")?p=t.getAttribute("data-caption"):p=s!=null?s:"";let u=t.getAttribute("data-id");return{src:s,thumb:m,caption:t.getAttribute("data-caption"),alt:p,groupId:r,translateX:o*i,translateY:0,index:i,width:50,height:50,scale:1,x:0,y:0,id:u||i,loaded:!1,processed:!1,element:t}}function Oe(t,e,i){var u,f,P,b,H;let o=pe(t),r=t.src,s=(u=t.thumb)!=null?u:r,n=(f=t.caption)!=null?f:null,m=(b=(P=t.alt)!=null?P:n)!=null?b:r,p=typeof t.width=="number"&&typeof t.height=="number";return{src:r,thumb:s,caption:n,alt:m,groupId:o,translateX:i*e,translateY:0,index:e,width:p?t.width:50,height:p?t.height:50,scale:1,x:0,y:0,id:(H=t.id)!=null?H:e,loaded:p,processed:!1,element:null}}function ve(t,e){t.groups.has(e.groupId)||t.groups.set(e.groupId,[]),t.groups.get(e.groupId).push(e),t.viewer.currentGroup=e.groupId}function L(t){var e;return t.viewer.currentGroup===null?null:(e=t.groups.get(t.viewer.currentGroup))!=null?e:null}function C(t){var i;let e=L(t);return e&&(i=e[t.viewer.currentIndex])!=null?i:null}function we(t){let e=L(t);if(!e)return;let i=e.length,o=t.viewer.currentIndex+1,r=t.viewer.currentIndex-1;t.viewer.showNextArrow=!1,t.viewer.showPrevArrow=!1,o!==i&&(t.viewer.next=o,t.viewer.showNextArrow=!0),r!==-1&&(t.viewer.prev=r,t.viewer.showPrevArrow=!0)}function ge(t,e){t.forEach((i,o)=>{i.translateX=e*o})}function te(t,e){let i=10**e;return Math.round(t*i)/i}function G(t,e,i,o){return o?t.width>t.height?i/(t.height*t.scale):e/(t.width*t.scale):1/t.scale}function Ne(t,e,i,o){let r=t.width*t.scale*e.scaleSize,s=t.height*t.scale*e.scaleSize,n,m,p,u;return i>r?(p=(i-r)/2,n=-1*p):(p=(r-i)/2,n=-1*p),o>s?(u=(o-s)/2,m=-1*u):(u=(s-o)/2,m=-1*u),{minX:te(n,6)*e.scaleSize,minY:te(m,6)*e.scaleSize,maxX:te(p,6)*e.scaleSize,maxY:te(u,6)*e.scaleSize}}function Be(t,e,i,o,r){let s=i-(o+r);t.forEach(n=>{n.loaded&&(n.processed=!0,n.scale=s/n.height,n.height<s&&(n.scale=1),n.x=(n.scale-1)/2*n.width+(e-n.width*n.scale)/2,n.y=(n.scale-1)/2*n.height+(i-n.height*n.scale)/2,n.width*n.scale>e&&(n.scale=e/n.width,n.x=(n.scale-1)/2*n.width))})}function De(t){let e=C(t);return e?`group=${t.viewer.currentGroup}&photo=${e.id}`:""}function Re(t,e){let i=null;return t.groups.forEach(o=>{o.forEach(r=>{e.group===r.groupId&&e.photo===r.id&&(i=r)})}),i}function ye(t,e){let i=10**e;return Math.round(t*i)/i}function U(t){return{x:t.pageX,y:t.pageY}}function Xe(t,e){let i=t.x-e.x,o=t.y-e.y;return Math.sqrt(i*i+o*o)}var Qe=10;function _e(t,e){return{force:Math.sqrt(t*t+e*e),theta:Math.atan2(e,t)}}function Ye(){return{width:Z(),height:ee()}}function Fe({state:t,callbacks:e},{signal:i}){let o=new Map,r=Date.now(),s=!1,n=!1,m=null,p=null,u=null,f=0,P=null,b=!1,H=null,T=null,z=0,Y=0,V=!1,R=0,x=null,O=0,c=0;function Q(){return K()}function k(a){let{width:h,height:E}=Ye();return Ne(a,t.viewer,h,E)}function _(a){let{width:h,height:E}=Ye();return G(a,h,E,Q())}function oe(a,h){let E=C(t),y=k(E);t.viewer.elastic=!0,a===1?t.viewer.photoPosX=y.minX:a===-1&&(t.viewer.photoPosX=y.maxX),h===1?t.viewer.photoPosY=y.minY:h===-1&&(t.viewer.photoPosY=y.maxY),e.onPhotoDragMove(),setTimeout(()=>{t.viewer.elastic=!1,e.onPhotoDragMove()},300)}let F=setInterval(()=>{if(V||s||b||t.viewer.elastic||!t.viewer.scale)return;t.viewer.photoPosX+=O,t.viewer.photoPosY+=c;let a=C(t);if(!a)return;let h=k(a);t.viewer.photoPosX<h.minX?(t.viewer.photoPosX=h.minX,O*=-.2):t.viewer.photoPosX>h.maxX&&(t.viewer.photoPosX=h.maxX,O*=-.2),t.viewer.photoPosY<h.minY?(t.viewer.photoPosY=h.minY,c*=-.2):t.viewer.photoPosY>h.maxY&&(t.viewer.photoPosY=h.maxY,c*=-.2);let E=_e(O,c),y=E.force-t.options.registance;Math.abs(y)<.5||(O=Math.cos(E.theta)*y,c=Math.sin(E.theta)*y,e.onPhotoDragMove())},t.options.forceInterval);function W(a,h){(a>5||a<-5)&&(O+=a*.05),t.options.verticalGravity&&(h>5||h<-5)&&(c+=h*.05)}function re(a){if(!(a!=null&&a.gamma)||t.viewer.appearEffect||V||s||b||t.viewer.elastic||!t.viewer.scale)return;let{orientation:h}=window;h===0?W(a.gamma,a.beta):h===90?W(a.beta,a.gamma):h===-90?W(-a.beta,-a.gamma):h===180&&W(-a.gamma,-a.beta)}t.options.useOrientationApi&&window.addEventListener("deviceorientation",re,{signal:i});function ne(){V=!0,s=!1,b=!1;let a=Array.from(o.values());R=Xe(a[0],a[1]),t.viewer.scale=!0,e.onGestureStart()}function se(a){let h=U(a);s=!0,n=!0,m=h,p=h,f=Date.now(),P=a.target}function ae(a){b=!0;let h=U(a);T=h,H=h}function le(a){var h,E;try{(E=(h=a.currentTarget).setPointerCapture)==null||E.call(h,a.pointerId)}catch(y){}if(o.set(a.pointerId,U(a)),o.size>1){ne();return}if(t.viewer.scale){ae(a);return}se(a)}function he(){x===null&&(x=requestAnimationFrame(()=>{x=null,e.onGestureMove()}))}function ue(){x!==null&&(cancelAnimationFrame(x),x=null,e.onGestureMove())}function ce(){let a=Array.from(o.values()),h=Xe(a[0],a[1]),E=(h-R)/100,y=t.viewer.scaleSize,I=t.viewer.photoPosX,M=t.viewer.photoPosY;t.viewer.scaleSize+=ye(E,6),t.viewer.scaleSize<.2&&(t.viewer.scaleSize=.2),t.viewer.scaleSize<y&&(t.viewer.photoPosX=(1+t.viewer.scaleSize-y)*I,t.viewer.photoPosY=(1+t.viewer.scaleSize-y)*M);let D=C(t);if(D){let de=_(D);t.viewer.hideUi=t.viewer.scaleSize<1||t.viewer.scaleSize>de}R=h,he()}function d(a){let h=U(a),E=h.x-p.x,y=h.y-m.y;n&&(e.onSwipeStart(),n=!1,u=Math.abs(E)>Math.abs(y)?"horizontal":"vertical"),u==="horizontal"?t.viewer.translateX+=E:t.viewer.translateY=y,p=h,e.onSwipeMove()}function l(a){let h=U(a),E=h.x-T.x,y=h.y-T.y,I=ye(t.viewer.scaleSize*E,6),M=ye(t.viewer.scaleSize*y,6);t.viewer.photoPosX+=I,z=I,t.viewer.photoPosY+=M,Y=M,T=h,e.onPhotoDragMove()}function g(a){if(o.has(a.pointerId)){if(o.set(a.pointerId,U(a)),V){ce();return}if(b){l(a);return}d(a)}}function v(){V=!1,ue();let a=C(t);if(!a)return;let h=_(a);t.viewer.scaleSize>h||(t.viewer.photoPosX=0,t.viewer.photoPosY=0,t.viewer.scale=!1,t.viewer.scaleSize=1,t.viewer.hideUi=!1,e.onGestureEnd())}function w(){var Pe;s=!1;let a=m,h=p,E=Date.now(),y=r-E,I=h.x-a.x,M=h.y-a.y,D=I===0&&M===0;if(!Q()&&D){e.onTap(P);return}if(Math.abs(y)<=500&&D){e.onTap(P);return}r=E;let de=(Pe=L(t))!=null?Pe:[];if(u==="horizontal"){let $="stay",Ge=Math.max(E-f,1),Se=Math.abs(I)>=Qe&&Math.abs(I)/Ge>=t.options.swipeVelocity;(I>=t.options.swipeOffset||Se&&I>0)&&t.viewer.currentIndex!==0?$="prev":(I<=-t.options.swipeOffset||Se&&I<0)&&t.viewer.currentIndex!==de.length-1&&($="next"),e.onSwipeEnd($)}else{let $="stay";t.options.swipeBottomToClose&&M>=t.options.swipeOffset?$="close-bottom":t.options.swipeTopToClose&&M<=-t.options.swipeOffset&&($="close-top"),e.onSwipeEnd($)}}function S(){b=!1;let a=T,h=H;if(a.x===h.x){e.onPhotoDragEnd("zoom-out");return}let E=C(t);if(!E){e.onPhotoDragEnd(null);return}let y=k(E),I=t.options.swipeOffset*t.viewer.scaleSize,M=0,D=0;if(t.viewer.photoPosX>y.maxX?M=-1:t.viewer.photoPosX<y.minX&&(M=1),t.viewer.photoPosY>y.maxY?D=-1:t.viewer.photoPosY<y.minY&&(D=1),t.viewer.photoPosX-y.maxX>I&&t.viewer.currentIndex!==0){e.onPhotoDragEnd("prev");return}if(y.minX-t.viewer.photoPosX>I&&t.viewer.currentIndex+1!==t.viewer.total){e.onPhotoDragEnd("next");return}M===0&&D===0?(O=z/5,c=Y/5):oe(M,D),e.onPhotoDragEnd(null)}function N(a){if(o.delete(a.pointerId),V){o.size<2&&v();return}if(b){S();return}s&&w()}function J(...a){for(let h of a)h.addEventListener("pointerdown",le,{signal:i}),h.addEventListener("pointermove",g,{signal:i}),h.addEventListener("pointerup",N,{signal:i}),h.addEventListener("pointercancel",N,{signal:i})}function B(){clearInterval(F),x!==null&&(cancelAnimationFrame(x),x=null)}return{attach:J,detach:B}}function ie(t){let e=document.createElement("span");return e.className="smartphoto-sr-only",e.textContent=t,e}function Ee(){let t=document.createElement("button");return t.type="button",t}function Je(t){return t.replace(/"/g,'\\"')}function We({id:t,options:e},i,{signal:o}){let{classNames:r,message:s}=e,n=document.createElement("div");n.setAttribute("data-id",t);let m=document.createElement("dialog");m.className=r.smartPhoto,m.setAttribute("aria-labelledby",`smartphoto-${t}-title`),m.style.display="none",m.style.setProperty("--smartphoto-animation-speed",`${e.animationSpeed}ms`);let p=document.createElement("div");p.className=r.smartPhotoBody;let u=document.createElement("div");u.className=r.smartPhotoInner;let f=document.createElement("div");f.className=r.smartPhotoHeader;let P=document.createElement("span");P.className=r.smartPhotoCount;let b=document.createElement("h1");b.id=`smartphoto-${t}-title`,b.className=r.smartPhotoCaption,b.setAttribute("tabindex","-1");let H=document.createElement("button");H.className=r.smartPhotoDismiss,H.appendChild(ie(s.closeDialog)),H.addEventListener("click",()=>i.onDismiss(),{signal:o}),f.append(P,b,H);let T=document.createElement("div");T.className=r.smartPhotoContent,T.addEventListener("click",d=>{d.target===T&&i.onBackdropClick()},{signal:o});let z=document.createElement("ul");z.className=r.smartPhotoList,z.setAttribute("role","region"),z.setAttribute("aria-roledescription","carousel"),z.setAttribute("aria-label",s.carouselLabel),z.setAttribute("aria-live","polite"),z.setAttribute("aria-atomic","false"),u.append(f,T,z);let Y=null,V=null,R=null;if(e.arrows){Y=document.createElement("ul"),Y.className=r.smartPhotoArrows,V=document.createElement("li"),V.className=r.smartPhotoArrowLeft;let d=Ee();d.appendChild(ie(s.gotoPrevImage)),d.addEventListener("click",()=>i.onPrev(),{signal:o}),V.appendChild(d),R=document.createElement("li"),R.className=r.smartPhotoArrowRight;let l=Ee();l.appendChild(ie(s.gotoNextImage)),l.addEventListener("click",()=>i.onNext(),{signal:o}),R.appendChild(l),Y.append(V,R),u.appendChild(Y)}let x=null,O=null;e.nav&&(x=document.createElement("nav"),x.className=r.smartPhotoNav,x.setAttribute("aria-label","Choose slide to display"),O=document.createElement("ul"),x.appendChild(O),u.appendChild(x)),p.appendChild(u),m.appendChild(p),n.appendChild(m);let c={dialog:m,count:P,caption:b,dismiss:H,content:T,list:z,arrows:Y,arrowLeft:V,arrowRight:R,nav:x,navList:O,slides:new Map,imgClone:null};function Q(){let d=document.createElement("div");d.className=r.smartPhotoLoaderWrap;let l=document.createElement("span");return l.className=r.smartPhotoLoader,d.appendChild(l),d}function k(d){var v,w;let l=document.createElement("div");l.className=r.smartPhotoImgWrap;let g=document.createElement("img");return g.className=r.smartPhotoImg,g.src=(v=d.src)!=null?v:"",g.alt=(w=d.alt)!=null?w:"",g.addEventListener("dragstart",S=>S.preventDefault(),{signal:o}),l.appendChild(g),{imgWrap:l,img:g}}function _(d,l){var g;c.list.replaceChildren(),(g=c.navList)==null||g.replaceChildren(),c.slides=new Map,d.forEach(v=>{var N,J;let w=document.createElement("li");w.setAttribute("role","group"),w.setAttribute("aria-roledescription","slide"),w.setAttribute("aria-label",`${v.index+1} of ${d.length}`);let S={li:w,loaderWrap:null,imgWrap:null,img:null,navLink:null};if(v.processed){let{imgWrap:B,img:a}=k(v);w.appendChild(B),S.imgWrap=B,S.img=a}else{let B=Q();w.appendChild(B),S.loaderWrap=B}if(c.list.appendChild(w),c.slides.set(v,S),c.navList){let B=document.createElement("li"),a=Ee();a.style.backgroundImage=`url("${Je((N=v.thumb)!=null?N:"")}")`;let h=v.index;a.addEventListener("click",()=>i.onNavigate(h),{signal:o}),a.appendChild(ie(`go to ${(J=v.caption)!=null?J:""}`)),B.appendChild(a),c.navList.appendChild(B),S.navLink=a}}),W(l)}function oe(d,l){var w;if(l.imgWrap||!d.processed)return l;let{imgWrap:g,img:v}=k(d);return(w=l.loaderWrap)==null||w.replaceWith(g),l.loaderWrap=null,l.imgWrap=g,l.img=v,l}function F(d){d&&document.activeElement&&d.contains(document.activeElement)&&c.caption.focus()}function W(d){let{viewer:l}=d;c.count.textContent=`${l.currentIndex+1}/${l.total}`,c.slides.forEach((g,v)=>{var N;let w=oe(v,g),S=v.index===l.currentIndex;w.li.style.transform=`translate(${v.translateX}px,${v.translateY}px)`,w.li.classList.toggle("current",S),S?w.li.removeAttribute("aria-hidden"):w.li.setAttribute("aria-hidden","true"),S&&(c.caption.textContent=(N=v.caption)!=null?N:""),w.imgWrap&&w.img&&(w.imgWrap.style.transform=`translate(${v.x}px,${v.y}px) scale(${v.scale})`,w.img.style.width=`${v.width}px`,S||(w.img.style.transform="translate(0px,0px) scale(1)"),w.img.classList.toggle("active",l.appear),w.img.classList.toggle(r.smartPhotoImgOnMove,l.scale),w.img.classList.toggle(r.smartPhotoImgElasticMove,l.elastic)),w.navLink&&(w.navLink.classList.toggle("current",S),S?w.navLink.setAttribute("aria-current","true"):w.navLink.removeAttribute("aria-current"))}),c.arrowLeft&&(l.showPrevArrow?c.arrowLeft.removeAttribute("aria-hidden"):(F(c.arrowLeft),c.arrowLeft.setAttribute("aria-hidden","true"))),c.arrowRight&&(l.showNextArrow?c.arrowRight.removeAttribute("aria-hidden"):(F(c.arrowRight),c.arrowRight.setAttribute("aria-hidden","true"))),c.arrows&&(l.hideUi&&F(c.arrows),c.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false")),c.nav&&(l.hideUi&&F(c.nav),c.nav.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function re(d){for(let[l,g]of c.slides)if(l.index===d.viewer.currentIndex)return g;return null}function ne(d){let{viewer:l}=d,g=re(d),v=g==null?void 0:g.img;v&&(v.style.transform=`translate(${l.photoPosX}px,${l.photoPosY}px) scale(${l.scaleSize})`,v.classList.toggle(r.smartPhotoImgOnMove,l.scale),v.classList.toggle(r.smartPhotoImgElasticMove,l.elastic)),c.nav&&(l.hideUi&&F(c.nav),c.nav.setAttribute("aria-hidden",l.hideUi?"true":"false")),c.arrows&&(l.hideUi&&F(c.arrows),c.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function se(d){let{viewer:l}=d;c.list.style.transform=`translate(${l.translateX}px,${l.translateY}px)`,c.list.classList.toggle(r.smartPhotoListOnMove,l.onMove)}function ae(d){for(let[l,g]of c.slides){if(l.index!==d.viewer.currentIndex)continue;let{img:v,imgWrap:w}=g;if(!v||!w||!l.width||!l.scale||l.scale>=1)return;let S=v.getBoundingClientRect();v.style.width=`${l.width*l.scale}px`,w.style.transform=`translate(${l.x}px,${l.y}px) scale(1)`;let N=v.getBoundingClientRect();w.style.transform=`translate(${l.x+S.left-N.left}px,${l.y+S.top-N.top}px) scale(1)`;return}}function le(){for(let[d,l]of c.slides){let{img:g,imgWrap:v}=l;g&&v&&(v.style.transform=`translate(${d.x}px,${d.y}px) scale(${d.scale})`,g.style.width=`${d.width}px`)}}function he(d){let l=document.createElement("img");l.className=r.smartPhotoImgClone,l.src=d.img,l.style.width=`${d.width}px`,l.style.height=`${d.height}px`,l.style.transform=`translate(${d.left}px,${d.top}px) scale(1)`,p.appendChild(l),c.imgClone=l}function ue(){var d;(d=c.imgClone)==null||d.remove(),c.imgClone=null}function ce(){n.remove()}return{root:n,refs:c,render:W,syncSlides:_,updatePhotoTransform:ne,applyViewTransitionLayout:ae,resetViewTransitionLayout:le,updateListTransform:se,showAppearEffect:he,removeAppearEffect:ue,destroy:ce}}var A=Z,X=ee;function Ke(t){return t.length>0&&t[0]instanceof Element}function Ze(){return(Date.now().toString(36)+Math.random().toString(36).substring(2,7)).toUpperCase()}function $e(){return{x:window.pageXOffset!==void 0?window.pageXOffset:document.documentElement.scrollLeft,y:window.pageYOffset!==void 0?window.pageYOffset:document.documentElement.scrollTop}}var q=class{constructor(e,i){this.id=Ze();this.abortController=new AbortController;this.isSmartPhoneFlag=K();this.lastTriggerElement=null;this.isFiringPublicCloseEvent=!1;this.finishHideEffect=null;this.isViewTransitionActive=!1;this.pendingViewTransitionResync=!1;this.timeouts=[];this.loadAllFired=new Set;this.syncedGroupId=null;this.rootSelector=null;this.itemsByElement=new Map;this.handleDocumentClick=e=>{if(!(e.target instanceof Element))return;let i=e;if(i.__smartphotoClaimed)return;let o=this.findRegisteredAncestor(e.target);if(!o&&this.rootSelector&&(o=e.target.closest(this.rootSelector)),!o)return;if(e.preventDefault(),i.__smartphotoClaimed=!0,!this.itemsByElement.has(o)&&this.rootSelector){let s=j(o);this.resyncGroupFromDom(s)&&this.syncCurrentGroupView()}let r=this.itemsByElement.get(o);r&&this.openPhoto(r,o)};this.updateViewportHeight=()=>{this.view.refs.dialog.style.setProperty("--smartphoto-vh",`${X()}px`)};this.handleVisualViewportResize=()=>{if(this.updateViewportHeight(),!(!this.isSmartPhoneFlag||!this.state.viewer.isOpen||!L(this.state))){if(this.isViewTransitionActive){this.pendingViewTransitionResync=!0;return}this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit()}};this.handleResize=()=>{if(!(!this.state.viewer.isOpen||!L(this.state))){if(this.updateViewportHeight(),this.isViewTransitionActive){this.pendingViewTransitionResync=!0;return}this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit()}};this.handleKeydown=e=>{if(!this.state.viewer.isOpen)return;let i=e.keyCode||e.which;i===37?this.gotoSlide(this.state.viewer.prev):i===39?this.gotoSlide(this.state.viewer.next):i===27&&this.hidePhoto()};this.handleOrientationChange=()=>{if(!this.state.viewer.isOpen||!L(this.state))return;if(this.isViewTransitionActive){this.pendingViewTransitionResync=!0;return}this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit();let e=A(),i=500,o=r=>{this.scheduleTimeout(()=>{this.state.viewer.isOpen&&(e!==A()?(this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit()):r<=i&&o(r+25))},25)};o(0)};this.rootSelector=typeof e=="string"?e:null,this.state=ze(i!=null?i:{}),this.view=We({id:this.id,options:this.state.options},this.buildViewHandlers(),{signal:this.abortController.signal}),document.body.appendChild(this.view.root),this.gestures=Fe({state:this.state,callbacks:this.buildGestureCallbacks()},{signal:this.abortController.signal}),this.gestures.attach(this.view.refs.content,this.view.refs.list),this.view.refs.dialog.addEventListener("close",()=>{!this.isFiringPublicCloseEvent&&this.state.viewer.isOpen&&this.hidePhoto()},{signal:this.abortController.signal}),document.addEventListener("click",this.handleDocumentClick,{signal:this.abortController.signal}),this.ingestSource(e),this.syncCurrentGroupView();let o=this.restoreFromHash();if(o&&this.openPhoto(o,o.element),this.updateViewportHeight(),this.applyAutoIconContrast(),window.visualViewport?window.visualViewport.addEventListener("resize",this.handleVisualViewportResize,{signal:this.abortController.signal}):window.addEventListener("resize",this.updateViewportHeight,{signal:this.abortController.signal}),!this.isSmartPhoneFlag){window.addEventListener("resize",this.handleResize,{signal:this.abortController.signal}),window.addEventListener("keydown",this.handleKeydown,{signal:this.abortController.signal});return}window.addEventListener("orientationchange",this.handleOrientationChange,{signal:this.abortController.signal})}on(e,i){let o=this.view.refs.dialog,r=s=>i.call(o,s);o.addEventListener(e,r,{signal:this.abortController.signal})}destroy(){this.state.viewer.isOpen=!1,this.view.refs.dialog.open&&this.view.refs.dialog.close(),this.abortController.abort(),this.timeouts.forEach(e=>{clearTimeout(e)}),this.timeouts=[],this.itemsByElement.clear(),this.gestures.detach(),this.view.destroy()}[Symbol.dispose](){this.destroy()}gotoSlide(e){var s,n;let i=Number.parseInt(String(e),10),o=Number.isNaN(i)?0:i,r=(n=(s=L(this.state))==null?void 0:s.length)!=null?n:0;o<0||o>=r||(this.state.viewer.currentIndex=o,this.slideList())}hidePhoto(e="bottom"){var o;if(!this.state.viewer.isOpen)return;this.state.viewer.isOpen=!1,this.state.viewer.appear=!1,this.state.viewer.appearEffect=null,this.view.removeAppearEffect(),this.state.viewer.hideUi=!1,this.state.viewer.scale=!1,this.state.viewer.scaleSize=1;let i=$e();location.hash&&this.setHash(""),window.scroll(i.x,i.y),this.syncDialog(),(o=this.lastTriggerElement)!=null&&o.isConnected&&this.lastTriggerElement.focus(),this.lastTriggerElement=null,this.doHideEffect(e).then(()=>{this.view.render(this.state),this.isFiringPublicCloseEvent=!0,this.fireEvent("close"),this.isFiringPublicCloseEvent=!1})}zoomPhoto(){let e=C(this.state);e&&(this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=G(e,A(),X(),this.isSmartPhoneFlag),!(this.state.viewer.scaleSize<=1)&&(this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.view.updatePhotoTransform(this.state),this.scheduleTimeout(()=>{this.state.viewer.isOpen&&(this.state.viewer.scale=!0,this.view.updatePhotoTransform(this.state),this.fireEvent("zoomin"))},this.state.options.animationSpeed)))}canZoomCurrentPhoto(){let e=C(this.state);return!!e&&G(e,A(),X(),this.isSmartPhoneFlag)>1}zoomOutPhoto(){this.state.viewer.scaleSize=1,this.state.viewer.hideUi=!1,this.state.viewer.scale=!1,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.view.updatePhotoTransform(this.state),this.fireEvent("zoomout")}addNewItem(e){return this.addItem(e)}show(e=0,i={}){var p,u,f;let o=(p=i.group)!=null?p:this.state.viewer.currentGroup;if(o===null)return;let r=this.state.groups.get(o);if(!(r!=null&&r.length))return;let s=typeof e=="number"?r[e]:r.find(P=>P.id===e);if(!s)return;let n=document.activeElement instanceof HTMLElement?document.activeElement:null,m=(f=(u=i.trigger)!=null?u:s.element)!=null?f:n;this.openPhoto(s,m)}hide(){this.hidePhoto()}next(){this.state.viewer.showNextArrow&&this.gotoSlide(this.state.viewer.next)}prev(){this.state.viewer.showPrevArrow&&this.gotoSlide(this.state.viewer.prev)}addItem(e){let i=e instanceof HTMLElement?this.addElementItem(e):this.addSlideItem(e);return this.syncCurrentGroupView(),i}get currentIndex(){return this.state.viewer.currentIndex}ingestSource(e){if(Array.isArray(e)&&!Ke(e)){e.forEach(o=>{this.addSlideItem(o)});return}Array.from(typeof e=="string"?document.querySelectorAll(e):e).forEach(o=>{this.addElementItem(o)})}addElementItem(e){var s,n;let i=j(e),o=(n=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?n:0,r=fe(e,this.state.options,o,A());return ve(this.state,r),this.loadAllFired.delete(i),this.itemsByElement.set(e,r),r}addSlideItem(e){var s,n;let i=pe(e),o=(n=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?n:0,r=Oe(e,o,A());return ve(this.state,r),this.loadAllFired.delete(i),r}findRegisteredAncestor(e){let i=e;for(;i;){if(this.itemsByElement.has(i))return i;i=i.parentElement}return null}resyncGroupFromDom(e){var p;if(!this.rootSelector)return!1;let i=Array.from(document.querySelectorAll(this.rootSelector)).filter(u=>j(u)===e),o=new Set(i),r=(p=this.state.groups.get(e))!=null?p:[],s=new Map;r.forEach(u=>{u.element&&s.set(u.element,u)});let n=i.length!==r.length,m=i.map((u,f)=>{let P=s.get(u);if(P)return P.index!==f&&(n=!0,P.index=f),P;n=!0;let b=fe(u,this.state.options,f,A());return this.itemsByElement.set(u,b),b});return r.forEach(u=>{u.element&&!o.has(u.element)&&this.itemsByElement.delete(u.element)}),ge(m,A()),this.state.groups.set(e,m),n&&this.loadAllFired.delete(e),n}syncCurrentGroupView(){let e=L(this.state);e&&(this.view.syncSlides(e,this.state),this.syncedGroupId=this.state.viewer.currentGroup)}setHash(e){var o;if(!((o=window.history)!=null&&o.pushState)||!this.state.options.useHistoryApi)return;let i=`${location.pathname}${location.search}`;window.history.replaceState(null,"",e?`${i}#${e}`:i)}setHashByCurrentIndex(){let e=$e();this.setHash(De(this.state)),window.scroll(e.x,e.y)}restoreFromHash(){let e=location.hash.substring(1);return e?Re(this.state,Ae(e)):null}setPosByCurrentIndex(){let e=C(this.state);e&&(this.state.viewer.translateX=-e.translateX,this.state.viewer.translateY=0,this.view.updateListTransform(this.state))}setSizeByScreen(){let e=L(this.state);e&&(Be(e,A(),X(),this.state.options.headerHeight,this.state.options.footerHeight),this.syncFillScale())}resetTranslateCurrent(){ge(L(this.state),A())}currentImgElement(){for(let[e,i]of this.view.refs.slides)if(e.index===this.state.viewer.currentIndex)return i.img;return null}currentLiElement(){for(let[e,i]of this.view.refs.slides)if(e.index===this.state.viewer.currentIndex)return i.li;return null}syncDialog(){let{dialog:e,caption:i}=this.view.refs;e.style.transition=this.state.options.showAnimation===!1?"none":"",this.state.viewer.isOpen&&!e.open?(e.style.removeProperty("display"),e.showModal(),i.focus()):!this.state.viewer.isOpen&&e.open&&(e.close(),e.style.display="none")}commit(){this.view.render(this.state),this.view.updatePhotoTransform(this.state),this.syncDialog()}initPhoto(){var i;(i=this.finishHideEffect)==null||i.call(this),this.updateViewportHeight(),this.view.refs.dialog.style.opacity="";let e=L(this.state);this.state.viewer.total=e.length,this.state.viewer.isOpen=!0,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.setPosByCurrentIndex(),this.setSizeByScreen(),we(this.state)}syncFillScale(){if(this.state.options.resizeStyle!=="fill"||!this.isSmartPhoneFlag)return;let e=C(this.state);e&&(this.state.viewer.scale=!0,this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=G(e,A(),X(),this.isSmartPhoneFlag))}supportsViewTransition(){return this.state.options.useViewTransitionApi&&typeof document.startViewTransition=="function"&&!Ie()}openPhotoWithViewTransition(e){var n,m;document.documentElement.style.setProperty("--smartphoto-animation-speed",`${this.state.options.animationSpeed}ms`);let i="smartphoto-hero",o=(n=e==null?void 0:e.querySelector("img"))!=null?n:null;o&&(o.style.viewTransitionName=i);let r=()=>{this.isViewTransitionActive=!1,o&&(o.style.viewTransitionName="");let p=this.currentImgElement();if(p&&(p.style.viewTransitionName=""),!this.state.viewer.isOpen){this.pendingViewTransitionResync=!1;return}if(this.pendingViewTransitionResync&&L(this.state)){this.pendingViewTransitionResync=!1,this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit();return}this.pendingViewTransitionResync=!1,this.view.resetViewTransitionLayout()},s=(m=document.startViewTransition)==null?void 0:m.call(document,()=>{this.initPhoto(),this.state.viewer.appear=!0,this.commit(),o&&(o.style.viewTransitionName=""),this.currentImgElement().style.viewTransitionName=i,this.view.applyViewTransitionLayout(this.state)});s&&(this.isViewTransitionActive=!0,s.ready.catch(()=>{r()}),s.finished.then(r,r))}addAppearEffect(e,i){var T;let o=(T=e==null?void 0:e.querySelector("img"))!=null?T:null;if(!o){this.state.viewer.appear=!0;return}let r=He(o),s=o.offsetWidth,n=o.offsetHeight,m=A(),p=X(),u=p-this.state.options.headerHeight-this.state.options.footerHeight,f=1;this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag?s>n?f=p/n:f=m/s:(s>=n?i.height<u?f=i.width/s:f=u/n:i.height<u?f=i.height/n:f=u/n,s*f>m&&(f=m/s));let P=(f-1)/2*s+(m-s*f)/2,b=(f-1)/2*n+(p-n*f)/2,H=o.getAttribute(this.state.options.lazyAttribute);this.state.viewer.appearEffect={width:s,height:n,top:r.top,left:r.left,once:!0,img:H||i.src||"",afterX:P,afterY:b,scale:f}}runAppearEffect(e){this.view.showAppearEffect(e);let i=this.view.refs.imgClone;return new Promise(o=>{let r=()=>{i.removeEventListener("transitionend",r,!0),o()};i.addEventListener("transitionend",r,!0),this.scheduleTimeout(()=>{i.style.transform=`translate(${e.afterX}px, ${e.afterY}px) scale(${e.scale})`},10)})}doOpen(e,i){if(this.state.options.showAnimation!==!1&&this.supportsViewTransition())this.openPhotoWithViewTransition(e);else if(this.state.options.showAnimation===!1)this.initPhoto(),this.state.viewer.appear=!0,this.commit();else{this.initPhoto(),this.addAppearEffect(e,i),this.commit();let o=this.state.viewer.appearEffect;o&&this.runAppearEffect(o).then(()=>{this.state.viewer.appearEffect=null,this.view.removeAppearEffect(),this.state.viewer.appear=!0,this.commit()})}this.fireEvent("open"),this.resyncSizeAfterOpen()}resyncSizeAfterOpen(){let e=A(),i=X();requestAnimationFrame(()=>{if(this.state.viewer.isOpen&&!(A()===e&&X()===i)){if(this.isViewTransitionActive){this.pendingViewTransitionResync=!0;return}this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit()}})}openPhoto(e,i){let o=this.rootSelector?this.resyncGroupFromDom(e.groupId):!1;this.lastTriggerElement=i,this.state.viewer.currentGroup=e.groupId,this.state.viewer.currentIndex=e.index,(this.syncedGroupId!==e.groupId||o)&&this.syncCurrentGroupView(),this.setHashByCurrentIndex(),e.loaded?this.doOpen(i,e):this.loadItem(e).then(()=>{this.doOpen(i,e)})}doHideEffect(e){return new Promise(i=>{if(this.state.options.showAnimation===!1){i();return}let o=this.view.refs.dialog,r=C(this.state),s=r?this.currentLiElement():null,n=X(),m=this.currentImgElement(),p=null;if(m){let f=getComputedStyle(m).transform;f&&f!=="none"&&(m.style.transform=f,p=m.style.transform)}if(s&&r){let f=e==="top"?-n:n;s.style.transform=`translate(${r.translateX}px,${r.translateY+f}px)`}let u=f=>{this.finishHideEffect===u&&(f&&f.target!==o||(this.finishHideEffect=null,o.removeEventListener("transitionend",u,!0),m&&p&&m.style.transform===p&&(m.style.transform=""),i()))};this.finishHideEffect=u,o.addEventListener("transitionend",u,!0),this.scheduleTimeout(u,this.state.options.animationSpeed+100)})}loadItem(e){return new Promise(i=>{var r;let o=new Image;o.onload=()=>{e.width=o.width,e.height=o.height,e.loaded=!0,this.checkLoadAll(e.groupId),i()},o.onerror=()=>i(),o.src=(r=e.src)!=null?r:""})}checkLoadAll(e){if(this.loadAllFired.has(e))return;let i=this.state.groups.get(e);i!=null&&i.length&&i.every(o=>o.loaded)&&(this.loadAllFired.add(e),this.fireEvent("loadall"))}loadNeighborItems(){let e=L(this.state);if(!e)return;let{currentIndex:i}=this.state.viewer,{loadOffset:o}=this.state.options,r=[];for(let s=i-o;s<i+o;s++){let n=e[s];n&&!n.loaded&&r.push(this.loadItem(n))}r.length&&Promise.all(r).then(()=>{this.state.viewer.isOpen&&(this.initPhoto(),this.commit())})}slideList(){this.state.viewer.scaleSize=1,this.state.viewer.hideUi=!1,this.state.viewer.scale=!1,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.state.viewer.onMove=!0,this.updateViewportHeight(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.scheduleTimeout(()=>{let e=C(this.state);this.state.viewer.onMove=!1,we(this.state),this.state.viewer.isOpen&&this.commit(),this.state.viewer.oldIndex!==this.state.viewer.currentIndex&&this.fireEvent("change"),this.state.viewer.oldIndex=this.state.viewer.currentIndex,this.loadNeighborItems(),e&&!e.loaded&&this.loadItem(e).then(()=>{this.state.viewer.isOpen&&(this.initPhoto(),this.commit())})},200)}scheduleTimeout(e,i){let o=window.setTimeout(()=>{this.timeouts=this.timeouts.filter(r=>r!==o),e()},i);return this.timeouts.push(o),o}applyAutoIconContrast(){let e=this.view.refs.dialog,i=getComputedStyle(e);if(i.getPropertyValue("--smartphoto-icon-color").trim())return;let o=i.getPropertyValue("--smartphoto-backdrop-color").trim();o&&e.style.setProperty("--smartphoto-icon-color",Me(o))}fireEvent(e){Ce(this.view.refs.dialog,e)}buildViewHandlers(){return{onDismiss:()=>this.hidePhoto(),onPrev:()=>this.prev(),onNext:()=>this.next(),onNavigate:e=>this.gotoSlide(e),onBackdropClick:()=>this.hidePhoto()}}buildGestureCallbacks(){return{onSwipeStart:()=>this.fireEvent("swipestart"),onSwipeMove:()=>this.view.updateListTransform(this.state),onSwipeEnd:e=>{if(this.fireEvent("swipeend"),e==="close-bottom"){this.hidePhoto("bottom");return}if(e==="close-top"){this.hidePhoto("top");return}e==="prev"?this.state.viewer.currentIndex-=1:e==="next"&&(this.state.viewer.currentIndex+=1),this.slideList()},onTap:e=>{let i=this.currentImgElement();!!i&&e instanceof Node&&i.contains(e)&&this.canZoomCurrentPhoto()?this.zoomPhoto():this.hidePhoto()},onGestureStart:()=>{this.fireEvent("gesturestart"),this.view.updatePhotoTransform(this.state)},onGestureMove:()=>this.view.updatePhotoTransform(this.state),onGestureEnd:()=>{this.fireEvent("gestureend"),this.view.updatePhotoTransform(this.state)},onPhotoDragMove:()=>this.view.updatePhotoTransform(this.state),onPhotoDragEnd:e=>{if(e==="zoom-out"){this.zoomOutPhoto();return}if(e==="prev"){this.gotoSlide(this.state.viewer.prev);return}if(e==="next"){this.gotoSlide(this.state.viewer.next);return}this.view.updatePhotoTransform(this.state)}}}};var ke=q;var be=t=>{t.fn.SmartPhoto=function(e){return typeof e=="string"||new ke(this,e),this}};if(typeof define=="function"&&define.amd)define(["jquery"],be);else{let t=window,e=t.jQuery?t.jQuery:t.$;typeof e!="undefined"&&be(e)}var ct=be;})();
package/js/smartphoto.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * SmartPhoto v2.1.12
2
+ * SmartPhoto v2.1.14
3
3
  * (c) appleple
4
4
  * Released under the MIT License.
5
5
  */
@@ -34,6 +34,9 @@ var SmartPhoto = (() => {
34
34
  const agent = navigator.userAgent;
35
35
  return agent.indexOf("iPhone") > 0 || agent.indexOf("iPad") > 0 || agent.indexOf("ipod") > 0 || agent.indexOf("Android") > 0;
36
36
  };
37
+ var isWebKit = () => {
38
+ return typeof window.webkitConvertPointFromNodeToPage === "function";
39
+ };
37
40
  function deepExtend(out, ...args) {
38
41
  var _a;
39
42
  out = out || {};
@@ -172,6 +175,7 @@ var SmartPhoto = (() => {
172
175
  verticalGravity: false,
173
176
  useOrientationApi: false,
174
177
  useHistoryApi: true,
178
+ useViewTransitionApi: true,
175
179
  swipeTopToClose: false,
176
180
  swipeBottomToClose: true,
177
181
  swipeOffset: 100,
@@ -459,6 +463,7 @@ var SmartPhoto = (() => {
459
463
  let oldPos = null;
460
464
  let moveDir = null;
461
465
  let swipeStartTime = 0;
466
+ let tapTarget = null;
462
467
  let photoSwipable = false;
463
468
  let firstPhotoPos = null;
464
469
  let oldPhotoPos = null;
@@ -589,6 +594,7 @@ var SmartPhoto = (() => {
589
594
  firstPos = pos;
590
595
  oldPos = pos;
591
596
  swipeStartTime = Date.now();
597
+ tapTarget = e.target;
592
598
  }
593
599
  function startPhotoDrag(e) {
594
600
  photoSwipable = true;
@@ -730,11 +736,11 @@ var SmartPhoto = (() => {
730
736
  const swipeHeight = last.y - first.y;
731
737
  const noMove = swipeWidth === 0 && swipeHeight === 0;
732
738
  if (!isSmartPhone2() && noMove) {
733
- callbacks.onTap();
739
+ callbacks.onTap(tapTarget);
734
740
  return;
735
741
  }
736
742
  if (Math.abs(offset) <= 500 && noMove) {
737
- callbacks.onTap();
743
+ callbacks.onTap(tapTarget);
738
744
  return;
739
745
  }
740
746
  tapSecond = now;
@@ -1059,6 +1065,9 @@ var SmartPhoto = (() => {
1059
1065
  if (slideRefs.imgWrap && slideRefs.img) {
1060
1066
  slideRefs.imgWrap.style.transform = `translate(${item.x}px,${item.y}px) scale(${item.scale})`;
1061
1067
  slideRefs.img.style.width = `${item.width}px`;
1068
+ if (!isCurrent) {
1069
+ slideRefs.img.style.transform = "translate(0px,0px) scale(1)";
1070
+ }
1062
1071
  slideRefs.img.classList.toggle("active", viewer.appear);
1063
1072
  slideRefs.img.classList.toggle(
1064
1073
  classNames.smartPhotoImgOnMove,
@@ -1142,6 +1151,32 @@ var SmartPhoto = (() => {
1142
1151
  refs.list.style.transform = `translate(${viewer.translateX}px,${viewer.translateY}px)`;
1143
1152
  refs.list.classList.toggle(classNames.smartPhotoListOnMove, viewer.onMove);
1144
1153
  }
1154
+ function applyViewTransitionLayout(state) {
1155
+ for (const [item, slideRefs] of refs.slides) {
1156
+ if (item.index !== state.viewer.currentIndex) {
1157
+ continue;
1158
+ }
1159
+ const { img, imgWrap } = slideRefs;
1160
+ if (!img || !imgWrap || !item.width || !item.scale || item.scale >= 1) {
1161
+ return;
1162
+ }
1163
+ const before = img.getBoundingClientRect();
1164
+ img.style.width = `${item.width * item.scale}px`;
1165
+ imgWrap.style.transform = `translate(${item.x}px,${item.y}px) scale(1)`;
1166
+ const after = img.getBoundingClientRect();
1167
+ imgWrap.style.transform = `translate(${item.x + before.left - after.left}px,${item.y + before.top - after.top}px) scale(1)`;
1168
+ return;
1169
+ }
1170
+ }
1171
+ function resetViewTransitionLayout() {
1172
+ for (const [item, slideRefs] of refs.slides) {
1173
+ const { img, imgWrap } = slideRefs;
1174
+ if (img && imgWrap) {
1175
+ imgWrap.style.transform = `translate(${item.x}px,${item.y}px) scale(${item.scale})`;
1176
+ img.style.width = `${item.width}px`;
1177
+ }
1178
+ }
1179
+ }
1145
1180
  function showAppearEffect(effect) {
1146
1181
  const clone = document.createElement("img");
1147
1182
  clone.className = classNames.smartPhotoImgClone;
@@ -1166,6 +1201,8 @@ var SmartPhoto = (() => {
1166
1201
  render,
1167
1202
  syncSlides,
1168
1203
  updatePhotoTransform,
1204
+ applyViewTransitionLayout,
1205
+ resetViewTransitionLayout,
1169
1206
  updateListTransform,
1170
1207
  showAppearEffect,
1171
1208
  removeAppearEffect,
@@ -1202,6 +1239,13 @@ var SmartPhoto = (() => {
1202
1239
  // doHideEffect() の後始末(画像に設定した translateY の除去と promise 解決)を
1203
1240
  // transitionend を待たずに即時実行するための関数。後始末が済むと null に戻る
1204
1241
  this.finishHideEffect = null;
1242
+ // 開く View Transition が進行中かどうか。進行中にリサイズ由来の再計算(commit)が
1243
+ // 走ると、モーフの目標位置は古いビューポート基準のままなのに実要素だけ新しい
1244
+ // 位置へ動いて「一旦ずれた位置に出てから正位置へ戻る」ように見え、さらに
1245
+ // モーフ用レイアウト(applyViewTransitionLayout)も巻き戻されてしまう。
1246
+ // そのため進行中はリサイズ再計算を保留し、finished 後にまとめて実行する
1247
+ this.isViewTransitionActive = false;
1248
+ this.pendingViewTransitionResync = false;
1205
1249
  this.timeouts = [];
1206
1250
  this.loadAllFired = /* @__PURE__ */ new Set();
1207
1251
  this.syncedGroupId = null;
@@ -1260,16 +1304,24 @@ var SmartPhoto = (() => {
1260
1304
  if (!this.isSmartPhoneFlag || !this.state.viewer.isOpen || !currentItems(this.state)) {
1261
1305
  return;
1262
1306
  }
1307
+ if (this.isViewTransitionActive) {
1308
+ this.pendingViewTransitionResync = true;
1309
+ return;
1310
+ }
1263
1311
  this.resetTranslateCurrent();
1264
1312
  this.setPosByCurrentIndex();
1265
1313
  this.setSizeByScreen();
1266
1314
  this.commit();
1267
1315
  };
1268
1316
  this.handleResize = () => {
1269
- if (!currentItems(this.state)) {
1317
+ if (!this.state.viewer.isOpen || !currentItems(this.state)) {
1270
1318
  return;
1271
1319
  }
1272
1320
  this.updateViewportHeight();
1321
+ if (this.isViewTransitionActive) {
1322
+ this.pendingViewTransitionResync = true;
1323
+ return;
1324
+ }
1273
1325
  this.resetTranslateCurrent();
1274
1326
  this.setPosByCurrentIndex();
1275
1327
  this.setSizeByScreen();
@@ -1289,7 +1341,11 @@ var SmartPhoto = (() => {
1289
1341
  }
1290
1342
  };
1291
1343
  this.handleOrientationChange = () => {
1292
- if (!currentItems(this.state)) {
1344
+ if (!this.state.viewer.isOpen || !currentItems(this.state)) {
1345
+ return;
1346
+ }
1347
+ if (this.isViewTransitionActive) {
1348
+ this.pendingViewTransitionResync = true;
1293
1349
  return;
1294
1350
  }
1295
1351
  this.updateViewportHeight();
@@ -1302,6 +1358,9 @@ var SmartPhoto = (() => {
1302
1358
  const timeout = 500;
1303
1359
  const poll = (time) => {
1304
1360
  this.scheduleTimeout(() => {
1361
+ if (!this.state.viewer.isOpen) {
1362
+ return;
1363
+ }
1305
1364
  if (prevWidth !== getWindowWidth2()) {
1306
1365
  this.updateViewportHeight();
1307
1366
  this.resetTranslateCurrent();
@@ -1400,10 +1459,14 @@ var SmartPhoto = (() => {
1400
1459
  this.destroy();
1401
1460
  }
1402
1461
  gotoSlide(index) {
1403
- this.state.viewer.currentIndex = Number.parseInt(String(index), 10);
1404
- if (!this.state.viewer.currentIndex) {
1405
- this.state.viewer.currentIndex = 0;
1462
+ var _a, _b;
1463
+ const parsed = Number.parseInt(String(index), 10);
1464
+ const next = Number.isNaN(parsed) ? 0 : parsed;
1465
+ const total = (_b = (_a = currentItems(this.state)) == null ? void 0 : _a.length) != null ? _b : 0;
1466
+ if (next < 0 || next >= total) {
1467
+ return;
1406
1468
  }
1469
+ this.state.viewer.currentIndex = next;
1407
1470
  this.slideList();
1408
1471
  }
1409
1472
  hidePhoto(dir = "bottom") {
@@ -1454,10 +1517,26 @@ var SmartPhoto = (() => {
1454
1517
  this.state.viewer.photoPosY = 0;
1455
1518
  this.view.updatePhotoTransform(this.state);
1456
1519
  this.scheduleTimeout(() => {
1520
+ if (!this.state.viewer.isOpen) {
1521
+ return;
1522
+ }
1457
1523
  this.state.viewer.scale = true;
1458
1524
  this.view.updatePhotoTransform(this.state);
1459
1525
  this.fireEvent("zoomin");
1460
- }, 300);
1526
+ }, this.state.options.animationSpeed);
1527
+ }
1528
+ // zoomPhoto() と同じ「ズームの余地があるか」の判定(scaleBorder <= 1 なら
1529
+ // ズームしても見た目が変わらない)。zoomPhoto() 自体は公開 API の契約
1530
+ // (ズームできなければ何もしない)を保つ必要があるため、タップの
1531
+ // zoom-or-close 分岐(§7)用に判定だけを切り出している
1532
+ canZoomCurrentPhoto() {
1533
+ const item = currentItem(this.state);
1534
+ return !!item && scaleBorder(
1535
+ item,
1536
+ getWindowWidth2(),
1537
+ getWindowHeight2(),
1538
+ this.isSmartPhoneFlag
1539
+ ) > 1;
1461
1540
  }
1462
1541
  zoomOutPhoto() {
1463
1542
  this.state.viewer.scaleSize = 1;
@@ -1668,6 +1747,7 @@ var SmartPhoto = (() => {
1668
1747
  this.state.options.headerHeight,
1669
1748
  this.state.options.footerHeight
1670
1749
  );
1750
+ this.syncFillScale();
1671
1751
  }
1672
1752
  // resize/orientationchange ハンドラは呼び出し前に currentItems の存在を確認済み
1673
1753
  resetTranslateCurrent() {
@@ -1681,9 +1761,18 @@ var SmartPhoto = (() => {
1681
1761
  }
1682
1762
  return null;
1683
1763
  }
1764
+ currentLiElement() {
1765
+ for (const [item, slideRefs] of this.view.refs.slides) {
1766
+ if (item.index === this.state.viewer.currentIndex) {
1767
+ return slideRefs.li;
1768
+ }
1769
+ }
1770
+ return null;
1771
+ }
1684
1772
  // ---- 内部: dialog 制御(§8) ----
1685
1773
  syncDialog() {
1686
1774
  const { dialog, caption } = this.view.refs;
1775
+ dialog.style.transition = this.state.options.showAnimation === false ? "none" : "";
1687
1776
  if (this.state.viewer.isOpen && !dialog.open) {
1688
1777
  dialog.style.removeProperty("display");
1689
1778
  dialog.showModal();
@@ -1695,6 +1784,7 @@ var SmartPhoto = (() => {
1695
1784
  }
1696
1785
  commit() {
1697
1786
  this.view.render(this.state);
1787
+ this.view.updatePhotoTransform(this.state);
1698
1788
  this.syncDialog();
1699
1789
  }
1700
1790
  // ---- 内部: 開く演出 ----
@@ -1713,20 +1803,34 @@ var SmartPhoto = (() => {
1713
1803
  this.setPosByCurrentIndex();
1714
1804
  this.setSizeByScreen();
1715
1805
  setArrow(this.state);
1716
- if (this.state.options.resizeStyle === "fill" && this.isSmartPhoneFlag) {
1717
- const item = currentItem(this.state);
1718
- this.state.viewer.scale = true;
1719
- this.state.viewer.hideUi = true;
1720
- this.state.viewer.scaleSize = scaleBorder(
1721
- item,
1722
- getWindowWidth2(),
1723
- getWindowHeight2(),
1724
- this.isSmartPhoneFlag
1725
- );
1806
+ }
1807
+ // resizeStyle: 'fill' はスマートフォンでのみ、画面を隙間なく覆うよう
1808
+ // scaleBorder() の倍率を viewer.scaleSize に適用する。fit用の item.scale に
1809
+ // 依存するため、setSizeByScreen() の末尾から必ず呼ばれる(個別に呼ぶ必要はない)
1810
+ syncFillScale() {
1811
+ if (this.state.options.resizeStyle !== "fill" || !this.isSmartPhoneFlag) {
1812
+ return;
1726
1813
  }
1814
+ const item = currentItem(this.state);
1815
+ if (!item) {
1816
+ return;
1817
+ }
1818
+ this.state.viewer.scale = true;
1819
+ this.state.viewer.hideUi = true;
1820
+ this.state.viewer.scaleSize = scaleBorder(
1821
+ item,
1822
+ getWindowWidth2(),
1823
+ getWindowHeight2(),
1824
+ this.isSmartPhoneFlag
1825
+ );
1727
1826
  }
1728
1827
  supportsViewTransition() {
1729
- return typeof document.startViewTransition === "function";
1828
+ return this.state.options.useViewTransitionApi && typeof document.startViewTransition === "function" && // WebKit には「view-transition-name 付き要素が root スナップショットから
1829
+ // 除外されず、モーフ中に最終位置へ二重描画される」実装バグがあり、開く演出が
1830
+ // 「一旦ずれた位置に出てから正位置へ戻る」ように乱れる。API 対応の有無では
1831
+ // 検出できないため、WebKit ではクローン演出(addAppearEffect)へフォールバック
1832
+ // する(§util.isWebKit)
1833
+ !isWebKit();
1730
1834
  }
1731
1835
  openPhotoWithViewTransition(trigger) {
1732
1836
  var _a, _b;
@@ -1739,7 +1843,8 @@ var SmartPhoto = (() => {
1739
1843
  if (thumbImg) {
1740
1844
  thumbImg.style.viewTransitionName = transitionName;
1741
1845
  }
1742
- const clearNames = () => {
1846
+ const cleanup = () => {
1847
+ this.isViewTransitionActive = false;
1743
1848
  if (thumbImg) {
1744
1849
  thumbImg.style.viewTransitionName = "";
1745
1850
  }
@@ -1747,6 +1852,21 @@ var SmartPhoto = (() => {
1747
1852
  if (img) {
1748
1853
  img.style.viewTransitionName = "";
1749
1854
  }
1855
+ if (!this.state.viewer.isOpen) {
1856
+ this.pendingViewTransitionResync = false;
1857
+ return;
1858
+ }
1859
+ if (this.pendingViewTransitionResync && currentItems(this.state)) {
1860
+ this.pendingViewTransitionResync = false;
1861
+ this.updateViewportHeight();
1862
+ this.resetTranslateCurrent();
1863
+ this.setPosByCurrentIndex();
1864
+ this.setSizeByScreen();
1865
+ this.commit();
1866
+ return;
1867
+ }
1868
+ this.pendingViewTransitionResync = false;
1869
+ this.view.resetViewTransitionLayout();
1750
1870
  };
1751
1871
  const transition = (_b = document.startViewTransition) == null ? void 0 : _b.call(document, () => {
1752
1872
  this.initPhoto();
@@ -1756,11 +1876,16 @@ var SmartPhoto = (() => {
1756
1876
  thumbImg.style.viewTransitionName = "";
1757
1877
  }
1758
1878
  this.currentImgElement().style.viewTransitionName = transitionName;
1879
+ this.view.applyViewTransitionLayout(this.state);
1759
1880
  });
1760
- transition == null ? void 0 : transition.ready.catch(() => {
1761
- clearNames();
1881
+ if (!transition) {
1882
+ return;
1883
+ }
1884
+ this.isViewTransitionActive = true;
1885
+ transition.ready.catch(() => {
1886
+ cleanup();
1762
1887
  });
1763
- transition == null ? void 0 : transition.finished.then(clearNames, clearNames);
1888
+ transition.finished.then(cleanup, cleanup);
1764
1889
  }
1765
1890
  // doOpen() の呼び出し元でこの分岐に来る時点で showAnimation !== false が保証されている
1766
1891
  addAppearEffect(trigger, item) {
@@ -1870,10 +1995,14 @@ var SmartPhoto = (() => {
1870
1995
  if (getWindowWidth2() === winWidthBefore && getWindowHeight2() === winHeightBefore) {
1871
1996
  return;
1872
1997
  }
1998
+ if (this.isViewTransitionActive) {
1999
+ this.pendingViewTransitionResync = true;
2000
+ return;
2001
+ }
1873
2002
  this.resetTranslateCurrent();
1874
2003
  this.setPosByCurrentIndex();
1875
2004
  this.setSizeByScreen();
1876
- this.view.render(this.state);
2005
+ this.commit();
1877
2006
  });
1878
2007
  }
1879
2008
  openPhoto(item, trigger) {
@@ -1895,21 +2024,37 @@ var SmartPhoto = (() => {
1895
2024
  }
1896
2025
  doHideEffect(dir) {
1897
2026
  return new Promise((resolve) => {
2027
+ if (this.state.options.showAnimation === false) {
2028
+ resolve();
2029
+ return;
2030
+ }
1898
2031
  const dialog = this.view.refs.dialog;
1899
- const img = this.currentImgElement();
2032
+ const item = currentItem(this.state);
2033
+ const li = item ? this.currentLiElement() : null;
1900
2034
  const height = getWindowHeight2();
1901
- const applied = dir === "top" ? `translateY(-${height}px)` : `translateY(${height}px)`;
2035
+ const img = this.currentImgElement();
2036
+ let frozenTransform = null;
1902
2037
  if (img) {
1903
- img.style.transform = applied;
2038
+ const rendered = getComputedStyle(img).transform;
2039
+ if (rendered && rendered !== "none") {
2040
+ img.style.transform = rendered;
2041
+ frozenTransform = img.style.transform;
2042
+ }
1904
2043
  }
1905
- const stored = img ? img.style.transform : "";
1906
- const finish = () => {
2044
+ if (li && item) {
2045
+ const offsetY = dir === "top" ? -height : height;
2046
+ li.style.transform = `translate(${item.translateX}px,${item.translateY + offsetY}px)`;
2047
+ }
2048
+ const finish = (e) => {
1907
2049
  if (this.finishHideEffect !== finish) {
1908
2050
  return;
1909
2051
  }
2052
+ if (e && e.target !== dialog) {
2053
+ return;
2054
+ }
1910
2055
  this.finishHideEffect = null;
1911
2056
  dialog.removeEventListener("transitionend", finish, true);
1912
- if (img && img.style.transform === stored) {
2057
+ if (img && frozenTransform && img.style.transform === frozenTransform) {
1913
2058
  img.style.transform = "";
1914
2059
  }
1915
2060
  resolve();
@@ -1985,7 +2130,9 @@ var SmartPhoto = (() => {
1985
2130
  const item = currentItem(this.state);
1986
2131
  this.state.viewer.onMove = false;
1987
2132
  setArrow(this.state);
1988
- this.commit();
2133
+ if (this.state.viewer.isOpen) {
2134
+ this.commit();
2135
+ }
1989
2136
  if (this.state.viewer.oldIndex !== this.state.viewer.currentIndex) {
1990
2137
  this.fireEvent("change");
1991
2138
  }
@@ -2070,7 +2217,21 @@ var SmartPhoto = (() => {
2070
2217
  }
2071
2218
  this.slideList();
2072
2219
  },
2073
- onTap: () => this.zoomPhoto(),
2220
+ // 主要ライトボックスのデファクトスタンダード(PhotoSwipe: bgClickAction
2221
+ // 'close' / imageClickAction 'zoom-or-close'、Fancybox: backdropClick
2222
+ // 'close'、GLightbox: closeOnOutsideClick、lightGallery: closable)に合わせ、
2223
+ // 写真の上のタップはズーム、写真の外(背景)のタップは閉じる。ズームの
2224
+ // 余地がない(scaleBorder <= 1 で zoomPhoto() が何もしない)写真の上の
2225
+ // タップも、無反応にせず 'zoom-or-close' に倣って閉じる
2226
+ onTap: (target) => {
2227
+ const img = this.currentImgElement();
2228
+ const onPhoto = !!img && target instanceof Node && img.contains(target);
2229
+ if (onPhoto && this.canZoomCurrentPhoto()) {
2230
+ this.zoomPhoto();
2231
+ } else {
2232
+ this.hidePhoto();
2233
+ }
2234
+ },
2074
2235
  onGestureStart: () => {
2075
2236
  this.fireEvent("gesturestart");
2076
2237
  this.view.updatePhotoTransform(this.state);