import{r as n,v as N,x as L,j as a,p as O,P,t as g,z,Y as H,a as j,o as K}from"./main-pzSpmpV2.js";import{u as T}from"./index-BtdXaa8D.js";var v="Checkbox",[q,Q]=O(v),[U,X]=q(v),I=n.forwardRef((e,i)=>{const{__scopeCheckbox:t,name:u,checked:p,defaultChecked:o,required:x,disabled:d,value:m="on",onCheckedChange:b,form:C,...y}=e,[r,E]=n.useState(null),w=N(i,s=>E(s)),l=n.useRef(!1),k=r?C||!!r.closest("form"):!0,[f,R]=L({prop:p,defaultProp:o??!1,onChange:b,caller:v}),A=n.useRef(f);return n.useEffect(()=>{const s=r==null?void 0:r.form;if(s){const h=()=>R(A.current);return s.addEventListener("reset",h),()=>s.removeEventListener("reset",h)}},[r,R]),a.jsxs(U,{scope:t,state:f,disabled:d,children:[a.jsx(P.button,{type:"button",role:"checkbox","aria-checked":c(f)?"mixed":f,"aria-required":x,"data-state":D(f),"data-disabled":d?"":void 0,disabled:d,value:m,...y,ref:w,onKeyDown:g(e.onKeyDown,s=>{s.key==="Enter"&&s.preventDefault()}),onClick:g(e.onClick,s=>{R(h=>c(h)?!0:!h),k&&(l.current=s.isPropagationStopped(),l.current||s.stopPropagation())})}),k&&a.jsx(B,{control:r,bubbles:!l.current,name:u,value:m,checked:f,required:x,disabled:d,form:C,style:{transform:"translateX(-100%)"},defaultChecked:c(o)?!1:o})]})});I.displayName=v;var S="CheckboxIndicator",_=n.forwardRef((e,i)=>{const{__scopeCheckbox:t,forceMount:u,...p}=e,o=X(S,t);return a.jsx(z,{present:u||c(o.state)||o.state===!0,children:a.jsx(P.span,{"data-state":D(o.state),"data-disabled":o.disabled?"":void 0,...p,ref:i,style:{pointerEvents:"none",...e.style}})})});_.displayName=S;var F="CheckboxBubbleInput",B=n.forwardRef(({__scopeCheckbox:e,control:i,checked:t,bubbles:u=!0,defaultChecked:p,...o},x)=>{const d=n.useRef(null),m=N(d,x),b=H(t),C=T(i);n.useEffect(()=>{const r=d.current;if(!r)return;const E=window.HTMLInputElement.prototype,l=Object.getOwnPropertyDescriptor(E,"checked").set;if(b!==t&&l){const k=new Event("click",{bubbles:u});r.indeterminate=c(t),l.call(r,c(t)?!1:t),r.dispatchEvent(k)}},[b,t,u]);const y=n.useRef(c(t)?!1:t);return a.jsx(P.input,{type:"checkbox","aria-hidden":!0,defaultChecked:p??y.current,...o,tabIndex:-1,ref:m,style:{...o.style,...C,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});B.displayName=F;function c(e){return e==="indeterminate"}function D(e){return c(e)?"indeterminate":e?"checked":"unchecked"}var M=I,Y=_;const $=n.forwardRef(({className:e,...i},t)=>a.jsx(M,{ref:t,className:j("peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...i,children:a.jsx(Y,{className:j("flex items-center justify-center text-current"),children:a.jsx(K,{className:"h-4 w-4"})})}));$.displayName=M.displayName;export{$ as C};
//# sourceMappingURL=checkbox-CIGiMGP9.js.map
