From 83233587820518d6aa732ce6d4a4915941f63923 Mon Sep 17 00:00:00 2001
From: Hikari_Nova <3044344887@qq.com>
Date: Sun, 24 May 2026 16:23:47 +0800
Subject: [PATCH 01/78] docs: add moonbridge console frontend design
---
.gitignore | 1 +
.../2026-05-24-moonbridge-console-design.md | 334 ++++++++++++++++++
2 files changed, 335 insertions(+)
create mode 100644 docs/superpowers/specs/2026-05-24-moonbridge-console-design.md
diff --git a/.gitignore b/.gitignore
index 5da6bd33..dfaec113 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,6 +8,7 @@ __pycache__/
# Agent / AI assistant local files
.planning/
+.superpowers/
helloagents/
AGENTS.md
CLAUDE.md
diff --git a/docs/superpowers/specs/2026-05-24-moonbridge-console-design.md b/docs/superpowers/specs/2026-05-24-moonbridge-console-design.md
new file mode 100644
index 00000000..c5ef32db
--- /dev/null
+++ b/docs/superpowers/specs/2026-05-24-moonbridge-console-design.md
@@ -0,0 +1,334 @@
+# Moon Bridge Console Frontend Integration Design
+
+Date: 2026-05-24
+Status: Approved direction, pending implementation plan
+
+## Summary
+
+Moon Bridge is a Go HTTP proxy and protocol conversion server. It exposes OpenAI-compatible endpoints such as `/v1/responses` and `/v1/models`, and, when persistence is enabled, a management API under `/api/v1/`.
+
+This design adds an embedded Web frontend at `/console/`. The frontend is an operations console, not a chat product or marketing page. Its primary job is to make Moon Bridge's runtime configuration visible and editable: status, providers, models, offers, routes, extensions, pending changes, import/export, and a small RPC smoke-test panel.
+
+Confirmed product direction:
+
+- Product focus: operations console first.
+- Integration form: embedded SPA served by the Go binary.
+- Frontend stack: Vite + React + TypeScript, Material Design 3 visual language, TanStack Query for RPC state, Motion for React for UI motion.
+- Theme: primary color `#7AA7A2`, support dark and light mode switching, default to dark mode.
+
+## Current Project Architecture
+
+The existing codebase is backend-first and already has most API boundaries needed by a console:
+
+- Entry points: `cmd/moonbridge/main.go` loads config, initializes logging, handles CLI flags, and starts `app.RunServer`.
+- Application lifecycle: `internal/service/app/app.go` builds provider managers, protocol adapters, extension registry, persistence, runtime snapshots, stats, trace, session management, and HTTP server wiring.
+- HTTP server: `internal/service/server/server.go` registers `/v1/responses`, `/responses`, `/v1/models`, `/models`, plugin routes, and `/api/v1/` when runtime and store are available.
+- Management API: `internal/service/api/router.go` registers providers, offers, models, routes, settings, config import/export/validate, pending changes, status, sessions, stats, logs, and version endpoints.
+- Runtime model: `internal/service/runtime/runtime.go` exposes atomic config snapshots and reloads them after validation.
+- Persistence: `internal/service/store` and DB extensions support staged changes and `ApplyPendingChanges`.
+- Protocol conversion: `internal/format` plus `internal/protocol/{openai,anthropic,google,chat}` map OpenAI Responses to upstream provider protocols.
+- Extensions: `internal/extension` includes DeepSeek V4 adaptation, visual delegation, web search, metrics, DB providers, Codex catalog support, and tool proxy logic.
+
+The console should respect this shape: it should consume existing API boundaries instead of adding a parallel configuration mechanism.
+
+## Primary User Workflows
+
+1. View current runtime state.
+ - Read mode, address, version, provider count, route count, active sessions, stats summary, and provider statuses.
+ - Show a clear setup state when the management API is absent or returns `store_unavailable` because persistence/store is not active.
+
+2. Understand and edit the configuration graph.
+ - Models define metadata and capability hints.
+ - Providers define upstream base URL, protocol, auth, user agent, web search, and offers.
+ - Offers link providers to model slugs with pricing and upstream names.
+ - Routes expose aliases that map to provider/model pairs.
+ - The UI should make these relationships visible, not just expose isolated forms.
+
+3. Stage, review, apply, or discard changes.
+ - All mutations call existing API endpoints that create pending changes.
+ - A persistent change queue shows resource, target, action, before/after summary, and creation time.
+ - Apply calls `POST /api/v1/changes/apply`; discard calls `POST /api/v1/changes/discard`.
+ - After apply/discard, invalidate status, providers, models, routes, defaults, web search, extensions, and changes queries.
+
+4. Import/export configuration.
+ - Import YAML through `POST /api/v1/config/import`, then review generated staged changes.
+ - Validate YAML through `POST /api/v1/config/validate`.
+ - Export masked or secret-including YAML through `GET /api/v1/config/export`, with the required `X-Confirm-Secrets: true` confirmation for secret export.
+
+5. Run a lightweight RPC smoke test.
+ - Select a route/model and send a minimal `POST /v1/responses` request.
+ - Support non-streaming first.
+ - Add streaming SSE inspection after the basic console is stable.
+ - This panel is for route verification and debugging, not a full chat UI.
+
+## Frontend Information Architecture
+
+The first version should use a dense operational layout:
+
+- Top app bar: product name, connection target, runtime mode, auth/session indicator.
+- Navigation rail:
+ - Overview
+ - Models
+ - Providers
+ - Routes
+ - Extensions
+ - Changes
+ - Config
+ - RPC Test
+- Global change queue indicator: visible in the app bar and as a right-side drawer on edit pages.
+- Snackbar/toast area: mutation accepted, apply succeeded, validation failed, auth failed, store unavailable.
+
+### Overview
+
+Shows:
+
+- Status from `GET /api/v1/status`.
+- Provider health summary from `GET /api/v1/status/providers`.
+- Usage summary from `GET /api/v1/stats/summary`.
+- Recent sessions from `GET /api/v1/sessions`.
+- Pending changes from `GET /api/v1/changes`.
+- Setup warning when `/api/v1/*` returns 404, 503, or `store_unavailable`.
+
+### Models
+
+Shows paginated model table from `GET /api/v1/models`.
+
+Key controls:
+
+- Create/update model metadata through `PUT /api/v1/models/{slug}`.
+- Delete model through `DELETE /api/v1/models/{slug}`.
+- Link to provider offers for the selected model.
+
+### Providers
+
+Shows paginated provider list from `GET /api/v1/providers`.
+
+Key controls:
+
+- View provider detail from `GET /api/v1/providers/{key}`.
+- Create/update provider through `PUT/PATCH /api/v1/providers/{key}`.
+- Delete provider through `DELETE /api/v1/providers/{key}`.
+- Test provider through `POST /api/v1/providers/{key}/test` only when the provider is Anthropic-compatible. The current backend probe constructs an Anthropic Messages request and should not be presented as protocol-neutral.
+- Manage offers under `POST/PATCH/DELETE /api/v1/providers/{key}/offers`.
+
+### Routes
+
+Shows routes from `GET /api/v1/routes`.
+
+Key controls:
+
+- Create/update alias through `PUT /api/v1/routes/{alias}`.
+- Delete alias through `DELETE /api/v1/routes/{alias}`.
+- Show route graph: alias -> model -> provider -> upstream base URL/protocol.
+
+### Extensions
+
+Shows extension names from `GET /api/v1/extensions` and details from `GET /api/v1/extensions/{name}`.
+
+First version should provide safe JSON editing for extension config through `PUT /api/v1/extensions/{name}`. Typed forms can be added later when extension config specs are exposed through an API.
+
+### Changes
+
+Shows pending rows from `GET /api/v1/changes`.
+
+Controls:
+
+- Apply all pending changes.
+- Discard all pending changes.
+- Show normalized before/after diff for JSON payloads.
+- Warn when route/provider/model deletions may affect visible aliases.
+
+### Config
+
+Controls:
+
+- Effective masked config from `GET /api/v1/config/effective`.
+- YAML import and validation.
+- YAML export, with explicit confirmation for secret export.
+
+### RPC Test
+
+Controls:
+
+- Select route/model from `/v1/models` or management route data.
+- Send a short `POST /v1/responses`.
+- Show request JSON, response JSON, latency, error object, and selected model/provider.
+- Stream mode is optional for v1. If included, show SSE events in an append-only event list.
+
+## Technical Architecture
+
+### Repository Layout
+
+Add:
+
+```text
+webui/
+ package.json
+ vite.config.ts
+ tsconfig.json
+ index.html
+ src/
+ app/
+ components/
+ features/
+ rpc/
+ theme/
+ test/
+internal/service/webui/
+ embed.go
+```
+
+The Go server should serve the built SPA under `/console/`. In development, the Vite dev server can proxy API calls to Moon Bridge.
+
+### Go Integration
+
+Use `go:embed` for production assets:
+
+- Embed `webui/dist`.
+- Register `/console/` to serve static assets.
+- Return `index.html` for unknown `/console/*` paths so client-side routing works.
+- Keep `/api/v1/`, `/v1/responses`, and `/v1/models` unchanged.
+- Prefer adding a small `internal/service/webui` package so `server.go` stays focused on HTTP API registration.
+
+Required backend additions:
+
+- Serve `/console/` static assets.
+- Optionally add `GET /api/v1/capabilities` or include capability flags in `GET /api/v1/status`, so the UI can show whether persistence, metrics, logs, and RPC test are available.
+- Implement a real recent log buffer before making `/api/v1/logs` prominent; the current handler returns an empty list.
+- Consider broadening `POST /api/v1/providers/{key}/test` beyond Anthropic-only probing before presenting it as protocol-neutral. Until then, hide or label it for non-Anthropic protocols.
+
+### Frontend Stack
+
+Use:
+
+- Vite + React + TypeScript for the SPA.
+- Material Web components and Material 3 design tokens for core controls and visual language. Material Web is Google's Material Web Components library and follows Material Design guidelines; its docs also describe Material 3 tokens as CSS custom properties.
+- TanStack Query for server-state fetching, caching, mutations, invalidation, and async state. Its docs describe it as async/server-state and data-fetching utilities for TS/JS applications.
+- Motion for React for layout transitions, enter/exit animations, drawer/dialog animation, list reordering, and pending-change feedback.
+- TanStack Table for dense resource tables unless Material Web table coverage is enough during implementation.
+- React Router or TanStack Router for client-side routing. Choose the one that minimizes setup after dependency installation.
+
+Rationale:
+
+- Material Web gives the closest Material Design 3 base.
+- MUI is mature and production-ready, but its own docs currently state Material UI adopts Material Design 2, so it should be a fallback for complex admin widgets rather than the default visual foundation.
+- TanStack Query fits this app because nearly all state is remote runtime/config state.
+- Motion fits the animation requirement while staying React-native and TypeScript-friendly.
+
+References:
+
+- Material Web intro: https://material-web.dev/about/intro/
+- MUI Material UI overview and MD2 note: https://mui.com/material-ui/
+- TanStack Query overview: https://tanstack.com/query/latest
+- Motion for React docs: https://motion.dev/docs/react
+
+## RPC Client Design
+
+Create a typed API client in `webui/src/rpc/`.
+
+Recommended modules:
+
+- `http.ts`: base URL resolution, auth header injection, JSON parsing, error normalization.
+- `management.ts`: `/api/v1` endpoints.
+- `responses.ts`: `/v1/responses` smoke-test client, including optional SSE reader.
+- `types.ts`: DTOs for status, providers, models, offers, routes, changes, settings, stats, sessions, and OpenAI error shape.
+
+Error handling:
+
+- Normalize `{ error: { code, message } }` from management endpoints.
+- Normalize OpenAI-style errors from `/v1/responses`.
+- Show auth failures as a global blocking state.
+- Show store unavailable as a setup state explaining that persistence must be enabled for the console.
+
+Auth handling:
+
+- If `auth_token` is configured, the same Bearer token protects all server routes.
+- The UI cannot discover the token. It should show a token entry screen when a protected API call returns 401.
+- Store the token in session storage by default, with an explicit "remember on this device" option for local storage.
+
+## Visual and Interaction Design
+
+Material 3 direction:
+
+- Use `#7AA7A2` as the default primary seed color.
+- Default to dark mode on first load.
+- Support explicit dark/light mode switching from the app shell.
+- Persist the user's selected mode locally, and fall back to default dark mode when no preference is stored.
+- Generate separate light and dark Material 3 token sets from the same primary seed color so surfaces, outlines, and state layers remain coherent in both modes.
+- Use navigation rail on desktop and modal navigation drawer on narrow screens.
+- Use surface levels, tonal buttons, outlined text fields, chips, dialogs, switches, segmented buttons, and snackbars.
+- Keep cards to repeated resources and panels; avoid nested cards.
+- Use compact dashboard typography, not landing-page hero typography.
+- Use clear status colors: healthy, unknown, pending, error, disabled.
+
+Motion:
+
+- Page transitions: subtle fade/slide, 120-180ms.
+- Change queue: animate item entry/exit and apply/discard collapse.
+- Dialogs and drawers: use spring only where it helps, otherwise short easing.
+- Resource tables: animate row insertion/removal only, not every hover.
+- Respect `prefers-reduced-motion`.
+
+## Data Consistency Rules
+
+- Treat runtime configuration as server-owned.
+- All write operations produce staged changes. The UI must not pretend a staged change is active.
+- After any staged mutation, invalidate only `changes` plus the affected resource detail if needed.
+- After apply/discard, invalidate all config-derived queries.
+- For forms editing masked secrets, preserve `"******"` semantics where existing APIs support it.
+- Never display plaintext secrets after masked reads.
+
+## Testing Strategy
+
+Frontend:
+
+- Unit test RPC client error normalization and query key builders.
+- Component test forms for provider, model, route, offers, and change queue.
+- E2E smoke tests with a mock Moon Bridge server:
+ - overview loads
+ - provider edit stages a change
+ - apply refreshes status/resources
+ - auth prompt appears on 401
+ - store unavailable state appears on 503
+
+Backend:
+
+- Add tests for `/console/` serving:
+ - index served at `/console/`
+ - assets served with correct content type
+ - nested routes fallback to index
+ - existing API routes unaffected
+- Add tests for any new capability/status endpoint fields.
+
+Manual verification:
+
+- `go test ./...`
+- `pnpm --dir webui test`
+- `pnpm --dir webui build`
+- Start Moon Bridge with `config.example.yml` style SQLite persistence and open `/console/`.
+
+## Open Questions
+
+- Should the console be enabled by default, or behind a config flag such as `server.console_enabled`?
+- Should `/console/` be served in Capture modes, where the management API may not be meaningful?
+- Should the first implementation include streaming SSE inspection, or defer it after CRUD/config flows?
+- Should extension config specs be exposed over API to support generated typed forms?
+
+## Non-Goals for v1
+
+- Full chat application.
+- Multi-user RBAC.
+- Remote workspace/project management.
+- Real-time websocket dashboard.
+- Editing raw SQLite/D1 state directly.
+- Replacing existing CLI config generation commands.
+
+## Recommended Implementation Slices
+
+1. Add embedded static serving and a minimal Vite React app at `/console/`.
+2. Add typed RPC client and overview/status page.
+3. Add provider/model/route read-only pages.
+4. Add staged mutations and change queue apply/discard.
+5. Add config import/export and validation.
+6. Add RPC smoke-test panel.
+7. Add animation polish and responsive navigation.
From 5e7e6d0aa1cfd5e9a952d2a1820be359904b7e8a Mon Sep 17 00:00:00 2001
From: Hikari_Nova <3044344887@qq.com>
Date: Sun, 24 May 2026 16:29:01 +0800
Subject: [PATCH 02/78] docs: expand console config workflows
---
.../2026-05-24-moonbridge-console-design.md | 36 ++++++++++++++++---
1 file changed, 31 insertions(+), 5 deletions(-)
diff --git a/docs/superpowers/specs/2026-05-24-moonbridge-console-design.md b/docs/superpowers/specs/2026-05-24-moonbridge-console-design.md
index c5ef32db..3959c822 100644
--- a/docs/superpowers/specs/2026-05-24-moonbridge-console-design.md
+++ b/docs/superpowers/specs/2026-05-24-moonbridge-console-design.md
@@ -7,7 +7,7 @@ Status: Approved direction, pending implementation plan
Moon Bridge is a Go HTTP proxy and protocol conversion server. It exposes OpenAI-compatible endpoints such as `/v1/responses` and `/v1/models`, and, when persistence is enabled, a management API under `/api/v1/`.
-This design adds an embedded Web frontend at `/console/`. The frontend is an operations console, not a chat product or marketing page. Its primary job is to make Moon Bridge's runtime configuration visible and editable: status, providers, models, offers, routes, extensions, pending changes, import/export, and a small RPC smoke-test panel.
+This design adds an embedded Web frontend at `/console/`. The frontend is an operations console, not a chat product or marketing page. Its primary job is to make Moon Bridge's runtime configuration visible and editable: status, providers, models, offers, routes, extensions, pending changes, config generation/import/apply, visual config editing, and a small RPC smoke-test panel.
Confirmed product direction:
@@ -51,11 +51,18 @@ The console should respect this shape: it should consume existing API boundaries
- After apply/discard, invalidate status, providers, models, routes, defaults, web search, extensions, and changes queries.
4. Import/export configuration.
+ - Generate a valid Moon Bridge YAML config from a guided visual form.
- Import YAML through `POST /api/v1/config/import`, then review generated staged changes.
- Validate YAML through `POST /api/v1/config/validate`.
- Export masked or secret-including YAML through `GET /api/v1/config/export`, with the required `X-Confirm-Secrets: true` confirmation for secret export.
+ - Apply an imported/generated config by staging its changes first, then using the existing change queue apply flow.
-5. Run a lightweight RPC smoke test.
+5. Visually edit configuration.
+ - Provide visual CRUD screens for models, providers, offers, routes, defaults, web search, and selected extension settings.
+ - Treat visual edits and YAML import/generation as equivalent sources of staged changes.
+ - Always show the active runtime config separately from the pending staged config.
+
+6. Run a lightweight RPC smoke test.
- Select a route/model and send a minimal `POST /v1/responses` request.
- Support non-streaming first.
- Add streaming SSE inspection after the basic console is stable.
@@ -143,8 +150,18 @@ Controls:
Controls:
- Effective masked config from `GET /api/v1/config/effective`.
+- Guided config generator:
+ - choose mode
+ - set server address/auth
+ - add provider credentials and protocol
+ - add model metadata
+ - create offers and route aliases
+ - configure persistence, cache, web search, and common extensions
+ - preview generated YAML before staging
- YAML import and validation.
+- YAML apply flow: generate or paste YAML, validate it, stage changes through `POST /api/v1/config/import`, review pending changes, then apply through `POST /api/v1/changes/apply`.
- YAML export, with explicit confirmation for secret export.
+- Visual editor entry points for the same resources. The Config page should not become a separate raw-only editor; it should link to Models, Providers, Routes, Extensions, Defaults, and Web Search visual forms.
### RPC Test
@@ -196,6 +213,7 @@ Required backend additions:
- Optionally add `GET /api/v1/capabilities` or include capability flags in `GET /api/v1/status`, so the UI can show whether persistence, metrics, logs, and RPC test are available.
- Implement a real recent log buffer before making `/api/v1/logs` prominent; the current handler returns an empty list.
- Consider broadening `POST /api/v1/providers/{key}/test` beyond Anthropic-only probing before presenting it as protocol-neutral. Until then, hide or label it for non-Anthropic protocols.
+- Consider adding a non-mutating config generation/normalization endpoint later if frontend-only YAML generation becomes hard to keep aligned with Go config serialization. v1 can generate YAML in the frontend and rely on `POST /api/v1/config/validate` plus `POST /api/v1/config/import` as the source of truth.
### Frontend Stack
@@ -231,6 +249,7 @@ Recommended modules:
- `http.ts`: base URL resolution, auth header injection, JSON parsing, error normalization.
- `management.ts`: `/api/v1` endpoints.
- `responses.ts`: `/v1/responses` smoke-test client, including optional SSE reader.
+- `config-generator.ts`: convert visual generator state into Moon Bridge YAML.
- `types.ts`: DTOs for status, providers, models, offers, routes, changes, settings, stats, sessions, and OpenAI error shape.
Error handling:
@@ -273,6 +292,8 @@ Motion:
- Treat runtime configuration as server-owned.
- All write operations produce staged changes. The UI must not pretend a staged change is active.
+- Generated YAML is not active configuration until it has been validated, imported into pending changes, reviewed, and applied.
+- Visual edits, YAML import, and generated YAML must all converge on the same pending-change queue.
- After any staged mutation, invalidate only `changes` plus the affected resource detail if needed.
- After apply/discard, invalidate all config-derived queries.
- For forms editing masked secrets, preserve `"******"` semantics where existing APIs support it.
@@ -283,10 +304,13 @@ Motion:
Frontend:
- Unit test RPC client error normalization and query key builders.
+- Unit test config generator output for representative Transform, CaptureResponse, and CaptureAnthropic configs.
- Component test forms for provider, model, route, offers, and change queue.
+- Component test the config generation/apply flow: fill wizard, preview YAML, validate, import, review changes, apply.
- E2E smoke tests with a mock Moon Bridge server:
- overview loads
- provider edit stages a change
+ - generated config validates and creates staged changes
- apply refreshes status/resources
- auth prompt appears on 401
- store unavailable state appears on 503
@@ -313,6 +337,7 @@ Manual verification:
- Should `/console/` be served in Capture modes, where the management API may not be meaningful?
- Should the first implementation include streaming SSE inspection, or defer it after CRUD/config flows?
- Should extension config specs be exposed over API to support generated typed forms?
+- Should config generation initially support only common Transform-mode provider/model/route setups, or also full CaptureResponse/CaptureAnthropic proxy setups?
## Non-Goals for v1
@@ -329,6 +354,7 @@ Manual verification:
2. Add typed RPC client and overview/status page.
3. Add provider/model/route read-only pages.
4. Add staged mutations and change queue apply/discard.
-5. Add config import/export and validation.
-6. Add RPC smoke-test panel.
-7. Add animation polish and responsive navigation.
+5. Add visual config generator, YAML preview, validation, import, and apply flow.
+6. Add config export and effective-config viewer.
+7. Add RPC smoke-test panel.
+8. Add animation polish and responsive navigation.
From 7299bea60064ce824da7bb1e563f7d17873d9230 Mon Sep 17 00:00:00 2001
From: Hikari_Nova <3044344887@qq.com>
Date: Sun, 24 May 2026 16:34:02 +0800
Subject: [PATCH 03/78] docs: add console implementation plan
---
...05-24-moonbridge-console-implementation.md | 1113 +++++++++++++++++
1 file changed, 1113 insertions(+)
create mode 100644 docs/superpowers/plans/2026-05-24-moonbridge-console-implementation.md
diff --git a/docs/superpowers/plans/2026-05-24-moonbridge-console-implementation.md b/docs/superpowers/plans/2026-05-24-moonbridge-console-implementation.md
new file mode 100644
index 00000000..595bb065
--- /dev/null
+++ b/docs/superpowers/plans/2026-05-24-moonbridge-console-implementation.md
@@ -0,0 +1,1113 @@
+# Moon Bridge Console Implementation Plan
+
+> **For agentic workers:** REQUIRED: Use superpowers:subagent-driven-development (if subagents available) or superpowers:executing-plans to implement this plan. Steps use checkbox (`- [ ]`) syntax for tracking.
+
+**Goal:** Build an embedded `/console/` Web operations console for Moon Bridge with Material Design 3 styling, default primary color `#7AA7A2`, default dark mode, RPC-backed config management, visual config editing, config generation/import/apply, and a lightweight Responses smoke-test panel.
+
+**Architecture:** Add a Vite + React + TypeScript SPA in `webui/`, serve its production build from Go via `go:embed`, and keep the existing `/api/v1` and `/v1/responses` HTTP contracts as the RPC boundary. Frontend state is server-owned via TanStack Query; all mutations create staged changes and converge on the existing `POST /api/v1/changes/apply` flow.
+
+**Tech Stack:** Go 1.25, `net/http`, `go:embed`, Vite, React, TypeScript, Material Web, TanStack Query, TanStack Table, Motion for React, Vitest, Playwright.
+
+---
+
+## Reference Documents
+
+- Spec: `docs/superpowers/specs/2026-05-24-moonbridge-console-design.md`
+- Existing API docs: `docs/api.md`
+- Existing architecture docs: `docs/architecture.md`
+- Go config file types: `internal/config/config_loader.go`
+- Go config YAML conversion: `internal/config/convert.go`
+- API route registration: `internal/service/api/router.go`
+- HTTP server route registration: `internal/service/server/server.go`
+
+## File Structure
+
+Create:
+
+- `internal/service/webui/embed.go` — embedded static file handler for built SPA assets.
+- `internal/service/webui/embed_test.go` — static serving and SPA fallback tests.
+- `webui/package.json` — frontend scripts and dependencies.
+- `webui/vite.config.ts` — Vite config with `/console/` base and dev proxy.
+- `webui/tsconfig.json`, `webui/tsconfig.node.json` — TypeScript configs.
+- `webui/index.html` — SPA HTML shell.
+- `webui/src/main.tsx` — React bootstrap.
+- `webui/src/app/App.tsx` — app shell and route layout.
+- `webui/src/app/routes.tsx` — client route definitions.
+- `webui/src/app/queryClient.ts` — TanStack Query client.
+- `webui/src/theme/tokens.ts` — Material 3 token values derived from `#7AA7A2`.
+- `webui/src/theme/ThemeProvider.tsx` — dark/light mode state, persistence, CSS variable application.
+- `webui/src/rpc/http.ts` — fetch wrapper, auth handling, error normalization.
+- `webui/src/rpc/types.ts` — API DTOs aligned with existing Go responses.
+- `webui/src/rpc/management.ts` — `/api/v1` typed client.
+- `webui/src/rpc/responses.ts` — `/v1/responses` smoke-test client.
+- `webui/src/rpc/configGenerator.ts` — visual generator state to YAML string.
+- `webui/src/features/overview/OverviewPage.tsx`
+- `webui/src/features/models/ModelsPage.tsx`
+- `webui/src/features/providers/ProvidersPage.tsx`
+- `webui/src/features/routes/RoutesPage.tsx`
+- `webui/src/features/extensions/ExtensionsPage.tsx`
+- `webui/src/features/changes/ChangesPage.tsx`
+- `webui/src/features/config/ConfigPage.tsx`
+- `webui/src/features/config/ConfigGenerator.tsx`
+- `webui/src/features/rpcTest/RpcTestPage.tsx`
+- `webui/src/components/AppShell.tsx`
+- `webui/src/components/AuthGate.tsx`
+- `webui/src/components/ChangeQueueDrawer.tsx`
+- `webui/src/components/ErrorState.tsx`
+- `webui/src/components/LoadingState.tsx`
+- `webui/src/components/ResourceTable.tsx`
+- `webui/src/test/server.ts` — MSW or fetch-mock fixtures for component tests.
+- `webui/src/**/*.test.ts(x)` — Vitest tests beside modules.
+- `webui/e2e/console.spec.ts` — Playwright smoke tests.
+
+Modify:
+
+- `internal/service/server/server.go` — register `/console/` handler.
+- `internal/service/server/server_test.go` or new focused tests — assert API routes remain unaffected.
+- `Makefile` — add `webui-install`, `webui-test`, `webui-build`, and include frontend build in an explicit target.
+- `.gitignore` — ignore `webui/dist`, `webui/node_modules`, and Playwright artifacts if not already covered.
+- `package.json` at repo root — either leave Cloudflare worker scripts untouched or add workspace scripts only if they do not break existing `wrangler` flow.
+- `docs/DEVELOPMENT.md` — document frontend development commands.
+- `docs/api.md` — document `/console/` and console-related setup notes.
+
+Do not modify:
+
+- Existing protocol adapters unless a test proves the console exposed a real backend bug.
+- Existing config storage semantics. Frontend writes must use existing staged-change APIs.
+
+---
+
+## Task 1: Serve Embedded Console Assets From Go
+
+**Files:**
+
+- Create: `internal/service/webui/embed.go`
+- Create: `internal/service/webui/embed_test.go`
+- Modify: `internal/service/server/server.go`
+- Test: `internal/service/webui/embed_test.go`
+
+- [ ] **Step 1: Write failing tests for SPA static serving**
+
+Create `internal/service/webui/embed_test.go`:
+
+```go
+package webui_test
+
+import (
+ "io/fs"
+ "net/http"
+ "net/http/httptest"
+ "strings"
+ "testing"
+ "testing/fstest"
+
+ "moonbridge/internal/service/webui"
+)
+
+func TestHandlerServesIndexAtConsoleRoot(t *testing.T) {
+ files := fstest.MapFS{
+ "dist/index.html": {Data: []byte(`
w)break;var G=M.transferSize,Q=M.initiatorType;G&&k0(Q)&&(M=M.responseEnd,v+=G*(M"u"?null:document;function tb(n,a,s){var l=fs;if(l&&typeof a=="string"&&a){var d=Jt(a);d='link[rel="'+n+'"][href="'+d+'"]',typeof s=="string"&&(d+='[crossorigin="'+s+'"]'),eb.has(d)||(eb.add(d),n={rel:n,crossOrigin:s,href:a},l.querySelector(d)===null&&(a=l.createElement("link"),Ht(a,"link",n),Ge(a),l.head.appendChild(a)))}}function z_(n){Yi.D(n),tb("dns-prefetch",n,null)}function V_(n,a){Yi.C(n,a),tb("preconnect",n,a)}function $_(n,a,s){Yi.L(n,a,s);var l=fs;if(l&&n&&a){var d='link[rel="preload"][as="'+Jt(a)+'"]';a==="image"&&s&&s.imageSrcSet?(d+='[imagesrcset="'+Jt(s.imageSrcSet)+'"]',typeof s.imageSizes=="string"&&(d+='[imagesizes="'+Jt(s.imageSizes)+'"]')):d+='[href="'+Jt(n)+'"]';var p=d;switch(a){case"style":p=ds(n);break;case"script":p=hs(n)}Un.has(p)||(n=y({rel:"preload",href:a==="image"&&s&&s.imageSrcSet?void 0:n,as:a},s),Un.set(p,n),l.querySelector(d)!==null||a==="style"&&l.querySelector(Vo(p))||a==="script"&&l.querySelector($o(p))||(a=l.createElement("link"),Ht(a,"link",n),Ge(a),l.head.appendChild(a)))}}function P_(n,a){Yi.m(n,a);var s=fs;if(s&&n){var l=a&&typeof a.as=="string"?a.as:"script",d='link[rel="modulepreload"][as="'+Jt(l)+'"][href="'+Jt(n)+'"]',p=d;switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":p=hs(n)}if(!Un.has(p)&&(n=y({rel:"modulepreload",href:n},a),Un.set(p,n),s.querySelector(d)===null)){switch(l){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(s.querySelector($o(p)))return}l=s.createElement("link"),Ht(l,"link",n),Ge(l),s.head.appendChild(l)}}}function U_(n,a,s){Yi.S(n,a,s);var l=fs;if(l&&n){var d=vt(l).hoistableStyles,p=ds(n);a=a||"default";var v=d.get(p);if(!v){var w={loading:0,preload:null};if(v=l.querySelector(Vo(p)))w.loading=5;else{n=y({rel:"stylesheet",href:n,"data-precedence":a},s),(s=Un.get(p))&&Ch(n,s);var M=v=l.createElement("link");Ge(M),Ht(M,"link",n),M._p=new Promise(function(B,G){M.onload=B,M.onerror=G}),M.addEventListener("load",function(){w.loading|=1}),M.addEventListener("error",function(){w.loading|=2}),w.loading|=4,ku(v,a,l)}v={type:"stylesheet",instance:v,count:1,state:w},d.set(p,v)}}}function B_(n,a){Yi.X(n,a);var s=fs;if(s&&n){var l=vt(s).hoistableScripts,d=hs(n),p=l.get(d);p||(p=s.querySelector($o(d)),p||(n=y({src:n,async:!0},a),(a=Un.get(d))&&Eh(n,a),p=s.createElement("script"),Ge(p),Ht(p,"link",n),s.head.appendChild(p)),p={type:"script",instance:p,count:1,state:null},l.set(d,p))}}function H_(n,a){Yi.M(n,a);var s=fs;if(s&&n){var l=vt(s).hoistableScripts,d=hs(n),p=l.get(d);p||(p=s.querySelector($o(d)),p||(n=y({src:n,async:!0,type:"module"},a),(a=Un.get(d))&&Eh(n,a),p=s.createElement("script"),Ge(p),Ht(p,"link",n),s.head.appendChild(p)),p={type:"script",instance:p,count:1,state:null},l.set(d,p))}}function nb(n,a,s,l){var d=(d=Se.current)?Fu(d):null;if(!d)throw Error(r(446));switch(n){case"meta":case"title":return null;case"style":return typeof s.precedence=="string"&&typeof s.href=="string"?(a=ds(s.href),s=vt(d).hoistableStyles,l=s.get(a),l||(l={type:"style",instance:null,count:0,state:null},s.set(a,l)),l):{type:"void",instance:null,count:0,state:null};case"link":if(s.rel==="stylesheet"&&typeof s.href=="string"&&typeof s.precedence=="string"){n=ds(s.href);var p=vt(d).hoistableStyles,v=p.get(n);if(v||(d=d.ownerDocument||d,v={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},p.set(n,v),(p=d.querySelector(Vo(n)))&&!p._p&&(v.instance=p,v.state.loading=5),Un.has(n)||(s={rel:"preload",as:"style",href:s.href,crossOrigin:s.crossOrigin,integrity:s.integrity,media:s.media,hrefLang:s.hrefLang,referrerPolicy:s.referrerPolicy},Un.set(n,s),p||F_(d,n,s,v.state))),a&&l===null)throw Error(r(528,""));return v}if(a&&l!==null)throw Error(r(529,""));return null;case"script":return a=s.async,s=s.src,typeof s=="string"&&a&&typeof a!="function"&&typeof a!="symbol"?(a=hs(s),s=vt(d).hoistableScripts,l=s.get(a),l||(l={type:"script",instance:null,count:0,state:null},s.set(a,l)),l):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,n))}}function ds(n){return'href="'+Jt(n)+'"'}function Vo(n){return'link[rel="stylesheet"]['+n+"]"}function ib(n){return y({},n,{"data-precedence":n.precedence,precedence:null})}function F_(n,a,s,l){n.querySelector('link[rel="preload"][as="style"]['+a+"]")?l.loading=1:(a=n.createElement("link"),l.preload=a,a.addEventListener("load",function(){return l.loading|=1}),a.addEventListener("error",function(){return l.loading|=2}),Ht(a,"link",s),Ge(a),n.head.appendChild(a))}function hs(n){return'[src="'+Jt(n)+'"]'}function $o(n){return"script[async]"+n}function ab(n,a,s){if(a.count++,a.instance===null)switch(a.type){case"style":var l=n.querySelector('style[data-href~="'+Jt(s.href)+'"]');if(l)return a.instance=l,Ge(l),l;var d=y({},s,{"data-href":s.href,"data-precedence":s.precedence,href:null,precedence:null});return l=(n.ownerDocument||n).createElement("style"),Ge(l),Ht(l,"style",d),ku(l,s.precedence,n),a.instance=l;case"stylesheet":d=ds(s.href);var p=n.querySelector(Vo(d));if(p)return a.state.loading|=4,a.instance=p,Ge(p),p;l=ib(s),(d=Un.get(d))&&Ch(l,d),p=(n.ownerDocument||n).createElement("link"),Ge(p);var v=p;return v._p=new Promise(function(w,M){v.onload=w,v.onerror=M}),Ht(p,"link",l),a.state.loading|=4,ku(p,s.precedence,n),a.instance=p;case"script":return p=hs(s.src),(d=n.querySelector($o(p)))?(a.instance=d,Ge(d),d):(l=s,(d=Un.get(p))&&(l=y({},s),Eh(l,d)),n=n.ownerDocument||n,d=n.createElement("script"),Ge(d),Ht(d,"link",l),n.head.appendChild(d),a.instance=d);case"void":return null;default:throw Error(r(443,a.type))}else a.type==="stylesheet"&&(a.state.loading&4)===0&&(l=a.instance,a.state.loading|=4,ku(l,s.precedence,n));return a.instance}function ku(n,a,s){for(var l=s.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),d=l.length?l[l.length-1]:null,p=d,v=0;v title"):null)}function k_(n,a,s){if(s===1||a.itemProp!=null)return!1;switch(n){case"meta":case"title":return!0;case"style":if(typeof a.precedence!="string"||typeof a.href!="string"||a.href==="")break;return!0;case"link":if(typeof a.rel!="string"||typeof a.href!="string"||a.href===""||a.onLoad||a.onError)break;return a.rel==="stylesheet"?(n=a.disabled,typeof a.precedence=="string"&&n==null):!0;case"script":if(a.async&&typeof a.async!="function"&&typeof a.async!="symbol"&&!a.onLoad&&!a.onError&&a.src&&typeof a.src=="string")return!0}return!1}function ob(n){return!(n.type==="stylesheet"&&(n.state.loading&3)===0)}function q_(n,a,s,l){if(s.type==="stylesheet"&&(typeof l.media!="string"||matchMedia(l.media).matches!==!1)&&(s.state.loading&4)===0){if(s.instance===null){var d=ds(l.href),p=a.querySelector(Vo(d));if(p){a=p._p,a!==null&&typeof a=="object"&&typeof a.then=="function"&&(n.count++,n=Gu.bind(n),a.then(n,n)),s.state.loading|=4,s.instance=p,Ge(p);return}p=a.ownerDocument||a,l=ib(l),(d=Un.get(d))&&Ch(l,d),p=p.createElement("link"),Ge(p);var v=p;v._p=new Promise(function(w,M){v.onload=w,v.onerror=M}),Ht(p,"link",l),s.instance=p}n.stylesheets===null&&(n.stylesheets=new Map),n.stylesheets.set(s,a),(a=s.state.preload)&&(s.state.loading&3)===0&&(n.count++,s=Gu.bind(n),a.addEventListener("load",s),a.addEventListener("error",s))}}var Rh=0;function G_(n,a){return n.stylesheets&&n.count===0&&Yu(n,n.stylesheets),0Rh?50:800)+a);return n.unsuspend=s,function(){n.unsuspend=null,clearTimeout(l),clearTimeout(d)}}:null}function Gu(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Yu(this,this.stylesheets);else if(this.unsuspend){var n=this.unsuspend;this.unsuspend=null,n()}}}var Iu=null;function Yu(n,a){n.stylesheets=null,n.unsuspend!==null&&(n.count++,Iu=new Map,a.forEach(I_,n),Iu=null,Gu.call(n))}function I_(n,a){if(!(a.state.loading&4)){var s=Iu.get(n);if(s)var l=s.get(null);else{s=new Map,Iu.set(n,s);for(var d=n.querySelectorAll("link[data-precedence],style[data-precedence]"),p=0;p"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Lh.exports=fT(),Lh.exports}var hT=dT(),$s=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},pT=class extends $s{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<"u"&&window.addEventListener){const t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(t=>{typeof t=="boolean"?this.setFocused(t):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},ym=new pT,mT={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},gT=class{#e=mT;#t=!1;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}},pr=new gT;function yT(e){setTimeout(e,0)}var vT=typeof window>"u"||"Deno"in globalThis;function tn(){}function bT(e,t){return typeof e=="function"?e(t):e}function vp(e){return typeof e=="number"&&e>=0&&e!==1/0}function fw(e,t){return Math.max(e+(t||0)-Date.now(),0)}function za(e,t){return typeof e=="function"?e(t):e}function Rn(e,t){return typeof e=="function"?e(t):e}function Db(e,t){const{type:i="all",exact:r,fetchStatus:o,predicate:u,queryKey:c,stale:f}=e;if(c){if(r){if(t.queryHash!==vm(c,t.options))return!1}else if(!cl(t.queryKey,c))return!1}if(i!=="all"){const h=t.isActive();if(i==="active"&&!h||i==="inactive"&&h)return!1}return!(typeof f=="boolean"&&t.isStale()!==f||o&&o!==t.state.fetchStatus||u&&!u(t))}function jb(e,t){const{exact:i,status:r,predicate:o,mutationKey:u}=e;if(u){if(!t.options.mutationKey)return!1;if(i){if(Cr(t.options.mutationKey)!==Cr(u))return!1}else if(!cl(t.options.mutationKey,u))return!1}return!(r&&t.state.status!==r||o&&!o(t))}function vm(e,t){return(t?.queryKeyHashFn||Cr)(e)}function Cr(e){return JSON.stringify(e,(t,i)=>bp(i)?Object.keys(i).sort().reduce((r,o)=>(r[o]=i[o],r),{}):i)}function cl(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(i=>cl(e[i],t[i])):!1}var ST=Object.prototype.hasOwnProperty;function dw(e,t,i=0){if(e===t)return e;if(i>500)return t;const r=Nb(e)&&Nb(t);if(!r&&!(bp(e)&&bp(t)))return t;const u=(r?e:Object.keys(e)).length,c=r?t:Object.keys(t),f=c.length,h=r?new Array(f):{};let m=0;for(let g=0;g{pr.setTimeout(t,e)})}function Sp(e,t,i){return typeof i.structuralSharing=="function"?i.structuralSharing(e,t):i.structuralSharing!==!1?dw(e,t):t}function wT(e,t,i=0){const r=[...e,t];return i&&r.length>i?r.slice(1):r}function CT(e,t,i=0){const r=[t,...e];return i&&r.length>i?r.slice(0,-1):r}var bm=Symbol();function hw(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===bm?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Sm(e,t){return typeof e=="function"?e(...t):!!e}function ET(e,t,i){let r=!1,o;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(o??=t(),r||(r=!0,o.aborted?i():o.addEventListener("abort",i,{once:!0})),o)}),e}var fl=(()=>{let e=()=>vT;return{isServer(){return e()},setIsServer(t){e=t}}})();function xp(){let e,t;const i=new Promise((o,u)=>{e=o,t=u});i.status="pending",i.catch(()=>{});function r(o){Object.assign(i,o),delete i.resolve,delete i.reject}return i.resolve=o=>{r({status:"fulfilled",value:o}),e(o)},i.reject=o=>{r({status:"rejected",reason:o}),t(o)},i}var RT=yT;function _T(){let e=[],t=0,i=f=>{f()},r=f=>{f()},o=RT;const u=f=>{t?e.push(f):o(()=>{i(f)})},c=()=>{const f=e;e=[],f.length&&o(()=>{r(()=>{f.forEach(h=>{i(h)})})})};return{batch:f=>{let h;t++;try{h=f()}finally{t--,t||c()}return h},batchCalls:f=>(...h)=>{u(()=>{f(...h)})},schedule:u,setNotifyFunction:f=>{i=f},setBatchNotifyFunction:f=>{r=f},setScheduler:f=>{o=f}}}var Nt=_T(),TT=class extends $s{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<"u"&&window.addEventListener){const t=()=>e(!0),i=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",i,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",i)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(i=>{i(e)}))}isOnline(){return this.#e}},Vc=new TT;function AT(e){return Math.min(1e3*2**e,3e4)}function pw(e){return(e??"online")==="online"?Vc.isOnline():!0}var wp=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function mw(e){let t=!1,i=0,r;const o=xp(),u=()=>o.status!=="pending",c=C=>{if(!u()){const R=new wp(C);b(R),e.onCancel?.(R)}},f=()=>{t=!0},h=()=>{t=!1},m=()=>ym.isFocused()&&(e.networkMode==="always"||Vc.isOnline())&&e.canRun(),g=()=>pw(e.networkMode)&&e.canRun(),y=C=>{u()||(r?.(),o.resolve(C))},b=C=>{u()||(r?.(),o.reject(C))},S=()=>new Promise(C=>{r=R=>{(u()||m())&&C(R)},e.onPause?.()}).then(()=>{r=void 0,u()||e.onContinue?.()}),x=()=>{if(u())return;let C;const R=i===0?e.initialPromise:void 0;try{C=R??e.fn()}catch(A){C=Promise.reject(A)}Promise.resolve(C).then(y).catch(A=>{if(u())return;const j=e.retry??(fl.isServer()?0:3),L=e.retryDelay??AT,V=typeof L=="function"?L(i,A):L,q=j===!0||typeof j=="number"&&im()?void 0:S()).then(()=>{t?b(A):x()})})};return{promise:o,status:()=>o.status,cancel:c,continue:()=>(r?.(),o),cancelRetry:f,continueRetry:h,canStart:g,start:()=>(g()?x():S().then(x),o)}}var gw=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),vp(this.gcTime)&&(this.#e=pr.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(fl.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e!==void 0&&(pr.clearTimeout(this.#e),this.#e=void 0)}};function MT(e){return{onFetch:(t,i)=>{const r=t.options,o=t.fetchOptions?.meta?.fetchMore?.direction,u=t.state.data?.pages||[],c=t.state.data?.pageParams||[];let f={pages:[],pageParams:[]},h=0;const m=async()=>{let g=!1;const y=x=>{ET(x,()=>t.signal,()=>g=!0)},b=hw(t.options,t.fetchOptions),S=async(x,C,R)=>{if(g)return Promise.reject(t.signal.reason);if(C==null&&x.pages.length)return Promise.resolve(x);const j=(()=>{const W={client:t.client,queryKey:t.queryKey,pageParam:C,direction:R?"backward":"forward",meta:t.options.meta};return y(W),W})(),L=await b(j),{maxPages:V}=t.options,q=R?CT:wT;return{pages:q(x.pages,L,V),pageParams:q(x.pageParams,C,V)}};if(o&&u.length){const x=o==="backward",C=x?OT:zb,R={pages:u,pageParams:c},A=C(r,R);f=await S(R,A,x)}else{const x=e??u.length;do{const C=h===0?c[0]??r.initialPageParam:zb(r,f);if(h>0&&C==null)break;f=await S(f,C),h++}while(ht.options.persister?.(m,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},i):t.fetchFn=m}}}function zb(e,{pages:t,pageParams:i}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,i[r],i):void 0}function OT(e,{pages:t,pageParams:i}){return t.length>0?e.getPreviousPageParam?.(t[0],t,i[0],i):void 0}var DT=class extends gw{#e;#t;#n;#i;#r;#a;#o;#s;constructor(e){super(),this.#s=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#r=e.client,this.#i=this.#r.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=$b(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#a?.promise}setOptions(e){if(this.options={...this.#o,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const t=$b(this.options);t.data!==void 0&&(this.setState(Vb(t.data,t.dataUpdatedAt)),this.#t=t)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#i.remove(this)}setData(e,t){const i=Sp(this.state.data,e,this.options);return this.#l({data:i,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),i}setState(e){this.#l({type:"setState",state:e})}cancel(e){const t=this.#a?.promise;return this.#a?.cancel(e),t?t.then(tn).catch(tn):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>Rn(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===bm||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>za(e.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e==="static"?!1:this.state.isInvalidated?!0:!fw(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(t=>t.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#a?.continue()}onOnline(){this.observers.find(t=>t.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#a?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#i.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#a&&(this.#s||this.#c()?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#i.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}#c(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"}invalidate(){this.state.isInvalidated||this.#l({type:"invalidate"})}async fetch(e,t){if(this.state.fetchStatus!=="idle"&&this.#a?.status()!=="rejected"){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#a)return this.#a.continueRetry(),this.#a.promise}if(e&&this.setOptions(e),!this.options.queryFn){const h=this.observers.find(m=>m.options.queryFn);h&&this.setOptions(h.options)}const i=new AbortController,r=h=>{Object.defineProperty(h,"signal",{enumerable:!0,get:()=>(this.#s=!0,i.signal)})},o=()=>{const h=hw(this.options,t),g=(()=>{const y={client:this.#r,queryKey:this.queryKey,meta:this.meta};return r(y),y})();return this.#s=!1,this.options.persister?this.options.persister(h,g,this):h(g)},c=(()=>{const h={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#r,state:this.state,fetchFn:o};return r(h),h})();(this.#e==="infinite"?MT(this.options.pages):this.options.behavior)?.onFetch(c,this),this.#n=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==c.fetchOptions?.meta)&&this.#l({type:"fetch",meta:c.fetchOptions?.meta}),this.#a=mw({initialPromise:t?.initialPromise,fn:c.fetchFn,onCancel:h=>{h instanceof wp&&h.revert&&this.setState({...this.#n,fetchStatus:"idle"}),i.abort()},onFail:(h,m)=>{this.#l({type:"failed",failureCount:h,error:m})},onPause:()=>{this.#l({type:"pause"})},onContinue:()=>{this.#l({type:"continue"})},retry:c.options.retry,retryDelay:c.options.retryDelay,networkMode:c.options.networkMode,canRun:()=>!0});try{const h=await this.#a.start();if(h===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(h),this.#i.config.onSuccess?.(h,this),this.#i.config.onSettled?.(h,this.state.error,this),h}catch(h){if(h instanceof wp){if(h.silent)return this.#a.promise;if(h.revert){if(this.state.data===void 0)throw h;return this.state.data}}throw this.#l({type:"error",error:h}),this.#i.config.onError?.(h,this),this.#i.config.onSettled?.(this.state.data,h,this),h}finally{this.scheduleGc()}}#l(e){const t=i=>{switch(e.type){case"failed":return{...i,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...i,fetchStatus:"paused"};case"continue":return{...i,fetchStatus:"fetching"};case"fetch":return{...i,...yw(i.data,this.options),fetchMeta:e.meta??null};case"success":const r={...i,...Vb(e.data,e.dataUpdatedAt),dataUpdateCount:i.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#n=e.manual?r:void 0,r;case"error":const o=e.error;return{...i,error:o,errorUpdateCount:i.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:i.fetchFailureCount+1,fetchFailureReason:o,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...i,isInvalidated:!0};case"setState":return{...i,...e.state}}};this.state=t(this.state),Nt.batch(()=>{this.observers.forEach(i=>{i.onQueryUpdate()}),this.#i.notify({query:this,type:"updated",action:e})})}};function yw(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:pw(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function Vb(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function $b(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,i=t!==void 0,r=i?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:i?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:i?"success":"pending",fetchStatus:"idle"}}var jT=class extends $s{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=xp(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#i=void 0;#r;#a;#o;#s;#c;#l;#p;#f;#d;#u;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),Pb(this.#t,this.options)?this.#h():this.updateResult(),this.#b())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Cp(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Cp(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#S(),this.#x(),this.#t.removeObserver(this)}setOptions(e){const t=this.options,i=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Rn(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#w(),this.#t.setOptions(this.options),t._defaulted&&!zc(this.options,t)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const r=this.hasListeners();r&&Ub(this.#t,i,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==i||Rn(this.options.enabled,this.#t)!==Rn(t.enabled,this.#t)||za(this.options.staleTime,this.#t)!==za(t.staleTime,this.#t))&&this.#g();const o=this.#y();r&&(this.#t!==i||Rn(this.options.enabled,this.#t)!==Rn(t.enabled,this.#t)||o!==this.#u)&&this.#v(o)}getOptimisticResult(e){const t=this.#e.getQueryCache().build(this.#e,e),i=this.createResult(t,e);return LT(this,i)&&(this.#i=i,this.#a=this.options,this.#r=this.#t.state),i}getCurrentResult(){return this.#i}trackResult(e,t){return new Proxy(e,{get:(i,r)=>(this.trackProp(r),t?.(r),r==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#o.status==="pending"&&this.#o.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(i,r))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const t=this.#e.defaultQueryOptions(e),i=this.#e.getQueryCache().build(this.#e,t);return i.fetch().then(()=>this.createResult(i,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#i))}#h(e){this.#w();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(tn)),t}#g(){this.#S();const e=za(this.options.staleTime,this.#t);if(fl.isServer()||this.#i.isStale||!vp(e))return;const i=fw(this.#i.dataUpdatedAt,e)+1;this.#f=pr.setTimeout(()=>{this.#i.isStale||this.updateResult()},i)}#y(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#u=e,!(fl.isServer()||Rn(this.options.enabled,this.#t)===!1||!vp(this.#u)||this.#u===0)&&(this.#d=pr.setInterval(()=>{(this.options.refetchIntervalInBackground||ym.isFocused())&&this.#h()},this.#u))}#b(){this.#g(),this.#v(this.#y())}#S(){this.#f!==void 0&&(pr.clearTimeout(this.#f),this.#f=void 0)}#x(){this.#d!==void 0&&(pr.clearInterval(this.#d),this.#d=void 0)}createResult(e,t){const i=this.#t,r=this.options,o=this.#i,u=this.#r,c=this.#a,h=e!==i?e.state:this.#n,{state:m}=e;let g={...m},y=!1,b;if(t._optimisticResults){const T=this.hasListeners(),ne=!T&&Pb(e,t),ee=T&&Ub(e,i,t,r);(ne||ee)&&(g={...g,...yw(m.data,e.options)}),t._optimisticResults==="isRestoring"&&(g.fetchStatus="idle")}let{error:S,errorUpdatedAt:x,status:C}=g;b=g.data;let R=!1;if(t.placeholderData!==void 0&&b===void 0&&C==="pending"){let T;o?.isPlaceholderData&&t.placeholderData===c?.placeholderData?(T=o.data,R=!0):T=typeof t.placeholderData=="function"?t.placeholderData(this.#p?.state.data,this.#p):t.placeholderData,T!==void 0&&(C="success",b=Sp(o?.data,T,t),y=!0)}if(t.select&&b!==void 0&&!R)if(o&&b===u?.data&&t.select===this.#c)b=this.#l;else try{this.#c=t.select,b=t.select(b),b=Sp(o?.data,b,t),this.#l=b,this.#s=null}catch(T){this.#s=T}this.#s&&(S=this.#s,b=this.#l,x=Date.now(),C="error");const A=g.fetchStatus==="fetching",j=C==="pending",L=C==="error",V=j&&A,q=b!==void 0,K={status:C,fetchStatus:g.fetchStatus,isPending:j,isSuccess:C==="success",isError:L,isInitialLoading:V,isLoading:V,data:b,dataUpdatedAt:g.dataUpdatedAt,error:S,errorUpdatedAt:x,failureCount:g.fetchFailureCount,failureReason:g.fetchFailureReason,errorUpdateCount:g.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:g.dataUpdateCount>h.dataUpdateCount||g.errorUpdateCount>h.errorUpdateCount,isFetching:A,isRefetching:A&&!j,isLoadingError:L&&!q,isPaused:g.fetchStatus==="paused",isPlaceholderData:y,isRefetchError:L&&q,isStale:xm(e,t),refetch:this.refetch,promise:this.#o,isEnabled:Rn(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const T=K.data!==void 0,ne=K.status==="error"&&!T,ee=Le=>{ne?Le.reject(K.error):T&&Le.resolve(K.data)},he=()=>{const Le=this.#o=K.promise=xp();ee(Le)},ae=this.#o;switch(ae.status){case"pending":e.queryHash===i.queryHash&&ee(ae);break;case"fulfilled":(ne||K.data!==ae.value)&&he();break;case"rejected":(!ne||K.error!==ae.reason)&&he();break}}return K}updateResult(){const e=this.#i,t=this.createResult(this.#t,this.options);if(this.#r=this.#t.state,this.#a=this.options,this.#r.data!==void 0&&(this.#p=this.#t),zc(t,e))return;this.#i=t;const i=()=>{if(!e)return!0;const{notifyOnChangeProps:r}=this.options,o=typeof r=="function"?r():r;if(o==="all"||!o&&!this.#m.size)return!0;const u=new Set(o??this.#m);return this.options.throwOnError&&u.add("error"),Object.keys(this.#i).some(c=>{const f=c;return this.#i[f]!==e[f]&&u.has(f)})};this.#C({listeners:i()})}#w(){const e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;const t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#b()}#C(e){Nt.batch(()=>{e.listeners&&this.listeners.forEach(t=>{t(this.#i)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function NT(e,t){return Rn(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&Rn(t.retryOnMount,e)===!1)}function Pb(e,t){return NT(e,t)||e.state.data!==void 0&&Cp(e,t,t.refetchOnMount)}function Cp(e,t,i){if(Rn(t.enabled,e)!==!1&&za(t.staleTime,e)!=="static"){const r=typeof i=="function"?i(e):i;return r==="always"||r!==!1&&xm(e,t)}return!1}function Ub(e,t,i,r){return(e!==t||Rn(r.enabled,e)===!1)&&(!i.suspense||e.state.status!=="error")&&xm(e,i)}function xm(e,t){return Rn(t.enabled,e)!==!1&&e.isStaleByTime(za(t.staleTime,e))}function LT(e,t){return!zc(e.getCurrentResult(),t)}var zT=class extends gw{#e;#t;#n;#i;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||vw(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#n.remove(this))}continue(){return this.#i?.continue()??this.execute(this.state.variables)}async execute(e){const t=()=>{this.#r({type:"continue"})},i={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#i=mw({fn:()=>this.options.mutationFn?this.options.mutationFn(e,i):Promise.reject(new Error("No mutationFn found")),onFail:(u,c)=>{this.#r({type:"failed",failureCount:u,error:c})},onPause:()=>{this.#r({type:"pause"})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});const r=this.state.status==="pending",o=!this.#i.canStart();try{if(r)t();else{this.#r({type:"pending",variables:e,isPaused:o}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,i);const c=await this.options.onMutate?.(e,i);c!==this.state.context&&this.#r({type:"pending",context:c,variables:e,isPaused:o})}const u=await this.#i.start();return await this.#n.config.onSuccess?.(u,e,this.state.context,this,i),await this.options.onSuccess?.(u,e,this.state.context,i),await this.#n.config.onSettled?.(u,null,this.state.variables,this.state.context,this,i),await this.options.onSettled?.(u,null,e,this.state.context,i),this.#r({type:"success",data:u}),u}catch(u){try{await this.#n.config.onError?.(u,e,this.state.context,this,i)}catch(c){Promise.reject(c)}try{await this.options.onError?.(u,e,this.state.context,i)}catch(c){Promise.reject(c)}try{await this.#n.config.onSettled?.(void 0,u,this.state.variables,this.state.context,this,i)}catch(c){Promise.reject(c)}try{await this.options.onSettled?.(void 0,u,e,this.state.context,i)}catch(c){Promise.reject(c)}throw this.#r({type:"error",error:u}),u}finally{this.#n.runNext(this)}}#r(e){const t=i=>{switch(e.type){case"failed":return{...i,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...i,isPaused:!0};case"continue":return{...i,isPaused:!1};case"pending":return{...i,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...i,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...i,data:void 0,error:e.error,failureCount:i.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=t(this.state),Nt.batch(()=>{this.#t.forEach(i=>{i.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:"updated",action:e})})}};function vw(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var VT=class extends $s{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,i){const r=new zT({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:i});return this.add(r),r}add(e){this.#e.add(e);const t=tc(e);if(typeof t=="string"){const i=this.#t.get(t);i?i.push(e):this.#t.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#e.delete(e)){const t=tc(e);if(typeof t=="string"){const i=this.#t.get(t);if(i)if(i.length>1){const r=i.indexOf(e);r!==-1&&i.splice(r,1)}else i[0]===e&&this.#t.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){const t=tc(e);if(typeof t=="string"){const r=this.#t.get(t)?.find(o=>o.state.status==="pending");return!r||r===e}else return!0}runNext(e){const t=tc(e);return typeof t=="string"?this.#t.get(t)?.find(r=>r!==e&&r.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){Nt.batch(()=>{this.#e.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){const t={exact:!0,...e};return this.getAll().find(i=>jb(t,i))}findAll(e={}){return this.getAll().filter(t=>jb(e,t))}notify(e){Nt.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){const e=this.getAll().filter(t=>t.state.isPaused);return Nt.batch(()=>Promise.all(e.map(t=>t.continue().catch(tn))))}};function tc(e){return e.options.scope?.id}var $T=class extends $s{#e;#t=void 0;#n;#i;constructor(t,i){super(),this.#e=t,this.setOptions(i),this.bindMethods(),this.#r()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){const i=this.options;this.options=this.#e.defaultMutationOptions(t),zc(this.options,i)||this.#e.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#n,observer:this}),i?.mutationKey&&this.options.mutationKey&&Cr(i.mutationKey)!==Cr(this.options.mutationKey)?this.reset():this.#n?.state.status==="pending"&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(t){this.#r(),this.#a(t)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#r(),this.#a()}mutate(t,i){return this.#i=i,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(t)}#r(){const t=this.#n?.state??vw();this.#t={...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset}}#a(t){Nt.batch(()=>{if(this.#i&&this.hasListeners()){const i=this.#t.variables,r=this.#t.context,o={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(t?.type==="success"){try{this.#i.onSuccess?.(t.data,i,r,o)}catch(u){Promise.reject(u)}try{this.#i.onSettled?.(t.data,null,i,r,o)}catch(u){Promise.reject(u)}}else if(t?.type==="error"){try{this.#i.onError?.(t.error,i,r,o)}catch(u){Promise.reject(u)}try{this.#i.onSettled?.(void 0,t.error,i,r,o)}catch(u){Promise.reject(u)}}}this.listeners.forEach(i=>{i(this.#t)})})}},PT=class extends $s{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,i){const r=t.queryKey,o=t.queryHash??vm(r,t);let u=this.get(o);return u||(u=new DT({client:e,queryKey:r,queryHash:o,options:e.defaultQueryOptions(t),state:i,defaultOptions:e.getQueryDefaults(r)}),this.add(u)),u}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){Nt.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){const t={exact:!0,...e};return this.getAll().find(i=>Db(t,i))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(i=>Db(e,i)):t}notify(e){Nt.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){Nt.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){Nt.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},UT=class{#e;#t;#n;#i;#r;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new PT,this.#t=e.mutationCache||new VT,this.#n=e.defaultOptions||{},this.#i=new Map,this.#r=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=ym.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=Vc.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#t.findAll({...e,status:"pending"}).length}getQueryData(e){const t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),i=this.#e.build(this,t),r=i.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&i.isStaleByTime(za(t.staleTime,i))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:t,state:i})=>{const r=i.data;return[t,r]})}setQueryData(e,t,i){const r=this.defaultQueryOptions({queryKey:e}),u=this.#e.get(r.queryHash)?.state.data,c=bT(t,u);if(c!==void 0)return this.#e.build(this,r).setData(c,{...i,manual:!0})}setQueriesData(e,t,i){return Nt.batch(()=>this.#e.findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,i)]))}getQueryState(e){const t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){const t=this.#e;Nt.batch(()=>{t.findAll(e).forEach(i=>{t.remove(i)})})}resetQueries(e,t){const i=this.#e;return Nt.batch(()=>(i.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const i={revert:!0,...t},r=Nt.batch(()=>this.#e.findAll(e).map(o=>o.cancel(i)));return Promise.all(r).then(tn).catch(tn)}invalidateQueries(e,t={}){return Nt.batch(()=>(this.#e.findAll(e).forEach(i=>{i.invalidate()}),e?.refetchType==="none"?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t)))}refetchQueries(e,t={}){const i={...t,cancelRefetch:t.cancelRefetch??!0},r=Nt.batch(()=>this.#e.findAll(e).filter(o=>!o.isDisabled()&&!o.isStatic()).map(o=>{let u=o.fetch(void 0,i);return i.throwOnError||(u=u.catch(tn)),o.state.fetchStatus==="paused"?Promise.resolve():u}));return Promise.all(r).then(tn)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const i=this.#e.build(this,t);return i.isStaleByTime(za(t.staleTime,i))?i.fetch(t):Promise.resolve(i.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(tn).catch(tn)}fetchInfiniteQuery(e){return e._type="infinite",this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(tn).catch(tn)}ensureInfiniteQueryData(e){return e._type="infinite",this.ensureQueryData(e)}resumePausedMutations(){return Vc.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#i.set(Cr(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...this.#i.values()],i={};return t.forEach(r=>{cl(e,r.queryKey)&&Object.assign(i,r.defaultOptions)}),i}setMutationDefaults(e,t){this.#r.set(Cr(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...this.#r.values()],i={};return t.forEach(r=>{cl(e,r.mutationKey)&&Object.assign(i,r.defaultOptions)}),i}defaultQueryOptions(e){if(e._defaulted)return e;const t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=vm(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===bm&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},bw=_.createContext(void 0),wm=e=>{const t=_.useContext(bw);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},BT=({client:e,children:t})=>(_.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),E.jsx(bw.Provider,{value:e,children:t})),Sw=_.createContext(!1),HT=()=>_.useContext(Sw);Sw.Provider;function FT(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var kT=_.createContext(FT()),qT=()=>_.useContext(kT),GT=(e,t,i)=>{const r=i?.state.error&&typeof e.throwOnError=="function"?Sm(e.throwOnError,[i.state.error,i]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},IT=e=>{_.useEffect(()=>{e.clearReset()},[e])},YT=({result:e,errorResetBoundary:t,throwOnError:i,query:r,suspense:o})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(o&&e.data===void 0||Sm(i,[e.error,r])),KT=e=>{if(e.suspense){const i=o=>o==="static"?o:Math.max(o??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...o)=>i(r(...o)):i(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},QT=(e,t)=>e.isLoading&&e.isFetching&&!t,XT=(e,t)=>e?.suspense&&t.isPending,Bb=(e,t,i)=>t.fetchOptimistic(e).catch(()=>{i.clearReset()});function ZT(e,t,i){const r=HT(),o=qT(),u=wm(),c=u.defaultQueryOptions(e);u.getDefaultOptions().queries?._experimental_beforeQuery?.(c);const f=u.getQueryCache().get(c.queryHash),h=e.subscribed!==!1;c._optimisticResults=r?"isRestoring":h?"optimistic":void 0,KT(c),GT(c,o,f),IT(o);const m=!u.getQueryCache().get(c.queryHash),[g]=_.useState(()=>new t(u,c)),y=g.getOptimisticResult(c),b=!r&&h;if(_.useSyncExternalStore(_.useCallback(S=>{const x=b?g.subscribe(Nt.batchCalls(S)):tn;return g.updateResult(),x},[g,b]),()=>g.getCurrentResult(),()=>g.getCurrentResult()),_.useEffect(()=>{g.setOptions(c)},[c,g]),XT(c,y))throw Bb(c,g,o);if(YT({result:y,errorResetBoundary:o,throwOnError:c.throwOnError,query:f,suspense:c.suspense}))throw y.error;return u.getDefaultOptions().queries?._experimental_afterQuery?.(c,y),c.experimental_prefetchInRender&&!fl.isServer()&&QT(y,r)&&(m?Bb(c,g,o):f?.promise)?.catch(tn).finally(()=>{g.updateResult()}),c.notifyOnChangeProps?y:g.trackResult(y)}function nn(e,t){return ZT(e,jT)}function Hb(e,t){const i=wm(),[r]=_.useState(()=>new $T(i,e));_.useEffect(()=>{r.setOptions(e)},[r,e]);const o=_.useSyncExternalStore(_.useCallback(c=>r.subscribe(Nt.batchCalls(c)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),u=_.useCallback((c,f)=>{r.mutate(c,f).catch(tn)},[r]);if(o.error&&Sm(r.options.throwOnError,[o.error]))throw o.error;return{...o,mutate:u,mutateAsync:o.mutate}}var xw=e=>{throw TypeError(e)},ww=(e,t,i)=>t.has(e)||xw("Cannot "+i),Bn=(e,t,i)=>(ww(e,t,"read from private field"),i?i.call(e):t.get(e)),Xo=(e,t,i)=>t.has(e)?xw("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,i),mi=(e,t,i,r)=>(ww(e,t,"write to private field"),t.set(e,i),i),Fb="popstate";function kb(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function JT(e={}){function t(r,o){let u=o.state?.masked,{pathname:c,search:f,hash:h}=u||r.location;return dl("",{pathname:c,search:f,hash:h},o.state&&o.state.usr||null,o.state&&o.state.key||"default",u?{pathname:r.location.pathname,search:r.location.search,hash:r.location.hash}:void 0)}function i(r,o){return typeof o=="string"?o:Si(o)}return eA(t,i,null,e)}function Ne(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function xt(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function WT(){return Math.random().toString(36).substring(2,10)}function qb(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function dl(e,t,i=null,r,o){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?wi(t):t,state:i,key:t&&t.key||r||WT(),mask:o}}function Si({pathname:e="/",search:t="",hash:i=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),i&&i!=="#"&&(e+=i.charAt(0)==="#"?i:"#"+i),e}function wi(e){let t={};if(e){let i=e.indexOf("#");i>=0&&(t.hash=e.substring(i),e=e.substring(0,i));let r=e.indexOf("?");r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function eA(e,t,i,r={}){let{window:o=document.defaultView,v5Compat:u=!1}=r,c=o.history,f="POP",h=null,m=g();m==null&&(m=0,c.replaceState({...c.state,idx:m},""));function g(){return(c.state||{idx:null}).idx}function y(){f="POP";let R=g(),A=R==null?null:R-m;m=R,h&&h({action:f,location:C.location,delta:A})}function b(R,A){f="PUSH";let j=kb(R)?R:dl(C.location,R,A);m=g()+1;let L=qb(j,m),V=C.createHref(j.mask||j);try{c.pushState(L,"",V)}catch(q){if(q instanceof DOMException&&q.name==="DataCloneError")throw q;o.location.assign(V)}u&&h&&h({action:f,location:C.location,delta:1})}function S(R,A){f="REPLACE";let j=kb(R)?R:dl(C.location,R,A);m=g();let L=qb(j,m),V=C.createHref(j.mask||j);c.replaceState(L,"",V),u&&h&&h({action:f,location:C.location,delta:0})}function x(R){return Cw(R)}let C={get action(){return f},get location(){return e(o,c)},listen(R){if(h)throw new Error("A history only accepts one active listener");return o.addEventListener(Fb,y),h=R,()=>{o.removeEventListener(Fb,y),h=null}},createHref(R){return t(o,R)},createURL:x,encodeLocation(R){let A=x(R);return{pathname:A.pathname,search:A.search,hash:A.hash}},push:b,replace:S,go(R){return c.go(R)}};return C}function Cw(e,t=!1){let i="http://localhost";typeof window<"u"&&(i=window.location.origin!=="null"?window.location.origin:window.location.href),Ne(i,"No window.location.(origin|href) available to create URL");let r=typeof e=="string"?e:Si(e);return r=r.replace(/ $/,"%20"),!t&&r.startsWith("//")&&(r=i+r),new URL(r,i)}var Zo,Gb=class{constructor(e){if(Xo(this,Zo,new Map),e)for(let[t,i]of e)this.set(t,i)}get(e){if(Bn(this,Zo).has(e))return Bn(this,Zo).get(e);if(e.defaultValue!==void 0)return e.defaultValue;throw new Error("No value found for context")}set(e,t){Bn(this,Zo).set(e,t)}};Zo=new WeakMap;var tA=new Set(["lazy","caseSensitive","path","id","index","children"]);function nA(e){return tA.has(e)}var iA=new Set(["lazy","caseSensitive","path","id","index","middleware","children"]);function aA(e){return iA.has(e)}function rA(e){return e.index===!0}function hl(e,t,i=[],r={},o=!1){return e.map((u,c)=>{let f=[...i,String(c)],h=typeof u.id=="string"?u.id:f.join("-");if(Ne(u.index!==!0||!u.children,"Cannot specify children on an index route"),Ne(o||!r[h],`Found a route id collision on id "${h}". Route id's must be globally unique within Data Router usages`),rA(u)){let m={...u,id:h};return r[h]=Ib(m,t(m)),m}else{let m={...u,id:h,children:void 0};return r[h]=Ib(m,t(m)),u.children&&(m.children=hl(u.children,t,f,r,o)),m}})}function Ib(e,t){return Object.assign(e,{...t,...typeof t.lazy=="object"&&t.lazy!=null?{lazy:{...e.lazy,...t.lazy}}:{}})}function Ew(e,t,i="/"){return ai(e,t,i,!1)}function ai(e,t,i,r,o){let u=typeof t=="string"?wi(t):t,c=Yn(u.pathname||"/",i);if(c==null)return null;let f=o??vc(e),h=null,m=vA(c);for(let g=0;h==null&&g{let g={relativePath:m===void 0?c.path||"":m,caseSensitive:c.caseSensitive===!0,childrenIndex:f,route:c};if(g.relativePath.startsWith("/")){if(!g.relativePath.startsWith(r)&&h)return;Ne(g.relativePath.startsWith(r),`Absolute route path "${g.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),g.relativePath=g.relativePath.slice(r.length)}let y=kn([r,g.relativePath]),b=i.concat(g);c.children&&c.children.length>0&&(Ne(c.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${y}".`),Rw(c.children,t,b,y,h)),!(c.path==null&&!c.index)&&t.push({path:y,score:pA(y,c.index),routesMeta:b})};return e.forEach((c,f)=>{if(c.path===""||!c.path?.includes("?"))u(c,f);else for(let h of _w(c.path))u(c,f,!0,h)}),t}function _w(e){let t=e.split("/");if(t.length===0)return[];let[i,...r]=t,o=i.endsWith("?"),u=i.replace(/\?$/,"");if(r.length===0)return o?[u,""]:[u];let c=_w(r.join("/")),f=[];return f.push(...c.map(h=>h===""?u:[u,h].join("/"))),o&&f.push(...c),f.map(h=>e.startsWith("/")&&h===""?"/":h)}function oA(e){e.sort((t,i)=>t.score!==i.score?i.score-t.score:mA(t.routesMeta.map(r=>r.childrenIndex),i.routesMeta.map(r=>r.childrenIndex)))}var lA=/^:[\w-]+$/,uA=3,cA=2,fA=1,dA=10,hA=-2,Yb=e=>e==="*";function pA(e,t){let i=e.split("/"),r=i.length;return i.some(Yb)&&(r+=hA),t&&(r+=cA),i.filter(o=>!Yb(o)).reduce((o,u)=>o+(lA.test(u)?uA:u===""?fA:dA),r)}function mA(e,t){return e.length===t.length&&e.slice(0,-1).every((r,o)=>r===t[o])?e[e.length-1]-t[t.length-1]:0}function gA(e,t,i=!1){let{routesMeta:r}=e,o={},u="/",c=[];for(let f=0;f{if(g==="*"){let x=f[b]||"";c=u.slice(0,u.length-x.length).replace(/(.)\/+$/,"$1")}const S=f[b];return y&&!S?m[g]=void 0:m[g]=(S||"").replace(/%2F/g,"/"),m},{}),pathname:u,pathnameBase:c,pattern:e}}function yA(e,t=!1,i=!0){xt(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 r=[],o="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(c,f,h,m,g)=>{if(r.push({paramName:f,isOptional:h!=null}),h){let y=g.charAt(m+c.length);return y&&y!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(r.push({paramName:"*"}),o+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):i?o+="\\/*$":e!==""&&e!=="/"&&(o+="(?:(?=\\/|$))"),[new RegExp(o,t?void 0:"i"),r]}function vA(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return xt(!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 Yn(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let i=t.endsWith("/")?t.length-1:t.length,r=e.charAt(i);return r&&r!=="/"?null:e.slice(i)||"/"}function bA({basename:e,pathname:t}){return t==="/"?e:kn([e,t])}var Tw=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Cm=e=>Tw.test(e);function SA(e,t="/"){let{pathname:i,search:r="",hash:o=""}=typeof e=="string"?wi(e):e,u;return i?(i=Em(i),i.startsWith("/")?u=Kb(i.substring(1),"/"):u=Kb(i,t)):u=t,{pathname:u,search:wA(r),hash:CA(o)}}function Kb(e,t){let i=Pc(t).split("/");return e.split("/").forEach(o=>{o===".."?i.length>1&&i.pop():o!=="."&&i.push(o)}),i.length>1?i.join("/"):"/"}function Ph(e,t,i,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${i}\` field. Alternatively you may provide the full path as a string in and the router will parse it for you.`}function Aw(e){return e.filter((t,i)=>i===0||t.route.path&&t.route.path.length>0)}function ef(e){let t=Aw(e);return t.map((i,r)=>r===t.length-1?i.pathname:i.pathnameBase)}function El(e,t,i,r=!1){let o;typeof e=="string"?o=wi(e):(o={...e},Ne(!o.pathname||!o.pathname.includes("?"),Ph("?","pathname","search",o)),Ne(!o.pathname||!o.pathname.includes("#"),Ph("#","pathname","hash",o)),Ne(!o.search||!o.search.includes("#"),Ph("#","search","hash",o)));let u=e===""||o.pathname==="",c=u?"/":o.pathname,f;if(c==null)f=i;else{let y=t.length-1;if(!r&&c.startsWith("..")){let b=c.split("/");for(;b[0]==="..";)b.shift(),y-=1;o.pathname=b.join("/")}f=y>=0?t[y]:"/"}let h=SA(o,f),m=c&&c!=="/"&&c.endsWith("/"),g=(u||c===".")&&i.endsWith("/");return!h.pathname.endsWith("/")&&(m||g)&&(h.pathname+="/"),h}var Em=e=>e.replace(/\/\/+/g,"/"),kn=e=>Em(e.join("/")),Pc=e=>e.replace(/\/+$/,""),xA=e=>Pc(e).replace(/^\/*/,"/"),wA=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,CA=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,Rl=class{constructor(e,t,i,r=!1){this.status=e,this.statusText=t||"",this.internal=r,i instanceof Error?(this.data=i.toString(),this.error=i):this.data=i}};function pl(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function _l(e){let t=e.map(i=>i.route.path).filter(Boolean);return kn(t)||"/"}var Mw=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Ow(e,t){let i=e;if(typeof i!="string"||!Tw.test(i))return{absoluteURL:void 0,isExternal:!1,to:i};let r=i,o=!1;if(Mw)try{let u=new URL(window.location.href),c=i.startsWith("//")?new URL(u.protocol+i):new URL(i),f=Yn(c.pathname,t);c.origin===u.origin&&f!=null?i=f+c.search+c.hash:o=!0}catch{xt(!1,` contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:o,to:i}}var ja=Symbol("Uninstrumented");function EA(e,t){let i={lazy:[],"lazy.loader":[],"lazy.action":[],"lazy.middleware":[],middleware:[],loader:[],action:[]};e.forEach(o=>o({id:t.id,index:t.index,path:t.path,instrument(u){let c=Object.keys(i);for(let f of c)u[f]&&i[f].push(u[f])}}));let r={};if(typeof t.lazy=="function"&&i.lazy.length>0){let o=ws(i.lazy,t.lazy,()=>{});o&&(r.lazy=o)}if(typeof t.lazy=="object"){let o=t.lazy;["middleware","loader","action"].forEach(u=>{let c=o[u],f=i[`lazy.${u}`];if(typeof c=="function"&&f.length>0){let h=ws(f,c,()=>{});h&&(r.lazy=Object.assign(r.lazy||{},{[u]:h}))}})}return["loader","action"].forEach(o=>{let u=t[o];if(typeof u=="function"&&i[o].length>0){let c=u[ja]??u,f=ws(i[o],c,(...h)=>Qb(h[0]));f&&(o==="loader"&&c.hydrate===!0&&(f.hydrate=!0),f[ja]=c,r[o]=f)}}),t.middleware&&t.middleware.length>0&&i.middleware.length>0&&(r.middleware=t.middleware.map(o=>{let u=o[ja]??o,c=ws(i.middleware,u,(...f)=>Qb(f[0]));return c?(c[ja]=u,c):o})),r}function RA(e,t){let i={navigate:[],fetch:[]};if(t.forEach(r=>r({instrument(o){let u=Object.keys(o);for(let c of u)o[c]&&i[c].push(o[c])}})),i.navigate.length>0){let r=e.navigate[ja]??e.navigate,o=ws(i.navigate,r,(...u)=>{let[c,f]=u;return{to:typeof c=="number"||typeof c=="string"?c:c?Si(c):".",...Xb(e,f??{})}});o&&(o[ja]=r,e.navigate=o)}if(i.fetch.length>0){let r=e.fetch[ja]??e.fetch,o=ws(i.fetch,r,(...u)=>{let[c,,f,h]=u;return{href:f??".",fetcherKey:c,...Xb(e,h??{})}});o&&(o[ja]=r,e.fetch=o)}return e}function ws(e,t,i){return e.length===0?null:async(...r)=>{let o=await Dw(e,i(...r),()=>t(...r),e.length-1);if(o.type==="error")throw o.value;return o.value}}async function Dw(e,t,i,r){let o=e[r],u;if(o){let c,f=async()=>(c?console.error("You cannot call instrumented handlers more than once"):c=Dw(e,t,i,r-1),u=await c,Ne(u,"Expected a result"),u.type==="error"&&u.value instanceof Error?{status:"error",error:u.value}:{status:"success",error:void 0});try{await o(f,t)}catch(h){console.error("An instrumentation function threw an error:",h)}c||await f(),await c}else try{u={type:"success",value:await i()}}catch(c){u={type:"error",value:c}}return u||{type:"error",value:new Error("No result assigned in instrumentation chain.")}}function Qb(e){let{request:t,context:i,params:r,pattern:o}=e;return{request:_A(t),params:{...r},pattern:o,context:TA(i)}}function Xb(e,t){return{currentUrl:Si(e.state.location),..."formMethod"in t?{formMethod:t.formMethod}:{},..."formEncType"in t?{formEncType:t.formEncType}:{},..."formData"in t?{formData:t.formData}:{},..."body"in t?{body:t.body}:{}}}function _A(e){return{method:e.method,url:e.url,headers:{get:(...t)=>e.headers.get(...t)}}}function TA(e){if(MA(e)){let t={...e};return Object.freeze(t),t}else return{get:t=>e.get(t)}}var AA=Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function MA(e){if(e===null||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null||Object.getOwnPropertyNames(t).sort().join("\0")===AA}var jw=["POST","PUT","PATCH","DELETE"],OA=new Set(jw),DA=["GET",...jw],jA=new Set(DA),Nw=new Set([301,302,303,307,308]),NA=new Set([307,308]),Uh={state:"idle",location:void 0,matches:void 0,historyAction:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},LA={state:"idle",data:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},qo={state:"unblocked",proceed:void 0,reset:void 0,location:void 0},zA=e=>({hasErrorBoundary:!!e.hasErrorBoundary}),Lw="remix-router-transitions",zw=Symbol("ResetLoaderData"),fr,ys,Aa,vs,VA=class{constructor(e){Xo(this,fr),Xo(this,ys),Xo(this,Aa),Xo(this,vs),mi(this,fr,e),mi(this,ys,vc(e))}get stableRoutes(){return Bn(this,fr)}get activeRoutes(){return Bn(this,Aa)??Bn(this,fr)}get branches(){return Bn(this,vs)??Bn(this,ys)}get hasHMRRoutes(){return Bn(this,Aa)!=null}setRoutes(e){mi(this,fr,e),mi(this,ys,vc(e))}setHmrRoutes(e){mi(this,Aa,e),mi(this,vs,vc(e))}commitHmrRoutes(){Bn(this,Aa)&&(mi(this,fr,Bn(this,Aa)),mi(this,ys,Bn(this,vs)),mi(this,Aa,void 0),mi(this,vs,void 0))}};fr=new WeakMap;ys=new WeakMap;Aa=new WeakMap;vs=new WeakMap;function $A(e){const t=e.window?e.window:typeof window<"u"?window:void 0,i=typeof t<"u"&&typeof t.document<"u"&&typeof t.document.createElement<"u";Ne(e.routes.length>0,"You must provide a non-empty routes array to createRouter");let r=e.hydrationRouteProperties||[],o=e.mapRouteProperties||zA,u=o;if(e.instrumentations){let O=e.instrumentations;u=z=>({...o(z),...EA(O.map(H=>H.route).filter(Boolean),z)})}let c={},f=new VA(hl(e.routes,u,void 0,c)),h=e.basename||"/";h.startsWith("/")||(h=`/${h}`);let m=e.dataStrategy||FA,g={...e.future},y=null,b=new Set,S=null,x=null,C=null,R=null,A=e.hydrationData!=null,j=ai(f.activeRoutes,e.history.location,h,!1,f.branches),L=!1,V=null,q,W;if(j==null&&!e.patchRoutesOnNavigation){let O=Hn(404,{pathname:e.history.location.pathname}),{matches:z,route:H}=nc(f.activeRoutes);q=!0,W=!q,j=z,V={[H.id]:O}}else if(j&&!e.hydrationData&&ia(j,f.activeRoutes,e.history.location.pathname).active&&(j=null),j)if(j.some(O=>O.route.lazy))q=!1,W=!q;else if(!j.some(O=>Rm(O.route)))q=!0,W=!q;else{let O=e.hydrationData?e.hydrationData.loaderData:null,z=e.hydrationData?e.hydrationData.errors:null,H=j;if(z){let X=j.findIndex(Z=>z[Z.route.id]!==void 0);H=H.slice(0,X+1)}W=!1,q=!0,H.forEach(X=>{let Z=Vw(X.route,O,z);W=W||Z.renderFallback,q=q&&!Z.shouldLoad})}else{q=!1,W=!q,j=[];let O=ia(null,f.activeRoutes,e.history.location.pathname);O.active&&O.matches&&(L=!0,j=O.matches)}let K,T={historyAction:e.history.action,location:e.history.location,matches:j,initialized:q,renderFallback:W,navigation:Uh,restoreScrollPosition:e.hydrationData!=null?!1:null,preventScrollReset:!1,revalidation:"idle",loaderData:e.hydrationData&&e.hydrationData.loaderData||{},actionData:e.hydrationData&&e.hydrationData.actionData||null,errors:e.hydrationData&&e.hydrationData.errors||V,fetchers:new Map,blockers:new Map},ne="POP",ee=null,he=!1,ae,Le=!1,Re=new Map,je=null,P=!1,J=!1,ie=new Set,oe=new Map,ye=0,D=-1,I=new Map,te=new Set,re=new Map,me=new Map,Se=new Set,ze=new Map,wt,it=null;function qa(){if(y=e.history.listen(({action:O,location:z,delta:H})=>{if(wt){wt(),wt=void 0;return}xt(ze.size===0||H!=null,"You are trying to use a blocker on a POP navigation to a location that was not created by @remix-run/router. This will fail silently in production. This can happen if you are navigating outside the router via `window.history.pushState`/`window.location.hash` instead of using router navigation APIs. This can also happen if you are using createHashRouter and the user manually changes the URL.");let X=Ia({currentLocation:T.location,nextLocation:z,historyAction:O});if(X&&H!=null){let Z=new Promise(ce=>{wt=ce});e.history.go(H*-1),Ti(X,{state:"blocked",location:z,proceed(){Ti(X,{state:"proceeding",proceed:void 0,reset:void 0,location:z}),Z.then(()=>e.history.go(H))},reset(){let ce=new Map(T.blockers);ce.set(X,qo),Ot({blockers:ce})}}),ee?.resolve(),ee=null;return}return Ei(O,z)}),i){sM(t,Re);let O=()=>oM(t,Re);t.addEventListener("pagehide",O),je=()=>t.removeEventListener("pagehide",O)}return T.initialized||Ei("POP",T.location,{initialHydration:!0}),K}function Ar(){y&&y(),je&&je(),b.clear(),ae&&ae.abort(),T.fetchers.forEach((O,z)=>_i(T.fetchers,z)),T.blockers.forEach((O,z)=>Ga(z))}function Ys(O){if(b.add(O),S){let{newErrors:z}=S;S=null,O(T,{deletedFetchers:[],newErrors:z,viewTransitionOpts:void 0,flushSync:!1})}return()=>b.delete(O)}function Ot(O,z={}){O.matches&&(O.matches=O.matches.map(Z=>{let ce=c[Z.route.id],se=Z.route;return se.element!==ce.element||se.errorElement!==ce.errorElement||se.hydrateFallbackElement!==ce.hydrateFallbackElement?{...Z,route:ce}:Z})),T={...T,...O};let H=[],X=[];T.fetchers.forEach((Z,ce)=>{Z.state==="idle"&&(Se.has(ce)?H.push(ce):X.push(ce))}),Se.forEach(Z=>{!T.fetchers.has(Z)&&!oe.has(Z)&&H.push(Z)}),b.size===0&&(S={newErrors:O.errors??null}),[...b].forEach(Z=>Z(T,{deletedFetchers:H,newErrors:O.errors??null,viewTransitionOpts:z.viewTransitionOpts,flushSync:z.flushSync===!0})),H.forEach(Z=>_i(T.fetchers,Z)),X.forEach(Z=>T.fetchers.delete(Z))}function on(O,z,{flushSync:H}={}){let X=T.actionData!=null&&T.navigation.formMethod!=null&&Yt(T.navigation.formMethod)&&T.navigation.state==="loading"&&O.state?._isRedirect!==!0,Z;z.actionData?Object.keys(z.actionData).length>0?Z=z.actionData:Z=null:X?Z=T.actionData:Z=null;let ce=z.loaderData?oS(T.loaderData,z.loaderData,z.matches||[],z.errors):T.loaderData,se=T.blockers;se.size>0&&(se=new Map(se),se.forEach((be,Me)=>se.set(Me,qo)));let ue=P?!1:Js(O,z.matches||T.matches),le=he===!0||T.navigation.formMethod!=null&&Yt(T.navigation.formMethod)&&O.state?._isRedirect!==!0;f.commitHmrRoutes(),P||ne==="POP"||(ne==="PUSH"?e.history.push(O,O.state):ne==="REPLACE"&&e.history.replace(O,O.state));let ve;if(ne==="POP"){let be=Re.get(T.location.pathname);be&&be.has(O.pathname)?ve={currentLocation:T.location,nextLocation:O}:Re.has(O.pathname)&&(ve={currentLocation:O,nextLocation:T.location})}else if(Le){let be=Re.get(T.location.pathname);be?be.add(O.pathname):(be=new Set([O.pathname]),Re.set(T.location.pathname,be)),ve={currentLocation:T.location,nextLocation:O}}Ot({...z,actionData:Z,loaderData:ce,historyAction:ne,location:O,initialized:!0,renderFallback:!1,navigation:Uh,revalidation:"idle",restoreScrollPosition:ue,preventScrollReset:le,blockers:se},{viewTransitionOpts:ve,flushSync:H===!0}),ne="POP",he=!1,Le=!1,P=!1,J=!1,ee?.resolve(),ee=null,it?.resolve(),it=null}async function Mr(O,z){if(ee?.resolve(),ee=null,typeof O=="number"){ee||(ee=fS());let Ie=ee.promise;return e.history.go(O),Ie}let H=Ep(T.location,T.matches,h,O,z?.fromRouteId,z?.relative),{path:X,submission:Z,error:ce}=Zb(!1,H,z),se;z?.mask&&(se={pathname:"",search:"",hash:"",...typeof z.mask=="string"?wi(z.mask):{...T.location.mask,...z.mask}});let ue=T.location,le=dl(ue,X,z&&z.state,void 0,se);le={...le,...e.history.encodeLocation(le)};let ve=z&&z.replace!=null?z.replace:void 0,be="PUSH";ve===!0?be="REPLACE":ve===!1||Z!=null&&Yt(Z.formMethod)&&Z.formAction===T.location.pathname+T.location.search&&(be="REPLACE");let Me=z&&"preventScrollReset"in z?z.preventScrollReset===!0:void 0,we=(z&&z.flushSync)===!0,Ve=Ia({currentLocation:ue,nextLocation:le,historyAction:be});if(Ve){Ti(Ve,{state:"blocked",location:le,proceed(){Ti(Ve,{state:"proceeding",proceed:void 0,reset:void 0,location:le}),Mr(O,z)},reset(){let Ie=new Map(T.blockers);Ie.set(Ve,qo),Ot({blockers:Ie})}});return}await Ei(be,le,{submission:Z,pendingError:ce,preventScrollReset:Me,replace:z&&z.replace,enableViewTransition:z&&z.viewTransition,flushSync:we,callSiteDefaultShouldRevalidate:z&&z.defaultShouldRevalidate})}function Ks(){it||(it=fS()),ta(),Ot({revalidation:"loading"});let O=it.promise;return T.navigation.state==="submitting"?O:T.navigation.state==="idle"?(Ei(T.historyAction,T.location,{startUninterruptedRevalidation:!0}),O):(Ei(ne||T.historyAction,T.navigation.location,{overrideNavigation:T.navigation,enableViewTransition:Le===!0}),O)}async function Ei(O,z,H){ae&&ae.abort(),ae=null,ne=O,P=(H&&H.startUninterruptedRevalidation)===!0,_f(T.location,T.matches),he=(H&&H.preventScrollReset)===!0,Le=(H&&H.enableViewTransition)===!0;let X=f.activeRoutes,Z=H?.initialHydration&&T.matches&&T.matches.length>0&&!L?T.matches:ai(X,z,h,!1,f.branches),ce=(H&&H.flushSync)===!0;if(Z&&T.initialized&&!J&&XA(T.location,z)&&!(H&&H.submission&&Yt(H.submission.formMethod))){on(z,{matches:Z},{flushSync:ce});return}let se=ia(Z,X,z.pathname);if(se.active&&se.matches&&(Z=se.matches),!Z){let{error:Xe,notFoundMatches:qe,route:vt}=Xn(z.pathname);on(z,{matches:qe,loaderData:{},errors:{[vt.id]:Xe}},{flushSync:ce});return}let ue=H&&H.overrideNavigation?{...H.overrideNavigation,matches:Z,historyAction:O}:void 0;ae=new AbortController;let le=bs(e.history,z,ae.signal,H&&H.submission),ve=e.getContext?await e.getContext():new Gb,be;if(H&&H.pendingError)be=[Ma(Z).route.id,{type:"error",error:H.pendingError}];else if(H&&H.submission&&Yt(H.submission.formMethod)){let Xe=await Bl(le,z,H.submission,Z,O,ve,se.active,H&&H.initialHydration===!0,{replace:H.replace,flushSync:ce});if(Xe.shortCircuited)return;if(Xe.pendingActionResult){let[qe,vt]=Xe.pendingActionResult;if(_n(vt)&&pl(vt.error)&&vt.error.status===404){ae=null,on(z,{matches:Xe.matches,loaderData:{},errors:{[qe]:vt.error}});return}}Z=Xe.matches||Z,be=Xe.pendingActionResult,ue=Bh(z,Z,O,H.submission),ce=!1,se.active=!1,le=bs(e.history,le.url,le.signal)}let{shortCircuited:Me,matches:we,loaderData:Ve,errors:Ie,workingFetchers:ut}=await Qs(le,z,Z,O,ve,se.active,ue,H&&H.submission,H&&H.fetcherSubmission,H&&H.replace,H&&H.initialHydration===!0,ce,be,H&&H.callSiteDefaultShouldRevalidate);Me||(ae=null,on(z,{matches:we||Z,...lS(be),loaderData:Ve,errors:Ie,...ut?{fetchers:ut}:{}}))}async function Bl(O,z,H,X,Z,ce,se,ue,le={}){ta();let ve=aM(z,X,Z,H);if(Ot({navigation:ve},{flushSync:le.flushSync===!0}),se){let we=await ci(X,z.pathname,O.signal);if(we.type==="aborted")return{shortCircuited:!0};if(we.type==="error"){if(we.partialMatches.length===0){let{matches:Ie,route:ut}=nc(f.activeRoutes);return{matches:Ie,pendingActionResult:[ut.id,{type:"error",error:we.error}]}}let Ve=Ma(we.partialMatches).route.id;return{matches:we.partialMatches,pendingActionResult:[Ve,{type:"error",error:we.error}]}}else if(we.matches)X=we.matches;else{let{notFoundMatches:Ve,error:Ie,route:ut}=Xn(z.pathname);return{matches:Ve,pendingActionResult:[ut.id,{type:"error",error:Ie}]}}}let be,Me=bc(X,z);if(!Me.route.action&&!Me.route.lazy)be={type:"error",error:Hn(405,{method:O.method,pathname:z.pathname,routeId:Me.route.id})};else{let we=Ms(u,c,O,z,X,Me,ue?[]:r,ce),Ve=await ea(O,z,we,ce,null);if(be=Ve[Me.route.id],!be){for(let Ie of X)if(Ve[Ie.route.id]){be=Ve[Ie.route.id];break}}if(O.signal.aborted)return{shortCircuited:!0}}if(mr(be)){let we;return le&&le.replace!=null?we=le.replace:we=aS(be.response.headers.get("Location"),new URL(O.url),h,e.history)===T.location.pathname+T.location.search,await Ri(O,be,!0,{submission:H,replace:we}),{shortCircuited:!0}}if(_n(be)){let we=Ma(X,Me.route.id);return(le&&le.replace)!==!0&&(ne="PUSH"),{matches:X,pendingActionResult:[we.route.id,be,Me.route.id]}}return{matches:X,pendingActionResult:[Me.route.id,be]}}async function Qs(O,z,H,X,Z,ce,se,ue,le,ve,be,Me,we,Ve){let Ie=se||Bh(z,H,X,ue),ut=ue||le||cS(Ie),Xe=!P&&!be;if(ce){if(Xe){let at=Or(we);Ot({navigation:Ie,...at!==void 0?{actionData:at}:{}},{flushSync:Me})}let _e=await ci(H,z.pathname,O.signal);if(_e.type==="aborted")return{shortCircuited:!0};if(_e.type==="error"){if(_e.partialMatches.length===0){let{matches:yn,route:Wn}=nc(f.activeRoutes);return{matches:yn,loaderData:{},errors:{[Wn.id]:_e.error}}}let at=Ma(_e.partialMatches).route.id;return{matches:_e.partialMatches,loaderData:{},errors:{[at]:_e.error}}}else if(_e.matches)H=_e.matches;else{let{error:at,notFoundMatches:yn,route:Wn}=Xn(z.pathname);return{matches:yn,loaderData:{},errors:{[Wn.id]:at}}}}let qe=f.activeRoutes,{dsMatches:vt,revalidatingFetchers:Ge}=Jb(O,Z,u,c,e.history,T,H,ut,z,be?[]:r,be===!0,J,ie,Se,re,te,qe,h,e.patchRoutesOnNavigation!=null,f.branches,we,Ve);if(D=++ye,!e.dataStrategy&&!vt.some(_e=>_e.shouldLoad)&&!vt.some(_e=>_e.route.middleware&&_e.route.middleware.length>0)&&Ge.length===0){let _e=new Map(T.fetchers),at=Hl(_e);return on(z,{matches:H,loaderData:{},errors:we&&_n(we[1])?{[we[0]]:we[1].error}:null,...lS(we),...at?{fetchers:_e}:{}},{flushSync:Me}),{shortCircuited:!0}}if(Xe){let _e={};if(!ce){_e.navigation=Ie;let at=Or(we);at!==void 0&&(_e.actionData=at)}Ge.length>0&&(_e.fetchers=Xs(Ge)),Ot(_e,{flushSync:Me})}Ge.forEach(_e=>{zt(_e.key),_e.controller&&oe.set(_e.key,_e.controller)});let aa=()=>Ge.forEach(_e=>zt(_e.key));ae&&ae.signal.addEventListener("abort",aa);let{loaderResults:Zn,fetcherResults:ln}=await Zs(vt,Ge,O,z,Z);if(O.signal.aborted)return{shortCircuited:!0};ae&&ae.signal.removeEventListener("abort",aa),Ge.forEach(_e=>oe.delete(_e.key));let Zt=ic(Zn);if(Zt)return await Ri(O,Zt.result,!0,{replace:ve}),{shortCircuited:!0};if(Zt=ic(ln),Zt)return te.add(Zt.key),await Ri(O,Zt.result,!0,{replace:ve}),{shortCircuited:!0};let Dn=new Map(T.fetchers),{loaderData:jr,errors:Jn}=sS(T,H,Zn,we,Ge,ln,Dn);be&&T.errors&&(Jn={...T.errors,...Jn});let Nr=Hl(Dn),Ai=Fl(D,Dn),Mi=Nr||Ai||Ge.length>0;return{matches:H,loaderData:jr,errors:Jn,...Mi?{workingFetchers:Dn}:{}}}function Or(O){if(O&&!_n(O[1]))return{[O[0]]:O[1].data};if(T.actionData)return Object.keys(T.actionData).length===0?null:T.actionData}function Xs(O){let z=new Map(T.fetchers);return O.forEach(H=>{let X=z.get(H.key),Z=Go(void 0,X?X.data:void 0);z.set(H.key,Z)}),z}async function xf(O,z,H,X){zt(O);let Z=(X&&X.flushSync)===!0,ce=f.activeRoutes,se=Ep(T.location,T.matches,h,H,z,X?.relative),ue=ai(ce,se,h,!1,f.branches),le=ia(ue,ce,se);if(le.active&&le.matches&&(ue=le.matches),!ue){On(O,z,Hn(404,{pathname:se}),{flushSync:Z});return}let{path:ve,submission:be,error:Me}=Zb(!0,se,X);if(Me){On(O,z,Me,{flushSync:Z});return}let we=e.getContext?await e.getContext():new Gb,Ve=(X&&X.preventScrollReset)===!0;if(be&&Yt(be.formMethod)){await wf(O,z,ve,ue,we,le.active,Z,Ve,be,X&&X.defaultShouldRevalidate);return}re.set(O,{routeId:z,path:ve}),await Qt(O,z,ve,ue,we,le.active,Z,Ve,be)}async function wf(O,z,H,X,Z,ce,se,ue,le,ve){ta(),re.delete(O);let be=T.fetchers.get(O);Qn(O,rM(le,be),{flushSync:se});let Me=new AbortController,we=bs(e.history,H,Me.signal,le);if(ce){let Ze=await ci(X,new URL(we.url).pathname,we.signal,O);if(Ze.type==="aborted")return;if(Ze.type==="error"){On(O,z,Ze.error,{flushSync:se});return}else if(Ze.matches)X=Ze.matches;else{On(O,z,Hn(404,{pathname:H}),{flushSync:se});return}}let Ve=bc(X,H);if(!Ve.route.action&&!Ve.route.lazy){let Ze=Hn(405,{method:le.formMethod,pathname:H,routeId:z});On(O,z,Ze,{flushSync:se});return}oe.set(O,Me);let Ie=ye,ut=Ms(u,c,we,H,X,Ve,r,Z),Xe=await ea(we,H,ut,Z,O),qe=Xe[Ve.route.id];if(!qe){for(let Ze of ut)if(Xe[Ze.route.id]){qe=Xe[Ze.route.id];break}}if(we.signal.aborted){oe.get(O)===Me&&oe.delete(O);return}if(Se.has(O)){if(mr(qe)||_n(qe)){Qn(O,gi(void 0));return}}else{if(mr(qe))if(oe.delete(O),D>Ie){Qn(O,gi(void 0));return}else return te.add(O),Qn(O,Go(le)),Ri(we,qe,!1,{fetcherSubmission:le,preventScrollReset:ue});if(_n(qe)){On(O,z,qe.error);return}}let vt=T.navigation.location||T.location,Ge=bs(e.history,vt,Me.signal),aa=f.activeRoutes,Zn=T.navigation.state!=="idle"?ai(aa,T.navigation.location,h,!1,f.branches):T.matches;Ne(Zn,"Didn't find any matches after fetcher action");let ln=++ye;I.set(O,ln);let{dsMatches:Zt,revalidatingFetchers:Dn}=Jb(Ge,Z,u,c,e.history,T,Zn,le,vt,r,!1,J,ie,Se,re,te,aa,h,e.patchRoutesOnNavigation!=null,f.branches,[Ve.route.id,qe],ve),jr=Go(le,qe.data),Jn=new Map(T.fetchers);Jn.set(O,jr),Dn.filter(Ze=>Ze.key!==O).forEach(Ze=>{let Oi=Ze.key,Jt=Jn.get(Oi),Ws=Go(void 0,Jt?Jt.data:void 0);Jn.set(Oi,Ws),zt(Oi),Ze.controller&&oe.set(Oi,Ze.controller)}),Ot({fetchers:Jn});let Nr=()=>Dn.forEach(Ze=>zt(Ze.key));Me.signal.addEventListener("abort",Nr);let{loaderResults:Ai,fetcherResults:Mi}=await Zs(Zt,Dn,Ge,vt,Z);if(Me.signal.aborted)return;Me.signal.removeEventListener("abort",Nr),I.delete(O),oe.delete(O),Dn.forEach(Ze=>oe.delete(Ze.key));let _e=T.fetchers.has(O),at=Ze=>{if(!_e)return Ze;let Oi=new Map(Ze.fetchers);return Oi.set(O,gi(qe.data)),{...Ze,fetchers:Oi}},yn=ic(Ai);if(yn)return T=at(T),Ri(Ge,yn.result,!1,{preventScrollReset:ue});if(yn=ic(Mi),yn)return te.add(yn.key),T=at(T),Ri(Ge,yn.result,!1,{preventScrollReset:ue});let Wn=new Map(T.fetchers);_e&&Wn.set(O,gi(qe.data));let{loaderData:Lr,errors:zr}=sS(T,Zn,Ai,void 0,Dn,Mi,Wn);Fl(ln,Wn),T.navigation.state==="loading"&&ln>D?(Ne(ne,"Expected pending action"),ae&&ae.abort(),on(T.navigation.location,{matches:Zn,loaderData:Lr,errors:zr,fetchers:Wn})):(Ot({errors:zr,loaderData:oS(T.loaderData,Lr,Zn,zr),fetchers:Wn}),J=!1)}async function Qt(O,z,H,X,Z,ce,se,ue,le){let ve=T.fetchers.get(O);Qn(O,Go(le,ve?ve.data:void 0),{flushSync:se});let be=new AbortController,Me=bs(e.history,H,be.signal);if(ce){let qe=await ci(X,new URL(Me.url).pathname,Me.signal,O);if(qe.type==="aborted")return;if(qe.type==="error"){On(O,z,qe.error,{flushSync:se});return}else if(qe.matches)X=qe.matches;else{On(O,z,Hn(404,{pathname:H}),{flushSync:se});return}}let we=bc(X,H);oe.set(O,be);let Ve=ye,Ie=Ms(u,c,Me,H,X,we,r,Z),ut=await ea(Me,H,Ie,Z,O),Xe=ut[we.route.id];if(!Xe){for(let qe of X)if(ut[qe.route.id]){Xe=ut[qe.route.id];break}}if(oe.get(O)===be&&oe.delete(O),!Me.signal.aborted){if(Se.has(O)){Qn(O,gi(void 0));return}if(mr(Xe))if(D>Ve){Qn(O,gi(void 0));return}else{te.add(O),await Ri(Me,Xe,!1,{preventScrollReset:ue});return}if(_n(Xe)){On(O,z,Xe.error);return}Qn(O,gi(Xe.data))}}async function Ri(O,z,H,{submission:X,fetcherSubmission:Z,preventScrollReset:ce,replace:se}={}){H||(ee?.resolve(),ee=null),z.response.headers.has("X-Remix-Revalidate")&&(J=!0);let ue=z.response.headers.get("Location");Ne(ue,"Expected a Location header on the redirect Response"),ue=aS(ue,new URL(O.url),h,e.history);let le=dl(T.location,ue,{_isRedirect:!0});if(i){let Ie=!1;if(z.response.headers.has("X-Remix-Reload-Document"))Ie=!0;else if(Cm(ue)){const ut=Cw(ue,!0);Ie=ut.origin!==t.location.origin||Yn(ut.pathname,h)==null}if(Ie){se?t.location.replace(ue):t.location.assign(ue);return}}ae=null;let ve=se===!0||z.response.headers.has("X-Remix-Replace")?"REPLACE":"PUSH",{formMethod:be,formAction:Me,formEncType:we}=T.navigation;!X&&!Z&&be&&Me&&we&&(X=cS(T.navigation));let Ve=X||Z;if(NA.has(z.response.status)&&Ve&&Yt(Ve.formMethod))await Ei(ve,le,{submission:{...Ve,formAction:ue},preventScrollReset:ce||he,enableViewTransition:H?Le:void 0});else{let Ie=Bh(le,[],ve,X);await Ei(ve,le,{overrideNavigation:Ie,fetcherSubmission:Z,preventScrollReset:ce||he,enableViewTransition:H?Le:void 0})}}async function ea(O,z,H,X,Z){let ce,se={};try{ce=await qA(m,O,z,H,Z,X,!1)}catch(ue){return H.filter(le=>le.shouldLoad).forEach(le=>{se[le.route.id]={type:"error",error:ue}}),se}if(O.signal.aborted)return se;if(!Yt(O.method))for(let ue of H){if(ce[ue.route.id]?.type==="error")break;!ce.hasOwnProperty(ue.route.id)&&!T.loaderData.hasOwnProperty(ue.route.id)&&(!T.errors||!T.errors.hasOwnProperty(ue.route.id))&&ue.shouldCallHandler()&&(ce[ue.route.id]={type:"error",result:new Error(`No result returned from dataStrategy for route ${ue.route.id}`)})}for(let[ue,le]of Object.entries(ce))if(eM(le)){let ve=le.result;se[ue]={type:"redirect",response:KA(ve,O,ue,H,h)}}else se[ue]=await YA(le);return se}async function Zs(O,z,H,X,Z){let ce=ea(H,X,O,Z,null),se=Promise.all(z.map(async ve=>{if(ve.matches&&ve.match&&ve.request&&ve.controller){let Me=(await ea(ve.request,ve.path,ve.matches,Z,ve.key))[ve.match.route.id];return{[ve.key]:Me}}else return Promise.resolve({[ve.key]:{type:"error",error:Hn(404,{pathname:ve.path})}})})),ue=await ce,le=(await se).reduce((ve,be)=>Object.assign(ve,be),{});return{loaderResults:ue,fetcherResults:le}}function ta(){J=!0,re.forEach((O,z)=>{oe.has(z)&&ie.add(z),zt(z)})}function Qn(O,z,H={}){let X=new Map(T.fetchers);X.set(O,z),Ot({fetchers:X},{flushSync:(H&&H.flushSync)===!0})}function On(O,z,H,X={}){let Z=Ma(T.matches,z),ce=new Map(T.fetchers);_i(ce,O),Ot({errors:{[Z.route.id]:H},fetchers:ce},{flushSync:(X&&X.flushSync)===!0})}function Cf(O){return me.set(O,(me.get(O)||0)+1),Se.has(O)&&Se.delete(O),T.fetchers.get(O)||LA}function Ef(O,z){zt(O,z?.reason),Qn(O,gi(null))}function _i(O,z){let H=T.fetchers.get(z);oe.has(z)&&!(H&&H.state==="loading"&&I.has(z))&&zt(z),re.delete(z),I.delete(z),te.delete(z),Se.delete(z),ie.delete(z),O.delete(z)}function Xt(O){let z=(me.get(O)||0)-1;z<=0?(me.delete(O),Se.add(O)):me.set(O,z),Ot({fetchers:new Map(T.fetchers)})}function zt(O,z){let H=oe.get(O);H&&(H.abort(z),oe.delete(O))}function qt(O,z){for(let H of O){let X=z.get(H);Ne(X,`Expected fetcher: ${H}`);let Z=gi(X.data);z.set(H,Z)}}function Hl(O){let z=[],H=!1;for(let X of te){let Z=O.get(X);Ne(Z,`Expected fetcher: ${X}`),Z.state==="loading"&&(te.delete(X),z.push(X),H=!0)}return qt(z,O),H}function Fl(O,z){let H=[];for(let[X,Z]of I)if(Z0}function Rf(O,z){let H=T.blockers.get(O)||qo;return ze.get(O)!==z&&ze.set(O,z),H}function Ga(O){T.blockers.delete(O),ze.delete(O)}function Ti(O,z){let H=T.blockers.get(O)||qo;Ne(H.state==="unblocked"&&z.state==="blocked"||H.state==="blocked"&&z.state==="blocked"||H.state==="blocked"&&z.state==="proceeding"||H.state==="blocked"&&z.state==="unblocked"||H.state==="proceeding"&&z.state==="unblocked",`Invalid blocker state transition: ${H.state} -> ${z.state}`);let X=new Map(T.blockers);X.set(O,z),Ot({blockers:X})}function Ia({currentLocation:O,nextLocation:z,historyAction:H}){if(ze.size===0)return;ze.size>1&&xt(!1,"A router only supports one blocker at a time");let X=Array.from(ze.entries()),[Z,ce]=X[X.length-1],se=T.blockers.get(Z);if(!(se&&se.state==="proceeding")&&ce({currentLocation:O,nextLocation:z,historyAction:H}))return Z}function Xn(O){let z=Hn(404,{pathname:O}),H=f.activeRoutes,{matches:X,route:Z}=nc(H);return{notFoundMatches:X,route:Z,error:z}}function Dr(O,z,H){if(x=O,R=z,C=H||null,!A&&T.navigation===Uh){A=!0;let X=Js(T.location,T.matches);X!=null&&Ot({restoreScrollPosition:X})}return()=>{x=null,R=null,C=null}}function na(O,z){return C&&C(O,z.map(X=>sA(X,T.loaderData)))||O.key}function _f(O,z){if(x&&R){let H=na(O,z);x[H]=R()}}function Js(O,z){if(x){let H=na(O,z),X=x[H];if(typeof X=="number")return X}return null}function ia(O,z,H){if(e.patchRoutesOnNavigation){let X=f.branches;if(O){if(Object.keys(O[0].params).length>0)return{active:!0,matches:ai(z,H,h,!0,X)}}else return{active:!0,matches:ai(z,H,h,!0,X)||[]}}return{active:!1,matches:null}}async function ci(O,z,H,X){if(!e.patchRoutesOnNavigation)return{type:"success",matches:O};let Z=O;for(;;){let ce=c;try{await e.patchRoutesOnNavigation({signal:H,path:z,matches:Z,fetcherKey:X,patch:(ve,be)=>{H.aborted||Wb(ve,be,f,ce,u,!1)}})}catch(ve){return{type:"error",error:ve,partialMatches:Z}}if(H.aborted)return{type:"aborted"};let se=f.branches,ue=ai(f.activeRoutes,z,h,!1,se),le=null;if(ue){if(Object.keys(ue[0].params).length===0)return{type:"success",matches:ue};if(le=ai(f.activeRoutes,z,h,!0,se),!(le&&Z.lengthH.route.id===z[X].route.id)}function ql(O){c={},f.setHmrRoutes(hl(O,u,void 0,c))}function Gl(O,z,H=!1){Wb(O,z,f,c,u,H),f.hasHMRRoutes||Ot({})}return K={get basename(){return h},get future(){return g},get state(){return T},get routes(){return f.stableRoutes},get branches(){return f.branches},get manifest(){return c},get window(){return t},initialize:qa,subscribe:Ys,enableScrollRestoration:Dr,navigate:Mr,fetch:xf,revalidate:Ks,createHref:O=>e.history.createHref(O),encodeLocation:O=>e.history.encodeLocation(O),getFetcher:Cf,resetFetcher:Ef,deleteFetcher:Xt,dispose:Ar,getBlocker:Rf,deleteBlocker:Ga,patchRoutes:Gl,_internalFetchControllers:oe,_internalSetRoutes:ql,_internalSetStateDoNotUseOrYouWillBreakYourApp(O){Ot(O)}},e.instrumentations&&(K=RA(K,e.instrumentations.map(O=>O.router).filter(Boolean))),K}function PA(e){return e!=null&&("formData"in e&&e.formData!=null||"body"in e&&e.body!==void 0)}function Ep(e,t,i,r,o,u){let c,f;if(o){c=[];for(let m of t)if(c.push(m),m.route.id===o){f=m;break}}else c=t,f=t[t.length-1];let h=El(r||".",ef(c),Yn(e.pathname,i)||e.pathname,u==="path");if(r==null&&(h.search=e.search,h.hash=e.hash),(r==null||r===""||r===".")&&f){let m=Tm(h.search);if(f.route.index&&!m)h.search=h.search?h.search.replace(/^\?/,"?index&"):"?index";else if(!f.route.index&&m){let g=new URLSearchParams(h.search),y=g.getAll("index");g.delete("index"),y.filter(S=>S).forEach(S=>g.append("index",S));let b=g.toString();h.search=b?`?${b}`:""}}return i!=="/"&&(h.pathname=bA({basename:i,pathname:h.pathname})),Si(h)}function Zb(e,t,i){if(!i||!PA(i))return{path:t};if(i.formMethod&&!iM(i.formMethod))return{path:t,error:Hn(405,{method:i.formMethod})};let r=()=>({path:t,error:Hn(400,{type:"invalid-body"})}),u=(i.formMethod||"get").toUpperCase(),c=kw(t);if(i.body!==void 0){if(i.formEncType==="text/plain"){if(!Yt(u))return r();let y=typeof i.body=="string"?i.body:i.body instanceof FormData||i.body instanceof URLSearchParams?Array.from(i.body.entries()).reduce((b,[S,x])=>`${b}${S}=${x}
+`,""):String(i.body);return{path:t,submission:{formMethod:u,formAction:c,formEncType:i.formEncType,formData:void 0,json:void 0,text:y}}}else if(i.formEncType==="application/json"){if(!Yt(u))return r();try{let y=typeof i.body=="string"?JSON.parse(i.body):i.body;return{path:t,submission:{formMethod:u,formAction:c,formEncType:i.formEncType,formData:void 0,json:y,text:void 0}}}catch{return r()}}}Ne(typeof FormData=="function","FormData is not available in this environment");let f,h;if(i.formData)f=_p(i.formData),h=i.formData;else if(i.body instanceof FormData)f=_p(i.body),h=i.body;else if(i.body instanceof URLSearchParams)f=i.body,h=rS(f);else if(i.body==null)f=new URLSearchParams,h=new FormData;else try{f=new URLSearchParams(i.body),h=rS(f)}catch{return r()}let m={formMethod:u,formAction:c,formEncType:i&&i.formEncType||"application/x-www-form-urlencoded",formData:h,json:void 0,text:void 0};if(Yt(m.formMethod))return{path:t,submission:m};let g=wi(t);return e&&g.search&&Tm(g.search)&&f.append("index",""),g.search=`?${f}`,{path:Si(g),submission:m}}function Jb(e,t,i,r,o,u,c,f,h,m,g,y,b,S,x,C,R,A,j,L,V,q){let W=V?_n(V[1])?V[1].error:V[1].data:void 0,K=o.createURL(u.location),T=o.createURL(h),ne;if(g&&u.errors){let P=Object.keys(u.errors)[0];ne=c.findIndex(J=>J.route.id===P)}else if(V&&_n(V[1])){let P=V[0];ne=c.findIndex(J=>J.route.id===P)-1}let ee=V?V[1].statusCode:void 0,he=ee&&ee>=400,ae={currentUrl:K,currentParams:u.matches[0]?.params||{},nextUrl:T,nextParams:c[0].params,...f,actionResult:W,actionStatus:ee},Le=_l(c),Re=c.map((P,J)=>{let{route:ie}=P,oe=null;if(ne!=null&&J>ne)oe=!1;else if(ie.lazy)oe=!0;else if(!Rm(ie))oe=!1;else if(g){let{shouldLoad:te}=Vw(ie,u.loaderData,u.errors);oe=te}else UA(u.loaderData,u.matches[J],P)&&(oe=!0);if(oe!==null)return Rp(i,r,e,h,Le,P,m,t,oe);let ye=!1;typeof q=="boolean"?ye=q:he?ye=!1:(y||K.pathname+K.search===T.pathname+T.search||K.search!==T.search||BA(u.matches[J],P))&&(ye=!0);let D={...ae,defaultShouldRevalidate:ye},I=el(P,D);return Rp(i,r,e,h,Le,P,m,t,I,D,q)}),je=[];return x.forEach((P,J)=>{if(g||!c.some(me=>me.route.id===P.routeId)||S.has(J))return;let ie=u.fetchers.get(J),oe=ie&&ie.state!=="idle"&&ie.data===void 0,ye=ai(R,P.path,A??"/",!1,L);if(!ye){if(j&&oe)return;je.push({key:J,routeId:P.routeId,path:P.path,matches:null,match:null,request:null,controller:null});return}if(C.has(J))return;let D=bc(ye,P.path),I=new AbortController,te=bs(o,P.path,I.signal),re=null;if(b.has(J))b.delete(J),re=Ms(i,r,te,P.path,ye,D,m,t);else if(oe)y&&(re=Ms(i,r,te,P.path,ye,D,m,t));else{let me;typeof q=="boolean"?me=q:he?me=!1:me=y;let Se={...ae,defaultShouldRevalidate:me};el(D,Se)&&(re=Ms(i,r,te,P.path,ye,D,m,t,Se))}re&&je.push({key:J,routeId:P.routeId,path:P.path,matches:re,match:D,request:te,controller:I})}),{dsMatches:Re,revalidatingFetchers:je}}function Rm(e){return e.loader!=null||e.middleware!=null&&e.middleware.length>0}function Vw(e,t,i){if(e.lazy)return{shouldLoad:!0,renderFallback:!0};if(!Rm(e))return{shouldLoad:!1,renderFallback:!1};let r=t!=null&&e.id in t,o=i!=null&&i[e.id]!==void 0;if(!r&&o)return{shouldLoad:!1,renderFallback:!1};if(typeof e.loader=="function"&&e.loader.hydrate===!0)return{shouldLoad:!0,renderFallback:!r};let u=!r&&!o;return{shouldLoad:u,renderFallback:u}}function UA(e,t,i){let r=!t||i.route.id!==t.route.id,o=!e.hasOwnProperty(i.route.id);return r||o}function BA(e,t){let i=e.route.path;return e.pathname!==t.pathname||i!=null&&i.endsWith("*")&&e.params["*"]!==t.params["*"]}function el(e,t){if(e.route.shouldRevalidate){let i=e.route.shouldRevalidate(t);if(typeof i=="boolean")return i}return t.defaultShouldRevalidate}function Wb(e,t,i,r,o,u){let c;if(e){let m=r[e];Ne(m,`No route found to patch children into: routeId = ${e}`),m.children||(m.children=[]),c=m.children}else c=i.activeRoutes;let f=[],h=[];if(t.forEach(m=>{let g=c.find(y=>$w(m,y));g?h.push({existingRoute:g,newRoute:m}):f.push(m)}),f.length>0){let m=hl(f,o,[e||"_","patch",String(c?.length||"0")],r);c.push(...m)}if(u&&h.length>0)for(let m=0;mt.children?.some(o=>$w(i,o)))??!1:!1}var eS=new WeakMap,Pw=({key:e,route:t,manifest:i,mapRouteProperties:r})=>{let o=i[t.id];if(Ne(o,"No route found in manifest"),!o.lazy||typeof o.lazy!="object")return;let u=o.lazy[e];if(!u)return;let c=eS.get(o);c||(c={},eS.set(o,c));let f=c[e];if(f)return f;let h=(async()=>{let m=nA(e),y=o[e]!==void 0&&e!=="hasErrorBoundary";if(m)xt(!m,"Route property "+e+" is not a supported lazy route property. This property will be ignored."),c[e]=Promise.resolve();else if(y)xt(!1,`Route "${o.id}" has a static property "${e}" defined. The lazy property will be ignored.`);else{let b=await u();b!=null&&(Object.assign(o,{[e]:b}),Object.assign(o,r(o)))}typeof o.lazy=="object"&&(o.lazy[e]=void 0,Object.values(o.lazy).every(b=>b===void 0)&&(o.lazy=void 0))})();return c[e]=h,h},tS=new WeakMap;function HA(e,t,i,r,o){let u=i[e.id];if(Ne(u,"No route found in manifest"),!e.lazy)return{lazyRoutePromise:void 0,lazyHandlerPromise:void 0};if(typeof e.lazy=="function"){let g=tS.get(u);if(g)return{lazyRoutePromise:g,lazyHandlerPromise:g};let y=(async()=>{Ne(typeof e.lazy=="function","No lazy route function found");let b=await e.lazy(),S={};for(let x in b){let C=b[x];if(C===void 0)continue;let R=aA(x),j=u[x]!==void 0&&x!=="hasErrorBoundary";R?xt(!R,"Route property "+x+" is not a supported property to be returned from a lazy route function. This property will be ignored."):j?xt(!j,`Route "${u.id}" has a static property "${x}" defined but its lazy function is also returning a value for this property. The lazy route property "${x}" will be ignored.`):S[x]=C}Object.assign(u,S),Object.assign(u,{...r(u),lazy:void 0})})();return tS.set(u,y),y.catch(()=>{}),{lazyRoutePromise:y,lazyHandlerPromise:y}}let c=Object.keys(e.lazy),f=[],h;for(let g of c){if(o&&o.includes(g))continue;let y=Pw({key:g,route:e,manifest:i,mapRouteProperties:r});y&&(f.push(y),g===t&&(h=y))}let m=f.length>0?Promise.all(f).then(()=>{}):void 0;return m?.catch(()=>{}),h?.catch(()=>{}),{lazyRoutePromise:m,lazyHandlerPromise:h}}async function nS(e){let t=e.matches.filter(o=>o.shouldLoad),i={};return(await Promise.all(t.map(o=>o.resolve()))).forEach((o,u)=>{i[t[u].route.id]=o}),i}async function FA(e){return e.matches.some(t=>t.route.middleware)?Uw(e,()=>nS(e)):nS(e)}function Uw(e,t){return kA(e,t,r=>{if(nM(r))throw r;return r},JA,i);function i(r,o,u){if(u)return Promise.resolve(Object.assign(u.value,{[o]:{type:"error",result:r}}));{let{matches:c}=e,f=Math.min(Math.max(c.findIndex(m=>m.route.id===o),0),Math.max(c.findIndex(m=>m.shouldCallHandler()),0)),h=Ma(c,c[f].route.id).route.id;return Promise.resolve({[h]:{type:"error",result:r}})}}}async function kA(e,t,i,r,o){let{matches:u,...c}=e,f=u.flatMap(m=>m.route.middleware?m.route.middleware.map(g=>[m.route.id,g]):[]);return await Bw(c,f,t,i,r,o)}async function Bw(e,t,i,r,o,u,c=0){let{request:f}=e;if(f.signal.aborted)throw f.signal.reason??new Error(`Request aborted: ${f.method} ${f.url}`);let h=t[c];if(!h)return await i();let[m,g]=h,y,b=async()=>{if(y)throw new Error("You may only call `next()` once per middleware");try{return y={value:await Bw(e,t,i,r,o,u,c+1)},y.value}catch(S){return y={value:await u(S,m,y)},y.value}};try{let S=await g(e,b),x=S!=null?r(S):void 0;return o(x)?x:y?x??y.value:(y={value:await b()},y.value)}catch(S){return await u(S,m,y)}}function Hw(e,t,i,r,o){let u=Pw({key:"middleware",route:r.route,manifest:t,mapRouteProperties:e}),c=HA(r.route,Yt(i.method)?"action":"loader",t,e,o);return{middleware:u,route:c.lazyRoutePromise,handler:c.lazyHandlerPromise}}function Rp(e,t,i,r,o,u,c,f,h,m=null,g){let y=!1,b=Hw(e,t,i,u,c);return{...u,_lazyPromises:b,shouldLoad:h,shouldRevalidateArgs:m,shouldCallHandler(S){return y=!0,m?typeof g=="boolean"?el(u,{...m,defaultShouldRevalidate:g}):typeof S=="boolean"?el(u,{...m,defaultShouldRevalidate:S}):el(u,m):h},resolve(S){let{lazy:x,loader:C,middleware:R}=u.route,A=y||h||S&&!Yt(i.method)&&(x||C),j=R&&R.length>0&&!C&&!x;return A&&(Yt(i.method)||!j)?GA({request:i,path:r,pattern:o,match:u,lazyHandlerPromise:b?.handler,lazyRoutePromise:b?.route,handlerOverride:S,scopedContext:f}):Promise.resolve({type:"data",result:void 0})}}}function Ms(e,t,i,r,o,u,c,f,h=null){return o.map(m=>m.route.id!==u.route.id?{...m,shouldLoad:!1,shouldRevalidateArgs:h,shouldCallHandler:()=>!1,_lazyPromises:Hw(e,t,i,m,c),resolve:()=>Promise.resolve({type:"data",result:void 0})}:Rp(e,t,i,r,_l(o),m,c,f,!0,h))}async function qA(e,t,i,r,o,u,c){r.some(g=>g._lazyPromises?.middleware)&&await Promise.all(r.map(g=>g._lazyPromises?.middleware));let f={request:t,url:Fw(t,i),pattern:_l(r),params:r[0].params,context:u,matches:r},m=await e({...f,fetcherKey:o,runClientMiddleware:g=>{let y=f;return Uw(y,()=>g({...y,fetcherKey:o,runClientMiddleware:()=>{throw new Error("Cannot call `runClientMiddleware()` from within an `runClientMiddleware` handler")}}))}});try{await Promise.all(r.flatMap(g=>[g._lazyPromises?.handler,g._lazyPromises?.route]))}catch{}return m}async function GA({request:e,path:t,pattern:i,match:r,lazyHandlerPromise:o,lazyRoutePromise:u,handlerOverride:c,scopedContext:f}){let h,m,g=Yt(e.method),y=g?"action":"loader",b=S=>{let x,C=new Promise((j,L)=>x=L);m=()=>x(),e.signal.addEventListener("abort",m);let R=j=>typeof S!="function"?Promise.reject(new Error(`You cannot call the handler for a route which defines a boolean "${y}" [routeId: ${r.route.id}]`)):S({request:e,url:Fw(e,t),pattern:i,params:r.params,context:f},...j!==void 0?[j]:[]),A=(async()=>{try{return{type:"data",result:await(c?c(L=>R(L)):R())}}catch(j){return{type:"error",result:j}}})();return Promise.race([A,C])};try{let S=g?r.route.action:r.route.loader;if(o||u)if(S){let x,[C]=await Promise.all([b(S).catch(R=>{x=R}),o,u]);if(x!==void 0)throw x;h=C}else{await o;let x=g?r.route.action:r.route.loader;if(x)[h]=await Promise.all([b(x),u]);else if(y==="action"){let C=new URL(e.url),R=C.pathname+C.search;throw Hn(405,{method:e.method,pathname:R,routeId:r.route.id})}else return{type:"data",result:void 0}}else if(S)h=await b(S);else{let x=new URL(e.url),C=x.pathname+x.search;throw Hn(404,{pathname:C})}}catch(S){return{type:"error",result:S}}finally{m&&e.signal.removeEventListener("abort",m)}return h}async function IA(e){let t=e.headers.get("Content-Type");return t&&/\bapplication\/json\b/.test(t)?e.body==null?null:e.json():e.text()}async function YA(e){let{result:t,type:i}=e;if(_m(t)){let r;try{r=await IA(t)}catch(o){return{type:"error",error:o}}return i==="error"?{type:"error",error:new Rl(t.status,t.statusText,r),statusCode:t.status,headers:t.headers}:{type:"data",data:r,statusCode:t.status,headers:t.headers}}return i==="error"?uS(t)?t.data instanceof Error?{type:"error",error:t.data,statusCode:t.init?.status,headers:t.init?.headers?new Headers(t.init.headers):void 0}:{type:"error",error:ZA(t),statusCode:pl(t)?t.status:void 0,headers:t.init?.headers?new Headers(t.init.headers):void 0}:{type:"error",error:t,statusCode:pl(t)?t.status:void 0}:uS(t)?{type:"data",data:t.data,statusCode:t.init?.status,headers:t.init?.headers?new Headers(t.init.headers):void 0}:{type:"data",data:t}}function KA(e,t,i,r,o){let u=e.headers.get("Location");if(Ne(u,"Redirects returned/thrown from loaders/actions must have a Location header"),!Cm(u)){let c=r.slice(0,r.findIndex(f=>f.route.id===i)+1);u=Ep(new URL(t.url),c,o,u),e.headers.set("Location",u)}return e}var iS=["about:","blob:","chrome:","chrome-untrusted:","content:","data:","devtools:","file:","filesystem:","javascript:"];function aS(e,t,i,r){if(Cm(e)){let o=e,u=o.startsWith("//")?new URL(t.protocol+o):new URL(o);if(iS.includes(u.protocol))throw new Error("Invalid redirect location");let c=Yn(u.pathname,i)!=null;if(u.origin===t.origin&&c)return Em(u.pathname)+u.search+u.hash}try{let o=r.createURL(e);if(iS.includes(o.protocol))throw new Error("Invalid redirect location")}catch{}return e}function bs(e,t,i,r){let o=e.createURL(kw(t)).toString(),u={signal:i};if(r&&Yt(r.formMethod)){let{formMethod:c,formEncType:f}=r;u.method=c.toUpperCase(),f==="application/json"?(u.headers=new Headers({"Content-Type":f}),u.body=JSON.stringify(r.json)):f==="text/plain"?u.body=r.text:f==="application/x-www-form-urlencoded"&&r.formData?u.body=_p(r.formData):u.body=r.formData}return new Request(o,u)}function Fw(e,t){let i=new URL(e.url),r=typeof t=="string"?wi(t):t;if(i.pathname=r.pathname||"/",r.search){let o=new URLSearchParams(r.search),u=o.getAll("index");o.delete("index");for(let c of u.filter(Boolean))o.append("index",c);i.search=o.size?`?${o.toString()}`:""}else i.search="";return i.hash=r.hash||"",i}function _p(e){let t=new URLSearchParams;for(let[i,r]of e.entries())t.append(i,typeof r=="string"?r:r.name);return t}function rS(e){let t=new FormData;for(let[i,r]of e.entries())t.append(i,r);return t}function QA(e,t,i,r=!1,o=!1){let u={},c=null,f,h=!1,m={},g=i&&_n(i[1])?i[1].error:void 0;return e.forEach(y=>{if(!(y.route.id in t))return;let b=y.route.id,S=t[b];if(Ne(!mr(S),"Cannot handle redirect results in processLoaderData"),_n(S)){let x=S.error;if(g!==void 0&&(x=g,g=void 0),c=c||{},o)c[b]=x;else{let C=Ma(e,b);c[C.route.id]==null&&(c[C.route.id]=x)}r||(u[b]=zw),h||(h=!0,f=pl(S.error)?S.error.status:500),S.headers&&(m[b]=S.headers)}else u[b]=S.data,S.statusCode&&S.statusCode!==200&&!h&&(f=S.statusCode),S.headers&&(m[b]=S.headers)}),g!==void 0&&i&&(c={[i[0]]:g},i[2]&&(u[i[2]]=void 0)),{loaderData:u,errors:c,statusCode:f||200,loaderHeaders:m}}function sS(e,t,i,r,o,u,c){let{loaderData:f,errors:h}=QA(t,i,r);return o.filter(m=>!m.matches||m.matches.some(g=>g.shouldLoad)).forEach(m=>{let{key:g,match:y,controller:b}=m;if(b&&b.signal.aborted)return;let S=u[g];if(Ne(S,"Did not find corresponding fetcher result"),_n(S)){let x=Ma(e.matches,y?.route.id);h&&h[x.route.id]||(h={...h,[x.route.id]:S.error}),c.delete(g)}else if(mr(S))Ne(!1,"Unhandled fetcher revalidation redirect");else{let x=gi(S.data);c.set(g,x)}}),{loaderData:f,errors:h}}function oS(e,t,i,r){let o=Object.entries(t).filter(([,u])=>u!==zw).reduce((u,[c,f])=>(u[c]=f,u),{});for(let u of i){let c=u.route.id;if(!t.hasOwnProperty(c)&&e.hasOwnProperty(c)&&u.route.loader&&(o[c]=e[c]),r&&r.hasOwnProperty(c))break}return o}function lS(e){return e?_n(e[1])?{actionData:{}}:{actionData:{[e[0]]:e[1].data}}:{}}function Ma(e,t){return(t?e.slice(0,e.findIndex(r=>r.route.id===t)+1):[...e]).reverse().find(r=>r.route.hasErrorBoundary===!0)||e[0]}function nc(e){let t=e.length===1?e[0]:e.find(i=>i.index||!i.path||i.path==="/")||{id:"__shim-error-route__"};return{matches:[{params:{},pathname:"",pathnameBase:"",route:t}],route:t}}function Hn(e,{pathname:t,routeId:i,method:r,type:o,message:u}={}){let c="Unknown Server Error",f="Unknown @remix-run/router error";return e===400?(c="Bad Request",r&&t&&i?f=`You made a ${r} request to "${t}" but did not provide a \`loader\` for route "${i}", so there is no way to handle the request.`:o==="invalid-body"&&(f="Unable to encode submission body")):e===403?(c="Forbidden",f=`Route "${i}" does not match URL "${t}"`):e===404?(c="Not Found",f=`No route matches URL "${t}"`):e===405&&(c="Method Not Allowed",r&&t&&i?f=`You made a ${r.toUpperCase()} request to "${t}" but did not provide an \`action\` for route "${i}", so there is no way to handle the request.`:r&&(f=`Invalid request method "${r.toUpperCase()}"`)),new Rl(e||500,c,new Error(f),!0)}function ic(e){let t=Object.entries(e);for(let i=t.length-1;i>=0;i--){let[r,o]=t[i];if(mr(o))return{key:r,result:o}}}function kw(e){let t=typeof e=="string"?wi(e):e;return Si({...t,hash:""})}function XA(e,t){return e.pathname!==t.pathname||e.search!==t.search?!1:e.hash===""?t.hash!=="":e.hash===t.hash?!0:t.hash!==""}function ZA(e){return new Rl(e.init?.status??500,e.init?.statusText??"Internal Server Error",e.data)}function JA(e){return e!=null&&typeof e=="object"&&Object.entries(e).every(([t,i])=>typeof t=="string"&&WA(i))}function WA(e){return e!=null&&typeof e=="object"&&"type"in e&&"result"in e&&(e.type==="data"||e.type==="error")}function eM(e){return _m(e.result)&&Nw.has(e.result.status)}function _n(e){return e.type==="error"}function mr(e){return(e&&e.type)==="redirect"}function uS(e){return typeof e=="object"&&e!=null&&"type"in e&&"data"in e&&"init"in e&&e.type==="DataWithResponseInit"}function _m(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.headers=="object"&&typeof e.body<"u"}function tM(e){return Nw.has(e)}function nM(e){return _m(e)&&tM(e.status)&&e.headers.has("Location")}function iM(e){return jA.has(e.toUpperCase())}function Yt(e){return OA.has(e.toUpperCase())}function Tm(e){return new URLSearchParams(e).getAll("index").some(t=>t==="")}function bc(e,t){let i=typeof t=="string"?wi(t).search:t.search;if(e[e.length-1].route.index&&Tm(i||""))return e[e.length-1];let r=Aw(e);return r[r.length-1]}function cS(e){let{formMethod:t,formAction:i,formEncType:r,text:o,formData:u,json:c}=e;if(!(!t||!i||!r)){if(o!=null)return{formMethod:t,formAction:i,formEncType:r,formData:void 0,json:void 0,text:o};if(u!=null)return{formMethod:t,formAction:i,formEncType:r,formData:u,json:void 0,text:void 0};if(c!==void 0)return{formMethod:t,formAction:i,formEncType:r,formData:void 0,json:c,text:void 0}}}function Bh(e,t,i,r){return r?{state:"loading",location:e,matches:t,historyAction:i,formMethod:r.formMethod,formAction:r.formAction,formEncType:r.formEncType,formData:r.formData,json:r.json,text:r.text}:{state:"loading",location:e,matches:t,historyAction:i,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0}}function aM(e,t,i,r){return{state:"submitting",location:e,matches:t,historyAction:i,formMethod:r.formMethod,formAction:r.formAction,formEncType:r.formEncType,formData:r.formData,json:r.json,text:r.text}}function Go(e,t){return e?{state:"loading",formMethod:e.formMethod,formAction:e.formAction,formEncType:e.formEncType,formData:e.formData,json:e.json,text:e.text,data:t}:{state:"loading",formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:t}}function rM(e,t){return{state:"submitting",formMethod:e.formMethod,formAction:e.formAction,formEncType:e.formEncType,formData:e.formData,json:e.json,text:e.text,data:t?t.data:void 0}}function gi(e){return{state:"idle",formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:e}}function sM(e,t){try{let i=e.sessionStorage.getItem(Lw);if(i){let r=JSON.parse(i);for(let[o,u]of Object.entries(r||{}))u&&Array.isArray(u)&&t.set(o,new Set(u||[]))}}catch{}}function oM(e,t){if(t.size>0){let i={};for(let[r,o]of t)i[r]=[...o];try{e.sessionStorage.setItem(Lw,JSON.stringify(i))}catch(r){xt(!1,`Failed to save applied view transitions in sessionStorage (${r}).`)}}}function fS(){let e,t,i=new Promise((r,o)=>{e=async u=>{r(u);try{await i}catch{}},t=async u=>{o(u);try{await i}catch{}}});return{promise:i,resolve:e,reject:t}}var _r=_.createContext(null);_r.displayName="DataRouter";var Tl=_.createContext(null);Tl.displayName="DataRouterState";var qw=_.createContext(!1);function Gw(){return _.useContext(qw)}var Am=_.createContext({isTransitioning:!1});Am.displayName="ViewTransition";var Iw=_.createContext(new Map);Iw.displayName="Fetchers";var lM=_.createContext(null);lM.displayName="Await";var Mn=_.createContext(null);Mn.displayName="Navigation";var tf=_.createContext(null);tf.displayName="Location";var li=_.createContext({outlet:null,matches:[],isDataRoute:!1});li.displayName="Route";var Mm=_.createContext(null);Mm.displayName="RouteError";var Yw="REACT_ROUTER_ERROR",uM="REDIRECT",cM="ROUTE_ERROR_RESPONSE";function fM(e){if(e.startsWith(`${Yw}:${uM}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.location=="string"&&typeof t.reloadDocument=="boolean"&&typeof t.replace=="boolean")return t}catch{}}function dM(e){if(e.startsWith(`${Yw}:${cM}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new Rl(t.status,t.statusText,t.data)}catch{}}function hM(e,{relative:t}={}){Ne(Ps(),"useHref() may be used only in the context of a component.");let{basename:i,navigator:r}=_.useContext(Mn),{hash:o,pathname:u,search:c}=Al(e,{relative:t}),f=u;return i!=="/"&&(f=u==="/"?i:kn([i,u])),r.createHref({pathname:f,search:c,hash:o})}function Ps(){return _.useContext(tf)!=null}function Ci(){return Ne(Ps(),"useLocation() may be used only in the context of a component."),_.useContext(tf).location}var Kw="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Qw(e){_.useContext(Mn).static||_.useLayoutEffect(e)}function Xw(){let{isDataRoute:e}=_.useContext(li);return e?AM():pM()}function pM(){Ne(Ps(),"useNavigate() may be used only in the context of a component.");let e=_.useContext(_r),{basename:t,navigator:i}=_.useContext(Mn),{matches:r}=_.useContext(li),{pathname:o}=Ci(),u=JSON.stringify(ef(r)),c=_.useRef(!1);return Qw(()=>{c.current=!0}),_.useCallback((h,m={})=>{if(xt(c.current,Kw),!c.current)return;if(typeof h=="number"){i.go(h);return}let g=El(h,JSON.parse(u),o,m.relative==="path");e==null&&t!=="/"&&(g.pathname=g.pathname==="/"?t:kn([t,g.pathname])),(m.replace?i.replace:i.push)(g,m.state,m)},[t,i,u,o,e])}var mM=_.createContext(null);function gM(e){let t=_.useContext(li).outlet;return _.useMemo(()=>t&&_.createElement(mM.Provider,{value:e},t),[t,e])}function Al(e,{relative:t}={}){let{matches:i}=_.useContext(li),{pathname:r}=Ci(),o=JSON.stringify(ef(i));return _.useMemo(()=>El(e,JSON.parse(o),r,t==="path"),[e,o,r,t])}function yM(e,t,i){Ne(Ps(),"useRoutes() may be used only in the context of a component.");let{navigator:r}=_.useContext(Mn),{matches:o}=_.useContext(li),u=o[o.length-1],c=u?u.params:{},f=u?u.pathname:"/",h=u?u.pathnameBase:"/",m=u&&u.route;{let R=m&&m.path||"";Jw(f,!m||R.endsWith("*")||R.endsWith("*?"),`You rendered descendant (or called \`useRoutes()\`) at "${f}" (under ) 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 to .`)}let g=Ci(),y;y=g;let b=y.pathname||"/",S=b;if(h!=="/"){let R=h.replace(/^\//,"").split("/");S="/"+b.replace(/^\//,"").split("/").slice(R.length).join("/")}let x=i&&i.state.matches.length?i.state.matches.map(R=>Object.assign(R,{route:i.manifest[R.route.id]||R.route})):Ew(e,{pathname:S});return xt(m||x!=null,`No routes matched location "${y.pathname}${y.search}${y.hash}" `),xt(x==null||x[x.length-1].route.element!==void 0||x[x.length-1].route.Component!==void 0||x[x.length-1].route.lazy!==void 0,`Matched leaf route at location "${y.pathname}${y.search}${y.hash}" does not have an element or Component. This means it will render an with a null value by default resulting in an "empty" page.`),wM(x&&x.map(R=>Object.assign({},R,{params:Object.assign({},c,R.params),pathname:kn([h,r.encodeLocation?r.encodeLocation(R.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:R.pathname]),pathnameBase:R.pathnameBase==="/"?h:kn([h,r.encodeLocation?r.encodeLocation(R.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:R.pathnameBase])})),o,i)}function vM(){let e=TM(),t=pl(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),i=e instanceof Error?e.stack:null,r="rgba(200,200,200, 0.5)",o={padding:"0.5rem",backgroundColor:r},u={padding:"2px 4px",backgroundColor:r},c=null;return console.error("Error handled by React Router default ErrorBoundary:",e),c=_.createElement(_.Fragment,null,_.createElement("p",null,"💿 Hey developer 👋"),_.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",_.createElement("code",{style:u},"ErrorBoundary")," or"," ",_.createElement("code",{style:u},"errorElement")," prop on your route.")),_.createElement(_.Fragment,null,_.createElement("h2",null,"Unexpected Application Error!"),_.createElement("h3",{style:{fontStyle:"italic"}},t),i?_.createElement("pre",{style:o},i):null,c)}var bM=_.createElement(vM,null),Zw=class extends _.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){this.props.onError?this.props.onError(e,t):console.error("React Router caught the following error during render",e)}render(){let e=this.state.error;if(this.context&&typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){const i=dM(e.digest);i&&(e=i)}let t=e!==void 0?_.createElement(li.Provider,{value:this.props.routeContext},_.createElement(Mm.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?_.createElement(SM,{error:e},t):t}};Zw.contextType=qw;var Hh=new WeakMap;function SM({children:e,error:t}){let{basename:i}=_.useContext(Mn);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let r=fM(t.digest);if(r){let o=Hh.get(t);if(o)throw o;let u=Ow(r.location,i);if(Mw&&!Hh.get(t))if(u.isExternal||r.reloadDocument)window.location.href=u.absoluteURL||u.to;else{const c=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(u.to,{replace:r.replace}));throw Hh.set(t,c),c}return _.createElement("meta",{httpEquiv:"refresh",content:`0;url=${u.absoluteURL||u.to}`})}}return e}function xM({routeContext:e,match:t,children:i}){let r=_.useContext(_r);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),_.createElement(li.Provider,{value:e},i)}function wM(e,t=[],i){let r=i?.state;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 o=e,u=r?.errors;if(u!=null){let g=o.findIndex(y=>y.route.id&&u?.[y.route.id]!==void 0);Ne(g>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(u).join(",")}`),o=o.slice(0,Math.min(o.length,g+1))}let c=!1,f=-1;if(i&&r){c=r.renderFallback;for(let g=0;g=0?o=o.slice(0,f+1):o=[o[0]];break}}}}let h=i?.onError,m=r&&h?(g,y)=>{h(g,{location:r.location,params:r.matches?.[0]?.params??{},pattern:_l(r.matches),errorInfo:y})}:void 0;return o.reduceRight((g,y,b)=>{let S,x=!1,C=null,R=null;r&&(S=u&&y.route.id?u[y.route.id]:void 0,C=y.route.errorElement||bM,c&&(f<0&&b===0?(Jw("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),x=!0,R=null):f===b&&(x=!0,R=y.route.hydrateFallbackElement||null)));let A=t.concat(o.slice(0,b+1)),j=()=>{let L;return S?L=C:x?L=R:y.route.Component?L=_.createElement(y.route.Component,null):y.route.element?L=y.route.element:L=g,_.createElement(xM,{match:y,routeContext:{outlet:g,matches:A,isDataRoute:r!=null},children:L})};return r&&(y.route.ErrorBoundary||y.route.errorElement||b===0)?_.createElement(Zw,{location:r.location,revalidation:r.revalidation,component:C,error:S,children:j(),routeContext:{outlet:null,matches:A,isDataRoute:!0},onError:m}):j()},null)}function Om(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function CM(e){let t=_.useContext(_r);return Ne(t,Om(e)),t}function EM(e){let t=_.useContext(Tl);return Ne(t,Om(e)),t}function RM(e){let t=_.useContext(li);return Ne(t,Om(e)),t}function Dm(e){let t=RM(e),i=t.matches[t.matches.length-1];return Ne(i.route.id,`${e} can only be used on routes that contain a unique "id"`),i.route.id}function _M(){return Dm("useRouteId")}function TM(){let e=_.useContext(Mm),t=EM("useRouteError"),i=Dm("useRouteError");return e!==void 0?e:t.errors?.[i]}function AM(){let{router:e}=CM("useNavigate"),t=Dm("useNavigate"),i=_.useRef(!1);return Qw(()=>{i.current=!0}),_.useCallback(async(o,u={})=>{xt(i.current,Kw),i.current&&(typeof o=="number"?await e.navigate(o):await e.navigate(o,{fromRouteId:t,...u}))},[e,t])}var dS={};function Jw(e,t,i){!t&&!dS[e]&&(dS[e]=!0,xt(!1,i))}var hS={};function pS(e,t){!e&&!hS[t]&&(hS[t]=!0,console.warn(t))}var MM="useOptimistic",mS=oT[MM],OM=()=>{};function DM(e){return mS?mS(e):[e,OM]}function jM(e){let t={hasErrorBoundary:e.hasErrorBoundary||e.ErrorBoundary!=null||e.errorElement!=null};return e.Component&&(e.element&&xt(!1,"You should not include both `Component` and `element` on your route - `Component` will be used."),Object.assign(t,{element:_.createElement(e.Component),Component:void 0})),e.HydrateFallback&&(e.hydrateFallbackElement&&xt(!1,"You should not include both `HydrateFallback` and `hydrateFallbackElement` on your route - `HydrateFallback` will be used."),Object.assign(t,{hydrateFallbackElement:_.createElement(e.HydrateFallback),HydrateFallback:void 0})),e.ErrorBoundary&&(e.errorElement&&xt(!1,"You should not include both `ErrorBoundary` and `errorElement` on your route - `ErrorBoundary` will be used."),Object.assign(t,{errorElement:_.createElement(e.ErrorBoundary),ErrorBoundary:void 0})),t}var NM=["HydrateFallback","hydrateFallbackElement"],LM=class{constructor(){this.status="pending",this.promise=new Promise((e,t)=>{this.resolve=i=>{this.status==="pending"&&(this.status="resolved",e(i))},this.reject=i=>{this.status==="pending"&&(this.status="rejected",t(i))}})}};function zM({router:e,flushSync:t,onError:i,useTransitions:r}){r=Gw()||r;let[u,c]=_.useState(e.state),[f,h]=DM(u),[m,g]=_.useState(),[y,b]=_.useState({isTransitioning:!1}),[S,x]=_.useState(),[C,R]=_.useState(),[A,j]=_.useState(),L=_.useRef(new Map),V=_.useCallback((T,{deletedFetchers:ne,newErrors:ee,flushSync:he,viewTransitionOpts:ae})=>{ee&&i&&Object.values(ee).forEach(Re=>i(Re,{location:T.location,params:T.matches[0]?.params??{},pattern:_l(T.matches)})),T.fetchers.forEach((Re,je)=>{Re.data!==void 0&&L.current.set(je,Re.data)}),ne.forEach(Re=>L.current.delete(Re)),pS(he===!1||t!=null,'You provided the `flushSync` option to a router update, but you are not using the `` from `react-router/dom` so `ReactDOM.flushSync()` is unavailable. Please update your app to `import { RouterProvider } from "react-router/dom"` and ensure you have `react-dom` installed as a dependency to use the `flushSync` option.');let Le=e.window!=null&&e.window.document!=null&&typeof e.window.document.startViewTransition=="function";if(pS(ae==null||Le,"You provided the `viewTransition` option to a router update, but you do not appear to be running in a DOM environment as `window.startViewTransition` is not available."),!ae||!Le){t&&he?t(()=>c(T)):r===!1?c(T):_.startTransition(()=>{r===!0&&h(Re=>gS(Re,T)),c(T)});return}if(t&&he){t(()=>{C&&(S?.resolve(),C.skipTransition()),b({isTransitioning:!0,flushSync:!0,currentLocation:ae.currentLocation,nextLocation:ae.nextLocation})});let Re=e.window.document.startViewTransition(()=>{t(()=>c(T))});Re.finished.finally(()=>{t(()=>{x(void 0),R(void 0),g(void 0),b({isTransitioning:!1})})}),t(()=>R(Re));return}C?(S?.resolve(),C.skipTransition(),j({state:T,currentLocation:ae.currentLocation,nextLocation:ae.nextLocation})):(g(T),b({isTransitioning:!0,flushSync:!1,currentLocation:ae.currentLocation,nextLocation:ae.nextLocation}))},[e.window,t,C,S,r,h,i]);_.useLayoutEffect(()=>e.subscribe(V),[e,V]),_.useEffect(()=>{y.isTransitioning&&!y.flushSync&&x(new LM)},[y]),_.useEffect(()=>{if(S&&m&&e.window){let T=m,ne=S.promise,ee=e.window.document.startViewTransition(async()=>{r===!1?c(T):_.startTransition(()=>{r===!0&&h(he=>gS(he,T)),c(T)}),await ne});ee.finished.finally(()=>{x(void 0),R(void 0),g(void 0),b({isTransitioning:!1})}),R(ee)}},[m,S,e.window,r,h]),_.useEffect(()=>{S&&m&&f.location.key===m.location.key&&S.resolve()},[S,C,f.location,m]),_.useEffect(()=>{!y.isTransitioning&&A&&(g(A.state),b({isTransitioning:!0,flushSync:!1,currentLocation:A.currentLocation,nextLocation:A.nextLocation}),j(void 0))},[y.isTransitioning,A]);let q=_.useMemo(()=>({createHref:e.createHref,encodeLocation:e.encodeLocation,go:T=>e.navigate(T),push:(T,ne,ee)=>e.navigate(T,{state:ne,preventScrollReset:ee?.preventScrollReset}),replace:(T,ne,ee)=>e.navigate(T,{replace:!0,state:ne,preventScrollReset:ee?.preventScrollReset})}),[e]),W=e.basename||"/",K=_.useMemo(()=>({router:e,navigator:q,static:!1,basename:W,onError:i}),[e,q,W,i]);return _.createElement(_.Fragment,null,_.createElement(_r.Provider,{value:K},_.createElement(Tl.Provider,{value:f},_.createElement(Iw.Provider,{value:L.current},_.createElement(Am.Provider,{value:y},_.createElement(BM,{basename:W,location:f.location,navigationType:f.historyAction,navigator:q,useTransitions:r},_.createElement(VM,{routes:e.routes,manifest:e.manifest,future:e.future,state:f,isStatic:!1,onError:i})))))),null)}function gS(e,t){return{...e,navigation:t.navigation.state!=="idle"?t.navigation:e.navigation,revalidation:t.revalidation!=="idle"?t.revalidation:e.revalidation,actionData:t.navigation.state!=="submitting"?t.actionData:e.actionData,fetchers:t.fetchers}}var VM=_.memo($M);function $M({routes:e,manifest:t,future:i,state:r,isStatic:o,onError:u}){return yM(e,void 0,{manifest:t,state:r,isStatic:o,onError:u})}function PM({to:e,replace:t,state:i,relative:r}){Ne(Ps()," may be used only in the context of a component.");let{static:o}=_.useContext(Mn);xt(!o," must not be used on the initial render in a . This is a no-op, but you should modify your code so the is only ever rendered in response to some user interaction or state change.");let{matches:u}=_.useContext(li),{pathname:c}=Ci(),f=Xw(),h=El(e,ef(u),c,r==="path"),m=JSON.stringify(h);return _.useEffect(()=>{f(JSON.parse(m),{replace:t,state:i,relative:r})},[f,m,r,t,i]),null}function UM(e){return gM(e.context)}function BM({basename:e="/",children:t=null,location:i,navigationType:r="POP",navigator:o,static:u=!1,useTransitions:c}){Ne(!Ps(),"You cannot render a inside another . You should never have more than one in your app.");let f=e.replace(/^\/*/,"/"),h=_.useMemo(()=>({basename:f,navigator:o,static:u,useTransitions:c,future:{}}),[f,o,u,c]);typeof i=="string"&&(i=wi(i));let{pathname:m="/",search:g="",hash:y="",state:b=null,key:S="default",mask:x}=i,C=_.useMemo(()=>{let R=Yn(m,f);return R==null?null:{location:{pathname:R,search:g,hash:y,state:b,key:S,mask:x},navigationType:r}},[f,m,g,y,b,S,r,x]);return xt(C!=null,` is not able to match the URL "${m}${g}${y}" because it does not start with the basename, so the won't render anything.`),C==null?null:_.createElement(Mn.Provider,{value:h},_.createElement(tf.Provider,{children:t,value:C}))}var Sc="get",xc="application/x-www-form-urlencoded";function nf(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function HM(e){return nf(e)&&e.tagName.toLowerCase()==="button"}function FM(e){return nf(e)&&e.tagName.toLowerCase()==="form"}function kM(e){return nf(e)&&e.tagName.toLowerCase()==="input"}function qM(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function GM(e,t){return e.button===0&&(!t||t==="_self")&&!qM(e)}var ac=null;function IM(){if(ac===null)try{new FormData(document.createElement("form"),0),ac=!1}catch{ac=!0}return ac}var YM=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Fh(e){return e!=null&&!YM.has(e)?(xt(!1,`"${e}" is not a valid \`encType\` for \`