1 "use strict";const t=require("vue"),m=require("./CdxLabel.cjs"),b=require("./useLabelChecker.js"),w=require("./useModelWrapper.cjs"),c=require("./useGeneratedId.cjs"),y=require("./useSplitAttributes.cjs"),k=require("./useFieldData.cjs"),C=require("./_plugin-vue_export-helper.js"),v=t.defineComponent({name:"CdxToggleSwitch",components:{CdxLabel:m},inheritAttrs:!1,props:{modelValue:{type:[Boolean,Array],default:!1},inputValue:{type:[String,Number,Boolean],default:!1},alignSwitch:{type:Boolean,default:!1},hideLabel:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(e,{emit:o,slots:i,attrs:l}){var a;b.useLabelChecker((a=i.default)==null?void 0:a.call(i),l,"CdxToggleSwitch");const d=t.ref(),r=c("toggle-switch"),n=c("description"),s=t.computed(()=>({"cdx-toggle-switch--align-switch":e.alignSwitch})),{rootClasses:p,rootStyle:u,otherAttrs:h}=y(l,s),{computedDisabled:g}=k(t.toRef(e,"disabled")),f=w(t.toRef(e,"modelValue"),o);return{input:d,inputId:r,descriptionId:n,rootClasses:p,rootStyle:u,otherAttrs:h,computedDisabled:g,wrappedModel:f,clickInput:()=>{d.value.click()}}}}),$=["id","aria-describedby","value","disabled"],S=t.createElementVNode("span",{class:"cdx-toggle-switch__switch"},[t.createElementVNode("span",{class:"cdx-toggle-switch__switch__grip"})],-1);function I(e,o,i,l,d,r){const n=t.resolveComponent("cdx-label");return t.openBlock(),t.createElementBlock("span",{class:t.normalizeClass(["cdx-toggle-switch",e.rootClasses]),style:t.normalizeStyle(e.rootStyle)},[t.withDirectives(t.createElementVNode("input",t.mergeProps({id:e.inputId,ref:"input","onUpdate:modelValue":o[0]||(o[0]=s=>e.wrappedModel=s),class:"cdx-toggle-switch__input",type:"checkbox",role:"switch","aria-describedby":e.$slots.description&&e.$slots.description().length>0?e.descriptionId:void 0,value:e.inputValue,disabled:e.computedDisabled},e.otherAttrs,{onKeydown:o[1]||(o[1]=t.withKeys(t.withModifiers((...s)=>e.clickInput&&e.clickInput(...s),["prevent"]),["enter"]))}),null,16,$),[[t.vModelCheckbox,e.wrappedModel]]),S,e.$slots.default&&e.$slots.default().length?(t.openBlock(),t.createBlock(n,{key:0,class:"cdx-toggle-switch__label","input-id":e.inputId,"description-id":e.$slots.description&&e.$slots.description().length>0?e.descriptionId:void 0,"visually-hidden":e.hideLabel,disabled:e.computedDisabled},t.createSlots({default:t.withCtx(()=>[t.renderSlot(e.$slots,"default")]),_:2},[e.$slots.description&&e.$slots.description().length>0?{name:"description",fn:t.withCtx(()=>[t.renderSlot(e.$slots,"description")]),key:"0"}:void 0]),1032,["input-id","description-id","visually-hidden","disabled"])):t.createCommentVNode("v-if",!0)],6)}const V=C._export_sfc(v,[["render",I]]);module.exports=V;