import{j as m}from"./index-6605a014.js";import{r}from"./react-e45097e1.js";import{y,z as I,B as x}from"./Author-826c76c5.js";import"./antd-6dbc138d.js";function a({children:n}){const s=y(),{autoplay:c,interval:f,defaultIndex:d}=I(),{currentIndex:u}=x(),e=r.useRef();return r.useEffect(()=>{function l(){let t=u+1;t>=r.Children.count(n)&&(t=0),s.setState({currentIndex:t})}return e.current&&(clearInterval(e.current),e.current=void 0),c&&(e.current=setInterval(()=>l(),(parseInt(f,10)||3)*1e3)),()=>{e.current&&(clearInterval(e.current),e.current=void 0)}},[s,n,c,f,d,u]),m.jsx(m.Fragment,{children:r.Children.map(n,(l,t)=>{var p;const i=l,o=((p=i.props)==null?void 0:p.overlayStyles)||{};return o.default={...o.default,position:"absolute",left:0,top:0,right:0,bottom:0,display:t===u?"flex":"none"},r.cloneElement(i,{overlayStyles:o})})})}a.title="走马灯";a.isLayoutable=!0;a.params={autoplay:{type:"boolean",name:"自动轮播",defaultValue:!1},interval:{type:"number",name:"轮播间隔(s)",defaultValue:3},defaultIndex:{type:"number",name:"默认序号",defaultValue:0}};a.stateParams={currentIndex:{type:"number",name:"当前轮播序号"}};export{a as default};
