{"ast":null,"code":"import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport * as React from 'react';\nimport { useIsDayDisabled } from '../internals/hooks/validation/useDateValidation';\nimport { useUtils, useNow } from '../internals/hooks/useUtils';\nexport const createCalendarStateReducer = (reduceAnimations, disableSwitchToMonthOnDayFocus, utils) => (state, action) => {\n switch (action.type) {\n case 'changeMonth':\n return _extends({}, state, {\n slideDirection: action.direction,\n currentMonth: action.newMonth,\n isMonthSwitchingAnimating: !reduceAnimations\n });\n case 'finishMonthSwitchingAnimation':\n return _extends({}, state, {\n isMonthSwitchingAnimating: false\n });\n case 'changeFocusedDay':\n {\n if (state.focusedDay != null && action.focusedDay != null && utils.isSameDay(action.focusedDay, state.focusedDay)) {\n return state;\n }\n const needMonthSwitch = action.focusedDay != null && !disableSwitchToMonthOnDayFocus && !utils.isSameMonth(state.currentMonth, action.focusedDay);\n return _extends({}, state, {\n focusedDay: action.focusedDay,\n isMonthSwitchingAnimating: needMonthSwitch && !reduceAnimations && !action.withoutMonthSwitchingAnimation,\n currentMonth: needMonthSwitch ? utils.startOfMonth(action.focusedDay) : state.currentMonth,\n slideDirection: action.focusedDay != null && utils.isAfterDay(action.focusedDay, state.currentMonth) ? 'left' : 'right'\n });\n }\n default:\n throw new Error('missing support');\n }\n};\nexport const useCalendarState = ({\n date,\n defaultCalendarMonth,\n disableFuture,\n disablePast,\n disableSwitchToMonthOnDayFocus = false,\n maxDate,\n minDate,\n onMonthChange,\n reduceAnimations,\n shouldDisableDate\n}) => {\n var _ref;\n const now = useNow();\n const utils = useUtils();\n const reducerFn = React.useRef(createCalendarStateReducer(Boolean(reduceAnimations), disableSwitchToMonthOnDayFocus, utils)).current;\n const [calendarState, dispatch] = React.useReducer(reducerFn, {\n isMonthSwitchingAnimating: false,\n focusedDay: date || now,\n currentMonth: utils.startOfMonth((_ref = date != null ? date : defaultCalendarMonth) != null ? _ref : now),\n slideDirection: 'left'\n });\n const handleChangeMonth = React.useCallback(payload => {\n dispatch(_extends({\n type: 'changeMonth'\n }, payload));\n if (onMonthChange) {\n onMonthChange(payload.newMonth);\n }\n }, [onMonthChange]);\n const changeMonth = React.useCallback(newDate => {\n const newDateRequested = newDate != null ? newDate : now;\n if (utils.isSameMonth(newDateRequested, calendarState.currentMonth)) {\n return;\n }\n handleChangeMonth({\n newMonth: utils.startOfMonth(newDateRequested),\n direction: utils.isAfterDay(newDateRequested, calendarState.currentMonth) ? 'left' : 'right'\n });\n }, [calendarState.currentMonth, handleChangeMonth, now, utils]);\n const isDateDisabled = useIsDayDisabled({\n shouldDisableDate,\n minDate,\n maxDate,\n disableFuture,\n disablePast\n });\n const onMonthSwitchingAnimationEnd = React.useCallback(() => {\n dispatch({\n type: 'finishMonthSwitchingAnimation'\n });\n }, []);\n const changeFocusedDay = React.useCallback((newFocusedDate, withoutMonthSwitchingAnimation) => {\n if (!isDateDisabled(newFocusedDate)) {\n dispatch({\n type: 'changeFocusedDay',\n focusedDay: newFocusedDate,\n withoutMonthSwitchingAnimation\n });\n }\n }, [isDateDisabled]);\n return {\n calendarState,\n changeMonth,\n changeFocusedDay,\n isDateDisabled,\n onMonthSwitchingAnimationEnd,\n handleChangeMonth\n };\n};","map":{"version":3,"names":["_extends","React","useIsDayDisabled","useUtils","useNow","createCalendarStateReducer","reduceAnimations","disableSwitchToMonthOnDayFocus","utils","state","action","type","slideDirection","direction","currentMonth","newMonth","isMonthSwitchingAnimating","focusedDay","isSameDay","needMonthSwitch","isSameMonth","withoutMonthSwitchingAnimation","startOfMonth","isAfterDay","Error","useCalendarState","date","defaultCalendarMonth","disableFuture","disablePast","maxDate","minDate","onMonthChange","shouldDisableDate","_ref","now","reducerFn","useRef","Boolean","current","calendarState","dispatch","useReducer","handleChangeMonth","useCallback","payload","changeMonth","newDate","newDateRequested","isDateDisabled","onMonthSwitchingAnimationEnd","changeFocusedDay","newFocusedDate"],"sources":["/home/gnx/Desktop/ETB/ETB-FrontEnd/node_modules/@mui/x-date-pickers/CalendarPicker/useCalendarState.js"],"sourcesContent":["import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport * as React from 'react';\nimport { useIsDayDisabled } from '../internals/hooks/validation/useDateValidation';\nimport { useUtils, useNow } from '../internals/hooks/useUtils';\nexport const createCalendarStateReducer = (reduceAnimations, disableSwitchToMonthOnDayFocus, utils) => (state, action) => {\n switch (action.type) {\n case 'changeMonth':\n return _extends({}, state, {\n slideDirection: action.direction,\n currentMonth: action.newMonth,\n isMonthSwitchingAnimating: !reduceAnimations\n });\n\n case 'finishMonthSwitchingAnimation':\n return _extends({}, state, {\n isMonthSwitchingAnimating: false\n });\n\n case 'changeFocusedDay':\n {\n if (state.focusedDay != null && action.focusedDay != null && utils.isSameDay(action.focusedDay, state.focusedDay)) {\n return state;\n }\n\n const needMonthSwitch = action.focusedDay != null && !disableSwitchToMonthOnDayFocus && !utils.isSameMonth(state.currentMonth, action.focusedDay);\n return _extends({}, state, {\n focusedDay: action.focusedDay,\n isMonthSwitchingAnimating: needMonthSwitch && !reduceAnimations && !action.withoutMonthSwitchingAnimation,\n currentMonth: needMonthSwitch ? utils.startOfMonth(action.focusedDay) : state.currentMonth,\n slideDirection: action.focusedDay != null && utils.isAfterDay(action.focusedDay, state.currentMonth) ? 'left' : 'right'\n });\n }\n\n default:\n throw new Error('missing support');\n }\n};\nexport const useCalendarState = ({\n date,\n defaultCalendarMonth,\n disableFuture,\n disablePast,\n disableSwitchToMonthOnDayFocus = false,\n maxDate,\n minDate,\n onMonthChange,\n reduceAnimations,\n shouldDisableDate\n}) => {\n var _ref;\n\n const now = useNow();\n const utils = useUtils();\n const reducerFn = React.useRef(createCalendarStateReducer(Boolean(reduceAnimations), disableSwitchToMonthOnDayFocus, utils)).current;\n const [calendarState, dispatch] = React.useReducer(reducerFn, {\n isMonthSwitchingAnimating: false,\n focusedDay: date || now,\n currentMonth: utils.startOfMonth((_ref = date != null ? date : defaultCalendarMonth) != null ? _ref : now),\n slideDirection: 'left'\n });\n const handleChangeMonth = React.useCallback(payload => {\n dispatch(_extends({\n type: 'changeMonth'\n }, payload));\n\n if (onMonthChange) {\n onMonthChange(payload.newMonth);\n }\n }, [onMonthChange]);\n const changeMonth = React.useCallback(newDate => {\n const newDateRequested = newDate != null ? newDate : now;\n\n if (utils.isSameMonth(newDateRequested, calendarState.currentMonth)) {\n return;\n }\n\n handleChangeMonth({\n newMonth: utils.startOfMonth(newDateRequested),\n direction: utils.isAfterDay(newDateRequested, calendarState.currentMonth) ? 'left' : 'right'\n });\n }, [calendarState.currentMonth, handleChangeMonth, now, utils]);\n const isDateDisabled = useIsDayDisabled({\n shouldDisableDate,\n minDate,\n maxDate,\n disableFuture,\n disablePast\n });\n const onMonthSwitchingAnimationEnd = React.useCallback(() => {\n dispatch({\n type: 'finishMonthSwitchingAnimation'\n });\n }, []);\n const changeFocusedDay = React.useCallback((newFocusedDate, withoutMonthSwitchingAnimation) => {\n if (!isDateDisabled(newFocusedDate)) {\n dispatch({\n type: 'changeFocusedDay',\n focusedDay: newFocusedDate,\n withoutMonthSwitchingAnimation\n });\n }\n }, [isDateDisabled]);\n return {\n calendarState,\n changeMonth,\n changeFocusedDay,\n isDateDisabled,\n onMonthSwitchingAnimationEnd,\n handleChangeMonth\n };\n};"],"mappings":"AAAA,OAAOA,QAAQ,MAAM,oCAAoC;AACzD,OAAO,KAAKC,KAAK,MAAM,OAAO;AAC9B,SAASC,gBAAgB,QAAQ,iDAAiD;AAClF,SAASC,QAAQ,EAAEC,MAAM,QAAQ,6BAA6B;AAC9D,OAAO,MAAMC,0BAA0B,GAAGA,CAACC,gBAAgB,EAAEC,8BAA8B,EAAEC,KAAK,KAAK,CAACC,KAAK,EAAEC,MAAM,KAAK;EACxH,QAAQA,MAAM,CAACC,IAAI;IACjB,KAAK,aAAa;MAChB,OAAOX,QAAQ,CAAC,CAAC,CAAC,EAAES,KAAK,EAAE;QACzBG,cAAc,EAAEF,MAAM,CAACG,SAAS;QAChCC,YAAY,EAAEJ,MAAM,CAACK,QAAQ;QAC7BC,yB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