import{as as C,at as b,a7 as D,r as v,c as E,au as W,av as P,aw as q,ax as A,K as L,w as M,ay as $,l as c,az as R,aA as y,aB as I,aC as z,aD as K,aE as O}from"./index-b3d42554.js";const[V,i]=C("notice-bar"),X={text:String,mode:String,color:String,delay:b(1),speed:b(60),leftIcon:String,wrapable:Boolean,background:String,scrollable:{type:Boolean,default:null}};var _=D({name:V,props:X,emits:["close","replay"],setup(e,{emit:m,slots:n}){let l=0,o=0,h;const u=v(),d=v(),t=E({show:!0,offset:0,duration:0}),x=()=>{if(n["left-icon"])return n["left-icon"]();if(e.leftIcon)return c(R,{class:i("left-icon"),name:e.leftIcon},null)},k=()=>{if(e.mode==="closeable")return"cross";if(e.mode==="link")return"arrow"},p=a=>{e.mode==="closeable"&&(t.show=!1,m("close",a))},N=()=>{if(n["right-icon"])return n["right-icon"]();const a=k();if(a)return c(R,{name:a,class:i("right-icon"),onClick:p},null)},S=()=>{t.offset=l,t.duration=0,z(()=>{I(()=>{t.offset=-o,t.duration=(o+l)/+e.speed,m("replay")})})},B=()=>{const a=e.scrollable===!1&&!e.wrapable,r={transform:t.offset?`translateX(${t.offset}px)`:"",transitionDuration:`${t.duration}s`};return c("div",{ref:u,role:"marquee",class:i("wrap")},[c("div",{ref:d,style:r,class:[i("content"),{"van-ellipsis":a}],onTransitionend:S},[n.default?n.default():e.text])])},s=()=>{const{delay:a,speed:r,scrollable:f}=e,T=K(a)?+a*1e3:0;l=0,o=0,t.offset=0,t.duration=0,clearTimeout(h),h=setTimeout(()=>{if(!u.value||!d.value||f===!1)return;const w=y(u).width,g=y(d).width;(f||g>w)&&I(()=>{l=w,o=g,t.offset=-o,t.duration=o/+r})},T)};return W(s),P(s),q("pageshow",s),A({reset:s}),L(()=>[e.text,e.scrollable],s),()=>{const{color:a,wrapable:r,background:f}=e;return M(c("div",{role:"alert",class:i({wrapable:r}),style:{color:a,background:f}},[x(),B(),N()]),[[$,t.show]])}}});const F=O(_);export{F as N};