{"version":3,"file":"use-time-panel.js","sources":["../../../../../../../packages/components/time-picker/src/composables/use-time-panel.ts"],"sourcesContent":["import type { Dayjs } from 'dayjs'\n\nimport type {\n GetDisabledHoursState,\n GetDisabledMinutesState,\n GetDisabledSecondsState,\n} from '../types'\n\ntype UseTimePanelProps = {\n getAvailableHours: GetDisabledHoursState\n getAvailableMinutes: GetDisabledMinutesState\n getAvailableSeconds: GetDisabledSecondsState\n}\n\nexport const useTimePanel = ({\n getAvailableHours,\n getAvailableMinutes,\n getAvailableSeconds,\n}: UseTimePanelProps) => {\n const getAvailableTime = (\n date: Dayjs,\n role: string,\n first: boolean,\n compareDate?: Dayjs\n ) => {\n const availableTimeGetters = {\n hour: getAvailableHours,\n minute: getAvailableMinutes,\n second: getAvailableSeconds,\n } as const\n let result = date\n ;(['hour', 'minute', 'second'] as const).forEach((type) => {\n if (availableTimeGetters[type]) {\n let availableTimeSlots: number[]\n const method = availableTimeGetters[type]\n switch (type) {\n case 'minute': {\n availableTimeSlots = (method as typeof getAvailableMinutes)(\n result.hour(),\n role,\n compareDate\n )\n break\n }\n case 'second': {\n availableTimeSlots = (method as typeof getAvailableSeconds)(\n result.hour(),\n result.minute(),\n role,\n compareDate\n )\n break\n }\n default: {\n availableTimeSlots = (method as typeof getAvailableHours)(\n role,\n compareDate\n )\n break\n }\n }\n\n if (\n availableTimeSlots?.length &&\n !availableTimeSlots.includes(result[type]())\n ) {\n const pos = first ? 0 : availableTimeSlots.length - 1\n result = result[type](availableTimeSlots[pos]) as unknown as Dayjs\n }\n }\n })\n return result\n }\n\n const timePickerOptions: Record void> = {}\n\n const onSetOption = ([key, val]: [string, (...args: any[]) => void]) => {\n timePickerOptions[key] = val\n }\n\n return {\n timePickerOptions,\n\n getAvailableTime,\n onSetOption,\n }\n}\n"],"names":[],"mappings":";;;;AAAY,MAAC,YAAY,GAAG,CAAC;AAC7B,EAAE,iBAAiB;AACnB,EAAE,mBAAmB;AACrB,EAAE,mBAAmB;AACrB,CAAC,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