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