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}from"./iframe-DaN-XFub.js";import{n as i,t as a}from"./Text-BPlJUr3R.js";import{n as o,t as s}from"./FlexContainer-LmZIdhq2.js";import{r as c,t as l}from"./DateInput-D8_Oleoy.js";import{a as u,c as d,i as f,n as p,o as m,r as h,s as g,t as _}from"./DateRangePresetSelect-Bfx-d5qg.js";function v(e){return e??`__empty__`}function y({value:e,onChange:t,presetId:n,onPresetIdChange:r,referenceDate:i,presetIds:a,presetOptions:o,presetLabel:c,presetDescription:f,presetPlaceholder:p=`Выберите пресет диапазона`,presetDisabled:y,...S}){let[C]=(0,b.useState)(()=>new Date),w=i??C,T=(0,b.useMemo)(()=>o??g(u(a,h)),[a,o]),E=e??null,D=(0,b.useMemo)(()=>m(E,w,T),[E,T,w]),O=n??D??void 0,k=(0,b.useRef)(``),A=(0,b.useCallback)(e=>{if(!r)return;let t=v(e);t!==k.current&&(k.current=t,r(e))},[r]),j=e=>{let n=d(e,w,T);if(!n){A(null);return}A(n.id),t(n.range)},M=e=>{t(e),A(m(e,w,T))};return(0,x.jsxs)(s,{gap:`sm`,align:`end`,children:[(0,x.jsx)(_,{size:`md`,label:c,description:f,placeholder:p,disabled:y??S.disabled,value:O,onChange:j,options:T,referenceDate:w}),(0,x.jsx)(l,{...S,size:`md`,value:E,onChange:M})]})}var b,x;function S(){return(S=e((()=>{b=n(),c(),p(),f(),o(),x=r(),y.__docgenInfo={description:`Составной компонент выбора диапазона дат через пресет или ручной ввод.`,methods:[],displayName:`PresetRangeDateInput`,props:{presetId:{required:!1,tsType:{name:`union`,raw:`DateRangePresetOption["id"] | null`,elements:[{name:`DateRangePresetOption["id"]`,raw:`DateRangePresetOption["id"]`},{name:`null`}]},description:``},onPresetIdChange:{required:!1,tsType:{name:`signature`,type:`function`,raw:`(presetId: DateRangePresetOption["id"] | null) => void`,signature:{arguments:[{type:{name:`union`,raw:`DateRangePresetOption["id"] | null`,elements:[{name:`DateRangePresetOption["id"]`,raw:`DateRangePresetOption["id"]`},{name:`null`}]},name:`presetId`}],return:{name:`void`}}},description:``},referenceDate:{required:!1,tsType:{name:`Date`},description:``},presetIds:{required:!1,tsType:{name:`unknown`},description:``},presetOptions:{required:!1,tsType:{name:`unknown`},description:``},presetLabel:{required:!1,tsType:{name:`ReactNode`},description:``},presetDescription:{required:!1,tsType:{name:`string`},description:``},presetPlaceholder:{required:!1,tsType:{name:`string`},description:``,defaultValue:{value:`"Выберите пресет диапазона"`,computed:!1}},presetDisabled:{required:!1,tsType:{name:`boolean`},description:``}},composes:[`Omit`]}})))()}var C=t({Default:()=>D,__namedExportsOrder:()=>O,default:()=>E}),w,T,E,D,O;function k(){return(k=e((()=>{w=n(),o(),i(),S(),T=r(),E={title:`Shared/UI/PresetRangeDateInput`,component:y,args:{value:null,onChange:()=>{}},parameters:{atomicCanvas:!0,layout:`padded`}},D={render:()=>{let[e,t]=(0,w.useState)([new Date(2026,2,10,0,0,0),new Date(2026,2,10,23,59,59)]),[n,r]=(0,w.useState)(`today`);return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(s,{gap:`sm`,align:`end`,children:(0,T.jsx)(y,{value:e,onChange:t,presetId:n,onPresetIdChange:r,referenceDate:new Date(2026,2,10,12,0,0),presetLabel:`Быстрый диапазон`,size:`md`})}),(0,T.jsxs)(a,{as:`p`,className:`marginBlockSm`,children:[`Активный presetId: `,(0,T.jsx)(a,{as:`code`,children:n??`null`})]})]})}},D.parameters={...D.parameters,docs:{...D.parameters?.docs,source:{originalSource:`{
  render: () => {
    const [value, setValue] = useState<NullableDateRange | null>([new Date(2026, 2, 10, 0, 0, 0), new Date(2026, 2, 10, 23, 59, 59)]);
    const [presetId, setPresetId] = useState<string | null>("today");
    return <>
                <FlexContainer gap="sm" align="end">
                    <PresetRangeDateInput value={value} onChange={setValue} presetId={presetId} onPresetIdChange={setPresetId} referenceDate={new Date(2026, 2, 10, 12, 0, 0)} presetLabel="Быстрый диапазон" size="md" />
                </FlexContainer>

                <Text as="p" className="marginBlockSm">
                    Активный presetId: <Text as="code">{presetId ?? "null"}</Text>
                </Text>
            </>;
  }
}`,...D.parameters?.docs?.source},description:{story:`Демонстрирует совместную работу пресета и ручного диапазона.`,...D.parameters?.docs?.description}}},O=[`Default`]})))()}export{C as n,k as r,D as t};