import{n as e}from"./rolldown-runtime-C0FnF6B9.js";import{t}from"./react-C21x__mS.js";import{n}from"./iframe-DaN-XFub.js";import{d as r,h as i,i as a,l as o,u as s,y as c}from"./formatters--mhLir82-v41eaI4a.js";import{a as l,n as u,o as d,r as f,t as p}from"./PresetSelect-C8uIYhPJ.js";function m(e){return typeof e==`string`&&S.has(e)}function h(e,t=[]){return f(e,m,t)}function g(e,t=b){return d(e,t)}function _(e,t=C){return l(e,t)}function v(e,t=new Date,n=C){let r=_(e,n);return r?{id:r.id,label:r.label,range:r.resolveRange({referenceDate:t})}:null}function y(e,t=new Date,n=C){if(!Array.isArray(e))return null;let[r,i]=e;if(!(r instanceof Date)||!(i instanceof Date))return null;let a=r.getTime(),o=i.getTime();for(let e of n){let[n,r]=e.resolveRange({referenceDate:t});if(!(!(n instanceof Date)||!(r instanceof Date))&&n.getTime()===a&&r.getTime()===o)return e.id}return null}var b,x,S,C;function w(){return(w=e((()=>{i(),b=Object.freeze([{id:`monthStartToYesterday`,label:`С начала месяца по вчера`,resolveRange:c},{id:`monthStartToToday`,label:`С начала месяца по сегодня`,resolveRange:a},{id:`today`,label:`За сегодня`,resolveRange:s},{id:`yesterday`,label:`За вчера`,resolveRange:o},{id:`monthAgo`,label:`Месяц назад`,resolveRange:r}]),x=Object.freeze([`monthStartToYesterday`,`monthStartToToday`,`today`,`yesterday`]),S=new Set(b.map(e=>e.id)),C=Object.freeze(g(x))})))()}function T(e){if(!e)return`__empty__`;let[t,n]=e.range;return[e.id,t?.getTime()??`null`,n?.getTime()??`null`].join(`|`)}function E({value:e,onChange:t,options:n=C,referenceDate:r,onRangeChange:i,...a}){let[o]=(0,D.useState)(()=>new Date),s=r?.getTime()??o.getTime(),c=!!i,l=(0,D.useRef)(``),u=(0,D.useEffectEvent)(e=>{if(!i)return;let t=v(e,new Date(s),n),r=T(t);r!==l.current&&(l.current=r,i(t))});return(0,D.useEffect)(()=>{u(e)},[c,n,s,e]),(0,O.jsx)(p,{...a,options:n,value:e,onChange:t})}var D,O;function k(){return(k=e((()=>{D=t(),u(),w(),O=n(),E.__docgenInfo={description:`Выбор пресета диапазона дат с вычислением диапазона без timezone-сдвига.`,methods:[],displayName:`DateRangePresetSelect`,props:{label:{required:!1,tsType:{name:`ReactNode`},description:``},description:{required:!1,tsType:{name:`string`},description:``},placeholder:{required:!1,tsType:{name:`string`},description:``},disabled:{required:!1,tsType:{name:`boolean`},description:``},size:{required:!1,tsType:{name:`union`,raw:`"xs" | "sm" | "md" | "lg" | "xl"`,elements:[{name:`literal`,value:`"xs"`},{name:`literal`,value:`"sm"`},{name:`literal`,value:`"md"`},{name:`literal`,value:`"lg"`},{name:`literal`,value:`"xl"`}]},description:``},value:{required:!0,tsType:{name:`V`},description:"Если начальное состояние может быть `null | undefined`\nзначит `onChange` тоже должен ументь сбрасывать.\nПоэтому такой контрол явно должен передавать `UiBaseProps<AnyType | undefined>`"},onChange:{required:!0,tsType:{name:`signature`,type:`function`,raw:`(value: T) => void`,signature:{arguments:[{type:{name:`C`},name:`value`}],return:{name:`void`}}},description:``},options:{required:!1,tsType:{name:`unknown`},description:``,defaultValue:{value:`Object.freeze(
	resolveDateRangePresetOptionsByIds(DEFAULT_DATE_RANGE_PRESET_IDS)
)`,computed:!0}},referenceDate:{required:!1,tsType:{name:`Date`},description:``},onRangeChange:{required:!1,tsType:{name:`signature`,type:`function`,raw:`(payload: DateRangePresetChangePayload | null) => void`,signature:{arguments:[{type:{name:`union`,raw:`DateRangePresetChangePayload | null`,elements:[{name:`DateRangePresetChangePayload`},{name:`null`}]},name:`payload`}],return:{name:`void`}}},description:``}}}})))()}export{h as a,v as c,w as i,k as n,y as o,x as r,g as s,E as t};