import{a as e,u as r,j as a,P as o,f as s,d as n,y as d,z as t,J as i,A as c,b as l,K as u,L as p}from"./ui-vendor-CJlQk0Tq.js";import{r as f}from"./react-vendor-f6QdChhz.js";import{K as m,aJ as b}from"./index-CUIxi1yy.js";var v="Radio",[h,y]=e(v),[k,R]=h(v),j=f.forwardRef((e,n)=>{const{__scopeRadio:d,name:t,checked:i=!1,required:c,disabled:l,value:u="on",onCheck:p,form:m,...b}=e,[v,h]=f.useState(null),y=r(n,e=>h(e)),R=f.useRef(!1),j=!v||(m||!!v.closest("form"));return a.jsxs(k,{scope:d,checked:i,disabled:l,children:[a.jsx(o.button,{type:"button",role:"radio","aria-checked":i,"data-state":N(i),"data-disabled":l?"":void 0,disabled:l,value:u,...b,ref:y,onClick:s(e.onClick,e=>{i||null==p||p(),j&&(R.current=e.isPropagationStopped(),R.current||e.stopPropagation())})}),j&&a.jsx(g,{control:v,bubbles:!R.current,name:t,value:u,checked:i,required:c,disabled:l,form:m,style:{transform:"translateX(-100%)"}})]})});j.displayName=v;var w="RadioIndicator",x=f.forwardRef((e,r)=>{const{__scopeRadio:s,forceMount:d,...t}=e,i=R(w,s);return a.jsx(n,{present:d||i.checked,children:a.jsx(o.span,{"data-state":N(i.checked),"data-disabled":i.disabled?"":void 0,...t,ref:r})})});x.displayName=w;var g=e=>{const{control:r,checked:o,bubbles:s=!0,...n}=e,i=f.useRef(null),c=d(o),l=t(r);return f.useEffect(()=>{const e=i.current,r=window.HTMLInputElement.prototype,a=Object.getOwnPropertyDescriptor(r,"checked").set;if(c!==o&&a){const r=new Event("click",{bubbles:s});a.call(e,o),e.dispatchEvent(r)}},[c,o,s]),a.jsx("input",{type:"radio","aria-hidden":!0,defaultChecked:o,...n,tabIndex:-1,ref:i,style:{...e.style,...l,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function N(e){return e?"checked":"unchecked"}var C=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],E="RadioGroup",[_,q]=e(E,[i,y]),L=i(),G=y(),[A,I]=_(E),P=f.forwardRef((e,r)=>{const{__scopeRadioGroup:s,name:n,defaultValue:d,value:t,required:i=!1,disabled:p=!1,orientation:f,dir:m,loop:b=!0,onValueChange:v,...h}=e,y=L(s),k=c(m),[R,j]=l({prop:t,defaultProp:d,onChange:v});return a.jsx(A,{scope:s,name:n,required:i,disabled:p,value:R,onValueChange:j,children:a.jsx(u,{asChild:!0,...y,orientation:f,dir:k,loop:b,children:a.jsx(o.div,{role:"radiogroup","aria-required":i,"aria-orientation":f,"data-disabled":p?"":void 0,dir:k,...h,ref:r})})})});P.displayName=E;var D="RadioGroupItem",V=f.forwardRef((e,o)=>{const{__scopeRadioGroup:n,disabled:d,...t}=e,i=I(D,n),c=i.disabled||d,l=L(n),u=G(n),m=f.useRef(null),b=r(o,m),v=i.value===t.value,h=f.useRef(!1);return f.useEffect(()=>{const e=e=>{C.includes(e.key)&&(h.current=!0)},r=()=>h.current=!1;return document.addEventListener("keydown",e),document.addEventListener("keyup",r),()=>{document.removeEventListener("keydown",e),document.removeEventListener("keyup",r)}},[]),a.jsx(p,{asChild:!0,...l,focusable:!c,active:v,children:a.jsx(j,{disabled:c,required:i.required,checked:v,...u,...t,name:i.name,ref:b,onCheck:()=>i.onValueChange(t.value),onKeyDown:s(e=>{"Enter"===e.key&&e.preventDefault()}),onFocus:s(t.onFocus,()=>{var e;h.current&&(null==(e=m.current)||e.click())})})})});V.displayName=D;var K=f.forwardRef((e,r)=>{const{__scopeRadioGroup:o,...s}=e,n=G(o);return a.jsx(x,{...n,...s,ref:r})});K.displayName="RadioGroupIndicator";var F=P,J=V,M=K;const O=f.forwardRef(({className:e,...r},o)=>a.jsx(F,{className:m("grid gap-2",e),...r,ref:o}));O.displayName=F.displayName;const S=f.forwardRef(({className:e,...r},o)=>a.jsx(J,{ref:o,className:m("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),...r,children:a.jsx(M,{className:"flex items-center justify-center",children:a.jsx(b,{className:"h-2.5 w-2.5 fill-current text-current"})})}));S.displayName=J.displayName;export{O as R,S as a};