'use client';
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),core=require("@gem-sdk/core"),React=require("react"),Dots=require("../dot/Dots.js"),Arrow=require("../arrow/Arrow.js"),helpers=require("../arrow/common/helpers.js"),useCarousel=require("../../hooks/useCarousel.js"),classes=require("./common/classes.js"),styles=require("./common/styles.js"),attrs=require("./common/attrs.js"),helpers$1=require("./common/helpers.js");const Carousel=React.forwardRef((e,r)=>{let{children:s,builderAttrs:t,builderProps:o,styles:a,isHiddenArrowWhenDisabled:l=!0,hiddenDotWhenOnlyOne:i,elmRef:n}=e,d=helpers.mappingNavigationCarousel(e.setting),u={...e,setting:d},{arrowButtonSize:c,arrowBackgroundColor:m,arrowGapToEachSide:j="16",roundedArrow:p,arrowIconSize:h,arrowCustomColor:x,arrowBorder:C,arrowShadow:w,showWhenHover:v}=d??{},{totalSlideItem:S,isInfinity:k,slider:y,currentSlide:g,localRef:R,showNavigation:f,isRenderDots:b,slideMaxIndex:q,handleDotClick:P,getItemsPerPage:A,sliderRef:D,handleNextAndPrevSlide:T,dispatchEventSelectSlide:N,getNumberOfFullWidthShow:z}=useCarousel.useCarousel(u,r),{loopConfig:E,arrowShowConfig:I}=helpers$1.getData(u),{rootClassRender:O,wrapperClassRender:W,wrapperInnerClass:B,sliderClass:H}=classes.getClass(u),{rootStyleRender:F,wrapperStyleRender:G,wrapperInnerStyle:$}=styles.getStyle(u),{rootAttrRender:_,sliderAttr:M}=attrs.getAttr(u),U=core.useCurrentDevice(),V=d?.sneakPeak?.[U],J=r=>{let s="next"===r,t=s?!k&&y?.track?.details?.abs===q:!k&&y?.track?.details?.abs===0;return jsxRuntime.jsx(Arrow.default,{uid:o?.uid,custom:d?.arrowCustom??"",showArrow:I,arrowButtonSize:c||{},arrowIconSize:h||{},arrowBackgroundColor:m||"",arrowCustomColor:x,gapToEachSize:j,showWhenHover:v,arrowBorder:C||{},arrowCorner:p||{},arrowShadow:w||{},onClick:e=>{e.stopPropagation(),T(r)},left:!s,disabled:t,vertical:d?.vertical,isHiddenWhenDisabled:l,rootId:e?.parentClass})},K=()=>jsxRuntime.jsx(jsxRuntime.Fragment,{children:core.isEmptyChildren(s)?jsxRuntime.jsx("div",{children:"No Slider"}):React.Children.map(core.filterToolbarPreview(s),(e,r)=>React.isValidElement(e)?jsxRuntime.jsx(e.type,{...e.props,index:r,parentSettings:d,parentStyle:a,background:d?.background,parentUid:o?.uid,dispatchEventSelectSlide:N}):null)});return jsxRuntime.jsx("div",{ref:n,..._,className:O,style:F,children:jsxRuntime.jsxs("div",{ref:R,...t,className:W,style:G,children:[jsxRuntime.jsxs("div",{className:B,style:$,children:[f&&J("prev"),jsxRuntime.jsx("div",{ref:D,...M,className:H,children:K()}),f&&J("next")]}),b&&jsxRuntime.jsx(Dots.default,{showDots:d?.dot,dotStyle:d?.dotStyle,totalSlideItem:S,slideItemsPerPage:A(),currentSlide:g,enabledSneakPeak:V,vertical:d?.vertical,loop:E,dotColor:d?.dotColor,dotGapToCarousel:d?.dotGapToCarousel,dotSize:d?.dotSize,dotActiveColor:d?.dotActiveColor,hiddenWhenOnlyOne:i,sneakPeakType:d?.sneakPeakType,numberOfFullWidthShow:z(U),onHandleClick:P}),core.filterToolbarPreview(s,!0)]})})});exports.default=Carousel;
