"use strict";const e=require("vue"),d=require("./Icon.js"),u=require("./CdxButton.cjs"),p=require("./_plugin-vue_export-helper.js"),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:t,emit:s}){const c=e.ref("open"in t),a=()=>{s("action-button-click")},r=l=>{c.value=l.newState==="open"},n=e.computed(()=>o.actionIcon&&(c.value||o.actionAlwaysVisible)),i=e.computed(()=>({"cdx-accordion--has-icon":n.value}));return{emitActionButtonClick:a,rootClasses:i,shouldShowActionButton:n,onToggle:r}}}),C={class:"cdx-accordion__header__title"},_={class:"cdx-accordion__header__description"};function f(o,t,s,c,a,r){const n=e.resolveComponent("cdx-icon"),i=e.resolveComponent("cdx-button");return e.openBlock(),e.createElementBlock("details",{class:e.normalizeClass(["cdx-accordion",o.rootClasses]),onToggle:t[1]||(t[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",C,[e.renderSlot(o.$slots,"title")]),e.createElementVNode("span",_,[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(n,{icon:o.actionIcon,"icon-label":o.actionButtonLabel,size:"medium"},null,8,["icon","icon-label"])]),_:1},8,["aria-label","onClick"])):e.createCommentVNode("v-if",!0)]),e.createElementVNode("div",{class:"cdx-accordion__content",onClick:t[0]||(t[0]=e.withModifiers(()=>{},["stop"]))},[e.renderSlot(o.$slots,"default")])],34)}const b=p._export_sfc(m,[["render",f]]);module.exports=b;
