import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{$P as t,TO as n}from"./lucide-C4oWPzu4.js";import{p as r,t as i}from"./utils-Bs-0X7qI.js";import{r as a}from"./bundle-mjs-C4g7ASB5.js";import{c as o,n as s}from"./dist-CImBN8k_.js";import{i as c,n as l}from"./dist-dVVC74St.js";import{t as u}from"./dist-yoGb4lVc.js";import{t as d}from"./dist-DwDcRD8a.js";import{t as f}from"./dist-DGxLVQCb.js";import{t as p}from"./dist-DSFWiYLH.js";var m=e(t(),1),h=a(),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:d=`on`,internal_do_not_use_render:f}=e,[p,_]=u({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:d,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(f)?f(T):r})}var S=`CheckboxTrigger`,C=m.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},i)=>{let{control:a,value:c,disabled:u,checked:d,required:f,setControl:p,setChecked:g,hasConsumerStoppedPropagationRef:_,isFormControl:v,bubbleInput:y}=b(S,e),x=o(i,p),C=m.useRef(d);return m.useEffect(()=>{let e=a?.form;if(e){let t=()=>g(C.current);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[a,g]),(0,h.jsx)(s.button,{type:`button`,role:`checkbox`,"aria-checked":A(d)?`mixed`:d,"aria-required":f,"data-state":j(d),"data-disabled":u?``:void 0,disabled:u,value:c,...r,ref:x,onKeyDown:l(t,e=>{e.key===`Enter`&&e.preventDefault()}),onClick:l(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)(s.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:a,defaultChecked:c,required:l,disabled:u,name:d,value:g,form:_,bubbleInput:v,setBubbleInput:y}=b(D,e),x=o(n,y),S=f(a),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!==a&&n){let t=new Event(`click`,{bubbles:r});e.indeterminate=A(a),n.call(e,A(a)?!1:a),e.dispatchEvent(t)}},[v,S,a,i]);let w=m.useRef(A(a)?!1:a);return(0,h.jsx)(s.input,{type:`checkbox`,"aria-hidden":!0,defaultChecked:c??w.current,required:l,disabled:u,name:d,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),r,a;t[0]===e?(r=t[1],a=t[2]):({className:r,...a}=e,t[0]=e,t[1]=r,t[2]=a);let o;t[3]===r?o=t[4]:(o=i(`border-input dark:bg-input/30 data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary data-checked:border-primary aria-invalid:aria-checked:border-primary aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border shadow-xs transition-shadow outline-none group-has-disabled/field:opacity-50 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-[3px]`,r),t[3]=r,t[4]=o);let s;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(s=(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)(n,{})}),t[5]=s):s=t[5];let c;return t[6]!==a||t[7]!==o?(c=(0,h.jsx)(w,{"data-slot":`checkbox`,className:o,...a,children:s}),t[6]=a,t[7]=o,t[8]=c):c=t[8],c}export{N as t};