import{i as e,t}from"./react-B8IZ02wI.js";import{At as n,Bt as r,E as i,Et as a,Ot as o,Tt as s,Ut as c,V as l,W as u,_ as d,et as f,ht as p,kt as m,ln as h,ot as g,pn as _,q as v,rt as y,u as b,v as x,vn as S}from"./button-DqbiydrF.js";import{C,W as w}from"./useForm-D_WiMFpZ.js";var T=e(t());function E(){return E=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},E.apply(this,arguments)}var D=(0,T.forwardRef)((e,t)=>{let{prefixCls:r=`rc-checkbox`,className:i,style:a,checked:o,disabled:s,defaultChecked:c=!1,type:l=`checkbox`,title:u,onChange:d,...f}=e,p=(0,T.useRef)(null),m=(0,T.useRef)(null),[h,g]=_(c,o);(0,T.useImperativeHandle)(t,()=>({focus:e=>{p.current?.focus(e)},blur:()=>{p.current?.blur()},input:p.current,nativeElement:m.current}));let v=n(r,i,{[`${r}-checked`]:h,[`${r}-disabled`]:s});return T.createElement(`span`,{className:v,title:u,style:a,ref:m},T.createElement(`input`,E({},f,{className:`${r}-input`,ref:p,onChange:t=>{s||(`checked`in e||g(t.target.checked),d?.({target:{...e,type:l,checked:t.target.checked},stopPropagation(){t.stopPropagation()},preventDefault(){t.preventDefault()},nativeEvent:t.nativeEvent}))},disabled:s,checked:!!h,type:l})))});function O(e){let t=T.useRef(null),n=()=>{r.cancel(t.current),t.current=null};return[()=>{n(),t.current=r(()=>{t.current=null})},r=>{t.current&&(r.stopPropagation(),n()),e?.(r)}]}var k=e=>{let{checkboxCls:t,checkboxSize:n,lineWidth:r}=e,i=`${t}-wrapper`,a=`@media (hover: hover) and (pointer: fine)`;return[{[`${t}-group`]:{...g(e),display:`inline-flex`,flexWrap:`wrap`,columnGap:e.marginXS,[`> ${e.antCls}-row`]:{flex:1}},[i]:{...g(e),display:`inline-flex`,alignItems:`baseline`,cursor:`pointer`,"&:after":{display:`inline-block`,width:0,overflow:`hidden`,content:`'\\a0'`},[`& + ${i}`]:{marginInlineStart:0}},[t]:{...g(e),position:`relative`,whiteSpace:`nowrap`,lineHeight:1,cursor:`pointer`,alignSelf:`center`,boxSizing:`border-box`,display:`block`,width:n,height:n,direction:`ltr`,backgroundColor:e.colorBgContainer,border:`${s(r)} ${e.lineType} ${e.colorBorder}`,borderRadius:e.borderRadiusSM,borderCollapse:`separate`,transition:`all ${e.motionDurationSlow}`,flex:`none`,...b(),"&:after":{boxSizing:`border-box`,position:`absolute`,top:`calc(${n} / 2 - ${r})`,insetInlineStart:`calc(${n} / 4 - ${r})`,display:`table`,width:e.calc(n).div(14).mul(5).equal(),height:e.calc(n).div(14).mul(8).equal(),border:`${s(e.lineWidthBold)} solid ${e.colorWhite}`,borderTop:0,borderInlineStart:0,transform:`rotate(45deg) scale(0) translate(-50%,-50%)`,opacity:0,content:`""`,transition:`all ${e.motionDurationFast} ${e.motionEaseInBack}, opacity ${e.motionDurationFast}`,...b()},[`${t}-input`]:{position:`absolute`,inset:`calc(-1 * (${r}))`,zIndex:1,cursor:`pointer`,opacity:0,margin:0},[`&:has(${t}-input:focus-visible)`]:y(e),"& + span":{paddingInlineStart:e.paddingXS,paddingInlineEnd:e.paddingXS}}},{[a]:{[`
          ${i}:not(${i}-disabled),
          ${t}:not(${t}-disabled)
        `]:{[`&:hover ${t}`]:{borderColor:e.colorPrimary}},[`${i}:not(${i}-disabled)`]:{[`&:hover ${t}-checked:not(${t}-disabled)`]:{backgroundColor:e.colorPrimaryHover,borderColor:`transparent`}}}},{[`${t}-checked`]:{backgroundColor:e.colorPrimary,borderColor:e.colorPrimary,"&:after":{opacity:1,transform:`rotate(45deg) scale(1) translate(-50%,-50%)`,transition:`all ${e.motionDurationMid} ${e.motionEaseOutBack} ${e.motionDurationFast}`,...b()},[a]:{[`&:not(${t}-disabled):hover`]:{backgroundColor:e.colorPrimaryHover,borderColor:`transparent`}}}},{[t]:{"&-indeterminate":{backgroundColor:e.colorBgContainer,borderColor:e.colorBorder,"&:after":{top:`50%`,insetInlineStart:`50%`,width:e.calc(e.fontSizeLG).div(2).equal(),height:e.calc(e.fontSizeLG).div(2).equal(),backgroundColor:e.colorPrimary,border:0,transform:`translate(-50%, -50%) scale(1)`,opacity:1,content:`""`},[a]:{[`&:not(${t}-disabled):hover`]:{backgroundColor:e.colorBgContainer,borderColor:e.colorPrimary}}}}},{[`${i}-disabled`]:{cursor:`not-allowed`},[`${t}-disabled`]:{[`&, ${t}-input`]:{cursor:`not-allowed`,pointerEvents:`none`},background:e.colorBgContainerDisabled,borderColor:e.colorBorder,"&:after":{borderColor:e.colorTextDisabled},"& + span":{color:e.colorTextDisabled},[`&${t}-indeterminate::after`]:{background:e.colorTextDisabled}}}]};function A(e,t){return k(p(t,{checkboxCls:`.${e}`,checkboxSize:t.controlInteractiveSize}))}var j=f(`Checkbox`,(e,{prefixCls:t})=>[A(t,e)]),M=T.createContext(null),N=T.forwardRef((e,t)=>{let{prefixCls:r,children:a,indeterminate:s=!1,onMouseEnter:c,onMouseLeave:u,skipGroup:f=!1,disabled:p,rootClassName:m,className:g,style:y,classNames:b,styles:E,name:k,value:A,checked:N,defaultChecked:P,onChange:F,...I}=e,{getPrefixCls:L,direction:R,className:z,style:B,classNames:V,styles:H}=o(`checkbox`),U=T.useContext(M),{isFormItemInput:W}=T.useContext(C),ee=T.useContext(i),G=(U?.disabled||p)??ee,[te,ne]=_(P,N),K=te,re=S(e=>{ne(e.target.checked),F?.(e),!f&&U?.toggleOption&&U.toggleOption({label:a,value:A})});U&&!f&&(K=U.value.includes(A));let q=T.useRef(null),ie=h(t,q);T.useEffect(()=>{if(!(f||!U))return U.registerValue(A),()=>{U.cancelValue(A)}},[A,f]),T.useEffect(()=>{q.current?.input&&(q.current.input.indeterminate=s)},[s]);let J=L(`checkbox`,r),Y=w(J),[X,ae]=j(J,Y),Z={...I},oe={...e,indeterminate:s,disabled:G,checked:K},[Q,$]=l([V,b],[H,E],{props:oe}),se=n(`${J}-wrapper`,{[`${J}-rtl`]:R===`rtl`,[`${J}-wrapper-checked`]:K,[`${J}-wrapper-disabled`]:G,[`${J}-wrapper-in-form-item`]:W},z,g,Q.root,m,ae,Y,X),ce=n(Q.icon,{[`${J}-indeterminate`]:s},x,X),[le,ue]=O(Z.onClick);return T.createElement(d,{component:`Checkbox`,disabled:G},T.createElement(`label`,{className:se,style:{...$.root,...B,...y},onMouseEnter:c,onMouseLeave:u,onClick:le},T.createElement(D,{...Z,name:!f&&U?U.name:k,checked:K,onClick:ue,onChange:re,prefixCls:J,className:ce,style:$.icon,disabled:G,ref:ie,value:A}),v(a)&&T.createElement(`span`,{className:n(`${J}-label`,Q.label),style:$.label},a)))}),P=T.forwardRef((e,t)=>{let{defaultValue:r,children:i,options:o=[],prefixCls:s,className:l,rootClassName:d,style:f,onChange:p,role:h=`group`,...g}=e,{getPrefixCls:_,direction:v}=T.useContext(a),[y,b]=T.useState(g.value||r||[]),[x,S]=T.useState([]);T.useEffect(()=>{`value`in g&&b(g.value||[])},[g.value]);let C=T.useMemo(()=>o.map(e=>typeof e==`string`||u(e)?{label:e,value:e}:e),[o]),E=e=>{S(t=>t.filter(t=>t!==e))},D=e=>{S(t=>[].concat(m(t),[e]))},O=e=>{let t=y.indexOf(e.value),n=m(y);t===-1?n.push(e.value):n.splice(t,1),`value`in g||b(n),p?.(n.filter(e=>x.includes(e)).sort((e,t)=>C.findIndex(t=>t.value===e)-C.findIndex(e=>e.value===t)))},k=_(`checkbox`,s),A=`${k}-group`,P=w(k),[F,I]=j(k,P),L=c(g,[`value`,`disabled`]),R=o.length?C.map(e=>T.createElement(N,{prefixCls:k,key:e.value.toString(),disabled:`disabled`in e?e.disabled:g.disabled,value:e.value,checked:y.includes(e.value),onChange:e.onChange,className:n(`${A}-item`,e.className),style:e.style,title:e.title,id:e.id,required:e.required},e.label)):i,z=T.useMemo(()=>({toggleOption:O,value:y,disabled:g.disabled,name:g.name,registerValue:D,cancelValue:E}),[O,y,g.disabled,g.name,D,E]),B=n(A,{[`${A}-rtl`]:v===`rtl`},l,d,I,P,F);return T.createElement(`div`,{className:B,style:f,role:h,...L,ref:t},T.createElement(M.Provider,{value:z},R))}),F=N;F.Group=P,F.__ANT_CHECKBOX=!0;export{D as i,A as n,O as r,F as t};