import{y as e,E as a,d as o,I as t,r as s,ag as r,a2 as l,n,ac as c,j as i,au as d,aA as f,a as u,V as p,a8 as b,as as g,X as m,ah as h,w as y}from"./index-4bd11d60.js";const[w,v]=e("notice-bar"),k=y(o({name:w,props:{text:String,mode:String,color:String,delay:a(1),speed:a(60),leftIcon:String,wrapable:Boolean,background:String,scrollable:{type:Boolean,"default":null}},emits:["close","replay"],setup(e,{emit:a,slots:o}){let y,w=0,k=0;const x=t(),j=t(),S=s({show:!0,offset:0,duration:0}),A=o=>{"closeable"===e.mode&&(S.show=!1,a("close",o))},I=()=>{if(o["right-icon"])return o["right-icon"]();const a="closeable"===e.mode?"cross":"link"===e.mode?"arrow":void 0;return a?u(p,{name:a,"class":v("right-icon"),onClick:A},null):void 0},T=()=>{S.offset=w,S.duration=0,m((()=>{g((()=>{S.offset=-k,S.duration=(k+w)/+e.speed,a("replay")}))}))},B=()=>{const a=!1===e.scrollable&&!e.wrapable,t={transform:S.offset?"translateX(".concat(S.offset,"px)"):"",transitionDuration:"".concat(S.duration,"s")};return u("div",{ref:x,role:"marquee","class":v("wrap")},[u("div",{ref:j,style:t,"class":[v("content"),{"van-ellipsis":a}],onTransitionend:T},[o["default"]?o["default"]():e.text])])},E=()=>{const{delay:a,speed:o,scrollable:t}=e,s=h(a)?1e3*+a:0;w=0,k=0,S.offset=0,S.duration=0,clearTimeout(y),y=setTimeout((()=>{if(!x.value||!j.value||!1===t)return;const e=b(x).width,a=b(j).width;(t||a>e)&&g((()=>{w=e,k=a,S.offset=-k,S.duration=k/+o}))}),s)};return r(E),l(E),n("pageshow",E),c({reset:E}),i((()=>[e.text,e.scrollable]),E),()=>{const{color:a,wrapable:t,background:s}=e;return d(u("div",{role:"alert","class":v({wrapable:t}),style:{color:a,background:s}},[o["left-icon"]?o["left-icon"]():e.leftIcon?u(p,{"class":v("left-icon"),name:e.leftIcon},null):void 0,B(),I()]),[[f,S.show]])}}})),x=e=>{if(null===e)return null;const a=Object.assign({},e);return Object.keys(a).forEach((o=>a[o]="object"==typeof e[o]?x(e[o]):e[o])),Array.isArray(e)?(a.length=e.length,Array.from(a)):a};export{k as N,x as d};
