import{o as e}from"./chunk-CFjPhJqf.js";import{a as t,o as n,t as r}from"./compiler-runtime-Cs91PcD2.js";import{l as i,s as a}from"./button-CNAPefQE.js";import{l as o,v as s}from"./dialog-Y0b8qUlN.js";import{d as c,f as l,l as u,o as d,s as f,t as p}from"./dist-CUqyztDT.js";var m=e(t(),1),h=n(),g=`Checkbox`,[_,v]=c(g),[y,b]=_(g);function x(e){let{__scopeCheckbox:t,checked:n,children:r,defaultChecked:i,disabled:a,form:o,name:s,onCheckedChange:c,required:l,value:u=`on`,internal_do_not_use_render:d}=e,[p,_]=f({prop:n,defaultProp:i??!1,onChange:c,caller:g}),[v,b]=m.useState(null),[x,S]=m.useState(null),C=m.useRef(!1),w=v?!!o||!!v.closest(`form`):!0,T={checked:p,disabled:a,setChecked:_,control:v,setControl:b,name:s,form:o,value:u,hasConsumerStoppedPropagationRef:C,required:l,defaultChecked:A(i)?!1:i,isFormControl:w,bubbleInput:x,setBubbleInput:S};return(0,h.jsx)(y,{scope:t,...T,children:k(d)?d(T):r})}var S=`CheckboxTrigger`,C=m.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},i)=>{let{control:o,value:s,disabled:c,checked:d,required:f,setControl:p,setChecked:g,hasConsumerStoppedPropagationRef:_,isFormControl:v,bubbleInput:y}=b(S,e),x=a(i,p),C=m.useRef(d);return m.useEffect(()=>{let e=o?.form;if(e){let t=()=>g(C.current);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[o,g]),(0,h.jsx)(l.button,{type:`button`,role:`checkbox`,"aria-checked":A(d)?`mixed`:d,"aria-required":f,"data-state":j(d),"data-disabled":c?``:void 0,disabled:c,value:s,...r,ref:x,onKeyDown:u(t,e=>{e.key===`Enter`&&e.preventDefault()}),onClick:u(n,e=>{g(e=>A(e)?!0:!e),y&&v&&(_.current=e.isPropagationStopped(),_.current||e.stopPropagation())})})});C.displayName=S;var w=m.forwardRef((e,t)=>{let{__scopeCheckbox:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c,onCheckedChange:l,form:u,...d}=e;return(0,h.jsx)(x,{__scopeCheckbox:n,checked:i,defaultChecked:a,disabled:s,required:o,onCheckedChange:l,name:r,form:u,value:c,internal_do_not_use_render:({isFormControl:e})=>(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(C,{...d,ref:t,__scopeCheckbox:n}),e&&(0,h.jsx)(O,{__scopeCheckbox:n})]})})});w.displayName=g;var T=`CheckboxIndicator`,E=m.forwardRef((e,t)=>{let{__scopeCheckbox:n,forceMount:r,...i}=e,a=b(T,n);return(0,h.jsx)(d,{present:r||A(a.checked)||a.checked===!0,children:(0,h.jsx)(l.span,{"data-state":j(a.checked),"data-disabled":a.disabled?``:void 0,...i,ref:t,style:{pointerEvents:`none`,...e.style}})})});E.displayName=T;var D=`CheckboxBubbleInput`,O=m.forwardRef(({__scopeCheckbox:e,...t},n)=>{let{control:r,hasConsumerStoppedPropagationRef:i,checked:s,defaultChecked:c,required:u,disabled:d,name:f,value:g,form:_,bubbleInput:v,setBubbleInput:y}=b(D,e),x=a(n,y),S=o(s),C=p(r);m.useEffect(()=>{let e=v;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`checked`).set,r=!i.current;if(S!==s&&n){let t=new Event(`click`,{bubbles:r});e.indeterminate=A(s),n.call(e,A(s)?!1:s),e.dispatchEvent(t)}},[v,S,s,i]);let w=m.useRef(A(s)?!1:s);return(0,h.jsx)(l.input,{type:`checkbox`,"aria-hidden":!0,defaultChecked:c??w.current,required:u,disabled:d,name:f,value:g,form:_,...t,tabIndex:-1,ref:x,style:{...t.style,...C,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})});O.displayName=D;function k(e){return typeof e==`function`}function A(e){return e===`indeterminate`}function j(e){return A(e)?`indeterminate`:e?`checked`:`unchecked`}var M=r();function N(e){let t=(0,M.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let a;t[3]===n?a=t[4]:(a=i(`peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input transition-colors outline-none group-has-disabled/field:opacity-50 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary`,n),t[3]=n,t[4]=a);let o;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,h.jsx)(E,{"data-slot":`checkbox-indicator`,className:`grid place-content-center text-current transition-none [&>svg]:size-3.5`,children:(0,h.jsx)(s,{})}),t[5]=o):o=t[5];let c;return t[6]!==r||t[7]!==a?(c=(0,h.jsx)(w,{"data-slot":`checkbox`,className:a,...r,children:o}),t[6]=r,t[7]=a,t[8]=c):c=t[8],c}export{N as t};