import{n as e,r as t}from"./rolldown-runtime-C0FnF6B9.js";import{t as n}from"./react-C21x__mS.js";import{n as r,t as i}from"./circle-check-VtVMsaJJ.js";import{i as a,n as o,r as s,t as c}from"./info-Cirk1RKZ.js";import{n as l,t as u}from"./triangle-alert-B1Q28Bq9.js";import{i as d,n as f,r as p}from"./iframe-DaN-XFub.js";import{a as m,i as h}from"./utils-DUM89eIj.js";import{c as g,h as _,t as v}from"./formatters--mhLir82-v41eaI4a.js";import{n as y,t as b}from"./Select-X_O4M8Hi.js";var x,S;function C(){return(C=e((()=>{d(),x=[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}]],S=p(`circle-minus`,x)})))()}var w,T,E,D,O,k,A,j,M,N,P,F;function I(){return(I=e((()=>{w=`p4nQdZ`,T=`_94tg5v`,E=`HyK7Zs`,D=`Mm4hrB`,O=`clxxBQ`,k=`_5pJ7o-`,A=`VV6hKN`,j=`cuQNP0`,M=`w7nIOT`,N=`ed-Afj`,P=`Lbxloe`,F={button:w,valueContainer:T,swatch:E,optionsPalette:D,optionsDetailed:O,option:k,optionPalette:A,optionDetailed:j,optionMeta:M,optionMetaIcon:N,optionMetaLabel:P}})))()}function L({state:e,className:t}){return(0,W.jsx)(`span`,{className:m(F.swatch,t),"data-empty":e===`none`?``:void 0,style:{"--state-color":g[e]}})}function R(e){return!!(e?.icon||e?.label)}function z(e,t){return typeof t?.label==`string`&&t.label.trim()?t.label:e||`empty`}function B(e){return R(e)?(0,W.jsxs)(`span`,{className:F.optionMeta,children:[e?.icon?(0,W.jsx)(`span`,{className:F.optionMetaIcon,children:e.icon}):null,e?.label?(0,W.jsx)(`span`,{className:F.optionMetaLabel,children:e.label}):null]}):null}function V(e,t){return(0,W.jsxs)(`div`,{className:F.valueContainer,children:[(0,W.jsx)(L,{state:e}),B(t)]})}function H({label:e,description:t,disabled:n,placeholder:r,size:i,value:a,onChange:o,options:s=v,stateMeta:c,className:l,clearable:u}){let d=(0,U.useMemo)(()=>Array.from(new Set(s)),[s]),f=d.some(e=>R(c?.[e])),p={getOptionKey:e=>e||`__empty_state__`,getOptionLabel:e=>c?.[e]?.label??e,getOptionAriaLabel:e=>z(e,c?.[e]),renderValue:e=>V(e,c?.[e]),renderOption:e=>(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(L,{state:e}),f?B(c?.[e]):null]}),buttonClassName:F.button,optionsContentClassName:m(f?F.optionsDetailed:F.optionsPalette),getOptionClassName:()=>m(F.option,f?F.optionDetailed:F.optionPalette)};return(0,W.jsx)(b,{label:e,description:t,disabled:n,placeholder:r,size:i,value:a,onChange:o,options:d,className:l,clearable:u,...p})}var U,W;function G(){return(G=e((()=>{U=n(),_(),h(),y(),I(),W=f(),H.__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`]}})))()}var ee=t({Controlled:()=>Y,PaletteOnly:()=>Z,WithMeta:()=>X,__namedExportsOrder:()=>Q,default:()=>J}),K,q,J,Y,X,Z,Q;function $(){return($=e((()=>{K=n(),l(),r(),o(),C(),a(),G(),q=f(),J={title:`Shared/UI/StateSelect`,component:H,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`}}},Y={render:e=>{let[t,n]=(0,K.useState)(`information`);return(0,q.jsx)(H,{...e,value:t,onChange:n})}},X={render:e=>{let[t,n]=(0,K.useState)(`warning`);return(0,q.jsx)(H,{...e,value:t,onChange:n,stateMeta:{none:{label:`Без статуса`,icon:(0,q.jsx)(S,{})},information:{label:`Инфо`,icon:(0,q.jsx)(c,{})},success:{label:`Успех`,icon:(0,q.jsx)(i,{})},warning:{label:`Предупреждение`,icon:(0,q.jsx)(u,{})},error:{label:`Ошибка`,icon:(0,q.jsx)(s,{})}}})},args:{value:`warning`}},Z={render:e=>{let[t,n]=(0,K.useState)(`none`);return(0,q.jsx)(H,{...e,value:t,onChange:n,options:[`none`,`success`,`error`]})},args:{options:[`none`,`success`,`error`],value:`none`}},Y.parameters={...Y.parameters,docs:{...Y.parameters?.docs,source:{originalSource:`{
  render: args => {
    const [value, setValue] = useState<State | undefined>("information");
    return <StateSelect {...args} value={value} onChange={setValue} />;
  }
}`,...Y.parameters?.docs?.source}}},X.parameters={...X.parameters,docs:{...X.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"
  }
}`,...X.parameters?.docs?.source}}},Z.parameters={...Z.parameters,docs:{...Z.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"
  }
}`,...Z.parameters?.docs?.source}}},Q=[`Controlled`,`WithMeta`,`PaletteOnly`]})))()}export{$ as a,X as i,Z as n,ee as r,Y as t};