import{d as f,r as l,e as A,y as d,f as m}from"./index-f5a86b16-1706882452509.js";const y="_wrap_3lsnj_1",p="_isAnitaion_3lsnj_7",v="_notice_3lsnj_7",a={wrap:y,isAnitaion:p,notice:v},o=n=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{n()})})},w=f({name:"TheNoticeBar",props:{text:{type:String,default:""},isAnimation:{type:Boolean,default:!1}},setup(n){const e=l(),i=l(),t=A({isActive:!1,wrapWidth:0,contentWidth:0,contentStyle:{transitionDuration:"0s",transform:"translateX(0px)"},time:null}),s=()=>{t.isActive||!i.value||!e.value||(t.isActive=!0,t.contentWidth=i.value.getBoundingClientRect().width,t.wrapWidth=e.value.getBoundingClientRect().width,r())},r=()=>{if(t.contentWidth<=t.wrapWidth||!t.isActive){t.contentStyle.transitionDuration="0s",t.contentStyle.transform="translateX(0px)";return}t.contentStyle.transitionDuration="5s",t.contentStyle.transform="translateX(-100%)",t.time=setTimeout(()=>{t.contentStyle.transitionDuration="0s",t.contentStyle.transform="translateX(".concat(t.wrapWidth,"px)"),o(r)},5*1e3)},c=()=>{clearTimeout(t.time),t.isActive=!1,t.contentStyle.transitionDuration="0s",t.contentStyle.transform="translateX(0px)",t.time=null};return d(()=>n.isAnimation,u=>{o(u?s:c)}),()=>m("div",{ref:e,class:[a.wrap,n.isAnimation?a.isAnitaion:""],onMouseenter:()=>!n.isAnimation&&s(),onMouseleave:()=>!n.isAnimation&&c()},[m("div",{ref:i,style:t.contentStyle,class:a.notice},[n.text])])}});export{w as T};
