import{a as e,c as t,i as n}from"./preload-helper-B45gAKPr.js";import{Lt as r,lt as i,n as a,pn as o,t as s}from"./iframe-GmIo3IOR.js";import{a as c,i as l}from"./utils-B73_kE2n.js";import{n as u,t as d}from"./ui.module-wFHXkJzp.js";var f,p,m,h,g,_=n((()=>{f=`Or5LYA`,p=`w0AMfA`,m=`P1x4lq`,h=`-ZVOZo`,g={switchWrapper:f,switch:`qge3io`,iconWrapper:p,auto:m,checked:h}}));function v(e){let{label:t,description:n,disabled:a,checkedIcon:o=(0,b.jsx)(i,{}),uncheckedIcon:s=(0,b.jsx)(r,{}),className:l,type:d,id:f,size:p,placeholder:m,onChange:h,value:_,triState:v,...x}=e,S=(0,y.useId)(),C=f??S,w=n?`${C}-description`:void 0,T=t?`${C}-label`:void 0,E=()=>{if(!e.triState){e.onChange(!e.value);return}if(e.value===void 0){e.onChange(!0);return}if(e.value===!0){e.onChange(!1);return}e.value===!1&&e.onChange(void 0)},D=typeof e.value==`boolean`?e.value:!1,O=e.triState&&typeof e.value!=`boolean`,k=x[`aria-label`]??(t?void 0:`Переключатель`);return(0,b.jsxs)(`div`,{className:c(u.uiElement,a&&u.disabled),"aria-disabled":a||void 0,children:[t&&(0,b.jsxs)(`div`,{id:T,className:u.uiLabel,children:[t,`:`]}),n&&(0,b.jsx)(`p`,{id:w,className:u.uiDescription,children:n}),(0,b.jsx)(`button`,{...x,id:C,type:d??`button`,role:`switch`,disabled:a,"aria-checked":D,"aria-describedby":w,"aria-labelledby":T,"aria-label":k,"aria-disabled":a,"data-ui":`switch`,"data-action":`toggle-switch`,onClick:E,className:c(u.uiInputControl,g.switchWrapper,l),children:(0,b.jsx)(`div`,{className:g.switch,"data-disabled":a||void 0,children:O?(0,b.jsx)(`div`,{className:c(g.iconWrapper,g.auto,g.checked),children:`Auto`}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`div`,{className:c(g.iconWrapper,!e.value&&g.checked),children:s}),(0,b.jsx)(`div`,{className:c(g.iconWrapper,e.value&&g.checked),children:o})]})})})]})}var y,b,x=n((()=>{y=t(o(),1),l(),a(),d(),_(),b=s(),v.__docgenInfo={description:`Переключатель boolean-состояния в виде слайдера. Подходит для быстрых настроек и включения/отключения опций.`,methods:[],displayName:`Switch`}})),S=e({BiState:()=>E,Disabled:()=>O,TriState:()=>D,__namedExportsOrder:()=>k,default:()=>T}),C,w,T,E,D,O,k,A=n((()=>{C=t(o(),1),x(),w=s(),T={title:`Shared/UI/Switch`,component:v,args:{label:`Режим обработки`,description:`Переключение состояния`,value:!1,onChange:()=>{},triState:!1,disabled:!1},parameters:{atomicCanvas:!0,layout:`padded`},argTypes:{label:{description:`Заголовок переключателя.`,control:`text`},description:{description:`Описание под заголовком.`,control:`text`},value:{description:"Текущее значение (`boolean` или `undefined` в tri-state).",control:!1},onChange:{description:`Вызывается при изменении состояния.`,control:!1},triState:{description:"Включает трехсостоянный режим (`undefined → true → false`).",control:`boolean`},checkedIcon:{description:"Кастомная иконка для состояния `true`.",control:!1},uncheckedIcon:{description:"Кастомная иконка для состояния `false`.",control:!1},disabled:{description:`Блокирует переключение.`,control:`boolean`}}},E={render:e=>{let[t,n]=(0,C.useState)(!1);return(0,w.jsx)(v,{...e,value:t,onChange:n,triState:!1})}},D={render:e=>{let[t,n]=(0,C.useState)(void 0);return(0,w.jsxs)(`div`,{style:{display:`grid`,gap:8},children:[(0,w.jsx)(v,{...e,value:t,onChange:n,triState:!0}),(0,w.jsxs)(`div`,{children:[`Текущее значение: `,String(t)]})]})},args:{triState:!0,value:void 0}},O={args:{disabled:!0,value:!0}},E.parameters={...E.parameters,docs:{...E.parameters?.docs,source:{originalSource:`{
  render: args => {
    const [value, setValue] = useState(false);
    return <Switch {...args} value={value} onChange={setValue} triState={false} />;
  }
}`,...E.parameters?.docs?.source}}},D.parameters={...D.parameters,docs:{...D.parameters?.docs,source:{originalSource:`{
  render: args => {
    const [value, setValue] = useState<boolean | undefined>(undefined);
    return <div style={{
      display: "grid",
      gap: 8
    }}>
                <Switch {...args} value={value} onChange={setValue} triState />
                <div>Текущее значение: {String(value)}</div>
            </div>;
  },
  args: {
    triState: true,
    value: undefined
  }
}`,...D.parameters?.docs?.source}}},O.parameters={...O.parameters,docs:{...O.parameters?.docs,source:{originalSource:`{
  args: {
    disabled: true,
    value: true
  }
}`,...O.parameters?.docs?.source}}},k=[`BiState`,`TriState`,`Disabled`]}));A();export{E as BiState,O as Disabled,D as TriState,k as __namedExportsOrder,T as default,A as n,S as t};