import{a as e,t}from"./chunk-jRWAZmH_.js";import{n}from"./jsx-runtime-CEixWuwE.js";import{Wn as r}from"./axios-v6FV69Ne.js";import{J as i,Y as a,_t as o,vt as s}from"./index-BqyXv5bE.js";import{E as c,T as l,_ as u,g as d,i as f,n as p,t as m,w as h,y as g}from"./context-un7wPzry.js";var _=t((e=>{var t=c().default,o=a().default;Object.defineProperty(e,`__esModule`,{value:!0}),e.default=e.GroupContext=void 0;var s=o(i()),d=o(l()),f=o(u()),m=o(h()),_=o(r()),y=o(g()),b=t(n()),x=p(),S=o(v()),C=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n},w=e.GroupContext=b.createContext(null),T=b.forwardRef(function(e,t){var n=e.defaultValue,r=e.children,i=e.options,a=i===void 0?[]:i,o=e.prefixCls,c=e.className,l=e.style,u=e.onChange,p=C(e,[`defaultValue`,`children`,`options`,`prefixCls`,`className`,`style`,`onChange`]),h=b.useContext(x.ConfigContext),g=h.getPrefixCls,v=h.direction,T=b.useState(p.value||n||[]),E=(0,m.default)(T,2),D=E[0],O=E[1],k=b.useState([]),A=(0,m.default)(k,2),j=A[0],M=A[1];b.useEffect(function(){`value`in p&&O(p.value||[])},[p.value]);var N=function(){return a.map(function(e){return typeof e==`string`||typeof e==`number`?{label:e,value:e}:e})},P=function(e){M(function(t){return t.filter(function(t){return t!==e})})},F=function(e){M(function(t){return[].concat((0,f.default)(t),[e])})},I=function(e){var t=D.indexOf(e.value),n=(0,f.default)(D);t===-1?n.push(e.value):n.splice(t,1),`value`in p||O(n);var r=N();u?.(n.filter(function(e){return j.includes(e)}).sort(function(e,t){return r.findIndex(function(t){return t.value===e})-r.findIndex(function(e){return e.value===t})}))},L=g(`checkbox`,o),R=`${L}-group`,z=(0,y.default)(p,[`value`,`disabled`]);a&&a.length>0&&(r=N().map(function(e){return b.createElement(S.default,{prefixCls:L,key:e.value.toString(),disabled:`disabled`in e?e.disabled:p.disabled,value:e.value,checked:D.includes(e.value),onChange:e.onChange,className:`${R}-item`,style:e.style},e.label)}));var B={toggleOption:I,value:D,disabled:p.disabled,name:p.name,registerValue:F,cancelValue:P},V=(0,_.default)(R,(0,d.default)({},`${R}-rtl`,v===`rtl`),c);return b.createElement(`div`,(0,s.default)({className:V,style:l},z,{ref:t}),b.createElement(w.Provider,{value:B},r))});e.default=b.memo(T)})),v=t((t=>{var u=c().default,h=a().default;Object.defineProperty(t,`__esModule`,{value:!0}),t.default=void 0;var g=h(l()),v=h(i()),y=h(r()),b=h((s(),e(o))),x=u(n()),S=x,C=p(),w=m();h(d());var T=_(),E=h(f()),D=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n};t.default=S.forwardRef(function(e,t){var n=e.prefixCls,r=e.className,i=e.children,a=e.indeterminate,o=a===void 0?!1:a,s=e.style,c=e.onMouseEnter,l=e.onMouseLeave,u=e.skipGroup,d=u===void 0?!1:u,f=e.disabled,p=D(e,[`prefixCls`,`className`,`children`,`indeterminate`,`style`,`onMouseEnter`,`onMouseLeave`,`skipGroup`,`disabled`]),m=S.useContext(C.ConfigContext),h=m.getPrefixCls,_=m.direction,O=S.useContext(T.GroupContext),k=(0,x.useContext)(w.FormItemInputContext).isFormItemInput,A=(0,x.useContext)(E.default),j=(O?.disabled||f)??A,M=S.useRef(p.value);S.useEffect(function(){O?.registerValue(p.value)},[]),S.useEffect(function(){if(!d)return p.value!==M.current&&(O?.cancelValue(M.current),O?.registerValue(p.value),M.current=p.value),function(){return O?.cancelValue(p.value)}},[p.value]);var N=h(`checkbox`,n),P=(0,v.default)({},p);O&&!d&&(P.onChange=function(){p.onChange&&p.onChange.apply(p,arguments),O.toggleOption&&O.toggleOption({label:i,value:p.value})},P.name=O.name,P.checked=O.value.includes(p.value));var F=(0,y.default)((0,g.default)((0,g.default)((0,g.default)((0,g.default)((0,g.default)({},`${N}-wrapper`,!0),`${N}-rtl`,_===`rtl`),`${N}-wrapper-checked`,P.checked),`${N}-wrapper-disabled`,j),`${N}-wrapper-in-form-item`,k),r),I=(0,y.default)((0,g.default)({},`${N}-indeterminate`,o)),L=o?`mixed`:void 0;return S.createElement(`label`,{className:F,style:s,onMouseEnter:c,onMouseLeave:l},S.createElement(b.default,(0,v.default)({"aria-checked":L},P,{prefixCls:N,className:I,disabled:j,ref:t})),i!==void 0&&S.createElement(`span`,null,i))})}));export{v as t};