import{ap as j,ao as M,aV as W,Q as A,aE as S,as as T,ac as y,ab as z,r as K,z as G,W as w,s as d,G as L,bm as k,aD as U,ad as q,U as V,j as E,c as D,h as g,a0 as _,n as f,O as e,ak as Q,aB as J,q as R,bn as X,b as h,f as $,e as Y,t as Z,w as B,l as ee,a1 as se,$ as ae,K as te,aL as oe,A as le,B as ne,b8 as ie,a4 as ce,av as re}from"./index-Xuk4tRmH.js";import{f as P}from"./select-CquTMhG_.js";const x=a=>j(a)||M(a)||W(a),de=A({accordion:Boolean,modelValue:{type:y([Array,String,Number]),default:()=>z([])},expandIconPosition:{type:y([String]),default:"right"},beforeCollapse:{type:y(Function)}}),ue={[T]:x,[S]:x},O=Symbol("collapseContextKey"),pe="ElCollapse",me=(a,n)=>{const t=K(P(a.modelValue)),i=o=>{t.value=o;const l=a.accordion?t.value[0]:t.value;n(T,l),n(S,l)},s=o=>{if(a.accordion)i([t.value[0]===o?"":o]);else{const l=[...t.value],r=l.indexOf(o);r>-1?l.splice(r,1):l.push(o),i(l)}},c=async o=>{const{beforeCollapse:l}=a;if(!l){s(o);return}const r=l(o);[k(r),U(r)].includes(!0)||q(pe,"beforeCollapse must return type `Promise<boolean>` or `boolean`"),k(r)?r.then(p=>{p!==!1&&s(o)}).catch(p=>{}):r&&s(o)};return G(()=>a.modelValue,()=>t.value=P(a.modelValue),{deep:!0}),L(O,{activeNames:t,handleItemClick:c}),{activeNames:t,setActiveNames:i}},fe=a=>{const n=w("collapse");return{rootKls:d(()=>[n.b(),n.b(`icon-position-${a.expandIconPosition}`)])}},ve=E({name:"ElCollapse"}),be=E({...ve,props:de,emits:ue,setup(a,{expose:n,emit:t}){const i=a,{activeNames:s,setActiveNames:c}=me(i,t),{rootKls:o}=fe(i);return n({activeNames:s,setActiveNames:c}),(l,r)=>(g(),D("div",{class:f(e(o))},[_(l.$slots,"default")],2))}});var Ce=V(be,[["__file","collapse.vue"]]);const he=A({title:{type:String,default:""},name:{type:y([String,Number]),default:void 0},icon:{type:J,default:Q},disabled:Boolean}),ye=a=>{const n=R(O),{namespace:t}=w("collapse"),i=K(!1),s=K(!1),c=X(),o=d(()=>c.current++),l=d(()=>{var u;return(u=a.name)!=null?u:`${t.value}-id-${c.prefix}-${e(o)}`}),r=d(()=>n?.activeNames.value.includes(e(l)));return{focusing:i,id:o,isActive:r,handleFocus:()=>{setTimeout(()=>{s.value?s.value=!1:i.value=!0},50)},handleHeaderClick:u=>{if(a.disabled)return;const m=u.target;m?.closest("input, textarea, select")||(n?.handleItemClick(e(l)),i.value=!1,s.value=!0)},handleEnterClick:u=>{const m=u.target;m?.closest("input, textarea, select")||(u.preventDefault(),n?.handleItemClick(e(l)))}}},_e=(a,{focusing:n,isActive:t,id:i})=>{const s=w("collapse"),c=d(()=>[s.b("item"),s.is("active",e(t)),s.is("disabled",a.disabled)]),o=d(()=>[s.be("item","header"),s.is("active",e(t)),{focusing:e(n)&&!a.disabled}]),l=d(()=>[s.be("item","arrow"),s.is("active",e(t))]),r=d(()=>[s.be("item","title")]),b=d(()=>s.be("item","wrap")),p=d(()=>s.be("item","content")),C=d(()=>s.b(`content-${e(i)}`)),u=d(()=>s.b(`head-${e(i)}`));return{itemTitleKls:r,arrowKls:l,headKls:o,rootKls:c,itemWrapperKls:b,itemContentKls:p,scopedContentId:C,scopedHeadId:u}},Ee=E({name:"ElCollapseItem"}),Ie=E({...Ee,props:he,setup(a,{expose:n}){const t=a,{focusing:i,id:s,isActive:c,handleFocus:o,handleHeaderClick:l,handleEnterClick:r}=ye(t),{arrowKls:b,headKls:p,rootKls:C,itemTitleKls:u,itemWrapperKls:m,itemContentKls:H,scopedContentId:I,scopedHeadId:N}=_e(t,{focusing:i,isActive:c,id:s});return n({isActive:c}),(v,Ke)=>(g(),D("div",{class:f(e(C))},[h("div",{id:e(N),class:f(e(p)),"aria-expanded":e(c),"aria-controls":e(I),"aria-describedby":e(I),tabindex:v.disabled?-1:0,role:"button",onClick:e(l),onKeydown:te(oe(e(r),["stop"]),["space","enter"]),onFocus:e(o),onBlur:ge=>i.value=!1},[h("span",{class:f(e(u))},[_(v.$slots,"title",{isActive:e(c)},()=>[Y(Z(v.title),1)])],2),_(v.$slots,"icon",{isActive:e(c)},()=>[$(e(ae),{class:f(e(b))},{default:B(()=>[(g(),ee(se(v.icon)))]),_:1},8,["class"])])],42,["id","aria-expanded","aria-controls","aria-describedby","tabindex","onClick","onKeydown","onFocus","onBlur"]),$(e(ie),null,{default:B(()=>[le(h("div",{id:e(I),role:"region",class:f(e(m)),"aria-hidden":!e(c),"aria-labelledby":e(N)},[h("div",{class:f(e(H))},[_(v.$slots,"default")],2)],10,["id","aria-hidden","aria-labelledby"]),[[ne,e(c)]])]),_:3})],2))}});var F=V(Ie,[["__file","collapse-item.vue"]]);const ke=ce(Ce,{CollapseItem:F}),$e=re(F);export{ke as E,$e as a};
