import{a6 as ge,a7 as Ce,a8 as Ne,a9 as I,aa as X,ab as le,ac as A,I as Y,ad as Q,ae as D,r as C,J as z,x as Z,af as oe,o as re,c as ie,n as ce,g as O,l as Te,ag as ue,ah as k,ai as K,aj as Pe,ak as we,z as V,s as de,al as Se,f,am as L,an as $e,ao as Ee,ap as xe,aq as M,H as Be,G as J,ar as Oe,as as be,at as ae,au as ke,av as Re,aw as ze,ax as se,ay as Ae,y as Fe,L as Le,az as Me,i as Ve,aA as Ie,aB as De}from"./index-Cdt4oMy6.js";const Ke=(e,n,c)=>Ce(e.subTree).filter(t=>{var d;return Ne(t)&&((d=t.type)==null?void 0:d.name)===n&&!!t.component}).map(t=>t.component.uid).map(t=>c[t]).filter(t=>!!t),Ue=(e,n)=>{const c={},N=ge([]);return{children:N,addChild:d=>{c[d.uid]=d,N.value=Ke(e,n,c)},removeChild:d=>{delete c[d],N.value=N.value.filter($=>$.uid!==d)}}},U=Symbol("tabsRootContextKey"),qe=I({tabs:{type:X(Array),default:()=>le([])}}),ve="ElTabBar",He=A({name:ve}),je=A({...He,props:qe,setup(e,{expose:n}){const c=e,N=K(),r=Y(U);r||Q(ve,"<el-tabs><el-tab-bar /></el-tabs>");const t=D("tabs"),d=C(),$=C(),b=()=>{let u=0,w=0;const v=["top","bottom"].includes(r.props.tabPosition)?"width":"height",l=v==="width"?"x":"y",B=l==="x"?"left":"top";return c.tabs.every(a=>{var m,S;const T=(S=(m=N.parent)==null?void 0:m.refs)==null?void 0:S[`tab-${a.uid}`];if(!T)return!1;if(!a.active)return!0;u=T[`offset${k(B)}`],w=T[`client${k(v)}`];const E=window.getComputedStyle(T);return v==="width"&&(c.tabs.length>1&&(w-=Number.parseFloat(E.paddingLeft)+Number.parseFloat(E.paddingRight)),u+=Number.parseFloat(E.paddingLeft)),!1}),{[v]:`${w}px`,transform:`translate${k(l)}(${u}px)`}},p=()=>$.value=b();return z(()=>c.tabs,async()=>{await Z(),p()},{immediate:!0}),oe(d,()=>p()),n({ref:d,update:p}),(u,w)=>(re(),ie("div",{ref_key:"barRef",ref:d,class:ce([O(t).e("active-bar"),O(t).is(O(r).props.tabPosition)]),style:Te($.value)},null,6))}});var We=ue(je,[["__file","tab-bar.vue"]]);const Ge=I({panes:{type:X(Array),default:()=>le([])},currentName:{type:[String,Number],default:""},editable:Boolean,type:{type:String,values:["card","border-card",""],default:""},stretch:Boolean}),Je={tabClick:(e,n,c)=>c instanceof Event,tabRemove:(e,n)=>n instanceof Event},ne="ElTabNav",Xe=A({name:ne,props:Ge,emits:Je,setup(e,{expose:n,emit:c}){const N=K(),r=Y(U);r||Q(ne,"<el-tabs><tab-nav /></el-tabs>");const t=D("tabs"),d=Pe(),$=we(),b=C(),p=C(),u=C(),w=C(),v=C(!1),l=C(0),B=C(!1),a=C(!0),m=V(()=>["top","bottom"].includes(r.props.tabPosition)?"width":"height"),S=V(()=>({transform:`translate${m.value==="width"?"X":"Y"}(-${l.value}px)`})),T=()=>{if(!b.value)return;const o=b.value[`offset${k(m.value)}`],i=l.value;if(!i)return;const s=i>o?i-o:0;l.value=s},E=()=>{if(!b.value||!p.value)return;const o=p.value[`offset${k(m.value)}`],i=b.value[`offset${k(m.value)}`],s=l.value;if(o-s<=i)return;const _=o-s>i*2?s+i:o-i;l.value=_},F=async()=>{const o=p.value;if(!v.value||!u.value||!b.value||!o)return;await Z();const i=u.value.querySelector(".is-active");if(!i)return;const s=b.value,_=["top","bottom"].includes(r.props.tabPosition),g=i.getBoundingClientRect(),y=s.getBoundingClientRect(),x=_?o.offsetWidth-y.width:o.offsetHeight-y.height,P=l.value;let h=P;_?(g.left<y.left&&(h=P-(y.left-g.left)),g.right>y.right&&(h=P+g.right-y.right)):(g.top<y.top&&(h=P-(y.top-g.top)),g.bottom>y.bottom&&(h=P+(g.bottom-y.bottom))),h=Math.max(h,0),l.value=Math.min(h,x)},ee=()=>{var o;if(!p.value||!b.value)return;e.stretch&&((o=w.value)==null||o.update());const i=p.value[`offset${k(m.value)}`],s=b.value[`offset${k(m.value)}`],_=l.value;s<i?(v.value=v.value||{},v.value.prev=_,v.value.next=_+s<i,i-_<s&&(l.value=i-s)):(v.value=!1,_>0&&(l.value=0))},me=o=>{const i=o.code,{up:s,down:_,left:g,right:y}=M;if(![s,_,g,y].includes(i))return;const x=Array.from(o.currentTarget.querySelectorAll("[role=tab]:not(.is-disabled)")),P=x.indexOf(o.target);let h;i===g||i===s?P===0?h=x.length-1:h=P-1:P<x.length-1?h=P+1:h=0,x[h].focus({preventScroll:!0}),x[h].click(),te()},te=()=>{a.value&&(B.value=!0)},q=()=>B.value=!1;return z(d,o=>{o==="hidden"?a.value=!1:o==="visible"&&setTimeout(()=>a.value=!0,50)}),z($,o=>{o?setTimeout(()=>a.value=!0,50):a.value=!1}),oe(u,ee),de(()=>setTimeout(()=>F(),0)),Se(()=>ee()),n({scrollToActiveTab:F,removeFocus:q}),z(()=>e.panes,()=>N.update(),{flush:"post",deep:!0}),()=>{const o=v.value?[f("span",{class:[t.e("nav-prev"),t.is("disabled",!v.value.prev)],onClick:T},[f(L,null,{default:()=>[f($e,null,null)]})]),f("span",{class:[t.e("nav-next"),t.is("disabled",!v.value.next)],onClick:E},[f(L,null,{default:()=>[f(Ee,null,null)]})])]:null,i=e.panes.map((s,_)=>{var g,y,x,P;const h=s.uid,H=s.props.disabled,j=(y=(g=s.props.name)!=null?g:s.index)!=null?y:`${_}`,W=!H&&(s.isClosable||e.editable);s.index=`${_}`;const he=W?f(L,{class:"is-icon-close",onClick:R=>c("tabRemove",s,R)},{default:()=>[f(xe,null,null)]}):null,ye=((P=(x=s.slots).label)==null?void 0:P.call(x))||s.props.label,_e=!H&&s.active?0:-1;return f("div",{ref:`tab-${h}`,class:[t.e("item"),t.is(r.props.tabPosition),t.is("active",s.active),t.is("disabled",H),t.is("closable",W),t.is("focus",B.value)],id:`tab-${j}`,key:`tab-${h}`,"aria-controls":`pane-${j}`,role:"tab","aria-selected":s.active,tabindex:_e,onFocus:()=>te(),onBlur:()=>q(),onClick:R=>{q(),c("tabClick",s,j,R)},onKeydown:R=>{W&&(R.code===M.delete||R.code===M.backspace)&&c("tabRemove",s,R)}},[ye,he])});return f("div",{ref:u,class:[t.e("nav-wrap"),t.is("scrollable",!!v.value),t.is(r.props.tabPosition)]},[o,f("div",{class:t.e("nav-scroll"),ref:b},[f("div",{class:[t.e("nav"),t.is(r.props.tabPosition),t.is("stretch",e.stretch&&["top","bottom"].includes(r.props.tabPosition))],ref:p,style:S.value,role:"tablist",onKeydown:me},[e.type?null:f(We,{ref:w,tabs:[...e.panes]},null),i])])])}}}),Ye=I({type:{type:String,values:["card","border-card",""],default:""},closable:Boolean,addable:Boolean,modelValue:{type:[String,Number]},editable:Boolean,tabPosition:{type:String,values:["top","right","bottom","left"],default:"top"},beforeLeave:{type:X(Function),default:()=>!0},stretch:Boolean}),G=e=>ke(e)||Re(e),Qe={[be]:e=>G(e),tabClick:(e,n)=>n instanceof Event,tabChange:e=>G(e),edit:(e,n)=>["remove","add"].includes(n),tabRemove:e=>G(e),tabAdd:()=>!0},Ze=A({name:"ElTabs",props:Ye,emits:Qe,setup(e,{emit:n,slots:c,expose:N}){var r;const t=D("tabs"),{children:d,addChild:$,removeChild:b}=Ue(K(),"ElTabPane"),p=C(),u=C((r=e.modelValue)!=null?r:"0"),w=async(a,m=!1)=>{var S,T,E;if(!(u.value===a||ae(a)))try{await((S=e.beforeLeave)==null?void 0:S.call(e,a,u.value))!==!1&&(u.value=a,m&&(n(be,a),n("tabChange",a)),(E=(T=p.value)==null?void 0:T.removeFocus)==null||E.call(T))}catch{}},v=(a,m,S)=>{a.props.disabled||(w(m,!0),n("tabClick",a,S))},l=(a,m)=>{a.props.disabled||ae(a.props.name)||(m.stopPropagation(),n("edit",a.props.name,"remove"),n("tabRemove",a.props.name))},B=()=>{n("edit",void 0,"add"),n("tabAdd")};return z(()=>e.modelValue,a=>w(a)),z(u,async()=>{var a;await Z(),(a=p.value)==null||a.scrollToActiveTab()}),Be(U,{props:e,currentName:u,registerPane:$,unregisterPane:b}),N({currentName:u}),()=>{const a=c["add-icon"],m=e.editable||e.addable?f("span",{class:t.e("new-tab"),tabindex:"0",onClick:B,onKeydown:E=>{E.code===M.enter&&B()}},[a?J(c,"add-icon"):f(L,{class:t.is("icon-plus")},{default:()=>[f(Oe,null,null)]})]):null,S=f("div",{class:[t.e("header"),t.is(e.tabPosition)]},[m,f(Xe,{ref:p,currentName:u.value,editable:e.editable,type:e.type,panes:d.value,stretch:e.stretch,onTabClick:v,onTabRemove:l},null)]),T=f("div",{class:t.e("content")},[J(c,"default")]);return f("div",{class:[t.b(),t.m(e.tabPosition),{[t.m("card")]:e.type==="card",[t.m("border-card")]:e.type==="border-card"}]},[...e.tabPosition!=="bottom"?[S,T]:[T,S]])}}}),et=I({label:{type:String,default:""},name:{type:[String,Number]},closable:Boolean,disabled:Boolean,lazy:Boolean}),tt=["id","aria-hidden","aria-labelledby"],fe="ElTabPane",at=A({name:fe}),st=A({...at,props:et,setup(e){const n=e,c=K(),N=ze(),r=Y(U);r||Q(fe,"usage: <el-tabs><el-tab-pane /></el-tabs/>");const t=D("tab-pane"),d=C(),$=V(()=>n.closable||r.props.closable),b=se(()=>{var l;return r.currentName.value===((l=n.name)!=null?l:d.value)}),p=C(b.value),u=V(()=>{var l;return(l=n.name)!=null?l:d.value}),w=se(()=>!n.lazy||p.value||b.value);z(b,l=>{l&&(p.value=!0)});const v=Ae({uid:c.uid,slots:N,props:n,paneName:u,active:b,index:d,isClosable:$});return de(()=>{r.registerPane(v)}),Fe(()=>{r.unregisterPane(v.uid)}),(l,B)=>O(w)?Le((re(),ie("div",{key:0,id:`pane-${O(u)}`,class:ce(O(t).b()),role:"tabpanel","aria-hidden":!O(b),"aria-labelledby":`tab-${O(u)}`},[J(l.$slots,"default")],10,tt)),[[Me,O(b)]]):Ve("v-if",!0)}});var pe=ue(st,[["__file","tab-pane.vue"]]);const lt=Ie(Ze,{TabPane:pe}),ot=De(pe);export{ot as E,lt as a};