import{b as D,d as X,Q as oe,n as I,S as le,_ as re,b5 as ge,b6 as Ce,E as M,aq as Ne,ae as Te,ap as Pe,e as L,b4 as we,J as ae,m as Se,b7 as se,p as $e,a2 as Ee}from"./utils-8tx6kmmJ.js";import{t as Y,U as ie}from"./event-15MBjHp5.js";import{c as k}from"./strings-5LKvwcDq.js";import{H as xe,p as Be,d as A,C as G,r as C,bF as z,aO as Z,a as ce,i as ue,n as de,u as O,e as Oe,av as K,c as V,o as be,a$ as ke,m as f,b1 as Re,j as Q,q as ze,bw as Ae,D as Fe,a_ as Me,k as Le,v as Ve,g as De}from"./index-9mEhc-b9.js";import{f as Ie}from"./vnode-mlbQf0U9.js";const Ke=(e,n,c)=>Ie(e.subTree).filter(t=>{var d;return Be(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=xe([]);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=D({tabs:{type:X(Array),default:()=>oe([])}}),ve="ElTabBar",He=A({name:ve}),je=A({...He,props:qe,setup(e,{expose:n}){const c=e,N=K(),r=G(U);r||Y(ve,"<el-tabs><el-tab-bar /></el-tabs>");const t=I("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 p,S;const T=(S=(p=N.parent)==null?void 0:p.refs)==null?void 0:S["tab-".concat(a.uid)];if(!T)return!1;if(!a.active)return!0;u=T["offset".concat(k(B))],w=T["client".concat(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]:"".concat(w,"px"),transform:"translate".concat(k(l),"(").concat(u,"px)")}},m=()=>$.value=b();return z(()=>c.tabs,async()=>{await Z(),m()},{immediate:!0}),le(d,()=>m()),n({ref:d,update:m}),(u,w)=>(ce(),ue("div",{ref_key:"barRef",ref:d,class:de([O(t).e("active-bar"),O(t).is(O(r).props.tabPosition)]),style:Oe($.value)},null,6))}});var We=re(je,[["__file","tab-bar.vue"]]);const Je=D({panes:{type:X(Array),default:()=>oe([])},currentName:{type:[String,Number],default:""},editable:Boolean,type:{type:String,values:["card","border-card",""],default:""},stretch:Boolean}),Qe={tabClick:(e,n,c)=>c instanceof Event,tabRemove:(e,n)=>n instanceof Event},ne="ElTabNav",Xe=A({name:ne,props:Je,emits:Qe,setup(e,{expose:n,emit:c}){const N=K(),r=G(U);r||Y(ne,"<el-tabs><tab-nav /></el-tabs>");const t=I("tabs"),d=ge(),$=Ce(),b=C(),m=C(),u=C(),w=C(),v=C(!1),l=C(0),B=C(!1),a=C(!0),p=V(()=>["top","bottom"].includes(r.props.tabPosition)?"width":"height"),S=V(()=>{const o=p.value==="width"?"X":"Y";return{transform:"translate".concat(o,"(-").concat(l.value,"px)")}}),T=()=>{if(!b.value)return;const o=b.value["offset".concat(k(p.value))],i=l.value;if(!i)return;const s=i>o?i-o:0;l.value=s},E=()=>{if(!b.value||!m.value)return;const o=m.value["offset".concat(k(p.value))],i=b.value["offset".concat(k(p.value))],s=l.value;if(o-s<=i)return;const _=o-s>i*2?s+i:o-i;l.value=_},F=async()=>{const o=m.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(!m.value||!b.value)return;e.stretch&&((o=w.value)==null||o.update());const i=m.value["offset".concat(k(p.value))],s=b.value["offset".concat(k(p.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))},pe=o=>{const i=o.code,{up:s,down:_,left:g,right:y}=L;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}),le(u,ee),be(()=>setTimeout(()=>F(),0)),ke(()=>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(M,null,{default:()=>[f(Ne,null,null)]})]),f("span",{class:[t.e("nav-next"),t.is("disabled",!v.value.next)],onClick:E},[f(M,null,{default:()=>[f(Te,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:"".concat(_),W=!H&&(s.isClosable||e.editable);s.index="".concat(_);const he=W?f(M,{class:"is-icon-close",onClick:R=>c("tabRemove",s,R)},{default:()=>[f(Pe,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-".concat(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-".concat(j),key:"tab-".concat(h),"aria-controls":"pane-".concat(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===L.delete||R.code===L.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:m,style:S.value,role:"tablist",onKeydown:pe},[e.type?null:f(We,{ref:w,tabs:[...e.panes]},null),i])])])}}}),Ye=D({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}),J=e=>ze(e)||Se(e),Ge={[ie]:e=>J(e),tabClick:(e,n)=>n instanceof Event,tabChange:e=>J(e),edit:(e,n)=>["remove","add"].includes(n),tabRemove:e=>J(e),tabAdd:()=>!0},Ze=A({name:"ElTabs",props:Ye,emits:Ge,setup(e,{emit:n,slots:c,expose:N}){var r;const t=I("tabs"),{children:d,addChild:$,removeChild:b}=Ue(K(),"ElTabPane"),m=C(),u=C((r=e.modelValue)!=null?r:"0"),w=async(a,p=!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,p&&(n(ie,a),n("tabChange",a)),(E=(T=m.value)==null?void 0:T.removeFocus)==null||E.call(T))}catch(F){}},v=(a,p,S)=>{a.props.disabled||(w(p,!0),n("tabClick",a,S))},l=(a,p)=>{a.props.disabled||ae(a.props.name)||(p.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=m.value)==null||a.scrollToActiveTab()}),Re(U,{props:e,currentName:u,registerPane:$,unregisterPane:b}),N({currentName:u}),()=>{const a=c["add-icon"],p=e.editable||e.addable?f("span",{class:t.e("new-tab"),tabindex:"0",onClick:B,onKeydown:E=>{E.code===L.enter&&B()}},[a?Q(c,"add-icon"):f(M,{class:t.is("icon-plus")},{default:()=>[f(we,null,null)]})]):null,S=f("div",{class:[t.e("header"),t.is(e.tabPosition)]},[p,f(Xe,{ref:m,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")},[Q(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=D({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=Ae(),r=G(U);r||Y(fe,"usage: <el-tabs><el-tab-pane /></el-tabs/>");const t=I("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)}),m=C(b.value),u=V(()=>{var l;return(l=n.name)!=null?l:d.value}),w=se(()=>!n.lazy||m.value||b.value);z(b,l=>{l&&(m.value=!0)});const v=Fe({uid:c.uid,slots:N,props:n,paneName:u,active:b,index:d,isClosable:$});return be(()=>{r.registerPane(v)}),Me(()=>{r.unregisterPane(v.uid)}),(l,B)=>O(w)?Le((ce(),ue("div",{key:0,id:"pane-".concat(O(u)),class:de(O(t).b()),role:"tabpanel","aria-hidden":!O(b),"aria-labelledby":"tab-".concat(O(u))},[Q(l.$slots,"default")],10,tt)),[[Ve,O(b)]]):De("v-if",!0)}});var me=re(st,[["__file","tab-pane.vue"]]);const ct=$e(Ze,{TabPane:me}),ut=Ee(me);export{ut as E,ct as a};
