UNPKG

@fk6/react-datepicker

Version:

React date picker with Hijri & Gregorian support, theming, localization, and more.

1,370 lines 50.3 kB
import we, { useMemo as U, Fragment as We, useRef as me, useState as te, useEffect as oe, forwardRef as ye, useCallback as Te } from "react"; import w, { isMoment as xe } from "moment-hijri"; import { createPortal as Be } from "react-dom"; var ke = { exports: {} }, he = {}; /** * @license React * react-jsx-runtime.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ var je; function Fe() { if (je) return he; je = 1; var e = Symbol.for("react.transitional.element"), r = Symbol.for("react.fragment"); function o(c, i, s) { var _ = null; if (s !== void 0 && (_ = "" + s), i.key !== void 0 && (_ = "" + i.key), "key" in i) { s = {}; for (var f in i) f !== "key" && (s[f] = i[f]); } else s = i; return i = s.ref, { $$typeof: e, type: c, key: _, ref: i !== void 0 ? i : null, props: s }; } return he.Fragment = r, he.jsx = o, he.jsxs = o, he; } var pe = {}; /** * @license React * react-jsx-runtime.development.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ var De; function He() { return De || (De = 1, process.env.NODE_ENV !== "production" && (function() { function e(t) { if (t == null) return null; if (typeof t == "function") return t.$$typeof === v ? null : t.displayName || t.name || null; if (typeof t == "string") return t; switch (t) { case D: return "Fragment"; case k: return "Profiler"; case m: return "StrictMode"; case d: return "Suspense"; case j: return "SuspenseList"; case W: return "Activity"; } if (typeof t == "object") switch (typeof t.tag == "number" && console.error( "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue." ), t.$$typeof) { case R: return "Portal"; case T: return (t.displayName || "Context") + ".Provider"; case h: return (t._context.displayName || "Context") + ".Consumer"; case n: var u = t.render; return t = t.displayName, t || (t = u.displayName || u.name || "", t = t !== "" ? "ForwardRef(" + t + ")" : "ForwardRef"), t; case Y: return u = t.displayName || null, u !== null ? u : e(t.type) || "Memo"; case O: u = t._payload, t = t._init; try { return e(t(u)); } catch { } } return null; } function r(t) { return "" + t; } function o(t) { try { r(t); var u = !1; } catch { u = !0; } if (u) { u = console; var N = u.error, I = typeof Symbol == "function" && Symbol.toStringTag && t[Symbol.toStringTag] || t.constructor.name || "Object"; return N.call( u, "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.", I ), r(t); } } function c(t) { if (t === D) return "<>"; if (typeof t == "object" && t !== null && t.$$typeof === O) return "<...>"; try { var u = e(t); return u ? "<" + u + ">" : "<...>"; } catch { return "<...>"; } } function i() { var t = $.A; return t === null ? null : t.getOwner(); } function s() { return Error("react-stack-top-frame"); } function _(t) { if (C.call(t, "key")) { var u = Object.getOwnPropertyDescriptor(t, "key").get; if (u && u.isReactWarning) return !1; } return t.key !== void 0; } function f(t, u) { function N() { q || (q = !0, console.error( "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)", u )); } N.isReactWarning = !0, Object.defineProperty(t, "key", { get: N, configurable: !0 }); } function y() { var t = e(this.type); return G[t] || (G[t] = !0, console.error( "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release." )), t = this.props.ref, t !== void 0 ? t : null; } function p(t, u, N, I, H, V, P, Q) { return N = V.ref, t = { $$typeof: S, type: t, key: u, props: V, _owner: H }, (N !== void 0 ? N : null) !== null ? Object.defineProperty(t, "ref", { enumerable: !1, get: y }) : Object.defineProperty(t, "ref", { enumerable: !1, value: null }), t._store = {}, Object.defineProperty(t._store, "validated", { configurable: !1, enumerable: !1, writable: !0, value: 0 }), Object.defineProperty(t, "_debugInfo", { configurable: !1, enumerable: !1, writable: !0, value: null }), Object.defineProperty(t, "_debugStack", { configurable: !1, enumerable: !1, writable: !0, value: P }), Object.defineProperty(t, "_debugTask", { configurable: !1, enumerable: !1, writable: !0, value: Q }), Object.freeze && (Object.freeze(t.props), Object.freeze(t)), t; } function E(t, u, N, I, H, V, P, Q) { var L = u.children; if (L !== void 0) if (I) if (F(L)) { for (I = 0; I < L.length; I++) b(L[I]); Object.freeze && Object.freeze(L); } else console.error( "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead." ); else b(L); if (C.call(u, "key")) { L = e(t); var re = Object.keys(u).filter(function(ue) { return ue !== "key"; }); I = 0 < re.length ? "{key: someKey, " + re.join(": ..., ") + ": ...}" : "{key: someKey}", M[L + I] || (re = 0 < re.length ? "{" + re.join(": ..., ") + ": ...}" : "{}", console.error( `A props object containing a "key" prop is being spread into JSX: let props = %s; <%s {...props} /> React keys must be passed directly to JSX without using spread: let props = %s; <%s key={someKey} {...props} />`, I, L, re, L ), M[L + I] = !0); } if (L = null, N !== void 0 && (o(N), L = "" + N), _(u) && (o(u.key), L = "" + u.key), "key" in u) { N = {}; for (var ne in u) ne !== "key" && (N[ne] = u[ne]); } else N = u; return L && f( N, typeof t == "function" ? t.displayName || t.name || "Unknown" : t ), p( t, L, V, H, i(), N, P, Q ); } function b(t) { typeof t == "object" && t !== null && t.$$typeof === S && t._store && (t._store.validated = 1); } var g = we, S = Symbol.for("react.transitional.element"), R = Symbol.for("react.portal"), D = Symbol.for("react.fragment"), m = Symbol.for("react.strict_mode"), k = Symbol.for("react.profiler"), h = Symbol.for("react.consumer"), T = Symbol.for("react.context"), n = Symbol.for("react.forward_ref"), d = Symbol.for("react.suspense"), j = Symbol.for("react.suspense_list"), Y = Symbol.for("react.memo"), O = Symbol.for("react.lazy"), W = Symbol.for("react.activity"), v = Symbol.for("react.client.reference"), $ = g.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, C = Object.prototype.hasOwnProperty, F = Array.isArray, X = console.createTask ? console.createTask : function() { return null; }; g = { react_stack_bottom_frame: function(t) { return t(); } }; var q, G = {}, z = g.react_stack_bottom_frame.bind( g, s )(), a = X(c(s)), M = {}; pe.Fragment = D, pe.jsx = function(t, u, N, I, H) { var V = 1e4 > $.recentlyCreatedOwnerStacks++; return E( t, u, N, !1, I, H, V ? Error("react-stack-top-frame") : z, V ? X(c(t)) : a ); }, pe.jsxs = function(t, u, N, I, H) { var V = 1e4 > $.recentlyCreatedOwnerStacks++; return E( t, u, N, !0, I, H, V ? Error("react-stack-top-frame") : z, V ? X(c(t)) : a ); }; })()), pe; } var Ne; function $e() { return Ne || (Ne = 1, process.env.NODE_ENV === "production" ? ke.exports = Fe() : ke.exports = He()), ke.exports; } var l = $e(); const Me = "1937-03-14", se = w(Me), Se = "2077-10-17", ee = w(Se), Ee = (e, r) => { if (e) { const o = w(e); o.isBefore(se) ? console.error(`@fk6/react-datepicker ERROR: The minimum supported date is (${Me})`) : o.isAfter(ee) && console.error(`@fk6/react-datepicker ERROR: The maximum supported date is (${Se})`); } if (r) { const o = w(r); o.isBefore(se) ? console.error(`@fk6/react-datepicker ERROR: The minimum supported date is (${Me})`) : o.isAfter(ee) && console.error(`@fk6/react-datepicker ERROR: The maximum supported date is (${Se})`); } }, ce = document.documentElement.lang ?? "en", ie = (e, r) => { if (!e) return; const o = xe(e) ? e.locale(r ?? ce) : w(e).locale(r ?? ce); return o.isBetween(se, ee, void 0, "[]") ? xe(e) ? e.toDate() : e : o.year() - ee.year() >= 0 ? ee.toDate() : se.toDate(); }, Ue = (e, r) => { if (e) return e.isBetween(se, ee, void 0, "[]") ? e : e.year() - ee.year() >= 0 ? ee.locale(r ?? ce) : se.locale(r ?? ce); }, B = (e, r) => w(e).locale(r ?? ce), Ve = (e, r, o = !0, c) => { let i = r.hour; const s = xe(e) ? e : w(e).locale(c ?? ce); return o && r.meridiem && (i || i === 0) && (r.meridiem === w.localeData(c).meridiem(12, 0, !1) && i < 12 && (i += 12), r.meridiem === w.localeData(c).meridiem(0, 0, !1) && i === 12 && (i = 0)), s.clone().hour(i || 0).minute(r.minute || 0).second(r.second || 0).millisecond(0); }, _e = (e, r = !0, o) => { if (!e) return; const c = w(e).locale(o ?? ce); let i = c.hour(), s; return r && (s = i >= 12 ? w.localeData(o).meridiem(12, 0, !1) : w.localeData(o).meridiem(0, 0, !1), i = i % 12, i === 0 && (i = 12)), { hour: i, minute: c.minute(), second: c.second(), meridiem: s }; }; var ae = /* @__PURE__ */ ((e) => (e.Hijri = "hijri", e.Gregorian = "gregorian", e))(ae || {}), x = /* @__PURE__ */ ((e) => (e.Days = "days", e.Months = "months", e.Years = "years", e))(x || {}), le = /* @__PURE__ */ ((e) => (e.D = "D", e.Day = "DD", e.Month = "MM", e.ShortMonth = "MMM", e.FullMonth = "MMMM", e.FullYear = "YYYY", e.FullTime = "hh:mm:ss A", e.Date = "YYYY/MM/DD", e.FullDateTime = "YYYY/MM/DD hh:mm:ss A", e.FullMonthYear = "MMMM YYYY", e.WeekNumber = "w", e))(le || {}), de = /* @__PURE__ */ ((e) => (e.D = "iD", e.Day = "iDD", e.Month = "iMM", e.FullYear = "iYYYY", e.FullMonth = "iMMMM", e.ShortMonth = "iMMM", e.FullTime = "hh:mm:ss A", e.Date = "iYYYY/iMM/iDD", e.FullDateTime = "iYYYY/iMM/iDD hh:mm:ss A", e.FullMonthYear = "iMMMM iYYYY", e.WeekNumber = "iw", e))(de || {}), Z = /* @__PURE__ */ ((e) => (e.Top = "top", e.Right = "right", e.Bottom = "bottom", e.Left = "left", e.Start = "start", e.End = "end", e.TopLeft = "top-left", e.TopRight = "top-right", e.TopStart = "top-start", e.TopEnd = "top-end", e.BottomLeft = "bottom-left", e.BottomRight = "bottom-right", e.BottomStart = "bottom-start", e.BottomEnd = "bottom-end", e))(Z || {}), Xe = /* @__PURE__ */ ((e) => (e.Dark = "dark", e.Light = "light", e))(Xe || {}), qe = /* @__PURE__ */ ((e) => (e.Inline = "inline", e.Popover = "popover", e))(qe || {}); const K = (e) => Object.entries(e).reduce((r, [o, c]) => r += c && !r.includes(o) ? `${o} ` : "", "").trim(), J = (e, r, o) => Math.min(Math.max(e, r), o), ze = (e, r, o) => { if (!e) return; const c = r?.clientHeight || 0, i = r?.clientWidth || 0, s = (r.dir || document.dir || document.body.dir) === "rtl", _ = e.getBoundingClientRect(), f = e.parentElement?.getBoundingClientRect() ?? _, { scrollY: y, scrollX: p, innerHeight: E, innerWidth: b } = window, g = s ? i : 0, S = s ? 0 : i; if (o) { const T = E - _.bottom - c + e.clientHeight - 20, n = b - _.right + g - 60; return { // topPosition: clamp(-calendarHeight - 5, -parentRect.top, verticalAvailable, stayInViewport, 'horizontal'), // bottomPosition: clamp(anchorEl.clientHeight, -parentRect.top, verticalAvailable, stayInViewport, 'horizontal'), // middleXPosition: clamp((isRTL ? (calendarWidth / 2) : -(calendarWidth / 2)) + (anchorEl.clientWidth / 2), calendarWidthIfRTL - parentRect.left, horizontalAvailable, stayInViewport, 'vertical'), // middleYPosition: clamp(-(calendarHeight / 2) + (anchorEl.clientHeight / 2), -parentRect.top, verticalAvailable, stayInViewport, 'horizontal'), // leftPosition: clamp(isRTL ? 0 : -(calendarHeight + 20), calendarWidthIfRTL - parentRect.left, horizontalAvailable, stayInViewport, 'vertical'), // rightPosition: clamp((isRTL ? calendarWidth : 0) + anchorEl.clientWidth + 2, calendarWidthIfRTL + anchorEl.clientWidth - parentRect.right, innerWidth - rect.left - calendarWidthIfNotRTL - 10, stayInViewport, 'vertical'), // startPosition: clamp(isRTL ? (calendarHeight + anchorEl.clientWidth + 43) : -(calendarHeight + 40), calendarWidthIfRTL + anchorEl.clientWidth - parentRect.right, horizontalAvailable, stayInViewport, 'vertical'), // endPosition: clamp(isRTL ? 0 : (anchorEl.clientWidth + 2), calendarWidthIfRTL + anchorEl.clientWidth - parentRect.right, horizontalAvailable, stayInViewport, 'vertical'), topPosition: J(-c - 5, -f.top, T), bottomPosition: J(e.clientHeight, -f.top, T), middleXPosition: J((s ? i / 2 : -(i / 2)) + e.clientWidth / 2, g - f.left, n), middleYPosition: J(-(c / 2) + e.clientHeight / 2, -f.top, T), leftPosition: J(s ? 0 : -(c + 20), g - f.left, n), rightPosition: J((s ? i : 0) + e.clientWidth + 2, g + e.clientWidth - f.right, b - _.left - S - 10), startPosition: J(s ? c + e.clientWidth + 43 : -(c + 40), g + e.clientWidth - f.right, n), endPosition: J(s ? 0 : e.clientWidth + 2, g + e.clientWidth - f.right, n) }; } const R = { left: _.left + p, right: _.right + p, top: _.top + y, bottom: _.bottom, start: s ? _.right : _.left, end: s ? _.left : _.right }, D = E + y - c, m = b + p - S, k = p + g, h = p - (s ? -i : i); return { topPosition: J(R.top - c, y, D), bottomPosition: J(R.bottom + y, y, y + E - c - 20), middleXPosition: J(R.left + g, p + g, m), middleYPosition: J(R.top - c / 2, y, D), leftPosition: J(R.left - S, k, m), rightPosition: J(R.right + g, p + g, m), startPosition: J(R.start + h, k, m), endPosition: J(R.end + p, k, m) // topPosition: clamp(anchorCoordinates.top - calendarHeight, scrollY, yEndEdgeWithoutCalendarHeight, stayInViewport, 'horizontal'), // bottomPosition: clamp(anchorCoordinates.bottom + scrollY, scrollY, scrollY + innerHeight - calendarHeight - 20, stayInViewport, 'horizontal'), // middleXPosition: clamp(anchorCoordinates.left + calendarWidthIfRTL, scrollX + calendarWidthIfRTL, xRTLEndEdgeWithoutCalendarWidth, stayInViewport, 'vertical'), // middleYPosition: clamp(anchorCoordinates.top - (calendarHeight / 2), scrollY, yEndEdgeWithoutCalendarHeight, stayInViewport, 'horizontal'), // leftPosition: clamp(anchorCoordinates.left - calendarWidthIfNotRTL, xRTLScrollWithCalendarWidth, xRTLEndEdgeWithoutCalendarWidth, stayInViewport, 'vertical'), // rightPosition: clamp(anchorCoordinates.right + calendarWidthIfRTL, scrollX + calendarWidthIfRTL, xRTLEndEdgeWithoutCalendarWidth, stayInViewport, 'vertical'), // startPosition: clamp(anchorCoordinates.start + xRTLScrollWithoutCalendarWidth, xRTLScrollWithCalendarWidth, xRTLEndEdgeWithoutCalendarWidth, stayInViewport, 'vertical'), // endPosition: clamp(anchorCoordinates.end + scrollX, xRTLScrollWithCalendarWidth, xRTLEndEdgeWithoutCalendarWidth, stayInViewport, 'vertical'), // topPosition: Math.min(Math.max(anchorCoordinates.top - calendarHeight, scrollY), yEndEdgeWithoutCalendarHeight), // bottomPosition: Math.max(Math.min(anchorCoordinates.bottom, innerHeight - calendarHeight) + scrollY, scrollY), // middleXPosition: Math.min(Math.max(anchorCoordinates.left, scrollX) + calendarWidthIfRTL, xRTLEndEdgeWithoutCalendarWidth), // middleYPosition: Math.min(Math.max(anchorCoordinates.top - (calendarHeight / 2), scrollY), yEndEdgeWithoutCalendarHeight), // leftPosition: Math.min(Math.max(anchorCoordinates.left - calendarWidthIfNotRTL, xRTLScrollWithCalendarWidth), xRTLEndEdgeWithoutCalendarWidth), // rightPosition: Math.min(Math.max(anchorCoordinates.right, scrollX) + calendarWidthIfRTL, xRTLEndEdgeWithoutCalendarWidth), // startPosition: Math.min(Math.max(anchorCoordinates.start + xRTLScrollWithoutCalendarWidth, xRTLScrollWithCalendarWidth), xRTLEndEdgeWithoutCalendarWidth), // endPosition: Math.max(Math.min(anchorCoordinates.end + scrollX, xRTLEndEdgeWithoutCalendarWidth), xRTLScrollWithCalendarWidth), }; }, Je = { [Z.Top]: (e) => ({ top: e?.topPosition, left: e?.middleXPosition }), [Z.Bottom]: (e) => ({ top: e?.bottomPosition, left: e?.middleXPosition }), [Z.Left]: (e) => ({ top: e?.middleYPosition, left: e?.leftPosition }), [Z.Right]: (e) => ({ top: e?.middleYPosition, left: e?.rightPosition }), [Z.Start]: (e) => ({ top: e?.middleYPosition, left: e?.startPosition }), [Z.End]: (e) => ({ top: e?.middleYPosition, left: e?.endPosition }), [Z.TopLeft]: (e) => ({ top: e?.topPosition, left: e?.leftPosition }), [Z.TopRight]: (e) => ({ top: e?.topPosition, left: e?.rightPosition }), [Z.TopStart]: (e) => ({ top: e?.topPosition, left: e?.startPosition }), [Z.TopEnd]: (e) => ({ top: e?.topPosition, left: e?.endPosition }), [Z.BottomLeft]: (e) => ({ top: e?.bottomPosition, left: e?.leftPosition }), [Z.BottomRight]: (e) => ({ top: e?.bottomPosition, left: e?.rightPosition }), [Z.BottomStart]: (e) => ({ top: e?.bottomPosition, left: e?.startPosition }), [Z.BottomEnd]: (e) => ({ top: e?.bottomPosition, left: e?.endPosition }) }, Ze = ({ locale: e, showTimePicker: r, enableGoToToday: o, renderGoToToday: c, renderConfirmBtn: i, onCurrentDateChange: s, onConfirm: _ }) => { const f = !!o || r, y = () => { s(B(void 0, e)); }, p = () => { _?.(); }; return f ? /* @__PURE__ */ l.jsxs("div", { className: "fkdp-calendar__footer", children: [ o && (c ? c(y) : /* @__PURE__ */ l.jsx("button", { onClick: y, className: "fkdp-calendar__go-to-today", children: "Go to today" })), r && /* @__PURE__ */ l.jsx("div", { className: "fkdp-calendar__footer--actions", children: i ? i(p) : /* @__PURE__ */ l.jsx("button", { onClick: p, className: "fkdp-calendar__footer--action fkdp-calendar__footer--action-ok", children: "OK" }) }) ] }) : /* @__PURE__ */ l.jsx(l.Fragment, {}); }, Ge = ({ view: e, calendar: r, currentDate: o, yearsRange: c = 12, calendarEl: i, views: s, disableLocaleDigits: _, renderPrevButton: f, renderNextButton: y, renderSelectedMonth: p, renderSelectedYear: E, onChangeView: b, onCurrentDateChange: g }) => { const S = r === ae.Hijri, R = S ? de : le, D = e === x.Years || e === x.Months ? x.Years : x.Months, m = U(() => s === void 0 || s.includes(x.Days), [s]), k = U(() => s === void 0 || s.includes(x.Months), [s]), h = U(() => s === void 0 || s.includes(x.Years), [s]), T = U(() => o.isAfter(se, D) && (e === x.Years || e === x.Months && h || e === x.Days && k), [o, e, k, h]), n = U(() => o.isBefore(ee, D) && (e === x.Years || e === x.Months && h || e === x.Days && k), [o, e, k, h]), d = U(() => (i?.dir || document.body.dir || document.dir) === "rtl", [i?.dir]), j = () => { k && (e === x.Months && m ? b?.(x.Days) : e === x.Days && k || e === x.Years && k ? b?.(x.Months) : e === x.Months && h && b?.(x.Years)); }, Y = () => { h && (e === x.Years && m ? b?.(x.Days) : (e === x.Days && h || e === x.Months && h || e === x.Days && h) && b?.(x.Years)); }, O = () => { switch (e) { case x.Days: k && g(o.clone().subtract(1, "month")); break; case x.Months: h && g(o.clone().subtract(1, "year")); break; case x.Years: T && g(o.clone().subtract(c, "year")); break; } }, W = () => { switch (e) { case x.Days: g(o.clone().add(1, "month")); break; case x.Months: g(o.clone().add(1, "year")); break; case x.Years: n && g(o.clone().add(c, "year")); break; } }, v = U(() => _ ? S ? o.iYear().toString() : o.year().toString() : o.format(R.FullYear), [o, S]), $ = U(() => o.format(R.FullMonth), [o]); return s?.length === 1 && s[0] === x.Days ? null : /* @__PURE__ */ l.jsxs("div", { className: "fkdp-calendar__header", children: [ f ? f({ disabled: !T, onClick: () => O() }) : /* @__PURE__ */ l.jsx( "button", { className: K({ "fkdp-calendar__btn": !0, "fkdp-calendar__btn-prev": !0, "fkdp-calendar__btn--disabled": !T }), disabled: !T, type: "button", "aria-label": "Previous", style: { transform: d ? "rotate(180deg)" : void 0 }, onClick: O, children: "◀" } ), h && (E ? E(v, o.toDate(), { opened: e === x.Years, onClick: () => Y() }) : /* @__PURE__ */ l.jsx("span", { style: { cursor: k || m ? "pointer" : void 0, fontWeight: e === x.Years ? "bold" : void 0 }, onClick: Y, children: v })), k && (p ? p($, o.toDate(), { opened: e === x.Months, onClick: () => j() }) : /* @__PURE__ */ l.jsx("span", { style: { cursor: h || m ? "pointer" : void 0, fontWeight: e === x.Months ? "bold" : void 0 }, onClick: j, children: $ })), y ? y({ disabled: !n, onClick: () => W() }) : /* @__PURE__ */ l.jsx( "button", { className: K({ "fkdp-calendar__btn": !0, "fkdp-calendar__btn-prev": !0, "fkdp-calendar__btn--disabled": !n }), disabled: !n, type: "button", "aria-label": "Next", style: { transform: d ? "rotate(180deg)" : void 0 }, onClick: W, children: "▶" } ) ] }); }, Ke = ({ value: e, currentDate: r, calendar: o, firstDayOfWeek: c = 0, focusedDate: i, minDate: s, maxDate: _, locale: f, hideOutsideDays: y, showWeeksNumber: p, highlightDates: E, disabledDates: b, disabledMonths: g, disabledYears: S, weekends: R, disableWeekends: D, disableLocaleDigits: m, renderDay: k, renderWeekNumber: h, disabledDatesFn: T, onSelect: n }) => { const d = o === ae.Hijri, j = d ? de : le, Y = E?.map((a) => w(a)), O = U(() => { const a = d ? r.clone().startOf("iMonth") : r.clone().startOf("month"), M = d ? r.clone().endOf("iMonth") : r.clone().endOf("month"), t = (a.day() - c + 7) % 7; let u = a.clone().subtract(t, "days"); for (; isNaN(u.iDate()); ) u = u.add(1, "days"); const N = M.clone().add(6 - (M.day() - c + 7) % 7, "days"), I = []; let H = u.locale(f ?? "en").clone(); for (; H.isSameOrBefore(N, "day"); ) isNaN(H.iDate()) || I.push(H.clone()), H.add(1, "day"); return I; }, [r, c, o]), W = U(() => { const a = []; for (let M = 0; M < O.length; M += 7) { const t = O.slice(M, M + 7); (d ? t[0]?.iMonth() === r.iMonth() || t[t.length - 1]?.iMonth() === r.iMonth() : t[0]?.month() === r.month() || t[t.length - 1]?.month() === r.month()) && a.push({ weekNum: t[0], days: t }); } return a; }, [O]), v = U(() => { const a = w.localeData(f).weekdaysMin(); return p ? ["#", ...a.slice(c), ...a.slice(0, c)] : [...a.slice(c), ...a.slice(0, c)]; }, [c]), $ = U(() => b?.map((a) => B(a, f)), [b]), C = U(() => g?.map((a) => B(a, f)), [g]), F = U(() => S?.map((a) => B(a, f)), [S]), X = (a) => !a.isBetween(s, _, "day", "[]") || !!D && !!R?.includes(a.day()) || !!T?.(a.toDate(), x.Days) || !!$?.some((M) => M.isSame(a, "day")) || !!C?.some((M) => M.isSame(a, "month")) || !!F?.some((M) => M.isSame(a, "year")), q = (a) => { if (X(a)) return; const M = _e(r, !1, f); n(a.add({ hours: M?.hour || 0, minutes: M?.minute || 0, seconds: M?.second || 0 }).toDate()); }, G = (a) => { const M = d ? a.iMonth() === r.iMonth() : a.month() === r.month(); if (y && !M) return /* @__PURE__ */ l.jsx("span", { className: "fkdp-calendar__cell fkdp-calendar__cell--outside" }, a.toString()); const t = !!e && B(e, f).isSame(a, "day"), u = X(a), N = B(void 0, f).isSame(a, "day"), I = !!Y?.some((L) => L.isSame(a, "day")), H = a.isSame(i, "day"), V = !!R?.includes(a.day()), P = m ? d ? a.iDate().toString() : a.date().toString() : a.format(j.Day), Q = K({ "fkdp-calendar__cell": !0, "fkdp-calendar__cell--selected": t, "fkdp-calendar__cell--disabled": u, "fkdp-calendar__cell--today": N, "fkdp-calendar__cell--highlighted": I, "fkdp-calendar__cell--focused": H, "fkdp-calendar__cell--holiday": V, "fkdp-calendar__cell--outside": !M }); return k ? k(P, a.toDate(), { className: Q, "aria-selected": !!t, tabIndex: a.isSame(i, "day") ? 0 : -1, onClick: () => q(a) }, { selected: t, disabled: u, today: N, highlighted: I, focused: H, holiday: V, outside: !M }) : /* @__PURE__ */ l.jsx( "button", { type: "button", className: Q, disabled: u, "aria-selected": !!t, tabIndex: a.isSame(i, "day") ? 0 : -1, onClick: () => q(a), children: P }, a.toString() ); }, z = (a) => /* @__PURE__ */ l.jsx( "span", { className: "fkdp-calendar__cell fkdp-calendar__cell--weekday", children: a }, a ); return /* @__PURE__ */ l.jsxs("div", { children: [ /* @__PURE__ */ l.jsx("div", { className: K({ "fkdp-calendar__grid": !0, "fkdp-calendar__grid-weekdays": !0, "fkdp-calendar__grid-with-weeknum": !!p }), children: v.map((a) => z(a)) }), /* @__PURE__ */ l.jsx("div", { className: K({ "fkdp-calendar__grid": !0, "fkdp-calendar__grid-days": !0, "fkdp-calendar__grid-with-weeknum": !!p }), children: W.map((a, M) => { const t = m ? (d ? a.weekNum?.iWeek().toString() : a.weekNum?.week().toString()) ?? "" : a.weekNum?.format(j.WeekNumber) || ""; return /* @__PURE__ */ l.jsxs(We, { children: [ p && /* @__PURE__ */ l.jsx("div", { className: "fkdp-calendar__cell", children: h ? h(t, a.weekNum?.isoWeek() || -1) : /* @__PURE__ */ l.jsx("span", { className: "fkdp-calendar__cell--weeknum", children: t }) }), a.days.map((u) => G(u)) ] }, M); }) }) ] }); }, Qe = ({ value: e, calendar: r, currentDate: o, focusedDate: c, minDate: i, maxDate: s, locale: _, disabledMonths: f, disabledYears: y, disabledDatesFn: p, renderMonth: E, onSelect: b }) => { const g = r === ae.Hijri, S = g ? de : le, R = U(() => { const n = [], d = g ? o.clone().startOf("iYear") : o.clone().startOf("year"); for (let j = 0; j < 12; j++) { const Y = g ? d.clone().add(j, "iMonth") : d.clone().add(j, "month"); n.push(Y); } return n; }, [o, r]), D = U(() => f?.map((n) => B(n, _)), [f]), m = U(() => y?.map((n) => B(n, _)), [y]), k = (n) => !n.isBetween(i, s, "month", "[]") || !!p?.(n.toDate(), x.Months) || !!D?.some((d) => d.isSame(n, "month")) || !!m?.some((d) => d.isSame(n, "year")), h = (n) => { if (!k(n)) if (n.isBetween(i, s, void 0, "[]")) { const d = _e(o, !1, _); b?.(n.add({ hours: d?.hour || 0, minutes: d?.minute || 0, seconds: d?.second || 0 }).toDate()); } else n.isBefore(i) ? b?.(w(i).toDate()) : b?.(w(s).toDate()); }, T = (n) => { const d = !!e && B(e, _).isSame(n, "month"), j = k(n), Y = B(void 0, _).isSame(n, "month"), O = n.isSame(c, "day"), W = n.format(S.ShortMonth), v = K({ "fkdp-calendar__cell": !0, "fkdp-calendar__cell--selected": d, "fkdp-calendar__cell--disabled": j, "fkdp-calendar__cell--today": Y, "fkdp-calendar__cell--focused": O }); return E ? E(W, n.toDate(), { className: v, "aria-selected": !!d, tabIndex: n.isSame(c, "day") ? 0 : -1, onClick: () => h(n) }, { selected: d, disabled: j, today: Y, focused: O }) : /* @__PURE__ */ l.jsx( "button", { type: "button", className: v, disabled: j, "aria-selected": !!d, tabIndex: n.isSame(c, "day") ? 0 : -1, onClick: () => h(n), children: W }, n.toString() ); }; return /* @__PURE__ */ l.jsx("div", { className: "fkdp-calendar__grid fkdp-calendar__grid-months", children: R.map((n) => T(n)) }); }, et = ({ value: e, currentDate: r, calendar: o, minDate: c, maxDate: i, focusedDate: s, range: _ = 16, disabledYears: f, locale: y, disableLocaleDigits: p, disabledDatesFn: E, renderYear: b, onSelect: g }) => { const S = o === ae.Hijri, R = S ? de : le, D = U(() => { const n = [], d = S ? r.iYear() : r.year(), j = d - d % _; for (let Y = 0; Y < _; Y++) { const O = S ? B(void 0, y).iYear(j + Y).startOf("iYear") : B(void 0, y).year(j + Y).startOf("year"); n.push(O); } return n; }, [r, o]), m = U(() => f?.map((n) => B(n, y)), [f]), k = (n) => !n.isBetween(c, i, "year", "[]") || !!E?.(n.toDate(), x.Years) || !!m?.some((d) => d.isSame(n, "year")), h = (n) => { if (!k(n)) if (n.isBetween(c, i, void 0, "[]")) { const d = _e(r, !1, y); g?.(n.add({ hours: d?.hour || 0, minutes: d?.minute || 0, seconds: d?.second || 0 }).toDate()); } else n.isBefore(c) ? g?.(w(c).toDate()) : g?.(w(i).toDate()); }, T = (n) => { const d = !!e && B(e, y).isSame(n, "year"), j = k(n), Y = B(void 0, y).isSame(n, "year"), O = n.isSame(s, "day"), W = p ? S ? n.iYear().toString() : n.year().toString() : n.format(R.FullYear), v = K({ "fkdp-calendar__cell": !0, "fkdp-calendar__cell--selected": d, "fkdp-calendar__cell--disabled": j, "fkdp-calendar__cell--today": Y, "fkdp-calendar__cell--focused": O }); return b ? b(W, n.toDate(), { className: v, "aria-selected": !!d, tabIndex: n.isSame(s, "day") ? 0 : -1, onClick: () => h(n) }, { selected: d, disabled: j, today: Y, focused: O }) : /* @__PURE__ */ l.jsx( "button", { type: "button", className: v, disabled: j, "aria-selected": !!d, tabIndex: n.isSame(s, "day") ? 0 : -1, onClick: () => h(n), children: W }, n.toString() ); }; return /* @__PURE__ */ l.jsx("div", { className: "fkdp-calendar__grid fkdp-calendar__grid-years", children: D.map((n) => T(n)) }); }, fe = 30, tt = 30, Oe = 7, Ye = Math.floor(Oe / 2), nt = fe * Oe, be = ({ locale: e, items: r, selected: o, disabledItems: c, showScrollbars: i, selectOnScrolling: s, disableLocaleDigits: _, renderTimeItem: f, onSelect: y }) => { const p = me(null), E = me(null), [b, g] = te(!1), S = o !== void 0 && !c?.includes(o) ? o : void 0; oe(() => { if (b || !p.current || !S && S !== 0) return; const m = r.indexOf(S); if (m === -1) return; const k = m * fe; p.current.scrollTo({ top: k, behavior: "smooth" }); }, [S, b, p.current]); const R = () => { !p.current || !s || (g(!0), E.current && clearTimeout(E.current), E.current = setTimeout(() => { if (!p.current) return; const m = p.current.scrollTop, k = Math.round(m / fe), h = Math.max(0, Math.min(r.length - 1, k)), T = r[h]; T !== S && y(T !== void 0 && !c?.includes(T) ? T : void 0), g(!1); }, 120)); }, D = (m) => { const k = m === S, h = !!c?.includes(m), T = typeof m == "number" ? _ ? String(m).padStart(2, "0") : w.localeData(e).postformat(String(m).padStart(2, "0")) : m, n = { height: fe, width: "100%" }, d = K({ "fkdp-calendar__time-item": !0, "fkdp-calendar__time-item--selected": k, "fkdp-calendar__time-item--disabled": h }); return f ? f(T, m, { className: d, style: n, onClick: () => y(m) }, { selected: k, disabled: h }) : /* @__PURE__ */ l.jsx( "button", { className: d, disabled: c?.includes(m), style: n, onClick: () => y(m), children: T }, m.toString() ); }; return /* @__PURE__ */ l.jsxs( "div", { ref: p, className: "fkdp-calendar__time-col", style: { height: nt, minWidth: tt, scrollbarWidth: i ? "thin" : "none" }, onScroll: s ? R : void 0, children: [ /* @__PURE__ */ l.jsx("div", { style: { height: fe * Ye } }), r.map((m) => D(m)), /* @__PURE__ */ l.jsx("div", { style: { height: fe * Ye } }) ] } ); }, st = ({ renderHeaderContent: e, value: r, initialDate: o, currentDate: c, locale: i, is12h: s = !1, visibleColumns: _, showScrollbars: f = !1, selectOnScrolling: y, disabledHours: p, disabledMinutes: E, disabledSeconds: b, disabledMeridiem: g, disableLocaleDigits: S, renderTimeItem: R, onSelect: D }) => { const m = _ === void 0 || _.includes("hours"), k = _ === void 0 || _.includes("minutes"), h = _ === void 0 || _.includes("seconds"), T = o ? _e(o, s, i) : { hour: s ? 12 : 0, minute: 0, second: 0, meridiem: w.localeData(i).meridiem(0, 0, !1) }, n = U(() => _e(r ?? o, s, i), [r, s]), d = [ w.localeData(i).meridiem(0, 0, !1), // AM w.localeData(i).meridiem(12, 0, !1) // PM ], j = h ? Array.from({ length: 60 }, (v, $) => $) : [], Y = k ? Array.from({ length: 60 }, (v, $) => $) : [], O = m ? s ? [12, ...Array.from({ length: 11 }, (v, $) => $ + 1)] : Array.from({ length: 24 }, (v, $) => $) : [], W = (v) => { D?.(v ? Ve(c, v, s, i).toDate() : null); }; return /* @__PURE__ */ l.jsxs("div", { style: { position: "relative", direction: "ltr" }, children: [ /* @__PURE__ */ l.jsx("div", { className: "fkdp-calendar__time-header", children: e ? e({ className: "fkdp-calendar__time-item", style: { width: "100%" } }, s) : /* @__PURE__ */ l.jsxs(l.Fragment, { children: [ m && /* @__PURE__ */ l.jsx("div", { className: "fkdp-calendar__time-item", style: { width: "100%" }, children: "h" }), k && /* @__PURE__ */ l.jsx("div", { className: "fkdp-calendar__time-item", style: { width: "100%" }, children: "m" }), h && /* @__PURE__ */ l.jsx("div", { className: "fkdp-calendar__time-item", style: { width: "100%" }, children: "s" }), s && /* @__PURE__ */ l.jsx("div", { className: "fkdp-calendar__time-item", style: { width: "100%" } }) ] }) }), /* @__PURE__ */ l.jsxs("div", { className: "fkdp-calendar__time", children: [ m && /* @__PURE__ */ l.jsx( be, { locale: i, items: O, selected: n?.hour, disabledItems: p, showScrollbars: f, selectOnScrolling: y, disableLocaleDigits: S, renderTimeItem: R, onSelect: (v) => W({ ...n ?? T, hour: v }) } ), k && /* @__PURE__ */ l.jsx( be, { locale: i, items: Y, disabledItems: E, selected: n?.minute, showScrollbars: f, selectOnScrolling: y, disableLocaleDigits: S, renderTimeItem: R, onSelect: (v) => W({ ...n ?? T, minute: v }) } ), h && /* @__PURE__ */ l.jsx( be, { locale: i, items: j, disabledItems: b, selected: n?.second, showScrollbars: f, selectOnScrolling: y, disableLocaleDigits: S, renderTimeItem: R, onSelect: (v) => W({ ...n ?? T, second: v }) } ), s && h && /* @__PURE__ */ l.jsx( be, { locale: i, items: d, showScrollbars: !1, disabledItems: g?.map((v) => v.toLowerCase() === "pm" || v.toLowerCase() === "م" ? w.localeData(i).meridiem(12, 0, !1) : w.localeData(i).meridiem(0, 0, !1)), selectOnScrolling: y, selected: n?.meridiem, renderTimeItem: R, onSelect: (v) => W({ ...n ?? T, meridiem: v }) } ) ] }) ] }); }, Pe = ye(({ open: e, value: r = null, initialDate: o, minDate: c, maxDate: i, locale: s, theme: _ = "light", calendar: f = ae.Gregorian, disablePortal: y = !1, mode: p = "popover", position: E = Z.Bottom, anchorEl: b, monthsCalendarProps: g, yearsCalendarProps: S, daysCalendarProps: R, timePickerProps: D, enableGoToToday: m, isControlled: k, views: h, initialView: T, showTimePicker: n, hideFooter: d, disableLocaleDigits: j, // stayInViewport = true, renderGoToToday: Y, renderConfirmBtn: O, disabledDatesFn: W, onSelect: v, onClose: $, ...C }, F) => { const X = e ?? p === "inline", q = ie(c, s) ?? se.toDate(), G = ie(i, s) ?? ee.toDate(), z = U(() => h === void 0 || h.includes("months"), [h]), a = U(() => h === void 0 || h.includes("years"), [h]), M = U(() => h === void 0 || h.includes("days"), [h]), [t, u] = te(T ?? h?.[0] ?? x.Days), [N, I] = te(B(ie(r || o || w({ hours: 0, minutes: 0, seconds: 0 }), s), s)), [H, V] = te(B(ie(r || w({ hours: 0, minutes: 0, seconds: 0 }), s), s)), [P, Q] = te({ visibility: "hidden" }), L = me(null); oe(() => { F && (typeof F == "function" ? F(L.current) : F.current = L.current); }, [F]), oe(() => { h !== void 0 && !h?.includes(t) && console.error(`The value of [initialView] property must be defined in views array. Please add (${T}) to views array!`); }, [h, o]); const re = Te(() => { if (!b || !L.current) return {}; const A = ze(b, L.current, y); return { position: "absolute", ...Je[E](A) }; }, [b, L.current, E]); oe(() => { if (p === "popover" && X && b) { const A = () => { const Le = re(); Q(Le); }; return A(), window.addEventListener("resize", A), window.addEventListener("scroll", A, !0), () => { window.removeEventListener("resize", A), window.removeEventListener("scroll", A, !0); }; } }, [p, X, b, E]); const ne = (A) => { I(Ue(A, s)); }; if (!X) return null; const ue = Te((A) => { L.current && !L.current.contains(A.target) && b && !b.contains(A.target) && !A.target.closest(".calendar-popover") && $?.(); }, [L.current, b]); oe(() => (p === "popover" && (X ? document.addEventListener("mousedown", ue) : document.removeEventListener("mousedown", ue)), () => document.removeEventListener("mousedown", ue)), [X, ue, p]); const Ce = /* @__PURE__ */ l.jsx( Ke, { ...R, value: r, currentDate: N, calendar: f, focusedDate: H, minDate: q, maxDate: G, locale: s, disableLocaleDigits: j, onSelect: (A) => { v?.(A, !n), ne(B(A, s)), V(B(A, s)); } } ), Re = /* @__PURE__ */ l.jsx( Qe, { ...g, value: r, currentDate: N, calendar: f, minDate: q, maxDate: G, focusedDate: H, locale: s, onSelect: (A) => { V(B(A, s)), ne(B(A, s)), M ? u(x.Days) : v?.(A, !n); } } ), ve = /* @__PURE__ */ l.jsx( et, { ...S, value: r, calendar: f, currentDate: N, focusedDate: H, minDate: q, maxDate: G, locale: s, disableLocaleDigits: j, onSelect: (A) => { ne(B(A, s)), V(B(A, s)), z ? u(x.Months) : M ? u(x.Days) : v?.(A, !n); } } ), Ie = () => { switch (t) { case "days": if (M) return Ce; case "months": if (z) return Re; case "years": if (a) return ve; default: if (z) return Re; if (a) return ve; } }, ge = /* @__PURE__ */ l.jsxs( "div", { ...C, ref: L, className: K({ "fkdp-calendar": !0, [C.className || ""]: !!C.className, "fkdp-calendar__dark": _ === "dark", "fkdp-calendar__woth-week-nums": R?.showWeeksNumber }), role: "grid", "aria-label": C["aria-label"] || "Calendar", onClick: (A) => A.stopPropagation(), children: [ /* @__PURE__ */ l.jsx( Ge, { yearsRange: S?.range, calendar: f, currentDate: N, view: t, views: h, calendarEl: L.current, disableLocaleDigits: j, onChangeView: u, onCurrentDateChange: ne } ), /* @__PURE__ */ l.jsxs("div", { className: "fkdp-calendar__container", children: [ Ie(), n && /* @__PURE__ */ l.jsxs(l.Fragment, { children: [ /* @__PURE__ */ l.jsx("div", { className: "fkdp-calendar__divider" }), /* @__PURE__ */ l.jsx( st, { ...D, value: r, currentDate: N, initialDate: o, locale: s, disableLocaleDigits: j, onSelect: (A) => { A && (v?.(A), ne(B(A, s)), V(B(A, s))); } } ) ] }) ] }), !d && /* @__PURE__ */ l.jsx( Ze, { showTimePicker: n, locale: s, enableGoToToday: m, renderGoToToday: Y, renderConfirmBtn: O, onConfirm: () => $?.(), onCurrentDateChange: ne } ) ] } ); return p === "inline" ? ge : /* @__PURE__ */ l.jsx(l.Fragment, { children: X && (b || k) && (y ? /* @__PURE__ */ l.jsx("div", { style: P, children: ge }) : Be(/* @__PURE__ */ l.jsx("div", { style: P, children: ge }), document.body)) }); }), Ae = ye(({ value: e, defaultValue: r = null, format: o = le.Date, clearable: c = !0, showIcon: i = !0, locale: s, disableLocaleDigits: _, htmlInputProps: f, placeholder: y, disabled: p, renderIcon: E, onChange: b, onInputChange: g, onOpenRequest: S, ...R }, D) => { const m = e !== void 0, [k, h] = te(r), T = (C) => { const F = B(m ? C : k, s).format(o); return _ ? w.localeData(s).preparse(F) : F; }, [n, d] = te( (m ? e : k) ? T(m ? e : k) : "" ), j = me(null); oe(() => { typeof D == "function" ? D(j.current) : D && (D.current = j.current); }, [D]), oe(() => { m && d(e ? T(e) : ""); }, [e, m, o]); const Y = (C) => { if (!C.trim()) { m || h(null), b?.(null); return; } try { const F = w(C, o, !0).locale(s ?? "en"); if (F.isValid()) { const X = F.toDate(); m || h(X), b?.(X); } } catch { return; } }, O = (C) => { const F = C.target.value; d(F), g?.(F); }, W = () => { Y(n); }, v = (C) => { C.key === "Enter" ? Y(n) : C.key === "ArrowDown" || C.key === " " ? (C.preventDefault(), S?.(j.current)) : C.key === "Escape" && d( (m ? e : k) ? T(m ? e : k) : "" ); }, $ = (C) => { C.stopPropagation(), d(""), m || h(null), b?.(null); }; return /* @__PURE__ */ l.jsxs( "div", { ...R, className: K({ "fkdp-field": !0, [R.className || ""]: !!R.className, "fkdp-field--disabled": p, "fkdp-field--readonly": R.readOnly }), children: [ /* @__PURE__ */ l.jsx( "input", { ref: j, type: "text", value: n, placeholder: y, disabled: p, onChange: O, onBlur: W, onKeyDown: v, onClick: (C) => { i || S?.(!0), R.onClick?.(C); }, "aria-haspopup": "dialog", id: "RDP_Field", ...f, className: K({ "fkdp-field__input": !0, [f?.className || ""]: !!f?.className }), readOnly: !0 } ), c && n && !p && !R.readOnly && /* @__PURE__ */ l.jsx( "button", { type: "button", className: "fkdp-field__clear", "aria-label": "Clear date", onClick: $, children: "×" } ), i && /* @__PURE__ */ l.jsx( "button", { type: "button", className: "fkdp-field__icon", "aria-label": "Open calendar", disabled: p, onClick: () => S?.(j.current), children: E ? E(() => S?.(j.current)) : "📅" } ) ] } ); }), at = ye(({ value: e, defaultValue: r = null, open: o, format: c, placeholder: i, minDate: s, maxDate: _, locale: f, disabled: y = !1, readOnly: p = !1, closeOnSelect: E = !0, name: b, calendar: g, initialDate: S, theme: R = "light", calendarProps: D, fieldProps: m, onChange: k, onOpenChange: h, renderInput: T, renderCalendar: n, ...d }, j) => { Ee(s, _); const Y = e !== void 0, O = o !== void 0, W = ie(s, f) ?? se.toDate(), v = ie(_, f) ?? ee.toDate(), C = g === ae.Hijri ? de : le, F = c ?? C.Date, [X, q] = te(r), [G, z] = te(null), a = me(null), M = Y ? e : X, t = O ? o : !!G; oe(() => { O && z(o ? a.current : null); }, [o]); const u = (P) => { O || z(P ? a.current : null), h?.(P); }, N = (P, Q) => { Y || q(P), k?.(P), E && Q && u(!1), a.current?.focus(); }, I = () => { !y && !p && u(!0); }, H = T ? T({ value: M, format: F, ref: a, readOnly: p, disabled: y, placeholder: i, onOpenRequest: I, onChange: (P) => { Y || q(P), k?.(P); } }) : /* @__PURE__ */ l.jsx( Ae, { ...m, ref: a, value: M, format: F, placeholder: i || "", disabled: y, readOnly: p, locale: f, disableLocaleDigits: D?.disableLocaleDigits, onOpenRequest: I, onChange: (P) => { Y || q(P), k?.(P); } } ), V = n ? n({ value: M, minDate: W, maxDate: v, locale: f, onSelect: N, ...D }) : /* @__PURE__ */ l.jsx( Pe, { ...D, dir: d.dir, theme: R, isControlled: O, open: t, anchorEl: G, value: M, minDate: W, maxDate: v, locale: f, calendar: g, initialDate: S, disableLocaleDigits: D?.disableLocaleDigits, onSelect: N, onClose: () => u(!1) } ); return /* @__PURE__ */ l.jsxs( "div", { ...d, ref: j, className: K({ "fkdp-datepicker": !0, [d.className || ""]: !!d.className, "fkdp-datepicker__dark": R === "dark" }), children: [ H, (t || D?.mode === "inline") && V, b && M && /* @__PURE__ */ l.jsx("input", { type: "hidden", name: b, value: M.toISOString() }) ] } ); }), lt = ye(({ value: e, defaultValue: r = null, open: o, format: c, placeholder: i, minDate: s, maxDate: _, locale: f, disabled: y = !1, readOnly: p = !1, closeOnSelect: E = !0, name: b, calendar: g, initialDate: S, theme: R = "light", calendarProps: D, fieldProps: m, onChange: k, onOpenChange: h, renderInput: T, renderCalendar: n, ...d }, j) => { Ee(s, _); const Y = e !== void 0, O = o !== void 0, W = ie(s, f) ?? se.toDate(), v = ie(_, f) ?? ee.toDate(), C = g === ae.Hijri ? de : le, F = c ?? C.FullDateTime, [X, q] = te(r), [G, z] = te(null), a = me(null), M = Y ? e : X, t = O ? o : !!G; oe(() => { O && z(o ? a.current : null); }, [o]); const u = (P) => { O || z(P ? a.current : null), h?.(P); }, N = (P, Q) => { Y || q(P), k?.(P), E && Q && u(!1), a.current?.focus(); }, I = () => { !y && !p && u(!0); }, H = T ? T({ value: M, format: F, ref: a, readOnly: p, disabled: y, placeholder: i, onOpenRequest: I, onChange: (P) => { Y || q(P), k?.(P); } }) : /* @__PURE__ */ l.jsx( Ae, { ...m, ref: a, value: M, format: F, placeholder: i || "", disabled: y, readOnly: p, locale: f, disableLocaleDigits: D?.disableLocaleDigits, onOpenRequest: I, onChange: (P) => { Y || q(P), k?.(P); } } ), V = n ? n({ value: M, minDate: W, maxDate: v, locale: f, onSelect: N, ...D }) : /* @__PURE__ */ l.jsx( Pe, { ...D, showTimePicker: !0, dir: d.dir, theme: R, isControlled: O, open: t, anchorEl: G, value: M, minDate: W, maxDate: v, locale: f, calendar: g, initialDate: S, disableLocaleDigits: D?.disableLocaleDigits, onSelect: N, onClose: () => u(!1) } ); return /* @__PURE__ */ l.jsxs( "div", { ...d, ref: j, className: K({ "fkdp-datepicker": !0, [d.className || ""]: !!d.className, "fkdp-datepicker__dark": R === "dark" }), children: [ H, (t || D?.mode === "inline") && V, b && M && /* @__PURE__ */ l.jsx("input", { type: "hidden", name: b, value: M.toISOString() }) ] } ); }); export { Pe a