import{$n as e,Br as t,Bt as n,Ht as r,Jr as i,Or as a,Pr as o,Qn as s,Rr as c,Ut as l,Vr as u,W as d,Xt as f,Zn as p,ai as m,ar as h,di as g,dr as _,et as v,fr as y,gr as b,jr as x,kr as S,li as C,lr as w,mi as T,nt as E,or as D,p as O,pr as k,q as A,qt as j,sr as M,ti as N,ui as P,v as ee,x as F,zt as I}from"./style-QAnagFj5.js";import{I as L,P as R,r as z}from"./style-BqiJaO0R.js";import{l as B}from"./style-aJpPAPRc.js";import{l as V}from"./index-Et3B7hka.js";var H=e=>f(e)||P(e)||m(e),U=r({accordion:Boolean,modelValue:{type:l([Array,String,Number]),default:()=>z([])},expandIconPosition:{type:l([String]),default:`right`},beforeCollapse:{type:l(Function)}}),W={[L]:H,[R]:H},G=Symbol(`collapseContextKey`),K=r({title:{type:String,default:``},name:{type:l([String,Number]),default:void 0},icon:{type:ee,default:F},disabled:Boolean}),q=`ElCollapse`,J=(e,t)=>{let r=i(B(e.modelValue)),a=n=>{r.value=n;let i=e.accordion?r.value[0]:r.value;t(L,i),t(R,i)},o=t=>{if(e.accordion)a([r.value[0]===t?``:t]);else{let e=[...r.value],n=e.indexOf(t);n>-1?e.splice(n,1):e.push(t),a(e)}};return c(()=>e.modelValue,()=>r.value=B(e.modelValue),{deep:!0}),S(G,{activeNames:r,handleItemClick:async t=>{let{beforeCollapse:r}=e;if(!r){o(t);return}let i=r(t);[C(i),j(i)].includes(!0)||n(q,"beforeCollapse must return type `Promise<boolean>` or `boolean`"),C(i)?i.then(e=>{e!==!1&&o(t)}).catch(e=>{I(q,`some error occurred: ${e}`)}):i&&o(t)}}),{activeNames:r,setActiveNames:a}},Y=e=>{let t=E(`collapse`);return{rootKls:h(()=>[t.b(),t.b(`icon-position-${e.expandIconPosition}`)])}},X=k({name:`ElCollapse`,__name:`collapse`,props:U,emits:W,setup(e,{expose:t,emit:n}){let r=e,{activeNames:i,setActiveNames:o}=J(r,n),{rootKls:s}=Y(r);return t({activeNames:i,setActiveNames:o}),(e,t)=>(a(),w(`div`,{class:g(N(s))},[x(e.$slots,`default`)],2))}}),Z=e=>{let t=b(G),{namespace:n}=E(`collapse`),r=i(!1),a=i(!1),o=v(),s=h(()=>o.current++),c=h(()=>e.name??`${n.value}-id-${o.prefix}-${N(s)}`);return{focusing:r,id:s,isActive:h(()=>t?.activeNames.value.includes(N(c))),handleFocus:()=>{setTimeout(()=>{a.value?a.value=!1:r.value=!0},50)},handleHeaderClick:n=>{e.disabled||n.target?.closest(`input, textarea, select`)||(t?.handleItemClick(N(c)),r.value=!1,a.value=!0)},handleEnterClick:e=>{e.target?.closest(`input, textarea, select`)||(e.preventDefault(),t?.handleItemClick(N(c)))}}},Q=(e,{focusing:t,isActive:n,id:r})=>{let i=E(`collapse`),a=h(()=>[i.b(`item`),i.is(`active`,N(n)),i.is(`disabled`,e.disabled)]),o=h(()=>[i.be(`item`,`header`),i.is(`active`,N(n)),{focusing:N(t)&&!e.disabled}]),s=h(()=>[i.be(`item`,`arrow`),i.is(`active`,N(n))]);return{itemTitleKls:h(()=>[i.be(`item`,`title`)]),arrowKls:s,headKls:o,rootKls:a,itemWrapperKls:h(()=>i.be(`item`,`wrap`)),itemContentKls:h(()=>i.be(`item`,`content`)),scopedContentId:h(()=>i.b(`content-${N(r)}`)),scopedHeadId:h(()=>i.b(`head-${N(r)}`))}},te=[`id`,`aria-expanded`,`aria-controls`,`aria-describedby`,`tabindex`,`aria-disabled`],ne=[`id`,`aria-hidden`,`aria-labelledby`],$=k({name:`ElCollapseItem`,__name:`collapse-item`,props:K,setup(n,{expose:r}){let i=n,{focusing:c,id:l,isActive:d,handleFocus:f,handleHeaderClick:m,handleEnterClick:h}=Z(i),{arrowKls:v,headKls:b,rootKls:S,itemTitleKls:C,itemWrapperKls:E,itemContentKls:k,scopedContentId:A,scopedHeadId:j}=Q(i,{focusing:c,isActive:d,id:l});return r({isActive:d}),(r,i)=>(a(),w(`div`,{class:g(N(S))},[D(`div`,{id:N(j),class:g(N(b)),"aria-expanded":N(d),"aria-controls":N(A),"aria-describedby":N(A),tabindex:n.disabled?void 0:0,"aria-disabled":n.disabled,role:`button`,onClick:i[0]||=(...e)=>N(m)&&N(m)(...e),onKeydown:i[1]||=s(e((...e)=>N(h)&&N(h)(...e),[`stop`]),[`space`,`enter`]),onFocus:i[2]||=(...e)=>N(f)&&N(f)(...e),onBlur:i[3]||=e=>c.value=!1},[D(`span`,{class:g(N(C))},[x(r.$slots,`title`,{isActive:N(d)},()=>[_(T(n.title),1)])],2),x(r.$slots,`icon`,{isActive:N(d)},()=>[y(N(O),{class:g(N(v))},{default:t(()=>[(a(),M(o(n.icon)))]),_:1},8,[`class`])])],42,te),y(N(V),null,{default:t(()=>[u(D(`div`,{id:N(A),role:`region`,class:g(N(E)),"aria-hidden":!N(d),"aria-labelledby":N(j)},[D(`div`,{class:g(N(k))},[x(r.$slots,`default`)],2)],10,ne),[[p,N(d)]])]),_:3})],2))}}),re=d(X,{CollapseItem:$}),ie=A($);export{ie as n,re as t};