/*! Tvist v1.6.7 | https://github.com/VladimirIvanin/tvist */
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i((t="undefined"!=typeof globalThis?globalThis:t||self).TvistV1={})}(this,function(t){"use strict";const i={version:"1.6.7"};class e{constructor(t){this.value=t}set(t){return this.value=t,this}get(){return this.value}add(t){return this.value+=t,this}subtract(t){return this.value-=t,this}multiply(t){return this.value*=t,this}lerp(t,i){return this.value+=(t-this.value)*i,this}normalize(t,i){return i===t?0:(this.value-t)/(i-t)}clone(){return new e(this.value)}}class s{constructor(t,i=0,e=!1,s){this.max=t,this.loop=e,this.endIndex=s??t-1,this.value=this.constrain(i)}set(t){return this.value=this.constrain(t),this.value}get(){return this.value}add(t){return this.set(this.value+t),this}clone(){return new s(this.max,this.value,this.loop,this.endIndex)}constrain(t){if(0===this.max)return 0;if(this.loop){for(;t<0;)t+=this.max;return t%this.max}return Math.max(0,Math.min(t,this.endIndex))}}const n={linear:t=>t,easeInQuad:t=>t*t,easeOutQuad:t=>t*(2-t),easeInOutQuad:t=>t<.5?2*t*t:(4-2*t)*t-1,easeOutCubic:t=>--t*t*t+1,easeOutQuint:t=>1+--t*t*t*t*t};class o{constructor(){this.animationId=null,this.startTime=0,this.isRunning=!1}animate(t,i,e,s,o,r=n.easeOutQuad){if(this.stop(),0===e)return s(i),void o?.();this.isRunning=!0;const a=i-t,h=i=>{this.startTime||(this.startTime=i);const n=i-this.startTime,l=Math.min(n/e,1),d=r(l);s(t+a*d),l<1?this.animationId=requestAnimationFrame(h):(this.isRunning=!1,this.startTime=0,o?.())};this.animationId=requestAnimationFrame(h)}stop(){null!==this.animationId&&(cancelAnimationFrame(this.animationId),this.animationId=null),this.isRunning=!1,this.startTime=0}isAnimating(){return this.isRunning}}function r(t,i){let e=0,s=null;return function(...n){const o=Date.now()-e,r=()=>{e=Date.now(),t(...n)};o>=i?r():(null!==s&&clearTimeout(s),s=window.setTimeout(()=>{r(),s=null},i-o))}}const a=String(i?.version),h=`tvist-v${parseInt(a.split(".")[0]??"0",10)||0}`,l={block:h,container:`${h}__container`,slide:`${h}__slide`,vertical:`${h}--vertical`,disabled:`${h}--disabled`,draggable:`${h}--draggable`,dragging:`${h}--dragging`,locked:`${h}--locked`,created:`${h}--created`,destroyed:`${h}--destroyed`,singlePage:`${h}--single-page`,nav:`${h}--nav`,cube:`${h}--cube`,scrollbar:`${h}__scrollbar`,scrollbarHorizontal:`${h}__scrollbar--horizontal`,scrollbarVertical:`${h}__scrollbar--vertical`,scrollbarHidden:`${h}__scrollbar--hidden`,scrollbarDragging:`${h}__scrollbar--dragging`,scrollbarTrack:`${h}__scrollbar-track`,scrollbarThumb:`${h}__scrollbar-thumb`,arrowPrev:`${h}__arrow--prev`,arrowNext:`${h}__arrow--next`,arrowDisabled:`${h}__arrow--disabled`,arrowHidden:`${h}__arrow--hidden`,pagination:`${h}__pagination`,paginationHidden:`${h}__pagination--hidden`,bullet:`${h}__bullet`,bulletActive:`${h}__bullet--active`,paginationCurrent:`${h}__pagination-current`,paginationSeparator:`${h}__pagination-separator`,paginationTotal:`${h}__pagination-total`,paginationProgress:`${h}__pagination-progress`,paginationProgressBar:`${h}__pagination-progress-bar`,slideActive:`${h}__slide--active`,slidePrev:`${h}__slide--prev`,slideNext:`${h}__slide--next`,slideVisible:`${h}__slide--visible`,slideClone:`${h}__slide--clone`,slideMarqueeClone:`${h}__slide--marquee-clone`,slideNavActive:`${h}__slide--nav-active`,slideGridPage:`${h}__slide--grid-page`,gridRow:`${h}__grid-row`,gridCol:`${h}__grid-col`,gridItem:`${h}__grid-item`,shadow:`${h}-shadow`},d=``;function c(t){if("string"==typeof t){const i=document.querySelector(t);if(!i)throw new Error(`Tvist: element "${t}" not found`);return i}return t}function u(t,i){t.classList.add(i)}function p(t,i){t.classList.remove(i)}function v(t){return t.offsetWidth}function g(t){return t.offsetHeight}function m(t,i){return i?Array.from(t.querySelectorAll(i)):Array.from(t.children)}function f(t){return"string"==typeof t?t:"number"==typeof t&&0!==t?`${t}px`:"0px"}function b(t){return"object"==typeof t&&null!==t}function y(t,i){const{peek:e}=t;if(!e)return"0px";if(b(e)){return f(e[i])}return f(e)}function S(t,i){const{peek:e}=t;if(!e)return 0;if(b(e)){const t=e[i];return"number"==typeof t?t:0}return"number"==typeof e?e:0}function x(t,i){const e=`padding${i.charAt(0).toUpperCase()}${i.slice(1)}`,s=window.getComputedStyle(t)[e];return parseFloat(s)||0}class E{constructor(t,i){this.containerSize=0,this.slideSize=0,this.slideSizes=[],this.slidePositions=[],this.peekStart=0,this.peekEnd=0,this.cachedMinScroll=0,this.cachedMaxScroll=0,this.cachedRootSize=0,this.scrollCacheValid=!1,this.cachedRootWidth=0,this.cachedRootHeight=0,this.rootSizeCacheValid=!1,this.slideSizesCacheValid=!1,this._isLocked=!1,this.tvist=t,this.options=i;const n=t.slides.length,r=i.start??0,a=!0===i.loop;this.location=new e(0),this.target=new e(0);const h=i.perPage??1,l=a||i.isNavigation||i.center?n-1:Math.max(0,n-h);this.index=new s(n,r,a,l),this.animator=new o,this.applyPeek(),this.calculateSizes(),this.calculatePositions(),this.checkLock();const d=this.getScrollPositionForIndex(r);this.location.set(d),this.target.set(d),this.applyTransform()}getSlideSize(t){if(this.slideSizes.length>0&&t>=0&&t0){const t=this.options.slideMinSize,i=Math.floor((this.containerSize+s)/(t+s));this.options.perPage=Math.max(1,i)}const t=this.options.perPage??1;this.slideSize=(this.containerSize-s*(t-1))/t,(this.slideSize<0||!isFinite(this.slideSize))&&(this.slideSize=0),this.slideSizes=[]}r?(t.forEach((e,n)=>{e.style.marginRight="",e.style.marginBottom="",s>0&&n!==t.length-1&&(i?e.style.marginBottom=`${s}px`:e.style.marginRight=`${s}px`)}),this.slideSizesCacheValid||(this.slideSizes=t.map(t=>i?g(t):v(t)),this.slideSizesCacheValid=!0)):(t.forEach((e,n)=>{e.style.width="",e.style.height="",e.style.marginRight="",e.style.marginBottom="",this.slideSize>0&&(i?(e.style.height=`${this.slideSize}px`,e.style.width="100%"):e.style.width=`${this.slideSize}px`),s>0&&n!==t.length-1&&(i?e.style.marginBottom=`${s}px`:e.style.marginRight=`${s}px`)}),this.slideSizes=[],this.slideSizesCacheValid=!1)}calculatePositions(){const t=this.tvist.slides,i=this.options.gap??0;if(this.slidePositions=[],this.slideSizes.length>0){let e=0;for(let s=0;s=0){const i=this.getSlidePosition(t)+this.getSlideSize(t);this.cachedMaxScroll=this.cachedRootSize-this.peekStart-i}else this.cachedMaxScroll=0;this.scrollCacheValid=!0}invalidateScrollCache(){this.scrollCacheValid=!1}setSlidePositions(t){this.slidePositions=t,this.invalidateScrollCache()}setSlideSize(t){this.slideSize=t}getEndIndex(){const t=this.tvist.slides.length,i=!0===this.options.loop,e=!0===this.options.autoWidth||!0===this.options.autoHeight;if(i||this.options.center||this.options.isNavigation||e)return t-1;const s=t-(this.options.perPage??1);return Math.max(0,Math.min(s,t-1))}getMinScrollPosition(){return this.scrollCacheValid||this.updateScrollCache(),this.cachedMinScroll}getMaxScrollPosition(){return this.scrollCacheValid||this.updateScrollCache(),this.cachedMaxScroll}getSlidePosition(t){return t<0||t>=this.slidePositions.length?0:this.slidePositions[t]??0}getSlidePositions(){return[...this.slidePositions]}scrollTo(t,i=!1){const e=this.getEndIndex(),s=this.options.isNavigation;let n=this.options.loop||s||this.options.center?t:Math.max(0,Math.min(t,e));this.options.rewind&&!this.options.loop&&(t>e?n=0:t<0&&(n=e));const o=this.index.get();let r=this.index.loop?n<0?n+this.index.max:n%this.index.max:Math.max(0,Math.min(n,this.index.endIndex)),a=r!==o;const h=this.getEventIndex(r);if(a&&!i){const t=this.tvist._scrollDirection??(r>o?"next":"prev");this.tvist._scrollDirection=void 0;const i=this.index.get();this.tvist.emit("beforeTransitionStart",{index:h,direction:t});const e=this.index.get();if(i!==e&&this.options.loop){const t=this.findDomIndexByRealIndex(h);if(-1!==t)n=t,r=t;else{n=e+(n-i),r=(n%this.index.max+this.index.max)%this.index.max}a=!0}}this.index.set(n),this.options.loop,(new Error).stack?.split("\n").slice(2,6).join(" <- ");let l=this.getScrollPositionForIndex(r);if(s&&!this.options.loop&&!this.options.center){const t=!1!==this.options.peekTrim,i=t?this.getMaxScrollPosition():-this.getSlidePosition(e),s=t?this.getMinScrollPosition():0;l=Math.max(i,Math.min(s,l))}if(a&&this.tvist.emit("beforeSlideChange",h),i)this.target.set(l),this.location.set(l),this.applyTransform(),a&&(this.tvist.emit("slideChangeEnd",h),this.emitReachEdge(h,e));else{this.target.set(l);const t=this.options.speed??300;a&&(this.tvist.emit("transitionStart",h),this.tvist.emit("slideChangeStart",h));const i=this.location.get();Math.abs(i-l)>.5?this.animator.animate(i,l,t,t=>{this.location.set(t),this.applyTransform(),this.tvist.emit("scroll")},()=>{this.location.get(),this.tvist.emit("transitionEnd",h),a&&(this.tvist.emit("slideChangeEnd",h),this.emitReachEdge(h,e))}):a||Promise.resolve().then(()=>{this.tvist.emit("transitionEnd",h)})}}emitProgress(){if(this.options.loop)return;const t=this.getMinScrollPosition(),i=this.getMaxScrollPosition()-t;if(i<=0)return;const e=this.location.get(),s=Math.max(0,Math.min(1,(e-t)/i));this.tvist.emit("progress",s)}emitReachEdge(t,i){t<=0&&this.tvist.emit("reachBeginning"),t>=i&&this.tvist.emit("reachEnd")}scrollBy(t){const i=this.index.get()+t,e=t>0?"next":t<0?"prev":void 0;e&&(this.tvist._scrollDirection=e),this.scrollTo(i)}applyTransform(){const t=this.tvist.container,i=this.location.get();this.index.get(),this.target.get(),"vertical"===this.options.direction?t.style.transform=`translate3d(0, ${i}px, 0)`:t.style.transform=`translate3d(${i}px, 0, 0)`,this.tvist.emit("setTranslate",this.tvist,i),this.emitProgress()}applyTransformPublic(){this.applyTransform()}update(){this.invalidateRootSizeCache(),this.slideSizesCacheValid=!1,this.applyPeek(),this.calculateSizes(),this.calculatePositions();const t=this.tvist.slides.length,i=this.options.perPage??1,e=!0===this.options.loop||this.options.isNavigation||this.options.center?t-1:Math.max(0,t-i);this.index.endIndex=e,this.index.max=t,this.checkLock();const s=this.index.get(),n=this.getScrollPositionForIndex(s);this.target.set(n),this.location.set(n),this.applyTransform()}checkLock(){const t=this.tvist.slides.length,i=this.options.perPage??1,e=this.slideSize>0||this.slideSizes.length===t;if(this.options.loop){if(e){const t=this.getContentSize()<=this.containerSize+1;this.setLocked(t)}else this.setLocked(t<=i);return}const s=!!e&&this.getMaxScrollPosition()>=this.getMinScrollPosition()-1;if(t>i)return void this.setLocked(e&&s);const n=this.getContentSize()<=this.containerSize+1;this.setLocked(e?n&&s:t<=i)}getTotalSize(){return this.getContentSize()}getContentSize(){const t=this.tvist.slides;if(0===t.length)return 0;let i=1/0,e=-1/0;for(let s=0;se&&(e=t+n)}return i===1/0?0:e-i}setLocked(t){if(this._isLocked!==t)if(this._isLocked=t,this.tvist.root.classList.toggle(l.locked,t),t){this.index.set(0);const t=this.getScrollPositionForIndex(0);this.location.set(t),this.target.set(t),this.applyTransform(),this.tvist.emit("lock")}else this.tvist.emit("unlock")}get isLocked(){return this._isLocked}get slideSizeValue(){return this.slideSizes.length>0?this.getSlideSize(0):this.slideSize}get containerSizeValue(){return this.containerSize}getVisibleSlides(){const t=this.location.get(),i=this.containerSize,e=this.tvist.slides,s=[];for(let n=0;ne+1;s.push(h)}return s}get activeIndex(){return this.index.get()}get slideCount(){return this.tvist.slides.length}canScrollNext(){if(this.isLocked)return!1;if(this.options.loop||this.options.rewind)return!0;const t=this.options.isNavigation?this.tvist.slides.length-1:this.getEndIndex();return this.index.get()0)}destroy(){this.animator.stop()}}class P{constructor(){this.listeners=new Map,this.anyListeners=new Set}on(t,i){let e=this.listeners.get(t);return e||(e=new Set,this.listeners.set(t,e)),e.add(i),this}off(t,i){if(i){const e=this.listeners.get(t);e&&(e.delete(i),0===e.size&&this.listeners.delete(t))}else this.listeners.delete(t);return this}emit(t,...i){const e=this.listeners.get(t);return e&&e.forEach(t=>{try{t(...i)}catch(e){}}),this.anyListeners.forEach(e=>{try{e(t,...i)}catch(s){}}),this}once(t,i){const e=(...s)=>{i(...s),this.off(t,e)};return this.on(t,e)}onAny(t){return this.anyListeners.add(t),this}offAny(t){return t?this.anyListeners.delete(t):this.anyListeners.clear(),this}clear(){this.listeners.clear(),this.anyListeners.clear()}eventNames(){return Array.from(this.listeners.keys())}listenerCount(t){const i=this.listeners.get(t);return i?i.size:0}}class T{constructor(t,i){this.tvist=t,this.options=i}shouldBeActive(){return!0}emit(t,...i){this.tvist.emit(t,...i)}on(t,i){this.tvist.on(t,i)}off(t,i){this.tvist.off(t,i)}}let L=0,w=null,I=0,A=0;function M(t,i,e=!1){if(!i.breakpoints||0===Object.keys(i.breakpoints).length)return null;const s=Date.now(),n=s-A>16;let o;if("container"===i.breakpointsBase){(e||n||w!==t)&&(L=t.clientWidth,w=t,A=s),o=L}else{if("undefined"!=typeof window){const t=window.innerWidth;(e||n||t!==I)&&(I=t,A=s)}o=I}const r=Object.keys(i.breakpoints).map(Number).sort((t,i)=>t-i);let a=null;for(const h of r)if(o<=h){a=h;break}return a}class k extends T{constructor(t,i){super(t,i),this.name="breakpoints",this.mediaQueries=new Map,this.currentBreakpoint=null,this.handleMediaChange=()=>{this.throttledCheckBreakpoints(),this.tvist.isEnabled&&this.tvist.update()},this.currentBreakpoint=M(t.root,i),this.throttledCheckBreakpoints=r(()=>{this.checkBreakpoints()},50)}getOriginalOptions(){return this.tvist._originalOptions??{...this.options}}resetCurrentBreakpoint(){this.currentBreakpoint=null}init(){this.shouldBeActive()&&("container"!==this.options.breakpointsBase&&this.setupMediaQueries(),this.checkBreakpoints())}destroy(){this.mediaQueries.forEach(t=>{try{t.removeEventListener("change",this.handleMediaChange)}catch{t.removeListener(this.handleMediaChange)}}),this.mediaQueries.clear()}shouldBeActive(){return!!(this.options.breakpoints&&Object.keys(this.options.breakpoints).length>0)}setupMediaQueries(){if(!this.options.breakpoints)return;if("undefined"==typeof window||"function"!=typeof window.matchMedia)return;const t=this.getOriginalOptions();if(!t.breakpoints)return;Object.keys(t.breakpoints).map(Number).sort((t,i)=>i-t).forEach(t=>{const i=window.matchMedia(`(max-width: ${t}px)`);i.addEventListener("change",this.handleMediaChange),this.mediaQueries.set(t,i)})}checkBreakpoints(){if(this.tvist.isTogglingEnabled)return;const t=this.getOriginalOptions(),i={...t,breakpointsBase:t.breakpointsBase},e=M(this.tvist.root,i,!0),s=this.tvist.checkAndResetManualEnabledChange(),n=e!==this.currentBreakpoint;(n||s)&&(this.currentBreakpoint=e,this.applyBreakpoint(e),n&&(this.emit("breakpoint",e),t.on?.breakpoint&&t.on.breakpoint(e)))}applyBreakpoint(t){const i=this.getOriginalOptions(),e=JSON.parse(JSON.stringify(i));var s,n;null!==t&&i.breakpoints?.[t]&&(s=e,n=i.breakpoints[t],Object.keys(n).forEach(t=>{const i=n[t];if(null==i||"object"!=typeof i||Array.isArray(i))s[t]=i;else{const e=s[t];e&&"object"==typeof e&&!Array.isArray(e)?s[t]={...e,...i}:s[t]=i}}));const o=!1!==e.enabled,r=this.tvist.options.breakpoints;Object.keys(this.tvist.options).forEach(t=>{"breakpoints"!==t&&"on"!==t&&delete this.tvist.options[t]}),Object.assign(this.tvist.options,e),this.tvist.options.breakpoints=r,o&&!this.tvist.isEnabled?this.tvist.enable():!o&&this.tvist.isEnabled&&this.tvist.disable()}getCurrentBreakpoint(){return this.currentBreakpoint}onResize(){this.checkBreakpoints()}}const C=class t{constructor(i,e={}){this.modules=new Map,this._isEnabled=!0,this._manualEnabledChange=!1,this._isTogglingEnabled=!1,this._isVisible=!0,this.allowClick=!0,this.slideClickHandler=t=>{if(!this.allowClick)return this.options.preventClicks&&t.preventDefault(),void(this.options.preventClicksPropagation&&this.engine.animator.isAnimating()&&(t.stopPropagation(),t.stopImmediatePropagation()));const i=t.target.closest(`.${l.slide}`);if(!i)return;const e=this.slides.indexOf(i);-1!==e&&this.emit("click",e,i,t)},this.id=t.generateId(),this.root=c(i);const s=this.root;s.tvistInstance&&"function"==typeof s.tvistInstance.destroy&&s.tvistInstance.destroy(),s.tvistInstance=this;const n=`.${l.container}`,o=this.root.querySelector(n);if(!o)throw new Error(`Tvist: container "${n}" not found inside root element`);this.container=o,this._slides=m(this.container,`.${l.slide}`),this.slides.length;if(this.options={perPage:1,slidesPerGroup:1,gap:0,speed:300,direction:"horizontal",drag:!0,start:0,loop:!1,enabled:!0,preventClicks:!0,preventClicksPropagation:!0,visibility:!0,...e,browserFixes:{firefoxImageDecoding:!0,...e.browserFixes}},this.options.breakpoints&&Object.keys(this.options.breakpoints).length>0){const t=JSON.parse(JSON.stringify(this.options));this.options.breakpointsBase&&(t.breakpointsBase=this.options.breakpointsBase),this._originalOptions=t}!function(t,i){const e=M(t,i);if(null!==e&&i.breakpoints?.[e]){const t=i.breakpoints[e];Object.keys(t).forEach(e=>{const s=t[e];if(null==s||"object"!=typeof s||Array.isArray(s))i[e]=s;else{const t=i[e];t&&"object"==typeof t&&!Array.isArray(t)?i[e]={...t,...s}:i[e]=s}})}}(this.root,this.options),this.updateSlideIndices(),this._isEnabled=!1!==this.options.enabled,this.events=new P,"vertical"===this.options.direction&&this.root.classList.add(l.vertical),this._isEnabled||this.root.classList.add(l.disabled),this.options.on&&Object.entries(this.options.on).forEach(([t,i])=>{i&&this.events.on(t,i)}),this.engine=new E(this,this.options),t.flushModuleQueue(),this.initModules(),this.setupResizeListener(),this._isEnabled?this.update():this.clearSliderStyles(),this.root.classList.add(l.created),this.emit("created",this),this.setupSlideClick()}static generateId(){if("undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID)return`tvist-${crypto.randomUUID()}`;return`tvist-${"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const i=16*Math.random()|0;return("x"===t?i:3&i|8).toString(16)})}`}setupSlideClick(){this.container.addEventListener("click",this.slideClickHandler)}initModules(){t.MODULES.forEach((t,i)=>{try{const e=new t(this,this.options);!1!==e.shouldBeActive?.()&&(this.modules.set(i,e),e.init())}catch(e){}})}setupResizeListener(){this.resizeHandler=r(()=>{this.update(),this.emit("resized")},100),"undefined"!=typeof ResizeObserver?(this.resizeObserver=new ResizeObserver(()=>{this.resizeHandler?.()}),this.resizeObserver.observe(this.root)):window.addEventListener("resize",this.resizeHandler)}next(){if(!this._isEnabled||!this._isVisible)return this;if(this.engine.canScrollNext()){const t=this.options.slidesPerGroup??1;this.engine.scrollBy(t)}return this}prev(){if(!this._isEnabled||!this._isVisible)return this;if(this.engine.canScrollPrev()){const t=this.options.slidesPerGroup??1;this.engine.scrollBy(-t)}return this}scrollTo(t,i=!1){if(!this._isEnabled||!this._isVisible)return this;const e=this.indexResolver?this.indexResolver(t):t;return this.engine.scrollTo(e,i),this}update(){return this._isEnabled?(this.modules.forEach(t=>{t.onResize?.()}),"vertical"===this.options.direction?this.root.classList.add(l.vertical):this.root.classList.remove(l.vertical),this.engine.update(),this.modules.forEach(t=>{t.onUpdate?.()}),this.emit("refresh"),this):this}updateOptions(i){const e={...this.options};if(void 0!==i.breakpoints||void 0!==i.breakpointsBase){if(this._originalOptions){const t=JSON.parse(JSON.stringify(this._originalOptions));delete t.breakpoints,delete t.on,Object.keys(this.options).forEach(t=>{"breakpoints"!==t&&"on"!==t&&delete this.options[t]}),Object.assign(this.options,t)}Object.assign(this.options,i);const t=JSON.parse(JSON.stringify(this.options));this.options.breakpointsBase&&(t.breakpointsBase=this.options.breakpointsBase),this._originalOptions=t;const e=this.modules.get("breakpoints");e instanceof k&&e.resetCurrentBreakpoint()}else if(i.browserFixes){this.options.browserFixes={...this.options.browserFixes,...i.browserFixes};const{browserFixes:t,...e}=i;Object.assign(this.options,e)}else Object.assign(this.options,i);void 0!==i.direction&&i.direction!==e.direction&&("vertical"===this.options.direction?this.root.classList.add(l.vertical):this.root.classList.remove(l.vertical)),i.on&&(e.on&&Object.entries(e.on).forEach(([t,i])=>{i&&this.events.off(t,i)}),Object.entries(i.on).forEach(([t,i])=>{i&&this.events.on(t,i)})),void 0===i.peek&&void 0===i.peekTrim||this.engine.applyPeekPublic();return(void 0!==i.perPage||void 0!==i.slideMinSize||void 0!==i.gap||void 0!==i.peek||void 0!==i.peekTrim||void 0!==i.direction||void 0!==i.center||void 0!==i.breakpoints||void 0!==i.breakpointsBase)&&this.update(),this.modules.forEach(t=>{t.onOptionsUpdate?.(i)}),t.MODULES.forEach((t,i)=>{if(!this.modules.has(i))try{const e=new t(this,this.options);!1!==e.shouldBeActive?.()&&(this.modules.set(i,e),e.init())}catch(e){}}),this.emit("optionsUpdated",this,i),this}clearSliderStyles(){this.container.style.transform="",this.slides.forEach(t=>{t.style.width="",t.style.height="",t.style.marginRight="",t.style.marginBottom=""})}disable(){if(!this._isEnabled)return this;this._isEnabled=!1,this._manualEnabledChange=!0,this._isTogglingEnabled=!0,this.root.classList.add(l.disabled),this.clearSliderStyles();const t=[];return this.modules.forEach((i,e)=>{"breakpoints"!==e&&t.push(e)}),t.forEach(t=>{try{this.modules.get(t)?.destroy(),this.modules.delete(t)}catch(i){}}),this._isTogglingEnabled=!1,this.emit("disabled",this),this}enable(){return this._isEnabled||(this._isEnabled=!0,this._manualEnabledChange=!0,this._isTogglingEnabled=!0,this.root.classList.remove(l.disabled),t.MODULES.forEach((t,i)=>{if("breakpoints"!==i&&!this.modules.has(i))try{const e=new t(this,this.options);this.modules.set(i,e),e.init()}catch(e){}}),this.update(),this._isTogglingEnabled=!1,this.emit("enabled",this)),this}get isEnabled(){return this._isEnabled}checkAndResetManualEnabledChange(){const t=this._manualEnabledChange;return this._manualEnabledChange=!1,t}get isTogglingEnabled(){return this._isTogglingEnabled}destroy(){this.emit("beforeDestroy",this),this.root.classList.add(l.destroyed),this.container.removeEventListener("click",this.slideClickHandler),this.emit("destroyed",this),this.modules.forEach(t=>{try{t.destroy()}catch(i){}}),this.modules.clear(),this.engine.destroy(),this.resizeObserver?this.resizeObserver.disconnect():this.resizeHandler&&window.removeEventListener("resize",this.resizeHandler),this.events.clear();const t=this.root;return t.tvistInstance===this&&(t.tvistInstance=null),this}getModule(t){return this.modules.get(t)}removeModule(t){this.modules.delete(t)}get slides(){return this._slides}updateSlidesList(){this._slides=m(this.container,`.${l.slide}`)}updateSlideIndices(){this._slides.forEach((t,i)=>{t.setAttribute("data-tvist-slide-index",String(i))})}get activeIndex(){return this.engine.activeIndex}get canScrollNext(){return this.engine.canScrollNext()}get canScrollPrev(){return this.engine.canScrollPrev()}get autoplay(){const t=this.modules.get("autoplay");if(t&&"function"==typeof t.getAutoplay)return t.getAutoplay()}get video(){const t=this.modules.get("video");if(t&&"function"==typeof t.getVideo)return t.getVideo()}on(t,i){return this.events.on(t,i),this}off(t,i){return this.events.off(t,i),this}emit(t,...i){return this.events.emit(t,...i),this}once(t,i){return this.events.once(t,i),this}sync(t){return this.on("slideChangeStart",i=>{t.activeIndex!==i&&t.scrollTo(i)}),t.on("slideChangeStart",t=>{this.activeIndex!==t&&this.scrollTo(t)}),this}static registerModule(i,e){t.MODULES.has(i)||t.MODULES.set(i,e)}static flushModuleQueue(){if("undefined"==typeof window)return;const e=`__tvistV${parseInt(i.version.split(".")[0]??"0",10)||0}Queue`,s=window,n=s[e];Array.isArray(n)&&0!==n.length&&(n.forEach(([i,e])=>{t.registerModule(i,e)}),s[e]=[])}static unregisterModule(i){t.MODULES.delete(i)}static getRegisteredModules(){return Array.from(t.MODULES.keys())}};C.VERSION=i.version,C.CLASSES=l,C.CSS_PREFIX=l.block,C.MODULES=new Map;let B=C;class O extends T{constructor(t,i){super(t,i),this.name="drag",this.isDragging=!1,this.startX=0,this.startY=0,this.startPosition=0,this.startIndex=0,this.currentX=0,this.currentY=0,this.wasAnimating=!1,this.animationTarget=null,this.animationId=null,this.minPosition=0,this.maxPosition=0,this.cachedViewportSize=0,this.loopModuleRef=null,this.isMarqueeActive=!1,this.FRICTION=.92,this.MIN_VELOCITY=.05,this.LOG_INTERVAL=200,this.MIN_DRAG_DISTANCE=5,this.isPotentialDrag=!1,this.isFirstMove=!0,this.coverageFixCooldown=0,this.accumulatedDeltaBeforeDragStart={x:0,y:0},this.shouldSubtractAccumulatedDelta=!1,this.lastMoveTime=0,this.baseEvent=null,this.prevBaseEvent=null,this.onLoopFix=()=>{if(this.isDragging){this.startPosition;this.startPosition=this.tvist.engine.location.get(),this.tvist.engine.index.get(),"realIndex"in this.tvist&&this.tvist.realIndex,this.startPosition}},this.onPositionShifted=t=>{this.isDragging&&(this.startPosition+=t)},this.onDragStart=t=>{t.preventDefault()},this.onPointerDown=t=>{if(this.isDragging)return;if(this.tvist.engine.isLocked)return;if("button"in t&&0!==t.button)return;const i=t.target;if(this.isFocusableElement(i))return;const e=this.getPointerPosition(t);if(!e)return;this.isPotentialDrag=!0,this.startX=e.x,this.startY=e.y,this.currentX=e.x,this.currentY=e.y,this.startIndex=this.tvist.engine.index.get(),this.tvist.allowClick=!0;const s=this.tvist.getModule("marquee");s?.pause?.(),this.startPosition=this.tvist.engine.location.get(),this.baseEvent=null,this.prevBaseEvent=null,this.lastMoveTime=0,this.isFirstMove=!0,this.accumulatedDeltaBeforeDragStart={x:0,y:0},this.shouldSubtractAccumulatedDelta=!1,this.wasAnimating=this.tvist.engine.animator.isAnimating(),this.wasAnimating&&(this.animationTarget=this.tvist.engine.activeIndex),this.tvist.engine.index.get(),"realIndex"in this.tvist&&this.tvist.realIndex,this.tvist.engine.location.get(),this.startPosition,this.startIndex,this.wasAnimating,this.animationTarget,this.options.loop,this.options.rewind,this.options.autoplay,this.tvist.slides.length,this.tvist.engine.slideSizeValue,this.tvist.engine.getScrollPositionForIndex(3),this.stopMomentum(),this.tvist.engine.animator.stop(),this.addDocumentEvents()},this.onPointerMove=t=>{if(!this.isPotentialDrag&&!this.isDragging)return;const i=this.getPointerPosition(t);if(!i)return;const e=Date.now();this.currentX=i.x,this.currentY=i.y;const s="vertical"!==this.options.direction;let n=i.x-this.startX,o=i.y-this.startY;const r=s?Math.abs(n):Math.abs(o);if(!this.isDragging){if(!(r>this.MIN_DRAG_DISTANCE))return;if(this.isDragging=!0,this.tvist.allowClick=!1,this.stopMomentum(),this.tvist.engine.animator.stop(),this.options.loop&&this.isFirstMove)if(this.isMarqueeActive)this.isFirstMove=!1;else if(this.loopModuleRef?.fix){const t=(s?n:o)>0?"prev":"next";this.tvist.engine.index.get(),"realIndex"in this.tvist&&this.tvist.realIndex,this.tvist.engine.location.get(),this.loopModuleRef.fix({direction:t}),this.isFirstMove=!1,this.startPosition=this.tvist.engine.location.get(),this.startX=i.x,this.startY=i.y,this.startIndex=this.tvist.engine.index.get(),this.coverageFixCooldown=5,this.tvist.engine.index.get(),"realIndex"in this.tvist&&this.tvist.realIndex,this.startPosition,this.startIndex}this.baseEvent={x:i.x,y:i.y,time:e},this.lastMoveTime=e,this.accumulatedDeltaBeforeDragStart={x:n,y:o},this.shouldSubtractAccumulatedDelta=!0,this.tvist.engine.index.get(),"realIndex"in this.tvist&&this.tvist.realIndex,this.startIndex,this.startPosition,this.accumulatedDeltaBeforeDragStart,this.emit("dragStart",t),this.tvist.root.classList.add(l.dragging)}this.shouldSubtractAccumulatedDelta&&(n-=this.accumulatedDeltaBeforeDragStart.x,o-=this.accumulatedDeltaBeforeDragStart.y,this.shouldSubtractAccumulatedDelta=!1,this.accumulatedDeltaBeforeDragStart={x:0,y:0});let a,h=(s?n:o)*(this.options.dragSpeed??1);if(this.isMarqueeActive)a=this.startPosition+h,!1===this.options.rubberband||this.options.loop||(a=this.applyRubberbandToPosition(a));else if(this.options.center&&!this.options.loop){a=-this.tvist.engine.getSlidePosition(this.startIndex)+this.tvist.engine.getCenterOffset(this.startIndex)+h,!1!==this.options.rubberband&&(a=this.applyRubberbandToPosition(a))}else!1!==this.options.rubberband&&(h=this.applyRubberband(h)),a=this.startPosition+h;this.tvist.engine.location.set(a),this.tvist.engine.location.get(),this.tvist.engine.applyTransformPublic(),this.tvist.engine.location.get(),this.options.loop&&this.checkContentCoverageAndFix(a,i);e-this.lastMoveTime>this.LOG_INTERVAL&&(this.prevBaseEvent=this.baseEvent,this.baseEvent={x:i.x,y:i.y,time:e},this.lastMoveTime=e),this.emit("drag",t),"touchmove"===t.type&&t.preventDefault()},this.onPointerUp=t=>{if(!this.isPotentialDrag&&!this.isDragging)return;const i=this.isDragging;if(this.isPotentialDrag=!1,this.isDragging){if(this.isDragging=!1,this.tvist.root.classList.remove(l.dragging),setTimeout(()=>{this.tvist.allowClick=!0},0),!this.options.loop){const t=this.tvist.engine.location.get();let i=t;t>this.minPosition?i=this.minPosition:tthis.updateBounds()),this.on("positionShifted",this.onPositionShifted),this.on("loopFix",this.onLoopFix))}updateCachedRefs(){this.loopModuleRef=this.tvist.getModule("loop"),this.isMarqueeActive=!1!==this.options.marquee&&void 0!==this.options.marquee}destroy(){this.detachEvents(),this.stopMomentum(),this.off("positionShifted",this.onPositionShifted),this.off("loopFix",this.onLoopFix)}shouldBeActive(){return!1!==this.options.drag}updateBounds(){const{engine:t,slides:i}=this.tvist,e=this.options.perPage??1,s="vertical"!==this.options.direction;if(this.cachedViewportSize=s?this.tvist.root.offsetWidth:this.tvist.root.offsetHeight,this.options.loop||this.isMarqueeActive)this.minPosition=1/0,this.maxPosition=-1/0;else if(this.options.center)this.minPosition=t.getScrollPositionForIndex(0),this.maxPosition=t.getScrollPositionForIndex(i.length-1);else{const s=!1!==this.options.peekTrim;this.minPosition=s?t.getMinScrollPosition():0,this.maxPosition=s?t.getMaxScrollPosition():-t.getSlidePosition(i.length-e)}this.options.debug}attachEvents(){const{root:t}=this.tvist;"PointerEvent"in window?t.addEventListener("pointerdown",this.onPointerDown):(t.addEventListener("touchstart",this.onPointerDown,{passive:!0}),t.addEventListener("mousedown",this.onPointerDown)),t.addEventListener("dragstart",this.onDragStart),t.classList.add(l.draggable)}detachEvents(){const{root:t}=this.tvist;"PointerEvent"in window?t.removeEventListener("pointerdown",this.onPointerDown):(t.removeEventListener("touchstart",this.onPointerDown),t.removeEventListener("mousedown",this.onPointerDown)),t.removeEventListener("dragstart",this.onDragStart),t.classList.remove(l.draggable),this.removeDocumentEvents()}addDocumentEvents(){"PointerEvent"in window?(document.addEventListener("pointermove",this.onPointerMove),document.addEventListener("pointerup",this.onPointerUp),document.addEventListener("pointercancel",this.onPointerUp)):(document.addEventListener("touchmove",this.onPointerMove,{passive:!1}),document.addEventListener("touchend",this.onPointerUp),document.addEventListener("touchcancel",this.onPointerUp),document.addEventListener("mousemove",this.onPointerMove),document.addEventListener("mouseup",this.onPointerUp))}removeDocumentEvents(){"PointerEvent"in window?(document.removeEventListener("pointermove",this.onPointerMove),document.removeEventListener("pointerup",this.onPointerUp),document.removeEventListener("pointercancel",this.onPointerUp)):(document.removeEventListener("touchmove",this.onPointerMove),document.removeEventListener("touchend",this.onPointerUp),document.removeEventListener("touchcancel",this.onPointerUp),document.removeEventListener("mousemove",this.onPointerMove),document.removeEventListener("mouseup",this.onPointerUp))}getPointerPosition(t){if("touches"in t&&t.touches.length>0){const i=t.touches[0];return i?{x:i.clientX,y:i.clientY}:null}return"clientX"in t?{x:t.clientX,y:t.clientY}:null}isFocusableElement(t){const i=this.options.focusableElements??"input, textarea, select, button, a[href], [tabindex]";return t.matches(i)}checkContentCoverageAndFix(t,i){const e=this.loopModuleRef;if(!e?.fix)return;const s=e.fix.bind(e),n=-t,o=n+this.cachedViewportSize,r=this.tvist.slides;if(0===r.length)return;const a=this.tvist.engine.getSlidePosition(0),h=r.length-1,l=this.tvist.engine.getSlidePosition(h)+this.tvist.engine.getSlideSize(h),d="vertical"!==this.options.direction?i.x-this.startX:i.y-this.startY;if(Math.abs(d)<10)return;if(this.coverageFixCooldown>0)return void this.coverageFixCooldown--;let c=!1;if(d>0&&nl- -5){const t=this.findSlideNearViewportEdge(n,r);this.tvist.engine.index.get(),"realIndex"in this.tvist&&this.tvist.realIndex,s({direction:"next",activeSlideIndex:t}),c=!0}c&&(this.startPosition=this.tvist.engine.location.get(),this.startX=i.x,this.startY=i.y,this.startIndex=this.tvist.engine.index.get(),this.coverageFixCooldown=5)}findSlideNearViewportEdge(t,i){let e=0;for(let s=0;st)break;e=s}return Math.max(e,1)}applyRubberband(t){const i=this.startPosition+t;if(i>=this.maxPosition&&i<=this.minPosition)return t;let e=t,s=0;if(i>this.minPosition){const n=i-this.minPosition;e=t-n,s=n}else if(i=this.maxPosition&&t<=this.minPosition)return t;if(t>this.minPosition){const i=t-this.minPosition;return this.minPosition+i/5}if(tthis.minPosition||i=this.LOG_INTERVAL)return 0;return("vertical"!==this.options.direction?n-r.x:o-r.y)/a}startMomentum(t){const i=this.tvist.engine.location.get(),e=this.options.loop;if(this.options.debug,!e){if(i>this.minPosition||i{n*=this.FRICTION;let i=this.tvist.engine.location.get()+n,s=!1;e||(i>this.minPosition?(i=this.minPosition,n=0,s=!0):ithis.MIN_VELOCITY&&!s?this.animationId=requestAnimationFrame(o):(this.stopMomentum(),("free"!==this.options.drag||this.options.freeSnap)&&this.snapToNearest(t))};o()}snapToNearest(t){"free"===this.options.drag&&this.options.freeSnap?this.snapToNearestSlide():this.snapWithThreshold()}snapToNearestSlide(){const{engine:t,slides:i}=this.tvist,e=t.location.get();let s=0,n=1/0;for(let o=0;o0?-1:1);const h=i+a;this.startIndex,t.location.get(),this.startPosition,"realIndex"in this.tvist&&this.tvist.realIndex,this.options.loop,this.options.rewind,t.scrollTo(h)}stopMomentum(){null!==this.animationId&&(cancelAnimationFrame(this.animationId),this.animationId=null)}onResize(){this.updateCachedRefs(),this.updateBounds()}onOptionsUpdate(){this.updateCachedRefs(),this.updateBounds()}}B.MODULES.set("drag",O);class V extends T{constructor(t,i){super(t,i),this.name="navigation",this.prevButton=null,this.nextButton=null}init(){this.shouldBeActive()&&(this.findOrCreateArrows(),this.prevButton&&this.nextButton?(this.injectArrowIcons(),this.attachEvents(),this.updateArrowsState(),this.emit("navigation:mounted"),this.on("slideChangeEnd",()=>this.updateArrowsState()),this.on("lock",()=>this.updateArrowsState()),this.on("unlock",()=>this.updateArrowsState())):this.options.debug)}destroy(){this.detachEvents(),this.prevButton=null,this.nextButton=null}shouldBeActive(){const{arrows:t}=this.options;return!!t}findOrCreateArrows(){const t=this.options.arrows;"object"==typeof t&&null!==t&&(t.prev&&(this.prevButton="string"==typeof t.prev?document.querySelector(t.prev):t.prev),t.next&&(this.nextButton="string"==typeof t.next?document.querySelector(t.next):t.next)),this.prevButton??(this.prevButton=this.tvist.root.querySelector(`.${l.arrowPrev}`)),this.nextButton??(this.nextButton=this.tvist.root.querySelector(`.${l.arrowNext}`))}injectArrowIcons(){const t=this.options.arrows;("object"!=typeof t||null===t||(t.addIcons??!0))&&(this.injectIconIntoButton(this.prevButton,"prev"),this.injectIconIntoButton(this.nextButton,"next"))}injectIconIntoButton(t,i){if(!t)return;const e="prev"===i?l.arrowPrev:l.arrowNext;if(!t.classList.contains(e))return;if(t.children.length>0)return;const s=t.textContent?.trim();if(s&&s.length>0)return;const n=document.createElement("div");n.innerHTML=d;const o=n.querySelector("svg");o&&t.appendChild(o)}attachEvents(){this.prevButton&&this.nextButton&&(this.prevClickHandler=()=>this.onPrevClick(),this.nextClickHandler=()=>this.onNextClick(),this.prevButton.addEventListener("click",this.prevClickHandler),this.nextButton.addEventListener("click",this.nextClickHandler))}detachEvents(){this.prevButton&&this.prevClickHandler&&this.prevButton.removeEventListener("click",this.prevClickHandler),this.nextButton&&this.nextClickHandler&&this.nextButton.removeEventListener("click",this.nextClickHandler)}onPrevClick(){this.prevButton?.hasAttribute("disabled")||this.tvist.prev()}onNextClick(){this.nextButton?.hasAttribute("disabled")||this.tvist.next()}calculatePageCount(){const{slides:t,options:i}=this.tvist,e=i.perPage??1,s=i.slidesPerGroup??1,n=t.length,o=!0===i.loop;if(0===n)return 0;if(o)return Math.ceil(n/s);const r=Math.max(0,n-e);return Math.ceil((r+1)/s)}updateArrowsState(){if(!this.prevButton||!this.nextButton)return;const{canScrollPrev:t,canScrollNext:i}=this.tvist,e=this.options.arrows,s="object"==typeof e&&null!==e?e.disabledClass??l.arrowDisabled:l.arrowDisabled,n="object"==typeof e&&null!==e?e.hiddenClass??l.arrowHidden:l.arrowHidden,o="object"!=typeof e||null===e||(e.hideWhenSinglePage??!0);if(this.tvist.engine.isLocked)return this.disableArrow(this.prevButton,s),this.disableArrow(this.nextButton,s),void(o?(this.hideArrow(this.prevButton,n),this.hideArrow(this.nextButton,n),this.updateRootClass(!0)):(this.showArrow(this.prevButton,n),this.showArrow(this.nextButton,n),this.updateRootClass(!1)));const r=this.calculatePageCount();return o&&r<=1?(this.hideArrow(this.prevButton,n),this.hideArrow(this.nextButton,n),void this.updateRootClass(!0)):(this.updateRootClass(!1),this.options.loop||this.options.rewind?(this.enableArrow(this.prevButton,s),this.enableArrow(this.nextButton,s),this.showArrow(this.prevButton,n),void this.showArrow(this.nextButton,n)):(this.showArrow(this.prevButton,n),this.showArrow(this.nextButton,n),t?this.enableArrow(this.prevButton,s):this.disableArrow(this.prevButton,s),void(i?this.enableArrow(this.nextButton,s):this.disableArrow(this.nextButton,s))))}updateRootClass(t){t?this.tvist.root.classList.add(l.singlePage):this.tvist.root.classList.remove(l.singlePage)}enableArrow(t,i){t.removeAttribute("disabled"),t.classList.remove(i),t.setAttribute("aria-disabled","false")}disableArrow(t,i){t.setAttribute("disabled",""),t.classList.add(i),t.setAttribute("aria-disabled","true")}showArrow(t,i){t.classList.remove(i),t.setAttribute("aria-hidden","false")}hideArrow(t,i){t.classList.add(i),t.setAttribute("aria-hidden","true")}onUpdate(){this.updateArrowsState()}}B.MODULES.set("navigation",V);class D extends T{constructor(t,i){super(t,i),this.name="pagination",this.container=null,this.bullets=[],this.clickHandlers=new Map,this.updateCounter=0,this.bulletGroups=[],this.progressBarEl=null,this.updateScheduled=!1}init(){this.shouldBeActive()&&(this.findOrCreateContainer(),this.container?(this.options.loop,this.options.perPage,this.tvist.slides.length,this.tvist,this.on("slideChangeStart",t=>{this.updateActive()}),this.on("slideChangeEnd",t=>{this.updateActive(),this.options.loop&&this.scheduleUpdateActive()}),this.on("lock",()=>this.updateVisibility()),this.on("unlock",()=>this.updateVisibility()),this.render(),this.updateActive(),this.updateVisibility(),this.emit("pagination:mounted"),this.options.loop&&(this.on("loopFix",()=>{this.updateActive(),this.scheduleUpdateActive()}),this.on("transitionEnd",()=>{this.updateActive(),this.scheduleUpdateActive()}))):this.options.debug)}scheduleUpdateActive(){this.updateScheduled||(this.updateScheduled=!0,requestAnimationFrame(()=>{this.updateActive(),this.updateScheduled=!1}))}destroy(){this.detachClickHandlers(),this.container&&(this.container.innerHTML=""),this.container=null,this.bullets=[],this.progressBarEl=null}shouldBeActive(){const{pagination:t}=this.options;return!!t}getBulletLimit(t){const i=this.options.pagination;return"object"==typeof i&&i?.limit?Math.min(i.limit,t):void 0}getExpectedBulletCount(){const{slides:t}=this.tvist,i=this.options.perPage??1,e=t.length,s=!0===this.options.loop;if(0===e)return 0;const n=(s?e-1:Math.max(0,e-i))+1;return this.getBulletLimit(n)??n}calculatePageCount(){const{slides:t}=this.tvist,i=this.options.perPage??1,e=this.options.slidesPerGroup??1,s=t.length,n=!0===this.options.loop;if(0===s)return 0;if(n)return Math.ceil(s/e);const o=Math.max(0,s-i);return Math.ceil((o+1)/e)}findOrCreateContainer(){const t=this.options.pagination;"object"==typeof t&&null!==t&&t.container&&(this.container="string"==typeof t.container?document.querySelector(t.container):t.container),this.container??(this.container=this.tvist.root.querySelector(`.${l.pagination}`))}getType(){const t=this.options.pagination;return"object"==typeof t&&null!==t?t.type??"bullets":"bullets"}calculateBulletGroups(t,i){const e=this.options.pagination;return"even"===("object"==typeof e&&null!==e?e.strategy??"even":"even")?this.calculateEvenGroups(t,i):this.calculateCenterGroups(t,i)}calculateEvenGroups(t,i){const e=this.options.pagination,s="object"==typeof e&&null!==e?e.remainderStrategy??"center":"center",n=[],o=Math.floor(t/i),r=t%i;let a=0;for(let h=0;h0)if("left"===s)h=e&&h=i-r&&t++;n.push({startIndex:a,endIndex:a+t-1,count:t}),a+=t}return n}calculateCenterGroups(t,i){const e=[];if(1===i)return e.push({startIndex:0,endIndex:t-1,count:t}),e;if(2===i){const i=Math.ceil(t/2);return e.push({startIndex:0,endIndex:i-1,count:i}),e.push({startIndex:i,endIndex:t-1,count:t-i}),e}if(3===i)return e.push({startIndex:0,endIndex:0,count:1}),e.push({startIndex:1,endIndex:t-2,count:t-2}),e.push({startIndex:t-1,endIndex:t-1,count:1}),e;const s=i%2==0?Math.floor(i/2)-1:Math.floor((i-1)/2);for(let a=0;a=e.startIndex&&t<=e.endIndex)return i}return 0}getCurrentSlideIndex(){const t=this.tvist.activeIndex;if(!this.options.loop)return t;const i="realIndex"in this.tvist,e=i?this.tvist.realIndex:void 0;if("number"==typeof e)return e;const s=this.tvist.slides[t];if(s){const t=s.getAttribute("data-tvist-slide-index");if(null!==t&&""!==t){const i=parseInt(t,10);if(!isNaN(i))return i}}return s?.hasAttribute("data-tvist-slide-index"),t}render(){if(!this.container)return;this.progressBarEl=null;switch(this.getType()){case"bullets":this.renderBullets();break;case"fraction":this.renderFraction();break;case"progress":this.renderProgress();break;case"custom":this.renderCustom()}}renderBullets(){if(!this.container)return;const t=this.container,{slides:i}=this.tvist,e=this.options.pagination,s="object"!=typeof e||null===e||(e.clickable??!0),n="object"==typeof e&&null!==e?e.bulletClass??l.bullet:l.bullet;this.container.innerHTML="",this.bullets=[],this.bulletGroups=[],this.detachClickHandlers();const o=this.options.perPage??1,r=i.length,a=!0===this.options.loop?r-1:Math.max(0,r-o),h=0===r?0:a+1,d=this.getBulletLimit(h);if(d&&d`;const a=this.createElementFromHTML(r);if(t.appendChild(a),this.bullets.push(a),s){const t=o.startIndex,i=()=>this.tvist.scrollTo(t);this.clickHandlers.set(a,i),a.addEventListener("click",i),a.style.cursor="pointer"}}}else for(let l=0;l`;const o=this.createElementFromHTML(i);if(t.appendChild(o),this.bullets.push(o),s){const t=l,i=()=>this.tvist.scrollTo(t);this.clickHandlers.set(o,i),o.addEventListener("click",i),o.style.cursor="pointer"}}}renderFraction(){if(!this.container)return;const t=this.options.pagination,{slides:i}=this.tvist,e=this.options.perPage??1,s=i.length,n=!0===this.options.loop?s-1:Math.max(0,s-e),o=this.getCurrentSlideIndex()+1,r=0===s?0:n+1;let a;a="object"==typeof t&&t?.renderFraction?t.renderFraction(o,r):`\n \n \n \n `,this.container.innerHTML=a}renderProgress(){if(!this.container)return;const{slides:t}=this.tvist,i=this.options.perPage??1,e=t.length,s=!0===this.options.loop?e-1:Math.max(0,e-i),n=this.getCurrentSlideIndex()+1,o=0===e?0:s+1,r=o>0?n/o*100:0;this.container.innerHTML=`\n \n `,this.progressBarEl=this.container.querySelector(`.${l.paginationProgressBar}`)}renderCustom(){if(!this.container)return;const t=this.options.pagination;if("object"==typeof t&&t?.renderCustom){const i=t.renderCustom(this.getCurrentSlideIndex()+1,this.tvist.slides.length);this.container.innerHTML=i}}updateVisibility(){if(!this.container)return;const t=this.options.pagination,i="object"!=typeof t||null===t||(t.hideWhenSinglePage??!0),e=this.calculatePageCount();i&&(this.tvist.engine.isLocked||e<=1)?(this.container.classList.add(l.paginationHidden),this.container.setAttribute("aria-hidden","true")):(this.container.classList.remove(l.paginationHidden),this.container.setAttribute("aria-hidden","false"))}updateActive(){if(!this.container)return;this.updateCounter++,this.updateCounter,this.tvist.activeIndex,this.options.loop&&this.tvist.realIndex,this.getCurrentSlideIndex(),this.getType(),this.updateVisibility();switch(this.getType()){case"bullets":this.updateBulletsActive();break;case"fraction":this.renderFraction();break;case"progress":this.updateProgressActive();break;case"custom":this.renderCustom()}}updateBulletsActive(){const t=this.options.pagination,i="object"==typeof t&&null!==t?t.bulletActiveClass??l.bulletActive:l.bulletActive,e=this.getCurrentSlideIndex(),s=this.bulletGroups.length>0?this.getActiveBulletIndex(e):e;this.bullets.length,this.bulletGroups.length,this.tvist.activeIndex,this.options.loop&&this.tvist.realIndex,this.bullets.forEach((t,e)=>{e===s?(t.classList.add(i),t.setAttribute("aria-current","true")):(t.classList.remove(i),t.removeAttribute("aria-current"))})}updateProgressActive(){if(this.progressBarEl??(this.progressBarEl=this.container?.querySelector(`.${l.paginationProgressBar}`)??null),this.progressBarEl){const{slides:t}=this.tvist,i=this.options.perPage??1,e=t.length,s=!0===this.options.loop?e-1:Math.max(0,e-i),n=this.getCurrentSlideIndex()+1,o=0===e?0:s+1,r=o>0?n/o*100:0;this.progressBarEl.style.width=`${r}%`}}createElementFromHTML(t){const i=document.createElement("template");return i.innerHTML=t.trim(),i.content.firstChild}detachClickHandlers(){this.clickHandlers.forEach((t,i)=>{i.removeEventListener("click",t)}),this.clickHandlers.clear()}onUpdate(){if("bullets"===this.getType()){this.getExpectedBulletCount()!==this.bullets.length&&this.render(),this.updateActive()}this.updateVisibility()}}B.MODULES.set("pagination",D);const z={delay:3e3,pauseOnHover:!0,pauseOnInteraction:!0,disableOnInteraction:!1,waitForVideo:!1};function _(t){return!1===t||void 0===t?null:!0===t?{...z}:"number"==typeof t?{...z,delay:t}:{delay:t.delay??z.delay,pauseOnHover:t.pauseOnHover??z.pauseOnHover,pauseOnInteraction:t.pauseOnInteraction??z.pauseOnInteraction,disableOnInteraction:t.disableOnInteraction??z.disableOnInteraction,waitForVideo:t.waitForVideo??z.waitForVideo}}const F=class t extends T{constructor(t,i){super(t,i),this.name="autoplay",this.timer=null,this.paused=!1,this.stopped=!1,this.config=null,this.isDragging=!1,this.dragEndTimeout=null,this.pausedByVisibility=!1,this.timeLeft=null,this.currentDuration=0,this.currentChunkDuration=0,this.progressRAF=null,this.progressStartTime=null,this.progressStartOffset=0,this.waitingForVideo=!1,this.videoEndedWhilePaused=!1,this.transitionByAutoplay=!1,this.clearTransitionByAutoplayTimeout=null,this.config=_(this.options.autoplay)}init(){this.shouldBeActive()&&(this.setupEvents(),this.attachVisibilityEvents(),this.start())}destroy(){this.stop(),this.clearDragEndTimeout(),this.clearTransitionByAutoplayFallback(),this.stopProgressTracking(),this.detachHoverEvents(),this.detachVisibilityEvents(),this.detachVideoEndedListener()}shouldBeActive(){return null!==this.config}onOptionsUpdate(t){if(void 0!==t.autoplay){const i=null!==this.config,e=this.config;this.config=_(t.autoplay);const s=null!==this.config;!i&&s?(this.stopped=!1,this.setupEvents(),this.attachVisibilityEvents(),this.start()):i&&!s?(this.stop(),this.detachHoverEvents(),this.detachVisibilityEvents(),this.detachVideoEndedListener(),this.stopped=!0):i&&s&&this.config&&(this.detachHoverEvents(),this.config.pauseOnHover&&this.attachHoverEvents(),e?.waitForVideo&&!this.config.waitForVideo&&this.waitingForVideo&&(this.waitingForVideo=!1,this.videoEndedWhilePaused=!1,this.detachVideoEndedListener()),this.start())}}clearTransitionByAutoplayFallback(){null!==this.clearTransitionByAutoplayTimeout&&(window.clearTimeout(this.clearTransitionByAutoplayTimeout),this.clearTransitionByAutoplayTimeout=null)}scheduleTransitionByAutoplayFallback(){this.clearTransitionByAutoplayFallback();const i=this.options.speed??300;this.clearTransitionByAutoplayTimeout=window.setTimeout(()=>{this.clearTransitionByAutoplayTimeout=null,this.transitionByAutoplay&&(this.transitionByAutoplay=!1)},i*t.TRANSITION_FALLBACK_MULTIPLIER)}clearDragEndTimeout(){null!==this.dragEndTimeout&&(window.clearTimeout(this.dragEndTimeout),this.dragEndTimeout=null)}resumeAfterDrag(){this.isDragging&&(this.isDragging=!1,this.clearDragEndTimeout(),this.timeLeft=null,this.progressStartOffset=0,this.config?.disableOnInteraction||this.stopped||!this.paused||this.resume())}setupEvents(){this.config&&(this.config.pauseOnHover&&this.attachHoverEvents(),this.on("dragStart",()=>{this.isDragging=!0,this.clearDragEndTimeout(),this.config?.disableOnInteraction?(this.stop(),this.stopped=!0):this.pause()}),this.on("dragEnd",()=>{if(!this.isDragging)return;const t=this.options.speed??300;this.dragEndTimeout=window.setTimeout(()=>{this.resumeAfterDrag()},t+100)}),this.on("transitionEnd",()=>{this.isDragging?this.resumeAfterDrag():this.config?.disableOnInteraction||this.stopped||!this.paused||this.resume()}),this.on("slideChangeEnd",t=>{const i=this.transitionByAutoplay;this.transitionByAutoplay&&(this.transitionByAutoplay=!1,this.clearTransitionByAutoplayFallback()),i||this.paused||this.stopped?this.config?.waitForVideo&&this.handleSlideChangedForVideo(t):(this.cancelTimer(),this.timeLeft=null,this.progressStartOffset=0,this.stopProgressTracking(),this.config?.waitForVideo?this.handleSlideChangedForVideo(t):this.run())}))}handleSlideChangedForVideo(t){this.detachVideoEndedListener(),this.waitingForVideo=!1,this.videoEndedWhilePaused=!1;const i=this.findSlideByRealIndex(t);if(!i)return this.cancelTimer(),this.stopProgressTracking(),this.timeLeft=null,this.progressStartOffset=0,void this.run();if(!i.querySelector("video"))return this.cancelTimer(),this.stopProgressTracking(),this.timeLeft=null,this.progressStartOffset=0,void this.run();this.waitingForVideo=!0,this.cancelTimer(),this.stopProgressTracking(),this.videoEndedHandler=()=>{if(this.stopped||!this.waitingForVideo)return;if(this.paused)return void(this.videoEndedWhilePaused=!0);this.waitingForVideo=!1;const t=this.tvist.activeIndex;this.transitionByAutoplay=!0,this.tvist.next(),this.tvist.activeIndex===t?this.transitionByAutoplay=!1:this.scheduleTransitionByAutoplayFallback()},this.on("videoEnded",this.videoEndedHandler)}findSlideByRealIndex(t){const i=this.tvist.slides;for(const e of i){const i=e.getAttribute("data-tvist-slide-index");if(null!==i&&parseInt(i,10)===t)return e}return i[t]}detachVideoEndedListener(){this.videoEndedHandler&&(this.off("videoEnded",this.videoEndedHandler),this.videoEndedHandler=void 0)}attachHoverEvents(){this.mouseEnterHandler=()=>{this.pause()},this.mouseLeaveHandler=()=>{this.resume()},this.tvist.root.addEventListener("mouseenter",this.mouseEnterHandler),this.tvist.root.addEventListener("mouseleave",this.mouseLeaveHandler)}detachHoverEvents(){this.mouseEnterHandler&&(this.tvist.root.removeEventListener("mouseenter",this.mouseEnterHandler),this.mouseEnterHandler=void 0),this.mouseLeaveHandler&&(this.tvist.root.removeEventListener("mouseleave",this.mouseLeaveHandler),this.mouseLeaveHandler=void 0)}attachVisibilityEvents(){this.visibilityChangeHandler=()=>{"hidden"===document.visibilityState?(this.pausedByVisibility=!0,this.pause()):"visible"===document.visibilityState&&this.pausedByVisibility&&(this.pausedByVisibility=!1,this.resume())},document.addEventListener("visibilitychange",this.visibilityChangeHandler)}detachVisibilityEvents(){this.visibilityChangeHandler&&(document.removeEventListener("visibilitychange",this.visibilityChangeHandler),this.visibilityChangeHandler=void 0)}run(){if(this.paused||this.stopped||!this.config)return;if(this.waitingForVideo)return;const t=this.timeLeft??this.config.delay;null===this.timeLeft&&(this.currentDuration=this.config.delay,this.progressStartOffset=0),this.currentChunkDuration=t,this.startProgressTracking(t,this.currentDuration,this.progressStartOffset),this.timer=window.setTimeout(()=>{if(!this.paused&&!this.stopped){this.timeLeft=null,this.progressStartOffset=0,this.stopProgressTracking();const t=this.tvist.activeIndex;this.transitionByAutoplay=!0,this.tvist.next(),this.tvist.activeIndex===t?this.transitionByAutoplay=!1:this.scheduleTransitionByAutoplayFallback(),this.run()}},t)}startProgressTracking(t,i,e){if(this.stopProgressTracking(),t<=0)return void this.emit("autoplayProgress",{progress:1,index:this.tvist.activeIndex});this.progressStartTime=performance.now();const s=()=>{if(this.paused||this.stopped||null===this.progressStartTime)return;const n=performance.now()-this.progressStartTime,o=Math.min(n/t,1);let r=e+o*(t/i);r=Math.min(r,1),this.emit("autoplayProgress",{progress:r,index:this.tvist.activeIndex}),r<1&&!this.paused&&!this.stopped&&(this.progressRAF=requestAnimationFrame(s))};this.progressRAF=requestAnimationFrame(s)}stopProgressTracking(){null!==this.progressRAF&&(cancelAnimationFrame(this.progressRAF),this.progressRAF=null),this.progressStartTime=null}cancelTimer(){null!==this.timer&&(window.clearTimeout(this.timer),this.timer=null)}start(){if(!this.stopped){if(this.stop(),this.paused=!1,this.config?.waitForVideo){const t=this.tvist.realIndex??this.tvist.activeIndex;this.handleSlideChangedForVideo(t)}else this.run();this.emit("autoplayStart")}}stop(){this.cancelTimer(),this.clearTransitionByAutoplayFallback(),this.stopProgressTracking(),this.emit("autoplayStop")}pause(){if(!this.paused){if(this.paused=!0,null!==this.timer&&null!==this.progressStartTime&&!this.waitingForVideo){const t=performance.now()-this.progressStartTime;this.timeLeft=Math.max(0,this.currentChunkDuration-t);const i=t/this.currentDuration;this.progressStartOffset=Math.min(1,this.progressStartOffset+i)}this.cancelTimer(),this.stopProgressTracking(),this.emit("autoplayPause")}}resume(){if(!this.pausedByVisibility&&this.paused&&!this.stopped){if(this.paused=!1,this.videoEndedWhilePaused&&this.waitingForVideo){this.videoEndedWhilePaused=!1,this.waitingForVideo=!1;const t=this.tvist.activeIndex;return this.transitionByAutoplay=!0,this.tvist.next(),this.tvist.activeIndex===t?(this.transitionByAutoplay=!1,this.config?.waitForVideo?this.handleSlideChangedForVideo(this.tvist.realIndex??this.tvist.activeIndex):this.run()):this.scheduleTransitionByAutoplayFallback(),void this.emit("autoplayResume")}this.videoEndedWhilePaused=!1,this.run(),this.emit("autoplayResume")}}getAutoplay(){return{start:()=>{this.stopped=!1,this.start()},stop:()=>this.stop(),pause:()=>this.pause(),resume:()=>this.resume(),isRunning:()=>null!==this.timer&&!this.paused,isPaused:()=>this.paused,isStopped:()=>this.stopped}}};F.TRANSITION_FALLBACK_MULTIPLIER=5;let R=F;B.MODULES.set("autoplay",R),B.MODULES.set("breakpoints",k);const H=(t,i)=>{};class $ extends T{constructor(t,i){super(t,i),this.name="loop",this.loopedSlides=0,this.isInitialized=!1}init(){if(!this.options.loop)return;if(this.isInitialized)return;if(this.tvist.slides.length<1)return;this.isInitialized=!0;const t=this.options.start??0,i=this.options.center??!1;this.loopFix({slideRealIndex:t,direction:i?void 0:"next",initial:!0}),this.loopedSlides,this.tvist.slides.length,this.tvist.engine.index.get(),this.on("beforeTransitionStart",t=>{this.loopFix({direction:t.direction})}),Object.defineProperty(this.tvist,"realIndex",{get:()=>this.getRealIndex(),configurable:!0}),this.tvist,this.tvist.realIndex}onOptionsUpdate(t){!0===t.loop?this.init():!1===t.loop&&this.destroy()}fix(t={}){return this.loopFix(t)}getTransformState(){const t=this.tvist.slides;return{location:this.tvist.engine.location.get(),target:this.tvist.engine.target.get(),activeIndex:this.tvist.engine.index.get(),realIndex:this.getRealIndex(),transform:this.tvist.container.style.transform,slidesOrder:t.map(t=>t.getAttribute("data-tvist-slide-index")??"?"),slidesText:t.map(t=>t.textContent?.trim()||"?"),loopedSlides:this.loopedSlides}}pause(t){this.tvist.engine.animator.stop()}loopFix(t={}){const{slideRealIndex:i,slideTo:e=!0,direction:s,setTranslate:n,activeSlideIndex:o,initial:r=!1}=t;if(!this.options.loop)return this.tvist.engine.index.get();this.tvist.engine.index.get(),this.tvist.engine.location.get(),this.tvist.engine.target.get(),this.emit("beforeLoopFix");const a=this.tvist.slides,h=this.tvist.container,l=a.length,d=this.options.perPage??1;let c="number"==typeof d?d:1;const u=this.options.center??!1;u&&c%2==0&&(c+=1);const p=this.options.slidesPerGroup??1;let v=u?Math.max(p,Math.ceil(c/2)):c;u||(v=Math.max(p,c)),v%p!==0&&(v+=p-v%p),this.loopedSlides=v;const g=o??this.tvist.engine.index.get(),m="next"===s||!s,f="prev"===s||!s;let b=0,y=0;const S=[],x=[],E=g+(u&&void 0===n?-c/2+.5:0);if(El-v&&m){y=Math.max(E-(l-2*v),p);for(let t=0;t0){const t=document.createDocumentFragment();for(let i=S.length-1;i>=0;i--){const e=S[i];if(void 0!==e){const i=a[e];i&&t.appendChild(i)}}h.prepend(t)}if(m&&x.length>0){const t=document.createDocumentFragment();x.forEach(i=>{const e=a[i];e&&t.appendChild(e)}),h.append(t)}if(h.offsetLeft,this.tvist.updateSlidesList(),e&&(S.length>0?this.tvist.engine.index.set(g+Math.ceil(b)):x.length>0&&this.tvist.engine.index.set(g-y)),0===S.length&&0===x.length);else{const t=this.tvist.engine.location.get(),i=this.tvist.engine.target.get();this.tvist.update(),this.tvist.engine.location.set(t),this.tvist.engine.target.set(i)}if(S.length>0){const t=T[g]??0,i=P-(this.tvist.engine.getSlidePosition(g+Math.ceil(b))-t);this.tvist.engine.location.set(i),this.tvist.engine.target.set(i),this.tvist.engine.applyTransformPublic()}else if(x.length>0){const t=T[g]??0,i=P-(this.tvist.engine.getSlidePosition(g-y)-t);this.tvist.engine.location.set(i),this.tvist.engine.target.set(i),this.tvist.engine.applyTransformPublic()}if((r||S.length>0||x.length>0)&&void 0!==i){const t=this.tvist.slides;for(let e=0;e=t.length)return 0;const e=t[i];if(!e)return 0;const s=e.getAttribute("data-tvist-slide-index");if(s){return parseInt(s,10)}return i}destroy(){if(!this.isInitialized)return;const t=this.tvist.slides,i=this.tvist.container,e=this.getRealIndex(),s=[];t.forEach(t=>{const i=t.getAttribute("data-tvist-slide-index");if(i){const e=parseInt(i,10);s[e]=t}}),t.forEach(t=>{t.removeAttribute("data-tvist-slide-index")});const n=document.createDocumentFragment();if(s.forEach(t=>{t&&n.appendChild(t)}),i.appendChild(n),this.tvist.updateSlidesList(),this.tvist.update(),this.tvist.scrollTo(e,!0),Object.getOwnPropertyDescriptor(this.tvist,"realIndex")){delete this.tvist.realIndex}this.isInitialized=!1}}B.MODULES.set("loop",$);const q="undefined"!=typeof navigator&&/Firefox/i.test(navigator.userAgent);class N extends T{constructor(t,i){super(t,i),this.name="slide-states",this.CLASS_ACTIVE=l.slideActive,this.CLASS_PREV=l.slidePrev,this.CLASS_NEXT=l.slideNext,this.CLASS_VISIBLE=l.slideVisible,this.visibilityUpdateScheduled=!1,this.visibilityRafId=null,this.decodedImages=new WeakMap,this.preloadedSlides=new WeakMap}init(){this.applyFirefoxImageFix(),this.updateActiveClasses(),this.updateVisibleClasses(),this.tvist.on("slideChangeStart",()=>{this.updateActiveClasses(),this.updateVisibleClasses()}),this.tvist.on("slideChangeEnd",()=>this.updateVisibleClasses()),this.tvist.on("scroll",()=>this.scheduleVisibilityUpdate())}onUpdate(){this.updateActiveClasses(),this.updateVisibleClasses()}scheduleVisibilityUpdate(){this.visibilityUpdateScheduled||(this.visibilityUpdateScheduled=!0,this.visibilityRafId=requestAnimationFrame(()=>{this.visibilityUpdateScheduled=!1,this.updateVisibleClasses()}))}applyFirefoxImageFix(){const t=this.options.browserFixes?.firefoxImageDecoding??!0;q&&t&&this.tvist.slides.forEach(t=>{t.querySelectorAll("img").forEach(t=>{t.hasAttribute("decoding")||t.setAttribute("decoding","sync")})})}async preloadSlideImages(t){if(this.preloadedSlides.has(t))return;const i=t.querySelectorAll("img"),e=[];i.forEach(t=>{t.complete&&t.naturalWidth>0&&!this.decodedImages.has(t)&&"decode"in t&&e.push(t.decode().then(()=>{this.decodedImages.set(t,!0)}).catch(()=>{}))}),await Promise.all(e).catch(()=>{}),this.preloadedSlides.set(t,!0)}updateActiveClasses(){const t=this.tvist.slides,i=this.tvist.activeIndex,e=t[i];if(!e)return;const s=[],n=e.getAttribute("data-tvist-slide-index"),o=null!==n||!0===this.options.loop;let r=i;const a=t.length;null!==n&&(r=parseInt(n,10));let h=r-1,l=r+1;o&&(h=(r-1+a)%a,l=(r+1)%a),t.forEach((t,e)=>{let n=e;if(o){const i=t.getAttribute("data-tvist-slide-index");null!==i&&(n=parseInt(i,10))}const a=n===r;let d=!1,c=!1;o?(d=n===h,c=n===l):(d=e===i-1,c=e===i+1),this.toggleClass(t,this.CLASS_ACTIVE,a),this.toggleClass(t,this.CLASS_PREV,d),this.toggleClass(t,this.CLASS_NEXT,c),(d||c)&&s.push(this.preloadSlideImages(t))}),s.length>0&&Promise.all(s).catch(()=>{})}updateVisibleClasses(){const t=this.tvist.slides,i=this.tvist.engine.getVisibleSlides();t.forEach((t,e)=>{const s=i[e]??!1,n=t.classList.contains(this.CLASS_VISIBLE);s&&!n?(t.classList.add(this.CLASS_VISIBLE),this.tvist.emit("visible",t,e)):!s&&n&&(t.classList.remove(this.CLASS_VISIBLE),this.tvist.emit("hidden",t,e))})}toggleClass(t,i,e){e&&!t.classList.contains(i)?t.classList.add(i):!e&&t.classList.contains(i)&&t.classList.remove(i)}destroy(){null!==this.visibilityRafId&&(cancelAnimationFrame(this.visibilityRafId),this.visibilityRafId=null),this.tvist.slides.forEach(t=>{t.classList.remove(this.CLASS_ACTIVE,this.CLASS_PREV,this.CLASS_NEXT,this.CLASS_VISIBLE)})}}B.registerModule("slide-states",N);class U extends T{constructor(){super(...arguments),this.name="thumbs"}init(){this.options.isNavigation&&this.initNavigation()}initNavigation(){this.tvist.root.classList.add(l.nav);const t=this.tvist.slides,i=[],e=l.slideNavActive;t.forEach((t,e)=>{const s=()=>{this.tvist.options.isNavigation&&(this.tvist.emit("navigation:click",e),this.tvist.scrollTo(e))};t.addEventListener("click",s),i.push(()=>t.removeEventListener("click",s))}),this.removeClickListeners=()=>{i.forEach(t=>t())};const s=i=>{t.forEach((t,s)=>{s===i?t.classList.add(e):t.classList.remove(e)})};this.on("slideChangeStart",s),this.on("slideChangeEnd",s),this.on("created",()=>{s(this.tvist.activeIndex)}),s(this.tvist.activeIndex)}destroy(){this.removeClickListeners?.()}}B.registerModule("thumbs",U);const j=new WeakMap;function W(t,i,e){const{container:s,root:n}=t,o=e.cubeEffect??{},r=t.engine.slideSizeValue;s.style.width="100%",s.style.height="100%";const a=(s.clientWidth>0?s.clientWidth:r)/2,h=o.slideShadows??!0,d=o.perspective??800;n.style.perspective=`${d}px`,n.style.webkitPerspective=`${d}px`;const c=o.perspectiveOriginY??60;n.style.perspectiveOrigin=`50% ${c}%`,s.style.transformStyle="preserve-3d",s.style.webkitTransformStyle="preserve-3d";const u=function(t){const{slides:i}=t;let e=j.get(t);return e?.lastSlidesList&&e.lastSlidesList===i||(e={slides:Array.from(i),shadows:e?.shadows??new WeakMap,lastSlidesList:i},j.set(t,e)),e.slides}(t),p=u.length,v=-i/r,g=-90*v;s.style.transformOrigin="50% 50%",s.style.transform=`translate3d(0,0,-${a}px) rotateY(${g}deg)`,u.forEach((i,e)=>{const s=90*e;let n=(s+g)%360;n<0&&(n+=360);const o=`rotateY(${s}deg) translate3d(0, 0, ${a}px)`;i.style.transform=o;const r=Math.round(100*Math.cos(n*Math.PI/180));i.style.zIndex=`${100+r}`;let d=e-v;Math.abs(d)>p/2&&(d-=p*Math.round(d/p));const c=Math.abs(d)<=1;if(i.style.visibility=c?"visible":"hidden",h&&c){let e=n;e>180&&(e-=360);!function(t,i,e){const s=j.get(e);if(!s)return;let n=s.shadows.get(t);if(!n){const i=document.createElement("div"),e=document.createElement("div"),o=l.block;i.className=`${o}-slide-shadow-cube ${o}-slide-shadow-left`,e.className=`${o}-slide-shadow-cube ${o}-slide-shadow-right`,t.appendChild(i),t.appendChild(e),n={left:i,right:e},s.shadows.set(t,n)}const o=Math.max(-i,0),r=Math.max(i,0);n.left.style.opacity=o.toString(),n.right.style.opacity=r.toString()}(i,Math.max(Math.min(e/90,1),-1),t)}})}class G extends T{constructor(t,i){super(t,i),this.name="effect",this.slideProgress=new WeakMap}init(){if(this.options.effect&&"slide"!==this.options.effect){if(1!==this.options.perPage&&(this.options.debug,this.options.perPage=1,this.tvist.update()),"cube"===this.options.effect){this.tvist.container.style.transformStyle="preserve-3d",this.tvist.root.classList.add(l.cube);const t=this.options.cubeEffect?.viewportPadding??10;this.tvist.root.style.padding=`${t}px`,this.tvist.root.style.boxSizing="border-box"}this.tvist.on("setTranslate",this.onSetTranslate.bind(this))}}destroy(){this.tvist.off("setTranslate",this.onSetTranslate.bind(this)),this.tvist.slides.forEach(t=>{t.style.opacity="",t.style.transform="",t.style.zIndex="",t.style.backfaceVisibility="",t.style.contentVisibility="",t.style.visibility=""}),this.tvist.container.style.transformStyle="",this.tvist.container.style.width="",this.tvist.container.style.height="",this.tvist.root.style.removeProperty("perspective"),this.tvist.root.style.removeProperty("-webkit-perspective"),this.tvist.root.style.removeProperty("perspective-origin"),this.tvist.root.style.removeProperty("overflow"),this.tvist.root.style.removeProperty("padding"),this.tvist.root.style.removeProperty("box-sizing"),this.tvist.root.classList.remove(l.cube)}onSetTranslate(t,i){const{slides:e}=this.tvist,s=this.tvist.engine.slideSizeValue;e.forEach((t,e)=>{const n=this.tvist.engine.getSlidePosition(e),o=(i+n)/s;this.slideProgress.set(t,o),"fade"===this.options.effect&&function(t,i){const e=Math.max(1-Math.abs(i),0);t.style.opacity=String(e),t.style.transform=`translate3d(${100*-i}%, 0, 0)`;const s=Math.max(1,100-Math.abs(10*i));t.style.zIndex=String(Math.round(s))}(t,o,this.options)}),"cube"===this.options.effect&&W(this.tvist,i,this.options)}}B.registerModule("effect",G);class X extends T{constructor(t,i){super(t,i),this.name="grid",this.isActive=!1,this.originalSlides=[],this.wrapperSlides=[]}init(){this.shouldBeActive()&&(this.isActive=!0,this.buildGrid(),this.fixEnginePositions())}destroy(){this.removeGrid()}onUpdate(){const t=this.isActive;this.shouldBeActive()?(t&&this.removeGrid(),this.isActive=!0,this.buildGrid(),this.fixEnginePositions()):t&&(this.isActive=!1,this.removeGrid(),this.tvist.engine.update())}shouldBeActive(){const{grid:t}=this.options;return!!t&&(!!t.rows||!!t.cols||!!t.dimensions&&t.dimensions.length>0)}hasDimensions(){const{grid:t}=this.options;return!!(t?.dimensions&&t.dimensions.length>0)}buildGrid(){const{grid:t}=this.options;if(!t)return;0===this.originalSlides.length&&(this.originalSlides=Array.from(this.tvist.slides));const i=this.tvist.container;i.innerHTML="",i.style.display="flex",this.wrapperSlides=[],this.hasDimensions()?this.buildDimensionsGrid():this.buildFixedGrid(),this.tvist.updateSlidesList()}buildFixedGrid(){const{grid:t}=this.options;if(!t?.rows||!t?.cols)return;const i=t.rows,e=t.cols,s=i*e,n=Math.ceil(this.originalSlides.length/s);let o=0;const r=document.createDocumentFragment();for(let a=0;a"number"==typeof t?t:parseInt(t,10)||0;if(i.gap){if("object"==typeof i.gap){return s(i.gap[t]??e)}return s(i.gap)}return s(e)}removeGrid(){if(this.originalSlides.length>0){const t=this.tvist.container;t.style.display="",t.innerHTML="";const i=document.createDocumentFragment();this.originalSlides.forEach(t=>{t.classList.remove(l.gridItem),t.classList.add(l.slide),t.style.width="",t.style.height="",i.appendChild(t)}),t.appendChild(i),this.tvist.updateSlidesList(),this.originalSlides=[],this.wrapperSlides=[]}}fixEnginePositions(){const t=this.tvist.engine,i=this.tvist.slides,e=i.map(t=>t.offsetLeft);if(t.setSlidePositions(e),i.length>0){const e=i[0];if(e){const i=e.offsetWidth;t.setSlideSize(i)}}const s=t.index.get(),n=t.getScrollPositionForIndex(s);t.target.set(n),t.location.set(n),t.applyTransformPublic(),t.checkLock()}}B.MODULES.set("grid",X);class Y extends T{constructor(t,i){super(t,i),this.name="ScrollControl",this.isScrolling=!1,this.lastWheelTime=0,this.wheelThrottle=50,this.handleWheel=t=>{const i="vertical"===this.options.direction;let e=t.deltaY;if(Math.abs(t.deltaY)<1&&Math.abs(t.deltaX)>0){if(i)return;e=t.deltaX}if(i&&Math.abs(t.deltaX)>Math.abs(t.deltaY))return;if(!i&&Math.abs(t.deltaX)>Math.abs(t.deltaY)&&Math.abs(t.deltaX)>0&&(e=t.deltaX),Math.abs(e)<1)return;const s=Date.now();if(s-this.lastWheelTime0,a=e<0;if(this.releaseOnEdges&&(n&&a||o&&r))return;if(t.preventDefault(),this.isScrolling)return;const h=Math.sign(e)*this.sensitivity;h>0?this.tvist.next():h<0&&this.tvist.prev(),this.isScrolling=!0,this.scrollTimer&&window.clearTimeout(this.scrollTimer);const l=this.options.speed??300;this.scrollTimer=window.setTimeout(()=>{this.isScrolling=!1},l+50)};const e=this.getWheelOptions();this.sensitivity=e.sensitivity??1,this.releaseOnEdges=e.releaseOnEdges??!0}getWheelOptions(){const t=this.options.wheel;return"boolean"==typeof t?{}:t??{}}shouldBeActive(){return!1!==this.options.wheel&&void 0!==this.options.wheel}init(){this.shouldBeActive()&&this.attachWheelListener()}attachWheelListener(){this.tvist.root.addEventListener("wheel",this.handleWheel,{passive:!1})}onOptionsUpdate(t){if(void 0!==t.wheel){const i="boolean"==typeof t.wheel?{}:t.wheel??{};this.sensitivity=i.sensitivity??1,this.releaseOnEdges=i.releaseOnEdges??!0}}destroy(){this.scrollTimer&&window.clearTimeout(this.scrollTimer),this.tvist.root.removeEventListener("wheel",this.handleWheel)}}B.registerModule("scroll-control",Y);class Q extends T{constructor(t,i){super(t,i),this.name="Scrollbar",this.isCustomContainer=!1,this.isDragging=!1,this.dragStartX=0,this.dragStartY=0,this.dragStartScroll=0,this.handleTrackClick=t=>{if(!this.trackEl||!this.thumbEl)return;if(t.target===this.thumbEl)return;const i="vertical"===this.options.direction,e=this.trackEl.getBoundingClientRect();let s,n;i?(s=t.clientY-e.top,n=e.height):(s=t.clientX-e.left,n=e.width);const o=s/n,r=this.tvist.slides.length,a=Math.round(o*(r-1));this.tvist.scrollTo(a)},this.handleThumbMouseDown=t=>{t.preventDefault(),this.startDrag(t.clientX,t.clientY),document.addEventListener("mousemove",this.handleThumbMouseMove),document.addEventListener("mouseup",this.handleThumbMouseUp)},this.handleThumbTouchStart=t=>{if(1!==t.touches.length)return;const i=t.touches[0];i&&(this.startDrag(i.clientX,i.clientY),document.addEventListener("touchmove",this.handleThumbTouchMove,{passive:!1}),document.addEventListener("touchend",this.handleThumbTouchEnd))},this.handleThumbMouseMove=t=>{this.isDragging&&(t.preventDefault(),this.updateDrag(t.clientX,t.clientY))},this.handleThumbTouchMove=t=>{if(!this.isDragging||1!==t.touches.length)return;t.preventDefault();const i=t.touches[0];i&&this.updateDrag(i.clientX,i.clientY)},this.handleThumbMouseUp=()=>{this.endDrag(),document.removeEventListener("mousemove",this.handleThumbMouseMove),document.removeEventListener("mouseup",this.handleThumbMouseUp)},this.handleThumbTouchEnd=()=>{this.endDrag(),document.removeEventListener("touchmove",this.handleThumbTouchMove),document.removeEventListener("touchend",this.handleThumbTouchEnd)},this.handleScroll=()=>{this.updateScrollbar()},this.handleSlideChanged=()=>{this.updateScrollbar()},this.showScrollbar=()=>{this.hide&&(this.scrollbarEl?.classList.remove(l.scrollbarHidden),this.hideTimer&&(window.clearTimeout(this.hideTimer),this.hideTimer=void 0))},this.startHideTimer=()=>{this.hide&&!this.isDragging&&(this.hideTimer=window.setTimeout(()=>{this.scrollbarEl?.classList.add(l.scrollbarHidden)},this.hideDelay))};const e=this.getScrollbarOptions();this.hide=e.hide??!1,this.hideDelay=e.hideDelay??1e3,this.draggable=e.draggable??!0}getScrollbarOptions(){const t=this.options.scrollbar;return"boolean"==typeof t?{}:t??{}}shouldBeActive(){return!1!==this.options.scrollbar&&void 0!==this.options.scrollbar}init(){this.shouldBeActive()&&(this.createScrollbar(),this.attachEventListeners(),this.updateScrollbar())}createScrollbar(){const t=this.getScrollbarOptions(),i="vertical"===this.options.direction;if(t.container){const i="string"==typeof t.container?document.querySelector(t.container):t.container;i&&(this.scrollbarEl=i,this.isCustomContainer=!0)}this.scrollbarEl||(this.scrollbarEl=document.createElement("div"),this.scrollbarEl.className=t.scrollbarClass??l.scrollbar,i?this.scrollbarEl.classList.add(l.scrollbarVertical):this.scrollbarEl.classList.add(l.scrollbarHorizontal),this.tvist.root.appendChild(this.scrollbarEl)),this.trackEl=document.createElement("div"),this.trackEl.className=t.trackClass??l.scrollbarTrack,this.thumbEl=document.createElement("div"),this.thumbEl.className=t.thumbClass??l.scrollbarThumb,this.trackEl.appendChild(this.thumbEl),this.scrollbarEl.appendChild(this.trackEl),this.hide&&this.scrollbarEl.classList.add(l.scrollbarHidden)}attachEventListeners(){this.scrollbarEl&&this.thumbEl&&this.trackEl&&(this.trackEl.addEventListener("click",this.handleTrackClick),this.draggable&&(this.thumbEl.addEventListener("mousedown",this.handleThumbMouseDown),this.thumbEl.addEventListener("touchstart",this.handleThumbTouchStart,{passive:!0})),this.on("scroll",this.handleScroll),this.on("slideChangeEnd",this.handleSlideChanged),this.updateAutoHideListeners())}startDrag(t,i){this.isDragging=!0,this.dragStartX=t,this.dragStartY=i,this.dragStartScroll=this.tvist.engine.location.get(),this.scrollbarEl?.classList.add(l.scrollbarDragging)}updateDrag(t,i){if(!this.trackEl)return;const e="vertical"===this.options.direction,s=this.trackEl.getBoundingClientRect();let n,o;e?(n=i-this.dragStartY,o=s.height):(n=t-this.dragStartX,o=s.width);const r=n/o,a=this.tvist.slides.length,h=this.tvist.engine.getScrollPositionForIndex(0),l=this.tvist.engine.getScrollPositionForIndex(a-1)-h,d=this.dragStartScroll+r*l,c=this.tvist.engine.getMinScrollPosition(),u=this.tvist.engine.getMaxScrollPosition(),p=Math.max(u,Math.min(c,d));this.tvist.engine.location.set(p),this.tvist.engine.target.set(p),this.tvist.engine.applyTransformPublic(),this.updateScrollbar();let v=0,g=1/0;for(let m=0;m0?s/n:0,r=100-e,a=Math.max(0,Math.min(r,o*r));t?(this.thumbEl.style.height=`${e}%`,this.thumbEl.style.width="100%",this.thumbEl.style.top=`${a}%`,this.thumbEl.style.left="0",this.thumbEl.style.transform="none"):(this.thumbEl.style.width=`${e}%`,this.thumbEl.style.height="100%",this.thumbEl.style.left=`${a}%`,this.thumbEl.style.top="0",this.thumbEl.style.transform="none")}onUpdate(){this.updateScrollbar()}updateAutoHideListeners(){this.tvist.root.removeEventListener("mouseenter",this.showScrollbar),this.tvist.root.removeEventListener("mouseleave",this.startHideTimer),this.hideTimer&&(window.clearTimeout(this.hideTimer),this.hideTimer=void 0),this.hide?(this.tvist.root.addEventListener("mouseenter",this.showScrollbar),this.tvist.root.addEventListener("mouseleave",this.startHideTimer)):this.scrollbarEl?.classList.remove(l.scrollbarHidden)}onOptionsUpdate(t){if(void 0!==t.scrollbar){const i="boolean"==typeof t.scrollbar?{}:t.scrollbar??{};this.hide=i.hide??!1,this.hideDelay=i.hideDelay??1e3,this.draggable=i.draggable??!0,this.updateAutoHideListeners(),this.hide&&this.scrollbarEl?.classList.add(l.scrollbarHidden),this.updateScrollbar()}}destroy(){this.hideTimer&&window.clearTimeout(this.hideTimer),this.trackEl&&this.trackEl.removeEventListener("click",this.handleTrackClick),this.thumbEl&&(this.thumbEl.removeEventListener("mousedown",this.handleThumbMouseDown),this.thumbEl.removeEventListener("touchstart",this.handleThumbTouchStart)),document.removeEventListener("mousemove",this.handleThumbMouseMove),document.removeEventListener("mouseup",this.handleThumbMouseUp),document.removeEventListener("touchmove",this.handleThumbTouchMove),document.removeEventListener("touchend",this.handleThumbTouchEnd),this.tvist.root.removeEventListener("mouseenter",this.showScrollbar),this.tvist.root.removeEventListener("mouseleave",this.startHideTimer),!this.isCustomContainer&&this.scrollbarEl&&this.scrollbarEl.remove()}}B.registerModule("scrollbar",Q);class J extends T{constructor(t,i){super(t,i),this.name="marquee",this.rafId=null,this.paused=!1,this.stopped=!1,this.lastTimestamp=null,this.totalSize=0,this.currentPosition=0,this.cachedSlideSizes=[];const e=this.options.marquee;"object"==typeof e?(this.speed=e.speed??50,this.direction=e.direction??this.getDefaultDirection()):(this.speed=50,this.direction=this.getDefaultDirection())}getDefaultDirection(){return"vertical"===this.options.direction?"up":"left"}init(){this.shouldBeActive()&&(this.options.loop||this.tvist.updateOptions({loop:!0}),this.fixLastSlideGap(),this.calculateTotalSize(),this.tvist.engine.animator.stop(),this.setupEvents(),this.on("dragStart",()=>this.pause()),this.on("dragEnd",()=>this.resume()),this.start())}destroy(){this.stop(),this.detachHoverEvents(),this.off("dragStart"),this.off("dragEnd")}shouldBeActive(){return!1!==this.options.marquee&&void 0!==this.options.marquee}onOptionsUpdate(t){if(void 0!==t.marquee){const i=null!==this.rafId,e=!1!==t.marquee&&void 0!==t.marquee;"object"==typeof t.marquee&&(void 0!==t.marquee.speed&&(this.speed=t.marquee.speed),void 0!==t.marquee.direction&&(this.direction=t.marquee.direction)),!i&&e?(this.stopped=!1,this.calculateTotalSize(),this.setupEvents(),this.start()):i&&!e?(this.stop(),this.detachHoverEvents(),this.stopped=!0):i&&e&&t.marquee&&"object"==typeof t.marquee&&t.marquee.direction&&(this.calculateTotalSize(),this.currentPosition=0)}t.marquee&&"object"==typeof t.marquee&&void 0!==t.marquee.pauseOnHover&&this.shouldBeActive()&&(this.detachHoverEvents(),this.setupEvents())}onUpdate(){this.shouldBeActive()&&(this.fixLastSlideGap(),this.calculateTotalSize())}fixLastSlideGap(){const t=this.options.gap??0;if(t<=0)return;const i=this.tvist.slides;if(0===i.length)return;const e="vertical"!==this.options.direction,s=i[i.length-1];s&&(e?s.style.marginRight||(s.style.marginRight=`${t}px`):s.style.marginBottom||(s.style.marginBottom=`${t}px`))}calculateTotalSize(){const t="vertical"!==this.options.direction,i=this.options.gap??0;if(0===this.tvist.slides.length)return this.totalSize=0,void(this.cachedSlideSizes=[]);this.cachedSlideSizes=this.tvist.slides.map(i=>t?i.offsetWidth:i.offsetHeight),this.totalSize=this.cachedSlideSizes.reduce((t,e)=>t+e+i,0)}setupEvents(){const t=this.options.marquee;("object"!=typeof t||t.pauseOnHover)&&this.attachHoverEvents()}attachHoverEvents(){this.mouseEnterHandler=()=>this.pause(),this.mouseLeaveHandler=()=>this.resume(),this.tvist.root.addEventListener("mouseenter",this.mouseEnterHandler),this.tvist.root.addEventListener("mouseleave",this.mouseLeaveHandler)}detachHoverEvents(){this.mouseEnterHandler&&this.tvist.root.removeEventListener("mouseenter",this.mouseEnterHandler),this.mouseLeaveHandler&&this.tvist.root.removeEventListener("mouseleave",this.mouseLeaveHandler)}start(){if(this.stopped)return;this.stop(),this.paused=!1,this.lastTimestamp=null;const t=i=>{if(this.stopped)return;this.lastTimestamp??(this.lastTimestamp=i);const e=(i-this.lastTimestamp)/1e3;this.lastTimestamp=i,this.paused||this.updatePosition(e),this.rafId=requestAnimationFrame(t)};this.rafId=requestAnimationFrame(t),this.emit("marqueeStart")}updatePosition(t){const i=this.speed*t,e=this.options.gap??0;if("right"===this.direction||"down"===this.direction){this.currentPosition-=i;let t=this.tvist.slides;for(;this.currentPosition<=0&&t.length>0;){const i=t[t.length-1];if(!i)break;const s=t.length-1,n=(this.cachedSlideSizes[s]??0)+e;if(n<=0)break;this.tvist.container.prepend(i),this.tvist.updateSlidesList();const o=this.cachedSlideSizes.pop();void 0!==o&&this.cachedSlideSizes.unshift(o),t=this.tvist.slides,this.currentPosition+=n}}else{this.currentPosition+=i;let t=this.tvist.slides,s=t[0];for(;s;){const i=(this.cachedSlideSizes[0]??0)+e;if(i<=0)break;if(this.currentPosition{this.stopped=!1,this.start()},stop:()=>{this.stop(),this.stopped=!0},pause:()=>this.pause(),resume:()=>this.resume(),isRunning:()=>null!==this.rafId&&!this.paused,isPaused:()=>this.paused,isStopped:()=>this.stopped,setSpeed:t=>{this.speed=t},getSpeed:()=>this.speed,setDirection:t=>{if(this.direction!==t){const i=this.currentPosition;this.direction=t,this.calculateTotalSize(),this.currentPosition=i,this.totalSize>0&&(this.currentPosition=this.currentPosition%this.totalSize,this.currentPosition<0&&(this.currentPosition+=this.totalSize)),this.lastTimestamp=null,this.applyTransform()}},getDirection:()=>this.direction}}}B.MODULES.set("marquee",J);const K="data-src",Z="data-srcset",tt=`${l.block}__spinner`,it=`${l.block}__slide--loading`;class et extends T{constructor(t,i){super(t,i),this.name="lazyload",this.entries=[];const e=this.options.lazy;this.preloadPrevNext="object"==typeof e&&void 0!==e.preloadPrevNext?e.preloadPrevNext:1}init(){this.shouldBeActive()&&(this.register(),this.setupEvents(),this.check())}destroy(){this.entries=[],this.removeSpinners()}shouldBeActive(){return!1!==this.options.lazy&&void 0!==this.options.lazy&&null!==this.options.lazy}onUpdate(){this.shouldBeActive()&&(this.register(),this.check())}onSlideChange(){this.shouldBeActive()&&this.check()}onOptionsUpdate(t){if(void 0!==t.lazy){const i=t.lazy;this.preloadPrevNext="object"==typeof i&&void 0!==i.preloadPrevNext?i.preloadPrevNext:1;const e=this.shouldBeActive();e||!1===t.lazy||void 0===t.lazy?!e||!1!==t.lazy&&void 0!==t.lazy||this.destroy():(this.register(),this.setupEvents(),this.check())}}register(){this.tvist.slides.forEach((t,i)=>{m(t).filter(t=>t.matches("img[data-src], img[data-srcset]")).forEach(t=>{const e=t.getAttribute(K),s=t.getAttribute(Z);if(e||s){if(this.entries.some(([i])=>i===t))return;const e=t.parentElement;if(!e)return;let s=e.querySelector(`.${tt}`);s||(s=document.createElement("span"),s.className=tt,e.appendChild(s)),this.entries.push([t,i,s]),t.src||(t.style.display="none")}})})}setupEvents(){this.on("scroll",()=>this.check()),this.on("slideChangeStart",()=>this.check()),this.on("slideChangeEnd",()=>this.check())}check(){const t=this.tvist.activeIndex,i=(this.options.perPage??1)*(this.preloadPrevNext+1)-1;this.entries=this.entries.filter(e=>{const[,s]=e;return!this.isWithinRange(s,t,i)||(this.load(e),!1)})}isWithinRange(t,i,e){const s=this.tvist.slides.length;if(this.options.loop){const n=Math.abs(t-i);return n<=e||n>=s-e}return Math.abs(t-i)<=e}load(t){const[i,e,s]=t,n=this.tvist.slides[e];if(!n)return;u(n,it);const o=()=>{p(n,it),s.remove(),i.style.display="",this.emit("lazyLoaded",i,e),i.removeEventListener("load",o),i.removeEventListener("error",r)},r=()=>{p(n,it),s.remove(),this.emit("lazyLoadError",i,e),i.removeEventListener("load",o),i.removeEventListener("error",r)};i.addEventListener("load",o),i.addEventListener("error",r);const a=i.getAttribute(K),h=i.getAttribute(Z);a&&(i.src=a,i.removeAttribute(K)),h&&(i.srcset=h,i.removeAttribute(Z))}removeSpinners(){this.entries.forEach(([,,t])=>{t.remove()})}loadAll(){const t=[...this.entries];this.entries=[],t.forEach(t=>this.load(t))}loadSlide(t){const i=this.entries.filter(([,i])=>i===t);this.entries=this.entries.filter(([,i])=>i!==t),i.forEach(t=>this.load(t))}}B.MODULES.set("lazyload",et);const st={autoplay:!0,muted:!0,loop:!1,playsinline:!0,pauseOnLeave:!0,resetOnLeave:!1};function nt(t){return!1===t||void 0===t?null:!0===t?{...st}:{autoplay:t.autoplay??st.autoplay,muted:t.muted??st.muted,loop:t.loop??st.loop,playsinline:t.playsinline??st.playsinline,pauseOnLeave:t.pauseOnLeave??st.pauseOnLeave,resetOnLeave:t.resetOnLeave??st.resetOnLeave}}const ot=/(?:youtube\.com\/embed\/|youtube-nocookie\.com\/embed\/)/i,rt=/player\.vimeo\.com\/video\//i;function at(t){return ot.test(t)}function ht(t){return rt.test(t)}function lt(t,i){try{const e=new URL(t);for(const[t,s]of Object.entries(i))e.searchParams.set(t,s);return e.toString()}catch{return t}}function dt(t){return at(t)?"youtube":ht(t)?"vimeo":null}class ct extends T{constructor(t,i){super(t,i),this.name="video",this.config=null,this.videos=new Map,this.iframes=new Map,this.muted=!0,this.activePlayPromise=null,this.progressRAF=null,this.previousIndex=-1,this.intersectionObserver=null,this.pausedByVisibility=!1,this.config=nt(this.options.video),this.config&&(this.muted=this.config.muted)}init(){if(!this.shouldBeActive())return;this.scanSlides(),this.setupVisibilityHandlers(),this.on("slideChangeStart",t=>{this.onSlideChange(t)});const t=this.tvist.realIndex??this.tvist.activeIndex;this.previousIndex=t,this.activateSlideByRealIndex(t)}destroy(){this.stopProgressTracking(),this.deactivateAll(),this.cleanupVideoListeners(),this.teardownVisibilityHandlers(),this.videos.clear(),this.iframes.clear()}shouldBeActive(){return null!==this.config}onSlideChange(t){if(!this.config)return;const i=t,e=this.previousIndex;this.previousIndex=i,-1!==e&&e!==i&&this.deactivateSlideByRealIndex(e),this.activateSlideByRealIndex(i)}onOptionsUpdate(t){if(void 0!==t.video){const i=null!==this.config;this.config=nt(t.video);const e=null!==this.config;!i&&e&&this.config?(this.muted=this.config.muted,this.scanSlides(),this.setupVisibilityHandlers(),this.activateSlideByRealIndex(this.tvist.realIndex??this.tvist.activeIndex)):i&&!e?this.destroy():i&&e&&this.applyVideoAttributes()}}scanSlides(){this.videos.clear(),this.iframes.clear(),this.tvist.slides.forEach((t,i)=>{const e=t.getAttribute("data-tvist-slide-index"),s=null!==e?parseInt(e,10):i,n=t.querySelector("video");n&&this.registerVideo(s,t,n);const o=t.querySelector("iframe");if(o){const i=o.getAttribute("src")??o.getAttribute("data-src")??"";(function(t){return at(t)||ht(t)})(i)&&this.registerIframe(s,t,o,i)}})}registerVideo(t,i,e){if(!this.config)return;this.config.muted&&(e.muted=!0,e.setAttribute("muted","")),this.config.playsinline&&(e.setAttribute("playsinline",""),e.playsInline=!0),this.config.loop&&(e.loop=!0),e.removeAttribute("autoplay"),e.autoplay=!1;const s={slideIndex:t,slide:i,video:e,handlers:new Map};this.setupVideoListeners(s),this.videos.set(t,s)}registerIframe(t,i,e,s){const n=e.getAttribute("allow")??"";n.includes("autoplay")||e.setAttribute("allow",n?`${n}; autoplay`:"autoplay"),this.iframes.set(t,{slideIndex:t,slide:i,iframe:e,originalSrc:s})}applyVideoAttributes(){this.config&&this.videos.forEach(t=>{const{video:i}=t;i.muted=this.muted,this.config?.playsinline&&(i.setAttribute("playsinline",""),i.playsInline=!0),this.config?.loop?i.loop=!0:i.loop=!1})}setupVideoListeners(t){const{video:i,slide:e,slideIndex:s}=t,n=(e,s)=>{i.addEventListener(e,s),t.handlers.set(e,s)};n("loadedmetadata",()=>{const t={slide:e,video:i,index:s};this.emit("videoReady",t)}),n("play",()=>{const t={slide:e,video:i,index:s};this.emit("videoPlay",t),this.startProgressTracking(i,e,s)}),n("pause",()=>{const t={slide:e,video:i,index:s};this.emit("videoPause",t),this.stopProgressTracking()}),n("ended",()=>{const t={slide:e,video:i,index:s};this.emit("videoEnded",t),this.stopProgressTracking()}),n("timeupdate",()=>{if((i.paused||i.ended)&&i.duration&&isFinite(i.duration)){const t={slide:e,video:i,index:s,progress:i.currentTime/i.duration,currentTime:i.currentTime,duration:i.duration};this.emit("videoProgress",t)}})}cleanupVideoListeners(){this.videos.forEach(t=>{t.handlers.forEach((i,e)=>{t.video.removeEventListener(e,i)}),t.handlers.clear()})}activateSlideByRealIndex(t){if(!this.config)return;const i=this.videos.get(t);i&&this.config.autoplay&&this.safePlay(i.video);const e=this.iframes.get(t);e&&this.config.autoplay&&this.activateIframe(e)}deactivateSlideByRealIndex(t){if(!this.config)return;const i=this.videos.get(t);i&&(this.config.pauseOnLeave&&i.video.pause(),this.config.resetOnLeave&&(i.video.currentTime=0));const e=this.iframes.get(t);e&&this.deactivateIframe(e),this.stopProgressTracking()}deactivateAll(){this.videos.forEach(t=>{t.video.pause(),t.video.currentTime=0}),this.iframes.forEach(t=>{this.deactivateIframe(t)}),this.stopProgressTracking()}safePlay(t){t.muted=this.muted;const i=()=>{const i=t.play();this.activePlayPromise=i,i.then(()=>{this.activePlayPromise===i&&(this.activePlayPromise=null)}).catch(t=>{this.activePlayPromise===i&&(this.activePlayPromise=null),t.name})};if(t.readyState>=2)i();else{t.load();const e=()=>{t.removeEventListener("canplay",e),t.removeEventListener("canplaythrough",e),t.removeEventListener("loadeddata",e),t.removeEventListener("loadedmetadata",e),requestAnimationFrame(i)};t.addEventListener("canplay",e),t.addEventListener("canplaythrough",e),t.addEventListener("loadeddata",e),t.addEventListener("loadedmetadata",e)}}activateIframe(t){const i=dt(t.originalSrc);if(!i)return;const e=function(t,i){return"youtube"===t?{autoplay:"1",mute:i?"1":"0",playsinline:"1",showinfo:"0",controls:"0",rel:"0",iv_load_policy:"3"}:{autoplay:"1",muted:i?"1":"0",playsinline:"1"}}(i,this.muted),s=lt(t.originalSrc,e);t.iframe.src!==s&&(t.iframe.src=s)}deactivateIframe(t){const i=dt(t.originalSrc);if(!i)return;const e={autoplay:"0"},s=lt(t.originalSrc,e);t.iframe.src!==s&&(t.iframe.src=s)}startProgressTracking(t,i,e){this.stopProgressTracking();const s=()=>{if(t.paused||t.ended)this.stopProgressTracking();else{if(t.duration&&isFinite(t.duration)){const s={slide:i,video:t,index:e,progress:t.currentTime/t.duration,currentTime:t.currentTime,duration:t.duration};this.emit("videoProgress",s)}this.progressRAF=requestAnimationFrame(s)}};this.progressRAF=requestAnimationFrame(s)}stopProgressTracking(){null!==this.progressRAF&&(cancelAnimationFrame(this.progressRAF),this.progressRAF=null)}setupVisibilityHandlers(){"undefined"!=typeof IntersectionObserver&&(this.intersectionObserver=new IntersectionObserver(t=>{t.forEach(t=>{t.isIntersecting?this.resumeFromVisibility():this.pauseByVisibility()})},{threshold:.1}),this.intersectionObserver.observe(this.tvist.root)),this.visibilityHandler=()=>{"hidden"===document.visibilityState?this.pauseByVisibility():"visible"===document.visibilityState&&this.resumeFromVisibility()},document.addEventListener("visibilitychange",this.visibilityHandler)}teardownVisibilityHandlers(){this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null),this.visibilityHandler&&(document.removeEventListener("visibilitychange",this.visibilityHandler),this.visibilityHandler=void 0)}pauseByVisibility(){if(this.pausedByVisibility)return;this.pausedByVisibility=!0;const t=this.tvist.realIndex??this.tvist.activeIndex,i=this.videos.get(t);i&&!i.video.paused&&i.video.pause()}resumeFromVisibility(){if(!this.pausedByVisibility)return;if(this.pausedByVisibility=!1,!this.config?.autoplay)return;const t=this.tvist.realIndex??this.tvist.activeIndex,i=this.videos.get(t);i?.video.paused&&this.safePlay(i.video)}playVideo(t){const i=t??this.tvist.activeIndex,e=this.videos.get(i);e&&this.safePlay(e.video)}pauseVideo(t){const i=t??this.tvist.activeIndex,e=this.videos.get(i);e&&e.video.pause()}muteAll(){this.muted=!0,this.videos.forEach(t=>{t.video.muted=!0,t.video.volume=0})}unmuteAll(){this.muted=!1,this.videos.forEach(t=>{t.video.muted=!1,t.video.volume=1;const i=t.video.currentTime;t.video.currentTime=i})}isMutedState(){return this.muted}getVideo(){if(this.config)return{play:t=>this.playVideo(t),pause:t=>this.pauseVideo(t),mute:()=>this.muteAll(),unmute:()=>this.unmuteAll(),isMuted:()=>this.isMutedState()}}}function ut(t,i,e){return t+(i-t)*e}B.MODULES.set("video",ct);const pt={pauseAutoplay:!0,pauseMarquee:!0,threshold:0};function vt(t){return!1===t||void 0===t?null:!0===t?{...pt}:{pauseAutoplay:t.pauseAutoplay??pt.pauseAutoplay,pauseMarquee:t.pauseMarquee??pt.pauseMarquee,threshold:t.threshold??pt.threshold}}function gt(t){const i=t;if("function"==typeof i.checkVisibility)return i.checkVisibility({visibilityProperty:!0});let e=t,s=0;for(;e&&e!==document.body&&s<10;){const t=window.getComputedStyle(e);if("none"===t.display)return!1;if("hidden"===t.visibility)return!1;e=e.parentElement,s++}return!0}function mt(){return void 0!==document.visibilityState?"visible"===document.visibilityState:!document.hidden}class ft extends T{constructor(t,i){super(t,i),this.name="visibility",this.config=null,this.intersectionObserver=null,this.isVisible=!0,this.autoplayWasRunning=!1,this.marqueeWasRunning=!1,this.mutationObserver=null,this.config=vt(this.options.visibility),this.throttledCheckVisibility=r(()=>{this.checkVisibility()},100)}init(){this.shouldBeActive()&&(this.setupObserver(),this.setupMutationObserver())}destroy(){this.stopObserver(),this.stopMutationObserver(),this.tvist._isVisible=!0}shouldBeActive(){return null!==this.config}onOptionsUpdate(t){if(void 0!==t.visibility){const i=null!==this.config;this.config=vt(t.visibility);const e=null!==this.config;!i&&e?(this.setupObserver(),this.setupMutationObserver()):i&&!e&&(this.stopObserver(),this.stopMutationObserver(),this.tvist._isVisible=!0,this.isVisible||this.resumeModules(),this.tvist.removeModule(this.name))}}setupObserver(){this.config&&(this.intersectionObserver=new IntersectionObserver(t=>{t.forEach(t=>{const i=t.isIntersecting,e=gt(this.tvist.root),s=i&&e&&mt();s!==this.isVisible&&(this.isVisible=s,this.handleVisibilityChange(s))})},{threshold:this.config.threshold}),this.intersectionObserver.observe(this.tvist.root))}stopObserver(){this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null)}setupMutationObserver(){this.mutationObserver=new MutationObserver(()=>{this.throttledCheckVisibility()});let t=this.tvist.root;for(;t&&t!==document.body;)this.mutationObserver.observe(t,{attributes:!0,attributeFilter:["style","class"]}),t=t.parentElement}stopMutationObserver(){this.mutationObserver&&(this.mutationObserver.disconnect(),this.mutationObserver=null)}checkVisibility(){const t=gt(this.tvist.root)&&mt();t!==this.isVisible&&(this.isVisible=t,this.handleVisibilityChange(t))}handleVisibilityChange(t){t?(this.tvist._isVisible=!0,this.emit("sliderVisible"),this.resumeModules()):(this.tvist._isVisible=!1,this.emit("sliderHidden"),this.pauseModules())}pauseModules(){if(this.config){if(this.config.pauseAutoplay){const t=this.tvist.getModule("autoplay"),i=t?.getAutoplay();i?.isRunning()&&(this.autoplayWasRunning=!0,i.pause())}if(this.config.pauseMarquee){const t=this.tvist.getModule("marquee"),i=t?.getMarquee();i?.isRunning()&&(this.marqueeWasRunning=!0,i.stop())}}}resumeModules(){if(this.config){if(this.config.pauseAutoplay&&this.autoplayWasRunning){const t=this.tvist.getModule("autoplay"),i=t?.getAutoplay();i&&i.resume(),this.autoplayWasRunning=!1}if(this.config.pauseMarquee&&this.marqueeWasRunning){const t=this.tvist.getModule("marquee"),i=t?.getMarquee();i&&i.start(),this.marqueeWasRunning=!1}}}getVisibility(){return{isVisible:()=>this.isVisible,check:()=>{const t=gt(this.tvist.root)&&mt();return t!==this.isVisible&&(this.isVisible=t,this.handleVisibilityChange(t)),this.isVisible}}}}B.MODULES.set("visibility",ft),t.Animator=o,t.AutoplayModule=R,t.BreakpointsModule=k,t.Counter=s,t.DragModule=O,t.EffectModule=G,t.Engine=E,t.EventEmitter=P,t.GridModule=X,t.LazyLoadModule=et,t.LoopModule=$,t.MarqueeModule=J,t.Module=T,t.NavigationModule=V,t.PaginationModule=D,t.ScrollControlModule=Y,t.ScrollbarModule=Q,t.SlideStatesModule=N,t.TVIST_CLASSES=l,t.TVIST_CSS_PREFIX=h,t.ThumbsModule=U,t.Tvist=B,t.TvistV1=B,t.Vector1D=e,t.VideoModule=ct,t.VisibilityModule=ft,t.addClass=u,t.children=m,t.clamp=function(t,i,e){return Math.max(i,Math.min(t,e))},t.closest=function(t,i){return t.closest(i)},t.default=B,t.easings=n,t.getElement=c,t.getElements=function(t){return Array.isArray(t)?t:"string"==typeof t?Array.from(document.querySelectorAll(t)):[t]},t.getOuterHeight=g,t.getOuterWidth=v,t.getStyle=function(t,i){return window.getComputedStyle(t).getPropertyValue(i)},t.hasClass=function(t,i){return t.classList.contains(i)},t.inRange=function(t,i,e){return t>=i&&t<=e},t.isFirefox=q,t.isFocusable=function(t){return["INPUT","TEXTAREA","SELECT","BUTTON","A"].includes(t.tagName)||t.hasAttribute("contenteditable")||t.tabIndex>=0},t.lerp=ut,t.map=function(t,i,e,s,n){return ut(s,n,(t-i)/(e-i))},t.modulo=function(t,i){return(t%i+i)%i},t.removeClass=p,t.roundTo=function(t,i){const e=Math.pow(10,i);return Math.round(t*e)/e},t.setTransform=function(t,i){t.style.transform=i},t.setTransition=function(t,i){t.style.transition=i},t.setTranslate=function(t,i,e=0){t.style.transform=`translate3d(${i}px, ${e}px, 0)`},t.throttle=r,t.toggleClass=function(t,i,e){void 0!==e?t.classList.toggle(i,e):t.classList.toggle(i)},Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),function(){try{var t="undefined"!=typeof window?window:"undefined"!=typeof globalThis?globalThis:this;t.TvistV1&&t.TvistV1.default&&(t.TvistV1=t.TvistV1.default)}catch(i){}}()});