"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("../../common/utils/index.cjs"),h=require("./collapsible-lazy-show.cjs"),i=require("@dialpad/dialtone-icons/vue3"),e=require("vue"),u=require("../../_plugin-vue_export-helper-BRilXfQE.cjs"),p=require("../lazy-show/lazy-show.cjs"),m=require("../button/button.cjs"),_={compatConfig:{MODE:3},name:"DtCollapsible",components:{DtButton:m.default,DtCollapsibleLazyShow:h.default,DtLazyShow:p.default,DtIconChevronDown:i.DtIconChevronDown,DtIconChevronRight:i.DtIconChevronRight},props:{anchorText:{type:String,default:null},open:{type:Boolean,default:null},id:{type:String,default(){return a.getUniqueString()}},elementType:{type:String,default:"div"},contentElementType:{type:String,default:"div"},anchorClass:{type:[String,Array,Object],default:null},contentClass:{type:[String,Array,Object],default:null},maxWidth:{type:String,default:null},maxHeight:{type:String,default:null},ariaLabel:{type:String,default:null},ariaLabelledBy:{type:String,default:null}},emits:["update:open","opened"],data(){return{isOpen:!0}},computed:{labelledBy(){return this.ariaLabelledBy||!this.ariaLabel&&a.getUniqueString("DtCollapsible__anchor")},collapsibleListeners(){return a.extractVueListeners(this.$attrs)}},watch:{open:{handler:function(l){l!==null&&(this.isOpen=l)},immediate:!0}},created(){this.validateProperAnchor()},methods:{onLeaveTransitionComplete(){this.$emit("opened",!1),this.open!==null&&this.$emit("update:open",!1)},onEnterTransitionComplete(){this.$emit("opened",!0,this.$refs.content),this.open!==null&&this.$emit("update:open",!0)},defaultToggleOpen(){this.open===null&&this.toggleOpen()},toggleOpen(){this.isOpen=!this.isOpen},validateProperAnchor(){!this.anchorText&&!a.hasSlotContent(this.$slots.anchor)&&console.error("anchor text and anchor slot content cannot both be falsy")}}},b=["id"],y=["title"];function f(l,C,t,v,o,n){const r=e.resolveComponent("dt-icon-chevron-down"),s=e.resolveComponent("dt-icon-chevron-right"),c=e.resolveComponent("dt-button"),d=e.resolveComponent("dt-collapsible-lazy-show");return e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.elementType),e.mergeProps({ref:"collapsible"},e.toHandlers(n.collapsibleListeners)),{default:e.withCtx(()=>[e.createElementVNode("div",{id:!t.ariaLabelledBy&&n.labelledBy,ref:"anchor",class:e.normalizeClass(t.anchorClass)},[e.renderSlot(l.$slots,"anchor",{attrs:{"aria-controls":t.id,"aria-expanded":o.isOpen.toString(),role:"button"}},()=>[e.createVNode(c,{importance:"clear",kind:"muted","aria-controls":t.id,"aria-expanded":`${o.isOpen}`,style:e.normalizeStyle({width:t.maxWidth}),onClick:n.defaultToggleOpen},{default:e.withCtx(()=>[o.isOpen?(e.openBlock(),e.createBlock(r,{key:0,class:"d-collapsible__icon",size:"300"})):(e.openBlock(),e.createBlock(s,{key:1,class:"d-collapsible__icon",size:"300"})),e.createElementVNode("span",{class:"d-collapsible__anchor-text",title:t.anchorText},e.toDisplayString(t.anchorText),9,y)]),_:1},8,["aria-controls","aria-expanded","style","onClick"])])],10,b),e.createVNode(d,e.mergeProps({id:t.id,ref:"contentWrapper","aria-hidden":`${!o.isOpen}`,"aria-labelledby":n.labelledBy,"aria-label":t.ariaLabel,show:o.isOpen,"element-type":t.contentElementType,class:t.contentClass,style:{"max-height":t.maxHeight,"max-width":t.maxWidth},"data-qa":"dt-collapsible--content",tabindex:"-1",appear:""},e.toHandlers(n.collapsibleListeners),{onAfterLeave:n.onLeaveTransitionComplete,onAfterEnter:n.onEnterTransitionComplete}),{default:e.withCtx(()=>[e.renderSlot(l.$slots,"content")]),_:3},16,["id","aria-hidden","aria-labelledby","aria-label","show","element-type","class","style","onAfterLeave","onAfterEnter"])]),_:3},16)}const g=u._(_,[["render",f]]);exports.default=g;
//# sourceMappingURL=collapsible.cjs.map
