const e=require("../config-provider/hooks/useConfigInject.js"),t=require("../form/FormItemContext.js"),n=require("./style/index.js"),r=require("./interface.js"),i=require("./Checkbox.js");let a=require("vue");var o=(0,a.defineComponent)({compatConfig:{MODE:3},name:`ACheckboxGroup`,inheritAttrs:!1,props:r.checkboxGroupProps(),setup(o,{slots:s,attrs:c,emit:l,expose:u}){let d=t.useInjectFormItemContext(),{prefixCls:f,direction:p}=e.default(`checkbox`,o),m=(0,a.computed)(()=>`${f.value}-group`),[h,g]=n.default(m),_=(0,a.ref)((o.value===void 0?o.defaultValue:o.value)||[]);(0,a.watch)(()=>o.value,()=>{_.value=o.value||[]});let v=(0,a.computed)(()=>o.options.map(e=>typeof e==`string`||typeof e==`number`?{label:e,value:e}:e)),y=(0,a.ref)(Symbol()),b=(0,a.ref)(new Map),x=e=>{b.value.delete(e),y.value=Symbol()},S=(e,t)=>{b.value.set(e,t),y.value=Symbol()},C=(0,a.ref)(new Map);return(0,a.watch)(y,()=>{let e=new Map;for(let t of b.value.values())e.set(t,!0);C.value=e}),(0,a.provide)(r.CheckboxGroupContextKey,{cancelValue:x,registerValue:S,toggleOption:e=>{let t=_.value.indexOf(e.value),n=[..._.value];t===-1?n.push(e.value):n.splice(t,1),o.value===void 0&&(_.value=n);let r=n.filter(e=>C.value.has(e)).sort((e,t)=>v.value.findIndex(t=>t.value===e)-v.value.findIndex(e=>e.value===t));l(`update:value`,r),l(`change`,r),d.onFieldChange()},mergedValue:_,name:(0,a.computed)(()=>o.name),disabled:(0,a.computed)(()=>o.disabled)}),u({mergedValue:_}),()=>{let{id:e=d.id.value}=o,t=null;return v.value&&v.value.length>0&&(t=v.value.map(e=>(0,a.createVNode)(i.default,{prefixCls:f.value,key:e.value.toString(),disabled:`disabled`in e?e.disabled:o.disabled,indeterminate:e.indeterminate,value:e.value,checked:_.value.includes(e.value),onChange:e.onChange,class:`${m.value}-item`},{default:()=>[s.label===void 0?e.label:s.label?.(e)]}))),h((0,a.createVNode)(`div`,{...c,class:[m.value,{[`${m.value}-rtl`]:p.value===`rtl`},c.class,g.value],id:e},[t||s.default?.()]))}}});exports.default=o;