import{r as c,dw as u,dZ as F,dU as R,dT as V,dS as D,dV as I,dW as Y,dX as H,dY as X,j as N,o as z,d1 as w}from"./index-Ef5HIHwv.js";var g="Checkbox",[K]=X(g),[W,P]=K(g);function Z(t){const{__scopeCheckbox:n,checked:r,children:l,defaultChecked:s,disabled:e,form:b,name:p,onCheckedChange:i,required:m,value:k="on",internal_do_not_use_render:d}=t,[f,v]=V({prop:r,defaultProp:s??!1,onChange:i,caller:g}),[x,C]=c.useState(null),[y,o]=c.useState(null),a=c.useRef(!1),E=x?!!b||!!x.closest("form"):!0,S={checked:f,disabled:e,setChecked:v,control:x,setControl:C,name:p,form:b,value:k,hasConsumerStoppedPropagationRef:a,required:m,defaultChecked:h(s)?!1:s,isFormControl:E,bubbleInput:y,setBubbleInput:o};return u.jsx(W,{scope:n,...S,children:$(d)?d(S):l})}var O="CheckboxTrigger",A=c.forwardRef(({__scopeCheckbox:t,onKeyDown:n,onClick:r,...l},s)=>{const{control:e,value:b,disabled:p,checked:i,required:m,setControl:k,setChecked:d,hasConsumerStoppedPropagationRef:f,isFormControl:v,bubbleInput:x}=P(O,t),C=D(s,k),y=c.useRef(i);return c.useEffect(()=>{const o=e==null?void 0:e.form;if(o){const a=()=>d(y.current);return o.addEventListener("reset",a),()=>o.removeEventListener("reset",a)}},[e,d]),u.jsx(R.button,{type:"button",role:"checkbox","aria-checked":h(i)?"mixed":i,"aria-required":m,"data-state":U(i),"data-disabled":p?"":void 0,disabled:p,value:b,...l,ref:C,onKeyDown:I(n,o=>{o.key==="Enter"&&o.preventDefault()}),onClick:I(r,o=>{d(a=>h(a)?!0:!a),x&&v&&(f.current=o.isPropagationStopped(),f.current||o.stopPropagation())})})});A.displayName=O;var _=c.forwardRef((t,n)=>{const{__scopeCheckbox:r,name:l,checked:s,defaultChecked:e,required:b,disabled:p,value:i,onCheckedChange:m,form:k,...d}=t;return u.jsx(Z,{__scopeCheckbox:r,checked:s,defaultChecked:e,disabled:p,required:b,onCheckedChange:m,name:l,form:k,value:i,internal_do_not_use_render:({isFormControl:f})=>u.jsxs(u.Fragment,{children:[u.jsx(A,{...d,ref:n,__scopeCheckbox:r}),f&&u.jsx(M,{__scopeCheckbox:r})]})})});_.displayName=g;var B="CheckboxIndicator",L=c.forwardRef((t,n)=>{const{__scopeCheckbox:r,forceMount:l,...s}=t,e=P(B,r);return u.jsx(F,{present:l||h(e.checked)||e.checked===!0,children:u.jsx(R.span,{"data-state":U(e.checked),"data-disabled":e.disabled?"":void 0,...s,ref:n,style:{pointerEvents:"none",...t.style}})})});L.displayName=B;var T="CheckboxBubbleInput",M=c.forwardRef(({__scopeCheckbox:t,...n},r)=>{const{control:l,hasConsumerStoppedPropagationRef:s,checked:e,defaultChecked:b,required:p,disabled:i,name:m,value:k,form:d,bubbleInput:f,setBubbleInput:v}=P(T,t),x=D(r,v),C=Y(e),y=H(l);c.useEffect(()=>{const a=f;if(!a)return;const E=window.HTMLInputElement.prototype,j=Object.getOwnPropertyDescriptor(E,"checked").set,q=!s.current;if(C!==e&&j){const G=new Event("click",{bubbles:q});a.indeterminate=h(e),j.call(a,h(e)?!1:e),a.dispatchEvent(G)}},[f,C,e,s]);const o=c.useRef(h(e)?!1:e);return u.jsx(R.input,{type:"checkbox","aria-hidden":!0,defaultChecked:b??o.current,required:p,disabled:i,name:m,value:k,form:d,...n,tabIndex:-1,ref:x,style:{...n.style,...y,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});M.displayName=T;function $(t){return typeof t=="function"}function h(t){return t==="indeterminate"}function U(t){return h(t)?"indeterminate":t?"checked":"unchecked"}const J=c.forwardRef(({className:t,...n},r)=>N.jsxDEV(_,{ref:r,className:w("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",t),...n,children:N.jsxDEV(L,{className:w("flex items-center justify-center text-current"),children:N.jsxDEV(z,{className:"h-4 w-4"},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/ui/checkbox.tsx",lineNumber:23,columnNumber:7},void 0)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/ui/checkbox.tsx",lineNumber:20,columnNumber:5},void 0)},void 0,!1,{fileName:"/Users/abanoubhelmy/Library/CloudStorage/OneDrive-Personal/EASYGDS/Operation System/trip-glide-control/src/components/ui/checkbox.tsx",lineNumber:12,columnNumber:3},void 0));J.displayName=_.displayName;export{J as C};
