"use client"
import{c as p}from"./chunk-IGMFMKPE.mjs";import{b as P}from"./chunk-KGQWA5H2.mjs";import{i as g}from"./chunk-QSMIB34W.mjs";import{Command as n}from"cmdk";import{Lock as T}from"lucide-react";import{jsx as o,jsxs as R}from"react/jsx-runtime";var w=({presets:s,onSelect:l,currentValue:i})=>{let b=e=>"dateRange"in e,y=e=>"date"in e,r=(e,t)=>e.getDate()===t.getDate()&&e.getMonth()===t.getMonth()&&e.getFullYear()===t.getFullYear(),h=(e,t)=>{let a=e.from,m=t.from,d=!1;a&&m&&r(a,m)&&(d=!0);let u=e.to,c=t.to,f=!1;return u&&c&&r(u,c)&&(f=!0),d&&f},x=e=>{if(b(e)){let t=i;return t&&h(t,e.dateRange)}else if(y(e)){let t=i;return t&&r(t,e.date)}return!1};return p(s.filter(e=>e.shortcut).map(e=>e.shortcut),e=>{let t=s.find(a=>a.shortcut===e.key);t&&l(t)},{enabled:!0}),o(n,{className:"w-full rounded ring-gray-200 ring-offset-2 focus:outline-none",tabIndex:0,autoFocus:!0,loop:!0,children:o(n.List,{className:"[&>*]:flex [&>*]:w-full [&>*]:items-start [&>*]:gap-x-2 [&>*]:gap-y-0.5 [&>*]:sm:flex-col",children:s.map((e,t)=>R(n.Item,{disabled:e.requiresUpgrade,onSelect:()=>l(e),title:e.label,value:e.id,className:g("group relative flex cursor-pointer items-center justify-between overflow-hidden text-ellipsis whitespace-nowrap rounded border border-gray-200","px-2.5 py-1.5 text-left text-sm text-gray-700 shadow-sm outline-none sm:w-full sm:border-none sm:py-2 sm:shadow-none","disabled:pointer-events-none disabled:opacity-50","sm:data-[selected=true]:bg-gray-100",x(e)&&"font-semibold text-gray-800"),children:[o("span",{children:e.label}),e.requiresUpgrade?o(T,{className:"h-3.5 w-3.5","aria-hidden":"true"}):e.shortcut?o("kbd",{className:"text-gray-4000 hidden rounded bg-gray-100 px-2 py-0.5 text-xs font-light group-data-[selected=true]:bg-gray-200 md:block",children:e.shortcut.toUpperCase()}):null,e.requiresUpgrade&&e.tooltipContent&&o(P,{side:"bottom",content:e.tooltipContent,children:o("div",{className:"absolute inset-0 cursor-not-allowed"})})]},t))})})};w.displayName="DatePicker.Presets";export{w as a};
