"use strict";const e=require("vue"),p=require("./Icon.js"),m=require("./CdxButton.cjs"),f=require("./useOptionalModelWrapper.js"),d=require("./constants.js"),g=require("./_plugin-vue_export-helper.js"),_=d.makeStringTypeValidator(d.AccordionSeparations),C=e.defineComponent({name:"CdxAccordion",components:{CdxButton:m,CdxIcon:p.CdxIcon},props:{modelValue:{type:[Boolean,null],default:null},actionAlwaysVisible:{type:Boolean,default:!1},separation:{type:String,default:"divider",validator:_},actionIcon:{type:[String,Object],default:null},actionButtonLabel:{type:String,default:""},headingLevel:{type:String,default:"h3"}},emits:["action-button-click","update:modelValue","toggle"],setup(o,{attrs:t,emit:c}){const r=e.ref("open"in t),n=f.useOptionalModelWrapper(r,e.toRef(o,"modelValue"),c),s=()=>{c("action-button-click")},i=u=>{n.value=u.newState==="open",c("toggle",n.value)},l=e.computed(()=>o.actionIcon?n.value?!0:!!o.actionAlwaysVisible:!1),a=e.computed(()=>({"cdx-accordion--has-icon":l.value,["cdx-accordion--separation-".concat(o.separation)]:!0}));return{emitActionButtonClick:s,rootClasses:a,shouldShowActionButton:l,onToggle:i,computedOpen:n}}}),h=["open"],B={class:"cdx-accordion__header__title"},b={class:"cdx-accordion__header__description"};function k(o,t,c,r,n,s){const i=e.resolveComponent("cdx-icon"),l=e.resolveComponent("cdx-button");return e.openBlock(),e.createElementBlock("details",{class:e.normalizeClass(["cdx-accordion",o.rootClasses]),open:o.computedOpen||void 0,onToggle:t[1]||(t[1]=(...a)=>o.onToggle&&o.onToggle(...a))},[e.createElementVNode("summary",null,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(o.headingLevel),{class:"cdx-accordion__header"},{default:e.withCtx(()=>[e.createElementVNode("span",B,[e.renderSlot(o.$slots,"title")]),e.createElementVNode("span",b,[e.renderSlot(o.$slots,"description")])]),_:3})),o.shouldShowActionButton?(e.openBlock(),e.createBlock(l,{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(i,{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")])],42,h)}const v=g._export_sfc(C,[["render",k]]);module.exports=v;
