smartphoto 2.1.4 → 2.1.7

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.4
2
+ * SmartPhoto v2.1.7
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 Pe(t,...e){var i;t=t||{};for(let o=0;o<e.length;o++){let r=e[o];if(r){for(let s in r)if(Object.hasOwn(r,s)){let n=r[s];n&&typeof n=="object"?t[s]=Pe((i=t[s])!=null?i:{},n):t[s]=n}}}return t}var be=Pe,he=(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)},ye=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},Se=t=>({left:t.getBoundingClientRect().left,top:t.getBoundingClientRect().top});var Ge={classNames:{smartPhoto:"smartphoto",smartPhotoClose:"smartphoto-close",smartPhotoBody:"smartphoto-body",smartPhotoInner:"smartphoto-inner",smartPhotoContent:"smartphoto-content",smartPhotoImg:"smartphoto-img",smartPhotoImgOnMove:"smartphoto-img-onmove",smartPhotoImgElasticMove:"smartphoto-img-elasticmove",smartPhotoImgWrap:"smartphoto-img-wrap",smartPhotoArrows:"smartphoto-arrows",smartPhotoNav:"smartphoto-nav",smartPhotoArrowRight:"smartphoto-arrow-right",smartPhotoArrowLeft:"smartphoto-arrow-left",smartPhotoArrowHideIcon:"smartphoto-arrow-hide",smartPhotoImgLeft:"smartphoto-img-left",smartPhotoImgRight:"smartphoto-img-right",smartPhotoList:"smartphoto-list",smartPhotoListOnMove:"smartphoto-list-onmove",smartPhotoHeader:"smartphoto-header",smartPhotoCount:"smartphoto-count",smartPhotoCaption:"smartphoto-caption",smartPhotoDismiss:"smartphoto-dismiss",smartPhotoLoader:"smartphoto-loader",smartPhotoLoaderWrap:"smartphoto-loader-wrap",smartPhotoImgClone:"smartphoto-img-clone"},message:{gotoNextImage:"go to the next image",gotoPrevImage:"go to the previous image",closeDialog:"close the image dialog",carouselLabel:"Images"},arrows:!0,nav:!0,showAnimation:!0,verticalGravity:!1,useOrientationApi:!1,useHistoryApi:!0,swipeTopToClose:!1,swipeBottomToClose:!0,swipeOffset:100,swipeVelocity:.5,headerHeight:60,footerHeight:60,forceInterval:10,registance:.5,loadOffset:2,resizeStyle:"fit",lazyAttribute:"data-src",animationSpeed:300};function xe(t){return Object.keys(t).forEach(e=>{let i=t[e];i&&typeof i=="object"&&!Object.isFrozen(i)&&xe(i)}),Object.freeze(t)}function Ie(t){return{options:xe(be({},Ge,t)),viewer:{isOpen:!1,currentGroup:null,currentIndex:0,oldIndex:0,total:0,translateX:0,translateY:0,photoPosX:0,photoPosY:0,scaleSize:1,scale:!1,elastic:!1,hideUi:!1,onMove:!1,appear:!1,appearEffect:null,prev:-1,next:-1,showPrevArrow:!1,showNextArrow:!1},groups:new Map}}function de(t){return t.getAttribute("data-group")||"nogroup"}function ce(t){return t.group||"nogroup"}function Le(t,e,i,o){let r=de(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 m="";n!=null&&n.getAttribute("alt")?m=n.getAttribute("alt"):t.getAttribute("data-caption")?m=t.getAttribute("data-caption"):m=s!=null?s:"";let v=t.getAttribute("data-id");return{src:s,thumb:c,caption:t.getAttribute("data-caption"),alt:m,groupId:r,translateX:o*i,translateY:0,index:i,width:50,height:50,scale:1,x:0,y:0,id:v||i,loaded:!1,processed:!1,element:t}}function Ce(t,e,i){var v,g,b,C,y;let o=ce(t),r=t.src,s=(v=t.thumb)!=null?v:r,n=(g=t.caption)!=null?g:null,c=(C=(b=t.alt)!=null?b:n)!=null?C:r,m=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:m?t.width:50,height:m?t.height:50,scale:1,x:0,y:0,id:(y=t.id)!=null?y:e,loaded:m,processed:!1,element:null}}function me(t,e){t.groups.has(e.groupId)||t.groups.set(e.groupId,[]),t.groups.get(e.groupId).push(e),t.viewer.currentGroup=e.groupId}function M(t){var e;return t.viewer.currentGroup===null?null:(e=t.groups.get(t.viewer.currentGroup))!=null?e:null}function H(t){var i;let e=M(t);return e&&(i=e[t.viewer.currentIndex])!=null?i:null}function pe(t){let e=M(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 Te(t,e){t.forEach((i,o)=>{i.translateX=e*o})}function _(t,e){let i=10**e;return Math.round(t*i)/i}function Q(t,e,i,o){return o?t.width>t.height?i/(t.height*t.scale):e/(t.width*t.scale):1/t.scale}function Ae(t,e,i,o){let r=t.width*t.scale*e.scaleSize,s=t.height*t.scale*e.scaleSize,n,c,m,v;return i>r?(m=(i-r)/2,n=-1*m):(m=(r-i)/2,n=-1*m),o>s?(v=(o-s)/2,c=-1*v):(v=(s-o)/2,c=-1*v),{minX:_(n,6)*e.scaleSize,minY:_(c,6)*e.scaleSize,maxX:_(m,6)*e.scaleSize,maxY:_(v,6)*e.scaleSize}}function Me(t,e,i,o,r){let s=i-(o+r);t.forEach(n=>{n.loaded&&(n.processed=!0,n.scale=s/n.height,n.height<s&&(n.scale=1),n.x=(n.scale-1)/2*n.width+(e-n.width*n.scale)/2,n.y=(n.scale-1)/2*n.height+(i-n.height*n.scale)/2,n.width*n.scale>e&&(n.scale=e/n.width,n.x=(n.scale-1)/2*n.width))})}function He(t){let e=H(t);return e?`group=${t.viewer.currentGroup}&photo=${e.id}`:""}function ze(t,e){let i=null;return t.groups.forEach(o=>{o.forEach(r=>{e.group===r.groupId&&e.photo===r.id&&(i=r)})}),i}function fe(t,e){let i=10**e;return Math.round(t*i)/i}function W(t){return{x:t.pageX,y:t.pageY}}function Oe(t,e){let i=t.x-e.x,o=t.y-e.y;return Math.sqrt(i*i+o*o)}var ke=10;function $e(t,e){return{force:Math.sqrt(t*t+e*e),theta:Math.atan2(e,t)}}function Xe(){return{width:document.documentElement.clientWidth,height:document.documentElement.clientHeight}}function Ne({state:t,callbacks:e},{signal:i}){let o=new Map,r=Date.now(),s=!1,n=!1,c=null,m=null,v=null,g=0,b=!1,C=null,y=null,z=0,O=0,A=!1,V=0,S=null,L=0,X=0;function u(){return K()}function R(a){let{width:h,height:E}=Xe();return Ae(a,t.viewer,h,E)}function U(a){let{width:h,height:E}=Xe();return Q(a,h,E,u())}function ee(a,h){let E=H(t),w=R(E);t.viewer.elastic=!0,a===1?t.viewer.photoPosX=w.minX:a===-1&&(t.viewer.photoPosX=w.maxX),h===1?t.viewer.photoPosY=w.minY:h===-1&&(t.viewer.photoPosY=w.maxY),e.onPhotoDragMove(),setTimeout(()=>{t.viewer.elastic=!1,e.onPhotoDragMove()},300)}let te=setInterval(()=>{if(A||s||b||t.viewer.elastic||!t.viewer.scale)return;t.viewer.photoPosX+=L,t.viewer.photoPosY+=X;let a=H(t);if(!a)return;let h=R(a);t.viewer.photoPosX<h.minX?(t.viewer.photoPosX=h.minX,L*=-.2):t.viewer.photoPosX>h.maxX&&(t.viewer.photoPosX=h.maxX,L*=-.2),t.viewer.photoPosY<h.minY?(t.viewer.photoPosY=h.minY,X*=-.2):t.viewer.photoPosY>h.maxY&&(t.viewer.photoPosY=h.maxY,X*=-.2);let E=$e(L,X),w=E.force-t.options.registance;Math.abs(w)<.5||(L=Math.cos(E.theta)*w,X=Math.sin(E.theta)*w,e.onPhotoDragMove())},t.options.forceInterval);function N(a,h){(a>5||a<-5)&&(L+=a*.05),t.options.verticalGravity&&(h>5||h<-5)&&(X+=h*.05)}function J(a){if(!(a!=null&&a.gamma)||t.viewer.appearEffect||A||s||b||t.viewer.elastic||!t.viewer.scale)return;let{orientation:h}=window;h===0?N(a.gamma,a.beta):h===90?N(a.beta,a.gamma):h===-90?N(-a.beta,-a.gamma):h===180&&N(-a.gamma,-a.beta)}t.options.useOrientationApi&&window.addEventListener("deviceorientation",J,{signal:i});function ie(){A=!0,s=!1,b=!1;let a=Array.from(o.values());V=Oe(a[0],a[1]),t.viewer.scale=!0,e.onGestureStart()}function oe(a){let h=W(a);s=!0,n=!0,c=h,m=h,g=Date.now()}function re(a){b=!0;let h=W(a);y=h,C=h}function ne(a){var h,E;try{(E=(h=a.currentTarget).setPointerCapture)==null||E.call(h,a.pointerId)}catch(w){}if(o.set(a.pointerId,W(a)),o.size>1){ie();return}if(t.viewer.scale){re(a);return}oe(a)}function se(){S===null&&(S=requestAnimationFrame(()=>{S=null,e.onGestureMove()}))}function ae(){S!==null&&(cancelAnimationFrame(S),S=null,e.onGestureMove())}function d(){let a=Array.from(o.values()),h=Oe(a[0],a[1]),E=(h-V)/100,w=t.viewer.scaleSize,I=t.viewer.photoPosX,T=t.viewer.photoPosY;t.viewer.scaleSize+=fe(E,6),t.viewer.scaleSize<.2&&(t.viewer.scaleSize=.2),t.viewer.scaleSize<w&&(t.viewer.photoPosX=(1+t.viewer.scaleSize-w)*I,t.viewer.photoPosY=(1+t.viewer.scaleSize-w)*T);let B=H(t);if(B){let le=U(B);t.viewer.hideUi=t.viewer.scaleSize<1||t.viewer.scaleSize>le}V=h,se()}function l(a){let h=W(a),E=h.x-m.x,w=h.y-c.y;n&&(e.onSwipeStart(),n=!1,v=Math.abs(E)>Math.abs(w)?"horizontal":"vertical"),v==="horizontal"?t.viewer.translateX+=E:t.viewer.translateY=w,m=h,e.onSwipeMove()}function P(a){let h=W(a),E=h.x-y.x,w=h.y-y.y,I=fe(t.viewer.scaleSize*E,6),T=fe(t.viewer.scaleSize*w,6);t.viewer.photoPosX+=I,z=I,t.viewer.photoPosY+=T,O=T,y=h,e.onPhotoDragMove()}function f(a){if(o.has(a.pointerId)){if(o.set(a.pointerId,W(a)),A){d();return}if(b){P(a);return}l(a)}}function p(){A=!1,ae();let a=H(t);if(!a)return;let h=U(a);t.viewer.scaleSize>h||(t.viewer.photoPosX=0,t.viewer.photoPosY=0,t.viewer.scale=!1,t.viewer.scaleSize=1,t.viewer.hideUi=!1,e.onGestureEnd())}function x(){var ge;s=!1;let a=c,h=m,E=Date.now(),w=r-E,I=h.x-a.x,T=h.y-a.y,B=I===0&&T===0;if(!u()&&B){e.onTap();return}if(Math.abs(w)<=500&&B){e.onTap();return}r=E;let le=(ge=M(t))!=null?ge:[];if(v==="horizontal"){let F="stay",Ve=Math.max(E-g,1),Ee=Math.abs(I)>=ke&&Math.abs(I)/Ve>=t.options.swipeVelocity;(I>=t.options.swipeOffset||Ee&&I>0)&&t.viewer.currentIndex!==0?F="prev":(I<=-t.options.swipeOffset||Ee&&I<0)&&t.viewer.currentIndex!==le.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 $(){b=!1;let a=y,h=C;if(a.x===h.x){e.onPhotoDragEnd("zoom-out");return}let E=H(t);if(!E){e.onPhotoDragEnd(null);return}let w=R(E),I=t.options.swipeOffset*t.viewer.scaleSize,T=0,B=0;if(t.viewer.photoPosX>w.maxX?T=-1:t.viewer.photoPosX<w.minX&&(T=1),t.viewer.photoPosY>w.maxY?B=-1:t.viewer.photoPosY<w.minY&&(B=1),t.viewer.photoPosX-w.maxX>I&&t.viewer.currentIndex!==0){e.onPhotoDragEnd("prev");return}if(w.minX-t.viewer.photoPosX>I&&t.viewer.currentIndex+1!==t.viewer.total){e.onPhotoDragEnd("next");return}T===0&&B===0?(L=z/5,X=O/5):ee(T,B),e.onPhotoDragEnd(null)}function j(a){if(o.delete(a.pointerId),A){o.size<2&&p();return}if(b){$();return}s&&x()}function D(...a){for(let h of a)h.addEventListener("pointerdown",ne,{signal:i}),h.addEventListener("pointermove",f,{signal:i}),h.addEventListener("pointerup",j,{signal:i}),h.addEventListener("pointercancel",j,{signal:i})}function G(){clearInterval(te),S!==null&&(cancelAnimationFrame(S),S=null)}return{attach:D,detach:G}}function Z(t){let e=document.createElement("span");return e.className="smartphoto-sr-only",e.textContent=t,e}function ve(){let t=document.createElement("button");return t.type="button",t}function Fe(t){return t.replace(/"/g,'\\"')}function Ye({id:t,options:e},i,{signal:o}){let{classNames:r,message:s}=e,n=document.createElement("div");n.setAttribute("data-id",t);let c=document.createElement("dialog");c.className=r.smartPhoto,c.setAttribute("aria-labelledby",`smartphoto-${t}-title`),c.style.setProperty("--smartphoto-animation-speed",`${e.animationSpeed}ms`);let m=document.createElement("div");m.className=r.smartPhotoBody;let v=document.createElement("div");v.className=r.smartPhotoInner;let g=document.createElement("div");g.className=r.smartPhotoHeader;let b=document.createElement("span");b.className=r.smartPhotoCount;let C=document.createElement("h1");C.id=`smartphoto-${t}-title`,C.className=r.smartPhotoCaption,C.setAttribute("tabindex","-1");let y=document.createElement("button");y.className=r.smartPhotoDismiss,y.appendChild(Z(s.closeDialog)),y.addEventListener("click",()=>i.onDismiss(),{signal:o}),g.append(b,C,y);let z=document.createElement("div");z.className=r.smartPhotoContent,z.addEventListener("click",d=>{d.target===z&&i.onBackdropClick()},{signal:o});let O=document.createElement("ul");O.className=r.smartPhotoList,O.setAttribute("role","region"),O.setAttribute("aria-roledescription","carousel"),O.setAttribute("aria-label",s.carouselLabel),O.setAttribute("aria-live","polite"),O.setAttribute("aria-atomic","false"),v.append(g,z,O);let A=null,V=null,S=null;if(e.arrows){A=document.createElement("ul"),A.className=r.smartPhotoArrows,V=document.createElement("li"),V.className=r.smartPhotoArrowLeft;let d=ve();d.appendChild(Z(s.gotoPrevImage)),d.addEventListener("click",()=>i.onPrev(),{signal:o}),V.appendChild(d),S=document.createElement("li"),S.className=r.smartPhotoArrowRight;let l=ve();l.appendChild(Z(s.gotoNextImage)),l.addEventListener("click",()=>i.onNext(),{signal:o}),S.appendChild(l),A.append(V,S),v.appendChild(A)}let L=null,X=null;e.nav&&(L=document.createElement("nav"),L.className=r.smartPhotoNav,L.setAttribute("aria-label","Choose slide to display"),X=document.createElement("ul"),L.appendChild(X),v.appendChild(L)),m.appendChild(v),c.appendChild(m),n.appendChild(c);let u={dialog:c,count:b,caption:C,dismiss:y,content:z,list:O,arrows:A,arrowLeft:V,arrowRight:S,nav:L,navList:X,slides:new Map,imgClone:null};function R(){let d=document.createElement("div");d.className=r.smartPhotoLoaderWrap;let l=document.createElement("span");return l.className=r.smartPhotoLoader,d.appendChild(l),d}function U(d){var f,p;let l=document.createElement("div");l.className=r.smartPhotoImgWrap;let P=document.createElement("img");return P.className=r.smartPhotoImg,P.src=(f=d.src)!=null?f:"",P.alt=(p=d.alt)!=null?p:"",P.addEventListener("dragstart",x=>x.preventDefault(),{signal:o}),l.appendChild(P),{imgWrap:l,img:P}}function ee(d,l){var P;u.list.replaceChildren(),(P=u.navList)==null||P.replaceChildren(),u.slides=new Map,d.forEach(f=>{var $,j;let p=document.createElement("li");p.setAttribute("role","group"),p.setAttribute("aria-roledescription","slide"),p.setAttribute("aria-label",`${f.index+1} of ${d.length}`);let x={li:p,loaderWrap:null,imgWrap:null,img:null,navLink:null};if(f.processed){let{imgWrap:D,img:G}=U(f);p.appendChild(D),x.imgWrap=D,x.img=G}else{let D=R();p.appendChild(D),x.loaderWrap=D}if(u.list.appendChild(p),u.slides.set(f,x),u.navList){let D=document.createElement("li"),G=ve();G.style.backgroundImage=`url("${Fe(($=f.thumb)!=null?$:"")}")`;let a=f.index;G.addEventListener("click",()=>i.onNavigate(a),{signal:o}),G.appendChild(Z(`go to ${(j=f.caption)!=null?j:""}`)),D.appendChild(G),u.navList.appendChild(D),x.navLink=G}}),J(l)}function te(d,l){var p;if(l.imgWrap||!d.processed)return l;let{imgWrap:P,img:f}=U(d);return(p=l.loaderWrap)==null||p.replaceWith(P),l.loaderWrap=null,l.imgWrap=P,l.img=f,l}function N(d){d&&document.activeElement&&d.contains(document.activeElement)&&u.caption.focus()}function J(d){let{viewer:l}=d;u.count.textContent=`${l.currentIndex+1}/${l.total}`,u.slides.forEach((P,f)=>{var $;let p=te(f,P),x=f.index===l.currentIndex;p.li.style.transform=`translate(${f.translateX}px,${f.translateY}px)`,p.li.classList.toggle("current",x),x?p.li.removeAttribute("aria-hidden"):p.li.setAttribute("aria-hidden","true"),x&&(u.caption.textContent=($=f.caption)!=null?$:""),p.imgWrap&&p.img&&(p.imgWrap.style.transform=`translate(${f.x}px,${f.y}px) scale(${f.scale})`,p.img.style.width=`${f.width}px`,p.img.classList.toggle("active",l.appear),p.img.classList.toggle(r.smartPhotoImgOnMove,l.scale),p.img.classList.toggle(r.smartPhotoImgElasticMove,l.elastic)),p.navLink&&(p.navLink.classList.toggle("current",x),x?p.navLink.setAttribute("aria-current","true"):p.navLink.removeAttribute("aria-current"))}),u.arrowLeft&&(l.showPrevArrow?u.arrowLeft.removeAttribute("aria-hidden"):(N(u.arrowLeft),u.arrowLeft.setAttribute("aria-hidden","true"))),u.arrowRight&&(l.showNextArrow?u.arrowRight.removeAttribute("aria-hidden"):(N(u.arrowRight),u.arrowRight.setAttribute("aria-hidden","true"))),u.arrows&&(l.hideUi&&N(u.arrows),u.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false")),u.nav&&(l.hideUi&&N(u.nav),u.nav.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function ie(d){for(let[l,P]of u.slides)if(l.index===d.viewer.currentIndex)return P;return null}function oe(d){let{viewer:l}=d,P=ie(d),f=P==null?void 0:P.img;f&&(f.style.transform=`translate(${l.photoPosX}px,${l.photoPosY}px) scale(${l.scaleSize})`,f.classList.toggle(r.smartPhotoImgOnMove,l.scale),f.classList.toggle(r.smartPhotoImgElasticMove,l.elastic)),u.nav&&(l.hideUi&&N(u.nav),u.nav.setAttribute("aria-hidden",l.hideUi?"true":"false")),u.arrows&&(l.hideUi&&N(u.arrows),u.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function re(d){let{viewer:l}=d;u.list.style.transform=`translate(${l.translateX}px,${l.translateY}px)`,u.list.classList.toggle(r.smartPhotoListOnMove,l.onMove)}function ne(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)`,m.appendChild(l),u.imgClone=l}function se(){var d;(d=u.imgClone)==null||d.remove(),u.imgClone=null}function ae(){n.remove()}return{root:n,refs:u,render:J,syncSlides:ee,updatePhotoTransform:oe,updateListTransform:re,showAppearEffect:ne,removeAppearEffect:se,destroy:ae}}function Y(){return document.documentElement.clientWidth}function k(){let t=window.visualViewport;return t?t.height*t.scale:document.documentElement.clientHeight}function We(t){return t.length>0&&t[0]instanceof Element}function Re(){return(Date.now().toString(36)+Math.random().toString(36).substring(2,7)).toUpperCase()}function De(){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=Re();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.updateViewportHeight=()=>{this.view.refs.dialog.style.setProperty("--smartphoto-vh",`${k()}px`)};this.handleResize=()=>{M(this.state)&&(this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit())};this.handleKeydown=e=>{if(!this.state.viewer.isOpen)return;let i=e.keyCode||e.which;i===37?this.gotoSlide(this.state.viewer.prev):i===39?this.gotoSlide(this.state.viewer.next):i===27&&this.hidePhoto()};this.handleOrientationChange=()=>{if(!M(this.state))return;this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit();let e=Y(),i=500,o=r=>{this.scheduleTimeout(()=>{e!==Y()?(this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit()):r<=i&&o(r+25)},25)};o(0)};this.state=Ie(i!=null?i:{}),this.view=Ye({id:this.id,options:this.state.options},this.buildViewHandlers(),{signal:this.abortController.signal}),document.body.appendChild(this.view.root),this.gestures=Ne({state:this.state,callbacks:this.buildGestureCallbacks()},{signal:this.abortController.signal}),this.gestures.attach(this.view.refs.content,this.view.refs.list),this.view.refs.dialog.addEventListener("close",()=>{!this.isFiringPublicCloseEvent&&this.state.viewer.isOpen&&this.hidePhoto()},{signal:this.abortController.signal}),this.ingestSource(e),this.syncCurrentGroupView();let o=this.restoreFromHash();if(o&&(o.element?he(o.element,"click"):this.openPhoto(o,null)),this.updateViewportHeight(),window.visualViewport?window.visualViewport.addEventListener("resize",this.updateViewportHeight,{signal:this.abortController.signal}):window.addEventListener("resize",this.updateViewportHeight,{signal:this.abortController.signal}),!this.isSmartPhoneFlag){window.addEventListener("resize",this.handleResize,{signal:this.abortController.signal}),window.addEventListener("keydown",this.handleKeydown,{signal:this.abortController.signal});return}window.addEventListener("orientationchange",this.handleOrientationChange,{signal:this.abortController.signal})}on(e,i){let o=this.view.refs.dialog,r=s=>i.call(o,s);o.addEventListener(e,r,{signal:this.abortController.signal})}destroy(){this.state.viewer.isOpen=!1,this.view.refs.dialog.open&&this.view.refs.dialog.close(),this.abortController.abort(),this.timeouts.forEach(e=>{clearTimeout(e)}),this.timeouts=[],this.gestures.detach(),this.view.destroy()}[Symbol.dispose](){this.destroy()}gotoSlide(e){this.state.viewer.currentIndex=Number.parseInt(String(e),10),this.state.viewer.currentIndex||(this.state.viewer.currentIndex=0),this.slideList()}hidePhoto(e="bottom"){var o;if(!this.state.viewer.isOpen)return;this.state.viewer.isOpen=!1,this.state.viewer.appear=!1,this.state.viewer.appearEffect=null,this.view.removeAppearEffect(),this.state.viewer.hideUi=!1,this.state.viewer.scale=!1,this.state.viewer.scaleSize=1;let i=De();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=H(this.state);e&&(this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=Q(e,Y(),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 m,v,g;let o=(m=i.group)!=null?m: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=(g=(v=i.trigger)!=null?v:s.element)!=null?g:n;this.openPhoto(s,c)}hide(){this.hidePhoto()}next(){this.state.viewer.showNextArrow&&this.gotoSlide(this.state.viewer.next)}prev(){this.state.viewer.showPrevArrow&&this.gotoSlide(this.state.viewer.prev)}addItem(e){let i=e instanceof Element?this.addElementItem(e):this.addSlideItem(e);return this.syncCurrentGroupView(),i}get currentIndex(){return this.state.viewer.currentIndex}ingestSource(e){if(Array.isArray(e)&&!We(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=de(e),o=(n=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?n:0,r=Le(e,this.state.options,o,Y());return me(this.state,r),this.loadAllFired.delete(i),this.bindThumbnailClick(e,r),r}addSlideItem(e){var s,n;let i=ce(e),o=(n=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?n:0,r=Ce(e,o,Y());return me(this.state,r),this.loadAllFired.delete(i),r}bindThumbnailClick(e,i){e.addEventListener("click",o=>{o.preventDefault(),this.openPhoto(i,e)},{signal:this.abortController.signal})}syncCurrentGroupView(){let e=M(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=De();this.setHash(He(this.state)),window.scroll(e.x,e.y)}restoreFromHash(){let e=location.hash.substring(1);return e?ze(this.state,ye(e)):null}setPosByCurrentIndex(){let e=H(this.state);e&&(this.state.viewer.translateX=-e.translateX,this.state.viewer.translateY=0,this.view.updateListTransform(this.state))}setSizeByScreen(){let e=M(this.state);e&&Me(e,Y(),k(),this.state.options.headerHeight,this.state.options.footerHeight)}resetTranslateCurrent(){Te(M(this.state),Y())}currentImgElement(){for(let[e,i]of this.view.refs.slides)if(e.index===this.state.viewer.currentIndex)return i.img;return null}syncDialog(){let{dialog:e,caption:i}=this.view.refs;this.state.viewer.isOpen&&!e.open?(e.showModal(),i.focus()):!this.state.viewer.isOpen&&e.open&&e.close()}commit(){this.view.render(this.state),this.syncDialog()}initPhoto(){var i;(i=this.finishHideEffect)==null||i.call(this),this.view.refs.dialog.style.opacity="";let e=M(this.state);if(this.state.viewer.total=e.length,this.state.viewer.isOpen=!0,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.setPosByCurrentIndex(),this.setSizeByScreen(),pe(this.state),this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag){let o=H(this.state);this.state.viewer.scale=!0,this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=Q(o,Y(),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 m=this.currentImgElement();m&&(m.style.viewTransitionName="")},s=(c=document.startViewTransition)==null?void 0:c.call(document,()=>{this.initPhoto(),this.state.viewer.appear=!0,this.commit(),o&&(o.style.viewTransitionName=""),this.currentImgElement().style.viewTransitionName=i});s==null||s.ready.catch(()=>{r()}),s==null||s.finished.then(r,r)}addAppearEffect(e,i){var z;let o=(z=e==null?void 0:e.querySelector("img"))!=null?z:null;if(!o){this.state.viewer.appear=!0;return}let r=Se(o),s=o.offsetWidth,n=o.offsetHeight,c=Y(),m=k(),v=m-this.state.options.headerHeight-this.state.options.footerHeight,g=1;this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag?s>n?g=m/n:g=c/s:(s>=n?i.height<v?g=i.width/s:g=v/n:i.height<v?g=i.height/n:g=v/n,s*g>c&&(g=c/s));let b=(g-1)/2*s+(c-s*g)/2,C=(g-1)/2*n+(m-n*g)/2,y=o.getAttribute(this.state.options.lazyAttribute);this.state.viewer.appearEffect={width:s,height:n,top:r.top,left:r.left,once:!0,img:y||i.src||"",afterX:b,afterY:C,scale:g}}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=Y(),i=k();requestAnimationFrame(()=>{this.state.viewer.isOpen&&(Y()===e&&k()===i||(this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.view.render(this.state)))})}openPhoto(e,i){this.lastTriggerElement=i,this.state.viewer.currentGroup=e.groupId,this.state.viewer.currentIndex=e.index,this.syncedGroupId!==e.groupId&&this.syncCurrentGroupView(),this.setHashByCurrentIndex(),e.loaded?this.doOpen(i,e):this.loadItem(e).then(()=>{this.doOpen(i,e)})}doHideEffect(e){return new Promise(i=>{let o=this.view.refs.dialog,r=this.currentImgElement(),s=k(),n=e==="top"?`translateY(-${s}px)`:`translateY(${s}px)`,c=()=>{this.finishHideEffect===c&&(this.finishHideEffect=null,o.removeEventListener("transitionend",c,!0),r&&r.style.transform===n&&(r.style.transform=""),i())};this.finishHideEffect=c,r&&(r.style.transform=n),o.addEventListener("transitionend",c,!0),this.scheduleTimeout(c,this.state.options.animationSpeed+100)})}loadItem(e){return new Promise(i=>{var r;let o=new Image;o.onload=()=>{e.width=o.width,e.height=o.height,e.loaded=!0,this.checkLoadAll(e.groupId),i()},o.onerror=()=>i(),o.src=(r=e.src)!=null?r:""})}checkLoadAll(e){if(this.loadAllFired.has(e))return;let i=this.state.groups.get(e);i!=null&&i.length&&i.every(o=>o.loaded)&&(this.loadAllFired.add(e),this.fireEvent("loadall"))}loadNeighborItems(){let e=M(this.state);if(!e)return;let{currentIndex:i}=this.state.viewer,{loadOffset:o}=this.state.options,r=[];for(let s=i-o;s<i+o;s++){let n=e[s];n&&!n.loaded&&r.push(this.loadItem(n))}r.length&&Promise.all(r).then(()=>{this.initPhoto(),this.commit()})}slideList(){this.state.viewer.scaleSize=1,this.state.viewer.hideUi=!1,this.state.viewer.scale=!1,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.state.viewer.onMove=!0,this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.scheduleTimeout(()=>{let e=H(this.state);this.state.viewer.onMove=!1,pe(this.state),this.commit(),this.state.viewer.oldIndex!==this.state.viewer.currentIndex&&this.fireEvent("change"),this.state.viewer.oldIndex=this.state.viewer.currentIndex,this.loadNeighborItems(),e&&!e.loaded&&this.loadItem(e).then(()=>{this.initPhoto(),this.commit()})},200)}scheduleTimeout(e,i){let o=window.setTimeout(()=>{this.timeouts=this.timeouts.filter(r=>r!==o),e()},i);return this.timeouts.push(o),o}fireEvent(e){he(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 Be=q;var we=t=>{t.fn.SmartPhoto=function(e){return typeof e=="string"||new Be(this,e),this}};if(typeof define=="function"&&define.amd)define(["jquery"],we);else{let t=window,e=t.jQuery?t.jQuery:t.$;typeof e!="undefined"&&we(e)}var ot=we;})();
6
+ "use strict";(()=>{var K=()=>{let t=navigator.userAgent;return t.indexOf("iPhone")>0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0};function ye(t,...e){var i;t=t||{};for(let o=0;o<e.length;o++){let r=e[o];if(r){for(let s in r)if(Object.hasOwn(r,s)){let n=r[s];n&&typeof n=="object"?t[s]=ye((i=t[s])!=null?i:{},n):t[s]=n}}}return t}var be=ye,Se=(t,e,i)=>{let o;window.CustomEvent?o=new CustomEvent(e,{cancelable:!0}):(o=document.createEvent("CustomEvent"),o.initCustomEvent(e,!1,!1,i)),t.dispatchEvent(o)},xe=t=>{let e={};for(let i of t.split("&")){let o=i.split("="),r=o[0],s=o.length>1?o.slice(1).join("="):r;e[r]=decodeURIComponent(s)}return e},Ie=t=>({left:t.getBoundingClientRect().left,top:t.getBoundingClientRect().top});var Ge={classNames:{smartPhoto:"smartphoto",smartPhotoClose:"smartphoto-close",smartPhotoBody:"smartphoto-body",smartPhotoInner:"smartphoto-inner",smartPhotoContent:"smartphoto-content",smartPhotoImg:"smartphoto-img",smartPhotoImgOnMove:"smartphoto-img-onmove",smartPhotoImgElasticMove:"smartphoto-img-elasticmove",smartPhotoImgWrap:"smartphoto-img-wrap",smartPhotoArrows:"smartphoto-arrows",smartPhotoNav:"smartphoto-nav",smartPhotoArrowRight:"smartphoto-arrow-right",smartPhotoArrowLeft:"smartphoto-arrow-left",smartPhotoArrowHideIcon:"smartphoto-arrow-hide",smartPhotoImgLeft:"smartphoto-img-left",smartPhotoImgRight:"smartphoto-img-right",smartPhotoList:"smartphoto-list",smartPhotoListOnMove:"smartphoto-list-onmove",smartPhotoHeader:"smartphoto-header",smartPhotoCount:"smartphoto-count",smartPhotoCaption:"smartphoto-caption",smartPhotoDismiss:"smartphoto-dismiss",smartPhotoLoader:"smartphoto-loader",smartPhotoLoaderWrap:"smartphoto-loader-wrap",smartPhotoImgClone:"smartphoto-img-clone"},message:{gotoNextImage:"go to the next image",gotoPrevImage:"go to the previous image",closeDialog:"close the image dialog",carouselLabel:"Images"},arrows:!0,nav:!0,showAnimation:!0,verticalGravity:!1,useOrientationApi:!1,useHistoryApi:!0,swipeTopToClose:!1,swipeBottomToClose:!0,swipeOffset:100,swipeVelocity:.5,headerHeight:60,footerHeight:60,forceInterval:10,registance:.5,loadOffset:2,resizeStyle:"fit",lazyAttribute:"data-src",animationSpeed:450};function Le(t){return Object.keys(t).forEach(e=>{let i=t[e];i&&typeof i=="object"&&!Object.isFrozen(i)&&Le(i)}),Object.freeze(t)}function Ce(t){return{options:Le(be({},Ge,t)),viewer:{isOpen:!1,currentGroup:null,currentIndex:0,oldIndex:0,total:0,translateX:0,translateY:0,photoPosX:0,photoPosY:0,scaleSize:1,scale:!1,elastic:!1,hideUi:!1,onMove:!1,appear:!1,appearEffect:null,prev:-1,next:-1,showPrevArrow:!1,showNextArrow:!1},groups:new Map}}function q(t){return t.getAttribute("data-group")||"nogroup"}function de(t){return t.group||"nogroup"}function ce(t,e,i,o){let r=q(t),s=t.getAttribute("href"),n=t.querySelector("img"),d=s;n&&(n.getAttribute(e.lazyAttribute)?d=n.getAttribute(e.lazyAttribute):n.currentSrc?d=n.currentSrc:d=n.src);let p="";n!=null&&n.getAttribute("alt")?p=n.getAttribute("alt"):t.getAttribute("data-caption")?p=t.getAttribute("data-caption"):p=s!=null?s:"";let u=t.getAttribute("data-id");return{src:s,thumb:d,caption:t.getAttribute("data-caption"),alt:p,groupId:r,translateX:o*i,translateY:0,index:i,width:50,height:50,scale:1,x:0,y:0,id:u||i,loaded:!1,processed:!1,element:t}}function Te(t,e,i){var u,v,P,b,S;let o=de(t),r=t.src,s=(u=t.thumb)!=null?u:r,n=(v=t.caption)!=null?v:null,d=(b=(P=t.alt)!=null?P:n)!=null?b:r,p=typeof t.width=="number"&&typeof t.height=="number";return{src:r,thumb:s,caption:n,alt:d,groupId:o,translateX:i*e,translateY:0,index:e,width:p?t.width:50,height:p?t.height:50,scale:1,x:0,y:0,id:(S=t.id)!=null?S:e,loaded:p,processed:!1,element:null}}function me(t,e){t.groups.has(e.groupId)||t.groups.set(e.groupId,[]),t.groups.get(e.groupId).push(e),t.viewer.currentGroup=e.groupId}function H(t){var e;return t.viewer.currentGroup===null?null:(e=t.groups.get(t.viewer.currentGroup))!=null?e:null}function z(t){var i;let e=H(t);return e&&(i=e[t.viewer.currentIndex])!=null?i:null}function pe(t){let e=H(t);if(!e)return;let i=e.length,o=t.viewer.currentIndex+1,r=t.viewer.currentIndex-1;t.viewer.showNextArrow=!1,t.viewer.showPrevArrow=!1,o!==i&&(t.viewer.next=o,t.viewer.showNextArrow=!0),r!==-1&&(t.viewer.prev=r,t.viewer.showPrevArrow=!0)}function fe(t,e){t.forEach((i,o)=>{i.translateX=e*o})}function Z(t,e){let i=10**e;return Math.round(t*i)/i}function Q(t,e,i,o){return o?t.width>t.height?i/(t.height*t.scale):e/(t.width*t.scale):1/t.scale}function Ae(t,e,i,o){let r=t.width*t.scale*e.scaleSize,s=t.height*t.scale*e.scaleSize,n,d,p,u;return i>r?(p=(i-r)/2,n=-1*p):(p=(r-i)/2,n=-1*p),o>s?(u=(o-s)/2,d=-1*u):(u=(s-o)/2,d=-1*u),{minX:Z(n,6)*e.scaleSize,minY:Z(d,6)*e.scaleSize,maxX:Z(p,6)*e.scaleSize,maxY:Z(u,6)*e.scaleSize}}function Me(t,e,i,o,r){let s=i-(o+r);t.forEach(n=>{n.loaded&&(n.processed=!0,n.scale=s/n.height,n.height<s&&(n.scale=1),n.x=(n.scale-1)/2*n.width+(e-n.width*n.scale)/2,n.y=(n.scale-1)/2*n.height+(i-n.height*n.scale)/2,n.width*n.scale>e&&(n.scale=e/n.width,n.x=(n.scale-1)/2*n.width))})}function He(t){let e=z(t);return e?`group=${t.viewer.currentGroup}&photo=${e.id}`:""}function ze(t,e){let i=null;return t.groups.forEach(o=>{o.forEach(r=>{e.group===r.groupId&&e.photo===r.id&&(i=r)})}),i}function ve(t,e){let i=10**e;return Math.round(t*i)/i}function R(t){return{x:t.pageX,y:t.pageY}}function Oe(t,e){let i=t.x-e.x,o=t.y-e.y;return Math.sqrt(i*i+o*o)}var ke=10;function Fe(t,e){return{force:Math.sqrt(t*t+e*e),theta:Math.atan2(e,t)}}function De(){return{width:document.documentElement.clientWidth,height:document.documentElement.clientHeight}}function Be({state:t,callbacks:e},{signal:i}){let o=new Map,r=Date.now(),s=!1,n=!1,d=null,p=null,u=null,v=0,P=!1,b=null,S=null,O=0,D=0,M=!1,V=0,x=null,C=0,B=0;function c(){return K()}function W(a){let{width:h,height:E}=De();return Ae(a,t.viewer,h,E)}function U(a){let{width:h,height:E}=De();return Q(a,h,E,c())}function te(a,h){let E=z(t),g=W(E);t.viewer.elastic=!0,a===1?t.viewer.photoPosX=g.minX:a===-1&&(t.viewer.photoPosX=g.maxX),h===1?t.viewer.photoPosY=g.minY:h===-1&&(t.viewer.photoPosY=g.maxY),e.onPhotoDragMove(),setTimeout(()=>{t.viewer.elastic=!1,e.onPhotoDragMove()},300)}let ie=setInterval(()=>{if(M||s||P||t.viewer.elastic||!t.viewer.scale)return;t.viewer.photoPosX+=C,t.viewer.photoPosY+=B;let a=z(t);if(!a)return;let h=W(a);t.viewer.photoPosX<h.minX?(t.viewer.photoPosX=h.minX,C*=-.2):t.viewer.photoPosX>h.maxX&&(t.viewer.photoPosX=h.maxX,C*=-.2),t.viewer.photoPosY<h.minY?(t.viewer.photoPosY=h.minY,B*=-.2):t.viewer.photoPosY>h.maxY&&(t.viewer.photoPosY=h.maxY,B*=-.2);let E=Fe(C,B),g=E.force-t.options.registance;Math.abs(g)<.5||(C=Math.cos(E.theta)*g,B=Math.sin(E.theta)*g,e.onPhotoDragMove())},t.options.forceInterval);function X(a,h){(a>5||a<-5)&&(C+=a*.05),t.options.verticalGravity&&(h>5||h<-5)&&(B+=h*.05)}function J(a){if(!(a!=null&&a.gamma)||t.viewer.appearEffect||M||s||P||t.viewer.elastic||!t.viewer.scale)return;let{orientation:h}=window;h===0?X(a.gamma,a.beta):h===90?X(a.beta,a.gamma):h===-90?X(-a.beta,-a.gamma):h===180&&X(-a.gamma,-a.beta)}t.options.useOrientationApi&&window.addEventListener("deviceorientation",J,{signal:i});function oe(){M=!0,s=!1,P=!1;let a=Array.from(o.values());V=Oe(a[0],a[1]),t.viewer.scale=!0,e.onGestureStart()}function re(a){let h=R(a);s=!0,n=!0,d=h,p=h,v=Date.now()}function ne(a){P=!0;let h=R(a);S=h,b=h}function se(a){var h,E;try{(E=(h=a.currentTarget).setPointerCapture)==null||E.call(h,a.pointerId)}catch(g){}if(o.set(a.pointerId,R(a)),o.size>1){oe();return}if(t.viewer.scale){ne(a);return}re(a)}function ae(){x===null&&(x=requestAnimationFrame(()=>{x=null,e.onGestureMove()}))}function le(){x!==null&&(cancelAnimationFrame(x),x=null,e.onGestureMove())}function m(){let a=Array.from(o.values()),h=Oe(a[0],a[1]),E=(h-V)/100,g=t.viewer.scaleSize,L=t.viewer.photoPosX,T=t.viewer.photoPosY;t.viewer.scaleSize+=ve(E,6),t.viewer.scaleSize<.2&&(t.viewer.scaleSize=.2),t.viewer.scaleSize<g&&(t.viewer.photoPosX=(1+t.viewer.scaleSize-g)*L,t.viewer.photoPosY=(1+t.viewer.scaleSize-g)*T);let Y=z(t);if(Y){let he=U(Y);t.viewer.hideUi=t.viewer.scaleSize<1||t.viewer.scaleSize>he}V=h,ae()}function l(a){let h=R(a),E=h.x-p.x,g=h.y-d.y;n&&(e.onSwipeStart(),n=!1,u=Math.abs(E)>Math.abs(g)?"horizontal":"vertical"),u==="horizontal"?t.viewer.translateX+=E:t.viewer.translateY=g,p=h,e.onSwipeMove()}function y(a){let h=R(a),E=h.x-S.x,g=h.y-S.y,L=ve(t.viewer.scaleSize*E,6),T=ve(t.viewer.scaleSize*g,6);t.viewer.photoPosX+=L,O=L,t.viewer.photoPosY+=T,D=T,S=h,e.onPhotoDragMove()}function w(a){if(o.has(a.pointerId)){if(o.set(a.pointerId,R(a)),M){m();return}if(P){y(a);return}l(a)}}function f(){M=!1,le();let a=z(t);if(!a)return;let h=U(a);t.viewer.scaleSize>h||(t.viewer.photoPosX=0,t.viewer.photoPosY=0,t.viewer.scale=!1,t.viewer.scaleSize=1,t.viewer.hideUi=!1,e.onGestureEnd())}function I(){var Ee;s=!1;let a=d,h=p,E=Date.now(),g=r-E,L=h.x-a.x,T=h.y-a.y,Y=L===0&&T===0;if(!c()&&Y){e.onTap();return}if(Math.abs(g)<=500&&Y){e.onTap();return}r=E;let he=(Ee=H(t))!=null?Ee:[];if(u==="horizontal"){let $="stay",Ve=Math.max(E-v,1),Pe=Math.abs(L)>=ke&&Math.abs(L)/Ve>=t.options.swipeVelocity;(L>=t.options.swipeOffset||Pe&&L>0)&&t.viewer.currentIndex!==0?$="prev":(L<=-t.options.swipeOffset||Pe&&L<0)&&t.viewer.currentIndex!==he.length-1&&($="next"),e.onSwipeEnd($)}else{let $="stay";t.options.swipeBottomToClose&&T>=t.options.swipeOffset?$="close-bottom":t.options.swipeTopToClose&&T<=-t.options.swipeOffset&&($="close-top"),e.onSwipeEnd($)}}function F(){P=!1;let a=S,h=b;if(a.x===h.x){e.onPhotoDragEnd("zoom-out");return}let E=z(t);if(!E){e.onPhotoDragEnd(null);return}let g=W(E),L=t.options.swipeOffset*t.viewer.scaleSize,T=0,Y=0;if(t.viewer.photoPosX>g.maxX?T=-1:t.viewer.photoPosX<g.minX&&(T=1),t.viewer.photoPosY>g.maxY?Y=-1:t.viewer.photoPosY<g.minY&&(Y=1),t.viewer.photoPosX-g.maxX>L&&t.viewer.currentIndex!==0){e.onPhotoDragEnd("prev");return}if(g.minX-t.viewer.photoPosX>L&&t.viewer.currentIndex+1!==t.viewer.total){e.onPhotoDragEnd("next");return}T===0&&Y===0?(C=O/5,B=D/5):te(T,Y),e.onPhotoDragEnd(null)}function j(a){if(o.delete(a.pointerId),M){o.size<2&&f();return}if(P){F();return}s&&I()}function N(...a){for(let h of a)h.addEventListener("pointerdown",se,{signal:i}),h.addEventListener("pointermove",w,{signal:i}),h.addEventListener("pointerup",j,{signal:i}),h.addEventListener("pointercancel",j,{signal:i})}function G(){clearInterval(ie),x!==null&&(cancelAnimationFrame(x),x=null)}return{attach:N,detach:G}}function ee(t){let e=document.createElement("span");return e.className="smartphoto-sr-only",e.textContent=t,e}function we(){let t=document.createElement("button");return t.type="button",t}function $e(t){return t.replace(/"/g,'\\"')}function Xe({id:t,options:e},i,{signal:o}){let{classNames:r,message:s}=e,n=document.createElement("div");n.setAttribute("data-id",t);let d=document.createElement("dialog");d.className=r.smartPhoto,d.setAttribute("aria-labelledby",`smartphoto-${t}-title`),d.style.display="none",d.style.setProperty("--smartphoto-animation-speed",`${e.animationSpeed}ms`);let p=document.createElement("div");p.className=r.smartPhotoBody;let u=document.createElement("div");u.className=r.smartPhotoInner;let v=document.createElement("div");v.className=r.smartPhotoHeader;let P=document.createElement("span");P.className=r.smartPhotoCount;let b=document.createElement("h1");b.id=`smartphoto-${t}-title`,b.className=r.smartPhotoCaption,b.setAttribute("tabindex","-1");let S=document.createElement("button");S.className=r.smartPhotoDismiss,S.appendChild(ee(s.closeDialog)),S.addEventListener("click",()=>i.onDismiss(),{signal:o}),v.append(P,b,S);let O=document.createElement("div");O.className=r.smartPhotoContent,O.addEventListener("click",m=>{m.target===O&&i.onBackdropClick()},{signal:o});let D=document.createElement("ul");D.className=r.smartPhotoList,D.setAttribute("role","region"),D.setAttribute("aria-roledescription","carousel"),D.setAttribute("aria-label",s.carouselLabel),D.setAttribute("aria-live","polite"),D.setAttribute("aria-atomic","false"),u.append(v,O,D);let M=null,V=null,x=null;if(e.arrows){M=document.createElement("ul"),M.className=r.smartPhotoArrows,V=document.createElement("li"),V.className=r.smartPhotoArrowLeft;let m=we();m.appendChild(ee(s.gotoPrevImage)),m.addEventListener("click",()=>i.onPrev(),{signal:o}),V.appendChild(m),x=document.createElement("li"),x.className=r.smartPhotoArrowRight;let l=we();l.appendChild(ee(s.gotoNextImage)),l.addEventListener("click",()=>i.onNext(),{signal:o}),x.appendChild(l),M.append(V,x),u.appendChild(M)}let C=null,B=null;e.nav&&(C=document.createElement("nav"),C.className=r.smartPhotoNav,C.setAttribute("aria-label","Choose slide to display"),B=document.createElement("ul"),C.appendChild(B),u.appendChild(C)),p.appendChild(u),d.appendChild(p),n.appendChild(d);let c={dialog:d,count:P,caption:b,dismiss:S,content:O,list:D,arrows:M,arrowLeft:V,arrowRight:x,nav:C,navList:B,slides:new Map,imgClone:null};function W(){let m=document.createElement("div");m.className=r.smartPhotoLoaderWrap;let l=document.createElement("span");return l.className=r.smartPhotoLoader,m.appendChild(l),m}function U(m){var w,f;let l=document.createElement("div");l.className=r.smartPhotoImgWrap;let y=document.createElement("img");return y.className=r.smartPhotoImg,y.src=(w=m.src)!=null?w:"",y.alt=(f=m.alt)!=null?f:"",y.addEventListener("dragstart",I=>I.preventDefault(),{signal:o}),l.appendChild(y),{imgWrap:l,img:y}}function te(m,l){var y;c.list.replaceChildren(),(y=c.navList)==null||y.replaceChildren(),c.slides=new Map,m.forEach(w=>{var F,j;let f=document.createElement("li");f.setAttribute("role","group"),f.setAttribute("aria-roledescription","slide"),f.setAttribute("aria-label",`${w.index+1} of ${m.length}`);let I={li:f,loaderWrap:null,imgWrap:null,img:null,navLink:null};if(w.processed){let{imgWrap:N,img:G}=U(w);f.appendChild(N),I.imgWrap=N,I.img=G}else{let N=W();f.appendChild(N),I.loaderWrap=N}if(c.list.appendChild(f),c.slides.set(w,I),c.navList){let N=document.createElement("li"),G=we();G.style.backgroundImage=`url("${$e((F=w.thumb)!=null?F:"")}")`;let a=w.index;G.addEventListener("click",()=>i.onNavigate(a),{signal:o}),G.appendChild(ee(`go to ${(j=w.caption)!=null?j:""}`)),N.appendChild(G),c.navList.appendChild(N),I.navLink=G}}),J(l)}function ie(m,l){var f;if(l.imgWrap||!m.processed)return l;let{imgWrap:y,img:w}=U(m);return(f=l.loaderWrap)==null||f.replaceWith(y),l.loaderWrap=null,l.imgWrap=y,l.img=w,l}function X(m){m&&document.activeElement&&m.contains(document.activeElement)&&c.caption.focus()}function J(m){let{viewer:l}=m;c.count.textContent=`${l.currentIndex+1}/${l.total}`,c.slides.forEach((y,w)=>{var F;let f=ie(w,y),I=w.index===l.currentIndex;f.li.style.transform=`translate(${w.translateX}px,${w.translateY}px)`,f.li.classList.toggle("current",I),I?f.li.removeAttribute("aria-hidden"):f.li.setAttribute("aria-hidden","true"),I&&(c.caption.textContent=(F=w.caption)!=null?F:""),f.imgWrap&&f.img&&(f.imgWrap.style.transform=`translate(${w.x}px,${w.y}px) scale(${w.scale})`,f.img.style.width=`${w.width}px`,f.img.classList.toggle("active",l.appear),f.img.classList.toggle(r.smartPhotoImgOnMove,l.scale),f.img.classList.toggle(r.smartPhotoImgElasticMove,l.elastic)),f.navLink&&(f.navLink.classList.toggle("current",I),I?f.navLink.setAttribute("aria-current","true"):f.navLink.removeAttribute("aria-current"))}),c.arrowLeft&&(l.showPrevArrow?c.arrowLeft.removeAttribute("aria-hidden"):(X(c.arrowLeft),c.arrowLeft.setAttribute("aria-hidden","true"))),c.arrowRight&&(l.showNextArrow?c.arrowRight.removeAttribute("aria-hidden"):(X(c.arrowRight),c.arrowRight.setAttribute("aria-hidden","true"))),c.arrows&&(l.hideUi&&X(c.arrows),c.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false")),c.nav&&(l.hideUi&&X(c.nav),c.nav.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function oe(m){for(let[l,y]of c.slides)if(l.index===m.viewer.currentIndex)return y;return null}function re(m){let{viewer:l}=m,y=oe(m),w=y==null?void 0:y.img;w&&(w.style.transform=`translate(${l.photoPosX}px,${l.photoPosY}px) scale(${l.scaleSize})`,w.classList.toggle(r.smartPhotoImgOnMove,l.scale),w.classList.toggle(r.smartPhotoImgElasticMove,l.elastic)),c.nav&&(l.hideUi&&X(c.nav),c.nav.setAttribute("aria-hidden",l.hideUi?"true":"false")),c.arrows&&(l.hideUi&&X(c.arrows),c.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function ne(m){let{viewer:l}=m;c.list.style.transform=`translate(${l.translateX}px,${l.translateY}px)`,c.list.classList.toggle(r.smartPhotoListOnMove,l.onMove)}function se(m){let l=document.createElement("img");l.className=r.smartPhotoImgClone,l.src=m.img,l.style.width=`${m.width}px`,l.style.height=`${m.height}px`,l.style.transform=`translate(${m.left}px,${m.top}px) scale(1)`,p.appendChild(l),c.imgClone=l}function ae(){var m;(m=c.imgClone)==null||m.remove(),c.imgClone=null}function le(){n.remove()}return{root:n,refs:c,render:J,syncSlides:te,updatePhotoTransform:re,updateListTransform:ne,showAppearEffect:se,removeAppearEffect:ae,destroy:le}}function A(){return document.documentElement.clientWidth}function k(){let t=window.visualViewport;return t?t.height*t.scale:document.documentElement.clientHeight}function Re(t){return t.length>0&&t[0]instanceof Element}function We(){return(Date.now().toString(36)+Math.random().toString(36).substring(2,7)).toUpperCase()}function Ne(){return{x:window.pageXOffset!==void 0?window.pageXOffset:document.documentElement.scrollLeft,y:window.pageYOffset!==void 0?window.pageYOffset:document.documentElement.scrollTop}}var _=class{constructor(e,i){this.id=We();this.abortController=new AbortController;this.isSmartPhoneFlag=K();this.lastTriggerElement=null;this.isFiringPublicCloseEvent=!1;this.finishHideEffect=null;this.timeouts=[];this.loadAllFired=new Set;this.syncedGroupId=null;this.rootSelector=null;this.itemsByElement=new Map;this.handleDocumentClick=e=>{if(!(e.target instanceof Element))return;let i=e;if(i.__smartphotoClaimed)return;let o=this.findRegisteredAncestor(e.target);if(!o&&this.rootSelector&&(o=e.target.closest(this.rootSelector)),!o)return;if(e.preventDefault(),i.__smartphotoClaimed=!0,!this.itemsByElement.has(o)&&this.rootSelector){let s=q(o);this.resyncGroupFromDom(s)&&this.syncCurrentGroupView()}let r=this.itemsByElement.get(o);r&&this.openPhoto(r,o)};this.updateViewportHeight=()=>{this.view.refs.dialog.style.setProperty("--smartphoto-vh",`${k()}px`)};this.handleResize=()=>{H(this.state)&&(this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit())};this.handleKeydown=e=>{if(!this.state.viewer.isOpen)return;let i=e.keyCode||e.which;i===37?this.gotoSlide(this.state.viewer.prev):i===39?this.gotoSlide(this.state.viewer.next):i===27&&this.hidePhoto()};this.handleOrientationChange=()=>{if(!H(this.state))return;this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit();let e=A(),i=500,o=r=>{this.scheduleTimeout(()=>{e!==A()?(this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit()):r<=i&&o(r+25)},25)};o(0)};this.rootSelector=typeof e=="string"?e:null,this.state=Ce(i!=null?i:{}),this.view=Xe({id:this.id,options:this.state.options},this.buildViewHandlers(),{signal:this.abortController.signal}),document.body.appendChild(this.view.root),this.gestures=Be({state:this.state,callbacks:this.buildGestureCallbacks()},{signal:this.abortController.signal}),this.gestures.attach(this.view.refs.content,this.view.refs.list),this.view.refs.dialog.addEventListener("close",()=>{!this.isFiringPublicCloseEvent&&this.state.viewer.isOpen&&this.hidePhoto()},{signal:this.abortController.signal}),document.addEventListener("click",this.handleDocumentClick,{signal:this.abortController.signal}),this.ingestSource(e),this.syncCurrentGroupView();let o=this.restoreFromHash();if(o&&this.openPhoto(o,o.element),this.updateViewportHeight(),window.visualViewport?window.visualViewport.addEventListener("resize",this.updateViewportHeight,{signal:this.abortController.signal}):window.addEventListener("resize",this.updateViewportHeight,{signal:this.abortController.signal}),!this.isSmartPhoneFlag){window.addEventListener("resize",this.handleResize,{signal:this.abortController.signal}),window.addEventListener("keydown",this.handleKeydown,{signal:this.abortController.signal});return}window.addEventListener("orientationchange",this.handleOrientationChange,{signal:this.abortController.signal})}on(e,i){let o=this.view.refs.dialog,r=s=>i.call(o,s);o.addEventListener(e,r,{signal:this.abortController.signal})}destroy(){this.state.viewer.isOpen=!1,this.view.refs.dialog.open&&this.view.refs.dialog.close(),this.abortController.abort(),this.timeouts.forEach(e=>{clearTimeout(e)}),this.timeouts=[],this.itemsByElement.clear(),this.gestures.detach(),this.view.destroy()}[Symbol.dispose](){this.destroy()}gotoSlide(e){this.state.viewer.currentIndex=Number.parseInt(String(e),10),this.state.viewer.currentIndex||(this.state.viewer.currentIndex=0),this.slideList()}hidePhoto(e="bottom"){var o;if(!this.state.viewer.isOpen)return;this.state.viewer.isOpen=!1,this.state.viewer.appear=!1,this.state.viewer.appearEffect=null,this.view.removeAppearEffect(),this.state.viewer.hideUi=!1,this.state.viewer.scale=!1,this.state.viewer.scaleSize=1;let i=Ne();location.hash&&this.setHash(""),window.scroll(i.x,i.y),this.syncDialog(),(o=this.lastTriggerElement)!=null&&o.isConnected&&this.lastTriggerElement.focus(),this.lastTriggerElement=null,this.doHideEffect(e).then(()=>{this.view.render(this.state),this.isFiringPublicCloseEvent=!0,this.fireEvent("close"),this.isFiringPublicCloseEvent=!1})}zoomPhoto(){let e=z(this.state);e&&(this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=Q(e,A(),k(),this.isSmartPhoneFlag),!(this.state.viewer.scaleSize<=1)&&(this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.view.updatePhotoTransform(this.state),this.scheduleTimeout(()=>{this.state.viewer.scale=!0,this.view.updatePhotoTransform(this.state),this.fireEvent("zoomin")},300)))}zoomOutPhoto(){this.state.viewer.scaleSize=1,this.state.viewer.hideUi=!1,this.state.viewer.scale=!1,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.view.updatePhotoTransform(this.state),this.fireEvent("zoomout")}addNewItem(e){return this.addItem(e)}show(e=0,i={}){var p,u,v;let o=(p=i.group)!=null?p:this.state.viewer.currentGroup;if(o===null)return;let r=this.state.groups.get(o);if(!(r!=null&&r.length))return;let s=typeof e=="number"?r[e]:r.find(P=>P.id===e);if(!s)return;let n=document.activeElement instanceof HTMLElement?document.activeElement:null,d=(v=(u=i.trigger)!=null?u:s.element)!=null?v:n;this.openPhoto(s,d)}hide(){this.hidePhoto()}next(){this.state.viewer.showNextArrow&&this.gotoSlide(this.state.viewer.next)}prev(){this.state.viewer.showPrevArrow&&this.gotoSlide(this.state.viewer.prev)}addItem(e){let i=e instanceof HTMLElement?this.addElementItem(e):this.addSlideItem(e);return this.syncCurrentGroupView(),i}get currentIndex(){return this.state.viewer.currentIndex}ingestSource(e){if(Array.isArray(e)&&!Re(e)){e.forEach(o=>{this.addSlideItem(o)});return}Array.from(typeof e=="string"?document.querySelectorAll(e):e).forEach(o=>{this.addElementItem(o)})}addElementItem(e){var s,n;let i=q(e),o=(n=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?n:0,r=ce(e,this.state.options,o,A());return me(this.state,r),this.loadAllFired.delete(i),this.itemsByElement.set(e,r),r}addSlideItem(e){var s,n;let i=de(e),o=(n=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?n:0,r=Te(e,o,A());return me(this.state,r),this.loadAllFired.delete(i),r}findRegisteredAncestor(e){let i=e;for(;i;){if(this.itemsByElement.has(i))return i;i=i.parentElement}return null}resyncGroupFromDom(e){var p;if(!this.rootSelector)return!1;let i=Array.from(document.querySelectorAll(this.rootSelector)).filter(u=>q(u)===e),o=new Set(i),r=(p=this.state.groups.get(e))!=null?p:[],s=new Map;r.forEach(u=>{u.element&&s.set(u.element,u)});let n=i.length!==r.length,d=i.map((u,v)=>{let P=s.get(u);if(P)return P.index!==v&&(n=!0,P.index=v),P;n=!0;let b=ce(u,this.state.options,v,A());return this.itemsByElement.set(u,b),b});return r.forEach(u=>{u.element&&!o.has(u.element)&&this.itemsByElement.delete(u.element)}),fe(d,A()),this.state.groups.set(e,d),n&&this.loadAllFired.delete(e),n}syncCurrentGroupView(){let e=H(this.state);e&&(this.view.syncSlides(e,this.state),this.syncedGroupId=this.state.viewer.currentGroup)}setHash(e){var o;if(!((o=window.history)!=null&&o.pushState)||!this.state.options.useHistoryApi)return;let i=`${location.pathname}${location.search}`;window.history.replaceState(null,"",e?`${i}#${e}`:i)}setHashByCurrentIndex(){let e=Ne();this.setHash(He(this.state)),window.scroll(e.x,e.y)}restoreFromHash(){let e=location.hash.substring(1);return e?ze(this.state,xe(e)):null}setPosByCurrentIndex(){let e=z(this.state);e&&(this.state.viewer.translateX=-e.translateX,this.state.viewer.translateY=0,this.view.updateListTransform(this.state))}setSizeByScreen(){let e=H(this.state);e&&Me(e,A(),k(),this.state.options.headerHeight,this.state.options.footerHeight)}resetTranslateCurrent(){fe(H(this.state),A())}currentImgElement(){for(let[e,i]of this.view.refs.slides)if(e.index===this.state.viewer.currentIndex)return i.img;return null}syncDialog(){let{dialog:e,caption:i}=this.view.refs;this.state.viewer.isOpen&&!e.open?(e.style.removeProperty("display"),e.showModal(),i.focus()):!this.state.viewer.isOpen&&e.open&&(e.close(),e.style.display="none")}commit(){this.view.render(this.state),this.syncDialog()}initPhoto(){var i;(i=this.finishHideEffect)==null||i.call(this),this.view.refs.dialog.style.opacity="";let e=H(this.state);if(this.state.viewer.total=e.length,this.state.viewer.isOpen=!0,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.setPosByCurrentIndex(),this.setSizeByScreen(),pe(this.state),this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag){let o=z(this.state);this.state.viewer.scale=!0,this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=Q(o,A(),k(),this.isSmartPhoneFlag)}}supportsViewTransition(){return typeof document.startViewTransition=="function"}openPhotoWithViewTransition(e){var n,d;document.documentElement.style.setProperty("--smartphoto-animation-speed",`${this.state.options.animationSpeed}ms`);let i="smartphoto-hero",o=(n=e==null?void 0:e.querySelector("img"))!=null?n:null;o&&(o.style.viewTransitionName=i);let r=()=>{o&&(o.style.viewTransitionName="");let p=this.currentImgElement();p&&(p.style.viewTransitionName="")},s=(d=document.startViewTransition)==null?void 0:d.call(document,()=>{this.initPhoto(),this.state.viewer.appear=!0,this.commit(),o&&(o.style.viewTransitionName=""),this.currentImgElement().style.viewTransitionName=i});s==null||s.ready.catch(()=>{r()}),s==null||s.finished.then(r,r)}addAppearEffect(e,i){var O;let o=(O=e==null?void 0:e.querySelector("img"))!=null?O:null;if(!o){this.state.viewer.appear=!0;return}let r=Ie(o),s=o.offsetWidth,n=o.offsetHeight,d=A(),p=k(),u=p-this.state.options.headerHeight-this.state.options.footerHeight,v=1;this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag?s>n?v=p/n:v=d/s:(s>=n?i.height<u?v=i.width/s:v=u/n:i.height<u?v=i.height/n:v=u/n,s*v>d&&(v=d/s));let P=(v-1)/2*s+(d-s*v)/2,b=(v-1)/2*n+(p-n*v)/2,S=o.getAttribute(this.state.options.lazyAttribute);this.state.viewer.appearEffect={width:s,height:n,top:r.top,left:r.left,once:!0,img:S||i.src||"",afterX:P,afterY:b,scale:v}}runAppearEffect(e){this.view.showAppearEffect(e);let i=this.view.refs.imgClone;return new Promise(o=>{let r=()=>{i.removeEventListener("transitionend",r,!0),o()};i.addEventListener("transitionend",r,!0),this.scheduleTimeout(()=>{i.style.transform=`translate(${e.afterX}px, ${e.afterY}px) scale(${e.scale})`},10)})}doOpen(e,i){if(this.state.options.showAnimation!==!1&&this.supportsViewTransition())this.openPhotoWithViewTransition(e);else if(this.state.options.showAnimation===!1)this.initPhoto(),this.state.viewer.appear=!0,this.commit();else{this.initPhoto(),this.addAppearEffect(e,i),this.commit();let o=this.state.viewer.appearEffect;o&&this.runAppearEffect(o).then(()=>{this.state.viewer.appearEffect=null,this.view.removeAppearEffect(),this.state.viewer.appear=!0,this.commit()})}this.fireEvent("open"),this.resyncSizeAfterOpen()}resyncSizeAfterOpen(){let e=A(),i=k();requestAnimationFrame(()=>{this.state.viewer.isOpen&&(A()===e&&k()===i||(this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.view.render(this.state)))})}openPhoto(e,i){let o=this.rootSelector?this.resyncGroupFromDom(e.groupId):!1;this.lastTriggerElement=i,this.state.viewer.currentGroup=e.groupId,this.state.viewer.currentIndex=e.index,(this.syncedGroupId!==e.groupId||o)&&this.syncCurrentGroupView(),this.setHashByCurrentIndex(),e.loaded?this.doOpen(i,e):this.loadItem(e).then(()=>{this.doOpen(i,e)})}doHideEffect(e){return new Promise(i=>{let o=this.view.refs.dialog,r=this.currentImgElement(),s=k(),n=e==="top"?`translateY(-${s}px)`:`translateY(${s}px)`,d=()=>{this.finishHideEffect===d&&(this.finishHideEffect=null,o.removeEventListener("transitionend",d,!0),r&&r.style.transform===n&&(r.style.transform=""),i())};this.finishHideEffect=d,r&&(r.style.transform=n),o.addEventListener("transitionend",d,!0),this.scheduleTimeout(d,this.state.options.animationSpeed+100)})}loadItem(e){return new Promise(i=>{var r;let o=new Image;o.onload=()=>{e.width=o.width,e.height=o.height,e.loaded=!0,this.checkLoadAll(e.groupId),i()},o.onerror=()=>i(),o.src=(r=e.src)!=null?r:""})}checkLoadAll(e){if(this.loadAllFired.has(e))return;let i=this.state.groups.get(e);i!=null&&i.length&&i.every(o=>o.loaded)&&(this.loadAllFired.add(e),this.fireEvent("loadall"))}loadNeighborItems(){let e=H(this.state);if(!e)return;let{currentIndex:i}=this.state.viewer,{loadOffset:o}=this.state.options,r=[];for(let s=i-o;s<i+o;s++){let n=e[s];n&&!n.loaded&&r.push(this.loadItem(n))}r.length&&Promise.all(r).then(()=>{this.initPhoto(),this.commit()})}slideList(){this.state.viewer.scaleSize=1,this.state.viewer.hideUi=!1,this.state.viewer.scale=!1,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.state.viewer.onMove=!0,this.updateViewportHeight(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.scheduleTimeout(()=>{let e=z(this.state);this.state.viewer.onMove=!1,pe(this.state),this.commit(),this.state.viewer.oldIndex!==this.state.viewer.currentIndex&&this.fireEvent("change"),this.state.viewer.oldIndex=this.state.viewer.currentIndex,this.loadNeighborItems(),e&&!e.loaded&&this.loadItem(e).then(()=>{this.initPhoto(),this.commit()})},200)}scheduleTimeout(e,i){let o=window.setTimeout(()=>{this.timeouts=this.timeouts.filter(r=>r!==o),e()},i);return this.timeouts.push(o),o}fireEvent(e){Se(this.view.refs.dialog,e)}buildViewHandlers(){return{onDismiss:()=>this.hidePhoto(),onPrev:()=>this.prev(),onNext:()=>this.next(),onNavigate:e=>this.gotoSlide(e),onBackdropClick:()=>this.hidePhoto()}}buildGestureCallbacks(){return{onSwipeStart:()=>this.fireEvent("swipestart"),onSwipeMove:()=>this.view.updateListTransform(this.state),onSwipeEnd:e=>{if(this.fireEvent("swipeend"),e==="close-bottom"){this.hidePhoto("bottom");return}if(e==="close-top"){this.hidePhoto("top");return}e==="prev"?this.state.viewer.currentIndex-=1:e==="next"&&(this.state.viewer.currentIndex+=1),this.slideList()},onTap:()=>this.zoomPhoto(),onGestureStart:()=>{this.fireEvent("gesturestart"),this.view.updatePhotoTransform(this.state)},onGestureMove:()=>this.view.updatePhotoTransform(this.state),onGestureEnd:()=>{this.fireEvent("gestureend"),this.view.updatePhotoTransform(this.state)},onPhotoDragMove:()=>this.view.updatePhotoTransform(this.state),onPhotoDragEnd:e=>{if(e==="zoom-out"){this.zoomOutPhoto();return}if(e==="prev"){this.gotoSlide(this.state.viewer.prev);return}if(e==="next"){this.gotoSlide(this.state.viewer.next);return}this.view.updatePhotoTransform(this.state)}}}};var Ye=_;var ge=t=>{t.fn.SmartPhoto=function(e){return typeof e=="string"||new Ye(this,e),this}};if(typeof define=="function"&&define.amd)define(["jquery"],ge);else{let t=window,e=t.jQuery?t.jQuery:t.$;typeof e!="undefined"&&ge(e)}var ot=ge;})();
package/js/smartphoto.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * SmartPhoto v2.1.4
2
+ * SmartPhoto v2.1.7
3
3
  * (c) appleple
4
4
  * Released under the MIT License.
5
5
  */
@@ -138,7 +138,7 @@ var SmartPhoto = (() => {
138
138
  loadOffset: 2,
139
139
  resizeStyle: "fit",
140
140
  lazyAttribute: "data-src",
141
- animationSpeed: 300
141
+ animationSpeed: 450
142
142
  };
143
143
  function deepFreeze(obj) {
144
144
  Object.keys(obj).forEach((key) => {
@@ -152,7 +152,11 @@ var SmartPhoto = (() => {
152
152
  function createState(settings) {
153
153
  return {
154
154
  options: deepFreeze(
155
- extend({}, defaults, settings)
155
+ extend(
156
+ {},
157
+ defaults,
158
+ settings
159
+ )
156
160
  ),
157
161
  viewer: {
158
162
  isOpen: false,
@@ -817,6 +821,7 @@ var SmartPhoto = (() => {
817
821
  const dialog = document.createElement("dialog");
818
822
  dialog.className = classNames.smartPhoto;
819
823
  dialog.setAttribute("aria-labelledby", `smartphoto-${id}-title`);
824
+ dialog.style.display = "none";
820
825
  dialog.style.setProperty(
821
826
  "--smartphoto-animation-speed",
822
827
  `${options.animationSpeed}ms`
@@ -1163,6 +1168,44 @@ var SmartPhoto = (() => {
1163
1168
  this.timeouts = [];
1164
1169
  this.loadAllFired = /* @__PURE__ */ new Set();
1165
1170
  this.syncedGroupId = null;
1171
+ // 文字列セレクタで構築された場合のみ設定される。Ajax等で後から追加された
1172
+ // 要素をクリック時に動的検出するための再スキャン起点(§discoverGroupElements)
1173
+ this.rootSelector = null;
1174
+ // クリックされた要素(またはその祖先)から登録済み Item を逆引きするための
1175
+ // キャッシュ。documentへのイベントデリゲーションで祖先チェーンを辿る際に使う
1176
+ this.itemsByElement = /* @__PURE__ */ new Map();
1177
+ // サムネイルクリックはこの1本の document デリゲーションリスナーだけで処理する
1178
+ // (個別バインドは廃止)。同じクリックイベントを複数の SmartPhoto インスタンスが
1179
+ // 二重処理しないよう、処理済みマーカーをイベント自体に立てて後続インスタンスに
1180
+ // 早期returnさせる(セレクタが重複するインスタンスが同時に存在するケース)
1181
+ this.handleDocumentClick = (e) => {
1182
+ if (!(e.target instanceof Element)) {
1183
+ return;
1184
+ }
1185
+ const marker = e;
1186
+ if (marker.__smartphotoClaimed) {
1187
+ return;
1188
+ }
1189
+ let matched = this.findRegisteredAncestor(e.target);
1190
+ if (!matched && this.rootSelector) {
1191
+ matched = e.target.closest(this.rootSelector);
1192
+ }
1193
+ if (!matched) {
1194
+ return;
1195
+ }
1196
+ e.preventDefault();
1197
+ marker.__smartphotoClaimed = true;
1198
+ if (!this.itemsByElement.has(matched) && this.rootSelector) {
1199
+ const groupId = groupIdFromElement(matched);
1200
+ if (this.resyncGroupFromDom(groupId)) {
1201
+ this.syncCurrentGroupView();
1202
+ }
1203
+ }
1204
+ const item = this.itemsByElement.get(matched);
1205
+ if (item) {
1206
+ this.openPhoto(item, matched);
1207
+ }
1208
+ };
1166
1209
  // ---- 内部: window イベント ----
1167
1210
  this.updateViewportHeight = () => {
1168
1211
  this.view.refs.dialog.style.setProperty(
@@ -1174,6 +1217,7 @@ var SmartPhoto = (() => {
1174
1217
  if (!currentItems(this.state)) {
1175
1218
  return;
1176
1219
  }
1220
+ this.updateViewportHeight();
1177
1221
  this.resetTranslateCurrent();
1178
1222
  this.setPosByCurrentIndex();
1179
1223
  this.setSizeByScreen();
@@ -1196,6 +1240,7 @@ var SmartPhoto = (() => {
1196
1240
  if (!currentItems(this.state)) {
1197
1241
  return;
1198
1242
  }
1243
+ this.updateViewportHeight();
1199
1244
  this.resetTranslateCurrent();
1200
1245
  this.setPosByCurrentIndex();
1201
1246
  this.setHashByCurrentIndex();
@@ -1206,6 +1251,7 @@ var SmartPhoto = (() => {
1206
1251
  const poll = (time) => {
1207
1252
  this.scheduleTimeout(() => {
1208
1253
  if (prevWidth !== getWindowWidth()) {
1254
+ this.updateViewportHeight();
1209
1255
  this.resetTranslateCurrent();
1210
1256
  this.setPosByCurrentIndex();
1211
1257
  this.setHashByCurrentIndex();
@@ -1218,6 +1264,7 @@ var SmartPhoto = (() => {
1218
1264
  };
1219
1265
  poll(0);
1220
1266
  };
1267
+ this.rootSelector = typeof source === "string" ? source : null;
1221
1268
  this.state = createState(settings != null ? settings : {});
1222
1269
  this.view = createView(
1223
1270
  { id: this.id, options: this.state.options },
@@ -1239,15 +1286,14 @@ var SmartPhoto = (() => {
1239
1286
  },
1240
1287
  { signal: this.abortController.signal }
1241
1288
  );
1289
+ document.addEventListener("click", this.handleDocumentClick, {
1290
+ signal: this.abortController.signal
1291
+ });
1242
1292
  this.ingestSource(source);
1243
1293
  this.syncCurrentGroupView();
1244
1294
  const restored = this.restoreFromHash();
1245
1295
  if (restored) {
1246
- if (restored.element) {
1247
- triggerEvent(restored.element, "click");
1248
- } else {
1249
- this.openPhoto(restored, null);
1250
- }
1296
+ this.openPhoto(restored, restored.element);
1251
1297
  }
1252
1298
  this.updateViewportHeight();
1253
1299
  if (window.visualViewport) {
@@ -1292,6 +1338,7 @@ var SmartPhoto = (() => {
1292
1338
  clearTimeout(id);
1293
1339
  });
1294
1340
  this.timeouts = [];
1341
+ this.itemsByElement.clear();
1295
1342
  this.gestures.detach();
1296
1343
  this.view.destroy();
1297
1344
  }
@@ -1406,7 +1453,7 @@ var SmartPhoto = (() => {
1406
1453
  this.gotoSlide(this.state.viewer.prev);
1407
1454
  }
1408
1455
  addItem(slideOrElement) {
1409
- const item = slideOrElement instanceof Element ? this.addElementItem(slideOrElement) : this.addSlideItem(slideOrElement);
1456
+ const item = slideOrElement instanceof HTMLElement ? this.addElementItem(slideOrElement) : this.addSlideItem(slideOrElement);
1410
1457
  this.syncCurrentGroupView();
1411
1458
  return item;
1412
1459
  }
@@ -1438,7 +1485,7 @@ var SmartPhoto = (() => {
1438
1485
  );
1439
1486
  addItemToGroup(this.state, item);
1440
1487
  this.loadAllFired.delete(groupId);
1441
- this.bindThumbnailClick(element, item);
1488
+ this.itemsByElement.set(element, item);
1442
1489
  return item;
1443
1490
  }
1444
1491
  addSlideItem(slide) {
@@ -1450,15 +1497,73 @@ var SmartPhoto = (() => {
1450
1497
  this.loadAllFired.delete(groupId);
1451
1498
  return item;
1452
1499
  }
1453
- bindThumbnailClick(element, item) {
1454
- element.addEventListener(
1455
- "click",
1456
- (e) => {
1457
- e.preventDefault();
1458
- this.openPhoto(item, element);
1459
- },
1460
- { signal: this.abortController.signal }
1461
- );
1500
+ // クリックされた要素(またはその祖先。<a><img></a> の img がクリックされる
1501
+ // ケースを含む)から、登録済み Item を持つ要素まで祖先チェーンを遡って探す
1502
+ findRegisteredAncestor(target) {
1503
+ let node = target;
1504
+ while (node) {
1505
+ if (this.itemsByElement.has(node)) {
1506
+ return node;
1507
+ }
1508
+ node = node.parentElement;
1509
+ }
1510
+ return null;
1511
+ }
1512
+ // rootSelector(文字列セレクタで構築した場合のみ設定される)を再スキャンし、
1513
+ // 指定グループを現在のDOM状態に合わせて丸ごと再構築する(追加・削除・並び順の
1514
+ // 変化を一度に反映)。既知要素は既存の Item オブジェクトをそのまま再利用する
1515
+ // ため loaded/width/height は保持され、DOM から消えた要素だけ itemsByElement
1516
+ // からも除去する。index/translateX は resetTranslate() で再計算する。
1517
+ // 呼び出し元(openPhoto)がこの結果を使い、変化があった場合のみ view を
1518
+ // 再同期する(§ダイアログを開く瞬間に整合を取る。開いている間の next()/prev()
1519
+ // では呼ばれないため、この間の追加/削除は次に開き直すまで反映されない)
1520
+ resyncGroupFromDom(groupId) {
1521
+ var _a;
1522
+ if (!this.rootSelector) {
1523
+ return false;
1524
+ }
1525
+ const domElements = Array.from(
1526
+ document.querySelectorAll(this.rootSelector)
1527
+ ).filter((el) => groupIdFromElement(el) === groupId);
1528
+ const domElementSet = new Set(domElements);
1529
+ const previous = (_a = this.state.groups.get(groupId)) != null ? _a : [];
1530
+ const previousByElement = /* @__PURE__ */ new Map();
1531
+ previous.forEach((it) => {
1532
+ if (it.element) {
1533
+ previousByElement.set(it.element, it);
1534
+ }
1535
+ });
1536
+ let changed = domElements.length !== previous.length;
1537
+ const rebuilt = domElements.map((el, index) => {
1538
+ const existing = previousByElement.get(el);
1539
+ if (existing) {
1540
+ if (existing.index !== index) {
1541
+ changed = true;
1542
+ existing.index = index;
1543
+ }
1544
+ return existing;
1545
+ }
1546
+ changed = true;
1547
+ const item = itemFromElement(
1548
+ el,
1549
+ this.state.options,
1550
+ index,
1551
+ getWindowWidth()
1552
+ );
1553
+ this.itemsByElement.set(el, item);
1554
+ return item;
1555
+ });
1556
+ previous.forEach((it) => {
1557
+ if (it.element && !domElementSet.has(it.element)) {
1558
+ this.itemsByElement.delete(it.element);
1559
+ }
1560
+ });
1561
+ resetTranslate(rebuilt, getWindowWidth());
1562
+ this.state.groups.set(groupId, rebuilt);
1563
+ if (changed) {
1564
+ this.loadAllFired.delete(groupId);
1565
+ }
1566
+ return changed;
1462
1567
  }
1463
1568
  syncCurrentGroupView() {
1464
1569
  const items = currentItems(this.state);
@@ -1527,10 +1632,12 @@ var SmartPhoto = (() => {
1527
1632
  syncDialog() {
1528
1633
  const { dialog, caption } = this.view.refs;
1529
1634
  if (this.state.viewer.isOpen && !dialog.open) {
1635
+ dialog.style.removeProperty("display");
1530
1636
  dialog.showModal();
1531
1637
  caption.focus();
1532
1638
  } else if (!this.state.viewer.isOpen && dialog.open) {
1533
1639
  dialog.close();
1640
+ dialog.style.display = "none";
1534
1641
  }
1535
1642
  }
1536
1643
  commit() {
@@ -1716,10 +1823,11 @@ var SmartPhoto = (() => {
1716
1823
  });
1717
1824
  }
1718
1825
  openPhoto(item, trigger) {
1826
+ const groupChanged = this.rootSelector ? this.resyncGroupFromDom(item.groupId) : false;
1719
1827
  this.lastTriggerElement = trigger;
1720
1828
  this.state.viewer.currentGroup = item.groupId;
1721
1829
  this.state.viewer.currentIndex = item.index;
1722
- if (this.syncedGroupId !== item.groupId) {
1830
+ if (this.syncedGroupId !== item.groupId || groupChanged) {
1723
1831
  this.syncCurrentGroupView();
1724
1832
  }
1725
1833
  this.setHashByCurrentIndex();
@@ -1811,6 +1919,7 @@ var SmartPhoto = (() => {
1811
1919
  this.state.viewer.photoPosX = 0;
1812
1920
  this.state.viewer.photoPosY = 0;
1813
1921
  this.state.viewer.onMove = true;
1922
+ this.updateViewportHeight();
1814
1923
  this.setPosByCurrentIndex();
1815
1924
  this.setHashByCurrentIndex();
1816
1925
  this.setSizeByScreen();
@@ -1,7 +1,7 @@
1
1
  /*!
2
- * SmartPhoto v2.1.4
2
+ * SmartPhoto v2.1.7
3
3
  * (c) appleple
4
4
  * Released under the MIT License.
5
5
  */
6
- "use strict";var SmartPhoto=(()=>{var he=Object.defineProperty;var Ve=Object.getOwnPropertyDescriptor;var Ge=Object.getOwnPropertyNames;var Fe=Object.prototype.hasOwnProperty;var $e=(t,e)=>{for(var i in e)he(t,i,{get:e[i],enumerable:!0})},ke=(t,e,i,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Ge(e))!Fe.call(t,r)&&r!==i&&he(t,r,{get:()=>e[r],enumerable:!(o=Ve(e,r))||o.enumerable});return t};var We=t=>ke(he({},"__esModule",{value:!0}),t);var Je={};$e(Je,{default:()=>Qe});var Q=()=>{let t=navigator.userAgent;return t.indexOf("iPhone")>0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0};function Pe(t,...e){var i;t=t||{};for(let o=0;o<e.length;o++){let r=e[o];if(r){for(let s in r)if(Object.hasOwn(r,s)){let n=r[s];n&&typeof n=="object"?t[s]=Pe((i=t[s])!=null?i:{},n):t[s]=n}}}return t}var be=Pe,ue=(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)},ye=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},Se=t=>({left:t.getBoundingClientRect().left,top:t.getBoundingClientRect().top});var Re={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:300};function xe(t){return Object.keys(t).forEach(e=>{let i=t[e];i&&typeof i=="object"&&!Object.isFrozen(i)&&xe(i)}),Object.freeze(t)}function Ie(t){return{options:xe(be({},Re,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 ce(t){return t.getAttribute("data-group")||"nogroup"}function me(t){return t.group||"nogroup"}function Le(t,e,i,o){let r=ce(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 m="";n!=null&&n.getAttribute("alt")?m=n.getAttribute("alt"):t.getAttribute("data-caption")?m=t.getAttribute("data-caption"):m=s!=null?s:"";let v=t.getAttribute("data-id");return{src:s,thumb:c,caption:t.getAttribute("data-caption"),alt:m,groupId:r,translateX:o*i,translateY:0,index:i,width:50,height:50,scale:1,x:0,y:0,id:v||i,loaded:!1,processed:!1,element:t}}function Ce(t,e,i){var v,g,b,C,y;let o=me(t),r=t.src,s=(v=t.thumb)!=null?v:r,n=(g=t.caption)!=null?g:null,c=(C=(b=t.alt)!=null?b:n)!=null?C:r,m=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:m?t.width:50,height:m?t.height:50,scale:1,x:0,y:0,id:(y=t.id)!=null?y:e,loaded:m,processed:!1,element:null}}function pe(t,e){t.groups.has(e.groupId)||t.groups.set(e.groupId,[]),t.groups.get(e.groupId).push(e),t.viewer.currentGroup=e.groupId}function M(t){var e;return t.viewer.currentGroup===null?null:(e=t.groups.get(t.viewer.currentGroup))!=null?e:null}function H(t){var i;let e=M(t);return e&&(i=e[t.viewer.currentIndex])!=null?i:null}function fe(t){let e=M(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 Te(t,e){t.forEach((i,o)=>{i.translateX=e*o})}function J(t,e){let i=10**e;return Math.round(t*i)/i}function j(t,e,i,o){return o?t.width>t.height?i/(t.height*t.scale):e/(t.width*t.scale):1/t.scale}function Ae(t,e,i,o){let r=t.width*t.scale*e.scaleSize,s=t.height*t.scale*e.scaleSize,n,c,m,v;return i>r?(m=(i-r)/2,n=-1*m):(m=(r-i)/2,n=-1*m),o>s?(v=(o-s)/2,c=-1*v):(v=(s-o)/2,c=-1*v),{minX:J(n,6)*e.scaleSize,minY:J(c,6)*e.scaleSize,maxX:J(m,6)*e.scaleSize,maxY:J(v,6)*e.scaleSize}}function Me(t,e,i,o,r){let s=i-(o+r);t.forEach(n=>{n.loaded&&(n.processed=!0,n.scale=s/n.height,n.height<s&&(n.scale=1),n.x=(n.scale-1)/2*n.width+(e-n.width*n.scale)/2,n.y=(n.scale-1)/2*n.height+(i-n.height*n.scale)/2,n.width*n.scale>e&&(n.scale=e/n.width,n.x=(n.scale-1)/2*n.width))})}function He(t){let e=H(t);return e?`group=${t.viewer.currentGroup}&photo=${e.id}`:""}function ze(t,e){let i=null;return t.groups.forEach(o=>{o.forEach(r=>{e.group===r.groupId&&e.photo===r.id&&(i=r)})}),i}function ve(t,e){let i=10**e;return Math.round(t*i)/i}function W(t){return{x:t.pageX,y:t.pageY}}function Oe(t,e){let i=t.x-e.x,o=t.y-e.y;return Math.sqrt(i*i+o*o)}var Ue=10;function qe(t,e){return{force:Math.sqrt(t*t+e*e),theta:Math.atan2(e,t)}}function Xe(){return{width:document.documentElement.clientWidth,height:document.documentElement.clientHeight}}function Ne({state:t,callbacks:e},{signal:i}){let o=new Map,r=Date.now(),s=!1,n=!1,c=null,m=null,v=null,g=0,b=!1,C=null,y=null,z=0,O=0,A=!1,V=0,S=null,L=0,X=0;function u(){return Q()}function R(a){let{width:h,height:E}=Xe();return Ae(a,t.viewer,h,E)}function U(a){let{width:h,height:E}=Xe();return j(a,h,E,u())}function ee(a,h){let E=H(t),w=R(E);t.viewer.elastic=!0,a===1?t.viewer.photoPosX=w.minX:a===-1&&(t.viewer.photoPosX=w.maxX),h===1?t.viewer.photoPosY=w.minY:h===-1&&(t.viewer.photoPosY=w.maxY),e.onPhotoDragMove(),setTimeout(()=>{t.viewer.elastic=!1,e.onPhotoDragMove()},300)}let te=setInterval(()=>{if(A||s||b||t.viewer.elastic||!t.viewer.scale)return;t.viewer.photoPosX+=L,t.viewer.photoPosY+=X;let a=H(t);if(!a)return;let h=R(a);t.viewer.photoPosX<h.minX?(t.viewer.photoPosX=h.minX,L*=-.2):t.viewer.photoPosX>h.maxX&&(t.viewer.photoPosX=h.maxX,L*=-.2),t.viewer.photoPosY<h.minY?(t.viewer.photoPosY=h.minY,X*=-.2):t.viewer.photoPosY>h.maxY&&(t.viewer.photoPosY=h.maxY,X*=-.2);let E=qe(L,X),w=E.force-t.options.registance;Math.abs(w)<.5||(L=Math.cos(E.theta)*w,X=Math.sin(E.theta)*w,e.onPhotoDragMove())},t.options.forceInterval);function N(a,h){(a>5||a<-5)&&(L+=a*.05),t.options.verticalGravity&&(h>5||h<-5)&&(X+=h*.05)}function _(a){if(!(a!=null&&a.gamma)||t.viewer.appearEffect||A||s||b||t.viewer.elastic||!t.viewer.scale)return;let{orientation:h}=window;h===0?N(a.gamma,a.beta):h===90?N(a.beta,a.gamma):h===-90?N(-a.beta,-a.gamma):h===180&&N(-a.gamma,-a.beta)}t.options.useOrientationApi&&window.addEventListener("deviceorientation",_,{signal:i});function ie(){A=!0,s=!1,b=!1;let a=Array.from(o.values());V=Oe(a[0],a[1]),t.viewer.scale=!0,e.onGestureStart()}function oe(a){let h=W(a);s=!0,n=!0,c=h,m=h,g=Date.now()}function re(a){b=!0;let h=W(a);y=h,C=h}function ne(a){var h,E;try{(E=(h=a.currentTarget).setPointerCapture)==null||E.call(h,a.pointerId)}catch(w){}if(o.set(a.pointerId,W(a)),o.size>1){ie();return}if(t.viewer.scale){re(a);return}oe(a)}function se(){S===null&&(S=requestAnimationFrame(()=>{S=null,e.onGestureMove()}))}function ae(){S!==null&&(cancelAnimationFrame(S),S=null,e.onGestureMove())}function d(){let a=Array.from(o.values()),h=Oe(a[0],a[1]),E=(h-V)/100,w=t.viewer.scaleSize,I=t.viewer.photoPosX,T=t.viewer.photoPosY;t.viewer.scaleSize+=ve(E,6),t.viewer.scaleSize<.2&&(t.viewer.scaleSize=.2),t.viewer.scaleSize<w&&(t.viewer.photoPosX=(1+t.viewer.scaleSize-w)*I,t.viewer.photoPosY=(1+t.viewer.scaleSize-w)*T);let B=H(t);if(B){let le=U(B);t.viewer.hideUi=t.viewer.scaleSize<1||t.viewer.scaleSize>le}V=h,se()}function l(a){let h=W(a),E=h.x-m.x,w=h.y-c.y;n&&(e.onSwipeStart(),n=!1,v=Math.abs(E)>Math.abs(w)?"horizontal":"vertical"),v==="horizontal"?t.viewer.translateX+=E:t.viewer.translateY=w,m=h,e.onSwipeMove()}function P(a){let h=W(a),E=h.x-y.x,w=h.y-y.y,I=ve(t.viewer.scaleSize*E,6),T=ve(t.viewer.scaleSize*w,6);t.viewer.photoPosX+=I,z=I,t.viewer.photoPosY+=T,O=T,y=h,e.onPhotoDragMove()}function f(a){if(o.has(a.pointerId)){if(o.set(a.pointerId,W(a)),A){d();return}if(b){P(a);return}l(a)}}function p(){A=!1,ae();let a=H(t);if(!a)return;let h=U(a);t.viewer.scaleSize>h||(t.viewer.photoPosX=0,t.viewer.photoPosY=0,t.viewer.scale=!1,t.viewer.scaleSize=1,t.viewer.hideUi=!1,e.onGestureEnd())}function x(){var ge;s=!1;let a=c,h=m,E=Date.now(),w=r-E,I=h.x-a.x,T=h.y-a.y,B=I===0&&T===0;if(!u()&&B){e.onTap();return}if(Math.abs(w)<=500&&B){e.onTap();return}r=E;let le=(ge=M(t))!=null?ge:[];if(v==="horizontal"){let k="stay",Be=Math.max(E-g,1),Ee=Math.abs(I)>=Ue&&Math.abs(I)/Be>=t.options.swipeVelocity;(I>=t.options.swipeOffset||Ee&&I>0)&&t.viewer.currentIndex!==0?k="prev":(I<=-t.options.swipeOffset||Ee&&I<0)&&t.viewer.currentIndex!==le.length-1&&(k="next"),e.onSwipeEnd(k)}else{let k="stay";t.options.swipeBottomToClose&&T>=t.options.swipeOffset?k="close-bottom":t.options.swipeTopToClose&&T<=-t.options.swipeOffset&&(k="close-top"),e.onSwipeEnd(k)}}function $(){b=!1;let a=y,h=C;if(a.x===h.x){e.onPhotoDragEnd("zoom-out");return}let E=H(t);if(!E){e.onPhotoDragEnd(null);return}let w=R(E),I=t.options.swipeOffset*t.viewer.scaleSize,T=0,B=0;if(t.viewer.photoPosX>w.maxX?T=-1:t.viewer.photoPosX<w.minX&&(T=1),t.viewer.photoPosY>w.maxY?B=-1:t.viewer.photoPosY<w.minY&&(B=1),t.viewer.photoPosX-w.maxX>I&&t.viewer.currentIndex!==0){e.onPhotoDragEnd("prev");return}if(w.minX-t.viewer.photoPosX>I&&t.viewer.currentIndex+1!==t.viewer.total){e.onPhotoDragEnd("next");return}T===0&&B===0?(L=z/5,X=O/5):ee(T,B),e.onPhotoDragEnd(null)}function q(a){if(o.delete(a.pointerId),A){o.size<2&&p();return}if(b){$();return}s&&x()}function D(...a){for(let h of a)h.addEventListener("pointerdown",ne,{signal:i}),h.addEventListener("pointermove",f,{signal:i}),h.addEventListener("pointerup",q,{signal:i}),h.addEventListener("pointercancel",q,{signal:i})}function G(){clearInterval(te),S!==null&&(cancelAnimationFrame(S),S=null)}return{attach:D,detach:G}}function Z(t){let e=document.createElement("span");return e.className="smartphoto-sr-only",e.textContent=t,e}function we(){let t=document.createElement("button");return t.type="button",t}function je(t){return t.replace(/"/g,'\\"')}function Ye({id:t,options:e},i,{signal:o}){let{classNames:r,message:s}=e,n=document.createElement("div");n.setAttribute("data-id",t);let c=document.createElement("dialog");c.className=r.smartPhoto,c.setAttribute("aria-labelledby",`smartphoto-${t}-title`),c.style.setProperty("--smartphoto-animation-speed",`${e.animationSpeed}ms`);let m=document.createElement("div");m.className=r.smartPhotoBody;let v=document.createElement("div");v.className=r.smartPhotoInner;let g=document.createElement("div");g.className=r.smartPhotoHeader;let b=document.createElement("span");b.className=r.smartPhotoCount;let C=document.createElement("h1");C.id=`smartphoto-${t}-title`,C.className=r.smartPhotoCaption,C.setAttribute("tabindex","-1");let y=document.createElement("button");y.className=r.smartPhotoDismiss,y.appendChild(Z(s.closeDialog)),y.addEventListener("click",()=>i.onDismiss(),{signal:o}),g.append(b,C,y);let z=document.createElement("div");z.className=r.smartPhotoContent,z.addEventListener("click",d=>{d.target===z&&i.onBackdropClick()},{signal:o});let O=document.createElement("ul");O.className=r.smartPhotoList,O.setAttribute("role","region"),O.setAttribute("aria-roledescription","carousel"),O.setAttribute("aria-label",s.carouselLabel),O.setAttribute("aria-live","polite"),O.setAttribute("aria-atomic","false"),v.append(g,z,O);let A=null,V=null,S=null;if(e.arrows){A=document.createElement("ul"),A.className=r.smartPhotoArrows,V=document.createElement("li"),V.className=r.smartPhotoArrowLeft;let d=we();d.appendChild(Z(s.gotoPrevImage)),d.addEventListener("click",()=>i.onPrev(),{signal:o}),V.appendChild(d),S=document.createElement("li"),S.className=r.smartPhotoArrowRight;let l=we();l.appendChild(Z(s.gotoNextImage)),l.addEventListener("click",()=>i.onNext(),{signal:o}),S.appendChild(l),A.append(V,S),v.appendChild(A)}let L=null,X=null;e.nav&&(L=document.createElement("nav"),L.className=r.smartPhotoNav,L.setAttribute("aria-label","Choose slide to display"),X=document.createElement("ul"),L.appendChild(X),v.appendChild(L)),m.appendChild(v),c.appendChild(m),n.appendChild(c);let u={dialog:c,count:b,caption:C,dismiss:y,content:z,list:O,arrows:A,arrowLeft:V,arrowRight:S,nav:L,navList:X,slides:new Map,imgClone:null};function R(){let d=document.createElement("div");d.className=r.smartPhotoLoaderWrap;let l=document.createElement("span");return l.className=r.smartPhotoLoader,d.appendChild(l),d}function U(d){var f,p;let l=document.createElement("div");l.className=r.smartPhotoImgWrap;let P=document.createElement("img");return P.className=r.smartPhotoImg,P.src=(f=d.src)!=null?f:"",P.alt=(p=d.alt)!=null?p:"",P.addEventListener("dragstart",x=>x.preventDefault(),{signal:o}),l.appendChild(P),{imgWrap:l,img:P}}function ee(d,l){var P;u.list.replaceChildren(),(P=u.navList)==null||P.replaceChildren(),u.slides=new Map,d.forEach(f=>{var $,q;let p=document.createElement("li");p.setAttribute("role","group"),p.setAttribute("aria-roledescription","slide"),p.setAttribute("aria-label",`${f.index+1} of ${d.length}`);let x={li:p,loaderWrap:null,imgWrap:null,img:null,navLink:null};if(f.processed){let{imgWrap:D,img:G}=U(f);p.appendChild(D),x.imgWrap=D,x.img=G}else{let D=R();p.appendChild(D),x.loaderWrap=D}if(u.list.appendChild(p),u.slides.set(f,x),u.navList){let D=document.createElement("li"),G=we();G.style.backgroundImage=`url("${je(($=f.thumb)!=null?$:"")}")`;let a=f.index;G.addEventListener("click",()=>i.onNavigate(a),{signal:o}),G.appendChild(Z(`go to ${(q=f.caption)!=null?q:""}`)),D.appendChild(G),u.navList.appendChild(D),x.navLink=G}}),_(l)}function te(d,l){var p;if(l.imgWrap||!d.processed)return l;let{imgWrap:P,img:f}=U(d);return(p=l.loaderWrap)==null||p.replaceWith(P),l.loaderWrap=null,l.imgWrap=P,l.img=f,l}function N(d){d&&document.activeElement&&d.contains(document.activeElement)&&u.caption.focus()}function _(d){let{viewer:l}=d;u.count.textContent=`${l.currentIndex+1}/${l.total}`,u.slides.forEach((P,f)=>{var $;let p=te(f,P),x=f.index===l.currentIndex;p.li.style.transform=`translate(${f.translateX}px,${f.translateY}px)`,p.li.classList.toggle("current",x),x?p.li.removeAttribute("aria-hidden"):p.li.setAttribute("aria-hidden","true"),x&&(u.caption.textContent=($=f.caption)!=null?$:""),p.imgWrap&&p.img&&(p.imgWrap.style.transform=`translate(${f.x}px,${f.y}px) scale(${f.scale})`,p.img.style.width=`${f.width}px`,p.img.classList.toggle("active",l.appear),p.img.classList.toggle(r.smartPhotoImgOnMove,l.scale),p.img.classList.toggle(r.smartPhotoImgElasticMove,l.elastic)),p.navLink&&(p.navLink.classList.toggle("current",x),x?p.navLink.setAttribute("aria-current","true"):p.navLink.removeAttribute("aria-current"))}),u.arrowLeft&&(l.showPrevArrow?u.arrowLeft.removeAttribute("aria-hidden"):(N(u.arrowLeft),u.arrowLeft.setAttribute("aria-hidden","true"))),u.arrowRight&&(l.showNextArrow?u.arrowRight.removeAttribute("aria-hidden"):(N(u.arrowRight),u.arrowRight.setAttribute("aria-hidden","true"))),u.arrows&&(l.hideUi&&N(u.arrows),u.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false")),u.nav&&(l.hideUi&&N(u.nav),u.nav.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function ie(d){for(let[l,P]of u.slides)if(l.index===d.viewer.currentIndex)return P;return null}function oe(d){let{viewer:l}=d,P=ie(d),f=P==null?void 0:P.img;f&&(f.style.transform=`translate(${l.photoPosX}px,${l.photoPosY}px) scale(${l.scaleSize})`,f.classList.toggle(r.smartPhotoImgOnMove,l.scale),f.classList.toggle(r.smartPhotoImgElasticMove,l.elastic)),u.nav&&(l.hideUi&&N(u.nav),u.nav.setAttribute("aria-hidden",l.hideUi?"true":"false")),u.arrows&&(l.hideUi&&N(u.arrows),u.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function re(d){let{viewer:l}=d;u.list.style.transform=`translate(${l.translateX}px,${l.translateY}px)`,u.list.classList.toggle(r.smartPhotoListOnMove,l.onMove)}function ne(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)`,m.appendChild(l),u.imgClone=l}function se(){var d;(d=u.imgClone)==null||d.remove(),u.imgClone=null}function ae(){n.remove()}return{root:n,refs:u,render:_,syncSlides:ee,updatePhotoTransform:oe,updateListTransform:re,showAppearEffect:ne,removeAppearEffect:se,destroy:ae}}function Y(){return document.documentElement.clientWidth}function F(){let t=window.visualViewport;return t?t.height*t.scale:document.documentElement.clientHeight}function Ke(t){return t.length>0&&t[0]instanceof Element}function _e(){return(Date.now().toString(36)+Math.random().toString(36).substring(2,7)).toUpperCase()}function De(){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=_e();this.abortController=new AbortController;this.isSmartPhoneFlag=Q();this.lastTriggerElement=null;this.isFiringPublicCloseEvent=!1;this.finishHideEffect=null;this.timeouts=[];this.loadAllFired=new Set;this.syncedGroupId=null;this.updateViewportHeight=()=>{this.view.refs.dialog.style.setProperty("--smartphoto-vh",`${F()}px`)};this.handleResize=()=>{M(this.state)&&(this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit())};this.handleKeydown=e=>{if(!this.state.viewer.isOpen)return;let i=e.keyCode||e.which;i===37?this.gotoSlide(this.state.viewer.prev):i===39?this.gotoSlide(this.state.viewer.next):i===27&&this.hidePhoto()};this.handleOrientationChange=()=>{if(!M(this.state))return;this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit();let e=Y(),i=500,o=r=>{this.scheduleTimeout(()=>{e!==Y()?(this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit()):r<=i&&o(r+25)},25)};o(0)};this.state=Ie(i!=null?i:{}),this.view=Ye({id:this.id,options:this.state.options},this.buildViewHandlers(),{signal:this.abortController.signal}),document.body.appendChild(this.view.root),this.gestures=Ne({state:this.state,callbacks:this.buildGestureCallbacks()},{signal:this.abortController.signal}),this.gestures.attach(this.view.refs.content,this.view.refs.list),this.view.refs.dialog.addEventListener("close",()=>{!this.isFiringPublicCloseEvent&&this.state.viewer.isOpen&&this.hidePhoto()},{signal:this.abortController.signal}),this.ingestSource(e),this.syncCurrentGroupView();let o=this.restoreFromHash();if(o&&(o.element?ue(o.element,"click"):this.openPhoto(o,null)),this.updateViewportHeight(),window.visualViewport?window.visualViewport.addEventListener("resize",this.updateViewportHeight,{signal:this.abortController.signal}):window.addEventListener("resize",this.updateViewportHeight,{signal:this.abortController.signal}),!this.isSmartPhoneFlag){window.addEventListener("resize",this.handleResize,{signal:this.abortController.signal}),window.addEventListener("keydown",this.handleKeydown,{signal:this.abortController.signal});return}window.addEventListener("orientationchange",this.handleOrientationChange,{signal:this.abortController.signal})}on(e,i){let o=this.view.refs.dialog,r=s=>i.call(o,s);o.addEventListener(e,r,{signal:this.abortController.signal})}destroy(){this.state.viewer.isOpen=!1,this.view.refs.dialog.open&&this.view.refs.dialog.close(),this.abortController.abort(),this.timeouts.forEach(e=>{clearTimeout(e)}),this.timeouts=[],this.gestures.detach(),this.view.destroy()}[Symbol.dispose](){this.destroy()}gotoSlide(e){this.state.viewer.currentIndex=Number.parseInt(String(e),10),this.state.viewer.currentIndex||(this.state.viewer.currentIndex=0),this.slideList()}hidePhoto(e="bottom"){var o;if(!this.state.viewer.isOpen)return;this.state.viewer.isOpen=!1,this.state.viewer.appear=!1,this.state.viewer.appearEffect=null,this.view.removeAppearEffect(),this.state.viewer.hideUi=!1,this.state.viewer.scale=!1,this.state.viewer.scaleSize=1;let i=De();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=H(this.state);e&&(this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=j(e,Y(),F(),this.isSmartPhoneFlag),!(this.state.viewer.scaleSize<=1)&&(this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.view.updatePhotoTransform(this.state),this.scheduleTimeout(()=>{this.state.viewer.scale=!0,this.view.updatePhotoTransform(this.state),this.fireEvent("zoomin")},300)))}zoomOutPhoto(){this.state.viewer.scaleSize=1,this.state.viewer.hideUi=!1,this.state.viewer.scale=!1,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.view.updatePhotoTransform(this.state),this.fireEvent("zoomout")}addNewItem(e){return this.addItem(e)}show(e=0,i={}){var m,v,g;let o=(m=i.group)!=null?m: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=(g=(v=i.trigger)!=null?v:s.element)!=null?g:n;this.openPhoto(s,c)}hide(){this.hidePhoto()}next(){this.state.viewer.showNextArrow&&this.gotoSlide(this.state.viewer.next)}prev(){this.state.viewer.showPrevArrow&&this.gotoSlide(this.state.viewer.prev)}addItem(e){let i=e instanceof Element?this.addElementItem(e):this.addSlideItem(e);return this.syncCurrentGroupView(),i}get currentIndex(){return this.state.viewer.currentIndex}ingestSource(e){if(Array.isArray(e)&&!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=ce(e),o=(n=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?n:0,r=Le(e,this.state.options,o,Y());return pe(this.state,r),this.loadAllFired.delete(i),this.bindThumbnailClick(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=Ce(e,o,Y());return pe(this.state,r),this.loadAllFired.delete(i),r}bindThumbnailClick(e,i){e.addEventListener("click",o=>{o.preventDefault(),this.openPhoto(i,e)},{signal:this.abortController.signal})}syncCurrentGroupView(){let e=M(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=De();this.setHash(He(this.state)),window.scroll(e.x,e.y)}restoreFromHash(){let e=location.hash.substring(1);return e?ze(this.state,ye(e)):null}setPosByCurrentIndex(){let e=H(this.state);e&&(this.state.viewer.translateX=-e.translateX,this.state.viewer.translateY=0,this.view.updateListTransform(this.state))}setSizeByScreen(){let e=M(this.state);e&&Me(e,Y(),F(),this.state.options.headerHeight,this.state.options.footerHeight)}resetTranslateCurrent(){Te(M(this.state),Y())}currentImgElement(){for(let[e,i]of this.view.refs.slides)if(e.index===this.state.viewer.currentIndex)return i.img;return null}syncDialog(){let{dialog:e,caption:i}=this.view.refs;this.state.viewer.isOpen&&!e.open?(e.showModal(),i.focus()):!this.state.viewer.isOpen&&e.open&&e.close()}commit(){this.view.render(this.state),this.syncDialog()}initPhoto(){var i;(i=this.finishHideEffect)==null||i.call(this),this.view.refs.dialog.style.opacity="";let e=M(this.state);if(this.state.viewer.total=e.length,this.state.viewer.isOpen=!0,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.setPosByCurrentIndex(),this.setSizeByScreen(),fe(this.state),this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag){let o=H(this.state);this.state.viewer.scale=!0,this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=j(o,Y(),F(),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 m=this.currentImgElement();m&&(m.style.viewTransitionName="")},s=(c=document.startViewTransition)==null?void 0:c.call(document,()=>{this.initPhoto(),this.state.viewer.appear=!0,this.commit(),o&&(o.style.viewTransitionName=""),this.currentImgElement().style.viewTransitionName=i});s==null||s.ready.catch(()=>{r()}),s==null||s.finished.then(r,r)}addAppearEffect(e,i){var z;let o=(z=e==null?void 0:e.querySelector("img"))!=null?z:null;if(!o){this.state.viewer.appear=!0;return}let r=Se(o),s=o.offsetWidth,n=o.offsetHeight,c=Y(),m=F(),v=m-this.state.options.headerHeight-this.state.options.footerHeight,g=1;this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag?s>n?g=m/n:g=c/s:(s>=n?i.height<v?g=i.width/s:g=v/n:i.height<v?g=i.height/n:g=v/n,s*g>c&&(g=c/s));let b=(g-1)/2*s+(c-s*g)/2,C=(g-1)/2*n+(m-n*g)/2,y=o.getAttribute(this.state.options.lazyAttribute);this.state.viewer.appearEffect={width:s,height:n,top:r.top,left:r.left,once:!0,img:y||i.src||"",afterX:b,afterY:C,scale:g}}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=Y(),i=F();requestAnimationFrame(()=>{this.state.viewer.isOpen&&(Y()===e&&F()===i||(this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.view.render(this.state)))})}openPhoto(e,i){this.lastTriggerElement=i,this.state.viewer.currentGroup=e.groupId,this.state.viewer.currentIndex=e.index,this.syncedGroupId!==e.groupId&&this.syncCurrentGroupView(),this.setHashByCurrentIndex(),e.loaded?this.doOpen(i,e):this.loadItem(e).then(()=>{this.doOpen(i,e)})}doHideEffect(e){return new Promise(i=>{let o=this.view.refs.dialog,r=this.currentImgElement(),s=F(),n=e==="top"?`translateY(-${s}px)`:`translateY(${s}px)`,c=()=>{this.finishHideEffect===c&&(this.finishHideEffect=null,o.removeEventListener("transitionend",c,!0),r&&r.style.transform===n&&(r.style.transform=""),i())};this.finishHideEffect=c,r&&(r.style.transform=n),o.addEventListener("transitionend",c,!0),this.scheduleTimeout(c,this.state.options.animationSpeed+100)})}loadItem(e){return new Promise(i=>{var r;let o=new Image;o.onload=()=>{e.width=o.width,e.height=o.height,e.loaded=!0,this.checkLoadAll(e.groupId),i()},o.onerror=()=>i(),o.src=(r=e.src)!=null?r:""})}checkLoadAll(e){if(this.loadAllFired.has(e))return;let i=this.state.groups.get(e);i!=null&&i.length&&i.every(o=>o.loaded)&&(this.loadAllFired.add(e),this.fireEvent("loadall"))}loadNeighborItems(){let e=M(this.state);if(!e)return;let{currentIndex:i}=this.state.viewer,{loadOffset:o}=this.state.options,r=[];for(let s=i-o;s<i+o;s++){let n=e[s];n&&!n.loaded&&r.push(this.loadItem(n))}r.length&&Promise.all(r).then(()=>{this.initPhoto(),this.commit()})}slideList(){this.state.viewer.scaleSize=1,this.state.viewer.hideUi=!1,this.state.viewer.scale=!1,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.state.viewer.onMove=!0,this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.scheduleTimeout(()=>{let e=H(this.state);this.state.viewer.onMove=!1,fe(this.state),this.commit(),this.state.viewer.oldIndex!==this.state.viewer.currentIndex&&this.fireEvent("change"),this.state.viewer.oldIndex=this.state.viewer.currentIndex,this.loadNeighborItems(),e&&!e.loaded&&this.loadItem(e).then(()=>{this.initPhoto(),this.commit()})},200)}scheduleTimeout(e,i){let o=window.setTimeout(()=>{this.timeouts=this.timeouts.filter(r=>r!==o),e()},i);return this.timeouts.push(o),o}fireEvent(e){ue(this.view.refs.dialog,e)}buildViewHandlers(){return{onDismiss:()=>this.hidePhoto(),onPrev:()=>this.prev(),onNext:()=>this.next(),onNavigate:e=>this.gotoSlide(e),onBackdropClick:()=>this.hidePhoto()}}buildGestureCallbacks(){return{onSwipeStart:()=>this.fireEvent("swipestart"),onSwipeMove:()=>this.view.updateListTransform(this.state),onSwipeEnd:e=>{if(this.fireEvent("swipeend"),e==="close-bottom"){this.hidePhoto("bottom");return}if(e==="close-top"){this.hidePhoto("top");return}e==="prev"?this.state.viewer.currentIndex-=1:e==="next"&&(this.state.viewer.currentIndex+=1),this.slideList()},onTap:()=>this.zoomPhoto(),onGestureStart:()=>{this.fireEvent("gesturestart"),this.view.updatePhotoTransform(this.state)},onGestureMove:()=>this.view.updatePhotoTransform(this.state),onGestureEnd:()=>{this.fireEvent("gestureend"),this.view.updatePhotoTransform(this.state)},onPhotoDragMove:()=>this.view.updatePhotoTransform(this.state),onPhotoDragEnd:e=>{if(e==="zoom-out"){this.zoomOutPhoto();return}if(e==="prev"){this.gotoSlide(this.state.viewer.prev);return}if(e==="next"){this.gotoSlide(this.state.viewer.next);return}this.view.updatePhotoTransform(this.state)}}}};var Qe=K;return We(Je);})();
6
+ "use strict";var SmartPhoto=(()=>{var ue=Object.defineProperty;var Ve=Object.getOwnPropertyDescriptor;var Ge=Object.getOwnPropertyNames;var Fe=Object.prototype.hasOwnProperty;var Re=(t,e)=>{for(var i in e)ue(t,i,{get:e[i],enumerable:!0})},$e=(t,e,i,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Ge(e))!Fe.call(t,r)&&r!==i&&ue(t,r,{get:()=>e[r],enumerable:!(o=Ve(e,r))||o.enumerable});return t};var ke=t=>$e(ue({},"__esModule",{value:!0}),t);var Je={};Re(Je,{default:()=>Qe});var J=()=>{let t=navigator.userAgent;return t.indexOf("iPhone")>0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0};function be(t,...e){var i;t=t||{};for(let o=0;o<e.length;o++){let r=e[o];if(r){for(let s in r)if(Object.hasOwn(r,s)){let n=r[s];n&&typeof n=="object"?t[s]=be((i=t[s])!=null?i:{},n):t[s]=n}}}return t}var ye=be,Se=(t,e,i)=>{let o;window.CustomEvent?o=new CustomEvent(e,{cancelable:!0}):(o=document.createEvent("CustomEvent"),o.initCustomEvent(e,!1,!1,i)),t.dispatchEvent(o)},xe=t=>{let e={};for(let i of t.split("&")){let o=i.split("="),r=o[0],s=o.length>1?o.slice(1).join("="):r;e[r]=decodeURIComponent(s)}return e},Ie=t=>({left:t.getBoundingClientRect().left,top:t.getBoundingClientRect().top});var We={classNames:{smartPhoto:"smartphoto",smartPhotoClose:"smartphoto-close",smartPhotoBody:"smartphoto-body",smartPhotoInner:"smartphoto-inner",smartPhotoContent:"smartphoto-content",smartPhotoImg:"smartphoto-img",smartPhotoImgOnMove:"smartphoto-img-onmove",smartPhotoImgElasticMove:"smartphoto-img-elasticmove",smartPhotoImgWrap:"smartphoto-img-wrap",smartPhotoArrows:"smartphoto-arrows",smartPhotoNav:"smartphoto-nav",smartPhotoArrowRight:"smartphoto-arrow-right",smartPhotoArrowLeft:"smartphoto-arrow-left",smartPhotoArrowHideIcon:"smartphoto-arrow-hide",smartPhotoImgLeft:"smartphoto-img-left",smartPhotoImgRight:"smartphoto-img-right",smartPhotoList:"smartphoto-list",smartPhotoListOnMove:"smartphoto-list-onmove",smartPhotoHeader:"smartphoto-header",smartPhotoCount:"smartphoto-count",smartPhotoCaption:"smartphoto-caption",smartPhotoDismiss:"smartphoto-dismiss",smartPhotoLoader:"smartphoto-loader",smartPhotoLoaderWrap:"smartphoto-loader-wrap",smartPhotoImgClone:"smartphoto-img-clone"},message:{gotoNextImage:"go to the next image",gotoPrevImage:"go to the previous image",closeDialog:"close the image dialog",carouselLabel:"Images"},arrows:!0,nav:!0,showAnimation:!0,verticalGravity:!1,useOrientationApi:!1,useHistoryApi:!0,swipeTopToClose:!1,swipeBottomToClose:!0,swipeOffset:100,swipeVelocity:.5,headerHeight:60,footerHeight:60,forceInterval:10,registance:.5,loadOffset:2,resizeStyle:"fit",lazyAttribute:"data-src",animationSpeed:450};function Le(t){return Object.keys(t).forEach(e=>{let i=t[e];i&&typeof i=="object"&&!Object.isFrozen(i)&&Le(i)}),Object.freeze(t)}function Ce(t){return{options:Le(ye({},We,t)),viewer:{isOpen:!1,currentGroup:null,currentIndex:0,oldIndex:0,total:0,translateX:0,translateY:0,photoPosX:0,photoPosY:0,scaleSize:1,scale:!1,elastic:!1,hideUi:!1,onMove:!1,appear:!1,appearEffect:null,prev:-1,next:-1,showPrevArrow:!1,showNextArrow:!1},groups:new Map}}function _(t){return t.getAttribute("data-group")||"nogroup"}function ce(t){return t.group||"nogroup"}function me(t,e,i,o){let r=_(t),s=t.getAttribute("href"),n=t.querySelector("img"),d=s;n&&(n.getAttribute(e.lazyAttribute)?d=n.getAttribute(e.lazyAttribute):n.currentSrc?d=n.currentSrc:d=n.src);let p="";n!=null&&n.getAttribute("alt")?p=n.getAttribute("alt"):t.getAttribute("data-caption")?p=t.getAttribute("data-caption"):p=s!=null?s:"";let u=t.getAttribute("data-id");return{src:s,thumb:d,caption:t.getAttribute("data-caption"),alt:p,groupId:r,translateX:o*i,translateY:0,index:i,width:50,height:50,scale:1,x:0,y:0,id:u||i,loaded:!1,processed:!1,element:t}}function Te(t,e,i){var u,v,P,y,S;let o=ce(t),r=t.src,s=(u=t.thumb)!=null?u:r,n=(v=t.caption)!=null?v:null,d=(y=(P=t.alt)!=null?P:n)!=null?y:r,p=typeof t.width=="number"&&typeof t.height=="number";return{src:r,thumb:s,caption:n,alt:d,groupId:o,translateX:i*e,translateY:0,index:e,width:p?t.width:50,height:p?t.height:50,scale:1,x:0,y:0,id:(S=t.id)!=null?S:e,loaded:p,processed:!1,element:null}}function pe(t,e){t.groups.has(e.groupId)||t.groups.set(e.groupId,[]),t.groups.get(e.groupId).push(e),t.viewer.currentGroup=e.groupId}function H(t){var e;return t.viewer.currentGroup===null?null:(e=t.groups.get(t.viewer.currentGroup))!=null?e:null}function z(t){var i;let e=H(t);return e&&(i=e[t.viewer.currentIndex])!=null?i:null}function fe(t){let e=H(t);if(!e)return;let i=e.length,o=t.viewer.currentIndex+1,r=t.viewer.currentIndex-1;t.viewer.showNextArrow=!1,t.viewer.showPrevArrow=!1,o!==i&&(t.viewer.next=o,t.viewer.showNextArrow=!0),r!==-1&&(t.viewer.prev=r,t.viewer.showPrevArrow=!0)}function ve(t,e){t.forEach((i,o)=>{i.translateX=e*o})}function Z(t,e){let i=10**e;return Math.round(t*i)/i}function j(t,e,i,o){return o?t.width>t.height?i/(t.height*t.scale):e/(t.width*t.scale):1/t.scale}function Ae(t,e,i,o){let r=t.width*t.scale*e.scaleSize,s=t.height*t.scale*e.scaleSize,n,d,p,u;return i>r?(p=(i-r)/2,n=-1*p):(p=(r-i)/2,n=-1*p),o>s?(u=(o-s)/2,d=-1*u):(u=(s-o)/2,d=-1*u),{minX:Z(n,6)*e.scaleSize,minY:Z(d,6)*e.scaleSize,maxX:Z(p,6)*e.scaleSize,maxY:Z(u,6)*e.scaleSize}}function Me(t,e,i,o,r){let s=i-(o+r);t.forEach(n=>{n.loaded&&(n.processed=!0,n.scale=s/n.height,n.height<s&&(n.scale=1),n.x=(n.scale-1)/2*n.width+(e-n.width*n.scale)/2,n.y=(n.scale-1)/2*n.height+(i-n.height*n.scale)/2,n.width*n.scale>e&&(n.scale=e/n.width,n.x=(n.scale-1)/2*n.width))})}function He(t){let e=z(t);return e?`group=${t.viewer.currentGroup}&photo=${e.id}`:""}function ze(t,e){let i=null;return t.groups.forEach(o=>{o.forEach(r=>{e.group===r.groupId&&e.photo===r.id&&(i=r)})}),i}function we(t,e){let i=10**e;return Math.round(t*i)/i}function k(t){return{x:t.pageX,y:t.pageY}}function Oe(t,e){let i=t.x-e.x,o=t.y-e.y;return Math.sqrt(i*i+o*o)}var Ue=10;function qe(t,e){return{force:Math.sqrt(t*t+e*e),theta:Math.atan2(e,t)}}function De(){return{width:document.documentElement.clientWidth,height:document.documentElement.clientHeight}}function Be({state:t,callbacks:e},{signal:i}){let o=new Map,r=Date.now(),s=!1,n=!1,d=null,p=null,u=null,v=0,P=!1,y=null,S=null,O=0,D=0,M=!1,V=0,x=null,C=0,B=0;function c(){return J()}function W(a){let{width:h,height:E}=De();return Ae(a,t.viewer,h,E)}function U(a){let{width:h,height:E}=De();return j(a,h,E,c())}function te(a,h){let E=z(t),g=W(E);t.viewer.elastic=!0,a===1?t.viewer.photoPosX=g.minX:a===-1&&(t.viewer.photoPosX=g.maxX),h===1?t.viewer.photoPosY=g.minY:h===-1&&(t.viewer.photoPosY=g.maxY),e.onPhotoDragMove(),setTimeout(()=>{t.viewer.elastic=!1,e.onPhotoDragMove()},300)}let ie=setInterval(()=>{if(M||s||P||t.viewer.elastic||!t.viewer.scale)return;t.viewer.photoPosX+=C,t.viewer.photoPosY+=B;let a=z(t);if(!a)return;let h=W(a);t.viewer.photoPosX<h.minX?(t.viewer.photoPosX=h.minX,C*=-.2):t.viewer.photoPosX>h.maxX&&(t.viewer.photoPosX=h.maxX,C*=-.2),t.viewer.photoPosY<h.minY?(t.viewer.photoPosY=h.minY,B*=-.2):t.viewer.photoPosY>h.maxY&&(t.viewer.photoPosY=h.maxY,B*=-.2);let E=qe(C,B),g=E.force-t.options.registance;Math.abs(g)<.5||(C=Math.cos(E.theta)*g,B=Math.sin(E.theta)*g,e.onPhotoDragMove())},t.options.forceInterval);function X(a,h){(a>5||a<-5)&&(C+=a*.05),t.options.verticalGravity&&(h>5||h<-5)&&(B+=h*.05)}function Q(a){if(!(a!=null&&a.gamma)||t.viewer.appearEffect||M||s||P||t.viewer.elastic||!t.viewer.scale)return;let{orientation:h}=window;h===0?X(a.gamma,a.beta):h===90?X(a.beta,a.gamma):h===-90?X(-a.beta,-a.gamma):h===180&&X(-a.gamma,-a.beta)}t.options.useOrientationApi&&window.addEventListener("deviceorientation",Q,{signal:i});function oe(){M=!0,s=!1,P=!1;let a=Array.from(o.values());V=Oe(a[0],a[1]),t.viewer.scale=!0,e.onGestureStart()}function re(a){let h=k(a);s=!0,n=!0,d=h,p=h,v=Date.now()}function ne(a){P=!0;let h=k(a);S=h,y=h}function se(a){var h,E;try{(E=(h=a.currentTarget).setPointerCapture)==null||E.call(h,a.pointerId)}catch(g){}if(o.set(a.pointerId,k(a)),o.size>1){oe();return}if(t.viewer.scale){ne(a);return}re(a)}function ae(){x===null&&(x=requestAnimationFrame(()=>{x=null,e.onGestureMove()}))}function le(){x!==null&&(cancelAnimationFrame(x),x=null,e.onGestureMove())}function m(){let a=Array.from(o.values()),h=Oe(a[0],a[1]),E=(h-V)/100,g=t.viewer.scaleSize,L=t.viewer.photoPosX,T=t.viewer.photoPosY;t.viewer.scaleSize+=we(E,6),t.viewer.scaleSize<.2&&(t.viewer.scaleSize=.2),t.viewer.scaleSize<g&&(t.viewer.photoPosX=(1+t.viewer.scaleSize-g)*L,t.viewer.photoPosY=(1+t.viewer.scaleSize-g)*T);let Y=z(t);if(Y){let he=U(Y);t.viewer.hideUi=t.viewer.scaleSize<1||t.viewer.scaleSize>he}V=h,ae()}function l(a){let h=k(a),E=h.x-p.x,g=h.y-d.y;n&&(e.onSwipeStart(),n=!1,u=Math.abs(E)>Math.abs(g)?"horizontal":"vertical"),u==="horizontal"?t.viewer.translateX+=E:t.viewer.translateY=g,p=h,e.onSwipeMove()}function b(a){let h=k(a),E=h.x-S.x,g=h.y-S.y,L=we(t.viewer.scaleSize*E,6),T=we(t.viewer.scaleSize*g,6);t.viewer.photoPosX+=L,O=L,t.viewer.photoPosY+=T,D=T,S=h,e.onPhotoDragMove()}function w(a){if(o.has(a.pointerId)){if(o.set(a.pointerId,k(a)),M){m();return}if(P){b(a);return}l(a)}}function f(){M=!1,le();let a=z(t);if(!a)return;let h=U(a);t.viewer.scaleSize>h||(t.viewer.photoPosX=0,t.viewer.photoPosY=0,t.viewer.scale=!1,t.viewer.scaleSize=1,t.viewer.hideUi=!1,e.onGestureEnd())}function I(){var Ee;s=!1;let a=d,h=p,E=Date.now(),g=r-E,L=h.x-a.x,T=h.y-a.y,Y=L===0&&T===0;if(!c()&&Y){e.onTap();return}if(Math.abs(g)<=500&&Y){e.onTap();return}r=E;let he=(Ee=H(t))!=null?Ee:[];if(u==="horizontal"){let $="stay",Ye=Math.max(E-v,1),Pe=Math.abs(L)>=Ue&&Math.abs(L)/Ye>=t.options.swipeVelocity;(L>=t.options.swipeOffset||Pe&&L>0)&&t.viewer.currentIndex!==0?$="prev":(L<=-t.options.swipeOffset||Pe&&L<0)&&t.viewer.currentIndex!==he.length-1&&($="next"),e.onSwipeEnd($)}else{let $="stay";t.options.swipeBottomToClose&&T>=t.options.swipeOffset?$="close-bottom":t.options.swipeTopToClose&&T<=-t.options.swipeOffset&&($="close-top"),e.onSwipeEnd($)}}function R(){P=!1;let a=S,h=y;if(a.x===h.x){e.onPhotoDragEnd("zoom-out");return}let E=z(t);if(!E){e.onPhotoDragEnd(null);return}let g=W(E),L=t.options.swipeOffset*t.viewer.scaleSize,T=0,Y=0;if(t.viewer.photoPosX>g.maxX?T=-1:t.viewer.photoPosX<g.minX&&(T=1),t.viewer.photoPosY>g.maxY?Y=-1:t.viewer.photoPosY<g.minY&&(Y=1),t.viewer.photoPosX-g.maxX>L&&t.viewer.currentIndex!==0){e.onPhotoDragEnd("prev");return}if(g.minX-t.viewer.photoPosX>L&&t.viewer.currentIndex+1!==t.viewer.total){e.onPhotoDragEnd("next");return}T===0&&Y===0?(C=O/5,B=D/5):te(T,Y),e.onPhotoDragEnd(null)}function q(a){if(o.delete(a.pointerId),M){o.size<2&&f();return}if(P){R();return}s&&I()}function N(...a){for(let h of a)h.addEventListener("pointerdown",se,{signal:i}),h.addEventListener("pointermove",w,{signal:i}),h.addEventListener("pointerup",q,{signal:i}),h.addEventListener("pointercancel",q,{signal:i})}function G(){clearInterval(ie),x!==null&&(cancelAnimationFrame(x),x=null)}return{attach:N,detach:G}}function ee(t){let e=document.createElement("span");return e.className="smartphoto-sr-only",e.textContent=t,e}function ge(){let t=document.createElement("button");return t.type="button",t}function _e(t){return t.replace(/"/g,'\\"')}function Xe({id:t,options:e},i,{signal:o}){let{classNames:r,message:s}=e,n=document.createElement("div");n.setAttribute("data-id",t);let d=document.createElement("dialog");d.className=r.smartPhoto,d.setAttribute("aria-labelledby",`smartphoto-${t}-title`),d.style.display="none",d.style.setProperty("--smartphoto-animation-speed",`${e.animationSpeed}ms`);let p=document.createElement("div");p.className=r.smartPhotoBody;let u=document.createElement("div");u.className=r.smartPhotoInner;let v=document.createElement("div");v.className=r.smartPhotoHeader;let P=document.createElement("span");P.className=r.smartPhotoCount;let y=document.createElement("h1");y.id=`smartphoto-${t}-title`,y.className=r.smartPhotoCaption,y.setAttribute("tabindex","-1");let S=document.createElement("button");S.className=r.smartPhotoDismiss,S.appendChild(ee(s.closeDialog)),S.addEventListener("click",()=>i.onDismiss(),{signal:o}),v.append(P,y,S);let O=document.createElement("div");O.className=r.smartPhotoContent,O.addEventListener("click",m=>{m.target===O&&i.onBackdropClick()},{signal:o});let D=document.createElement("ul");D.className=r.smartPhotoList,D.setAttribute("role","region"),D.setAttribute("aria-roledescription","carousel"),D.setAttribute("aria-label",s.carouselLabel),D.setAttribute("aria-live","polite"),D.setAttribute("aria-atomic","false"),u.append(v,O,D);let M=null,V=null,x=null;if(e.arrows){M=document.createElement("ul"),M.className=r.smartPhotoArrows,V=document.createElement("li"),V.className=r.smartPhotoArrowLeft;let m=ge();m.appendChild(ee(s.gotoPrevImage)),m.addEventListener("click",()=>i.onPrev(),{signal:o}),V.appendChild(m),x=document.createElement("li"),x.className=r.smartPhotoArrowRight;let l=ge();l.appendChild(ee(s.gotoNextImage)),l.addEventListener("click",()=>i.onNext(),{signal:o}),x.appendChild(l),M.append(V,x),u.appendChild(M)}let C=null,B=null;e.nav&&(C=document.createElement("nav"),C.className=r.smartPhotoNav,C.setAttribute("aria-label","Choose slide to display"),B=document.createElement("ul"),C.appendChild(B),u.appendChild(C)),p.appendChild(u),d.appendChild(p),n.appendChild(d);let c={dialog:d,count:P,caption:y,dismiss:S,content:O,list:D,arrows:M,arrowLeft:V,arrowRight:x,nav:C,navList:B,slides:new Map,imgClone:null};function W(){let m=document.createElement("div");m.className=r.smartPhotoLoaderWrap;let l=document.createElement("span");return l.className=r.smartPhotoLoader,m.appendChild(l),m}function U(m){var w,f;let l=document.createElement("div");l.className=r.smartPhotoImgWrap;let b=document.createElement("img");return b.className=r.smartPhotoImg,b.src=(w=m.src)!=null?w:"",b.alt=(f=m.alt)!=null?f:"",b.addEventListener("dragstart",I=>I.preventDefault(),{signal:o}),l.appendChild(b),{imgWrap:l,img:b}}function te(m,l){var b;c.list.replaceChildren(),(b=c.navList)==null||b.replaceChildren(),c.slides=new Map,m.forEach(w=>{var R,q;let f=document.createElement("li");f.setAttribute("role","group"),f.setAttribute("aria-roledescription","slide"),f.setAttribute("aria-label",`${w.index+1} of ${m.length}`);let I={li:f,loaderWrap:null,imgWrap:null,img:null,navLink:null};if(w.processed){let{imgWrap:N,img:G}=U(w);f.appendChild(N),I.imgWrap=N,I.img=G}else{let N=W();f.appendChild(N),I.loaderWrap=N}if(c.list.appendChild(f),c.slides.set(w,I),c.navList){let N=document.createElement("li"),G=ge();G.style.backgroundImage=`url("${_e((R=w.thumb)!=null?R:"")}")`;let a=w.index;G.addEventListener("click",()=>i.onNavigate(a),{signal:o}),G.appendChild(ee(`go to ${(q=w.caption)!=null?q:""}`)),N.appendChild(G),c.navList.appendChild(N),I.navLink=G}}),Q(l)}function ie(m,l){var f;if(l.imgWrap||!m.processed)return l;let{imgWrap:b,img:w}=U(m);return(f=l.loaderWrap)==null||f.replaceWith(b),l.loaderWrap=null,l.imgWrap=b,l.img=w,l}function X(m){m&&document.activeElement&&m.contains(document.activeElement)&&c.caption.focus()}function Q(m){let{viewer:l}=m;c.count.textContent=`${l.currentIndex+1}/${l.total}`,c.slides.forEach((b,w)=>{var R;let f=ie(w,b),I=w.index===l.currentIndex;f.li.style.transform=`translate(${w.translateX}px,${w.translateY}px)`,f.li.classList.toggle("current",I),I?f.li.removeAttribute("aria-hidden"):f.li.setAttribute("aria-hidden","true"),I&&(c.caption.textContent=(R=w.caption)!=null?R:""),f.imgWrap&&f.img&&(f.imgWrap.style.transform=`translate(${w.x}px,${w.y}px) scale(${w.scale})`,f.img.style.width=`${w.width}px`,f.img.classList.toggle("active",l.appear),f.img.classList.toggle(r.smartPhotoImgOnMove,l.scale),f.img.classList.toggle(r.smartPhotoImgElasticMove,l.elastic)),f.navLink&&(f.navLink.classList.toggle("current",I),I?f.navLink.setAttribute("aria-current","true"):f.navLink.removeAttribute("aria-current"))}),c.arrowLeft&&(l.showPrevArrow?c.arrowLeft.removeAttribute("aria-hidden"):(X(c.arrowLeft),c.arrowLeft.setAttribute("aria-hidden","true"))),c.arrowRight&&(l.showNextArrow?c.arrowRight.removeAttribute("aria-hidden"):(X(c.arrowRight),c.arrowRight.setAttribute("aria-hidden","true"))),c.arrows&&(l.hideUi&&X(c.arrows),c.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false")),c.nav&&(l.hideUi&&X(c.nav),c.nav.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function oe(m){for(let[l,b]of c.slides)if(l.index===m.viewer.currentIndex)return b;return null}function re(m){let{viewer:l}=m,b=oe(m),w=b==null?void 0:b.img;w&&(w.style.transform=`translate(${l.photoPosX}px,${l.photoPosY}px) scale(${l.scaleSize})`,w.classList.toggle(r.smartPhotoImgOnMove,l.scale),w.classList.toggle(r.smartPhotoImgElasticMove,l.elastic)),c.nav&&(l.hideUi&&X(c.nav),c.nav.setAttribute("aria-hidden",l.hideUi?"true":"false")),c.arrows&&(l.hideUi&&X(c.arrows),c.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function ne(m){let{viewer:l}=m;c.list.style.transform=`translate(${l.translateX}px,${l.translateY}px)`,c.list.classList.toggle(r.smartPhotoListOnMove,l.onMove)}function se(m){let l=document.createElement("img");l.className=r.smartPhotoImgClone,l.src=m.img,l.style.width=`${m.width}px`,l.style.height=`${m.height}px`,l.style.transform=`translate(${m.left}px,${m.top}px) scale(1)`,p.appendChild(l),c.imgClone=l}function ae(){var m;(m=c.imgClone)==null||m.remove(),c.imgClone=null}function le(){n.remove()}return{root:n,refs:c,render:Q,syncSlides:te,updatePhotoTransform:re,updateListTransform:ne,showAppearEffect:se,removeAppearEffect:ae,destroy:le}}function A(){return document.documentElement.clientWidth}function F(){let t=window.visualViewport;return t?t.height*t.scale:document.documentElement.clientHeight}function je(t){return t.length>0&&t[0]instanceof Element}function Ke(){return(Date.now().toString(36)+Math.random().toString(36).substring(2,7)).toUpperCase()}function Ne(){return{x:window.pageXOffset!==void 0?window.pageXOffset:document.documentElement.scrollLeft,y:window.pageYOffset!==void 0?window.pageYOffset:document.documentElement.scrollTop}}var K=class{constructor(e,i){this.id=Ke();this.abortController=new AbortController;this.isSmartPhoneFlag=J();this.lastTriggerElement=null;this.isFiringPublicCloseEvent=!1;this.finishHideEffect=null;this.timeouts=[];this.loadAllFired=new Set;this.syncedGroupId=null;this.rootSelector=null;this.itemsByElement=new Map;this.handleDocumentClick=e=>{if(!(e.target instanceof Element))return;let i=e;if(i.__smartphotoClaimed)return;let o=this.findRegisteredAncestor(e.target);if(!o&&this.rootSelector&&(o=e.target.closest(this.rootSelector)),!o)return;if(e.preventDefault(),i.__smartphotoClaimed=!0,!this.itemsByElement.has(o)&&this.rootSelector){let s=_(o);this.resyncGroupFromDom(s)&&this.syncCurrentGroupView()}let r=this.itemsByElement.get(o);r&&this.openPhoto(r,o)};this.updateViewportHeight=()=>{this.view.refs.dialog.style.setProperty("--smartphoto-vh",`${F()}px`)};this.handleResize=()=>{H(this.state)&&(this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit())};this.handleKeydown=e=>{if(!this.state.viewer.isOpen)return;let i=e.keyCode||e.which;i===37?this.gotoSlide(this.state.viewer.prev):i===39?this.gotoSlide(this.state.viewer.next):i===27&&this.hidePhoto()};this.handleOrientationChange=()=>{if(!H(this.state))return;this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit();let e=A(),i=500,o=r=>{this.scheduleTimeout(()=>{e!==A()?(this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit()):r<=i&&o(r+25)},25)};o(0)};this.rootSelector=typeof e=="string"?e:null,this.state=Ce(i!=null?i:{}),this.view=Xe({id:this.id,options:this.state.options},this.buildViewHandlers(),{signal:this.abortController.signal}),document.body.appendChild(this.view.root),this.gestures=Be({state:this.state,callbacks:this.buildGestureCallbacks()},{signal:this.abortController.signal}),this.gestures.attach(this.view.refs.content,this.view.refs.list),this.view.refs.dialog.addEventListener("close",()=>{!this.isFiringPublicCloseEvent&&this.state.viewer.isOpen&&this.hidePhoto()},{signal:this.abortController.signal}),document.addEventListener("click",this.handleDocumentClick,{signal:this.abortController.signal}),this.ingestSource(e),this.syncCurrentGroupView();let o=this.restoreFromHash();if(o&&this.openPhoto(o,o.element),this.updateViewportHeight(),window.visualViewport?window.visualViewport.addEventListener("resize",this.updateViewportHeight,{signal:this.abortController.signal}):window.addEventListener("resize",this.updateViewportHeight,{signal:this.abortController.signal}),!this.isSmartPhoneFlag){window.addEventListener("resize",this.handleResize,{signal:this.abortController.signal}),window.addEventListener("keydown",this.handleKeydown,{signal:this.abortController.signal});return}window.addEventListener("orientationchange",this.handleOrientationChange,{signal:this.abortController.signal})}on(e,i){let o=this.view.refs.dialog,r=s=>i.call(o,s);o.addEventListener(e,r,{signal:this.abortController.signal})}destroy(){this.state.viewer.isOpen=!1,this.view.refs.dialog.open&&this.view.refs.dialog.close(),this.abortController.abort(),this.timeouts.forEach(e=>{clearTimeout(e)}),this.timeouts=[],this.itemsByElement.clear(),this.gestures.detach(),this.view.destroy()}[Symbol.dispose](){this.destroy()}gotoSlide(e){this.state.viewer.currentIndex=Number.parseInt(String(e),10),this.state.viewer.currentIndex||(this.state.viewer.currentIndex=0),this.slideList()}hidePhoto(e="bottom"){var o;if(!this.state.viewer.isOpen)return;this.state.viewer.isOpen=!1,this.state.viewer.appear=!1,this.state.viewer.appearEffect=null,this.view.removeAppearEffect(),this.state.viewer.hideUi=!1,this.state.viewer.scale=!1,this.state.viewer.scaleSize=1;let i=Ne();location.hash&&this.setHash(""),window.scroll(i.x,i.y),this.syncDialog(),(o=this.lastTriggerElement)!=null&&o.isConnected&&this.lastTriggerElement.focus(),this.lastTriggerElement=null,this.doHideEffect(e).then(()=>{this.view.render(this.state),this.isFiringPublicCloseEvent=!0,this.fireEvent("close"),this.isFiringPublicCloseEvent=!1})}zoomPhoto(){let e=z(this.state);e&&(this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=j(e,A(),F(),this.isSmartPhoneFlag),!(this.state.viewer.scaleSize<=1)&&(this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.view.updatePhotoTransform(this.state),this.scheduleTimeout(()=>{this.state.viewer.scale=!0,this.view.updatePhotoTransform(this.state),this.fireEvent("zoomin")},300)))}zoomOutPhoto(){this.state.viewer.scaleSize=1,this.state.viewer.hideUi=!1,this.state.viewer.scale=!1,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.view.updatePhotoTransform(this.state),this.fireEvent("zoomout")}addNewItem(e){return this.addItem(e)}show(e=0,i={}){var p,u,v;let o=(p=i.group)!=null?p:this.state.viewer.currentGroup;if(o===null)return;let r=this.state.groups.get(o);if(!(r!=null&&r.length))return;let s=typeof e=="number"?r[e]:r.find(P=>P.id===e);if(!s)return;let n=document.activeElement instanceof HTMLElement?document.activeElement:null,d=(v=(u=i.trigger)!=null?u:s.element)!=null?v:n;this.openPhoto(s,d)}hide(){this.hidePhoto()}next(){this.state.viewer.showNextArrow&&this.gotoSlide(this.state.viewer.next)}prev(){this.state.viewer.showPrevArrow&&this.gotoSlide(this.state.viewer.prev)}addItem(e){let i=e instanceof HTMLElement?this.addElementItem(e):this.addSlideItem(e);return this.syncCurrentGroupView(),i}get currentIndex(){return this.state.viewer.currentIndex}ingestSource(e){if(Array.isArray(e)&&!je(e)){e.forEach(o=>{this.addSlideItem(o)});return}Array.from(typeof e=="string"?document.querySelectorAll(e):e).forEach(o=>{this.addElementItem(o)})}addElementItem(e){var s,n;let i=_(e),o=(n=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?n:0,r=me(e,this.state.options,o,A());return pe(this.state,r),this.loadAllFired.delete(i),this.itemsByElement.set(e,r),r}addSlideItem(e){var s,n;let i=ce(e),o=(n=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?n:0,r=Te(e,o,A());return pe(this.state,r),this.loadAllFired.delete(i),r}findRegisteredAncestor(e){let i=e;for(;i;){if(this.itemsByElement.has(i))return i;i=i.parentElement}return null}resyncGroupFromDom(e){var p;if(!this.rootSelector)return!1;let i=Array.from(document.querySelectorAll(this.rootSelector)).filter(u=>_(u)===e),o=new Set(i),r=(p=this.state.groups.get(e))!=null?p:[],s=new Map;r.forEach(u=>{u.element&&s.set(u.element,u)});let n=i.length!==r.length,d=i.map((u,v)=>{let P=s.get(u);if(P)return P.index!==v&&(n=!0,P.index=v),P;n=!0;let y=me(u,this.state.options,v,A());return this.itemsByElement.set(u,y),y});return r.forEach(u=>{u.element&&!o.has(u.element)&&this.itemsByElement.delete(u.element)}),ve(d,A()),this.state.groups.set(e,d),n&&this.loadAllFired.delete(e),n}syncCurrentGroupView(){let e=H(this.state);e&&(this.view.syncSlides(e,this.state),this.syncedGroupId=this.state.viewer.currentGroup)}setHash(e){var o;if(!((o=window.history)!=null&&o.pushState)||!this.state.options.useHistoryApi)return;let i=`${location.pathname}${location.search}`;window.history.replaceState(null,"",e?`${i}#${e}`:i)}setHashByCurrentIndex(){let e=Ne();this.setHash(He(this.state)),window.scroll(e.x,e.y)}restoreFromHash(){let e=location.hash.substring(1);return e?ze(this.state,xe(e)):null}setPosByCurrentIndex(){let e=z(this.state);e&&(this.state.viewer.translateX=-e.translateX,this.state.viewer.translateY=0,this.view.updateListTransform(this.state))}setSizeByScreen(){let e=H(this.state);e&&Me(e,A(),F(),this.state.options.headerHeight,this.state.options.footerHeight)}resetTranslateCurrent(){ve(H(this.state),A())}currentImgElement(){for(let[e,i]of this.view.refs.slides)if(e.index===this.state.viewer.currentIndex)return i.img;return null}syncDialog(){let{dialog:e,caption:i}=this.view.refs;this.state.viewer.isOpen&&!e.open?(e.style.removeProperty("display"),e.showModal(),i.focus()):!this.state.viewer.isOpen&&e.open&&(e.close(),e.style.display="none")}commit(){this.view.render(this.state),this.syncDialog()}initPhoto(){var i;(i=this.finishHideEffect)==null||i.call(this),this.view.refs.dialog.style.opacity="";let e=H(this.state);if(this.state.viewer.total=e.length,this.state.viewer.isOpen=!0,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.setPosByCurrentIndex(),this.setSizeByScreen(),fe(this.state),this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag){let o=z(this.state);this.state.viewer.scale=!0,this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=j(o,A(),F(),this.isSmartPhoneFlag)}}supportsViewTransition(){return typeof document.startViewTransition=="function"}openPhotoWithViewTransition(e){var n,d;document.documentElement.style.setProperty("--smartphoto-animation-speed",`${this.state.options.animationSpeed}ms`);let i="smartphoto-hero",o=(n=e==null?void 0:e.querySelector("img"))!=null?n:null;o&&(o.style.viewTransitionName=i);let r=()=>{o&&(o.style.viewTransitionName="");let p=this.currentImgElement();p&&(p.style.viewTransitionName="")},s=(d=document.startViewTransition)==null?void 0:d.call(document,()=>{this.initPhoto(),this.state.viewer.appear=!0,this.commit(),o&&(o.style.viewTransitionName=""),this.currentImgElement().style.viewTransitionName=i});s==null||s.ready.catch(()=>{r()}),s==null||s.finished.then(r,r)}addAppearEffect(e,i){var O;let o=(O=e==null?void 0:e.querySelector("img"))!=null?O:null;if(!o){this.state.viewer.appear=!0;return}let r=Ie(o),s=o.offsetWidth,n=o.offsetHeight,d=A(),p=F(),u=p-this.state.options.headerHeight-this.state.options.footerHeight,v=1;this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag?s>n?v=p/n:v=d/s:(s>=n?i.height<u?v=i.width/s:v=u/n:i.height<u?v=i.height/n:v=u/n,s*v>d&&(v=d/s));let P=(v-1)/2*s+(d-s*v)/2,y=(v-1)/2*n+(p-n*v)/2,S=o.getAttribute(this.state.options.lazyAttribute);this.state.viewer.appearEffect={width:s,height:n,top:r.top,left:r.left,once:!0,img:S||i.src||"",afterX:P,afterY:y,scale:v}}runAppearEffect(e){this.view.showAppearEffect(e);let i=this.view.refs.imgClone;return new Promise(o=>{let r=()=>{i.removeEventListener("transitionend",r,!0),o()};i.addEventListener("transitionend",r,!0),this.scheduleTimeout(()=>{i.style.transform=`translate(${e.afterX}px, ${e.afterY}px) scale(${e.scale})`},10)})}doOpen(e,i){if(this.state.options.showAnimation!==!1&&this.supportsViewTransition())this.openPhotoWithViewTransition(e);else if(this.state.options.showAnimation===!1)this.initPhoto(),this.state.viewer.appear=!0,this.commit();else{this.initPhoto(),this.addAppearEffect(e,i),this.commit();let o=this.state.viewer.appearEffect;o&&this.runAppearEffect(o).then(()=>{this.state.viewer.appearEffect=null,this.view.removeAppearEffect(),this.state.viewer.appear=!0,this.commit()})}this.fireEvent("open"),this.resyncSizeAfterOpen()}resyncSizeAfterOpen(){let e=A(),i=F();requestAnimationFrame(()=>{this.state.viewer.isOpen&&(A()===e&&F()===i||(this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.view.render(this.state)))})}openPhoto(e,i){let o=this.rootSelector?this.resyncGroupFromDom(e.groupId):!1;this.lastTriggerElement=i,this.state.viewer.currentGroup=e.groupId,this.state.viewer.currentIndex=e.index,(this.syncedGroupId!==e.groupId||o)&&this.syncCurrentGroupView(),this.setHashByCurrentIndex(),e.loaded?this.doOpen(i,e):this.loadItem(e).then(()=>{this.doOpen(i,e)})}doHideEffect(e){return new Promise(i=>{let o=this.view.refs.dialog,r=this.currentImgElement(),s=F(),n=e==="top"?`translateY(-${s}px)`:`translateY(${s}px)`,d=()=>{this.finishHideEffect===d&&(this.finishHideEffect=null,o.removeEventListener("transitionend",d,!0),r&&r.style.transform===n&&(r.style.transform=""),i())};this.finishHideEffect=d,r&&(r.style.transform=n),o.addEventListener("transitionend",d,!0),this.scheduleTimeout(d,this.state.options.animationSpeed+100)})}loadItem(e){return new Promise(i=>{var r;let o=new Image;o.onload=()=>{e.width=o.width,e.height=o.height,e.loaded=!0,this.checkLoadAll(e.groupId),i()},o.onerror=()=>i(),o.src=(r=e.src)!=null?r:""})}checkLoadAll(e){if(this.loadAllFired.has(e))return;let i=this.state.groups.get(e);i!=null&&i.length&&i.every(o=>o.loaded)&&(this.loadAllFired.add(e),this.fireEvent("loadall"))}loadNeighborItems(){let e=H(this.state);if(!e)return;let{currentIndex:i}=this.state.viewer,{loadOffset:o}=this.state.options,r=[];for(let s=i-o;s<i+o;s++){let n=e[s];n&&!n.loaded&&r.push(this.loadItem(n))}r.length&&Promise.all(r).then(()=>{this.initPhoto(),this.commit()})}slideList(){this.state.viewer.scaleSize=1,this.state.viewer.hideUi=!1,this.state.viewer.scale=!1,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.state.viewer.onMove=!0,this.updateViewportHeight(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.scheduleTimeout(()=>{let e=z(this.state);this.state.viewer.onMove=!1,fe(this.state),this.commit(),this.state.viewer.oldIndex!==this.state.viewer.currentIndex&&this.fireEvent("change"),this.state.viewer.oldIndex=this.state.viewer.currentIndex,this.loadNeighborItems(),e&&!e.loaded&&this.loadItem(e).then(()=>{this.initPhoto(),this.commit()})},200)}scheduleTimeout(e,i){let o=window.setTimeout(()=>{this.timeouts=this.timeouts.filter(r=>r!==o),e()},i);return this.timeouts.push(o),o}fireEvent(e){Se(this.view.refs.dialog,e)}buildViewHandlers(){return{onDismiss:()=>this.hidePhoto(),onPrev:()=>this.prev(),onNext:()=>this.next(),onNavigate:e=>this.gotoSlide(e),onBackdropClick:()=>this.hidePhoto()}}buildGestureCallbacks(){return{onSwipeStart:()=>this.fireEvent("swipestart"),onSwipeMove:()=>this.view.updateListTransform(this.state),onSwipeEnd:e=>{if(this.fireEvent("swipeend"),e==="close-bottom"){this.hidePhoto("bottom");return}if(e==="close-top"){this.hidePhoto("top");return}e==="prev"?this.state.viewer.currentIndex-=1:e==="next"&&(this.state.viewer.currentIndex+=1),this.slideList()},onTap:()=>this.zoomPhoto(),onGestureStart:()=>{this.fireEvent("gesturestart"),this.view.updatePhotoTransform(this.state)},onGestureMove:()=>this.view.updatePhotoTransform(this.state),onGestureEnd:()=>{this.fireEvent("gestureend"),this.view.updatePhotoTransform(this.state)},onPhotoDragMove:()=>this.view.updatePhotoTransform(this.state),onPhotoDragEnd:e=>{if(e==="zoom-out"){this.zoomOutPhoto();return}if(e==="prev"){this.gotoSlide(this.state.viewer.prev);return}if(e==="next"){this.gotoSlide(this.state.viewer.next);return}this.view.updatePhotoTransform(this.state)}}}};var Qe=K;return ke(Je);})();
7
7
  SmartPhoto = SmartPhoto.default;