"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("@dialpad/dialtone-icons/vue3"),n=require("./chip-constants.cjs"),o=require("../../common/utils/index.cjs"),u=require("../../localization/index.cjs"),e=require("vue"),h=require("../../_plugin-vue_export-helper-BRilXfQE.cjs"),_=require("../button/button.cjs"),b={compatConfig:{MODE:3},name:"DtChip",components:{DtButton:_.default,DtIconClose:r.DtIconClose},props:{disabled:{type:Boolean,default:!1},hideClose:{type:Boolean,default:!1},size:{type:String,default:"md",validator:t=>Object.keys(n.CHIP_SIZE_MODIFIERS).includes(t)},interactive:{type:Boolean,default:!0},id:{type:String,default:function(){return o.getUniqueString()}},ariaLabel:{type:String,default:""},contentClass:{type:[String,Array,Object],default:""},labelClass:{type:[String,Array,Object],default:""}},emits:["click","close","keyup","keydown"],data(){return{isActive:!1,hasSlotContent:o.hasSlotContent,i18n:new u.DialtoneLocalization}},computed:{chipListeners(){return{click:t=>{this.interactive&&this.$emit("click",t)},keydown:t=>{var a;((a=t.code)==null?void 0:a.toLowerCase())==="delete"?this.onClose():this.$emit("keydown",t)},keyup:t=>{this.$emit("keyup",t)}}},closeButtonIconSize(){return n.CHIP_ICON_SIZES[this.size]},closeButtonTitle(){return this.i18n.$t("DIALTONE_CLOSE_BUTTON")}},methods:{chipClasses(){return[this.$attrs["grouped-chip"]?"d-chip":"d-chip__label",n.CHIP_SIZE_MODIFIERS[this.size],this.labelClass,this.disabled&&"d-chip--disabled"]},chipCloseButtonClasses(){return["d-chip__close",n.CHIP_CLOSE_BUTTON_SIZE_MODIFIERS[this.size],this.disabled&&"d-chip__close--disabled"]},onClose(){this.hideClose||this.$emit("close")}}},C={class:"d-chip"},p={key:0,class:"d-chip__icon","data-qa":"dt-chip-icon"},m={key:1,"data-qa":"dt-chip-avatar"},S=["id"];function k(t,a,i,f,s,l){const c=e.resolveComponent("dt-icon-close"),d=e.resolveComponent("dt-button");return e.openBlock(),e.createElementBlock("span",C,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(i.interactive?"button":"span"),e.mergeProps({id:i.id,"aria-label":i.ariaLabel,"aria-labelledby":i.ariaLabel?void 0:`${i.id}-content`,"aria-disabled":i.disabled,class:l.chipClasses(),type:i.interactive&&"button","data-qa":"dt-chip",tabindex:i.disabled?-1:null},e.toHandlers(l.chipListeners)),{default:e.withCtx(()=>[s.hasSlotContent(t.$slots.icon)?(e.openBlock(),e.createElementBlock("span",p,[e.renderSlot(t.$slots,"icon")])):s.hasSlotContent(t.$slots.avatar)?(e.openBlock(),e.createElementBlock("span",m,[e.renderSlot(t.$slots,"avatar")])):e.createCommentVNode("",!0),s.hasSlotContent(t.$slots.default)?(e.openBlock(),e.createElementBlock("span",{key:2,id:`${i.id}-content`,class:e.normalizeClass(["d-chip__text",i.contentClass]),"data-qa":"dt-chip-label"},[e.renderSlot(t.$slots,"default")],10,S)):e.createCommentVNode("",!0)]),_:3},16,["id","aria-label","aria-labelledby","aria-disabled","class","type","tabindex"])),i.hideClose?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(d,{key:0,class:e.normalizeClass(l.chipCloseButtonClasses()),"data-qa":"dt-chip-close","aria-label":l.closeButtonTitle,"aria-disabled":i.disabled,title:l.closeButtonTitle,tabindex:i.disabled?-1:null,onClick:a[0]||(a[0]=B=>t.$emit("close"))},{icon:e.withCtx(()=>[e.createVNode(c,{size:l.closeButtonIconSize},null,8,["size"])]),_:1},8,["class","aria-label","aria-disabled","title","tabindex"]))])}const y=h._(b,[["render",k]]);exports.default=y;
//# sourceMappingURL=chip.cjs.map
