"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("vue"),A=require("../_util/classNames.js"),M=require("../_util/props-util/initDefaultProps.js"),w=require("../_util/vue-types/index.js"),h={prefixCls:String,name:String,id:String,type:String,defaultChecked:{type:[Boolean,Number],default:void 0},checked:{type:[Boolean,Number],default:void 0},disabled:Boolean,tabindex:{type:[Number,String]},readonly:Boolean,autofocus:Boolean,value:w.default.any,required:Boolean},E=n.defineComponent({compatConfig:{MODE:3},name:"Checkbox",inheritAttrs:!1,props:M.default(h,{prefixCls:"rc-checkbox",type:"checkbox",defaultChecked:!1}),emits:["click","change"],setup(t,{attrs:d,emit:s,expose:k}){const a=n.ref(t.checked===void 0?t.defaultChecked:t.checked),o=n.ref();n.watch(()=>t.checked,()=>{a.value=t.checked}),k({focus(){o.value?.focus()},blur(){o.value?.blur()}});const l=n.ref(),b=e=>{if(t.disabled)return;t.checked===void 0&&(a.value=e.target.checked),e.shiftKey=l.value;const u={target:{...t,checked:e.target.checked},stopPropagation(){e.stopPropagation()},preventDefault(){e.preventDefault()},nativeEvent:e};t.checked!==void 0&&(o.value.checked=!!t.checked),s("change",u),l.value=!1},v=e=>{s("click",e),l.value=e.shiftKey};return()=>{const{prefixCls:e,name:u,id:g,type:p,disabled:r,readonly:y,tabindex:C,autofocus:x,value:m,required:S,...N}=t,{class:P,onFocus:B,onBlur:q,onKeydown:K,onKeypress:D,onKeyup:O}=d,i={...N,...d},V=Object.keys(i).reduce((f,c)=>((c.startsWith("data-")||c.startsWith("aria-")||c==="role")&&(f[c]=i[c]),f),{}),$=A.default(e,P,{[`${e}-checked`]:a.value,[`${e}-disabled`]:r}),j={name:u,id:g,type:p,readonly:y,disabled:r,tabindex:C,class:`${e}-input`,checked:!!a.value,autofocus:x,value:m,...V,onChange:b,onClick:v,onFocus:B,onBlur:q,onKeydown:K,onKeypress:D,onKeyup:O,required:S};return n.createVNode("span",{class:$},[n.createVNode("input",{ref:o,...j},null),n.createVNode("span",{class:`${e}-inner`},null)])}}});exports.checkboxProps=h;exports.default=E;
