"use client";import{a as m}from"./chunk-EI3IJHIE.mjs";import{c as d}from"./chunk-S7CSCIW4.mjs";import"./chunk-JZXLCA2E.mjs";import{useCallback as i,useEffect as C,useRef as E,useState as v}from"react";import{jsx as s,jsxs as x}from"react/jsx-runtime";var R=({countOfItems:l,backgroundColor:t,spacing:h,border:p,fluidContent:w,fullHeight:b,children:o})=>{let n=E(null),[a,u]=v(0),[B,N]=v(!1),r=l||(Array.isArray(o)?o.length:1);C(()=>{let e=()=>N(y=>!y);return window.addEventListener("resize",e,{passive:!0}),()=>window.removeEventListener("resize",e)},[]),C(()=>{if(n.current){let{clientWidth:e}=n.current;n.current.scrollLeft=a*e}},[a,B]);let c=i(()=>u(e=>e===0?r-1:e-1),[r]),f=i(()=>u(e=>r-1===e?0:e+1),[r]),k=i(()=>x("div",{className:d("absolute inset-x-5 top-1/2 flex -translate-y-1/2 justify-between",{[`text-${t} invert`]:!!t,"text-black dark:text-white":!t}),children:[s("button",{onClick:c,children:"\u276E"}),s("button",{onClick:f,children:"\u276F"})]}),[t,f,c]);return s(m,{backgroundColor:t,spacing:h,border:p,fluidContent:w,fullHeight:b,children:x("div",{className:"relative",children:[s("div",{ref:n,className:"flex flex-row items-center overflow-x-hidden scroll-smooth",children:o}),k()]})})};export{R as Carousel};
