import{j as n,a as y}from"./jsx-runtime-5BUNAZ9W.js";import{c as w}from"./cn-466VSCev.js";import{$ as j,_ as N}from"./index-VfKohXEB.js";import{r as t}from"./index-4g5l5LRQ.js";import{$ as K}from"./index-dNGI4_9C.js";import{$ as L}from"./index-tktZLsKA.js";import{$ as P}from"./index-pbeB-vsG.js";import{$ as H}from"./index-nyvS1vus.js";import{$ as X}from"./index-FkhxRFYx.js";import{$ as Y}from"./index-bKbe1a_Q.js";import{$ as z}from"./index-rFlDZKmw.js";import{C as V}from"./check-MqRccGre.js";import"./extends-dGVwEr9R.js";import"./index-zaNpaTzt.js";import"./_commonjsHelpers-4gQjN7DL.js";import"./index-TrPPXL0M.js";import"./index-gxNcLOY3.js";import"./createLucideIcon-SOGh5HrW.js";const q="Checkbox",[G,ge]=L(q),[J,Q]=G(q),U=t.forwardRef((e,c)=>{const{__scopeCheckbox:r,name:i,checked:b,defaultChecked:s,required:u,disabled:l,value:m="on",onCheckedChange:k,..._}=e,[o,g]=t.useState(null),O=K(c,a=>g(a)),v=t.useRef(!1),E=o?!!o.closest("form"):!0,[p=!1,C]=H({prop:b,defaultProp:s,onChange:k}),T=t.useRef(p);return t.useEffect(()=>{const a=o==null?void 0:o.form;if(a){const $=()=>C(T.current);return a.addEventListener("reset",$),()=>a.removeEventListener("reset",$)}},[o,C]),t.createElement(J,{scope:r,state:p,disabled:l},t.createElement(j.button,N({type:"button",role:"checkbox","aria-checked":d(p)?"mixed":p,"aria-required":u,"data-state":F(p),"data-disabled":l?"":void 0,disabled:l,value:m},_,{ref:O,onKeyDown:P(e.onKeyDown,a=>{a.key==="Enter"&&a.preventDefault()}),onClick:P(e.onClick,a=>{C($=>d($)?!0:!$),E&&(v.current=a.isPropagationStopped(),v.current||a.stopPropagation())})})),E&&t.createElement(ee,{control:o,bubbles:!v.current,name:i,value:m,checked:p,required:u,disabled:l,style:{transform:"translateX(-100%)"}}))}),W="CheckboxIndicator",Z=t.forwardRef((e,c)=>{const{__scopeCheckbox:r,forceMount:i,...b}=e,s=Q(W,r);return t.createElement(z,{present:i||d(s.state)||s.state===!0},t.createElement(j.span,N({"data-state":F(s.state),"data-disabled":s.disabled?"":void 0},b,{ref:c,style:{pointerEvents:"none",...e.style}})))}),ee=e=>{const{control:c,checked:r,bubbles:i=!0,...b}=e,s=t.useRef(null),u=X(r),l=Y(c);return t.useEffect(()=>{const m=s.current,k=window.HTMLInputElement.prototype,o=Object.getOwnPropertyDescriptor(k,"checked").set;if(u!==r&&o){const g=new Event("click",{bubbles:i});m.indeterminate=d(r),o.call(m,d(r)?!1:r),m.dispatchEvent(g)}},[u,r,i]),t.createElement("input",N({type:"checkbox","aria-hidden":!0,defaultChecked:d(r)?!1:r},b,{tabIndex:-1,ref:s,style:{...e.style,...l,position:"absolute",pointerEvents:"none",opacity:0,margin:0}}))};function d(e){return e==="indeterminate"}function F(e){return d(e)?"indeterminate":e?"checked":"unchecked"}const M=U,te=Z,f=t.forwardRef(({className:e,...c},r)=>n(M,{ref:r,className:w("peer h-4 w-4 shrink-0 rounded-sm border border-border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-info focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-background-primary data-[state=checked]:text-text-weakest",e),...c,children:n(te,{className:w("flex items-center justify-center text-current"),children:n(V,{className:"h-4 w-4"})})}));f.displayName=M.displayName;try{f.displayName="Checkbox",f.__docgenInfo={description:"",displayName:"Checkbox",props:{asChild:{defaultValue:null,description:"",name:"asChild",required:!1,type:{name:"boolean"}}}}}catch{}const ve={title:"ui/Checkbox",component:f,tags:["autodocs"],argTypes:{}},x={render:e=>y("div",{className:"items-top flex space-x-2",children:[n(f,{...e,id:"terms1"}),y("div",{className:"grid gap-1.5 leading-none",children:[n("label",{htmlFor:"terms1",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:"Accept terms and conditions"}),n("p",{className:"text-sm text-text-primary",children:"You agree to our Terms of Service and Privacy Policy."})]})]}),args:{}},h={render:e=>y("div",{className:"flex items-center space-x-2",children:[n(f,{...e,id:"terms2"}),n("label",{htmlFor:"terms2",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:"Accept terms and conditions"})]}),args:{disabled:!0}};var R,S,I;x.parameters={...x.parameters,docs:{...(R=x.parameters)==null?void 0:R.docs,source:{originalSource:`{
  render: args => <div className="items-top flex space-x-2">
      <Checkbox {...args} id="terms1" />
      <div className="grid gap-1.5 leading-none">
        <label htmlFor="terms1" className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70">
          Accept terms and conditions
        </label>
        <p className="text-sm text-text-primary">
          You agree to our Terms of Service and Privacy Policy.
        </p>
      </div>
    </div>,
  args: {}
}`,...(I=(S=x.parameters)==null?void 0:S.docs)==null?void 0:I.source}}};var A,D,B;h.parameters={...h.parameters,docs:{...(A=h.parameters)==null?void 0:A.docs,source:{originalSource:`{
  render: args => <div className="flex items-center space-x-2">
      <Checkbox {...args} id="terms2" />
      <label htmlFor="terms2" className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70">
        Accept terms and conditions
      </label>
    </div>,
  args: {
    disabled: true
  }
}`,...(B=(D=h.parameters)==null?void 0:D.docs)==null?void 0:B.source}}};const Ce=["Base","Disabled"];export{x as Base,h as Disabled,Ce as __namedExportsOrder,ve as default};
