import{g as R,m as I,c as d,a as j,n as B,e as N}from"./swiper-core-KMhvhzce.js";import{c as G,a as U}from"./classes-to-selector-B0617UQA.js";function X(x){let{swiper:s,extendParams:k,on:f,emit:g}=x;const y=R();let b=!1,E=null,v=null,h,i,c,D;k({scrollbar:{el:null,dragSize:"auto",hide:!1,draggable:!1,snapOnRelease:!0,lockClass:"swiper-scrollbar-lock",dragClass:"swiper-scrollbar-drag",scrollbarDisabledClass:"swiper-scrollbar-disabled",horizontalClass:"swiper-scrollbar-horizontal",verticalClass:"swiper-scrollbar-vertical"}}),s.scrollbar={el:null,dragEl:null};function m(){if(!s.params.scrollbar.el||!s.scrollbar.el)return;const{scrollbar:l,rtlTranslate:r}=s,{dragEl:a,el:e}=l,t=s.params.scrollbar,n=s.params.loop?s.progressLoop:s.progress;let p=i,o=(c-i)*n;r?(o=-o,o>0?(p=i-o,o=0):-o+i>c&&(p=c+o)):o<0?(p=i+o,o=0):o+i>c&&(p=c-o),s.isHorizontal()?(a.style.transform=`translate3d(${o}px, 0, 0)`,a.style.width=`${p}px`):(a.style.transform=`translate3d(0px, ${o}px, 0)`,a.style.height=`${p}px`),t.hide&&(clearTimeout(E),e.style.opacity=1,E=setTimeout(()=>{e.style.opacity=0,e.style.transitionDuration="400ms"},1e3))}function H(l){!s.params.scrollbar.el||!s.scrollbar.el||(s.scrollbar.dragEl.style.transitionDuration=`${l}ms`)}function u(){if(!s.params.scrollbar.el||!s.scrollbar.el)return;const{scrollbar:l}=s,{dragEl:r,el:a}=l;r.style.width="",r.style.height="",c=s.isHorizontal()?a.offsetWidth:a.offsetHeight,D=s.size/(s.virtualSize+s.params.slidesOffsetBefore-(s.params.centeredSlides?s.snapGrid[0]:0)),s.params.scrollbar.dragSize==="auto"?i=c*D:i=parseInt(s.params.scrollbar.dragSize,10),s.isHorizontal()?r.style.width=`${i}px`:r.style.height=`${i}px`,D>=1?a.style.display="none":a.style.display="",s.params.scrollbar.hide&&(a.style.opacity=0),s.params.watchOverflow&&s.enabled&&l.el.classList[s.isLocked?"add":"remove"](s.params.scrollbar.lockClass)}function w(l){return s.isHorizontal()?l.clientX:l.clientY}function S(l){const{scrollbar:r,rtlTranslate:a}=s,{el:e}=r;let t;t=(w(l)-N(e)[s.isHorizontal()?"left":"top"]-(h!==null?h:i/2))/(c-i),t=Math.max(Math.min(t,1),0),a&&(t=1-t);const n=s.minTranslate()+(s.maxTranslate()-s.minTranslate())*t;s.updateProgress(n),s.setTranslate(n),s.updateActiveIndex(),s.updateSlidesClasses()}function P(l){const r=s.params.scrollbar,{scrollbar:a,wrapperEl:e}=s,{el:t,dragEl:n}=a;b=!0,h=l.target===n?w(l)-l.target.getBoundingClientRect()[s.isHorizontal()?"left":"top"]:null,l.preventDefault(),l.stopPropagation(),e.style.transitionDuration="100ms",n.style.transitionDuration="100ms",S(l),clearTimeout(v),t.style.transitionDuration="0ms",r.hide&&(t.style.opacity=1),s.params.cssMode&&(s.wrapperEl.style["scroll-snap-type"]="none"),g("scrollbarDragStart",l)}function M(l){const{scrollbar:r,wrapperEl:a}=s,{el:e,dragEl:t}=r;b&&(l.preventDefault&&l.cancelable?l.preventDefault():l.returnValue=!1,S(l),a.style.transitionDuration="0ms",e.style.transitionDuration="0ms",t.style.transitionDuration="0ms",g("scrollbarDragMove",l))}function O(l){const r=s.params.scrollbar,{scrollbar:a,wrapperEl:e}=s,{el:t}=a;b&&(b=!1,s.params.cssMode&&(s.wrapperEl.style["scroll-snap-type"]="",e.style.transitionDuration=""),r.hide&&(clearTimeout(v),v=B(()=>{t.style.opacity=0,t.style.transitionDuration="400ms"},1e3)),g("scrollbarDragEnd",l),r.snapOnRelease&&s.slideToClosest())}function T(l){const{scrollbar:r,params:a}=s,e=r.el;if(!e)return;const t=e,n=a.passiveListeners?{passive:!1,capture:!1}:!1,p=a.passiveListeners?{passive:!0,capture:!1}:!1;if(!t)return;const o=l==="on"?"addEventListener":"removeEventListener";t[o]("pointerdown",P,n),y[o]("pointermove",M,n),y[o]("pointerup",O,p)}function $(){!s.params.scrollbar.el||!s.scrollbar.el||T("on")}function q(){!s.params.scrollbar.el||!s.scrollbar.el||T("off")}function z(){const{scrollbar:l,el:r}=s;s.params.scrollbar=G(s,s.originalParams.scrollbar,s.params.scrollbar,{el:"swiper-scrollbar"});const a=s.params.scrollbar;if(!a.el)return;let e;if(typeof a.el=="string"&&s.isElement&&(e=s.el.querySelector(a.el)),!e&&typeof a.el=="string"){if(e=y.querySelectorAll(a.el),!e.length)return}else e||(e=a.el);s.params.uniqueNavElements&&typeof a.el=="string"&&e.length>1&&r.querySelectorAll(a.el).length===1&&(e=r.querySelector(a.el)),e.length>0&&(e=e[0]),e.classList.add(s.isHorizontal()?a.horizontalClass:a.verticalClass);let t;e&&(t=e.querySelector(U(s.params.scrollbar.dragClass)),t||(t=j("div",s.params.scrollbar.dragClass),e.append(t))),Object.assign(l,{el:e,dragEl:t}),a.draggable&&$(),e&&e.classList[s.enabled?"remove":"add"](...d(s.params.scrollbar.lockClass))}function C(){const l=s.params.scrollbar,r=s.scrollbar.el;r&&r.classList.remove(...d(s.isHorizontal()?l.horizontalClass:l.verticalClass)),q()}f("changeDirection",()=>{if(!s.scrollbar||!s.scrollbar.el)return;const l=s.params.scrollbar;let{el:r}=s.scrollbar;r=I(r),r.forEach(a=>{a.classList.remove(l.horizontalClass,l.verticalClass),a.classList.add(s.isHorizontal()?l.horizontalClass:l.verticalClass)})}),f("init",()=>{s.params.scrollbar.enabled===!1?L():(z(),u(),m())}),f("update resize observerUpdate lock unlock changeDirection",()=>{u()}),f("setTranslate",()=>{m()}),f("setTransition",(l,r)=>{H(r)}),f("enable disable",()=>{const{el:l}=s.scrollbar;l&&l.classList[s.enabled?"remove":"add"](...d(s.params.scrollbar.lockClass))}),f("destroy",()=>{C()});const A=()=>{s.el.classList.remove(...d(s.params.scrollbar.scrollbarDisabledClass)),s.scrollbar.el&&s.scrollbar.el.classList.remove(...d(s.params.scrollbar.scrollbarDisabledClass)),z(),u(),m()},L=()=>{s.el.classList.add(...d(s.params.scrollbar.scrollbarDisabledClass)),s.scrollbar.el&&s.scrollbar.el.classList.add(...d(s.params.scrollbar.scrollbarDisabledClass)),C()};Object.assign(s.scrollbar,{enable:A,disable:L,updateSize:u,setTranslate:m,init:z,destroy:C})}export{X as S};