"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:o,...w}=s,[f,d]=r.useState(!1),y=r.useMemo(()=>o?{"thumbs-swiper":o}:{},[o]),m=t.getStyleSwiperContainer(),E="object"==typeof s.autoplay&&null!==s.autoplay?s.autoplay.pauseOnMouseEnter:void 0,b=()=>{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,w),i.current.initialize?.(),p?.(i.current.swiper),b())},[f]),r.useEffect(()=>{i.current?.swiper&&(i.current.swiper.destroy(!1,!1),Object.assign(i.current,w),i.current.initialize?.(),p(i.current.swiper),c())},[w.dir,w.loop,E,w.slidesPerView,p,c,w.spaceBetween,w.slidesOffsetBefore]),r.useEffect(()=>{let e=i.current;e&&(Object.assign(e,w),e.swiper?.update(),b())},[w]),r.useEffect(()=>{c()},[l,c]),r.useEffect(()=>{let e=i.current;if(!e)return;let r=()=>{b()};return e.addEventListener("swiperresize",r),()=>{e.removeEventListener("swiperresize",r)}},[]),e.jsx("swiper-container",{init:!1,ref:i,class:a,style:{...m,display:f?"block":"none"},...y,children:n})};
