import{c as e,i as t}from"./preload-helper-B45gAKPr.js";import{pn as n,t as r}from"./iframe-CMLjY6eW.js";import{a as i,i as a,n as o,o as s}from"./utils-PcgESe3m.js";import{n as c,t as l}from"./ui.module-wFHXkJzp.js";var u,d,f,p,m,h,g,_=t((()=>{u=`nINbA6`,d=`GL-UWx`,f=`_6PeF-i`,p=`_5wP4aR`,m=`S3MnZI`,h=`KHJ0ja`,g={radioGroup:u,noWrap:d,horizontal:f,vertical:p,radioItem:m,checked:h}}));function v({value:e,onChange:t,label:n,description:r,disabled:a,className:o,noWrap:s,orientation:l=`horizontal`,"aria-label":u,children:d}){let f=(0,b.useId)(),p=n?`${f}-label`:void 0,m=r?`${f}-description`:void 0,[h,_]=(0,b.useState)([]),v=(0,b.useCallback)(e=>t?.(e),[t]),y=(0,b.useCallback)(e=>(_(t=>t.includes(e)?t:[...t,e]),()=>{_(t=>t.filter(t=>t!==e))}),[]),C=(0,b.useMemo)(()=>({value:e,onChange:v,disabled:a,orientation:l,groupId:f,labelId:p,descriptionId:m,firstOptionId:h[0],registerOption:y}),[m,a,f,v,p,l,y,h,e]);return(0,x.jsxs)(`div`,{className:i(c.uiElement,a&&c.disabled,o),children:[n&&(0,x.jsx)(`div`,{id:p,className:c.uiLabel,children:n}),r&&(0,x.jsx)(`div`,{id:m,className:c.uiDescription,children:r}),(0,x.jsx)(S.Provider,{value:C,children:(0,x.jsx)(`div`,{role:`radiogroup`,"aria-labelledby":p,"aria-label":p?void 0:u,"aria-describedby":m,"aria-disabled":a||void 0,"data-disabled":a||void 0,className:i(c.uiInputControl,g.radioGroup,s&&g.noWrap,g[l]),children:d})})]})}function y({value:e,label:t,description:n,className:r}){let a=(0,b.useContext)(S),c=(0,b.useId)(),l=a?.registerOption;if((0,b.useLayoutEffect)(()=>{if(l)return l(c)},[l,c]),!a)return(0,x.jsxs)(`div`,{className:i(g.radioItem,r),children:[(0,x.jsx)(`p`,{className:`textNoWrap`,children:t}),n&&(0,x.jsx)(`div`,{className:`fontSizeSm content2`,children:n})]});let u=Object.is(a.value,e),d=a.disabled===!0,f=a.value===void 0&&a.firstOptionId===c,p=()=>{d||u||a.onChange?.(e)};return(0,x.jsxs)(`button`,{id:`${a.groupId}-option-${c}`,type:`button`,role:`radio`,"aria-checked":u,disabled:d,tabIndex:u||f?0:-1,className:i(g.radioItem,u&&g.checked,r),"data-ui":`radio-option`,"data-action":`select-radio-option`,onClick:p,onKeyDown:e=>{if(d||o(e,p))return;let t=e.currentTarget,n=t.closest(`[role="radiogroup"]`),r=Array.from(n?.querySelectorAll(`[role="radio"]:not([disabled])`)??[]);if(!r.length)return;let i=r.indexOf(t);if(i===-1)return;let c=s({currentIndex:i,itemCount:r.length,key:e.key,orientation:a.orientation});c!==null&&(e.preventDefault(),r[c]?.focus(),r[c]?.click())},children:[(0,x.jsx)(`span`,{className:`textNoWrap`,children:t}),n&&(0,x.jsx)(`span`,{className:`fontSizeSm`,children:n})]})}var b,x,S,C=t((()=>{b=e(n(),1),a(),l(),_(),x=r(),S=(0,b.createContext)(null),v.Option=y,v.__docgenInfo={description:`Группа радиокнопок с общим состоянием выбранного значения. Обеспечивает единый API выбора и контекст для дочерних опций.`,methods:[{name:`Option`,docblock:null,modifiers:[`static`],params:[{name:`{ value, label, description, className }: OptionProps<T>`,optional:!1,type:{name:`OptionProps`,elements:[{name:`T`}],raw:`OptionProps<T>`,alias:`OptionProps`}}],returns:null}],displayName:`RadioGroup`,props:{value:{required:!1,tsType:{name:`T`},description:``},onChange:{required:!1,tsType:{name:`signature`,type:`function`,raw:`(value: T) => void`,signature:{arguments:[{type:{name:`T`},name:`value`}],return:{name:`void`}}},description:``},label:{required:!1,tsType:{name:`string`},description:``},description:{required:!1,tsType:{name:`string`},description:``},disabled:{required:!1,tsType:{name:`boolean`},description:``},className:{required:!1,tsType:{name:`string`},description:``},noWrap:{required:!1,tsType:{name:`literal`,value:`true`},description:``},orientation:{required:!1,tsType:{name:`union`,raw:`"vertical" | "horizontal"`,elements:[{name:`literal`,value:`"vertical"`},{name:`literal`,value:`"horizontal"`}]},description:``,defaultValue:{value:`"horizontal"`,computed:!1}},"aria-label":{required:!1,tsType:{name:`string`},description:``},children:{required:!0,tsType:{name:`ReactReactNode`,raw:`React.ReactNode`},description:``}}},y.__docgenInfo={description:"Опция внутри `RadioGroup`, представляющая одно выбираемое значение. Отрисовывает подпись, описание и состояние выбора.",methods:[],displayName:`Option`,props:{value:{required:!0,tsType:{name:`T`},description:``},label:{required:!0,tsType:{name:`ReactNode`},description:``},description:{required:!1,tsType:{name:`ReactNode`},description:``},className:{required:!1,tsType:{name:`string`},description:``}}}}));export{C as n,v as t};