UNPKG

@fancyapps/ui

Version:

Robust JavaScript UI Component Library

5 lines 31.3 kB
/*! 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==`object`&&!!e&&e.constructor===Object&&Object.prototype.toString.call(e)===`[object Object]`,n=e=>typeof e==`string`,r=function(e=``,t=``,n=``){return e.split(t).join(n)},i=e=>e&&e!==null&&e instanceof Element&&`nodeType`in e,a=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},o=function(e,t=void 0){return!e||e===document.body||t&&e===t?null:a(e)?e:o(e.parentElement,t)},s=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},c=function(e=0,t=0,n=0){return Math.max(Math.min(t,n),e)};function l(e){return t(e)||Array.isArray(e)}function u(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}`:!l(r)||!l(i)?r===i:u(r,i)}):!1}let d=function(e){for(let t of h)t.getState()===f.Running&&t.tick(_?e-_:0);_=e,g=window.requestAnimationFrame(d)},f=function(e){return 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`,e}({});var p=function(e){return e[e.Spring=0]=`Spring`,e[e.Ease=1]=`Ease`,e}(p||{});let m=function(e){return e[e.Loop=0]=`Loop`,e[e.Reverse=1]=`Reverse`,e}({}),h=new Set,g=null,_=0;function v(){let e=f.Initializing,t=p.Ease,n=0,r=0,i=v.Easings.Linear,a=500,o=0,s=0,l=0,_=0,y=1/0,b=.01,x=.01,S=!1,C={},w=null,T={},E={},D={},O=0,k=0,A=m.Loop,j=v.Easings.Linear,M=new Map;function N(e,t){M.set(e,[...M.get(e)||[],t])}function P(e,t){M.has(e)&&M.set(e,M.get(e).filter(e=>e!==t))}function F(e,...t){for(let n of M.get(e)||[])n(...t)}function ee(e){return r=0,e?w=setTimeout(()=>{I()},e):I(),B}function I(){e=f.Running,F(`start`,T,E)}function L(){return w&&=(clearTimeout(w),null),e===f.Running&&(e=f.Paused,F(`pause`,T)),B}function R(n){n>50&&(n=50),r+=n;let d=0,h=!1;if(e!==f.Running)return B;if(t===p.Ease){d=c(0,r/a,1),h=d===1;let e=A===m.Reverse?j:i;for(let t in T)T[t]=C[t]+(E[t]-C[t])*e(d)}if(t===p.Spring){let e=n*.001,t=0;for(let n in T){let r=E[n],i=T[n];if(!(typeof r==`number`&&!isNaN(r))||!(typeof i==`number`&&!isNaN(i)))continue;if(Math.abs(r-i)<=x){T[n]=r,D[n]=0;continue}D[n]||(typeof o==`object`&&typeof o[n]==`number`?D[n]=o[n]:typeof o==`number`?D[n]=o:D[n]=0);let a=D[n];a=c(Math.abs(y)*-1,a,Math.abs(y));let u=a*s*_,d=Math.abs(r-i)*l,f=((i>r?-1:1)*d-u)/s;a+=f*e,i+=a*e;let p=T[n]>r?i<r:i>r,m=Math.abs(a)<b&&Math.abs(r-i)<=x;S&&p&&(m=!0),m?(i=r,a=0):t++,T[n]=i,D[n]=a}h=!t}let g={...E};return F(`step`,T,C,E,d),h&&e===f.Running&&u(E,g)&&(e=f.Completed,z()),B}function z(){if(e=f.Completed,D={},F(`end`,T),e===f.Completed)if(n<O){if(n++,A===m.Reverse){let e={...C};C={...E},E=e}ee(k)}else n=0;return B}let B={getState:function(){return e},easing:function(e){return i=e,t=p.Ease,D={},B},duration:function(e){return a=e,B},spring:function(e={}){t=p.Spring;let{velocity:n,mass:r,tension:i,friction:a,restDelta:c,restSpeed:u,maxSpeed:d,clamp:f}={velocity:0,mass:1,tension:170,friction:26,restDelta:.1,restSpeed:.1,maxSpeed:1/0,clamp:!0,...e};return o=n,s=r,l=i,_=a,x=c,b=u,y=d,S=f,D={},B},isRunning:function(){return e===f.Running},isSpring:function(){return t===p.Spring},from:function(e){return T={...e},B},to:function(e){return E=e,B},repeat:function(e,t=0,n=m.Loop,r){return O=e,k=t,A=n,j=r||i,B},on:function(e,t){return N(e,t),B},off:function(e,t){return P(e,t),B},start:function(t){return u(T,E)||(e=f.Initializing,C={...T},h.add(this),g||=window.requestAnimationFrame(d),ee(t)),B},pause:L,end:z,tick:R,getStartValues:function(){return C},getCurrentValues:function(){return T},getCurrentVelocities:function(){return D},getEndValues:function(){return E},destroy:function(){e=f.Destroyed,w&&=(clearTimeout(w),null),C=T=E={},h.delete(this)}};return B}v.destroy=()=>{for(let e of h)e.destroy();g&&=(cancelAnimationFrame(g),null)},v.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 y(e){return typeof TouchEvent<`u`&&e instanceof TouchEvent}function b(e,t){let n=[],r=y(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 x(e){return b(e,`touches`)}function S(e){return b(e,`targetTouches`)}function C(e){return b(e,`changedTouches`)}function w(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 T(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 E=e=>{e.cancelable&&e.preventDefault()},D={passive:!1},O={panThreshold:5,swipeThreshold:3,ignore:[`textarea`,`input`,`select`,`[contenteditable]`,`[data-selectable]`,`[data-draggable]`]},k=!1,A=!0,j=(e,t)=>{let n={...O,...t},r,i=[],a=[],o=[],s=!1,c=!1,l=!1,u=!1,d=0,f=0,p,m=0,h=0,g=0,_=0,v=0,y=0,b=0,j,M=[],N,P,F=new Map;function ee(e,t){F.set(e,[...F.get(e)||[],t])}function I(e){let t=T(a),n=T(o),l=t&&n?t/n:0,u={srcEvent:r,isPanRecognized:s,isSwipeRecognized:c,firstTouch:i,previousTouch:o,currentTouch:a,deltaX:m,deltaY:h,offsetX:g,offsetY:_,velocityX:v,velocityY:y,velocity:Math.abs(v)>Math.abs(y)?v:y,angle:b,axis:j,scale:l,center:p};for(let t of F.get(e)||[])t(u)}function L(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 R(e){let t=Date.now();if(M=M.filter(e=>!e.ts||e.ts>t-100),e&&M.push(e),v=0,y=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&&(v=Math.abs(n)>3?n/(i/30):0,y=Math.abs(r)>3?r/(i/30):0)}}}function z(e){if(L(e)===!1)return;if(typeof MouseEvent<`u`&&e instanceof MouseEvent){if(k)return}else k=!0;if(typeof MouseEvent<`u`&&e instanceof MouseEvent){if(!e.buttons||e.button!==0)return;E(e)}e instanceof MouseEvent&&(window.addEventListener(`mousemove`,B),window.addEventListener(`mouseup`,V)),window.addEventListener(`blur`,te),r=e,a=S(e),i=[...a],o=[],f=a.length,p=w(a),f===1&&(s=!1,c=!1,l=!1),f&&R(w(a));let t=Date.now(),n=t-(d||t);u=n>0&&n<=250&&f===1,d=t,clearTimeout(N),I(`start`)}function B(e){if(!i.length||e.defaultPrevented||L(e)===!1)return;r=e,o=[...a],a=x(e);let t=w(o),c=w(x(e));if(R(c),f=a.length,p=c,o.length===a.length?(m=c.x-t.x,h=c.y-t.y):(m=0,h=0),i.length){let e=w(i);g=c.x-e.x,_=c.y-e.y}if(a.length>1){let e=T(a),t=T(o);Math.abs(e-t)>=.1&&(l=!0,I(`pinch`))}s||(s=Math.abs(g)>=n.panThreshold||Math.abs(_)>=n.panThreshold,s&&(A=!1,clearTimeout(P),P=void 0,b=Math.abs(Math.atan2(_,g)*180/Math.PI),j=b>45&&b<135?`y`:`x`,i=[...a],o=[...a],g=0,_=0,m=0,h=0,window.getSelection()?.removeAllRanges(),I(`panstart`))),s&&(m||h)&&I(`pan`),I(`move`)}function V(e){if(r=e,!i.length)return;let t=S(e),d=C(e);if(f=t.length,p=w(d),d.length&&R(w(d)),o=[...a],a=[...t],i=[...t],f>0)I(`end`),s=!1,c=!1,M=[];else{let e=n.swipeThreshold;(Math.abs(v)>e||Math.abs(y)>e)&&(c=!0),s&&I(`panend`),c&&I(`swipe`),!s&&!c&&!l&&(I(`tap`),u?I(`doubleTap`):N=setTimeout(function(){I(`singleTap`)},250)),I(`end`),ne()}}function te(){clearTimeout(N),ne(),s&&I(`panend`),I(`end`)}function ne(){k=!1,s=!1,c=!1,u=!1,f=0,M=[],a=[],o=[],i=[],m=0,h=0,g=0,_=0,v=0,y=0,b=0,j=void 0,window.removeEventListener(`mousemove`,B),window.removeEventListener(`mouseup`,V),window.removeEventListener(`blur`,te),!A&&!P&&(P=setTimeout(()=>{A=!0,P=void 0},100))}function re(e){let t=e.target;k=!1,!(!t||e.defaultPrevented)&&(A||(E(e),e.stopPropagation()))}function ie(){return e&&(e.addEventListener(`click`,re,D),e.addEventListener(`mousedown`,z,D),e.addEventListener(`touchstart`,z,D),e.addEventListener(`touchmove`,B,D),e.addEventListener(`touchend`,V),e.addEventListener(`touchcancel`,V)),H}let H={init:ie,on:function(e,t){return ee(e,t),H},off:function(e,t){return F.has(e)&&F.set(e,F.get(e).filter(e=>e!==t)),H},isPointerDown:()=>f>0,destroy:function(){clearTimeout(N),clearTimeout(P),P=void 0,e&&(e.removeEventListener(`click`,re,D),e.removeEventListener(`mousedown`,z,D),e.removeEventListener(`touchstart`,z,D),e.removeEventListener(`touchmove`,B,D),e.removeEventListener(`touchend`,V),e.removeEventListener(`touchcancel`,V)),e=null,ne()}};return H};j.isClickAllowed=()=>A;let M={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`},N=(e,t=``)=>{e&&e.classList&&t.split(` `).forEach(t=>{t&&e.classList.add(t)})},P=(e,t=``)=>{e&&e.classList&&t.split(` `).forEach(t=>{t&&e.classList.remove(t)})},F=(e,t=``,n)=>{e&&e.classList&&t.split(` `).forEach(t=>{t&&e.classList.toggle(t,n||!1)})},ee=1e4,I=e=>{e.cancelable&&e.preventDefault()},L=(e,t=ee)=>(e=parseFloat(e+``)||0,Math.round((e+2**-52)*t)/t),R=e=>e instanceof HTMLImageElement,z=function(e){return 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`,e}({}),B={x:0,y:0,scale:1,angle:0,flipX:1,flipY:1},V=function(e){return 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`,e}({}),te={bounds:!0,classes:{container:`f-panzoom`,wrapper:`f-panzoom__wrapper`,content:`f-panzoom__content`,viewport:`f-panzoom__viewport`},clickAction:z.ToggleFull,dblClickAction:!1,gestures:{},height:`auto`,l10n:M,maxScale:4,minScale:1,mouseMoveFactor:1,panMode:`drag`,protected:!1,singleClickAction:!1,spinnerTpl:`<div class="f-spinner"></div>`,wheelAction:z.Zoom,width:`auto`},ne=0,re,ie=0,H=0,U=(e,t={},r={})=>{let a=V.Init,l={...te,...t},d={},f,p,m,h,g={...B},_={...B},y,b,x,S,T=[];function E(e){let t=l[e];return t&&typeof t==`function`?t($):t}function D(e,t=[]){let n=E(`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 O(){return e&&e.parentElement&&f&&a===V.Ready}let k=new Map;function A(e,t){for(let n of e instanceof Array?e:[e])k.set(n,[...k.get(n)||[],t]);return $}function M(e,t){for(let n of e instanceof Array?e:[e])k.has(n)&&k.set(n,k.get(n).filter(e=>e!==t));return $}function U(e,...t){let n=[...k.get(e)||[]];l.on&&n.push(l.on[e]);for(let e of n)e&&typeof e==`function`&&e($,...t);e!==`*`&&U(`*`,e,...t)}function ae(){return a=V.Init,U(`init`),oe(),se(),ce(),le(),$}function oe(){for(let[e,t]of Object.entries({...r,...l.plugins||{}}))if(e&&!d[e]&&t instanceof Function){let n=t();n.init($),d[e]=n}U(`initPlugins`)}function se(){let t={...te.classes,...E(`classes`)},n=t.content?.split(` `).shift(),r=t.wrapper?.split(` `).shift(),i=t.viewport?.split(` `).shift();if(!(!n||!r||!i)&&e&&(N(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`),N(f,t.wrapper),p.insertAdjacentElement(`beforebegin`,f),f.insertAdjacentElement(`afterbegin`,p)),h=e.querySelector(`.${i}`),h||(h=document.createElement(`div`),N(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`),N(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`,E(`protected`))){h.addEventListener(`contextmenu`,e=>{I(e)});let e=document.createElement(`div`);N(e,`f-panzoom__protected`),h.appendChild(e)}U(`initLayout`)}}function ce(){if(e&&f&&!x){let e=null;x=new ResizeObserver(()=>{O()&&(e||=requestAnimationFrame(()=>{O()&&(X(),De(),U(`refresh`)),e=null}))}),x.observe(f),T.push(()=>{x?.disconnect(),x=void 0,e&&=(cancelAnimationFrame(e),null)})}}function le(){if(!e||!p)return;if(!(R(p)&&R(m))){ye();return}let t=()=>{p&&R(p)&&p.decode().then(()=>{ye()}).catch(()=>{ye()})};if(a=V.Loading,e.classList.add(`is-loading`),U(`loading`),m.src&&m.complete){t();return}_e(),m.addEventListener(`load`,t,!1),m.addEventListener(`error`,t,!1),T.push(()=>{m?.removeEventListener(`load`,t,!1),m?.removeEventListener(`error`,t,!1)})}function ue(){b=v().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),_={...B,...t},X(),U(`animationStart`)}).on(`pause`,e=>{_={...B,...e}}).on(`step`,e=>{if(!O()){b?.end();return}if(g={...B,...e},W()||!E(`bounds`)||We()||_.scale>g.scale||_.scale<K()){Oe();return}let t=Y(_.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 o=!1,s=!1,l=!1,u=!1;_.x<t.x[0]&&(o=!0),_.x>t.x[1]&&(s=!0),_.y<t.y[0]&&(u=!0),_.y>t.y[1]&&(l=!0);let d=!1;(r&&s||n&&o)&&(_.x=c(t.x[0],_.x,t.x[1]),d=!0),(i&&l||a&&u)&&(_.y=c(t.y[0],_.y,t.y[1]),d=!0),d&&b&&b.spring({tension:94,friction:17,maxSpeed:555*_.scale,restDelta:.1,restSpeed:.1,velocity:b.getCurrentVelocities()}).from(g).to(_).start(),Oe()}).on(`end`,()=>{y?.isPointerDown()||De(),b?.isRunning()||(X(),U(`animationEnd`))})}function de(){let e=E(`gestures`);if(!e||!h||!p)return;let t=!1;y=j(h,e).on(`start`,e=>{if(!E(`gestures`)||!b||!O()||W())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&&U(`touchStart`)}).on(`move`,e=>{t&&(_.scale!==1||Q(_.angle)||e.currentTouch.length>1)&&(I(e.srcEvent),e.srcEvent?.stopPropagation())}).on(`pan`,e=>{if(!t)return;let n=e.srcEvent;(_.scale!==1||Q(_.angle)||e.currentTouch.length>1)&&(I(n),Z(z.Pan,e))}).on(`swipe`,e=>{t&&(_.scale>1||Q(_.angle))&&Z(z.Swipe,e)}).on(`tap`,e=>{U(`click`,e)}).on(`singleTap`,e=>{U(`singleClick`,e)}).on(`doubleTap`,e=>{U(`dblClick`,e)}).on(`pinch`,e=>{t&&(e.scale>K()?Z(z.ZoomIn,e):e.scale<K()?Z(z.ZoomOut,e):Z(z.Pan,e))}).on(`end`,e=>{t&&(e.currentTouch.length?(e.srcEvent.stopPropagation(),I(e.srcEvent),b?.end()):(t=!1,X(),De(),U(`touchEnd`)))}).init()}function fe(){h&&(h.addEventListener(`wheel`,pe,{passive:!1}),T.push(()=>{h?.removeEventListener(`wheel`,pe,{passive:!1})}))}function pe(e){if(!O())return;let t=e.target;if(o(t))return;let n=Date.now(),r=c(-1,[-e.deltaX||0,-e.deltaY||0,-e.detail||0].reduce(function(e,t){return Math.abs(t)>Math.abs(e)?t:e}),1);U(`wheel`,e,r);let i=E(`wheelAction`);if(!i||e.defaultPrevented)return;let a=_.scale,s=a*(r>0?1.5:.5);if(i===z.Zoom){let t=Math.abs(e.deltaY)<100&&Math.abs(e.deltaX)<100?200:45;if(n-ie<t){I(e);return}ie=n;let i=Te(),o=J();if(L(s)<L(i)&&L(a)<=L(i)?(H+=Math.abs(r),s=i):L(s)>L(o)&&L(a)>=L(o)?(H+=Math.abs(r),s=o):(H=0,s=c(i,s,o)),H>7)return}switch(I(e),i){case z.Pan:Z(i,{srcEvent:e,deltaX:-e.deltaX*2,deltaY:-e.deltaY*2});break;case z.Zoom:Z(z.ZoomTo,{srcEvent:e,scale:s,center:{x:e.clientX,y:e.clientY}});break;default:Z(i,{srcEvent:e})}}function me(t){let n=t.composedPath()[0];if(!j.isClickAllowed()||!i(n)||t.defaultPrevented||!e?.contains(n)||n.hasAttribute(`disabled`)||n.hasAttribute(`aria-disabled`)||n.hasAttribute(`data-carousel-go-prev`)||n.hasAttribute(`data-carousel-go-next`))return;let r=n.closest(`[data-panzoom-action]`),a=r?.dataset?.panzoomAction,o=r?.dataset?.panzoomValue||``;if(a){switch(I(t),a){case z.ZoomTo:case z.ZoomIn:case z.ZoomOut:Z(a,{scale:parseFloat(o||``)||void 0});break;case z.MoveLeft:case z.MoveRight:Z(a,{deltaX:parseFloat(o||``)||void 0});break;case z.MoveUp:case z.MoveDown:Z(a,{deltaY:parseFloat(o||``)||void 0});break;case z.ToggleFS:qe();break;default:Z(a);break}return}if(!f?.contains(n))return;let s={srcEvent:t};if(Z(E(`clickAction`),s),E(`dblClickAction`)){let e=Date.now(),t=e-(ne||e),n=t>0&&t<=250;ne=e,n?(re&&=(clearTimeout(re),void 0),Z(E(`dblClickAction`),s)):re=setTimeout(()=>{Z(E(`singleClickAction`),s)},250)}}function he(e){if(S=e,!O()||!W()||g.scale<=1||_.scale<=1||(f?.dataset.animationName||``).indexOf(`zoom`)>-1)return;let t=we(_.scale);if(!t)return;let{x:n,y:r}=t;Z(z.Pan,{deltaX:n-_.x,deltaY:r-_.y})}function ge(){e?.addEventListener(`click`,me),document?.addEventListener(`mousemove`,he),T.push(()=>{e?.removeEventListener(`click`,me),document?.removeEventListener(`mousemove`,he)})}function _e(){if(!e||e?.querySelector(`.f-spinner`))return;let t=s(E(`spinnerTpl`));t&&(t.classList.add(`f-spinner`),e.classList.add(`is-loading`),f?.insertAdjacentElement(`afterbegin`,t))}function ve(){e&&(P(e,`is-loading`),e.querySelector(`.f-spinner`)?.remove())}function ye(){if(!e||!p)return;if(ve(),R(p)&&!(p.complete&&p.naturalWidth)){a=V.Error,f?.classList.add(`has-error`),U(`error`);return}U(`loaded`);let{width:t,height:n}=Se();R(p)&&(p.setAttribute(`width`,t+``),p.setAttribute(`height`,n+``)),f&&(P(f,`has-error`),R(p)&&(f.setAttribute(`width`,t+``),f.setAttribute(`height`,n+``),f.style.aspectRatio=`${t/n||``}`)),ue(),de(),fe(),ge();let r=be();g={...r},_={...r},a=V.Ready,Oe(),X(),U(`ready`),requestAnimationFrame(()=>{a===V.Ready&&(ve(),h&&(h.style.visibility=``))})}function be(){let e={...E(`startPos`)||{}},t=e.scale,n=1;n=typeof t==`string`?G(t):typeof t==`number`?t:K();let r={...B,...e,scale:n},i=W()?we(n):void 0;if(i){let{x:e,y:t}=i;r.x=e,r.y=t}return r}function xe(){let e={top:0,left:0,width:0,height:0};if(f){let t=f.getBoundingClientRect();Q(_.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 Se(){let e=E(`width`),t=E(`height`);if(p&&e===`auto`){let t=p.getAttribute(`width`);e=t?parseFloat(t+``):p.dataset.width===void 0?R(h)?h.naturalWidth:R(p)?p.naturalWidth:f?.getBoundingClientRect().width||0:parseFloat(p.dataset.width+``)}else e=n(e)?parseFloat(e):e;if(p&&t===`auto`){let e=p.getAttribute(`height`);t=e?parseFloat(e+``):p.dataset.height===void 0?R(h)?h.naturalHeight:R(p)?p.naturalHeight:f?.getBoundingClientRect().height||0:parseFloat(p.dataset.height+``)}else t=n(t)?parseFloat(t):t;return{width:e,height:t}}function Ce(){let e=xe();return{width:e.width,height:e.height}}function W(){return E(`panMode`)===`mousemove`&&matchMedia(`(hover: hover)`).matches}function we(e){let t=S||E(`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:o}=Ce(),s=Y(e);if(e>1){let t=E(`mouseMoveFactor`);t>1&&(e*=t)}let l=a*e,u=o*e,d=(l-a)*.5-(l-a)*(r/a*100/100),p=(u-o)*.5-(u-o)*(i/o*100/100);return d=c(s.x[0],d,s.x[1]),p=c(s.y[0],p,s.y[1]),{x:d,y:p}}function G(t){if(!t)return _.scale;if(!e)return 1;let n=e.getBoundingClientRect(),r=xe(),{width:i,height:a}=Se(),o=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(_.angle)?a:i;return e&&r.width?e/r.width:1}}},s=E(`minScale`),l=E(`maxScale`),u=Math.min(o(`full`),o(s)),d=typeof l==`number`?o(`full`)*l:Math.min(o(`full`),o(l));switch(t){case`min`:return u;case`base`:return c(u,1,d);case`cover`:return o(`cover`);case`full`:return Math.min(d,o(`full`));case`max`:return d}}function Te(){return G(`min`)}function K(){return G(`base`)}function Ee(){return G(`cover`)}function q(){return G(`full`)}function J(){return G(`max`)}function Y(t){let n={x:[0,0],y:[0,0]},r=e?.getBoundingClientRect();if(!r)return n;let i=xe(),a=r.width,o=r.height,s=i.width,c=i.height;t=t===void 0?_.scale:t;let l=t,u=t;if(W()&&t>1){let e=E(`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 De(){if(!O()||!E(`bounds`)||!b)return;let e=Te(),t=J(),n=c(e,_.scale,t);if(_.scale<e-.01||_.scale>t+.01){Z(z.ZoomTo,{scale:n});return}if(b.isRunning()||We())return;let r=Y(n);_.x<r.x[0]||_.x>r.x[1]||_.y<r.y[0]||_.y>r.y[1]?(_.x=c(r.x[0],_.x,r.x[1]),_.y=c(r.y[0],_.y,r.y[1]),b.spring({tension:170,friction:17,restDelta:.001,restSpeed:.001,maxSpeed:1/0,velocity:b.getCurrentVelocities()}),b.from(g).to(_).start()):Oe()}function X(t){if(!O())return;let n=Ue(),r=We(),i=Ge(),a=Ke(),o=Re(),s=ze();F(f,`is-fullsize`,a),F(f,`is-expanded`,i),F(f,`is-dragging`,r),F(f,`can-drag`,n),F(f,`will-zoom-in`,o),F(f,`will-zoom-out`,s);let c=Ve(),l=He(),u=Be(),d=!O();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 z.ZoomIn:c||(t=!0);break;case z.ZoomOut:u||(t=!0);break;case z.ToggleFull:{l||u||(t=!0);let e=n.querySelector(`g`);e&&(e.style.display=a&&!t?`none`:``);break}case z.IterateZoom:{c||u||(t=!0);let e=n.querySelector(`g`);e&&(e.style.display=!c&&!t?`none`:``);break}case z.ToggleCover:case z.ToggleMax:c||u||(t=!0);break}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||!O()||t===z.Swipe&&Math.abs(b.getCurrentVelocities().scale)>.01)return;let r={..._},i={..._},a=Y(W()?r.scale:g.scale),o=b.getCurrentVelocities(),s=xe();n||={};let l=(n.currentTouch?.length||0)>1,d=n.velocityX||0,f=n.velocityY||0,m=n.center;n.srcEvent&&(m=w(C(n.srcEvent)));let h=n.deltaX||0,v=n.deltaY||0;switch(t){case z.MoveRight:h=n.deltaX||100;break;case z.MoveLeft:h=n.deltaX||-100;break;case z.MoveUp:v=n.deltaY||-100;break;case z.MoveDown:v=n.deltaY||100;break}let y=[];if(typeof t==`number`)i.scale=t;else switch(t){case z.Reset:i={...B},i.scale=K();break;case z.ZoomTo:case z.ZoomIn:case z.ZoomOut:case z.ToggleCover:case z.ToggleFull:case z.ToggleMax:case z.IterateZoom:case z.Zoom:i.scale=Le(t,n);break;case z.Pan:case z.Move:case z.MoveLeft:case z.MoveRight:case z.MoveUp:case z.MoveDown:if(We()){let e=1,t=1;i.x<=a.x[0]&&d<=0&&(e=Math.max(.01,1-Math.abs(1/s.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/s.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/s.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/s.height*Math.abs(i.y-a.y[1]))),t*=.2),i.x+=h*e,i.y+=v*t}else i.x=c(a.x[0],i.x+h,a.x[1]),i.y=c(a.y[0],i.y+v,a.y[1]);break;case z.Swipe:let e=(e=0)=>Math.sign(e)*Math.abs(e)**1.5;i.x+=c(-1e3,e(d),1e3),i.y+=c(-1e3,e(f),1e3),f&&!d&&(i.x=c(a.x[0],i.x,a.x[1])),!f&&d&&(i.y=c(a.y[0],i.y,a.y[1])),o.x=d,o.y=f;break;case z.RotateCW:i.angle+=90;break;case z.RotateCCW:i.angle-=90;break;case z.FlipX:i.flipX*=-1;break;case z.FlipY:i.flipY*=-1;break}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/ee);i.scale=y[e]||y[0]}if(l&&(i.scale=c(Te()*(l?.8:1),i.scale,J()*(l?1.6:1))),W()){let e=we(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 o=t-s.left,u=n-s.top;o-=s.width*.5,u-=s.height*.5;let d=(o-r.x)/r.scale,f=(u-r.y)/r.scale;i.x=o-d*i.scale,i.y=u-f*i.scale,!l&&E(`bounds`)&&(a=Y(i.scale),i.x=c(a.x[0],i.x,a.x[1]),i.y=c(a.y[0],i.y,a.y[1]))}if(t===z.Swipe){let e=500*i.scale,t=o;b.spring({tension:94,friction:17,maxSpeed:e,restDelta:.1,restSpeed:.1,velocity:t})}else t===z.Pan||l?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:o});if(n.velocity===0||u(g,i))g={...i},_={...i},b.end(),Oe(),X();else{if(u(_,i))return;b.from(g).to(i).start()}U(`action`,t)}function Oe(){if(!p||!f||!h)return;let{width:e,height:t}=Se();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}=ke(),u=`translate(${L(n,100)}px, ${L(r,100)}px)`;c!==1||l!==1?u+=` scaleX(${L(o*c)}) scaleY(${L(o*l)})`:u+=` scale(${L(o)})`,s!==0&&(u+=` rotate(${s}deg)`),h.style.width=`${L(i)}px`,h.style.height=`${L(a)}px`,h.style.transform=`${u}`,U(`render`)}function ke(){let{width:t,height:n}=Se(),{width:r,height:i}=Ce();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/q(),f=t,p=n,m=g.scale*d,h=_.scale*d,v=Math.max(r,i),y=Math.min(r,i);t>n?(f=v,p=y):(f=y,p=v),m=t>n?v*s/t||1:v*s/n||1;let b=f?t*h:0,x=p?n*h:0,S=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:S,flipX:l,flipY:u,angle:c,fitWidth:r,fitHeight:i,fullWidth:t,fullHeight:n}}function Ae(){return b}function je(){return y}function Me(){return e}function Ne(){return p}function Pe(){return f}function Fe(){return h}function Ie(){U(`destroy`);for(let e of Object.values(d))e?.destroy($);for(let e of T)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},_={...B},b?.destroy(),b=void 0,y?.destroy(),y=void 0,a=V.Destroyed,$}function Le(e=E(`clickAction`),t={}){let n=_.scale,r=K(),i=[];if(typeof e==`number`)r=e;else if(e){switch(e){case z.ZoomTo:r=t.scale||1;break;case z.ZoomIn:r=n*(t.scale||2);break;case z.ZoomOut:r=n*(t.scale||.5);break;case z.ToggleCover:i=[K(),Ee()];break;case z.ToggleFull:i=[K(),q()];break;case z.ToggleMax:i=[K(),J()];break;case z.IterateZoom:i=[K(),q(),J()];break;case z.Zoom:{let e=q();r=n>=e-.05?K():Math.min(e,n*(t.scale||2));break}}i.length&&(r=i.find(e=>e>n+1/ee)??K())}return e!==z.ZoomTo&&(r=c(Te(),r,J())),r}function Re(){return!!(O()&&Le()>_.scale)}function ze(){return!!(O()&&Le()<_.scale)}function Be(){return!!(O()&&_.scale>Te())}function Ve(){return!!(O()&&_.scale<J())}function He(){return!!(O()&&_.scale<q())}function Ue(){return!!(O()&&(Ge()||Q(_.angle))&&y&&!W())}function Q(e){return Math.abs(e%180)===90}function We(){return!!(O()&&y?.isPointerDown()&&!W())}function Ge(){return!!(O()&&_.scale>K())}function Ke(){return!!(O()&&_.scale>=q())}function qe(){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`,Je,!0)):(document.documentElement.classList.remove(n),document.removeEventListener(`keydown`,Je,!0)),Oe(),U(r?`enterFS`:`exitFS`)}function Je(e){e.key===`Escape`&&!e.defaultPrevented&&qe()}let $={canDrag:Ue,canZoomIn:Ve,canZoomOut:Be,canZoomToFull:He,destroy:Ie,emit:U,execute:Z,getBoundaries:Y,getContainer:Me,getContent:Ne,getFullDim:Se,getGestures:je,getMousemovePos:we,getOptions:function(){return l},getPlugins:function(){return d},getScale:G,getStartPosition:be,getState:function(){return a},getTransform:function(e){return e===!0?_:g},getTween:Ae,getViewport:Fe,getWrapper:Pe,init:ae,isDragging:We,isExpanded:Ge,isFullsize:Ke,isMousemoveMode:W,localize:D,off:M,on:A,toggleFS:qe,updateControls:X,version:`6.1.14`,willZoomIn:Re,willZoomOut:ze};return $};U.l10n={en_EN:M},U.getDefaults=()=>te;let ae={tpl:e=>`<img class="f-panzoom__content" ${e.srcset?`data-lazy-srcset="{{srcset}}"`:``} ${e.sizes?`data-lazy-sizes="{{sizes}}"`:``} data-lazy-src="{{src}}" alt="{{alt}}" />`};e.Zoomable=()=>{let e;function i(n,r){let i=e?.getOptions().Zoomable,a=(t(i)?{...ae,...i}:ae)[n];return a&&typeof a==`function`&&r?a(r):a}function a(){e&&e.getOptions().Zoomable!==!1&&(e.on(`addSlide`,c),e.on(`removeSlide`,l),e.on(`attachSlideEl`,u),e.on(`click`,s),e.on(`change`,o),e.on(`ready`,o))}function o(){d();let t=e?.getVisibleSlides()||[];if(t.length>1||e?.getOption(`transition`)===`slide`)for(let n of t){let t=n.panzoomRef;t&&(e?.getPage().slides||[]).indexOf(n)<0&&t.execute(z.ZoomTo,{...t.getStartPosition()})}}function s(e,t){let n=t.target;!n||t.defaultPrevented||n.dataset.panzoomAction&&f(n.dataset.panzoomAction)}function c(t,a){let o=a.el;if(!e||!o||a.panzoomRef)return;let s=a.src||a.lazySrc||``,c=a.alt||a.caption||`Image #${a.index}`,l=a.srcset||a.lazySrcset||``,u=a.sizes||a.lazySizes||``;if(s&&n(s)&&!a.html&&(!a.type||a.type===`image`)){a.type=`image`,a.thumbSrc=a.thumbSrc||s;let e=i(`tpl`,a);e=r(e,`{{src}}`,s+``),e=r(e,`{{srcset}}`,l+``),e=r(e,`{{sizes}}`,u+``),o.insertAdjacentHTML(`afterbegin`,e)}let f=o.querySelector(`.f-panzoom__content`);if(!f)return;f.setAttribute(`alt`,c+``);let p=U(o,{width:a.width&&a.width!==`auto`?parseFloat(a.width+``):`auto`,height:a.height&&a.height!==`auto`?parseFloat(a.height+``):`auto`,classes:{container:`f-zoomable`},event:()=>e?.getLastMouseMove(),spinnerTpl:()=>e?.getOption(`spinnerTpl`)||``,...i(`Panzoom`)});p.on(`*`,(t,n,...r)=>{e&&(n===`loading`&&(a.state=0),n===`loaded`&&(a.state=1),n===`error`&&(a.state=2,e?.showError(a,`{{IMAGE_ERROR}}`)),e.emit(`panzoom:${n}`,a,...r),n===`loading`&&e.emit(`contentLoading`,a),n===`ready`&&e.emit(`contentReady`,a),a.index===e?.getPageIndex()&&d())}),a.panzoomRef=p}function l(e,t){t.panzoomRef&&=(t.panzoomRef.destroy(),void 0)}function u(e,t){let n=t.panzoomRef;if(n)switch(n.getState()){case V.Init:n.init();break;case V.Ready:n.execute(z.ZoomTo,{...n.getStartPosition(),velocity:0});break}}function d(){let t=e?.getContainer()||void 0,n=e?.getPage()?.slides[0]?.panzoomRef;if(t)if(n)n.updateControls(t);else for(let e of t.querySelectorAll(`[data-panzoom-action]`)||[])e.setAttribute(`aria-disabled`,``),e.setAttribute(`tabindex`,`-1`)}function f(t,...n){e?.getPage().slides[0].panzoomRef?.execute(t,...n)}return{init:function(t){e=t,e.on(`initPlugins`,a)},destroy:function(){if(e){e.off(`initPlugins`,a),e.off(`addSlide`,c),e.off(`removeSlide`,l),e.off(`attachSlideEl`,u),e.off(`click`,s),e.off(`change`,o),e.off(`ready`,o);for(let t of e.getSlides())l(e,t)}e=void 0},execute:f}}});