@fancyapps/ui
Version:
Robust JavaScript UI Component Library
2 lines • 28.9 kB
JavaScript
/*! License details at fancyapps.com/license */
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.window=e.window||{}))})(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});let t=e=>typeof e==`string`,n=e=>e&&e!==null&&e instanceof Element&&`nodeType`in e,r=function(e){if(!(e&&e instanceof Element&&e.offsetParent))return!1;let t=!1,n=!1;if(e.scrollWidth>e.clientWidth){let n=window.getComputedStyle(e).overflowX,r=n.indexOf(`hidden`)!==-1,i=n.indexOf(`clip`)!==-1,a=n.indexOf(`visible`)!==-1;t=!r&&!i&&!a}if(e.scrollHeight>e.clientHeight){let t=window.getComputedStyle(e).overflowY,r=t.indexOf(`hidden`)!==-1,i=t.indexOf(`clip`)!==-1,a=t.indexOf(`visible`)!==-1;n=!r&&!i&&!a}return t||n},i=function(e,t=void 0){return!e||e===document.body||t&&e===t?null:r(e)?e:i(e.parentElement,t)},a=function(e){var t=new DOMParser().parseFromString(e,`text/html`).body;if(t.childElementCount>1){for(var n=document.createElement(`div`);t.firstChild;)n.appendChild(t.firstChild);return n}let r=t.firstChild;if(r&&!(r instanceof HTMLElement)){var n=document.createElement(`div`);return n.appendChild(r),n}return r},o=function(e=0,t=0,n=0){return Math.max(Math.min(t,n),e)},s=e=>typeof e==`object`&&!!e&&e.constructor===Object&&Object.prototype.toString.call(e)===`[object Object]`;function c(e){return s(e)||Array.isArray(e)}function l(e,t){let n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(n=>{let r=e[n],i=t[n];return typeof r==`function`?`${r}`==`${i}`:!c(r)||!c(i)?r===i:l(r,i)})}let u=function(e){for(let t of m)t.getState()===d.Running&&t.tick(g?e-g:0);g=e,h=window.requestAnimationFrame(u)};var d;(function(e){e[e.Initializing=0]=`Initializing`,e[e.Running=1]=`Running`,e[e.Paused=2]=`Paused`,e[e.Completed=3]=`Completed`,e[e.Destroyed=4]=`Destroyed`})(d||={});var f;(function(e){e[e.Spring=0]=`Spring`,e[e.Ease=1]=`Ease`})(f||={});var p;(function(e){e[e.Loop=0]=`Loop`,e[e.Reverse=1]=`Reverse`})(p||={});let m=new Set,h=null,g=0;function _(){let e=d.Initializing,t=f.Ease,n=0,r=0,i=_.Easings.Linear,a=500,s=0,c=0,g=0,v=0,y=1/0,b=.01,x=.01,ee=!1,S={},C=null,w={},T={},E={},D=0,O=0,k=p.Loop,A=_.Easings.Linear,j=new Map;function M(e,t){j.set(e,[...j.get(e)||[],t])}function N(e,t){j.has(e)&&j.set(e,j.get(e).filter(e=>e!==t))}function P(e,...t){for(let n of j.get(e)||[])n(...t)}function F(e){return r=0,e?C=setTimeout(()=>{I()},e):I(),B}function I(){e=d.Running,P(`start`,w,T)}function L(){return C&&=(clearTimeout(C),null),e===d.Running&&(e=d.Paused,P(`pause`,w)),B}function R(n){n>50&&(n=50),r+=n;let u=0,m=!1;if(e!==d.Running)return B;if(t===f.Ease){u=o(0,r/a,1),m=u===1;let e=k===p.Reverse?A:i;for(let t in w)w[t]=S[t]+(T[t]-S[t])*e(u)}if(t===f.Spring){let e=n*.001,t=0;for(let n in w){let r=T[n],i=w[n];if(typeof r!=`number`||isNaN(r)||typeof i!=`number`||isNaN(i))continue;if(Math.abs(r-i)<=x){w[n]=r,E[n]=0;continue}E[n]||(typeof s==`object`&&typeof s[n]==`number`?E[n]=s[n]:typeof s==`number`?E[n]=s:E[n]=0);let a=E[n];a=o(Math.abs(y)*-1,a,Math.abs(y));let l=a*c*v,u=Math.abs(r-i)*g,d=((i>r?-1:1)*u-l)/c;a+=d*e,i+=a*e;let f=w[n]>r?i<r:i>r,p=Math.abs(a)<b&&Math.abs(r-i)<=x;ee&&f&&(p=!0),p?(i=r,a=0):t++,w[n]=i,E[n]=a}m=!t}let h={...T};return P(`step`,w,S,T,u),m&&e===d.Running&&l(T,h)&&(e=d.Completed,z()),B}function z(){if(e=d.Completed,E={},P(`end`,w),e===d.Completed){if(n<D){if(n++,k===p.Reverse){let e={...S};S={...T},T=e}F(O)}else n=0}return B}let B={getState:function(){return e},easing:function(e){return i=e,t=f.Ease,E={},B},duration:function(e){return a=e,B},spring:function(e={}){t=f.Spring;let{velocity:n,mass:r,tension:i,friction:a,restDelta:o,restSpeed:l,maxSpeed:u,clamp:d}={velocity:0,mass:1,tension:170,friction:26,restDelta:.1,restSpeed:.1,maxSpeed:1/0,clamp:!0,...e};return s=n,c=r,g=i,v=a,x=o,b=l,y=u,ee=d,E={},B},isRunning:function(){return e===d.Running},isSpring:function(){return t===f.Spring},from:function(e){return w={...e},B},to:function(e){return T=e,B},repeat:function(e,t=0,n=p.Loop,r){return D=e,O=t,k=n,A=r||i,B},on:function(e,t){return M(e,t),B},off:function(e,t){return N(e,t),B},start:function(t){return l(w,T)||(e=d.Initializing,S={...w},m.add(this),h||=window.requestAnimationFrame(u),F(t)),B},pause:L,end:z,tick:R,getStartValues:function(){return S},getCurrentValues:function(){return w},getCurrentVelocities:function(){return E},getEndValues:function(){return T},destroy:function(){e=d.Destroyed,C&&=(clearTimeout(C),null),S=w=T={},m.delete(this)}};return B}_.destroy=()=>{for(let e of m)e.destroy();h&&=(cancelAnimationFrame(h),null)},_.Easings={Linear:function(e){return e},EaseIn:function(e){return e===0?0:2**(10*e-10)},EaseOut:function(e){return e===1?1:1-2**(-10*e)},EaseInOut:function(e){return e===0?0:e===1?1:e<.5?2**(20*e-10)/2:(2-2**(-20*e+10))/2}};function v(e){return typeof TouchEvent<`u`&&e instanceof TouchEvent}function y(e,t){let n=[],r=v(e)?e[t]:e instanceof MouseEvent&&(t===`changedTouches`||e.type!==`mouseup`)?[e]:[];for(let e of r)n.push({x:e.clientX,y:e.clientY,ts:Date.now()});return n}function b(e){return y(e,`touches`)}function x(e){return y(e,`targetTouches`)}function ee(e){return y(e,`changedTouches`)}function S(e){let t=e[0],n=e[1]||t;return{x:(t.x+n.x)/2,y:(t.y+n.y)/2,ts:n.ts}}function C(e){let t=e[0],n=e[1]||e[0];return t&&n?Math.sqrt((n.x-t.x)*(n.x-t.x)+(n.y-t.y)*(n.y-t.y))*-1:0}let w=e=>{e.cancelable&&e.preventDefault()},T={passive:!1},E={panThreshold:5,swipeThreshold:3,ignore:[`textarea`,`input`,`select`,`[contenteditable]`,`[data-selectable]`,`[data-draggable]`]},D=!1,O=!0,k=(e,t)=>{let n={...E,...t},r=!0,i,a=[],o=[],s=[],c=!1,l=!1,u=!1,d=!1,f=0,p=0,m,h=0,g=0,_=0,v=0,y=0,k=0,A=0,j,M=[],N,P,F=new Map;function I(e,t){F.set(e,[...F.get(e)||[],t])}function L(e){let t=C(o),n=C(s),r=t&&n?t/n:0,u={srcEvent:i,isPanRecognized:c,isSwipeRecognized:l,firstTouch:a,previousTouch:s,currentTouch:o,deltaX:h,deltaY:g,offsetX:_,offsetY:v,velocityX:y,velocityY:k,velocity:Math.abs(y)>Math.abs(k)?y:k,angle:A,axis:j,scale:r,center:m};for(let t of F.get(e)||[])t(u)}function R(e){let t=e.target,r=e.composedPath()[0],i=n.ignore.join(`,`),a=e=>e&&e instanceof HTMLElement&&(e.matches(i)||e.closest(i));if(a(t)||a(r))return!1}function z(e){let t=Date.now();if(M=M.filter(e=>!e.ts||e.ts>t-100),e&&M.push(e),y=0,k=0,M.length>3){let e=M[0],t=M[M.length-1];if(e&&t){let n=t.x-e.x,r=t.y-e.y,i=e.ts&&t.ts?t.ts-e.ts:0;i>0&&(y=Math.abs(n)>3?n/(i/30):0,k=Math.abs(r)>3?r/(i/30):0)}}}function B(e){if(!r||R(e)===!1)return;if(typeof MouseEvent<`u`&&e instanceof MouseEvent){if(D)return}else D=!0;if(typeof MouseEvent<`u`&&e instanceof MouseEvent){if(!e.buttons||e.button!==0)return;w(e)}e instanceof MouseEvent&&(window.addEventListener(`mousemove`,V),window.addEventListener(`mouseup`,H)),window.addEventListener(`blur`,te),i=e,o=x(e),a=[...o],s=[],p=o.length,m=S(o),p===1&&(c=!1,l=!1,u=!1),p&&z(S(o));let t=Date.now(),n=t-(f||t);d=n>0&&n<=250&&p===1,f=t,clearTimeout(N),L(`start`)}function V(e){if(!a.length||e.defaultPrevented||R(e)===!1)return;i=e,s=[...o],o=b(e);let t=S(s),r=S(b(e));if(z(r),p=o.length,m=r,s.length===o.length?(h=r.x-t.x,g=r.y-t.y):(h=0,g=0),a.length){let e=S(a);_=r.x-e.x,v=r.y-e.y}if(o.length>1){let e=C(o),t=C(s);Math.abs(e-t)>=.1&&(u=!0,L(`pinch`))}c||(c=Math.abs(_)>=n.panThreshold||Math.abs(v)>=n.panThreshold,c&&(O=!1,clearTimeout(P),P=void 0,A=Math.abs(Math.atan2(v,_)*180/Math.PI),j=A>45&&A<135?`y`:`x`,a=[...o],s=[...o],_=0,v=0,h=0,g=0,window.getSelection()?.removeAllRanges(),L(`panstart`))),c&&(h||g)&&L(`pan`),L(`move`)}function H(e){if(i=e,!a.length)return;let t=x(e),r=ee(e);if(p=t.length,m=S(r),r.length&&z(S(r)),s=[...o],o=[...t],a=[...t],p>0)L(`end`),c=!1,l=!1,M=[];else{let e=n.swipeThreshold;(Math.abs(y)>e||Math.abs(k)>e)&&(l=!0),c&&L(`panend`),l&&L(`swipe`),!c&&!l&&!u&&(L(`tap`),d?L(`doubleTap`):N=setTimeout(function(){L(`singleTap`)},250)),L(`end`),U()}}function te(){clearTimeout(N),U(),c&&L(`panend`),L(`end`)}function U(){D=!1,c=!1,l=!1,d=!1,p=0,M=[],o=[],s=[],a=[],h=0,g=0,_=0,v=0,y=0,k=0,A=0,j=void 0,window.removeEventListener(`mousemove`,V),window.removeEventListener(`mouseup`,H),window.removeEventListener(`blur`,te),!O&&!P&&(P=setTimeout(()=>{O=!0,P=void 0},100))}function ne(e){let t=e.target;D=!1,t&&!e.defaultPrevented&&(O||(w(e),e.stopPropagation()))}function re(){return e&&(e.addEventListener(`click`,ne,T),e.addEventListener(`mousedown`,B,T),e.addEventListener(`touchstart`,B,T),e.addEventListener(`touchmove`,V,T),e.addEventListener(`touchend`,H),e.addEventListener(`touchcancel`,H)),W}let W={init:re,on:function(e,t){return I(e,t),W},off:function(e,t){return F.has(e)&&F.set(e,F.get(e).filter(e=>e!==t)),W},enable:function(){return r=!0,W},disable:function(){return r=!1,a.length&&(l=!1,y=0,k=0,h=0,g=0,L(`end`)),U(),W},isPointerDown:()=>p>0,destroy:function(){clearTimeout(N),clearTimeout(P),P=void 0,e&&(e.removeEventListener(`click`,ne,T),e.removeEventListener(`mousedown`,B,T),e.removeEventListener(`touchstart`,B,T),e.removeEventListener(`touchmove`,V,T),e.removeEventListener(`touchend`,H),e.removeEventListener(`touchcancel`,H)),e=null,U()}};return W};k.isClickAllowed=()=>O;let A={IMAGE_ERROR:`This image couldn't be loaded. <br /> Please try again later.`,MOVE_UP:`Move up`,MOVE_DOWN:`Move down`,MOVE_LEFT:`Move left`,MOVE_RIGHT:`Move right`,ZOOM_IN:`Zoom in`,ZOOM_OUT:`Zoom out`,TOGGLE_FULL:`Toggle zoom level`,TOGGLE_1TO1:`Toggle zoom level`,ITERATE_ZOOM:`Toggle zoom level`,ROTATE_CCW:`Rotate counterclockwise`,ROTATE_CW:`Rotate clockwise`,FLIP_X:`Flip horizontally`,FLIP_Y:`Flip vertically`,RESET:`Reset`,TOGGLE_FS:`Toggle fullscreen`},j=(e,t=``)=>{e&&e.classList&&t.split(` `).forEach(t=>{t&&e.classList.add(t)})},M=(e,t=``)=>{e&&e.classList&&t.split(` `).forEach(t=>{t&&e.classList.remove(t)})},N=(e,t=``,n)=>{e&&e.classList&&t.split(` `).forEach(t=>{t&&e.classList.toggle(t,n||!1)})},P=1e4,F=e=>{e.cancelable&&e.preventDefault()},I=(e,t=P)=>(e=parseFloat(e+``)||0,Math.round((e+2**-52)*t)/t),L=e=>e instanceof HTMLImageElement;var R;(function(e){e.Reset=`reset`,e.Zoom=`zoom`,e.ZoomIn=`zoomIn`,e.ZoomOut=`zoomOut`,e.ZoomTo=`zoomTo`,e.ToggleCover=`toggleCover`,e.ToggleFull=`toggleFull`,e.ToggleMax=`toggleMax`,e.IterateZoom=`iterateZoom`,e.Pan=`pan`,e.Swipe=`swipe`,e.Move=`move`,e.MoveLeft=`moveLeft`,e.MoveRight=`moveRight`,e.MoveUp=`moveUp`,e.MoveDown=`moveDown`,e.RotateCCW=`rotateCCW`,e.RotateCW=`rotateCW`,e.FlipX=`flipX`,e.FlipY=`flipY`,e.ToggleFS=`toggleFS`})(R||={});var z;(function(e){e.Cover=`cover`,e.Full=`full`,e.Max=`max`})(z||={});let B={x:0,y:0,scale:1,angle:0,flipX:1,flipY:1};var V;(function(e){e[e.Init=0]=`Init`,e[e.Loading=1]=`Loading`,e[e.Error=2]=`Error`,e[e.Ready=3]=`Ready`,e[e.Destroyed=4]=`Destroyed`})(V||={});let H={bounds:!0,classes:{container:`f-panzoom`,wrapper:`f-panzoom__wrapper`,content:`f-panzoom__content`,viewport:`f-panzoom__viewport`},clickAction:R.ToggleFull,dblClickAction:!1,gestures:{},height:`auto`,l10n:A,maxScale:4,minScale:1,mouseMoveFactor:1,panMode:`drag`,protected:!1,singleClickAction:!1,spinnerTpl:`<div class="f-spinner"></div>`,wheelAction:R.Zoom,width:`auto`},te=0,U,ne=0,re=0,W=(e,r={},s={})=>{let c=0,u={...H,...r},d={},f,p,m,h,g={...B},v={...B},y,b,x,C,w=[];function T(e){let t=u[e];return t&&typeof t==`function`?t($):t}function E(e,t=[]){let n=T(`l10n`)||{};e=String(e).replace(/\{\{(\w+)\}\}/g,(e,t)=>n[t]||e);for(let n=0;n<t.length;n++)e=e.split(t[n][0]).join(t[n][1]);return e=e.replace(/\{\{(.*?)\}\}/g,(e,t)=>t),e}function D(){return e&&e.parentElement&&f&&c===3}let O=new Map;function A(e,t){for(let n of e instanceof Array?e:[e])O.set(n,[...O.get(n)||[],t]);return $}function z(e,t){for(let n of e instanceof Array?e:[e])O.has(n)&&O.set(n,O.get(n).filter(e=>e!==t));return $}function V(e,...t){let n=[...O.get(e)||[]];u.on&&n.push(u.on[e]);for(let e of n)e&&typeof e==`function`&&e($,...t);e!==`*`&&V(`*`,e,...t)}function W(){return c=0,V(`init`),ie(),ae(),oe(),se(),$}function ie(){for(let[e,t]of Object.entries({...s,...u.plugins||{}}))if(e&&!d[e]&&t instanceof Function){let n=t();n.init($),d[e]=n}V(`initPlugins`)}function ae(){let t={...H.classes,...T(`classes`)},n=t.content?.split(` `).shift(),r=t.wrapper?.split(` `).shift(),i=t.viewport?.split(` `).shift();if(n&&r&&i&&e&&(j(e,t.container),p=e.querySelector(`.${n}:not(.is-clone)`),p)){if(p.setAttribute(`draggable`,`false`),f=e.querySelector(`.${r}`),f||(f=document.createElement(`div`),j(f,t.wrapper),p.insertAdjacentElement(`beforebegin`,f),f.insertAdjacentElement(`afterbegin`,p)),h=e.querySelector(`.${i}`),h||(h=document.createElement(`div`),j(h,t.viewport),f.insertAdjacentElement(`beforeend`,h)),h.contains(p)||h.insertAdjacentElement(`afterbegin`,p),m=e.querySelector(`.${n}.is-clone`),m||(m=p.cloneNode(!0),m.removeAttribute(`id`),j(m,`is-clone`),f.insertAdjacentElement(`afterbegin`,m)),p instanceof HTMLPictureElement&&(p=p.querySelector(`img`)),m instanceof HTMLPictureElement&&(m=m.querySelector(`img`)),h instanceof HTMLPictureElement&&(h=h.querySelector(`img`)),h&&(h.style.visibility=`hidden`,T(`protected`))){h.addEventListener(`contextmenu`,e=>{F(e)});let e=document.createElement(`div`);j(e,`f-panzoom__protected`),h.appendChild(e)}V(`initLayout`)}}function oe(){if(e&&f&&!x){let e=null;x=new ResizeObserver(()=>{D()&&(e||=requestAnimationFrame(()=>{D()&&(X(),Ee(),V(`refresh`)),e=null}))}),x.observe(f),w.push(()=>{x?.disconnect(),x=void 0,e&&=(cancelAnimationFrame(e),null)})}}function se(){if(!e||!p)return;if(!(L(p)&&L(m))){_e();return}let t=()=>{p&&L(p)&&p.decode().then(()=>{_e()}).catch(()=>{_e()})};if(c=1,e.classList.add(`is-loading`),V(`loading`),m.src&&m.complete){t();return}he(),m.addEventListener(`load`,t,!1),m.addEventListener(`error`,t,!1),w.push(()=>{m?.removeEventListener(`load`,t,!1),m?.removeEventListener(`error`,t,!1)})}function ce(){b=_().on(`start`,(e,t)=>{t.angle!==void 0&&(t.angle=Math.round(t.angle/90)*90),t.flipX!==void 0&&(t.flipX=t.flipX>0?1:-1),t.flipY!==void 0&&(t.flipY=t.flipY>0?1:-1),v={...B,...t},X(),V(`animationStart`)}).on(`pause`,e=>{v={...B,...e}}).on(`step`,e=>{if(!D()){b?.end();return}if(g={...B,...e},G()||!T(`bounds`)||Ue()||v.scale>g.scale||v.scale<q()){De();return}let t=Te(v.scale),n=!1,r=!1,i=!1,a=!1;g.x<t.x[0]&&(n=!0),g.x>t.x[1]&&(r=!0),g.y<t.y[0]&&(a=!0),g.y>t.y[1]&&(i=!0);let s=!1,c=!1,l=!1,u=!1;v.x<t.x[0]&&(s=!0),v.x>t.x[1]&&(c=!0),v.y<t.y[0]&&(u=!0),v.y>t.y[1]&&(l=!0);let d=!1;(r&&c||n&&s)&&(v.x=o(t.x[0],v.x,t.x[1]),d=!0),(i&&l||a&&u)&&(v.y=o(t.y[0],v.y,t.y[1]),d=!0),d&&b&&b.spring({tension:94,friction:17,maxSpeed:555*v.scale,restDelta:.1,restSpeed:.1,velocity:b.getCurrentVelocities()}).from(g).to(v).start(),De()}).on(`end`,()=>{y?.isPointerDown()||Ee(),b?.isRunning()||(X(),V(`animationEnd`))})}function le(){let e=T(`gestures`);if(!e||!h||!p)return;let t=!1;y=k(h,e).on(`start`,e=>{if(!T(`gestures`)||!b||!D()||G())return;let n=e.srcEvent;(g.scale>1||Q(g.angle)||e.currentTouch.length>1)&&(n?.stopPropagation(),b.pause(),t=!0),e.currentTouch.length===1&&V(`touchStart`)}).on(`move`,e=>{t&&(v.scale!==1||Q(v.angle)||e.currentTouch.length>1)&&(F(e.srcEvent),e.srcEvent?.stopPropagation())}).on(`pan`,e=>{if(!t)return;let n=e.srcEvent;(v.scale!==1||Q(v.angle)||e.currentTouch.length>1)&&(F(n),Z(R.Pan,e))}).on(`swipe`,e=>{t&&(v.scale>1||Q(v.angle))&&Z(R.Swipe,e)}).on(`tap`,e=>{V(`click`,e)}).on(`singleTap`,e=>{V(`singleClick`,e)}).on(`doubleTap`,e=>{V(`dblClick`,e)}).on(`pinch`,e=>{t&&(e.scale>q()?Z(R.ZoomIn,e):e.scale<q()?Z(R.ZoomOut,e):Z(R.Pan,e))}).on(`end`,e=>{t&&(e.currentTouch.length?(e.srcEvent.stopPropagation(),F(e.srcEvent),b?.end()):(t=!1,X(),Ee(),V(`touchEnd`)))}).init()}function ue(){h&&(h.addEventListener(`wheel`,de,{passive:!1}),w.push(()=>{h?.removeEventListener(`wheel`,de,{passive:!1})}))}function de(e){if(!D())return;let t=e.target;if(i(t))return;let n=Date.now(),r=[-e.deltaX||0,-e.deltaY||0,-e.detail||0].reduce(function(e,t){return Math.abs(t)>Math.abs(e)?t:e}),a=o(-1,r,1);V(`wheel`,e,a);let s=T(`wheelAction`);if(!s||e.defaultPrevented)return;let c=v.scale,l=c*(a>0?1.5:.5);if(s===R.Zoom){let t=Math.abs(e.deltaY)<100&&Math.abs(e.deltaX)<100?200:45;if(n-ne<t){F(e);return}ne=n;let r=Ce(),i=Y();if(I(l)<I(r)&&I(c)<=I(r)?(re+=Math.abs(a),l=r):I(l)>I(i)&&I(c)>=I(i)?(re+=Math.abs(a),l=i):(re=0,l=o(r,l,i)),re>7)return}switch(F(e),s){case R.Pan:Z(s,{srcEvent:e,deltaX:-e.deltaX*2,deltaY:-e.deltaY*2});break;case R.Zoom:Z(R.ZoomTo,{srcEvent:e,scale:l,center:{x:e.clientX,y:e.clientY}});break;default:Z(s,{srcEvent:e})}}function fe(t){let r=t.composedPath()[0];if(!k.isClickAllowed()||!n(r)||t.defaultPrevented||!e?.contains(r)||r.hasAttribute(`disabled`)||r.hasAttribute(`aria-disabled`)||r.hasAttribute(`data-carousel-go-prev`)||r.hasAttribute(`data-carousel-go-next`))return;let i=r.closest(`[data-panzoom-action]`),a=i?.dataset?.panzoomAction,o=i?.dataset?.panzoomValue||``;if(a){switch(F(t),a){case R.ZoomTo:case R.ZoomIn:case R.ZoomOut:Z(a,{scale:parseFloat(o||``)||void 0});break;case R.MoveLeft:case R.MoveRight:Z(a,{deltaX:parseFloat(o||``)||void 0});break;case R.MoveUp:case R.MoveDown:Z(a,{deltaY:parseFloat(o||``)||void 0});break;case R.ToggleFS:Ke();break;default:Z(a)}return}if(!f?.contains(r))return;let s={srcEvent:t};if(Z(T(`clickAction`),s),T(`dblClickAction`)){let e=Date.now(),t=e-(te||e),n=t>0&&t<=250;te=e,n?(U&&=(clearTimeout(U),void 0),Z(T(`dblClickAction`),s)):U=setTimeout(()=>{Z(T(`singleClickAction`),s)},250)}}function pe(e){if(C=e,!D()||!G()||g.scale<=1||v.scale<=1||(f?.dataset.animationName||``).indexOf(`zoom`)>-1)return;let t=Se(v.scale);if(!t)return;let{x:n,y:r}=t;Z(R.Pan,{deltaX:n-v.x,deltaY:r-v.y})}function me(){e?.addEventListener(`click`,fe),document?.addEventListener(`mousemove`,pe),w.push(()=>{e?.removeEventListener(`click`,fe),document?.removeEventListener(`mousemove`,pe)})}function he(){if(!e||e?.querySelector(`.f-spinner`))return;let t=T(`spinnerTpl`),n=a(t);n&&(n.classList.add(`f-spinner`),e.classList.add(`is-loading`),f?.insertAdjacentElement(`afterbegin`,n))}function ge(){e&&(M(e,`is-loading`),e.querySelector(`.f-spinner`)?.remove())}function _e(){if(!e||!p)return;if(ge(),L(p)&&!(p.complete&&p.naturalWidth)){c=2,f?.classList.add(`has-error`),V(`error`);return}V(`loaded`);let{width:t,height:n}=be();L(p)&&(p.setAttribute(`width`,t+``),p.setAttribute(`height`,n+``)),f&&(M(f,`has-error`),L(p)&&(f.setAttribute(`width`,t+``),f.setAttribute(`height`,n+``),f.style.aspectRatio=`${t/n||``}`)),ce(),le(),ue(),me();let r=ve();g={...r},v={...r},c=3,De(),X(),V(`ready`),requestAnimationFrame(()=>{c===3&&(ge(),h&&(h.style.visibility=``))})}function ve(){let e={...T(`startPos`)||{}},t=e.scale,n=1;n=typeof t==`string`?K(t):typeof t==`number`?t:q();let r={...B,...e,scale:n},i=G()?Se(n):void 0;if(i){let{x:e,y:t}=i;r.x=e,r.y=t}return r}function ye(){let e={top:0,left:0,width:0,height:0};if(f){let t=f.getBoundingClientRect();Q(v.angle)?(e.top=t.top+t.height*.5-t.width*.5,e.left=t.left+t.width*.5-t.height*.5,e.width=t.height,e.height=t.width):(e.top=t.top,e.left=t.left,e.width=t.width,e.height=t.height)}return e}function be(){let e=T(`width`),n=T(`height`);if(p&&e===`auto`){let t=p.getAttribute(`width`);e=t?parseFloat(t+``):p.dataset.width===void 0?L(h)?h.naturalWidth:L(p)?p.naturalWidth:f?.getBoundingClientRect().width||0:parseFloat(p.dataset.width+``)}else e=t(e)?parseFloat(e):e;if(p&&n===`auto`){let e=p.getAttribute(`height`);n=e?parseFloat(e+``):p.dataset.height===void 0?L(h)?h.naturalHeight:L(p)?p.naturalHeight:f?.getBoundingClientRect().height||0:parseFloat(p.dataset.height+``)}else n=t(n)?parseFloat(n):n;return{width:e,height:n}}function xe(){let e=ye();return{width:e.width,height:e.height}}function G(){return T(`panMode`)===`mousemove`&&matchMedia(`(hover: hover)`).matches}function Se(e){let t=C||T(`event`),n=f?.getBoundingClientRect();if(!t||!n||e<=1)return{x:0,y:0};let r=(t.clientX||0)-n.left,i=(t.clientY||0)-n.top,{width:a,height:s}=xe(),c=Te(e);if(e>1){let t=T(`mouseMoveFactor`);t>1&&(e*=t)}let l=a*e,u=s*e,d=(l-a)*.5-(l-a)*(r/a*100/100),p=(u-s)*.5-(u-s)*(i/s*100/100);return d=o(c.x[0],d,c.x[1]),p=o(c.y[0],p,c.y[1]),{x:d,y:p}}function K(t){if(!t)return v.scale;if(!e)return 1;let n=e.getBoundingClientRect(),r=ye(),{width:i,height:a}=be(),s=e=>{if(typeof e==`number`)return e;switch(e){case`min`:return 1;case`base`:return 1;case`cover`:return Math.max(n.height/r.height,n.width/r.width)||1;case`full`:case`max`:{let e=Q(v.angle)?a:i;return e&&r.width?e/r.width:1}}},c=T(`minScale`),l=T(`maxScale`),u=Math.min(s(`full`),s(c)),d=typeof l==`number`?s(`full`)*l:Math.min(s(`full`),s(l));switch(t){case`min`:return u;case`base`:return o(u,1,d);case`cover`:return s(`cover`);case`full`:return Math.min(d,s(`full`));case`max`:return d}}function Ce(){return K(`min`)}function q(){return K(`base`)}function we(){return K(`cover`)}function J(){return K(`full`)}function Y(){return K(`max`)}function Te(t){let n={x:[0,0],y:[0,0]},r=e?.getBoundingClientRect();if(!r)return n;let i=ye(),a=r.width,o=r.height,s=i.width,c=i.height;t=t===void 0?v.scale:t;let l=t,u=t;if(G()&&t>1){let e=T(`mouseMoveFactor`);e>1&&(s*t>a+.01&&(l*=e),c*t>o+.01&&(u*=e))}if(s*=l,c*=u,s>a){n.x[0]=(a-s)*.5,n.x[1]=(s-a)*.5;let e=(i.left-r.left)*.5,t=(i.left+i.width-r.right)*.5;n.x[0]-=e+t,n.x[1]-=e+t}if(c>o){n.y[0]=(o-c)*.5,n.y[1]=(c-o)*.5;let e=(i.top-r.top)*.5,t=(i.top+i.height-r.bottom)*.5;n.y[0]-=e+t,n.y[1]-=e+t}return n}function Ee(){if(!D()||!T(`bounds`)||!b)return;let e=Ce(),t=Y(),n=o(e,v.scale,t);if(v.scale<e-.01||v.scale>t+.01){Z(R.ZoomTo,{scale:n});return}if(b.isRunning()||Ue())return;let r=Te(n);v.x<r.x[0]||v.x>r.x[1]||v.y<r.y[0]||v.y>r.y[1]?(v.x=o(r.x[0],v.x,r.x[1]),v.y=o(r.y[0],v.y,r.y[1]),b.spring({tension:170,friction:17,restDelta:.001,restSpeed:.001,maxSpeed:1/0,velocity:b.getCurrentVelocities()}),b.from(g).to(v).start()):De()}function X(t){if(!D())return;let n=He(),r=Ue(),i=We(),a=Ge(),o=Le(),s=Re();N(f,`is-fullsize`,a),N(f,`is-expanded`,i),N(f,`is-dragging`,r),N(f,`can-drag`,n),N(f,`will-zoom-in`,o),N(f,`will-zoom-out`,s);let c=Be(),l=Ve(),u=ze(),d=!D();for(let n of(t||e)?.querySelectorAll(`[data-panzoom-action]`)||[]){let e=n.dataset.panzoomAction,t=!1;if(d)t=!0;else switch(e){case R.ZoomIn:c||(t=!0);break;case R.ZoomOut:u||(t=!0);break;case R.ToggleFull:{l||u||(t=!0);let e=n.querySelector(`g`);e&&(e.style.display=a&&!t?`none`:``);break}case R.IterateZoom:{c||u||(t=!0);let e=n.querySelector(`g`);e&&(e.style.display=!c&&!t?`none`:``);break}case R.ToggleCover:case R.ToggleMax:c||u||(t=!0)}t?(n.setAttribute(`aria-disabled`,``),n.setAttribute(`tabindex`,`-1`)):(n.removeAttribute(`aria-disabled`),n.removeAttribute(`tabindex`))}}function Z(t,n){if(!t||!e||!p||!b||!D()||t===R.Swipe&&Math.abs(b.getCurrentVelocities().scale)>.01)return;let r={...v},i={...v},a=Te(G()?r.scale:g.scale),s=b.getCurrentVelocities(),c=ye();n||={};let u=(n.currentTouch?.length||0)>1,d=n.velocityX||0,f=n.velocityY||0,m=n.center;n.srcEvent&&(m=S(ee(n.srcEvent)));let h=n.deltaX||0,_=n.deltaY||0;switch(t){case R.MoveRight:h=n.deltaX||100;break;case R.MoveLeft:h=n.deltaX||-100;break;case R.MoveUp:_=n.deltaY||-100;break;case R.MoveDown:_=n.deltaY||100}let y=[];if(typeof t==`number`)i.scale=t;else switch(t){case R.Reset:i={...B},i.scale=q();break;case R.ZoomTo:case R.ZoomIn:case R.ZoomOut:case R.ToggleCover:case R.ToggleFull:case R.ToggleMax:case R.IterateZoom:case R.Zoom:i.scale=Ie(t,n);break;case R.Pan:case R.Move:case R.MoveLeft:case R.MoveRight:case R.MoveUp:case R.MoveDown:if(Ue()){let e=1,t=1;i.x<=a.x[0]&&d<=0&&(e=Math.max(.01,1-Math.abs(1/c.width*Math.abs(i.x-a.x[0]))),e*=.2),i.x>=a.x[1]&&d>=0&&(e=Math.max(.01,1-Math.abs(1/c.width*Math.abs(i.x-a.x[1]))),e*=.2),i.y<=a.y[0]&&f<=0&&(t=Math.max(.01,1-Math.abs(1/c.height*Math.abs(i.y-a.y[0]))),t*=.2),i.y>=a.y[1]&&f>=0&&(t=Math.max(.01,1-Math.abs(1/c.height*Math.abs(i.y-a.y[1]))),t*=.2),i.x+=h*e,i.y+=_*t}else i.x=o(a.x[0],i.x+h,a.x[1]),i.y=o(a.y[0],i.y+_,a.y[1]);break;case R.Swipe:let e=(e=0)=>Math.sign(e)*Math.abs(e)**1.5;i.x+=o(-1e3,e(d),1e3),i.y+=o(-1e3,e(f),1e3),f&&!d&&(i.x=o(a.x[0],i.x,a.x[1])),!f&&d&&(i.y=o(a.y[0],i.y,a.y[1])),s.x=d,s.y=f;break;case R.RotateCW:i.angle+=90;break;case R.RotateCCW:i.angle-=90;break;case R.FlipX:i.flipX*=-1;break;case R.FlipY:i.flipY*=-1}if(g.angle!==void 0&&Math.abs(g.angle)>=360&&(i.angle-=Math.floor(g.angle/360)*360,g.angle-=Math.floor(g.angle/360)*360),y.length){let e=y.findIndex(e=>e>i.scale+1/P);i.scale=y[e]||y[0]}if(u&&(i.scale=o(Ce()*(u?.8:1),i.scale,Y()*(u?1.6:1))),G()){let e=Se(i.scale);if(e){let{x:t,y:n}=e;i.x=t,i.y=n}}else if(Math.abs(i.scale-r.scale)>1e-4){let t=0,n=0;if(m)t=m.x,n=m.y;else{let r=e.getBoundingClientRect();t=r.x+r.width*.5,n=r.y+r.height*.5}let s=t-c.left,l=n-c.top;s-=c.width*.5,l-=c.height*.5;let d=(s-r.x)/r.scale,f=(l-r.y)/r.scale;i.x=s-d*i.scale,i.y=l-f*i.scale,!u&&T(`bounds`)&&(a=Te(i.scale),i.x=o(a.x[0],i.x,a.x[1]),i.y=o(a.y[0],i.y,a.y[1]))}if(t===R.Swipe){let e=500*i.scale,t=s;b.spring({tension:94,friction:17,maxSpeed:e,restDelta:.1,restSpeed:.1,velocity:t})}else t===R.Pan||u?b.spring({tension:900,friction:17,restDelta:.01,restSpeed:.01,maxSpeed:1}):b.spring({tension:170,friction:17,restDelta:.001,restSpeed:.001,maxSpeed:1/0,velocity:s});if(n.velocity===0||l(g,i))g={...i},v={...i},b.end(),De(),X();else{if(l(v,i))return;b.from(g).to(i).start()}V(`action`,t)}function De(){if(!p||!f||!h)return;let{width:e,height:t}=be();Object.assign(f.style,{maxWidth:`min(${e}px, 100%)`,maxHeight:`min(${t}px, 100%)`});let{x:n,y:r,width:i,height:a,scale:o,angle:s,flipX:c,flipY:l}=Oe(),u=`translate(${I(n,100)}px, ${I(r,100)}px)`;u+=c!==1||l!==1?` scaleX(${I(o*c)}) scaleY(${I(o*l)})`:` scale(${I(o)})`,s!==0&&(u+=` rotate(${s}deg)`),h.style.width=`${I(i)}px`,h.style.height=`${I(a)}px`,h.style.transform=`${u}`,V(`render`)}function Oe(){let{width:t,height:n}=be(),{width:r,height:i}=xe();if(!e)return{x:0,y:0,width:0,height:0,scale:0,flipX:0,flipY:0,angle:0,fitWidth:r,fitHeight:i,fullWidth:t,fullHeight:n};let{x:a,y:o,scale:s,angle:c,flipX:l,flipY:u}=g,d=1/J(),f=t,p=n,m=g.scale*d,h=v.scale*d,_=Math.max(r,i),y=Math.min(r,i);t>n?(f=_,p=y):(f=y,p=_),m=t>n?_*s/t||1:_*s/n||1;let b=f?t*h:0,x=p?n*h:0,ee=f&&p?t*m/b:0;return a=a+f*.5-b*.5,o=o+p*.5-x*.5,{x:a,y:o,width:b,height:x,scale:ee,flipX:l,flipY:u,angle:c,fitWidth:r,fitHeight:i,fullWidth:t,fullHeight:n}}function ke(){return b}function Ae(){return y}function je(){return e}function Me(){return p}function Ne(){return f}function Pe(){return h}function Fe(){V(`destroy`);for(let e of Object.values(d))e?.destroy($);for(let e of w)e();return f&&(f.style.aspectRatio=``,f.style.maxWidth=``,f.style.maxHeight=``),h&&(h.style.width=``,h.style.height=``,h.style.transform=``),f=void 0,p=void 0,h=void 0,g={...B},v={...B},b?.destroy(),b=void 0,y?.destroy(),y=void 0,c=4,$}function Ie(e=T(`clickAction`),t={}){let n=v.scale,r=q(),i=[];if(typeof e==`number`)r=e;else if(e){switch(e){case R.ZoomTo:r=t.scale||1;break;case R.ZoomIn:r=n*(t.scale||2);break;case R.ZoomOut:r=n*(t.scale||.5);break;case R.ToggleCover:i=[q(),we()];break;case R.ToggleFull:i=[q(),J()];break;case R.ToggleMax:i=[q(),Y()];break;case R.IterateZoom:i=[q(),J(),Y()];break;case R.Zoom:{let e=J();r=n>=e-.05?q():Math.min(e,n*(t.scale||2));break}}i.length&&(r=i.find(e=>e>n+1/P)??q())}return e!==R.ZoomTo&&(r=o(Ce(),r,Y())),r}function Le(){return!!(D()&&Ie()>v.scale)}function Re(){return!!(D()&&Ie()<v.scale)}function ze(){return!!(D()&&v.scale>Ce())}function Be(){return!!(D()&&v.scale<Y())}function Ve(){return!!(D()&&v.scale<J())}function He(){return!!(D()&&(We()||Q(v.angle))&&y&&!G())}function Q(e){return Math.abs(e%180)===90}function Ue(){return!!(D()&&y?.isPointerDown()&&!G())}function We(){return!!(D()&&v.scale>q())}function Ge(){return!!(D()&&v.scale>=J())}function Ke(){let t=`in-fullscreen`,n=`with-panzoom-in-fullscreen`;e?.classList.toggle(t);let r=e?.classList.contains(t);r?(document.documentElement.classList.add(n),document.addEventListener(`keydown`,qe,!0)):(document.documentElement.classList.remove(n),document.removeEventListener(`keydown`,qe,!0)),De(),V(r?`enterFS`:`exitFS`)}function qe(e){e.key===`Escape`&&!e.defaultPrevented&&Ke()}let $={canDrag:He,canZoomIn:Be,canZoomOut:ze,canZoomToFull:Ve,destroy:Fe,emit:V,execute:Z,getBoundaries:Te,getContainer:je,getContent:Me,getFullDim:be,getGestures:Ae,getMousemovePos:Se,getOptions:function(){return u},getPlugins:function(){return d},getScale:K,getStartPosition:ve,getState:function(){return c},getTransform:function(e){return e===!0?v:g},getTween:ke,getViewport:Pe,getWrapper:Ne,init:W,isDragging:Ue,isExpanded:We,isFullsize:Ge,isMousemoveMode:G,localize:E,off:z,on:A,toggleFS:Ke,updateControls:X,version:`6.1.15`,willZoomIn:Le,willZoomOut:Re};return $};W.l10n={en_EN:A},W.getDefaults=()=>H,e.PANZOOM_DEFAULT_POS=B,e.Panzoom=W,Object.defineProperty(e,"PanzoomAction",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"PanzoomState",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"PanzoomZoomLevel",{enumerable:!0,get:function(){return z}})});