import{aA as de,aB as G,bE as ue,bK as Oe,r as C,aG as Le,aw as Ne,aY as Ee,av as He,bL as fe,c as W,n as z,m as ve,b as L,d as Z,by as be,x as he,e as R,bB as me,ad as ge,i as Me,w as $,_ as ye,bA as J,z as P,$ as N,bH as we,bI as We,a as m,k as p,bb as j,y as Ze,Z as ee,t as X,bo as Te,ab as De,aX as Ve,bJ as Fe,o as oe,Y as Q,aQ as Ue,bn as Ye,bM as ie,a1 as Ke,bN as Xe,b8 as je,b5 as qe,a6 as Ge,ae as Je,au as Qe,bf as pe,bO as et,aL as tt,aS as nt,aF as at,g as lt,v as ot,h as it,af as se,aV as st}from"./index-869d77fb.js";import{T as rt}from"./use-tab-status-0ed30c24.js";import{S as ct,a as dt}from"./index-d45dfe1a.js";function ut(e,a,i){let l,r=0;const t=e.scrollLeft,s=i===0?1:Math.round(i*1e3/16);function c(){de(l)}function v(){e.scrollLeft+=(a-t)/s,++ra||!s&&ta?r=G(w):l&&(r=G(l))}return w(),g}function vt(){const e=C([]),a=[];return Le(()=>{e.value=[]}),[e,l=>(a[l]||(a[l]=r=>{e.value[l]=r}),a[l])]}function xe(e,a){if(!Ne||!window.IntersectionObserver)return;const i=new IntersectionObserver(t=>{a(t[0].intersectionRatio>0)},{root:document.body}),l=()=>{e.value&&i.observe(e.value)},r=()=>{e.value&&i.unobserve(e.value)};Ee(r),He(r),fe(l)}const[bt,ht]=W("sticky"),mt={zIndex:z,position:ve("top"),container:Object,offsetTop:L(0),offsetBottom:L(0)};var gt=Z({name:bt,props:mt,emits:["scroll","change"],setup(e,{emit:a,slots:i}){const l=C(),r=be(l),t=he({fixed:!1,width:0,height:0,transform:0}),s=C(!1),c=R(()=>me(e.position==="top"?e.offsetTop:e.offsetBottom)),v=R(()=>{if(s.value)return;const{fixed:f,height:S,width:u}=t;if(f)return{width:`${u}px`,height:`${S}px`}}),g=R(()=>{if(!t.fixed||s.value)return;const f=ge(Me(e.zIndex),{width:`${t.width}px`,height:`${t.height}px`,[e.position]:`${c.value}px`});return t.transform&&(f.transform=`translate3d(0, ${t.transform}px, 0)`),f}),w=f=>a("scroll",{scrollTop:f,isFixed:t.fixed}),k=()=>{if(!l.value||J(l))return;const{container:f,position:S}=e,u=N(l),x=ue(window);if(t.width=u.width,t.height=u.height,S==="top")if(f){const d=N(f),B=d.bottom-c.value-t.height;t.fixed=c.value>u.top&&d.bottom>0,t.transform=B<0?B:0}else t.fixed=c.value>u.top;else{const{clientHeight:d}=document.documentElement;if(f){const B=N(f),h=d-B.top-c.value-t.height;t.fixed=d-c.valueB.top,t.transform=h<0?-h:0}else t.fixed=d-c.valuet.fixed,f=>a("change",f)),ye("scroll",k,{target:r,passive:!0}),xe(l,k),$([we,We],()=>{!l.value||J(l)||!t.fixed||(s.value=!0,P(()=>{const f=N(l);t.width=f.width,t.height=f.height,s.value=!1}))}),()=>{var f;return m("div",{ref:l,style:v.value},[m("div",{class:ht({fixed:t.fixed&&!s.value}),style:g.value},[(f=i.default)==null?void 0:f.call(i)])])}}});const yt=p(gt),[wt,re]=W("tabs");var Tt=Z({name:wt,props:{count:j(Number),inited:Boolean,animated:Boolean,duration:j(z),swipeable:Boolean,lazyRender:Boolean,currentIndex:j(Number)},emits:["change"],setup(e,{emit:a,slots:i}){const l=C(),r=c=>a("change",c),t=()=>{var c;const v=(c=i.default)==null?void 0:c.call(i);return e.animated||e.swipeable?m(ct,{ref:l,loop:!1,class:re("track"),duration:+e.duration*1e3,touchable:e.swipeable,lazyRender:e.lazyRender,showIndicators:!1,onChange:r},{default:()=>[v]}):v},s=c=>{const v=l.value;v&&v.state.active!==c&&v.swipeTo(c,{immediate:!e.inited})};return $(()=>e.currentIndex,s),Ze(()=>{s(e.currentIndex)}),ee({swipeRef:l}),()=>m("div",{class:re("content",{animated:e.animated||e.swipeable})},[t()])}});const[Se,K]=W("tabs"),xt={type:ve("line"),color:String,border:Boolean,sticky:Boolean,shrink:Boolean,active:L(0),duration:L(.3),animated:Boolean,ellipsis:X,swipeable:Boolean,scrollspy:Boolean,offsetTop:L(0),background:String,lazyRender:X,lineWidth:z,lineHeight:z,beforeChange:Function,swipeThreshold:L(5),titleActiveColor:String,titleInactiveColor:String},Ce=Symbol(Se);var St=Z({name:Se,props:xt,emits:["change","scroll","rendered","clickTab","update:active"],setup(e,{emit:a,slots:i}){let l,r,t,s,c;const v=C(),g=C(),w=C(),k=C(),f=Te(),S=be(v),[u,x]=vt(),{children:d,linkChildren:B}=De(Ce),h=he({inited:!1,position:"",lineStyle:{},currentIndex:-1}),E=R(()=>d.length>+e.swipeThreshold||!e.ellipsis||e.shrink),D=R(()=>({borderColor:e.color,background:e.background})),H=(n,o)=>{var b;return(b=n.name)!=null?b:o},V=R(()=>{const n=d[h.currentIndex];if(n)return H(n,h.currentIndex)}),O=R(()=>me(e.offsetTop)),te=R(()=>e.sticky?O.value+l:0),M=n=>{const o=g.value,b=u.value;if(!E.value||!o||!b||!b[h.currentIndex])return;const T=b[h.currentIndex].$el,y=T.offsetLeft-(o.offsetWidth-T.offsetWidth)/2;s&&s(),s=ut(o,y,n?0:+e.duration)},_=()=>{const n=h.inited;P(()=>{const o=u.value;if(!o||!o[h.currentIndex]||e.type!=="line"||J(v.value))return;const b=o[h.currentIndex].$el,{lineWidth:T,lineHeight:y}=e,I=b.offsetLeft+b.offsetWidth/2,A={width:oe(T),backgroundColor:e.color,transform:`translateX(${I}px) translateX(-50%)`};if(n&&(A.transitionDuration=`${e.duration}s`),Q(y)){const Y=oe(y);A.height=Y,A.borderRadius=Y}h.lineStyle=A})},Ie=n=>{const o=n=0&&n{const b=Ie(n);if(!Q(b))return;const T=d[b],y=H(T,b),I=h.currentIndex!==null;h.currentIndex!==b&&(h.currentIndex=b,o||M(),_()),y!==e.active&&(a("update:active",y),I&&a("change",y,T.title)),t&&!e.scrollspy&&Ye(Math.ceil(ie(v.value)-O.value))},U=(n,o)=>{const b=d.find((y,I)=>H(y,I)===n),T=b?d.indexOf(b):0;F(T,o)},ne=(n=!1)=>{if(e.scrollspy){const o=d[h.currentIndex].$el;if(o&&S.value){const b=ie(o,S.value)-te.value;r=!0,c&&c(),c=ft(S.value,b,n?0:+e.duration,()=>{r=!1})}}},Re=(n,o,b)=>{const{title:T,disabled:y}=d[o],I=H(d[o],o);y||(Ke(e.beforeChange,{args:[I],done:()=>{F(o),ne()}}),Xe(n)),a("clickTab",{name:I,title:T,event:b,disabled:y})},ke=n=>{t=n.isFixed,a("scroll",n)},Be=n=>{P(()=>{U(n),ne(!0)})},$e=()=>{for(let n=0;nte.value)return n===0?0:n-1}return d.length-1},_e=()=>{if(e.scrollspy&&!r){const n=$e();F(n)}},Ae=()=>{if(e.type==="line"&&d.length)return m("div",{class:K("line"),style:h.lineStyle},null)},ae=()=>{var n,o,b;const{type:T,border:y,sticky:I}=e,A=[m("div",{ref:I?void 0:w,class:[K("wrap"),{[Ue]:T==="line"&&y}]},[m("div",{ref:g,role:"tablist",class:K("nav",[T,{shrink:e.shrink,complete:E.value}]),style:D.value,"aria-orientation":"horizontal"},[(n=i["nav-left"])==null?void 0:n.call(i),d.map(Y=>Y.renderTitle(Re)),Ae(),(o=i["nav-right"])==null?void 0:o.call(i)])]),(b=i["nav-bottom"])==null?void 0:b.call(i)];return I?m("div",{ref:w},[A]):A},le=()=>{_(),P(()=>{var n,o;M(!0),(o=(n=k.value)==null?void 0:n.swipeRef.value)==null||o.resize()})};$(()=>[e.color,e.duration,e.lineWidth,e.lineHeight],_),$(we,le),$(()=>e.active,n=>{n!==V.value&&U(n)}),$(()=>d.length,()=>{h.inited&&(U(e.active),_(),P(()=>{M(!0)}))});const Pe=()=>{U(e.active,!0),P(()=>{h.inited=!0,w.value&&(l=N(w.value).height),M(!0)})},ze=(n,o)=>a("rendered",n,o);return ee({resize:le,scrollTo:Be}),Ve(_),Fe(_),fe(Pe),xe(v,_),ye("scroll",_e,{target:S,passive:!0}),B({id:f,props:e,setLine:_,scrollable:E,onRendered:ze,currentName:V,setTitleRefs:x,scrollIntoView:M}),()=>m("div",{ref:v,class:K([e.type])},[e.sticky?m(yt,{container:v.value,offsetTop:O.value,onScroll:ke},{default:()=>[ae()]}):ae(),m(Tt,{ref:k,count:d.length,inited:h.inited,animated:e.animated,duration:e.duration,swipeable:e.swipeable,lazyRender:e.lazyRender,currentIndex:h.currentIndex,onChange:F},{default:()=>{var n;return[(n=i.default)==null?void 0:n.call(i)]}})])}});const[Ct,ce]=W("tab"),It=Z({name:Ct,props:{id:String,dot:Boolean,type:String,color:String,title:String,badge:z,shrink:Boolean,isActive:Boolean,disabled:Boolean,controls:String,scrollable:Boolean,activeColor:String,inactiveColor:String,showZeroBadge:X},setup(e,{slots:a}){const i=R(()=>{const r={},{type:t,color:s,disabled:c,isActive:v,activeColor:g,inactiveColor:w}=e;s&&t==="card"&&(r.borderColor=s,c||(v?r.backgroundColor=s:r.color=s));const f=v?g:w;return f&&(r.color=f),r}),l=()=>{const r=m("span",{class:ce("text",{ellipsis:!e.scrollable})},[a.title?a.title():e.title]);return e.dot||Q(e.badge)&&e.badge!==""?m(je,{dot:e.dot,content:e.badge,showZero:e.showZeroBadge},{default:()=>[r]}):r};return()=>m("div",{id:e.id,role:"tab",class:[ce([e.type,{grow:e.scrollable&&!e.shrink,shrink:e.shrink,active:e.isActive,disabled:e.disabled}])],style:i.value,tabindex:e.disabled?void 0:e.isActive?0:-1,"aria-selected":e.isActive,"aria-disabled":e.disabled||void 0,"aria-controls":e.controls},[l()])}}),[Rt,q]=W("tab"),kt=ge({},qe,{dot:Boolean,name:z,badge:z,title:String,disabled:Boolean,titleClass:Ge,titleStyle:[String,Object],showZeroBadge:X});var Bt=Z({name:Rt,props:kt,setup(e,{slots:a}){const i=Te(),l=C(!1),r=st(),{parent:t,index:s}=Je(Ce);if(!t){console.error("[Vant] must be a child component of .");return}const c=()=>{var u;return(u=e.name)!=null?u:s.value},v=()=>{l.value=!0,t.props.lazyRender&&P(()=>{t.onRendered(c(),e.title)})},g=R(()=>{const u=c()===t.currentName.value;return u&&!l.value&&v(),u}),w=C(""),k=C("");Qe(()=>{const{titleClass:u,titleStyle:x}=e;w.value=u?pe(u):"",k.value=x&&typeof x!="string"?et(tt(x)):x});const f=u=>m(It,it({key:i,id:`${t.id}-${s.value}`,ref:t.setTitleRefs(s.value),style:k.value,class:w.value,isActive:g.value,controls:i,scrollable:t.scrollable.value,activeColor:t.props.titleActiveColor,inactiveColor:t.props.titleInactiveColor,onClick:x=>u(r.proxy,s.value,x)},se(t.props,["type","color","shrink"]),se(e,["dot","badge","title","disabled","showZeroBadge"])),{title:a.title}),S=C(!g.value);return $(g,u=>{u?S.value=!1:nt(()=>{S.value=!0})}),$(()=>e.title,()=>{t.setLine(),t.scrollIntoView()}),at(rt,g),ee({id:i,renderTitle:f}),()=>{var u;const x=`${t.id}-${s.value}`,{animated:d,swipeable:B,scrollspy:h,lazyRender:E}=t.props;if(!a.default&&!d)return;const D=h||g.value;if(d||B)return m(dt,{id:i,role:"tabpanel",class:q("panel-wrapper",{inactive:S.value}),tabindex:g.value?0:-1,"aria-hidden":!g.value,"aria-labelledby":x},{default:()=>{var O;return[m("div",{class:q("panel")},[(O=a.default)==null?void 0:O.call(a)])]}});const V=l.value||h||!E?(u=a.default)==null?void 0:u.call(a):null;return lt(m("div",{id:i,role:"tabpanel",class:q("panel"),tabindex:D?0:-1,"aria-labelledby":x},[V]),[[ot,D]])}}});const Pt=p(Bt),zt=p(St);export{zt as T,Pt as a};