UNPKG

@fancyapps/ui

Version:

Robust JavaScript UI Component Library

1 lines 27.4 kB
!/*! License details at fancyapps.com/license */function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).window=e.window||{})}(this,function(e){"use strict";let t,n=function(e){if(!(e&&e instanceof Element&&e.offsetParent))return!1;let t=e.scrollHeight>e.clientHeight,n=window.getComputedStyle(e).overflowY,o=-1!==n.indexOf("hidden"),i=-1!==n.indexOf("visible");return t&&!o&&!i},o=function(e,t){return!e||e===document.body||t&&e===t?null:n(e)?e:o(e.parentElement,t)},i=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 o=t.firstChild;if(o&&!(o instanceof HTMLElement)){var n=document.createElement("div");return n.appendChild(o),n}return o},a=function(e=0,t=0,n=0){return Math.max(Math.min(t,n),e)};function r(e){return"object"==typeof e&&null!==e&&e.constructor===Object&&"[object Object]"===Object.prototype.toString.call(e)||Array.isArray(e)}function l(e,t){let n=Object.keys(e),o=Object.keys(t);return n.length===o.length&&n.every(n=>{let o=e[n],i=t[n];return"function"==typeof o?`${o}`==`${i}`:r(o)&&r(i)?l(o,i):o===i})}let s=1/60*3e3,c=function(e){for(let t of b)t.getState()===u.Running&&t.tick(M?e-M:0);M=e,x=window.requestAnimationFrame(c)},u=((f={})[f.Initializing=0]="Initializing",f[f.Running=1]="Running",f[f.Paused=2]="Paused",f[f.Completed=3]="Completed",f[f.Destroyed=4]="Destroyed",f);var f,d,h,g,m,p,v=((d=v||{})[d.Spring=0]="Spring",d[d.Ease=1]="Ease",d);let y=((h={})[h.Loop=0]="Loop",h[h.Reverse=1]="Reverse",h),b=new Set,x=null,M=0;function w(){let e=u.Initializing,t=v.Ease,n=0,o=0,i=w.Easings.Linear,r=500,f=0,d=0,h=0,g=0,m=1/0,p=.01,M=.01,E=!1,T={},L=null,C={},k={},A={},R=0,S=0,O=y.Loop,P=w.Easings.Linear,F=new Map;function I(e,...t){for(let n of F.get(e)||[])n(...t)}function Z(e){return o=0,e?L=setTimeout(()=>{D()},e):D(),Y}function D(){e=u.Running,I("start",C,k)}function z(){if(e=u.Completed,A={},I("end",C),e===u.Completed)if(n<R){if(n++,O===y.Reverse){let e={...T};T={...k},k=e}Z(S)}else n=0;return Y}let Y={getState:function(){return e},easing:function(e){return i=e,t=v.Ease,A={},Y},duration:function(e){return r=e,Y},spring:function(e={}){t=v.Spring;let{velocity:n,mass:o,tension:i,friction:a,restDelta:r,restSpeed:l,maxSpeed:s,clamp:c}={velocity:0,mass:1,tension:170,friction:26,restDelta:.1,restSpeed:.1,maxSpeed:1/0,clamp:!0,...e};return f=n,d=o,h=i,g=a,M=r,p=l,m=s,E=c,A={},Y},isRunning:function(){return e===u.Running},isSpring:function(){return t===v.Spring},from:function(e){return C={...e},Y},to:function(e){return k=e,Y},repeat:function(e,t=0,n=y.Loop,o){return R=e,S=t,O=n,P=o||i,Y},on:function(e,t){return F.set(e,[...F.get(e)||[],t]),Y},off:function(e,t){return F.has(e)&&F.set(e,F.get(e).filter(e=>e!==t)),Y},start:function(t){return e=u.Initializing,l(T={...C},k)||(b.add(this),x||(x=window.requestAnimationFrame(c)),Z(t)),Y},pause:function(){return L&&(clearTimeout(L),L=null),e===u.Running&&(e=u.Paused,I("pause",C)),Y},end:z,tick:function(n){n>s&&(n=s),o+=n;let c=0,b=!1;if(e!==u.Running)return Y;if(t===v.Ease){b=1===(c=a(0,o/r,1));let e=O===y.Reverse?P:i;for(let t in C)C[t]=T[t]+(k[t]-T[t])*e(c)}if(t===v.Spring){let e=.001*n,t=0;for(let n in C){let o=k[n],i=C[n];if(!("number"==typeof o&&!isNaN(o))||!("number"==typeof i&&!isNaN(i)))continue;if(Math.abs(o-i)<=M){C[n]=o,A[n]=0;continue}A[n]||("object"==typeof f&&"number"==typeof f[n]?A[n]=f[n]:"number"==typeof f?A[n]=f:A[n]=0);let r=A[n],l=(r=a(-1*Math.abs(m),r,Math.abs(m)))*d*g,s=Math.abs(o-i)*h;r+=((i>o?-1:1)*s-l)/d*e,i+=r*e;let c=C[n]>o?i<o:i>o,u=Math.abs(r)<p&&Math.abs(o-i)<=M;E&&c&&(u=!0),u?(i=o,r=0):t++,C[n]=i,A[n]=r}b=!t}let x={...k};return I("step",C,T,k,c),b&&e===u.Running&&l(k,x)&&(e=u.Completed,z()),Y},getStartValues:function(){return T},getCurrentValues:function(){return C},getCurrentVelocities:function(){return A},getEndValues:function(){return k},destroy:function(){e=u.Destroyed,L&&(clearTimeout(L),L=null),T=C=k={},b.delete(this)}};return Y}function E(e){let t=[];for(let n of"undefined"!=typeof TouchEvent&&e instanceof TouchEvent?e.touches:e instanceof MouseEvent&&"mouseup"!==e.type?[e]:[])t.push({x:n.clientX,y:n.clientY,ts:Date.now()});return t}function T(e){let t=[];for(let n of"undefined"!=typeof TouchEvent&&e instanceof TouchEvent?e.changedTouches:e instanceof MouseEvent?[e]:[])t.push({x:n.clientX,y:n.clientY,ts:Date.now()});return t}function L(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?-1*Math.sqrt((n.x-t.x)*(n.x-t.x)+(n.y-t.y)*(n.y-t.y)):0}w.destroy=()=>{for(let e of b)e.destroy();x&&(cancelAnimationFrame(x),x=null)},w.Easings={Linear:function(e){return e},EaseIn:function(e){return 0===e?0:Math.pow(2,10*e-10)},EaseOut:function(e){return 1===e?1:1-Math.pow(2,-10*e)},EaseInOut:function(e){return 0===e?0:1===e?1:e<.5?Math.pow(2,20*e-10)/2:(2-Math.pow(2,-20*e+10))/2}};let k=e=>{e.cancelable&&e.preventDefault()},A={passive:!1},R={panThreshold:5,swipeThreshold:3,ignore:["textarea","input","select","[contenteditable]","[data-selectable]","[data-draggable]"]},S=!1,O=!0,P=(e,t)=>{let n,o,i,a={...R,...t},r=[],l=[],s=[],c=!1,u=!1,f=!1,d=0,h=0,g=0,m=0,p=0,v=0,y=0,b=0,x=0,M=[],w=0,P=0,F=new Map;function I(e){let t=C(l),a=C(s),f=Math.abs(y)>Math.abs(b)?y:b,d={srcEvent:i,isPanRecognized:c,isSwipeRecognized:u,firstTouch:r,previousTouch:s,currentTouch:l,deltaX:g,deltaY:m,offsetX:p,offsetY:v,velocityX:y,velocityY:b,velocity:f,angle:x,axis:o,scale:t&&a?t/a:0,center:n};for(let t of F.get(e)||[])t(d)}function Z(e){let t=Date.now();M=M.filter(e=>!e.ts||e.ts>t-100),e&&M.push(e)}function D(){if(y=0,b=0,M.length>3){let e=M[0],t=M[M.length-1];if(e&&t){let n=t.x-e.x,o=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,b=Math.abs(o)>3?o/(i/30):0)}}}function z(e){if(e instanceof MouseEvent){if(S)return}else S=!0;let t=e.composedPath()[0],o=a.ignore.join(",");if(t.matches(o)||t.closest(o)||"undefined"!=typeof MouseEvent&&e instanceof MouseEvent&&(!e.buttons||0!==e.button))return;e instanceof MouseEvent&&k(e);let g=Date.now(),m=g-(d||g);f=m>0&&m<=250,d=g,clearTimeout(w),i=e,e instanceof MouseEvent&&(window.addEventListener("mousemove",Y),window.addEventListener("mouseup",X)),window.addEventListener("blur",_),r=[...l=E(e)],s=[],h=l.length,n=L(l),1===h&&(c=!1,u=!1),h&&Z(L(l)),I("start")}function Y(e){if(!r.length||e.defaultPrevented)return;i=e,s=[...l],h=(l=E(e)).length;let t=n=L(l),u=L(s);if(g=t.x-u.x,m=t.y-u.y,Z(t),D(),I("move"),l.length>1&&Math.abs(C(l)-C(s))>=.1&&I("pinch"),!c&&r.length){let e=L(r);p=t.x-e.x,v=t.y-e.y,(c=Math.abs(p)>a.panThreshold||Math.abs(v)>a.panThreshold)&&(O=!1,clearTimeout(P),P=0,o=(x=Math.abs(180*Math.atan2(v,p)/Math.PI))>45&&x<135?"y":"x",r=[...l],s=[...l],window.getSelection()?.removeAllRanges(),I("panstart"))}c&&(g||m)&&I("pan")}function X(e){if(i=e,!r.length)return;let t=E(e),o=T(e);if(h=t.length,n=L(o),o.length&&Z(L(o)),D(),s=[...l],l=[...t],r=[...t],t.length>0)I("end"),c=!1,u=!1,M=[];else{let e=a.swipeThreshold;(Math.abs(y)>e||Math.abs(b)>e)&&(u=!0),c&&I("panend"),u&&I("swipe"),c||u||(I("tap"),f?I("doubleTap"):w=setTimeout(function(){I("singleTap")},250)),I("end"),H()}}function _(){clearTimeout(w),H(),c&&I("panend"),I("end")}function H(){c=!1,u=!1,f=!1,h=0,M=[],l=[],s=[],r=[],g=0,m=0,p=0,v=0,y=0,b=0,x=0,o=void 0,window.removeEventListener("mousemove",Y),window.removeEventListener("mouseup",X),window.removeEventListener("blur",_),O||P||(P=setTimeout(()=>{O=!0,P=0},100))}function $(e){let t=e.target;S=!1,t&&!e.defaultPrevented&&(O||(k(e),e.stopPropagation()))}let j={init:function(){if(e)return e.addEventListener("click",$,A),e.addEventListener("mousedown",z,A),e.addEventListener("touchstart",z,A),e.addEventListener("touchmove",Y,A),e.addEventListener("touchend",X),e.addEventListener("touchcancel",X),j},on:function(e,t){return F.set(e,[...F.get(e)||[],t]),j},off:function(e,t){return F.has(e)&&F.set(e,F.get(e).filter(e=>e!==t)),j},isPointerDown:()=>h>0,destroy:function(){clearTimeout(w),clearTimeout(P),P=0,e&&(e.removeEventListener("click",$,A),e.removeEventListener("mousedown",z,A),e.removeEventListener("touchstart",z,A),e.removeEventListener("touchmove",Y,A),e.removeEventListener("touchend",X),e.removeEventListener("touchcancel",X)),e=null,H()}};return j};P.isClickAllowed=()=>O;let F={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"},I=(e,t="")=>{e&&e.classList&&t.split(" ").forEach(t=>{t&&e.classList.add(t)})},Z=(e,t="")=>{e&&e.classList&&t.split(" ").forEach(t=>{t&&e.classList.remove(t)})},D=(e,t="",n)=>{e&&e.classList&&t.split(" ").forEach(t=>{t&&e.classList.toggle(t,n||!1)})},z=1e4,Y=e=>{e.cancelable&&e.preventDefault()},X=(e,t=z)=>Math.round(((e=parseFloat(e+"")||0)+Number.EPSILON)*t)/t,_=((g={}).Reset="reset",g.Zoom="zoom",g.ZoomIn="zoomIn",g.ZoomOut="zoomOut",g.ZoomTo="zoomTo",g.ToggleCover="toggleCover",g.ToggleFull="toggleFull",g.ToggleMax="toggleMax",g.IterateZoom="iterateZoom",g.Pan="pan",g.Swipe="swipe",g.Move="move",g.MoveLeft="moveLeft",g.MoveRight="moveRight",g.MoveUp="moveUp",g.MoveDown="moveDown",g.RotateCCW="rotateCCW",g.RotateCW="rotateCW",g.FlipX="flipX",g.FlipY="flipY",g),H=((m={}).Cover="cover",m.Full="full",m.Max="max",m),$={x:0,y:0,scale:1,angle:0,flipX:1,flipY:1},j=((p={})[p.Init=0]="Init",p[p.Loading=1]="Loading",p[p.Error=2]="Error",p[p.Ready=3]="Ready",p[p.Destroyed=4]="Destroyed",p),q={bounds:!0,classes:{container:"f-panzoom",wrapper:"f-panzoom__wrapper",content:"f-panzoom__content",viewport:"f-panzoom__viewport"},clickAction:_.ToggleFull,dblClickAction:!1,gestures:{},height:"auto",l10n:F,maxScale:4,minScale:1,mouseMoveFactor:1,panMode:"drag",protected:!1,singleClickAction:!1,spinnerTpl:'<div class="f-spinner"></div>',wheelAction:_.Zoom,width:"auto"},W=0,V=0,N=0,U=(e,n={},r={})=>{let l,s,c,u,f,d,h,g,m=j.Init,p={...q,...n},v={},y={...$},b={...$},x=[];function M(e){let t=p[e];return t&&"function"==typeof t?t(eb):t}function E(){return e&&e.parentElement&&l&&m===j.Ready}let C=new Map;function k(e,...t){let n=[...C.get(e)||[]];for(let o of(p.on&&n.push(p.on[e]),n))o&&o instanceof Function&&o(eb,...t);"*"!==e&&k("*",e,...t)}function A(e){if(!E()||o(e.target))return;let t=Date.now(),n=a(-1,[-e.deltaX||0,-e.deltaY||0,-e.detail||0].reduce(function(e,t){return Math.abs(t)>Math.abs(e)?t:e}),1);k("wheel",e,n);let i=M("wheelAction");if(!i||e.defaultPrevented)return;let r=b.scale,l=r*(n>0?1.5:.5);if(i===_.Zoom){let o=100>Math.abs(e.deltaY)&&100>Math.abs(e.deltaX);if(t-V<(o?200:45))return void Y(e);V=t;let i=ee(),s=ei();if(X(l)<X(i)&&X(r)<=X(i)?(N+=Math.abs(n),l=i):X(l)>X(s)&&X(r)>=X(s)?(N+=Math.abs(n),l=s):(N=0,l=a(i,l,s)),N>7)return}switch(Y(e),i){case _.Pan:es(i,{srcEvent:e,deltaX:-(2*e.deltaX),deltaY:-(2*e.deltaY)});break;case _.Zoom:es(_.ZoomTo,{srcEvent:e,scale:l,center:{x:e.clientX,y:e.clientY}});break;default:es(i,{srcEvent:e})}}function R(n){let o=n.composedPath()[0];if(!P.isClickAllowed()||!(o&&null!==o&&o instanceof Element&&"nodeType"in o)||n.defaultPrevented||!e?.contains(o)||o.hasAttribute("disabled")||o.hasAttribute("aria-disabled"))return;let i=o.closest("[data-panzoom-action]"),a=i?.dataset?.panzoomAction,r=i?.dataset?.panzoomValue||"";if(a){switch(a){case _.ZoomTo:case _.ZoomIn:case _.ZoomOut:es(a,{scale:parseFloat(r||"")||void 0});break;case _.MoveLeft:case _.MoveRight:es(a,{deltaX:parseFloat(r||"")||void 0});break;case _.MoveUp:case _.MoveDown:es(a,{deltaY:parseFloat(r||"")||void 0});break;default:es(a)}return}if(!l?.contains(o))return;let s={srcEvent:n};if(es(M("clickAction"),s),M("dblClickAction")){let e=Date.now(),n=e-(W||e);W=e,n>0&&n<=250?(t&&(clearTimeout(t),t=void 0),es(M("dblClickAction"),s)):t=setTimeout(()=>{es(M("singleClickAction"),s)},250)}}function S(e){if(g=e,!E()||!J()||y.scale<=1||b.scale<=1||(l?.dataset.animationName||"").indexOf("zoom")>-1)return;let t=K(b.scale);if(!t)return;let{x:n,y:o}=t;es(_.Pan,{deltaX:n-b.x,deltaY:o-b.y})}function O(){e&&(Z(e,"is-loading"),e.querySelector(".f-spinner")?.remove())}function F(){if(!e||!s)return;if(O(),s instanceof HTMLImageElement&&!(s.complete&&s.naturalWidth)){m=j.Error,l?.classList.add("has-error"),k("error");return}k("loaded");let{width:t,height:n}=B();s instanceof HTMLImageElement&&(s.setAttribute("width",t+""),s.setAttribute("height",n+"")),l&&(Z(l,"has-error"),s instanceof HTMLImageElement&&(l.setAttribute("width",t+""),l.setAttribute("height",n+""),l.style.aspectRatio=`${t/n||""}`)),d=w().on("start",(e,t)=>{b={...$,...t},void 0!==t.angle&&(t.angle=90*Math.round(t.angle/90)),void 0!==t.flipX&&(t.flipX=t.flipX>0?1:-1),void 0!==t.flipY&&(t.flipY=t.flipY>0?1:-1),el(),k("animationStart")}).on("pause",e=>{b={...$,...e}}).on("step",e=>{if(!E())return void d?.end();if(y={...$,...e},J()||!M("bounds")||ep()||b.scale>y.scale||b.scale<et())return void ec();let t=ea(b.scale),n=!1,o=!1,i=!1,r=!1;y.x<t.x[0]&&(n=!0),y.x>t.x[1]&&(o=!0),y.y<t.y[0]&&(r=!0),y.y>t.y[1]&&(i=!0);let l=!1,s=!1,c=!1,u=!1;b.x<t.x[0]&&(l=!0),b.x>t.x[1]&&(s=!0),b.y<t.y[0]&&(u=!0),b.y>t.y[1]&&(c=!0);let f=!1;(o&&s||n&&l)&&(b.x=a(t.x[0],b.x,t.x[1]),f=!0),(i&&c||r&&u)&&(b.y=a(t.y[0],b.y,t.y[1]),f=!0),f&&d&&d.spring({tension:94,friction:17,maxSpeed:555*b.scale,restDelta:.1,restSpeed:.1,velocity:d.getCurrentVelocities()}).from(y).to(b).start(),ec()}).on("end",()=>{er(),d?.isRunning()||(el(),k("animationEnd"))}),function(){let e=M("gestures");e&&u&&s&&(f=P(u,e).on("start",e=>{if(!d)return;let t=e.srcEvent;J()||((y.scale>1||e.currentTouch.length>1)&&(t?.stopPropagation(),d.pause()),1===e.currentTouch.length&&k("touchStart"))}).on("move",e=>{!J()&&(1!==b.scale||e.currentTouch.length>1)&&(e.srcEvent.preventDefault(),e.srcEvent.stopPropagation())}).on("pan",e=>{if(!E()||J())return;let t=e.srcEvent;(1!==b.scale||e.currentTouch.length>1)&&(Y(t),es(_.Pan,e))}).on("swipe",e=>{!(!E()||J())&&b.scale>1&&es(_.Swipe,e)}).on("tap",e=>{k("click",e)}).on("singleTap",e=>{k("singleClick",e)}).on("doubleTap",e=>{k("dblClick",e)}).on("pinch",e=>{J()||(e.scale>et()?es(_.ZoomIn,e):e.scale<et()?es(_.ZoomOut,e):es(_.Pan,e))}).on("end",e=>{J()||(e.currentTouch.length?(e.srcEvent.stopPropagation(),Y(e.srcEvent),d?.end()):(el(),er(),k("touchEnd")))}).init())}(),u&&(u.addEventListener("wheel",A,{passive:!1}),x.push(()=>{u?.removeEventListener("wheel",A,{passive:!1})})),e?.addEventListener("click",R),document?.addEventListener("mousemove",S),x.push(()=>{e?.removeEventListener("click",R),document?.removeEventListener("mousemove",S)});let o=H();y={...o},b={...o},m=j.Ready,ec(),el(),k("ready"),requestAnimationFrame(()=>{O(),u&&(u.style.visibility="")})}function H(){let e={...M("startPos")||{}},t=e.scale,n=1;n="string"==typeof t?Q(t):"number"==typeof t?t:et();let o={...$,...e,scale:n},i=J()?K(n):void 0;if(i){let{x:e,y:t}=i;o.x=e,o.y=t}return o}function U(){let e={top:0,left:0,width:0,height:0};if(l){let t=l.getBoundingClientRect();b.angle%180==90?(e.top=t.top+.5*t.height-.5*t.width,e.left=t.left+.5*t.width-.5*t.height,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 B(){let e=M("width"),t=M("height");if(s&&"auto"===e){let t=s.getAttribute("width");e=t?parseFloat(t+""):void 0!==s.dataset.width?parseFloat(s.dataset.width+""):u instanceof HTMLImageElement?u.naturalWidth:s instanceof HTMLImageElement?s.naturalWidth:s.getBoundingClientRect().width}else e="string"==typeof e?parseFloat(e):e;if(s&&"auto"===t){let e=s.getAttribute("height");t=e?parseFloat(e+""):void 0!==s.dataset.height?parseFloat(s.dataset.height+""):u instanceof HTMLImageElement?u.naturalHeight:s instanceof HTMLImageElement?s.naturalHeight:s.getBoundingClientRect().height}else t="string"==typeof t?parseFloat(t):t;return{width:e,height:t}}function G(){let e=U();return{width:e.width,height:e.height}}function J(){return"mousemove"===M("panMode")&&matchMedia("(hover: hover)").matches}function K(e){let t=g||M("event"),n=l?.getBoundingClientRect();if(!t||!n||e<=1)return{x:0,y:0};let o=(t.clientX||0)-n.left,i=(t.clientY||0)-n.top,{width:r,height:s}=G(),c=ea(e);if(e>1){let t=M("mouseMoveFactor");t>1&&(e*=t)}let u=r*e,f=s*e,d=(u-r)*.5-o/r*100/100*(u-r),h=(f-s)*.5-i/s*100/100*(f-s);return{x:d=a(c.x[0],d,c.x[1]),y:h=a(c.y[0],h,c.y[1])}}function Q(t="base"){if(!e)return 1;let n=e.getBoundingClientRect(),o=U(),{width:i,height:r}=B(),l=e=>{if("number"==typeof e)return e;switch(e){case"min":case"base":return 1;case"cover":return Math.max(n.height/o.height,n.width/o.width)||1;case"full":case"max":{let e=b.angle%180==90?r:i;return e&&o.width?e/o.width:1}}},s=M("minScale"),c=M("maxScale"),u=Math.min(l("full"),l(s)),f="number"==typeof c?l("full")*c:Math.min(l("full"),l(c));switch(t){case"min":return u;case"base":return a(u,1,f);case"cover":return l("cover");case"full":return Math.min(f,l("full"));case"max":return f}}function ee(){return Q("min")}function et(){return Q("base")}function en(){return Q("cover")}function eo(){return Q("full")}function ei(){return Q("max")}function ea(t){let n={x:[0,0],y:[0,0]},o=e?.getBoundingClientRect();if(!o)return n;let i=U(),a=o.width,r=o.height,l=i.width,s=i.height,c=t=void 0===t?b.scale:t,u=t;if(J()&&t>1){let e=M("mouseMoveFactor");e>1&&(l*t>a+.01&&(c*=e),s*t>r+.01&&(u*=e))}return l*=c,s*=u,t>1&&(l>a&&(n.x[0]=(a-l)*.5,n.x[1]=(l-a)*.5),n.x[0]-=(i.left-o.left)*.5,n.x[1]-=(i.left-o.left)*.5,n.x[0]-=(i.left+i.width-o.right)*.5,n.x[1]-=(i.left+i.width-o.right)*.5,s>r&&(n.y[0]=(r-s)*.5,n.y[1]=(s-r)*.5),n.y[0]-=(i.top-o.top)*.5,n.y[1]-=(i.top-o.top)*.5,n.y[0]-=(i.top+i.height-o.bottom)*.5,n.y[1]-=(i.top+i.height-o.bottom)*.5),n}function er(){if(!E()||!M("bounds")||!d)return;let e=ee(),t=ei(),n=a(e,b.scale,t);if(b.scale<e-.01||b.scale>t+.01)return void es(_.ZoomTo,{scale:n});if(d.isRunning()||ep())return;let o=ea(n);b.x<o.x[0]||b.x>o.x[1]||b.y<o.y[0]||b.y>o.y[1]?(b.x=a(o.x[0],b.x,o.x[1]),b.y=a(o.y[0],b.y,o.y[1]),d.spring({tension:170,friction:17,restDelta:.001,restSpeed:.001,maxSpeed:1/0,velocity:d.getCurrentVelocities()}),d.from(y).to(b).start()):ec()}function el(){if(!E())return;let t=em(),n=ep(),o=ev(),i=ey(),a=ef(),r=ed();D(l,"is-fullsize",i),D(l,"is-expanded",o),D(l,"is-dragging",n),D(l,"can-drag",t),D(l,"will-zoom-in",a),D(l,"will-zoom-out",r);let s=eh(),c=eg(),u=!E();for(let t of e?.querySelectorAll("[data-panzoom-action]")||[]){let e=t.dataset.panzoomAction,n=!1;if(u)n=!0;else switch(e){case _.ZoomIn:s||(n=!0);break;case _.ZoomOut:c||(n=!0);break;case _.ToggleFull:s||c||(n=!0);let o=t.querySelector("g");o&&(o.style.display=i?"none":"");break;case _.ToggleCover:case _.ToggleMax:s||c||(n=!0)}n?(t.setAttribute("aria-disabled",""),t.setAttribute("tabindex","-1")):(t.removeAttribute("aria-disabled"),t.removeAttribute("tabindex"))}}function es(t,n){if(!e||!s||!d||t===_.Swipe&&Math.abs(d.getCurrentVelocities().scale)>.01)return;let o={...b},i=ea(J()?b.scale:y.scale),r=d.getCurrentVelocities(),l=U();n=n||{};let c=(n.currentTouch?.length||0)>1,u=n.velocityX||0,f=n.velocityY||0,h=n.center;!h&&n.srcEvent&&(h=L(T(n.srcEvent)));let g=n.deltaX||0,m=n.deltaY||0;switch(t){case _.MoveRight:g=n.deltaX||100;break;case _.MoveLeft:g=n.deltaX||-100;break;case _.MoveUp:m=n.deltaY||-100;break;case _.MoveDown:m=n.deltaY||100}let p=[];switch(t){case _.Reset:(b={...$}).scale=et();break;case _.Pan:case _.Move:case _.MoveLeft:case _.MoveRight:case _.MoveUp:case _.MoveDown:if(ep()){let e=1,t=1;b.x<=i.x[0]&&u<=0&&(e=.2*Math.max(.01,1-Math.abs(1/l.width*Math.abs(b.x-i.x[0])))),b.x>=i.x[1]&&u>=0&&(e=.2*Math.max(.01,1-Math.abs(1/l.width*Math.abs(b.x-i.x[1])))),b.y<=i.y[0]&&f<=0&&(t=.2*Math.max(.01,1-Math.abs(1/l.height*Math.abs(b.y-i.y[0])))),b.y>=i.y[1]&&f>=0&&(t=.2*Math.max(.01,1-Math.abs(1/l.height*Math.abs(b.y-i.y[1])))),b.x+=g*e,b.y+=m*t}else b.x=a(i.x[0],b.x+g,i.x[1]),b.y=a(i.y[0],b.y+m,i.y[1]);break;case _.Swipe:let v=(e=0)=>Math.sign(e)*Math.pow(Math.abs(e),1.5);b.x+=a(-1e3,v(u),1e3),b.y+=a(-1e3,v(f),1e3),f&&!u&&(b.x=a(i.x[0],b.x,i.x[1])),!f&&u&&(b.y=a(i.y[0],b.y,i.y[1])),r.x=u,r.y=f;break;case _.ZoomTo:b.scale=n.scale||1;break;case _.ZoomIn:b.scale=b.scale*(n.scale||2),c||(b.scale=Math.min(b.scale,ei()));break;case _.ZoomOut:b.scale=b.scale*(n.scale||.5),c||(b.scale=Math.max(b.scale,ee()));break;case _.ToggleCover:p=[et(),en()];break;case _.ToggleFull:p=[et(),eo()];break;case _.ToggleMax:p=[et(),ei()];break;case _.IterateZoom:p=[et(),eo(),ei()];break;case _.Zoom:let x=eo();b.scale>=x-.05?b.scale=et():b.scale=Math.min(x,b.scale*(n.scale||2));break;case _.RotateCW:b.angle+=90;break;case _.RotateCCW:b.angle-=90;break;case _.FlipX:b.flipX*=-1;break;case _.FlipY:b.flipY*=-1}if(void 0!==y.angle&&Math.abs(y.angle)>=360&&(b.angle-=360*Math.floor(y.angle/360),y.angle-=360*Math.floor(y.angle/360)),p.length){let e=p.findIndex(e=>e>b.scale+1/z);b.scale=p[e]||p[0]}if(c&&(b.scale=a(ee()*(c?.8:1),b.scale,ei()*(c?1.6:1))),J()){let e=K(b.scale);if(e){let{x:t,y:n}=e;b.x=t,b.y=n}}else if(b.scale!==o.scale){let t=0,n=0;if(h)t=h.x,n=h.y;else{let o=e.getBoundingClientRect();t=o.x+.5*o.width,n=o.y+.5*o.height}let r=t-l.left,s=n-l.top;r-=.5*l.width,s-=.5*l.height;let u=(r-o.x)/o.scale,f=(s-o.y)/o.scale;b.x=r-u*b.scale,b.y=s-f*b.scale,!c&&M("bounds")&&(i=ea(),b.x=a(i.x[0],b.x,i.x[1]),b.y=a(i.y[0],b.y,i.y[1]))}if(t===_.Swipe){let e=500*b.scale;d.spring({tension:94,friction:17,maxSpeed:e,restDelta:.1,restSpeed:.1,velocity:r})}else t===_.Pan||c?d.spring({tension:900,friction:17,restDelta:.01,restSpeed:.01,maxSpeed:1}):d.spring({tension:170,friction:17,restDelta:.001,restSpeed:.001,maxSpeed:1/0,velocity:r});t===_.Reset||0===n.velocity?y={...b}:d.from(y).to(b).start(),k("action",t)}function ec(){if(!s)return;if(l){let{width:e,height:t}=B();l.style.maxWidth=`min(${e}px, 100%)`,l.style.maxHeight=`min(${t}px, 100%)`}let{x:t,y:n,scale:o,angle:i,flipX:a,flipY:r}=y,c=`translate3d(${t}px, ${n}px, 0)`;1!==a||1!==r?c+=` scaleX(${o*a}) scaleY(${o*r})`:1!==o&&(c+=` scale(${o})`),i%360!=0&&(c+=` rotate(${i}deg)`);let f=function(){let{width:t,height:n}=B(),{width:o,height:i}=G();if(!e)return{x:0,y:0,width:0,height:0,scale:0,flipX:0,flipY:0,angle:0,fitWidth:o,fitHeight:i,fullWidth:t,fullHeight:n};let{x:a,y:r,scale:l,angle:s,flipX:c,flipY:u}=y,f=1/eo(),d=t,h=n,g=y.scale*f,m=b.scale*f,p=Math.max(o,i),v=Math.min(o,i);t>n?(d=p,h=v):(d=v,h=p),g=t>n?p*l/t||1:p*l/n||1;let x=d?t*m:0,M=h?n*m:0,w=d&&h?t*g/x:0;return{x:a=a+.5*d-.5*x,y:r=r+.5*h-.5*M,width:x,height:M,scale:w,flipX:c,flipY:u,angle:s,fitWidth:o,fitHeight:i,fullWidth:t,fullHeight:n}}();if(f){let{x:e,y:t,width:n,height:o,scale:a,flipX:r,flipY:l}=f,s=`translate(${X(e)}px, ${X(t)}px)`;1!==r||1!==l?s+=` scaleX(${X(a*r)}) scaleY(${X(a*l)})`:s+=` scale(${X(a)})`,0!==i&&(s+=` rotate(${i}deg)`),u&&(u.style.width=`${X(n)}px`,u.style.height=`${X(o)}px`,u.style.transform=`${s}`)}k("render")}function eu(){let e=b.scale,t=void 0,n=M("clickAction"),o=et();if(n){let i=[];switch(n){case _.ZoomIn:o=e*(t||2);break;case _.ZoomOut:o=e*(t||.5);break;case _.ToggleCover:i=[et(),en()];break;case _.ToggleFull:i=[et(),eo()];break;case _.ToggleMax:i=[et(),ei()];break;case _.IterateZoom:i=[et(),eo(),ei()];break;case _.Zoom:let a=eo();o=e>=a-.05?et():Math.min(a,e*(t||2))}if(i.length){let t=i.findIndex(t=>t>e+1/z);o=i[t]||et()}}return a(ee(),o,ei())}function ef(){return!!(E()&&eu()>b.scale)}function ed(){return!!(E()&&eu()<b.scale)}function eh(){return!!(E()&&b.scale<ei())}function eg(){return!!(E()&&b.scale>ee())}function em(){return!!(E()&&ev()&&f&&!J())}function ep(){return!!(E()&&f?.isPointerDown()&&!J())}function ev(){return!!(E()&&b.scale>et())}function ey(){return!!(E()&&b.scale>=eo())}let eb={canDrag:em,canZoomIn:eh,canZoomOut:eg,destroy:function(){for(let e of(k("destroy"),Object.values(v)))e?.destroy(eb);for(let e of x)e();return l&&(l.style.aspectRatio="",l.style.maxWidth="",l.style.maxHeight=""),u&&(u.style.width="",u.style.height="",u.style.transform=""),l=void 0,s=void 0,u=void 0,y={...$},b={...$},d?.destroy(),d=void 0,f?.destroy(),f=void 0,m=j.Destroyed,eb},emit:k,execute:es,getBoundaries:ea,getContainer:function(){return e},getContent:function(){return s},getFullDim:B,getGestures:function(){return f},getMousemovePos:K,getOptions:function(){return p},getScale:Q,getStartPosition:H,getState:function(){return m},getTransform:function(e){return!0===e?b:y},getTween:function(){return d},getViewport:function(){return u},getWrapper:function(){return l},init:function(){return m=j.Init,k("init"),function(){for(let[e,t]of Object.entries({...r,...p.plugins||{}}))if(e&&!v[e]&&t instanceof Function){let n=t();n.init(eb),v[e]=n}k("initPlugins")}(),function(){let t={...q.classes,...M("classes")};if(e&&(I(e,t.container),s=e.querySelector("."+t.content))){if(s.setAttribute("draggable","false"),(l=e.querySelector("."+t.wrapper))||(I(l=document.createElement("div"),t.wrapper),s.insertAdjacentElement("beforebegin",l),l.insertAdjacentElement("afterbegin",s)),(u=e.querySelector("."+t.viewport))||(I(u=document.createElement("div"),t.viewport),u.insertAdjacentElement("afterbegin",s),l.insertAdjacentElement("beforeend",u)),(c=s.cloneNode(!0)).removeAttribute("id"),l.insertAdjacentElement("afterbegin",c),s instanceof HTMLPictureElement&&(s=s.querySelector("img")),c instanceof HTMLPictureElement&&(c=c.querySelector("img")),u instanceof HTMLPictureElement&&(u=u.querySelector("img")),u&&(u.style.visibility="hidden",M("protected"))){u.addEventListener("contextmenu",e=>{e.preventDefault()});let e=document.createElement("div");I(e,"f-panzoom__protected"),u.appendChild(e)}k("initLayout")}}(),function(){if(e&&l&&!h){let e=null;(h=new ResizeObserver(()=>{E()&&(e=e||requestAnimationFrame(()=>{E()&&(el(),er(),k("refresh")),e=null}))})).observe(l),x.push(()=>{h?.disconnect(),h=void 0,e&&(cancelAnimationFrame(e),e=null)})}}(),function(){if(!e||!s)return;if(!(s instanceof HTMLImageElement&&c instanceof HTMLImageElement))return F();let t=()=>{s&&s instanceof HTMLImageElement&&s.decode().then(()=>{F()}).catch(()=>{F()})};if(m=j.Loading,e.classList.add("is-loading"),k("loading"),c.src&&c.complete)return t();(function(){if(!e||e?.querySelector(".f-spinner"))return;let t=i(M("spinnerTpl"));t&&(t.classList.add("f-spinner"),e.classList.add("is-loading"),l?.insertAdjacentElement("afterbegin",t))})(),c.addEventListener("load",t,!1),c.addEventListener("error",t,!1),x.push(()=>{c?.removeEventListener("load",t,!1),c?.removeEventListener("error",t,!1)})}(),eb},isDragging:ep,isExpanded:ev,isFullsize:ey,localize:function(e,t=[]){let n=M("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.replace(/\{\{(.*?)\}\}/g,(e,t)=>t)},off:function(e,t){for(let n of e instanceof Array?e:[e])C.has(n)&&C.set(n,C.get(n).filter(e=>e!==t));return eb},on:function(e,t){for(let n of e instanceof Array?e:[e])C.set(n,[...C.get(n)||[],t]);return eb},version:"6.0.29",willZoomIn:ef,willZoomOut:ed};return eb};U.l10n={en_EN:F},U.getDefaults=()=>q,e.PANZOOM_DEFAULT_POS=$,e.Panzoom=U,e.PanzoomAction=_,e.PanzoomState=j,e.PanzoomZoomLevel=H});