nepali-patro-datepicker-react
Version:
Nepali Patro Datepicker as a ReactJS component
986 lines (983 loc) • 35 kB
JavaScript
import D3, { useState as S3, useEffect as O3, useRef as he } from "react";
var q = { exports: {} }, Y = {};
/**
* @license React
* react-jsx-runtime.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var P3;
function ye() {
if (P3) return Y;
P3 = 1;
var t = D3, o = Symbol.for("react.element"), d = Symbol.for("react.fragment"), m = Object.prototype.hasOwnProperty, g = t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, i = { key: !0, ref: !0, __self: !0, __source: !0 };
function c(R, v, w) {
var C, _ = {}, x = null, I = null;
w !== void 0 && (x = "" + w), v.key !== void 0 && (x = "" + v.key), v.ref !== void 0 && (I = v.ref);
for (C in v) m.call(v, C) && !i.hasOwnProperty(C) && (_[C] = v[C]);
if (R && R.defaultProps) for (C in v = R.defaultProps, v) _[C] === void 0 && (_[C] = v[C]);
return { $$typeof: o, type: R, key: x, ref: I, props: _, _owner: g.current };
}
return Y.Fragment = d, Y.jsx = c, Y.jsxs = c, Y;
}
var V = {};
/**
* @license React
* react-jsx-runtime.development.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var F3;
function me() {
return F3 || (F3 = 1, process.env.NODE_ENV !== "production" && function() {
var t = D3, o = Symbol.for("react.element"), d = Symbol.for("react.portal"), m = Symbol.for("react.fragment"), g = Symbol.for("react.strict_mode"), i = Symbol.for("react.profiler"), c = Symbol.for("react.provider"), R = Symbol.for("react.context"), v = Symbol.for("react.forward_ref"), w = Symbol.for("react.suspense"), C = Symbol.for("react.suspense_list"), _ = Symbol.for("react.memo"), x = Symbol.for("react.lazy"), I = Symbol.for("react.offscreen"), $ = Symbol.iterator, L = "@@iterator";
function h(e) {
if (e === null || typeof e != "object")
return null;
var r = $ && e[$] || e[L];
return typeof r == "function" ? r : null;
}
var S = t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
function b(e) {
{
for (var r = arguments.length, n = new Array(r > 1 ? r - 1 : 0), a = 1; a < r; a++)
n[a - 1] = arguments[a];
K("error", e, n);
}
}
function K(e, r, n) {
{
var a = S.ReactDebugCurrentFrame, l = a.getStackAddendum();
l !== "" && (r += "%s", n = n.concat([l]));
var f = n.map(function(u) {
return String(u);
});
f.unshift("Warning: " + r), Function.prototype.apply.call(console[e], console, f);
}
}
var N3 = !1, I3 = !1, $3 = !1, M3 = !1, W3 = !1, a3;
a3 = Symbol.for("react.module.reference");
function Y3(e) {
return !!(typeof e == "string" || typeof e == "function" || e === m || e === i || W3 || e === g || e === w || e === C || M3 || e === I || N3 || I3 || $3 || typeof e == "object" && e !== null && (e.$$typeof === x || e.$$typeof === _ || e.$$typeof === c || e.$$typeof === R || e.$$typeof === v || // This needs to include all possible module reference object
// types supported by any Flight configuration anywhere since
// we don't know which Flight build this will end up being used
// with.
e.$$typeof === a3 || e.getModuleId !== void 0));
}
function V3(e, r, n) {
var a = e.displayName;
if (a)
return a;
var l = r.displayName || r.name || "";
return l !== "" ? n + "(" + l + ")" : n;
}
function o3(e) {
return e.displayName || "Context";
}
function O(e) {
if (e == null)
return null;
if (typeof e.tag == "number" && b("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof e == "function")
return e.displayName || e.name || null;
if (typeof e == "string")
return e;
switch (e) {
case m:
return "Fragment";
case d:
return "Portal";
case i:
return "Profiler";
case g:
return "StrictMode";
case w:
return "Suspense";
case C:
return "SuspenseList";
}
if (typeof e == "object")
switch (e.$$typeof) {
case R:
var r = e;
return o3(r) + ".Consumer";
case c:
var n = e;
return o3(n._context) + ".Provider";
case v:
return V3(e, e.render, "ForwardRef");
case _:
var a = e.displayName || null;
return a !== null ? a : O(e.type) || "Memo";
case x: {
var l = e, f = l._payload, u = l._init;
try {
return O(u(f));
} catch {
return null;
}
}
}
return null;
}
var P = Object.assign, M = 0, i3, s3, u3, c3, l3, f3, d3;
function v3() {
}
v3.__reactDisabledLog = !0;
function L3() {
{
if (M === 0) {
i3 = console.log, s3 = console.info, u3 = console.warn, c3 = console.error, l3 = console.group, f3 = console.groupCollapsed, d3 = console.groupEnd;
var e = {
configurable: !0,
enumerable: !0,
value: v3,
writable: !0
};
Object.defineProperties(console, {
info: e,
log: e,
warn: e,
error: e,
group: e,
groupCollapsed: e,
groupEnd: e
});
}
M++;
}
}
function B3() {
{
if (M--, M === 0) {
var e = {
configurable: !0,
enumerable: !0,
writable: !0
};
Object.defineProperties(console, {
log: P({}, e, {
value: i3
}),
info: P({}, e, {
value: s3
}),
warn: P({}, e, {
value: u3
}),
error: P({}, e, {
value: c3
}),
group: P({}, e, {
value: l3
}),
groupCollapsed: P({}, e, {
value: f3
}),
groupEnd: P({}, e, {
value: d3
})
});
}
M < 0 && b("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
}
}
var G = S.ReactCurrentDispatcher, z;
function B(e, r, n) {
{
if (z === void 0)
try {
throw Error();
} catch (l) {
var a = l.stack.trim().match(/\n( *(at )?)/);
z = a && a[1] || "";
}
return `
` + z + e;
}
}
var X = !1, U;
{
var U3 = typeof WeakMap == "function" ? WeakMap : Map;
U = new U3();
}
function p3(e, r) {
if (!e || X)
return "";
{
var n = U.get(e);
if (n !== void 0)
return n;
}
var a;
X = !0;
var l = Error.prepareStackTrace;
Error.prepareStackTrace = void 0;
var f;
f = G.current, G.current = null, L3();
try {
if (r) {
var u = function() {
throw Error();
};
if (Object.defineProperty(u.prototype, "props", {
set: function() {
throw Error();
}
}), typeof Reflect == "object" && Reflect.construct) {
try {
Reflect.construct(u, []);
} catch (T) {
a = T;
}
Reflect.construct(e, [], u);
} else {
try {
u.call();
} catch (T) {
a = T;
}
e.call(u.prototype);
}
} else {
try {
throw Error();
} catch (T) {
a = T;
}
e();
}
} catch (T) {
if (T && a && typeof T.stack == "string") {
for (var s = T.stack.split(`
`), j = a.stack.split(`
`), y = s.length - 1, E = j.length - 1; y >= 1 && E >= 0 && s[y] !== j[E]; )
E--;
for (; y >= 1 && E >= 0; y--, E--)
if (s[y] !== j[E]) {
if (y !== 1 || E !== 1)
do
if (y--, E--, E < 0 || s[y] !== j[E]) {
var k = `
` + s[y].replace(" at new ", " at ");
return e.displayName && k.includes("<anonymous>") && (k = k.replace("<anonymous>", e.displayName)), typeof e == "function" && U.set(e, k), k;
}
while (y >= 1 && E >= 0);
break;
}
}
} finally {
X = !1, G.current = f, B3(), Error.prepareStackTrace = l;
}
var D = e ? e.displayName || e.name : "", F = D ? B(D) : "";
return typeof e == "function" && U.set(e, F), F;
}
function H3(e, r, n) {
return p3(e, !1);
}
function J3(e) {
var r = e.prototype;
return !!(r && r.isReactComponent);
}
function H(e, r, n) {
if (e == null)
return "";
if (typeof e == "function")
return p3(e, J3(e));
if (typeof e == "string")
return B(e);
switch (e) {
case w:
return B("Suspense");
case C:
return B("SuspenseList");
}
if (typeof e == "object")
switch (e.$$typeof) {
case v:
return H3(e.render);
case _:
return H(e.type, r, n);
case x: {
var a = e, l = a._payload, f = a._init;
try {
return H(f(l), r, n);
} catch {
}
}
}
return "";
}
var W = Object.prototype.hasOwnProperty, h3 = {}, y3 = S.ReactDebugCurrentFrame;
function J(e) {
if (e) {
var r = e._owner, n = H(e.type, e._source, r ? r.type : null);
y3.setExtraStackFrame(n);
} else
y3.setExtraStackFrame(null);
}
function q3(e, r, n, a, l) {
{
var f = Function.call.bind(W);
for (var u in e)
if (f(e, u)) {
var s = void 0;
try {
if (typeof e[u] != "function") {
var j = Error((a || "React class") + ": " + n + " type `" + u + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof e[u] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
throw j.name = "Invariant Violation", j;
}
s = e[u](r, u, a, n, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
} catch (y) {
s = y;
}
s && !(s instanceof Error) && (J(l), b("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", a || "React class", n, u, typeof s), J(null)), s instanceof Error && !(s.message in h3) && (h3[s.message] = !0, J(l), b("Failed %s type: %s", n, s.message), J(null));
}
}
}
var K3 = Array.isArray;
function Z(e) {
return K3(e);
}
function G3(e) {
{
var r = typeof Symbol == "function" && Symbol.toStringTag, n = r && e[Symbol.toStringTag] || e.constructor.name || "Object";
return n;
}
}
function z3(e) {
try {
return m3(e), !1;
} catch {
return !0;
}
}
function m3(e) {
return "" + e;
}
function g3(e) {
if (z3(e))
return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", G3(e)), m3(e);
}
var b3 = S.ReactCurrentOwner, X3 = {
key: !0,
ref: !0,
__self: !0,
__source: !0
}, E3, R3;
function Z3(e) {
if (W.call(e, "ref")) {
var r = Object.getOwnPropertyDescriptor(e, "ref").get;
if (r && r.isReactWarning)
return !1;
}
return e.ref !== void 0;
}
function Q3(e) {
if (W.call(e, "key")) {
var r = Object.getOwnPropertyDescriptor(e, "key").get;
if (r && r.isReactWarning)
return !1;
}
return e.key !== void 0;
}
function ee(e, r) {
typeof e.ref == "string" && b3.current;
}
function re(e, r) {
{
var n = function() {
E3 || (E3 = !0, b("%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://reactjs.org/link/special-props)", r));
};
n.isReactWarning = !0, Object.defineProperty(e, "key", {
get: n,
configurable: !0
});
}
}
function ne(e, r) {
{
var n = function() {
R3 || (R3 = !0, b("%s: `ref` 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://reactjs.org/link/special-props)", r));
};
n.isReactWarning = !0, Object.defineProperty(e, "ref", {
get: n,
configurable: !0
});
}
}
var te = function(e, r, n, a, l, f, u) {
var s = {
// This tag allows us to uniquely identify this as a React Element
$$typeof: o,
// Built-in properties that belong on the element
type: e,
key: r,
ref: n,
props: u,
// Record the component responsible for creating this element.
_owner: f
};
return s._store = {}, Object.defineProperty(s._store, "validated", {
configurable: !1,
enumerable: !1,
writable: !0,
value: !1
}), Object.defineProperty(s, "_self", {
configurable: !1,
enumerable: !1,
writable: !1,
value: a
}), Object.defineProperty(s, "_source", {
configurable: !1,
enumerable: !1,
writable: !1,
value: l
}), Object.freeze && (Object.freeze(s.props), Object.freeze(s)), s;
};
function ae(e, r, n, a, l) {
{
var f, u = {}, s = null, j = null;
n !== void 0 && (g3(n), s = "" + n), Q3(r) && (g3(r.key), s = "" + r.key), Z3(r) && (j = r.ref, ee(r, l));
for (f in r)
W.call(r, f) && !X3.hasOwnProperty(f) && (u[f] = r[f]);
if (e && e.defaultProps) {
var y = e.defaultProps;
for (f in y)
u[f] === void 0 && (u[f] = y[f]);
}
if (s || j) {
var E = typeof e == "function" ? e.displayName || e.name || "Unknown" : e;
s && re(u, E), j && ne(u, E);
}
return te(e, s, j, l, a, b3.current, u);
}
}
var Q = S.ReactCurrentOwner, _3 = S.ReactDebugCurrentFrame;
function A(e) {
if (e) {
var r = e._owner, n = H(e.type, e._source, r ? r.type : null);
_3.setExtraStackFrame(n);
} else
_3.setExtraStackFrame(null);
}
var e3;
e3 = !1;
function r3(e) {
return typeof e == "object" && e !== null && e.$$typeof === o;
}
function C3() {
{
if (Q.current) {
var e = O(Q.current.type);
if (e)
return `
Check the render method of \`` + e + "`.";
}
return "";
}
}
function oe(e) {
return "";
}
var x3 = {};
function ie(e) {
{
var r = C3();
if (!r) {
var n = typeof e == "string" ? e : e.displayName || e.name;
n && (r = `
Check the top-level render call using <` + n + ">.");
}
return r;
}
}
function w3(e, r) {
{
if (!e._store || e._store.validated || e.key != null)
return;
e._store.validated = !0;
var n = ie(r);
if (x3[n])
return;
x3[n] = !0;
var a = "";
e && e._owner && e._owner !== Q.current && (a = " It was passed a child from " + O(e._owner.type) + "."), A(e), b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', n, a), A(null);
}
}
function j3(e, r) {
{
if (typeof e != "object")
return;
if (Z(e))
for (var n = 0; n < e.length; n++) {
var a = e[n];
r3(a) && w3(a, r);
}
else if (r3(e))
e._store && (e._store.validated = !0);
else if (e) {
var l = h(e);
if (typeof l == "function" && l !== e.entries)
for (var f = l.call(e), u; !(u = f.next()).done; )
r3(u.value) && w3(u.value, r);
}
}
}
function se(e) {
{
var r = e.type;
if (r == null || typeof r == "string")
return;
var n;
if (typeof r == "function")
n = r.propTypes;
else if (typeof r == "object" && (r.$$typeof === v || // Note: Memo only checks outer props here.
// Inner props are checked in the reconciler.
r.$$typeof === _))
n = r.propTypes;
else
return;
if (n) {
var a = O(r);
q3(n, e.props, "prop", a, e);
} else if (r.PropTypes !== void 0 && !e3) {
e3 = !0;
var l = O(r);
b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", l || "Unknown");
}
typeof r.getDefaultProps == "function" && !r.getDefaultProps.isReactClassApproved && b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
}
}
function ue(e) {
{
for (var r = Object.keys(e.props), n = 0; n < r.length; n++) {
var a = r[n];
if (a !== "children" && a !== "key") {
A(e), b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", a), A(null);
break;
}
}
e.ref !== null && (A(e), b("Invalid attribute `ref` supplied to `React.Fragment`."), A(null));
}
}
var T3 = {};
function k3(e, r, n, a, l, f) {
{
var u = Y3(e);
if (!u) {
var s = "";
(e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (s += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
var j = oe();
j ? s += j : s += C3();
var y;
e === null ? y = "null" : Z(e) ? y = "array" : e !== void 0 && e.$$typeof === o ? (y = "<" + (O(e.type) || "Unknown") + " />", s = " Did you accidentally export a JSX literal instead of a component?") : y = typeof e, b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", y, s);
}
var E = ae(e, r, n, l, f);
if (E == null)
return E;
if (u) {
var k = r.children;
if (k !== void 0)
if (a)
if (Z(k)) {
for (var D = 0; D < k.length; D++)
j3(k[D], e);
Object.freeze && Object.freeze(k);
} else
b("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
j3(k, e);
}
if (W.call(r, "key")) {
var F = O(e), T = Object.keys(r).filter(function(pe) {
return pe !== "key";
}), n3 = T.length > 0 ? "{key: someKey, " + T.join(": ..., ") + ": ...}" : "{key: someKey}";
if (!T3[F + n3]) {
var ve = T.length > 0 ? "{" + T.join(": ..., ") + ": ...}" : "{}";
b(`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} />`, n3, F, ve, F), T3[F + n3] = !0;
}
}
return e === m ? ue(E) : se(E), E;
}
}
function ce(e, r, n) {
return k3(e, r, n, !0);
}
function le(e, r, n) {
return k3(e, r, n, !1);
}
var fe = le, de = ce;
V.Fragment = m, V.jsx = fe, V.jsxs = de;
}()), V;
}
var A3;
function ge() {
return A3 || (A3 = 1, process.env.NODE_ENV === "production" ? q.exports = ye() : q.exports = me()), q.exports;
}
var p = ge();
const be = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], Ee = [
"Baisakh",
"Jestha",
"Ashadh",
"Shrawan",
"Bhadra",
"Ashwin",
"Kartik",
"Mangsir",
"Poush",
"Magh",
"Falgun",
"Chaitra"
], N = {
2e3: [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
2001: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
2002: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
2003: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
2004: [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
2005: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
2006: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
2007: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
2008: [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31],
2009: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
2010: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
2011: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
2012: [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30],
2013: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
2014: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
2015: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
2016: [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30],
2017: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
2018: [31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30],
2019: [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
2020: [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
2021: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
2022: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30],
2023: [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
2024: [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
2025: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
2026: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
2027: [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
2028: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
2029: [31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30],
2030: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
2031: [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
2032: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
2033: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
2034: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
2035: [30, 32, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31],
2036: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
2037: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
2038: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
2039: [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30],
2040: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
2041: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
2042: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
2043: [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30],
2044: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
2045: [31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30],
2046: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
2047: [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
2048: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
2049: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30],
2050: [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
2051: [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
2052: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
2053: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30],
2054: [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
2055: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
2056: [31, 31, 32, 31, 32, 30, 30, 29, 30, 29, 30, 30],
2057: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
2058: [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
2059: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
2060: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
2061: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
2062: [31, 31, 31, 32, 31, 31, 29, 30, 29, 30, 29, 31],
2063: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
2064: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
2065: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
2066: [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 29, 31],
2067: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
2068: [31, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
2069: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
2070: [31, 31, 31, 32, 31, 31, 29, 30, 30, 29, 30, 30],
2071: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
2072: [31, 32, 31, 32, 31, 30, 30, 29, 30, 29, 30, 30],
2073: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31],
2074: [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
2075: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
2076: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30],
2077: [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
2078: [31, 31, 31, 32, 31, 31, 30, 29, 30, 29, 30, 30],
2079: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
2080: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 30],
2081: [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
2082: [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
2083: [31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30],
2084: [31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30],
2085: [31, 32, 31, 32, 30, 31, 30, 30, 29, 30, 30, 30],
2086: [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30],
2087: [31, 31, 32, 31, 31, 31, 30, 30, 30, 30, 30, 30],
2088: [30, 31, 32, 32, 30, 31, 30, 30, 29, 30, 30, 30],
2089: [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30],
2090: [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30],
2091: [31, 31, 32, 31, 31, 31, 30, 30, 29, 30, 30, 30],
2092: [30, 31, 32, 32, 31, 30, 30, 30, 29, 30, 30, 30],
2093: [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 30, 30],
2094: [31, 31, 32, 31, 31, 30, 30, 30, 29, 30, 30, 30],
2095: [31, 31, 32, 31, 31, 31, 30, 29, 30, 30, 30, 30],
2096: [30, 31, 32, 32, 31, 30, 30, 29, 30, 29, 30, 30],
2097: [31, 32, 31, 31, 31, 30, 30, 30, 29, 30, 30, 30],
2098: [31, 31, 32, 31, 31, 31, 29, 30, 29, 30, 29, 31],
2099: [31, 32, 31, 32, 31, 30, 30, 30, 29, 29, 30, 31]
}, t3 = { 2e3: 3 }, Re = 2e3, _e = 2099;
for (let t = Re + 1; t <= _e; t++) {
const o = t - 1, d = t3[o], m = (N[o] ?? []).reduce(
(g, i) => g + i,
0
);
if (typeof d == "number") {
const g = (d + m) % 7;
t3[t] = g;
} else
console.warn(`Missing weekday for year ${o}`);
}
function Ce({
selectedDate: t,
setSelectedDate: o,
handleSelectedValue: d
}) {
const m = () => {
var v;
let { year: i, month: c } = t;
c -= 1, c < 1 && (c = 12, i -= 1);
const R = ((v = N[i]) == null ? void 0 : v[c - 1]) || 30;
o((w) => ({
year: i,
month: c,
day: Math.min(w.day, R)
}));
}, g = () => {
var v;
let { year: i, month: c } = t;
c += 1, c > 12 && (c = 1, i += 1);
const R = ((v = N[i]) == null ? void 0 : v[c - 1]) || 30;
o((w) => ({
year: i,
month: c,
day: Math.min(w.day, R)
}));
};
return /* @__PURE__ */ p.jsxs("div", { className: "nepali-calendar-inner", children: [
/* @__PURE__ */ p.jsx(
"button",
{
onClick: m,
className: "nepali-calendar-prev-button",
type: "button",
children: "◀"
}
),
/* @__PURE__ */ p.jsxs("div", { className: "nepali-calendar-month", children: [
/* @__PURE__ */ p.jsx(
"select",
{
value: t.month - 1,
onChange: (i) => {
const c = parseInt(i.target.value, 10) + 1;
o((R) => ({ ...R, month: c })), d({ ...t, month: c });
},
className: "nepali-calendar-month-dropdown",
children: Ee.map((i, c) => /* @__PURE__ */ p.jsx("option", { value: c, children: i }, c))
}
),
/* @__PURE__ */ p.jsx(
"select",
{
value: t.year,
onChange: (i) => {
const c = parseInt(i.target.value, 10);
o((R) => ({ ...R, year: c })), d({ ...t, year: c });
},
className: "nepali-calendar-month-dropdown",
children: Object.keys(N).map((i) => /* @__PURE__ */ p.jsx("option", { value: i, children: i }, i))
}
)
] }),
/* @__PURE__ */ p.jsx(
"button",
{
onClick: g,
className: "nepali-calendar-next-button",
type: "button",
children: "▶"
}
)
] });
}
function xe(t, o) {
return t.year < o.year || t.year === o.year && t.month < o.month || t.year === o.year && t.month === o.month && t.day < o.day;
}
function we(t, o) {
return t.year > o.year || t.year === o.year && t.month > o.month || t.year === o.year && t.month === o.month && t.day > o.day;
}
const je = ({ date: t, selected: o, minDate: d, maxDate: m, onSelect: g }) => {
const i = xe(t, d) || we(t, m);
return /* @__PURE__ */ p.jsx(
"div",
{
onClick: () => !i && g(t),
style: {
cursor: i ? "not-allowed" : "pointer",
backgroundColor: o ? "#3b82f6" : "",
color: i ? "#ccc" : o ? "#fff" : "rgb(107, 107, 107)"
},
className: "current-month-days",
children: t.day
}
);
}, Te = ({
selectedDate: t,
setSelectedDate: o,
handleSelectedValue: d,
minDate: m,
maxDate: g
}) => {
var L;
const i = N[t.year], c = (i == null ? void 0 : i[t.month - 1]) ?? 30, R = () => {
const h = t3[t.year] ?? 0, S = (i == null ? void 0 : i.slice(0, t.month - 1).reduce((b, K) => b + K, 0)) || 0;
return (h + S) % 7;
}, v = t.month === 1 ? 12 : t.month - 1, w = t.month === 1 ? t.year - 1 : t.year, C = ((L = N[w]) == null ? void 0 : L[v - 1]) || 30, _ = R(), x = [];
for (let h = _ - 1; h >= 0; h--)
x.push(
/* @__PURE__ */ p.jsx("div", { className: "prev-next-month-days", children: C - h }, `p-${h}`)
);
for (let h = 1; h <= c; h++) {
const S = { ...t, day: h };
x.push(
/* @__PURE__ */ p.jsx(
je,
{
date: S,
selected: t.day === h,
minDate: m,
maxDate: g,
onSelect: (b) => {
o(b), d(b);
}
},
h
)
);
}
const $ = x.length % 7;
for (let h = 1; h <= ($ ? 7 - $ : 0); h++)
x.push(
/* @__PURE__ */ p.jsx("div", { className: "prev-next-month-days", children: h }, `n-${h}`)
);
return /* @__PURE__ */ p.jsxs("div", { className: "nepali-calendar-render", children: [
be.map((h) => /* @__PURE__ */ p.jsx("div", { className: "nepali-calendar-week", children: h }, h)),
x
] });
}, ke = ({
selectedDate: t,
setSelectedDate: o,
handleSelectedValue: d,
minDate: m,
maxDate: g
}) => /* @__PURE__ */ p.jsxs("div", { className: "nepali-calendar", children: [
/* @__PURE__ */ p.jsx(
Ce,
{
selectedDate: t,
setSelectedDate: o,
handleSelectedValue: d
}
),
/* @__PURE__ */ p.jsx(
Te,
{
selectedDate: t,
setSelectedDate: o,
handleSelectedValue: d,
minDate: m,
maxDate: g
}
)
] }), Se = "data:image/svg+xml,%3csvg%20width='14'%20height='16'%20viewBox='0%200%2020%2022'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2.75002%2021.2917C2.20276%2021.2917%201.73954%2021.1021%201.36038%2020.7229C0.981209%2020.3438%200.791626%2019.8806%200.791626%2019.3333V4.83341C0.791626%204.28615%200.981209%203.82293%201.36038%203.44377C1.73954%203.0646%202.20276%202.87502%202.75002%202.87502H4.2499V0.583496H5.91661V2.87502H14.125V0.583496H15.75V2.87502H17.2499C17.7972%202.87502%2018.2604%203.0646%2018.6395%203.44377C19.0187%203.82293%2019.2083%204.28615%2019.2083%204.83341V19.3333C19.2083%2019.8806%2019.0187%2020.3438%2018.6395%2020.7229C18.2604%2021.1021%2017.7972%2021.2917%2017.2499%2021.2917H2.75002ZM2.75002%2019.6667H17.2499C17.3333%2019.6667%2017.4097%2019.6319%2017.479%2019.5624C17.5485%2019.4931%2017.5833%2019.4167%2017.5833%2019.3333V9.16675H2.41663V19.3333C2.41663%2019.4167%202.45138%2019.4931%202.5209%2019.5624C2.59023%2019.6319%202.6666%2019.6667%202.75002%2019.6667ZM2.41663%207.54175H17.5833V4.83341C17.5833%204.75%2017.5485%204.67362%2017.479%204.60429C17.4097%204.53477%2017.3333%204.50002%2017.2499%204.50002H2.75002C2.6666%204.50002%202.59023%204.53477%202.5209%204.60429C2.45138%204.67362%202.41663%204.75%202.41663%204.83341V7.54175Z'%20fill='%231C1B1F'/%3e%3c/svg%3e", Oe = (t) => {
const { selectedDate: o, setShowDatepicker: d } = t;
return /* @__PURE__ */ p.jsxs(
"button",
{
className: "nepali-date-picker-button",
onClick: () => d((m) => !m),
type: "button",
children: [
/* @__PURE__ */ p.jsxs("span", { children: [
o.year,
"-",
String(o.month).padStart(2, "0"),
"-",
String(o.day).padStart(2, "0")
] }),
/* @__PURE__ */ p.jsx("img", { src: Se, alt: "DatepickerIcon" })
]
}
);
}, Fe = ({ value: t, onChange: o }) => {
const d = t.split("-"), [m, g] = S3(!1), [i, c] = S3({
year: Number(d[0]),
month: Number(d[1]),
day: Number(d[2])
});
O3(() => {
t && c({
year: Number(d[0]),
month: Number(d[1]),
day: Number(d[2])
});
}, [t]);
const R = {}, v = {}, w = he(null);
O3(() => {
const _ = (x) => {
w.current && !w.current.contains(x.target) && g(!1);
};
return document.addEventListener("mousedown", _), () => document.removeEventListener("mousedown", _);
}, []);
const C = (_) => {
const x = `${_.year}-${_.month}-${_.day}`;
o(x), g(!1);
};
return /* @__PURE__ */ p.jsxs("div", { className: "nepali-date-picker-container", ref: w, children: [
/* @__PURE__ */ p.jsx(
Oe,
{
selectedDate: i,
setShowDatepicker: g
}
),
m && /* @__PURE__ */ p.jsx(
ke,
{
selectedDate: i,
setSelectedDate: c,
handleSelectedValue: C,
minDate: R,
maxDate: v
}
)
] });
};
export {
Fe as Datepicker
};