"use strict";var e=require("react/jsx-runtime"),r=require("react"),t=require("./common/styles.js");exports.Swiper=function(s){let i=r.useRef(null),{children:n,totalSlides:u,onSwiperReset:c,onSwiperReady:p,sliderClass:a,sliderOrder:l,thumbsSwiper:w,...o}=s,[f,d]=r.useState(!1),y=r.useRef(o);y.current=o;let m=r.useMemo(()=>w?{"thumbs-swiper":w}:{},[w]),E=t.getStyleSwiperContainer(),b="object"==typeof s.autoplay&&null!==s.autoplay?s.autoplay.pauseOnMouseEnter:void 0,j=()=>{i.current?.swiper&&i.current.swiper.wrapperEl.style.setProperty("width",`${i.current.swiper.width}px`)};return r.useEffect(()=>{let e=async()=>{let e=await import("@gem-sdk/swiper/element/bundle");e.register(),await window.customElements.whenDefined("swiper-container"),d(!0)};e()},[]),r.useEffect(()=>{f&&i.current&&(Object.assign(i.current,o),i.current.initialize?.(),p?.(i.current.swiper),j())},[f]),r.useEffect(()=>{i.current?.swiper&&(i.current.swiper.destroy(!1,!1),Object.assign(i.current,y.current),i.current.initialize?.(),p(i.current.swiper),c())},[o.dir,o.loop,b,o.slidesPerView,p,c,o.spaceBetween]),r.useEffect(()=>{let e=i.current;e?.swiper&&(Object.assign(e,y.current),e.swiper.update(),j())},[o.speed,o.spaceBetween,o.slidesPerView,o.direction,o.slidesOffsetBefore,o.isSneakPeekCenter]),r.useEffect(()=>{c()},[l,c]),r.useEffect(()=>{let e=i.current;if(!e)return;let r=()=>{j()};return e.addEventListener("swiperresize",r),()=>{e.removeEventListener("swiperresize",r)}},[]),e.jsx("swiper-container",{init:!1,ref:i,class:a,style:{...E,display:f?"block":"none"},...m,children:n})};
