"use client"
import{c as p}from"./chunk-IGMFMKPE.mjs";import{b as y}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:a,onSelect:l,currentValue:i})=>{let P=e=>"dateRange"in e,b=e=>"date"in e,r=(e,t)=>e.getDate()===t.getDate()&&e.getMonth()===t.getMonth()&&e.getFullYear()===t.getFullYear(),h=(e,t)=>{let s=e.from,m=t.from,u=!1;s&&m&&r(s,m)&&(u=!0);let d=e.to,c=t.to,f=!1;return d&&c&&r(d,c)&&(f=!0),u&&f},x=e=>{if(P(e)){let t=i;return t&&h(t,e.dateRange)}else if(b(e)){let t=i;return t&&r(t,e.date)}return!1};return p(a.filter(e=>e.shortcut).map(e=>e.shortcut),e=>{console.log("shortcut",e.key);let t=a.find(s=>s.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:a.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 rounded bg-gray-100 px-2 py-0.5 text-xs font-light group-data-[selected=true]:bg-gray-200",children:e.shortcut}):null,e.requiresUpgrade&&e.tooltipContent&&o(y,{side:"bottom",content:e.tooltipContent,children:o("div",{className:"absolute inset-0 cursor-not-allowed"})})]},t))})})};w.displayName="DatePicker.Presets";export{w as a};
