@fancyapps/ui
Version:
Robust JavaScript UI Component Library
1 lines • 28.7 kB
JavaScript
!/*! 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=e=>"object"==typeof e&&null!==e&&e.constructor===Object&&"[object Object]"===Object.prototype.toString.call(e),i=e=>e&&null!==e&&e instanceof Element&&"nodeType"in e,o=function(e){if(!(e&&e instanceof Element&&e.offsetParent))return!1;let t=e.scrollHeight>e.clientHeight,n=window.getComputedStyle(e).overflowY,i=-1!==n.indexOf("hidden"),o=-1!==n.indexOf("visible");return t&&!i&&!o},r=function(e,t){return!e||e===document.body||t&&e===t?null:o(e)?e:r(e.parentElement,t)},l=(e,t)=>{let n=[];return e.childNodes.forEach(e=>{e.nodeType===Node.ELEMENT_NODE&&(!t||e.matches(t))&&n.push(e)}),n},s=(e,...t)=>{let i=t.length;for(let o=0;o<i;o++)Object.entries(t[o]||{}).forEach(([t,i])=>{let o=Array.isArray(i)?[]:{};e[t]||Object.assign(e,{[t]:o}),n(i)?Object.assign(e[t],s(o,i)):Array.isArray(i)?Object.assign(e,{[t]:[...i]}):Object.assign(e,{[t]:i})});return e},a=function(e=0,t=0,n=0){return Math.max(Math.min(t,n),e)},u=function(e=0,t=0,n=0,i=0,o=0,r=!1){let l=(e-t)/(n-t)*(o-i)+i;return r?i<o?a(i,l,o):a(o,l,i):l},f=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 i=t.firstChild;if(i&&!(i instanceof HTMLElement)){var n=document.createElement("div");return n.appendChild(i),n}return i},d=(e,t="")=>{e&&e.classList&&t.split(" ").forEach(t=>{t&&e.classList.add(t)})},c=(e,t="")=>{e&&e.classList&&t.split(" ").forEach(t=>{t&&e.classList.remove(t)})},p=(e,t="",n)=>{e&&e.classList&&t.split(" ").forEach(t=>{t&&e.classList.toggle(t,n||!1)})};function g(e){return n(e)||Array.isArray(e)}function h(e,t){let n=Object.keys(e),i=Object.keys(t);return n.length===i.length&&n.every(n=>{let i=e[n],o=t[n];return"function"==typeof i?`${i}`==`${o}`:g(i)&&g(o)?h(i,o):i===o})}let m=1/60*3e3,v=function(e){for(let t of S)t.getState()===E.Running&&t.tick(R?e-R:0);R=e,O=window.requestAnimationFrame(v)},E=((y={})[y.Initializing=0]="Initializing",y[y.Running=1]="Running",y[y.Paused=2]="Paused",y[y.Completed=3]="Completed",y[y.Destroyed=4]="Destroyed",y);var y,b,M,w,L,T=((b=T||{})[b.Spring=0]="Spring",b[b.Ease=1]="Ease",b);let x=((M={})[M.Loop=0]="Loop",M[M.Reverse=1]="Reverse",M),S=new Set,O=null,R=0;function P(){let e=E.Initializing,t=T.Ease,n=0,i=0,o=P.Easings.Linear,r=500,l=0,s=0,u=0,f=0,d=1/0,c=.01,p=.01,g=!1,y={},b=null,M={},w={},L={},R=0,A=0,C=x.Loop,D=P.Easings.Linear,I=new Map;function V(e,...t){for(let n of I.get(e)||[])n(...t)}function j(e){return i=0,e?b=setTimeout(()=>{H()},e):H(),_}function H(){e=E.Running,V("start",M,w)}function z(){if(e=E.Completed,L={},V("end",M),e===E.Completed)if(n<R){if(n++,C===x.Reverse){let e={...y};y={...w},w=e}j(A)}else n=0;return _}let _={getState:function(){return e},easing:function(e){return o=e,t=T.Ease,L={},_},duration:function(e){return r=e,_},spring:function(e={}){t=T.Spring;let{velocity:n,mass:i,tension:o,friction:r,restDelta:a,restSpeed:h,maxSpeed:m,clamp:v}={velocity:0,mass:1,tension:170,friction:26,restDelta:.1,restSpeed:.1,maxSpeed:1/0,clamp:!0,...e};return l=n,s=i,u=o,f=r,p=a,c=h,d=m,g=v,L={},_},isRunning:function(){return e===E.Running},isSpring:function(){return t===T.Spring},from:function(e){return M={...e},_},to:function(e){return w=e,_},repeat:function(e,t=0,n=x.Loop,i){return R=e,A=t,C=n,D=i||o,_},on:function(e,t){return I.set(e,[...I.get(e)||[],t]),_},off:function(e,t){return I.has(e)&&I.set(e,I.get(e).filter(e=>e!==t)),_},start:function(t){return e=E.Initializing,h(y={...M},w)||(S.add(this),O||(O=window.requestAnimationFrame(v)),j(t)),_},pause:function(){return b&&(clearTimeout(b),b=null),e===E.Running&&(e=E.Paused,V("pause",M)),_},end:z,tick:function(n){n>m&&(n=m),i+=n;let v=0,b=!1;if(e!==E.Running)return _;if(t===T.Ease){b=1===(v=a(0,i/r,1));let e=C===x.Reverse?D:o;for(let t in M)M[t]=y[t]+(w[t]-y[t])*e(v)}if(t===T.Spring){let e=.001*n,t=0;for(let n in M){let i=w[n],o=M[n];if(!("number"==typeof i&&!isNaN(i))||!("number"==typeof o&&!isNaN(o)))continue;if(Math.abs(i-o)<=p){M[n]=i,L[n]=0;continue}L[n]||("object"==typeof l&&"number"==typeof l[n]?L[n]=l[n]:"number"==typeof l?L[n]=l:L[n]=0);let r=L[n],h=(r=a(-1*Math.abs(d),r,Math.abs(d)))*s*f,m=Math.abs(i-o)*u;r+=((o>i?-1:1)*m-h)/s*e,o+=r*e;let v=M[n]>i?o<i:o>i,E=Math.abs(r)<c&&Math.abs(i-o)<=p;g&&v&&(E=!0),E?(o=i,r=0):t++,M[n]=o,L[n]=r}b=!t}let S={...w};return V("step",M,y,w,v),b&&e===E.Running&&h(w,S)&&(e=E.Completed,z()),_},getStartValues:function(){return y},getCurrentValues:function(){return M},getCurrentVelocities:function(){return L},getEndValues:function(){return w},destroy:function(){e=E.Destroyed,b&&(clearTimeout(b),b=null),y=M=w={},S.delete(this)}};return _}function A(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 C(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 D(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}P.destroy=()=>{for(let e of S)e.destroy();O&&(cancelAnimationFrame(O),O=null)},P.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 I=e=>{e.cancelable&&e.preventDefault()},V={passive:!1},j={panThreshold:5,swipeThreshold:3,ignore:["textarea","input","select","[contenteditable]","[data-selectable]","[data-draggable]"]},H=!1,z=!0,_=(e,t)=>{let n,i,o,r={...j,...t},l=[],s=[],a=[],u=!1,f=!1,d=!1,c=0,p=0,g=0,h=0,m=0,v=0,E=0,y=0,b=0,M=[],w=0,L=0,T=new Map;function x(e){let t=D(s),r=D(a),d=Math.abs(E)>Math.abs(y)?E:y,c={srcEvent:o,isPanRecognized:u,isSwipeRecognized:f,firstTouch:l,previousTouch:a,currentTouch:s,deltaX:g,deltaY:h,offsetX:m,offsetY:v,velocityX:E,velocityY:y,velocity:d,angle:b,axis:i,scale:t&&r?t/r:0,center:n};for(let t of T.get(e)||[])t(c)}function S(e){let t=Date.now();M=M.filter(e=>!e.ts||e.ts>t-100),e&&M.push(e)}function O(){if(E=0,y=0,M.length>3){let e=M[0],t=M[M.length-1];if(e&&t){let n=t.x-e.x,i=t.y-e.y,o=e.ts&&t.ts?t.ts-e.ts:0;o>0&&(E=Math.abs(n)>3?n/(o/30):0,y=Math.abs(i)>3?i/(o/30):0)}}}function R(e){if(e instanceof MouseEvent){if(H)return}else H=!0;let t=e.composedPath()[0],i=r.ignore.join(",");if(t.matches(i)||t.closest(i)||"undefined"!=typeof MouseEvent&&e instanceof MouseEvent&&(!e.buttons||0!==e.button))return;e instanceof MouseEvent&&I(e);let g=Date.now(),h=g-(c||g);d=h>0&&h<=250,c=g,clearTimeout(w),o=e,e instanceof MouseEvent&&(window.addEventListener("mousemove",P),window.addEventListener("mouseup",_)),window.addEventListener("blur",F),l=[...s=A(e)],a=[],p=s.length,n=C(s),1===p&&(u=!1,f=!1),p&&S(C(s)),x("start")}function P(e){if(!l.length||e.defaultPrevented)return;o=e,a=[...s],p=(s=A(e)).length;let t=n=C(s),f=C(a);if(g=t.x-f.x,h=t.y-f.y,S(t),O(),x("move"),s.length>1&&Math.abs(D(s)-D(a))>=.1&&x("pinch"),!u&&l.length){let e=C(l);m=t.x-e.x,v=t.y-e.y,(u=Math.abs(m)>r.panThreshold||Math.abs(v)>r.panThreshold)&&(z=!1,clearTimeout(L),L=0,i=(b=Math.abs(180*Math.atan2(v,m)/Math.PI))>45&&b<135?"y":"x",l=[...s],a=[...s],window.getSelection()?.removeAllRanges(),x("panstart"))}u&&(g||h)&&x("pan")}function _(e){if(o=e,!l.length)return;let t=A(e),i=function(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}(e);if(p=t.length,n=C(i),i.length&&S(C(i)),O(),a=[...s],s=[...t],l=[...t],t.length>0)x("end"),u=!1,f=!1,M=[];else{let e=r.swipeThreshold;(Math.abs(E)>e||Math.abs(y)>e)&&(f=!0),u&&x("panend"),f&&x("swipe"),u||f||(x("tap"),d?x("doubleTap"):w=setTimeout(function(){x("singleTap")},250)),x("end"),N()}}function F(){clearTimeout(w),N(),u&&x("panend"),x("end")}function N(){u=!1,f=!1,d=!1,p=0,M=[],s=[],a=[],l=[],g=0,h=0,m=0,v=0,E=0,y=0,b=0,i=void 0,window.removeEventListener("mousemove",P),window.removeEventListener("mouseup",_),window.removeEventListener("blur",F),z||L||(L=setTimeout(()=>{z=!0,L=0},100))}function G(e){let t=e.target;H=!1,t&&!e.defaultPrevented&&(z||(I(e),e.stopPropagation()))}let $={init:function(){if(e)return e.addEventListener("click",G,V),e.addEventListener("mousedown",R,V),e.addEventListener("touchstart",R,V),e.addEventListener("touchmove",P,V),e.addEventListener("touchend",_),e.addEventListener("touchcancel",_),$},on:function(e,t){return T.set(e,[...T.get(e)||[],t]),$},off:function(e,t){return T.has(e)&&T.set(e,T.get(e).filter(e=>e!==t)),$},isPointerDown:()=>p>0,destroy:function(){clearTimeout(w),clearTimeout(L),L=0,e&&(e.removeEventListener("click",G,V),e.removeEventListener("mousedown",R,V),e.removeEventListener("touchstart",R,V),e.removeEventListener("touchmove",P,V),e.removeEventListener("touchend",_),e.removeEventListener("touchcancel",_)),e=null,N()}};return $};_.isClickAllowed=()=>z;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",ERROR:"Something went wrong. <br /> Please try again later.",NEXT:"Next page",PREV:"Previous page",GOTO:"Go to page #%d",DOWNLOAD:"Download",TOGGLE_FULLSCREEN:"Toggle full-screen mode",TOGGLE_EXPAND:"Toggle full-size mode",TOGGLE_THUMBS:"Toggle thumbnails",TOGGLE_AUTOPLAY:"Toggle slideshow"},N=e=>{e.cancelable&&e.preventDefault()},G=((w={})[w.Init=0]="Init",w[w.Ready=1]="Ready",w[w.Destroyed=2]="Destroyed",w),$=((L={})[L.Loading=0]="Loading",L[L.Loaded=1]="Loaded",L[L.Error=2]="Error",L),k={adaptiveHeight:!1,center:!0,classes:{container:"f-carousel",isEnabled:"is-enabled",isLTR:"is-ltr",isRTL:"is-rtl",isHorizontal:"is-horizontal",isVertical:"is-vertical",hasAdaptiveHeight:"has-adaptive-height",viewport:"f-carousel__viewport",slide:"f-carousel__slide",isSelected:"is-selected"},dragFree:!1,enabled:!0,errorTpl:'<div class="f-html">{{ERROR}}</div>',fill:!1,infinite:!0,initialPage:0,l10n:F,rtl:!1,slides:[],slidesPerPage:"auto",spinnerTpl:'<div class="f-spinner"></div>',transition:"fade",tween:{clamp:!0,mass:1,tension:200,friction:25,restDelta:1,restSpeed:1,velocity:0},vertical:!1},q=0,B=(e,o={},g={})=>{let h,m,v,E,y;q++;let b=G.Init,M={...k},w={...k},L={},T=null,x=null,S=!1,O=!1,R=!1,A=!1,C="height",D=0,I=!0,V=0,j=0,H=0,z=0,F="*",$=[],U=[],X=new Set,Y=[],Z=[],W=0,J=0;function K(e,...t){let n=w[e];return n&&n instanceof Function?n(eP,...t):n}function Q(e,t=[]){let n=K("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)}let ee=new Map;function et(e,...t){let n=ee.get(e)||[];for(let i of(w.on&&n.push(w.on[e]),n))i&&i instanceof Function&&i(eP,...t);"*"!==e&&et("*",e,...t)}function en(){let e=s({},k,M);s(e,k,M);let t="",i=M.breakpoints||{};if(i)for(let[n,o]of Object.entries(i))window.matchMedia(n).matches&&(t+=n,s(e,o));if(void 0===y||t!==y){if(y=t,b!==G.Init){let t=Z[V]?.slides[0]?.index;for(let n of(void 0===t&&(t=w.initialSlide),e.initialSlide=t,e.slides=[],$))n.isVirtual&&e.slides.push(n)}eR(),!1!==(w=e).enabled&&(b=G.Init,et("init"),function(){for(let[e,t]of Object.entries({...g,...w.plugins||{}}))if(e&&!L[e]&&t instanceof Function){let n=t();n.init(eP,B),L[e]=n}et("initPlugins")}(),function(){if(!T)return;let e=K("classes")||{};d(T,e.container),d(T,e.isEnabled);let t=K("style");if(t&&n(t))for(let[e,n]of Object.entries(t))T.style.setProperty(e,n);(x=T.querySelector(`.${e.viewport}`))||(d(x=document.createElement("div"),e.viewport),x.append(...l(T,`.${e.slide}`)),T.insertAdjacentElement("afterbegin",x)),S="visible"===window.getComputedStyle(x).getPropertyValue("overflow"),T.carousel=eP,et("initLayout")}(),function(){if(!x)return;let e=K("classes")||{};for(let t of($=[],[...l(x,`.${e.slide}`)].forEach(e=>{e.parentElement&&($.push(eg({el:e,isVirtual:!1,...e.dataset||{}})),e.parentElement.removeChild(e))}),ep(K("slides")),$))et("addSlide",t);et("initSlides")}(),m=P().on("start",()=>{I=!1,h&&h.isPointerDown()||(er(),eO())}).on("step",e=>{D=e.pos,eO()}).on("end",e=>{!h?.isPointerDown()&&(D=e.pos,m&&!O&&(D<H||D>z)?m.spring({clamp:!0,mass:1,tension:200,friction:25,velocity:0,restDelta:1,restSpeed:1}).from({pos:D}).to({pos:a(H,D,z)}).start():I||(I=!0,et("settle")))}),function(){let e=K("gestures");x&&!1!==e&&(h=_(x,e).on("start",e=>{if(!m)return;let{srcEvent:t}=e;A&&N(t),m.pause(),m.getCurrentVelocities().pos=0;let n=Z[V]?.slides[0];n&&X.has(n.index)&&n.el&&(D=(n.offset||0)+(function(e){let t=new DOMMatrixReadOnly(window.getComputedStyle(e).transform);return{width:t.m41||0,height:t.m42||0}}(n.el)[C]||0)*(R&&!A?1:-1)),eb(),!O&&(D<H||D>z)&&m.spring({clamp:!0,mass:1,tension:500,friction:25,velocity:m.getCurrentVelocities()?.pos||0,restDelta:1,restSpeed:1}).from({pos:D}).to({pos:a(H,D,z)}).start()}).on("move",e=>{let{srcEvent:t,axis:n}=e,i=e.srcEvent.target;i&&r(i)||(n||(t.stopPropagation(),t.stopImmediatePropagation()),("y"===n&&A||"x"===n&&!A)&&(N(t),t.stopPropagation()))}).on("panstart",e=>{e?.axis===(A?"y":"x")&&d(x,"is-dragging")}).on("panend",()=>{c(x,"is-dragging")}).on("pan",e=>{let{deltaX:t,deltaY:n,currentTouch:i,axis:o}=e;if(!m||i.length>1||"y"===o&&!A||"x"===o&&A)return;let r=R&&!A?1:-1,l=A?n:t,s=m?.isRunning()?m.getEndValues().pos:D,a=1;!O&&(s<=H&&l*r<0?a=.2*Math.max(.01,1-Math.abs(1/ef()*Math.abs(s-H))):s>=z&&l*r>0&&(a=.2*Math.max(.01,1-Math.abs(1/ef()*Math.abs(s-z))))),s+=l*a*r,m.spring({clamp:!0,mass:1,tension:700,friction:25,velocity:m.getCurrentVelocities()?.pos||0,restDelta:1,restSpeed:1}).from({pos:D}).to({pos:s}).start()}).on("end",e=>{let{axis:t,velocityX:n,velocityY:i,currentTouch:o}=e,r=Z.length,l=K("dragFree");if(o.length>0||!m||!r)return;let s=K("vertical")?i:n,u=m?.isRunning()?m.getEndValues().pos:D,f=R&&!A?1:-1;if(u+=s*(l?5:1)*f,!O&&(s*f<=0&&u<H||s*f>=0&&u>z)){let e=0;Math.abs(s)>0&&(e=2*Math.abs(s),e=Math.min(.3*ef(),e)),u=a(H+-1*e,u,z+e),m.spring({clamp:!0,mass:1,tension:380,friction:25,velocity:-1*s,restDelta:1,restSpeed:1}).from({pos:D}).to({pos:u}).start();return}if(l||L.Autoscroll?.isEnabled())return void(Math.abs(s)>10?m.spring({clamp:!0,mass:1,tension:150,friction:25,velocity:-1*s,restDelta:1,restSpeed:1}).from({pos:D}).to({pos:u}).start():m.isRunning()||I||(I=!0,et("settle")));if(!(l||L.Autoscroll?.isEnabled())&&(!(e.offsetX||e.offsetY)||"y"===t&&!A||"x"===t&&A))return void eS(V,{transition:"tween"});let d=ea(u);Math.abs(s)>10&&d===V&&(s>0?d+=R&&!A?1:-1:d+=R&&!A?-1:1),eS(d,{transition:"tween",tween:{tension:160,friction:25,velocity:-1*s}})}).init())}(),eE(),function(){if(T&&(T.addEventListener("click",ew,{passive:!1}),document.addEventListener("mousemove",ei),!v)){let e=null;(v=new ResizeObserver(t=>{e||(e=requestAnimationFrame(()=>{(function(e){if(!T)return;let t=e[0].contentBoxSize[0].blockSize,n=e[0].contentBoxSize[0].inlineSize;if(b===G.Init){W=t,J=n,b=G.Ready,eO(),el(),et("ready");return}if(b!==G.Ready)return;let i=Z.length;eE();let o=T.getBoundingClientRect();if(t=o.height,n=o.width,!(i>1&&(A&&.5>Math.abs(t-W)||!A&&.5>Math.abs(n-J))))W=t,J=n,(!A||t)&&(A||n)&&T&&x&&(i===Z.length&&h?.isPointerDown()||(K("dragFree")&&(O||D>H&&D<z)?(er(),eO()):eS(V,{transition:!1})))})(t),e=null}))})).observe(T)}}())}}function ei(e){t=e}function eo(e="*"){let t=[];for(let n of $)("*"===e||n.class&&n.class.includes(e)||n.el&&n.el?.classList.contains(e))&&t.push(n);E=void 0,F=e,U=[...t]}function er(){if(!m)return;let e=ea(m?.isRunning()?m.getEndValues().pos:D);e!==V&&(E=V,V=e,ex(),el(),es(),et("change",V,E))}function el(){if(!T)return;for(let e of(p(x,"is-draggable",!!h&&Z.length>0),T.querySelectorAll("[data-carousel-index]")))e.innerHTML=V+"";for(let e of T.querySelectorAll("[data-carousel-page]"))e.innerHTML=V+1+"";for(let e of T.querySelectorAll("[data-carousel-pages]"))e.innerHTML=Z.length+"";let e=!1,t=Z[V]?.slides[0];for(let n of(t&&(t.downloadSrc||"image"===t.type&&t.src)&&(e=!0),T.querySelectorAll("[data-carousel-download]")))n.toggleAttribute("aria-disabled",!e)}function es(e){if(!T)return;e||(e=Z[V]?.slides[0]);let t=e.el;if(t)for(let n of t.querySelectorAll("[data-slide-index]"))n.innerHTML=e.index+1+""}function ea(e){if(!Z.length||!m)return 0;let t=ed(),n=e;O?n-=Math.floor((e-Z[0].pos)/t)*t:n=a(Z[0].pos,e,Z[Z.length-1].pos);let i=new Map,o=0;for(let e of Z){let r=Math.abs(e.pos-n),l=Math.min(r,Math.abs(e.pos-n-t),Math.abs(e.pos-n+t));i.set(o,l),o++}return parseInt((i.size>0?[...i.entries()].reduce((e,t)=>t[1]<e[1]?t:e):[V,0])[0])}function eu(){return x&&parseFloat(getComputedStyle(x).getPropertyValue("--f-carousel-gap"))||0}function ef(){return x&&x.getBoundingClientRect()[C]||0}function ed(e=!0){let t=eu();return U.reduce((e,t)=>e+t.dim,0)+(U.length-(O&&e?0:1))*t}function ec(e){let t=eu(),n=ed(),i=ef();if(!x)return[];let o=[];if(!n||!i)return[];e=void 0===e?D:e,O&&(e-=Math.floor(e/n)*n);let r=0,l=0;if(S){let e=x.getBoundingClientRect();r=e.left,l=e.right-e.width}let s=0;for(let a of U){let u=(t=0)=>{!(o.indexOf(a)>-1)&&(a.pos=s-e+t||0,a.offset+t>e-a.dim-r+.51&&a.offset+t<e+i+l-.51&&o.push(a))};if(a.offset=s,O)for(let e=-1;e<=1;e++)u(n*e);else u();s+=a.dim+t}return o}function ep(e,t){let n=[];for(let t of Array.isArray(e)?e:[e]){let e=eg({...t,isVirtual:!0});n.push(e)}for(let e of($.splice(void 0===t?$.length:t,0,...n),ev(),n))!function(e){if(!e)return;let t=e.el;t||(e.el=t=document.createElement("div"));let n=e.html?e.html instanceof HTMLElement?e.html:f(e.html):void 0;n&&(d(n,"f-html"),e.htmlEl=n,d(t,"has-html"),t.append(n),et("contentReady",e))}(e);return eo(F),n}function eg(e){return("string"==typeof e||e instanceof HTMLElement)&&(e={html:e}),{index:-1,el:void 0,class:"",isVirtual:!0,dim:0,pos:0,offset:0,html:"",src:"",...e}}function eh(e){if(!x||!e)return;let t=e.el;if(t){if(t.setAttribute("index",e.index+""),t.parentElement!==x){let n;for(let i of(d(t,w.classes.slide),d(t,e.class),ex(e),$))if(i.index>e.index){n=i.el;break}x.insertBefore(t,n&&x.contains(n)?n:null),et("attachSlideEl",e)}return t}}function em(e){let t=e?.el;t&&(t.remove(),ey(t),et("detachSlideEl",e))}function ev(){for(let e=0;e<$.length;e++){let t=$[e],n=t.el;n&&(t.index!==e&&ey(n),n.setAttribute("index",`${e}`)),t.index=e}}function eE(){if(!T||!x)return;R=K("rtl"),C=(A=K("vertical"))?"height":"width";let e=K("classes");p(T,e.isLTR,!R),p(T,e.isRTL,R),p(T,e.isHorizontal,!A),p(T,e.isVertical,A),p(T,e.hasAdaptiveHeight,K("adaptiveHeight"));let t=x.getBoundingClientRect();if(!t.width&&!t.height)return;let n=function(){let e=0;if(x){let t=document.createElement("div");d(t,w.classes.slide),x.appendChild(t),e=t.getBoundingClientRect()[C],t.remove(),t=void 0}return e}();for(let e of U){let t=e.el,o=0;if(!e.isVirtual&&t&&i(t)){let e=!1;t.parentElement&&t.parentElement===x||(x.appendChild(t),e=!0),o=t.getBoundingClientRect()[C],e&&t.parentElement?.removeChild(t)}else o=n;e.dim=o}if(!function(){let e;if(!T)return;ev();let t=ef(),n=eu(),i=ed(!1),o=K("slidesPerPage");o="auto"===o?1/0:parseFloat(o+""),Z=[];let r=0,l=0;for(let e of U)(!Z.length||r+e.dim-t>.05||l>=o)&&(Z.push({index:Z.length,slides:[],dim:0,offset:0,pos:0}),r=0,l=0),Z[Z.length-1].slides.push(e),r+=e.dim+n,l++;let s=K("center"),u=K("fill"),f=K("infinite"),d=0;for(let e of Z){for(let t of(e.dim=(e.slides.length-1)*n,e.slides))e.dim+=t.dim;e.offset=d,e.pos=d,!1!==s&&(e.pos-=(t-e.dim)*.5),u&&!f&&i>t&&(e.pos=a(0,e.pos,i-t)),d+=e.dim+n}let c=[];for(let t of Z){let n={...t};e&&n.pos===e.pos?(e.dim+=n.dim,e.slides=[...e.slides,...n.slides]):(e=n,n.index=c.length,c.push(n))}Z=c,el()}(),O=K("infinite")&&Z.length>1&&ed()-(ef()+(U[0]?.dim||0))>-.5,H=Z[0]?.pos||0,z=Z[Z.length-1]?.pos||0,b===G.Init){E=void 0,V=K("initialPage");let e=K("initialSlide")||void 0;void 0!==e&&(V=eP.getPageIndex(e)||0),V=a(0,V,Z.length-1),j=D=Z[V]?.pos||0}else{let e=m?.isRunning()?m.getEndValues().pos:D;(e<H||e>z)&&(V=a(0,V,Z.length-1),j=Z[V||0].pos||0)}et("refresh")}function ey(e){if(!e||!i(e))return;let t=parseInt(e.getAttribute("index")||"-1"),n="";for(let t of Array.from(e.classList)){let e=t.match(/^f-(\w+)(Out|In)$/);e&&e[1]&&(n=e[1]+"")}if(!e||!n)return;let o=[`f-${n}Out`,`f-${n}In`,"to-prev","to-next","from-prev","from-next"];e.removeEventListener("animationend",eM),c(e,o.join(" ")),X.delete(t)}function eb(){if(!x)return;let e=X.size;for(let e of U)ey(e.el);X.clear(),e&&eO()}function eM(e){"f-"===e.animationName.substring(0,2)&&(ey(e.target),!X.size&&(c(T,"in-transition"),!I&&.5>Math.abs(eP.getPosition(!0)-j)&&(I=!0,et("settle"))),eO())}function ew(e){if(e.defaultPrevented)return;let t=e.composedPath()[0];if(t.closest("[data-carousel-go-prev]")){N(e),eP.prev();return}if(t.closest("[data-carousel-go-next]")){N(e),eP.next();return}let n=t.closest("[data-carousel-go-to]");if(n){N(e),eP.goTo(parseFloat(n.dataset.carouselGoTo||"")||0);return}if(t.closest("[data-carousel-download]")){N(e);let t=Z[V].slides[0];if(t.downloadSrc||"image"===t.type&&t.src){let e=t.downloadFilename,n=document.createElement("a"),i=t.downloadSrc||t.src||"";n.href=i,n.target="_blank",n.download=e||i,n.click()}return}et("click",e)}function eL(e){let t=e.el;t&&(t.querySelector(".f-spinner")?.remove(),c(t,"is-loading"))}function eT(e){let t=e.el;t&&(t.querySelector(".f-html.is-error")?.remove(),c(t,"has-error"))}function ex(e){e||(e=Z[V]?.slides[0]);let t=e?.el;if(!t)return;let n=K("formatCaption",e);void 0===n&&(n=e.caption),n=n||"";let i=K("captionEl");if(i&&i instanceof HTMLElement){if(e.index!==V)return;if("string"==typeof n&&(i.innerHTML=Q(n+"")),n instanceof HTMLElement){if(n.parentElement===i)return;i.innerHTML="",n.parentElement&&(n=n.cloneNode(!0)),i.append(n)}return}if(!n)return;let o=e.captionEl||t.querySelector(".f-caption");!o&&n instanceof HTMLElement&&n.classList.contains("f-caption")&&(o=n),!o&&(d(o=document.createElement("div"),"f-caption"),"string"==typeof n?o.innerHTML=Q(n+""):n instanceof HTMLElement&&(n.parentElement&&(n=n.cloneNode(!0)),o.append(n)));let r=`f-caption-${q}_${e.index}`;o.setAttribute("id",r),o.dataset.selectable="true",d(t,"has-caption"),t.setAttribute("aria-labelledby",r),e.captionEl=o,t.insertAdjacentElement("beforeend",o)}function eS(e,t){let{transition:i,tween:o}={...{transition:w.transition,tween:w.tween},...t||{}};if(!T||!m)return;let r=Z.length;if(!r||function(e,t){if(!T||!m||!t||"string"!=typeof t||"tween"===t||Z[V]?.slides.length>1)return!1;let n=Z.length,i=e>V?1:-1;e=O?(e%n+n)%n:a(0,e,n-1),R&&(i*=-1);let o=Z[V]?.slides[0],r=o?.index,l=Z[e]?.slides[0],s=l?.index,u=Z[e]?.pos;if(void 0===s||void 0===r||r===s||D===u||Math.abs(ef()-(l?.dim||0))>1)return!1;I=!1,m.pause(),eb(),d(T,"in-transition"),D=j=u;let f=eh(o),p=eh(l);return er(),f&&(X.add(r),f.style.transform="",f.addEventListener("animationend",eM),c(f,w.classes.isSelected),d(f,`f-${t}Out to-${i>0?"next":"prev"}`)),p&&(X.add(s),p.style.transform="",p.addEventListener("animationend",eM),d(p,w.classes.isSelected),d(p,`f-${t}In from-${i>0?"prev":"next"}`)),eO(),!0}(e,i))return;j=Z[(e=O?(e%r+r)%r:a(0,e,r-1))||0].pos||0;let l=m.isRunning()?m.getEndValues().pos:D;if(1>Math.abs(j-l)){D=j,V!==e&&(ex(),el(),es(),E=V,et("change",V=e,E)),eO(),I||(I=!0,et("settle"));return}if(m.pause(),eb(),O){let e=ed(),t=Math.floor((l-Z[0].pos)/e),n=j+t*e,i=n-e;j=[n+e,n,i].reduce(function(e,t){return Math.abs(t-l)<Math.abs(e-l)?t:e})}if(!1!==i&&n(o))return void m.spring(o).from({pos:D}).to({pos:j}).start();D=j,er(),eO(),I||(I=!0,et("settle"))}function eO(){let e;if(!T||!x)return;let t=Z[V];Y=ec();let n=new Set,i=[];for(let o of U){if(o.isVirtual&&!X.has(o.index)&&0>Y.indexOf(o))continue;let r=eh(o);if(!r)continue;i.push(o);let l=t?.slides?.indexOf(o)>-1;if(l&&n.add(r),!X.has(o.index)){let e=o.pos?Math.round(1e4*o.pos)/1e4:0,t=A?0:R?-1*e:e,n=A?e:0,i=u(t,0,o.dim,0,100),l=u(n,0,o.dim,0,100),s=w.setTransform||void 0;s instanceof Function?s(eP,o,{x:t,y:n,xPercent:i,yPercent:l}):r.style.transform=t||n?`translate3d(${i}%, ${l}%,0)`:""}if(K("adaptiveHeight")&&l){let t=(r.firstElementChild||r).getBoundingClientRect().height;e=void 0==e?t:Math.max(e,t)}}[...l(x,`.${w.classes.slide}`)].forEach(e=>{let t=$[parseInt(e.getAttribute("index")||"-1")];t||e.remove(),p(e,w.classes.isSelected,n.has(e)),t.isVirtual&&!X.has(t.index)&&0>Y.indexOf(t)&&em(t)}),x&&e&&(x.style.height=`${e}px`),et("render",i)}function eR(){for(let e of(T?.removeEventListener("click",ew),eb(),document.removeEventListener("mousemove",ei),v?.disconnect(),v=void 0,$))e.el&&i(e.el)&&(e.state=void 0,eL(e),eT(e),em(e),e.isVirtual?(e.el?.remove(),e.el=void 0):(e.el.style.transform="",x?.appendChild(e.el)));for(let e of Object.values(L))e?.destroy();for(let e of(L={},h?.destroy(),h=void 0,m?.destroy(),m=void 0,Object.values(w.classes||{})))c(T,e);c(x,"is-draggable")}let eP={add:function(e,t){let n=D,i=j;for(let n of ep(e,t))et("addSlide",n);return eo(F),eE(),m&&i!==j&&m.spring({clamp:!0,mass:1,tension:300,friction:25,restDelta:1,restSpeed:1}).from({pos:n}).to({pos:j}).start(),eO(),eP},canGoPrev:function(){return O||V>0},canGoNext:function(){return O||V<Z.length-1},destroy:function(){return et("destroy"),window.removeEventListener("resize",en),eR(),ee.clear(),T=null,Z=[],$=[],w={...k},L={},U=[],y="",F="*",b=G.Destroyed,eP},emit:et,filter:function(e="*"){return eo(e),eE(),eO(),et("filter",e),eP},getContainer:function(){return T},getGapDim:eu,getGestures:function(){return h},getLastMouseMove:function(){return t},getOptions:function(){return w},getPage:function(){return Z[V]},getPageIndex:function(e){if(void 0!==e){for(let t of Z||[])for(let n of t.slides)if(n.index===e)return t.index;return -1}return V},getPageProgress:function(e,t){void 0===e&&(e=V);let n=Z[e];if(!n)return e>V?-1:1;let i=n.pos,o=eu(),r=eP.getPosition(),l=ed();if(O&&!0!==t){let e=Math.floor((r-Z[0].pos)/l),t=i+l*e;i=[t+l,t,t-l].reduce(function(e,t){return Math.abs(t-r)<Math.abs(e-r)?t:e})}return(r-i)/(n.dim+o)},getPageVisibility:function(e){void 0===e&&(e=V);let t=Z[e];if(!t)return e>V?-1:1;let n=eP.getPosition(),i=ef(),o=t.pos;if(O){let e=eP.getPosition(),t=ed(),n=o+Math.floor((e-Z[0].pos)/t)*t,i=n-t;o=[n+t,n,i].reduce(function(t,n){return Math.abs(n-e)<Math.abs(t-e)?n:t})}return o>n&&o+t.dim<n+i?1:o<n?(o+t.dim-n)/t.dim:o+t.dim>n+i?(n+i-o)/t.dim:0},getPages:function(){return Z},getPlugins:function(){return L},getPosition:function(e){let t=D;if(O&&!0!==e){let e=ed();t-=Math.floor((D-Z[0]?.pos||0)/e)*e}return t},getSlides:function(){return $},getState:function(){return b},getTotalSlideDim:ed,getTween:function(){return m},getViewport:function(){return x},getViewportDim:ef,getVisibleSlides:function(e){return void 0===e?Y:ec(e)},goTo:eS,hasNavigated:function(){return void 0!==E},hideError:eT,hideLoading:eL,init:function(){if(!e||!i(e))throw Error("No Element found");return b!==G.Init&&(eR(),b=G.Init),T=e,M=o,window.removeEventListener("resize",en),M.breakpoints&&window.addEventListener("resize",en),en(),eP},isInfinite:function(){return O},isInTransition:function(){return X.size>0},isRTL:function(){return R},isSettled:function(){return I},localize:function(e,t=[]){return Q(e,t)},next:function(e={}){return eS(V+1,e),eP},off:function(e,t){for(let n of e instanceof Array?e:[e])ee.has(n)&&ee.set(n,ee.get(n).filter(e=>e!==t));return eP},on:function(e,t){for(let n of e instanceof Array?e:[e])ee.set(n,[...ee.get(n)||[],t]);return eP},prev:function(e={}){return eS(V-1,e),eP},remove:function(e){void 0===e&&(e=$.length-1);let t=$[e];return t&&(et("removeSlide",t),t.el&&(ey(t.el),t.el.remove(),t.el=void 0),$.splice(e,1),eo(F),eE(),eO()),eP},setPosition:function(e){D=e,er(),eO()},showError:function(e,t){eL(e),eT(e);let n=e.el;if(n){let i=document.createElement("div");d(i,"f-html"),d(i,"is-error"),i.innerHTML=Q(t||"<p>{{ERROR}}</p>"),e.htmlEl=i,d(n,"has-html"),d(n,"has-error"),n.insertAdjacentElement("afterbegin",i),et("contentReady",e)}return eP},showLoading:function(e){let t=e.el,n=t?.querySelector(".f-spinner");if(!t||n)return eP;let i=f(K("spinnerTpl"));return i&&(d(i,"f-spinner"),d(t,"is-loading"),t.insertAdjacentElement("beforeend",i)),eP},version:"6.0.14"};return eP};B.l10n={en_EN:F},B.getDefaults=()=>k,e.Carousel=B,e.CarouselSlideContentState=$,e.CarouselState=G});