const e=require("../_util/util.js"),t=require("../_util/classNames.js"),n=require("../_util/props-util/initDefaultProps.js"),r=require("../_util/props-util/index.js"),i=require("../config-provider/hooks/useConfigInject.js"),a=require("../_util/vnode.js"),o=require("../_util/firstNotUndefined.js"),s=require("../_util/collapseMotion.js"),c=require("./commonProps.js"),l=require("./style/index.js");let u=require("vue"),d=require("@antsoo-lib/icons");function f(e){let t=e;if(!Array.isArray(t)){let e=typeof t;t=e===`number`||e===`string`?[t]:[]}return t.map(e=>String(e))}var p=(0,u.defineComponent)({compatConfig:{MODE:3},name:`ACollapse`,inheritAttrs:!1,props:n.default(c.collapseProps(),{accordion:!1,destroyInactivePanel:!1,bordered:!0,expandIconPosition:`start`}),slots:Object,setup(n,{attrs:c,slots:p,emit:m}){let h=(0,u.ref)(f(o.default([n.activeKey,n.defaultActiveKey])));(0,u.watch)(()=>n.activeKey,()=>{h.value=f(n.activeKey)},{deep:!0});let{prefixCls:g,direction:_,rootPrefixCls:v}=i.default(`collapse`,n),[y,b]=l.default(g),x=(0,u.computed)(()=>{let{expandIconPosition:e}=n;return e===void 0?_.value===`rtl`?`end`:`start`:e}),S=e=>{let{expandIcon:t=p.expandIcon}=n,i=t?t(e):(0,u.createVNode)(d.RightOutlined,{rotate:e.isActive?90:void 0},null);return(0,u.createVNode)(`div`,{class:[`${g.value}-expand-icon`,b.value],onClick:()=>[`header`,`icon`].includes(n.collapsible)&&w(e.panelKey)},[r.isValidElement(Array.isArray(t)?i[0]:i)?a.cloneElement(i,{class:`${g.value}-arrow`},!1):i])},C=e=>{n.activeKey===void 0&&(h.value=e);let t=n.accordion?e[0]:e;m(`update:activeKey`,t),m(`change`,t)},w=e=>{let t=h.value;if(n.accordion)t=t[0]===e?[]:[e];else{t=[...t];let n=t.indexOf(e);n>-1?t.splice(n,1):t.push(e)}C(t)},T=(e,t)=>{if(r.isEmptyElement(e))return;let i=h.value,{accordion:o,destroyInactivePanel:c,collapsible:l,openAnimation:u}=n,d=u||s.default(`${v.value}-motion-collapse`),f=String(e.key??t),{header:p=e.children?.header?.(),headerClass:m,collapsible:_,disabled:y}=e.props||{},b=!1;b=o?i[0]===f:i.includes(f);let x=_??l;return(y||y===``)&&(x=`disabled`),a.cloneElement(e,{key:f,panelKey:f,header:p,headerClass:m,isActive:b,prefixCls:g.value,destroyInactivePanel:c,openAnimation:d,accordion:o,onItemClick:x===`disabled`?null:w,expandIcon:S,collapsible:x})},E=()=>r.flattenChildren(p.default?.()).map(T);return()=>{let{accordion:r,bordered:i,ghost:a}=n,o=t.default(g.value,{[`${g.value}-borderless`]:!i,[`${g.value}-icon-position-${x.value}`]:!0,[`${g.value}-rtl`]:_.value===`rtl`,[`${g.value}-ghost`]:!!a,[c.class]:!!c.class},b.value);return y((0,u.createVNode)(`div`,{class:o,...e.getDataAndAriaProps(c),style:c.style,role:r?`tablist`:null},[E()]))}}});exports.collapseProps=c.collapseProps,exports.default=p;