import{a as e,c as t,i as n}from"./preload-helper-B45gAKPr.js";import{at as r,d as i,lt as a,n as o,pn as s,st as c,t as l,z as u}from"./iframe-CMLjY6eW.js";import{a as d,i as f}from"./utils-PcgESe3m.js";import{l as p,n as m,t as h}from"./formatters-CvqCBcOp.js";import{t as g}from"./Select-DMXjzkDO.js";import{t as _}from"./select-DhlrNWXm.js";var v,y,b,x,S,C,w,T,E,D,O,k,A=n((()=>{v=`p4nQdZ`,y=`_94tg5v`,b=`HyK7Zs`,x=`Mm4hrB`,S=`clxxBQ`,C=`_5pJ7o-`,w=`VV6hKN`,T=`cuQNP0`,E=`w7nIOT`,D=`ed-Afj`,O=`Lbxloe`,k={button:v,valueContainer:y,swatch:b,optionsPalette:x,optionsDetailed:S,option:C,optionPalette:w,optionDetailed:T,optionMeta:E,optionMetaIcon:D,optionMetaLabel:O}}));function j({state:e,className:t}){return(0,R.jsx)(`span`,{className:d(k.swatch,t),"data-empty":e===`none`?``:void 0,style:{"--state-color":p[e]}})}function M(e){return!!(e?.icon||e?.label)}function N(e,t){return typeof t?.label==`string`&&t.label.trim()?t.label:e||`empty`}function P(e){return M(e)?(0,R.jsxs)(`span`,{className:k.optionMeta,children:[e?.icon?(0,R.jsx)(`span`,{className:k.optionMetaIcon,children:e.icon}):null,e?.label?(0,R.jsx)(`span`,{className:k.optionMetaLabel,children:e.label}):null]}):null}function F(e,t){return(0,R.jsxs)(`div`,{className:k.valueContainer,children:[(0,R.jsx)(j,{state:e}),P(t)]})}function I({label:e,description:t,disabled:n,placeholder:r,size:i,value:a,onChange:o,options:s=m,stateMeta:c,className:l,clearable:u}){let f=(0,L.useMemo)(()=>Array.from(new Set(s)),[s]),p=f.some(e=>M(c?.[e]));return(0,R.jsx)(g,{label:e,description:t,disabled:n,placeholder:r,size:i,value:a,onChange:o,options:f,className:l,clearable:u,getOptionKey:e=>e||`__empty_state__`,getOptionLabel:e=>c?.[e]?.label??e,getOptionAriaLabel:e=>N(e,c?.[e]),renderValue:e=>F(e,c?.[e]),renderOption:e=>(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(j,{state:e}),p?P(c?.[e]):null]}),buttonClassName:k.button,optionsContentClassName:d(p?k.optionsDetailed:k.optionsPalette),getOptionClassName:()=>d(k.option,p?k.optionDetailed:k.optionPalette)})}var L,R,z=n((()=>{L=t(s(),1),h(),f(),_(),A(),R=l(),I.__docgenInfo={description:`Специализированный селект для выбора цветового или статусного состояния. Используется там, где значению соответствует визуальный swatch.`,methods:[],displayName:`StateSelect`,props:{placeholder:{required:!1,tsType:{name:`string`},description:``},options:{required:!1,tsType:{name:`unknown`},description:``,defaultValue:{value:`DEFAULT_VALUE_STATES`,computed:!0}},stateMeta:{required:!1,tsType:{name:`Partial`,elements:[{name:`Record`,elements:[{name:`State`},{name:`signature`,type:`object`,raw:`{
	label?: ReactNode;
	icon?: ReactNode;
}`,signature:{properties:[{key:`label`,value:{name:`ReactNode`,required:!1}},{key:`icon`,value:{name:`ReactNode`,required:!1}}]}}],raw:`Record<State, StateMeta>`}],raw:`Partial<Record<State, StateMeta>>`},description:``},className:{required:!1,tsType:{name:`string`},description:``},clearable:{required:!1,tsType:{name:`boolean`},description:``}},composes:[`Omit`]}})),B=e({Controlled:()=>W,PaletteOnly:()=>K,WithMeta:()=>G,__namedExportsOrder:()=>q,default:()=>U}),V,H,U,W,G,K,q,J=n((()=>{V=t(s(),1),o(),z(),H=l(),U={title:`Shared/UI/StateSelect`,component:I,args:{label:`Состояние`,description:`Выберите визуальный статус.`,placeholder:`Выберите значение`,value:`information`,onChange:()=>{},disabled:!1,size:`md`},parameters:{atomicCanvas:!0,layout:`padded`},argTypes:{label:{description:`Заголовок поля выбора состояния.`,control:`text`},description:{description:`Описание под заголовком.`,control:`text`},placeholder:{description:`Текст, когда значение не выбрано.`,control:`text`},value:{description:`Текущее состояние.`,control:`select`,options:[``,`none`,`information`,`success`,`warning`,`error`]},onChange:{description:`Вызывается при выборе состояния.`,control:!1},options:{description:`Кастомный набор доступных состояний.`,control:!1},stateMeta:{description:`Кастомные иконки и подписи для значений.`,control:!1},disabled:{description:`Блокирует взаимодействие с полем.`,control:`boolean`},size:{description:`Размер поля и подписей.`,control:`select`,options:[`xs`,`sm`,`md`,`lg`,`xl`]},className:{description:`Дополнительный CSS-класс.`,control:`text`}}},W={render:e=>{let[t,n]=(0,V.useState)(`information`);return(0,H.jsx)(I,{...e,value:t,onChange:n})}},G={render:e=>{let[t,n]=(0,V.useState)(`warning`);return(0,H.jsx)(I,{...e,value:t,onChange:n,stateMeta:{none:{label:`Без статуса`,icon:(0,H.jsx)(c,{})},information:{label:`Инфо`,icon:(0,H.jsx)(u,{})},success:{label:`Успех`,icon:(0,H.jsx)(a,{})},warning:{label:`Предупреждение`,icon:(0,H.jsx)(i,{})},error:{label:`Ошибка`,icon:(0,H.jsx)(r,{})}}})},args:{value:`warning`}},K={render:e=>{let[t,n]=(0,V.useState)(`none`);return(0,H.jsx)(I,{...e,value:t,onChange:n,options:[`none`,`success`,`error`]})},args:{options:[`none`,`success`,`error`],value:`none`}},W.parameters={...W.parameters,docs:{...W.parameters?.docs,source:{originalSource:`{
  render: args => {
    const [value, setValue] = useState<State | undefined>("information");
    return <StateSelect {...args} value={value} onChange={setValue} />;
  }
}`,...W.parameters?.docs?.source}}},G.parameters={...G.parameters,docs:{...G.parameters?.docs,source:{originalSource:`{
  render: args => {
    const [value, setValue] = useState<State | undefined>("warning");
    return <StateSelect {...args} value={value} onChange={setValue} stateMeta={{
      none: {
        label: "Без статуса",
        icon: <MinusCircleIcon />
      },
      information: {
        label: "Инфо",
        icon: <InfoIcon />
      },
      success: {
        label: "Успех",
        icon: <CheckCircle2Icon />
      },
      warning: {
        label: "Предупреждение",
        icon: <AlertTriangleIcon />
      },
      error: {
        label: "Ошибка",
        icon: <XCircleIcon />
      }
    }} />;
  },
  args: {
    value: "warning"
  }
}`,...G.parameters?.docs?.source}}},K.parameters={...K.parameters,docs:{...K.parameters?.docs,source:{originalSource:`{
  render: args => {
    const [value, setValue] = useState<State | undefined>("none");
    return <StateSelect {...args} value={value} onChange={setValue} options={["none", "success", "error"]} />;
  },
  args: {
    options: ["none", "success", "error"],
    value: "none"
  }
}`,...K.parameters?.docs?.source}}},q=[`Controlled`,`WithMeta`,`PaletteOnly`]}));J();export{W as Controlled,K as PaletteOnly,G as WithMeta,q as __namedExportsOrder,U as default,J as n,B as t};