smartphoto 2.1.12 → 2.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  /*!
2
- * SmartPhoto v2.1.12
2
+ * SmartPhoto v2.1.13
3
3
  * (c) appleple
4
4
  * Released under the MIT License.
5
5
  */
6
- "use strict";var SmartPhoto=(()=>{var ce=Object.defineProperty;var Re=Object.getOwnPropertyDescriptor;var ke=Object.getOwnPropertyNames;var $e=Object.prototype.hasOwnProperty;var Ue=(t,e)=>{for(var i in e)ce(t,i,{get:e[i],enumerable:!0})},_e=(t,e,i,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of ke(e))!$e.call(t,r)&&r!==i&&ce(t,r,{get:()=>e[r],enumerable:!(o=Re(e,r))||o.enumerable});return t};var qe=t=>_e(ce({},"__esModule",{value:!0}),t);var rt={};Ue(rt,{default:()=>ot});var J=()=>{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},je=.179,Ke=([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&&Ke(i)>je?"#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,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({},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 q(t){return t.getAttribute("data-group")||"nogroup"}function pe(t){return t.group||"nogroup"}function fe(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,b,y,S;let o=pe(t),r=t.src,s=(d=t.thumb)!=null?d:r,n=(v=t.caption)!=null?v:null,c=(y=(b=t.alt)!=null?b:n)!=null?y: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 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 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 we(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 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 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 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 Ee(t,e){let i=10**e;return Math.round(t*i)/i}function k(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 Ze(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,b=!1,y=null,S=null,O=0,D=0,H=!1,Y=0,x=null,C=0,N=0;function m(){return J()}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 j(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||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=$(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=Ze(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 ne(){H=!0,s=!1,b=!1;let a=Array.from(o.values());Y=Be(a[0],a[1]),t.viewer.scale=!0,e.onGestureStart()}function se(a){let h=k(a);s=!0,n=!0,c=h,u=h,v=Date.now()}function ae(a){b=!0;let h=k(a);S=h,y=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,k(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+=Ee(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=k(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 P(a){let h=k(a),E=h.x-S.x,g=h.y-S.y,L=Ee(t.viewer.scaleSize*E,6),T=Ee(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)),H){p();return}if(b){P(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 Pe;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=(Pe=A(t))!=null?Pe:[];if(d==="horizontal"){let R="stay",Fe=Math.max(E-v,1),ye=Math.abs(L)>=Je&&Math.abs(L)/Fe>=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!==de.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(){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=$(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 _(a){if(o.delete(a.pointerId),H){o.size<2&&f();return}if(b){F();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",_,{signal:i}),h.addEventListener("pointercancel",_,{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 be(){let t=document.createElement("button");return t.type="button",t}function et(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 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(ie(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",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=be();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=be();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:b,caption:y,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 P=document.createElement("img");return P.className=r.smartPhotoImg,P.src=(w=p.src)!=null?w:"",P.alt=(f=p.alt)!=null?f:"",P.addEventListener("dragstart",I=>I.preventDefault(),{signal:o}),l.appendChild(P),{imgWrap:l,img:P}}function oe(p,l){var P;m.list.replaceChildren(),(P=m.navList)==null||P.replaceChildren(),m.slides=new Map,p.forEach(w=>{var F,_;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=be();G.style.backgroundImage=`url("${et((F=w.thumb)!=null?F:"")}")`;let a=w.index;G.addEventListener("click",()=>i.onNavigate(a),{signal:o}),G.appendChild(ie(`go to ${(_=w.caption)!=null?_:""}`)),B.appendChild(G),m.navList.appendChild(B),I.navLink=G}}),Q(l)}function re(p,l){var f;if(l.imgWrap||!p.processed)return l;let{imgWrap:P,img:w}=U(p);return(f=l.loaderWrap)==null||f.replaceWith(P),l.loaderWrap=null,l.imgWrap=P,l.img=w,l}function V(p){p&&document.activeElement&&p.contains(document.activeElement)&&m.caption.focus()}function Q(p){let{viewer:l}=p;m.count.textContent=`${l.currentIndex+1}/${l.total}`,m.slides.forEach((P,w)=>{var F;let f=re(w,P),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=(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"))}),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,P]of m.slides)if(l.index===p.viewer.currentIndex)return P;return null}function se(p){let{viewer:l}=p,P=ne(p),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)),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:Q,syncSlides:oe,updatePhotoTransform:se,updateListTransform:ae,showAppearEffect:le,removeAppearEffect:he,destroy:ue}}var M=Z,W=ee;function tt(t){return t.length>0&&t[0]instanceof Element}function it(){return(Date.now().toString(36)+Math.random().toString(36).substring(2,7)).toUpperCase()}function We(){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=it();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",`${W()}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=We();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(),W(),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(b=>b.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)&&!tt(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=fe(e,this.state.options,o,M());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=ze(e,o,M());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 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 b=s.get(d);if(b)return b.index!==v&&(n=!0,b.index=v),b;n=!0;let y=fe(d,this.state.options,v,M());return this.itemsByElement.set(d,y),y});return r.forEach(d=>{d.element&&!o.has(d.element)&&this.itemsByElement.delete(d.element)}),ge(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=We();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(),W(),this.state.options.headerHeight,this.state.options.footerHeight)}resetTranslateCurrent(){ge(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(),we(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(),W(),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=W(),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 b=(v-1)/2*s+(c-s*v)/2,y=(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: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=W();requestAnimationFrame(()=>{this.state.viewer.isOpen&&(M()===e&&W()===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=W(),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,we(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 ot=K;return qe(rt);})();
6
+ "use strict";var SmartPhoto=(()=>{var me=Object.defineProperty;var ke=Object.getOwnPropertyDescriptor;var Ue=Object.getOwnPropertyNames;var _e=Object.prototype.hasOwnProperty;var qe=(t,e)=>{for(var i in e)me(t,i,{get:e[i],enumerable:!0})},je=(t,e,i,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Ue(e))!_e.call(t,r)&&r!==i&&me(t,r,{get:()=>e[r],enumerable:!(o=ke(e,r))||o.enumerable});return t};var Ke=t=>je(me({},"__esModule",{value:!0}),t);var st={};qe(st,{default:()=>nt});var J=()=>{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},ee=()=>document.documentElement.clientWidth,te=()=>{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},Qe=.179,Ze=([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},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&&Ze(i)>Qe?"#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,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 ze(t){return Object.keys(t).forEach(e=>{let i=t[e];i&&typeof i=="object"&&!Object.isFrozen(i)&&ze(i)}),Object.freeze(t)}function Ve(t){return{options:ze(Te({},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 j(t){return t.getAttribute("data-group")||"nogroup"}function fe(t){return t.group||"nogroup"}function ve(t,e,i,o){let r=j(t),s=t.getAttribute("href"),n=t.querySelector("img"),c=s;n&&(n.getAttribute(e.lazyAttribute)?c=n.getAttribute(e.lazyAttribute):n.currentSrc?c=n.currentSrc:c=n.src);let p="";n!=null&&n.getAttribute("alt")?p=n.getAttribute("alt"):t.getAttribute("data-caption")?p=t.getAttribute("data-caption"):p=s!=null?s:"";let u=t.getAttribute("data-id");return{src:s,thumb:c,caption:t.getAttribute("data-caption"),alt:p,groupId:r,translateX:o*i,translateY:0,index:i,width:50,height:50,scale:1,x:0,y:0,id:u||i,loaded:!1,processed:!1,element:t}}function Oe(t,e,i){var u,f,P,b,H;let o=fe(t),r=t.src,s=(u=t.thumb)!=null?u:r,n=(f=t.caption)!=null?f:null,c=(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:c,groupId:o,translateX:i*e,translateY:0,index:e,width:p?t.width:50,height:p?t.height:50,scale:1,x:0,y:0,id:(H=t.id)!=null?H:e,loaded:p,processed:!1,element:null}}function we(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 T(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=T(t);return e&&(i=e[t.viewer.currentIndex])!=null?i:null}function ge(t){let e=T(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 Ee(t,e){t.forEach((i,o)=>{i.translateX=e*o})}function ie(t,e){let i=10**e;return Math.round(t*i)/i}function U(t,e,i,o){return o?t.width>t.height?i/(t.height*t.scale):e/(t.width*t.scale):1/t.scale}function Be(t,e,i,o){let r=t.width*t.scale*e.scaleSize,s=t.height*t.scale*e.scaleSize,n,c,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,c=-1*u):(u=(s-o)/2,c=-1*u),{minX:ie(n,6)*e.scaleSize,minY:ie(c,6)*e.scaleSize,maxX:ie(p,6)*e.scaleSize,maxY:ie(u,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=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 _(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 et=10;function tt(t,e){return{force:Math.sqrt(t*t+e*e),theta:Math.atan2(e,t)}}function Ye(){return{width:ee(),height:te()}}function Fe({state:t,callbacks:e},{signal:i}){let o=new Map,r=Date.now(),s=!1,n=!1,c=null,p=null,u=null,f=0,P=null,b=!1,H=null,L=null,V=0,F=0,z=!1,R=0,x=null,O=0,d=0;function Q(){return J()}function k(l){let{width:h,height:E}=Ye();return Be(l,t.viewer,h,E)}function Z(l){let{width:h,height:E}=Ye();return U(l,h,E,Q())}function re(l,h){let E=C(t),g=k(E);t.viewer.elastic=!0,l===1?t.viewer.photoPosX=g.minX:l===-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 G=setInterval(()=>{if(z||s||b||t.viewer.elastic||!t.viewer.scale)return;t.viewer.photoPosX+=O,t.viewer.photoPosY+=d;let l=C(t);if(!l)return;let h=k(l);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,d*=-.2):t.viewer.photoPosY>h.maxY&&(t.viewer.photoPosY=h.maxY,d*=-.2);let E=tt(O,d),g=E.force-t.options.registance;Math.abs(g)<.5||(O=Math.cos(E.theta)*g,d=Math.sin(E.theta)*g,e.onPhotoDragMove())},t.options.forceInterval);function W(l,h){(l>5||l<-5)&&(O+=l*.05),t.options.verticalGravity&&(h>5||h<-5)&&(d+=h*.05)}function ne(l){if(!(l!=null&&l.gamma)||t.viewer.appearEffect||z||s||b||t.viewer.elastic||!t.viewer.scale)return;let{orientation:h}=window;h===0?W(l.gamma,l.beta):h===90?W(l.beta,l.gamma):h===-90?W(-l.beta,-l.gamma):h===180&&W(-l.gamma,-l.beta)}t.options.useOrientationApi&&window.addEventListener("deviceorientation",ne,{signal:i});function se(){z=!0,s=!1,b=!1;let l=Array.from(o.values());R=Xe(l[0],l[1]),t.viewer.scale=!0,e.onGestureStart()}function ae(l){let h=_(l);s=!0,n=!0,c=h,p=h,f=Date.now(),P=l.target}function le(l){b=!0;let h=_(l);L=h,H=h}function he(l){var h,E;try{(E=(h=l.currentTarget).setPointerCapture)==null||E.call(h,l.pointerId)}catch(g){}if(o.set(l.pointerId,_(l)),o.size>1){se();return}if(t.viewer.scale){le(l);return}ae(l)}function ue(){x===null&&(x=requestAnimationFrame(()=>{x=null,e.onGestureMove()}))}function ce(){x!==null&&(cancelAnimationFrame(x),x=null,e.onGestureMove())}function m(){let l=Array.from(o.values()),h=Xe(l[0],l[1]),E=(h-R)/100,g=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<g&&(t.viewer.photoPosX=(1+t.viewer.scaleSize-g)*I,t.viewer.photoPosY=(1+t.viewer.scaleSize-g)*M);let N=C(t);if(N){let de=Z(N);t.viewer.hideUi=t.viewer.scaleSize<1||t.viewer.scaleSize>de}R=h,ue()}function a(l){let h=_(l),E=h.x-p.x,g=h.y-c.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(l){let h=_(l),E=h.x-L.x,g=h.y-L.y,I=ye(t.viewer.scaleSize*E,6),M=ye(t.viewer.scaleSize*g,6);t.viewer.photoPosX+=I,V=I,t.viewer.photoPosY+=M,F=M,L=h,e.onPhotoDragMove()}function w(l){if(o.has(l.pointerId)){if(o.set(l.pointerId,_(l)),z){m();return}if(b){y(l);return}a(l)}}function v(){z=!1,ce();let l=C(t);if(!l)return;let h=Z(l);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 S(){var Pe;s=!1;let l=c,h=p,E=Date.now(),g=r-E,I=h.x-l.x,M=h.y-l.y,N=I===0&&M===0;if(!Q()&&N){e.onTap(P);return}if(Math.abs(g)<=500&&N){e.onTap(P);return}r=E;let de=(Pe=T(t))!=null?Pe:[];if(u==="horizontal"){let $="stay",$e=Math.max(E-f,1),Se=Math.abs(I)>=et&&Math.abs(I)/$e>=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 B(){b=!1;let l=L,h=H;if(l.x===h.x){e.onPhotoDragEnd("zoom-out");return}let E=C(t);if(!E){e.onPhotoDragEnd(null);return}let g=k(E),I=t.options.swipeOffset*t.viewer.scaleSize,M=0,N=0;if(t.viewer.photoPosX>g.maxX?M=-1:t.viewer.photoPosX<g.minX&&(M=1),t.viewer.photoPosY>g.maxY?N=-1:t.viewer.photoPosY<g.minY&&(N=1),t.viewer.photoPosX-g.maxX>I&&t.viewer.currentIndex!==0){e.onPhotoDragEnd("prev");return}if(g.minX-t.viewer.photoPosX>I&&t.viewer.currentIndex+1!==t.viewer.total){e.onPhotoDragEnd("next");return}M===0&&N===0?(O=V/5,d=F/5):re(M,N),e.onPhotoDragEnd(null)}function q(l){if(o.delete(l.pointerId),z){o.size<2&&v();return}if(b){B();return}s&&S()}function D(...l){for(let h of l)h.addEventListener("pointerdown",he,{signal:i}),h.addEventListener("pointermove",w,{signal:i}),h.addEventListener("pointerup",q,{signal:i}),h.addEventListener("pointercancel",q,{signal:i})}function X(){clearInterval(G),x!==null&&(cancelAnimationFrame(x),x=null)}return{attach:D,detach:X}}function oe(t){let e=document.createElement("span");return e.className="smartphoto-sr-only",e.textContent=t,e}function be(){let t=document.createElement("button");return t.type="button",t}function it(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 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(oe(s.closeDialog)),H.addEventListener("click",()=>i.onDismiss(),{signal:o}),f.append(P,b,H);let L=document.createElement("div");L.className=r.smartPhotoContent,L.addEventListener("click",m=>{m.target===L&&i.onBackdropClick()},{signal:o});let V=document.createElement("ul");V.className=r.smartPhotoList,V.setAttribute("role","region"),V.setAttribute("aria-roledescription","carousel"),V.setAttribute("aria-label",s.carouselLabel),V.setAttribute("aria-live","polite"),V.setAttribute("aria-atomic","false"),u.append(f,L,V);let F=null,z=null,R=null;if(e.arrows){F=document.createElement("ul"),F.className=r.smartPhotoArrows,z=document.createElement("li"),z.className=r.smartPhotoArrowLeft;let m=be();m.appendChild(oe(s.gotoPrevImage)),m.addEventListener("click",()=>i.onPrev(),{signal:o}),z.appendChild(m),R=document.createElement("li"),R.className=r.smartPhotoArrowRight;let a=be();a.appendChild(oe(s.gotoNextImage)),a.addEventListener("click",()=>i.onNext(),{signal:o}),R.appendChild(a),F.append(z,R),u.appendChild(F)}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),c.appendChild(p),n.appendChild(c);let d={dialog:c,count:P,caption:b,dismiss:H,content:L,list:V,arrows:F,arrowLeft:z,arrowRight:R,nav:x,navList:O,slides:new Map,imgClone:null};function Q(){let m=document.createElement("div");m.className=r.smartPhotoLoaderWrap;let a=document.createElement("span");return a.className=r.smartPhotoLoader,m.appendChild(a),m}function k(m){var w,v;let a=document.createElement("div");a.className=r.smartPhotoImgWrap;let y=document.createElement("img");return y.className=r.smartPhotoImg,y.src=(w=m.src)!=null?w:"",y.alt=(v=m.alt)!=null?v:"",y.addEventListener("dragstart",S=>S.preventDefault(),{signal:o}),a.appendChild(y),{imgWrap:a,img:y}}function Z(m,a){var y;d.list.replaceChildren(),(y=d.navList)==null||y.replaceChildren(),d.slides=new Map,m.forEach(w=>{var B,q;let v=document.createElement("li");v.setAttribute("role","group"),v.setAttribute("aria-roledescription","slide"),v.setAttribute("aria-label",`${w.index+1} of ${m.length}`);let S={li:v,loaderWrap:null,imgWrap:null,img:null,navLink:null};if(w.processed){let{imgWrap:D,img:X}=k(w);v.appendChild(D),S.imgWrap=D,S.img=X}else{let D=Q();v.appendChild(D),S.loaderWrap=D}if(d.list.appendChild(v),d.slides.set(w,S),d.navList){let D=document.createElement("li"),X=be();X.style.backgroundImage=`url("${it((B=w.thumb)!=null?B:"")}")`;let l=w.index;X.addEventListener("click",()=>i.onNavigate(l),{signal:o}),X.appendChild(oe(`go to ${(q=w.caption)!=null?q:""}`)),D.appendChild(X),d.navList.appendChild(D),S.navLink=X}}),W(a)}function re(m,a){var v;if(a.imgWrap||!m.processed)return a;let{imgWrap:y,img:w}=k(m);return(v=a.loaderWrap)==null||v.replaceWith(y),a.loaderWrap=null,a.imgWrap=y,a.img=w,a}function G(m){m&&document.activeElement&&m.contains(document.activeElement)&&d.caption.focus()}function W(m){let{viewer:a}=m;d.count.textContent=`${a.currentIndex+1}/${a.total}`,d.slides.forEach((y,w)=>{var B;let v=re(w,y),S=w.index===a.currentIndex;v.li.style.transform=`translate(${w.translateX}px,${w.translateY}px)`,v.li.classList.toggle("current",S),S?v.li.removeAttribute("aria-hidden"):v.li.setAttribute("aria-hidden","true"),S&&(d.caption.textContent=(B=w.caption)!=null?B:""),v.imgWrap&&v.img&&(v.imgWrap.style.transform=`translate(${w.x}px,${w.y}px) scale(${w.scale})`,v.img.style.width=`${w.width}px`,S||(v.img.style.transform="translate(0px,0px) scale(1)"),v.img.classList.toggle("active",a.appear),v.img.classList.toggle(r.smartPhotoImgOnMove,a.scale),v.img.classList.toggle(r.smartPhotoImgElasticMove,a.elastic)),v.navLink&&(v.navLink.classList.toggle("current",S),S?v.navLink.setAttribute("aria-current","true"):v.navLink.removeAttribute("aria-current"))}),d.arrowLeft&&(a.showPrevArrow?d.arrowLeft.removeAttribute("aria-hidden"):(G(d.arrowLeft),d.arrowLeft.setAttribute("aria-hidden","true"))),d.arrowRight&&(a.showNextArrow?d.arrowRight.removeAttribute("aria-hidden"):(G(d.arrowRight),d.arrowRight.setAttribute("aria-hidden","true"))),d.arrows&&(a.hideUi&&G(d.arrows),d.arrows.setAttribute("aria-hidden",a.hideUi?"true":"false")),d.nav&&(a.hideUi&&G(d.nav),d.nav.setAttribute("aria-hidden",a.hideUi?"true":"false"))}function ne(m){for(let[a,y]of d.slides)if(a.index===m.viewer.currentIndex)return y;return null}function se(m){let{viewer:a}=m,y=ne(m),w=y==null?void 0:y.img;w&&(w.style.transform=`translate(${a.photoPosX}px,${a.photoPosY}px) scale(${a.scaleSize})`,w.classList.toggle(r.smartPhotoImgOnMove,a.scale),w.classList.toggle(r.smartPhotoImgElasticMove,a.elastic)),d.nav&&(a.hideUi&&G(d.nav),d.nav.setAttribute("aria-hidden",a.hideUi?"true":"false")),d.arrows&&(a.hideUi&&G(d.arrows),d.arrows.setAttribute("aria-hidden",a.hideUi?"true":"false"))}function ae(m){let{viewer:a}=m;d.list.style.transform=`translate(${a.translateX}px,${a.translateY}px)`,d.list.classList.toggle(r.smartPhotoListOnMove,a.onMove)}function le(m){for(let[a,y]of d.slides){if(a.index!==m.viewer.currentIndex)continue;let{img:w,imgWrap:v}=y;if(!w||!v||!a.width||!a.scale||a.scale>=1)return;let S=w.getBoundingClientRect();w.style.width=`${a.width*a.scale}px`,v.style.transform=`translate(${a.x}px,${a.y}px) scale(1)`;let B=w.getBoundingClientRect();v.style.transform=`translate(${a.x+S.left-B.left}px,${a.y+S.top-B.top}px) scale(1)`;return}}function he(m){let a=document.createElement("img");a.className=r.smartPhotoImgClone,a.src=m.img,a.style.width=`${m.width}px`,a.style.height=`${m.height}px`,a.style.transform=`translate(${m.left}px,${m.top}px) scale(1)`,p.appendChild(a),d.imgClone=a}function ue(){var m;(m=d.imgClone)==null||m.remove(),d.imgClone=null}function ce(){n.remove()}return{root:n,refs:d,render:W,syncSlides:Z,updatePhotoTransform:se,applyViewTransitionLayout:le,updateListTransform:ae,showAppearEffect:he,removeAppearEffect:ue,destroy:ce}}var A=ee,Y=te;function ot(t){return t.length>0&&t[0]instanceof Element}function rt(){return(Date.now().toString(36)+Math.random().toString(36).substring(2,7)).toUpperCase()}function We(){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=rt();this.abortController=new AbortController;this.isSmartPhoneFlag=J();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",`${Y()}px`)};this.handleVisualViewportResize=()=>{if(this.updateViewportHeight(),!(!this.isSmartPhoneFlag||!this.state.viewer.isOpen||!T(this.state))){if(this.isViewTransitionActive){this.pendingViewTransitionResync=!0;return}this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit()}};this.handleResize=()=>{if(!(!this.state.viewer.isOpen||!T(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||!T(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=Ve(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=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){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=We();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=U(e,A(),Y(),this.isSmartPhoneFlag),!(this.state.viewer.scaleSize<=1)&&(this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.view.updatePhotoTransform(this.state),this.scheduleTimeout(()=>{this.state.viewer.isOpen&&(this.state.viewer.scale=!0,this.view.updatePhotoTransform(this.state),this.fireEvent("zoomin"))},this.state.options.animationSpeed)))}canZoomCurrentPhoto(){let e=C(this.state);return!!e&&U(e,A(),Y(),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,c=(f=(u=i.trigger)!=null?u:s.element)!=null?f: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)&&!ot(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=ve(e,this.state.options,o,A());return we(this.state,r),this.loadAllFired.delete(i),this.itemsByElement.set(e,r),r}addSlideItem(e){var s,n;let i=fe(e),o=(n=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?n:0,r=Oe(e,o,A());return we(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,c=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=ve(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)}),Ee(c,A()),this.state.groups.set(e,c),n&&this.loadAllFired.delete(e),n}syncCurrentGroupView(){let e=T(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=We();this.setHash(Ne(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=T(this.state);e&&(De(e,A(),Y(),this.state.options.headerHeight,this.state.options.footerHeight),this.syncFillScale())}resetTranslateCurrent(){Ee(T(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=T(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(),ge(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=U(e,A(),Y(),this.isSmartPhoneFlag))}supportsViewTransition(){return this.state.options.useViewTransitionApi&&typeof document.startViewTransition=="function"&&!Ie()}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=()=>{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&&T(this.state)){this.pendingViewTransitionResync=!1,this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit();return}this.pendingViewTransitionResync=!1,this.view.render(this.state)},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,this.view.applyViewTransitionLayout(this.state)});s&&(this.isViewTransitionActive=!0,s.ready.catch(()=>{r()}),s.finished.then(r,r))}addAppearEffect(e,i){var L;let o=(L=e==null?void 0:e.querySelector("img"))!=null?L:null;if(!o){this.state.viewer.appear=!0;return}let r=He(o),s=o.offsetWidth,n=o.offsetHeight,c=A(),p=Y(),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=c/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>c&&(f=c/s));let P=(f-1)/2*s+(c-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=Y();requestAnimationFrame(()=>{if(this.state.viewer.isOpen&&!(A()===e&&Y()===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=Y(),c=this.currentImgElement(),p=null;if(c){let f=getComputedStyle(c).transform;f&&f!=="none"&&(c.style.transform=f,p=c.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),c&&p&&c.style.transform===p&&(c.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=T(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,ge(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 nt=K;return Ke(st);})();
7
7
  SmartPhoto = SmartPhoto.default;
package/lib/smartphoto.js CHANGED
@@ -29,6 +29,9 @@ var isSmartPhone = () => {
29
29
  const agent = navigator.userAgent;
30
30
  return agent.indexOf("iPhone") > 0 || agent.indexOf("iPad") > 0 || agent.indexOf("ipod") > 0 || agent.indexOf("Android") > 0;
31
31
  };
32
+ var isWebKit = () => {
33
+ return typeof window.webkitConvertPointFromNodeToPage === "function";
34
+ };
32
35
  function deepExtend(out, ...args) {
33
36
  out = out || {};
34
37
  for (let i = 0; i < args.length; i++) {
@@ -166,6 +169,7 @@ var defaults = {
166
169
  verticalGravity: false,
167
170
  useOrientationApi: false,
168
171
  useHistoryApi: true,
172
+ useViewTransitionApi: true,
169
173
  swipeTopToClose: false,
170
174
  swipeBottomToClose: true,
171
175
  swipeOffset: 100,
@@ -450,6 +454,7 @@ function createGestures({ state, callbacks }, { signal }) {
450
454
  let oldPos = null;
451
455
  let moveDir = null;
452
456
  let swipeStartTime = 0;
457
+ let tapTarget = null;
453
458
  let photoSwipable = false;
454
459
  let firstPhotoPos = null;
455
460
  let oldPhotoPos = null;
@@ -580,6 +585,7 @@ function createGestures({ state, callbacks }, { signal }) {
580
585
  firstPos = pos;
581
586
  oldPos = pos;
582
587
  swipeStartTime = Date.now();
588
+ tapTarget = e.target;
583
589
  }
584
590
  function startPhotoDrag(e) {
585
591
  photoSwipable = true;
@@ -719,11 +725,11 @@ function createGestures({ state, callbacks }, { signal }) {
719
725
  const swipeHeight = last.y - first.y;
720
726
  const noMove = swipeWidth === 0 && swipeHeight === 0;
721
727
  if (!isSmartPhone2() && noMove) {
722
- callbacks.onTap();
728
+ callbacks.onTap(tapTarget);
723
729
  return;
724
730
  }
725
731
  if (Math.abs(offset) <= 500 && noMove) {
726
- callbacks.onTap();
732
+ callbacks.onTap(tapTarget);
727
733
  return;
728
734
  }
729
735
  tapSecond = now;
@@ -1043,6 +1049,9 @@ function createView({ id, options }, handlers, { signal }) {
1043
1049
  if (slideRefs.imgWrap && slideRefs.img) {
1044
1050
  slideRefs.imgWrap.style.transform = `translate(${item.x}px,${item.y}px) scale(${item.scale})`;
1045
1051
  slideRefs.img.style.width = `${item.width}px`;
1052
+ if (!isCurrent) {
1053
+ slideRefs.img.style.transform = "translate(0px,0px) scale(1)";
1054
+ }
1046
1055
  slideRefs.img.classList.toggle("active", viewer.appear);
1047
1056
  slideRefs.img.classList.toggle(
1048
1057
  classNames.smartPhotoImgOnMove,
@@ -1126,6 +1135,23 @@ function createView({ id, options }, handlers, { signal }) {
1126
1135
  refs.list.style.transform = `translate(${viewer.translateX}px,${viewer.translateY}px)`;
1127
1136
  refs.list.classList.toggle(classNames.smartPhotoListOnMove, viewer.onMove);
1128
1137
  }
1138
+ function applyViewTransitionLayout(state) {
1139
+ for (const [item, slideRefs] of refs.slides) {
1140
+ if (item.index !== state.viewer.currentIndex) {
1141
+ continue;
1142
+ }
1143
+ const { img, imgWrap } = slideRefs;
1144
+ if (!img || !imgWrap || !item.width || !item.scale || item.scale >= 1) {
1145
+ return;
1146
+ }
1147
+ const before = img.getBoundingClientRect();
1148
+ img.style.width = `${item.width * item.scale}px`;
1149
+ imgWrap.style.transform = `translate(${item.x}px,${item.y}px) scale(1)`;
1150
+ const after = img.getBoundingClientRect();
1151
+ imgWrap.style.transform = `translate(${item.x + before.left - after.left}px,${item.y + before.top - after.top}px) scale(1)`;
1152
+ return;
1153
+ }
1154
+ }
1129
1155
  function showAppearEffect(effect) {
1130
1156
  const clone = document.createElement("img");
1131
1157
  clone.className = classNames.smartPhotoImgClone;
@@ -1149,6 +1175,7 @@ function createView({ id, options }, handlers, { signal }) {
1149
1175
  render,
1150
1176
  syncSlides,
1151
1177
  updatePhotoTransform,
1178
+ applyViewTransitionLayout,
1152
1179
  updateListTransform,
1153
1180
  showAppearEffect,
1154
1181
  removeAppearEffect,
@@ -1185,6 +1212,13 @@ var SmartPhoto = class {
1185
1212
  // doHideEffect() の後始末(画像に設定した translateY の除去と promise 解決)を
1186
1213
  // transitionend を待たずに即時実行するための関数。後始末が済むと null に戻る
1187
1214
  this.finishHideEffect = null;
1215
+ // 開く View Transition が進行中かどうか。進行中にリサイズ由来の再計算(commit)が
1216
+ // 走ると、モーフの目標位置は古いビューポート基準のままなのに実要素だけ新しい
1217
+ // 位置へ動いて「一旦ずれた位置に出てから正位置へ戻る」ように見え、さらに
1218
+ // モーフ用レイアウト(applyViewTransitionLayout)も巻き戻されてしまう。
1219
+ // そのため進行中はリサイズ再計算を保留し、finished 後にまとめて実行する
1220
+ this.isViewTransitionActive = false;
1221
+ this.pendingViewTransitionResync = false;
1188
1222
  this.timeouts = [];
1189
1223
  this.loadAllFired = /* @__PURE__ */ new Set();
1190
1224
  this.syncedGroupId = null;
@@ -1243,16 +1277,24 @@ var SmartPhoto = class {
1243
1277
  if (!this.isSmartPhoneFlag || !this.state.viewer.isOpen || !currentItems(this.state)) {
1244
1278
  return;
1245
1279
  }
1280
+ if (this.isViewTransitionActive) {
1281
+ this.pendingViewTransitionResync = true;
1282
+ return;
1283
+ }
1246
1284
  this.resetTranslateCurrent();
1247
1285
  this.setPosByCurrentIndex();
1248
1286
  this.setSizeByScreen();
1249
1287
  this.commit();
1250
1288
  };
1251
1289
  this.handleResize = () => {
1252
- if (!currentItems(this.state)) {
1290
+ if (!this.state.viewer.isOpen || !currentItems(this.state)) {
1253
1291
  return;
1254
1292
  }
1255
1293
  this.updateViewportHeight();
1294
+ if (this.isViewTransitionActive) {
1295
+ this.pendingViewTransitionResync = true;
1296
+ return;
1297
+ }
1256
1298
  this.resetTranslateCurrent();
1257
1299
  this.setPosByCurrentIndex();
1258
1300
  this.setSizeByScreen();
@@ -1272,7 +1314,11 @@ var SmartPhoto = class {
1272
1314
  }
1273
1315
  };
1274
1316
  this.handleOrientationChange = () => {
1275
- if (!currentItems(this.state)) {
1317
+ if (!this.state.viewer.isOpen || !currentItems(this.state)) {
1318
+ return;
1319
+ }
1320
+ if (this.isViewTransitionActive) {
1321
+ this.pendingViewTransitionResync = true;
1276
1322
  return;
1277
1323
  }
1278
1324
  this.updateViewportHeight();
@@ -1285,6 +1331,9 @@ var SmartPhoto = class {
1285
1331
  const timeout = 500;
1286
1332
  const poll = (time) => {
1287
1333
  this.scheduleTimeout(() => {
1334
+ if (!this.state.viewer.isOpen) {
1335
+ return;
1336
+ }
1288
1337
  if (prevWidth !== getWindowWidth2()) {
1289
1338
  this.updateViewportHeight();
1290
1339
  this.resetTranslateCurrent();
@@ -1436,10 +1485,26 @@ var SmartPhoto = class {
1436
1485
  this.state.viewer.photoPosY = 0;
1437
1486
  this.view.updatePhotoTransform(this.state);
1438
1487
  this.scheduleTimeout(() => {
1488
+ if (!this.state.viewer.isOpen) {
1489
+ return;
1490
+ }
1439
1491
  this.state.viewer.scale = true;
1440
1492
  this.view.updatePhotoTransform(this.state);
1441
1493
  this.fireEvent("zoomin");
1442
- }, 300);
1494
+ }, this.state.options.animationSpeed);
1495
+ }
1496
+ // zoomPhoto() と同じ「ズームの余地があるか」の判定(scaleBorder <= 1 なら
1497
+ // ズームしても見た目が変わらない)。zoomPhoto() 自体は公開 API の契約
1498
+ // (ズームできなければ何もしない)を保つ必要があるため、タップの
1499
+ // zoom-or-close 分岐(§7)用に判定だけを切り出している
1500
+ canZoomCurrentPhoto() {
1501
+ const item = currentItem(this.state);
1502
+ return !!item && scaleBorder(
1503
+ item,
1504
+ getWindowWidth2(),
1505
+ getWindowHeight2(),
1506
+ this.isSmartPhoneFlag
1507
+ ) > 1;
1443
1508
  }
1444
1509
  zoomOutPhoto() {
1445
1510
  this.state.viewer.scaleSize = 1;
@@ -1645,6 +1710,7 @@ var SmartPhoto = class {
1645
1710
  this.state.options.headerHeight,
1646
1711
  this.state.options.footerHeight
1647
1712
  );
1713
+ this.syncFillScale();
1648
1714
  }
1649
1715
  // resize/orientationchange ハンドラは呼び出し前に currentItems の存在を確認済み
1650
1716
  resetTranslateCurrent() {
@@ -1658,9 +1724,18 @@ var SmartPhoto = class {
1658
1724
  }
1659
1725
  return null;
1660
1726
  }
1727
+ currentLiElement() {
1728
+ for (const [item, slideRefs] of this.view.refs.slides) {
1729
+ if (item.index === this.state.viewer.currentIndex) {
1730
+ return slideRefs.li;
1731
+ }
1732
+ }
1733
+ return null;
1734
+ }
1661
1735
  // ---- 内部: dialog 制御(§8) ----
1662
1736
  syncDialog() {
1663
1737
  const { dialog, caption } = this.view.refs;
1738
+ dialog.style.transition = this.state.options.showAnimation === false ? "none" : "";
1664
1739
  if (this.state.viewer.isOpen && !dialog.open) {
1665
1740
  dialog.style.removeProperty("display");
1666
1741
  dialog.showModal();
@@ -1672,6 +1747,7 @@ var SmartPhoto = class {
1672
1747
  }
1673
1748
  commit() {
1674
1749
  this.view.render(this.state);
1750
+ this.view.updatePhotoTransform(this.state);
1675
1751
  this.syncDialog();
1676
1752
  }
1677
1753
  // ---- 内部: 開く演出 ----
@@ -1689,20 +1765,34 @@ var SmartPhoto = class {
1689
1765
  this.setPosByCurrentIndex();
1690
1766
  this.setSizeByScreen();
1691
1767
  setArrow(this.state);
1692
- if (this.state.options.resizeStyle === "fill" && this.isSmartPhoneFlag) {
1693
- const item = currentItem(this.state);
1694
- this.state.viewer.scale = true;
1695
- this.state.viewer.hideUi = true;
1696
- this.state.viewer.scaleSize = scaleBorder(
1697
- item,
1698
- getWindowWidth2(),
1699
- getWindowHeight2(),
1700
- this.isSmartPhoneFlag
1701
- );
1768
+ }
1769
+ // resizeStyle: 'fill' はスマートフォンでのみ、画面を隙間なく覆うよう
1770
+ // scaleBorder() の倍率を viewer.scaleSize に適用する。fit用の item.scale に
1771
+ // 依存するため、setSizeByScreen() の末尾から必ず呼ばれる(個別に呼ぶ必要はない)
1772
+ syncFillScale() {
1773
+ if (this.state.options.resizeStyle !== "fill" || !this.isSmartPhoneFlag) {
1774
+ return;
1702
1775
  }
1776
+ const item = currentItem(this.state);
1777
+ if (!item) {
1778
+ return;
1779
+ }
1780
+ this.state.viewer.scale = true;
1781
+ this.state.viewer.hideUi = true;
1782
+ this.state.viewer.scaleSize = scaleBorder(
1783
+ item,
1784
+ getWindowWidth2(),
1785
+ getWindowHeight2(),
1786
+ this.isSmartPhoneFlag
1787
+ );
1703
1788
  }
1704
1789
  supportsViewTransition() {
1705
- return typeof document.startViewTransition === "function";
1790
+ return this.state.options.useViewTransitionApi && typeof document.startViewTransition === "function" && // WebKit には「view-transition-name 付き要素が root スナップショットから
1791
+ // 除外されず、モーフ中に最終位置へ二重描画される」実装バグがあり、開く演出が
1792
+ // 「一旦ずれた位置に出てから正位置へ戻る」ように乱れる。API 対応の有無では
1793
+ // 検出できないため、WebKit ではクローン演出(addAppearEffect)へフォールバック
1794
+ // する(§util.isWebKit)
1795
+ !isWebKit();
1706
1796
  }
1707
1797
  openPhotoWithViewTransition(trigger) {
1708
1798
  document.documentElement.style.setProperty(
@@ -1714,7 +1804,8 @@ var SmartPhoto = class {
1714
1804
  if (thumbImg) {
1715
1805
  thumbImg.style.viewTransitionName = transitionName;
1716
1806
  }
1717
- const clearNames = () => {
1807
+ const cleanup = () => {
1808
+ this.isViewTransitionActive = false;
1718
1809
  if (thumbImg) {
1719
1810
  thumbImg.style.viewTransitionName = "";
1720
1811
  }
@@ -1722,6 +1813,21 @@ var SmartPhoto = class {
1722
1813
  if (img) {
1723
1814
  img.style.viewTransitionName = "";
1724
1815
  }
1816
+ if (!this.state.viewer.isOpen) {
1817
+ this.pendingViewTransitionResync = false;
1818
+ return;
1819
+ }
1820
+ if (this.pendingViewTransitionResync && currentItems(this.state)) {
1821
+ this.pendingViewTransitionResync = false;
1822
+ this.updateViewportHeight();
1823
+ this.resetTranslateCurrent();
1824
+ this.setPosByCurrentIndex();
1825
+ this.setSizeByScreen();
1826
+ this.commit();
1827
+ return;
1828
+ }
1829
+ this.pendingViewTransitionResync = false;
1830
+ this.view.render(this.state);
1725
1831
  };
1726
1832
  const transition = document.startViewTransition?.(() => {
1727
1833
  this.initPhoto();
@@ -1731,11 +1837,16 @@ var SmartPhoto = class {
1731
1837
  thumbImg.style.viewTransitionName = "";
1732
1838
  }
1733
1839
  this.currentImgElement().style.viewTransitionName = transitionName;
1840
+ this.view.applyViewTransitionLayout(this.state);
1734
1841
  });
1735
- transition?.ready.catch(() => {
1736
- clearNames();
1842
+ if (!transition) {
1843
+ return;
1844
+ }
1845
+ this.isViewTransitionActive = true;
1846
+ transition.ready.catch(() => {
1847
+ cleanup();
1737
1848
  });
1738
- transition?.finished.then(clearNames, clearNames);
1849
+ transition.finished.then(cleanup, cleanup);
1739
1850
  }
1740
1851
  // doOpen() の呼び出し元でこの分岐に来る時点で showAnimation !== false が保証されている
1741
1852
  addAppearEffect(trigger, item) {
@@ -1844,10 +1955,14 @@ var SmartPhoto = class {
1844
1955
  if (getWindowWidth2() === winWidthBefore && getWindowHeight2() === winHeightBefore) {
1845
1956
  return;
1846
1957
  }
1958
+ if (this.isViewTransitionActive) {
1959
+ this.pendingViewTransitionResync = true;
1960
+ return;
1961
+ }
1847
1962
  this.resetTranslateCurrent();
1848
1963
  this.setPosByCurrentIndex();
1849
1964
  this.setSizeByScreen();
1850
- this.view.render(this.state);
1965
+ this.commit();
1851
1966
  });
1852
1967
  }
1853
1968
  openPhoto(item, trigger) {
@@ -1869,21 +1984,37 @@ var SmartPhoto = class {
1869
1984
  }
1870
1985
  doHideEffect(dir) {
1871
1986
  return new Promise((resolve) => {
1987
+ if (this.state.options.showAnimation === false) {
1988
+ resolve();
1989
+ return;
1990
+ }
1872
1991
  const dialog = this.view.refs.dialog;
1873
- const img = this.currentImgElement();
1992
+ const item = currentItem(this.state);
1993
+ const li = item ? this.currentLiElement() : null;
1874
1994
  const height = getWindowHeight2();
1875
- const applied = dir === "top" ? `translateY(-${height}px)` : `translateY(${height}px)`;
1995
+ const img = this.currentImgElement();
1996
+ let frozenTransform = null;
1876
1997
  if (img) {
1877
- img.style.transform = applied;
1998
+ const rendered = getComputedStyle(img).transform;
1999
+ if (rendered && rendered !== "none") {
2000
+ img.style.transform = rendered;
2001
+ frozenTransform = img.style.transform;
2002
+ }
1878
2003
  }
1879
- const stored = img ? img.style.transform : "";
1880
- const finish = () => {
2004
+ if (li && item) {
2005
+ const offsetY = dir === "top" ? -height : height;
2006
+ li.style.transform = `translate(${item.translateX}px,${item.translateY + offsetY}px)`;
2007
+ }
2008
+ const finish = (e) => {
1881
2009
  if (this.finishHideEffect !== finish) {
1882
2010
  return;
1883
2011
  }
2012
+ if (e && e.target !== dialog) {
2013
+ return;
2014
+ }
1884
2015
  this.finishHideEffect = null;
1885
2016
  dialog.removeEventListener("transitionend", finish, true);
1886
- if (img && img.style.transform === stored) {
2017
+ if (img && frozenTransform && img.style.transform === frozenTransform) {
1887
2018
  img.style.transform = "";
1888
2019
  }
1889
2020
  resolve();
@@ -1958,7 +2089,9 @@ var SmartPhoto = class {
1958
2089
  const item = currentItem(this.state);
1959
2090
  this.state.viewer.onMove = false;
1960
2091
  setArrow(this.state);
1961
- this.commit();
2092
+ if (this.state.viewer.isOpen) {
2093
+ this.commit();
2094
+ }
1962
2095
  if (this.state.viewer.oldIndex !== this.state.viewer.currentIndex) {
1963
2096
  this.fireEvent("change");
1964
2097
  }
@@ -2043,7 +2176,21 @@ var SmartPhoto = class {
2043
2176
  }
2044
2177
  this.slideList();
2045
2178
  },
2046
- onTap: () => this.zoomPhoto(),
2179
+ // 主要ライトボックスのデファクトスタンダード(PhotoSwipe: bgClickAction
2180
+ // 'close' / imageClickAction 'zoom-or-close'、Fancybox: backdropClick
2181
+ // 'close'、GLightbox: closeOnOutsideClick、lightGallery: closable)に合わせ、
2182
+ // 写真の上のタップはズーム、写真の外(背景)のタップは閉じる。ズームの
2183
+ // 余地がない(scaleBorder <= 1 で zoomPhoto() が何もしない)写真の上の
2184
+ // タップも、無反応にせず 'zoom-or-close' に倣って閉じる
2185
+ onTap: (target) => {
2186
+ const img = this.currentImgElement();
2187
+ const onPhoto = !!img && target instanceof Node && img.contains(target);
2188
+ if (onPhoto && this.canZoomCurrentPhoto()) {
2189
+ this.zoomPhoto();
2190
+ } else {
2191
+ this.hidePhoto();
2192
+ }
2193
+ },
2047
2194
  onGestureStart: () => {
2048
2195
  this.fireEvent("gesturestart");
2049
2196
  this.view.updatePhotoTransform(this.state);