UNPKG

dgz-ui-shared

Version:

Custom ui library using React.js, Shadcn/ui, TailwindCSS, Typescript, dgz-ui library

1,492 lines (1,490 loc) 45.4 kB
import * as s from "react"; import { useMemo as le, useCallback as $e, useState as Ie, useEffect as ie } from "react"; import { a as q } from "./MyInput-qse97Dxt.js"; import { u as Ae } from "./useDateRangeStore-BQDedoTk.js"; import { a as B } from "./dayjs.min-DQzb66fB.js"; var F = {}, ue; function De() { if (ue) return F; ue = 1, Object.defineProperty(F, "__esModule", { value: !0 }), F.parse = c, F.serialize = i; const e = /^[\u0021-\u003A\u003C\u003E-\u007E]+$/, t = /^[\u0021-\u003A\u003C-\u007E]*$/, r = /^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i, o = /^[\u0020-\u003A\u003D-\u007E]*$/, n = Object.prototype.toString, a = /* @__PURE__ */ (() => { const h = function() { }; return h.prototype = /* @__PURE__ */ Object.create(null), h; })(); function c(h, y) { const f = new a(), g = h.length; if (g < 2) return f; const x = (y == null ? void 0 : y.decode) || m; let d = 0; do { const v = h.indexOf("=", d); if (v === -1) break; const w = h.indexOf(";", d), C = w === -1 ? g : w; if (v > C) { d = h.lastIndexOf(";", v - 1) + 1; continue; } const S = u(h, d, v), T = l(h, v, S), $ = h.slice(S, T); if (f[$] === void 0) { let O = u(h, v + 1, C), R = l(h, C, O); const I = x(h.slice(O, R)); f[$] = I; } d = C + 1; } while (d < g); return f; } function u(h, y, f) { do { const g = h.charCodeAt(y); if (g !== 32 && g !== 9) return y; } while (++y < f); return f; } function l(h, y, f) { for (; y > f; ) { const g = h.charCodeAt(--y); if (g !== 32 && g !== 9) return y + 1; } return f; } function i(h, y, f) { const g = (f == null ? void 0 : f.encode) || encodeURIComponent; if (!e.test(h)) throw new TypeError(`argument name is invalid: ${h}`); const x = g(y); if (!t.test(x)) throw new TypeError(`argument val is invalid: ${y}`); let d = h + "=" + x; if (!f) return d; if (f.maxAge !== void 0) { if (!Number.isInteger(f.maxAge)) throw new TypeError(`option maxAge is invalid: ${f.maxAge}`); d += "; Max-Age=" + f.maxAge; } if (f.domain) { if (!r.test(f.domain)) throw new TypeError(`option domain is invalid: ${f.domain}`); d += "; Domain=" + f.domain; } if (f.path) { if (!o.test(f.path)) throw new TypeError(`option path is invalid: ${f.path}`); d += "; Path=" + f.path; } if (f.expires) { if (!p(f.expires) || !Number.isFinite(f.expires.valueOf())) throw new TypeError(`option expires is invalid: ${f.expires}`); d += "; Expires=" + f.expires.toUTCString(); } if (f.httpOnly && (d += "; HttpOnly"), f.secure && (d += "; Secure"), f.partitioned && (d += "; Partitioned"), f.priority) switch (typeof f.priority == "string" ? f.priority.toLowerCase() : void 0) { case "low": d += "; Priority=Low"; break; case "medium": d += "; Priority=Medium"; break; case "high": d += "; Priority=High"; break; default: throw new TypeError(`option priority is invalid: ${f.priority}`); } if (f.sameSite) switch (typeof f.sameSite == "string" ? f.sameSite.toLowerCase() : f.sameSite) { case !0: case "strict": d += "; SameSite=Strict"; break; case "lax": d += "; SameSite=Lax"; break; case "none": d += "; SameSite=None"; break; default: throw new TypeError(`option sameSite is invalid: ${f.sameSite}`); } return d; } function m(h) { if (h.indexOf("%") === -1) return h; try { return decodeURIComponent(h); } catch { return h; } } function p(h) { return n.call(h) === "[object Date]"; } return F; } De(); /** * react-router v7.6.2 * * Copyright (c) Remix Software Inc. * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */ function E(e, t) { if (e === !1 || e === null || typeof e > "u") throw new Error(t); } function b(e, t) { if (!e) { typeof console < "u" && console.warn(t); try { throw new Error(t); } catch { } } } function G({ pathname: e = "/", search: t = "", hash: r = "" }) { return t && t !== "?" && (e += t.charAt(0) === "?" ? t : "?" + t), r && r !== "#" && (e += r.charAt(0) === "#" ? r : "#" + r), e; } function Q(e) { let t = {}; if (e) { let r = e.indexOf("#"); r >= 0 && (t.hash = e.substring(r), e = e.substring(0, r)); let o = e.indexOf("?"); o >= 0 && (t.search = e.substring(o), e = e.substring(0, o)), e && (t.pathname = e); } return t; } function de(e, t, r = "/") { return Oe(e, t, r, !1); } function Oe(e, t, r, o) { let n = typeof t == "string" ? Q(t) : t, a = A(n.pathname || "/", r); if (a == null) return null; let c = he(e); Te(c); let u = null; for (let l = 0; u == null && l < c.length; ++l) { let i = Ve(a); u = je( c[l], i, o ); } return u; } function he(e, t = [], r = [], o = "") { let n = (a, c, u) => { let l = { relativePath: u === void 0 ? a.path || "" : u, caseSensitive: a.caseSensitive === !0, childrenIndex: c, route: a }; l.relativePath.startsWith("/") && (E( l.relativePath.startsWith(o), `Absolute route path "${l.relativePath}" nested under path "${o}" is not valid. An absolute child route path must start with the combined path of all its parent routes.` ), l.relativePath = l.relativePath.slice(o.length)); let i = P([o, l.relativePath]), m = r.concat(l); a.children && a.children.length > 0 && (E( // Our types know better, but runtime JS may not! // @ts-expect-error a.index !== !0, `Index routes must not have child routes. Please remove all child routes from route path "${i}".` ), he(a.children, t, m, i)), !(a.path == null && !a.index) && t.push({ path: i, score: We(i, a.index), routesMeta: m }); }; return e.forEach((a, c) => { var u; if (a.path === "" || !((u = a.path) != null && u.includes("?"))) n(a, c); else for (let l of me(a.path)) n(a, c, l); }), t; } function me(e) { let t = e.split("/"); if (t.length === 0) return []; let [r, ...o] = t, n = r.endsWith("?"), a = r.replace(/\?$/, ""); if (o.length === 0) return n ? [a, ""] : [a]; let c = me(o.join("/")), u = []; return u.push( ...c.map( (l) => l === "" ? a : [a, l].join("/") ) ), n && u.push(...c), u.map( (l) => e.startsWith("/") && l === "" ? "/" : l ); } function Te(e) { e.sort( (t, r) => t.score !== r.score ? r.score - t.score : He( t.routesMeta.map((o) => o.childrenIndex), r.routesMeta.map((o) => o.childrenIndex) ) ); } var Ne = /^:[\w-]+$/, Fe = 3, Me = 2, Ue = 1, Be = 10, _e = -2, se = (e) => e === "*"; function We(e, t) { let r = e.split("/"), o = r.length; return r.some(se) && (o += _e), t && (o += Me), r.filter((n) => !se(n)).reduce( (n, a) => n + (Ne.test(a) ? Fe : a === "" ? Ue : Be), o ); } function He(e, t) { return e.length === t.length && e.slice(0, -1).every((o, n) => o === t[n]) ? ( // If two routes are siblings, we should try to match the earlier sibling // first. This allows people to have fine-grained control over the matching // behavior by simply putting routes with identical paths in the order they // want them tried. e[e.length - 1] - t[t.length - 1] ) : ( // Otherwise, it doesn't really make sense to rank non-siblings by index, // so they sort equally. 0 ); } function je(e, t, r = !1) { let { routesMeta: o } = e, n = {}, a = "/", c = []; for (let u = 0; u < o.length; ++u) { let l = o[u], i = u === o.length - 1, m = a === "/" ? t : t.slice(a.length) || "/", p = j( { path: l.relativePath, caseSensitive: l.caseSensitive, end: i }, m ), h = l.route; if (!p && i && r && !o[o.length - 1].route.index && (p = j( { path: l.relativePath, caseSensitive: l.caseSensitive, end: !1 }, m )), !p) return null; Object.assign(n, p.params), c.push({ // TODO: Can this as be avoided? params: n, pathname: P([a, p.pathname]), pathnameBase: qe( P([a, p.pathnameBase]) ), route: h }), p.pathnameBase !== "/" && (a = P([a, p.pathnameBase])); } return c; } function j(e, t) { typeof e == "string" && (e = { path: e, caseSensitive: !1, end: !0 }); let [r, o] = ze( e.path, e.caseSensitive, e.end ), n = t.match(r); if (!n) return null; let a = n[0], c = a.replace(/(.)\/+$/, "$1"), u = n.slice(1); return { params: o.reduce( (i, { paramName: m, isOptional: p }, h) => { if (m === "*") { let f = u[h] || ""; c = a.slice(0, a.length - f.length).replace(/(.)\/+$/, "$1"); } const y = u[h]; return p && !y ? i[m] = void 0 : i[m] = (y || "").replace(/%2F/g, "/"), i; }, {} ), pathname: a, pathnameBase: c, pattern: e }; } function ze(e, t = !1, r = !0) { b( e === "*" || !e.endsWith("*") || e.endsWith("/*"), `Route path "${e}" will be treated as if it were "${e.replace(/\*$/, "/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/, "/*")}".` ); let o = [], n = "^" + e.replace(/\/*\*?$/, "").replace(/^\/*/, "/").replace(/[\\.*+^${}|()[\]]/g, "\\$&").replace( /\/:([\w-]+)(\?)?/g, (c, u, l) => (o.push({ paramName: u, isOptional: l != null }), l ? "/?([^\\/]+)?" : "/([^\\/]+)") ); return e.endsWith("*") ? (o.push({ paramName: "*" }), n += e === "*" || e === "/*" ? "(.*)$" : "(?:\\/(.+)|\\/*)$") : r ? n += "\\/*$" : e !== "" && e !== "/" && (n += "(?:(?=\\/|$))"), [new RegExp(n, t ? void 0 : "i"), o]; } function Ve(e) { try { return e.split("/").map((t) => decodeURIComponent(t).replace(/\//g, "%2F")).join("/"); } catch (t) { return b( !1, `The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).` ), e; } } function A(e, t) { if (t === "/") return e; if (!e.toLowerCase().startsWith(t.toLowerCase())) return null; let r = t.endsWith("/") ? t.length - 1 : t.length, o = e.charAt(r); return o && o !== "/" ? null : e.slice(r) || "/"; } function Je(e, t = "/") { let { pathname: r, search: o = "", hash: n = "" } = typeof e == "string" ? Q(e) : e; return { pathname: r ? r.startsWith("/") ? r : Ke(r, t) : t, search: Ge(o), hash: Xe(n) }; } function Ke(e, t) { let r = t.replace(/\/+$/, "").split("/"); return e.split("/").forEach((n) => { n === ".." ? r.length > 1 && r.pop() : n !== "." && r.push(n); }), r.length > 1 ? r.join("/") : "/"; } function K(e, t, r, o) { return `Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify( o )}]. Please separate it out to the \`to.${r}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`; } function Ye(e) { return e.filter( (t, r) => r === 0 || t.route.path && t.route.path.length > 0 ); } function pe(e) { let t = Ye(e); return t.map( (r, o) => o === t.length - 1 ? r.pathname : r.pathnameBase ); } function ge(e, t, r, o = !1) { let n; typeof e == "string" ? n = Q(e) : (n = { ...e }, E( !n.pathname || !n.pathname.includes("?"), K("?", "pathname", "search", n) ), E( !n.pathname || !n.pathname.includes("#"), K("#", "pathname", "hash", n) ), E( !n.search || !n.search.includes("#"), K("#", "search", "hash", n) )); let a = e === "" || n.pathname === "", c = a ? "/" : n.pathname, u; if (c == null) u = r; else { let p = t.length - 1; if (!o && c.startsWith("..")) { let h = c.split("/"); for (; h[0] === ".."; ) h.shift(), p -= 1; n.pathname = h.join("/"); } u = p >= 0 ? t[p] : "/"; } let l = Je(n, u), i = c && c !== "/" && c.endsWith("/"), m = (a || c === ".") && r.endsWith("/"); return !l.pathname.endsWith("/") && (i || m) && (l.pathname += "/"), l; } var P = (e) => e.join("/").replace(/\/\/+/g, "/"), qe = (e) => e.replace(/\/+$/, "").replace(/^\/*/, "/"), Ge = (e) => !e || e === "?" ? "" : e.startsWith("?") ? e : "?" + e, Xe = (e) => !e || e === "#" ? "" : e.startsWith("#") ? e : "#" + e; function Qe(e) { return e != null && typeof e.status == "number" && typeof e.statusText == "string" && typeof e.internal == "boolean" && "data" in e; } var ye = [ "POST", "PUT", "PATCH", "DELETE" ]; new Set( ye ); var Ze = [ "GET", ...ye ]; new Set(Ze); var N = s.createContext(null); N.displayName = "DataRouter"; var z = s.createContext(null); z.displayName = "DataRouterState"; var ve = s.createContext({ isTransitioning: !1 }); ve.displayName = "ViewTransition"; var et = s.createContext( /* @__PURE__ */ new Map() ); et.displayName = "Fetchers"; var tt = s.createContext(null); tt.displayName = "Await"; var L = s.createContext( null ); L.displayName = "Navigation"; var Z = s.createContext( null ); Z.displayName = "Location"; var k = s.createContext({ outlet: null, matches: [], isDataRoute: !1 }); k.displayName = "Route"; var ee = s.createContext(null); ee.displayName = "RouteError"; function rt(e, { relative: t } = {}) { E( V(), // TODO: This error is probably because they somehow have 2 versions of the // router loaded. We can help them understand how to avoid that. "useHref() may be used only in the context of a <Router> component." ); let { basename: r, navigator: o } = s.useContext(L), { hash: n, pathname: a, search: c } = U(e, { relative: t }), u = a; return r !== "/" && (u = a === "/" ? r : P([r, a])), o.createHref({ pathname: u, search: c, hash: n }); } function V() { return s.useContext(Z) != null; } function D() { return E( V(), // TODO: This error is probably because they somehow have 2 versions of the // router loaded. We can help them understand how to avoid that. "useLocation() may be used only in the context of a <Router> component." ), s.useContext(Z).location; } var we = "You should call navigate() in a React.useEffect(), not when your component is first rendered."; function xe(e) { s.useContext(L).static || s.useLayoutEffect(e); } function Ee() { let { isDataRoute: e } = s.useContext(k); return e ? pt() : nt(); } function nt() { E( V(), // TODO: This error is probably because they somehow have 2 versions of the // router loaded. We can help them understand how to avoid that. "useNavigate() may be used only in the context of a <Router> component." ); let e = s.useContext(N), { basename: t, navigator: r } = s.useContext(L), { matches: o } = s.useContext(k), { pathname: n } = D(), a = JSON.stringify(pe(o)), c = s.useRef(!1); return xe(() => { c.current = !0; }), s.useCallback( (l, i = {}) => { if (b(c.current, we), !c.current) return; if (typeof l == "number") { r.go(l); return; } let m = ge( l, JSON.parse(a), n, i.relative === "path" ); e == null && t !== "/" && (m.pathname = m.pathname === "/" ? t : P([t, m.pathname])), (i.replace ? r.replace : r.push)( m, i.state, i ); }, [ t, r, a, n, e ] ); } s.createContext(null); function U(e, { relative: t } = {}) { let { matches: r } = s.useContext(k), { pathname: o } = D(), n = JSON.stringify(pe(r)); return s.useMemo( () => ge( e, JSON.parse(n), o, t === "path" ), [e, n, o, t] ); } function at(e, t, r, o) { E( V(), // TODO: This error is probably because they somehow have 2 versions of the // router loaded. We can help them understand how to avoid that. "useRoutes() may be used only in the context of a <Router> component." ); let { navigator: n } = s.useContext(L), { matches: a } = s.useContext(k), c = a[a.length - 1], u = c ? c.params : {}, l = c ? c.pathname : "/", i = c ? c.pathnameBase : "/", m = c && c.route; { let d = m && m.path || ""; Ce( l, !m || d.endsWith("*") || d.endsWith("*?"), `You rendered descendant <Routes> (or called \`useRoutes()\`) at "${l}" (under <Route path="${d}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render. Please change the parent <Route path="${d}"> to <Route path="${d === "/" ? "*" : `${d}/*`}">.` ); } let p = D(), h; h = p; let y = h.pathname || "/", f = y; if (i !== "/") { let d = i.replace(/^\//, "").split("/"); f = "/" + y.replace(/^\//, "").split("/").slice(d.length).join("/"); } let g = de(e, { pathname: f }); return b( m || g != null, `No routes matched location "${h.pathname}${h.search}${h.hash}" ` ), b( g == null || g[g.length - 1].route.element !== void 0 || g[g.length - 1].route.Component !== void 0 || g[g.length - 1].route.lazy !== void 0, `Matched leaf route at location "${h.pathname}${h.search}${h.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.` ), st( g && g.map( (d) => Object.assign({}, d, { params: Object.assign({}, u, d.params), pathname: P([ i, // Re-encode pathnames that were decoded inside matchRoutes n.encodeLocation ? n.encodeLocation(d.pathname).pathname : d.pathname ]), pathnameBase: d.pathnameBase === "/" ? i : P([ i, // Re-encode pathnames that were decoded inside matchRoutes n.encodeLocation ? n.encodeLocation(d.pathnameBase).pathname : d.pathnameBase ]) }) ), a, r, o ); } function ot() { let e = mt(), t = Qe(e) ? `${e.status} ${e.statusText}` : e instanceof Error ? e.message : JSON.stringify(e), r = e instanceof Error ? e.stack : null, o = "rgba(200,200,200, 0.5)", n = { padding: "0.5rem", backgroundColor: o }, a = { padding: "2px 4px", backgroundColor: o }, c = null; return console.error( "Error handled by React Router default ErrorBoundary:", e ), c = /* @__PURE__ */ s.createElement(s.Fragment, null, /* @__PURE__ */ s.createElement("p", null, "💿 Hey developer 👋"), /* @__PURE__ */ s.createElement("p", null, "You can provide a way better UX than this when your app throws errors by providing your own ", /* @__PURE__ */ s.createElement("code", { style: a }, "ErrorBoundary"), " or", " ", /* @__PURE__ */ s.createElement("code", { style: a }, "errorElement"), " prop on your route.")), /* @__PURE__ */ s.createElement(s.Fragment, null, /* @__PURE__ */ s.createElement("h2", null, "Unexpected Application Error!"), /* @__PURE__ */ s.createElement("h3", { style: { fontStyle: "italic" } }, t), r ? /* @__PURE__ */ s.createElement("pre", { style: n }, r) : null, c); } var lt = /* @__PURE__ */ s.createElement(ot, null), it = class extends s.Component { constructor(e) { super(e), this.state = { location: e.location, revalidation: e.revalidation, error: e.error }; } static getDerivedStateFromError(e) { return { error: e }; } static getDerivedStateFromProps(e, t) { return t.location !== e.location || t.revalidation !== "idle" && e.revalidation === "idle" ? { error: e.error, location: e.location, revalidation: e.revalidation } : { error: e.error !== void 0 ? e.error : t.error, location: t.location, revalidation: e.revalidation || t.revalidation }; } componentDidCatch(e, t) { console.error( "React Router caught the following error during render", e, t ); } render() { return this.state.error !== void 0 ? /* @__PURE__ */ s.createElement(k.Provider, { value: this.props.routeContext }, /* @__PURE__ */ s.createElement( ee.Provider, { value: this.state.error, children: this.props.component } )) : this.props.children; } }; function ut({ routeContext: e, match: t, children: r }) { let o = s.useContext(N); return o && o.static && o.staticContext && (t.route.errorElement || t.route.ErrorBoundary) && (o.staticContext._deepestRenderedBoundaryId = t.route.id), /* @__PURE__ */ s.createElement(k.Provider, { value: e }, r); } function st(e, t = [], r = null, o = null) { if (e == null) { if (!r) return null; if (r.errors) e = r.matches; else if (t.length === 0 && !r.initialized && r.matches.length > 0) e = r.matches; else return null; } let n = e, a = r == null ? void 0 : r.errors; if (a != null) { let l = n.findIndex( (i) => i.route.id && (a == null ? void 0 : a[i.route.id]) !== void 0 ); E( l >= 0, `Could not find a matching route for errors on route IDs: ${Object.keys( a ).join(",")}` ), n = n.slice( 0, Math.min(n.length, l + 1) ); } let c = !1, u = -1; if (r) for (let l = 0; l < n.length; l++) { let i = n[l]; if ((i.route.HydrateFallback || i.route.hydrateFallbackElement) && (u = l), i.route.id) { let { loaderData: m, errors: p } = r, h = i.route.loader && !m.hasOwnProperty(i.route.id) && (!p || p[i.route.id] === void 0); if (i.route.lazy || h) { c = !0, u >= 0 ? n = n.slice(0, u + 1) : n = [n[0]]; break; } } } return n.reduceRight((l, i, m) => { let p, h = !1, y = null, f = null; r && (p = a && i.route.id ? a[i.route.id] : void 0, y = i.route.errorElement || lt, c && (u < 0 && m === 0 ? (Ce( "route-fallback", !1, "No `HydrateFallback` element provided to render during initial hydration" ), h = !0, f = null) : u === m && (h = !0, f = i.route.hydrateFallbackElement || null))); let g = t.concat(n.slice(0, m + 1)), x = () => { let d; return p ? d = y : h ? d = f : i.route.Component ? d = /* @__PURE__ */ s.createElement(i.route.Component, null) : i.route.element ? d = i.route.element : d = l, /* @__PURE__ */ s.createElement( ut, { match: i, routeContext: { outlet: l, matches: g, isDataRoute: r != null }, children: d } ); }; return r && (i.route.ErrorBoundary || i.route.errorElement || m === 0) ? /* @__PURE__ */ s.createElement( it, { location: r.location, revalidation: r.revalidation, component: y, error: p, children: x(), routeContext: { outlet: null, matches: g, isDataRoute: !0 } } ) : x(); }, null); } function te(e) { return `${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`; } function ct(e) { let t = s.useContext(N); return E(t, te(e)), t; } function ft(e) { let t = s.useContext(z); return E(t, te(e)), t; } function dt(e) { let t = s.useContext(k); return E(t, te(e)), t; } function re(e) { let t = dt(e), r = t.matches[t.matches.length - 1]; return E( r.route.id, `${e} can only be used on routes that contain a unique "id"` ), r.route.id; } function ht() { return re( "useRouteId" /* UseRouteId */ ); } function mt() { var o; let e = s.useContext(ee), t = ft( "useRouteError" /* UseRouteError */ ), r = re( "useRouteError" /* UseRouteError */ ); return e !== void 0 ? e : (o = t.errors) == null ? void 0 : o[r]; } function pt() { let { router: e } = ct( "useNavigate" /* UseNavigateStable */ ), t = re( "useNavigate" /* UseNavigateStable */ ), r = s.useRef(!1); return xe(() => { r.current = !0; }), s.useCallback( async (n, a = {}) => { b(r.current, we), r.current && (typeof n == "number" ? e.navigate(n) : await e.navigate(n, { fromRouteId: t, ...a })); }, [e, t] ); } var ce = {}; function Ce(e, t, r) { !t && !ce[e] && (ce[e] = !0, b(!1, r)); } s.memo(gt); function gt({ routes: e, future: t, state: r }) { return at(e, void 0, r, t); } var W = "get", H = "application/x-www-form-urlencoded"; function J(e) { return e != null && typeof e.tagName == "string"; } function yt(e) { return J(e) && e.tagName.toLowerCase() === "button"; } function vt(e) { return J(e) && e.tagName.toLowerCase() === "form"; } function wt(e) { return J(e) && e.tagName.toLowerCase() === "input"; } function xt(e) { return !!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey); } function Et(e, t) { return e.button === 0 && // Ignore everything but left clicks (!t || t === "_self") && // Let browser handle "target=_blank" etc. !xt(e); } function X(e = "") { return new URLSearchParams( typeof e == "string" || Array.isArray(e) || e instanceof URLSearchParams ? e : Object.keys(e).reduce((t, r) => { let o = e[r]; return t.concat( Array.isArray(o) ? o.map((n) => [r, n]) : [[r, o]] ); }, []) ); } function Ct(e, t) { let r = X(e); return t && t.forEach((o, n) => { r.has(n) || t.getAll(n).forEach((a) => { r.append(n, a); }); }), r; } var _ = null; function Rt() { if (_ === null) try { new FormData( document.createElement("form"), // @ts-expect-error if FormData supports the submitter parameter, this will throw 0 ), _ = !1; } catch { _ = !0; } return _; } var St = /* @__PURE__ */ new Set([ "application/x-www-form-urlencoded", "multipart/form-data", "text/plain" ]); function Y(e) { return e != null && !St.has(e) ? (b( !1, `"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${H}"` ), null) : e; } function bt(e, t) { let r, o, n, a, c; if (vt(e)) { let u = e.getAttribute("action"); o = u ? A(u, t) : null, r = e.getAttribute("method") || W, n = Y(e.getAttribute("enctype")) || H, a = new FormData(e); } else if (yt(e) || wt(e) && (e.type === "submit" || e.type === "image")) { let u = e.form; if (u == null) throw new Error( 'Cannot submit a <button> or <input type="submit"> without a <form>' ); let l = e.getAttribute("formaction") || u.getAttribute("action"); if (o = l ? A(l, t) : null, r = e.getAttribute("formmethod") || u.getAttribute("method") || W, n = Y(e.getAttribute("formenctype")) || Y(u.getAttribute("enctype")) || H, a = new FormData(u, e), !Rt()) { let { name: i, type: m, value: p } = e; if (m === "image") { let h = i ? `${i}.` : ""; a.append(`${h}x`, "0"), a.append(`${h}y`, "0"); } else i && a.append(i, p); } } else { if (J(e)) throw new Error( 'Cannot submit element that is not <form>, <button>, or <input type="submit|image">' ); r = W, o = null, n = H, c = e; } return a && n === "text/plain" && (c = a, a = void 0), { action: o, method: r.toLowerCase(), encType: n, formData: a, body: c }; } function ne(e, t) { if (e === !1 || e === null || typeof e > "u") throw new Error(t); } async function Pt(e, t) { if (e.id in t) return t[e.id]; try { let r = await import( /* @vite-ignore */ /* webpackIgnore: true */ e.module ); return t[e.id] = r, r; } catch (r) { return console.error( `Error loading route module \`${e.module}\`, reloading page...` ), console.error(r), window.__reactRouterContext && window.__reactRouterContext.isSpaMode, window.location.reload(), new Promise(() => { }); } } function Lt(e) { return e == null ? !1 : e.href == null ? e.rel === "preload" && typeof e.imageSrcSet == "string" && typeof e.imageSizes == "string" : typeof e.rel == "string" && typeof e.href == "string"; } async function kt(e, t, r) { let o = await Promise.all( e.map(async (n) => { let a = t.routes[n.route.id]; if (a) { let c = await Pt(a, r); return c.links ? c.links() : []; } return []; }) ); return Dt( o.flat(1).filter(Lt).filter((n) => n.rel === "stylesheet" || n.rel === "preload").map( (n) => n.rel === "stylesheet" ? { ...n, rel: "prefetch", as: "style" } : { ...n, rel: "prefetch" } ) ); } function fe(e, t, r, o, n, a) { let c = (l, i) => r[i] ? l.route.id !== r[i].route.id : !0, u = (l, i) => { var m; return ( // param change, /users/123 -> /users/456 r[i].pathname !== l.pathname || // splat param changed, which is not present in match.path // e.g. /files/images/avatar.jpg -> files/finances.xls ((m = r[i].route.path) == null ? void 0 : m.endsWith("*")) && r[i].params["*"] !== l.params["*"] ); }; return a === "assets" ? t.filter( (l, i) => c(l, i) || u(l, i) ) : a === "data" ? t.filter((l, i) => { var p; let m = o.routes[l.route.id]; if (!m || !m.hasLoader) return !1; if (c(l, i) || u(l, i)) return !0; if (l.route.shouldRevalidate) { let h = l.route.shouldRevalidate({ currentUrl: new URL( n.pathname + n.search + n.hash, window.origin ), currentParams: ((p = r[0]) == null ? void 0 : p.params) || {}, nextUrl: new URL(e, window.origin), nextParams: l.params, defaultShouldRevalidate: !0 }); if (typeof h == "boolean") return h; } return !0; }) : []; } function $t(e, t, { includeHydrateFallback: r } = {}) { return It( e.map((o) => { let n = t.routes[o.route.id]; if (!n) return []; let a = [n.module]; return n.clientActionModule && (a = a.concat(n.clientActionModule)), n.clientLoaderModule && (a = a.concat(n.clientLoaderModule)), r && n.hydrateFallbackModule && (a = a.concat(n.hydrateFallbackModule)), n.imports && (a = a.concat(n.imports)), a; }).flat(1) ); } function It(e) { return [...new Set(e)]; } function At(e) { let t = {}, r = Object.keys(e).sort(); for (let o of r) t[o] = e[o]; return t; } function Dt(e, t) { let r = /* @__PURE__ */ new Set(); return new Set(t), e.reduce((o, n) => { let a = JSON.stringify(At(n)); return r.has(a) || (r.add(a), o.push({ key: a, link: n })), o; }, []); } Object.getOwnPropertyNames(Object.prototype).sort().join("\0"); var Ot = /* @__PURE__ */ new Set([100, 101, 204, 205]); function Tt(e, t) { let r = typeof e == "string" ? new URL( e, // This can be called during the SSR flow via PrefetchPageLinksImpl so // don't assume window is available typeof window > "u" ? "server://singlefetch/" : window.location.origin ) : e; return r.pathname === "/" ? r.pathname = "_root.data" : t && A(r.pathname, t) === "/" ? r.pathname = `${t.replace(/\/$/, "")}/_root.data` : r.pathname = `${r.pathname.replace(/\/$/, "")}.data`, r; } function Re() { let e = s.useContext(N); return ne( e, "You must render this element inside a <DataRouterContext.Provider> element" ), e; } function Nt() { let e = s.useContext(z); return ne( e, "You must render this element inside a <DataRouterStateContext.Provider> element" ), e; } var ae = s.createContext(void 0); ae.displayName = "FrameworkContext"; function Se() { let e = s.useContext(ae); return ne( e, "You must render this element inside a <HydratedRouter> element" ), e; } function Ft(e, t) { let r = s.useContext(ae), [o, n] = s.useState(!1), [a, c] = s.useState(!1), { onFocus: u, onBlur: l, onMouseEnter: i, onMouseLeave: m, onTouchStart: p } = t, h = s.useRef(null); s.useEffect(() => { if (e === "render" && c(!0), e === "viewport") { let g = (d) => { d.forEach((v) => { c(v.isIntersecting); }); }, x = new IntersectionObserver(g, { threshold: 0.5 }); return h.current && x.observe(h.current), () => { x.disconnect(); }; } }, [e]), s.useEffect(() => { if (o) { let g = setTimeout(() => { c(!0); }, 100); return () => { clearTimeout(g); }; } }, [o]); let y = () => { n(!0); }, f = () => { n(!1), c(!1); }; return r ? e !== "intent" ? [a, h, {}] : [ a, h, { onFocus: M(u, y), onBlur: M(l, f), onMouseEnter: M(i, y), onMouseLeave: M(m, f), onTouchStart: M(p, y) } ] : [!1, h, {}]; } function M(e, t) { return (r) => { e && e(r), r.defaultPrevented || t(r); }; } function Mt({ page: e, ...t }) { let { router: r } = Re(), o = s.useMemo( () => de(r.routes, e, r.basename), [r.routes, e, r.basename] ); return o ? /* @__PURE__ */ s.createElement(Bt, { page: e, matches: o, ...t }) : null; } function Ut(e) { let { manifest: t, routeModules: r } = Se(), [o, n] = s.useState([]); return s.useEffect(() => { let a = !1; return kt(e, t, r).then( (c) => { a || n(c); } ), () => { a = !0; }; }, [e, t, r]), o; } function Bt({ page: e, matches: t, ...r }) { let o = D(), { manifest: n, routeModules: a } = Se(), { basename: c } = Re(), { loaderData: u, matches: l } = Nt(), i = s.useMemo( () => fe( e, t, l, n, o, "data" ), [e, t, l, n, o] ), m = s.useMemo( () => fe( e, t, l, n, o, "assets" ), [e, t, l, n, o] ), p = s.useMemo(() => { if (e === o.pathname + o.search + o.hash) return []; let f = /* @__PURE__ */ new Set(), g = !1; if (t.forEach((d) => { var w; let v = n.routes[d.route.id]; !v || !v.hasLoader || (!i.some((C) => C.route.id === d.route.id) && d.route.id in u && ((w = a[d.route.id]) != null && w.shouldRevalidate) || v.hasClientLoader ? g = !0 : f.add(d.route.id)); }), f.size === 0) return []; let x = Tt(e, c); return g && f.size > 0 && x.searchParams.set( "_routes", t.filter((d) => f.has(d.route.id)).map((d) => d.route.id).join(",") ), [x.pathname + x.search]; }, [ c, u, o, n, i, t, e, a ]), h = s.useMemo( () => $t(m, n), [m, n] ), y = Ut(m); return /* @__PURE__ */ s.createElement(s.Fragment, null, p.map((f) => /* @__PURE__ */ s.createElement("link", { key: f, rel: "prefetch", as: "fetch", href: f, ...r })), h.map((f) => /* @__PURE__ */ s.createElement("link", { key: f, rel: "modulepreload", href: f, ...r })), y.map(({ key: f, link: g }) => ( // these don't spread `linkProps` because they are full link descriptors // already with their own props /* @__PURE__ */ s.createElement("link", { key: f, ...g }) ))); } function _t(...e) { return (t) => { e.forEach((r) => { typeof r == "function" ? r(t) : r != null && (r.current = t); }); }; } var be = typeof window < "u" && typeof window.document < "u" && typeof window.document.createElement < "u"; try { be && (window.__reactRouterVersion = "7.6.2"); } catch { } var Pe = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i, Le = s.forwardRef( function({ onClick: t, discover: r = "render", prefetch: o = "none", relative: n, reloadDocument: a, replace: c, state: u, target: l, to: i, preventScrollReset: m, viewTransition: p, ...h }, y) { let { basename: f } = s.useContext(L), g = typeof i == "string" && Pe.test(i), x, d = !1; if (typeof i == "string" && g && (x = i, be)) try { let R = new URL(window.location.href), I = i.startsWith("//") ? new URL(R.protocol + i) : new URL(i), oe = A(I.pathname, f); I.origin === R.origin && oe != null ? i = oe + I.search + I.hash : d = !0; } catch { b( !1, `<Link to="${i}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.` ); } let v = rt(i, { relative: n }), [w, C, S] = Ft( o, h ), T = zt(i, { replace: c, state: u, target: l, preventScrollReset: m, relative: n, viewTransition: p }); function $(R) { t && t(R), R.defaultPrevented || T(R); } let O = ( // eslint-disable-next-line jsx-a11y/anchor-has-content /* @__PURE__ */ s.createElement( "a", { ...h, ...S, href: x || v, onClick: d || a ? t : $, ref: _t(y, C), target: l, "data-discover": !g && r === "render" ? "true" : void 0 } ) ); return w && !g ? /* @__PURE__ */ s.createElement(s.Fragment, null, O, /* @__PURE__ */ s.createElement(Mt, { page: v })) : O; } ); Le.displayName = "Link"; var Wt = s.forwardRef( function({ "aria-current": t = "page", caseSensitive: r = !1, className: o = "", end: n = !1, style: a, to: c, viewTransition: u, children: l, ...i }, m) { let p = U(c, { relative: i.relative }), h = D(), y = s.useContext(z), { navigator: f, basename: g } = s.useContext(L), x = y != null && // Conditional usage is OK here because the usage of a data router is static // eslint-disable-next-line react-hooks/rules-of-hooks Gt(p) && u === !0, d = f.encodeLocation ? f.encodeLocation(p).pathname : p.pathname, v = h.pathname, w = y && y.navigation && y.navigation.location ? y.navigation.location.pathname : null; r || (v = v.toLowerCase(), w = w ? w.toLowerCase() : null, d = d.toLowerCase()), w && g && (w = A(w, g) || w); const C = d !== "/" && d.endsWith("/") ? d.length - 1 : d.length; let S = v === d || !n && v.startsWith(d) && v.charAt(C) === "/", T = w != null && (w === d || !n && w.startsWith(d) && w.charAt(d.length) === "/"), $ = { isActive: S, isPending: T, isTransitioning: x }, O = S ? t : void 0, R; typeof o == "function" ? R = o($) : R = [ o, S ? "active" : null, T ? "pending" : null, x ? "transitioning" : null ].filter(Boolean).join(" "); let I = typeof a == "function" ? a($) : a; return /* @__PURE__ */ s.createElement( Le, { ...i, "aria-current": O, className: R, ref: m, style: I, to: c, viewTransition: u }, typeof l == "function" ? l($) : l ); } ); Wt.displayName = "NavLink"; var Ht = s.forwardRef( ({ discover: e = "render", fetcherKey: t, navigate: r, reloadDocument: o, replace: n, state: a, method: c = W, action: u, onSubmit: l, relative: i, preventScrollReset: m, viewTransition: p, ...h }, y) => { let f = Yt(), g = qt(u, { relative: i }), x = c.toLowerCase() === "get" ? "get" : "post", d = typeof u == "string" && Pe.test(u), v = (w) => { if (l && l(w), w.defaultPrevented) return; w.preventDefault(); let C = w.nativeEvent.submitter, S = (C == null ? void 0 : C.getAttribute("formmethod")) || c; f(C || w.currentTarget, { fetcherKey: t, method: S, navigate: r, replace: n, state: a, relative: i, preventScrollReset: m, viewTransition: p }); }; return /* @__PURE__ */ s.createElement( "form", { ref: y, method: x, action: g, onSubmit: o ? l : v, ...h, "data-discover": !d && e === "render" ? "true" : void 0 } ); } ); Ht.displayName = "Form"; function jt(e) { return `${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`; } function ke(e) { let t = s.useContext(N); return E(t, jt(e)), t; } function zt(e, { target: t, replace: r, state: o, preventScrollReset: n, relative: a, viewTransition: c } = {}) { let u = Ee(), l = D(), i = U(e, { relative: a }); return s.useCallback( (m) => { if (Et(m, t)) { m.preventDefault(); let p = r !== void 0 ? r : G(l) === G(i); u(e, { replace: p, state: o, preventScrollReset: n, relative: a, viewTransition: c }); } }, [ l, u, i, r, o, t, e, n, a, c ] ); } function Vt(e) { b( typeof URLSearchParams < "u", "You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params." ); let t = s.useRef(X(e)), r = s.useRef(!1), o = D(), n = s.useMemo( () => ( // Only merge in the defaults if we haven't yet called setSearchParams. // Once we call that we want those to take precedence, otherwise you can't // remove a param with setSearchParams({}) if it has an initial value Ct( o.search, r.current ? null : t.current ) ), [o.search] ), a = Ee(), c = s.useCallback( (u, l) => { const i = X( typeof u == "function" ? u(n) : u ); r.current = !0, a("?" + i, l); }, [a, n] ); return [n, c]; } var Jt = 0, Kt = () => `__${String(++Jt)}__`; function Yt() { let { router: e } = ke( "useSubmit" /* UseSubmit */ ), { basename: t } = s.useContext(L), r = ht(); return s.useCallback( async (o, n = {}) => { let { action: a, method: c, encType: u, formData: l, body: i } = bt( o, t ); if (n.navigate === !1) { let m = n.fetcherKey || Kt(); await e.fetch(m, r, n.action || a, { preventScrollReset: n.preventScrollReset, formData: l, body: i, formMethod: n.method || c, formEncType: n.encType || u, flushSync: n.flushSync }); } else await e.navigate(n.action || a, { preventScrollReset: n.preventScrollReset, formData: l, body: i, formMethod: n.method || c, formEncType: n.encType || u, replace: n.replace, state: n.state, fromRouteId: r, flushSync: n.flushSync, viewTransition: n.viewTransition }); }, [e, t, r] ); } function qt(e, { relative: t } = {}) { let { basename: r } = s.useContext(L), o = s.useContext(k); E(o, "useFormAction must be used inside a RouteContext"); let [n] = o.matches.slice(-1), a = { ...U(e || ".", { relative: t }) }, c = D(); if (e == null) { a.search = c.search; let u = new URLSearchParams(a.search), l = u.getAll("index"); if (l.some((m) => m === "")) { u.delete("index"), l.filter((p) => p).forEach((p) => u.append("index", p)); let m = u.toString(); a.search = m ? `?${m}` : ""; } } return (!e || e === ".") && n.route.index && (a.search = a.search ? a.search.replace(/^\?/, "?index&") : "?index"), r !== "/" && (a.pathname = a.pathname === "/" ? r : P([r, a.pathname])), G(a); } function Gt(e, t = {}) { let r = s.useContext(ve); E( r != null, "`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?" ); let { basename: o } = ke( "useViewTransitionState" /* useViewTransitionState */ ), n = U(e, { relative: t.relative }); if (!r.isTransitioning) return !1; let a = A(r.currentLocation.pathname, o) || r.currentLocation.pathname, c = A(r.nextLocation.pathname, o) || r.nextLocation.pathname; return j(n.pathname, c) != null || j(n.pathname, a) != null; } [ ...Ot ]; const Xt = (e) => { const [t, r] = Vt(), o = le( () => (e == null ? void 0 : e.excludeParams) || [], [e == null ? void 0 : e.excludeParams] ), n = le(() => { const c = {}; return t.forEach((u, l) => { if (!o.includes(l)) { const i = t.getAll(l); c[l] = i.length > 1 ? i : u; } }), c; }, [t, o]), a = $e( (c) => { const u = new URLSearchParams(); Object.entries(c).forEach(([l, i]) => { q.isNil(i) ? u.delete(l) : Array.isArray(i) ? i.forEach((m) => u.append(l, String(m))) : u.set(l, String(i)); }), r(u, { replace: !0 }); }, [r] ); return { params: n, handleSetParams: a }; }, rr = (e) => { const { params: t } = Xt(), { storedRanges: r, setStoredRange: o } = Ae(), [n, a] = Ie(); return ie(() => { const u = q.get(t, "start") || B().subtract(2, "week").startOf("day"), l = q.get(t, "end") || B().endOf("day"); u && l && a({ from: B(u).toDate(), to: B(l).toDate() }); }, [t]), ie(() => { let u = { ...r }; n ? u = { ...u, [e]: n } : Object.prototype.hasOwnProperty.call(u, e) && delete u[e], o({ ...u }); }, [n, JSON.stringify(r), e]), { range: n, handleRangeSelected: (u) => { a(u); } }; }; export { Xt as a, rr as u };