"use strict";const e=require("vue"),d=require("./Icon.js"),u=require("./CdxButton.cjs"),p=require("./_plugin-vue_export-helper.js");require("./useComputedDirection.cjs");require("./useComputedLanguage.cjs");require("./constants.js");require("./useIconOnlyButton.js");require("./useSlotContents.js");require("./useWarnOnce.cjs");const m=e.defineComponent({name:"CdxAccordion",components:{CdxButton:u,CdxIcon:d.CdxIcon},props:{actionAlwaysVisible:{type:Boolean,default:!1},actionIcon:{type:[String,Object],default:null},actionButtonLabel:{type:String,default:""},headingLevel:{type:String,default:"h3"}},emits:["action-button-click"],setup(o,{attrs:n,emit:r}){const c=e.ref("open"in n),s=()=>{r("action-button-click")},a=l=>{c.value=l.newState==="open"},t=e.computed(()=>o.actionIcon&&(c.value||o.actionAlwaysVisible)),i=e.computed(()=>({"cdx-accordion--has-icon":t.value}));return{emitActionButtonClick:s,rootClasses:i,shouldShowActionButton:t,onToggle:a}}});const _={class:"cdx-accordion__header__title"},C={class:"cdx-accordion__header__description"};function f(o,n,r,c,s,a){const t=e.resolveComponent("cdx-icon"),i=e.resolveComponent("cdx-button");return e.openBlock(),e.createElementBlock("details",{class:e.normalizeClass(["cdx-accordion",o.rootClasses]),onToggle:n[1]||(n[1]=(...l)=>o.onToggle&&o.onToggle(...l))},[e.createElementVNode("summary",null,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(o.headingLevel),{class:"cdx-accordion__header"},{default:e.withCtx(()=>[e.createElementVNode("span",_,[e.renderSlot(o.$slots,"title")]),e.createElementVNode("span",C,[e.renderSlot(o.$slots,"description")])]),_:3})),o.shouldShowActionButton?(e.openBlock(),e.createBlock(i,{key:0,class:"cdx-accordion__action","aria-label":o.actionButtonLabel,type:"button",weight:"quiet",onClick:e.withModifiers(o.emitActionButtonClick,["stop"])},{default:e.withCtx(()=>[e.createVNode(t,{icon:o.actionIcon,"icon-label":o.actionButtonLabel,size:"medium"},null,8,["icon","icon-label"])]),_:1},8,["aria-label","onClick"])):e.createCommentVNode("",!0)]),e.createElementVNode("div",{class:"cdx-accordion__content",onClick:n[0]||(n[0]=e.withModifiers(()=>{},["stop"]))},[e.renderSlot(o.$slots,"default")])],34)}const g=p._export_sfc(m,[["render",f]]);module.exports=g;
