import{_ as h,C as S,d as U,y as m,x as ne,P as te,a as L,s as le,w as ue,f as oe,g as R,b as P}from"./bootstrap-Bqxdt4iG.js";import{V as se}from"./Checkbox-DJCXJeWP.js";import{u as X,F as re}from"./FormItemContext-DjC4AFm9.js";import{u as q}from"./index-DUu2QB5i.js";import{a1 as z,E as y,a6 as ce,a8 as ie,N as de,aa as ve,L as I,p as w,U as K,a2 as fe}from"../jse/index-index-BUJ_4tQs.js";const me=()=>({name:String,prefixCls:String,options:U([]),disabled:Boolean,id:String}),he=()=>h(h({},me()),{defaultValue:U(),value:U(),onChange:S(),"onUpdate:value":S()}),be=()=>({prefixCls:String,defaultChecked:m(),checked:m(),disabled:m(),isGroup:m(),value:te.any,name:String,id:String,indeterminate:m(),type:ne("checkbox"),autofocus:m(),onChange:S(),"onUpdate:checked":S(),onClick:S(),skipGroup:m(!1)}),ge=()=>h(h({},be()),{indeterminate:m(!1)}),J=Symbol("CheckboxGroupContext");var H=function(e,b){var o={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&b.indexOf(t)<0&&(o[t]=e[t]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,t=Object.getOwnPropertySymbols(e);r<t.length;r++)b.indexOf(t[r])<0&&Object.prototype.propertyIsEnumerable.call(e,t[r])&&(o[t[r]]=e[t[r]]);return o};const O=z({compatConfig:{MODE:3},name:"ACheckbox",inheritAttrs:!1,__ANT_CHECKBOX:!0,props:ge(),setup(e,b){let{emit:o,attrs:t,slots:r,expose:_}=b;const C=X(),M=re.useInject(),{prefixCls:c,direction:g,disabled:j}=L("checkbox",e),$=le(),[i,f]=q(c),l=de(J,void 0),p=Symbol("checkboxUniId"),G=y(()=>(l==null?void 0:l.disabled.value)||j.value);ce(()=>{!e.skipGroup&&l&&l.registerValue(p,e.value)}),ie(()=>{l&&l.cancelValue(p)}),ve(()=>{ue(!!(e.checked!==void 0||l||e.value===void 0))});const A=a=>{const s=a.target.checked;o("update:checked",s),o("change",a),C.onFieldChange()},x=I();return _({focus:()=>{var a;(a=x.value)===null||a===void 0||a.focus()},blur:()=>{var a;(a=x.value)===null||a===void 0||a.blur()}}),()=>{var a;const s=oe((a=r.default)===null||a===void 0?void 0:a.call(r)),{indeterminate:u,skipGroup:d,id:E=C.id.value}=e,F=H(e,["indeterminate","skipGroup","id"]),{onMouseenter:T,onMouseleave:k,onInput:pe,class:W,style:Y}=t,Z=H(t,["onMouseenter","onMouseleave","onInput","class","style"]),v=h(h(h(h({},F),{id:E,prefixCls:c.value}),Z),{disabled:G.value});l&&!d?(v.onChange=function(){for(var N=arguments.length,B=new Array(N),V=0;V<N;V++)B[V]=arguments[V];o("change",...B),l.toggleOption({label:s,value:e.value})},v.name=l.name.value,v.checked=l.mergedValue.value.includes(e.value),v.disabled=G.value||$.value,v.indeterminate=u):v.onChange=A;const ee=R({[`${c.value}-wrapper`]:!0,[`${c.value}-rtl`]:g.value==="rtl",[`${c.value}-wrapper-checked`]:v.checked,[`${c.value}-wrapper-disabled`]:v.disabled,[`${c.value}-wrapper-in-form-item`]:M.isFormItemInput},W,f.value),ae=R({[`${c.value}-indeterminate`]:u},f.value);return i(w("label",{class:ee,style:Y,onMouseenter:T,onMouseleave:k},[w(se,P(P({"aria-checked":u?"mixed":void 0},v),{},{class:ae,ref:x}),null),s.length?w("span",null,[s]):null]))}}}),D=z({compatConfig:{MODE:3},name:"ACheckboxGroup",inheritAttrs:!1,props:he(),setup(e,b){let{slots:o,attrs:t,emit:r,expose:_}=b;const C=X(),{prefixCls:M,direction:c}=L("checkbox",e),g=y(()=>`${M.value}-group`),[j,$]=q(g),i=I((e.value===void 0?e.defaultValue:e.value)||[]);K(()=>e.value,()=>{i.value=e.value||[]});const f=y(()=>e.options.map(n=>typeof n=="string"||typeof n=="number"?{label:n,value:n}:n)),l=I(Symbol()),p=I(new Map),G=n=>{p.value.delete(n),l.value=Symbol()},A=(n,a)=>{p.value.set(n,a),l.value=Symbol()},x=I(new Map);return K(l,()=>{const n=new Map;for(const a of p.value.values())n.set(a,!0);x.value=n}),fe(J,{cancelValue:G,registerValue:A,toggleOption:n=>{const a=i.value.indexOf(n.value),s=[...i.value];a===-1?s.push(n.value):s.splice(a,1),e.value===void 0&&(i.value=s);const u=s.filter(d=>x.value.has(d)).sort((d,E)=>{const F=f.value.findIndex(k=>k.value===d),T=f.value.findIndex(k=>k.value===E);return F-T});r("update:value",u),r("change",u),C.onFieldChange()},mergedValue:i,name:y(()=>e.name),disabled:y(()=>e.disabled)}),_({mergedValue:i}),()=>{var n;const{id:a=C.id.value}=e;let s=null;return f.value&&f.value.length>0&&(s=f.value.map(u=>{var d;return w(O,{prefixCls:M.value,key:u.value.toString(),disabled:"disabled"in u?u.disabled:e.disabled,indeterminate:u.indeterminate,value:u.value,checked:i.value.indexOf(u.value)!==-1,onChange:u.onChange,class:`${g.value}-item`},{default:()=>[o.label!==void 0?(d=o.label)===null||d===void 0?void 0:d.call(o,u):u.label]})})),j(w("div",P(P({},t),{},{class:[g.value,{[`${g.value}-rtl`]:c.value==="rtl"},t.class,$.value],id:a}),[s||((n=o.default)===null||n===void 0?void 0:n.call(o))]))}}});O.Group=D;O.install=function(e){return e.component(O.name,O),e.component(D.name,D),e};export{D as CheckboxGroup,he as checkboxGroupProps,ge as checkboxProps,O as default};
