| 1 | "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 | var _chunkYMKMFAYZjs = require('./chunk-YMKMFAYZ.js');
|
| 55 |
|
| 56 |
|
| 57 | var defaultMethod = "get";
|
| 58 | var defaultEncType = "application/x-www-form-urlencoded";
|
| 59 | function isHtmlElement(object) {
|
| 60 | return typeof HTMLElement !== "undefined" && object instanceof HTMLElement;
|
| 61 | }
|
| 62 | function isButtonElement(object) {
|
| 63 | return isHtmlElement(object) && object.tagName.toLowerCase() === "button";
|
| 64 | }
|
| 65 | function isFormElement(object) {
|
| 66 | return isHtmlElement(object) && object.tagName.toLowerCase() === "form";
|
| 67 | }
|
| 68 | function isInputElement(object) {
|
| 69 | return isHtmlElement(object) && object.tagName.toLowerCase() === "input";
|
| 70 | }
|
| 71 | function isModifiedEvent(event) {
|
| 72 | return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
|
| 73 | }
|
| 74 | function shouldProcessLinkClick(event, target) {
|
| 75 | return event.button === 0 &&
|
| 76 | (!target || target === "_self") &&
|
| 77 | !isModifiedEvent(event);
|
| 78 | }
|
| 79 | function createSearchParams(init = "") {
|
| 80 | return new URLSearchParams(
|
| 81 | typeof init === "string" || Array.isArray(init) || init instanceof URLSearchParams ? init : Object.keys(init).reduce((memo, key) => {
|
| 82 | let value = init[key];
|
| 83 | return memo.concat(
|
| 84 | Array.isArray(value) ? value.map((v) => [key, v]) : [[key, value]]
|
| 85 | );
|
| 86 | }, [])
|
| 87 | );
|
| 88 | }
|
| 89 | function getSearchParamsForLocation(locationSearch, defaultSearchParams) {
|
| 90 | let searchParams = createSearchParams(locationSearch);
|
| 91 | if (defaultSearchParams) {
|
| 92 | defaultSearchParams.forEach((_, key) => {
|
| 93 | if (!searchParams.has(key)) {
|
| 94 | defaultSearchParams.getAll(key).forEach((value) => {
|
| 95 | searchParams.append(key, value);
|
| 96 | });
|
| 97 | }
|
| 98 | });
|
| 99 | }
|
| 100 | return searchParams;
|
| 101 | }
|
| 102 | var _formDataSupportsSubmitter = null;
|
| 103 | function isFormDataSubmitterSupported() {
|
| 104 | if (_formDataSupportsSubmitter === null) {
|
| 105 | try {
|
| 106 | new FormData(
|
| 107 | document.createElement("form"),
|
| 108 |
|
| 109 | 0
|
| 110 | );
|
| 111 | _formDataSupportsSubmitter = false;
|
| 112 | } catch (e) {
|
| 113 | _formDataSupportsSubmitter = true;
|
| 114 | }
|
| 115 | }
|
| 116 | return _formDataSupportsSubmitter;
|
| 117 | }
|
| 118 | var supportedFormEncTypes = new Set([
|
| 119 | "application/x-www-form-urlencoded",
|
| 120 | "multipart/form-data",
|
| 121 | "text/plain"
|
| 122 | ]);
|
| 123 | function getFormEncType(encType) {
|
| 124 | if (encType != null && !supportedFormEncTypes.has(encType)) {
|
| 125 | _chunkYMKMFAYZjs.warning.call(void 0,
|
| 126 | false,
|
| 127 | `"${encType}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${defaultEncType}"`
|
| 128 | );
|
| 129 | return null;
|
| 130 | }
|
| 131 | return encType;
|
| 132 | }
|
| 133 | function getFormSubmissionInfo(target, basename) {
|
| 134 | let method;
|
| 135 | let action;
|
| 136 | let encType;
|
| 137 | let formData;
|
| 138 | let body;
|
| 139 | if (isFormElement(target)) {
|
| 140 | let attr = target.getAttribute("action");
|
| 141 | action = attr ? _chunkYMKMFAYZjs.stripBasename.call(void 0, attr, basename) : null;
|
| 142 | method = target.getAttribute("method") || defaultMethod;
|
| 143 | encType = getFormEncType(target.getAttribute("enctype")) || defaultEncType;
|
| 144 | formData = new FormData(target);
|
| 145 | } else if (isButtonElement(target) || isInputElement(target) && (target.type === "submit" || target.type === "image")) {
|
| 146 | let form = target.form;
|
| 147 | if (form == null) {
|
| 148 | throw new Error(
|
| 149 | `Cannot submit a <button> or <input type="submit"> without a <form>`
|
| 150 | );
|
| 151 | }
|
| 152 | let attr = target.getAttribute("formaction") || form.getAttribute("action");
|
| 153 | action = attr ? _chunkYMKMFAYZjs.stripBasename.call(void 0, attr, basename) : null;
|
| 154 | method = target.getAttribute("formmethod") || form.getAttribute("method") || defaultMethod;
|
| 155 | encType = getFormEncType(target.getAttribute("formenctype")) || getFormEncType(form.getAttribute("enctype")) || defaultEncType;
|
| 156 | formData = new FormData(form, target);
|
| 157 | if (!isFormDataSubmitterSupported()) {
|
| 158 | let { name, type, value } = target;
|
| 159 | if (type === "image") {
|
| 160 | let prefix = name ? `${name}.` : "";
|
| 161 | formData.append(`${prefix}x`, "0");
|
| 162 | formData.append(`${prefix}y`, "0");
|
| 163 | } else if (name) {
|
| 164 | formData.append(name, value);
|
| 165 | }
|
| 166 | }
|
| 167 | } else if (isHtmlElement(target)) {
|
| 168 | throw new Error(
|
| 169 | `Cannot submit element that is not <form>, <button>, or <input type="submit|image">`
|
| 170 | );
|
| 171 | } else {
|
| 172 | method = defaultMethod;
|
| 173 | action = null;
|
| 174 | encType = defaultEncType;
|
| 175 | body = target;
|
| 176 | }
|
| 177 | if (formData && encType === "text/plain") {
|
| 178 | body = formData;
|
| 179 | formData = void 0;
|
| 180 | }
|
| 181 | return { action, method: method.toLowerCase(), encType, formData, body };
|
| 182 | }
|
| 183 |
|
| 184 |
|
| 185 | var _react = require('react'); var React = _interopRequireWildcard(_react); var React2 = _interopRequireWildcard(_react);
|
| 186 | var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
|
| 187 | try {
|
| 188 | if (isBrowser) {
|
| 189 | window.__reactRouterVersion =
|
| 190 | "7.14.1";
|
| 191 | }
|
| 192 | } catch (e) {
|
| 193 | }
|
| 194 | function createBrowserRouter(routes, opts) {
|
| 195 | return _chunkYMKMFAYZjs.createRouter.call(void 0, {
|
| 196 | basename: _optionalChain([opts, 'optionalAccess', _2 => _2.basename]),
|
| 197 | getContext: _optionalChain([opts, 'optionalAccess', _3 => _3.getContext]),
|
| 198 | future: _optionalChain([opts, 'optionalAccess', _4 => _4.future]),
|
| 199 | history: _chunkYMKMFAYZjs.createBrowserHistory.call(void 0, { window: _optionalChain([opts, 'optionalAccess', _5 => _5.window]) }),
|
| 200 | hydrationData: _optionalChain([opts, 'optionalAccess', _6 => _6.hydrationData]) || parseHydrationData(),
|
| 201 | routes,
|
| 202 | mapRouteProperties: _chunkYMKMFAYZjs.mapRouteProperties,
|
| 203 | hydrationRouteProperties: _chunkYMKMFAYZjs.hydrationRouteProperties,
|
| 204 | dataStrategy: _optionalChain([opts, 'optionalAccess', _7 => _7.dataStrategy]),
|
| 205 | patchRoutesOnNavigation: _optionalChain([opts, 'optionalAccess', _8 => _8.patchRoutesOnNavigation]),
|
| 206 | window: _optionalChain([opts, 'optionalAccess', _9 => _9.window]),
|
| 207 | unstable_instrumentations: _optionalChain([opts, 'optionalAccess', _10 => _10.unstable_instrumentations])
|
| 208 | }).initialize();
|
| 209 | }
|
| 210 | function createHashRouter(routes, opts) {
|
| 211 | return _chunkYMKMFAYZjs.createRouter.call(void 0, {
|
| 212 | basename: _optionalChain([opts, 'optionalAccess', _11 => _11.basename]),
|
| 213 | getContext: _optionalChain([opts, 'optionalAccess', _12 => _12.getContext]),
|
| 214 | future: _optionalChain([opts, 'optionalAccess', _13 => _13.future]),
|
| 215 | history: _chunkYMKMFAYZjs.createHashHistory.call(void 0, { window: _optionalChain([opts, 'optionalAccess', _14 => _14.window]) }),
|
| 216 | hydrationData: _optionalChain([opts, 'optionalAccess', _15 => _15.hydrationData]) || parseHydrationData(),
|
| 217 | routes,
|
| 218 | mapRouteProperties: _chunkYMKMFAYZjs.mapRouteProperties,
|
| 219 | hydrationRouteProperties: _chunkYMKMFAYZjs.hydrationRouteProperties,
|
| 220 | dataStrategy: _optionalChain([opts, 'optionalAccess', _16 => _16.dataStrategy]),
|
| 221 | patchRoutesOnNavigation: _optionalChain([opts, 'optionalAccess', _17 => _17.patchRoutesOnNavigation]),
|
| 222 | window: _optionalChain([opts, 'optionalAccess', _18 => _18.window]),
|
| 223 | unstable_instrumentations: _optionalChain([opts, 'optionalAccess', _19 => _19.unstable_instrumentations])
|
| 224 | }).initialize();
|
| 225 | }
|
| 226 | function parseHydrationData() {
|
| 227 | let state = _optionalChain([window, 'optionalAccess', _20 => _20.__staticRouterHydrationData]);
|
| 228 | if (state && state.errors) {
|
| 229 | state = {
|
| 230 | ...state,
|
| 231 | errors: deserializeErrors(state.errors)
|
| 232 | };
|
| 233 | }
|
| 234 | return state;
|
| 235 | }
|
| 236 | function deserializeErrors(errors) {
|
| 237 | if (!errors) return null;
|
| 238 | let entries = Object.entries(errors);
|
| 239 | let serialized = {};
|
| 240 | for (let [key, val] of entries) {
|
| 241 | if (val && val.__type === "RouteErrorResponse") {
|
| 242 | serialized[key] = new (0, _chunkYMKMFAYZjs.ErrorResponseImpl)(
|
| 243 | val.status,
|
| 244 | val.statusText,
|
| 245 | val.data,
|
| 246 | val.internal === true
|
| 247 | );
|
| 248 | } else if (val && val.__type === "Error") {
|
| 249 | if (val.__subType) {
|
| 250 | let ErrorConstructor = window[val.__subType];
|
| 251 | if (typeof ErrorConstructor === "function") {
|
| 252 | try {
|
| 253 | let error = new ErrorConstructor(val.message);
|
| 254 | error.stack = "";
|
| 255 | serialized[key] = error;
|
| 256 | } catch (e) {
|
| 257 | }
|
| 258 | }
|
| 259 | }
|
| 260 | if (serialized[key] == null) {
|
| 261 | let error = new Error(val.message);
|
| 262 | error.stack = "";
|
| 263 | serialized[key] = error;
|
| 264 | }
|
| 265 | } else {
|
| 266 | serialized[key] = val;
|
| 267 | }
|
| 268 | }
|
| 269 | return serialized;
|
| 270 | }
|
| 271 | function BrowserRouter({
|
| 272 | basename,
|
| 273 | children,
|
| 274 | unstable_useTransitions,
|
| 275 | window: window2
|
| 276 | }) {
|
| 277 | let historyRef = React.useRef();
|
| 278 | if (historyRef.current == null) {
|
| 279 | historyRef.current = _chunkYMKMFAYZjs.createBrowserHistory.call(void 0, { window: window2, v5Compat: true });
|
| 280 | }
|
| 281 | let history = historyRef.current;
|
| 282 | let [state, setStateImpl] = React.useState({
|
| 283 | action: history.action,
|
| 284 | location: history.location
|
| 285 | });
|
| 286 | let setState = React.useCallback(
|
| 287 | (newState) => {
|
| 288 | if (unstable_useTransitions === false) {
|
| 289 | setStateImpl(newState);
|
| 290 | } else {
|
| 291 | React.startTransition(() => setStateImpl(newState));
|
| 292 | }
|
| 293 | },
|
| 294 | [unstable_useTransitions]
|
| 295 | );
|
| 296 | React.useLayoutEffect(() => history.listen(setState), [history, setState]);
|
| 297 | return React.createElement(
|
| 298 | _chunkYMKMFAYZjs.Router,
|
| 299 | {
|
| 300 | basename,
|
| 301 | children,
|
| 302 | location: state.location,
|
| 303 | navigationType: state.action,
|
| 304 | navigator: history,
|
| 305 | unstable_useTransitions
|
| 306 | }
|
| 307 | );
|
| 308 | }
|
| 309 | function HashRouter({
|
| 310 | basename,
|
| 311 | children,
|
| 312 | unstable_useTransitions,
|
| 313 | window: window2
|
| 314 | }) {
|
| 315 | let historyRef = React.useRef();
|
| 316 | if (historyRef.current == null) {
|
| 317 | historyRef.current = _chunkYMKMFAYZjs.createHashHistory.call(void 0, { window: window2, v5Compat: true });
|
| 318 | }
|
| 319 | let history = historyRef.current;
|
| 320 | let [state, setStateImpl] = React.useState({
|
| 321 | action: history.action,
|
| 322 | location: history.location
|
| 323 | });
|
| 324 | let setState = React.useCallback(
|
| 325 | (newState) => {
|
| 326 | if (unstable_useTransitions === false) {
|
| 327 | setStateImpl(newState);
|
| 328 | } else {
|
| 329 | React.startTransition(() => setStateImpl(newState));
|
| 330 | }
|
| 331 | },
|
| 332 | [unstable_useTransitions]
|
| 333 | );
|
| 334 | React.useLayoutEffect(() => history.listen(setState), [history, setState]);
|
| 335 | return React.createElement(
|
| 336 | _chunkYMKMFAYZjs.Router,
|
| 337 | {
|
| 338 | basename,
|
| 339 | children,
|
| 340 | location: state.location,
|
| 341 | navigationType: state.action,
|
| 342 | navigator: history,
|
| 343 | unstable_useTransitions
|
| 344 | }
|
| 345 | );
|
| 346 | }
|
| 347 | function HistoryRouter({
|
| 348 | basename,
|
| 349 | children,
|
| 350 | history,
|
| 351 | unstable_useTransitions
|
| 352 | }) {
|
| 353 | let [state, setStateImpl] = React.useState({
|
| 354 | action: history.action,
|
| 355 | location: history.location
|
| 356 | });
|
| 357 | let setState = React.useCallback(
|
| 358 | (newState) => {
|
| 359 | if (unstable_useTransitions === false) {
|
| 360 | setStateImpl(newState);
|
| 361 | } else {
|
| 362 | React.startTransition(() => setStateImpl(newState));
|
| 363 | }
|
| 364 | },
|
| 365 | [unstable_useTransitions]
|
| 366 | );
|
| 367 | React.useLayoutEffect(() => history.listen(setState), [history, setState]);
|
| 368 | return React.createElement(
|
| 369 | _chunkYMKMFAYZjs.Router,
|
| 370 | {
|
| 371 | basename,
|
| 372 | children,
|
| 373 | location: state.location,
|
| 374 | navigationType: state.action,
|
| 375 | navigator: history,
|
| 376 | unstable_useTransitions
|
| 377 | }
|
| 378 | );
|
| 379 | }
|
| 380 | HistoryRouter.displayName = "unstable_HistoryRouter";
|
| 381 | var ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
|
| 382 | var Link = React.forwardRef(
|
| 383 | function LinkWithRef({
|
| 384 | onClick,
|
| 385 | discover = "render",
|
| 386 | prefetch = "none",
|
| 387 | relative,
|
| 388 | reloadDocument,
|
| 389 | replace,
|
| 390 | unstable_mask,
|
| 391 | state,
|
| 392 | target,
|
| 393 | to,
|
| 394 | preventScrollReset,
|
| 395 | viewTransition,
|
| 396 | unstable_defaultShouldRevalidate,
|
| 397 | ...rest
|
| 398 | }, forwardedRef) {
|
| 399 | let { basename, navigator, unstable_useTransitions } = React.useContext(_chunkYMKMFAYZjs.NavigationContext);
|
| 400 | let isAbsolute = typeof to === "string" && ABSOLUTE_URL_REGEX.test(to);
|
| 401 | let parsed = _chunkYMKMFAYZjs.parseToInfo.call(void 0, to, basename);
|
| 402 | to = parsed.to;
|
| 403 | let href = _chunkYMKMFAYZjs.useHref.call(void 0, to, { relative });
|
| 404 | let location = _chunkYMKMFAYZjs.useLocation.call(void 0, );
|
| 405 | let maskedHref = null;
|
| 406 | if (unstable_mask) {
|
| 407 | let resolved = _chunkYMKMFAYZjs.resolveTo.call(void 0,
|
| 408 | unstable_mask,
|
| 409 | [],
|
| 410 | location.unstable_mask ? location.unstable_mask.pathname : "/",
|
| 411 | true
|
| 412 | );
|
| 413 | if (basename !== "/") {
|
| 414 | resolved.pathname = resolved.pathname === "/" ? basename : _chunkYMKMFAYZjs.joinPaths.call(void 0, [basename, resolved.pathname]);
|
| 415 | }
|
| 416 | maskedHref = navigator.createHref(resolved);
|
| 417 | }
|
| 418 | let [shouldPrefetch, prefetchRef, prefetchHandlers] = _chunkYMKMFAYZjs.usePrefetchBehavior.call(void 0,
|
| 419 | prefetch,
|
| 420 | rest
|
| 421 | );
|
| 422 | let internalOnClick = useLinkClickHandler(to, {
|
| 423 | replace,
|
| 424 | unstable_mask,
|
| 425 | state,
|
| 426 | target,
|
| 427 | preventScrollReset,
|
| 428 | relative,
|
| 429 | viewTransition,
|
| 430 | unstable_defaultShouldRevalidate,
|
| 431 | unstable_useTransitions
|
| 432 | });
|
| 433 | function handleClick(event) {
|
| 434 | if (onClick) onClick(event);
|
| 435 | if (!event.defaultPrevented) {
|
| 436 | internalOnClick(event);
|
| 437 | }
|
| 438 | }
|
| 439 | let isSpaLink = !(parsed.isExternal || reloadDocument);
|
| 440 | let link = (
|
| 441 |
|
| 442 | React.createElement(
|
| 443 | "a",
|
| 444 | {
|
| 445 | ...rest,
|
| 446 | ...prefetchHandlers,
|
| 447 | href: (isSpaLink ? maskedHref : void 0) || parsed.absoluteURL || href,
|
| 448 | onClick: isSpaLink ? handleClick : onClick,
|
| 449 | ref: _chunkYMKMFAYZjs.mergeRefs.call(void 0, forwardedRef, prefetchRef),
|
| 450 | target,
|
| 451 | "data-discover": !isAbsolute && discover === "render" ? "true" : void 0
|
| 452 | }
|
| 453 | )
|
| 454 | );
|
| 455 | return shouldPrefetch && !isAbsolute ? React.createElement(React.Fragment, null, link, React.createElement(_chunkYMKMFAYZjs.PrefetchPageLinks, { page: href })) : link;
|
| 456 | }
|
| 457 | );
|
| 458 | Link.displayName = "Link";
|
| 459 | var NavLink = React.forwardRef(
|
| 460 | function NavLinkWithRef({
|
| 461 | "aria-current": ariaCurrentProp = "page",
|
| 462 | caseSensitive = false,
|
| 463 | className: classNameProp = "",
|
| 464 | end = false,
|
| 465 | style: styleProp,
|
| 466 | to,
|
| 467 | viewTransition,
|
| 468 | children,
|
| 469 | ...rest
|
| 470 | }, ref) {
|
| 471 | let path = _chunkYMKMFAYZjs.useResolvedPath.call(void 0, to, { relative: rest.relative });
|
| 472 | let location = _chunkYMKMFAYZjs.useLocation.call(void 0, );
|
| 473 | let routerState = React.useContext(_chunkYMKMFAYZjs.DataRouterStateContext);
|
| 474 | let { navigator, basename } = React.useContext(_chunkYMKMFAYZjs.NavigationContext);
|
| 475 | let isTransitioning = routerState != null &&
|
| 476 |
|
| 477 | useViewTransitionState(path) && viewTransition === true;
|
| 478 | let toPathname = navigator.encodeLocation ? navigator.encodeLocation(path).pathname : path.pathname;
|
| 479 | let locationPathname = location.pathname;
|
| 480 | let nextLocationPathname = routerState && routerState.navigation && routerState.navigation.location ? routerState.navigation.location.pathname : null;
|
| 481 | if (!caseSensitive) {
|
| 482 | locationPathname = locationPathname.toLowerCase();
|
| 483 | nextLocationPathname = nextLocationPathname ? nextLocationPathname.toLowerCase() : null;
|
| 484 | toPathname = toPathname.toLowerCase();
|
| 485 | }
|
| 486 | if (nextLocationPathname && basename) {
|
| 487 | nextLocationPathname = _chunkYMKMFAYZjs.stripBasename.call(void 0, nextLocationPathname, basename) || nextLocationPathname;
|
| 488 | }
|
| 489 | const endSlashPosition = toPathname !== "/" && toPathname.endsWith("/") ? toPathname.length - 1 : toPathname.length;
|
| 490 | let isActive = locationPathname === toPathname || !end && locationPathname.startsWith(toPathname) && locationPathname.charAt(endSlashPosition) === "/";
|
| 491 | let isPending = nextLocationPathname != null && (nextLocationPathname === toPathname || !end && nextLocationPathname.startsWith(toPathname) && nextLocationPathname.charAt(toPathname.length) === "/");
|
| 492 | let renderProps = {
|
| 493 | isActive,
|
| 494 | isPending,
|
| 495 | isTransitioning
|
| 496 | };
|
| 497 | let ariaCurrent = isActive ? ariaCurrentProp : void 0;
|
| 498 | let className;
|
| 499 | if (typeof classNameProp === "function") {
|
| 500 | className = classNameProp(renderProps);
|
| 501 | } else {
|
| 502 | className = [
|
| 503 | classNameProp,
|
| 504 | isActive ? "active" : null,
|
| 505 | isPending ? "pending" : null,
|
| 506 | isTransitioning ? "transitioning" : null
|
| 507 | ].filter(Boolean).join(" ");
|
| 508 | }
|
| 509 | let style = typeof styleProp === "function" ? styleProp(renderProps) : styleProp;
|
| 510 | return React.createElement(
|
| 511 | Link,
|
| 512 | {
|
| 513 | ...rest,
|
| 514 | "aria-current": ariaCurrent,
|
| 515 | className,
|
| 516 | ref,
|
| 517 | style,
|
| 518 | to,
|
| 519 | viewTransition
|
| 520 | },
|
| 521 | typeof children === "function" ? children(renderProps) : children
|
| 522 | );
|
| 523 | }
|
| 524 | );
|
| 525 | NavLink.displayName = "NavLink";
|
| 526 | var Form = React.forwardRef(
|
| 527 | ({
|
| 528 | discover = "render",
|
| 529 | fetcherKey,
|
| 530 | navigate,
|
| 531 | reloadDocument,
|
| 532 | replace,
|
| 533 | state,
|
| 534 | method = defaultMethod,
|
| 535 | action,
|
| 536 | onSubmit,
|
| 537 | relative,
|
| 538 | preventScrollReset,
|
| 539 | viewTransition,
|
| 540 | unstable_defaultShouldRevalidate,
|
| 541 | ...props
|
| 542 | }, forwardedRef) => {
|
| 543 | let { unstable_useTransitions } = React.useContext(_chunkYMKMFAYZjs.NavigationContext);
|
| 544 | let submit = useSubmit();
|
| 545 | let formAction = useFormAction(action, { relative });
|
| 546 | let formMethod = method.toLowerCase() === "get" ? "get" : "post";
|
| 547 | let isAbsolute = typeof action === "string" && ABSOLUTE_URL_REGEX.test(action);
|
| 548 | let submitHandler = (event) => {
|
| 549 | onSubmit && onSubmit(event);
|
| 550 | if (event.defaultPrevented) return;
|
| 551 | event.preventDefault();
|
| 552 | let submitter = event.nativeEvent.submitter;
|
| 553 | let submitMethod = _optionalChain([submitter, 'optionalAccess', _21 => _21.getAttribute, 'call', _22 => _22("formmethod")]) || method;
|
| 554 | let doSubmit = () => submit(submitter || event.currentTarget, {
|
| 555 | fetcherKey,
|
| 556 | method: submitMethod,
|
| 557 | navigate,
|
| 558 | replace,
|
| 559 | state,
|
| 560 | relative,
|
| 561 | preventScrollReset,
|
| 562 | viewTransition,
|
| 563 | unstable_defaultShouldRevalidate
|
| 564 | });
|
| 565 | if (unstable_useTransitions && navigate !== false) {
|
| 566 | React.startTransition(() => doSubmit());
|
| 567 | } else {
|
| 568 | doSubmit();
|
| 569 | }
|
| 570 | };
|
| 571 | return React.createElement(
|
| 572 | "form",
|
| 573 | {
|
| 574 | ref: forwardedRef,
|
| 575 | method: formMethod,
|
| 576 | action: formAction,
|
| 577 | onSubmit: reloadDocument ? onSubmit : submitHandler,
|
| 578 | ...props,
|
| 579 | "data-discover": !isAbsolute && discover === "render" ? "true" : void 0
|
| 580 | }
|
| 581 | );
|
| 582 | }
|
| 583 | );
|
| 584 | Form.displayName = "Form";
|
| 585 | function ScrollRestoration({
|
| 586 | getKey,
|
| 587 | storageKey,
|
| 588 | ...props
|
| 589 | }) {
|
| 590 | let remixContext = React.useContext(_chunkYMKMFAYZjs.FrameworkContext);
|
| 591 | let { basename } = React.useContext(_chunkYMKMFAYZjs.NavigationContext);
|
| 592 | let location = _chunkYMKMFAYZjs.useLocation.call(void 0, );
|
| 593 | let matches = _chunkYMKMFAYZjs.useMatches.call(void 0, );
|
| 594 | useScrollRestoration({ getKey, storageKey });
|
| 595 | let ssrKey = React.useMemo(
|
| 596 | () => {
|
| 597 | if (!remixContext || !getKey) return null;
|
| 598 | let userKey = getScrollRestorationKey(
|
| 599 | location,
|
| 600 | matches,
|
| 601 | basename,
|
| 602 | getKey
|
| 603 | );
|
| 604 | return userKey !== location.key ? userKey : null;
|
| 605 | },
|
| 606 |
|
| 607 |
|
| 608 | []
|
| 609 | );
|
| 610 | if (!remixContext || remixContext.isSpaMode) {
|
| 611 | return null;
|
| 612 | }
|
| 613 | let restoreScroll = ((storageKey2, restoreKey) => {
|
| 614 | if (!window.history.state || !window.history.state.key) {
|
| 615 | let key = Math.random().toString(32).slice(2);
|
| 616 | window.history.replaceState({ key }, "");
|
| 617 | }
|
| 618 | try {
|
| 619 | let positions = JSON.parse(sessionStorage.getItem(storageKey2) || "{}");
|
| 620 | let storedY = positions[restoreKey || window.history.state.key];
|
| 621 | if (typeof storedY === "number") {
|
| 622 | window.scrollTo(0, storedY);
|
| 623 | }
|
| 624 | } catch (error) {
|
| 625 | console.error(error);
|
| 626 | sessionStorage.removeItem(storageKey2);
|
| 627 | }
|
| 628 | }).toString();
|
| 629 | return React.createElement(
|
| 630 | "script",
|
| 631 | {
|
| 632 | ...props,
|
| 633 | suppressHydrationWarning: true,
|
| 634 | dangerouslySetInnerHTML: {
|
| 635 | __html: `(${restoreScroll})(${_chunkYMKMFAYZjs.escapeHtml.call(void 0,
|
| 636 | JSON.stringify(storageKey || SCROLL_RESTORATION_STORAGE_KEY)
|
| 637 | )}, ${_chunkYMKMFAYZjs.escapeHtml.call(void 0, JSON.stringify(ssrKey))})`
|
| 638 | }
|
| 639 | }
|
| 640 | );
|
| 641 | }
|
| 642 | ScrollRestoration.displayName = "ScrollRestoration";
|
| 643 | function getDataRouterConsoleError(hookName) {
|
| 644 | return `${hookName} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`;
|
| 645 | }
|
| 646 | function useDataRouterContext(hookName) {
|
| 647 | let ctx = React.useContext(_chunkYMKMFAYZjs.DataRouterContext);
|
| 648 | _chunkYMKMFAYZjs.invariant.call(void 0, ctx, getDataRouterConsoleError(hookName));
|
| 649 | return ctx;
|
| 650 | }
|
| 651 | function useDataRouterState(hookName) {
|
| 652 | let state = React.useContext(_chunkYMKMFAYZjs.DataRouterStateContext);
|
| 653 | _chunkYMKMFAYZjs.invariant.call(void 0, state, getDataRouterConsoleError(hookName));
|
| 654 | return state;
|
| 655 | }
|
| 656 | function useLinkClickHandler(to, {
|
| 657 | target,
|
| 658 | replace: replaceProp,
|
| 659 | unstable_mask,
|
| 660 | state,
|
| 661 | preventScrollReset,
|
| 662 | relative,
|
| 663 | viewTransition,
|
| 664 | unstable_defaultShouldRevalidate,
|
| 665 | unstable_useTransitions
|
| 666 | } = {}) {
|
| 667 | let navigate = _chunkYMKMFAYZjs.useNavigate.call(void 0, );
|
| 668 | let location = _chunkYMKMFAYZjs.useLocation.call(void 0, );
|
| 669 | let path = _chunkYMKMFAYZjs.useResolvedPath.call(void 0, to, { relative });
|
| 670 | return React.useCallback(
|
| 671 | (event) => {
|
| 672 | if (shouldProcessLinkClick(event, target)) {
|
| 673 | event.preventDefault();
|
| 674 | let replace = replaceProp !== void 0 ? replaceProp : _chunkYMKMFAYZjs.createPath.call(void 0, location) === _chunkYMKMFAYZjs.createPath.call(void 0, path);
|
| 675 | let doNavigate = () => navigate(to, {
|
| 676 | replace,
|
| 677 | unstable_mask,
|
| 678 | state,
|
| 679 | preventScrollReset,
|
| 680 | relative,
|
| 681 | viewTransition,
|
| 682 | unstable_defaultShouldRevalidate
|
| 683 | });
|
| 684 | if (unstable_useTransitions) {
|
| 685 | React.startTransition(() => doNavigate());
|
| 686 | } else {
|
| 687 | doNavigate();
|
| 688 | }
|
| 689 | }
|
| 690 | },
|
| 691 | [
|
| 692 | location,
|
| 693 | navigate,
|
| 694 | path,
|
| 695 | replaceProp,
|
| 696 | unstable_mask,
|
| 697 | state,
|
| 698 | target,
|
| 699 | to,
|
| 700 | preventScrollReset,
|
| 701 | relative,
|
| 702 | viewTransition,
|
| 703 | unstable_defaultShouldRevalidate,
|
| 704 | unstable_useTransitions
|
| 705 | ]
|
| 706 | );
|
| 707 | }
|
| 708 | function useSearchParams(defaultInit) {
|
| 709 | _chunkYMKMFAYZjs.warning.call(void 0,
|
| 710 | typeof URLSearchParams !== "undefined",
|
| 711 | `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.`
|
| 712 | );
|
| 713 | let defaultSearchParamsRef = React.useRef(createSearchParams(defaultInit));
|
| 714 | let hasSetSearchParamsRef = React.useRef(false);
|
| 715 | let location = _chunkYMKMFAYZjs.useLocation.call(void 0, );
|
| 716 | let searchParams = React.useMemo(
|
| 717 | () => (
|
| 718 |
|
| 719 |
|
| 720 |
|
| 721 | getSearchParamsForLocation(
|
| 722 | location.search,
|
| 723 | hasSetSearchParamsRef.current ? null : defaultSearchParamsRef.current
|
| 724 | )
|
| 725 | ),
|
| 726 | [location.search]
|
| 727 | );
|
| 728 | let navigate = _chunkYMKMFAYZjs.useNavigate.call(void 0, );
|
| 729 | let setSearchParams = React.useCallback(
|
| 730 | (nextInit, navigateOptions) => {
|
| 731 | const newSearchParams = createSearchParams(
|
| 732 | typeof nextInit === "function" ? nextInit(new URLSearchParams(searchParams)) : nextInit
|
| 733 | );
|
| 734 | hasSetSearchParamsRef.current = true;
|
| 735 | navigate("?" + newSearchParams, navigateOptions);
|
| 736 | },
|
| 737 | [navigate, searchParams]
|
| 738 | );
|
| 739 | return [searchParams, setSearchParams];
|
| 740 | }
|
| 741 | var fetcherId = 0;
|
| 742 | var getUniqueFetcherId = () => `__${String(++fetcherId)}__`;
|
| 743 | function useSubmit() {
|
| 744 | let { router } = useDataRouterContext("useSubmit" );
|
| 745 | let { basename } = React.useContext(_chunkYMKMFAYZjs.NavigationContext);
|
| 746 | let currentRouteId = _chunkYMKMFAYZjs.useRouteId.call(void 0, );
|
| 747 | let routerFetch = router.fetch;
|
| 748 | let routerNavigate = router.navigate;
|
| 749 | return React.useCallback(
|
| 750 | async (target, options = {}) => {
|
| 751 | let { action, method, encType, formData, body } = getFormSubmissionInfo(
|
| 752 | target,
|
| 753 | basename
|
| 754 | );
|
| 755 | if (options.navigate === false) {
|
| 756 | let key = options.fetcherKey || getUniqueFetcherId();
|
| 757 | await routerFetch(key, currentRouteId, options.action || action, {
|
| 758 | unstable_defaultShouldRevalidate: options.unstable_defaultShouldRevalidate,
|
| 759 | preventScrollReset: options.preventScrollReset,
|
| 760 | formData,
|
| 761 | body,
|
| 762 | formMethod: options.method || method,
|
| 763 | formEncType: options.encType || encType,
|
| 764 | flushSync: options.flushSync
|
| 765 | });
|
| 766 | } else {
|
| 767 | await routerNavigate(options.action || action, {
|
| 768 | unstable_defaultShouldRevalidate: options.unstable_defaultShouldRevalidate,
|
| 769 | preventScrollReset: options.preventScrollReset,
|
| 770 | formData,
|
| 771 | body,
|
| 772 | formMethod: options.method || method,
|
| 773 | formEncType: options.encType || encType,
|
| 774 | replace: options.replace,
|
| 775 | state: options.state,
|
| 776 | fromRouteId: currentRouteId,
|
| 777 | flushSync: options.flushSync,
|
| 778 | viewTransition: options.viewTransition
|
| 779 | });
|
| 780 | }
|
| 781 | },
|
| 782 | [routerFetch, routerNavigate, basename, currentRouteId]
|
| 783 | );
|
| 784 | }
|
| 785 | function useFormAction(action, { relative } = {}) {
|
| 786 | let { basename } = React.useContext(_chunkYMKMFAYZjs.NavigationContext);
|
| 787 | let routeContext = React.useContext(_chunkYMKMFAYZjs.RouteContext);
|
| 788 | _chunkYMKMFAYZjs.invariant.call(void 0, routeContext, "useFormAction must be used inside a RouteContext");
|
| 789 | let [match] = routeContext.matches.slice(-1);
|
| 790 | let path = { ..._chunkYMKMFAYZjs.useResolvedPath.call(void 0, action ? action : ".", { relative }) };
|
| 791 | let location = _chunkYMKMFAYZjs.useLocation.call(void 0, );
|
| 792 | if (action == null) {
|
| 793 | path.search = location.search;
|
| 794 | let params = new URLSearchParams(path.search);
|
| 795 | let indexValues = params.getAll("index");
|
| 796 | let hasNakedIndexParam = indexValues.some((v) => v === "");
|
| 797 | if (hasNakedIndexParam) {
|
| 798 | params.delete("index");
|
| 799 | indexValues.filter((v) => v).forEach((v) => params.append("index", v));
|
| 800 | let qs = params.toString();
|
| 801 | path.search = qs ? `?${qs}` : "";
|
| 802 | }
|
| 803 | }
|
| 804 | if ((!action || action === ".") && match.route.index) {
|
| 805 | path.search = path.search ? path.search.replace(/^\?/, "?index&") : "?index";
|
| 806 | }
|
| 807 | if (basename !== "/") {
|
| 808 | path.pathname = path.pathname === "/" ? basename : _chunkYMKMFAYZjs.joinPaths.call(void 0, [basename, path.pathname]);
|
| 809 | }
|
| 810 | return _chunkYMKMFAYZjs.createPath.call(void 0, path);
|
| 811 | }
|
| 812 | function useFetcher({
|
| 813 | key
|
| 814 | } = {}) {
|
| 815 | let { router } = useDataRouterContext("useFetcher" );
|
| 816 | let state = useDataRouterState("useFetcher" );
|
| 817 | let fetcherData = React.useContext(_chunkYMKMFAYZjs.FetchersContext);
|
| 818 | let route = React.useContext(_chunkYMKMFAYZjs.RouteContext);
|
| 819 | let routeId = _optionalChain([route, 'access', _23 => _23.matches, 'access', _24 => _24[route.matches.length - 1], 'optionalAccess', _25 => _25.route, 'access', _26 => _26.id]);
|
| 820 | _chunkYMKMFAYZjs.invariant.call(void 0, fetcherData, `useFetcher must be used inside a FetchersContext`);
|
| 821 | _chunkYMKMFAYZjs.invariant.call(void 0, route, `useFetcher must be used inside a RouteContext`);
|
| 822 | _chunkYMKMFAYZjs.invariant.call(void 0,
|
| 823 | routeId != null,
|
| 824 | `useFetcher can only be used on routes that contain a unique "id"`
|
| 825 | );
|
| 826 | let defaultKey = React.useId();
|
| 827 | let [fetcherKey, setFetcherKey] = React.useState(key || defaultKey);
|
| 828 | if (key && key !== fetcherKey) {
|
| 829 | setFetcherKey(key);
|
| 830 | }
|
| 831 | let { deleteFetcher, getFetcher, resetFetcher, fetch: routerFetch } = router;
|
| 832 | React.useEffect(() => {
|
| 833 | getFetcher(fetcherKey);
|
| 834 | return () => deleteFetcher(fetcherKey);
|
| 835 | }, [deleteFetcher, getFetcher, fetcherKey]);
|
| 836 | let load = React.useCallback(
|
| 837 | async (href, opts) => {
|
| 838 | _chunkYMKMFAYZjs.invariant.call(void 0, routeId, "No routeId available for fetcher.load()");
|
| 839 | await routerFetch(fetcherKey, routeId, href, opts);
|
| 840 | },
|
| 841 | [fetcherKey, routeId, routerFetch]
|
| 842 | );
|
| 843 | let submitImpl = useSubmit();
|
| 844 | let submit = React.useCallback(
|
| 845 | async (target, opts) => {
|
| 846 | await submitImpl(target, {
|
| 847 | ...opts,
|
| 848 | navigate: false,
|
| 849 | fetcherKey
|
| 850 | });
|
| 851 | },
|
| 852 | [fetcherKey, submitImpl]
|
| 853 | );
|
| 854 | let reset = React.useCallback(
|
| 855 | (opts) => resetFetcher(fetcherKey, opts),
|
| 856 | [resetFetcher, fetcherKey]
|
| 857 | );
|
| 858 | let FetcherForm = React.useMemo(() => {
|
| 859 | let FetcherForm2 = React.forwardRef(
|
| 860 | (props, ref) => {
|
| 861 | return React.createElement(Form, { ...props, navigate: false, fetcherKey, ref });
|
| 862 | }
|
| 863 | );
|
| 864 | FetcherForm2.displayName = "fetcher.Form";
|
| 865 | return FetcherForm2;
|
| 866 | }, [fetcherKey]);
|
| 867 | let fetcher = state.fetchers.get(fetcherKey) || _chunkYMKMFAYZjs.IDLE_FETCHER;
|
| 868 | let data = fetcherData.get(fetcherKey);
|
| 869 | let fetcherWithComponents = React.useMemo(
|
| 870 | () => ({
|
| 871 | Form: FetcherForm,
|
| 872 | submit,
|
| 873 | load,
|
| 874 | reset,
|
| 875 | ...fetcher,
|
| 876 | data
|
| 877 | }),
|
| 878 | [FetcherForm, submit, load, reset, fetcher, data]
|
| 879 | );
|
| 880 | return fetcherWithComponents;
|
| 881 | }
|
| 882 | function useFetchers() {
|
| 883 | let state = useDataRouterState("useFetchers" );
|
| 884 | return Array.from(state.fetchers.entries()).map(([key, fetcher]) => ({
|
| 885 | ...fetcher,
|
| 886 | key
|
| 887 | }));
|
| 888 | }
|
| 889 | var SCROLL_RESTORATION_STORAGE_KEY = "react-router-scroll-positions";
|
| 890 | var savedScrollPositions = {};
|
| 891 | function getScrollRestorationKey(location, matches, basename, getKey) {
|
| 892 | let key = null;
|
| 893 | if (getKey) {
|
| 894 | if (basename !== "/") {
|
| 895 | key = getKey(
|
| 896 | {
|
| 897 | ...location,
|
| 898 | pathname: _chunkYMKMFAYZjs.stripBasename.call(void 0, location.pathname, basename) || location.pathname
|
| 899 | },
|
| 900 | matches
|
| 901 | );
|
| 902 | } else {
|
| 903 | key = getKey(location, matches);
|
| 904 | }
|
| 905 | }
|
| 906 | if (key == null) {
|
| 907 | key = location.key;
|
| 908 | }
|
| 909 | return key;
|
| 910 | }
|
| 911 | function useScrollRestoration({
|
| 912 | getKey,
|
| 913 | storageKey
|
| 914 | } = {}) {
|
| 915 | let { router } = useDataRouterContext("useScrollRestoration" );
|
| 916 | let { restoreScrollPosition, preventScrollReset } = useDataRouterState(
|
| 917 | "useScrollRestoration"
|
| 918 | );
|
| 919 | let { basename } = React.useContext(_chunkYMKMFAYZjs.NavigationContext);
|
| 920 | let location = _chunkYMKMFAYZjs.useLocation.call(void 0, );
|
| 921 | let matches = _chunkYMKMFAYZjs.useMatches.call(void 0, );
|
| 922 | let navigation = _chunkYMKMFAYZjs.useNavigation.call(void 0, );
|
| 923 | React.useEffect(() => {
|
| 924 | window.history.scrollRestoration = "manual";
|
| 925 | return () => {
|
| 926 | window.history.scrollRestoration = "auto";
|
| 927 | };
|
| 928 | }, []);
|
| 929 | usePageHide(
|
| 930 | React.useCallback(() => {
|
| 931 | if (navigation.state === "idle") {
|
| 932 | let key = getScrollRestorationKey(location, matches, basename, getKey);
|
| 933 | savedScrollPositions[key] = window.scrollY;
|
| 934 | }
|
| 935 | try {
|
| 936 | sessionStorage.setItem(
|
| 937 | storageKey || SCROLL_RESTORATION_STORAGE_KEY,
|
| 938 | JSON.stringify(savedScrollPositions)
|
| 939 | );
|
| 940 | } catch (error) {
|
| 941 | _chunkYMKMFAYZjs.warning.call(void 0,
|
| 942 | false,
|
| 943 | `Failed to save scroll positions in sessionStorage, <ScrollRestoration /> will not work properly (${error}).`
|
| 944 | );
|
| 945 | }
|
| 946 | window.history.scrollRestoration = "auto";
|
| 947 | }, [navigation.state, getKey, basename, location, matches, storageKey])
|
| 948 | );
|
| 949 | if (typeof document !== "undefined") {
|
| 950 | React.useLayoutEffect(() => {
|
| 951 | try {
|
| 952 | let sessionPositions = sessionStorage.getItem(
|
| 953 | storageKey || SCROLL_RESTORATION_STORAGE_KEY
|
| 954 | );
|
| 955 | if (sessionPositions) {
|
| 956 | savedScrollPositions = JSON.parse(sessionPositions);
|
| 957 | }
|
| 958 | } catch (e) {
|
| 959 | }
|
| 960 | }, [storageKey]);
|
| 961 | React.useLayoutEffect(() => {
|
| 962 | let disableScrollRestoration = _optionalChain([router, 'optionalAccess', _27 => _27.enableScrollRestoration, 'call', _28 => _28(
|
| 963 | savedScrollPositions,
|
| 964 | () => window.scrollY,
|
| 965 | getKey ? (location2, matches2) => getScrollRestorationKey(location2, matches2, basename, getKey) : void 0
|
| 966 | )]);
|
| 967 | return () => disableScrollRestoration && disableScrollRestoration();
|
| 968 | }, [router, basename, getKey]);
|
| 969 | React.useLayoutEffect(() => {
|
| 970 | if (restoreScrollPosition === false) {
|
| 971 | return;
|
| 972 | }
|
| 973 | if (typeof restoreScrollPosition === "number") {
|
| 974 | window.scrollTo(0, restoreScrollPosition);
|
| 975 | return;
|
| 976 | }
|
| 977 | try {
|
| 978 | if (location.hash) {
|
| 979 | let el = document.getElementById(
|
| 980 | decodeURIComponent(location.hash.slice(1))
|
| 981 | );
|
| 982 | if (el) {
|
| 983 | el.scrollIntoView();
|
| 984 | return;
|
| 985 | }
|
| 986 | }
|
| 987 | } catch (e2) {
|
| 988 | _chunkYMKMFAYZjs.warning.call(void 0,
|
| 989 | false,
|
| 990 | `"${location.hash.slice(
|
| 991 | 1
|
| 992 | )}" is not a decodable element ID. The view will not scroll to it.`
|
| 993 | );
|
| 994 | }
|
| 995 | if (preventScrollReset === true) {
|
| 996 | return;
|
| 997 | }
|
| 998 | window.scrollTo(0, 0);
|
| 999 | }, [location, restoreScrollPosition, preventScrollReset]);
|
| 1000 | }
|
| 1001 | }
|
| 1002 | function useBeforeUnload(callback, options) {
|
| 1003 | let { capture } = options || {};
|
| 1004 | React.useEffect(() => {
|
| 1005 | let opts = capture != null ? { capture } : void 0;
|
| 1006 | window.addEventListener("beforeunload", callback, opts);
|
| 1007 | return () => {
|
| 1008 | window.removeEventListener("beforeunload", callback, opts);
|
| 1009 | };
|
| 1010 | }, [callback, capture]);
|
| 1011 | }
|
| 1012 | function usePageHide(callback, options) {
|
| 1013 | let { capture } = options || {};
|
| 1014 | React.useEffect(() => {
|
| 1015 | let opts = capture != null ? { capture } : void 0;
|
| 1016 | window.addEventListener("pagehide", callback, opts);
|
| 1017 | return () => {
|
| 1018 | window.removeEventListener("pagehide", callback, opts);
|
| 1019 | };
|
| 1020 | }, [callback, capture]);
|
| 1021 | }
|
| 1022 | function usePrompt({
|
| 1023 | when,
|
| 1024 | message
|
| 1025 | }) {
|
| 1026 | let blocker = _chunkYMKMFAYZjs.useBlocker.call(void 0, when);
|
| 1027 | React.useEffect(() => {
|
| 1028 | if (blocker.state === "blocked") {
|
| 1029 | let proceed = window.confirm(message);
|
| 1030 | if (proceed) {
|
| 1031 | setTimeout(blocker.proceed, 0);
|
| 1032 | } else {
|
| 1033 | blocker.reset();
|
| 1034 | }
|
| 1035 | }
|
| 1036 | }, [blocker, message]);
|
| 1037 | React.useEffect(() => {
|
| 1038 | if (blocker.state === "blocked" && !when) {
|
| 1039 | blocker.reset();
|
| 1040 | }
|
| 1041 | }, [blocker, when]);
|
| 1042 | }
|
| 1043 | function useViewTransitionState(to, { relative } = {}) {
|
| 1044 | let vtContext = React.useContext(_chunkYMKMFAYZjs.ViewTransitionContext);
|
| 1045 | _chunkYMKMFAYZjs.invariant.call(void 0,
|
| 1046 | vtContext != null,
|
| 1047 | "`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?"
|
| 1048 | );
|
| 1049 | let { basename } = useDataRouterContext(
|
| 1050 | "useViewTransitionState"
|
| 1051 | );
|
| 1052 | let path = _chunkYMKMFAYZjs.useResolvedPath.call(void 0, to, { relative });
|
| 1053 | if (!vtContext.isTransitioning) {
|
| 1054 | return false;
|
| 1055 | }
|
| 1056 | let currentPath = _chunkYMKMFAYZjs.stripBasename.call(void 0, vtContext.currentLocation.pathname, basename) || vtContext.currentLocation.pathname;
|
| 1057 | let nextPath = _chunkYMKMFAYZjs.stripBasename.call(void 0, vtContext.nextLocation.pathname, basename) || vtContext.nextLocation.pathname;
|
| 1058 | return _chunkYMKMFAYZjs.matchPath.call(void 0, path.pathname, nextPath) != null || _chunkYMKMFAYZjs.matchPath.call(void 0, path.pathname, currentPath) != null;
|
| 1059 | }
|
| 1060 |
|
| 1061 |
|
| 1062 |
|
| 1063 | function StaticRouter({
|
| 1064 | basename,
|
| 1065 | children,
|
| 1066 | location: locationProp = "/"
|
| 1067 | }) {
|
| 1068 | if (typeof locationProp === "string") {
|
| 1069 | locationProp = _chunkYMKMFAYZjs.parsePath.call(void 0, locationProp);
|
| 1070 | }
|
| 1071 | let action = "POP" ;
|
| 1072 | let location = {
|
| 1073 | pathname: locationProp.pathname || "/",
|
| 1074 | search: locationProp.search || "",
|
| 1075 | hash: locationProp.hash || "",
|
| 1076 | state: locationProp.state != null ? locationProp.state : null,
|
| 1077 | key: locationProp.key || "default",
|
| 1078 | unstable_mask: void 0
|
| 1079 | };
|
| 1080 | let staticNavigator = getStatelessNavigator();
|
| 1081 | return React2.createElement(
|
| 1082 | _chunkYMKMFAYZjs.Router,
|
| 1083 | {
|
| 1084 | basename,
|
| 1085 | children,
|
| 1086 | location,
|
| 1087 | navigationType: action,
|
| 1088 | navigator: staticNavigator,
|
| 1089 | static: true,
|
| 1090 | unstable_useTransitions: false
|
| 1091 | }
|
| 1092 | );
|
| 1093 | }
|
| 1094 | function StaticRouterProvider({
|
| 1095 | context,
|
| 1096 | router,
|
| 1097 | hydrate = true,
|
| 1098 | nonce
|
| 1099 | }) {
|
| 1100 | _chunkYMKMFAYZjs.invariant.call(void 0,
|
| 1101 | router && context,
|
| 1102 | "You must provide `router` and `context` to <StaticRouterProvider>"
|
| 1103 | );
|
| 1104 | let dataRouterContext = {
|
| 1105 | router,
|
| 1106 | navigator: getStatelessNavigator(),
|
| 1107 | static: true,
|
| 1108 | staticContext: context,
|
| 1109 | basename: context.basename || "/"
|
| 1110 | };
|
| 1111 | let fetchersContext = new Map();
|
| 1112 | let hydrateScript = "";
|
| 1113 | if (hydrate !== false) {
|
| 1114 | let data = {
|
| 1115 | loaderData: context.loaderData,
|
| 1116 | actionData: context.actionData,
|
| 1117 | errors: serializeErrors(context.errors)
|
| 1118 | };
|
| 1119 | let json = _chunkYMKMFAYZjs.escapeHtml.call(void 0, JSON.stringify(JSON.stringify(data)));
|
| 1120 | hydrateScript = `window.__staticRouterHydrationData = JSON.parse(${json});`;
|
| 1121 | }
|
| 1122 | let { state } = dataRouterContext.router;
|
| 1123 | return React2.createElement(React2.Fragment, null, React2.createElement(_chunkYMKMFAYZjs.DataRouterContext.Provider, { value: dataRouterContext }, React2.createElement(_chunkYMKMFAYZjs.DataRouterStateContext.Provider, { value: state }, React2.createElement(_chunkYMKMFAYZjs.FetchersContext.Provider, { value: fetchersContext }, React2.createElement(_chunkYMKMFAYZjs.ViewTransitionContext.Provider, { value: { isTransitioning: false } }, React2.createElement(
|
| 1124 | _chunkYMKMFAYZjs.Router,
|
| 1125 | {
|
| 1126 | basename: dataRouterContext.basename,
|
| 1127 | location: state.location,
|
| 1128 | navigationType: state.historyAction,
|
| 1129 | navigator: dataRouterContext.navigator,
|
| 1130 | static: dataRouterContext.static,
|
| 1131 | unstable_useTransitions: false
|
| 1132 | },
|
| 1133 | React2.createElement(
|
| 1134 | _chunkYMKMFAYZjs.DataRoutes,
|
| 1135 | {
|
| 1136 | routes: router.routes,
|
| 1137 | future: router.future,
|
| 1138 | state,
|
| 1139 | isStatic: true
|
| 1140 | }
|
| 1141 | )
|
| 1142 | ))))), hydrateScript ? React2.createElement(
|
| 1143 | "script",
|
| 1144 | {
|
| 1145 | suppressHydrationWarning: true,
|
| 1146 | nonce,
|
| 1147 | dangerouslySetInnerHTML: { __html: hydrateScript }
|
| 1148 | }
|
| 1149 | ) : null);
|
| 1150 | }
|
| 1151 | function serializeErrors(errors) {
|
| 1152 | if (!errors) return null;
|
| 1153 | let entries = Object.entries(errors);
|
| 1154 | let serialized = {};
|
| 1155 | for (let [key, val] of entries) {
|
| 1156 | if (_chunkYMKMFAYZjs.isRouteErrorResponse.call(void 0, val)) {
|
| 1157 | serialized[key] = { ...val, __type: "RouteErrorResponse" };
|
| 1158 | } else if (val instanceof Error) {
|
| 1159 | serialized[key] = {
|
| 1160 | message: val.message,
|
| 1161 | __type: "Error",
|
| 1162 |
|
| 1163 |
|
| 1164 | ...val.name !== "Error" ? {
|
| 1165 | __subType: val.name
|
| 1166 | } : {}
|
| 1167 | };
|
| 1168 | } else {
|
| 1169 | serialized[key] = val;
|
| 1170 | }
|
| 1171 | }
|
| 1172 | return serialized;
|
| 1173 | }
|
| 1174 | function getStatelessNavigator() {
|
| 1175 | return {
|
| 1176 | createHref,
|
| 1177 | encodeLocation,
|
| 1178 | push(to) {
|
| 1179 | throw new Error(
|
| 1180 | `You cannot use navigator.push() on the server because it is a stateless environment. This error was probably triggered when you did a \`navigate(${JSON.stringify(to)})\` somewhere in your app.`
|
| 1181 | );
|
| 1182 | },
|
| 1183 | replace(to) {
|
| 1184 | throw new Error(
|
| 1185 | `You cannot use navigator.replace() on the server because it is a stateless environment. This error was probably triggered when you did a \`navigate(${JSON.stringify(to)}, { replace: true })\` somewhere in your app.`
|
| 1186 | );
|
| 1187 | },
|
| 1188 | go(delta) {
|
| 1189 | throw new Error(
|
| 1190 | `You cannot use navigator.go() on the server because it is a stateless environment. This error was probably triggered when you did a \`navigate(${delta})\` somewhere in your app.`
|
| 1191 | );
|
| 1192 | },
|
| 1193 | back() {
|
| 1194 | throw new Error(
|
| 1195 | `You cannot use navigator.back() on the server because it is a stateless environment.`
|
| 1196 | );
|
| 1197 | },
|
| 1198 | forward() {
|
| 1199 | throw new Error(
|
| 1200 | `You cannot use navigator.forward() on the server because it is a stateless environment.`
|
| 1201 | );
|
| 1202 | }
|
| 1203 | };
|
| 1204 | }
|
| 1205 | function createStaticHandler2(routes, opts) {
|
| 1206 | return _chunkYMKMFAYZjs.createStaticHandler.call(void 0, routes, {
|
| 1207 | ...opts,
|
| 1208 | mapRouteProperties: _chunkYMKMFAYZjs.mapRouteProperties
|
| 1209 | });
|
| 1210 | }
|
| 1211 | function createStaticRouter(routes, context, opts = {}) {
|
| 1212 | let manifest = {};
|
| 1213 | let dataRoutes = _chunkYMKMFAYZjs.convertRoutesToDataRoutes.call(void 0,
|
| 1214 | routes,
|
| 1215 | _chunkYMKMFAYZjs.mapRouteProperties,
|
| 1216 | void 0,
|
| 1217 | manifest
|
| 1218 | );
|
| 1219 | let matches = context.matches.map((match) => {
|
| 1220 | let route = manifest[match.route.id] || match.route;
|
| 1221 | return {
|
| 1222 | ...match,
|
| 1223 | route
|
| 1224 | };
|
| 1225 | });
|
| 1226 | let msg = (method) => `You cannot use router.${method}() on the server because it is a stateless environment`;
|
| 1227 | return {
|
| 1228 | get basename() {
|
| 1229 | return context.basename;
|
| 1230 | },
|
| 1231 | get future() {
|
| 1232 | return {
|
| 1233 | v8_middleware: false,
|
| 1234 | unstable_passThroughRequests: false,
|
| 1235 | ..._optionalChain([opts, 'optionalAccess', _29 => _29.future])
|
| 1236 | };
|
| 1237 | },
|
| 1238 | get state() {
|
| 1239 | return {
|
| 1240 | historyAction: "POP" ,
|
| 1241 | location: context.location,
|
| 1242 | matches,
|
| 1243 | loaderData: context.loaderData,
|
| 1244 | actionData: context.actionData,
|
| 1245 | errors: context.errors,
|
| 1246 | initialized: true,
|
| 1247 | renderFallback: false,
|
| 1248 | navigation: _chunkYMKMFAYZjs.IDLE_NAVIGATION,
|
| 1249 | restoreScrollPosition: null,
|
| 1250 | preventScrollReset: false,
|
| 1251 | revalidation: "idle",
|
| 1252 | fetchers: new Map(),
|
| 1253 | blockers: new Map()
|
| 1254 | };
|
| 1255 | },
|
| 1256 | get routes() {
|
| 1257 | return dataRoutes;
|
| 1258 | },
|
| 1259 | get window() {
|
| 1260 | return void 0;
|
| 1261 | },
|
| 1262 | initialize() {
|
| 1263 | throw msg("initialize");
|
| 1264 | },
|
| 1265 | subscribe() {
|
| 1266 | throw msg("subscribe");
|
| 1267 | },
|
| 1268 | enableScrollRestoration() {
|
| 1269 | throw msg("enableScrollRestoration");
|
| 1270 | },
|
| 1271 | navigate() {
|
| 1272 | throw msg("navigate");
|
| 1273 | },
|
| 1274 | fetch() {
|
| 1275 | throw msg("fetch");
|
| 1276 | },
|
| 1277 | revalidate() {
|
| 1278 | throw msg("revalidate");
|
| 1279 | },
|
| 1280 | createHref,
|
| 1281 | encodeLocation,
|
| 1282 | getFetcher() {
|
| 1283 | return _chunkYMKMFAYZjs.IDLE_FETCHER;
|
| 1284 | },
|
| 1285 | deleteFetcher() {
|
| 1286 | throw msg("deleteFetcher");
|
| 1287 | },
|
| 1288 | resetFetcher() {
|
| 1289 | throw msg("resetFetcher");
|
| 1290 | },
|
| 1291 | dispose() {
|
| 1292 | throw msg("dispose");
|
| 1293 | },
|
| 1294 | getBlocker() {
|
| 1295 | return _chunkYMKMFAYZjs.IDLE_BLOCKER;
|
| 1296 | },
|
| 1297 | deleteBlocker() {
|
| 1298 | throw msg("deleteBlocker");
|
| 1299 | },
|
| 1300 | patchRoutes() {
|
| 1301 | throw msg("patchRoutes");
|
| 1302 | },
|
| 1303 | _internalFetchControllers: new Map(),
|
| 1304 | _internalSetRoutes() {
|
| 1305 | throw msg("_internalSetRoutes");
|
| 1306 | },
|
| 1307 | _internalSetStateDoNotUseOrYouWillBreakYourApp() {
|
| 1308 | throw msg("_internalSetStateDoNotUseOrYouWillBreakYourApp");
|
| 1309 | }
|
| 1310 | };
|
| 1311 | }
|
| 1312 | function createHref(to) {
|
| 1313 | return typeof to === "string" ? to : _chunkYMKMFAYZjs.createPath.call(void 0, to);
|
| 1314 | }
|
| 1315 | function encodeLocation(to) {
|
| 1316 | let href = typeof to === "string" ? to : _chunkYMKMFAYZjs.createPath.call(void 0, to);
|
| 1317 | href = href.replace(/ $/, "%20");
|
| 1318 | let encoded = ABSOLUTE_URL_REGEX2.test(href) ? new URL(href) : new URL(href, "http://localhost");
|
| 1319 | return {
|
| 1320 | pathname: encoded.pathname,
|
| 1321 | search: encoded.search,
|
| 1322 | hash: encoded.hash
|
| 1323 | };
|
| 1324 | }
|
| 1325 | var ABSOLUTE_URL_REGEX2 = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
|
| 1326 |
|
| 1327 |
|
| 1328 |
|
| 1329 |
|
| 1330 |
|
| 1331 |
|
| 1332 |
|
| 1333 |
|
| 1334 |
|
| 1335 |
|
| 1336 |
|
| 1337 |
|
| 1338 |
|
| 1339 |
|
| 1340 |
|
| 1341 |
|
| 1342 |
|
| 1343 |
|
| 1344 |
|
| 1345 |
|
| 1346 |
|
| 1347 |
|
| 1348 |
|
| 1349 |
|
| 1350 |
|
| 1351 |
|
| 1352 | exports.createSearchParams = createSearchParams; exports.createBrowserRouter = createBrowserRouter; exports.createHashRouter = createHashRouter; exports.BrowserRouter = BrowserRouter; exports.HashRouter = HashRouter; exports.HistoryRouter = HistoryRouter; exports.Link = Link; exports.NavLink = NavLink; exports.Form = Form; exports.ScrollRestoration = ScrollRestoration; exports.useLinkClickHandler = useLinkClickHandler; exports.useSearchParams = useSearchParams; exports.useSubmit = useSubmit; exports.useFormAction = useFormAction; exports.useFetcher = useFetcher; exports.useFetchers = useFetchers; exports.useScrollRestoration = useScrollRestoration; exports.useBeforeUnload = useBeforeUnload; exports.usePrompt = usePrompt; exports.useViewTransitionState = useViewTransitionState; exports.StaticRouter = StaticRouter; exports.StaticRouterProvider = StaticRouterProvider; exports.createStaticHandler = createStaticHandler2; exports.createStaticRouter = createStaticRouter;
|