Not Found
)`
);
}
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DefaultGlobalNotFound, {});
}
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(route.options.notFoundComponent, { data });
}
// node_modules/@tanstack/react-router/dist/esm/scroll-restoration.js
var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
// node_modules/@tanstack/react-router/dist/esm/ScriptOnce.js
var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
function ScriptOnce({ children }) {
const router = useRouter();
if (!router.isServer) {
return null;
}
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
"script",
{
nonce: router.options.ssr?.nonce,
className: "$tsr",
dangerouslySetInnerHTML: {
__html: [children].filter(Boolean).join("\n") + ";$_TSR.c()"
}
}
);
}
// node_modules/@tanstack/react-router/dist/esm/scroll-restoration.js
function ScrollRestoration() {
const router = useRouter();
if (!router.isScrollRestoring || !router.isServer) {
return null;
}
if (typeof router.options.scrollRestoration === "function") {
const shouldRestore = router.options.scrollRestoration({
location: router.latestLocation
});
if (!shouldRestore) {
return null;
}
}
const getKey = router.options.getScrollRestorationKey || defaultGetScrollRestorationKey;
const userKey = getKey(router.latestLocation);
const resolvedKey = userKey !== defaultGetScrollRestorationKey(router.latestLocation) ? userKey : void 0;
const restoreScrollOptions = {
storageKey,
shouldScrollRestoration: true
};
if (resolvedKey) {
restoreScrollOptions.key = resolvedKey;
}
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
ScriptOnce,
{
children: `(${restoreScroll.toString()})(${JSON.stringify(restoreScrollOptions)})`
}
);
}
// node_modules/@tanstack/react-router/dist/esm/Match.js
var Match = React10.memo(function MatchImpl({
matchId
}) {
const router = useRouter();
const matchState = useRouterState({
select: (s) => {
const match = s.matches.find((d) => d.id === matchId);
invariant(
match,
`Could not find match for matchId "${matchId}". Please file an issue!`
);
return {
routeId: match.routeId,
ssr: match.ssr,
_displayPending: match._displayPending
};
},
structuralSharing: true
});
const route = router.routesById[matchState.routeId];
const PendingComponent = route.options.pendingComponent ?? router.options.defaultPendingComponent;
const pendingElement = PendingComponent ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(PendingComponent, {}) : null;
const routeErrorComponent = route.options.errorComponent ?? router.options.defaultErrorComponent;
const routeOnCatch = route.options.onCatch ?? router.options.defaultOnCatch;
const routeNotFoundComponent = route.isRoot ? (
// If it's the root route, use the globalNotFound option, with fallback to the notFoundRoute's component
route.options.notFoundComponent ?? router.options.notFoundRoute?.options.component
) : route.options.notFoundComponent;
const resolvedNoSsr = matchState.ssr === false || matchState.ssr === "data-only";
const ResolvedSuspenseBoundary = (
// If we're on the root route, allow forcefully wrapping in suspense
(!route.isRoot || route.options.wrapInSuspense || resolvedNoSsr) && (route.options.wrapInSuspense ?? PendingComponent ?? (route.options.errorComponent?.preload || resolvedNoSsr)) ? React10.Suspense : SafeFragment
);
const ResolvedCatchBoundary = routeErrorComponent ? CatchBoundary : SafeFragment;
const ResolvedNotFoundBoundary = routeNotFoundComponent ? CatchNotFound : SafeFragment;
const resetKey = useRouterState({
select: (s) => s.loadedAt
});
const parentRouteId = useRouterState({
select: (s) => {
const index = s.matches.findIndex((d) => d.id === matchId);
return s.matches[index - 1]?.routeId;
}
});
const ShellComponent = route.isRoot ? route.options.shellComponent ?? SafeFragment : SafeFragment;
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(ShellComponent, { children: [
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(matchContext.Provider, { value: matchId, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ResolvedSuspenseBoundary, { fallback: pendingElement, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
ResolvedCatchBoundary,
{
getResetKey: () => resetKey,
errorComponent: routeErrorComponent || ErrorComponent,
onCatch: (error, errorInfo) => {
if (isNotFound(error)) throw error;
tiny_warning_esm_default(false, `Error in route match: ${matchId}`);
routeOnCatch?.(error, errorInfo);
},
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
ResolvedNotFoundBoundary,
{
fallback: (error) => {
if (!routeNotFoundComponent || error.routeId && error.routeId !== matchState.routeId || !error.routeId && !route.isRoot)
throw error;
return React10.createElement(routeNotFoundComponent, error);
},
children: resolvedNoSsr || matchState._displayPending ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ClientOnly, { fallback: pendingElement, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(MatchInner, { matchId }) }) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(MatchInner, { matchId })
}
)
}
) }) }),
parentRouteId === rootRouteId && router.options.scrollRestoration ? /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(OnRendered, {}),
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ScrollRestoration, {})
] }) : null
] });
});
function OnRendered() {
const router = useRouter();
const prevLocationRef = React10.useRef(
void 0
);
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
"script",
{
suppressHydrationWarning: true,
ref: (el) => {
if (el && (prevLocationRef.current === void 0 || prevLocationRef.current.href !== router.latestLocation.href)) {
router.emit({
type: "onRendered",
...getLocationChangeInfo(router.state)
});
prevLocationRef.current = router.latestLocation;
}
}
},
router.latestLocation.state.__TSR_key
);
}
var MatchInner = React10.memo(function MatchInnerImpl({
matchId
}) {
const router = useRouter();
const { match, key, routeId } = useRouterState({
select: (s) => {
const match2 = s.matches.find((d) => d.id === matchId);
const routeId2 = match2.routeId;
const remountFn = router.routesById[routeId2].options.remountDeps ?? router.options.defaultRemountDeps;
const remountDeps = remountFn?.({
routeId: routeId2,
loaderDeps: match2.loaderDeps,
params: match2._strictParams,
search: match2._strictSearch
});
const key2 = remountDeps ? JSON.stringify(remountDeps) : void 0;
return {
key: key2,
routeId: routeId2,
match: {
id: match2.id,
status: match2.status,
error: match2.error,
_forcePending: match2._forcePending,
_displayPending: match2._displayPending
}
};
},
structuralSharing: true
});
const route = router.routesById[routeId];
const out = React10.useMemo(() => {
const Comp = route.options.component ?? router.options.defaultComponent;
if (Comp) {
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Comp, {}, key);
}
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Outlet, {});
}, [key, route.options.component, router.options.defaultComponent]);
if (match._displayPending) {
throw router.getMatch(match.id)?._nonReactive.displayPendingPromise;
}
if (match._forcePending) {
throw router.getMatch(match.id)?._nonReactive.minPendingPromise;
}
if (match.status === "pending") {
const pendingMinMs = route.options.pendingMinMs ?? router.options.defaultPendingMinMs;
if (pendingMinMs) {
const routerMatch = router.getMatch(match.id);
if (routerMatch && !routerMatch._nonReactive.minPendingPromise) {
if (!router.isServer) {
const minPendingPromise = createControlledPromise();
routerMatch._nonReactive.minPendingPromise = minPendingPromise;
setTimeout(() => {
minPendingPromise.resolve();
routerMatch._nonReactive.minPendingPromise = void 0;
}, pendingMinMs);
}
}
}
throw router.getMatch(match.id)?._nonReactive.loadPromise;
}
if (match.status === "notFound") {
invariant(isNotFound(match.error), "Expected a notFound error");
return renderRouteNotFound(router, route, match.error);
}
if (match.status === "redirected") {
invariant(isRedirect(match.error), "Expected a redirect error");
throw router.getMatch(match.id)?._nonReactive.loadPromise;
}
if (match.status === "error") {
if (router.isServer) {
const RouteErrorComponent = (route.options.errorComponent ?? router.options.defaultErrorComponent) || ErrorComponent;
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
RouteErrorComponent,
{
error: match.error,
reset: void 0,
info: {
componentStack: ""
}
}
);
}
throw match.error;
}
return out;
});
var Outlet = React10.memo(function OutletImpl() {
const router = useRouter();
const matchId = React10.useContext(matchContext);
const routeId = useRouterState({
select: (s) => s.matches.find((d) => d.id === matchId)?.routeId
});
const route = router.routesById[routeId];
const parentGlobalNotFound = useRouterState({
select: (s) => {
const matches = s.matches;
const parentMatch = matches.find((d) => d.id === matchId);
invariant(
parentMatch,
`Could not find parent match for matchId "${matchId}"`
);
return parentMatch.globalNotFound;
}
});
const childMatchId = useRouterState({
select: (s) => {
const matches = s.matches;
const index = matches.findIndex((d) => d.id === matchId);
return matches[index + 1]?.id;
}
});
const pendingElement = router.options.defaultPendingComponent ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(router.options.defaultPendingComponent, {}) : null;
if (parentGlobalNotFound) {
return renderRouteNotFound(router, route, void 0);
}
if (!childMatchId) {
return null;
}
const nextMatch = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Match, { matchId: childMatchId });
if (matchId === rootRouteId) {
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(React10.Suspense, { fallback: pendingElement, children: nextMatch });
}
return nextMatch;
});
// node_modules/@tanstack/react-router/dist/esm/Matches.js
function Matches() {
const router = useRouter();
const rootRoute = router.routesById[rootRouteId];
const PendingComponent = rootRoute.options.pendingComponent ?? router.options.defaultPendingComponent;
const pendingElement = PendingComponent ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(PendingComponent, {}) : null;
const ResolvedSuspense = router.isServer || typeof document !== "undefined" && router.ssr ? SafeFragment : React11.Suspense;
const inner = /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(ResolvedSuspense, { fallback: pendingElement, children: [
!router.isServer && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Transitioner, {}),
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(MatchesInner, {})
] });
return router.options.InnerWrap ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(router.options.InnerWrap, { children: inner }) : inner;
}
function MatchesInner() {
const router = useRouter();
const matchId = useRouterState({
select: (s) => {
return s.matches[0]?.id;
}
});
const resetKey = useRouterState({
select: (s) => s.loadedAt
});
const matchComponent = matchId ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Match, { matchId }) : null;
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(matchContext.Provider, { value: matchId, children: router.options.disableGlobalCatchBoundary ? matchComponent : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
CatchBoundary,
{
getResetKey: () => resetKey,
errorComponent: ErrorComponent,
onCatch: (error) => {
tiny_warning_esm_default(
false,
`The following error wasn't caught by any route! At the very least, consider setting an 'errorComponent' in your RootRoute!`
);
tiny_warning_esm_default(false, error.message || error.toString());
},
children: matchComponent
}
) });
}
function useMatches(opts) {
return useRouterState({
select: (state) => {
const matches = state.matches;
return opts?.select ? opts.select(matches) : matches;
},
structuralSharing: opts?.structuralSharing
});
}
// node_modules/@tanstack/react-router/dist/esm/router.js
var createRouter = (options) => {
return new Router(options);
};
var Router = class extends RouterCore {
constructor(options) {
super(options);
}
};
if (typeof globalThis !== "undefined") {
globalThis.createFileRoute = createFileRoute;
globalThis.createLazyFileRoute = createLazyFileRoute;
} else if (typeof window !== "undefined") {
window.createFileRoute = createFileRoute;
window.createLazyFileRoute = createLazyFileRoute;
}
// node_modules/@tanstack/react-router/dist/esm/RouterProvider.js
var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
function RouterContextProvider({
router,
children,
...rest
}) {
if (Object.keys(rest).length > 0) {
router.update({
...router.options,
...rest,
context: {
...router.options.context,
...rest.context
}
});
}
const routerContext2 = getRouterContext();
const provider = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(routerContext2.Provider, { value: router, children });
if (router.options.Wrap) {
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(router.options.Wrap, { children: provider });
}
return provider;
}
function RouterProvider({ router, ...rest }) {
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(RouterContextProvider, { router, ...rest, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Matches, {}) });
}
// node_modules/@tanstack/react-router/dist/esm/useBlocker.js
var React12 = __toESM(require_react(), 1);
function _resolveBlockerOpts(opts, condition) {
if (opts === void 0) {
return {
shouldBlockFn: () => true,
withResolver: false
};
}
if ("shouldBlockFn" in opts) {
return opts;
}
if (typeof opts === "function") {
const shouldBlock2 = Boolean(condition ?? true);
const _customBlockerFn2 = async () => {
if (shouldBlock2) return await opts();
return false;
};
return {
shouldBlockFn: _customBlockerFn2,
enableBeforeUnload: shouldBlock2,
withResolver: false
};
}
const shouldBlock = Boolean(opts.condition ?? true);
const fn = opts.blockerFn;
const _customBlockerFn = async () => {
if (shouldBlock && fn !== void 0) {
return await fn();
}
return shouldBlock;
};
return {
shouldBlockFn: _customBlockerFn,
enableBeforeUnload: shouldBlock,
withResolver: fn === void 0
};
}
function useBlocker(opts, condition) {
const {
shouldBlockFn,
enableBeforeUnload = true,
disabled = false,
withResolver = false
} = _resolveBlockerOpts(opts, condition);
const router = useRouter();
const { history } = router;
const [resolver, setResolver] = React12.useState({
status: "idle",
current: void 0,
next: void 0,
action: void 0,
proceed: void 0,
reset: void 0
});
React12.useEffect(() => {
const blockerFnComposed = async (blockerFnArgs) => {
function getLocation(location) {
const parsedLocation = router.parseLocation(location);
const matchedRoutes = router.getMatchedRoutes(
parsedLocation.pathname,
void 0
);
if (matchedRoutes.foundRoute === void 0) {
throw new Error(`No route found for location ${location.href}`);
}
return {
routeId: matchedRoutes.foundRoute.id,
fullPath: matchedRoutes.foundRoute.fullPath,
pathname: parsedLocation.pathname,
params: matchedRoutes.routeParams,
search: parsedLocation.search
};
}
const current = getLocation(blockerFnArgs.currentLocation);
const next = getLocation(blockerFnArgs.nextLocation);
const shouldBlock = await shouldBlockFn({
action: blockerFnArgs.action,
current,
next
});
if (!withResolver) {
return shouldBlock;
}
if (!shouldBlock) {
return false;
}
const promise = new Promise((resolve) => {
setResolver({
status: "blocked",
current,
next,
action: blockerFnArgs.action,
proceed: () => resolve(false),
reset: () => resolve(true)
});
});
const canNavigateAsync = await promise;
setResolver({
status: "idle",
current: void 0,
next: void 0,
action: void 0,
proceed: void 0,
reset: void 0
});
return canNavigateAsync;
};
return disabled ? void 0 : history.block({ blockerFn: blockerFnComposed, enableBeforeUnload });
}, [
shouldBlockFn,
enableBeforeUnload,
disabled,
withResolver,
history,
router
]);
return resolver;
}
// node_modules/@tanstack/react-router/dist/esm/useLocation.js
function useLocation(opts) {
return useRouterState({
select: (state) => opts?.select ? opts.select(state.location) : state.location
});
}
// node_modules/@tanstack/react-router/dist/esm/useCanGoBack.js
function useCanGoBack() {
return useRouterState({ select: (s) => s.location.state.__TSR_index !== 0 });
}
// packages/route/build-module/lock-unlock.mjs
var import_private_apis = __toESM(require_private_apis(), 1);
var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
"I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
"@wordpress/route"
);
// packages/route/build-module/private-apis.mjs
var privateApis = {};
lock(privateApis, {
// Router creation and setup
createBrowserHistory,
createLazyRoute,
createMemoryHistory,
createRouter,
createRootRoute,
createRoute,
Outlet,
RouterProvider,
// Internal routing utilities
redirect,
createLink,
useCanGoBack,
useLoaderData,
useLocation,
useMatches,
useRouter,
useRouterState,
useBlocker,
// History utilities
parseHref
});
// packages/route/build-module/index.mjs
function useInvalidate() {
const router = useRouter();
return () => router.invalidate();
}
export {
Link,
notFound,
privateApis,
redirect,
useInvalidate,
useLinkProps,
useNavigate,
useParams,
useSearch
};
/*! Bundled license information:
use-sync-external-store/cjs/use-sync-external-store-shim.development.js:
(**
* @license React
* use-sync-external-store-shim.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.
*)
use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js:
(**
* @license React
* use-sync-external-store-shim/with-selector.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.
*)
*/