@ttianqii/takaui 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/takaui.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Dt=require("clsx"),Ct=require("tailwind-merge"),e=require("react/jsx-runtime"),z=require("react"),Mt=require("@radix-ui/react-slot"),kt=require("@radix-ui/react-checkbox"),v=require("lucide-react"),Tt=require("@radix-ui/react-dropdown-menu"),Rt=require("@radix-ui/react-select"),Ze=require("@tanstack/react-table"),q=require("date-fns"),Pt=require("@radix-ui/react-popover"),It=require("@radix-ui/react-label"),zt=require("@radix-ui/react-dialog");function Ne(t){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const i=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(s,a,i.get?i:{enumerable:!0,get:()=>t[a]})}}return s.default=t,Object.freeze(s)}const w=Ne(z),Le=Ne(kt),J=Ne(Tt),B=Ne(Rt),De=Ne(Pt),st=Ne(It),se=Ne(zt);function d(...t){return Ct.twMerge(Dt.clsx(t))}const y=w.forwardRef(({className:t,variant:s="default",size:a="default",asChild:i=!1,...m},b)=>{const u=i?Mt.Slot:"button";return e.jsx(u,{className:d("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2","disabled:pointer-events-none disabled:opacity-50",s==="default"&&"bg-blue-600 text-white hover:bg-blue-700 active:bg-blue-800 active:scale-95",s==="destructive"&&"bg-red-600 text-white hover:bg-red-700 active:bg-red-800 active:scale-95",s==="outline"&&"border border-gray-300 bg-white text-gray-900 hover:bg-gray-50 active:bg-gray-100 active:scale-95",s==="secondary"&&"bg-gray-200 text-gray-900 hover:bg-gray-300 active:bg-gray-400 active:scale-95",s==="ghost"&&"bg-transparent text-gray-900 hover:bg-gray-100 active:bg-gray-200 active:scale-95",s==="link"&&"bg-transparent text-blue-600 underline-offset-4 hover:text-blue-700 hover:underline active:text-blue-800",a==="default"&&"h-9 px-4 py-2",a==="sm"&&"h-8 px-3 text-xs gap-1.5",a==="lg"&&"h-10 px-6",a==="icon"&&"h-9 w-9 p-0",a==="icon-sm"&&"h-8 w-8 p-0",a==="icon-lg"&&"h-10 w-10 p-0",t),ref:b,...m})});y.displayName="Button";const Re=w.forwardRef(({className:t,...s},a)=>e.jsx(Le.Root,{ref:a,className:d("peer h-4 w-4 shrink-0 rounded border border-gray-200 bg-white ring-offset-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-gray-400 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-gray-900 data-[state=checked]:border-gray-900 data-[state=checked]:text-white transition-colors",t),...s,children:e.jsx(Le.Indicator,{className:d("flex items-center justify-center text-current"),children:e.jsx(v.Check,{className:"h-3.5 w-3.5 stroke-[2.5]"})})}));Re.displayName=Le.Root.displayName;const ce=w.forwardRef(({className:t,type:s,...a},i)=>e.jsx("input",{type:s,className:d("flex h-10 w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-sm file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-gray-400 focus:outline-none focus:border-gray-500 hover:border-gray-400 disabled:cursor-not-allowed disabled:opacity-50 transition-colors",t),ref:i,...a}));ce.displayName="Input";const at=w.forwardRef(({className:t,orientation:s="horizontal",decorative:a=!0,...i},m)=>e.jsx("div",{ref:m,role:a?"none":"separator","aria-orientation":s,className:d("shrink-0 bg-gray-200",s==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",t),...i}));at.displayName="Separator";const rt=w.createContext({variant:"default"});function Pe({className:t,variant:s="default",...a}){return e.jsx(rt.Provider,{value:{variant:s},children:e.jsx("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:e.jsx("table",{"data-slot":"table",className:d("w-full caption-bottom text-sm",t),...a})})})}function Ie({className:t,...s}){return e.jsx("thead",{"data-slot":"table-header",className:d("bg-gray-50 [&_tr]:border-b [&_tr]:border-gray-200",t),...s})}function ze({className:t,...s}){return e.jsx("tbody",{"data-slot":"table-body",className:d("[&_tr:last-child]:border-b-0",t),...s})}function Ht({className:t,...s}){return e.jsx("tfoot",{"data-slot":"table-footer",className:d("bg-muted/50 border-t font-medium [&>tr]:last:border-b-0",t),...s})}function ne({className:t,...s}){const{variant:a}=w.useContext(rt);return e.jsx("tr",{"data-slot":"table-row",className:d("hover:bg-gray-50 data-[state=selected]:bg-gray-50 transition-colors border-b border-gray-200",a==="clean"&&"border-b-0",t),...s})}function He({className:t,...s}){return e.jsx("th",{"data-slot":"table-head",className:d("text-foreground h-auto px-3 py-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",t),...s})}function we({className:t,...s}){return e.jsx("td",{"data-slot":"table-cell",className:d("px-3 py-2 text-left align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",t),...s})}function Ft({className:t,...s}){return e.jsx("caption",{"data-slot":"table-caption",className:d("text-muted-foreground mt-4 text-sm",t),...s})}function At({...t}){return e.jsx(J.Root,{"data-slot":"dropdown-menu",...t})}function Et({...t}){return e.jsx(J.Portal,{"data-slot":"dropdown-menu-portal",...t})}function Ot({...t}){return e.jsx(J.Trigger,{"data-slot":"dropdown-menu-trigger",suppressHydrationWarning:!0,...t})}function $t({className:t,sideOffset:s=4,...a}){return e.jsx(J.Portal,{children:e.jsx(J.Content,{"data-slot":"dropdown-menu-content",sideOffset:s,className:d("bg-white text-gray-900 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border border-gray-200 p-2 shadow-lg",t),...a})})}function Yt({...t}){return e.jsx(J.Group,{"data-slot":"dropdown-menu-group",...t})}function Lt({className:t,inset:s,variant:a="default",...i}){return e.jsx(J.Item,{"data-slot":"dropdown-menu-item","data-inset":s,"data-variant":a,className:d("focus:bg-gray-100 focus:text-gray-900 data-[variant=destructive]:text-red-600 data-[variant=destructive]:focus:bg-red-50 data-[variant=destructive]:focus:text-red-700 [&_svg:not([class*='text-'])]:text-gray-500 relative flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none select-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...i})}function _t({className:t,children:s,checked:a,...i}){return e.jsxs(J.CheckboxItem,{"data-slot":"dropdown-menu-checkbox-item",className:d("focus:bg-gray-100 focus:text-gray-900 relative flex cursor-pointer items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-none select-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),checked:a,...i,children:[e.jsx("span",{className:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center",children:e.jsx(J.ItemIndicator,{children:e.jsx(v.CheckIcon,{className:"size-4 text-blue-600"})})}),s]})}function Gt({...t}){return e.jsx(J.RadioGroup,{"data-slot":"dropdown-menu-radio-group",...t})}function Wt({className:t,children:s,...a}){return e.jsxs(J.RadioItem,{"data-slot":"dropdown-menu-radio-item",className:d("focus:bg-gray-100 focus:text-gray-900 relative flex cursor-pointer items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-none select-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...a,children:[e.jsx("span",{className:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center",children:e.jsx(J.ItemIndicator,{children:e.jsx(v.CircleIcon,{className:"size-2 fill-blue-600"})})}),s]})}function Vt({className:t,inset:s,...a}){return e.jsx(J.Label,{"data-slot":"dropdown-menu-label","data-inset":s,className:d("px-2 py-1.5 text-sm font-semibold text-gray-900 data-[inset]:pl-8",t),...a})}function Bt({className:t,...s}){return e.jsx(J.Separator,{"data-slot":"dropdown-menu-separator",className:d("bg-gray-100 my-1 h-px",t),...s})}function qt({className:t,...s}){return e.jsx("span",{"data-slot":"dropdown-menu-shortcut",className:d("text-gray-500 ml-auto text-xs tracking-widest",t),...s})}function Ut({...t}){return e.jsx(J.Sub,{"data-slot":"dropdown-menu-sub",...t})}function Jt({className:t,inset:s,children:a,...i}){return e.jsxs(J.SubTrigger,{"data-slot":"dropdown-menu-sub-trigger","data-inset":s,className:d("focus:bg-gray-100 focus:text-gray-900 data-[state=open]:bg-gray-100 data-[state=open]:text-gray-900 [&_svg:not([class*='text-'])]:text-gray-500 flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none select-none transition-colors data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...i,children:[a,e.jsx(v.ChevronRightIcon,{className:"ml-auto size-4"})]})}function Kt({className:t,...s}){return e.jsx(J.SubContent,{"data-slot":"dropdown-menu-sub-content",className:d("bg-white text-gray-900 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-md border border-gray-200 p-2 shadow-lg",t),...s})}function Xt({data:t=[],columns:s,searchPlaceholder:a="Search...",onRowClick:i,className:m="",showPagination:b=!0,showSearch:u=!0,pageSize:D=10,renderToolbar:C,variant:F="default"}){const[$,f]=z.useState(1),[N]=z.useState(D),[P,I]=z.useState(""),[A,W]=z.useState(null),[L,H]=z.useState("asc"),U=z.useMemo(()=>{if(!u||!P.trim())return t;const g=P.toLowerCase();return t.filter(h=>s.some(o=>(o.accessor?o.accessor(h):h[o.key])?.toString().toLowerCase().includes(g)))},[t,P,u,s]),p=z.useMemo(()=>A?[...U].sort((g,h)=>{const o=s.find(n=>n.key===A);if(!o)return 0;const c=o.accessor?o.accessor(g):g[o.key],l=o.accessor?o.accessor(h):h[o.key];if(c===l)return 0;if(c==null)return 1;if(l==null)return-1;const T=c<l?-1:1;return L==="asc"?T:-T}):U,[U,A,L,s]),E=z.useMemo(()=>{if(!b)return p;const g=($-1)*N;return p.slice(g,g+N)},[p,$,N,b]);z.useEffect(()=>f(1),[P]);const V=g=>{A===g?H(L==="asc"?"desc":"asc"):(W(g),H("asc"))},_=(g,h,o)=>{const c=h.accessor?h.accessor(g):g[h.key];return h.cell?h.cell(c,g,o):c};return e.jsxs("div",{className:d("w-full space-y-4",m),children:[(u||C)&&e.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4",children:[u&&e.jsxs("div",{className:"relative w-full sm:w-auto",children:[e.jsx(v.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400"}),e.jsx(ce,{placeholder:a,value:P,onChange:g=>I(g.target.value),className:"pl-10 w-full sm:w-[300px] bg-gray-50 border-gray-300"})]}),C&&e.jsx("div",{className:"w-full sm:w-auto",children:C()})]}),e.jsx("div",{className:"border border-gray-200 rounded-lg overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Pe,{variant:F,children:[e.jsx(Ie,{children:e.jsx(ne,{children:s.map(g=>e.jsx(He,{className:"h-10 px-0 py-0",style:{width:g.width},children:g.align==="center"||!g.align&&typeof g.header!="string"?e.jsx("div",{className:"h-10 flex items-center justify-center",children:typeof g.header!="string"?g.header:e.jsx("span",{className:"text-xs font-normal text-gray-500 uppercase tracking-widest",children:g.header})}):e.jsx("div",{className:"h-10 flex items-center text-xs font-normal text-gray-500 uppercase tracking-widest",children:typeof g.header!="string"?e.jsx("div",{children:g.header}):g.sortable!==!1?e.jsxs(y,{variant:"ghost",className:"h-auto px-3 py-1.5 font-normal hover:bg-transparent hover:text-gray-900",onClick:()=>V(g.key),children:[g.header,A===g.key&&L==="desc"?e.jsx(v.ChevronDown,{className:"h-4 w-4"}):A===g.key&&L==="asc"?e.jsx(v.ChevronUp,{className:"h-4 w-4"}):e.jsx(v.ChevronsUpDown,{className:"h-4 w-4"})]}):e.jsx("span",{className:"px-3",children:g.header})})},g.key))})}),e.jsx(ze,{children:E.length===0?e.jsx(ne,{children:e.jsx(we,{colSpan:s.length,className:"text-center py-8 text-gray-500",children:"No results found."})}):E.map((g,h)=>e.jsx(ne,{className:"hover:bg-gray-50 cursor-pointer",onClick:()=>i?.(g),children:s.map(o=>{const c=o.align==="center"||!o.align&&typeof o.header!="string";return e.jsx(we,{className:c?"px-0 py-4":"px-3 py-4",style:{width:o.width},children:c?e.jsx("div",{className:"flex items-center justify-center h-full",children:_(g,o,h)}):_(g,o,h)},o.key)})},h))})]})})}),b&&e.jsxs("div",{className:"flex items-center justify-between px-2 py-4",children:[e.jsxs("div",{className:"text-sm text-gray-600",children:["Showing ",E.length," of ",p.length," row(s)"]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"text-sm text-gray-700",children:["Page ",$," of ",Math.ceil(p.length/N)]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(y,{variant:"outline",size:"sm",onClick:()=>f(g=>Math.max(1,g-1)),disabled:$===1,className:"h-8 w-8 p-0",children:e.jsx(v.ChevronLeft,{className:"h-4 w-4"})}),e.jsx(y,{variant:"outline",size:"sm",onClick:()=>f(g=>Math.min(Math.ceil(p.length/N),g+1)),disabled:$===Math.ceil(p.length/N),className:"h-8 w-8 p-0",children:e.jsx(v.ChevronRight,{className:"h-4 w-4"})})]})]})]})]})}const nt=z.createContext(null);function Ce(){const t=z.useContext(nt);if(!t)throw new Error("useDataGrid must be used within DataGrid");return t}function Zt({columns:t,data:s,getRowId:a=u=>u.id||String(Math.random()),onRowClick:i,children:m,recordCount:b}){const[u,D]=z.useState({pageIndex:0,pageSize:5}),[C,F]=z.useState([]),[$,f]=z.useState(new Set),N=z.useMemo(()=>C.length===0?s:[...s].sort((c,l)=>{for(const T of C){const n=t.find(Y=>Y.id===T.id);if(!n?.accessorKey)continue;const k=c[n.accessorKey],S=l[n.accessorKey];if(k===S)continue;const R=k<S?-1:1;return T.desc?-R:R}return 0}),[s,C,t]),P=z.useMemo(()=>{const o=u.pageIndex*u.pageSize,c=o+u.pageSize;return N.slice(o,c)},[N,u]),I=Math.ceil(N.length/u.pageSize),A=I,W=u.pageIndex>0,L=u.pageIndex<I-1,H=()=>D(o=>({...o,pageIndex:o.pageIndex-1})),U=()=>{D(o=>({...o,pageIndex:Math.min(o.pageIndex+1,A-1)}))},p=o=>{D(()=>({pageIndex:0,pageSize:o}))},E=o=>{D(c=>({...c,pageIndex:Math.max(0,Math.min(o,A-1))}))},V=o=>{f(c=>{const l=new Set(c);return l.has(o)?l.delete(o):l.add(o),l})},_=()=>{$.size===P.length?f(new Set):f(new Set(P.map(o=>a(o))))},g=P.length>0&&$.size===P.length,h={columns:t,data:s,getRowId:a,onRowClick:i,pagination:u,setPagination:D,canPreviousPage:W,canNextPage:L,previousPage:H,nextPage:U,setPageSize:p,goToPage:E,pageCount:A,sorting:C,setSorting:F,selectedRows:$,toggleRow:V,toggleAllRows:_,isAllRowsSelected:g,paginatedData:P,sortedData:N,totalPages:I,recordCount:b??s.length};return e.jsx(nt.Provider,{value:h,children:m})}function Qt(){const{columns:t,paginatedData:s,getRowId:a,onRowClick:i}=Ce();return e.jsx("div",{className:"border border-gray-200 rounded-lg overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Pe,{children:[e.jsx(Ie,{children:e.jsx(ne,{children:t.map(m=>e.jsx(He,{className:"h-10 px-0 py-0",style:{width:m.size?`${m.size}px`:void 0},children:m.align==="center"?e.jsx("div",{className:"h-10 flex items-center justify-center",children:typeof m.header!="string"?m.header:e.jsx("span",{className:"text-xs font-normal text-gray-500 uppercase tracking-widest",children:m.header})}):e.jsx("div",{className:"h-10 flex items-center text-xs font-normal text-gray-500 uppercase tracking-widest",children:typeof m.header!="string"?e.jsx("div",{children:m.header}):e.jsx("span",{className:"px-3",children:m.header})})},m.id))})}),e.jsx(ze,{children:s.length===0?e.jsx(ne,{children:e.jsx(we,{colSpan:t.length,className:"text-center py-8 text-gray-500",children:"No results found."})}):s.map((m,b)=>e.jsx(ne,{className:"hover:bg-gray-50 cursor-pointer",onClick:()=>i?.(m),children:t.map(u=>{const D=u.align==="center",C=u.cell?u.cell(m,b):u.accessorKey?m[u.accessorKey]:null;return e.jsx(we,{className:D?"px-0 py-4":"px-3 py-4",style:{width:u.size?`${u.size}px`:void 0},children:D?e.jsx("div",{className:"flex items-center justify-center h-full",children:C}):C},u.id)})},a(m)))})]})})})}const je=B.Root,es=B.Group,ve=B.Value,xe=w.forwardRef(({className:t,children:s,...a},i)=>e.jsxs(B.Trigger,{ref:i,className:d("flex h-10 w-full items-center justify-between rounded-md border border-gray-300 bg-white px-3 py-2 text-sm ring-offset-white placeholder:text-gray-400 focus:outline-none focus:border-gray-500 hover:border-gray-400 disabled:cursor-not-allowed disabled:opacity-50 transition-colors",t),...a,children:[s,e.jsx(B.Icon,{asChild:!0,children:e.jsx(v.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));xe.displayName=B.Trigger.displayName;const ot=w.forwardRef(({className:t,...s},a)=>e.jsx(B.ScrollUpButton,{ref:a,className:d("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(v.ChevronUp,{className:"h-4 w-4"})}));ot.displayName=B.ScrollUpButton.displayName;const lt=w.forwardRef(({className:t,...s},a)=>e.jsx(B.ScrollDownButton,{ref:a,className:d("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(v.ChevronDown,{className:"h-4 w-4"})}));lt.displayName=B.ScrollDownButton.displayName;const ge=w.forwardRef(({className:t,children:s,position:a="popper",...i},m)=>e.jsx(B.Portal,{children:e.jsxs(B.Content,{ref:m,className:d("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border border-gray-200 bg-white text-gray-950 shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:a,...i,children:[e.jsx(ot,{}),e.jsx(B.Viewport,{className:d("p-1",a==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:s}),e.jsx(lt,{})]})}));ge.displayName=B.Content.displayName;const it=w.forwardRef(({className:t,...s},a)=>e.jsx(B.Label,{ref:a,className:d("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...s}));it.displayName=B.Label.displayName;const de=w.forwardRef(({className:t,children:s,...a},i)=>e.jsxs(B.Item,{ref:i,className:d("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-gray-100 focus:text-gray-900 data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...a,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(B.ItemIndicator,{children:e.jsx(v.Check,{className:"h-4 w-4"})})}),e.jsx(B.ItemText,{children:s})]}));de.displayName=B.Item.displayName;const ct=w.forwardRef(({className:t,...s},a)=>e.jsx(B.Separator,{ref:a,className:d("-mx-1 my-1 h-px bg-gray-100",t),...s}));ct.displayName=B.Separator.displayName;function ts({mode:t="simple",pageSizeOptions:s=[5,10,15,20]}){const{canPreviousPage:a,canNextPage:i,previousPage:m,nextPage:b,pageCount:u,pagination:D,setPageSize:C,goToPage:F}=Ce(),$=()=>{const f=D.pageIndex,N=u,P=[];if(N<=7)for(let I=0;I<N;I++)P.push(I);else if(f<=3){for(let I=0;I<=4;I++)P.push(I);P.push("..."),P.push(N-1)}else if(f>=N-4){P.push(0),P.push("...");for(let I=N-5;I<N;I++)P.push(I)}else P.push(0),P.push("..."),P.push(f-1),P.push(f),P.push(f+1),P.push("..."),P.push(N-1);return P};return t==="simple"?e.jsx("div",{className:"flex items-center justify-end px-2 py-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"text-sm text-gray-700 hidden sm:block",children:["Page ",D.pageIndex+1," of ",u]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(y,{variant:"outline",size:"sm",onClick:m,disabled:!a,className:"h-8 w-8 p-0",children:e.jsx(v.ChevronLeft,{className:"h-4 w-4"})}),e.jsx(y,{variant:"outline",size:"sm",onClick:b,disabled:!i,className:"h-8 w-8 p-0",children:e.jsx(v.ChevronRight,{className:"h-4 w-4"})})]})]})}):e.jsxs("div",{className:"flex items-center justify-between gap-3 px-2 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-gray-600 hidden sm:inline",children:"Rows per page:"}),e.jsxs(je,{value:String(D.pageSize),onValueChange:f=>C(Number(f)),children:[e.jsx(xe,{className:"h-8 w-16",children:e.jsx(ve,{})}),e.jsx(ge,{children:s.map(f=>e.jsx(de,{value:String(f),children:f},f))})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(y,{variant:"outline",size:"sm",onClick:m,disabled:!a,className:"h-8 w-8 p-0",children:e.jsx(v.ChevronLeft,{className:"h-4 w-4"})}),e.jsxs("span",{className:"text-sm text-gray-700 sm:hidden px-2",children:[D.pageIndex+1," / ",u]}),e.jsx("div",{className:"hidden sm:flex gap-1",children:$().map((f,N)=>typeof f=="number"?e.jsx(y,{variant:D.pageIndex===f?"default":"outline",size:"sm",onClick:()=>F(f),className:"h-8 w-8 p-0",children:f+1},N):e.jsx("span",{className:"flex h-8 w-8 items-center justify-center text-gray-400",children:f},N))}),e.jsx(y,{variant:"outline",size:"sm",onClick:b,disabled:!i,className:"h-8 w-8 p-0",children:e.jsx(v.ChevronRight,{className:"h-4 w-4"})})]})]})}function ss({id:t,title:s}){const{sorting:a,setSorting:i}=Ce(),m=a.find(C=>C.id===t),b=!!m,u=m?.desc??!1,D=()=>{i(C=>{const F=C.find($=>$.id===t);return F?F.desc?[]:[{id:t,desc:!0}]:[{id:t,desc:!1}]})};return e.jsxs(y,{variant:"ghost",className:"h-auto px-3 py-1.5 font-normal hover:bg-transparent hover:text-gray-900",onClick:D,children:[s,b&&u?e.jsx(v.ChevronDown,{className:"h-4 w-4"}):b?e.jsx(v.ChevronUp,{className:"h-4 w-4"}):e.jsx(v.ChevronsUpDown,{className:"h-4 w-4"})]})}function as(){const{toggleAllRows:t,isAllRowsSelected:s}=Ce();return e.jsx(Re,{checked:s,onCheckedChange:t})}function rs({row:t}){const{selectedRows:s,toggleRow:a,getRowId:i}=Ce(),m=i(t);return e.jsx(Re,{checked:s.has(m),onCheckedChange:()=>a(m)})}const dt=w.createContext(null);function ut(){const t=w.useContext(dt);if(!t)throw new Error("useTableContext must be used within a TableRoot component");return t}function ns({table:t,totalRecords:s,children:a}){return e.jsx(dt.Provider,{value:{tableInstance:t,totalRecords:s},children:a})}function os({children:t,className:s}){return e.jsx("div",{className:d("rounded-xl border border-gray-200 bg-white overflow-hidden",s),children:t})}function ls(){const{tableInstance:t}=ut();return e.jsxs(Pe,{children:[e.jsx(Ie,{children:t.getHeaderGroups().map(s=>e.jsx(ne,{children:s.headers.map(a=>e.jsx(He,{children:a.isPlaceholder?null:Ze.flexRender(a.column.columnDef.header,a.getContext())},a.id))},s.id))}),e.jsx(ze,{children:t.getRowModel().rows?.length?t.getRowModel().rows.map(s=>e.jsx(ne,{"data-state":s.getIsSelected()&&"selected",children:s.getVisibleCells().map(a=>e.jsx(we,{children:Ze.flexRender(a.column.columnDef.cell,a.getContext())},a.id))},s.id)):e.jsx(ne,{children:e.jsx(we,{colSpan:t.getAllColumns().length,className:"h-24 text-center",children:"No results."})})})]})}function is({rowsPerPageOptions:t=[5,10,20,30,50],showPageSelector:s=!0,showRecordInfo:a=!0,showControls:i=!0}={}){const{tableInstance:m,totalRecords:b}=ut(),u=m.getState().pagination.pageIndex+1,D=m.getPageCount(),C=m.getState().pagination.pageSize,F=u===1?1:(u-1)*C+1,$=Math.min(u*C,b);return e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-4 px-3 py-4",children:[s&&e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:"text-sm text-gray-700 font-medium",children:"Items per page:"}),e.jsxs(je,{value:`${C}`,onValueChange:f=>{m.setPageSize(Number(f))},children:[e.jsx(xe,{className:"h-9 w-[75px]",children:e.jsx(ve,{placeholder:C})}),e.jsx(ge,{side:"top",children:t.map(f=>e.jsx(de,{value:`${f}`,children:f},f))})]})]}),a&&e.jsx("div",{className:"flex items-center gap-2 text-sm text-gray-700",children:e.jsxs("span",{children:[F,"–",$," of ",b]})}),i&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs(y,{variant:"outline",size:"sm",onClick:()=>m.setPageIndex(0),disabled:!m.getCanPreviousPage(),className:"h-9 w-9 p-0",children:[e.jsx("span",{className:"sr-only",children:"First page"}),e.jsx(v.ChevronsLeft,{className:"h-4 w-4"})]}),e.jsxs(y,{variant:"outline",size:"sm",onClick:()=>m.previousPage(),disabled:!m.getCanPreviousPage(),className:"h-9 w-9 p-0",children:[e.jsx("span",{className:"sr-only",children:"Previous page"}),e.jsx(v.ChevronLeft,{className:"h-4 w-4"})]}),e.jsxs("div",{className:"flex items-center justify-center text-sm font-medium min-w-[110px]",children:["Page ",u," of ",D]}),e.jsxs(y,{variant:"outline",size:"sm",onClick:()=>m.nextPage(),disabled:!m.getCanNextPage(),className:"h-9 w-9 p-0",children:[e.jsx("span",{className:"sr-only",children:"Next page"}),e.jsx(v.ChevronRight,{className:"h-4 w-4"})]}),e.jsxs(y,{variant:"outline",size:"sm",onClick:()=>m.setPageIndex(m.getPageCount()-1),disabled:!m.getCanNextPage(),className:"h-9 w-9 p-0",children:[e.jsx("span",{className:"sr-only",children:"Last page"}),e.jsx(v.ChevronsRight,{className:"h-4 w-4"})]})]})]})}function cs({column:t,title:s,align:a="left",className:i}){const m=t.getCanSort(),b=t.getIsSorted(),u={left:"",center:"text-center",right:"text-right"},D=()=>b==="asc"?e.jsx(v.ChevronDown,{className:"h-4 w-4"}):b==="desc"?e.jsx(v.ChevronUp,{className:"h-4 w-4"}):e.jsx(v.ChevronsUpDown,{className:"h-4 w-4"});return m?e.jsx("div",{className:d(u[a]),children:e.jsxs(y,{variant:"ghost",className:"h-auto px-2 py-1 font-normal hover:bg-transparent hover:text-gray-900",onClick:()=>t.toggleSorting(b==="asc"),children:[s,D()]})}):e.jsx("div",{className:d("px-2 py-1",i),children:s})}const ds=t=>new Date(t.getFullYear(),t.getMonth(),1),us=t=>new Date(t.getFullYear(),t.getMonth()+1,0),hs=(t,s)=>{const a=[],i=new Date(t);for(;i<=s;)a.push(new Date(i)),i.setDate(i.getDate()+1);return a},Qe=(t,s)=>t.getMonth()===s.getMonth()&&t.getFullYear()===s.getFullYear(),Se=(t,s)=>t.getDate()===s.getDate()&&t.getMonth()===s.getMonth()&&t.getFullYear()===s.getFullYear(),et=t=>Se(t,new Date),ms=t=>{const s=new Date;return s.setDate(s.getDate()+1),Se(t,s)},tt=(t,s)=>{const a=new Date(t);return a.setMonth(a.getMonth()+s),a},$e=(t,s)=>{const a=["January","February","March","April","May","June","July","August","September","October","November","December"],i=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];return s==="MMMM yyyy"?`${a[t.getMonth()]} ${t.getFullYear()}`:s==="MMM d, yyyy"?`${i[t.getMonth()]} ${t.getDate()}, ${t.getFullYear()}`:s==="d"?t.getDate().toString():t.toLocaleDateString()};function xs({selected:t,onSelect:s,events:a=[],holidays:i=[],className:m,...b}){const[u,D]=w.useState(new Date),[C,F]=w.useState("calendar"),$=ds(u),f=us(u),N=hs($,f),P=["January","February","March","April","May","June","July","August","September","October","November","December"],I=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],A=u.getFullYear(),W=Array.from({length:20},(h,o)=>A-10+o),L=()=>{D(tt(u,-1))},H=()=>{D(tt(u,1))},U=()=>{const h=new Date(u);h.setFullYear(A-1),D(h)},p=()=>{const h=new Date(u);h.setFullYear(A+1),D(h)},E=h=>{const o=new Date(u);o.setMonth(h),D(o),F("calendar")},V=h=>{const o=new Date(u);o.setFullYear(h),D(o),F("calendar")},_=h=>a.filter(o=>Se(o.date,h)),g=h=>i.some(o=>Se(o.date,h));return C==="months"?e.jsxs("div",{className:d("bg-white rounded-lg border border-gray-200 w-full",m),...b,children:[e.jsx("div",{className:"px-6 py-4 border-b border-gray-100",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>F("calendar"),className:"h-9 px-3 text-sm font-medium text-gray-600 hover:text-gray-900 hover:bg-gray-50 rounded",children:"← Back"}),e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsx(y,{variant:"outline",size:"sm",onClick:U,className:"h-9 w-9 p-0 border-gray-200 rounded",children:e.jsx(v.ChevronLeft,{className:"h-4 w-4"})}),e.jsx(y,{variant:"ghost",onClick:()=>F("years"),className:"h-9 px-4 text-lg font-semibold text-gray-900 hover:bg-gray-50 rounded",children:A}),e.jsx(y,{variant:"outline",size:"sm",onClick:p,className:"h-9 w-9 p-0 border-gray-200 rounded",children:e.jsx(v.ChevronRight,{className:"h-4 w-4"})})]})]})}),e.jsx("div",{className:"p-6",children:e.jsx("div",{className:"grid grid-cols-3 gap-2",children:P.map((h,o)=>e.jsx(y,{variant:"ghost",onClick:()=>E(o),className:d("h-11 w-full text-sm font-medium rounded transition-all duration-200",o===u.getMonth()?"bg-gray-900 text-white hover:bg-gray-800 shadow-sm":"text-gray-600 hover:text-gray-900 hover:bg-gray-50"),children:h},h))})})]}):C==="years"?e.jsxs("div",{className:d("bg-white rounded-lg border border-gray-200 w-full",m),...b,children:[e.jsx("div",{className:"px-6 py-4 border-b border-gray-100",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>F("months"),className:"h-9 px-3 text-sm font-medium text-gray-600 hover:text-gray-900 hover:bg-gray-50 rounded",children:"← Back"}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:"Select Year"})]})}),e.jsx("div",{className:"p-6",children:e.jsx("div",{className:"grid grid-cols-4 gap-2 max-h-64 overflow-y-auto",children:W.map(h=>e.jsx(y,{variant:"ghost",onClick:()=>V(h),className:d("h-11 w-full text-sm font-medium rounded transition-all duration-200",h===A?"bg-gray-900 text-white hover:bg-gray-800 shadow-sm":"text-gray-600 hover:text-gray-900 hover:bg-gray-50"),children:h},h))})})]}):e.jsxs("div",{className:d("bg-white rounded-lg border border-gray-200 w-full",m),...b,children:[e.jsx("div",{className:"px-6 py-4 border-b border-gray-100",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(y,{variant:"outline",size:"sm",onClick:L,className:"h-9 w-9 p-0 border-gray-200 rounded",children:e.jsx(v.ChevronLeft,{className:"h-4 w-4"})}),e.jsx(y,{variant:"ghost",onClick:()=>F("months"),className:"h-9 px-4 text-lg font-semibold text-gray-900 hover:bg-gray-50 rounded",children:$e(u,"MMMM yyyy")}),e.jsx(y,{variant:"outline",size:"sm",onClick:H,className:"h-9 w-9 p-0 border-gray-200 rounded",children:e.jsx(v.ChevronRight,{className:"h-4 w-4"})})]})}),e.jsxs("div",{className:"p-6",children:[e.jsx("div",{className:"grid grid-cols-7 gap-1 mb-2",children:I.map((h,o)=>e.jsx("div",{className:"h-10 flex items-center justify-center",children:e.jsx("span",{className:"text-xs font-medium text-gray-400 uppercase",children:h})},o))}),e.jsxs("div",{className:"grid grid-cols-7 gap-1",children:[Array.from({length:$.getDay()}).map((h,o)=>e.jsx("div",{className:"h-12"},`empty-${o}`)),N.map(h=>{const o=_(h),c=t&&Se(h,t),l=et(h),T=Qe(h,u),n=g(h);return e.jsx("div",{className:"relative",children:e.jsxs(y,{variant:"ghost",size:"sm",className:d("h-12 w-full p-0 text-sm relative rounded transition-all duration-200",!T&&"text-gray-300",T&&!c&&!l&&!n&&"text-gray-700 hover:bg-gray-50",n&&!c&&"text-red-600 font-medium hover:bg-red-50",l&&!c&&"bg-gray-100 text-gray-900 font-medium border border-gray-200",c&&"bg-gray-900 text-white font-medium shadow-sm"),onClick:()=>s?.(h),children:[$e(h,"d"),o.length>0&&e.jsxs("div",{className:"absolute bottom-1 left-1/2 transform -translate-x-1/2 flex space-x-0.5",children:[o.slice(0,3).map((k,S)=>{const R=Y=>{if(c)return"bg-white/80";switch(Y){case"class":return"bg-blue-500";case"meeting":return"bg-green-500";case"appointment":return"bg-orange-500";case"deadline":return"bg-red-500";default:return"bg-gray-500"}};return e.jsx("div",{className:d("w-1 h-1 rounded-full",R(k.type))},S)}),o.length>3&&e.jsx("div",{className:d("w-1 h-1 rounded-full",c?"bg-white/60":"bg-gray-400")})]})]})},h.toISOString())})]})]}),t&&e.jsx("div",{className:"border-t border-gray-100",children:e.jsxs("div",{className:"p-6",children:[e.jsx("div",{className:"flex items-center justify-between mb-4",children:e.jsx("h4",{className:"text-sm font-semibold text-gray-900",children:et(t)?"Today":ms(t)?"Tomorrow":$e(t,"MMM d, yyyy")})}),(()=>{const h=a.filter(o=>Se(o.date,t));return e.jsxs("div",{className:"space-y-3",children:[h.length>0&&h.map(o=>{const l=(T=>{switch(T){case"class":return{bg:"bg-blue-50",border:"border-blue-100",dot:"bg-blue-500",text:"text-blue-900",subtext:"text-blue-600"};case"meeting":return{bg:"bg-green-50",border:"border-green-100",dot:"bg-green-500",text:"text-green-900",subtext:"text-green-600"};case"appointment":return{bg:"bg-orange-50",border:"border-orange-100",dot:"bg-orange-500",text:"text-orange-900",subtext:"text-orange-600"};case"deadline":return{bg:"bg-red-50",border:"border-red-100",dot:"bg-red-500",text:"text-red-900",subtext:"text-red-600"};default:return{bg:"bg-gray-50",border:"border-gray-100",dot:"bg-gray-500",text:"text-gray-900",subtext:"text-gray-600"}}})(o.type);return e.jsxs("div",{className:`flex items-center space-x-3 p-3 ${l.bg} rounded border ${l.border} hover:shadow-sm transition-shadow cursor-pointer`,children:[e.jsx("div",{className:`w-2 h-2 rounded-full ${l.dot} flex-shrink-0`}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:`text-sm font-medium ${l.text} truncate`,children:o.title}),(o.time||o.location)&&e.jsxs("p",{className:`text-xs ${l.subtext} truncate`,children:[o.time,o.time&&o.location&&" • ",o.location]})]})]},o.id||o.title)}),h.length===0&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"w-12 h-12 bg-gray-100 rounded-full flex items-center justify-center mx-auto mb-3",children:e.jsx(v.Calendar,{className:"w-5 h-5 text-gray-400"})}),e.jsx("p",{className:"text-sm text-gray-500",children:"No events scheduled"})]})]})})()]})}),!Qe(u,new Date)&&e.jsx("div",{className:"p-6 pt-0",children:e.jsx(y,{variant:"outline",size:"sm",onClick:()=>{const h=new Date;D(h),s?.(h),F("calendar")},className:"w-full h-10 text-sm font-medium border-gray-200 hover:bg-gray-50 rounded",children:"Today"})})]})}const We=De.Root,Ve=De.Trigger,gs=De.Anchor,Fe=w.forwardRef(({className:t,align:s="center",sideOffset:a=4,...i},m)=>e.jsx(De.Portal,{children:e.jsx(De.Content,{ref:m,align:s,sideOffset:a,className:d("z-50 w-auto rounded-md border border-gray-200 bg-white p-3 text-gray-950 shadow-lg outline-none","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95","data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2","data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...i})}));Fe.displayName=De.Content.displayName;function ps({date:t,onDateChange:s,mode:a="single",dateRange:i,onDateRangeChange:m,placeholder:b="Pick a date",dateFormat:u="PPP",disabled:D=!1,className:C,variant:F="outline",size:$="default",align:f="start",showIcon:N=!0,icon:P,minDate:I,maxDate:A,disabledDates:W,isDateDisabled:L,fullWidth:H=!1,customTrigger:U,numberOfMonths:p=1,holidays:E=[]}){const[V,_]=w.useState(!1),[g,h]=w.useState(t||new Date),[o,c]=w.useState("calendar"),[l,T]=w.useState(i?.from),[n,k]=w.useState(i?.to),[S,R]=w.useState();w.useEffect(()=>{T(i?.from),k(i?.to)},[i]),w.useEffect(()=>{V&&(c("calendar"),a==="single"&&t?h(t):a==="range"&&i?.from&&h(i.from))},[V,t,i,a]);const Y=x=>{if(a==="range")if(!l||l&&n)T(x),k(void 0),m?.({from:x,to:void 0});else{const O=l<x?l:x,te=l<x?x:l;T(O),k(te),m?.({from:O,to:te}),_(!1)}else s?.(x),_(!1)},X=x=>!!(W?.some(O=>O.toDateString()===x.toDateString())||I&&x<I||A&&x>A||L?.(x)),oe=x=>E.some(O=>q.isSameDay(O.date,x)),ue=q.startOfMonth(g),ee=q.endOfMonth(g),le=q.eachDayOfInterval({start:ue,end:ee}),ie=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],he=q.addMonths(g,1),Me=q.startOfMonth(he),Te=q.endOfMonth(he),ke=q.eachDayOfInterval({start:Me,end:Te}),pe=()=>{h(q.subMonths(g,1))},me=()=>{h(q.addMonths(g,1))},ae=(x,O)=>q.format(x,O),r=x=>{if(l&&n)return x>=l&&x<=n;if(l&&!n&&S){const O=l<S?l:S,te=l<S?S:l;return x>=O&&x<=te}return!1},j=x=>l&&q.isSameDay(x,l),G=x=>n&&q.isSameDay(x,n),M=()=>{const x=new Date(g);x.setFullYear(fe-1),h(x)},re=()=>{const x=new Date(g);x.setFullYear(fe+1),h(x)},Z=x=>{const O=new Date(g.getFullYear(),x,1);h(O),c("calendar")},K=x=>{const O=new Date(x,g.getMonth(),1);h(O),c("calendar")},Ae=["January","February","March","April","May","June","July","August","September","October","November","December"],fe=g.getFullYear(),Ee=Array.from({length:20},(x,O)=>fe-10+O),Ke=U||e.jsxs(y,{variant:F,size:$,className:d("justify-start text-left font-normal",!t&&!l&&"text-gray-500",H&&"w-full",C),disabled:D,children:[N&&(P||e.jsx(v.Calendar,{className:"mr-2 h-4 w-4"})),a==="range"?l&&n?e.jsxs("span",{children:[q.format(l,u)," - ",q.format(n,u)]}):l?e.jsxs("span",{children:[q.format(l,u)," - ..."]}):e.jsx("span",{children:b}):t?q.format(t,u):e.jsx("span",{children:b})]}),ye=(x,O)=>{const te=a==="single"?t&&q.isSameDay(x,t):j(x)||G(x),vt=q.isToday(x),Oe=X(x),be=a==="range"&&r(x),wt=oe(x),Xe=x.getDay(),Nt=j(x),St=G(x);return e.jsx("div",{className:d("relative p-0.5",be&&"bg-gray-100",be&&Xe===0&&"rounded-l-md",be&&Xe===6&&"rounded-r-md",be&&Nt&&"rounded-l-md",be&&St&&"rounded-r-md"),onMouseEnter:()=>a==="range"&&l&&!n&&R(x),onMouseLeave:()=>R(void 0),children:e.jsx(y,{variant:"ghost",size:"sm",disabled:Oe||D,className:d("h-10 w-full p-0 text-sm relative transition-all duration-200 rounded-md text-gray-900",!O&&"text-gray-300",wt&&!te&&"text-red-600 font-medium",vt&&!te&&!be&&"bg-gray-50 text-gray-900 font-medium border border-gray-200",te&&"bg-gray-900 text-white font-medium shadow-sm z-10 hover:bg-gray-800",be&&!te&&"text-gray-900 bg-gray-100",Oe&&"opacity-40 cursor-not-allowed"),onClick:()=>!Oe&&Y(x),children:ae(x,"d")})},x.toISOString())};return e.jsxs(We,{open:V,onOpenChange:_,children:[e.jsx(Ve,{asChild:!0,children:Ke}),e.jsx(Fe,{className:d("p-0 border-gray-200",p===2?"w-[640px]":"w-80"),align:f,side:"bottom",sideOffset:4,collisionPadding:8,children:e.jsxs("div",{className:"bg-white rounded-lg","data-takaui":"datepicker",children:[e.jsx("div",{className:"border-b border-gray-100 px-6 py-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(y,{variant:"outline",size:"sm",onClick:pe,className:"h-9 w-9 p-0",children:e.jsx(v.ChevronLeft,{className:"h-4 w-4"})}),p===2?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>c("months"),className:"h-9 px-3 font-semibold text-base",children:ae(g,"MMMM")}),e.jsx("span",{className:"text-gray-400 text-sm",children:"-"}),e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>c("months"),className:"h-9 px-3 font-semibold text-base",children:ae(he,"MMMM yyyy")})]}):e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>c("months"),className:"h-9 px-4 font-semibold text-lg",children:ae(g,"MMMM yyyy")}),e.jsx(y,{variant:"outline",size:"sm",onClick:me,className:"h-9 w-9 p-0",children:e.jsx(v.ChevronRight,{className:"h-4 w-4"})})]})}),e.jsxs("div",{className:"p-6",children:[o==="years"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>c("months"),className:"h-9 px-3 text-sm font-medium text-gray-600",children:"← Back"}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:"Select Year"})]}),e.jsx("div",{className:"grid grid-cols-4 gap-2 max-h-64 overflow-y-auto",children:Ee.map(x=>e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>K(x),className:d("h-11 w-full text-sm font-medium rounded-md transition-all duration-200",x===fe?"bg-gray-900 text-white shadow-sm hover:bg-gray-800":"text-gray-900 bg-transparent"),children:x},x))})]}),o==="months"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>c("calendar"),className:"h-9 px-3 text-sm font-medium text-gray-600",children:"← Back"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(y,{variant:"outline",size:"sm",onClick:M,className:"h-9 w-9 p-0",children:e.jsx(v.ChevronLeft,{className:"h-4 w-4"})}),e.jsx(y,{variant:"ghost",onClick:()=>c("years"),className:"h-9 px-4 text-lg font-semibold text-gray-900",children:fe}),e.jsx(y,{variant:"outline",size:"sm",onClick:re,className:"h-9 w-9 p-0",children:e.jsx(v.ChevronRight,{className:"h-4 w-4"})})]})]}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:Ae.map((x,O)=>e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>Z(O),className:d("h-11 w-full text-sm font-medium rounded-md transition-all duration-200",O===g.getMonth()?"bg-gray-900 text-white shadow-sm hover:bg-gray-800":"text-gray-900 bg-transparent"),children:x},x))})]}),o==="calendar"&&e.jsxs("div",{className:d("flex",p===2?"gap-6":"gap-0"),children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"grid grid-cols-7 gap-1 mb-2",children:ie.map((x,O)=>e.jsx("div",{className:"h-8 flex items-center justify-center",children:e.jsx("span",{className:"text-xs font-medium text-gray-400 uppercase",children:x})},O))}),e.jsxs("div",{className:"grid grid-cols-7",children:[Array.from({length:ue.getDay()}).map((x,O)=>e.jsx("div",{className:"h-10"},`empty-${O}`)),le.map(x=>ye(x,q.isSameMonth(x,g)))]})]}),p===2&&e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"grid grid-cols-7 gap-1 mb-2",children:ie.map((x,O)=>e.jsx("div",{className:"h-8 flex items-center justify-center",children:e.jsx("span",{className:"text-xs font-medium text-gray-400 uppercase",children:x})},O))}),e.jsxs("div",{className:"grid grid-cols-7",children:[Array.from({length:Me.getDay()}).map((x,O)=>e.jsx("div",{className:"h-10"},`next-empty-${O}`)),ke.map(x=>ye(x,q.isSameMonth(x,he)))]})]})]})]})]})})]})}const fs=({time:t,onTimeChange:s,timezone:a="UTC",format:i="24h",showTimezone:m=!1,minuteStep:b=1,showSeconds:u=!1,placeholder:D="Select time",variant:C="outline",size:F="default",showClockFace:$=!1})=>{const f=i==="24h",N=t?t.getHours():0,P=t?t.getMinutes():0,I=t?t.getSeconds():0,A=N>=12?"PM":"AM",[W,L]=z.useState(N),[H,U]=z.useState(P),[p,E]=z.useState(I),[V,_]=z.useState(A),[g,h]=z.useState(""),[o,c]=z.useState(""),[l,T]=z.useState(""),n=z.useRef(null),k=z.useRef(null),S=z.useRef(null),R=z.useRef(null),Y=z.useRef(null),X=z.useRef(null);z.useEffect(()=>{if(t){const r=t.getHours(),j=t.getMinutes(),G=t.getSeconds(),M=r>=12?"PM":"AM";r!==W&&L(r),j!==H&&U(j),G!==p&&E(G),M!==V&&_(M)}},[t]),z.useEffect(()=>{R.current&&R.current.querySelector('[data-selected="true"]')?.scrollIntoView({block:"center",behavior:"smooth"}),Y.current&&Y.current.querySelector('[data-selected="true"]')?.scrollIntoView({block:"center",behavior:"smooth"}),X.current&&X.current.querySelector('[data-selected="true"]')?.scrollIntoView({block:"center",behavior:"smooth"})},[W,H,p,f]);const oe=(r,j,G)=>{const M=new Date;M.setHours(r),M.setMinutes(j),M.setSeconds(G),s(M)},ue=r=>{let j=r;f||(V==="PM"&&r!==12?j=r+12:V==="AM"&&r===12&&(j=0)),L(j),oe(j,H,p)},ee=r=>{U(r),oe(W,r,p)},le=r=>{E(r),oe(W,H,r)},ie=r=>{if(V===r)return;_(r);const j=r==="PM"?W%12+12:W%12;L(j),oe(j,H,p)},he=()=>{const r=new Date;L(r.getHours()),U(r.getMinutes()),E(r.getSeconds()),_(r.getHours()>=12?"PM":"AM"),s(r)},Me=()=>{if(!t)return D;const r=f?W:W%12||12,j=H.toString().padStart(2,"0"),G=p.toString().padStart(2,"0");let M=`${r.toString().padStart(2,"0")}:${j}`;return u&&(M+=`:${G}`),f||(M+=` ${V}`),m&&(M+=` ${a}`),M},Te=()=>{const r=f?23:12,j=f?0:1;return Array.from({length:r-j+1},(G,M)=>j+M)},ke=()=>Array.from({length:Math.floor(60/b)},(r,j)=>j*b),pe=()=>Array.from({length:60},(r,j)=>j),me=f?W:W%12||12,ae=()=>{const re=(me%12*30+H*.5)*(Math.PI/180)-Math.PI/2,Z=H*6*(Math.PI/180)-Math.PI/2,K=100+50*Math.cos(re),Ae=100+50*Math.sin(re),fe=100+70*Math.cos(Z),Ee=100+70*Math.sin(Z);return e.jsxs("svg",{width:200,height:200,className:"mx-auto",children:[e.jsx("circle",{cx:100,cy:100,r:95,fill:"white",stroke:"#e5e7eb",strokeWidth:"2"}),Array.from({length:12},(Ke,ye)=>{const x=ye*30*(Math.PI/180)-Math.PI/2,O=100+80*Math.cos(x),te=100+80*Math.sin(x);return e.jsx("text",{x:O,y:te,textAnchor:"middle",dominantBaseline:"middle",className:"text-sm fill-gray-600",children:ye===0?12:ye},ye)}),e.jsx("line",{x1:100,y1:100,x2:K,y2:Ae,stroke:"#374151",strokeWidth:"6",strokeLinecap:"round"}),e.jsx("line",{x1:100,y1:100,x2:fe,y2:Ee,stroke:"#ef4444",strokeWidth:"4",strokeLinecap:"round"}),e.jsx("circle",{cx:100,cy:100,r:"6",fill:"#ef4444"})]})};return e.jsxs(We,{children:[e.jsx(Ve,{asChild:!0,children:e.jsxs(y,{variant:C,size:F,className:d("justify-start text-left font-normal",!t&&"text-muted-foreground"),children:[e.jsx(v.Clock,{className:"mr-2 h-4 w-4"}),Me()]})}),e.jsx(Fe,{className:"w-auto p-0",align:"start",children:e.jsxs("div",{className:"p-6 space-y-4 min-w-[460px]",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-center gap-6",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("input",{ref:n,type:"text",inputMode:"numeric",value:g!==""?g.padStart(2,"0"):me.toString().padStart(2,"0"),onKeyDown:r=>{if(r.key>="0"&&r.key<="9"){r.preventDefault();const j=g+r.key;if(j.length===1)h(r.key);else if(j.length===2){const G=parseInt(j),M=f?23:12,re=f?0:1;let Z=G;G<re&&(Z=re),G>M&&(Z=M),h(""),ue(Z),setTimeout(()=>k.current?.focus(),0)}}else r.key==="Backspace"?(r.preventDefault(),g.length>0&&h(g.slice(0,-1))):r.key==="ArrowRight"||r.key==="Tab"?(r.key==="ArrowRight"&&r.preventDefault(),k.current?.focus()):r.key===":"&&(r.preventDefault(),k.current?.focus())},onBlur:()=>{if(g){const r=parseInt(g),j=f?23:12,G=f?0:1;let M=r;r<G&&(M=G),r>j&&(M=j),ue(M)}h("")},onFocus:()=>{h("")},className:"text-6xl font-medium tabular-nums leading-none w-[85px] text-center bg-transparent outline-none focus:ring-2 focus:ring-primary rounded px-1 cursor-text",readOnly:!0}),e.jsx("div",{className:"text-6xl font-medium leading-none flex items-center px-1",children:":"}),e.jsx("input",{ref:k,type:"text",inputMode:"numeric",value:o!==""?o.padStart(2,"0"):H.toString().padStart(2,"0"),onKeyDown:r=>{if(r.key>="0"&&r.key<="9"){r.preventDefault();const j=o+r.key;if(j.length===1)c(r.key);else if(j.length===2){const G=parseInt(j),M=Math.min(59,Math.max(0,G));c(""),ee(M),u&&setTimeout(()=>S.current?.focus(),0)}}else r.key==="Backspace"?(r.preventDefault(),o.length>0?c(o.slice(0,-1)):n.current?.focus()):r.key==="ArrowLeft"?(r.preventDefault(),n.current?.focus()):r.key==="ArrowRight"||r.key==="Tab"?(r.key==="ArrowRight"&&r.preventDefault(),u&&S.current?.focus()):r.key===":"&&(r.preventDefault(),u&&S.current?.focus())},onBlur:()=>{if(o){const r=parseInt(o),j=Math.min(59,Math.max(0,r));ee(j)}c("")},onFocus:()=>{c("")},className:"text-6xl font-medium tabular-nums leading-none w-[85px] text-center bg-transparent outline-none focus:ring-2 focus:ring-primary rounded px-1 cursor-text",readOnly:!0}),u&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-6xl font-medium leading-none flex items-center px-1",children:":"}),e.jsx("input",{ref:S,type:"text",inputMode:"numeric",value:l!==""?l.padStart(2,"0"):p.toString().padStart(2,"0"),onKeyDown:r=>{if(r.key>="0"&&r.key<="9"){r.preventDefault();const j=l+r.key;if(j.length===1)T(r.key);else if(j.length===2){const G=parseInt(j),M=Math.min(59,Math.max(0,G));T(""),le(M)}}else r.key==="Backspace"?(r.preventDefault(),l.length>0?T(l.slice(0,-1)):k.current?.focus()):r.key==="ArrowLeft"&&(r.preventDefault(),k.current?.focus())},onBlur:()=>{if(l){const r=parseInt(l),j=Math.min(59,Math.max(0,r));le(j)}T("")},onFocus:()=>{T("")},className:"text-6xl font-medium tabular-nums leading-none w-[85px] text-center bg-transparent outline-none focus:ring-2 focus:ring-primary rounded px-1 cursor-text",readOnly:!0})]})]}),!f&&e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(y,{size:"sm",variant:V==="AM"?"default":"outline",onClick:()=>ie("AM"),className:"h-8 w-12 text-xs font-medium",children:"AM"}),e.jsx(y,{size:"sm",variant:V==="PM"?"default":"outline",onClick:()=>ie("PM"),className:"h-8 w-12 text-xs font-medium",children:"PM"})]})]}),m&&e.jsx("div",{className:"text-xs text-gray-500 text-center",children:a})]}),$?e.jsx("div",{className:"space-y-4",children:ae()}):e.jsxs("div",{className:"flex gap-2 justify-center items-start",children:[e.jsxs("div",{className:"flex-1 max-w-[80px]",children:[e.jsx("div",{className:"text-xs text-center text-gray-500 mb-2",children:"Hour"}),e.jsx("div",{ref:R,className:"h-40 overflow-y-scroll border rounded-md scrollbar-thin scrollbar-thumb-gray-300 scrollbar-track-gray-100",children:Te().map(r=>e.jsx("button",{"data-selected":me===r,onClick:()=>ue(r),className:d("w-full py-2 text-center transition-colors",me===r?"bg-blue-500 text-white font-medium":"hover:bg-gray-100 text-gray-700"),children:r.toString().padStart(2,"0")},r))})]}),e.jsxs("div",{className:"flex-1 max-w-[80px]",children:[e.jsx("div",{className:"text-xs text-center text-gray-500 mb-2",children:"Min"}),e.jsx("div",{ref:Y,className:"h-40 overflow-y-scroll border rounded-md scrollbar-thin scrollbar-thumb-gray-300 scrollbar-track-gray-100",children:ke().map(r=>e.jsx("button",{"data-selected":H===r,onClick:()=>ee(r),className:d("w-full py-2 text-center transition-colors",H===r?"bg-blue-500 text-white font-medium":"hover:bg-gray-100 text-gray-700"),children:r.toString().padStart(2,"0")},r))})]}),u&&e.jsxs("div",{className:"flex-1 max-w-[80px]",children:[e.jsx("div",{className:"text-xs text-center text-gray-500 mb-2",children:"Sec"}),e.jsx("div",{ref:X,className:"h-40 overflow-y-scroll border rounded-md scrollbar-thin scrollbar-thumb-gray-300 scrollbar-track-gray-100",children:pe().map(r=>e.jsx("button",{"data-selected":p===r,onClick:()=>le(r),className:d("w-full py-2 text-center transition-colors",p===r?"bg-blue-500 text-white font-medium":"hover:bg-gray-100 text-gray-700"),children:r.toString().padStart(2,"0")},r))})]})]}),e.jsxs("div",{className:"flex gap-2 justify-between pt-2 border-t",children:[e.jsx(y,{size:"sm",variant:"outline",onClick:he,children:"Now"}),e.jsx(y,{size:"sm",onClick:()=>s(t),children:"Done"})]})]})})]})},Be=w.forwardRef(({className:t,...s},a)=>e.jsx("div",{ref:a,className:d("rounded-lg border border-gray-200 bg-white text-gray-950 shadow-sm",t),...s}));Be.displayName="Card";const qe=w.forwardRef(({className:t,...s},a)=>e.jsx("div",{ref:a,className:d("flex flex-col space-y-1.5 p-6",t),...s}));qe.displayName="CardHeader";const Ue=w.forwardRef(({className:t,...s},a)=>e.jsx("h3",{ref:a,className:d("text-2xl font-semibold leading-none tracking-tight",t),...s}));Ue.displayName="CardTitle";const ht=w.forwardRef(({className:t,...s},a)=>e.jsx("p",{ref:a,className:d("text-sm text-gray-500",t),...s}));ht.displayName="CardDescription";const Je=w.forwardRef(({className:t,...s},a)=>e.jsx("div",{ref:a,className:d("p-6 pt-0",t),...s}));Je.displayName="CardContent";const mt=w.forwardRef(({className:t,...s},a)=>e.jsx("div",{ref:a,className:d("flex items-center p-6 pt-0",t),...s}));mt.displayName="CardFooter";const Q=w.forwardRef(({className:t,...s},a)=>e.jsx(st.Root,{ref:a,className:d("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",t),...s}));Q.displayName=st.Root.displayName;const xt=se.Root,ys=se.Portal,gt=w.forwardRef(({className:t,...s},a)=>e.jsx(se.Overlay,{ref:a,className:d("fixed inset-0 z-50 bg-black/50 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...s}));gt.displayName=se.Overlay.displayName;const pt=w.forwardRef(({className:t,children:s,...a},i)=>e.jsxs(ys,{children:[e.jsx(gt,{}),e.jsxs(se.Content,{ref:i,className:d("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border border-gray-200 bg-white p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] rounded-lg",t),...a,children:[s,e.jsxs(se.Close,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-white transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-gray-950 focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-gray-100",children:[e.jsx(v.X,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));pt.displayName=se.Content.displayName;const ft=({className:t,...s})=>e.jsx("div",{className:d("flex flex-col space-y-1.5 text-center sm:text-left",t),...s});ft.displayName="ModalHeader";const yt=w.forwardRef(({className:t,...s},a)=>e.jsx(se.Title,{ref:a,className:d("text-lg font-semibold leading-none tracking-tight",t),...s}));yt.displayName=se.Title.displayName;const bt=w.forwardRef(({className:t,...s},a)=>e.jsx(se.Description,{ref:a,className:d("text-sm text-gray-500",t),...s}));bt.displayName=se.Description.displayName;function bs({isOpen:t,onClose:s,title:a,description:i,children:m,className:b}){return e.jsx(xt,{open:t,onOpenChange:s,children:e.jsxs(pt,{className:b,children:[(a||i)&&e.jsxs(ft,{children:[a&&e.jsx(yt,{children:a}),i&&e.jsx(bt,{children:i})]}),m]})})}const Ye=["January","February","March","April","May","June","July","August","September","October","November","December"];function jt({onWeekChange:t,initialDate:s=new Date,className:a,compact:i=!1}){const[m,b]=w.useState(s),[u,D]=w.useState(!1),[C,F]=w.useState(!1),[$,f]=w.useState(!1),[N,P]=w.useState(s.getFullYear()),[I,A]=w.useState(s.getMonth()),[W,L]=w.useState(0),H=w.useRef(null),U=w.useRef(null),p=c=>{const l=[],T=new Date(c),n=T.getDay(),k=n===0?-6:1-n;T.setDate(T.getDate()+k);for(let S=0;S<7;S++){const R=new Date(T);R.setDate(T.getDate()+S),l.push(R)}return l},E=(c,l)=>{const T=new Date(c,l,1),n=new Date(c,l+1,0),k=new Date(T);k.setDate(T.getDate()-(T.getDay()+6)%7);const S=[],R=new Date(k);for(;R<=n||R.getMonth()===l;){const Y=new Date(R);if(Y.setDate(R.getDate()+6),S.push({start:new Date(R),end:new Date(Y)}),R.setDate(R.getDate()+7),S.length>6)break}return S},V=(c,l)=>{const T=c.toLocaleDateString("en-US",{month:"short"}),n=l.toLocaleDateString("en-US",{month:"short"});return T===n?`${T} ${c.getDate()}-${l.getDate()}`:`${T} ${c.getDate()}-${n} ${l.getDate()}`},_=p(m),g=Array.from({length:10},(c,l)=>N-5+l),h=c=>{const l=new Date(m);l.setDate(m.getDate()+(c==="next"?7:-7)),b(l),P(l.getFullYear()),A(l.getMonth()),t?.(l)},o=(c,l)=>{L(l),D(!1),b(c.start),t?.(c.start)};return w.useEffect(()=>{const c=l=>{H.current&&!H.current.contains(l.target)&&U.current&&!U.current.contains(l.target)&&(D(!1),F(!1),f(!1))};return u&&document.addEventListener("mousedown",c),()=>{document.removeEventListener("mousedown",c)}},[u]),w.useEffect(()=>{const l=E(N,I).findIndex(T=>m>=T.start&&m<=T.end);l!==-1&&L(l)},[m,N,I]),e.jsxs("div",{className:d("flex items-center gap-3",a),children:[e.jsx(y,{variant:"outline",size:"sm",onClick:()=>h("prev"),className:d("rounded-lg border-gray-200 hover:border-gray-300 hover:bg-gray-50",i?"h-8 w-8 p-0":"h-9 w-9 p-0"),children:e.jsx(v.ChevronLeft,{className:d(i?"h-3 w-3":"h-4 w-4","text-gray-600")})}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{ref:U,className:d("flex items-center gap-2 bg-white rounded-lg border border-gray-200 shadow-sm cursor-pointer hover:bg-gray-50 transition-colors",i?"px-2 py-1":"px-3 py-2"),onClick:()=>D(!u),children:[e.jsx(v.Calendar,{className:d(i?"h-3 w-3":"h-4 w-4","text-gray-500")}),e.jsx("span",{className:d(i?"text-xs":"text-sm","font-medium text-gray-700"),children:_.length>=7&&_[0]&&_[6]&&`${_[0].getDate()}-${_[6].getDate()} ${Ye[_[0].getMonth()]} ${_[0].getFullYear()}`}),e.jsx(v.ChevronRight,{className:d(i?"h-2 w-2":"h-3 w-3","text-gray-400 transition-transform",u&&"rotate-90")})]}),u&&e.jsxs("div",{ref:H,className:"absolute top-full right-0 mt-2 bg-white border border-gray-200 rounded-lg shadow-lg p-4 z-50 w-80 sm:w-96",children:[!C&&!$&&e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>{const c=I===0?11:I-1,l=I===0?N-1:N;A(c),P(l)},className:"h-8 w-8 p-0",children:e.jsx(v.ChevronLeft,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{className:"text-lg font-semibold text-gray-800 hover:text-blue-600 transition-colors",onClick:()=>F(!C),children:Ye[I]}),e.jsx("button",{className:"text-lg font-semibold text-gray-800 hover:text-blue-600 transition-colors",onClick:()=>f(!$),children:N})]}),e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>{const c=I===11?0:I+1,l=I===11?N+1:N;A(c),P(l)},className:"h-8 w-8 p-0",children:e.jsx(v.ChevronRight,{className:"h-4 w-4"})})]}),C?e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>F(!1),className:"h-9 px-3 text-sm font-medium",children:"← Back"}),e.jsx("span",{className:"text-lg font-semibold",children:N})]}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:Ye.map((c,l)=>e.jsx("button",{className:d("h-11 w-full text-sm font-medium rounded-xl transition-all",I===l?"bg-blue-500 text-white":"text-gray-600 hover:bg-gray-50"),onClick:()=>{A(l),F(!1)},children:c},c))})]}):$?e.jsxs("div",{className:"p-6",children:[e.jsx("div",{className:"flex items-center justify-start mb-4",children:e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>f(!1),className:"h-9 px-3 text-sm font-medium",children:"← Back"})}),e.jsx("div",{className:"grid grid-cols-4 gap-2 max-h-64 overflow-y-auto",children:g.map(c=>e.jsx("button",{className:d("h-11 w-full text-sm font-medium rounded-xl transition-all",N===c?"bg-blue-500 text-white":"text-gray-600 hover:bg-gray-50"),onClick:()=>{P(c),f(!1),F(!0)},children:c},c))})]}):e.jsx("div",{className:"grid grid-cols-2 gap-2 max-h-64 overflow-y-auto",children:E(N,I).map((c,l)=>{const T=new Date>=c.start&&new Date<=c.end,n=W===l;return e.jsx("button",{className:d("w-full p-3 text-left rounded-lg border transition-all",n?"bg-blue-500 text-white border-blue-500":T?"bg-white text-blue-600 border-blue-500":"bg-white border-gray-200 text-gray-700 hover:border-blue-300"),onClick:()=>o(c,l),children:e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("div",{className:d("font-medium text-sm",n?"text-white":"text-gray-800"),children:["Week ",l+1]}),e.jsx("div",{className:d("text-xs",n?"text-blue-100":"text-gray-500"),children:V(c.start,c.end)})]})},l)})}),e.jsx("div",{className:"flex gap-2 pt-3 border-t border-gray-100 mt-3",children:e.jsx(y,{size:"sm",variant:"outline",className:"flex-1",onClick:()=>{const c=new Date;b(c),D(!1),F(!1),f(!1),t?.(c)},children:"This Week"})})]})]}),e.jsx(y,{variant:"outline",size:"sm",onClick:()=>h("next"),className:d("rounded-lg border-gray-200 hover:border-gray-300 hover:bg-gray-50",i?"h-8 w-8 p-0":"h-9 w-9 p-0"),children:e.jsx(v.ChevronRight,{className:d(i?"h-3 w-3":"h-4 w-4","text-gray-600")})})]})}const _e={calculateWeekDates:t=>{const s=[],a=new Date(t),i=a.getDay(),m=i===0?-6:1-i;a.setDate(a.getDate()+m);for(let b=0;b<7;b++){const u=new Date(a);u.setDate(a.getDate()+b),s.push(u)}return s},formatDateDisplay:t=>t.toLocaleDateString("en-US",{month:"short",day:"numeric"}),getWeekNumber:t=>{const s=new Date(t.getFullYear(),0,1),a=(t.getTime()-s.getTime())/864e5;return Math.ceil((a+s.getDay()+1)/7)},getWeekOfMonth:t=>{const a=new Date(t.getFullYear(),t.getMonth(),1).getDay(),i=t.getDate()+a-1;return Math.ceil(i/7)}},js=["08:00","09:00","10:00","11:00","12:00","13:00","14:00","15:00","16:00"],vs=["Monday","Tuesday","Wednesday","Thursday","Friday"],ws=[{name:"Blue",value:"bg-blue-500"},{name:"Green",value:"bg-emerald-500"},{name:"Purple",value:"bg-purple-500"},{name:"Orange",value:"bg-orange-500"},{name:"Pink",value:"bg-pink-500"}];function Ns({title:t="Weekly Schedule",subtitle:s,events:a,onEventAdd:i,onEventUpdate:m,onEventDelete:b,className:u,timeSlots:D=js,daysOfWeek:C=vs,showAddButton:F=!0,eventColors:$=ws,customFields:f=[],showWeekNavigation:N=!1,showHalfHourLines:P=!0,showCurrentTimeIndicator:I=!0,slotHeight:A=85}){const[W,L]=z.useState(!1),[H,U]=z.useState(null),[p,E]=z.useState({title:"",day:"",startTime:"",endTime:"",color:"bg-blue-500",description:"",recurrenceType:"none",specificDate:"",scheduleMode:"day"}),[V,_]=z.useState(new Date),g=N?_e.calculateWeekDates(V):[],h=(n,k,S)=>{if(S){U(S);const R={title:S.title,day:S.day,startTime:S.startTime,endTime:S.endTime,color:S.color,description:S.description||"",recurrenceType:S.recurrenceType||"none",specificDate:S.specificDate||"",scheduleMode:S.specificDate?"date":"day"};f.forEach(Y=>{const X=S[Y.key];R[Y.key]=X instanceof Date?X.toISOString():X||(Y.type==="number"?0:"")}),E(R)}else{U(null);const R={title:"",day:n||"",startTime:k||"",endTime:"",color:"bg-blue-500",description:"",recurrenceType:"none",specificDate:"",scheduleMode:"day"};f.forEach(Y=>{R[Y.key]=Y.type==="number"?0:""}),E(R)}L(!0)},o=()=>{if(!p.title||!p.day||!p.startTime||!p.endTime)return;const n={...p,id:H?.id||Date.now().toString()};H?m?.(n):i?.(p),L(!1)},c=()=>{H&&(b?.(H.id),L(!1))},l=(n,k)=>a.filter(S=>{if(S.day!==n)return!1;const R=parseInt(S.startTime.replace(":","")),Y=parseInt(k.replace(":",""));return R===Y}),T=n=>{const[k,S]=n.startTime.split(":").map(Number),[R,Y]=n.endTime.split(":").map(Number),X=k*60+S,ee=(R*60+Y-X)/60,le=Math.max(4,A*.1);return ee*A-le};return e.jsxs(e.Fragment,{children:[e.jsxs(Be,{className:d("w-full",u),children:[e.jsx(qe,{className:"pb-6 bg-gradient-to-r from-slate-50 to-gray-50 border-b border-gray-100",children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx(Ue,{className:"text-2xl",children:t}),s&&e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:s})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[N&&e.jsx(jt,{onWeekChange:_,initialDate:V}),F&&e.jsxs(y,{onClick:()=>h(),className:"gap-2",children:[e.jsx(v.Plus,{className:"h-4 w-4"}),"Add Event"]})]})]})}),e.jsx(Je,{className:"p-0",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("div",{className:"min-w-[800px]",children:[e.jsxs("div",{className:"grid border-b border-gray-200",style:{gridTemplateColumns:`80px repeat(${C.length}, 1fr)`},children:[e.jsx("div",{className:"p-3 bg-gray-50 border-r border-gray-200",children:e.jsx("span",{className:"text-xs font-medium text-gray-500",children:"Time"})}),C.map((n,k)=>{const S=new Date,R=N&&g[k],Y=R&&R.getDate()===S.getDate()&&R.getMonth()===S.getMonth()&&R.getFullYear()===S.getFullYear();return e.jsxs("div",{className:"p-4 text-center border-r border-gray-200 last:border-r-0 bg-gray-50 hover:bg-white/50 transition-colors",children:[e.jsx("div",{className:`font-semibold text-sm ${Y?"text-blue-600":"text-gray-800"}`,children:n}),N&&R&&e.jsx("div",{className:`text-xs mt-1 font-medium ${Y?"text-blue-600 font-bold":"text-gray-500"}`,children:_e.formatDateDisplay(R)})]},n)})]}),D.map(n=>{const k=new Date,S=k.getHours(),R=k.getMinutes(),[Y,X]=n.split(":"),oe=parseInt(X||"0"),ee=parseInt(Y||"0")*60+oe,le=ee+60,ie=S*60+R,he=ie>=ee&&ie<le,ke=(ie-ee)/60*A;return e.jsxs("div",{className:"grid border-b border-gray-100 last:border-b-0",style:{gridTemplateColumns:`80px repeat(${C.length}, 1fr)`},children:[e.jsx("div",{className:"p-2 bg-gray-50/50 border-r border-gray-200",children:e.jsx("span",{className:"text-xs text-gray-600",children:n})}),C.map((pe,me)=>{const ae=l(pe,n),r=new Date,j=N&&g[me],G=j?j.getDate()===r.getDate()&&j.getMonth()===r.getMonth()&&j.getFullYear()===r.getFullYear():!1;return e.jsxs("div",{className:"relative border-r border-gray-200 last:border-r-0 hover:bg-blue-50/30 cursor-pointer transition-colors",style:{minHeight:`${A}px`},onClick:()=>!ae.length&&h(pe,n),children:[P&&e.jsx("div",{className:"absolute top-1/2 left-0 right-0 h-px bg-gray-200/60 z-[5]"}),ae.map(M=>{const re=T(M),Z=re<40;return e.jsx("div",{className:d("absolute rounded-md text-white cursor-pointer hover:scale-[1.02] transition-transform overflow-visible",M.color,Z?"inset-x-1 py-0.5 px-1":"inset-1 p-2"),style:{height:`${re}px`,zIndex:10,minHeight:Z?"auto":void 0},onClick:K=>{K.stopPropagation(),h(void 0,void 0,M)},children:Z?e.jsxs("div",{className:"flex items-center justify-between gap-1",children:[e.jsx("div",{className:"font-semibold truncate text-[10px] leading-tight flex-1",children:M.title}),e.jsxs("div",{className:"text-[9px] opacity-80 whitespace-nowrap",children:[M.startTime,"-",M.endTime]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-xs font-semibold truncate",children:M.title}),f.filter(K=>K.showInCard&&M[K.key]).map(K=>e.jsxs("div",{className:"text-xs opacity-90 flex items-center gap-1 mt-1",children:[K.icon,e.jsx("span",{className:"truncate",children:M[K.key]instanceof Date?M[K.key].toLocaleString():String(M[K.key]||"")})]},K.key)),e.jsx("div",{className:"text-xs opacity-80 mt-1",children:e.jsxs("span",{children:[M.startTime,"-",M.endTime]})})]})},M.id)}),I&&G&&he&&e.jsxs("div",{className:"absolute left-0 right-0 flex items-center z-20",style:{top:`${ke-8}px`},children:[e.jsx("div",{className:"h-[3px] bg-red-500 absolute -left-14 right-0"}),e.jsxs("div",{className:"bg-red-500 text-white text-xs px-2 py-0.5 rounded font-bold whitespace-nowrap relative z-30 -ml-14",children:[k.getHours(),":",k.getMinutes().toString().padStart(2,"0")]})]}),!ae.length&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center opacity-0 hover:opacity-100 transition-opacity",children:e.jsx(v.Plus,{className:"h-5 w-5 text-gray-400"})})]},`${pe}-${n}`)})]},n)})]})})})]}),e.jsx(bs,{isOpen:W,onClose:()=>L(!1),title:H?"Edit Event":"Add New Event",children:e.jsxs("div",{className:"space-y-4 p-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Q,{className:"text-sm font-medium",children:"Schedule Type"}),e.jsxs(je,{value:String(p.scheduleMode),onValueChange:n=>E({...p,scheduleMode:n}),children:[e.jsx(xe,{children:e.jsx(ve,{placeholder:"Select schedule type"})}),e.jsxs(ge,{children:[e.jsx(de,{value:"day",children:"By Day (Monday, Tuesday, etc.)"}),e.jsx(de,{value:"date",children:"By Date (Specific date)"})]})]}),e.jsx("p",{className:"text-xs text-gray-500",children:p.scheduleMode==="day"?"Schedule by day of the week (e.g., every Monday)":"Schedule by specific date (e.g., January 15, 2025)"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Q,{htmlFor:"title",children:"Title *"}),e.jsx(ce,{id:"title",value:String(p.title),onChange:n=>E({...p,title:n.target.value}),placeholder:"Event title"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[p.scheduleMode==="day"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(Q,{children:"Day *"}),e.jsxs(je,{value:String(p.day),onValueChange:n=>E({...p,day:n}),children:[e.jsx(xe,{children:e.jsx(ve,{placeholder:"Select day"})}),e.jsx(ge,{children:C.map(n=>e.jsx(de,{value:n,children:n},n))})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(Q,{htmlFor:"specificDate",children:"Date *"}),e.jsx(ce,{id:"specificDate",type:"date",value:String(p.specificDate),onChange:n=>E({...p,specificDate:n.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Q,{htmlFor:"startTime",children:"Start Time *"}),e.jsx(ce,{id:"startTime",type:"time",value:String(p.startTime),onChange:n=>E({...p,startTime:n.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Q,{htmlFor:"endTime",children:"End Time *"}),e.jsx(ce,{id:"endTime",type:"time",value:String(p.endTime),onChange:n=>E({...p,endTime:n.target.value})})]})]}),f.length>0&&e.jsx("div",{className:"grid grid-cols-2 gap-4",children:f.map(n=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Q,{htmlFor:n.key,children:[n.label," ",n.required&&"*"]}),n.type==="select"?e.jsxs(je,{value:String(p[n.key]||""),onValueChange:k=>E({...p,[n.key]:k}),children:[e.jsx(xe,{children:e.jsx(ve,{placeholder:n.placeholder||`Select ${n.label}`})}),e.jsx(ge,{children:n.options?.map(k=>e.jsx(de,{value:k.value,children:k.label},k.value))})]}):e.jsx(ce,{id:n.key,type:n.type,value:n.type==="number"?Number(p[n.key]||0):String(p[n.key]||""),onChange:k=>E({...p,[n.key]:n.type==="number"?parseInt(k.target.value)||0:k.target.value}),placeholder:n.placeholder})]},n.key))}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"isRecurring",checked:p.recurrenceType!=="none",onChange:n=>{n.target.checked?E({...p,recurrenceType:p.scheduleMode==="day"?"weekly":"monthly"}):E({...p,recurrenceType:"none"})},className:"w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 focus:ring-2"}),e.jsx(Q,{htmlFor:"isRecurring",className:"text-sm font-medium text-gray-700 cursor-pointer",children:p.scheduleMode==="day"?"Repeat every week on this day":"Repeat every month on this date"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Q,{children:"Color"}),e.jsxs(je,{value:String(p.color),onValueChange:n=>E({...p,color:n}),children:[e.jsx(xe,{children:e.jsx(ve,{})}),e.jsx(ge,{children:$.map(n=>e.jsx(de,{value:n.value,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:d("w-4 h-4 rounded",n.value)}),n.name]})},n.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Q,{htmlFor:"description",children:"Description"}),e.jsx(ce,{id:"description",value:String(p.description||""),onChange:n=>E({...p,description:n.target.value}),placeholder:"Optional description"})]}),e.jsxs("div",{className:"flex gap-2 pt-4",children:[H&&e.jsxs(y,{variant:"destructive",onClick:c,className:"gap-2",children:[e.jsx(v.Trash2,{className:"h-4 w-4"}),"Delete"]}),e.jsx("div",{className:"flex-1"}),e.jsx(y,{variant:"outline",onClick:()=>L(!1),children:"Cancel"}),e.jsxs(y,{onClick:o,children:[H?"Update":"Add"," Event"]})]})]})})]})}const Ge=[{label:"UTC",offset:0},{label:"EST",offset:-5},{label:"CST",offset:-6},{label:"MST",offset:-7},{label:"PST",offset:-8},{label:"GMT",offset:0},{label:"CET",offset:1},{label:"EET",offset:2},{label:"IST",offset:5.5},{label:"CST (China)",offset:8},{label:"JST",offset:9},{label:"AEST",offset:10},{label:"NZST",offset:12},{label:"HST",offset:-10},{label:"AKST",offset:-9},{label:"Asia/Bangkok",offset:7}],Ss=(t,s,a)=>{const i=Ge.find(u=>u.label===s)?.offset||0,m=Ge.find(u=>u.label===a)?.offset||0,b=new Date(t);return b.setHours(b.getHours()+(m-i)),b},Ds=(t,s,a="24h",i=!1)=>{const m=a==="12h"?t.getHours()%12||12:t.getHours(),b=t.getMinutes().toString().padStart(2,"0"),u=t.getSeconds().toString().padStart(2,"0"),D=t.getHours()>=12?"PM":"AM";let C=`${m.toString().padStart(2,"0")}:${b}`;return i&&(C+=`:${u}`),a==="12h"&&(C+=` ${D}`),C+=` ${s}`,C};exports.Button=y;exports.Calendar=xs;exports.Card=Be;exports.CardContent=Je;exports.CardDescription=ht;exports.CardFooter=mt;exports.CardHeader=qe;exports.CardTitle=Ue;exports.Checkbox=Re;exports.DataGrid=Zt;exports.DataGridColumnHeader=ss;exports.DataGridPagination=ts;exports.DataGridTable=Qt;exports.DataGridTableRowSelect=rs;exports.DataGridTableRowSelectAll=as;exports.DataTable=Xt;exports.DatePicker=ps;exports.DropdownMenu=At;exports.DropdownMenuCheckboxItem=_t;exports.DropdownMenuContent=$t;exports.DropdownMenuGroup=Yt;exports.DropdownMenuItem=Lt;exports.DropdownMenuLabel=Vt;exports.DropdownMenuPortal=Et;exports.DropdownMenuRadioGroup=Gt;exports.DropdownMenuRadioItem=Wt;exports.DropdownMenuSeparator=Bt;exports.DropdownMenuShortcut=qt;exports.DropdownMenuSub=Ut;exports.DropdownMenuSubContent=Kt;exports.DropdownMenuSubTrigger=Jt;exports.DropdownMenuTrigger=Ot;exports.Input=ce;exports.Label=Q;exports.Modal=xt;exports.Popover=We;exports.PopoverAnchor=gs;exports.PopoverContent=Fe;exports.PopoverTrigger=Ve;exports.Schedule=Ns;exports.Select=je;exports.SelectContent=ge;exports.SelectGroup=es;exports.SelectItem=de;exports.SelectLabel=it;exports.SelectSeparator=ct;exports.SelectTrigger=xe;exports.SelectValue=ve;exports.Separator=at;exports.SortableHeader=cs;exports.TIMEZONES=Ge;exports.Table=Pe;exports.TableBody=ze;exports.TableCaption=Ft;exports.TableCell=we;exports.TableContent=ls;exports.TableFooter=Ht;exports.TableHead=He;exports.TableHeader=Ie;exports.TableNavigator=is;exports.TableRoot=ns;exports.TableRow=ne;exports.TableWrapper=os;exports.TimePicker=fs;exports.WeekNavigator=jt;exports.cn=d;exports.convertTimezone=Ss;exports.formatTimeWithTimezone=Ds;exports.useDataGrid=Ce;exports.weekNavigatorUtils=_e;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const wt=require("clsx"),Nt=require("tailwind-merge"),e=require("react/jsx-runtime"),P=require("react"),St=require("@radix-ui/react-slot"),Dt=require("@radix-ui/react-checkbox"),M=require("lucide-react"),Mt=require("@radix-ui/react-dropdown-menu"),Ct=require("@radix-ui/react-select"),q=require("date-fns"),kt=require("@radix-ui/react-popover"),Tt=require("@radix-ui/react-label"),Rt=require("@radix-ui/react-dialog");function ve(t){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const c=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(s,a,c.get?c:{enumerable:!0,get:()=>t[a]})}}return s.default=t,Object.freeze(s)}const w=ve(P),Ee=ve(Dt),U=ve(Mt),V=ve(Ct),Se=ve(kt),tt=ve(Tt),se=ve(Rt);function u(...t){return Nt.twMerge(wt.clsx(t))}const y=w.forwardRef(({className:t,variant:s="default",size:a="default",asChild:c=!1,...g},N)=>{const h=c?St.Slot:"button";return e.jsx(h,{className:u("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2","disabled:pointer-events-none disabled:opacity-50",s==="default"&&"bg-blue-600 text-white hover:bg-blue-700 active:bg-blue-800 active:scale-95",s==="destructive"&&"bg-red-600 text-white hover:bg-red-700 active:bg-red-800 active:scale-95",s==="outline"&&"border border-gray-300 bg-white text-gray-900 hover:bg-gray-50 active:bg-gray-100 active:scale-95",s==="secondary"&&"bg-gray-200 text-gray-900 hover:bg-gray-300 active:bg-gray-400 active:scale-95",s==="ghost"&&"bg-transparent text-gray-900 hover:bg-gray-100 active:bg-gray-200 active:scale-95",s==="link"&&"bg-transparent text-blue-600 underline-offset-4 hover:text-blue-700 hover:underline active:text-blue-800",a==="default"&&"h-9 px-4 py-2",a==="sm"&&"h-8 px-3 text-xs gap-1.5",a==="lg"&&"h-10 px-6",a==="icon"&&"h-9 w-9 p-0",a==="icon-sm"&&"h-8 w-8 p-0",a==="icon-lg"&&"h-10 w-10 p-0",t),ref:N,...g})});y.displayName="Button";const Re=w.forwardRef(({className:t,...s},a)=>e.jsx(Ee.Root,{ref:a,className:u("peer h-4 w-4 shrink-0 rounded border border-gray-200 bg-white ring-offset-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-gray-400 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-gray-900 data-[state=checked]:border-gray-900 data-[state=checked]:text-white transition-colors",t),...s,children:e.jsx(Ee.Indicator,{className:u("flex items-center justify-center text-current"),children:e.jsx(M.Check,{className:"h-3.5 w-3.5 stroke-[2.5]"})})}));Re.displayName=Ee.Root.displayName;const ie=w.forwardRef(({className:t,type:s,...a},c)=>e.jsx("input",{type:s,className:u("flex h-10 w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-sm file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-gray-400 focus:outline-none focus:border-gray-500 hover:border-gray-400 disabled:cursor-not-allowed disabled:opacity-50 transition-colors",t),ref:c,...a}));ie.displayName="Input";const st=w.forwardRef(({className:t,orientation:s="horizontal",decorative:a=!0,...c},g)=>e.jsx("div",{ref:g,role:a?"none":"separator","aria-orientation":s,className:u("shrink-0 bg-gray-200",s==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",t),...c}));st.displayName="Separator";const at=w.createContext({variant:"default"});function Ye({className:t,variant:s="default",...a}){return e.jsx(at.Provider,{value:{variant:s},children:e.jsx("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:e.jsx("table",{"data-slot":"table",className:u("w-full caption-bottom text-sm",t),...a})})})}function _e({className:t,...s}){return e.jsx("thead",{"data-slot":"table-header",className:u("bg-gray-50 [&_tr]:border-b [&_tr]:border-gray-200",t),...s})}function Le({className:t,...s}){return e.jsx("tbody",{"data-slot":"table-body",className:u("[&_tr:last-child]:border-b-0",t),...s})}function It({className:t,...s}){return e.jsx("tfoot",{"data-slot":"table-footer",className:u("bg-muted/50 border-t font-medium [&>tr]:last:border-b-0",t),...s})}function be({className:t,...s}){const{variant:a}=w.useContext(at);return e.jsx("tr",{"data-slot":"table-row",className:u("hover:bg-gray-50 data-[state=selected]:bg-gray-50 transition-colors border-b border-gray-200",a==="clean"&&"border-b-0",t),...s})}function Ge({className:t,...s}){return e.jsx("th",{"data-slot":"table-head",className:u("text-foreground h-auto px-3 py-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",t),...s})}function ke({className:t,...s}){return e.jsx("td",{"data-slot":"table-cell",className:u("px-3 py-2 text-left align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",t),...s})}function zt({className:t,...s}){return e.jsx("caption",{"data-slot":"table-caption",className:u("text-muted-foreground mt-4 text-sm",t),...s})}function Pt({...t}){return e.jsx(U.Root,{"data-slot":"dropdown-menu",...t})}function Ht({...t}){return e.jsx(U.Portal,{"data-slot":"dropdown-menu-portal",...t})}function Ft({...t}){return e.jsx(U.Trigger,{"data-slot":"dropdown-menu-trigger",suppressHydrationWarning:!0,...t})}function At({className:t,sideOffset:s=4,...a}){return e.jsx(U.Portal,{children:e.jsx(U.Content,{"data-slot":"dropdown-menu-content",sideOffset:s,className:u("bg-white text-gray-900 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border border-gray-200 p-2 shadow-lg",t),...a})})}function Et({...t}){return e.jsx(U.Group,{"data-slot":"dropdown-menu-group",...t})}function Ot({className:t,inset:s,variant:a="default",...c}){return e.jsx(U.Item,{"data-slot":"dropdown-menu-item","data-inset":s,"data-variant":a,className:u("focus:bg-gray-100 focus:text-gray-900 data-[variant=destructive]:text-red-600 data-[variant=destructive]:focus:bg-red-50 data-[variant=destructive]:focus:text-red-700 [&_svg:not([class*='text-'])]:text-gray-500 relative flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none select-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...c})}function $t({className:t,children:s,checked:a,...c}){return e.jsxs(U.CheckboxItem,{"data-slot":"dropdown-menu-checkbox-item",className:u("focus:bg-gray-100 focus:text-gray-900 relative flex cursor-pointer items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-none select-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),checked:a,...c,children:[e.jsx("span",{className:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center",children:e.jsx(U.ItemIndicator,{children:e.jsx(M.CheckIcon,{className:"size-4 text-blue-600"})})}),s]})}function Yt({...t}){return e.jsx(U.RadioGroup,{"data-slot":"dropdown-menu-radio-group",...t})}function _t({className:t,children:s,...a}){return e.jsxs(U.RadioItem,{"data-slot":"dropdown-menu-radio-item",className:u("focus:bg-gray-100 focus:text-gray-900 relative flex cursor-pointer items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-none select-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...a,children:[e.jsx("span",{className:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center",children:e.jsx(U.ItemIndicator,{children:e.jsx(M.CircleIcon,{className:"size-2 fill-blue-600"})})}),s]})}function Lt({className:t,inset:s,...a}){return e.jsx(U.Label,{"data-slot":"dropdown-menu-label","data-inset":s,className:u("px-2 py-1.5 text-sm font-semibold text-gray-900 data-[inset]:pl-8",t),...a})}function Gt({className:t,...s}){return e.jsx(U.Separator,{"data-slot":"dropdown-menu-separator",className:u("bg-gray-100 my-1 h-px",t),...s})}function Wt({className:t,...s}){return e.jsx("span",{"data-slot":"dropdown-menu-shortcut",className:u("text-gray-500 ml-auto text-xs tracking-widest",t),...s})}function Bt({...t}){return e.jsx(U.Sub,{"data-slot":"dropdown-menu-sub",...t})}function Vt({className:t,inset:s,children:a,...c}){return e.jsxs(U.SubTrigger,{"data-slot":"dropdown-menu-sub-trigger","data-inset":s,className:u("focus:bg-gray-100 focus:text-gray-900 data-[state=open]:bg-gray-100 data-[state=open]:text-gray-900 [&_svg:not([class*='text-'])]:text-gray-500 flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none select-none transition-colors data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...c,children:[a,e.jsx(M.ChevronRightIcon,{className:"ml-auto size-4"})]})}function qt({className:t,...s}){return e.jsx(U.SubContent,{"data-slot":"dropdown-menu-sub-content",className:u("bg-white text-gray-900 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-md border border-gray-200 p-2 shadow-lg",t),...s})}function Jt({data:t=[],columns:s,searchPlaceholder:a="Search...",onRowClick:c,className:g="",showPagination:N=!0,showSearch:h=!0,pageSize:T=10,renderToolbar:I,variant:O="default"}){const[Y,f]=P.useState(1),[v]=P.useState(T),[R,z]=P.useState(""),[F,W]=P.useState(null),[_,H]=P.useState("asc"),J=P.useMemo(()=>{if(!h||!R.trim())return t;const x=R.toLowerCase();return t.filter(d=>s.some(o=>(o.accessor?o.accessor(d):d[o.key])?.toString().toLowerCase().includes(x)))},[t,R,h,s]),p=P.useMemo(()=>F?[...J].sort((x,d)=>{const o=s.find(n=>n.key===F);if(!o)return 0;const i=o.accessor?o.accessor(x):x[o.key],l=o.accessor?o.accessor(d):d[o.key];if(i===l)return 0;if(i==null)return 1;if(l==null)return-1;const C=i<l?-1:1;return _==="asc"?C:-C}):J,[J,F,_,s]),A=P.useMemo(()=>{if(!N)return p;const x=(Y-1)*v;return p.slice(x,x+v)},[p,Y,v,N]);P.useEffect(()=>f(1),[R]);const B=x=>{F===x?H(_==="asc"?"desc":"asc"):(W(x),H("asc"))},L=(x,d,o)=>{const i=d.accessor?d.accessor(x):x[d.key];return d.cell?d.cell(i,x,o):i};return e.jsxs("div",{className:u("w-full space-y-4",g),children:[(h||I)&&e.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4",children:[h&&e.jsxs("div",{className:"relative w-full sm:w-auto",children:[e.jsx(M.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400"}),e.jsx(ie,{placeholder:a,value:R,onChange:x=>z(x.target.value),className:"pl-10 w-full sm:w-[300px] bg-gray-50 border-gray-300"})]}),I&&e.jsx("div",{className:"w-full sm:w-auto",children:I()})]}),e.jsx("div",{className:"border border-gray-200 rounded-lg overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Ye,{variant:O,children:[e.jsx(_e,{children:e.jsx(be,{children:s.map(x=>e.jsx(Ge,{className:"h-10 px-0 py-0",style:{width:x.width},children:x.align==="center"||!x.align&&typeof x.header!="string"?e.jsx("div",{className:"h-10 flex items-center justify-center",children:typeof x.header!="string"?x.header:e.jsx("span",{className:"text-xs font-normal text-gray-500 uppercase tracking-widest",children:x.header})}):e.jsx("div",{className:"h-10 flex items-center text-xs font-normal text-gray-500 uppercase tracking-widest",children:typeof x.header!="string"?e.jsx("div",{children:x.header}):x.sortable!==!1?e.jsxs(y,{variant:"ghost",className:"h-auto px-3 py-1.5 font-normal hover:bg-transparent hover:text-gray-900",onClick:()=>B(x.key),children:[x.header,F===x.key&&_==="desc"?e.jsx(M.ChevronDown,{className:"h-4 w-4"}):F===x.key&&_==="asc"?e.jsx(M.ChevronUp,{className:"h-4 w-4"}):e.jsx(M.ChevronsUpDown,{className:"h-4 w-4"})]}):e.jsx("span",{className:"px-3",children:x.header})})},x.key))})}),e.jsx(Le,{children:A.length===0?e.jsx(be,{children:e.jsx(ke,{colSpan:s.length,className:"text-center py-8 text-gray-500",children:"No results found."})}):A.map((x,d)=>e.jsx(be,{className:"hover:bg-gray-50 cursor-pointer",onClick:()=>c?.(x),children:s.map(o=>{const i=o.align==="center"||!o.align&&typeof o.header!="string";return e.jsx(ke,{className:i?"px-0 py-4":"px-3 py-4",style:{width:o.width},children:i?e.jsx("div",{className:"flex items-center justify-center h-full",children:L(x,o,d)}):L(x,o,d)},o.key)})},d))})]})})}),N&&e.jsxs("div",{className:"flex items-center justify-between px-2 py-4",children:[e.jsxs("div",{className:"text-sm text-gray-600",children:["Showing ",A.length," of ",p.length," row(s)"]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"text-sm text-gray-700",children:["Page ",Y," of ",Math.ceil(p.length/v)]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(y,{variant:"outline",size:"sm",onClick:()=>f(x=>Math.max(1,x-1)),disabled:Y===1,className:"h-8 w-8 p-0",children:e.jsx(M.ChevronLeft,{className:"h-4 w-4"})}),e.jsx(y,{variant:"outline",size:"sm",onClick:()=>f(x=>Math.min(Math.ceil(p.length/v),x+1)),disabled:Y===Math.ceil(p.length/v),className:"h-8 w-8 p-0",children:e.jsx(M.ChevronRight,{className:"h-4 w-4"})})]})]})]})]})}const rt=P.createContext(null);function De(){const t=P.useContext(rt);if(!t)throw new Error("useDataGrid must be used within DataGrid");return t}function Ut({columns:t,data:s,getRowId:a=h=>h.id||String(Math.random()),onRowClick:c,children:g,recordCount:N}){const[h,T]=P.useState({pageIndex:0,pageSize:5}),[I,O]=P.useState([]),[Y,f]=P.useState(new Set),v=P.useMemo(()=>I.length===0?s:[...s].sort((i,l)=>{for(const C of I){const n=t.find($=>$.id===C.id);if(!n?.accessorKey)continue;const D=i[n.accessorKey],j=l[n.accessorKey];if(D===j)continue;const k=D<j?-1:1;return C.desc?-k:k}return 0}),[s,I,t]),R=P.useMemo(()=>{const o=h.pageIndex*h.pageSize,i=o+h.pageSize;return v.slice(o,i)},[v,h]),z=Math.ceil(v.length/h.pageSize),F=z,W=h.pageIndex>0,_=h.pageIndex<z-1,H=()=>T(o=>({...o,pageIndex:o.pageIndex-1})),J=()=>{T(o=>({...o,pageIndex:Math.min(o.pageIndex+1,F-1)}))},p=o=>{T(()=>({pageIndex:0,pageSize:o}))},A=o=>{T(i=>({...i,pageIndex:Math.max(0,Math.min(o,F-1))}))},B=o=>{f(i=>{const l=new Set(i);return l.has(o)?l.delete(o):l.add(o),l})},L=()=>{Y.size===R.length?f(new Set):f(new Set(R.map(o=>a(o))))},x=R.length>0&&Y.size===R.length,d={columns:t,data:s,getRowId:a,onRowClick:c,pagination:h,setPagination:T,canPreviousPage:W,canNextPage:_,previousPage:H,nextPage:J,setPageSize:p,goToPage:A,pageCount:F,sorting:I,setSorting:O,selectedRows:Y,toggleRow:B,toggleAllRows:L,isAllRowsSelected:x,paginatedData:R,sortedData:v,totalPages:z,recordCount:N??s.length};return e.jsx(rt.Provider,{value:d,children:g})}function Kt(){const{columns:t,paginatedData:s,getRowId:a,onRowClick:c}=De();return e.jsx("div",{className:"border border-gray-200 rounded-lg overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Ye,{children:[e.jsx(_e,{children:e.jsx(be,{children:t.map(g=>e.jsx(Ge,{className:"h-10 px-0 py-0",style:{width:g.size?`${g.size}px`:void 0},children:g.align==="center"?e.jsx("div",{className:"h-10 flex items-center justify-center",children:typeof g.header!="string"?g.header:e.jsx("span",{className:"text-xs font-normal text-gray-500 uppercase tracking-widest",children:g.header})}):e.jsx("div",{className:"h-10 flex items-center text-xs font-normal text-gray-500 uppercase tracking-widest",children:typeof g.header!="string"?e.jsx("div",{children:g.header}):e.jsx("span",{className:"px-3",children:g.header})})},g.id))})}),e.jsx(Le,{children:s.length===0?e.jsx(be,{children:e.jsx(ke,{colSpan:t.length,className:"text-center py-8 text-gray-500",children:"No results found."})}):s.map((g,N)=>e.jsx(be,{className:"hover:bg-gray-50 cursor-pointer",onClick:()=>c?.(g),children:t.map(h=>{const T=h.align==="center",I=h.cell?h.cell(g,N):h.accessorKey?g[h.accessorKey]:null;return e.jsx(ke,{className:T?"px-0 py-4":"px-3 py-4",style:{width:h.size?`${h.size}px`:void 0},children:T?e.jsx("div",{className:"flex items-center justify-center h-full",children:I}):I},h.id)})},a(g)))})]})})})}const je=V.Root,Xt=V.Group,we=V.Value,fe=w.forwardRef(({className:t,children:s,...a},c)=>e.jsxs(V.Trigger,{ref:c,className:u("flex h-10 w-full items-center justify-between rounded-md border border-gray-300 bg-white px-3 py-2 text-sm ring-offset-white placeholder:text-gray-400 focus:outline-none focus:border-gray-500 hover:border-gray-400 disabled:cursor-not-allowed disabled:opacity-50 transition-colors",t),...a,children:[s,e.jsx(V.Icon,{asChild:!0,children:e.jsx(M.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));fe.displayName=V.Trigger.displayName;const nt=w.forwardRef(({className:t,...s},a)=>e.jsx(V.ScrollUpButton,{ref:a,className:u("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(M.ChevronUp,{className:"h-4 w-4"})}));nt.displayName=V.ScrollUpButton.displayName;const ot=w.forwardRef(({className:t,...s},a)=>e.jsx(V.ScrollDownButton,{ref:a,className:u("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(M.ChevronDown,{className:"h-4 w-4"})}));ot.displayName=V.ScrollDownButton.displayName;const ye=w.forwardRef(({className:t,children:s,position:a="popper",...c},g)=>e.jsx(V.Portal,{children:e.jsxs(V.Content,{ref:g,className:u("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border border-gray-200 bg-white text-gray-950 shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:a,...c,children:[e.jsx(nt,{}),e.jsx(V.Viewport,{className:u("p-1",a==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:s}),e.jsx(ot,{})]})}));ye.displayName=V.Content.displayName;const lt=w.forwardRef(({className:t,...s},a)=>e.jsx(V.Label,{ref:a,className:u("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...s}));lt.displayName=V.Label.displayName;const he=w.forwardRef(({className:t,children:s,...a},c)=>e.jsxs(V.Item,{ref:c,className:u("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-gray-100 focus:text-gray-900 data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...a,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(V.ItemIndicator,{children:e.jsx(M.Check,{className:"h-4 w-4"})})}),e.jsx(V.ItemText,{children:s})]}));he.displayName=V.Item.displayName;const it=w.forwardRef(({className:t,...s},a)=>e.jsx(V.Separator,{ref:a,className:u("-mx-1 my-1 h-px bg-gray-100",t),...s}));it.displayName=V.Separator.displayName;function Zt({mode:t="simple",pageSizeOptions:s=[5,10,15,20]}){const{canPreviousPage:a,canNextPage:c,previousPage:g,nextPage:N,pageCount:h,pagination:T,setPageSize:I,goToPage:O}=De(),Y=()=>{const f=T.pageIndex,v=h,R=[];if(v<=7)for(let z=0;z<v;z++)R.push(z);else if(f<=3){for(let z=0;z<=4;z++)R.push(z);R.push("..."),R.push(v-1)}else if(f>=v-4){R.push(0),R.push("...");for(let z=v-5;z<v;z++)R.push(z)}else R.push(0),R.push("..."),R.push(f-1),R.push(f),R.push(f+1),R.push("..."),R.push(v-1);return R};return t==="simple"?e.jsx("div",{className:"flex items-center justify-end px-2 py-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"text-sm text-gray-700 hidden sm:block",children:["Page ",T.pageIndex+1," of ",h]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(y,{variant:"outline",size:"sm",onClick:g,disabled:!a,className:"h-8 w-8 p-0",children:e.jsx(M.ChevronLeft,{className:"h-4 w-4"})}),e.jsx(y,{variant:"outline",size:"sm",onClick:N,disabled:!c,className:"h-8 w-8 p-0",children:e.jsx(M.ChevronRight,{className:"h-4 w-4"})})]})]})}):e.jsxs("div",{className:"flex items-center justify-between gap-3 px-2 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-gray-600 hidden sm:inline",children:"Rows per page:"}),e.jsxs(je,{value:String(T.pageSize),onValueChange:f=>I(Number(f)),children:[e.jsx(fe,{className:"h-8 w-16",children:e.jsx(we,{})}),e.jsx(ye,{children:s.map(f=>e.jsx(he,{value:String(f),children:f},f))})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(y,{variant:"outline",size:"sm",onClick:g,disabled:!a,className:"h-8 w-8 p-0",children:e.jsx(M.ChevronLeft,{className:"h-4 w-4"})}),e.jsxs("span",{className:"text-sm text-gray-700 sm:hidden px-2",children:[T.pageIndex+1," / ",h]}),e.jsx("div",{className:"hidden sm:flex gap-1",children:Y().map((f,v)=>typeof f=="number"?e.jsx(y,{variant:T.pageIndex===f?"default":"outline",size:"sm",onClick:()=>O(f),className:"h-8 w-8 p-0",children:f+1},v):e.jsx("span",{className:"flex h-8 w-8 items-center justify-center text-gray-400",children:f},v))}),e.jsx(y,{variant:"outline",size:"sm",onClick:N,disabled:!c,className:"h-8 w-8 p-0",children:e.jsx(M.ChevronRight,{className:"h-4 w-4"})})]})]})}function Qt({id:t,title:s}){const{sorting:a,setSorting:c}=De(),g=a.find(I=>I.id===t),N=!!g,h=g?.desc??!1,T=()=>{c(I=>{const O=I.find(Y=>Y.id===t);return O?O.desc?[]:[{id:t,desc:!0}]:[{id:t,desc:!1}]})};return e.jsxs(y,{variant:"ghost",className:"h-auto px-3 py-1.5 font-normal hover:bg-transparent hover:text-gray-900",onClick:T,children:[s,N&&h?e.jsx(M.ChevronDown,{className:"h-4 w-4"}):N?e.jsx(M.ChevronUp,{className:"h-4 w-4"}):e.jsx(M.ChevronsUpDown,{className:"h-4 w-4"})]})}function es(){const{toggleAllRows:t,isAllRowsSelected:s}=De();return e.jsx(Re,{checked:s,onCheckedChange:t})}function ts({row:t}){const{selectedRows:s,toggleRow:a,getRowId:c}=De(),g=c(t);return e.jsx(Re,{checked:s.has(g),onCheckedChange:()=>a(g)})}const ss=t=>new Date(t.getFullYear(),t.getMonth(),1),as=t=>new Date(t.getFullYear(),t.getMonth()+1,0),rs=(t,s)=>{const a=[],c=new Date(t);for(;c<=s;)a.push(new Date(c)),c.setDate(c.getDate()+1);return a},Ze=(t,s)=>t.getMonth()===s.getMonth()&&t.getFullYear()===s.getFullYear(),Ne=(t,s)=>t.getDate()===s.getDate()&&t.getMonth()===s.getMonth()&&t.getFullYear()===s.getFullYear(),Qe=t=>Ne(t,new Date),ns=t=>{const s=new Date;return s.setDate(s.getDate()+1),Ne(t,s)},et=(t,s)=>{const a=new Date(t);return a.setMonth(a.getMonth()+s),a},Fe=(t,s)=>{const a=["January","February","March","April","May","June","July","August","September","October","November","December"],c=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];return s==="MMMM yyyy"?`${a[t.getMonth()]} ${t.getFullYear()}`:s==="MMM d, yyyy"?`${c[t.getMonth()]} ${t.getDate()}, ${t.getFullYear()}`:s==="d"?t.getDate().toString():t.toLocaleDateString()};function os({selected:t,onSelect:s,events:a=[],holidays:c=[],className:g,...N}){const[h,T]=w.useState(new Date),[I,O]=w.useState("calendar"),Y=ss(h),f=as(h),v=rs(Y,f),R=["January","February","March","April","May","June","July","August","September","October","November","December"],z=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],F=h.getFullYear(),W=Array.from({length:20},(d,o)=>F-10+o),_=()=>{T(et(h,-1))},H=()=>{T(et(h,1))},J=()=>{const d=new Date(h);d.setFullYear(F-1),T(d)},p=()=>{const d=new Date(h);d.setFullYear(F+1),T(d)},A=d=>{const o=new Date(h);o.setMonth(d),T(o),O("calendar")},B=d=>{const o=new Date(h);o.setFullYear(d),T(o),O("calendar")},L=d=>a.filter(o=>Ne(o.date,d)),x=d=>c.some(o=>Ne(o.date,d));return I==="months"?e.jsxs("div",{className:u("bg-white rounded-lg border border-gray-200 w-full",g),...N,children:[e.jsx("div",{className:"px-6 py-4 border-b border-gray-100",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>O("calendar"),className:"h-9 px-3 text-sm font-medium text-gray-600 hover:text-gray-900 hover:bg-gray-50 rounded",children:"← Back"}),e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsx(y,{variant:"outline",size:"sm",onClick:J,className:"h-9 w-9 p-0 border-gray-200 rounded",children:e.jsx(M.ChevronLeft,{className:"h-4 w-4"})}),e.jsx(y,{variant:"ghost",onClick:()=>O("years"),className:"h-9 px-4 text-lg font-semibold text-gray-900 hover:bg-gray-50 rounded",children:F}),e.jsx(y,{variant:"outline",size:"sm",onClick:p,className:"h-9 w-9 p-0 border-gray-200 rounded",children:e.jsx(M.ChevronRight,{className:"h-4 w-4"})})]})]})}),e.jsx("div",{className:"p-6",children:e.jsx("div",{className:"grid grid-cols-3 gap-2",children:R.map((d,o)=>e.jsx(y,{variant:"ghost",onClick:()=>A(o),className:u("h-11 w-full text-sm font-medium rounded transition-all duration-200",o===h.getMonth()?"bg-gray-900 text-white hover:bg-gray-800 shadow-sm":"text-gray-600 hover:text-gray-900 hover:bg-gray-50"),children:d},d))})})]}):I==="years"?e.jsxs("div",{className:u("bg-white rounded-lg border border-gray-200 w-full",g),...N,children:[e.jsx("div",{className:"px-6 py-4 border-b border-gray-100",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>O("months"),className:"h-9 px-3 text-sm font-medium text-gray-600 hover:text-gray-900 hover:bg-gray-50 rounded",children:"← Back"}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:"Select Year"})]})}),e.jsx("div",{className:"p-6",children:e.jsx("div",{className:"grid grid-cols-4 gap-2 max-h-64 overflow-y-auto",children:W.map(d=>e.jsx(y,{variant:"ghost",onClick:()=>B(d),className:u("h-11 w-full text-sm font-medium rounded transition-all duration-200",d===F?"bg-gray-900 text-white hover:bg-gray-800 shadow-sm":"text-gray-600 hover:text-gray-900 hover:bg-gray-50"),children:d},d))})})]}):e.jsxs("div",{className:u("bg-white rounded-lg border border-gray-200 w-full",g),...N,children:[e.jsx("div",{className:"px-6 py-4 border-b border-gray-100",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(y,{variant:"outline",size:"sm",onClick:_,className:"h-9 w-9 p-0 border-gray-200 rounded",children:e.jsx(M.ChevronLeft,{className:"h-4 w-4"})}),e.jsx(y,{variant:"ghost",onClick:()=>O("months"),className:"h-9 px-4 text-lg font-semibold text-gray-900 hover:bg-gray-50 rounded",children:Fe(h,"MMMM yyyy")}),e.jsx(y,{variant:"outline",size:"sm",onClick:H,className:"h-9 w-9 p-0 border-gray-200 rounded",children:e.jsx(M.ChevronRight,{className:"h-4 w-4"})})]})}),e.jsxs("div",{className:"p-6",children:[e.jsx("div",{className:"grid grid-cols-7 gap-1 mb-2",children:z.map((d,o)=>e.jsx("div",{className:"h-10 flex items-center justify-center",children:e.jsx("span",{className:"text-xs font-medium text-gray-400 uppercase",children:d})},o))}),e.jsxs("div",{className:"grid grid-cols-7 gap-1",children:[Array.from({length:Y.getDay()}).map((d,o)=>e.jsx("div",{className:"h-12"},`empty-${o}`)),v.map(d=>{const o=L(d),i=t&&Ne(d,t),l=Qe(d),C=Ze(d,h),n=x(d);return e.jsx("div",{className:"relative",children:e.jsxs(y,{variant:"ghost",size:"sm",className:u("h-12 w-full p-0 text-sm relative rounded transition-all duration-200",!C&&"text-gray-300",C&&!i&&!l&&!n&&"text-gray-700 hover:bg-gray-50",n&&!i&&"text-red-600 font-medium hover:bg-red-50",l&&!i&&"bg-gray-100 text-gray-900 font-medium border border-gray-200",i&&"bg-gray-900 text-white font-medium shadow-sm"),onClick:()=>s?.(d),children:[Fe(d,"d"),o.length>0&&e.jsxs("div",{className:"absolute bottom-1 left-1/2 transform -translate-x-1/2 flex space-x-0.5",children:[o.slice(0,3).map((D,j)=>{const k=$=>{if(i)return"bg-white/80";switch($){case"class":return"bg-blue-500";case"meeting":return"bg-green-500";case"appointment":return"bg-orange-500";case"deadline":return"bg-red-500";default:return"bg-gray-500"}};return e.jsx("div",{className:u("w-1 h-1 rounded-full",k(D.type))},j)}),o.length>3&&e.jsx("div",{className:u("w-1 h-1 rounded-full",i?"bg-white/60":"bg-gray-400")})]})]})},d.toISOString())})]})]}),t&&e.jsx("div",{className:"border-t border-gray-100",children:e.jsxs("div",{className:"p-6",children:[e.jsx("div",{className:"flex items-center justify-between mb-4",children:e.jsx("h4",{className:"text-sm font-semibold text-gray-900",children:Qe(t)?"Today":ns(t)?"Tomorrow":Fe(t,"MMM d, yyyy")})}),(()=>{const d=a.filter(o=>Ne(o.date,t));return e.jsxs("div",{className:"space-y-3",children:[d.length>0&&d.map(o=>{const l=(C=>{switch(C){case"class":return{bg:"bg-blue-50",border:"border-blue-100",dot:"bg-blue-500",text:"text-blue-900",subtext:"text-blue-600"};case"meeting":return{bg:"bg-green-50",border:"border-green-100",dot:"bg-green-500",text:"text-green-900",subtext:"text-green-600"};case"appointment":return{bg:"bg-orange-50",border:"border-orange-100",dot:"bg-orange-500",text:"text-orange-900",subtext:"text-orange-600"};case"deadline":return{bg:"bg-red-50",border:"border-red-100",dot:"bg-red-500",text:"text-red-900",subtext:"text-red-600"};default:return{bg:"bg-gray-50",border:"border-gray-100",dot:"bg-gray-500",text:"text-gray-900",subtext:"text-gray-600"}}})(o.type);return e.jsxs("div",{className:`flex items-center space-x-3 p-3 ${l.bg} rounded border ${l.border} hover:shadow-sm transition-shadow cursor-pointer`,children:[e.jsx("div",{className:`w-2 h-2 rounded-full ${l.dot} flex-shrink-0`}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:`text-sm font-medium ${l.text} truncate`,children:o.title}),(o.time||o.location)&&e.jsxs("p",{className:`text-xs ${l.subtext} truncate`,children:[o.time,o.time&&o.location&&" • ",o.location]})]})]},o.id||o.title)}),d.length===0&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"w-12 h-12 bg-gray-100 rounded-full flex items-center justify-center mx-auto mb-3",children:e.jsx(M.Calendar,{className:"w-5 h-5 text-gray-400"})}),e.jsx("p",{className:"text-sm text-gray-500",children:"No events scheduled"})]})]})})()]})}),!Ze(h,new Date)&&e.jsx("div",{className:"p-6 pt-0",children:e.jsx(y,{variant:"outline",size:"sm",onClick:()=>{const d=new Date;T(d),s?.(d),O("calendar")},className:"w-full h-10 text-sm font-medium border-gray-200 hover:bg-gray-50 rounded",children:"Today"})})]})}const We=Se.Root,Be=Se.Trigger,ls=Se.Anchor,Ie=w.forwardRef(({className:t,align:s="center",sideOffset:a=4,...c},g)=>e.jsx(Se.Portal,{children:e.jsx(Se.Content,{ref:g,align:s,sideOffset:a,className:u("z-50 w-auto rounded-md border border-gray-200 bg-white p-3 text-gray-950 shadow-lg outline-none","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95","data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2","data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...c})}));Ie.displayName=Se.Content.displayName;function is({date:t,onDateChange:s,mode:a="single",dateRange:c,onDateRangeChange:g,placeholder:N="Pick a date",dateFormat:h="PPP",disabled:T=!1,className:I,variant:O="outline",size:Y="default",align:f="start",showIcon:v=!0,icon:R,minDate:z,maxDate:F,disabledDates:W,isDateDisabled:_,fullWidth:H=!1,customTrigger:J,numberOfMonths:p=1,holidays:A=[]}){const[B,L]=w.useState(!1),[x,d]=w.useState(t||new Date),[o,i]=w.useState("calendar"),[l,C]=w.useState(c?.from),[n,D]=w.useState(c?.to),[j,k]=w.useState();w.useEffect(()=>{C(c?.from),D(c?.to)},[c]),w.useEffect(()=>{B&&(i("calendar"),a==="single"&&t?d(t):a==="range"&&c?.from&&d(c.from))},[B,t,c,a]);const $=m=>{if(a==="range")if(!l||l&&n)C(m),D(void 0),g?.({from:m,to:void 0});else{const E=l<m?l:m,te=l<m?m:l;C(E),D(te),g?.({from:E,to:te}),L(!1)}else s?.(m),L(!1)},X=m=>!!(W?.some(E=>E.toDateString()===m.toDateString())||z&&m<z||F&&m>F||_?.(m)),ne=m=>A.some(E=>q.isSameDay(E.date,m)),ce=q.startOfMonth(x),ee=q.endOfMonth(x),oe=q.eachDayOfInterval({start:ce,end:ee}),le=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],de=q.addMonths(x,1),Me=q.startOfMonth(de),Te=q.endOfMonth(de),Ce=q.eachDayOfInterval({start:Me,end:Te}),me=()=>{d(q.subMonths(x,1))},ue=()=>{d(q.addMonths(x,1))},ae=(m,E)=>q.format(m,E),r=m=>{if(l&&n)return m>=l&&m<=n;if(l&&!n&&j){const E=l<j?l:j,te=l<j?j:l;return m>=E&&m<=te}return!1},b=m=>l&&q.isSameDay(m,l),G=m=>n&&q.isSameDay(m,n),S=()=>{const m=new Date(x);m.setFullYear(xe-1),d(m)},re=()=>{const m=new Date(x);m.setFullYear(xe+1),d(m)},Z=m=>{const E=new Date(x.getFullYear(),m,1);d(E),i("calendar")},K=m=>{const E=new Date(m,x.getMonth(),1);d(E),i("calendar")},ze=["January","February","March","April","May","June","July","August","September","October","November","December"],xe=x.getFullYear(),Pe=Array.from({length:20},(m,E)=>xe-10+E),Ke=J||e.jsxs(y,{variant:O,size:Y,className:u("justify-start text-left font-normal",!t&&!l&&"text-gray-500",H&&"w-full",I),disabled:T,children:[v&&(R||e.jsx(M.Calendar,{className:"mr-2 h-4 w-4"})),a==="range"?l&&n?e.jsxs("span",{children:[q.format(l,h)," - ",q.format(n,h)]}):l?e.jsxs("span",{children:[q.format(l,h)," - ..."]}):e.jsx("span",{children:N}):t?q.format(t,h):e.jsx("span",{children:N})]}),ge=(m,E)=>{const te=a==="single"?t&&q.isSameDay(m,t):b(m)||G(m),yt=q.isToday(m),He=X(m),pe=a==="range"&&r(m),bt=ne(m),Xe=m.getDay(),vt=b(m),jt=G(m);return e.jsx("div",{className:u("relative p-0.5",pe&&"bg-gray-100",pe&&Xe===0&&"rounded-l-md",pe&&Xe===6&&"rounded-r-md",pe&&vt&&"rounded-l-md",pe&&jt&&"rounded-r-md"),onMouseEnter:()=>a==="range"&&l&&!n&&k(m),onMouseLeave:()=>k(void 0),children:e.jsx(y,{variant:"ghost",size:"sm",disabled:He||T,className:u("h-10 w-full p-0 text-sm relative transition-all duration-200 rounded-md text-gray-900",!E&&"text-gray-300",bt&&!te&&"text-red-600 font-medium",yt&&!te&&!pe&&"bg-gray-50 text-gray-900 font-medium border border-gray-200",te&&"bg-gray-900 text-white font-medium shadow-sm z-10 hover:bg-gray-800",pe&&!te&&"text-gray-900 bg-gray-100",He&&"opacity-40 cursor-not-allowed"),onClick:()=>!He&&$(m),children:ae(m,"d")})},m.toISOString())};return e.jsxs(We,{open:B,onOpenChange:L,children:[e.jsx(Be,{asChild:!0,children:Ke}),e.jsx(Ie,{className:u("p-0 border-gray-200",p===2?"w-[640px]":"w-80"),align:f,side:"bottom",sideOffset:4,collisionPadding:8,children:e.jsxs("div",{className:"bg-white rounded-lg","data-takaui":"datepicker",children:[e.jsx("div",{className:"border-b border-gray-100 px-6 py-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(y,{variant:"outline",size:"sm",onClick:me,className:"h-9 w-9 p-0",children:e.jsx(M.ChevronLeft,{className:"h-4 w-4"})}),p===2?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>i("months"),className:"h-9 px-3 font-semibold text-base",children:ae(x,"MMMM")}),e.jsx("span",{className:"text-gray-400 text-sm",children:"-"}),e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>i("months"),className:"h-9 px-3 font-semibold text-base",children:ae(de,"MMMM yyyy")})]}):e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>i("months"),className:"h-9 px-4 font-semibold text-lg",children:ae(x,"MMMM yyyy")}),e.jsx(y,{variant:"outline",size:"sm",onClick:ue,className:"h-9 w-9 p-0",children:e.jsx(M.ChevronRight,{className:"h-4 w-4"})})]})}),e.jsxs("div",{className:"p-6",children:[o==="years"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>i("months"),className:"h-9 px-3 text-sm font-medium text-gray-600",children:"← Back"}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:"Select Year"})]}),e.jsx("div",{className:"grid grid-cols-4 gap-2 max-h-64 overflow-y-auto",children:Pe.map(m=>e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>K(m),className:u("h-11 w-full text-sm font-medium rounded-md transition-all duration-200",m===xe?"bg-gray-900 text-white shadow-sm hover:bg-gray-800":"text-gray-900 bg-transparent"),children:m},m))})]}),o==="months"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>i("calendar"),className:"h-9 px-3 text-sm font-medium text-gray-600",children:"← Back"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(y,{variant:"outline",size:"sm",onClick:S,className:"h-9 w-9 p-0",children:e.jsx(M.ChevronLeft,{className:"h-4 w-4"})}),e.jsx(y,{variant:"ghost",onClick:()=>i("years"),className:"h-9 px-4 text-lg font-semibold text-gray-900",children:xe}),e.jsx(y,{variant:"outline",size:"sm",onClick:re,className:"h-9 w-9 p-0",children:e.jsx(M.ChevronRight,{className:"h-4 w-4"})})]})]}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:ze.map((m,E)=>e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>Z(E),className:u("h-11 w-full text-sm font-medium rounded-md transition-all duration-200",E===x.getMonth()?"bg-gray-900 text-white shadow-sm hover:bg-gray-800":"text-gray-900 bg-transparent"),children:m},m))})]}),o==="calendar"&&e.jsxs("div",{className:u("flex",p===2?"gap-6":"gap-0"),children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"grid grid-cols-7 gap-1 mb-2",children:le.map((m,E)=>e.jsx("div",{className:"h-8 flex items-center justify-center",children:e.jsx("span",{className:"text-xs font-medium text-gray-400 uppercase",children:m})},E))}),e.jsxs("div",{className:"grid grid-cols-7",children:[Array.from({length:ce.getDay()}).map((m,E)=>e.jsx("div",{className:"h-10"},`empty-${E}`)),oe.map(m=>ge(m,q.isSameMonth(m,x)))]})]}),p===2&&e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"grid grid-cols-7 gap-1 mb-2",children:le.map((m,E)=>e.jsx("div",{className:"h-8 flex items-center justify-center",children:e.jsx("span",{className:"text-xs font-medium text-gray-400 uppercase",children:m})},E))}),e.jsxs("div",{className:"grid grid-cols-7",children:[Array.from({length:Me.getDay()}).map((m,E)=>e.jsx("div",{className:"h-10"},`next-empty-${E}`)),Ce.map(m=>ge(m,q.isSameMonth(m,de)))]})]})]})]})]})})]})}const cs=({time:t,onTimeChange:s,timezone:a="UTC",format:c="24h",showTimezone:g=!1,minuteStep:N=1,showSeconds:h=!1,placeholder:T="Select time",variant:I="outline",size:O="default",showClockFace:Y=!1})=>{const f=c==="24h",v=t?t.getHours():0,R=t?t.getMinutes():0,z=t?t.getSeconds():0,F=v>=12?"PM":"AM",[W,_]=P.useState(v),[H,J]=P.useState(R),[p,A]=P.useState(z),[B,L]=P.useState(F),[x,d]=P.useState(""),[o,i]=P.useState(""),[l,C]=P.useState(""),n=P.useRef(null),D=P.useRef(null),j=P.useRef(null),k=P.useRef(null),$=P.useRef(null),X=P.useRef(null);P.useEffect(()=>{if(t){const r=t.getHours(),b=t.getMinutes(),G=t.getSeconds(),S=r>=12?"PM":"AM";r!==W&&_(r),b!==H&&J(b),G!==p&&A(G),S!==B&&L(S)}},[t]),P.useEffect(()=>{k.current&&k.current.querySelector('[data-selected="true"]')?.scrollIntoView({block:"center",behavior:"smooth"}),$.current&&$.current.querySelector('[data-selected="true"]')?.scrollIntoView({block:"center",behavior:"smooth"}),X.current&&X.current.querySelector('[data-selected="true"]')?.scrollIntoView({block:"center",behavior:"smooth"})},[W,H,p,f]);const ne=(r,b,G)=>{const S=new Date;S.setHours(r),S.setMinutes(b),S.setSeconds(G),s(S)},ce=r=>{let b=r;f||(B==="PM"&&r!==12?b=r+12:B==="AM"&&r===12&&(b=0)),_(b),ne(b,H,p)},ee=r=>{J(r),ne(W,r,p)},oe=r=>{A(r),ne(W,H,r)},le=r=>{if(B===r)return;L(r);const b=r==="PM"?W%12+12:W%12;_(b),ne(b,H,p)},de=()=>{const r=new Date;_(r.getHours()),J(r.getMinutes()),A(r.getSeconds()),L(r.getHours()>=12?"PM":"AM"),s(r)},Me=()=>{if(!t)return T;const r=f?W:W%12||12,b=H.toString().padStart(2,"0"),G=p.toString().padStart(2,"0");let S=`${r.toString().padStart(2,"0")}:${b}`;return h&&(S+=`:${G}`),f||(S+=` ${B}`),g&&(S+=` ${a}`),S},Te=()=>{const r=f?23:12,b=f?0:1;return Array.from({length:r-b+1},(G,S)=>b+S)},Ce=()=>Array.from({length:Math.floor(60/N)},(r,b)=>b*N),me=()=>Array.from({length:60},(r,b)=>b),ue=f?W:W%12||12,ae=()=>{const re=(ue%12*30+H*.5)*(Math.PI/180)-Math.PI/2,Z=H*6*(Math.PI/180)-Math.PI/2,K=100+50*Math.cos(re),ze=100+50*Math.sin(re),xe=100+70*Math.cos(Z),Pe=100+70*Math.sin(Z);return e.jsxs("svg",{width:200,height:200,className:"mx-auto",children:[e.jsx("circle",{cx:100,cy:100,r:95,fill:"white",stroke:"#e5e7eb",strokeWidth:"2"}),Array.from({length:12},(Ke,ge)=>{const m=ge*30*(Math.PI/180)-Math.PI/2,E=100+80*Math.cos(m),te=100+80*Math.sin(m);return e.jsx("text",{x:E,y:te,textAnchor:"middle",dominantBaseline:"middle",className:"text-sm fill-gray-600",children:ge===0?12:ge},ge)}),e.jsx("line",{x1:100,y1:100,x2:K,y2:ze,stroke:"#374151",strokeWidth:"6",strokeLinecap:"round"}),e.jsx("line",{x1:100,y1:100,x2:xe,y2:Pe,stroke:"#ef4444",strokeWidth:"4",strokeLinecap:"round"}),e.jsx("circle",{cx:100,cy:100,r:"6",fill:"#ef4444"})]})};return e.jsxs(We,{children:[e.jsx(Be,{asChild:!0,children:e.jsxs(y,{variant:I,size:O,className:u("justify-start text-left font-normal",!t&&"text-muted-foreground"),children:[e.jsx(M.Clock,{className:"mr-2 h-4 w-4"}),Me()]})}),e.jsx(Ie,{className:"w-auto p-0",align:"start",children:e.jsxs("div",{className:"p-6 space-y-4 min-w-[460px]",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-center gap-6",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("input",{ref:n,type:"text",inputMode:"numeric",value:x!==""?x.padStart(2,"0"):ue.toString().padStart(2,"0"),onKeyDown:r=>{if(r.key>="0"&&r.key<="9"){r.preventDefault();const b=x+r.key;if(b.length===1)d(r.key);else if(b.length===2){const G=parseInt(b),S=f?23:12,re=f?0:1;let Z=G;G<re&&(Z=re),G>S&&(Z=S),d(""),ce(Z),setTimeout(()=>D.current?.focus(),0)}}else r.key==="Backspace"?(r.preventDefault(),x.length>0&&d(x.slice(0,-1))):r.key==="ArrowRight"||r.key==="Tab"?(r.key==="ArrowRight"&&r.preventDefault(),D.current?.focus()):r.key===":"&&(r.preventDefault(),D.current?.focus())},onBlur:()=>{if(x){const r=parseInt(x),b=f?23:12,G=f?0:1;let S=r;r<G&&(S=G),r>b&&(S=b),ce(S)}d("")},onFocus:()=>{d("")},className:"text-6xl font-medium tabular-nums leading-none w-[85px] text-center bg-transparent outline-none focus:ring-2 focus:ring-primary rounded px-1 cursor-text",readOnly:!0}),e.jsx("div",{className:"text-6xl font-medium leading-none flex items-center px-1",children:":"}),e.jsx("input",{ref:D,type:"text",inputMode:"numeric",value:o!==""?o.padStart(2,"0"):H.toString().padStart(2,"0"),onKeyDown:r=>{if(r.key>="0"&&r.key<="9"){r.preventDefault();const b=o+r.key;if(b.length===1)i(r.key);else if(b.length===2){const G=parseInt(b),S=Math.min(59,Math.max(0,G));i(""),ee(S),h&&setTimeout(()=>j.current?.focus(),0)}}else r.key==="Backspace"?(r.preventDefault(),o.length>0?i(o.slice(0,-1)):n.current?.focus()):r.key==="ArrowLeft"?(r.preventDefault(),n.current?.focus()):r.key==="ArrowRight"||r.key==="Tab"?(r.key==="ArrowRight"&&r.preventDefault(),h&&j.current?.focus()):r.key===":"&&(r.preventDefault(),h&&j.current?.focus())},onBlur:()=>{if(o){const r=parseInt(o),b=Math.min(59,Math.max(0,r));ee(b)}i("")},onFocus:()=>{i("")},className:"text-6xl font-medium tabular-nums leading-none w-[85px] text-center bg-transparent outline-none focus:ring-2 focus:ring-primary rounded px-1 cursor-text",readOnly:!0}),h&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-6xl font-medium leading-none flex items-center px-1",children:":"}),e.jsx("input",{ref:j,type:"text",inputMode:"numeric",value:l!==""?l.padStart(2,"0"):p.toString().padStart(2,"0"),onKeyDown:r=>{if(r.key>="0"&&r.key<="9"){r.preventDefault();const b=l+r.key;if(b.length===1)C(r.key);else if(b.length===2){const G=parseInt(b),S=Math.min(59,Math.max(0,G));C(""),oe(S)}}else r.key==="Backspace"?(r.preventDefault(),l.length>0?C(l.slice(0,-1)):D.current?.focus()):r.key==="ArrowLeft"&&(r.preventDefault(),D.current?.focus())},onBlur:()=>{if(l){const r=parseInt(l),b=Math.min(59,Math.max(0,r));oe(b)}C("")},onFocus:()=>{C("")},className:"text-6xl font-medium tabular-nums leading-none w-[85px] text-center bg-transparent outline-none focus:ring-2 focus:ring-primary rounded px-1 cursor-text",readOnly:!0})]})]}),!f&&e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(y,{size:"sm",variant:B==="AM"?"default":"outline",onClick:()=>le("AM"),className:"h-8 w-12 text-xs font-medium",children:"AM"}),e.jsx(y,{size:"sm",variant:B==="PM"?"default":"outline",onClick:()=>le("PM"),className:"h-8 w-12 text-xs font-medium",children:"PM"})]})]}),g&&e.jsx("div",{className:"text-xs text-gray-500 text-center",children:a})]}),Y?e.jsx("div",{className:"space-y-4",children:ae()}):e.jsxs("div",{className:"flex gap-2 justify-center items-start",children:[e.jsxs("div",{className:"flex-1 max-w-[80px]",children:[e.jsx("div",{className:"text-xs text-center text-gray-500 mb-2",children:"Hour"}),e.jsx("div",{ref:k,className:"h-40 overflow-y-scroll border rounded-md scrollbar-thin scrollbar-thumb-gray-300 scrollbar-track-gray-100",children:Te().map(r=>e.jsx("button",{"data-selected":ue===r,onClick:()=>ce(r),className:u("w-full py-2 text-center transition-colors",ue===r?"bg-blue-500 text-white font-medium":"hover:bg-gray-100 text-gray-700"),children:r.toString().padStart(2,"0")},r))})]}),e.jsxs("div",{className:"flex-1 max-w-[80px]",children:[e.jsx("div",{className:"text-xs text-center text-gray-500 mb-2",children:"Min"}),e.jsx("div",{ref:$,className:"h-40 overflow-y-scroll border rounded-md scrollbar-thin scrollbar-thumb-gray-300 scrollbar-track-gray-100",children:Ce().map(r=>e.jsx("button",{"data-selected":H===r,onClick:()=>ee(r),className:u("w-full py-2 text-center transition-colors",H===r?"bg-blue-500 text-white font-medium":"hover:bg-gray-100 text-gray-700"),children:r.toString().padStart(2,"0")},r))})]}),h&&e.jsxs("div",{className:"flex-1 max-w-[80px]",children:[e.jsx("div",{className:"text-xs text-center text-gray-500 mb-2",children:"Sec"}),e.jsx("div",{ref:X,className:"h-40 overflow-y-scroll border rounded-md scrollbar-thin scrollbar-thumb-gray-300 scrollbar-track-gray-100",children:me().map(r=>e.jsx("button",{"data-selected":p===r,onClick:()=>oe(r),className:u("w-full py-2 text-center transition-colors",p===r?"bg-blue-500 text-white font-medium":"hover:bg-gray-100 text-gray-700"),children:r.toString().padStart(2,"0")},r))})]})]}),e.jsxs("div",{className:"flex gap-2 justify-between pt-2 border-t",children:[e.jsx(y,{size:"sm",variant:"outline",onClick:de,children:"Now"}),e.jsx(y,{size:"sm",onClick:()=>s(t),children:"Done"})]})]})})]})},Ve=w.forwardRef(({className:t,...s},a)=>e.jsx("div",{ref:a,className:u("rounded-lg border border-gray-200 bg-white text-gray-950 shadow-sm",t),...s}));Ve.displayName="Card";const qe=w.forwardRef(({className:t,...s},a)=>e.jsx("div",{ref:a,className:u("flex flex-col space-y-1.5 p-6",t),...s}));qe.displayName="CardHeader";const Je=w.forwardRef(({className:t,...s},a)=>e.jsx("h3",{ref:a,className:u("text-2xl font-semibold leading-none tracking-tight",t),...s}));Je.displayName="CardTitle";const ct=w.forwardRef(({className:t,...s},a)=>e.jsx("p",{ref:a,className:u("text-sm text-gray-500",t),...s}));ct.displayName="CardDescription";const Ue=w.forwardRef(({className:t,...s},a)=>e.jsx("div",{ref:a,className:u("p-6 pt-0",t),...s}));Ue.displayName="CardContent";const dt=w.forwardRef(({className:t,...s},a)=>e.jsx("div",{ref:a,className:u("flex items-center p-6 pt-0",t),...s}));dt.displayName="CardFooter";const Q=w.forwardRef(({className:t,...s},a)=>e.jsx(tt.Root,{ref:a,className:u("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",t),...s}));Q.displayName=tt.Root.displayName;const ut=se.Root,ds=se.Portal,ht=w.forwardRef(({className:t,...s},a)=>e.jsx(se.Overlay,{ref:a,className:u("fixed inset-0 z-50 bg-black/50 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...s}));ht.displayName=se.Overlay.displayName;const mt=w.forwardRef(({className:t,children:s,...a},c)=>e.jsxs(ds,{children:[e.jsx(ht,{}),e.jsxs(se.Content,{ref:c,className:u("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border border-gray-200 bg-white p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] rounded-lg",t),...a,children:[s,e.jsxs(se.Close,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-white transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-gray-950 focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-gray-100",children:[e.jsx(M.X,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));mt.displayName=se.Content.displayName;const xt=({className:t,...s})=>e.jsx("div",{className:u("flex flex-col space-y-1.5 text-center sm:text-left",t),...s});xt.displayName="ModalHeader";const gt=w.forwardRef(({className:t,...s},a)=>e.jsx(se.Title,{ref:a,className:u("text-lg font-semibold leading-none tracking-tight",t),...s}));gt.displayName=se.Title.displayName;const pt=w.forwardRef(({className:t,...s},a)=>e.jsx(se.Description,{ref:a,className:u("text-sm text-gray-500",t),...s}));pt.displayName=se.Description.displayName;function us({isOpen:t,onClose:s,title:a,description:c,children:g,className:N}){return e.jsx(ut,{open:t,onOpenChange:s,children:e.jsxs(mt,{className:N,children:[(a||c)&&e.jsxs(xt,{children:[a&&e.jsx(gt,{children:a}),c&&e.jsx(pt,{children:c})]}),g]})})}const Ae=["January","February","March","April","May","June","July","August","September","October","November","December"];function ft({onWeekChange:t,initialDate:s=new Date,className:a,compact:c=!1}){const[g,N]=w.useState(s),[h,T]=w.useState(!1),[I,O]=w.useState(!1),[Y,f]=w.useState(!1),[v,R]=w.useState(s.getFullYear()),[z,F]=w.useState(s.getMonth()),[W,_]=w.useState(0),H=w.useRef(null),J=w.useRef(null),p=i=>{const l=[],C=new Date(i),n=C.getDay(),D=n===0?-6:1-n;C.setDate(C.getDate()+D);for(let j=0;j<7;j++){const k=new Date(C);k.setDate(C.getDate()+j),l.push(k)}return l},A=(i,l)=>{const C=new Date(i,l,1),n=new Date(i,l+1,0),D=new Date(C);D.setDate(C.getDate()-(C.getDay()+6)%7);const j=[],k=new Date(D);for(;k<=n||k.getMonth()===l;){const $=new Date(k);if($.setDate(k.getDate()+6),j.push({start:new Date(k),end:new Date($)}),k.setDate(k.getDate()+7),j.length>6)break}return j},B=(i,l)=>{const C=i.toLocaleDateString("en-US",{month:"short"}),n=l.toLocaleDateString("en-US",{month:"short"});return C===n?`${C} ${i.getDate()}-${l.getDate()}`:`${C} ${i.getDate()}-${n} ${l.getDate()}`},L=p(g),x=Array.from({length:10},(i,l)=>v-5+l),d=i=>{const l=new Date(g);l.setDate(g.getDate()+(i==="next"?7:-7)),N(l),R(l.getFullYear()),F(l.getMonth()),t?.(l)},o=(i,l)=>{_(l),T(!1),N(i.start),t?.(i.start)};return w.useEffect(()=>{const i=l=>{H.current&&!H.current.contains(l.target)&&J.current&&!J.current.contains(l.target)&&(T(!1),O(!1),f(!1))};return h&&document.addEventListener("mousedown",i),()=>{document.removeEventListener("mousedown",i)}},[h]),w.useEffect(()=>{const l=A(v,z).findIndex(C=>g>=C.start&&g<=C.end);l!==-1&&_(l)},[g,v,z]),e.jsxs("div",{className:u("flex items-center gap-3",a),children:[e.jsx(y,{variant:"outline",size:"sm",onClick:()=>d("prev"),className:u("rounded-lg border-gray-200 hover:border-gray-300 hover:bg-gray-50",c?"h-8 w-8 p-0":"h-9 w-9 p-0"),children:e.jsx(M.ChevronLeft,{className:u(c?"h-3 w-3":"h-4 w-4","text-gray-600")})}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{ref:J,className:u("flex items-center gap-2 bg-white rounded-lg border border-gray-200 shadow-sm cursor-pointer hover:bg-gray-50 transition-colors",c?"px-2 py-1":"px-3 py-2"),onClick:()=>T(!h),children:[e.jsx(M.Calendar,{className:u(c?"h-3 w-3":"h-4 w-4","text-gray-500")}),e.jsx("span",{className:u(c?"text-xs":"text-sm","font-medium text-gray-700"),children:L.length>=7&&L[0]&&L[6]&&`${L[0].getDate()}-${L[6].getDate()} ${Ae[L[0].getMonth()]} ${L[0].getFullYear()}`}),e.jsx(M.ChevronRight,{className:u(c?"h-2 w-2":"h-3 w-3","text-gray-400 transition-transform",h&&"rotate-90")})]}),h&&e.jsxs("div",{ref:H,className:"absolute top-full right-0 mt-2 bg-white border border-gray-200 rounded-lg shadow-lg p-4 z-50 w-80 sm:w-96",children:[!I&&!Y&&e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>{const i=z===0?11:z-1,l=z===0?v-1:v;F(i),R(l)},className:"h-8 w-8 p-0",children:e.jsx(M.ChevronLeft,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{className:"text-lg font-semibold text-gray-800 hover:text-blue-600 transition-colors",onClick:()=>O(!I),children:Ae[z]}),e.jsx("button",{className:"text-lg font-semibold text-gray-800 hover:text-blue-600 transition-colors",onClick:()=>f(!Y),children:v})]}),e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>{const i=z===11?0:z+1,l=z===11?v+1:v;F(i),R(l)},className:"h-8 w-8 p-0",children:e.jsx(M.ChevronRight,{className:"h-4 w-4"})})]}),I?e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>O(!1),className:"h-9 px-3 text-sm font-medium",children:"← Back"}),e.jsx("span",{className:"text-lg font-semibold",children:v})]}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:Ae.map((i,l)=>e.jsx("button",{className:u("h-11 w-full text-sm font-medium rounded-xl transition-all",z===l?"bg-blue-500 text-white":"text-gray-600 hover:bg-gray-50"),onClick:()=>{F(l),O(!1)},children:i},i))})]}):Y?e.jsxs("div",{className:"p-6",children:[e.jsx("div",{className:"flex items-center justify-start mb-4",children:e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>f(!1),className:"h-9 px-3 text-sm font-medium",children:"← Back"})}),e.jsx("div",{className:"grid grid-cols-4 gap-2 max-h-64 overflow-y-auto",children:x.map(i=>e.jsx("button",{className:u("h-11 w-full text-sm font-medium rounded-xl transition-all",v===i?"bg-blue-500 text-white":"text-gray-600 hover:bg-gray-50"),onClick:()=>{R(i),f(!1),O(!0)},children:i},i))})]}):e.jsx("div",{className:"grid grid-cols-2 gap-2 max-h-64 overflow-y-auto",children:A(v,z).map((i,l)=>{const C=new Date>=i.start&&new Date<=i.end,n=W===l;return e.jsx("button",{className:u("w-full p-3 text-left rounded-lg border transition-all",n?"bg-blue-500 text-white border-blue-500":C?"bg-white text-blue-600 border-blue-500":"bg-white border-gray-200 text-gray-700 hover:border-blue-300"),onClick:()=>o(i,l),children:e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("div",{className:u("font-medium text-sm",n?"text-white":"text-gray-800"),children:["Week ",l+1]}),e.jsx("div",{className:u("text-xs",n?"text-blue-100":"text-gray-500"),children:B(i.start,i.end)})]})},l)})}),e.jsx("div",{className:"flex gap-2 pt-3 border-t border-gray-100 mt-3",children:e.jsx(y,{size:"sm",variant:"outline",className:"flex-1",onClick:()=>{const i=new Date;N(i),T(!1),O(!1),f(!1),t?.(i)},children:"This Week"})})]})]}),e.jsx(y,{variant:"outline",size:"sm",onClick:()=>d("next"),className:u("rounded-lg border-gray-200 hover:border-gray-300 hover:bg-gray-50",c?"h-8 w-8 p-0":"h-9 w-9 p-0"),children:e.jsx(M.ChevronRight,{className:u(c?"h-3 w-3":"h-4 w-4","text-gray-600")})})]})}const Oe={calculateWeekDates:t=>{const s=[],a=new Date(t),c=a.getDay(),g=c===0?-6:1-c;a.setDate(a.getDate()+g);for(let N=0;N<7;N++){const h=new Date(a);h.setDate(a.getDate()+N),s.push(h)}return s},formatDateDisplay:t=>t.toLocaleDateString("en-US",{month:"short",day:"numeric"}),getWeekNumber:t=>{const s=new Date(t.getFullYear(),0,1),a=(t.getTime()-s.getTime())/864e5;return Math.ceil((a+s.getDay()+1)/7)},getWeekOfMonth:t=>{const a=new Date(t.getFullYear(),t.getMonth(),1).getDay(),c=t.getDate()+a-1;return Math.ceil(c/7)}},hs=["08:00","09:00","10:00","11:00","12:00","13:00","14:00","15:00","16:00"],ms=["Monday","Tuesday","Wednesday","Thursday","Friday"],xs=[{name:"Blue",value:"bg-blue-500"},{name:"Green",value:"bg-emerald-500"},{name:"Purple",value:"bg-purple-500"},{name:"Orange",value:"bg-orange-500"},{name:"Pink",value:"bg-pink-500"}];function gs({title:t="Weekly Schedule",subtitle:s,events:a,onEventAdd:c,onEventUpdate:g,onEventDelete:N,className:h,timeSlots:T=hs,daysOfWeek:I=ms,showAddButton:O=!0,eventColors:Y=xs,customFields:f=[],showWeekNavigation:v=!1,showHalfHourLines:R=!0,showCurrentTimeIndicator:z=!0,slotHeight:F=85}){const[W,_]=P.useState(!1),[H,J]=P.useState(null),[p,A]=P.useState({title:"",day:"",startTime:"",endTime:"",color:"bg-blue-500",description:"",recurrenceType:"none",specificDate:"",scheduleMode:"day"}),[B,L]=P.useState(new Date),x=v?Oe.calculateWeekDates(B):[],d=(n,D,j)=>{if(j){J(j);const k={title:j.title,day:j.day,startTime:j.startTime,endTime:j.endTime,color:j.color,description:j.description||"",recurrenceType:j.recurrenceType||"none",specificDate:j.specificDate||"",scheduleMode:j.specificDate?"date":"day"};f.forEach($=>{const X=j[$.key];k[$.key]=X instanceof Date?X.toISOString():X||($.type==="number"?0:"")}),A(k)}else{J(null);const k={title:"",day:n||"",startTime:D||"",endTime:"",color:"bg-blue-500",description:"",recurrenceType:"none",specificDate:"",scheduleMode:"day"};f.forEach($=>{k[$.key]=$.type==="number"?0:""}),A(k)}_(!0)},o=()=>{if(!p.title||!p.day||!p.startTime||!p.endTime)return;const n={...p,id:H?.id||Date.now().toString()};H?g?.(n):c?.(p),_(!1)},i=()=>{H&&(N?.(H.id),_(!1))},l=(n,D)=>a.filter(j=>{if(j.day!==n)return!1;const k=parseInt(j.startTime.replace(":","")),$=parseInt(D.replace(":",""));return k===$}),C=n=>{const[D,j]=n.startTime.split(":").map(Number),[k,$]=n.endTime.split(":").map(Number),X=D*60+j,ee=(k*60+$-X)/60,oe=Math.max(4,F*.1);return ee*F-oe};return e.jsxs(e.Fragment,{children:[e.jsxs(Ve,{className:u("w-full",h),children:[e.jsx(qe,{className:"pb-6 bg-gradient-to-r from-slate-50 to-gray-50 border-b border-gray-100",children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx(Je,{className:"text-2xl",children:t}),s&&e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:s})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[v&&e.jsx(ft,{onWeekChange:L,initialDate:B}),O&&e.jsxs(y,{onClick:()=>d(),className:"gap-2",children:[e.jsx(M.Plus,{className:"h-4 w-4"}),"Add Event"]})]})]})}),e.jsx(Ue,{className:"p-0",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("div",{className:"min-w-[800px]",children:[e.jsxs("div",{className:"grid border-b border-gray-200",style:{gridTemplateColumns:`80px repeat(${I.length}, 1fr)`},children:[e.jsx("div",{className:"p-3 bg-gray-50 border-r border-gray-200",children:e.jsx("span",{className:"text-xs font-medium text-gray-500",children:"Time"})}),I.map((n,D)=>{const j=new Date,k=v&&x[D],$=k&&k.getDate()===j.getDate()&&k.getMonth()===j.getMonth()&&k.getFullYear()===j.getFullYear();return e.jsxs("div",{className:"p-4 text-center border-r border-gray-200 last:border-r-0 bg-gray-50 hover:bg-white/50 transition-colors",children:[e.jsx("div",{className:`font-semibold text-sm ${$?"text-blue-600":"text-gray-800"}`,children:n}),v&&k&&e.jsx("div",{className:`text-xs mt-1 font-medium ${$?"text-blue-600 font-bold":"text-gray-500"}`,children:Oe.formatDateDisplay(k)})]},n)})]}),T.map(n=>{const D=new Date,j=D.getHours(),k=D.getMinutes(),[$,X]=n.split(":"),ne=parseInt(X||"0"),ee=parseInt($||"0")*60+ne,oe=ee+60,le=j*60+k,de=le>=ee&&le<oe,Ce=(le-ee)/60*F;return e.jsxs("div",{className:"grid border-b border-gray-100 last:border-b-0",style:{gridTemplateColumns:`80px repeat(${I.length}, 1fr)`},children:[e.jsx("div",{className:"p-2 bg-gray-50/50 border-r border-gray-200",children:e.jsx("span",{className:"text-xs text-gray-600",children:n})}),I.map((me,ue)=>{const ae=l(me,n),r=new Date,b=v&&x[ue],G=b?b.getDate()===r.getDate()&&b.getMonth()===r.getMonth()&&b.getFullYear()===r.getFullYear():!1;return e.jsxs("div",{className:"relative border-r border-gray-200 last:border-r-0 hover:bg-blue-50/30 cursor-pointer transition-colors",style:{minHeight:`${F}px`},onClick:()=>!ae.length&&d(me,n),children:[R&&e.jsx("div",{className:"absolute top-1/2 left-0 right-0 h-px bg-gray-200/60 z-[5]"}),ae.map(S=>{const re=C(S),Z=re<40;return e.jsx("div",{className:u("absolute rounded-md text-white cursor-pointer hover:scale-[1.02] transition-transform overflow-visible",S.color,Z?"inset-x-1 py-0.5 px-1":"inset-1 p-2"),style:{height:`${re}px`,zIndex:10,minHeight:Z?"auto":void 0},onClick:K=>{K.stopPropagation(),d(void 0,void 0,S)},children:Z?e.jsxs("div",{className:"flex items-center justify-between gap-1",children:[e.jsx("div",{className:"font-semibold truncate text-[10px] leading-tight flex-1",children:S.title}),e.jsxs("div",{className:"text-[9px] opacity-80 whitespace-nowrap",children:[S.startTime,"-",S.endTime]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-xs font-semibold truncate",children:S.title}),f.filter(K=>K.showInCard&&S[K.key]).map(K=>e.jsxs("div",{className:"text-xs opacity-90 flex items-center gap-1 mt-1",children:[K.icon,e.jsx("span",{className:"truncate",children:S[K.key]instanceof Date?S[K.key].toLocaleString():String(S[K.key]||"")})]},K.key)),e.jsx("div",{className:"text-xs opacity-80 mt-1",children:e.jsxs("span",{children:[S.startTime,"-",S.endTime]})})]})},S.id)}),z&&G&&de&&e.jsxs("div",{className:"absolute left-0 right-0 flex items-center z-20",style:{top:`${Ce-8}px`},children:[e.jsx("div",{className:"h-[3px] bg-red-500 absolute -left-14 right-0"}),e.jsxs("div",{className:"bg-red-500 text-white text-xs px-2 py-0.5 rounded font-bold whitespace-nowrap relative z-30 -ml-14",children:[D.getHours(),":",D.getMinutes().toString().padStart(2,"0")]})]}),!ae.length&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center opacity-0 hover:opacity-100 transition-opacity",children:e.jsx(M.Plus,{className:"h-5 w-5 text-gray-400"})})]},`${me}-${n}`)})]},n)})]})})})]}),e.jsx(us,{isOpen:W,onClose:()=>_(!1),title:H?"Edit Event":"Add New Event",children:e.jsxs("div",{className:"space-y-4 p-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Q,{className:"text-sm font-medium",children:"Schedule Type"}),e.jsxs(je,{value:String(p.scheduleMode),onValueChange:n=>A({...p,scheduleMode:n}),children:[e.jsx(fe,{children:e.jsx(we,{placeholder:"Select schedule type"})}),e.jsxs(ye,{children:[e.jsx(he,{value:"day",children:"By Day (Monday, Tuesday, etc.)"}),e.jsx(he,{value:"date",children:"By Date (Specific date)"})]})]}),e.jsx("p",{className:"text-xs text-gray-500",children:p.scheduleMode==="day"?"Schedule by day of the week (e.g., every Monday)":"Schedule by specific date (e.g., January 15, 2025)"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Q,{htmlFor:"title",children:"Title *"}),e.jsx(ie,{id:"title",value:String(p.title),onChange:n=>A({...p,title:n.target.value}),placeholder:"Event title"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[p.scheduleMode==="day"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(Q,{children:"Day *"}),e.jsxs(je,{value:String(p.day),onValueChange:n=>A({...p,day:n}),children:[e.jsx(fe,{children:e.jsx(we,{placeholder:"Select day"})}),e.jsx(ye,{children:I.map(n=>e.jsx(he,{value:n,children:n},n))})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(Q,{htmlFor:"specificDate",children:"Date *"}),e.jsx(ie,{id:"specificDate",type:"date",value:String(p.specificDate),onChange:n=>A({...p,specificDate:n.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Q,{htmlFor:"startTime",children:"Start Time *"}),e.jsx(ie,{id:"startTime",type:"time",value:String(p.startTime),onChange:n=>A({...p,startTime:n.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Q,{htmlFor:"endTime",children:"End Time *"}),e.jsx(ie,{id:"endTime",type:"time",value:String(p.endTime),onChange:n=>A({...p,endTime:n.target.value})})]})]}),f.length>0&&e.jsx("div",{className:"grid grid-cols-2 gap-4",children:f.map(n=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Q,{htmlFor:n.key,children:[n.label," ",n.required&&"*"]}),n.type==="select"?e.jsxs(je,{value:String(p[n.key]||""),onValueChange:D=>A({...p,[n.key]:D}),children:[e.jsx(fe,{children:e.jsx(we,{placeholder:n.placeholder||`Select ${n.label}`})}),e.jsx(ye,{children:n.options?.map(D=>e.jsx(he,{value:D.value,children:D.label},D.value))})]}):e.jsx(ie,{id:n.key,type:n.type,value:n.type==="number"?Number(p[n.key]||0):String(p[n.key]||""),onChange:D=>A({...p,[n.key]:n.type==="number"?parseInt(D.target.value)||0:D.target.value}),placeholder:n.placeholder})]},n.key))}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"isRecurring",checked:p.recurrenceType!=="none",onChange:n=>{n.target.checked?A({...p,recurrenceType:p.scheduleMode==="day"?"weekly":"monthly"}):A({...p,recurrenceType:"none"})},className:"w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 focus:ring-2"}),e.jsx(Q,{htmlFor:"isRecurring",className:"text-sm font-medium text-gray-700 cursor-pointer",children:p.scheduleMode==="day"?"Repeat every week on this day":"Repeat every month on this date"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Q,{children:"Color"}),e.jsxs(je,{value:String(p.color),onValueChange:n=>A({...p,color:n}),children:[e.jsx(fe,{children:e.jsx(we,{})}),e.jsx(ye,{children:Y.map(n=>e.jsx(he,{value:n.value,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:u("w-4 h-4 rounded",n.value)}),n.name]})},n.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Q,{htmlFor:"description",children:"Description"}),e.jsx(ie,{id:"description",value:String(p.description||""),onChange:n=>A({...p,description:n.target.value}),placeholder:"Optional description"})]}),e.jsxs("div",{className:"flex gap-2 pt-4",children:[H&&e.jsxs(y,{variant:"destructive",onClick:i,className:"gap-2",children:[e.jsx(M.Trash2,{className:"h-4 w-4"}),"Delete"]}),e.jsx("div",{className:"flex-1"}),e.jsx(y,{variant:"outline",onClick:()=>_(!1),children:"Cancel"}),e.jsxs(y,{onClick:o,children:[H?"Update":"Add"," Event"]})]})]})})]})}const $e=[{label:"UTC",offset:0},{label:"EST",offset:-5},{label:"CST",offset:-6},{label:"MST",offset:-7},{label:"PST",offset:-8},{label:"GMT",offset:0},{label:"CET",offset:1},{label:"EET",offset:2},{label:"IST",offset:5.5},{label:"CST (China)",offset:8},{label:"JST",offset:9},{label:"AEST",offset:10},{label:"NZST",offset:12},{label:"HST",offset:-10},{label:"AKST",offset:-9},{label:"Asia/Bangkok",offset:7}],ps=(t,s,a)=>{const c=$e.find(h=>h.label===s)?.offset||0,g=$e.find(h=>h.label===a)?.offset||0,N=new Date(t);return N.setHours(N.getHours()+(g-c)),N},fs=(t,s,a="24h",c=!1)=>{const g=a==="12h"?t.getHours()%12||12:t.getHours(),N=t.getMinutes().toString().padStart(2,"0"),h=t.getSeconds().toString().padStart(2,"0"),T=t.getHours()>=12?"PM":"AM";let I=`${g.toString().padStart(2,"0")}:${N}`;return c&&(I+=`:${h}`),a==="12h"&&(I+=` ${T}`),I+=` ${s}`,I};exports.Button=y;exports.Calendar=os;exports.Card=Ve;exports.CardContent=Ue;exports.CardDescription=ct;exports.CardFooter=dt;exports.CardHeader=qe;exports.CardTitle=Je;exports.Checkbox=Re;exports.DataGrid=Ut;exports.DataGridColumnHeader=Qt;exports.DataGridPagination=Zt;exports.DataGridTable=Kt;exports.DataGridTableRowSelect=ts;exports.DataGridTableRowSelectAll=es;exports.DataTable=Jt;exports.DatePicker=is;exports.DropdownMenu=Pt;exports.DropdownMenuCheckboxItem=$t;exports.DropdownMenuContent=At;exports.DropdownMenuGroup=Et;exports.DropdownMenuItem=Ot;exports.DropdownMenuLabel=Lt;exports.DropdownMenuPortal=Ht;exports.DropdownMenuRadioGroup=Yt;exports.DropdownMenuRadioItem=_t;exports.DropdownMenuSeparator=Gt;exports.DropdownMenuShortcut=Wt;exports.DropdownMenuSub=Bt;exports.DropdownMenuSubContent=qt;exports.DropdownMenuSubTrigger=Vt;exports.DropdownMenuTrigger=Ft;exports.Input=ie;exports.Label=Q;exports.Modal=ut;exports.Popover=We;exports.PopoverAnchor=ls;exports.PopoverContent=Ie;exports.PopoverTrigger=Be;exports.Schedule=gs;exports.Select=je;exports.SelectContent=ye;exports.SelectGroup=Xt;exports.SelectItem=he;exports.SelectLabel=lt;exports.SelectSeparator=it;exports.SelectTrigger=fe;exports.SelectValue=we;exports.Separator=st;exports.TIMEZONES=$e;exports.Table=Ye;exports.TableBody=Le;exports.TableCaption=zt;exports.TableCell=ke;exports.TableFooter=It;exports.TableHead=Ge;exports.TableHeader=_e;exports.TableRow=be;exports.TimePicker=cs;exports.WeekNavigator=ft;exports.cn=u;exports.convertTimezone=ps;exports.formatTimeWithTimezone=fs;exports.useDataGrid=De;exports.weekNavigatorUtils=Oe;
2
2
  //# sourceMappingURL=takaui.cjs.map