{"version":3,"file":"index.cjs","sources":["../src/utils/presets.ts","../src/index.ts"],"sourcesContent":["/**\n * Preset filter and formatter functions for common use cases\n *\n * @module utils/presets\n */\n\nimport type {\n  DayFilterContext,\n  DayFilterResult,\n  TimeFilterResult,\n  TimeFormatter,\n} from \"../types\";\n\n// =============================================================================\n// Day Filter Presets\n// =============================================================================\n\n/**\n * Hide weekends (Saturday and Sunday)\n *\n * @returns Day filter function that excludes weekends\n * @example\n * ```typescript\n * new Calendar({\n *   view: {\n *     type: 'week',\n *     dayFilter: hideWeekends()\n *   }\n * });\n * ```\n */\nexport function hideWeekends(): (\n  date: unknown,\n  context: DayFilterContext,\n) => DayFilterResult {\n  return (_date: unknown, context: DayFilterContext) => {\n    return !context.isWeekend;\n  };\n}\n\n/**\n * Hide weekdays (Monday to Friday)\n *\n * @returns Day filter function that excludes weekdays\n * @example\n * ```typescript\n * new Calendar({\n *   view: {\n *     type: 'week',\n *     dayFilter: hideWeekdays()\n *   }\n * });\n * ```\n */\nexport function hideWeekdays(): (\n  date: unknown,\n  context: DayFilterContext,\n) => DayFilterResult {\n  return (_date: unknown, context: DayFilterContext) => {\n    return context.isWeekend;\n  };\n}\n\n/**\n * Show only specific days of the week\n *\n * @param days - Array of day indices to show (0 = Sunday, 1 = Monday, ..., 6 = Saturday)\n * @returns Day filter function that shows only the specified days\n * @example\n * ```typescript\n * // Show only Monday to Friday\n * new Calendar({\n *   view: {\n *     type: 'week',\n *     dayFilter: onlyDays([1, 2, 3, 4, 5])\n *   }\n * });\n * ```\n */\nexport function onlyDays(days: number[]): (\n  date: unknown,\n  context: DayFilterContext,\n) => DayFilterResult {\n  return (_date: unknown, context: DayFilterContext) => {\n    return days.includes(context.dayOfWeek);\n  };\n}\n\n/**\n * Hide specific days of the week\n *\n * @param days - Array of day indices to hide (0 = Sunday, 1 = Monday, ..., 6 = Saturday)\n * @returns Day filter function that hides the specified days\n * @example\n * ```typescript\n * // Hide Tuesday and Thursday\n * new Calendar({\n *   view: {\n *     type: 'week',\n *     dayFilter: hideDays([2, 4])\n *   }\n * });\n * ```\n */\nexport function hideDays(days: number[]): (\n  date: unknown,\n  context: DayFilterContext,\n) => DayFilterResult {\n  return (_date: unknown, context: DayFilterContext) => {\n    return !days.includes(context.dayOfWeek);\n  };\n}\n\n// =============================================================================\n// Time Filter Presets\n// =============================================================================\n\n/**\n * Show only working hours\n *\n * @param startHour - Start hour (default: 8)\n * @param endHour - End hour, exclusive (default: 18)\n * @returns Time filter function that shows only the specified hour range\n * @example\n * ```typescript\n * // Show 9:00 AM to 5:00 PM\n * new Calendar({\n *   view: {\n *     type: 'day',\n *     timeFilter: workingHours(9, 17)\n *   }\n * });\n * ```\n */\nexport function workingHours(\n  startHour = 8,\n  endHour = 18,\n): (hour: number) => TimeFilterResult {\n  return (hour: number) => {\n    return hour >= startHour && hour < endHour;\n  };\n}\n\n/**\n * Hide specific hours\n *\n * @param hours - Array of hour values to hide (0-23)\n * @returns Time filter function that hides the specified hours\n * @example\n * ```typescript\n * // Hide midnight and lunch hour\n * new Calendar({\n *   view: {\n *     type: 'day',\n *     timeFilter: hideHours([0, 12])\n *   }\n * });\n * ```\n */\nexport function hideHours(hours: number[]): (hour: number) => TimeFilterResult {\n  return (hour: number) => {\n    return !hours.includes(hour);\n  };\n}\n\n/**\n * Show only specific hours\n *\n * @param hours - Array of hour values to show (0-23)\n * @returns Time filter function that shows only the specified hours\n * @example\n * ```typescript\n * // Show only 9, 10, 11, 14, 15, 16\n * new Calendar({\n *   view: {\n *     type: 'day',\n *     timeFilter: onlyHours([9, 10, 11, 14, 15, 16])\n *   }\n * });\n * ```\n */\nexport function onlyHours(hours: number[]): (hour: number) => TimeFilterResult {\n  return (hour: number) => {\n    return hours.includes(hour);\n  };\n}\n\n// =============================================================================\n// Time Formatter Presets\n// =============================================================================\n\n/**\n * Format time in 12-hour format with AM/PM\n *\n * @returns Time formatter function for 12-hour format\n * @example\n * ```typescript\n * new Calendar({\n *   view: {\n *     type: 'day',\n *     timeFormatter: format12h()\n *   }\n * });\n * // Output: \"8 AM\", \"12 PM\", \"3:30 PM\"\n * ```\n */\nexport function format12h(): TimeFormatter {\n  return (hour: number, minute = 0) => {\n    const period = hour >= 12 ? \"PM\" : \"AM\";\n    const h = hour % 12 || 12;\n    return minute > 0\n      ? `${h}:${minute.toString().padStart(2, \"0\")} ${period}`\n      : `${h} ${period}`;\n  };\n}\n\n/**\n * Format time in 24-hour format (HH:mm or HH:00)\n *\n * @returns Time formatter function for 24-hour format\n * @example\n * ```typescript\n * new Calendar({\n *   view: {\n *     type: 'day',\n *     timeFormatter: format24h()\n *   }\n * });\n * // Output: \"08:00\", \"12:00\", \"15:30\"\n * ```\n */\nexport function format24h(): TimeFormatter {\n  return (hour: number, minute = 0) => {\n    return minute > 0\n      ? `${hour.toString().padStart(2, \"0\")}:${minute.toString().padStart(2, \"0\")}`\n      : `${hour}:00`;\n  };\n}\n\n/**\n * Custom time labels for specific hours\n *\n * @param labels - Mapping of hour to label string\n * @param fallback - Optional fallback formatter for unlabeled hours (defaults to \"HH:00\")\n * @returns Time formatter function with custom labels\n * @example\n * ```typescript\n * new Calendar({\n *   view: {\n *     type: 'day',\n *     timeFormatter: customTimeLabels({\n *       9: 'Morning Standup',\n *       12: 'Lunch Break',\n *       17: 'End of Day'\n *     })\n *   }\n * });\n * // Output: \"Morning Standup\" at 9:00, \"12:00\" at other hours\n * ```\n */\nexport function customTimeLabels(\n  labels: Record<number, string>,\n  fallback?: TimeFormatter,\n): TimeFormatter {\n  const defaultFormatter = fallback || format24h();\n  return (hour: number, minute = 0) => {\n    return labels[hour] || defaultFormatter(hour, minute);\n  };\n}\n\n/**\n * Compact time format (no leading zeros, no \":00\" for whole hours)\n *\n * @returns Time formatter function for compact format\n * @example\n * ```typescript\n * new Calendar({\n *   view: {\n *     type: 'day',\n *     timeFormatter: formatCompact()\n *   }\n * });\n * // Output: \"8\", \"12\", \"3:30\"\n * ```\n */\nexport function formatCompact(): TimeFormatter {\n  return (hour: number, minute = 0) => {\n    return minute > 0 ? `${hour}:${minute.toString().padStart(2, \"0\")}` : `${hour}`;\n  };\n}\n","/**\n * @taskgenius/calendar\n *\n * A lightweight, configurable TypeScript calendar component library\n * with drag-and-drop support and extensible view system.\n */\n\n// Main Calendar class (batteries-included)\nimport {\n  Calendar as CalendarCore,\n  type ExtendedCalendarConfig,\n} from \"./core/Calendar\";\nimport { ViewRegistry, MonthView, WeekView, DayView } from \"./views\";\n\n/**\n * Default Calendar exports with built-in views pre-registered for\n * backward compatibility. Use `CalendarCore` for tree-shaking +\n * manual view registration.\n */\nexport class Calendar<T = Date> extends CalendarCore<T> {\n  constructor(\n    containerSelector: string | HTMLElement,\n    config: ExtendedCalendarConfig = {},\n  ) {\n    const registry = config.viewRegistry ?? new ViewRegistry();\n    const requestedView = config.view?.type ?? \"week\";\n\n    // Ensure built-in views exist when requested or when registry is empty\n    if (registry.size === 0 || !registry.has(requestedView)) {\n      if (!registry.has(\"month\")) registry.register(MonthView);\n      if (!registry.has(\"week\")) registry.register(WeekView);\n      if (!registry.has(\"day\")) registry.register(DayView);\n    }\n\n    super(containerSelector, { ...config, viewRegistry: registry });\n  }\n}\n\n// Tree-shakeable core (manual view registration)\nexport { CalendarCore };\nexport type { ExtendedCalendarConfig } from \"./core/Calendar\";\n\n// Core utilities\nexport { EventManager } from \"./core/EventManager\";\nexport { DragController } from \"./core/DragController\";\nexport { InteractionController } from \"./core/InteractionController\";\n\n// Date adapters\nexport { DayJsAdapter } from \"./adapters/DayJsAdapter\";\nexport { NativeDateAdapter } from \"./adapters/NativeDateAdapter\";\nexport { DateFnsAdapter } from \"./adapters/DateFnsAdapter\";\nexport type { DateAdapter, TimeUnit } from \"./adapters/DateAdapter\";\n\n// Engines\nexport { MonthEngine } from \"./engines/MonthEngine\";\nexport { TimeEngine } from \"./engines/TimeEngine\";\n\n// Renderers\nexport { MonthRenderer } from \"./renderers/MonthRenderer\";\nexport { TimeRenderer } from \"./renderers/TimeRenderer\";\n\n// Views - Extensible view system\nexport {\n  // Base classes\n  BaseView,\n  ViewRegistry,\n  createViewRegistry,\n  // Built-in views (imported on-demand for tree-shaking)\n  MonthView,\n  TimeView,\n  WeekView,\n  DayView,\n} from \"./views\";\nexport type {\n  ViewContext,\n  ViewMeta,\n  ViewRenderOptions,\n  ViewClass,\n  ViewConstructor, // Legacy alias for ViewClass\n  ViewRegistrationOptions,\n} from \"./views\";\n\n// Styles\nexport { applyThemeVariables, clearThemeVariables } from \"./styles\";\n\n// Filter/Format preset utilities\nexport {\n  hideWeekends,\n  hideWeekdays,\n  onlyDays,\n  hideDays,\n  workingHours,\n  hideHours,\n  onlyHours,\n  format12h,\n  format24h,\n  customTimeLabels,\n  formatCompact,\n} from \"./utils/presets\";\n\n// Factory presets for quick setup (includes all views)\n// For tree-shaking optimization, use Calendar directly with manual view registration\nexport {\n  createCalendar,\n  createFullCalendar,\n  createMonthCalendar,\n  createWeekCalendar,\n  createDayCalendar,\n  registerBuiltInViews,\n} from \"./presets\";\nexport type { FullCalendarConfig } from \"./presets\";\n\n// Types\nexport type {\n  CalendarEvent,\n  CalendarConfig,\n  ViewType,\n  ViewConfig,\n  DraggableConfig,\n  ThemeConfig,\n  MonthLayoutItem,\n  AllDayLayoutItem,\n  TimeLayoutItem,\n  GridCell,\n  TimeColumn,\n  VisibleDay,\n  DragMode,\n  DragType,\n  DragState,\n  ResolvedCalendarConfig,\n  DayFilterContext,\n  DayRenderConfig,\n  TimeSlotConfig,\n  TimeFormatter,\n  DayFilterResult,\n  TimeFilterResult,\n  DateCellContext,\n  EventStyle,\n  EventRenderContext,\n} from \"./types\";\n"],"names":["format24h","hour","minute","toString","padStart","Calendar","CalendarCore","constructor","containerSelector","config","registry","viewRegistry","ViewRegistry","requestedView","_a","view","type","size","has","register","MonthView","WeekView","DayView","super","labels","fallback","defaultFormatter","period","h","days","_date","context","includes","dayOfWeek","hours","isWeekend","startHour","endHour"],"mappings":"oOAuOO,SAASA,IACd,MAAO,CAACC,EAAcC,EA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