From bacb528de6ac0a016465858aa100f21b27c39c57 Mon Sep 17 00:00:00 2001 From: Snow Lee Date: Sun, 19 Jul 2026 10:51:25 -0700 Subject: [PATCH] feat(web): Installation and Settings are real routes; every page owns a URL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit //install and //settings join /insights and /history as view routes — deep links, reload, and back/forward work; the sidebar menu navigates instead of toggling panel state. Rule recorded in CLAUDE.md: new surfaces are view routes, never URL-less panels (org/hub admin panels are the legacy exceptions). 46/46 e2e incl. deep-link spec. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01VbiaaVM2ACxeRi8ySG9ybc --- CLAUDE.md | 2 +- internal/webapp/frontend/e2e/home.spec.ts | 15 ++++-- internal/webapp/frontend/src/apps/HubApp.tsx | 48 ++++++++++++------- internal/webapp/frontend/src/router.ts | 23 ++++----- .../{index-DDdhKsd5.js => index-B9q7i7UX.js} | 12 ++--- internal/webapp/static/index.html | 2 +- 6 files changed, 60 insertions(+), 42 deletions(-) rename internal/webapp/static/assets/{index-DDdhKsd5.js => index-B9q7i7UX.js} (69%) diff --git a/CLAUDE.md b/CLAUDE.md index 9ae5695..0c964ab 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -44,7 +44,7 @@ Package roles (`internal/`): - **`syncer`** — the heart: `Session.Cycle()` runs one pass: scan → commit local ops → pull peer journals → preserve conflict copies → materialize merged state → push blobs + own journal. Read the package doc comment in `syncer.go` first. `ignore.go` holds the path filter (`.bdriveignore` rules + the `.bdrive` include list), applied symmetrically in scan and materialize; a newly filtered path is dropped from the cache *without* a delete op so opting out locally never deletes remotely. - **`daemon`** — per-mount background loop (detached process, `daemon.pid`/`daemon.log` in the mount's volume dir). Scans every `--scan-interval` (3s), talks to the remote every `--remote-interval` (10s) or immediately after local edits. Re-reads `.bdrive/config.json` each tick; if it vanishes (folder moved/renamed/deleted) the daemon **exits cleanly without propagating deletes** — the next bdrive command at the new location resumes it (self-heal on next touch). - **`config`** — global state under `$BDRIVE_HOME` (default `~/.bdrive`): device identity (`device.json`), settings (`settings.json`: default server + device token + signed-in account), and the mount registry (`mounts.json`, keyed by **stable mount id**, holding only each mount's last-known path). The per-folder `.bdrive/` directory (`project.go`) holds `config.json` with the mount id + volume/remote/include; **nothing is keyed by the folder path**, so renames/moves are free — `ResolveMount` self-heals the registry path, and the volume store lives at `~/.bdrive/volumes//`. `.bdrive/` is never synced and holds no credentials. -- **`webapp`** — the `bdrive web` server, in two modes. Single-volume: `Source` is a `DirSource` (plain folder from disk) or `RemoteSource` (folds journals into a file tree with per-file provenance). Hub: `Root` + `Projects` host many projects on one storage root, each under `//` via `remote.Prefixed`; `ProjectDB` (`projects.go`) is a file-backed registry (JSON, loaded at open, rewritten atomically per change) with create-or-join-by-name semantics, name-scoped per organization. Orgs (`orgs.go`, file-backed `orgs.json`) wall projects by membership (email → owner|member): every per-project route — viewer APIs, uploads, history, shares management, the `/store/*` sync proxy — 403s for non-members, `/api/projects` lists only your orgs' projects, owners mint expiring multi-use invite links (`/join/`), and a pre-org hub migrates all projects into a "default" org (all existing accounts join, oldest owns) at startup. `QuotaProvider` (`quota.go`) is the plan-enforcement seam mirroring `AuthProvider` — CheckWrite/RecordUsage on every write path, CheckSeat on invite redemption; OSS ships only `UnlimitedQuota`, managed deployments swap the provider. Renders markdown (goldmark + Obsidian `[[wikilinks]]`). With `--upload` it accepts writes: browser uploads (`upload.go` — direct-to-storage via presigned URLs when the backend implements `remote.PutSigner`, relayed otherwise; ops journaled under the server's own device) and the per-project `/api/p//store/*` proxy (`store.go`) that whole devices sync through — the `https://` remote backend (`remote/http.go`) is its client; journals are never presigned, only immutable blobs. Frontend is a React + TypeScript app (`webapp/frontend/`, Vite; runtime deps only react, react-dom, @tanstack/react-query, lucide-react) whose **built output is committed** at `webapp/static/` — the `go:embed static` target — so plain `go build` needs no Node; after any `frontend/src` change run `npm run build` there and commit the new `static/` (`frontend/check-dist.sh` verifies freshness; e2e suite: `npm run e2e` — Playwright against the seeded harness in `e2e_serve_test.go`, port 8993). It learns everything from `/api/config` (+ `/api/projects` in hub mode) and never sees storage info or credentials. It uses native History-API path routing (`//` in hub mode, `/` in volume mode, `/join/` for invites — no `#`, slashes stay literal) implemented by the in-repo synchronous router `frontend/src/nav.ts` + `router.ts` (deliberately NOT a router library: react-router v7's startTransition navigation left stale views on screen); `Server.frontend` serves `index.html` as the SPA fallback for any non-asset, non-API/auth/share route so deep links and refreshes resolve (hashed `assets/*` are cached immutable, everything else no-cache), and all client API/asset URLs are root-absolute so a deep path doesn't break relative resolution. Rendered markdown is transformed as a string before mounting and link clicks are delegated on the container — never patch the `dangerouslySetInnerHTML` subtree after commit (React re-applies the markup on unrelated updates and discards DOM patches). **Read heat** (`reads.go`): a `ReadLedger` (hub-only, nil = off, config `reads` block) aggregates read telemetry into daily per-actor buckets, debounced to 10-minute visits, folded into all-time rows past `retention_days` — viewer file/render/download = human (recorded via the project id the `proj()` resolver stashes in the request context), `/s/*` hits = share, device-reported reads (`POST /api/p//reads`) = agent; `/store/*` replication and history `/blob` views are NEVER reads. `GET /api/p//heat?prefix=&days=` returns counts/distinct-readers/last-read only — actor identities (the email/device/token in the buckets) must never appear in an API response. Recording and flushing degrade silently (log once); telemetry must never fail a request or a sync cycle. The frontend shows heat dots on folder listings for members and an admin/org-owner Insights quadrant (reads × staleness). **Hub metadata persistence** (accounts, projects, orgs+invites, shares, devices, read buckets — never blobs or journals) sits behind a pluggable `MetaStore` of typed repos (`db.go`): the service structs (`BuiltinAuth`, `OrgDB`, `ProjectDB`, `ShareDB`, `DeviceRegistry`, `ReadLedger`) keep their in-memory maps + logic and persist each change as one record through a repo (the `ReadRepo` alone is batch-oriented — one flush, one write). Two backends — `db_file.go` (the historical JSON files, still the zero-dep default, reached via the `Open*(path)` constructors) and `db_sql.go` (one `database/sql` impl over pure-Go drivers: `modernc.org/sqlite` locally, `jackc/pgx` for Postgres/Supabase, portable schema + idempotent migrations + transactional multi-row writes). `web.go`'s `database` config (`{driver:file|sqlite|postgres, dsn}`) selects it; file is default and untouched. `db_conformance_test.go` runs the same service ops against every backend. +- **`webapp`** — the `bdrive web` server, in two modes. Single-volume: `Source` is a `DirSource` (plain folder from disk) or `RemoteSource` (folds journals into a file tree with per-file provenance). Hub: `Root` + `Projects` host many projects on one storage root, each under `//` via `remote.Prefixed`; `ProjectDB` (`projects.go`) is a file-backed registry (JSON, loaded at open, rewritten atomically per change) with create-or-join-by-name semantics, name-scoped per organization. Orgs (`orgs.go`, file-backed `orgs.json`) wall projects by membership (email → owner|member): every per-project route — viewer APIs, uploads, history, shares management, the `/store/*` sync proxy — 403s for non-members, `/api/projects` lists only your orgs' projects, owners mint expiring multi-use invite links (`/join/`), and a pre-org hub migrates all projects into a "default" org (all existing accounts join, oldest owns) at startup. `QuotaProvider` (`quota.go`) is the plan-enforcement seam mirroring `AuthProvider` — CheckWrite/RecordUsage on every write path, CheckSeat on invite redemption; OSS ships only `UnlimitedQuota`, managed deployments swap the provider. Renders markdown (goldmark + Obsidian `[[wikilinks]]`). With `--upload` it accepts writes: browser uploads (`upload.go` — direct-to-storage via presigned URLs when the backend implements `remote.PutSigner`, relayed otherwise; ops journaled under the server's own device) and the per-project `/api/p//store/*` proxy (`store.go`) that whole devices sync through — the `https://` remote backend (`remote/http.go`) is its client; journals are never presigned, only immutable blobs. Frontend is a React + TypeScript app (`webapp/frontend/`, Vite; runtime deps only react, react-dom, @tanstack/react-query, lucide-react) whose **built output is committed** at `webapp/static/` — the `go:embed static` target — so plain `go build` needs no Node; after any `frontend/src` change run `npm run build` there and commit the new `static/` (`frontend/check-dist.sh` verifies freshness; e2e suite: `npm run e2e` — Playwright against the seeded harness in `e2e_serve_test.go`, port 8993). It learns everything from `/api/config` (+ `/api/projects` in hub mode) and never sees storage info or credentials. It uses native History-API path routing (`//` in hub mode, `/` in volume mode, `/join/` for invites — no `#`, slashes stay literal). **Every user-facing page owns a URL path**: new surfaces are view routes (`//{insights|history|install|settings}[/]`, `VIEW_ROUTES` in `router.ts`) so deep links, reload, and back/forward always work — never URL-less panel state (the org/hub admin panels are the legacy exceptions; don't add more) implemented by the in-repo synchronous router `frontend/src/nav.ts` + `router.ts` (deliberately NOT a router library: react-router v7's startTransition navigation left stale views on screen); `Server.frontend` serves `index.html` as the SPA fallback for any non-asset, non-API/auth/share route so deep links and refreshes resolve (hashed `assets/*` are cached immutable, everything else no-cache), and all client API/asset URLs are root-absolute so a deep path doesn't break relative resolution. Rendered markdown is transformed as a string before mounting and link clicks are delegated on the container — never patch the `dangerouslySetInnerHTML` subtree after commit (React re-applies the markup on unrelated updates and discards DOM patches). **Read heat** (`reads.go`): a `ReadLedger` (hub-only, nil = off, config `reads` block) aggregates read telemetry into daily per-actor buckets, debounced to 10-minute visits, folded into all-time rows past `retention_days` — viewer file/render/download = human (recorded via the project id the `proj()` resolver stashes in the request context), `/s/*` hits = share, device-reported reads (`POST /api/p//reads`) = agent; `/store/*` replication and history `/blob` views are NEVER reads. `GET /api/p//heat?prefix=&days=` returns counts/distinct-readers/last-read only — actor identities (the email/device/token in the buckets) must never appear in an API response. Recording and flushing degrade silently (log once); telemetry must never fail a request or a sync cycle. The frontend shows heat dots on folder listings for members and an admin/org-owner Insights quadrant (reads × staleness). **Hub metadata persistence** (accounts, projects, orgs+invites, shares, devices, read buckets — never blobs or journals) sits behind a pluggable `MetaStore` of typed repos (`db.go`): the service structs (`BuiltinAuth`, `OrgDB`, `ProjectDB`, `ShareDB`, `DeviceRegistry`, `ReadLedger`) keep their in-memory maps + logic and persist each change as one record through a repo (the `ReadRepo` alone is batch-oriented — one flush, one write). Two backends — `db_file.go` (the historical JSON files, still the zero-dep default, reached via the `Open*(path)` constructors) and `db_sql.go` (one `database/sql` impl over pure-Go drivers: `modernc.org/sqlite` locally, `jackc/pgx` for Postgres/Supabase, portable schema + idempotent migrations + transactional multi-row writes). `web.go`'s `database` config (`{driver:file|sqlite|postgres, dsn}`) selects it; file is default and untouched. `db_conformance_test.go` runs the same service ops against every backend. `cmd/bdrive/` is a thin cobra CLI over these packages (`login`, `logout`, `init`, `stop`, `sync`, `status`, `log`, `url`, `web`, `whoami`, `daemon`, `version` — `mnt`/`umnt`/`remote` are gone; `init` is the front door and `stop` pauses). `bdrive login` signs the device in (bare form uses the remembered server or `config.DefaultServer` = beardrive.ai; loopback-callback browser flow in `login.go`, `--device` for headless) and stores server+token+account in `settings.json`; `bdrive logout` clears the saved token+account (keeps the remembered server unless `--forget`). Switching hubs is `bdrive login ` then re-`init` — `init` is the only thing that writes a folder's remote (always a hub, `server + "/p/" + id`); there is no client command to point a folder at a raw bucket. `bdrive init` is interactive on a TTY (survey menus: create-new vs connect-existing with a project list; whole-folder vs `--shared `, which becomes the include list) with full flag bypass (`--name/--project/--shared/--yes`) and never prompts without a TTY; it runs the login flow first when there is no session, writes `.bdrive/config.json`, seeds `.bdriveignore`, and starts sync via `startSync`; re-running it resumes — including after a folder move. `bdrive web -c config.json` configures the server from a file, explicit flags winning. diff --git a/internal/webapp/frontend/e2e/home.spec.ts b/internal/webapp/frontend/e2e/home.spec.ts index f398cbb..4169f19 100644 --- a/internal/webapp/frontend/e2e/home.spec.ts +++ b/internal/webapp/frontend/e2e/home.spec.ts @@ -164,21 +164,26 @@ test("insights scopes to the selected folder via the ⋯ menu", async ({ page }) await expect(page.locator(".insights .dl-sub")).toContainText("notes and everything in it"); }); -test("project menu: Dashboard, Installation, Settings", async ({ page }) => { +test("project menu pages each own a URL: Dashboard, Installation, Settings", async ({ page }) => { await login(page); - await wikiId(page); + const pid = await wikiId(page); await page.click("#nav-dashboard"); + await page.waitForURL(`/${pid}/insights`); await expect(page.locator(".insights .in-title")).toContainText("Knowledge insights"); await expect(page.locator("#nav-dashboard")).toHaveClass(/active/); await page.click("#nav-install"); + await page.waitForURL(`/${pid}/install`); await expect(page.locator("#crumb")).toHaveText("Installation"); await expect(page.locator("#nav-install")).toHaveClass(/active/); await page.click("#nav-settings"); + await page.waitForURL(`/${pid}/settings`); await expect(page.locator("#crumb")).toHaveText("Project settings"); await expect(page.locator(".project-settings h2")).toHaveText("wiki"); - // Regression: from a panel, Dashboard must work even when the URL is - // already /insights (same-path navigation can't rely on route change). await page.click("#nav-dashboard"); - await expect(page.locator(".insights .in-title")).toContainText("Knowledge insights"); + await page.waitForURL(`/${pid}/insights`); await expect(page.locator("#nav-dashboard")).toHaveClass(/active/); + // Deep link + reload land on the page, like any URL. + await page.goto(`/${pid}/settings`); + await expect(page.locator(".project-settings h2")).toHaveText("wiki"); + await expect(page.locator("#nav-settings")).toHaveClass(/active/); }); diff --git a/internal/webapp/frontend/src/apps/HubApp.tsx b/internal/webapp/frontend/src/apps/HubApp.tsx index a115dda..bf5df7c 100644 --- a/internal/webapp/frontend/src/apps/HubApp.tsx +++ b/internal/webapp/frontend/src/apps/HubApp.tsx @@ -23,7 +23,7 @@ export default function HubApp({ config }: { config: ServerConfig }) { const [joinedOrgId, setJoinedOrgId] = useState(null); // Admin panels replace the content pane without touching the URL (they // were never routes in the classic app); any navigation closes them. - const [panel, setPanel] = useState(null); + const [panel, setPanel] = useState(null); useEffect(() => setPanel(null), [pathname]); const joinToken = useMemo(() => { @@ -141,11 +141,7 @@ export default function HubApp({ config }: { config: ServerConfig }) { const activePanel = panel?.kind === "hub" ? { crumb: "Signup & access", body: } - : panel?.kind === "project" - ? { crumb: "Project settings", body: } - : panel?.kind === "install" - ? { crumb: "Installation", body:
} - : panelOrg + : panelOrg ? { crumb: panelOrg.name, body: ( @@ -159,6 +155,20 @@ export default function HubApp({ config }: { config: ServerConfig }) { } : null; + const routePage = + route.view === "settings" + ? { crumb: "Project settings", body: } + : route.view === "install" + ? { + crumb: "Installation", + body: ( +
+ +
+ ), + } + : null; + // Landing ("/") and unknown project ids both resolve to a real project // URL; replace so back/forward never bounces through the redirect. if (route.project !== current.id) { @@ -182,28 +192,30 @@ export default function HubApp({ config }: { config: ServerConfig }) { projects={projects} currentId={current.id} menu={{ - active: - panel?.kind === "project" - ? "settings" - : panel?.kind === "install" + active: panel + ? null + : route.view === "insights" + ? "dashboard" + : route.view === "install" ? "install" - : !panel && route.view === "insights" - ? "dashboard" + : route.view === "settings" + ? "settings" : null, + // Each page is a URL; explicitly close overlay panels because + // same-path navigation doesn't change pathname. onDashboard: () => { - // Explicitly close any panel: navigating to the SAME url - // (already on /insights) doesn't change pathname, so the - // route-change effect can't do it. setPanel(null); navigate(urlForView("insights", current.id)); closeSidebarOnMobile(); }, onInstall: () => { - setPanel({ kind: "install" }); + setPanel(null); + navigate(urlForView("install", current.id)); closeSidebarOnMobile(); }, onSettings: () => { - setPanel({ kind: "project" }); + setPanel(null); + navigate(urlForView("settings", current.id)); closeSidebarOnMobile(); }, }} @@ -211,7 +223,7 @@ export default function HubApp({ config }: { config: ServerConfig }) { ), orgBar: accountBar, }} - panel={activePanel} + panel={activePanel || routePage} onClosePanel={() => setPanel(null)} /> ); diff --git a/internal/webapp/frontend/src/router.ts b/internal/webapp/frontend/src/router.ts index f36787c..96d20d8 100644 --- a/internal/webapp/frontend/src/router.ts +++ b/internal/webapp/frontend/src/router.ts @@ -16,16 +16,21 @@ export function decodePath(p: string): string { // Special views are RESTful routes under the project — the first segment // after the project id is reserved when it names a view: -// //insights the Insights dashboard +// //insights[/] the Insights dashboard (optionally scoped) // //history[/] change feed (project / subtree / file) -// (Root-level files literally named "insights" or "history" lose the URL -// shortcut and remain reachable through the tree.) -export const VIEW_ROUTES = new Set(["insights", "history"]); +// //install connect-a-device guide +// //settings project settings +// Rule: every page gets its own URL path (see CLAUDE.md) — new surfaces are +// view routes here, not ephemeral panel state. (Root-level files literally +// named like a view lose the URL shortcut and remain reachable via the tree.) +export const VIEW_ROUTES = new Set(["insights", "history", "install", "settings"]); + +export type ViewName = "insights" | "history" | "install" | "settings"; export interface Route { project?: string; path: string; - view?: "insights" | "history"; + view?: ViewName; viewTarget?: string; } @@ -38,7 +43,7 @@ export function parseRoute(pathname: string, mode: "volume" | "hub"): Route { const seg = r.path.indexOf("/"); const head = seg === -1 ? r.path : r.path.slice(0, seg); if (VIEW_ROUTES.has(head)) { - r.view = head as "insights" | "history"; + r.view = head as ViewName; r.viewTarget = seg === -1 ? "" : r.path.slice(seg + 1).replace(/\/+$/, ""); r.path = ""; } @@ -53,11 +58,7 @@ export function urlForPath(path: string, projectId?: string): string { } // The URL for a special view of a project. -export function urlForView( - view: "insights" | "history", - projectId?: string, - target?: string, -): string { +export function urlForView(view: ViewName, projectId?: string, target?: string): string { let s = (projectId ? "/" + projectId : "") + "/" + view; if (target) s += "/" + encodePath(target.replace(/\/+$/, "")); return s; diff --git a/internal/webapp/static/assets/index-DDdhKsd5.js b/internal/webapp/static/assets/index-B9q7i7UX.js similarity index 69% rename from internal/webapp/static/assets/index-DDdhKsd5.js rename to internal/webapp/static/assets/index-B9q7i7UX.js index 1584967..08f206c 100644 --- a/internal/webapp/static/assets/index-DDdhKsd5.js +++ b/internal/webapp/static/assets/index-B9q7i7UX.js @@ -1,11 +1,11 @@ -(function(){const c=document.createElement("link").relList;if(c&&c.supports&&c.supports("modulepreload"))return;for(const d of document.querySelectorAll('link[rel="modulepreload"]'))f(d);new MutationObserver(d=>{for(const m of d)if(m.type==="childList")for(const g of m.addedNodes)g.tagName==="LINK"&&g.rel==="modulepreload"&&f(g)}).observe(document,{childList:!0,subtree:!0});function r(d){const m={};return d.integrity&&(m.integrity=d.integrity),d.referrerPolicy&&(m.referrerPolicy=d.referrerPolicy),d.crossOrigin==="use-credentials"?m.credentials="include":d.crossOrigin==="anonymous"?m.credentials="omit":m.credentials="same-origin",m}function f(d){if(d.ep)return;d.ep=!0;const m=r(d);fetch(d.href,m)}})();var Ys={exports:{}},Xn={};var yh;function Bv(){if(yh)return Xn;yh=1;var i=Symbol.for("react.transitional.element"),c=Symbol.for("react.fragment");function r(f,d,m){var g=null;if(m!==void 0&&(g=""+m),d.key!==void 0&&(g=""+d.key),"key"in d){m={};for(var A in d)A!=="key"&&(m[A]=d[A])}else m=d;return d=m.ref,{$$typeof:i,type:f,key:g,ref:d!==void 0?d:null,props:m}}return Xn.Fragment=c,Xn.jsx=r,Xn.jsxs=r,Xn}var vh;function Lv(){return vh||(vh=1,Ys.exports=Bv()),Ys.exports}var o=Lv(),Gs={exports:{}},W={};var ph;function Yv(){if(ph)return W;ph=1;var i=Symbol.for("react.transitional.element"),c=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),f=Symbol.for("react.strict_mode"),d=Symbol.for("react.profiler"),m=Symbol.for("react.consumer"),g=Symbol.for("react.context"),A=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),y=Symbol.for("react.memo"),M=Symbol.for("react.lazy"),E=Symbol.for("react.activity"),x=Symbol.iterator;function q(S){return S===null||typeof S!="object"?null:(S=x&&S[x]||S["@@iterator"],typeof S=="function"?S:null)}var z={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},w=Object.assign,Y={};function F(S,H,L){this.props=S,this.context=H,this.refs=Y,this.updater=L||z}F.prototype.isReactComponent={},F.prototype.setState=function(S,H){if(typeof S!="object"&&typeof S!="function"&&S!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,S,H,"setState")},F.prototype.forceUpdate=function(S){this.updater.enqueueForceUpdate(this,S,"forceUpdate")};function yt(){}yt.prototype=F.prototype;function ot(S,H,L){this.props=S,this.context=H,this.refs=Y,this.updater=L||z}var zt=ot.prototype=new yt;zt.constructor=ot,w(zt,F.prototype),zt.isPureReactComponent=!0;var lt=Array.isArray;function Nt(){}var $={H:null,A:null,T:null,S:null},gt=Object.prototype.hasOwnProperty;function wt(S,H,L){var G=L.ref;return{$$typeof:i,type:S,key:H,ref:G!==void 0?G:null,props:L}}function ue(S,H){return wt(S.type,H,S.props)}function le(S){return typeof S=="object"&&S!==null&&S.$$typeof===i}function Dt(S){var H={"=":"=0",":":"=2"};return"$"+S.replace(/[=:]/g,function(L){return H[L]})}var ce=/\/+/g;function Ut(S,H){return typeof S=="object"&&S!==null&&S.key!=null?Dt(""+S.key):H.toString(36)}function kt(S){switch(S.status){case"fulfilled":return S.value;case"rejected":throw S.reason;default:switch(typeof S.status=="string"?S.then(Nt,Nt):(S.status="pending",S.then(function(H){S.status==="pending"&&(S.status="fulfilled",S.value=H)},function(H){S.status==="pending"&&(S.status="rejected",S.reason=H)})),S.status){case"fulfilled":return S.value;case"rejected":throw S.reason}}throw S}function D(S,H,L,G,V){var et=typeof S;(et==="undefined"||et==="boolean")&&(S=null);var rt=!1;if(S===null)rt=!0;else switch(et){case"bigint":case"string":case"number":rt=!0;break;case"object":switch(S.$$typeof){case i:case c:rt=!0;break;case M:return rt=S._init,D(rt(S._payload),H,L,G,V)}}if(rt)return V=V(S),rt=G===""?"."+Ut(S,0):G,lt(V)?(L="",rt!=null&&(L=rt.replace(ce,"$&/")+"/"),D(V,H,L,"",function(Xl){return Xl})):V!=null&&(le(V)&&(V=ue(V,L+(V.key==null||S&&S.key===V.key?"":(""+V.key).replace(ce,"$&/")+"/")+rt)),H.push(V)),1;rt=0;var Vt=G===""?".":G+":";if(lt(S))for(var Rt=0;Rt>>1,dt=D[vt];if(0>>1;vtd(L,k))Gd(V,L)?(D[vt]=V,D[G]=k,vt=G):(D[vt]=L,D[H]=k,vt=H);else if(Gd(V,k))D[vt]=V,D[G]=k,vt=G;else break t}}return B}function d(D,B){var k=D.sortIndex-B.sortIndex;return k!==0?k:D.id-B.id}if(i.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var m=performance;i.unstable_now=function(){return m.now()}}else{var g=Date,A=g.now();i.unstable_now=function(){return g.now()-A}}var p=[],y=[],M=1,E=null,x=3,q=!1,z=!1,w=!1,Y=!1,F=typeof setTimeout=="function"?setTimeout:null,yt=typeof clearTimeout=="function"?clearTimeout:null,ot=typeof setImmediate<"u"?setImmediate:null;function zt(D){for(var B=r(y);B!==null;){if(B.callback===null)f(y);else if(B.startTime<=D)f(y),B.sortIndex=B.expirationTime,c(p,B);else break;B=r(y)}}function lt(D){if(w=!1,zt(D),!z)if(r(p)!==null)z=!0,Nt||(Nt=!0,Dt());else{var B=r(y);B!==null&&kt(lt,B.startTime-D)}}var Nt=!1,$=-1,gt=5,wt=-1;function ue(){return Y?!0:!(i.unstable_now()-wtD&&ue());){var vt=E.callback;if(typeof vt=="function"){E.callback=null,x=E.priorityLevel;var dt=vt(E.expirationTime<=D);if(D=i.unstable_now(),typeof dt=="function"){E.callback=dt,zt(D),B=!0;break e}E===r(p)&&f(p),zt(D)}else f(p);E=r(p)}if(E!==null)B=!0;else{var S=r(y);S!==null&&kt(lt,S.startTime-D),B=!1}}break t}finally{E=null,x=k,q=!1}B=void 0}}finally{B?Dt():Nt=!1}}}var Dt;if(typeof ot=="function")Dt=function(){ot(le)};else if(typeof MessageChannel<"u"){var ce=new MessageChannel,Ut=ce.port2;ce.port1.onmessage=le,Dt=function(){Ut.postMessage(null)}}else Dt=function(){F(le,0)};function kt(D,B){$=F(function(){D(i.unstable_now())},B)}i.unstable_IdlePriority=5,i.unstable_ImmediatePriority=1,i.unstable_LowPriority=4,i.unstable_NormalPriority=3,i.unstable_Profiling=null,i.unstable_UserBlockingPriority=2,i.unstable_cancelCallback=function(D){D.callback=null},i.unstable_forceFrameRate=function(D){0>D||125vt?(D.sortIndex=k,c(y,D),r(p)===null&&D===r(y)&&(w?(yt($),$=-1):w=!0,kt(lt,k-vt))):(D.sortIndex=dt,c(p,D),z||q||(z=!0,Nt||(Nt=!0,Dt()))),D},i.unstable_shouldYield=ue,i.unstable_wrapCallback=function(D){var B=x;return function(){var k=x;x=B;try{return D.apply(this,arguments)}finally{x=k}}}})(Zs)),Zs}var Sh;function Xv(){return Sh||(Sh=1,Ks.exports=Gv()),Ks.exports}var ks={exports:{}},ae={};var xh;function Kv(){if(xh)return ae;xh=1;var i=ir();function c(p){var y="https://react.dev/errors/"+p;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(i)}catch(c){console.error(c)}}return i(),ks.exports=Kv(),ks.exports}var Eh;function kv(){if(Eh)return Kn;Eh=1;var i=Xv(),c=ir(),r=Zv();function f(t){var e="https://react.dev/errors/"+t;if(1dt||(t.current=vt[dt],vt[dt]=null,dt--)}function L(t,e){dt++,vt[dt]=t.current,t.current=e}var G=S(null),V=S(null),et=S(null),rt=S(null);function Vt(t,e){switch(L(et,e),L(V,t),L(G,null),e.nodeType){case 9:case 11:t=(t=e.documentElement)&&(t=t.namespaceURI)?Qd(t):0;break;default:if(t=e.tagName,e=e.namespaceURI)e=Qd(e),t=Bd(e,t);else switch(t){case"svg":t=1;break;case"math":t=2;break;default:t=0}}H(G),L(G,t)}function Rt(){H(G),H(V),H(et)}function Xl(t){t.memoizedState!==null&&L(rt,t);var e=G.current,l=Bd(e,t.type);e!==l&&(L(V,t),L(G,l))}function ml(t){V.current===t&&(H(G),H(V)),rt.current===t&&(H(rt),Bn._currentValue=k)}var yl,ei;function Ce(t){if(yl===void 0)try{throw Error()}catch(l){var e=l.stack.trim().match(/\n( *(at )?)/);yl=e&&e[1]||"",ei=-1{for(const m of d)if(m.type==="childList")for(const g of m.addedNodes)g.tagName==="LINK"&&g.rel==="modulepreload"&&f(g)}).observe(document,{childList:!0,subtree:!0});function r(d){const m={};return d.integrity&&(m.integrity=d.integrity),d.referrerPolicy&&(m.referrerPolicy=d.referrerPolicy),d.crossOrigin==="use-credentials"?m.credentials="include":d.crossOrigin==="anonymous"?m.credentials="omit":m.credentials="same-origin",m}function f(d){if(d.ep)return;d.ep=!0;const m=r(d);fetch(d.href,m)}})();var Gs={exports:{}},Xn={};var yh;function Bv(){if(yh)return Xn;yh=1;var i=Symbol.for("react.transitional.element"),c=Symbol.for("react.fragment");function r(f,d,m){var g=null;if(m!==void 0&&(g=""+m),d.key!==void 0&&(g=""+d.key),"key"in d){m={};for(var A in d)A!=="key"&&(m[A]=d[A])}else m=d;return d=m.ref,{$$typeof:i,type:f,key:g,ref:d!==void 0?d:null,props:m}}return Xn.Fragment=c,Xn.jsx=r,Xn.jsxs=r,Xn}var vh;function Lv(){return vh||(vh=1,Gs.exports=Bv()),Gs.exports}var o=Lv(),Xs={exports:{}},W={};var ph;function Yv(){if(ph)return W;ph=1;var i=Symbol.for("react.transitional.element"),c=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),f=Symbol.for("react.strict_mode"),d=Symbol.for("react.profiler"),m=Symbol.for("react.consumer"),g=Symbol.for("react.context"),A=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),y=Symbol.for("react.memo"),M=Symbol.for("react.lazy"),E=Symbol.for("react.activity"),x=Symbol.iterator;function q(S){return S===null||typeof S!="object"?null:(S=x&&S[x]||S["@@iterator"],typeof S=="function"?S:null)}var z={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},w=Object.assign,Y={};function $(S,H,L){this.props=S,this.context=H,this.refs=Y,this.updater=L||z}$.prototype.isReactComponent={},$.prototype.setState=function(S,H){if(typeof S!="object"&&typeof S!="function"&&S!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,S,H,"setState")},$.prototype.forceUpdate=function(S){this.updater.enqueueForceUpdate(this,S,"forceUpdate")};function yt(){}yt.prototype=$.prototype;function ot(S,H,L){this.props=S,this.context=H,this.refs=Y,this.updater=L||z}var Ct=ot.prototype=new yt;Ct.constructor=ot,w(Ct,$.prototype),Ct.isPureReactComponent=!0;var Rt=Array.isArray;function et(){}var k={H:null,A:null,T:null,S:null},gt=Object.prototype.hasOwnProperty;function wt(S,H,L){var G=L.ref;return{$$typeof:i,type:S,key:H,ref:G!==void 0?G:null,props:L}}function ue(S,H){return wt(S.type,H,S.props)}function le(S){return typeof S=="object"&&S!==null&&S.$$typeof===i}function _t(S){var H={"=":"=0",":":"=2"};return"$"+S.replace(/[=:]/g,function(L){return H[L]})}var ce=/\/+/g;function Ut(S,H){return typeof S=="object"&&S!==null&&S.key!=null?_t(""+S.key):H.toString(36)}function kt(S){switch(S.status){case"fulfilled":return S.value;case"rejected":throw S.reason;default:switch(typeof S.status=="string"?S.then(et,et):(S.status="pending",S.then(function(H){S.status==="pending"&&(S.status="fulfilled",S.value=H)},function(H){S.status==="pending"&&(S.status="rejected",S.reason=H)})),S.status){case"fulfilled":return S.value;case"rejected":throw S.reason}}throw S}function D(S,H,L,G,J){var lt=typeof S;(lt==="undefined"||lt==="boolean")&&(S=null);var rt=!1;if(S===null)rt=!0;else switch(lt){case"bigint":case"string":case"number":rt=!0;break;case"object":switch(S.$$typeof){case i:case c:rt=!0;break;case M:return rt=S._init,D(rt(S._payload),H,L,G,J)}}if(rt)return J=J(S),rt=G===""?"."+Ut(S,0):G,Rt(J)?(L="",rt!=null&&(L=rt.replace(ce,"$&/")+"/"),D(J,H,L,"",function(Xl){return Xl})):J!=null&&(le(J)&&(J=ue(J,L+(J.key==null||S&&S.key===J.key?"":(""+J.key).replace(ce,"$&/")+"/")+rt)),H.push(J)),1;rt=0;var Vt=G===""?".":G+":";if(Rt(S))for(var Dt=0;Dt>>1,dt=D[vt];if(0>>1;vtd(L,V))Gd(J,L)?(D[vt]=J,D[G]=V,vt=G):(D[vt]=L,D[H]=V,vt=H);else if(Gd(J,V))D[vt]=J,D[G]=V,vt=G;else break t}}return B}function d(D,B){var V=D.sortIndex-B.sortIndex;return V!==0?V:D.id-B.id}if(i.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var m=performance;i.unstable_now=function(){return m.now()}}else{var g=Date,A=g.now();i.unstable_now=function(){return g.now()-A}}var p=[],y=[],M=1,E=null,x=3,q=!1,z=!1,w=!1,Y=!1,$=typeof setTimeout=="function"?setTimeout:null,yt=typeof clearTimeout=="function"?clearTimeout:null,ot=typeof setImmediate<"u"?setImmediate:null;function Ct(D){for(var B=r(y);B!==null;){if(B.callback===null)f(y);else if(B.startTime<=D)f(y),B.sortIndex=B.expirationTime,c(p,B);else break;B=r(y)}}function Rt(D){if(w=!1,Ct(D),!z)if(r(p)!==null)z=!0,et||(et=!0,_t());else{var B=r(y);B!==null&&kt(Rt,B.startTime-D)}}var et=!1,k=-1,gt=5,wt=-1;function ue(){return Y?!0:!(i.unstable_now()-wtD&&ue());){var vt=E.callback;if(typeof vt=="function"){E.callback=null,x=E.priorityLevel;var dt=vt(E.expirationTime<=D);if(D=i.unstable_now(),typeof dt=="function"){E.callback=dt,Ct(D),B=!0;break e}E===r(p)&&f(p),Ct(D)}else f(p);E=r(p)}if(E!==null)B=!0;else{var S=r(y);S!==null&&kt(Rt,S.startTime-D),B=!1}}break t}finally{E=null,x=V,q=!1}B=void 0}}finally{B?_t():et=!1}}}var _t;if(typeof ot=="function")_t=function(){ot(le)};else if(typeof MessageChannel<"u"){var ce=new MessageChannel,Ut=ce.port2;ce.port1.onmessage=le,_t=function(){Ut.postMessage(null)}}else _t=function(){$(le,0)};function kt(D,B){k=$(function(){D(i.unstable_now())},B)}i.unstable_IdlePriority=5,i.unstable_ImmediatePriority=1,i.unstable_LowPriority=4,i.unstable_NormalPriority=3,i.unstable_Profiling=null,i.unstable_UserBlockingPriority=2,i.unstable_cancelCallback=function(D){D.callback=null},i.unstable_forceFrameRate=function(D){0>D||125vt?(D.sortIndex=V,c(y,D),r(p)===null&&D===r(y)&&(w?(yt(k),k=-1):w=!0,kt(Rt,V-vt))):(D.sortIndex=dt,c(p,D),z||q||(z=!0,et||(et=!0,_t()))),D},i.unstable_shouldYield=ue,i.unstable_wrapCallback=function(D){var B=x;return function(){var V=x;x=B;try{return D.apply(this,arguments)}finally{x=V}}}})(ks)),ks}var Sh;function Xv(){return Sh||(Sh=1,Zs.exports=Gv()),Zs.exports}var Vs={exports:{}},ae={};var xh;function Kv(){if(xh)return ae;xh=1;var i=ir();function c(p){var y="https://react.dev/errors/"+p;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(i)}catch(c){console.error(c)}}return i(),Vs.exports=Kv(),Vs.exports}var Eh;function kv(){if(Eh)return Kn;Eh=1;var i=Xv(),c=ir(),r=Zv();function f(t){var e="https://react.dev/errors/"+t;if(1dt||(t.current=vt[dt],vt[dt]=null,dt--)}function L(t,e){dt++,vt[dt]=t.current,t.current=e}var G=S(null),J=S(null),lt=S(null),rt=S(null);function Vt(t,e){switch(L(lt,e),L(J,t),L(G,null),e.nodeType){case 9:case 11:t=(t=e.documentElement)&&(t=t.namespaceURI)?Qd(t):0;break;default:if(t=e.tagName,e=e.namespaceURI)e=Qd(e),t=Bd(e,t);else switch(t){case"svg":t=1;break;case"math":t=2;break;default:t=0}}H(G),L(G,t)}function Dt(){H(G),H(J),H(lt)}function Xl(t){t.memoizedState!==null&&L(rt,t);var e=G.current,l=Bd(e,t.type);e!==l&&(L(J,t),L(G,l))}function ml(t){J.current===t&&(H(G),H(J)),rt.current===t&&(H(rt),Bn._currentValue=V)}var yl,li;function ze(t){if(yl===void 0)try{throw Error()}catch(l){var e=l.stack.trim().match(/\n( *(at )?)/);yl=e&&e[1]||"",li=-1)":-1n||v[a]!==N[n]){var _=` -`+v[a].replace(" at new "," at ");return t.displayName&&_.includes("")&&(_=_.replace("",t.displayName)),_}while(1<=a&&0<=n);break}}}finally{Le=!1,Error.prepareStackTrace=l}return(l=t?t.displayName||t.name:"")?Ce(l):""}function Mu(t,e){switch(t.tag){case 26:case 27:case 5:return Ce(t.type);case 16:return Ce("Lazy");case 13:return t.child!==e&&e!==null?Ce("Suspense Fallback"):Ce("Suspense");case 19:return Ce("SuspenseList");case 0:case 15:return se(t.type,!1);case 11:return se(t.type.render,!1);case 1:return se(t.type,!0);case 31:return Ce("Activity");default:return""}}function li(t){try{var e="",l=null;do e+=Mu(t,l),l=t,t=t.return;while(t);return e}catch(a){return` +`+v[a].replace(" at new "," at ");return t.displayName&&_.includes("")&&(_=_.replace("",t.displayName)),_}while(1<=a&&0<=n);break}}}finally{Ye=!1,Error.prepareStackTrace=l}return(l=t?t.displayName||t.name:"")?ze(l):""}function Au(t,e){switch(t.tag){case 26:case 27:case 5:return ze(t.type);case 16:return ze("Lazy");case 13:return t.child!==e&&e!==null?ze("Suspense Fallback"):ze("Suspense");case 19:return ze("SuspenseList");case 0:case 15:return se(t.type,!1);case 11:return se(t.type.render,!1);case 1:return se(t.type,!0);case 31:return ze("Activity");default:return""}}function ai(t){try{var e="",l=null;do e+=Au(t,l),l=t,t=t.return;while(t);return e}catch(a){return` Error generating stack: `+a.message+` -`+a.stack}}var P=Object.prototype.hasOwnProperty,ft=i.unstable_scheduleCallback,xt=i.unstable_cancelCallback,Fa=i.unstable_shouldYield,Au=i.unstable_requestPaint,ne=i.unstable_now,bm=i.unstable_getCurrentPriorityLevel,mr=i.unstable_ImmediatePriority,yr=i.unstable_UserBlockingPriority,ai=i.unstable_NormalPriority,Sm=i.unstable_LowPriority,vr=i.unstable_IdlePriority,xm=i.log,jm=i.unstable_setDisableYieldValue,$a=null,ge=null;function vl(t){if(typeof xm=="function"&&jm(t),ge&&typeof ge.setStrictMode=="function")try{ge.setStrictMode($a,t)}catch{}}var be=Math.clz32?Math.clz32:Nm,Em=Math.log,Tm=Math.LN2;function Nm(t){return t>>>=0,t===0?32:31-(Em(t)/Tm|0)|0}var ni=256,ii=262144,ui=4194304;function Kl(t){var e=t&42;if(e!==0)return e;switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return t&261888;case 262144:case 524288:case 1048576:case 2097152:return t&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return t&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return t}}function ci(t,e,l){var a=t.pendingLanes;if(a===0)return 0;var n=0,u=t.suspendedLanes,s=t.pingedLanes;t=t.warmLanes;var h=a&134217727;return h!==0?(a=h&~u,a!==0?n=Kl(a):(s&=h,s!==0?n=Kl(s):l||(l=h&~t,l!==0&&(n=Kl(l))))):(h=a&~u,h!==0?n=Kl(h):s!==0?n=Kl(s):l||(l=a&~t,l!==0&&(n=Kl(l)))),n===0?0:e!==0&&e!==n&&(e&u)===0&&(u=n&-n,l=e&-e,u>=l||u===32&&(l&4194048)!==0)?e:n}function Wa(t,e){return(t.pendingLanes&~(t.suspendedLanes&~t.pingedLanes)&e)===0}function Om(t,e){switch(t){case 1:case 2:case 4:case 8:case 64:return e+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function pr(){var t=ui;return ui<<=1,(ui&62914560)===0&&(ui=4194304),t}function Cu(t){for(var e=[],l=0;31>l;l++)e.push(t);return e}function Ia(t,e){t.pendingLanes|=e,e!==268435456&&(t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0)}function Mm(t,e,l,a,n,u){var s=t.pendingLanes;t.pendingLanes=l,t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0,t.expiredLanes&=l,t.entangledLanes&=l,t.errorRecoveryDisabledLanes&=l,t.shellSuspendCounter=0;var h=t.entanglements,v=t.expirationTimes,N=t.hiddenUpdates;for(l=s&~l;0"u")return null;try{return t.activeElement||t.body}catch{return t.body}}var Rm=/[\n"\\]/g;function _e(t){return t.replace(Rm,function(e){return"\\"+e.charCodeAt(0).toString(16)+" "})}function Hu(t,e,l,a,n,u,s,h){t.name="",s!=null&&typeof s!="function"&&typeof s!="symbol"&&typeof s!="boolean"?t.type=s:t.removeAttribute("type"),e!=null?s==="number"?(e===0&&t.value===""||t.value!=e)&&(t.value=""+ze(e)):t.value!==""+ze(e)&&(t.value=""+ze(e)):s!=="submit"&&s!=="reset"||t.removeAttribute("value"),e!=null?qu(t,s,ze(e)):l!=null?qu(t,s,ze(l)):a!=null&&t.removeAttribute("value"),n==null&&u!=null&&(t.defaultChecked=!!u),n!=null&&(t.checked=n&&typeof n!="function"&&typeof n!="symbol"),h!=null&&typeof h!="function"&&typeof h!="symbol"&&typeof h!="boolean"?t.name=""+ze(h):t.removeAttribute("name")}function zr(t,e,l,a,n,u,s,h){if(u!=null&&typeof u!="function"&&typeof u!="symbol"&&typeof u!="boolean"&&(t.type=u),e!=null||l!=null){if(!(u!=="submit"&&u!=="reset"||e!=null)){Uu(t);return}l=l!=null?""+ze(l):"",e=e!=null?""+ze(e):l,h||e===t.value||(t.value=e),t.defaultValue=e}a=a??n,a=typeof a!="function"&&typeof a!="symbol"&&!!a,t.checked=h?t.checked:!!a,t.defaultChecked=!!a,s!=null&&typeof s!="function"&&typeof s!="symbol"&&typeof s!="boolean"&&(t.name=s),Uu(t)}function qu(t,e,l){e==="number"&&fi(t.ownerDocument)===t||t.defaultValue===""+l||(t.defaultValue=""+l)}function ma(t,e,l,a){if(t=t.options,e){e={};for(var n=0;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Yu=!1;if(We)try{var ln={};Object.defineProperty(ln,"passive",{get:function(){Yu=!0}}),window.addEventListener("test",ln,ln),window.removeEventListener("test",ln,ln)}catch{Yu=!1}var gl=null,Gu=null,di=null;function wr(){if(di)return di;var t,e=Gu,l=e.length,a,n="value"in gl?gl.value:gl.textContent,u=n.length;for(t=0;t=un),Xr=" ",Kr=!1;function Zr(t,e){switch(t){case"keyup":return cy.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function kr(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var ga=!1;function ry(t,e){switch(t){case"compositionend":return kr(e);case"keypress":return e.which!==32?null:(Kr=!0,Xr);case"textInput":return t=e.data,t===Xr&&Kr?null:t;default:return null}}function fy(t,e){if(ga)return t==="compositionend"||!Vu&&Zr(t,e)?(t=wr(),di=Gu=gl=null,ga=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1=e)return{node:l,offset:e-t};t=a}t:{for(;l;){if(l.nextSibling){l=l.nextSibling;break t}l=l.parentNode}l=void 0}l=tf(l)}}function lf(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?lf(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function af(t){t=t!=null&&t.ownerDocument!=null&&t.ownerDocument.defaultView!=null?t.ownerDocument.defaultView:window;for(var e=fi(t.document);e instanceof t.HTMLIFrameElement;){try{var l=typeof e.contentWindow.location.href=="string"}catch{l=!1}if(l)t=e.contentWindow;else break;e=fi(t.document)}return e}function $u(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e&&(e==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||e==="textarea"||t.contentEditable==="true")}var gy=We&&"documentMode"in document&&11>=document.documentMode,ba=null,Wu=null,fn=null,Iu=!1;function nf(t,e,l){var a=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;Iu||ba==null||ba!==fi(a)||(a=ba,"selectionStart"in a&&$u(a)?a={start:a.selectionStart,end:a.selectionEnd}:(a=(a.ownerDocument&&a.ownerDocument.defaultView||window).getSelection(),a={anchorNode:a.anchorNode,anchorOffset:a.anchorOffset,focusNode:a.focusNode,focusOffset:a.focusOffset}),fn&&rn(fn,a)||(fn=a,a=iu(Wu,"onSelect"),0>=s,n-=s,Ze=1<<32-be(e)+n|l<tt?(ut=K,K=null):ut=K.sibling;var mt=O(j,K,T[tt],R);if(mt===null){K===null&&(K=ut);break}t&&K&&mt.alternate===null&&e(j,K),b=u(mt,b,tt),ht===null?Z=mt:ht.sibling=mt,ht=mt,K=ut}if(tt===T.length)return l(j,K),ct&&Pe(j,tt),Z;if(K===null){for(;tttt?(ut=K,K=null):ut=K.sibling;var Ll=O(j,K,mt.value,R);if(Ll===null){K===null&&(K=ut);break}t&&K&&Ll.alternate===null&&e(j,K),b=u(Ll,b,tt),ht===null?Z=Ll:ht.sibling=Ll,ht=Ll,K=ut}if(mt.done)return l(j,K),ct&&Pe(j,tt),Z;if(K===null){for(;!mt.done;tt++,mt=T.next())mt=U(j,mt.value,R),mt!==null&&(b=u(mt,b,tt),ht===null?Z=mt:ht.sibling=mt,ht=mt);return ct&&Pe(j,tt),Z}for(K=a(K);!mt.done;tt++,mt=T.next())mt=C(K,j,tt,mt.value,R),mt!==null&&(t&&mt.alternate!==null&&K.delete(mt.key===null?tt:mt.key),b=u(mt,b,tt),ht===null?Z=mt:ht.sibling=mt,ht=mt);return t&&K.forEach(function(Qv){return e(j,Qv)}),ct&&Pe(j,tt),Z}function Tt(j,b,T,R){if(typeof T=="object"&&T!==null&&T.type===w&&T.key===null&&(T=T.props.children),typeof T=="object"&&T!==null){switch(T.$$typeof){case q:t:{for(var Z=T.key;b!==null;){if(b.key===Z){if(Z=T.type,Z===w){if(b.tag===7){l(j,b.sibling),R=n(b,T.props.children),R.return=j,j=R;break t}}else if(b.elementType===Z||typeof Z=="object"&&Z!==null&&Z.$$typeof===gt&&ea(Z)===b.type){l(j,b.sibling),R=n(b,T.props),vn(R,T),R.return=j,j=R;break t}l(j,b);break}else e(j,b);b=b.sibling}T.type===w?(R=$l(T.props.children,j.mode,R,T.key),R.return=j,j=R):(R=ji(T.type,T.key,T.props,null,j.mode,R),vn(R,T),R.return=j,j=R)}return s(j);case z:t:{for(Z=T.key;b!==null;){if(b.key===Z)if(b.tag===4&&b.stateNode.containerInfo===T.containerInfo&&b.stateNode.implementation===T.implementation){l(j,b.sibling),R=n(b,T.children||[]),R.return=j,j=R;break t}else{l(j,b);break}else e(j,b);b=b.sibling}R=ic(T,j.mode,R),R.return=j,j=R}return s(j);case gt:return T=ea(T),Tt(j,b,T,R)}if(kt(T))return X(j,b,T,R);if(Dt(T)){if(Z=Dt(T),typeof Z!="function")throw Error(f(150));return T=Z.call(T),J(j,b,T,R)}if(typeof T.then=="function")return Tt(j,b,Ci(T),R);if(T.$$typeof===ot)return Tt(j,b,Ni(j,T),R);zi(j,T)}return typeof T=="string"&&T!==""||typeof T=="number"||typeof T=="bigint"?(T=""+T,b!==null&&b.tag===6?(l(j,b.sibling),R=n(b,T),R.return=j,j=R):(l(j,b),R=nc(T,j.mode,R),R.return=j,j=R),s(j)):l(j,b)}return function(j,b,T,R){try{yn=0;var Z=Tt(j,b,T,R);return za=null,Z}catch(K){if(K===Ca||K===Mi)throw K;var ht=xe(29,K,null,j.mode);return ht.lanes=R,ht.return=j,ht}}}var aa=Af(!0),Cf=Af(!1),El=!1;function pc(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function gc(t,e){t=t.updateQueue,e.updateQueue===t&&(e.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,callbacks:null})}function Tl(t){return{lane:t,tag:0,payload:null,callback:null,next:null}}function Nl(t,e,l){var a=t.updateQueue;if(a===null)return null;if(a=a.shared,(pt&2)!==0){var n=a.pending;return n===null?e.next=e:(e.next=n.next,n.next=e),a.pending=e,e=xi(t),df(t,null,l),e}return Si(t,a,e,l),xi(t)}function pn(t,e,l){if(e=e.updateQueue,e!==null&&(e=e.shared,(l&4194048)!==0)){var a=e.lanes;a&=t.pendingLanes,l|=a,e.lanes=l,br(t,l)}}function bc(t,e){var l=t.updateQueue,a=t.alternate;if(a!==null&&(a=a.updateQueue,l===a)){var n=null,u=null;if(l=l.firstBaseUpdate,l!==null){do{var s={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};u===null?n=u=s:u=u.next=s,l=l.next}while(l!==null);u===null?n=u=e:u=u.next=e}else n=u=e;l={baseState:a.baseState,firstBaseUpdate:n,lastBaseUpdate:u,shared:a.shared,callbacks:a.callbacks},t.updateQueue=l;return}t=l.lastBaseUpdate,t===null?l.firstBaseUpdate=e:t.next=e,l.lastBaseUpdate=e}var Sc=!1;function gn(){if(Sc){var t=Aa;if(t!==null)throw t}}function bn(t,e,l,a){Sc=!1;var n=t.updateQueue;El=!1;var u=n.firstBaseUpdate,s=n.lastBaseUpdate,h=n.shared.pending;if(h!==null){n.shared.pending=null;var v=h,N=v.next;v.next=null,s===null?u=N:s.next=N,s=v;var _=t.alternate;_!==null&&(_=_.updateQueue,h=_.lastBaseUpdate,h!==s&&(h===null?_.firstBaseUpdate=N:h.next=N,_.lastBaseUpdate=v))}if(u!==null){var U=n.baseState;s=0,_=N=v=null,h=u;do{var O=h.lane&-536870913,C=O!==h.lane;if(C?(it&O)===O:(a&O)===O){O!==0&&O===Ma&&(Sc=!0),_!==null&&(_=_.next={lane:0,tag:h.tag,payload:h.payload,callback:null,next:null});t:{var X=t,J=h;O=e;var Tt=l;switch(J.tag){case 1:if(X=J.payload,typeof X=="function"){U=X.call(Tt,U,O);break t}U=X;break t;case 3:X.flags=X.flags&-65537|128;case 0:if(X=J.payload,O=typeof X=="function"?X.call(Tt,U,O):X,O==null)break t;U=E({},U,O);break t;case 2:El=!0}}O=h.callback,O!==null&&(t.flags|=64,C&&(t.flags|=8192),C=n.callbacks,C===null?n.callbacks=[O]:C.push(O))}else C={lane:O,tag:h.tag,payload:h.payload,callback:h.callback,next:null},_===null?(N=_=C,v=U):_=_.next=C,s|=O;if(h=h.next,h===null){if(h=n.shared.pending,h===null)break;C=h,h=C.next,C.next=null,n.lastBaseUpdate=C,n.shared.pending=null}}while(!0);_===null&&(v=U),n.baseState=v,n.firstBaseUpdate=N,n.lastBaseUpdate=_,u===null&&(n.shared.lanes=0),zl|=s,t.lanes=s,t.memoizedState=U}}function zf(t,e){if(typeof t!="function")throw Error(f(191,t));t.call(e)}function _f(t,e){var l=t.callbacks;if(l!==null)for(t.callbacks=null,t=0;tu?u:8;var s=D.T,h={};D.T=h,Bc(t,!1,e,l);try{var v=n(),N=D.S;if(N!==null&&N(h,v),v!==null&&typeof v=="object"&&typeof v.then=="function"){var _=My(v,a);jn(t,e,_,Oe(t))}else jn(t,e,a,Oe(t))}catch(U){jn(t,e,{then:function(){},status:"rejected",reason:U},Oe())}finally{B.p=u,s!==null&&h.types!==null&&(s.types=h.types),D.T=s}}function Ry(){}function wc(t,e,l,a){if(t.tag!==5)throw Error(f(476));var n=ro(t).queue;so(t,n,e,k,l===null?Ry:function(){return fo(t),l(a)})}function ro(t){var e=t.memoizedState;if(e!==null)return e;e={memoizedState:k,baseState:k,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:al,lastRenderedState:k},next:null};var l={};return e.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:al,lastRenderedState:l},next:null},t.memoizedState=e,t=t.alternate,t!==null&&(t.memoizedState=e),e}function fo(t){var e=ro(t);e.next===null&&(e=t.alternate.memoizedState),jn(t,e.next.queue,{},Oe())}function Qc(){return It(Bn)}function oo(){return Bt().memoizedState}function ho(){return Bt().memoizedState}function Uy(t){for(var e=t.return;e!==null;){switch(e.tag){case 24:case 3:var l=Oe();t=Tl(l);var a=Nl(e,t,l);a!==null&&(ye(a,e,l),pn(a,e,l)),e={cache:hc()},t.payload=e;return}e=e.return}}function Hy(t,e,l){var a=Oe();l={lane:a,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},Li(t)?yo(e,l):(l=lc(t,e,l,a),l!==null&&(ye(l,t,a),vo(l,e,a)))}function mo(t,e,l){var a=Oe();jn(t,e,l,a)}function jn(t,e,l,a){var n={lane:a,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(Li(t))yo(e,n);else{var u=t.alternate;if(t.lanes===0&&(u===null||u.lanes===0)&&(u=e.lastRenderedReducer,u!==null))try{var s=e.lastRenderedState,h=u(s,l);if(n.hasEagerState=!0,n.eagerState=h,Se(h,s))return Si(t,e,n,0),Ot===null&&bi(),!1}catch{}if(l=lc(t,e,n,a),l!==null)return ye(l,t,a),vo(l,e,a),!0}return!1}function Bc(t,e,l,a){if(a={lane:2,revertLane:ps(),gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},Li(t)){if(e)throw Error(f(479))}else e=lc(t,l,a,2),e!==null&&ye(e,t,2)}function Li(t){var e=t.alternate;return t===I||e!==null&&e===I}function yo(t,e){Da=Ri=!0;var l=t.pending;l===null?e.next=e:(e.next=l.next,l.next=e),t.pending=e}function vo(t,e,l){if((l&4194048)!==0){var a=e.lanes;a&=t.pendingLanes,l|=a,e.lanes=l,br(t,l)}}var En={readContext:It,use:qi,useCallback:Ht,useContext:Ht,useEffect:Ht,useImperativeHandle:Ht,useLayoutEffect:Ht,useInsertionEffect:Ht,useMemo:Ht,useReducer:Ht,useRef:Ht,useState:Ht,useDebugValue:Ht,useDeferredValue:Ht,useTransition:Ht,useSyncExternalStore:Ht,useId:Ht,useHostTransitionStatus:Ht,useFormState:Ht,useActionState:Ht,useOptimistic:Ht,useMemoCache:Ht,useCacheRefresh:Ht};En.useEffectEvent=Ht;var po={readContext:It,use:qi,useCallback:function(t,e){return ie().memoizedState=[t,e===void 0?null:e],t},useContext:It,useEffect:Pf,useImperativeHandle:function(t,e,l){l=l!=null?l.concat([t]):null,Qi(4194308,4,ao.bind(null,e,t),l)},useLayoutEffect:function(t,e){return Qi(4194308,4,t,e)},useInsertionEffect:function(t,e){Qi(4,2,t,e)},useMemo:function(t,e){var l=ie();e=e===void 0?null:e;var a=t();if(na){vl(!0);try{t()}finally{vl(!1)}}return l.memoizedState=[a,e],a},useReducer:function(t,e,l){var a=ie();if(l!==void 0){var n=l(e);if(na){vl(!0);try{l(e)}finally{vl(!1)}}}else n=e;return a.memoizedState=a.baseState=n,t={pending:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:n},a.queue=t,t=t.dispatch=Hy.bind(null,I,t),[a.memoizedState,t]},useRef:function(t){var e=ie();return t={current:t},e.memoizedState=t},useState:function(t){t=Dc(t);var e=t.queue,l=mo.bind(null,I,e);return e.dispatch=l,[t.memoizedState,l]},useDebugValue:Hc,useDeferredValue:function(t,e){var l=ie();return qc(l,t,e)},useTransition:function(){var t=Dc(!1);return t=so.bind(null,I,t.queue,!0,!1),ie().memoizedState=t,[!1,t]},useSyncExternalStore:function(t,e,l){var a=I,n=ie();if(ct){if(l===void 0)throw Error(f(407));l=l()}else{if(l=e(),Ot===null)throw Error(f(349));(it&127)!==0||wf(a,e,l)}n.memoizedState=l;var u={value:l,getSnapshot:e};return n.queue=u,Pf(Bf.bind(null,a,u,t),[t]),a.flags|=2048,Ua(9,{destroy:void 0},Qf.bind(null,a,u,l,e),null),l},useId:function(){var t=ie(),e=Ot.identifierPrefix;if(ct){var l=ke,a=Ze;l=(a&~(1<<32-be(a)-1)).toString(32)+l,e="_"+e+"R_"+l,l=Ui++,0<\/script>",u=u.removeChild(u.firstChild);break;case"select":u=typeof a.is=="string"?s.createElement("select",{is:a.is}):s.createElement("select"),a.multiple?u.multiple=!0:a.size&&(u.size=a.size);break;default:u=typeof a.is=="string"?s.createElement(n,{is:a.is}):s.createElement(n)}}u[$t]=e,u[re]=a;t:for(s=e.child;s!==null;){if(s.tag===5||s.tag===6)u.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===e)break t;for(;s.sibling===null;){if(s.return===null||s.return===e)break t;s=s.return}s.sibling.return=s.return,s=s.sibling}e.stateNode=u;t:switch(te(u,n,a),n){case"button":case"input":case"select":case"textarea":a=!!a.autoFocus;break t;case"img":a=!0;break t;default:a=!1}a&&il(e)}}return Ct(e),Pc(e,e.type,t===null?null:t.memoizedProps,e.pendingProps,l),null;case 6:if(t&&e.stateNode!=null)t.memoizedProps!==a&&il(e);else{if(typeof a!="string"&&e.stateNode===null)throw Error(f(166));if(t=et.current,Na(e)){if(t=e.stateNode,l=e.memoizedProps,a=null,n=Wt,n!==null)switch(n.tag){case 27:case 5:a=n.memoizedProps}t[$t]=e,t=!!(t.nodeValue===l||a!==null&&a.suppressHydrationWarning===!0||qd(t.nodeValue,l)),t||xl(e,!0)}else t=uu(t).createTextNode(a),t[$t]=e,e.stateNode=t}return Ct(e),null;case 31:if(l=e.memoizedState,t===null||t.memoizedState!==null){if(a=Na(e),l!==null){if(t===null){if(!a)throw Error(f(318));if(t=e.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(f(557));t[$t]=e}else Wl(),(e.flags&128)===0&&(e.memoizedState=null),e.flags|=4;Ct(e),t=!1}else l=rc(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=l),t=!0;if(!t)return e.flags&256?(Ee(e),e):(Ee(e),null);if((e.flags&128)!==0)throw Error(f(558))}return Ct(e),null;case 13:if(a=e.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(n=Na(e),a!==null&&a.dehydrated!==null){if(t===null){if(!n)throw Error(f(318));if(n=e.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(f(317));n[$t]=e}else Wl(),(e.flags&128)===0&&(e.memoizedState=null),e.flags|=4;Ct(e),n=!1}else n=rc(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=n),n=!0;if(!n)return e.flags&256?(Ee(e),e):(Ee(e),null)}return Ee(e),(e.flags&128)!==0?(e.lanes=l,e):(l=a!==null,t=t!==null&&t.memoizedState!==null,l&&(a=e.child,n=null,a.alternate!==null&&a.alternate.memoizedState!==null&&a.alternate.memoizedState.cachePool!==null&&(n=a.alternate.memoizedState.cachePool.pool),u=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(u=a.memoizedState.cachePool.pool),u!==n&&(a.flags|=2048)),l!==t&&l&&(e.child.flags|=8192),Zi(e,e.updateQueue),Ct(e),null);case 4:return Rt(),t===null&&xs(e.stateNode.containerInfo),Ct(e),null;case 10:return el(e.type),Ct(e),null;case 19:if(H(Qt),a=e.memoizedState,a===null)return Ct(e),null;if(n=(e.flags&128)!==0,u=a.rendering,u===null)if(n)Nn(a,!1);else{if(qt!==0||t!==null&&(t.flags&128)!==0)for(t=e.child;t!==null;){if(u=Di(t),u!==null){for(e.flags|=128,Nn(a,!1),t=u.updateQueue,e.updateQueue=t,Zi(e,t),e.subtreeFlags=0,t=l,l=e.child;l!==null;)hf(l,t),l=l.sibling;return L(Qt,Qt.current&1|2),ct&&Pe(e,a.treeForkCount),e.child}t=t.sibling}a.tail!==null&&ne()>$i&&(e.flags|=128,n=!0,Nn(a,!1),e.lanes=4194304)}else{if(!n)if(t=Di(u),t!==null){if(e.flags|=128,n=!0,t=t.updateQueue,e.updateQueue=t,Zi(e,t),Nn(a,!0),a.tail===null&&a.tailMode==="hidden"&&!u.alternate&&!ct)return Ct(e),null}else 2*ne()-a.renderingStartTime>$i&&l!==536870912&&(e.flags|=128,n=!0,Nn(a,!1),e.lanes=4194304);a.isBackwards?(u.sibling=e.child,e.child=u):(t=a.last,t!==null?t.sibling=u:e.child=u,a.last=u)}return a.tail!==null?(t=a.tail,a.rendering=t,a.tail=t.sibling,a.renderingStartTime=ne(),t.sibling=null,l=Qt.current,L(Qt,n?l&1|2:l&1),ct&&Pe(e,a.treeForkCount),t):(Ct(e),null);case 22:case 23:return Ee(e),jc(),a=e.memoizedState!==null,t!==null?t.memoizedState!==null!==a&&(e.flags|=8192):a&&(e.flags|=8192),a?(l&536870912)!==0&&(e.flags&128)===0&&(Ct(e),e.subtreeFlags&6&&(e.flags|=8192)):Ct(e),l=e.updateQueue,l!==null&&Zi(e,l.retryQueue),l=null,t!==null&&t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(l=t.memoizedState.cachePool.pool),a=null,e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(a=e.memoizedState.cachePool.pool),a!==l&&(e.flags|=2048),t!==null&&H(ta),null;case 24:return l=null,t!==null&&(l=t.memoizedState.cache),e.memoizedState.cache!==l&&(e.flags|=2048),el(Lt),Ct(e),null;case 25:return null;case 30:return null}throw Error(f(156,e.tag))}function Ly(t,e){switch(cc(e),e.tag){case 1:return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return el(Lt),Rt(),t=e.flags,(t&65536)!==0&&(t&128)===0?(e.flags=t&-65537|128,e):null;case 26:case 27:case 5:return ml(e),null;case 31:if(e.memoizedState!==null){if(Ee(e),e.alternate===null)throw Error(f(340));Wl()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 13:if(Ee(e),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(f(340));Wl()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return H(Qt),null;case 4:return Rt(),null;case 10:return el(e.type),null;case 22:case 23:return Ee(e),jc(),t!==null&&H(ta),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 24:return el(Lt),null;case 25:return null;default:return null}}function Yo(t,e){switch(cc(e),e.tag){case 3:el(Lt),Rt();break;case 26:case 27:case 5:ml(e);break;case 4:Rt();break;case 31:e.memoizedState!==null&&Ee(e);break;case 13:Ee(e);break;case 19:H(Qt);break;case 10:el(e.type);break;case 22:case 23:Ee(e),jc(),t!==null&&H(ta);break;case 24:el(Lt)}}function On(t,e){try{var l=e.updateQueue,a=l!==null?l.lastEffect:null;if(a!==null){var n=a.next;l=n;do{if((l.tag&t)===t){a=void 0;var u=l.create,s=l.inst;a=u(),s.destroy=a}l=l.next}while(l!==n)}}catch(h){St(e,e.return,h)}}function Al(t,e,l){try{var a=e.updateQueue,n=a!==null?a.lastEffect:null;if(n!==null){var u=n.next;a=u;do{if((a.tag&t)===t){var s=a.inst,h=s.destroy;if(h!==void 0){s.destroy=void 0,n=e;var v=l,N=h;try{N()}catch(_){St(n,v,_)}}}a=a.next}while(a!==u)}}catch(_){St(e,e.return,_)}}function Go(t){var e=t.updateQueue;if(e!==null){var l=t.stateNode;try{_f(e,l)}catch(a){St(t,t.return,a)}}}function Xo(t,e,l){l.props=ia(t.type,t.memoizedProps),l.state=t.memoizedState;try{l.componentWillUnmount()}catch(a){St(t,e,a)}}function Mn(t,e){try{var l=t.ref;if(l!==null){switch(t.tag){case 26:case 27:case 5:var a=t.stateNode;break;case 30:a=t.stateNode;break;default:a=t.stateNode}typeof l=="function"?t.refCleanup=l(a):l.current=a}}catch(n){St(t,e,n)}}function Ve(t,e){var l=t.ref,a=t.refCleanup;if(l!==null)if(typeof a=="function")try{a()}catch(n){St(t,e,n)}finally{t.refCleanup=null,t=t.alternate,t!=null&&(t.refCleanup=null)}else if(typeof l=="function")try{l(null)}catch(n){St(t,e,n)}else l.current=null}function Ko(t){var e=t.type,l=t.memoizedProps,a=t.stateNode;try{t:switch(e){case"button":case"input":case"select":case"textarea":l.autoFocus&&a.focus();break t;case"img":l.src?a.src=l.src:l.srcSet&&(a.srcset=l.srcSet)}}catch(n){St(t,t.return,n)}}function ts(t,e,l){try{var a=t.stateNode;sv(a,t.type,l,e),a[re]=e}catch(n){St(t,t.return,n)}}function Zo(t){return t.tag===5||t.tag===3||t.tag===26||t.tag===27&&Hl(t.type)||t.tag===4}function es(t){t:for(;;){for(;t.sibling===null;){if(t.return===null||Zo(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.tag===27&&Hl(t.type)||t.flags&2||t.child===null||t.tag===4)continue t;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function ls(t,e,l){var a=t.tag;if(a===5||a===6)t=t.stateNode,e?(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l).insertBefore(t,e):(e=l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,e.appendChild(t),l=l._reactRootContainer,l!=null||e.onclick!==null||(e.onclick=$e));else if(a!==4&&(a===27&&Hl(t.type)&&(l=t.stateNode,e=null),t=t.child,t!==null))for(ls(t,e,l),t=t.sibling;t!==null;)ls(t,e,l),t=t.sibling}function ki(t,e,l){var a=t.tag;if(a===5||a===6)t=t.stateNode,e?l.insertBefore(t,e):l.appendChild(t);else if(a!==4&&(a===27&&Hl(t.type)&&(l=t.stateNode),t=t.child,t!==null))for(ki(t,e,l),t=t.sibling;t!==null;)ki(t,e,l),t=t.sibling}function ko(t){var e=t.stateNode,l=t.memoizedProps;try{for(var a=t.type,n=e.attributes;n.length;)e.removeAttributeNode(n[0]);te(e,a,l),e[$t]=t,e[re]=l}catch(u){St(t,t.return,u)}}var ul=!1,Xt=!1,as=!1,Vo=typeof WeakSet=="function"?WeakSet:Set,Ft=null;function Yy(t,e){if(t=t.containerInfo,Ts=hu,t=af(t),$u(t)){if("selectionStart"in t)var l={start:t.selectionStart,end:t.selectionEnd};else t:{l=(l=t.ownerDocument)&&l.defaultView||window;var a=l.getSelection&&l.getSelection();if(a&&a.rangeCount!==0){l=a.anchorNode;var n=a.anchorOffset,u=a.focusNode;a=a.focusOffset;try{l.nodeType,u.nodeType}catch{l=null;break t}var s=0,h=-1,v=-1,N=0,_=0,U=t,O=null;e:for(;;){for(var C;U!==l||n!==0&&U.nodeType!==3||(h=s+n),U!==u||a!==0&&U.nodeType!==3||(v=s+a),U.nodeType===3&&(s+=U.nodeValue.length),(C=U.firstChild)!==null;)O=U,U=C;for(;;){if(U===t)break e;if(O===l&&++N===n&&(h=s),O===u&&++_===a&&(v=s),(C=U.nextSibling)!==null)break;U=O,O=U.parentNode}U=C}l=h===-1||v===-1?null:{start:h,end:v}}else l=null}l=l||{start:0,end:0}}else l=null;for(Ns={focusedElem:t,selectionRange:l},hu=!1,Ft=e;Ft!==null;)if(e=Ft,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,Ft=t;else for(;Ft!==null;){switch(e=Ft,u=e.alternate,t=e.flags,e.tag){case 0:if((t&4)!==0&&(t=e.updateQueue,t=t!==null?t.events:null,t!==null))for(l=0;l title"))),te(u,a,l),u[$t]=t,Jt(u),a=u;break t;case"link":var s=Pd("link","href",n).get(a+(l.href||""));if(s){for(var h=0;hTt&&(s=Tt,Tt=J,J=s);var j=ef(h,J),b=ef(h,Tt);if(j&&b&&(C.rangeCount!==1||C.anchorNode!==j.node||C.anchorOffset!==j.offset||C.focusNode!==b.node||C.focusOffset!==b.offset)){var T=U.createRange();T.setStart(j.node,j.offset),C.removeAllRanges(),J>Tt?(C.addRange(T),C.extend(b.node,b.offset)):(T.setEnd(b.node,b.offset),C.addRange(T))}}}}for(U=[],C=h;C=C.parentNode;)C.nodeType===1&&U.push({element:C,left:C.scrollLeft,top:C.scrollTop});for(typeof h.focus=="function"&&h.focus(),h=0;hl?32:l,D.T=null,l=fs,fs=null;var u=Dl,s=ol;if(Zt=0,Ba=Dl=null,ol=0,(pt&6)!==0)throw Error(f(331));var h=pt;if(pt|=4,nd(u.current),ed(u,u.current,s,l),pt=h,Rn(0,!1),ge&&typeof ge.onPostCommitFiberRoot=="function")try{ge.onPostCommitFiberRoot($a,u)}catch{}return!0}finally{B.p=n,D.T=a,jd(t,e)}}function Td(t,e,l){e=Re(l,e),e=Xc(t.stateNode,e,2),t=Nl(t,e,2),t!==null&&(Ia(t,2),Je(t))}function St(t,e,l){if(t.tag===3)Td(t,t,l);else for(;e!==null;){if(e.tag===3){Td(e,t,l);break}else if(e.tag===1){var a=e.stateNode;if(typeof e.type.getDerivedStateFromError=="function"||typeof a.componentDidCatch=="function"&&(_l===null||!_l.has(a))){t=Re(l,t),l=No(2),a=Nl(e,l,2),a!==null&&(Oo(l,a,e,t),Ia(a,2),Je(a));break}}e=e.return}}function ms(t,e,l){var a=t.pingCache;if(a===null){a=t.pingCache=new Ky;var n=new Set;a.set(e,n)}else n=a.get(e),n===void 0&&(n=new Set,a.set(e,n));n.has(l)||(us=!0,n.add(l),t=Fy.bind(null,t,e,l),e.then(t,t))}function Fy(t,e,l){var a=t.pingCache;a!==null&&a.delete(e),t.pingedLanes|=t.suspendedLanes&l,t.warmLanes&=~l,Ot===t&&(it&l)===l&&(qt===4||qt===3&&(it&62914560)===it&&300>ne()-Fi?(pt&2)===0&&La(t,0):cs|=l,Qa===it&&(Qa=0)),Je(t)}function Nd(t,e){e===0&&(e=pr()),t=Fl(t,e),t!==null&&(Ia(t,e),Je(t))}function $y(t){var e=t.memoizedState,l=0;e!==null&&(l=e.retryLane),Nd(t,l)}function Wy(t,e){var l=0;switch(t.tag){case 31:case 13:var a=t.stateNode,n=t.memoizedState;n!==null&&(l=n.retryLane);break;case 19:a=t.stateNode;break;case 22:a=t.stateNode._retryCache;break;default:throw Error(f(314))}a!==null&&a.delete(e),Nd(t,l)}function Iy(t,e){return ft(t,e)}var lu=null,Ga=null,ys=!1,au=!1,vs=!1,Ul=0;function Je(t){t!==Ga&&t.next===null&&(Ga===null?lu=Ga=t:Ga=Ga.next=t),au=!0,ys||(ys=!0,tv())}function Rn(t,e){if(!vs&&au){vs=!0;do for(var l=!1,a=lu;a!==null;){if(t!==0){var n=a.pendingLanes;if(n===0)var u=0;else{var s=a.suspendedLanes,h=a.pingedLanes;u=(1<<31-be(42|t)+1)-1,u&=n&~(s&~h),u=u&201326741?u&201326741|1:u?u|2:0}u!==0&&(l=!0,Cd(a,u))}else u=it,u=ci(a,a===Ot?u:0,a.cancelPendingCommit!==null||a.timeoutHandle!==-1),(u&3)===0||Wa(a,u)||(l=!0,Cd(a,u));a=a.next}while(l);vs=!1}}function Py(){Od()}function Od(){au=ys=!1;var t=0;Ul!==0&&fv()&&(t=Ul);for(var e=ne(),l=null,a=lu;a!==null;){var n=a.next,u=Md(a,e);u===0?(a.next=null,l===null?lu=n:l.next=n,n===null&&(Ga=l)):(l=a,(t!==0||(u&3)!==0)&&(au=!0)),a=n}Zt!==0&&Zt!==5||Rn(t),Ul!==0&&(Ul=0)}function Md(t,e){for(var l=t.suspendedLanes,a=t.pingedLanes,n=t.expirationTimes,u=t.pendingLanes&-62914561;0h)break;var _=v.transferSize,U=v.initiatorType;_&&wd(U)&&(v=v.responseEnd,s+=_*(v"u"?null:document;function Fd(t,e,l){var a=Xa;if(a&&typeof e=="string"&&e){var n=_e(e);n='link[rel="'+t+'"][href="'+n+'"]',typeof l=="string"&&(n+='[crossorigin="'+l+'"]'),Jd.has(n)||(Jd.add(n),t={rel:t,crossOrigin:l,href:e},a.querySelector(n)===null&&(e=a.createElement("link"),te(e,"link",t),Jt(e),a.head.appendChild(e)))}}function bv(t){dl.D(t),Fd("dns-prefetch",t,null)}function Sv(t,e){dl.C(t,e),Fd("preconnect",t,e)}function xv(t,e,l){dl.L(t,e,l);var a=Xa;if(a&&t&&e){var n='link[rel="preload"][as="'+_e(e)+'"]';e==="image"&&l&&l.imageSrcSet?(n+='[imagesrcset="'+_e(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(n+='[imagesizes="'+_e(l.imageSizes)+'"]')):n+='[href="'+_e(t)+'"]';var u=n;switch(e){case"style":u=Ka(t);break;case"script":u=Za(t)}Be.has(u)||(t=E({rel:"preload",href:e==="image"&&l&&l.imageSrcSet?void 0:t,as:e},l),Be.set(u,t),a.querySelector(n)!==null||e==="style"&&a.querySelector(wn(u))||e==="script"&&a.querySelector(Qn(u))||(e=a.createElement("link"),te(e,"link",t),Jt(e),a.head.appendChild(e)))}}function jv(t,e){dl.m(t,e);var l=Xa;if(l&&t){var a=e&&typeof e.as=="string"?e.as:"script",n='link[rel="modulepreload"][as="'+_e(a)+'"][href="'+_e(t)+'"]',u=n;switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":u=Za(t)}if(!Be.has(u)&&(t=E({rel:"modulepreload",href:t},e),Be.set(u,t),l.querySelector(n)===null)){switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(Qn(u)))return}a=l.createElement("link"),te(a,"link",t),Jt(a),l.head.appendChild(a)}}}function Ev(t,e,l){dl.S(t,e,l);var a=Xa;if(a&&t){var n=da(a).hoistableStyles,u=Ka(t);e=e||"default";var s=n.get(u);if(!s){var h={loading:0,preload:null};if(s=a.querySelector(wn(u)))h.loading=5;else{t=E({rel:"stylesheet",href:t,"data-precedence":e},l),(l=Be.get(u))&&Ds(t,l);var v=s=a.createElement("link");Jt(v),te(v,"link",t),v._p=new Promise(function(N,_){v.onload=N,v.onerror=_}),v.addEventListener("load",function(){h.loading|=1}),v.addEventListener("error",function(){h.loading|=2}),h.loading|=4,su(s,e,a)}s={type:"stylesheet",instance:s,count:1,state:h},n.set(u,s)}}}function Tv(t,e){dl.X(t,e);var l=Xa;if(l&&t){var a=da(l).hoistableScripts,n=Za(t),u=a.get(n);u||(u=l.querySelector(Qn(n)),u||(t=E({src:t,async:!0},e),(e=Be.get(n))&&Rs(t,e),u=l.createElement("script"),Jt(u),te(u,"link",t),l.head.appendChild(u)),u={type:"script",instance:u,count:1,state:null},a.set(n,u))}}function Nv(t,e){dl.M(t,e);var l=Xa;if(l&&t){var a=da(l).hoistableScripts,n=Za(t),u=a.get(n);u||(u=l.querySelector(Qn(n)),u||(t=E({src:t,async:!0,type:"module"},e),(e=Be.get(n))&&Rs(t,e),u=l.createElement("script"),Jt(u),te(u,"link",t),l.head.appendChild(u)),u={type:"script",instance:u,count:1,state:null},a.set(n,u))}}function $d(t,e,l,a){var n=(n=et.current)?cu(n):null;if(!n)throw Error(f(446));switch(t){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(e=Ka(l.href),l=da(n).hoistableStyles,a=l.get(e),a||(a={type:"style",instance:null,count:0,state:null},l.set(e,a)),a):{type:"void",instance:null,count:0,state:null};case"link":if(l.rel==="stylesheet"&&typeof l.href=="string"&&typeof l.precedence=="string"){t=Ka(l.href);var u=da(n).hoistableStyles,s=u.get(t);if(s||(n=n.ownerDocument||n,s={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},u.set(t,s),(u=n.querySelector(wn(t)))&&!u._p&&(s.instance=u,s.state.loading=5),Be.has(t)||(l={rel:"preload",as:"style",href:l.href,crossOrigin:l.crossOrigin,integrity:l.integrity,media:l.media,hrefLang:l.hrefLang,referrerPolicy:l.referrerPolicy},Be.set(t,l),u||Ov(n,t,l,s.state))),e&&a===null)throw Error(f(528,""));return s}if(e&&a!==null)throw Error(f(529,""));return null;case"script":return e=l.async,l=l.src,typeof l=="string"&&e&&typeof e!="function"&&typeof e!="symbol"?(e=Za(l),l=da(n).hoistableScripts,a=l.get(e),a||(a={type:"script",instance:null,count:0,state:null},l.set(e,a)),a):{type:"void",instance:null,count:0,state:null};default:throw Error(f(444,t))}}function Ka(t){return'href="'+_e(t)+'"'}function wn(t){return'link[rel="stylesheet"]['+t+"]"}function Wd(t){return E({},t,{"data-precedence":t.precedence,precedence:null})}function Ov(t,e,l,a){t.querySelector('link[rel="preload"][as="style"]['+e+"]")?a.loading=1:(e=t.createElement("link"),a.preload=e,e.addEventListener("load",function(){return a.loading|=1}),e.addEventListener("error",function(){return a.loading|=2}),te(e,"link",l),Jt(e),t.head.appendChild(e))}function Za(t){return'[src="'+_e(t)+'"]'}function Qn(t){return"script[async]"+t}function Id(t,e,l){if(e.count++,e.instance===null)switch(e.type){case"style":var a=t.querySelector('style[data-href~="'+_e(l.href)+'"]');if(a)return e.instance=a,Jt(a),a;var n=E({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return a=(t.ownerDocument||t).createElement("style"),Jt(a),te(a,"style",n),su(a,l.precedence,t),e.instance=a;case"stylesheet":n=Ka(l.href);var u=t.querySelector(wn(n));if(u)return e.state.loading|=4,e.instance=u,Jt(u),u;a=Wd(l),(n=Be.get(n))&&Ds(a,n),u=(t.ownerDocument||t).createElement("link"),Jt(u);var s=u;return s._p=new Promise(function(h,v){s.onload=h,s.onerror=v}),te(u,"link",a),e.state.loading|=4,su(u,l.precedence,t),e.instance=u;case"script":return u=Za(l.src),(n=t.querySelector(Qn(u)))?(e.instance=n,Jt(n),n):(a=l,(n=Be.get(u))&&(a=E({},l),Rs(a,n)),t=t.ownerDocument||t,n=t.createElement("script"),Jt(n),te(n,"link",a),t.head.appendChild(n),e.instance=n);case"void":return null;default:throw Error(f(443,e.type))}else e.type==="stylesheet"&&(e.state.loading&4)===0&&(a=e.instance,e.state.loading|=4,su(a,l.precedence,t));return e.instance}function su(t,e,l){for(var a=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),n=a.length?a[a.length-1]:null,u=n,s=0;s title"):null)}function Mv(t,e,l){if(l===1||e.itemProp!=null)return!1;switch(t){case"meta":case"title":return!0;case"style":if(typeof e.precedence!="string"||typeof e.href!="string"||e.href==="")break;return!0;case"link":if(typeof e.rel!="string"||typeof e.href!="string"||e.href===""||e.onLoad||e.onError)break;return e.rel==="stylesheet"?(t=e.disabled,typeof e.precedence=="string"&&t==null):!0;case"script":if(e.async&&typeof e.async!="function"&&typeof e.async!="symbol"&&!e.onLoad&&!e.onError&&e.src&&typeof e.src=="string")return!0}return!1}function eh(t){return!(t.type==="stylesheet"&&(t.state.loading&3)===0)}function Av(t,e,l,a){if(l.type==="stylesheet"&&(typeof a.media!="string"||matchMedia(a.media).matches!==!1)&&(l.state.loading&4)===0){if(l.instance===null){var n=Ka(a.href),u=e.querySelector(wn(n));if(u){e=u._p,e!==null&&typeof e=="object"&&typeof e.then=="function"&&(t.count++,t=fu.bind(t),e.then(t,t)),l.state.loading|=4,l.instance=u,Jt(u);return}u=e.ownerDocument||e,a=Wd(a),(n=Be.get(n))&&Ds(a,n),u=u.createElement("link"),Jt(u);var s=u;s._p=new Promise(function(h,v){s.onload=h,s.onerror=v}),te(u,"link",a),l.instance=u}t.stylesheets===null&&(t.stylesheets=new Map),t.stylesheets.set(l,e),(e=l.state.preload)&&(l.state.loading&3)===0&&(t.count++,l=fu.bind(t),e.addEventListener("load",l),e.addEventListener("error",l))}}var Us=0;function Cv(t,e){return t.stylesheets&&t.count===0&&du(t,t.stylesheets),0Us?50:800)+e);return t.unsuspend=l,function(){t.unsuspend=null,clearTimeout(a),clearTimeout(n)}}:null}function fu(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)du(this,this.stylesheets);else if(this.unsuspend){var t=this.unsuspend;this.unsuspend=null,t()}}}var ou=null;function du(t,e){t.stylesheets=null,t.unsuspend!==null&&(t.count++,ou=new Map,e.forEach(zv,t),ou=null,fu.call(t))}function zv(t,e){if(!(e.state.loading&4)){var l=ou.get(t);if(l)var a=l.get(null);else{l=new Map,ou.set(t,l);for(var n=t.querySelectorAll("link[data-precedence],style[data-precedence]"),u=0;u"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(i)}catch(c){console.error(c)}}return i(),Xs.exports=kv(),Xs.exports}var Jv=Vv(),Pn=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(i){return this.listeners.add(i),this.onSubscribe(),()=>{this.listeners.delete(i),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Fv=class extends Pn{#t;#e;#l;constructor(){super(),this.#l=i=>{if(typeof window<"u"&&window.addEventListener){const c=()=>i();return window.addEventListener("visibilitychange",c,!1),()=>{window.removeEventListener("visibilitychange",c)}}}}onSubscribe(){this.#e||this.setEventListener(this.#l)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(i){this.#l=i,this.#e?.(),this.#e=i(c=>{typeof c=="boolean"?this.setFocused(c):this.onFocus()})}setFocused(i){this.#t!==i&&(this.#t=i,this.onFocus())}onFocus(){const i=this.isFocused();this.listeners.forEach(c=>{c(i)})}isFocused(){return typeof this.#t=="boolean"?this.#t:globalThis.document?.visibilityState!=="hidden"}},ur=new Fv,$v={setTimeout:(i,c)=>setTimeout(i,c),clearTimeout:i=>clearTimeout(i),setInterval:(i,c)=>setInterval(i,c),clearInterval:i=>clearInterval(i)},Wv=class{#t=$v;#e=!1;setTimeoutProvider(i){this.#t=i}setTimeout(i,c){return this.#t.setTimeout(i,c)}clearTimeout(i){this.#t.clearTimeout(i)}setInterval(i,c){return this.#t.setInterval(i,c)}clearInterval(i){this.#t.clearInterval(i)}},sa=new Wv;function Iv(i){setTimeout(i,0)}var Pv=typeof window>"u"||"Deno"in globalThis;function ve(){}function t0(i,c){return typeof i=="function"?i(c):i}function $s(i){return typeof i=="number"&&i>=0&&i!==1/0}function kh(i,c){return Math.max(i+(c||0)-Date.now(),0)}function Gl(i,c){return typeof i=="function"?i(c):i}function Me(i,c){return typeof i=="function"?i(c):i}function Nh(i,c){const{type:r="all",exact:f,fetchStatus:d,predicate:m,queryKey:g,stale:A}=i;if(g){if(f){if(c.queryHash!==cr(g,c.options))return!1}else if(!Vn(c.queryKey,g))return!1}if(r!=="all"){const p=c.isActive();if(r==="active"&&!p||r==="inactive"&&p)return!1}return!(typeof A=="boolean"&&c.isStale()!==A||d&&d!==c.state.fetchStatus||m&&!m(c))}function Oh(i,c){const{exact:r,status:f,predicate:d,mutationKey:m}=i;if(m){if(!c.options.mutationKey)return!1;if(r){if(kn(c.options.mutationKey)!==kn(m))return!1}else if(!Vn(c.options.mutationKey,m))return!1}return!(f&&c.state.status!==f||d&&!d(c))}function cr(i,c){return(c?.queryKeyHashFn||kn)(i)}function kn(i){return JSON.stringify(i,(c,r)=>Is(r)?Object.keys(r).sort().reduce((f,d)=>(f[d]=r[d],f),{}):r)}function Vn(i,c){return i===c?!0:typeof i!=typeof c?!1:i&&c&&typeof i=="object"&&typeof c=="object"?Object.keys(c).every(r=>Vn(i[r],c[r])):!1}var e0=Object.prototype.hasOwnProperty;function Vh(i,c,r=0){if(i===c)return i;if(r>500)return c;const f=Mh(i)&&Mh(c);if(!f&&!(Is(i)&&Is(c)))return c;const m=(f?i:Object.keys(i)).length,g=f?c:Object.keys(c),A=g.length,p=f?new Array(A):{};let y=0;for(let M=0;M{sa.setTimeout(c,i)})}function Ps(i,c,r){return typeof r.structuralSharing=="function"?r.structuralSharing(i,c):r.structuralSharing!==!1?Vh(i,c):c}function a0(i,c,r=0){const f=[...i,c];return r&&f.length>r?f.slice(1):f}function n0(i,c,r=0){const f=[c,...i];return r&&f.length>r?f.slice(0,-1):f}var sr=Symbol();function Jh(i,c){return!i.queryFn&&c?.initialPromise?()=>c.initialPromise:!i.queryFn||i.queryFn===sr?()=>Promise.reject(new Error(`Missing queryFn: '${i.queryHash}'`)):i.queryFn}function Fh(i,c){return typeof i=="function"?i(...c):!!i}function i0(i,c,r){let f=!1,d;return Object.defineProperty(i,"signal",{enumerable:!0,get:()=>(d??=c(),f||(f=!0,d.aborted?r():d.addEventListener("abort",r,{once:!0})),d)}),i}var Jn=(()=>{let i=()=>Pv;return{isServer(){return i()},setIsServer(c){i=c}}})();function tr(){let i,c;const r=new Promise((d,m)=>{i=d,c=m});r.status="pending",r.catch(()=>{});function f(d){Object.assign(r,d),delete r.resolve,delete r.reject}return r.resolve=d=>{f({status:"fulfilled",value:d}),i(d)},r.reject=d=>{f({status:"rejected",reason:d}),c(d)},r}var u0=Iv;function c0(){let i=[],c=0,r=A=>{A()},f=A=>{A()},d=u0;const m=A=>{c?i.push(A):d(()=>{r(A)})},g=()=>{const A=i;i=[],A.length&&d(()=>{f(()=>{A.forEach(p=>{r(p)})})})};return{batch:A=>{let p;c++;try{p=A()}finally{c--,c||g()}return p},batchCalls:A=>(...p)=>{m(()=>{A(...p)})},schedule:m,setNotifyFunction:A=>{r=A},setBatchNotifyFunction:A=>{f=A},setScheduler:A=>{d=A}}}var ee=c0(),s0=class extends Pn{#t=!0;#e;#l;constructor(){super(),this.#l=i=>{if(typeof window<"u"&&window.addEventListener){const c=()=>i(!0),r=()=>i(!1);return window.addEventListener("online",c,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",c),window.removeEventListener("offline",r)}}}}onSubscribe(){this.#e||this.setEventListener(this.#l)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(i){this.#l=i,this.#e?.(),this.#e=i(this.setOnline.bind(this))}setOnline(i){this.#t!==i&&(this.#t=i,this.listeners.forEach(r=>{r(i)}))}isOnline(){return this.#t}},Nu=new s0;function r0(i){return Math.min(1e3*2**i,3e4)}function $h(i){return(i??"online")==="online"?Nu.isOnline():!0}var er=class extends Error{constructor(i){super("CancelledError"),this.revert=i?.revert,this.silent=i?.silent}};function Wh(i){let c=!1,r=0,f;const d=tr(),m=()=>d.status!=="pending",g=w=>{if(!m()){const Y=new er(w);x(Y),i.onCancel?.(Y)}},A=()=>{c=!0},p=()=>{c=!1},y=()=>ur.isFocused()&&(i.networkMode==="always"||Nu.isOnline())&&i.canRun(),M=()=>$h(i.networkMode)&&i.canRun(),E=w=>{m()||(f?.(),d.resolve(w))},x=w=>{m()||(f?.(),d.reject(w))},q=()=>new Promise(w=>{f=Y=>{(m()||y())&&w(Y)},i.onPause?.()}).then(()=>{f=void 0,m()||i.onContinue?.()}),z=()=>{if(m())return;let w;const Y=r===0?i.initialPromise:void 0;try{w=Y??i.fn()}catch(F){w=Promise.reject(F)}Promise.resolve(w).then(E).catch(F=>{if(m())return;const yt=i.retry??(Jn.isServer()?0:3),ot=i.retryDelay??r0,zt=typeof ot=="function"?ot(r,F):ot,lt=yt===!0||typeof yt=="number"&&ry()?void 0:q()).then(()=>{c?x(F):z()})})};return{promise:d,status:()=>d.status,cancel:g,continue:()=>(f?.(),d),cancelRetry:A,continueRetry:p,canStart:M,start:()=>(M()?z():q().then(z),d)}}var Ih=class{#t;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),$s(this.gcTime)&&(this.#t=sa.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(i){this.gcTime=Math.max(this.gcTime||0,i??(Jn.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#t!==void 0&&(sa.clearTimeout(this.#t),this.#t=void 0)}};function f0(i){return{onFetch:(c,r)=>{const f=c.options,d=c.fetchOptions?.meta?.fetchMore?.direction,m=c.state.data?.pages||[],g=c.state.data?.pageParams||[];let A={pages:[],pageParams:[]},p=0;const y=async()=>{let M=!1;const E=z=>{i0(z,()=>c.signal,()=>M=!0)},x=Jh(c.options,c.fetchOptions),q=async(z,w,Y)=>{if(M)return Promise.reject(c.signal.reason);if(w==null&&z.pages.length)return Promise.resolve(z);const yt=(()=>{const Nt={client:c.client,queryKey:c.queryKey,pageParam:w,direction:Y?"backward":"forward",meta:c.options.meta};return E(Nt),Nt})(),ot=await x(yt),{maxPages:zt}=c.options,lt=Y?n0:a0;return{pages:lt(z.pages,ot,zt),pageParams:lt(z.pageParams,w,zt)}};if(d&&m.length){const z=d==="backward",w=z?o0:Ch,Y={pages:m,pageParams:g},F=w(f,Y);A=await q(Y,F,z)}else{const z=i??m.length;do{const w=p===0?g[0]??f.initialPageParam:Ch(f,A);if(p>0&&w==null)break;A=await q(A,w),p++}while(pc.options.persister?.(y,{client:c.client,queryKey:c.queryKey,meta:c.options.meta,signal:c.signal},r):c.fetchFn=y}}}function Ch(i,{pages:c,pageParams:r}){const f=c.length-1;return c.length>0?i.getNextPageParam(c[f],c,r[f],r):void 0}function o0(i,{pages:c,pageParams:r}){return c.length>0?i.getPreviousPageParam?.(c[0],c,r[0],r):void 0}var d0=class extends Ih{#t;#e;#l;#a;#i;#n;#c;#u;constructor(i){super(),this.#u=!1,this.#c=i.defaultOptions,this.setOptions(i.options),this.observers=[],this.#i=i.client,this.#a=this.#i.getQueryCache(),this.queryKey=i.queryKey,this.queryHash=i.queryHash,this.#e=_h(this.options),this.state=i.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#t}get promise(){return this.#n?.promise}setOptions(i){if(this.options={...this.#c,...i},i?._type&&(this.#t=i._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const c=_h(this.options);c.data!==void 0&&(this.setState(zh(c.data,c.dataUpdatedAt)),this.#e=c)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#a.remove(this)}setData(i,c){const r=Ps(this.state.data,i,this.options);return this.#s({data:r,type:"success",dataUpdatedAt:c?.updatedAt,manual:c?.manual}),r}setState(i){this.#s({type:"setState",state:i})}cancel(i){const c=this.#n?.promise;return this.#n?.cancel(i),c?c.then(ve).catch(ve):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#e}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(i=>Me(i.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===sr||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(i=>Gl(i.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(i=>i.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(i=0){return this.state.data===void 0?!0:i==="static"?!1:this.state.isInvalidated?!0:!kh(this.state.dataUpdatedAt,i)}onFocus(){this.observers.find(c=>c.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#n?.continue()}onOnline(){this.observers.find(c=>c.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#n?.continue()}addObserver(i){this.observers.includes(i)||(this.observers.push(i),this.clearGcTimeout(),this.#a.notify({type:"observerAdded",query:this,observer:i}))}removeObserver(i){this.observers.includes(i)&&(this.observers=this.observers.filter(c=>c!==i),this.observers.length||(this.#n&&(this.#u||this.#f()?this.#n.cancel({revert:!0}):this.#n.cancelRetry()),this.scheduleGc()),this.#a.notify({type:"observerRemoved",query:this,observer:i}))}getObserversCount(){return this.observers.length}#f(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"}invalidate(){this.state.isInvalidated||this.#s({type:"invalidate"})}async fetch(i,c){if(this.state.fetchStatus!=="idle"&&this.#n?.status()!=="rejected"){if(this.state.data!==void 0&&c?.cancelRefetch)this.cancel({silent:!0});else if(this.#n)return this.#n.continueRetry(),this.#n.promise}if(i&&this.setOptions(i),!this.options.queryFn){const p=this.observers.find(y=>y.options.queryFn);p&&this.setOptions(p.options)}const r=new AbortController,f=p=>{Object.defineProperty(p,"signal",{enumerable:!0,get:()=>(this.#u=!0,r.signal)})},d=()=>{const p=Jh(this.options,c),M=(()=>{const E={client:this.#i,queryKey:this.queryKey,meta:this.meta};return f(E),E})();return this.#u=!1,this.options.persister?this.options.persister(p,M,this):p(M)},g=(()=>{const p={fetchOptions:c,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:d};return f(p),p})();(this.#t==="infinite"?f0(this.options.pages):this.options.behavior)?.onFetch(g,this),this.#l=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==g.fetchOptions?.meta)&&this.#s({type:"fetch",meta:g.fetchOptions?.meta}),this.#n=Wh({initialPromise:c?.initialPromise,fn:g.fetchFn,onCancel:p=>{p instanceof er&&p.revert&&this.setState({...this.#l,fetchStatus:"idle"}),r.abort()},onFail:(p,y)=>{this.#s({type:"failed",failureCount:p,error:y})},onPause:()=>{this.#s({type:"pause"})},onContinue:()=>{this.#s({type:"continue"})},retry:g.options.retry,retryDelay:g.options.retryDelay,networkMode:g.options.networkMode,canRun:()=>!0});try{const p=await this.#n.start();if(p===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(p),this.#a.config.onSuccess?.(p,this),this.#a.config.onSettled?.(p,this.state.error,this),p}catch(p){if(p instanceof er){if(p.silent)return this.#n.promise;if(p.revert){if(this.state.data===void 0)throw p;return this.state.data}}throw this.#s({type:"error",error:p}),this.#a.config.onError?.(p,this),this.#a.config.onSettled?.(this.state.data,p,this),p}finally{this.scheduleGc()}}#s(i){const c=r=>{switch(i.type){case"failed":return{...r,fetchFailureCount:i.failureCount,fetchFailureReason:i.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...Ph(r.data,this.options),fetchMeta:i.meta??null};case"success":const f={...r,...zh(i.data,i.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!i.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#l=i.manual?f:void 0,f;case"error":const d=i.error;return{...r,error:d,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:d,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...i.state}}};this.state=c(this.state),ee.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),this.#a.notify({query:this,type:"updated",action:i})})}};function Ph(i,c){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:$h(c.networkMode)?"fetching":"paused",...i===void 0&&{error:null,status:"pending"}}}function zh(i,c){return{data:i,dataUpdatedAt:c??Date.now(),error:null,isInvalidated:!1,status:"success"}}function _h(i){const c=typeof i.initialData=="function"?i.initialData():i.initialData,r=c!==void 0,f=r?typeof i.initialDataUpdatedAt=="function"?i.initialDataUpdatedAt():i.initialDataUpdatedAt:0;return{data:c,dataUpdateCount:0,dataUpdatedAt:r?f??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var h0=class extends Pn{constructor(i,c){super(),this.options=c,this.#t=i,this.#u=null,this.#c=tr(),this.bindMethods(),this.setOptions(c)}#t;#e=void 0;#l=void 0;#a=void 0;#i;#n;#c;#u;#f;#s;#m;#o;#d;#r;#y=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#e.addObserver(this),Dh(this.#e,this.options)?this.#h():this.updateResult(),this.#b())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return lr(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return lr(this.#e,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#S(),this.#x(),this.#e.removeObserver(this)}setOptions(i){const c=this.options,r=this.#e;if(this.options=this.#t.defaultQueryOptions(i),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Me(this.options.enabled,this.#e)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#j(),this.#e.setOptions(this.options),c._defaulted&&!Ws(this.options,c)&&this.#t.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const f=this.hasListeners();f&&Rh(this.#e,r,this.options,c)&&this.#h(),this.updateResult(),f&&(this.#e!==r||Me(this.options.enabled,this.#e)!==Me(c.enabled,this.#e)||Gl(this.options.staleTime,this.#e)!==Gl(c.staleTime,this.#e))&&this.#v();const d=this.#p();f&&(this.#e!==r||Me(this.options.enabled,this.#e)!==Me(c.enabled,this.#e)||d!==this.#r)&&this.#g(d)}getOptimisticResult(i){const c=this.#t.getQueryCache().build(this.#t,i),r=this.createResult(c,i);return y0(this,r)&&(this.#a=r,this.#n=this.options,this.#i=this.#e.state),r}getCurrentResult(){return this.#a}trackResult(i,c){return new Proxy(i,{get:(r,f)=>(this.trackProp(f),c?.(f),f==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#c.status==="pending"&&this.#c.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,f))})}trackProp(i){this.#y.add(i)}getCurrentQuery(){return this.#e}refetch({...i}={}){return this.fetch({...i})}fetchOptimistic(i){const c=this.#t.defaultQueryOptions(i),r=this.#t.getQueryCache().build(this.#t,c);return r.fetch().then(()=>this.createResult(r,c))}fetch(i){return this.#h({...i,cancelRefetch:i.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#a))}#h(i){this.#j();let c=this.#e.fetch(this.options,i);return i?.throwOnError||(c=c.catch(ve)),c}#v(){this.#S();const i=Gl(this.options.staleTime,this.#e);if(Jn.isServer()||this.#a.isStale||!$s(i))return;const r=kh(this.#a.dataUpdatedAt,i)+1;this.#o=sa.setTimeout(()=>{this.#a.isStale||this.updateResult()},r)}#p(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#e):this.options.refetchInterval)??!1}#g(i){this.#x(),this.#r=i,!(Jn.isServer()||Me(this.options.enabled,this.#e)===!1||!$s(this.#r)||this.#r===0)&&(this.#d=sa.setInterval(()=>{(this.options.refetchIntervalInBackground||ur.isFocused())&&this.#h()},this.#r))}#b(){this.#v(),this.#g(this.#p())}#S(){this.#o!==void 0&&(sa.clearTimeout(this.#o),this.#o=void 0)}#x(){this.#d!==void 0&&(sa.clearInterval(this.#d),this.#d=void 0)}createResult(i,c){const r=this.#e,f=this.options,d=this.#a,m=this.#i,g=this.#n,p=i!==r?i.state:this.#l,{state:y}=i;let M={...y},E=!1,x;if(c._optimisticResults){const gt=this.hasListeners(),wt=!gt&&Dh(i,c),ue=gt&&Rh(i,r,c,f);(wt||ue)&&(M={...M,...Ph(y.data,i.options)}),c._optimisticResults==="isRestoring"&&(M.fetchStatus="idle")}let{error:q,errorUpdatedAt:z,status:w}=M;x=M.data;let Y=!1;if(c.placeholderData!==void 0&&x===void 0&&w==="pending"){let gt;d?.isPlaceholderData&&c.placeholderData===g?.placeholderData?(gt=d.data,Y=!0):gt=typeof c.placeholderData=="function"?c.placeholderData(this.#m?.state.data,this.#m):c.placeholderData,gt!==void 0&&(w="success",x=Ps(d?.data,gt,c),E=!0)}if(c.select&&x!==void 0&&!Y)if(d&&x===m?.data&&c.select===this.#f)x=this.#s;else try{this.#f=c.select,x=c.select(x),x=Ps(d?.data,x,c),this.#s=x,this.#u=null}catch(gt){this.#u=gt}this.#u&&(q=this.#u,x=this.#s,z=Date.now(),w="error");const F=M.fetchStatus==="fetching",yt=w==="pending",ot=w==="error",zt=yt&&F,lt=x!==void 0,$={status:w,fetchStatus:M.fetchStatus,isPending:yt,isSuccess:w==="success",isError:ot,isInitialLoading:zt,isLoading:zt,data:x,dataUpdatedAt:M.dataUpdatedAt,error:q,errorUpdatedAt:z,failureCount:M.fetchFailureCount,failureReason:M.fetchFailureReason,errorUpdateCount:M.errorUpdateCount,isFetched:i.isFetched(),isFetchedAfterMount:M.dataUpdateCount>p.dataUpdateCount||M.errorUpdateCount>p.errorUpdateCount,isFetching:F,isRefetching:F&&!yt,isLoadingError:ot&&!lt,isPaused:M.fetchStatus==="paused",isPlaceholderData:E,isRefetchError:ot&<,isStale:rr(i,c),refetch:this.refetch,promise:this.#c,isEnabled:Me(c.enabled,i)!==!1};if(this.options.experimental_prefetchInRender){const gt=$.data!==void 0,wt=$.status==="error"&&!gt,ue=ce=>{wt?ce.reject($.error):gt&&ce.resolve($.data)},le=()=>{const ce=this.#c=$.promise=tr();ue(ce)},Dt=this.#c;switch(Dt.status){case"pending":i.queryHash===r.queryHash&&ue(Dt);break;case"fulfilled":(wt||$.data!==Dt.value)&&le();break;case"rejected":(!wt||$.error!==Dt.reason)&&le();break}}return $}updateResult(){const i=this.#a,c=this.createResult(this.#e,this.options);if(this.#i=this.#e.state,this.#n=this.options,this.#i.data!==void 0&&(this.#m=this.#e),Ws(c,i))return;this.#a=c;const r=()=>{if(!i)return!0;const{notifyOnChangeProps:f}=this.options,d=typeof f=="function"?f():f;if(d==="all"||!d&&!this.#y.size)return!0;const m=new Set(d??this.#y);return this.options.throwOnError&&m.add("error"),Object.keys(this.#a).some(g=>{const A=g;return this.#a[A]!==i[A]&&m.has(A)})};this.#E({listeners:r()})}#j(){const i=this.#t.getQueryCache().build(this.#t,this.options);if(i===this.#e)return;const c=this.#e;this.#e=i,this.#l=i.state,this.hasListeners()&&(c?.removeObserver(this),i.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#b()}#E(i){ee.batch(()=>{i.listeners&&this.listeners.forEach(c=>{c(this.#a)}),this.#t.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function m0(i,c){return Me(c.enabled,i)!==!1&&i.state.data===void 0&&!(i.state.status==="error"&&Me(c.retryOnMount,i)===!1)}function Dh(i,c){return m0(i,c)||i.state.data!==void 0&&lr(i,c,c.refetchOnMount)}function lr(i,c,r){if(Me(c.enabled,i)!==!1&&Gl(c.staleTime,i)!=="static"){const f=typeof r=="function"?r(i):r;return f==="always"||f!==!1&&rr(i,c)}return!1}function Rh(i,c,r,f){return(i!==c||Me(f.enabled,i)===!1)&&(!r.suspense||i.state.status!=="error")&&rr(i,r)}function rr(i,c){return Me(c.enabled,i)!==!1&&i.isStaleByTime(Gl(c.staleTime,i))}function y0(i,c){return!Ws(i.getCurrentResult(),c)}var v0=class extends Ih{#t;#e;#l;#a;constructor(i){super(),this.#t=i.client,this.mutationId=i.mutationId,this.#l=i.mutationCache,this.#e=[],this.state=i.state||p0(),this.setOptions(i.options),this.scheduleGc()}setOptions(i){this.options=i,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(i){this.#e.includes(i)||(this.#e.push(i),this.clearGcTimeout(),this.#l.notify({type:"observerAdded",mutation:this,observer:i}))}removeObserver(i){this.#e=this.#e.filter(c=>c!==i),this.scheduleGc(),this.#l.notify({type:"observerRemoved",mutation:this,observer:i})}optionalRemove(){this.#e.length||(this.state.status==="pending"?this.scheduleGc():this.#l.remove(this))}continue(){return this.#a?.continue()??this.execute(this.state.variables)}async execute(i){const c=()=>{this.#i({type:"continue"})},r={client:this.#t,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#a=Wh({fn:()=>this.options.mutationFn?this.options.mutationFn(i,r):Promise.reject(new Error("No mutationFn found")),onFail:(m,g)=>{this.#i({type:"failed",failureCount:m,error:g})},onPause:()=>{this.#i({type:"pause"})},onContinue:c,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#l.canRun(this)});const f=this.state.status==="pending",d=!this.#a.canStart();try{if(f)c();else{this.#i({type:"pending",variables:i,isPaused:d}),this.#l.config.onMutate&&await this.#l.config.onMutate(i,this,r);const g=await this.options.onMutate?.(i,r);g!==this.state.context&&this.#i({type:"pending",context:g,variables:i,isPaused:d})}const m=await this.#a.start();return await this.#l.config.onSuccess?.(m,i,this.state.context,this,r),await this.options.onSuccess?.(m,i,this.state.context,r),await this.#l.config.onSettled?.(m,null,this.state.variables,this.state.context,this,r),await this.options.onSettled?.(m,null,i,this.state.context,r),this.#i({type:"success",data:m}),m}catch(m){try{await this.#l.config.onError?.(m,i,this.state.context,this,r)}catch(g){Promise.reject(g)}try{await this.options.onError?.(m,i,this.state.context,r)}catch(g){Promise.reject(g)}try{await this.#l.config.onSettled?.(void 0,m,this.state.variables,this.state.context,this,r)}catch(g){Promise.reject(g)}try{await this.options.onSettled?.(void 0,m,i,this.state.context,r)}catch(g){Promise.reject(g)}throw this.#i({type:"error",error:m}),m}finally{this.#l.runNext(this)}}#i(i){const c=r=>{switch(i.type){case"failed":return{...r,failureCount:i.failureCount,failureReason:i.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:i.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:i.isPaused,status:"pending",variables:i.variables,submittedAt:Date.now()};case"success":return{...r,data:i.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:i.error,failureCount:r.failureCount+1,failureReason:i.error,isPaused:!1,status:"error"}}};this.state=c(this.state),ee.batch(()=>{this.#e.forEach(r=>{r.onMutationUpdate(i)}),this.#l.notify({mutation:this,type:"updated",action:i})})}};function p0(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var g0=class extends Pn{constructor(i={}){super(),this.config=i,this.#t=new Set,this.#e=new Map,this.#l=0}#t;#e;#l;build(i,c,r){const f=new v0({client:i,mutationCache:this,mutationId:++this.#l,options:i.defaultMutationOptions(c),state:r});return this.add(f),f}add(i){this.#t.add(i);const c=Su(i);if(typeof c=="string"){const r=this.#e.get(c);r?r.push(i):this.#e.set(c,[i])}this.notify({type:"added",mutation:i})}remove(i){if(this.#t.delete(i)){const c=Su(i);if(typeof c=="string"){const r=this.#e.get(c);if(r)if(r.length>1){const f=r.indexOf(i);f!==-1&&r.splice(f,1)}else r[0]===i&&this.#e.delete(c)}}this.notify({type:"removed",mutation:i})}canRun(i){const c=Su(i);if(typeof c=="string"){const f=this.#e.get(c)?.find(d=>d.state.status==="pending");return!f||f===i}else return!0}runNext(i){const c=Su(i);return typeof c=="string"?this.#e.get(c)?.find(f=>f!==i&&f.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){ee.batch(()=>{this.#t.forEach(i=>{this.notify({type:"removed",mutation:i})}),this.#t.clear(),this.#e.clear()})}getAll(){return Array.from(this.#t)}find(i){const c={exact:!0,...i};return this.getAll().find(r=>Oh(c,r))}findAll(i={}){return this.getAll().filter(c=>Oh(i,c))}notify(i){ee.batch(()=>{this.listeners.forEach(c=>{c(i)})})}resumePausedMutations(){const i=this.getAll().filter(c=>c.state.isPaused);return ee.batch(()=>Promise.all(i.map(c=>c.continue().catch(ve))))}};function Su(i){return i.options.scope?.id}var b0=class extends Pn{constructor(i={}){super(),this.config=i,this.#t=new Map}#t;build(i,c,r){const f=c.queryKey,d=c.queryHash??cr(f,c);let m=this.get(d);return m||(m=new d0({client:i,queryKey:f,queryHash:d,options:i.defaultQueryOptions(c),state:r,defaultOptions:i.getQueryDefaults(f)}),this.add(m)),m}add(i){this.#t.has(i.queryHash)||(this.#t.set(i.queryHash,i),this.notify({type:"added",query:i}))}remove(i){const c=this.#t.get(i.queryHash);c&&(i.destroy(),c===i&&this.#t.delete(i.queryHash),this.notify({type:"removed",query:i}))}clear(){ee.batch(()=>{this.getAll().forEach(i=>{this.remove(i)})})}get(i){return this.#t.get(i)}getAll(){return[...this.#t.values()]}find(i){const c={exact:!0,...i};return this.getAll().find(r=>Nh(c,r))}findAll(i={}){const c=this.getAll();return Object.keys(i).length>0?c.filter(r=>Nh(i,r)):c}notify(i){ee.batch(()=>{this.listeners.forEach(c=>{c(i)})})}onFocus(){ee.batch(()=>{this.getAll().forEach(i=>{i.onFocus()})})}onOnline(){ee.batch(()=>{this.getAll().forEach(i=>{i.onOnline()})})}},S0=class{#t;#e;#l;#a;#i;#n;#c;#u;constructor(i={}){this.#t=i.queryCache||new b0,this.#e=i.mutationCache||new g0,this.#l=i.defaultOptions||{},this.#a=new Map,this.#i=new Map,this.#n=0}mount(){this.#n++,this.#n===1&&(this.#c=ur.subscribe(async i=>{i&&(await this.resumePausedMutations(),this.#t.onFocus())}),this.#u=Nu.subscribe(async i=>{i&&(await this.resumePausedMutations(),this.#t.onOnline())}))}unmount(){this.#n--,this.#n===0&&(this.#c?.(),this.#c=void 0,this.#u?.(),this.#u=void 0)}isFetching(i){return this.#t.findAll({...i,fetchStatus:"fetching"}).length}isMutating(i){return this.#e.findAll({...i,status:"pending"}).length}getQueryData(i){const c=this.defaultQueryOptions({queryKey:i});return this.#t.get(c.queryHash)?.state.data}ensureQueryData(i){const c=this.defaultQueryOptions(i),r=this.#t.build(this,c),f=r.state.data;return f===void 0?this.fetchQuery(i):(i.revalidateIfStale&&r.isStaleByTime(Gl(c.staleTime,r))&&this.prefetchQuery(c),Promise.resolve(f))}getQueriesData(i){return this.#t.findAll(i).map(({queryKey:c,state:r})=>{const f=r.data;return[c,f]})}setQueryData(i,c,r){const f=this.defaultQueryOptions({queryKey:i}),m=this.#t.get(f.queryHash)?.state.data,g=t0(c,m);if(g!==void 0)return this.#t.build(this,f).setData(g,{...r,manual:!0})}setQueriesData(i,c,r){return ee.batch(()=>this.#t.findAll(i).map(({queryKey:f})=>[f,this.setQueryData(f,c,r)]))}getQueryState(i){const c=this.defaultQueryOptions({queryKey:i});return this.#t.get(c.queryHash)?.state}removeQueries(i){const c=this.#t;ee.batch(()=>{c.findAll(i).forEach(r=>{c.remove(r)})})}resetQueries(i,c){const r=this.#t;return ee.batch(()=>(r.findAll(i).forEach(f=>{f.reset()}),this.refetchQueries({type:"active",...i},c)))}cancelQueries(i,c={}){const r={revert:!0,...c},f=ee.batch(()=>this.#t.findAll(i).map(d=>d.cancel(r)));return Promise.all(f).then(ve).catch(ve)}invalidateQueries(i,c={}){return ee.batch(()=>(this.#t.findAll(i).forEach(r=>{r.invalidate()}),i?.refetchType==="none"?Promise.resolve():this.refetchQueries({...i,type:i?.refetchType??i?.type??"active"},c)))}refetchQueries(i,c={}){const r={...c,cancelRefetch:c.cancelRefetch??!0},f=ee.batch(()=>this.#t.findAll(i).filter(d=>!d.isDisabled()&&!d.isStatic()).map(d=>{let m=d.fetch(void 0,r);return r.throwOnError||(m=m.catch(ve)),d.state.fetchStatus==="paused"?Promise.resolve():m}));return Promise.all(f).then(ve)}fetchQuery(i){const c=this.defaultQueryOptions(i);c.retry===void 0&&(c.retry=!1);const r=this.#t.build(this,c);return r.isStaleByTime(Gl(c.staleTime,r))?r.fetch(c):Promise.resolve(r.state.data)}prefetchQuery(i){return this.fetchQuery(i).then(ve).catch(ve)}fetchInfiniteQuery(i){return i._type="infinite",this.fetchQuery(i)}prefetchInfiniteQuery(i){return this.fetchInfiniteQuery(i).then(ve).catch(ve)}ensureInfiniteQueryData(i){return i._type="infinite",this.ensureQueryData(i)}resumePausedMutations(){return Nu.isOnline()?this.#e.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#t}getMutationCache(){return this.#e}getDefaultOptions(){return this.#l}setDefaultOptions(i){this.#l=i}setQueryDefaults(i,c){this.#a.set(kn(i),{queryKey:i,defaultOptions:c})}getQueryDefaults(i){const c=[...this.#a.values()],r={};return c.forEach(f=>{Vn(i,f.queryKey)&&Object.assign(r,f.defaultOptions)}),r}setMutationDefaults(i,c){this.#i.set(kn(i),{mutationKey:i,defaultOptions:c})}getMutationDefaults(i){const c=[...this.#i.values()],r={};return c.forEach(f=>{Vn(i,f.mutationKey)&&Object.assign(r,f.defaultOptions)}),r}defaultQueryOptions(i){if(i._defaulted)return i;const c={...this.#l.queries,...this.getQueryDefaults(i.queryKey),...i,_defaulted:!0};return c.queryHash||(c.queryHash=cr(c.queryKey,c)),c.refetchOnReconnect===void 0&&(c.refetchOnReconnect=c.networkMode!=="always"),c.throwOnError===void 0&&(c.throwOnError=!!c.suspense),!c.networkMode&&c.persister&&(c.networkMode="offlineFirst"),c.queryFn===sr&&(c.enabled=!1),c}defaultMutationOptions(i){return i?._defaulted?i:{...this.#l.mutations,...i?.mutationKey&&this.getMutationDefaults(i.mutationKey),...i,_defaulted:!0}}clear(){this.#t.clear(),this.#e.clear()}},tm=Q.createContext(void 0),ti=i=>{const c=Q.useContext(tm);if(!c)throw new Error("No QueryClient set, use QueryClientProvider to set one");return c},x0=({client:i,children:c})=>(Q.useEffect(()=>(i.mount(),()=>{i.unmount()}),[i]),o.jsx(tm.Provider,{value:i,children:c})),em=Q.createContext(!1),j0=()=>Q.useContext(em);em.Provider;function E0(){let i=!1;return{clearReset:()=>{i=!1},reset:()=>{i=!0},isReset:()=>i}}var T0=Q.createContext(E0()),N0=()=>Q.useContext(T0),O0=(i,c,r)=>{const f=r?.state.error&&typeof i.throwOnError=="function"?Fh(i.throwOnError,[r.state.error,r]):i.throwOnError;(i.suspense||i.experimental_prefetchInRender||f)&&(c.isReset()||(i.retryOnMount=!1))},M0=i=>{Q.useEffect(()=>{i.clearReset()},[i])},A0=({result:i,errorResetBoundary:c,throwOnError:r,query:f,suspense:d})=>i.isError&&!c.isReset()&&!i.isFetching&&f&&(d&&i.data===void 0||Fh(r,[i.error,f])),C0=i=>{if(i.suspense){const r=d=>d==="static"?d:Math.max(d??1e3,1e3),f=i.staleTime;i.staleTime=typeof f=="function"?(...d)=>r(f(...d)):r(f),typeof i.gcTime=="number"&&(i.gcTime=Math.max(i.gcTime,1e3))}},z0=(i,c)=>i.isLoading&&i.isFetching&&!c,_0=(i,c)=>i?.suspense&&c.isPending,Uh=(i,c,r)=>c.fetchOptimistic(i).catch(()=>{r.clearReset()});function D0(i,c,r){const f=j0(),d=N0(),m=ti(),g=m.defaultQueryOptions(i);m.getDefaultOptions().queries?._experimental_beforeQuery?.(g);const A=m.getQueryCache().get(g.queryHash),p=i.subscribed!==!1;g._optimisticResults=f?"isRestoring":p?"optimistic":void 0,C0(g),O0(g,d,A),M0(d);const y=!m.getQueryCache().get(g.queryHash),[M]=Q.useState(()=>new c(m,g)),E=M.getOptimisticResult(g),x=!f&&p;if(Q.useSyncExternalStore(Q.useCallback(q=>{const z=x?M.subscribe(ee.batchCalls(q)):ve;return M.updateResult(),z},[M,x]),()=>M.getCurrentResult(),()=>M.getCurrentResult()),Q.useEffect(()=>{M.setOptions(g)},[g,M]),_0(g,E))throw Uh(g,M,d);if(A0({result:E,errorResetBoundary:d,throwOnError:g.throwOnError,query:A,suspense:g.suspense}))throw E.error;return m.getDefaultOptions().queries?._experimental_afterQuery?.(g,E),g.experimental_prefetchInRender&&!Jn.isServer()&&z0(E,f)&&(y?Uh(g,M,d):A?.promise)?.catch(ve).finally(()=>{M.updateResult()}),g.notifyOnChangeProps?E:M.trackResult(E)}function pe(i,c){return D0(i,h0)}function lm(){throw location.href="/auth/login?next="+encodeURIComponent(location.pathname+location.search),new Error("signing in…")}async function Ae(i){const c=await fetch(i);if(c.status===401&&lm(),!c.ok)throw new Error(await c.text());return c.json()}async function Yl(i,c,r){const f={method:i};r!==void 0&&(f.headers={"Content-Type":"application/json"},f.body=JSON.stringify(r));const d=await fetch(c,f);if(!d.ok)throw new Error(await d.text());return d.status===204?{}:d.json()}async function Ja(i,c){const r=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c||{})});if(r.status===401&&lm(),!r.ok)throw new Error(await r.text());return r.json()}function R0(){return pe({queryKey:["config"],queryFn:async()=>{const i=await Ae("/api/config");return i.auth.enabled&&!i.me&&(location.href="/auth/login?next="+encodeURIComponent(location.pathname+location.search),await new Promise(()=>{})),i},staleTime:1/0})}const am=(...i)=>i.filter((c,r,f)=>!!c&&c.trim()!==""&&f.indexOf(c)===r).join(" ").trim();const U0=i=>i.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const H0=i=>i.replace(/^([A-Z])|[\s-_]+(\w)/g,(c,r,f)=>f?f.toUpperCase():r.toLowerCase());const Hh=i=>{const c=H0(i);return c.charAt(0).toUpperCase()+c.slice(1)};var Vs={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const q0=i=>{for(const c in i)if(c.startsWith("aria-")||c==="role"||c==="title")return!0;return!1},w0=Q.createContext({}),Q0=()=>Q.useContext(w0),B0=Q.forwardRef(({color:i,size:c,strokeWidth:r,absoluteStrokeWidth:f,className:d="",children:m,iconNode:g,...A},p)=>{const{size:y=24,strokeWidth:M=2,absoluteStrokeWidth:E=!1,color:x="currentColor",className:q=""}=Q0()??{},z=f??E?Number(r??M)*24/Number(c??y):r??M;return Q.createElement("svg",{ref:p,...Vs,width:c??y??Vs.width,height:c??y??Vs.height,stroke:i??x,strokeWidth:z,className:am("lucide",q,d),...!m&&!q0(A)&&{"aria-hidden":"true"},...A},[...g.map(([w,Y])=>Q.createElement(w,Y)),...Array.isArray(m)?m:[m]])});const Mt=(i,c)=>{const r=Q.forwardRef(({className:f,...d},m)=>Q.createElement(B0,{ref:m,iconNode:c,className:am(`lucide-${U0(Hh(i))}`,`lucide-${i}`,f),...d}));return r.displayName=Hh(i),r};const L0=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Y0=Mt("check",L0);const G0=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],X0=Mt("chevron-down",G0);const K0=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Z0=Mt("chevron-right",K0);const k0=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],V0=Mt("clock",k0);const J0=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],F0=Mt("copy",J0);const $0=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],W0=Mt("download",$0);const I0=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],P0=Mt("ellipsis",I0);const tp=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],ep=Mt("file-text",tp);const lp=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],ap=Mt("folder",lp);const np=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],ip=Mt("globe",np);const up=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],cp=Mt("history",up);const sp=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],rp=Mt("layout-dashboard",sp);const fp=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],op=Mt("link",fp);const dp=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],hp=Mt("lock",dp);const mp=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],yp=Mt("log-out",mp);const vp=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],pp=Mt("menu",vp);const gp=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],bp=Mt("plus",gp);const Sp=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],xp=Mt("search",Sp);const jp=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Ep=Mt("settings",jp);const Tp=[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]],Np=Mt("share-2",Tp);const Op=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],Mp=Mt("shield",Op);const Ap=[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]],Cp=Mt("square-terminal",Ap);const zp=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],_p=Mt("trash-2",zp);const Dp=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Rp=Mt("triangle-alert",Dp);const Up=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],Hp=Mt("upload",Up);const qp=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],wp=Mt("users",qp);const Qp=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Bp=Mt("x",Qp);function Lp(){document.body.classList.toggle("sb-open")}function hl(){document.body.classList.remove("sb-open")}const Yp={alert:Rp,check:Y0,chev:Z0,chevd:X0,clock:V0,copy:F0,doc:ep,dots:P0,download:W0,folder:ap,dashboard:rp,gear:Ep,globe:ip,hist:cp,link:op,lock:hp,menu:pp,plus:bp,power:yp,search:xp,share:Np,shield:Mp,terminal:Cp,trash:_p,upload:Hp,users:wp,x:Bp};function Kt({name:i}){const c=Yp[i];return c?o.jsx(c,{className:"ico","aria-hidden":"true"}):null}function Fn(i){return o.jsxs(o.Fragment,{children:[o.jsx("div",{id:"sb-backdrop",onClick:hl}),o.jsxs("aside",{id:"sidebar",children:[i.vault,i.projectsNav,i.tree??o.jsx("nav",{id:"tree","aria-label":"Files"}),i.orgBar]}),o.jsxs("main",{id:"main",children:[i.topbar,o.jsx("article",{id:"content",className:i.contentClass??"markdown",ref:i.contentRef,onScroll:i.onContentScroll,children:i.children})]})]})}function Ou(i){const{name:c,onHome:r,showSignout:f}=i;return o.jsxs("header",{id:"vault",children:[o.jsx("span",{id:"vault-badge","aria-hidden":"true",children:"🐻"}),o.jsx("span",{id:"vault-name",className:r?"vault-link":void 0,onClick:r,role:r?"button":void 0,tabIndex:r?0:void 0,onKeyDown:d=>{r&&(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),r())},children:c}),o.jsx("div",{className:"vault-actions",children:f&&o.jsx("a",{id:"signout",href:"/auth/logout",title:"Sign out","aria-label":"Sign out",children:o.jsx(Kt,{name:"power"})})})]})}function $n(i){return o.jsxs("header",{id:"topbar",children:[o.jsx("button",{id:"menu-btn",className:"icon-btn",title:"Menu","aria-label":"Menu",onClick:Lp,children:o.jsx(Kt,{name:"menu"})}),o.jsx("span",{id:"crumb",children:i.crumb}),o.jsx("span",{id:"meta",children:i.meta}),i.actions]})}let fr={msg:"",err:!1,shown:!1},ju=[],qh;function wh(i){fr=i,ju.forEach(c=>c())}function st(i,c=!1){wh({msg:i,err:c,shown:!0}),clearTimeout(qh),qh=setTimeout(()=>wh({...fr,shown:!1}),3200)}function Gp(){const i=Q.useSyncExternalStore(c=>(ju.push(c),()=>{ju=ju.filter(r=>r!==c)}),()=>fr);return o.jsx("div",{id:"toast",className:i.shown?"show"+(i.err?" err":""):"",children:i.msg})}let nm=null,Eu=[];function or(i){nm=i,Eu.forEach(c=>c())}function im(i,c,r="",f="OK"){return new Promise(d=>or({kind:"prompt",title:i,label:c,value:r,okLabel:f,resolve:d}))}function xu(i,c,r="Confirm",f=!1){return new Promise(d=>or({kind:"confirm",title:i,message:c,confirmLabel:r,danger:f,resolve:d}))}function Xp(){const i=Q.useSyncExternalStore(c=>(Eu.push(c),()=>{Eu=Eu.filter(r=>r!==c)}),()=>nm);return i?i.kind==="prompt"?o.jsx(Kp,{m:i}):o.jsx(Zp,{m:i}):null}function um(){or(null)}function Kp({m:i}){const c=Q.useRef(null),r=d=>{um(),i.resolve(d)},f=()=>r(c.current.value.trim()||null);return Q.useEffect(()=>{c.current.focus(),c.current.select();const d=m=>{m.key==="Escape"&&r(null),m.key==="Enter"&&f()};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[]),o.jsx("div",{className:"modal-back",onClick:d=>d.target===d.currentTarget&&r(null),children:o.jsxs("div",{className:"modal",children:[o.jsx("h3",{children:i.title}),o.jsx("label",{className:"modal-label",children:i.label}),o.jsx("input",{className:"modal-input",type:"text",autoComplete:"off",defaultValue:i.value,ref:c}),o.jsxs("div",{className:"modal-actions",children:[o.jsx("button",{className:"ai-btn",onClick:()=>r(null),children:"Cancel"}),o.jsx("button",{className:"pbtn",onClick:f,children:i.okLabel})]})]})})}function Zp({m:i}){const c=Q.useRef(null),r=f=>{um(),i.resolve(f)};return Q.useEffect(()=>{c.current.focus();const f=d=>{d.key==="Escape"&&r(!1),d.key==="Enter"&&r(!0)};return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)},[]),o.jsx("div",{className:"modal-back",onClick:f=>f.target===f.currentTarget&&r(!1),children:o.jsxs("div",{className:"modal",children:[o.jsx("h3",{children:i.title}),o.jsx("p",{className:"modal-msg",children:i.message}),o.jsxs("div",{className:"modal-actions",children:[o.jsx("button",{className:"ai-btn",onClick:()=>r(!1),children:"Cancel"}),o.jsx("button",{className:i.danger?"danger-btn":"pbtn",onClick:()=>r(!0),ref:c,children:i.confirmLabel})]})]})})}function kp(i){return pe({queryKey:["projects"],queryFn:()=>Ae("/api/projects"),enabled:i,refetchInterval:3e4,select:c=>c.projects||[]})}function Vp(i){return pe({queryKey:["orgs"],queryFn:()=>Ae("/api/orgs"),enabled:i,select:c=>c.orgs||[]})}function cm(i){return pe({queryKey:["admin","pending"],queryFn:()=>Ae("/api/admin/pending"),enabled:i,select:c=>c.pending||[]})}function sm(){const i=ti();return()=>Promise.all([i.invalidateQueries({queryKey:["projects"]}),i.invalidateQueries({queryKey:["orgs"]})]).then(()=>{})}function rm(i){return i.split("/").map(encodeURIComponent).join("/")}function Qh(i){return i.split("/").map(decodeURIComponent).join("/")}const Jp=new Set(["insights","history"]);function fm(i,c){const r=i.replace(/^\/+/,"");if(c!=="hub")return{path:r?Qh(r):""};const f=r.indexOf("/");if(f===-1)return{project:r,path:""};const d={project:r.slice(0,f),path:Qh(r.slice(f+1))},m=d.path.indexOf("/"),g=m===-1?d.path:d.path.slice(0,m);return Jp.has(g)&&(d.view=g,d.viewTarget=m===-1?"":d.path.slice(m+1).replace(/\/+$/,""),d.path=""),d}function Fp(i,c){const r=rm(i);return c?"/"+c+(r?"/"+r:""):"/"+r}function ar(i,c,r){let f=(c?"/"+c:"")+"/"+i;return r&&(f+="/"+rm(r.replace(/\/+$/,""))),f}let dr="POP";const nr=new Set;function om(){for(const i of nr)i()}window.addEventListener("popstate",()=>{dr="POP",om()});function Ke(i,c){const r=location.pathname+location.search;!c?.replace&&r===i||(history[c?.replace?"replaceState":"pushState"](null,"",i),dr=c?.replace?"REPLACE":"PUSH",om())}function hr(){return Q.useSyncExternalStore(i=>(nr.add(i),()=>{nr.delete(i)}),()=>location.pathname)}function $p(){return dr}function Wp({to:i}){return Q.useEffect(()=>{Ke(i,{replace:!0})},[i]),null}const Ip=/\.(md|markdown)$/i,Pp=/\.(png|jpe?g|gif|svg|webp|ico|bmp|avif)$/i,tg=/\.html?$/i,eg=/\.(txt|log|json|ya?ml|toml|csv|go|py|js|ts|jsx|tsx|sh|bash|zsh|rb|rs|c|h|cpp|java|kt|swift|sql|css|xml|ini|conf|env|mod|sum|jsonl)$/i;function dm(i){if(i<1024)return i+" B";const c=["KB","MB","GB","TB"];let r=-1;do i/=1024,r++;while(i>=1024&&rd.invalidateQueries({queryKey:["orgs"]}),y=()=>d.invalidateQueries({queryKey:["invites",i.id]}),M=()=>d.invalidateQueries({queryKey:["orgShares",i.id]}),{data:E}=pe({queryKey:["invites",i.id],queryFn:()=>Ae(`/api/orgs/${i.id}/invites`),enabled:m,select:z=>z.invites||[]}),{data:x}=pe({queryKey:["orgShares",i.id],queryFn:()=>Ae(`/api/orgs/${i.id}/shares`),enabled:m,select:z=>z.shares||[]}),q=c.filter(z=>z.org===i.id);return o.jsxs("div",{className:"admin",children:[o.jsx("h1",{id:"org-title",children:i.name+(m?"":" · member")}),m&&o.jsxs("div",{className:"admin-row",children:[o.jsx("input",{id:"org-rename",type:"text",value:g,onChange:z=>A(z.target.value)}),o.jsx("button",{className:"pbtn",id:"org-rename-btn",onClick:async()=>{try{await Yl("PATCH","/api/orgs/"+i.id,{name:g.trim()}),st("Renamed."),p()}catch(z){st(z.message,!0)}},children:"Rename org"})]}),o.jsx("h3",{children:"Members"}),o.jsx("div",{className:"admin-list",children:i.members.map(z=>{const w=!!r&&z.email.toLowerCase()===r.toLowerCase();return o.jsxs("div",{className:"admin-item",children:[o.jsx("span",{className:"ai-main",children:z.email+(w?" (you)":"")}),m&&!w?o.jsxs(o.Fragment,{children:[o.jsxs("select",{value:z.role,onChange:async Y=>{try{await Yl("PATCH",`/api/orgs/${i.id}/members/${encodeURIComponent(z.email)}`,{role:Y.target.value}),st("Role updated.")}catch(F){st(F.message,!0)}p()},children:[o.jsx("option",{value:"owner",children:"owner"}),o.jsx("option",{value:"member",children:"member"})]}),o.jsx("button",{className:"ai-del",onClick:async()=>{if(await xu("Remove member",`Remove ${z.email} from ${i.name}?`,"Remove",!0))try{await Yl("DELETE",`/api/orgs/${i.id}/members/${encodeURIComponent(z.email)}`),st("Removed."),p()}catch(Y){st(Y.message,!0)}},children:"Remove"})]}):o.jsx("span",{className:"ai-tag",children:z.role})]},z.email)})}),m&&o.jsxs(o.Fragment,{children:[o.jsx("h3",{children:"Projects"}),o.jsxs("div",{className:"admin-list",children:[q.length===0&&o.jsx("div",{className:"admin-empty",children:"No projects yet."}),q.map(z=>o.jsxs("div",{className:"admin-item",children:[o.jsx("span",{className:"ai-main",children:z.name}),o.jsx("button",{className:"ai-btn",onClick:async()=>{const w=await im("Rename project","New name",z.name,"Rename");if(!(!w||w===z.name))try{await Yl("PATCH","/api/projects/"+z.id,{name:w}),st("Renamed."),await f()}catch(Y){st(Y.message,!0)}},children:"Rename"}),o.jsx("button",{className:"ai-del",onClick:async()=>{if(await xu("Delete project",`Delete “${z.name}”? Its files stay in storage, but it's removed from the hub.`,"Delete",!0))try{await Yl("DELETE","/api/projects/"+z.id),st(`Deleted “${z.name}”.`),await f()}catch(w){st(w.message,!0)}},children:"Delete"})]},z.id))]}),o.jsxs("div",{className:"admin-h",children:[o.jsx("h3",{children:"Invite links"}),o.jsx("button",{className:"pbtn",onClick:async()=>{try{const z=await Ja(`/api/orgs/${i.id}/invites`),w=await Wn(z.url);st(w?"Invite link copied to clipboard.":"Invite created — copy it from the list below."),y()}catch(z){st(z.message,!0)}},children:"New invite"})]}),o.jsxs("div",{className:"admin-list",children:[E&&E.length===0&&o.jsx("div",{className:"admin-empty",children:"No active invite links."}),(E||[]).map(z=>o.jsxs("div",{className:"admin-item",children:[o.jsx("span",{className:"ai-main mono",style:{cursor:"pointer"},title:"Copy",onClick:()=>Wn(z.url).then(w=>st(w?"Copied.":"Select and copy the link.")),children:z.url}),o.jsx("span",{className:"ai-tag",children:(z.creator?"by "+z.creator+" · ":"")+(z.uses?z.uses+" joined · ":"unused · ")+"expires "+new Date(z.expires).toLocaleDateString()}),o.jsx("button",{className:"ai-del",onClick:async()=>{if(await xu("Revoke invite","Revoke this invite link? Anyone still holding it won't be able to join.","Revoke",!0))try{await Yl("DELETE",`/api/orgs/${i.id}/invites/${z.token}`),st("Revoked."),y()}catch(w){st(w.message,!0)}},children:"Revoke"})]},z.token))]}),o.jsx("h3",{children:"Public share links"}),o.jsxs("div",{className:"admin-list",children:[x&&x.length===0&&o.jsx("div",{className:"admin-empty",children:"No public shares."}),(x||[]).map(z=>o.jsxs("div",{className:"admin-item",children:[o.jsx("span",{className:"ai-main mono",style:{cursor:"pointer"},title:z.url,onClick:()=>window.open(z.url,"_blank"),children:z.path}),o.jsx("span",{className:"ai-tag",children:(z.project_name||"")+(z.creator?" · by "+z.creator:"")+(z.created?" · "+new Date(z.created).toLocaleDateString():"")}),o.jsx("button",{className:"ai-del",onClick:async()=>{if(await xu("Revoke share link",`Revoke the public link to “${z.path}”? Anyone with the URL will lose access.`,"Revoke",!0))try{await Yl("DELETE","/api/shares/"+z.token),st("Share revoked."),M()}catch(w){st(w.message,!0)}},children:"Revoke"})]},z.token))]})]})]})}function ag(){const i=ti(),{data:c,error:r}=pe({queryKey:["admin","policy"],queryFn:()=>Ae("/api/admin/policy")}),{data:f}=cm(!0),[d,m]=Q.useState(!1),[g,A]=Q.useState(!1);if(Q.useEffect(()=>{c&&(m(c.require_verification&&c.mailer),A(c.require_approval))},[c]),Q.useEffect(()=>{r&&st(r.message,!0)},[r]),!c)return null;const p=async(y,M,E)=>{try{await Ja(`/api/admin/pending/${y}/${M}`),st((M==="approve"?"Approved ":"Denied ")+E),i.invalidateQueries({queryKey:["admin","pending"]})}catch(x){st(x.message,!0)}};return o.jsxs("div",{className:"admin",children:[o.jsx("h1",{children:"Signup & access"}),o.jsx("p",{className:"admin-sub",children:"Who can create an account on this hub, and how new accounts are vetted."}),o.jsx("h3",{children:"New-account vetting"}),o.jsxs("div",{className:"admin-list",children:[o.jsx(Bh,{label:"Require email verification",desc:c.mailer?"New accounts must click an emailed link before they can sign in — proves they control the address.":"Configure SMTP on the server (auth.smtp) to enable email verification.",checked:d,disabled:!c.mailer,onChange:m}),o.jsx(Bh,{label:"Require admin approval",desc:"New accounts wait for a hub admin to approve them before they gain access.",checked:g,onChange:A})]}),o.jsx("button",{className:"pbtn",style:{marginTop:14},onClick:async()=>{try{await Ja("/api/admin/policy",{require_verification:d,require_approval:g}),st("Signup policy saved."),i.invalidateQueries({queryKey:["admin","policy"]})}catch(y){st(y.message,!0)}},children:"Save policy"}),o.jsx("h3",{children:"Who can sign up"}),o.jsxs("div",{className:"admin-list",children:[o.jsxs("div",{className:"admin-item",children:[o.jsx("span",{className:"ai-main",children:"Allowed email domains"}),o.jsx("span",{className:"ai-tag",children:c.allowed_domains&&c.allowed_domains.length?c.allowed_domains.map(y=>"@"+y).join(", "):"any"})]}),o.jsxs("div",{className:"admin-item",children:[o.jsx("span",{className:"ai-main",children:"Self-signup"}),o.jsx("span",{className:"ai-tag",children:c.allow_signup?"open":"invite-only"})]}),o.jsxs("div",{className:"admin-item",children:[o.jsx("span",{className:"ai-main",children:"Hub admins"}),o.jsx("span",{className:"ai-tag",children:c.admins&&c.admins.length?c.admins.join(", "):"none"})]})]}),o.jsx("p",{className:"admin-sub",children:"Domains and admins are set in the server config file (they can't be widened from the browser)."}),o.jsx("h3",{children:"Pending signups"}),o.jsxs("div",{className:"admin-list",children:[(!f||f.length===0)&&o.jsx("div",{className:"admin-empty",children:"No one is waiting for approval."}),(f||[]).map(y=>o.jsxs("div",{className:"admin-item",children:[o.jsx("span",{className:"ai-main",children:(y.name?y.name+" · ":"")+y.email}),o.jsx("button",{className:"pbtn",onClick:()=>p(y.id,"approve",y.email),children:"Approve"}),o.jsx("button",{className:"ai-del",onClick:()=>p(y.id,"deny",y.email),children:"Deny"})]},y.id))]})]})}function Bh({label:i,desc:c,checked:r,disabled:f,onChange:d}){return o.jsxs("label",{className:"admin-item toggle",style:f?{opacity:.55}:void 0,children:[o.jsxs("span",{className:"ai-main",children:[o.jsx("div",{className:"tg-label",children:i}),o.jsx("div",{className:"tg-desc",children:c})]}),o.jsx("input",{type:"checkbox",checked:r,disabled:f,onChange:m=>d(m.target.checked)})]})}const Lh=["#5b8def","#f5a623","#4cc38a","#e0679b","#8b7bf0","#3ec8c8","#e6934a"];function mm(i){let c=0;for(const r of i)c=c*31+r.charCodeAt(0)>>>0;return Lh[c%Lh.length]}function Yh({projects:i,currentId:c,menu:r}){const f=sm(),d=async()=>{const m=await im("New project","Project name","","Create");if(m)try{const g=await Ja("/api/projects",{name:m});await f(),Ke("/"+g.project.id),st(`Created “${g.project.name}”.`)}catch(g){st("Could not create the project: "+g.message,!0)}};return o.jsxs("nav",{id:"projects","aria-label":"Projects",children:[o.jsxs("div",{className:"nav-head",children:[o.jsx("span",{children:"Projects"}),o.jsx("button",{className:"nav-add",title:"New project",onClick:d,children:"+"})]}),o.jsx("div",{className:"proj-row",children:o.jsxs("span",{className:"proj-select-wrap",children:[c&&o.jsx("span",{className:"proj-mark","aria-hidden":"true",style:{background:mm(i.find(m=>m.id===c)?.name||"")}}),o.jsxs("select",{id:"project-select","aria-label":"Switch project",value:c||"",onChange:m=>{m.target.value&&(Ke("/"+m.target.value),hl())},children:[!c&&o.jsx("option",{value:"",disabled:!0}),i.map(m=>o.jsx("option",{value:m.id,children:m.name},m.id))]}),o.jsx(Kt,{name:"chevd"})]})}),r&&o.jsx("ul",{className:"nav-menu","aria-label":"Project pages",children:[["dashboard","Dashboard","dashboard",r.onDashboard],["install","Installation","terminal",r.onInstall],["settings","Settings","gear",r.onSettings]].map(([m,g,A,p])=>o.jsx("li",{children:o.jsxs("div",{id:"nav-"+m,className:"row"+(r.active===m?" active":""),role:"button",tabIndex:0,onClick:p,onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),p())},children:[o.jsx(Kt,{name:A}),o.jsx("span",{className:"label",children:g})]})},m))})]})}function ng({me:i,org:c,admin:r,onOrgSettings:f}){const[d,m]=Q.useState(!1),g=Q.useRef(null);Q.useEffect(()=>{if(!d)return;const p=M=>{g.current&&!g.current.contains(M.target)&&m(!1)},y=M=>{M.key==="Escape"&&m(!1)};return document.addEventListener("mousedown",p),document.addEventListener("keydown",y),()=>{document.removeEventListener("mousedown",p),document.removeEventListener("keydown",y)}},[d]);const A=i.name||i.email;return o.jsxs("footer",{id:"accountbar",ref:g,children:[d&&o.jsxs("div",{id:"account-menu",role:"menu","aria-label":"Account menu",children:[c&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"menu-sec",children:"Organization"}),o.jsxs("button",{id:"menu-org-settings",role:"menuitem",onClick:()=>{m(!1),f(c)},children:[o.jsx(Kt,{name:"gear"}),o.jsxs("span",{children:[o.jsx("b",{children:c.name})," Settings"]})]})]}),r&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"menu-sec",children:"Hub"}),o.jsxs("button",{id:"menu-hub-admin",role:"menuitem",onClick:()=>{m(!1),r.onClick()},children:[o.jsx(Kt,{name:"shield"}),o.jsxs("span",{children:["Signup & access",r.pending?` · ${r.pending}`:""]})]})]}),o.jsx("div",{className:"menu-sec",children:"Account"}),o.jsxs("a",{id:"signout",role:"menuitem",href:"/auth/logout",children:[o.jsx(Kt,{name:"power"}),o.jsx("span",{children:"Log out"})]})]}),o.jsxs("button",{id:"account-btn","aria-haspopup":"menu","aria-expanded":d,onClick:()=>m(p=>!p),children:[o.jsx("span",{className:"avatar",style:{background:mm(i.email)},"aria-hidden":"true",children:(A.trim()[0]||"?").toUpperCase()}),o.jsxs("span",{className:"acct",children:[o.jsx("b",{children:A}),i.name&&o.jsx("small",{children:i.email})]}),o.jsx(Kt,{name:"chev"})]})]})}function ig({project:i,org:c}){return o.jsxs("div",{className:"project-settings",children:[o.jsx("h2",{children:i.name}),o.jsxs("dl",{className:"ps-facts",children:[o.jsx("dt",{children:"Project id"}),o.jsx("dd",{children:o.jsx("code",{children:i.id})}),c&&o.jsxs(o.Fragment,{children:[o.jsx("dt",{children:"Workspace"}),o.jsx("dd",{children:c.name})]}),i.created&&o.jsxs(o.Fragment,{children:[o.jsx("dt",{children:"Created"}),o.jsx("dd",{children:new Date(i.created).toLocaleDateString()})]})]})]})}const Js=[{key:"claude",label:"Claude Code & Cowork"},{key:"hermes",label:"Hermes",hook:"hermes",note:"Registers BearDrive's hooks in Hermes's config: pull before every turn, push after edits with a session note, and report file reads to Insights."},{key:"codex",label:"Codex",hook:"codex",note:"Registers hooks in .codex/hooks.json.",extra:"Run /hooks inside Codex once to trust the project's .codex layer — after that every turn pulls, edits push automatically, and reads are reported to Insights."}];function ug(i,c){const r=window.location.origin,f=c.id;if(i.key==="claude")return[{title:"Add the BearDrive plugin",desc:"One time, in any Claude Code session. The plugin ships the beardrive skill, the /beardrive commands, and turn-boundary sync hooks — and Claude Cowork shares the same plugins, so installing it once covers both.",code:`/plugin marketplace add runbear-io/beardrive +`+a.stack}}var P=Object.prototype.hasOwnProperty,ft=i.unstable_scheduleCallback,xt=i.unstable_cancelCallback,Fa=i.unstable_shouldYield,Cu=i.unstable_requestPaint,ne=i.unstable_now,bm=i.unstable_getCurrentPriorityLevel,mr=i.unstable_ImmediatePriority,yr=i.unstable_UserBlockingPriority,ni=i.unstable_NormalPriority,Sm=i.unstable_LowPriority,vr=i.unstable_IdlePriority,xm=i.log,jm=i.unstable_setDisableYieldValue,$a=null,ge=null;function vl(t){if(typeof xm=="function"&&jm(t),ge&&typeof ge.setStrictMode=="function")try{ge.setStrictMode($a,t)}catch{}}var be=Math.clz32?Math.clz32:Nm,Em=Math.log,Tm=Math.LN2;function Nm(t){return t>>>=0,t===0?32:31-(Em(t)/Tm|0)|0}var ii=256,ui=262144,ci=4194304;function Kl(t){var e=t&42;if(e!==0)return e;switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return t&261888;case 262144:case 524288:case 1048576:case 2097152:return t&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return t&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return t}}function si(t,e,l){var a=t.pendingLanes;if(a===0)return 0;var n=0,u=t.suspendedLanes,s=t.pingedLanes;t=t.warmLanes;var h=a&134217727;return h!==0?(a=h&~u,a!==0?n=Kl(a):(s&=h,s!==0?n=Kl(s):l||(l=h&~t,l!==0&&(n=Kl(l))))):(h=a&~u,h!==0?n=Kl(h):s!==0?n=Kl(s):l||(l=a&~t,l!==0&&(n=Kl(l)))),n===0?0:e!==0&&e!==n&&(e&u)===0&&(u=n&-n,l=e&-e,u>=l||u===32&&(l&4194048)!==0)?e:n}function Wa(t,e){return(t.pendingLanes&~(t.suspendedLanes&~t.pingedLanes)&e)===0}function Om(t,e){switch(t){case 1:case 2:case 4:case 8:case 64:return e+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function pr(){var t=ci;return ci<<=1,(ci&62914560)===0&&(ci=4194304),t}function zu(t){for(var e=[],l=0;31>l;l++)e.push(t);return e}function Ia(t,e){t.pendingLanes|=e,e!==268435456&&(t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0)}function Mm(t,e,l,a,n,u){var s=t.pendingLanes;t.pendingLanes=l,t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0,t.expiredLanes&=l,t.entangledLanes&=l,t.errorRecoveryDisabledLanes&=l,t.shellSuspendCounter=0;var h=t.entanglements,v=t.expirationTimes,N=t.hiddenUpdates;for(l=s&~l;0"u")return null;try{return t.activeElement||t.body}catch{return t.body}}var Rm=/[\n"\\]/g;function De(t){return t.replace(Rm,function(e){return"\\"+e.charCodeAt(0).toString(16)+" "})}function qu(t,e,l,a,n,u,s,h){t.name="",s!=null&&typeof s!="function"&&typeof s!="symbol"&&typeof s!="boolean"?t.type=s:t.removeAttribute("type"),e!=null?s==="number"?(e===0&&t.value===""||t.value!=e)&&(t.value=""+_e(e)):t.value!==""+_e(e)&&(t.value=""+_e(e)):s!=="submit"&&s!=="reset"||t.removeAttribute("value"),e!=null?wu(t,s,_e(e)):l!=null?wu(t,s,_e(l)):a!=null&&t.removeAttribute("value"),n==null&&u!=null&&(t.defaultChecked=!!u),n!=null&&(t.checked=n&&typeof n!="function"&&typeof n!="symbol"),h!=null&&typeof h!="function"&&typeof h!="symbol"&&typeof h!="boolean"?t.name=""+_e(h):t.removeAttribute("name")}function zr(t,e,l,a,n,u,s,h){if(u!=null&&typeof u!="function"&&typeof u!="symbol"&&typeof u!="boolean"&&(t.type=u),e!=null||l!=null){if(!(u!=="submit"&&u!=="reset"||e!=null)){Hu(t);return}l=l!=null?""+_e(l):"",e=e!=null?""+_e(e):l,h||e===t.value||(t.value=e),t.defaultValue=e}a=a??n,a=typeof a!="function"&&typeof a!="symbol"&&!!a,t.checked=h?t.checked:!!a,t.defaultChecked=!!a,s!=null&&typeof s!="function"&&typeof s!="symbol"&&typeof s!="boolean"&&(t.name=s),Hu(t)}function wu(t,e,l){e==="number"&&oi(t.ownerDocument)===t||t.defaultValue===""+l||(t.defaultValue=""+l)}function ma(t,e,l,a){if(t=t.options,e){e={};for(var n=0;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Gu=!1;if(We)try{var ln={};Object.defineProperty(ln,"passive",{get:function(){Gu=!0}}),window.addEventListener("test",ln,ln),window.removeEventListener("test",ln,ln)}catch{Gu=!1}var gl=null,Xu=null,hi=null;function wr(){if(hi)return hi;var t,e=Xu,l=e.length,a,n="value"in gl?gl.value:gl.textContent,u=n.length;for(t=0;t=un),Xr=" ",Kr=!1;function Zr(t,e){switch(t){case"keyup":return cy.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function kr(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var ga=!1;function ry(t,e){switch(t){case"compositionend":return kr(e);case"keypress":return e.which!==32?null:(Kr=!0,Xr);case"textInput":return t=e.data,t===Xr&&Kr?null:t;default:return null}}function fy(t,e){if(ga)return t==="compositionend"||!Ju&&Zr(t,e)?(t=wr(),hi=Xu=gl=null,ga=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1=e)return{node:l,offset:e-t};t=a}t:{for(;l;){if(l.nextSibling){l=l.nextSibling;break t}l=l.parentNode}l=void 0}l=tf(l)}}function lf(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?lf(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function af(t){t=t!=null&&t.ownerDocument!=null&&t.ownerDocument.defaultView!=null?t.ownerDocument.defaultView:window;for(var e=oi(t.document);e instanceof t.HTMLIFrameElement;){try{var l=typeof e.contentWindow.location.href=="string"}catch{l=!1}if(l)t=e.contentWindow;else break;e=oi(t.document)}return e}function Wu(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e&&(e==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||e==="textarea"||t.contentEditable==="true")}var gy=We&&"documentMode"in document&&11>=document.documentMode,ba=null,Iu=null,fn=null,Pu=!1;function nf(t,e,l){var a=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;Pu||ba==null||ba!==oi(a)||(a=ba,"selectionStart"in a&&Wu(a)?a={start:a.selectionStart,end:a.selectionEnd}:(a=(a.ownerDocument&&a.ownerDocument.defaultView||window).getSelection(),a={anchorNode:a.anchorNode,anchorOffset:a.anchorOffset,focusNode:a.focusNode,focusOffset:a.focusOffset}),fn&&rn(fn,a)||(fn=a,a=uu(Iu,"onSelect"),0>=s,n-=s,Ze=1<<32-be(e)+n|l<tt?(ut=K,K=null):ut=K.sibling;var mt=O(j,K,T[tt],R);if(mt===null){K===null&&(K=ut);break}t&&K&&mt.alternate===null&&e(j,K),b=u(mt,b,tt),ht===null?Z=mt:ht.sibling=mt,ht=mt,K=ut}if(tt===T.length)return l(j,K),ct&&Pe(j,tt),Z;if(K===null){for(;tttt?(ut=K,K=null):ut=K.sibling;var Ll=O(j,K,mt.value,R);if(Ll===null){K===null&&(K=ut);break}t&&K&&Ll.alternate===null&&e(j,K),b=u(Ll,b,tt),ht===null?Z=Ll:ht.sibling=Ll,ht=Ll,K=ut}if(mt.done)return l(j,K),ct&&Pe(j,tt),Z;if(K===null){for(;!mt.done;tt++,mt=T.next())mt=U(j,mt.value,R),mt!==null&&(b=u(mt,b,tt),ht===null?Z=mt:ht.sibling=mt,ht=mt);return ct&&Pe(j,tt),Z}for(K=a(K);!mt.done;tt++,mt=T.next())mt=C(K,j,tt,mt.value,R),mt!==null&&(t&&mt.alternate!==null&&K.delete(mt.key===null?tt:mt.key),b=u(mt,b,tt),ht===null?Z=mt:ht.sibling=mt,ht=mt);return t&&K.forEach(function(Qv){return e(j,Qv)}),ct&&Pe(j,tt),Z}function Tt(j,b,T,R){if(typeof T=="object"&&T!==null&&T.type===w&&T.key===null&&(T=T.props.children),typeof T=="object"&&T!==null){switch(T.$$typeof){case q:t:{for(var Z=T.key;b!==null;){if(b.key===Z){if(Z=T.type,Z===w){if(b.tag===7){l(j,b.sibling),R=n(b,T.props.children),R.return=j,j=R;break t}}else if(b.elementType===Z||typeof Z=="object"&&Z!==null&&Z.$$typeof===gt&&ea(Z)===b.type){l(j,b.sibling),R=n(b,T.props),vn(R,T),R.return=j,j=R;break t}l(j,b);break}else e(j,b);b=b.sibling}T.type===w?(R=$l(T.props.children,j.mode,R,T.key),R.return=j,j=R):(R=Ei(T.type,T.key,T.props,null,j.mode,R),vn(R,T),R.return=j,j=R)}return s(j);case z:t:{for(Z=T.key;b!==null;){if(b.key===Z)if(b.tag===4&&b.stateNode.containerInfo===T.containerInfo&&b.stateNode.implementation===T.implementation){l(j,b.sibling),R=n(b,T.children||[]),R.return=j,j=R;break t}else{l(j,b);break}else e(j,b);b=b.sibling}R=uc(T,j.mode,R),R.return=j,j=R}return s(j);case gt:return T=ea(T),Tt(j,b,T,R)}if(kt(T))return X(j,b,T,R);if(_t(T)){if(Z=_t(T),typeof Z!="function")throw Error(f(150));return T=Z.call(T),F(j,b,T,R)}if(typeof T.then=="function")return Tt(j,b,zi(T),R);if(T.$$typeof===ot)return Tt(j,b,Oi(j,T),R);_i(j,T)}return typeof T=="string"&&T!==""||typeof T=="number"||typeof T=="bigint"?(T=""+T,b!==null&&b.tag===6?(l(j,b.sibling),R=n(b,T),R.return=j,j=R):(l(j,b),R=ic(T,j.mode,R),R.return=j,j=R),s(j)):l(j,b)}return function(j,b,T,R){try{yn=0;var Z=Tt(j,b,T,R);return za=null,Z}catch(K){if(K===Ca||K===Ai)throw K;var ht=xe(29,K,null,j.mode);return ht.lanes=R,ht.return=j,ht}}}var aa=Af(!0),Cf=Af(!1),El=!1;function gc(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function bc(t,e){t=t.updateQueue,e.updateQueue===t&&(e.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,callbacks:null})}function Tl(t){return{lane:t,tag:0,payload:null,callback:null,next:null}}function Nl(t,e,l){var a=t.updateQueue;if(a===null)return null;if(a=a.shared,(pt&2)!==0){var n=a.pending;return n===null?e.next=e:(e.next=n.next,n.next=e),a.pending=e,e=ji(t),df(t,null,l),e}return xi(t,a,e,l),ji(t)}function pn(t,e,l){if(e=e.updateQueue,e!==null&&(e=e.shared,(l&4194048)!==0)){var a=e.lanes;a&=t.pendingLanes,l|=a,e.lanes=l,br(t,l)}}function Sc(t,e){var l=t.updateQueue,a=t.alternate;if(a!==null&&(a=a.updateQueue,l===a)){var n=null,u=null;if(l=l.firstBaseUpdate,l!==null){do{var s={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};u===null?n=u=s:u=u.next=s,l=l.next}while(l!==null);u===null?n=u=e:u=u.next=e}else n=u=e;l={baseState:a.baseState,firstBaseUpdate:n,lastBaseUpdate:u,shared:a.shared,callbacks:a.callbacks},t.updateQueue=l;return}t=l.lastBaseUpdate,t===null?l.firstBaseUpdate=e:t.next=e,l.lastBaseUpdate=e}var xc=!1;function gn(){if(xc){var t=Aa;if(t!==null)throw t}}function bn(t,e,l,a){xc=!1;var n=t.updateQueue;El=!1;var u=n.firstBaseUpdate,s=n.lastBaseUpdate,h=n.shared.pending;if(h!==null){n.shared.pending=null;var v=h,N=v.next;v.next=null,s===null?u=N:s.next=N,s=v;var _=t.alternate;_!==null&&(_=_.updateQueue,h=_.lastBaseUpdate,h!==s&&(h===null?_.firstBaseUpdate=N:h.next=N,_.lastBaseUpdate=v))}if(u!==null){var U=n.baseState;s=0,_=N=v=null,h=u;do{var O=h.lane&-536870913,C=O!==h.lane;if(C?(it&O)===O:(a&O)===O){O!==0&&O===Ma&&(xc=!0),_!==null&&(_=_.next={lane:0,tag:h.tag,payload:h.payload,callback:null,next:null});t:{var X=t,F=h;O=e;var Tt=l;switch(F.tag){case 1:if(X=F.payload,typeof X=="function"){U=X.call(Tt,U,O);break t}U=X;break t;case 3:X.flags=X.flags&-65537|128;case 0:if(X=F.payload,O=typeof X=="function"?X.call(Tt,U,O):X,O==null)break t;U=E({},U,O);break t;case 2:El=!0}}O=h.callback,O!==null&&(t.flags|=64,C&&(t.flags|=8192),C=n.callbacks,C===null?n.callbacks=[O]:C.push(O))}else C={lane:O,tag:h.tag,payload:h.payload,callback:h.callback,next:null},_===null?(N=_=C,v=U):_=_.next=C,s|=O;if(h=h.next,h===null){if(h=n.shared.pending,h===null)break;C=h,h=C.next,C.next=null,n.lastBaseUpdate=C,n.shared.pending=null}}while(!0);_===null&&(v=U),n.baseState=v,n.firstBaseUpdate=N,n.lastBaseUpdate=_,u===null&&(n.shared.lanes=0),zl|=s,t.lanes=s,t.memoizedState=U}}function zf(t,e){if(typeof t!="function")throw Error(f(191,t));t.call(e)}function _f(t,e){var l=t.callbacks;if(l!==null)for(t.callbacks=null,t=0;tu?u:8;var s=D.T,h={};D.T=h,Lc(t,!1,e,l);try{var v=n(),N=D.S;if(N!==null&&N(h,v),v!==null&&typeof v=="object"&&typeof v.then=="function"){var _=My(v,a);jn(t,e,_,Oe(t))}else jn(t,e,a,Oe(t))}catch(U){jn(t,e,{then:function(){},status:"rejected",reason:U},Oe())}finally{B.p=u,s!==null&&h.types!==null&&(s.types=h.types),D.T=s}}function Ry(){}function Qc(t,e,l,a){if(t.tag!==5)throw Error(f(476));var n=ro(t).queue;so(t,n,e,V,l===null?Ry:function(){return fo(t),l(a)})}function ro(t){var e=t.memoizedState;if(e!==null)return e;e={memoizedState:V,baseState:V,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:al,lastRenderedState:V},next:null};var l={};return e.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:al,lastRenderedState:l},next:null},t.memoizedState=e,t=t.alternate,t!==null&&(t.memoizedState=e),e}function fo(t){var e=ro(t);e.next===null&&(e=t.alternate.memoizedState),jn(t,e.next.queue,{},Oe())}function Bc(){return It(Bn)}function oo(){return Bt().memoizedState}function ho(){return Bt().memoizedState}function Uy(t){for(var e=t.return;e!==null;){switch(e.tag){case 24:case 3:var l=Oe();t=Tl(l);var a=Nl(e,t,l);a!==null&&(ye(a,e,l),pn(a,e,l)),e={cache:mc()},t.payload=e;return}e=e.return}}function Hy(t,e,l){var a=Oe();l={lane:a,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},Yi(t)?yo(e,l):(l=ac(t,e,l,a),l!==null&&(ye(l,t,a),vo(l,e,a)))}function mo(t,e,l){var a=Oe();jn(t,e,l,a)}function jn(t,e,l,a){var n={lane:a,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(Yi(t))yo(e,n);else{var u=t.alternate;if(t.lanes===0&&(u===null||u.lanes===0)&&(u=e.lastRenderedReducer,u!==null))try{var s=e.lastRenderedState,h=u(s,l);if(n.hasEagerState=!0,n.eagerState=h,Se(h,s))return xi(t,e,n,0),Nt===null&&Si(),!1}catch{}if(l=ac(t,e,n,a),l!==null)return ye(l,t,a),vo(l,e,a),!0}return!1}function Lc(t,e,l,a){if(a={lane:2,revertLane:gs(),gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},Yi(t)){if(e)throw Error(f(479))}else e=ac(t,l,a,2),e!==null&&ye(e,t,2)}function Yi(t){var e=t.alternate;return t===I||e!==null&&e===I}function yo(t,e){Da=Ui=!0;var l=t.pending;l===null?e.next=e:(e.next=l.next,l.next=e),t.pending=e}function vo(t,e,l){if((l&4194048)!==0){var a=e.lanes;a&=t.pendingLanes,l|=a,e.lanes=l,br(t,l)}}var En={readContext:It,use:wi,useCallback:Ht,useContext:Ht,useEffect:Ht,useImperativeHandle:Ht,useLayoutEffect:Ht,useInsertionEffect:Ht,useMemo:Ht,useReducer:Ht,useRef:Ht,useState:Ht,useDebugValue:Ht,useDeferredValue:Ht,useTransition:Ht,useSyncExternalStore:Ht,useId:Ht,useHostTransitionStatus:Ht,useFormState:Ht,useActionState:Ht,useOptimistic:Ht,useMemoCache:Ht,useCacheRefresh:Ht};En.useEffectEvent=Ht;var po={readContext:It,use:wi,useCallback:function(t,e){return ie().memoizedState=[t,e===void 0?null:e],t},useContext:It,useEffect:Pf,useImperativeHandle:function(t,e,l){l=l!=null?l.concat([t]):null,Bi(4194308,4,ao.bind(null,e,t),l)},useLayoutEffect:function(t,e){return Bi(4194308,4,t,e)},useInsertionEffect:function(t,e){Bi(4,2,t,e)},useMemo:function(t,e){var l=ie();e=e===void 0?null:e;var a=t();if(na){vl(!0);try{t()}finally{vl(!1)}}return l.memoizedState=[a,e],a},useReducer:function(t,e,l){var a=ie();if(l!==void 0){var n=l(e);if(na){vl(!0);try{l(e)}finally{vl(!1)}}}else n=e;return a.memoizedState=a.baseState=n,t={pending:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:n},a.queue=t,t=t.dispatch=Hy.bind(null,I,t),[a.memoizedState,t]},useRef:function(t){var e=ie();return t={current:t},e.memoizedState=t},useState:function(t){t=Rc(t);var e=t.queue,l=mo.bind(null,I,e);return e.dispatch=l,[t.memoizedState,l]},useDebugValue:qc,useDeferredValue:function(t,e){var l=ie();return wc(l,t,e)},useTransition:function(){var t=Rc(!1);return t=so.bind(null,I,t.queue,!0,!1),ie().memoizedState=t,[!1,t]},useSyncExternalStore:function(t,e,l){var a=I,n=ie();if(ct){if(l===void 0)throw Error(f(407));l=l()}else{if(l=e(),Nt===null)throw Error(f(349));(it&127)!==0||wf(a,e,l)}n.memoizedState=l;var u={value:l,getSnapshot:e};return n.queue=u,Pf(Bf.bind(null,a,u,t),[t]),a.flags|=2048,Ua(9,{destroy:void 0},Qf.bind(null,a,u,l,e),null),l},useId:function(){var t=ie(),e=Nt.identifierPrefix;if(ct){var l=ke,a=Ze;l=(a&~(1<<32-be(a)-1)).toString(32)+l,e="_"+e+"R_"+l,l=Hi++,0<\/script>",u=u.removeChild(u.firstChild);break;case"select":u=typeof a.is=="string"?s.createElement("select",{is:a.is}):s.createElement("select"),a.multiple?u.multiple=!0:a.size&&(u.size=a.size);break;default:u=typeof a.is=="string"?s.createElement(n,{is:a.is}):s.createElement(n)}}u[$t]=e,u[re]=a;t:for(s=e.child;s!==null;){if(s.tag===5||s.tag===6)u.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===e)break t;for(;s.sibling===null;){if(s.return===null||s.return===e)break t;s=s.return}s.sibling.return=s.return,s=s.sibling}e.stateNode=u;t:switch(te(u,n,a),n){case"button":case"input":case"select":case"textarea":a=!!a.autoFocus;break t;case"img":a=!0;break t;default:a=!1}a&&il(e)}}return At(e),ts(e,e.type,t===null?null:t.memoizedProps,e.pendingProps,l),null;case 6:if(t&&e.stateNode!=null)t.memoizedProps!==a&&il(e);else{if(typeof a!="string"&&e.stateNode===null)throw Error(f(166));if(t=lt.current,Na(e)){if(t=e.stateNode,l=e.memoizedProps,a=null,n=Wt,n!==null)switch(n.tag){case 27:case 5:a=n.memoizedProps}t[$t]=e,t=!!(t.nodeValue===l||a!==null&&a.suppressHydrationWarning===!0||qd(t.nodeValue,l)),t||xl(e,!0)}else t=cu(t).createTextNode(a),t[$t]=e,e.stateNode=t}return At(e),null;case 31:if(l=e.memoizedState,t===null||t.memoizedState!==null){if(a=Na(e),l!==null){if(t===null){if(!a)throw Error(f(318));if(t=e.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(f(557));t[$t]=e}else Wl(),(e.flags&128)===0&&(e.memoizedState=null),e.flags|=4;At(e),t=!1}else l=fc(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=l),t=!0;if(!t)return e.flags&256?(Ee(e),e):(Ee(e),null);if((e.flags&128)!==0)throw Error(f(558))}return At(e),null;case 13:if(a=e.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(n=Na(e),a!==null&&a.dehydrated!==null){if(t===null){if(!n)throw Error(f(318));if(n=e.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(f(317));n[$t]=e}else Wl(),(e.flags&128)===0&&(e.memoizedState=null),e.flags|=4;At(e),n=!1}else n=fc(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=n),n=!0;if(!n)return e.flags&256?(Ee(e),e):(Ee(e),null)}return Ee(e),(e.flags&128)!==0?(e.lanes=l,e):(l=a!==null,t=t!==null&&t.memoizedState!==null,l&&(a=e.child,n=null,a.alternate!==null&&a.alternate.memoizedState!==null&&a.alternate.memoizedState.cachePool!==null&&(n=a.alternate.memoizedState.cachePool.pool),u=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(u=a.memoizedState.cachePool.pool),u!==n&&(a.flags|=2048)),l!==t&&l&&(e.child.flags|=8192),ki(e,e.updateQueue),At(e),null);case 4:return Dt(),t===null&&js(e.stateNode.containerInfo),At(e),null;case 10:return el(e.type),At(e),null;case 19:if(H(Qt),a=e.memoizedState,a===null)return At(e),null;if(n=(e.flags&128)!==0,u=a.rendering,u===null)if(n)Nn(a,!1);else{if(qt!==0||t!==null&&(t.flags&128)!==0)for(t=e.child;t!==null;){if(u=Ri(t),u!==null){for(e.flags|=128,Nn(a,!1),t=u.updateQueue,e.updateQueue=t,ki(e,t),e.subtreeFlags=0,t=l,l=e.child;l!==null;)hf(l,t),l=l.sibling;return L(Qt,Qt.current&1|2),ct&&Pe(e,a.treeForkCount),e.child}t=t.sibling}a.tail!==null&&ne()>Wi&&(e.flags|=128,n=!0,Nn(a,!1),e.lanes=4194304)}else{if(!n)if(t=Ri(u),t!==null){if(e.flags|=128,n=!0,t=t.updateQueue,e.updateQueue=t,ki(e,t),Nn(a,!0),a.tail===null&&a.tailMode==="hidden"&&!u.alternate&&!ct)return At(e),null}else 2*ne()-a.renderingStartTime>Wi&&l!==536870912&&(e.flags|=128,n=!0,Nn(a,!1),e.lanes=4194304);a.isBackwards?(u.sibling=e.child,e.child=u):(t=a.last,t!==null?t.sibling=u:e.child=u,a.last=u)}return a.tail!==null?(t=a.tail,a.rendering=t,a.tail=t.sibling,a.renderingStartTime=ne(),t.sibling=null,l=Qt.current,L(Qt,n?l&1|2:l&1),ct&&Pe(e,a.treeForkCount),t):(At(e),null);case 22:case 23:return Ee(e),Ec(),a=e.memoizedState!==null,t!==null?t.memoizedState!==null!==a&&(e.flags|=8192):a&&(e.flags|=8192),a?(l&536870912)!==0&&(e.flags&128)===0&&(At(e),e.subtreeFlags&6&&(e.flags|=8192)):At(e),l=e.updateQueue,l!==null&&ki(e,l.retryQueue),l=null,t!==null&&t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(l=t.memoizedState.cachePool.pool),a=null,e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(a=e.memoizedState.cachePool.pool),a!==l&&(e.flags|=2048),t!==null&&H(ta),null;case 24:return l=null,t!==null&&(l=t.memoizedState.cache),e.memoizedState.cache!==l&&(e.flags|=2048),el(Lt),At(e),null;case 25:return null;case 30:return null}throw Error(f(156,e.tag))}function Ly(t,e){switch(sc(e),e.tag){case 1:return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return el(Lt),Dt(),t=e.flags,(t&65536)!==0&&(t&128)===0?(e.flags=t&-65537|128,e):null;case 26:case 27:case 5:return ml(e),null;case 31:if(e.memoizedState!==null){if(Ee(e),e.alternate===null)throw Error(f(340));Wl()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 13:if(Ee(e),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(f(340));Wl()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return H(Qt),null;case 4:return Dt(),null;case 10:return el(e.type),null;case 22:case 23:return Ee(e),Ec(),t!==null&&H(ta),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 24:return el(Lt),null;case 25:return null;default:return null}}function Yo(t,e){switch(sc(e),e.tag){case 3:el(Lt),Dt();break;case 26:case 27:case 5:ml(e);break;case 4:Dt();break;case 31:e.memoizedState!==null&&Ee(e);break;case 13:Ee(e);break;case 19:H(Qt);break;case 10:el(e.type);break;case 22:case 23:Ee(e),Ec(),t!==null&&H(ta);break;case 24:el(Lt)}}function On(t,e){try{var l=e.updateQueue,a=l!==null?l.lastEffect:null;if(a!==null){var n=a.next;l=n;do{if((l.tag&t)===t){a=void 0;var u=l.create,s=l.inst;a=u(),s.destroy=a}l=l.next}while(l!==n)}}catch(h){St(e,e.return,h)}}function Al(t,e,l){try{var a=e.updateQueue,n=a!==null?a.lastEffect:null;if(n!==null){var u=n.next;a=u;do{if((a.tag&t)===t){var s=a.inst,h=s.destroy;if(h!==void 0){s.destroy=void 0,n=e;var v=l,N=h;try{N()}catch(_){St(n,v,_)}}}a=a.next}while(a!==u)}}catch(_){St(e,e.return,_)}}function Go(t){var e=t.updateQueue;if(e!==null){var l=t.stateNode;try{_f(e,l)}catch(a){St(t,t.return,a)}}}function Xo(t,e,l){l.props=ia(t.type,t.memoizedProps),l.state=t.memoizedState;try{l.componentWillUnmount()}catch(a){St(t,e,a)}}function Mn(t,e){try{var l=t.ref;if(l!==null){switch(t.tag){case 26:case 27:case 5:var a=t.stateNode;break;case 30:a=t.stateNode;break;default:a=t.stateNode}typeof l=="function"?t.refCleanup=l(a):l.current=a}}catch(n){St(t,e,n)}}function Ve(t,e){var l=t.ref,a=t.refCleanup;if(l!==null)if(typeof a=="function")try{a()}catch(n){St(t,e,n)}finally{t.refCleanup=null,t=t.alternate,t!=null&&(t.refCleanup=null)}else if(typeof l=="function")try{l(null)}catch(n){St(t,e,n)}else l.current=null}function Ko(t){var e=t.type,l=t.memoizedProps,a=t.stateNode;try{t:switch(e){case"button":case"input":case"select":case"textarea":l.autoFocus&&a.focus();break t;case"img":l.src?a.src=l.src:l.srcSet&&(a.srcset=l.srcSet)}}catch(n){St(t,t.return,n)}}function es(t,e,l){try{var a=t.stateNode;sv(a,t.type,l,e),a[re]=e}catch(n){St(t,t.return,n)}}function Zo(t){return t.tag===5||t.tag===3||t.tag===26||t.tag===27&&Hl(t.type)||t.tag===4}function ls(t){t:for(;;){for(;t.sibling===null;){if(t.return===null||Zo(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.tag===27&&Hl(t.type)||t.flags&2||t.child===null||t.tag===4)continue t;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function as(t,e,l){var a=t.tag;if(a===5||a===6)t=t.stateNode,e?(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l).insertBefore(t,e):(e=l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,e.appendChild(t),l=l._reactRootContainer,l!=null||e.onclick!==null||(e.onclick=$e));else if(a!==4&&(a===27&&Hl(t.type)&&(l=t.stateNode,e=null),t=t.child,t!==null))for(as(t,e,l),t=t.sibling;t!==null;)as(t,e,l),t=t.sibling}function Vi(t,e,l){var a=t.tag;if(a===5||a===6)t=t.stateNode,e?l.insertBefore(t,e):l.appendChild(t);else if(a!==4&&(a===27&&Hl(t.type)&&(l=t.stateNode),t=t.child,t!==null))for(Vi(t,e,l),t=t.sibling;t!==null;)Vi(t,e,l),t=t.sibling}function ko(t){var e=t.stateNode,l=t.memoizedProps;try{for(var a=t.type,n=e.attributes;n.length;)e.removeAttributeNode(n[0]);te(e,a,l),e[$t]=t,e[re]=l}catch(u){St(t,t.return,u)}}var ul=!1,Xt=!1,ns=!1,Vo=typeof WeakSet=="function"?WeakSet:Set,Ft=null;function Yy(t,e){if(t=t.containerInfo,Ns=mu,t=af(t),Wu(t)){if("selectionStart"in t)var l={start:t.selectionStart,end:t.selectionEnd};else t:{l=(l=t.ownerDocument)&&l.defaultView||window;var a=l.getSelection&&l.getSelection();if(a&&a.rangeCount!==0){l=a.anchorNode;var n=a.anchorOffset,u=a.focusNode;a=a.focusOffset;try{l.nodeType,u.nodeType}catch{l=null;break t}var s=0,h=-1,v=-1,N=0,_=0,U=t,O=null;e:for(;;){for(var C;U!==l||n!==0&&U.nodeType!==3||(h=s+n),U!==u||a!==0&&U.nodeType!==3||(v=s+a),U.nodeType===3&&(s+=U.nodeValue.length),(C=U.firstChild)!==null;)O=U,U=C;for(;;){if(U===t)break e;if(O===l&&++N===n&&(h=s),O===u&&++_===a&&(v=s),(C=U.nextSibling)!==null)break;U=O,O=U.parentNode}U=C}l=h===-1||v===-1?null:{start:h,end:v}}else l=null}l=l||{start:0,end:0}}else l=null;for(Os={focusedElem:t,selectionRange:l},mu=!1,Ft=e;Ft!==null;)if(e=Ft,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,Ft=t;else for(;Ft!==null;){switch(e=Ft,u=e.alternate,t=e.flags,e.tag){case 0:if((t&4)!==0&&(t=e.updateQueue,t=t!==null?t.events:null,t!==null))for(l=0;l title"))),te(u,a,l),u[$t]=t,Jt(u),a=u;break t;case"link":var s=Pd("link","href",n).get(a+(l.href||""));if(s){for(var h=0;hTt&&(s=Tt,Tt=F,F=s);var j=ef(h,F),b=ef(h,Tt);if(j&&b&&(C.rangeCount!==1||C.anchorNode!==j.node||C.anchorOffset!==j.offset||C.focusNode!==b.node||C.focusOffset!==b.offset)){var T=U.createRange();T.setStart(j.node,j.offset),C.removeAllRanges(),F>Tt?(C.addRange(T),C.extend(b.node,b.offset)):(T.setEnd(b.node,b.offset),C.addRange(T))}}}}for(U=[],C=h;C=C.parentNode;)C.nodeType===1&&U.push({element:C,left:C.scrollLeft,top:C.scrollTop});for(typeof h.focus=="function"&&h.focus(),h=0;hl?32:l,D.T=null,l=os,os=null;var u=Dl,s=ol;if(Zt=0,Ba=Dl=null,ol=0,(pt&6)!==0)throw Error(f(331));var h=pt;if(pt|=4,nd(u.current),ed(u,u.current,s,l),pt=h,Rn(0,!1),ge&&typeof ge.onPostCommitFiberRoot=="function")try{ge.onPostCommitFiberRoot($a,u)}catch{}return!0}finally{B.p=n,D.T=a,jd(t,e)}}function Td(t,e,l){e=Ue(l,e),e=Kc(t.stateNode,e,2),t=Nl(t,e,2),t!==null&&(Ia(t,2),Je(t))}function St(t,e,l){if(t.tag===3)Td(t,t,l);else for(;e!==null;){if(e.tag===3){Td(e,t,l);break}else if(e.tag===1){var a=e.stateNode;if(typeof e.type.getDerivedStateFromError=="function"||typeof a.componentDidCatch=="function"&&(_l===null||!_l.has(a))){t=Ue(l,t),l=No(2),a=Nl(e,l,2),a!==null&&(Oo(l,a,e,t),Ia(a,2),Je(a));break}}e=e.return}}function ys(t,e,l){var a=t.pingCache;if(a===null){a=t.pingCache=new Ky;var n=new Set;a.set(e,n)}else n=a.get(e),n===void 0&&(n=new Set,a.set(e,n));n.has(l)||(cs=!0,n.add(l),t=Fy.bind(null,t,e,l),e.then(t,t))}function Fy(t,e,l){var a=t.pingCache;a!==null&&a.delete(e),t.pingedLanes|=t.suspendedLanes&l,t.warmLanes&=~l,Nt===t&&(it&l)===l&&(qt===4||qt===3&&(it&62914560)===it&&300>ne()-$i?(pt&2)===0&&La(t,0):ss|=l,Qa===it&&(Qa=0)),Je(t)}function Nd(t,e){e===0&&(e=pr()),t=Fl(t,e),t!==null&&(Ia(t,e),Je(t))}function $y(t){var e=t.memoizedState,l=0;e!==null&&(l=e.retryLane),Nd(t,l)}function Wy(t,e){var l=0;switch(t.tag){case 31:case 13:var a=t.stateNode,n=t.memoizedState;n!==null&&(l=n.retryLane);break;case 19:a=t.stateNode;break;case 22:a=t.stateNode._retryCache;break;default:throw Error(f(314))}a!==null&&a.delete(e),Nd(t,l)}function Iy(t,e){return ft(t,e)}var au=null,Ga=null,vs=!1,nu=!1,ps=!1,Ul=0;function Je(t){t!==Ga&&t.next===null&&(Ga===null?au=Ga=t:Ga=Ga.next=t),nu=!0,vs||(vs=!0,tv())}function Rn(t,e){if(!ps&&nu){ps=!0;do for(var l=!1,a=au;a!==null;){if(t!==0){var n=a.pendingLanes;if(n===0)var u=0;else{var s=a.suspendedLanes,h=a.pingedLanes;u=(1<<31-be(42|t)+1)-1,u&=n&~(s&~h),u=u&201326741?u&201326741|1:u?u|2:0}u!==0&&(l=!0,Cd(a,u))}else u=it,u=si(a,a===Nt?u:0,a.cancelPendingCommit!==null||a.timeoutHandle!==-1),(u&3)===0||Wa(a,u)||(l=!0,Cd(a,u));a=a.next}while(l);ps=!1}}function Py(){Od()}function Od(){nu=vs=!1;var t=0;Ul!==0&&fv()&&(t=Ul);for(var e=ne(),l=null,a=au;a!==null;){var n=a.next,u=Md(a,e);u===0?(a.next=null,l===null?au=n:l.next=n,n===null&&(Ga=l)):(l=a,(t!==0||(u&3)!==0)&&(nu=!0)),a=n}Zt!==0&&Zt!==5||Rn(t),Ul!==0&&(Ul=0)}function Md(t,e){for(var l=t.suspendedLanes,a=t.pingedLanes,n=t.expirationTimes,u=t.pendingLanes&-62914561;0h)break;var _=v.transferSize,U=v.initiatorType;_&&wd(U)&&(v=v.responseEnd,s+=_*(v"u"?null:document;function Fd(t,e,l){var a=Xa;if(a&&typeof e=="string"&&e){var n=De(e);n='link[rel="'+t+'"][href="'+n+'"]',typeof l=="string"&&(n+='[crossorigin="'+l+'"]'),Jd.has(n)||(Jd.add(n),t={rel:t,crossOrigin:l,href:e},a.querySelector(n)===null&&(e=a.createElement("link"),te(e,"link",t),Jt(e),a.head.appendChild(e)))}}function bv(t){dl.D(t),Fd("dns-prefetch",t,null)}function Sv(t,e){dl.C(t,e),Fd("preconnect",t,e)}function xv(t,e,l){dl.L(t,e,l);var a=Xa;if(a&&t&&e){var n='link[rel="preload"][as="'+De(e)+'"]';e==="image"&&l&&l.imageSrcSet?(n+='[imagesrcset="'+De(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(n+='[imagesizes="'+De(l.imageSizes)+'"]')):n+='[href="'+De(t)+'"]';var u=n;switch(e){case"style":u=Ka(t);break;case"script":u=Za(t)}Le.has(u)||(t=E({rel:"preload",href:e==="image"&&l&&l.imageSrcSet?void 0:t,as:e},l),Le.set(u,t),a.querySelector(n)!==null||e==="style"&&a.querySelector(wn(u))||e==="script"&&a.querySelector(Qn(u))||(e=a.createElement("link"),te(e,"link",t),Jt(e),a.head.appendChild(e)))}}function jv(t,e){dl.m(t,e);var l=Xa;if(l&&t){var a=e&&typeof e.as=="string"?e.as:"script",n='link[rel="modulepreload"][as="'+De(a)+'"][href="'+De(t)+'"]',u=n;switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":u=Za(t)}if(!Le.has(u)&&(t=E({rel:"modulepreload",href:t},e),Le.set(u,t),l.querySelector(n)===null)){switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(Qn(u)))return}a=l.createElement("link"),te(a,"link",t),Jt(a),l.head.appendChild(a)}}}function Ev(t,e,l){dl.S(t,e,l);var a=Xa;if(a&&t){var n=da(a).hoistableStyles,u=Ka(t);e=e||"default";var s=n.get(u);if(!s){var h={loading:0,preload:null};if(s=a.querySelector(wn(u)))h.loading=5;else{t=E({rel:"stylesheet",href:t,"data-precedence":e},l),(l=Le.get(u))&&Rs(t,l);var v=s=a.createElement("link");Jt(v),te(v,"link",t),v._p=new Promise(function(N,_){v.onload=N,v.onerror=_}),v.addEventListener("load",function(){h.loading|=1}),v.addEventListener("error",function(){h.loading|=2}),h.loading|=4,ru(s,e,a)}s={type:"stylesheet",instance:s,count:1,state:h},n.set(u,s)}}}function Tv(t,e){dl.X(t,e);var l=Xa;if(l&&t){var a=da(l).hoistableScripts,n=Za(t),u=a.get(n);u||(u=l.querySelector(Qn(n)),u||(t=E({src:t,async:!0},e),(e=Le.get(n))&&Us(t,e),u=l.createElement("script"),Jt(u),te(u,"link",t),l.head.appendChild(u)),u={type:"script",instance:u,count:1,state:null},a.set(n,u))}}function Nv(t,e){dl.M(t,e);var l=Xa;if(l&&t){var a=da(l).hoistableScripts,n=Za(t),u=a.get(n);u||(u=l.querySelector(Qn(n)),u||(t=E({src:t,async:!0,type:"module"},e),(e=Le.get(n))&&Us(t,e),u=l.createElement("script"),Jt(u),te(u,"link",t),l.head.appendChild(u)),u={type:"script",instance:u,count:1,state:null},a.set(n,u))}}function $d(t,e,l,a){var n=(n=lt.current)?su(n):null;if(!n)throw Error(f(446));switch(t){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(e=Ka(l.href),l=da(n).hoistableStyles,a=l.get(e),a||(a={type:"style",instance:null,count:0,state:null},l.set(e,a)),a):{type:"void",instance:null,count:0,state:null};case"link":if(l.rel==="stylesheet"&&typeof l.href=="string"&&typeof l.precedence=="string"){t=Ka(l.href);var u=da(n).hoistableStyles,s=u.get(t);if(s||(n=n.ownerDocument||n,s={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},u.set(t,s),(u=n.querySelector(wn(t)))&&!u._p&&(s.instance=u,s.state.loading=5),Le.has(t)||(l={rel:"preload",as:"style",href:l.href,crossOrigin:l.crossOrigin,integrity:l.integrity,media:l.media,hrefLang:l.hrefLang,referrerPolicy:l.referrerPolicy},Le.set(t,l),u||Ov(n,t,l,s.state))),e&&a===null)throw Error(f(528,""));return s}if(e&&a!==null)throw Error(f(529,""));return null;case"script":return e=l.async,l=l.src,typeof l=="string"&&e&&typeof e!="function"&&typeof e!="symbol"?(e=Za(l),l=da(n).hoistableScripts,a=l.get(e),a||(a={type:"script",instance:null,count:0,state:null},l.set(e,a)),a):{type:"void",instance:null,count:0,state:null};default:throw Error(f(444,t))}}function Ka(t){return'href="'+De(t)+'"'}function wn(t){return'link[rel="stylesheet"]['+t+"]"}function Wd(t){return E({},t,{"data-precedence":t.precedence,precedence:null})}function Ov(t,e,l,a){t.querySelector('link[rel="preload"][as="style"]['+e+"]")?a.loading=1:(e=t.createElement("link"),a.preload=e,e.addEventListener("load",function(){return a.loading|=1}),e.addEventListener("error",function(){return a.loading|=2}),te(e,"link",l),Jt(e),t.head.appendChild(e))}function Za(t){return'[src="'+De(t)+'"]'}function Qn(t){return"script[async]"+t}function Id(t,e,l){if(e.count++,e.instance===null)switch(e.type){case"style":var a=t.querySelector('style[data-href~="'+De(l.href)+'"]');if(a)return e.instance=a,Jt(a),a;var n=E({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return a=(t.ownerDocument||t).createElement("style"),Jt(a),te(a,"style",n),ru(a,l.precedence,t),e.instance=a;case"stylesheet":n=Ka(l.href);var u=t.querySelector(wn(n));if(u)return e.state.loading|=4,e.instance=u,Jt(u),u;a=Wd(l),(n=Le.get(n))&&Rs(a,n),u=(t.ownerDocument||t).createElement("link"),Jt(u);var s=u;return s._p=new Promise(function(h,v){s.onload=h,s.onerror=v}),te(u,"link",a),e.state.loading|=4,ru(u,l.precedence,t),e.instance=u;case"script":return u=Za(l.src),(n=t.querySelector(Qn(u)))?(e.instance=n,Jt(n),n):(a=l,(n=Le.get(u))&&(a=E({},l),Us(a,n)),t=t.ownerDocument||t,n=t.createElement("script"),Jt(n),te(n,"link",a),t.head.appendChild(n),e.instance=n);case"void":return null;default:throw Error(f(443,e.type))}else e.type==="stylesheet"&&(e.state.loading&4)===0&&(a=e.instance,e.state.loading|=4,ru(a,l.precedence,t));return e.instance}function ru(t,e,l){for(var a=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),n=a.length?a[a.length-1]:null,u=n,s=0;s title"):null)}function Mv(t,e,l){if(l===1||e.itemProp!=null)return!1;switch(t){case"meta":case"title":return!0;case"style":if(typeof e.precedence!="string"||typeof e.href!="string"||e.href==="")break;return!0;case"link":if(typeof e.rel!="string"||typeof e.href!="string"||e.href===""||e.onLoad||e.onError)break;return e.rel==="stylesheet"?(t=e.disabled,typeof e.precedence=="string"&&t==null):!0;case"script":if(e.async&&typeof e.async!="function"&&typeof e.async!="symbol"&&!e.onLoad&&!e.onError&&e.src&&typeof e.src=="string")return!0}return!1}function eh(t){return!(t.type==="stylesheet"&&(t.state.loading&3)===0)}function Av(t,e,l,a){if(l.type==="stylesheet"&&(typeof a.media!="string"||matchMedia(a.media).matches!==!1)&&(l.state.loading&4)===0){if(l.instance===null){var n=Ka(a.href),u=e.querySelector(wn(n));if(u){e=u._p,e!==null&&typeof e=="object"&&typeof e.then=="function"&&(t.count++,t=ou.bind(t),e.then(t,t)),l.state.loading|=4,l.instance=u,Jt(u);return}u=e.ownerDocument||e,a=Wd(a),(n=Le.get(n))&&Rs(a,n),u=u.createElement("link"),Jt(u);var s=u;s._p=new Promise(function(h,v){s.onload=h,s.onerror=v}),te(u,"link",a),l.instance=u}t.stylesheets===null&&(t.stylesheets=new Map),t.stylesheets.set(l,e),(e=l.state.preload)&&(l.state.loading&3)===0&&(t.count++,l=ou.bind(t),e.addEventListener("load",l),e.addEventListener("error",l))}}var Hs=0;function Cv(t,e){return t.stylesheets&&t.count===0&&hu(t,t.stylesheets),0Hs?50:800)+e);return t.unsuspend=l,function(){t.unsuspend=null,clearTimeout(a),clearTimeout(n)}}:null}function ou(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)hu(this,this.stylesheets);else if(this.unsuspend){var t=this.unsuspend;this.unsuspend=null,t()}}}var du=null;function hu(t,e){t.stylesheets=null,t.unsuspend!==null&&(t.count++,du=new Map,e.forEach(zv,t),du=null,ou.call(t))}function zv(t,e){if(!(e.state.loading&4)){var l=du.get(t);if(l)var a=l.get(null);else{l=new Map,du.set(t,l);for(var n=t.querySelectorAll("link[data-precedence],style[data-precedence]"),u=0;u"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(i)}catch(c){console.error(c)}}return i(),Ks.exports=kv(),Ks.exports}var Jv=Vv(),ti=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(i){return this.listeners.add(i),this.onSubscribe(),()=>{this.listeners.delete(i),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Fv=class extends ti{#t;#e;#l;constructor(){super(),this.#l=i=>{if(typeof window<"u"&&window.addEventListener){const c=()=>i();return window.addEventListener("visibilitychange",c,!1),()=>{window.removeEventListener("visibilitychange",c)}}}}onSubscribe(){this.#e||this.setEventListener(this.#l)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(i){this.#l=i,this.#e?.(),this.#e=i(c=>{typeof c=="boolean"?this.setFocused(c):this.onFocus()})}setFocused(i){this.#t!==i&&(this.#t=i,this.onFocus())}onFocus(){const i=this.isFocused();this.listeners.forEach(c=>{c(i)})}isFocused(){return typeof this.#t=="boolean"?this.#t:globalThis.document?.visibilityState!=="hidden"}},ur=new Fv,$v={setTimeout:(i,c)=>setTimeout(i,c),clearTimeout:i=>clearTimeout(i),setInterval:(i,c)=>setInterval(i,c),clearInterval:i=>clearInterval(i)},Wv=class{#t=$v;#e=!1;setTimeoutProvider(i){this.#t=i}setTimeout(i,c){return this.#t.setTimeout(i,c)}clearTimeout(i){this.#t.clearTimeout(i)}setInterval(i,c){return this.#t.setInterval(i,c)}clearInterval(i){this.#t.clearInterval(i)}},sa=new Wv;function Iv(i){setTimeout(i,0)}var Pv=typeof window>"u"||"Deno"in globalThis;function ve(){}function t0(i,c){return typeof i=="function"?i(c):i}function Ws(i){return typeof i=="number"&&i>=0&&i!==1/0}function kh(i,c){return Math.max(i+(c||0)-Date.now(),0)}function Gl(i,c){return typeof i=="function"?i(c):i}function Me(i,c){return typeof i=="function"?i(c):i}function Nh(i,c){const{type:r="all",exact:f,fetchStatus:d,predicate:m,queryKey:g,stale:A}=i;if(g){if(f){if(c.queryHash!==cr(g,c.options))return!1}else if(!Jn(c.queryKey,g))return!1}if(r!=="all"){const p=c.isActive();if(r==="active"&&!p||r==="inactive"&&p)return!1}return!(typeof A=="boolean"&&c.isStale()!==A||d&&d!==c.state.fetchStatus||m&&!m(c))}function Oh(i,c){const{exact:r,status:f,predicate:d,mutationKey:m}=i;if(m){if(!c.options.mutationKey)return!1;if(r){if(Vn(c.options.mutationKey)!==Vn(m))return!1}else if(!Jn(c.options.mutationKey,m))return!1}return!(f&&c.state.status!==f||d&&!d(c))}function cr(i,c){return(c?.queryKeyHashFn||Vn)(i)}function Vn(i){return JSON.stringify(i,(c,r)=>Ps(r)?Object.keys(r).sort().reduce((f,d)=>(f[d]=r[d],f),{}):r)}function Jn(i,c){return i===c?!0:typeof i!=typeof c?!1:i&&c&&typeof i=="object"&&typeof c=="object"?Object.keys(c).every(r=>Jn(i[r],c[r])):!1}var e0=Object.prototype.hasOwnProperty;function Vh(i,c,r=0){if(i===c)return i;if(r>500)return c;const f=Mh(i)&&Mh(c);if(!f&&!(Ps(i)&&Ps(c)))return c;const m=(f?i:Object.keys(i)).length,g=f?c:Object.keys(c),A=g.length,p=f?new Array(A):{};let y=0;for(let M=0;M{sa.setTimeout(c,i)})}function tr(i,c,r){return typeof r.structuralSharing=="function"?r.structuralSharing(i,c):r.structuralSharing!==!1?Vh(i,c):c}function a0(i,c,r=0){const f=[...i,c];return r&&f.length>r?f.slice(1):f}function n0(i,c,r=0){const f=[c,...i];return r&&f.length>r?f.slice(0,-1):f}var sr=Symbol();function Jh(i,c){return!i.queryFn&&c?.initialPromise?()=>c.initialPromise:!i.queryFn||i.queryFn===sr?()=>Promise.reject(new Error(`Missing queryFn: '${i.queryHash}'`)):i.queryFn}function Fh(i,c){return typeof i=="function"?i(...c):!!i}function i0(i,c,r){let f=!1,d;return Object.defineProperty(i,"signal",{enumerable:!0,get:()=>(d??=c(),f||(f=!0,d.aborted?r():d.addEventListener("abort",r,{once:!0})),d)}),i}var Fn=(()=>{let i=()=>Pv;return{isServer(){return i()},setIsServer(c){i=c}}})();function er(){let i,c;const r=new Promise((d,m)=>{i=d,c=m});r.status="pending",r.catch(()=>{});function f(d){Object.assign(r,d),delete r.resolve,delete r.reject}return r.resolve=d=>{f({status:"fulfilled",value:d}),i(d)},r.reject=d=>{f({status:"rejected",reason:d}),c(d)},r}var u0=Iv;function c0(){let i=[],c=0,r=A=>{A()},f=A=>{A()},d=u0;const m=A=>{c?i.push(A):d(()=>{r(A)})},g=()=>{const A=i;i=[],A.length&&d(()=>{f(()=>{A.forEach(p=>{r(p)})})})};return{batch:A=>{let p;c++;try{p=A()}finally{c--,c||g()}return p},batchCalls:A=>(...p)=>{m(()=>{A(...p)})},schedule:m,setNotifyFunction:A=>{r=A},setBatchNotifyFunction:A=>{f=A},setScheduler:A=>{d=A}}}var ee=c0(),s0=class extends ti{#t=!0;#e;#l;constructor(){super(),this.#l=i=>{if(typeof window<"u"&&window.addEventListener){const c=()=>i(!0),r=()=>i(!1);return window.addEventListener("online",c,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",c),window.removeEventListener("offline",r)}}}}onSubscribe(){this.#e||this.setEventListener(this.#l)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(i){this.#l=i,this.#e?.(),this.#e=i(this.setOnline.bind(this))}setOnline(i){this.#t!==i&&(this.#t=i,this.listeners.forEach(r=>{r(i)}))}isOnline(){return this.#t}},Ou=new s0;function r0(i){return Math.min(1e3*2**i,3e4)}function $h(i){return(i??"online")==="online"?Ou.isOnline():!0}var lr=class extends Error{constructor(i){super("CancelledError"),this.revert=i?.revert,this.silent=i?.silent}};function Wh(i){let c=!1,r=0,f;const d=er(),m=()=>d.status!=="pending",g=w=>{if(!m()){const Y=new lr(w);x(Y),i.onCancel?.(Y)}},A=()=>{c=!0},p=()=>{c=!1},y=()=>ur.isFocused()&&(i.networkMode==="always"||Ou.isOnline())&&i.canRun(),M=()=>$h(i.networkMode)&&i.canRun(),E=w=>{m()||(f?.(),d.resolve(w))},x=w=>{m()||(f?.(),d.reject(w))},q=()=>new Promise(w=>{f=Y=>{(m()||y())&&w(Y)},i.onPause?.()}).then(()=>{f=void 0,m()||i.onContinue?.()}),z=()=>{if(m())return;let w;const Y=r===0?i.initialPromise:void 0;try{w=Y??i.fn()}catch($){w=Promise.reject($)}Promise.resolve(w).then(E).catch($=>{if(m())return;const yt=i.retry??(Fn.isServer()?0:3),ot=i.retryDelay??r0,Ct=typeof ot=="function"?ot(r,$):ot,Rt=yt===!0||typeof yt=="number"&&ry()?void 0:q()).then(()=>{c?x($):z()})})};return{promise:d,status:()=>d.status,cancel:g,continue:()=>(f?.(),d),cancelRetry:A,continueRetry:p,canStart:M,start:()=>(M()?z():q().then(z),d)}}var Ih=class{#t;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Ws(this.gcTime)&&(this.#t=sa.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(i){this.gcTime=Math.max(this.gcTime||0,i??(Fn.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#t!==void 0&&(sa.clearTimeout(this.#t),this.#t=void 0)}};function f0(i){return{onFetch:(c,r)=>{const f=c.options,d=c.fetchOptions?.meta?.fetchMore?.direction,m=c.state.data?.pages||[],g=c.state.data?.pageParams||[];let A={pages:[],pageParams:[]},p=0;const y=async()=>{let M=!1;const E=z=>{i0(z,()=>c.signal,()=>M=!0)},x=Jh(c.options,c.fetchOptions),q=async(z,w,Y)=>{if(M)return Promise.reject(c.signal.reason);if(w==null&&z.pages.length)return Promise.resolve(z);const yt=(()=>{const et={client:c.client,queryKey:c.queryKey,pageParam:w,direction:Y?"backward":"forward",meta:c.options.meta};return E(et),et})(),ot=await x(yt),{maxPages:Ct}=c.options,Rt=Y?n0:a0;return{pages:Rt(z.pages,ot,Ct),pageParams:Rt(z.pageParams,w,Ct)}};if(d&&m.length){const z=d==="backward",w=z?o0:Ch,Y={pages:m,pageParams:g},$=w(f,Y);A=await q(Y,$,z)}else{const z=i??m.length;do{const w=p===0?g[0]??f.initialPageParam:Ch(f,A);if(p>0&&w==null)break;A=await q(A,w),p++}while(pc.options.persister?.(y,{client:c.client,queryKey:c.queryKey,meta:c.options.meta,signal:c.signal},r):c.fetchFn=y}}}function Ch(i,{pages:c,pageParams:r}){const f=c.length-1;return c.length>0?i.getNextPageParam(c[f],c,r[f],r):void 0}function o0(i,{pages:c,pageParams:r}){return c.length>0?i.getPreviousPageParam?.(c[0],c,r[0],r):void 0}var d0=class extends Ih{#t;#e;#l;#a;#i;#n;#c;#u;constructor(i){super(),this.#u=!1,this.#c=i.defaultOptions,this.setOptions(i.options),this.observers=[],this.#i=i.client,this.#a=this.#i.getQueryCache(),this.queryKey=i.queryKey,this.queryHash=i.queryHash,this.#e=_h(this.options),this.state=i.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#t}get promise(){return this.#n?.promise}setOptions(i){if(this.options={...this.#c,...i},i?._type&&(this.#t=i._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const c=_h(this.options);c.data!==void 0&&(this.setState(zh(c.data,c.dataUpdatedAt)),this.#e=c)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#a.remove(this)}setData(i,c){const r=tr(this.state.data,i,this.options);return this.#s({data:r,type:"success",dataUpdatedAt:c?.updatedAt,manual:c?.manual}),r}setState(i){this.#s({type:"setState",state:i})}cancel(i){const c=this.#n?.promise;return this.#n?.cancel(i),c?c.then(ve).catch(ve):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#e}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(i=>Me(i.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===sr||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(i=>Gl(i.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(i=>i.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(i=0){return this.state.data===void 0?!0:i==="static"?!1:this.state.isInvalidated?!0:!kh(this.state.dataUpdatedAt,i)}onFocus(){this.observers.find(c=>c.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#n?.continue()}onOnline(){this.observers.find(c=>c.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#n?.continue()}addObserver(i){this.observers.includes(i)||(this.observers.push(i),this.clearGcTimeout(),this.#a.notify({type:"observerAdded",query:this,observer:i}))}removeObserver(i){this.observers.includes(i)&&(this.observers=this.observers.filter(c=>c!==i),this.observers.length||(this.#n&&(this.#u||this.#f()?this.#n.cancel({revert:!0}):this.#n.cancelRetry()),this.scheduleGc()),this.#a.notify({type:"observerRemoved",query:this,observer:i}))}getObserversCount(){return this.observers.length}#f(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"}invalidate(){this.state.isInvalidated||this.#s({type:"invalidate"})}async fetch(i,c){if(this.state.fetchStatus!=="idle"&&this.#n?.status()!=="rejected"){if(this.state.data!==void 0&&c?.cancelRefetch)this.cancel({silent:!0});else if(this.#n)return this.#n.continueRetry(),this.#n.promise}if(i&&this.setOptions(i),!this.options.queryFn){const p=this.observers.find(y=>y.options.queryFn);p&&this.setOptions(p.options)}const r=new AbortController,f=p=>{Object.defineProperty(p,"signal",{enumerable:!0,get:()=>(this.#u=!0,r.signal)})},d=()=>{const p=Jh(this.options,c),M=(()=>{const E={client:this.#i,queryKey:this.queryKey,meta:this.meta};return f(E),E})();return this.#u=!1,this.options.persister?this.options.persister(p,M,this):p(M)},g=(()=>{const p={fetchOptions:c,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:d};return f(p),p})();(this.#t==="infinite"?f0(this.options.pages):this.options.behavior)?.onFetch(g,this),this.#l=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==g.fetchOptions?.meta)&&this.#s({type:"fetch",meta:g.fetchOptions?.meta}),this.#n=Wh({initialPromise:c?.initialPromise,fn:g.fetchFn,onCancel:p=>{p instanceof lr&&p.revert&&this.setState({...this.#l,fetchStatus:"idle"}),r.abort()},onFail:(p,y)=>{this.#s({type:"failed",failureCount:p,error:y})},onPause:()=>{this.#s({type:"pause"})},onContinue:()=>{this.#s({type:"continue"})},retry:g.options.retry,retryDelay:g.options.retryDelay,networkMode:g.options.networkMode,canRun:()=>!0});try{const p=await this.#n.start();if(p===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(p),this.#a.config.onSuccess?.(p,this),this.#a.config.onSettled?.(p,this.state.error,this),p}catch(p){if(p instanceof lr){if(p.silent)return this.#n.promise;if(p.revert){if(this.state.data===void 0)throw p;return this.state.data}}throw this.#s({type:"error",error:p}),this.#a.config.onError?.(p,this),this.#a.config.onSettled?.(this.state.data,p,this),p}finally{this.scheduleGc()}}#s(i){const c=r=>{switch(i.type){case"failed":return{...r,fetchFailureCount:i.failureCount,fetchFailureReason:i.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...Ph(r.data,this.options),fetchMeta:i.meta??null};case"success":const f={...r,...zh(i.data,i.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!i.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#l=i.manual?f:void 0,f;case"error":const d=i.error;return{...r,error:d,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:d,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...i.state}}};this.state=c(this.state),ee.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),this.#a.notify({query:this,type:"updated",action:i})})}};function Ph(i,c){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:$h(c.networkMode)?"fetching":"paused",...i===void 0&&{error:null,status:"pending"}}}function zh(i,c){return{data:i,dataUpdatedAt:c??Date.now(),error:null,isInvalidated:!1,status:"success"}}function _h(i){const c=typeof i.initialData=="function"?i.initialData():i.initialData,r=c!==void 0,f=r?typeof i.initialDataUpdatedAt=="function"?i.initialDataUpdatedAt():i.initialDataUpdatedAt:0;return{data:c,dataUpdateCount:0,dataUpdatedAt:r?f??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var h0=class extends ti{constructor(i,c){super(),this.options=c,this.#t=i,this.#u=null,this.#c=er(),this.bindMethods(),this.setOptions(c)}#t;#e=void 0;#l=void 0;#a=void 0;#i;#n;#c;#u;#f;#s;#m;#o;#d;#r;#y=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#e.addObserver(this),Dh(this.#e,this.options)?this.#h():this.updateResult(),this.#b())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return ar(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return ar(this.#e,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#S(),this.#x(),this.#e.removeObserver(this)}setOptions(i){const c=this.options,r=this.#e;if(this.options=this.#t.defaultQueryOptions(i),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Me(this.options.enabled,this.#e)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#j(),this.#e.setOptions(this.options),c._defaulted&&!Is(this.options,c)&&this.#t.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const f=this.hasListeners();f&&Rh(this.#e,r,this.options,c)&&this.#h(),this.updateResult(),f&&(this.#e!==r||Me(this.options.enabled,this.#e)!==Me(c.enabled,this.#e)||Gl(this.options.staleTime,this.#e)!==Gl(c.staleTime,this.#e))&&this.#v();const d=this.#p();f&&(this.#e!==r||Me(this.options.enabled,this.#e)!==Me(c.enabled,this.#e)||d!==this.#r)&&this.#g(d)}getOptimisticResult(i){const c=this.#t.getQueryCache().build(this.#t,i),r=this.createResult(c,i);return y0(this,r)&&(this.#a=r,this.#n=this.options,this.#i=this.#e.state),r}getCurrentResult(){return this.#a}trackResult(i,c){return new Proxy(i,{get:(r,f)=>(this.trackProp(f),c?.(f),f==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#c.status==="pending"&&this.#c.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,f))})}trackProp(i){this.#y.add(i)}getCurrentQuery(){return this.#e}refetch({...i}={}){return this.fetch({...i})}fetchOptimistic(i){const c=this.#t.defaultQueryOptions(i),r=this.#t.getQueryCache().build(this.#t,c);return r.fetch().then(()=>this.createResult(r,c))}fetch(i){return this.#h({...i,cancelRefetch:i.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#a))}#h(i){this.#j();let c=this.#e.fetch(this.options,i);return i?.throwOnError||(c=c.catch(ve)),c}#v(){this.#S();const i=Gl(this.options.staleTime,this.#e);if(Fn.isServer()||this.#a.isStale||!Ws(i))return;const r=kh(this.#a.dataUpdatedAt,i)+1;this.#o=sa.setTimeout(()=>{this.#a.isStale||this.updateResult()},r)}#p(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#e):this.options.refetchInterval)??!1}#g(i){this.#x(),this.#r=i,!(Fn.isServer()||Me(this.options.enabled,this.#e)===!1||!Ws(this.#r)||this.#r===0)&&(this.#d=sa.setInterval(()=>{(this.options.refetchIntervalInBackground||ur.isFocused())&&this.#h()},this.#r))}#b(){this.#v(),this.#g(this.#p())}#S(){this.#o!==void 0&&(sa.clearTimeout(this.#o),this.#o=void 0)}#x(){this.#d!==void 0&&(sa.clearInterval(this.#d),this.#d=void 0)}createResult(i,c){const r=this.#e,f=this.options,d=this.#a,m=this.#i,g=this.#n,p=i!==r?i.state:this.#l,{state:y}=i;let M={...y},E=!1,x;if(c._optimisticResults){const gt=this.hasListeners(),wt=!gt&&Dh(i,c),ue=gt&&Rh(i,r,c,f);(wt||ue)&&(M={...M,...Ph(y.data,i.options)}),c._optimisticResults==="isRestoring"&&(M.fetchStatus="idle")}let{error:q,errorUpdatedAt:z,status:w}=M;x=M.data;let Y=!1;if(c.placeholderData!==void 0&&x===void 0&&w==="pending"){let gt;d?.isPlaceholderData&&c.placeholderData===g?.placeholderData?(gt=d.data,Y=!0):gt=typeof c.placeholderData=="function"?c.placeholderData(this.#m?.state.data,this.#m):c.placeholderData,gt!==void 0&&(w="success",x=tr(d?.data,gt,c),E=!0)}if(c.select&&x!==void 0&&!Y)if(d&&x===m?.data&&c.select===this.#f)x=this.#s;else try{this.#f=c.select,x=c.select(x),x=tr(d?.data,x,c),this.#s=x,this.#u=null}catch(gt){this.#u=gt}this.#u&&(q=this.#u,x=this.#s,z=Date.now(),w="error");const $=M.fetchStatus==="fetching",yt=w==="pending",ot=w==="error",Ct=yt&&$,Rt=x!==void 0,k={status:w,fetchStatus:M.fetchStatus,isPending:yt,isSuccess:w==="success",isError:ot,isInitialLoading:Ct,isLoading:Ct,data:x,dataUpdatedAt:M.dataUpdatedAt,error:q,errorUpdatedAt:z,failureCount:M.fetchFailureCount,failureReason:M.fetchFailureReason,errorUpdateCount:M.errorUpdateCount,isFetched:i.isFetched(),isFetchedAfterMount:M.dataUpdateCount>p.dataUpdateCount||M.errorUpdateCount>p.errorUpdateCount,isFetching:$,isRefetching:$&&!yt,isLoadingError:ot&&!Rt,isPaused:M.fetchStatus==="paused",isPlaceholderData:E,isRefetchError:ot&&Rt,isStale:rr(i,c),refetch:this.refetch,promise:this.#c,isEnabled:Me(c.enabled,i)!==!1};if(this.options.experimental_prefetchInRender){const gt=k.data!==void 0,wt=k.status==="error"&&!gt,ue=ce=>{wt?ce.reject(k.error):gt&&ce.resolve(k.data)},le=()=>{const ce=this.#c=k.promise=er();ue(ce)},_t=this.#c;switch(_t.status){case"pending":i.queryHash===r.queryHash&&ue(_t);break;case"fulfilled":(wt||k.data!==_t.value)&&le();break;case"rejected":(!wt||k.error!==_t.reason)&&le();break}}return k}updateResult(){const i=this.#a,c=this.createResult(this.#e,this.options);if(this.#i=this.#e.state,this.#n=this.options,this.#i.data!==void 0&&(this.#m=this.#e),Is(c,i))return;this.#a=c;const r=()=>{if(!i)return!0;const{notifyOnChangeProps:f}=this.options,d=typeof f=="function"?f():f;if(d==="all"||!d&&!this.#y.size)return!0;const m=new Set(d??this.#y);return this.options.throwOnError&&m.add("error"),Object.keys(this.#a).some(g=>{const A=g;return this.#a[A]!==i[A]&&m.has(A)})};this.#E({listeners:r()})}#j(){const i=this.#t.getQueryCache().build(this.#t,this.options);if(i===this.#e)return;const c=this.#e;this.#e=i,this.#l=i.state,this.hasListeners()&&(c?.removeObserver(this),i.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#b()}#E(i){ee.batch(()=>{i.listeners&&this.listeners.forEach(c=>{c(this.#a)}),this.#t.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function m0(i,c){return Me(c.enabled,i)!==!1&&i.state.data===void 0&&!(i.state.status==="error"&&Me(c.retryOnMount,i)===!1)}function Dh(i,c){return m0(i,c)||i.state.data!==void 0&&ar(i,c,c.refetchOnMount)}function ar(i,c,r){if(Me(c.enabled,i)!==!1&&Gl(c.staleTime,i)!=="static"){const f=typeof r=="function"?r(i):r;return f==="always"||f!==!1&&rr(i,c)}return!1}function Rh(i,c,r,f){return(i!==c||Me(f.enabled,i)===!1)&&(!r.suspense||i.state.status!=="error")&&rr(i,r)}function rr(i,c){return Me(c.enabled,i)!==!1&&i.isStaleByTime(Gl(c.staleTime,i))}function y0(i,c){return!Is(i.getCurrentResult(),c)}var v0=class extends Ih{#t;#e;#l;#a;constructor(i){super(),this.#t=i.client,this.mutationId=i.mutationId,this.#l=i.mutationCache,this.#e=[],this.state=i.state||p0(),this.setOptions(i.options),this.scheduleGc()}setOptions(i){this.options=i,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(i){this.#e.includes(i)||(this.#e.push(i),this.clearGcTimeout(),this.#l.notify({type:"observerAdded",mutation:this,observer:i}))}removeObserver(i){this.#e=this.#e.filter(c=>c!==i),this.scheduleGc(),this.#l.notify({type:"observerRemoved",mutation:this,observer:i})}optionalRemove(){this.#e.length||(this.state.status==="pending"?this.scheduleGc():this.#l.remove(this))}continue(){return this.#a?.continue()??this.execute(this.state.variables)}async execute(i){const c=()=>{this.#i({type:"continue"})},r={client:this.#t,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#a=Wh({fn:()=>this.options.mutationFn?this.options.mutationFn(i,r):Promise.reject(new Error("No mutationFn found")),onFail:(m,g)=>{this.#i({type:"failed",failureCount:m,error:g})},onPause:()=>{this.#i({type:"pause"})},onContinue:c,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#l.canRun(this)});const f=this.state.status==="pending",d=!this.#a.canStart();try{if(f)c();else{this.#i({type:"pending",variables:i,isPaused:d}),this.#l.config.onMutate&&await this.#l.config.onMutate(i,this,r);const g=await this.options.onMutate?.(i,r);g!==this.state.context&&this.#i({type:"pending",context:g,variables:i,isPaused:d})}const m=await this.#a.start();return await this.#l.config.onSuccess?.(m,i,this.state.context,this,r),await this.options.onSuccess?.(m,i,this.state.context,r),await this.#l.config.onSettled?.(m,null,this.state.variables,this.state.context,this,r),await this.options.onSettled?.(m,null,i,this.state.context,r),this.#i({type:"success",data:m}),m}catch(m){try{await this.#l.config.onError?.(m,i,this.state.context,this,r)}catch(g){Promise.reject(g)}try{await this.options.onError?.(m,i,this.state.context,r)}catch(g){Promise.reject(g)}try{await this.#l.config.onSettled?.(void 0,m,this.state.variables,this.state.context,this,r)}catch(g){Promise.reject(g)}try{await this.options.onSettled?.(void 0,m,i,this.state.context,r)}catch(g){Promise.reject(g)}throw this.#i({type:"error",error:m}),m}finally{this.#l.runNext(this)}}#i(i){const c=r=>{switch(i.type){case"failed":return{...r,failureCount:i.failureCount,failureReason:i.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:i.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:i.isPaused,status:"pending",variables:i.variables,submittedAt:Date.now()};case"success":return{...r,data:i.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:i.error,failureCount:r.failureCount+1,failureReason:i.error,isPaused:!1,status:"error"}}};this.state=c(this.state),ee.batch(()=>{this.#e.forEach(r=>{r.onMutationUpdate(i)}),this.#l.notify({mutation:this,type:"updated",action:i})})}};function p0(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var g0=class extends ti{constructor(i={}){super(),this.config=i,this.#t=new Set,this.#e=new Map,this.#l=0}#t;#e;#l;build(i,c,r){const f=new v0({client:i,mutationCache:this,mutationId:++this.#l,options:i.defaultMutationOptions(c),state:r});return this.add(f),f}add(i){this.#t.add(i);const c=xu(i);if(typeof c=="string"){const r=this.#e.get(c);r?r.push(i):this.#e.set(c,[i])}this.notify({type:"added",mutation:i})}remove(i){if(this.#t.delete(i)){const c=xu(i);if(typeof c=="string"){const r=this.#e.get(c);if(r)if(r.length>1){const f=r.indexOf(i);f!==-1&&r.splice(f,1)}else r[0]===i&&this.#e.delete(c)}}this.notify({type:"removed",mutation:i})}canRun(i){const c=xu(i);if(typeof c=="string"){const f=this.#e.get(c)?.find(d=>d.state.status==="pending");return!f||f===i}else return!0}runNext(i){const c=xu(i);return typeof c=="string"?this.#e.get(c)?.find(f=>f!==i&&f.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){ee.batch(()=>{this.#t.forEach(i=>{this.notify({type:"removed",mutation:i})}),this.#t.clear(),this.#e.clear()})}getAll(){return Array.from(this.#t)}find(i){const c={exact:!0,...i};return this.getAll().find(r=>Oh(c,r))}findAll(i={}){return this.getAll().filter(c=>Oh(i,c))}notify(i){ee.batch(()=>{this.listeners.forEach(c=>{c(i)})})}resumePausedMutations(){const i=this.getAll().filter(c=>c.state.isPaused);return ee.batch(()=>Promise.all(i.map(c=>c.continue().catch(ve))))}};function xu(i){return i.options.scope?.id}var b0=class extends ti{constructor(i={}){super(),this.config=i,this.#t=new Map}#t;build(i,c,r){const f=c.queryKey,d=c.queryHash??cr(f,c);let m=this.get(d);return m||(m=new d0({client:i,queryKey:f,queryHash:d,options:i.defaultQueryOptions(c),state:r,defaultOptions:i.getQueryDefaults(f)}),this.add(m)),m}add(i){this.#t.has(i.queryHash)||(this.#t.set(i.queryHash,i),this.notify({type:"added",query:i}))}remove(i){const c=this.#t.get(i.queryHash);c&&(i.destroy(),c===i&&this.#t.delete(i.queryHash),this.notify({type:"removed",query:i}))}clear(){ee.batch(()=>{this.getAll().forEach(i=>{this.remove(i)})})}get(i){return this.#t.get(i)}getAll(){return[...this.#t.values()]}find(i){const c={exact:!0,...i};return this.getAll().find(r=>Nh(c,r))}findAll(i={}){const c=this.getAll();return Object.keys(i).length>0?c.filter(r=>Nh(i,r)):c}notify(i){ee.batch(()=>{this.listeners.forEach(c=>{c(i)})})}onFocus(){ee.batch(()=>{this.getAll().forEach(i=>{i.onFocus()})})}onOnline(){ee.batch(()=>{this.getAll().forEach(i=>{i.onOnline()})})}},S0=class{#t;#e;#l;#a;#i;#n;#c;#u;constructor(i={}){this.#t=i.queryCache||new b0,this.#e=i.mutationCache||new g0,this.#l=i.defaultOptions||{},this.#a=new Map,this.#i=new Map,this.#n=0}mount(){this.#n++,this.#n===1&&(this.#c=ur.subscribe(async i=>{i&&(await this.resumePausedMutations(),this.#t.onFocus())}),this.#u=Ou.subscribe(async i=>{i&&(await this.resumePausedMutations(),this.#t.onOnline())}))}unmount(){this.#n--,this.#n===0&&(this.#c?.(),this.#c=void 0,this.#u?.(),this.#u=void 0)}isFetching(i){return this.#t.findAll({...i,fetchStatus:"fetching"}).length}isMutating(i){return this.#e.findAll({...i,status:"pending"}).length}getQueryData(i){const c=this.defaultQueryOptions({queryKey:i});return this.#t.get(c.queryHash)?.state.data}ensureQueryData(i){const c=this.defaultQueryOptions(i),r=this.#t.build(this,c),f=r.state.data;return f===void 0?this.fetchQuery(i):(i.revalidateIfStale&&r.isStaleByTime(Gl(c.staleTime,r))&&this.prefetchQuery(c),Promise.resolve(f))}getQueriesData(i){return this.#t.findAll(i).map(({queryKey:c,state:r})=>{const f=r.data;return[c,f]})}setQueryData(i,c,r){const f=this.defaultQueryOptions({queryKey:i}),m=this.#t.get(f.queryHash)?.state.data,g=t0(c,m);if(g!==void 0)return this.#t.build(this,f).setData(g,{...r,manual:!0})}setQueriesData(i,c,r){return ee.batch(()=>this.#t.findAll(i).map(({queryKey:f})=>[f,this.setQueryData(f,c,r)]))}getQueryState(i){const c=this.defaultQueryOptions({queryKey:i});return this.#t.get(c.queryHash)?.state}removeQueries(i){const c=this.#t;ee.batch(()=>{c.findAll(i).forEach(r=>{c.remove(r)})})}resetQueries(i,c){const r=this.#t;return ee.batch(()=>(r.findAll(i).forEach(f=>{f.reset()}),this.refetchQueries({type:"active",...i},c)))}cancelQueries(i,c={}){const r={revert:!0,...c},f=ee.batch(()=>this.#t.findAll(i).map(d=>d.cancel(r)));return Promise.all(f).then(ve).catch(ve)}invalidateQueries(i,c={}){return ee.batch(()=>(this.#t.findAll(i).forEach(r=>{r.invalidate()}),i?.refetchType==="none"?Promise.resolve():this.refetchQueries({...i,type:i?.refetchType??i?.type??"active"},c)))}refetchQueries(i,c={}){const r={...c,cancelRefetch:c.cancelRefetch??!0},f=ee.batch(()=>this.#t.findAll(i).filter(d=>!d.isDisabled()&&!d.isStatic()).map(d=>{let m=d.fetch(void 0,r);return r.throwOnError||(m=m.catch(ve)),d.state.fetchStatus==="paused"?Promise.resolve():m}));return Promise.all(f).then(ve)}fetchQuery(i){const c=this.defaultQueryOptions(i);c.retry===void 0&&(c.retry=!1);const r=this.#t.build(this,c);return r.isStaleByTime(Gl(c.staleTime,r))?r.fetch(c):Promise.resolve(r.state.data)}prefetchQuery(i){return this.fetchQuery(i).then(ve).catch(ve)}fetchInfiniteQuery(i){return i._type="infinite",this.fetchQuery(i)}prefetchInfiniteQuery(i){return this.fetchInfiniteQuery(i).then(ve).catch(ve)}ensureInfiniteQueryData(i){return i._type="infinite",this.ensureQueryData(i)}resumePausedMutations(){return Ou.isOnline()?this.#e.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#t}getMutationCache(){return this.#e}getDefaultOptions(){return this.#l}setDefaultOptions(i){this.#l=i}setQueryDefaults(i,c){this.#a.set(Vn(i),{queryKey:i,defaultOptions:c})}getQueryDefaults(i){const c=[...this.#a.values()],r={};return c.forEach(f=>{Jn(i,f.queryKey)&&Object.assign(r,f.defaultOptions)}),r}setMutationDefaults(i,c){this.#i.set(Vn(i),{mutationKey:i,defaultOptions:c})}getMutationDefaults(i){const c=[...this.#i.values()],r={};return c.forEach(f=>{Jn(i,f.mutationKey)&&Object.assign(r,f.defaultOptions)}),r}defaultQueryOptions(i){if(i._defaulted)return i;const c={...this.#l.queries,...this.getQueryDefaults(i.queryKey),...i,_defaulted:!0};return c.queryHash||(c.queryHash=cr(c.queryKey,c)),c.refetchOnReconnect===void 0&&(c.refetchOnReconnect=c.networkMode!=="always"),c.throwOnError===void 0&&(c.throwOnError=!!c.suspense),!c.networkMode&&c.persister&&(c.networkMode="offlineFirst"),c.queryFn===sr&&(c.enabled=!1),c}defaultMutationOptions(i){return i?._defaulted?i:{...this.#l.mutations,...i?.mutationKey&&this.getMutationDefaults(i.mutationKey),...i,_defaulted:!0}}clear(){this.#t.clear(),this.#e.clear()}},tm=Q.createContext(void 0),ei=i=>{const c=Q.useContext(tm);if(!c)throw new Error("No QueryClient set, use QueryClientProvider to set one");return c},x0=({client:i,children:c})=>(Q.useEffect(()=>(i.mount(),()=>{i.unmount()}),[i]),o.jsx(tm.Provider,{value:i,children:c})),em=Q.createContext(!1),j0=()=>Q.useContext(em);em.Provider;function E0(){let i=!1;return{clearReset:()=>{i=!1},reset:()=>{i=!0},isReset:()=>i}}var T0=Q.createContext(E0()),N0=()=>Q.useContext(T0),O0=(i,c,r)=>{const f=r?.state.error&&typeof i.throwOnError=="function"?Fh(i.throwOnError,[r.state.error,r]):i.throwOnError;(i.suspense||i.experimental_prefetchInRender||f)&&(c.isReset()||(i.retryOnMount=!1))},M0=i=>{Q.useEffect(()=>{i.clearReset()},[i])},A0=({result:i,errorResetBoundary:c,throwOnError:r,query:f,suspense:d})=>i.isError&&!c.isReset()&&!i.isFetching&&f&&(d&&i.data===void 0||Fh(r,[i.error,f])),C0=i=>{if(i.suspense){const r=d=>d==="static"?d:Math.max(d??1e3,1e3),f=i.staleTime;i.staleTime=typeof f=="function"?(...d)=>r(f(...d)):r(f),typeof i.gcTime=="number"&&(i.gcTime=Math.max(i.gcTime,1e3))}},z0=(i,c)=>i.isLoading&&i.isFetching&&!c,_0=(i,c)=>i?.suspense&&c.isPending,Uh=(i,c,r)=>c.fetchOptimistic(i).catch(()=>{r.clearReset()});function D0(i,c,r){const f=j0(),d=N0(),m=ei(),g=m.defaultQueryOptions(i);m.getDefaultOptions().queries?._experimental_beforeQuery?.(g);const A=m.getQueryCache().get(g.queryHash),p=i.subscribed!==!1;g._optimisticResults=f?"isRestoring":p?"optimistic":void 0,C0(g),O0(g,d,A),M0(d);const y=!m.getQueryCache().get(g.queryHash),[M]=Q.useState(()=>new c(m,g)),E=M.getOptimisticResult(g),x=!f&&p;if(Q.useSyncExternalStore(Q.useCallback(q=>{const z=x?M.subscribe(ee.batchCalls(q)):ve;return M.updateResult(),z},[M,x]),()=>M.getCurrentResult(),()=>M.getCurrentResult()),Q.useEffect(()=>{M.setOptions(g)},[g,M]),_0(g,E))throw Uh(g,M,d);if(A0({result:E,errorResetBoundary:d,throwOnError:g.throwOnError,query:A,suspense:g.suspense}))throw E.error;return m.getDefaultOptions().queries?._experimental_afterQuery?.(g,E),g.experimental_prefetchInRender&&!Fn.isServer()&&z0(E,f)&&(y?Uh(g,M,d):A?.promise)?.catch(ve).finally(()=>{M.updateResult()}),g.notifyOnChangeProps?E:M.trackResult(E)}function pe(i,c){return D0(i,h0)}function lm(){throw location.href="/auth/login?next="+encodeURIComponent(location.pathname+location.search),new Error("signing in…")}async function Ce(i){const c=await fetch(i);if(c.status===401&&lm(),!c.ok)throw new Error(await c.text());return c.json()}async function Yl(i,c,r){const f={method:i};r!==void 0&&(f.headers={"Content-Type":"application/json"},f.body=JSON.stringify(r));const d=await fetch(c,f);if(!d.ok)throw new Error(await d.text());return d.status===204?{}:d.json()}async function Ja(i,c){const r=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c||{})});if(r.status===401&&lm(),!r.ok)throw new Error(await r.text());return r.json()}function R0(){return pe({queryKey:["config"],queryFn:async()=>{const i=await Ce("/api/config");return i.auth.enabled&&!i.me&&(location.href="/auth/login?next="+encodeURIComponent(location.pathname+location.search),await new Promise(()=>{})),i},staleTime:1/0})}const am=(...i)=>i.filter((c,r,f)=>!!c&&c.trim()!==""&&f.indexOf(c)===r).join(" ").trim();const U0=i=>i.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const H0=i=>i.replace(/^([A-Z])|[\s-_]+(\w)/g,(c,r,f)=>f?f.toUpperCase():r.toLowerCase());const Hh=i=>{const c=H0(i);return c.charAt(0).toUpperCase()+c.slice(1)};var Js={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const q0=i=>{for(const c in i)if(c.startsWith("aria-")||c==="role"||c==="title")return!0;return!1},w0=Q.createContext({}),Q0=()=>Q.useContext(w0),B0=Q.forwardRef(({color:i,size:c,strokeWidth:r,absoluteStrokeWidth:f,className:d="",children:m,iconNode:g,...A},p)=>{const{size:y=24,strokeWidth:M=2,absoluteStrokeWidth:E=!1,color:x="currentColor",className:q=""}=Q0()??{},z=f??E?Number(r??M)*24/Number(c??y):r??M;return Q.createElement("svg",{ref:p,...Js,width:c??y??Js.width,height:c??y??Js.height,stroke:i??x,strokeWidth:z,className:am("lucide",q,d),...!m&&!q0(A)&&{"aria-hidden":"true"},...A},[...g.map(([w,Y])=>Q.createElement(w,Y)),...Array.isArray(m)?m:[m]])});const Ot=(i,c)=>{const r=Q.forwardRef(({className:f,...d},m)=>Q.createElement(B0,{ref:m,iconNode:c,className:am(`lucide-${U0(Hh(i))}`,`lucide-${i}`,f),...d}));return r.displayName=Hh(i),r};const L0=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Y0=Ot("check",L0);const G0=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],X0=Ot("chevron-down",G0);const K0=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Z0=Ot("chevron-right",K0);const k0=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],V0=Ot("clock",k0);const J0=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],F0=Ot("copy",J0);const $0=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],W0=Ot("download",$0);const I0=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],P0=Ot("ellipsis",I0);const tp=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],ep=Ot("file-text",tp);const lp=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],ap=Ot("folder",lp);const np=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],ip=Ot("globe",np);const up=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],cp=Ot("history",up);const sp=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],rp=Ot("layout-dashboard",sp);const fp=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],op=Ot("link",fp);const dp=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],hp=Ot("lock",dp);const mp=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],yp=Ot("log-out",mp);const vp=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],pp=Ot("menu",vp);const gp=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],bp=Ot("plus",gp);const Sp=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],xp=Ot("search",Sp);const jp=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Ep=Ot("settings",jp);const Tp=[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]],Np=Ot("share-2",Tp);const Op=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],Mp=Ot("shield",Op);const Ap=[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]],Cp=Ot("square-terminal",Ap);const zp=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],_p=Ot("trash-2",zp);const Dp=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Rp=Ot("triangle-alert",Dp);const Up=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],Hp=Ot("upload",Up);const qp=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],wp=Ot("users",qp);const Qp=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Bp=Ot("x",Qp);function Lp(){document.body.classList.toggle("sb-open")}function hl(){document.body.classList.remove("sb-open")}const Yp={alert:Rp,check:Y0,chev:Z0,chevd:X0,clock:V0,copy:F0,doc:ep,dots:P0,download:W0,folder:ap,dashboard:rp,gear:Ep,globe:ip,hist:cp,link:op,lock:hp,menu:pp,plus:bp,power:yp,search:xp,share:Np,shield:Mp,terminal:Cp,trash:_p,upload:Hp,users:wp,x:Bp};function Kt({name:i}){const c=Yp[i];return c?o.jsx(c,{className:"ico","aria-hidden":"true"}):null}function $n(i){return o.jsxs(o.Fragment,{children:[o.jsx("div",{id:"sb-backdrop",onClick:hl}),o.jsxs("aside",{id:"sidebar",children:[i.vault,i.projectsNav,i.tree??o.jsx("nav",{id:"tree","aria-label":"Files"}),i.orgBar]}),o.jsxs("main",{id:"main",children:[i.topbar,o.jsx("article",{id:"content",className:i.contentClass??"markdown",ref:i.contentRef,onScroll:i.onContentScroll,children:i.children})]})]})}function Mu(i){const{name:c,onHome:r,showSignout:f}=i;return o.jsxs("header",{id:"vault",children:[o.jsx("span",{id:"vault-badge","aria-hidden":"true",children:"🐻"}),o.jsx("span",{id:"vault-name",className:r?"vault-link":void 0,onClick:r,role:r?"button":void 0,tabIndex:r?0:void 0,onKeyDown:d=>{r&&(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),r())},children:c}),o.jsx("div",{className:"vault-actions",children:f&&o.jsx("a",{id:"signout",href:"/auth/logout",title:"Sign out","aria-label":"Sign out",children:o.jsx(Kt,{name:"power"})})})]})}function Wn(i){return o.jsxs("header",{id:"topbar",children:[o.jsx("button",{id:"menu-btn",className:"icon-btn",title:"Menu","aria-label":"Menu",onClick:Lp,children:o.jsx(Kt,{name:"menu"})}),o.jsx("span",{id:"crumb",children:i.crumb}),o.jsx("span",{id:"meta",children:i.meta}),i.actions]})}let fr={msg:"",err:!1,shown:!1},Eu=[],qh;function wh(i){fr=i,Eu.forEach(c=>c())}function st(i,c=!1){wh({msg:i,err:c,shown:!0}),clearTimeout(qh),qh=setTimeout(()=>wh({...fr,shown:!1}),3200)}function Gp(){const i=Q.useSyncExternalStore(c=>(Eu.push(c),()=>{Eu=Eu.filter(r=>r!==c)}),()=>fr);return o.jsx("div",{id:"toast",className:i.shown?"show"+(i.err?" err":""):"",children:i.msg})}let nm=null,Tu=[];function or(i){nm=i,Tu.forEach(c=>c())}function im(i,c,r="",f="OK"){return new Promise(d=>or({kind:"prompt",title:i,label:c,value:r,okLabel:f,resolve:d}))}function ju(i,c,r="Confirm",f=!1){return new Promise(d=>or({kind:"confirm",title:i,message:c,confirmLabel:r,danger:f,resolve:d}))}function Xp(){const i=Q.useSyncExternalStore(c=>(Tu.push(c),()=>{Tu=Tu.filter(r=>r!==c)}),()=>nm);return i?i.kind==="prompt"?o.jsx(Kp,{m:i}):o.jsx(Zp,{m:i}):null}function um(){or(null)}function Kp({m:i}){const c=Q.useRef(null),r=d=>{um(),i.resolve(d)},f=()=>r(c.current.value.trim()||null);return Q.useEffect(()=>{c.current.focus(),c.current.select();const d=m=>{m.key==="Escape"&&r(null),m.key==="Enter"&&f()};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[]),o.jsx("div",{className:"modal-back",onClick:d=>d.target===d.currentTarget&&r(null),children:o.jsxs("div",{className:"modal",children:[o.jsx("h3",{children:i.title}),o.jsx("label",{className:"modal-label",children:i.label}),o.jsx("input",{className:"modal-input",type:"text",autoComplete:"off",defaultValue:i.value,ref:c}),o.jsxs("div",{className:"modal-actions",children:[o.jsx("button",{className:"ai-btn",onClick:()=>r(null),children:"Cancel"}),o.jsx("button",{className:"pbtn",onClick:f,children:i.okLabel})]})]})})}function Zp({m:i}){const c=Q.useRef(null),r=f=>{um(),i.resolve(f)};return Q.useEffect(()=>{c.current.focus();const f=d=>{d.key==="Escape"&&r(!1),d.key==="Enter"&&r(!0)};return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)},[]),o.jsx("div",{className:"modal-back",onClick:f=>f.target===f.currentTarget&&r(!1),children:o.jsxs("div",{className:"modal",children:[o.jsx("h3",{children:i.title}),o.jsx("p",{className:"modal-msg",children:i.message}),o.jsxs("div",{className:"modal-actions",children:[o.jsx("button",{className:"ai-btn",onClick:()=>r(!1),children:"Cancel"}),o.jsx("button",{className:i.danger?"danger-btn":"pbtn",onClick:()=>r(!0),ref:c,children:i.confirmLabel})]})]})})}function kp(i){return pe({queryKey:["projects"],queryFn:()=>Ce("/api/projects"),enabled:i,refetchInterval:3e4,select:c=>c.projects||[]})}function Vp(i){return pe({queryKey:["orgs"],queryFn:()=>Ce("/api/orgs"),enabled:i,select:c=>c.orgs||[]})}function cm(i){return pe({queryKey:["admin","pending"],queryFn:()=>Ce("/api/admin/pending"),enabled:i,select:c=>c.pending||[]})}function sm(){const i=ei();return()=>Promise.all([i.invalidateQueries({queryKey:["projects"]}),i.invalidateQueries({queryKey:["orgs"]})]).then(()=>{})}function rm(i){return i.split("/").map(encodeURIComponent).join("/")}function Qh(i){return i.split("/").map(decodeURIComponent).join("/")}const Jp=new Set(["insights","history","install","settings"]);function fm(i,c){const r=i.replace(/^\/+/,"");if(c!=="hub")return{path:r?Qh(r):""};const f=r.indexOf("/");if(f===-1)return{project:r,path:""};const d={project:r.slice(0,f),path:Qh(r.slice(f+1))},m=d.path.indexOf("/"),g=m===-1?d.path:d.path.slice(0,m);return Jp.has(g)&&(d.view=g,d.viewTarget=m===-1?"":d.path.slice(m+1).replace(/\/+$/,""),d.path=""),d}function Fp(i,c){const r=rm(i);return c?"/"+c+(r?"/"+r:""):"/"+r}function kn(i,c,r){let f=(c?"/"+c:"")+"/"+i;return r&&(f+="/"+rm(r.replace(/\/+$/,""))),f}let dr="POP";const nr=new Set;function om(){for(const i of nr)i()}window.addEventListener("popstate",()=>{dr="POP",om()});function Ae(i,c){const r=location.pathname+location.search;!c?.replace&&r===i||(history[c?.replace?"replaceState":"pushState"](null,"",i),dr=c?.replace?"REPLACE":"PUSH",om())}function hr(){return Q.useSyncExternalStore(i=>(nr.add(i),()=>{nr.delete(i)}),()=>location.pathname)}function $p(){return dr}function Wp({to:i}){return Q.useEffect(()=>{Ae(i,{replace:!0})},[i]),null}const Ip=/\.(md|markdown)$/i,Pp=/\.(png|jpe?g|gif|svg|webp|ico|bmp|avif)$/i,tg=/\.html?$/i,eg=/\.(txt|log|json|ya?ml|toml|csv|go|py|js|ts|jsx|tsx|sh|bash|zsh|rb|rs|c|h|cpp|java|kt|swift|sql|css|xml|ini|conf|env|mod|sum|jsonl)$/i;function dm(i){if(i<1024)return i+" B";const c=["KB","MB","GB","TB"];let r=-1;do i/=1024,r++;while(i>=1024&&rd.invalidateQueries({queryKey:["orgs"]}),y=()=>d.invalidateQueries({queryKey:["invites",i.id]}),M=()=>d.invalidateQueries({queryKey:["orgShares",i.id]}),{data:E}=pe({queryKey:["invites",i.id],queryFn:()=>Ce(`/api/orgs/${i.id}/invites`),enabled:m,select:z=>z.invites||[]}),{data:x}=pe({queryKey:["orgShares",i.id],queryFn:()=>Ce(`/api/orgs/${i.id}/shares`),enabled:m,select:z=>z.shares||[]}),q=c.filter(z=>z.org===i.id);return o.jsxs("div",{className:"admin",children:[o.jsx("h1",{id:"org-title",children:i.name+(m?"":" · member")}),m&&o.jsxs("div",{className:"admin-row",children:[o.jsx("input",{id:"org-rename",type:"text",value:g,onChange:z=>A(z.target.value)}),o.jsx("button",{className:"pbtn",id:"org-rename-btn",onClick:async()=>{try{await Yl("PATCH","/api/orgs/"+i.id,{name:g.trim()}),st("Renamed."),p()}catch(z){st(z.message,!0)}},children:"Rename org"})]}),o.jsx("h3",{children:"Members"}),o.jsx("div",{className:"admin-list",children:i.members.map(z=>{const w=!!r&&z.email.toLowerCase()===r.toLowerCase();return o.jsxs("div",{className:"admin-item",children:[o.jsx("span",{className:"ai-main",children:z.email+(w?" (you)":"")}),m&&!w?o.jsxs(o.Fragment,{children:[o.jsxs("select",{value:z.role,onChange:async Y=>{try{await Yl("PATCH",`/api/orgs/${i.id}/members/${encodeURIComponent(z.email)}`,{role:Y.target.value}),st("Role updated.")}catch($){st($.message,!0)}p()},children:[o.jsx("option",{value:"owner",children:"owner"}),o.jsx("option",{value:"member",children:"member"})]}),o.jsx("button",{className:"ai-del",onClick:async()=>{if(await ju("Remove member",`Remove ${z.email} from ${i.name}?`,"Remove",!0))try{await Yl("DELETE",`/api/orgs/${i.id}/members/${encodeURIComponent(z.email)}`),st("Removed."),p()}catch(Y){st(Y.message,!0)}},children:"Remove"})]}):o.jsx("span",{className:"ai-tag",children:z.role})]},z.email)})}),m&&o.jsxs(o.Fragment,{children:[o.jsx("h3",{children:"Projects"}),o.jsxs("div",{className:"admin-list",children:[q.length===0&&o.jsx("div",{className:"admin-empty",children:"No projects yet."}),q.map(z=>o.jsxs("div",{className:"admin-item",children:[o.jsx("span",{className:"ai-main",children:z.name}),o.jsx("button",{className:"ai-btn",onClick:async()=>{const w=await im("Rename project","New name",z.name,"Rename");if(!(!w||w===z.name))try{await Yl("PATCH","/api/projects/"+z.id,{name:w}),st("Renamed."),await f()}catch(Y){st(Y.message,!0)}},children:"Rename"}),o.jsx("button",{className:"ai-del",onClick:async()=>{if(await ju("Delete project",`Delete “${z.name}”? Its files stay in storage, but it's removed from the hub.`,"Delete",!0))try{await Yl("DELETE","/api/projects/"+z.id),st(`Deleted “${z.name}”.`),await f()}catch(w){st(w.message,!0)}},children:"Delete"})]},z.id))]}),o.jsxs("div",{className:"admin-h",children:[o.jsx("h3",{children:"Invite links"}),o.jsx("button",{className:"pbtn",onClick:async()=>{try{const z=await Ja(`/api/orgs/${i.id}/invites`),w=await In(z.url);st(w?"Invite link copied to clipboard.":"Invite created — copy it from the list below."),y()}catch(z){st(z.message,!0)}},children:"New invite"})]}),o.jsxs("div",{className:"admin-list",children:[E&&E.length===0&&o.jsx("div",{className:"admin-empty",children:"No active invite links."}),(E||[]).map(z=>o.jsxs("div",{className:"admin-item",children:[o.jsx("span",{className:"ai-main mono",style:{cursor:"pointer"},title:"Copy",onClick:()=>In(z.url).then(w=>st(w?"Copied.":"Select and copy the link.")),children:z.url}),o.jsx("span",{className:"ai-tag",children:(z.creator?"by "+z.creator+" · ":"")+(z.uses?z.uses+" joined · ":"unused · ")+"expires "+new Date(z.expires).toLocaleDateString()}),o.jsx("button",{className:"ai-del",onClick:async()=>{if(await ju("Revoke invite","Revoke this invite link? Anyone still holding it won't be able to join.","Revoke",!0))try{await Yl("DELETE",`/api/orgs/${i.id}/invites/${z.token}`),st("Revoked."),y()}catch(w){st(w.message,!0)}},children:"Revoke"})]},z.token))]}),o.jsx("h3",{children:"Public share links"}),o.jsxs("div",{className:"admin-list",children:[x&&x.length===0&&o.jsx("div",{className:"admin-empty",children:"No public shares."}),(x||[]).map(z=>o.jsxs("div",{className:"admin-item",children:[o.jsx("span",{className:"ai-main mono",style:{cursor:"pointer"},title:z.url,onClick:()=>window.open(z.url,"_blank"),children:z.path}),o.jsx("span",{className:"ai-tag",children:(z.project_name||"")+(z.creator?" · by "+z.creator:"")+(z.created?" · "+new Date(z.created).toLocaleDateString():"")}),o.jsx("button",{className:"ai-del",onClick:async()=>{if(await ju("Revoke share link",`Revoke the public link to “${z.path}”? Anyone with the URL will lose access.`,"Revoke",!0))try{await Yl("DELETE","/api/shares/"+z.token),st("Share revoked."),M()}catch(w){st(w.message,!0)}},children:"Revoke"})]},z.token))]})]})]})}function ag(){const i=ei(),{data:c,error:r}=pe({queryKey:["admin","policy"],queryFn:()=>Ce("/api/admin/policy")}),{data:f}=cm(!0),[d,m]=Q.useState(!1),[g,A]=Q.useState(!1);if(Q.useEffect(()=>{c&&(m(c.require_verification&&c.mailer),A(c.require_approval))},[c]),Q.useEffect(()=>{r&&st(r.message,!0)},[r]),!c)return null;const p=async(y,M,E)=>{try{await Ja(`/api/admin/pending/${y}/${M}`),st((M==="approve"?"Approved ":"Denied ")+E),i.invalidateQueries({queryKey:["admin","pending"]})}catch(x){st(x.message,!0)}};return o.jsxs("div",{className:"admin",children:[o.jsx("h1",{children:"Signup & access"}),o.jsx("p",{className:"admin-sub",children:"Who can create an account on this hub, and how new accounts are vetted."}),o.jsx("h3",{children:"New-account vetting"}),o.jsxs("div",{className:"admin-list",children:[o.jsx(Bh,{label:"Require email verification",desc:c.mailer?"New accounts must click an emailed link before they can sign in — proves they control the address.":"Configure SMTP on the server (auth.smtp) to enable email verification.",checked:d,disabled:!c.mailer,onChange:m}),o.jsx(Bh,{label:"Require admin approval",desc:"New accounts wait for a hub admin to approve them before they gain access.",checked:g,onChange:A})]}),o.jsx("button",{className:"pbtn",style:{marginTop:14},onClick:async()=>{try{await Ja("/api/admin/policy",{require_verification:d,require_approval:g}),st("Signup policy saved."),i.invalidateQueries({queryKey:["admin","policy"]})}catch(y){st(y.message,!0)}},children:"Save policy"}),o.jsx("h3",{children:"Who can sign up"}),o.jsxs("div",{className:"admin-list",children:[o.jsxs("div",{className:"admin-item",children:[o.jsx("span",{className:"ai-main",children:"Allowed email domains"}),o.jsx("span",{className:"ai-tag",children:c.allowed_domains&&c.allowed_domains.length?c.allowed_domains.map(y=>"@"+y).join(", "):"any"})]}),o.jsxs("div",{className:"admin-item",children:[o.jsx("span",{className:"ai-main",children:"Self-signup"}),o.jsx("span",{className:"ai-tag",children:c.allow_signup?"open":"invite-only"})]}),o.jsxs("div",{className:"admin-item",children:[o.jsx("span",{className:"ai-main",children:"Hub admins"}),o.jsx("span",{className:"ai-tag",children:c.admins&&c.admins.length?c.admins.join(", "):"none"})]})]}),o.jsx("p",{className:"admin-sub",children:"Domains and admins are set in the server config file (they can't be widened from the browser)."}),o.jsx("h3",{children:"Pending signups"}),o.jsxs("div",{className:"admin-list",children:[(!f||f.length===0)&&o.jsx("div",{className:"admin-empty",children:"No one is waiting for approval."}),(f||[]).map(y=>o.jsxs("div",{className:"admin-item",children:[o.jsx("span",{className:"ai-main",children:(y.name?y.name+" · ":"")+y.email}),o.jsx("button",{className:"pbtn",onClick:()=>p(y.id,"approve",y.email),children:"Approve"}),o.jsx("button",{className:"ai-del",onClick:()=>p(y.id,"deny",y.email),children:"Deny"})]},y.id))]})]})}function Bh({label:i,desc:c,checked:r,disabled:f,onChange:d}){return o.jsxs("label",{className:"admin-item toggle",style:f?{opacity:.55}:void 0,children:[o.jsxs("span",{className:"ai-main",children:[o.jsx("div",{className:"tg-label",children:i}),o.jsx("div",{className:"tg-desc",children:c})]}),o.jsx("input",{type:"checkbox",checked:r,disabled:f,onChange:m=>d(m.target.checked)})]})}const Lh=["#5b8def","#f5a623","#4cc38a","#e0679b","#8b7bf0","#3ec8c8","#e6934a"];function mm(i){let c=0;for(const r of i)c=c*31+r.charCodeAt(0)>>>0;return Lh[c%Lh.length]}function Yh({projects:i,currentId:c,menu:r}){const f=sm(),d=async()=>{const m=await im("New project","Project name","","Create");if(m)try{const g=await Ja("/api/projects",{name:m});await f(),Ae("/"+g.project.id),st(`Created “${g.project.name}”.`)}catch(g){st("Could not create the project: "+g.message,!0)}};return o.jsxs("nav",{id:"projects","aria-label":"Projects",children:[o.jsxs("div",{className:"nav-head",children:[o.jsx("span",{children:"Projects"}),o.jsx("button",{className:"nav-add",title:"New project",onClick:d,children:"+"})]}),o.jsx("div",{className:"proj-row",children:o.jsxs("span",{className:"proj-select-wrap",children:[c&&o.jsx("span",{className:"proj-mark","aria-hidden":"true",style:{background:mm(i.find(m=>m.id===c)?.name||"")}}),o.jsxs("select",{id:"project-select","aria-label":"Switch project",value:c||"",onChange:m=>{m.target.value&&(Ae("/"+m.target.value),hl())},children:[!c&&o.jsx("option",{value:"",disabled:!0}),i.map(m=>o.jsx("option",{value:m.id,children:m.name},m.id))]}),o.jsx(Kt,{name:"chevd"})]})}),r&&o.jsx("ul",{className:"nav-menu","aria-label":"Project pages",children:[["dashboard","Dashboard","dashboard",r.onDashboard],["install","Installation","terminal",r.onInstall],["settings","Settings","gear",r.onSettings]].map(([m,g,A,p])=>o.jsx("li",{children:o.jsxs("div",{id:"nav-"+m,className:"row"+(r.active===m?" active":""),role:"button",tabIndex:0,onClick:p,onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),p())},children:[o.jsx(Kt,{name:A}),o.jsx("span",{className:"label",children:g})]})},m))})]})}function ng({me:i,org:c,admin:r,onOrgSettings:f}){const[d,m]=Q.useState(!1),g=Q.useRef(null);Q.useEffect(()=>{if(!d)return;const p=M=>{g.current&&!g.current.contains(M.target)&&m(!1)},y=M=>{M.key==="Escape"&&m(!1)};return document.addEventListener("mousedown",p),document.addEventListener("keydown",y),()=>{document.removeEventListener("mousedown",p),document.removeEventListener("keydown",y)}},[d]);const A=i.name||i.email;return o.jsxs("footer",{id:"accountbar",ref:g,children:[d&&o.jsxs("div",{id:"account-menu",role:"menu","aria-label":"Account menu",children:[c&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"menu-sec",children:"Organization"}),o.jsxs("button",{id:"menu-org-settings",role:"menuitem",onClick:()=>{m(!1),f(c)},children:[o.jsx(Kt,{name:"gear"}),o.jsxs("span",{children:[o.jsx("b",{children:c.name})," Settings"]})]})]}),r&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"menu-sec",children:"Hub"}),o.jsxs("button",{id:"menu-hub-admin",role:"menuitem",onClick:()=>{m(!1),r.onClick()},children:[o.jsx(Kt,{name:"shield"}),o.jsxs("span",{children:["Signup & access",r.pending?` · ${r.pending}`:""]})]})]}),o.jsx("div",{className:"menu-sec",children:"Account"}),o.jsxs("a",{id:"signout",role:"menuitem",href:"/auth/logout",children:[o.jsx(Kt,{name:"power"}),o.jsx("span",{children:"Log out"})]})]}),o.jsxs("button",{id:"account-btn","aria-haspopup":"menu","aria-expanded":d,onClick:()=>m(p=>!p),children:[o.jsx("span",{className:"avatar",style:{background:mm(i.email)},"aria-hidden":"true",children:(A.trim()[0]||"?").toUpperCase()}),o.jsxs("span",{className:"acct",children:[o.jsx("b",{children:A}),i.name&&o.jsx("small",{children:i.email})]}),o.jsx(Kt,{name:"chev"})]})]})}function ig({project:i,org:c}){return o.jsxs("div",{className:"project-settings",children:[o.jsx("h2",{children:i.name}),o.jsxs("dl",{className:"ps-facts",children:[o.jsx("dt",{children:"Project id"}),o.jsx("dd",{children:o.jsx("code",{children:i.id})}),c&&o.jsxs(o.Fragment,{children:[o.jsx("dt",{children:"Workspace"}),o.jsx("dd",{children:c.name})]}),i.created&&o.jsxs(o.Fragment,{children:[o.jsx("dt",{children:"Created"}),o.jsx("dd",{children:new Date(i.created).toLocaleDateString()})]})]})]})}const Fs=[{key:"claude",label:"Claude Code & Cowork"},{key:"hermes",label:"Hermes",hook:"hermes",note:"Registers BearDrive's hooks in Hermes's config: pull before every turn, push after edits with a session note, and report file reads to Insights."},{key:"codex",label:"Codex",hook:"codex",note:"Registers hooks in .codex/hooks.json.",extra:"Run /hooks inside Codex once to trust the project's .codex layer — after that every turn pulls, edits push automatically, and reads are reported to Insights."}];function ug(i,c){const r=window.location.origin,f=c.id;if(i.key==="claude")return[{title:"Add the BearDrive plugin",desc:"One time, in any Claude Code session. The plugin ships the beardrive skill, the /beardrive commands, and turn-boundary sync hooks — and Claude Cowork shares the same plugins, so installing it once covers both.",code:`/plugin marketplace add runbear-io/beardrive /plugin install beardrive@beardrive`},{title:"Set up this project conversationally",desc:"In a Claude Code or Cowork session in the folder where you want the files, run:",code:"/beardrive:install connect to "+r+", project "+f,extra:"Claude installs the CLI, signs this machine in, mounts the project, and registers the sync hooks — pull the latest before every turn, push after edits (stamped with the session that made them), and report file reads to Insights. It asks before anything it changes."}];const d=(c.name||"project").toLowerCase().replace(/[^a-z0-9._-]+/g,"-")||"project";return[{title:"Install the BearDrive CLI",desc:"One static binary. Homebrew on macOS and Linux; releases and `go install` also work.",code:"brew install runbear-io/tap/beardrive"},{title:"Sign in to this hub",desc:"Opens the browser once and stores a device token on this machine — the synced folder itself never holds credentials.",code:"bdrive login "+r},{title:"Mount the project into a local folder",desc:"Run it where you want the files. An existing folder works too — contents merge, and re-running init later (or after moving the folder) just resumes.",code:"mkdir -p ~/"+d+" && cd ~/"+d+` -bdrive init --project `+f},{title:"Connect "+i.label,desc:i.note,code:"bdrive hooks install --agent "+i.hook,extra:i.extra}]}function cg(){try{return localStorage.getItem("bdrive-guide-agent")||"claude"}catch{return"claude"}}function ym({project:i}){const[c,r]=Q.useState(cg),f=Js.find(d=>d.key===c)||Js[0];return o.jsxs("div",{className:"guide",children:[o.jsx("h1",{className:"in-title",children:i.name}),o.jsx("p",{className:"dl-sub",children:"Mount this project as a folder on any machine and connect your coding agent: files sync both ways in the background, every change is journaled with who made it, and agent reads feed Insights."}),o.jsx("div",{className:"gd-tabs",children:Js.map(d=>o.jsx("button",{className:"gd-tab"+(d.key===f.key?" active":""),"data-key":d.key,onClick:()=>{r(d.key);try{localStorage.setItem("bdrive-guide-agent",d.key)}catch{}},children:d.label},d.key))}),o.jsxs("div",{className:"gd-body",children:[ug(f,i).map((d,m)=>o.jsxs("div",{className:"gd-step",children:[o.jsxs("div",{className:"gd-step-head",children:[o.jsx("span",{className:"gd-num",children:m+1}),o.jsx("span",{className:"gd-step-title",children:d.title})]}),d.desc&&o.jsx("p",{className:"gd-desc",children:d.desc}),d.code&&o.jsx(sg,{code:d.code}),d.extra&&o.jsx("p",{className:"gd-desc gd-extra",children:d.extra})]},m)),o.jsx("p",{className:"gd-done",children:"That's it — the folder now syncs on its own. Every agent turn starts from the latest state, edits appear here (and on every teammate's mount) within seconds, and what your agents read shows up in Insights."})]})]})}function sg({code:i}){const[c,r]=Q.useState("Copy");return o.jsxs("pre",{className:"gd-code",children:[o.jsx("code",{children:i}),o.jsx("button",{className:"gd-copy",onClick:async()=>{r(await Wn(i)?"Copied":"Copy failed"),setTimeout(()=>r("Copy"),1400)},children:c})]})}function rg({authEnabled:i,onCreate:c}){const r=Q.useRef(null),f=Q.useRef(null),d=()=>{const m=r.current.value.trim(),g=m.match(/join\/([0-9a-f]+)/)||m.match(/^([0-9a-f]{8,})$/);if(!g){st("That doesn't look like an invite link.",!0);return}location.href="/join/"+g[1]};return o.jsxs("div",{className:"onboard",children:[o.jsx("h1",{children:"Welcome to BearDrive"}),o.jsx("p",{children:"You're signed in, but you're not part of any project yet."}),i&&o.jsxs("div",{className:"ob-card",children:[o.jsx("h3",{children:"Have an invite link?"}),o.jsx("p",{children:"A teammate can send you a join link. Paste it here:"}),o.jsxs("div",{className:"ob-row",children:[o.jsx("input",{id:"ob-invite",type:"text",placeholder:"https://…/join/…",autoComplete:"off",ref:r}),o.jsx("button",{id:"ob-join",className:"pbtn",onClick:d,children:"Join"})]})]}),o.jsxs("div",{className:"ob-card",children:[o.jsx("h3",{children:"Or start a new project"}),o.jsx("p",{children:"Create a shared space for your team's files."}),o.jsxs("div",{className:"ob-row",children:[o.jsx("input",{id:"ob-name",type:"text",placeholder:"Project name, e.g. wiki",autoComplete:"off",ref:f}),o.jsx("button",{id:"ob-create",className:"pbtn",onClick:()=>c(f.current.value.trim()),children:"Create"})]})]})]})}function fg(i,c=!0){const r=pe({queryKey:["tree",i],queryFn:()=>Ae(i+"tree"),enabled:c,refetchInterval:15e3}),f=Q.useMemo(()=>{const d=[],m=new Map,g=A=>{for(const p of A.children||[])p.dir?(m.set(p.path,p),g(p)):d.push(p)};return r.data&&g(r.data),{flatFiles:d,dirIndex:m}},[r.data]);return{tree:r.data,...f,loaded:!!r.data}}function og(i,c){return pe({queryKey:["heat",i],queryFn:()=>Ae(i+"heat?days=30"),enabled:c,staleTime:6e4,refetchInterval:6e4}).data?.entries??null}function dg(i,c,r){return pe({queryKey:["history",i,"prefix",c,20],queryFn:()=>Ae(i+"history?prefix="+encodeURIComponent(c)+"&n=20"),enabled:r,staleTime:15e3}).data?.entries??null}function Gh(i,c,r){if(!i)return null;if(!r)return i[c]||null;const f={human:0,agent:0,share:0};for(const[d,m]of Object.entries(i))d.startsWith(c+"/")&&(f.human+=m.human||0,f.agent+=m.agent||0,f.share+=m.share||0);return f.human||f.agent||f.share?f:null}function In(i){return(i.human||0)+(i.agent||0)+(i.share||0)}function Tu(i){const c=In(i);if(!c)return"";let r=c+(c===1?" read":" reads");return i.agent&&(r+=" ("+i.agent+" agent)"),r}function hg(i){const c=In(i);return c?c<3?1:c<10?2:c<30?3:4:0}function mg(i){return o.jsx("nav",{id:"tree","aria-label":"Files",children:i.root&&o.jsx(vm,{nodes:i.root.children||[],...i})})}function vm({nodes:i,...c}){return o.jsx("ul",{children:i.map(r=>o.jsx(yg,{node:r,...c},r.path))})}function yg({node:i,...c}){const{expanded:r,onToggle:f,currentPath:d,listingShowing:m,onOpen:g}=c,A=i.dir?r.has(i.path):!1,p=()=>{if(i.dir&&d===i.path&&m){f(i.path);return}g(i.path),i.dir||hl()};return o.jsxs("li",{className:(i.dir?"dir":"file")+(i.dir&&!A?" collapsed":""),children:[o.jsxs("div",{className:"row"+(d===i.path?" active":""),"data-path":i.path,tabIndex:0,role:"button",title:i.name,"aria-expanded":i.dir?A:void 0,onClick:p,onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),p())},children:[o.jsx("span",{className:"chev",onClick:y=>{i.dir&&(y.stopPropagation(),f(i.path))},children:o.jsx(Kt,{name:"chevd"})}),o.jsx("span",{className:"ticon",children:o.jsx(Kt,{name:i.dir?"folder":"doc"})}),o.jsx("span",{className:"label",children:i.name})]}),i.dir&&o.jsx(vm,{nodes:i.children||[],...c})]})}function vg(i){const c=i.split("/"),r=[];let f="";for(let d=0;d{f=f?f+"/"+d:d;const g=f,A=m===r.length-1;return o.jsxs("span",{children:[m>0&&o.jsx("span",{className:"crumb-sep",children:"/"}),A?o.jsx("span",{children:d}):o.jsx("span",{className:"crumb-seg",title:g,onClick:()=>c(g),children:d})]},g)})})}const gg={add:"plus",edit:"edit",delete:"x"},bg={add:"added",edit:"edited",delete:"deleted"};function pm({entry:i,onOpen:c}){const[r,f]=Q.useState(!1),d=i.kind==="put"?"edit":i.kind,m=i.user_name?`${i.user_name} <${i.user}>`:i.user||i.author||"unknown",g=[i.device.name||i.device.id,i.device.os,i.device.ip].filter(Boolean).join(" · "),A=d!=="delete",p=y=>{y.target.tagName!=="A"&&A&&c(i.path)};return o.jsxs("div",{className:"hentry "+d+(A?" clickable":""),tabIndex:A?0:void 0,role:A?"button":void 0,onClick:p,onKeyDown:y=>{A&&(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),c(i.path))},children:[o.jsxs("div",{className:"hline",children:[o.jsx("span",{className:"hkind",children:o.jsx(Kt,{name:gg[d]||"dot"})}),o.jsx("span",{className:"hpath",children:i.path}),o.jsx("span",{className:"htag",children:bg[d]||d}),o.jsx("span",{className:"htime",children:new Date(i.time).toLocaleString()})]}),o.jsxs("div",{className:"hmeta",children:[o.jsx("span",{className:"hwho",children:m}),o.jsx("span",{className:"hdev",children:g}),o.jsx("span",{className:"hsize",children:i.size?dm(i.size):""})]}),i.note&&o.jsx("div",{className:"hnote"+(r?" open":""),tabIndex:0,role:"button",title:r?"Collapse note":"Show full note","aria-expanded":r,onClick:y=>{y.stopPropagation(),y.target.tagName!=="A"&&f(!r)},onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),y.stopPropagation(),f(!r))},children:i.note.split(/(https?:\/\/\S+)/).map((y,M)=>/^https?:\/\//.test(y)?o.jsx("a",{href:y,target:"_blank",rel:"noopener",children:y},M):y)})]})}function Sg(i){const{node:c,heatMap:r,onOpen:f}=i,d=(c.children||[]).slice().sort((y,M)=>Number(M.dir||!1)-Number(y.dir||!1)||y.name.localeCompare(M.name)),m=d.filter(y=>y.dir).length,g=d.length-m,A=[];m&&A.push(m+(m===1?" folder":" folders")),g&&A.push(g+(g===1?" file":" files"));const p=Gh(r,c.path,!0);return p&&A.push(Tu(p)+" in 30 days"),o.jsxs("div",{className:"dirlist",children:[o.jsxs("h1",{className:"dl-title",children:[o.jsx("span",{className:"dl-title-icon",children:o.jsx(Kt,{name:"folder"})}),o.jsx("span",{children:c.name})]}),o.jsx("p",{className:"dl-sub",children:A.join(" · ")||"Empty folder"}),d.length===0?o.jsx("div",{className:"dl-empty",children:"Nothing in this folder yet."}):o.jsx("div",{className:"dl-items",children:d.map(y=>{let M="";if(y.dir){const x=(y.children||[]).length;M=x+(x===1?" item":" items")}else M=[y.size?dm(y.size):"",y.time?new Date(y.time).toLocaleDateString():""].filter(Boolean).join(" · ");const E=Gh(r,y.path,!!y.dir);return E&&(M=Tu(E)+(M?" · "+M:"")),o.jsxs("div",{className:"dl-row",tabIndex:0,role:"button",title:y.path,onClick:()=>f(y.path),onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),f(y.path))},children:[o.jsx("span",{className:"ticon",children:o.jsx(Kt,{name:y.dir?"folder":"doc"})}),o.jsx("span",{className:"dl-name",children:y.name}),E&&o.jsx("span",{className:"heatdot lvl"+hg(E),title:Tu(E)+" in 30 days"}),o.jsx("span",{className:"dl-meta",children:M})]},y.path)})}),i.hub&&o.jsx(xg,{apiBase:i.apiBase,prefix:c.path+"/",onOpen:f,onFullHistory:()=>i.onFullHistory(c.path+"/"),onRendered:i.onRendered})]})}function xg(i){const c=dg(i.apiBase,i.prefix,!0),{onRendered:r}=i;return Q.useEffect(()=>{c&&c.length&&r&&r()},[c,r]),!c||c.length===0?null:o.jsxs("div",{className:"dl-history",children:[o.jsx("h3",{className:"dl-h3",children:"Recent changes"}),o.jsx("div",{className:"history dl-hlist",children:c.map((f,d)=>o.jsx(pm,{entry:f,onOpen:i.onOpen},d))}),o.jsx("button",{className:"ai-btn dl-more",onClick:i.onFullHistory,children:"Full history"})]})}function jg(i){const{apiBase:c,path:r,onMeta:f}=i,d=c+"file?path="+encodeURIComponent(r);return Q.useEffect(()=>()=>f(""),[r,f]),Ip.test(r)?o.jsx(Eg,{...i}):tg.test(r)?o.jsx("iframe",{className:"htmlview",sandbox:"allow-scripts",src:d,title:r,onLoad:i.onRendered}):Pp.test(r)?o.jsx(Og,{src:d,alt:r,onRendered:i.onRendered}):eg.test(r)?o.jsx(Mg,{...i,fileURL:d}):o.jsxs("div",{className:"filecard",children:[o.jsx("div",{className:"name",children:r.split("/").pop()}),o.jsx("p",{children:"No preview for this file type."}),o.jsx("a",{className:"btn",download:!0,href:c+"download?path="+encodeURIComponent(r),children:"Download"})]})}function Eg(i){const{apiBase:c,path:r,heatMap:f,flatFiles:d,onOpenFile:m,onMeta:g,onRendered:A}=i,{data:p,error:y}=pe({queryKey:["render",c,r],queryFn:()=>Ae(c+"render?path="+encodeURIComponent(r))}),M=Q.useMemo(()=>p?Ng(p.html,r,c):"",[p,r,c]);return Q.useEffect(()=>{if(!p)return;const E=[];p.author&&E.push(p.author+(p.device?" on "+p.device:"")),p.time&&E.push(new Date(p.time).toLocaleString());const x=f&&f[p.path];x&&In(x)&&E.push(Tu(x)+" / 30d"),g(E.join(" · ")),A?.()},[p,f,g,A]),y?o.jsxs("div",{className:"empty",children:["Could not load file: ",y.message]}):p?o.jsx("div",{dangerouslySetInnerHTML:{__html:M},onClick:E=>Tg(E,r,d,m)}):null}function Tg(i,c,r,f){const d=i.target.closest("a");if(!d||!i.currentTarget.contains(d))return;const m=d.getAttribute("href")||"",g=c.includes("/")?c.slice(0,c.lastIndexOf("/")):"";m.startsWith("wiki:")?(i.preventDefault(),Ag(decodeURIComponent(m.slice(5)),r,f)):/^([a-z]+:|\/|#)/i.test(m)||(i.preventDefault(),f(hm(g,decodeURIComponent(m))))}function Ng(i,c,r){const f=c.includes("/")?c.slice(0,c.lastIndexOf("/")):"",d=g=>r+"file?path="+encodeURIComponent(g),m=new DOMParser().parseFromString(i,"text/html");for(const g of m.querySelectorAll("img")){const A=g.getAttribute("src")||"";/^([a-z]+:|\/)/i.test(A)||g.setAttribute("src",d(hm(f,A)))}for(const g of m.querySelectorAll("a")){const A=g.getAttribute("href")||"";/^https?:/i.test(A)&&(g.setAttribute("target","_blank"),g.setAttribute("rel","noopener"))}return m.body.innerHTML}function Og({src:i,alt:c,onRendered:r}){return o.jsx("img",{src:i,alt:c,onLoad:r})}function Mg(i){const{path:c,fileURL:r,onRendered:f}=i,{data:d,error:m}=pe({queryKey:["text",r],queryFn:async()=>{const g=await fetch(r);if(!g.ok)throw new Error(await g.text());return g.text()}});return Q.useEffect(()=>{d!=null&&f?.()},[d,f]),m?o.jsxs("div",{className:"empty",children:["Could not load file: ",m.message]}):d==null?null:o.jsx("pre",{className:"plain",children:d},c)}function Ag(i,c,r){const f=i.toLowerCase(),d=c.find(m=>m.path.toLowerCase()===f||m.path.toLowerCase()===f+".md")||c.find(m=>{const g=m.name.toLowerCase();return g===f||g===f+".md"});d&&r(d.path)}function Cg({url:i,copied:c,onClose:r}){const f=i.split("/s/")[1];return Q.useEffect(()=>{const d=m=>{m.key==="Escape"&&r()};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[r]),o.jsx("div",{className:"modal-back",onClick:d=>d.target===d.currentTarget&&r(),children:o.jsxs("div",{className:"modal",children:[o.jsx("h3",{children:"Public link created"}),o.jsxs("p",{children:[o.jsx("b",{children:"Anyone with this link can view this file"})," — no account needed. It always shows the latest version until you revoke it."]}),o.jsx("div",{className:"modal-url",children:i}),o.jsxs("div",{className:"modal-actions",children:[o.jsx("button",{className:"pbtn",onClick:()=>Wn(i).then(d=>st(d?"Copied.":"Select and copy the link above.")),children:c?"Copied ✓":"Copy link"}),o.jsx("button",{className:"ai-btn",onClick:()=>window.open(i,"_blank"),children:"Open"}),o.jsx("button",{className:"ai-del",onClick:async()=>{try{await Yl("DELETE","/api/shares/"+f),st("Link revoked — it no longer works."),r()}catch(d){st(d.message,!0)}},children:"Revoke"}),o.jsx("button",{className:"ai-btn",onClick:r,children:"Done"})]})]})})}function Xh(i,c){if(!i)return{score:0,hits:[]};const r=i.toLowerCase(),f=c.toLowerCase();let d=0,m=0,g=0;const A=[];for(let p=0;p3&&f.endsWith("ies")?d=f.slice(0,-3)+"y":f.length>3&&f.endsWith("es")?d=f.slice(0,-2):f.length>2&&f.endsWith("s")&&(d=f.slice(0,-1)),d?Xh(d,c):null}function _g({text:i,hits:c}){const r=[];let f=0;return c.forEach((d,m)=>{d>f&&r.push(i.slice(f,d)),r.push(o.jsx("b",{children:i[d]},m)),f=d+1}),r.push(i.slice(f)),o.jsx("span",{className:"plabel",children:r})}function Dg({open:i,onClose:c,candidates:r}){const[f,d]=Q.useState(""),[m,g]=Q.useState(0),A=Q.useRef(null),p=Q.useRef(null),y=Q.useMemo(()=>{if(!i)return[];const E=[];for(const x of r()){const q=zg(f,x.label);q&&E.push({...x,score:q.score,hits:q.hits})}return E.sort((x,q)=>q.score-x.score),E.slice(0,40)},[i,f,r]);Q.useEffect(()=>{i&&(d(""),g(0),A.current?.focus())},[i]),Q.useEffect(()=>g(0),[f]),Q.useEffect(()=>{p.current?.children[m]?.scrollIntoView({block:"nearest"})},[m,y]);const M=E=>{c(),E.run()};return Q.useEffect(()=>{if(!i)return;const E=x=>{if(x.key==="Escape")x.preventDefault(),c();else if(x.key==="ArrowDown"||x.key==="ArrowUp"){x.preventDefault();const q=y.length;q&&g(z=>(z+(x.key==="ArrowDown"?1:q-1))%q)}else x.key==="Enter"&&(x.preventDefault(),y[m]&&M(y[m]))};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[i,y,m]),i?o.jsx("div",{id:"palette-overlay",onClick:E=>E.target===E.currentTarget&&c(),children:o.jsxs("div",{id:"palette",role:"dialog","aria-label":"Search and quick actions",children:[o.jsxs("div",{id:"palette-inputwrap",children:[o.jsx(Kt,{name:"search"}),o.jsx("input",{id:"palette-input",type:"text",placeholder:"Search file names, projects, actions…",autoComplete:"off",spellCheck:!1,ref:A,value:f,onChange:E=>d(E.target.value)})]}),o.jsx("ul",{id:"palette-results",ref:p,children:y.length===0?o.jsx("li",{className:"pempty",children:"No matches — search covers file names, projects, and actions"}):y.map((E,x)=>o.jsxs("li",{className:x===m?"selected":void 0,onClick:()=>M(E),onMouseMove:()=>m!==x&&g(x),children:[o.jsx("span",{className:"picon",children:o.jsx(Kt,{name:E.icon})}),o.jsx(_g,{text:E.label,hits:E.hits}),o.jsx("span",{className:"pkind",children:E.kind})]},E.kind+":"+E.label))}),o.jsx("footer",{id:"palette-hint",children:"↑↓ navigate · ⏎ select · esc close"})]})}):null}const Zn=3,Va=30;function Rg(i,c){return pe({queryKey:["heatDevices",i],queryFn:()=>Ae(i+"heat?by=device&days=30"),enabled:c,retry:!1,staleTime:6e4}).data?.devices??null}function Kh(i){const[c,r]=Q.useState("all"),{flatFiles:f,heatMap:d,devices:m,scope:g}=i,A=x=>!g||x===g||x.startsWith(g+"/"),p=g?f.filter(x=>A(x.path)):f,y=m&&g?m.map(x=>{const q={};for(const[z,w]of Object.entries(x.folders||{}))A(z)&&(q[z]=w);return{...x,folders:q}}).filter(x=>Object.keys(x.folders).length>0):m,M=Date.now(),E=p.map(x=>{const q=d&&d[x.path]||{},z=x.time?Math.max(0,(M-new Date(x.time).getTime())/864e5):0,w=c==="all"?In(q):q[c]||0;return{path:x.path,reads:w,agent:q.agent||0,total:In(q),days:z,danger:w>=Zn&&z>=Va}});return o.jsxs("div",{className:"insights",children:[o.jsxs("h1",{className:"in-title",children:["Knowledge insights",g?o.jsxs("span",{className:"in-scope",children:[" · ",g]}):null]}),o.jsx("p",{className:"dl-sub",children:g?`Reads over the last 30 days × freshness, for ${g} and everything in it.`:"Reads over the last 30 days × how long since each file changed. Hot but stale knowledge — read a lot, maintained by nobody — is the danger zone."}),o.jsx("div",{className:"in-lens",children:["all","human","agent"].map(x=>o.jsx("button",{className:"in-lens-btn"+(x===c?" active":""),onClick:()=>r(x),children:x==="all"?"All reads":x==="human"?"Human reads":"Agent reads"},x))}),o.jsx("h3",{className:"dl-h3",children:"Map — cell size = reads, color = freshness"}),o.jsx(Hg,{pts:E,onOpenFile:i.onOpenFile,onOpenFolder:i.onOpenFolder,isFolder:i.isFolder}),o.jsx("h3",{className:"dl-h3",children:"Reads × freshness"}),o.jsx(qg,{pts:E,onOpenFile:i.onOpenFile}),o.jsx("h3",{className:"dl-h3",children:"Hot path — top files by reads"}),o.jsx(wg,{pts:E,lens:c,onOpenFile:i.onOpenFile}),y&&y.length>0&&o.jsxs(o.Fragment,{children:[o.jsx("h3",{className:"dl-h3",children:"Agent coverage — which agents read which areas"}),o.jsx(Qg,{devices:y})]})]})}function Ug(i){const c=[[76,195,138],[232,196,84],[224,93,93]],r=Math.min(1,Math.max(0,i/300))*(c.length-1),f=Math.min(c.length-2,Math.floor(r)),d=r-f,m=c[f].map((g,A)=>Math.round(g+(c[f+1][A]-g)*d));return`rgb(${m[0]},${m[1]},${m[2]})`}function Zh(i,c,r,f,d){const m=i.reduce((y,M)=>y+M.value,0);if(!m||f<=0||d<=0)return[];const g=i.slice().sort((y,M)=>M.value-y.value).map(y=>({it:y,a:y.value/m*f*d})),A=(y,M)=>{const x=y.reduce((z,w)=>z+w.a,0)/M;let q=0;for(const z of y){const w=z.a/x;q=Math.max(q,w/x,x/w)}return q},p=[];for(;g.length;){const y=f>=d,M=y?d:f,E=[g.shift()];for(;g.length&&A(E.concat(g[0]),M)<=A(E,M);)E.push(g.shift());const x=E.reduce((z,w)=>z+w.a,0)/M;let q=0;for(const z of E){const w=z.a/x;y?p.push({item:z.it,x:c,y:r+q,w:x,h:w}):p.push({item:z.it,x:c+q,y:r,w,h:x}),q+=w}y?(c+=x,f-=x):(r+=x,d-=x)}return p}const Fs=15;function Hg({pts:i,onOpenFile:c,onOpenFolder:r,isFolder:f}){const g=new Map;for(const p of i){const y=p.path.includes("/")?p.path.split("/")[0]:"/";let M=g.get(y);M||g.set(y,M={name:y,files:[],value:0}),M.files.push(p),M.value+=p.reads+1}const A=[];for(const p of Zh([...g.values()],0,0,720,480)){const y=p.item,M=y.name==="/"?"":y.name;if(A.push(o.jsx("rect",{x:p.x+1,y:p.y+1,width:Math.max(0,p.w-2),height:Math.max(0,p.h-2),rx:3,className:"in-tm-group","data-dir":M},"g"+y.name)),p.w>46&&p.h>Fs+10){let x=y.name==="/"?"(root)":y.name;const q=Math.floor((p.w-8)/6);x.length>q&&(x=x.slice(0,Math.max(1,q-1))+"…"),A.push(o.jsx("text",{x:p.x+5,y:p.y+12,className:"in-tm-glabel","data-dir":M,children:x},"gl"+y.name))}const E=Zh(y.files.map(x=>({...x,name:x.path.split("/").pop(),value:x.reads+1})),p.x+2,p.y+Fs,Math.max(0,p.w-4),Math.max(0,p.h-Fs-2));for(const x of E)if(A.push(o.jsx("rect",{x:x.x+.6,y:x.y+.6,width:Math.max(.4,x.w-1.2),height:Math.max(.4,x.h-1.2),rx:1.5,fill:Ug(x.item.days),className:"in-tm-cell","data-path":x.item.path,children:o.jsx("title",{children:`${x.item.path} — ${x.item.reads} read${x.item.reads===1?"":"s"}/30d · changed ${Math.round(x.item.days)}d ago`})},x.item.path)),x.w>54&&x.h>16){const q=Math.floor((x.w-8)/6);let z=(x.item.danger?"⚠ ":"")+x.item.name;z.length>q&&(z=z.slice(0,Math.max(1,q-1))+"…"),q>=5&&A.push(o.jsx("text",{x:x.x+4.5,y:x.y+12.5,className:"in-tm-label","data-path":x.item.path,children:z},"l"+x.item.path))}}return o.jsx("svg",{viewBox:"0 0 720 480",className:"in-chart in-treemap",onClick:p=>{const y=p.target.closest("[data-path], [data-dir]");if(!y)return;const M=y.getAttribute("data-path");if(M)return c(M);const E=y.getAttribute("data-dir");E&&f(E)&&r(E)},children:A})}function qg({pts:i,onOpenFile:c}){const d={l:44,r:16,t:20,b:34},m=Math.max(Va*2,...i.map(E=>E.days)),g=Math.max(Zn*2,...i.map(E=>E.reads)),A=E=>Math.log10(E+1)/Math.log10(m+1),p=E=>Math.log10(E+1)/Math.log10(g+1),y=E=>d.l+A(E)*(720-d.l-d.r),M=E=>360-d.b-p(E)*(360-d.t-d.b);return o.jsxs("svg",{viewBox:"0 0 720 360",className:"in-chart",children:[o.jsx("rect",{x:y(Va),y:d.t,width:720-d.r-y(Va),height:M(Zn)-d.t,className:"in-danger-zone"}),o.jsx("line",{x1:y(Va),y1:d.t,x2:y(Va),y2:360-d.b,className:"in-threshold"}),o.jsx("line",{x1:d.l,y1:M(Zn),x2:720-d.r,y2:M(Zn),className:"in-threshold"}),o.jsx("line",{x1:d.l,y1:360-d.b,x2:720-d.r,y2:360-d.b,className:"in-axis"}),o.jsx("line",{x1:d.l,y1:d.t,x2:d.l,y2:360-d.b,className:"in-axis"}),o.jsx("text",{x:(d.l+720-d.r)/2,y:352,className:"in-label",children:"days since last change →"}),o.jsx("text",{x:12,y:(d.t+360-d.b)/2,className:"in-label",transform:`rotate(-90 12 ${(d.t+360-d.b)/2})`,children:"reads / 30d →"}),o.jsx("text",{x:720-d.r-6,y:d.t+14,className:"in-quad in-quad-danger",textAnchor:"end",children:"hot + stale"}),o.jsx("text",{x:d.l+6,y:d.t+14,className:"in-quad",children:"hot + fresh"}),o.jsx("text",{x:720-d.r-6,y:360-d.b-8,className:"in-quad",textAnchor:"end",children:"cold + stale"}),o.jsx("text",{x:720-d.r-6,y:d.t+28,className:"in-label",textAnchor:"end",children:"dot size = agent share of reads"}),i.map(E=>{const x=E.total?(E.agent||0)/E.total:0;return o.jsx("circle",{cx:Number(y(E.days).toFixed(1)),cy:Number(M(E.reads).toFixed(1)),r:Number((3+4*x).toFixed(1)),className:"in-pt"+(E.danger?" danger":E.reads?"":" cold"),onClick:()=>c(E.path),children:o.jsx("title",{children:`${E.path} — ${E.reads} read${E.reads===1?"":"s"} / 30d · changed ${Math.round(E.days)}d ago`})},E.path)})]})}function wg({pts:i,lens:c,onOpenFile:r}){const f=i.filter(m=>m.reads>0).sort((m,g)=>g.reads-m.reads||g.days-m.days).slice(0,20);if(!f.length)return o.jsx("div",{className:"dl-empty",children:"No reads in the window yet."});const d=f[0].reads;return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"in-hotpath",children:f.map(m=>{const g=c==="agent"?1:c==="human"?0:m.total?m.agent/m.total:0,A=m.reads/d*100;return o.jsxs("div",{className:"in-hp-row",tabIndex:0,role:"button",title:m.danger?`${m.reads} read${m.reads===1?"":"s"}/30d · unchanged ${Math.round(m.days)}d — review this file`:m.path,onClick:()=>r(m.path),onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),r(m.path))},children:[o.jsx("span",{className:"in-hp-name"+(m.danger?" danger":""),children:m.path+(m.danger?" ⚠":"")}),o.jsxs("span",{className:"in-hp-bar",children:[o.jsx("span",{className:"in-hp-agent",style:{width:(A*g).toFixed(1)+"%"}}),o.jsx("span",{className:"in-hp-human",style:{width:(A*(1-g)).toFixed(1)+"%"}})]}),o.jsx("span",{className:"in-hp-count",children:m.reads})]},m.path)})}),o.jsxs("p",{className:"in-legend",children:[o.jsx("span",{className:"in-sw agent"})," agent reads ",o.jsx("span",{className:"in-sw human"})," human reads"]})]})}function Qg({devices:i}){const c=new Map;for(const x of i)for(const[q,z]of Object.entries(x.folders||{}))c.set(q,(c.get(q)||0)+z);const r=[...c.entries()].sort((x,q)=>q[1]-x[1]).slice(0,12).map(x=>x[0]),f=i.slice(0,12),d=140,m=6,g=Math.min(76,Math.max(34,(720-d-8)/r.length)),A=26,p=720,y=m+f.length*A+58,M=Math.max(1,...f.flatMap(x=>r.map(q=>(x.folders||{})[q]||0))),E=x=>{const q=[23,25,31],z=[245,166,35],w=q.map((Y,F)=>Math.round(Y+(z[F]-Y)*x));return`rgb(${w[0]},${w[1]},${w[2]})`};return o.jsxs("svg",{viewBox:`0 0 ${p} ${y}`,className:"in-chart in-matrix",children:[f.map((x,q)=>{let z=x.name||x.id||"";return z.length>20&&(z=z.slice(0,19)+"…"),o.jsxs("g",{children:[o.jsx("text",{x:d-8,y:m+q*A+17,textAnchor:"end",className:"in-label",children:z}),r.map((w,Y)=>{const F=(x.folders||{})[w]||0;return o.jsx("rect",{x:d+Y*g,y:m+q*A,width:g-4,height:A-4,rx:3,fill:E(Math.sqrt(F/M)),children:o.jsx("title",{children:`${x.name||x.id} × ${w||"(root)"}: ${F} read${F===1?"":"s"}/30d`})},w)})]},x.id||q)}),r.map((x,q)=>{const z=d+q*g+(g-4)/2,w=m+f.length*A+14;return o.jsx("text",{x:z,y:w,className:"in-label",textAnchor:"end",transform:`rotate(-28 ${z} ${w})`,children:x||"(root)"},x)})]})}function Bg(i){const{apiBase:c,target:r,isFolder:f,onMeta:d,onRendered:m}=i,g=r?f(r)?{prefix:r+"/"}:{path:r}:{prefix:""},A="path"in g&&g.path!==void 0?"path="+encodeURIComponent(g.path):"prefix="+encodeURIComponent(g.prefix??""),{data:p,error:y}=pe({queryKey:["history",c,A,200],queryFn:()=>Ae(c+"history?"+A+"&n=200"),staleTime:15e3});if(Q.useEffect(()=>{y&&d("History unavailable: "+y.message)},[y,d]),Q.useEffect(()=>{p&&m?.()},[p,m]),!p)return null;const M=p.entries||[];return o.jsxs("div",{className:"history",children:[M.length===0&&o.jsx("div",{className:"empty",children:"No history yet."}),M.map((E,x)=>o.jsx(pm,{entry:E,onOpen:i.onOpen},x))]})}function Lg(i,c){return i?c(i)?i+"/ (folder)":i:"all changes"}function gm(i){const{config:c,apiBase:r,route:f,hub:d,project:m}=i,g=hr(),A=ti(),{tree:p,flatFiles:y,dirIndex:M,loaded:E}=fg(r,!d||!!m),x=og(r,d&&!!m&&!!c.reads?.enabled),q=d&&!!m&&!f.path&&!f.view,z=!!i.canInsights&&(f.view==="insights"||q),w=Rg(r,z);Q.useEffect(()=>{z&&A.invalidateQueries({queryKey:["heat",r]})},[z,r,A]);const Y=f.path,F=!!Y&&M.has(Y),yt=!!Y&&E&&!F&&y.some(P=>P.path===Y),ot=!!Y&&E&&!F&&!yt,zt=F&&!f.view,[lt,Nt]=Q.useState(()=>new Set),$=Q.useRef(!0);Q.useEffect(()=>{if(!p||!$.current)return;$.current=!1;const P=(p.children||[]).filter(ft=>ft.dir);P.length===1&&Nt(ft=>new Set(ft).add(P[0].path))},[p]),Q.useEffect(()=>{if(!Y||!E)return;Nt(ft=>{const xt=new Set(ft);for(const Fa of vg(Y))xt.add(Fa);return M.has(Y)&&xt.add(Y),xt});const P=document.querySelector(`#tree .row[data-path="${CSS.escape(Y)}"]`);P&&P.scrollIntoView({block:"nearest"})},[Y,E,M]);const gt=Q.useCallback(P=>{Nt(ft=>{const xt=new Set(ft);return xt.has(P)?xt.delete(P):xt.add(P),xt})},[]),wt=Q.useRef(null),ue=Q.useRef(new Map),le=Q.useRef({key:"",want:0,attempts:0});Q.useEffect(()=>{le.current={key:g,want:$p()==="POP"?ue.current.get(g)??0:0,attempts:0}},[g]);const Dt=Q.useCallback(()=>{const P=wt.current,ft=le.current;!P||ft.key!==g||ft.attempts>=3||(ft.attempts++,P.scrollTo({top:ft.want,behavior:"instant"}))},[g]),ce=Q.useCallback(()=>{wt.current&&ue.current.set(g,wt.current.scrollTop)},[g]),Ut=Q.useCallback(P=>{Ke(Fp(P,m?.id)),hl()},[m?.id]),kt=Q.useCallback(P=>Ke(ar("history",m?.id,P)),[m?.id]),[D,B]=Q.useState(""),[k,vt]=Q.useState(null),[dt,S]=Q.useState(!1),[H,L]=Q.useState(!1),G=Q.useRef(null),V=i.panel??null,et=!V&&d&&!!m&&yt,rt=!V&&d&&!!m,Vt=!V&&yt,Rt=!V&&(yt||d&&!!m&&F),Xl=r+"download?path="+encodeURIComponent(Y),ml=Q.useCallback(async()=>{try{const P=await fetch(r+"shares",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:Y})});if(!P.ok)throw new Error(await P.text());const ft=await P.json(),xt=await Wn(ft.url);vt({url:ft.url,copied:xt})}catch(P){st("Share failed: "+P.message,!0)}},[r,Y]),yl=Q.useCallback(()=>{if(!Y)return kt("");kt(F?Y+"/":Y)},[Y,F,kt]);Q.useEffect(()=>{const P=ft=>{(ft.metaKey||ft.ctrlKey)&&ft.key.toLowerCase()==="k"&&(ft.preventDefault(),L(xt=>!xt))};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[]);const ei=Q.useCallback(()=>{const P=[],ft=(xt,Fa,Au,ne)=>P.push({icon:xt,label:Fa,kind:Au,run:ne});if(d&&m&&Y&&(yt&&ft("share","Share: "+Y,"action",ml),ft("hist","History: "+Y,"action",yl),yt&&ft("download","Download: "+Y,"action",()=>G.current?.click())),d&&m&&ft("hist","History: whole project","action",()=>kt("")),d)for(const xt of i.projects||[])(!m||xt.id!==m.id)&&ft("folder","Switch to project: "+xt.name,"project",()=>Ke("/"+xt.id));c.auth?.enabled&&ft("power","Sign out","action",()=>window.location.href="/auth/logout");for(const xt of M.keys())ft("folder",xt,"folder",()=>Ut(xt));for(const xt of y)ft("doc",xt.path,"file",()=>Ut(xt.path));return P},[d,m,Y,yt,c.auth?.enabled,M,y,i.projects,ml,yl,kt,Ut]);Q.useEffect(()=>{if(!dt)return;const P=()=>S(!1);return document.addEventListener("click",P),()=>document.removeEventListener("click",P)},[dt]);const Ce=Q.useCallback(P=>M.has(P),[M]);let Le="markdown",se;V?(Le="view",se=V.body):f.view==="insights"?(Le="view",se=i.canInsights?o.jsx(Kh,{flatFiles:y,heatMap:x,devices:w,scope:f.viewTarget||"",onOpenFile:Ut,onOpenFolder:Ut,isFolder:Ce}):o.jsx("div",{className:"empty",children:"Insights is for hub admins and org owners."})):f.view==="history"?(Le="view",se=o.jsx(Bg,{apiBase:r,target:f.viewTarget||"",isFolder:Ce,onOpen:Ut,onMeta:B,onRendered:Dt})):Y?E?ot?(Le="view",se=o.jsxs("div",{className:"notfound",children:[o.jsx("h1",{children:"Couldn't find that"}),o.jsxs("p",{children:[o.jsx("code",{children:Y})," isn't in this project right now."]}),o.jsx("p",{className:"nf-sub",children:"If it was just created, it may still be uploading or syncing from a teammate's device — this page checks again automatically every few seconds, so refresh or come back in a moment."}),o.jsx("button",{className:"pbtn",onClick:()=>A.invalidateQueries({queryKey:["tree",r]}),children:"Check again"})]})):F?(Le="view",se=o.jsx(Sg,{node:M.get(Y),heatMap:x,hub:d&&!!m,apiBase:r,onOpen:Ut,onFullHistory:kt,onRendered:Dt})):se=o.jsx(jg,{apiBase:r,path:Y,heatMap:x,flatFiles:y,onOpenFile:Ut,onMeta:B,onRendered:Dt}):se=o.jsx("div",{className:"empty",children:"Loading…"}):q?(Le="view",se=o.jsxs(o.Fragment,{children:[o.jsx(ym,{project:m}),i.canInsights&&o.jsx("div",{className:"home-insights",children:o.jsx(Kh,{flatFiles:y,heatMap:x,devices:w,onOpenFile:Ut,onOpenFolder:Ut,isFolder:Ce})})]})):se=o.jsx("div",{className:"empty",children:"Select a file to read it."});const Mu=V?V.crumb:Y?o.jsx(pg,{path:Y,onOpenFolder:Ut}):f.view==="insights"?"Insights — "+(f.viewTarget||m?.name||""):f.view==="history"?"History — "+Lg(f.viewTarget||"",Ce):q?m.name:null,li=o.jsx($n,{crumb:Mu,meta:D,actions:o.jsxs(o.Fragment,{children:[o.jsxs("button",{id:"search-btn",className:"btn ghost",title:"Search (⌘K)",onClick:()=>L(!0),children:[o.jsx(Kt,{name:"search"})," ",o.jsx("span",{className:"lbl",children:"Search"})," ",o.jsx("kbd",{children:"⌘K"})]}),et&&o.jsxs("button",{id:"share-btn",className:"btn",onClick:ml,children:[o.jsx(Kt,{name:"share"})," ",o.jsx("span",{className:"lbl",children:"Share"})]}),rt&&o.jsxs("button",{id:"history-btn",className:"btn",onClick:yl,children:[o.jsx(Kt,{name:"hist"})," ",o.jsx("span",{className:"lbl",children:"History"})]}),Vt&&o.jsxs("a",{id:"download",className:"btn",download:!0,href:Xl,ref:G,children:[o.jsx(Kt,{name:"download"})," ",o.jsx("span",{className:"lbl",children:"Download"})]}),Rt&&o.jsx("button",{id:"more-btn",className:"btn icon-only",title:"More actions","aria-label":"More actions",onClick:P=>{P.stopPropagation(),S(!dt)},children:o.jsx(Kt,{name:"dots"})}),dt&&o.jsxs("div",{id:"more-menu",role:"menu",children:[rt&&o.jsx("button",{className:"more-item",onClick:yl,children:"History"}),Vt&&o.jsx("button",{className:"more-item",onClick:()=>G.current?.click(),children:"Download"}),i.canInsights&&o.jsx("button",{className:"more-item",onClick:()=>{i.onClosePanel?.(),Ke(ar("insights",m?.id,Y))},children:"Insights"})]})]})});return o.jsxs(o.Fragment,{children:[o.jsx(Fn,{vault:i.sidebar.vault,projectsNav:i.sidebar.projectsNav,orgBar:i.sidebar.orgBar,tree:o.jsx(mg,{root:p,expanded:lt,onToggle:gt,currentPath:Y,listingShowing:zt,onOpen:Ut}),topbar:li,contentClass:Le,contentRef:wt,onContentScroll:ce,children:se}),k&&o.jsx(Cg,{url:k.url,copied:k.copied,onClose:()=>vt(null)}),o.jsx(Dg,{open:H,onClose:()=>L(!1),candidates:ei})]})}function Yg({config:i}){const c=hr(),r=sm(),[f,d]=Q.useState(null),[m,g]=Q.useState(null);Q.useEffect(()=>g(null),[c]);const A=Q.useMemo(()=>{const lt=c.match(/^\/join\/([0-9a-f]+)\/?$/);return lt?lt[1]:null},[c]),{data:p}=kp(!A),{data:y}=Vp(!A),M=!!i.auth.admin,{data:E}=cm(M),x=Q.useMemo(()=>fm(c,"hub"),[c]),q=Q.useMemo(()=>p&&(p.find(lt=>lt.id===x.project)||f&&p.find(lt=>lt.org===f)||p[0])||null,[p,x.project,f]);if(Q.useEffect(()=>{document.title=q?q.name+" — BearDrive":i.brand||i.volume||"BearDrive"},[q,i]),A)return o.jsx(Gg,{token:A,onDone:async lt=>{d(lt),await r(),Ke("/",{replace:!0})}});const z=i.brand||i.volume||"BearDrive",w=q&&y?.find(lt=>lt.id===q.org)||null,Y=M||(w?w.role==="owner":!1),F=o.jsx(Ou,{name:z,onHome:()=>Ke("/")}),yt=i.me?o.jsx(ng,{me:i.me,org:w,admin:M?{pending:E?.length||0,onClick:()=>{g({kind:"hub"}),hl()}}:void 0,onOrgSettings:lt=>{g({kind:"org",orgId:lt.id}),hl()}}):void 0;if(!p||!y)return o.jsx(Fn,{vault:F,topbar:o.jsx($n,{}),children:o.jsx("div",{className:"empty",children:"Loading…"})});if(!q)return o.jsx(Fn,{vault:F,projectsNav:o.jsx(Yh,{projects:p}),orgBar:yt,topbar:o.jsx($n,{}),contentClass:"view",children:o.jsx(rg,{authEnabled:i.auth.enabled,onCreate:async lt=>{if(!lt){st("Give the project a name.",!0);return}try{const Nt=await Ja("/api/projects",{name:lt});await r(),Ke("/"+Nt.project.id),st(`Created “${Nt.project.name}”.`)}catch(Nt){st("Could not create the project: "+Nt.message,!0)}}})});const ot=m?.kind==="org"?y.find(lt=>lt.id===m.orgId):null,zt=m?.kind==="hub"?{crumb:"Signup & access",body:o.jsx(ag,{})}:m?.kind==="project"?{crumb:"Project settings",body:o.jsx(ig,{project:q,org:w})}:m?.kind==="install"?{crumb:"Installation",body:o.jsx("div",{className:"onboard",children:o.jsx(ym,{project:q})})}:ot?{crumb:ot.name,body:o.jsx(lg,{org:ot,projects:p,myEmail:i.me?.email||"",onProjectsChanged:r})}:null;return x.project!==q.id?o.jsx(Wp,{to:"/"+q.id}):o.jsx(gm,{config:i,apiBase:"/api/p/"+q.id+"/",route:x,hub:!0,project:q,projects:p,canInsights:Y,sidebar:{vault:F,projectsNav:o.jsx(Yh,{projects:p,currentId:q.id,menu:{active:m?.kind==="project"?"settings":m?.kind==="install"?"install":!m&&x.view==="insights"?"dashboard":null,onDashboard:()=>{g(null),Ke(ar("insights",q.id)),hl()},onInstall:()=>{g({kind:"install"}),hl()},onSettings:()=>{g({kind:"project"}),hl()}}}),orgBar:yt},panel:zt,onClosePanel:()=>g(null)},q.id)}function Gg({token:i,onDone:c}){return Q.useEffect(()=>{let r=!1;return Ja("/api/invites/"+i).then(f=>{r||(st(`Welcome — you joined the “${f.org.name}” team. Opening its projects…`),c(f.org.id))}).catch(f=>{r||String(f.message).includes("signing in")||(st("Could not accept the invite: "+f.message,!0),c(null))}),()=>{r=!0}},[i]),o.jsx(Fn,{vault:o.jsx(Ou,{name:"BearDrive"}),topbar:o.jsx($n,{}),children:o.jsx("div",{className:"empty",children:"Joining…"})})}function Xg({config:i}){const c=hr(),r=i.volume||"BearDrive";Q.useEffect(()=>{document.title=i.brand||r},[i,r]);const f=Q.useMemo(()=>fm(c,"volume"),[c]);return o.jsx(gm,{config:i,apiBase:"/api/",route:f,hub:!1,sidebar:{vault:o.jsx(Ou,{name:r,showSignout:i.auth.enabled})}})}function Kg(){const{data:i}=R0();return o.jsxs(o.Fragment,{children:[i?i.mode==="hub"?o.jsx(Yg,{config:i}):o.jsx(Xg,{config:i}):o.jsx(Fn,{vault:o.jsx(Ou,{name:"…",showSignout:!1}),topbar:o.jsx($n,{}),children:o.jsx("div",{className:"empty",children:"Loading…"})}),o.jsx(Gp,{}),o.jsx(Xp,{})]})}const Zg=new S0({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}});Jv.createRoot(document.getElementById("root")).render(o.jsx(Q.StrictMode,{children:o.jsx(x0,{client:Zg,children:o.jsx(Kg,{})})})); +bdrive init --project `+f},{title:"Connect "+i.label,desc:i.note,code:"bdrive hooks install --agent "+i.hook,extra:i.extra}]}function cg(){try{return localStorage.getItem("bdrive-guide-agent")||"claude"}catch{return"claude"}}function ym({project:i}){const[c,r]=Q.useState(cg),f=Fs.find(d=>d.key===c)||Fs[0];return o.jsxs("div",{className:"guide",children:[o.jsx("h1",{className:"in-title",children:i.name}),o.jsx("p",{className:"dl-sub",children:"Mount this project as a folder on any machine and connect your coding agent: files sync both ways in the background, every change is journaled with who made it, and agent reads feed Insights."}),o.jsx("div",{className:"gd-tabs",children:Fs.map(d=>o.jsx("button",{className:"gd-tab"+(d.key===f.key?" active":""),"data-key":d.key,onClick:()=>{r(d.key);try{localStorage.setItem("bdrive-guide-agent",d.key)}catch{}},children:d.label},d.key))}),o.jsxs("div",{className:"gd-body",children:[ug(f,i).map((d,m)=>o.jsxs("div",{className:"gd-step",children:[o.jsxs("div",{className:"gd-step-head",children:[o.jsx("span",{className:"gd-num",children:m+1}),o.jsx("span",{className:"gd-step-title",children:d.title})]}),d.desc&&o.jsx("p",{className:"gd-desc",children:d.desc}),d.code&&o.jsx(sg,{code:d.code}),d.extra&&o.jsx("p",{className:"gd-desc gd-extra",children:d.extra})]},m)),o.jsx("p",{className:"gd-done",children:"That's it — the folder now syncs on its own. Every agent turn starts from the latest state, edits appear here (and on every teammate's mount) within seconds, and what your agents read shows up in Insights."})]})]})}function sg({code:i}){const[c,r]=Q.useState("Copy");return o.jsxs("pre",{className:"gd-code",children:[o.jsx("code",{children:i}),o.jsx("button",{className:"gd-copy",onClick:async()=>{r(await In(i)?"Copied":"Copy failed"),setTimeout(()=>r("Copy"),1400)},children:c})]})}function rg({authEnabled:i,onCreate:c}){const r=Q.useRef(null),f=Q.useRef(null),d=()=>{const m=r.current.value.trim(),g=m.match(/join\/([0-9a-f]+)/)||m.match(/^([0-9a-f]{8,})$/);if(!g){st("That doesn't look like an invite link.",!0);return}location.href="/join/"+g[1]};return o.jsxs("div",{className:"onboard",children:[o.jsx("h1",{children:"Welcome to BearDrive"}),o.jsx("p",{children:"You're signed in, but you're not part of any project yet."}),i&&o.jsxs("div",{className:"ob-card",children:[o.jsx("h3",{children:"Have an invite link?"}),o.jsx("p",{children:"A teammate can send you a join link. Paste it here:"}),o.jsxs("div",{className:"ob-row",children:[o.jsx("input",{id:"ob-invite",type:"text",placeholder:"https://…/join/…",autoComplete:"off",ref:r}),o.jsx("button",{id:"ob-join",className:"pbtn",onClick:d,children:"Join"})]})]}),o.jsxs("div",{className:"ob-card",children:[o.jsx("h3",{children:"Or start a new project"}),o.jsx("p",{children:"Create a shared space for your team's files."}),o.jsxs("div",{className:"ob-row",children:[o.jsx("input",{id:"ob-name",type:"text",placeholder:"Project name, e.g. wiki",autoComplete:"off",ref:f}),o.jsx("button",{id:"ob-create",className:"pbtn",onClick:()=>c(f.current.value.trim()),children:"Create"})]})]})]})}function fg(i,c=!0){const r=pe({queryKey:["tree",i],queryFn:()=>Ce(i+"tree"),enabled:c,refetchInterval:15e3}),f=Q.useMemo(()=>{const d=[],m=new Map,g=A=>{for(const p of A.children||[])p.dir?(m.set(p.path,p),g(p)):d.push(p)};return r.data&&g(r.data),{flatFiles:d,dirIndex:m}},[r.data]);return{tree:r.data,...f,loaded:!!r.data}}function og(i,c){return pe({queryKey:["heat",i],queryFn:()=>Ce(i+"heat?days=30"),enabled:c,staleTime:6e4,refetchInterval:6e4}).data?.entries??null}function dg(i,c,r){return pe({queryKey:["history",i,"prefix",c,20],queryFn:()=>Ce(i+"history?prefix="+encodeURIComponent(c)+"&n=20"),enabled:r,staleTime:15e3}).data?.entries??null}function Gh(i,c,r){if(!i)return null;if(!r)return i[c]||null;const f={human:0,agent:0,share:0};for(const[d,m]of Object.entries(i))d.startsWith(c+"/")&&(f.human+=m.human||0,f.agent+=m.agent||0,f.share+=m.share||0);return f.human||f.agent||f.share?f:null}function Pn(i){return(i.human||0)+(i.agent||0)+(i.share||0)}function Nu(i){const c=Pn(i);if(!c)return"";let r=c+(c===1?" read":" reads");return i.agent&&(r+=" ("+i.agent+" agent)"),r}function hg(i){const c=Pn(i);return c?c<3?1:c<10?2:c<30?3:4:0}function mg(i){return o.jsx("nav",{id:"tree","aria-label":"Files",children:i.root&&o.jsx(vm,{nodes:i.root.children||[],...i})})}function vm({nodes:i,...c}){return o.jsx("ul",{children:i.map(r=>o.jsx(yg,{node:r,...c},r.path))})}function yg({node:i,...c}){const{expanded:r,onToggle:f,currentPath:d,listingShowing:m,onOpen:g}=c,A=i.dir?r.has(i.path):!1,p=()=>{if(i.dir&&d===i.path&&m){f(i.path);return}g(i.path),i.dir||hl()};return o.jsxs("li",{className:(i.dir?"dir":"file")+(i.dir&&!A?" collapsed":""),children:[o.jsxs("div",{className:"row"+(d===i.path?" active":""),"data-path":i.path,tabIndex:0,role:"button",title:i.name,"aria-expanded":i.dir?A:void 0,onClick:p,onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),p())},children:[o.jsx("span",{className:"chev",onClick:y=>{i.dir&&(y.stopPropagation(),f(i.path))},children:o.jsx(Kt,{name:"chevd"})}),o.jsx("span",{className:"ticon",children:o.jsx(Kt,{name:i.dir?"folder":"doc"})}),o.jsx("span",{className:"label",children:i.name})]}),i.dir&&o.jsx(vm,{nodes:i.children||[],...c})]})}function vg(i){const c=i.split("/"),r=[];let f="";for(let d=0;d{f=f?f+"/"+d:d;const g=f,A=m===r.length-1;return o.jsxs("span",{children:[m>0&&o.jsx("span",{className:"crumb-sep",children:"/"}),A?o.jsx("span",{children:d}):o.jsx("span",{className:"crumb-seg",title:g,onClick:()=>c(g),children:d})]},g)})})}const gg={add:"plus",edit:"edit",delete:"x"},bg={add:"added",edit:"edited",delete:"deleted"};function pm({entry:i,onOpen:c}){const[r,f]=Q.useState(!1),d=i.kind==="put"?"edit":i.kind,m=i.user_name?`${i.user_name} <${i.user}>`:i.user||i.author||"unknown",g=[i.device.name||i.device.id,i.device.os,i.device.ip].filter(Boolean).join(" · "),A=d!=="delete",p=y=>{y.target.tagName!=="A"&&A&&c(i.path)};return o.jsxs("div",{className:"hentry "+d+(A?" clickable":""),tabIndex:A?0:void 0,role:A?"button":void 0,onClick:p,onKeyDown:y=>{A&&(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),c(i.path))},children:[o.jsxs("div",{className:"hline",children:[o.jsx("span",{className:"hkind",children:o.jsx(Kt,{name:gg[d]||"dot"})}),o.jsx("span",{className:"hpath",children:i.path}),o.jsx("span",{className:"htag",children:bg[d]||d}),o.jsx("span",{className:"htime",children:new Date(i.time).toLocaleString()})]}),o.jsxs("div",{className:"hmeta",children:[o.jsx("span",{className:"hwho",children:m}),o.jsx("span",{className:"hdev",children:g}),o.jsx("span",{className:"hsize",children:i.size?dm(i.size):""})]}),i.note&&o.jsx("div",{className:"hnote"+(r?" open":""),tabIndex:0,role:"button",title:r?"Collapse note":"Show full note","aria-expanded":r,onClick:y=>{y.stopPropagation(),y.target.tagName!=="A"&&f(!r)},onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),y.stopPropagation(),f(!r))},children:i.note.split(/(https?:\/\/\S+)/).map((y,M)=>/^https?:\/\//.test(y)?o.jsx("a",{href:y,target:"_blank",rel:"noopener",children:y},M):y)})]})}function Sg(i){const{node:c,heatMap:r,onOpen:f}=i,d=(c.children||[]).slice().sort((y,M)=>Number(M.dir||!1)-Number(y.dir||!1)||y.name.localeCompare(M.name)),m=d.filter(y=>y.dir).length,g=d.length-m,A=[];m&&A.push(m+(m===1?" folder":" folders")),g&&A.push(g+(g===1?" file":" files"));const p=Gh(r,c.path,!0);return p&&A.push(Nu(p)+" in 30 days"),o.jsxs("div",{className:"dirlist",children:[o.jsxs("h1",{className:"dl-title",children:[o.jsx("span",{className:"dl-title-icon",children:o.jsx(Kt,{name:"folder"})}),o.jsx("span",{children:c.name})]}),o.jsx("p",{className:"dl-sub",children:A.join(" · ")||"Empty folder"}),d.length===0?o.jsx("div",{className:"dl-empty",children:"Nothing in this folder yet."}):o.jsx("div",{className:"dl-items",children:d.map(y=>{let M="";if(y.dir){const x=(y.children||[]).length;M=x+(x===1?" item":" items")}else M=[y.size?dm(y.size):"",y.time?new Date(y.time).toLocaleDateString():""].filter(Boolean).join(" · ");const E=Gh(r,y.path,!!y.dir);return E&&(M=Nu(E)+(M?" · "+M:"")),o.jsxs("div",{className:"dl-row",tabIndex:0,role:"button",title:y.path,onClick:()=>f(y.path),onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),f(y.path))},children:[o.jsx("span",{className:"ticon",children:o.jsx(Kt,{name:y.dir?"folder":"doc"})}),o.jsx("span",{className:"dl-name",children:y.name}),E&&o.jsx("span",{className:"heatdot lvl"+hg(E),title:Nu(E)+" in 30 days"}),o.jsx("span",{className:"dl-meta",children:M})]},y.path)})}),i.hub&&o.jsx(xg,{apiBase:i.apiBase,prefix:c.path+"/",onOpen:f,onFullHistory:()=>i.onFullHistory(c.path+"/"),onRendered:i.onRendered})]})}function xg(i){const c=dg(i.apiBase,i.prefix,!0),{onRendered:r}=i;return Q.useEffect(()=>{c&&c.length&&r&&r()},[c,r]),!c||c.length===0?null:o.jsxs("div",{className:"dl-history",children:[o.jsx("h3",{className:"dl-h3",children:"Recent changes"}),o.jsx("div",{className:"history dl-hlist",children:c.map((f,d)=>o.jsx(pm,{entry:f,onOpen:i.onOpen},d))}),o.jsx("button",{className:"ai-btn dl-more",onClick:i.onFullHistory,children:"Full history"})]})}function jg(i){const{apiBase:c,path:r,onMeta:f}=i,d=c+"file?path="+encodeURIComponent(r);return Q.useEffect(()=>()=>f(""),[r,f]),Ip.test(r)?o.jsx(Eg,{...i}):tg.test(r)?o.jsx("iframe",{className:"htmlview",sandbox:"allow-scripts",src:d,title:r,onLoad:i.onRendered}):Pp.test(r)?o.jsx(Og,{src:d,alt:r,onRendered:i.onRendered}):eg.test(r)?o.jsx(Mg,{...i,fileURL:d}):o.jsxs("div",{className:"filecard",children:[o.jsx("div",{className:"name",children:r.split("/").pop()}),o.jsx("p",{children:"No preview for this file type."}),o.jsx("a",{className:"btn",download:!0,href:c+"download?path="+encodeURIComponent(r),children:"Download"})]})}function Eg(i){const{apiBase:c,path:r,heatMap:f,flatFiles:d,onOpenFile:m,onMeta:g,onRendered:A}=i,{data:p,error:y}=pe({queryKey:["render",c,r],queryFn:()=>Ce(c+"render?path="+encodeURIComponent(r))}),M=Q.useMemo(()=>p?Ng(p.html,r,c):"",[p,r,c]);return Q.useEffect(()=>{if(!p)return;const E=[];p.author&&E.push(p.author+(p.device?" on "+p.device:"")),p.time&&E.push(new Date(p.time).toLocaleString());const x=f&&f[p.path];x&&Pn(x)&&E.push(Nu(x)+" / 30d"),g(E.join(" · ")),A?.()},[p,f,g,A]),y?o.jsxs("div",{className:"empty",children:["Could not load file: ",y.message]}):p?o.jsx("div",{dangerouslySetInnerHTML:{__html:M},onClick:E=>Tg(E,r,d,m)}):null}function Tg(i,c,r,f){const d=i.target.closest("a");if(!d||!i.currentTarget.contains(d))return;const m=d.getAttribute("href")||"",g=c.includes("/")?c.slice(0,c.lastIndexOf("/")):"";m.startsWith("wiki:")?(i.preventDefault(),Ag(decodeURIComponent(m.slice(5)),r,f)):/^([a-z]+:|\/|#)/i.test(m)||(i.preventDefault(),f(hm(g,decodeURIComponent(m))))}function Ng(i,c,r){const f=c.includes("/")?c.slice(0,c.lastIndexOf("/")):"",d=g=>r+"file?path="+encodeURIComponent(g),m=new DOMParser().parseFromString(i,"text/html");for(const g of m.querySelectorAll("img")){const A=g.getAttribute("src")||"";/^([a-z]+:|\/)/i.test(A)||g.setAttribute("src",d(hm(f,A)))}for(const g of m.querySelectorAll("a")){const A=g.getAttribute("href")||"";/^https?:/i.test(A)&&(g.setAttribute("target","_blank"),g.setAttribute("rel","noopener"))}return m.body.innerHTML}function Og({src:i,alt:c,onRendered:r}){return o.jsx("img",{src:i,alt:c,onLoad:r})}function Mg(i){const{path:c,fileURL:r,onRendered:f}=i,{data:d,error:m}=pe({queryKey:["text",r],queryFn:async()=>{const g=await fetch(r);if(!g.ok)throw new Error(await g.text());return g.text()}});return Q.useEffect(()=>{d!=null&&f?.()},[d,f]),m?o.jsxs("div",{className:"empty",children:["Could not load file: ",m.message]}):d==null?null:o.jsx("pre",{className:"plain",children:d},c)}function Ag(i,c,r){const f=i.toLowerCase(),d=c.find(m=>m.path.toLowerCase()===f||m.path.toLowerCase()===f+".md")||c.find(m=>{const g=m.name.toLowerCase();return g===f||g===f+".md"});d&&r(d.path)}function Cg({url:i,copied:c,onClose:r}){const f=i.split("/s/")[1];return Q.useEffect(()=>{const d=m=>{m.key==="Escape"&&r()};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[r]),o.jsx("div",{className:"modal-back",onClick:d=>d.target===d.currentTarget&&r(),children:o.jsxs("div",{className:"modal",children:[o.jsx("h3",{children:"Public link created"}),o.jsxs("p",{children:[o.jsx("b",{children:"Anyone with this link can view this file"})," — no account needed. It always shows the latest version until you revoke it."]}),o.jsx("div",{className:"modal-url",children:i}),o.jsxs("div",{className:"modal-actions",children:[o.jsx("button",{className:"pbtn",onClick:()=>In(i).then(d=>st(d?"Copied.":"Select and copy the link above.")),children:c?"Copied ✓":"Copy link"}),o.jsx("button",{className:"ai-btn",onClick:()=>window.open(i,"_blank"),children:"Open"}),o.jsx("button",{className:"ai-del",onClick:async()=>{try{await Yl("DELETE","/api/shares/"+f),st("Link revoked — it no longer works."),r()}catch(d){st(d.message,!0)}},children:"Revoke"}),o.jsx("button",{className:"ai-btn",onClick:r,children:"Done"})]})]})})}function Xh(i,c){if(!i)return{score:0,hits:[]};const r=i.toLowerCase(),f=c.toLowerCase();let d=0,m=0,g=0;const A=[];for(let p=0;p3&&f.endsWith("ies")?d=f.slice(0,-3)+"y":f.length>3&&f.endsWith("es")?d=f.slice(0,-2):f.length>2&&f.endsWith("s")&&(d=f.slice(0,-1)),d?Xh(d,c):null}function _g({text:i,hits:c}){const r=[];let f=0;return c.forEach((d,m)=>{d>f&&r.push(i.slice(f,d)),r.push(o.jsx("b",{children:i[d]},m)),f=d+1}),r.push(i.slice(f)),o.jsx("span",{className:"plabel",children:r})}function Dg({open:i,onClose:c,candidates:r}){const[f,d]=Q.useState(""),[m,g]=Q.useState(0),A=Q.useRef(null),p=Q.useRef(null),y=Q.useMemo(()=>{if(!i)return[];const E=[];for(const x of r()){const q=zg(f,x.label);q&&E.push({...x,score:q.score,hits:q.hits})}return E.sort((x,q)=>q.score-x.score),E.slice(0,40)},[i,f,r]);Q.useEffect(()=>{i&&(d(""),g(0),A.current?.focus())},[i]),Q.useEffect(()=>g(0),[f]),Q.useEffect(()=>{p.current?.children[m]?.scrollIntoView({block:"nearest"})},[m,y]);const M=E=>{c(),E.run()};return Q.useEffect(()=>{if(!i)return;const E=x=>{if(x.key==="Escape")x.preventDefault(),c();else if(x.key==="ArrowDown"||x.key==="ArrowUp"){x.preventDefault();const q=y.length;q&&g(z=>(z+(x.key==="ArrowDown"?1:q-1))%q)}else x.key==="Enter"&&(x.preventDefault(),y[m]&&M(y[m]))};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[i,y,m]),i?o.jsx("div",{id:"palette-overlay",onClick:E=>E.target===E.currentTarget&&c(),children:o.jsxs("div",{id:"palette",role:"dialog","aria-label":"Search and quick actions",children:[o.jsxs("div",{id:"palette-inputwrap",children:[o.jsx(Kt,{name:"search"}),o.jsx("input",{id:"palette-input",type:"text",placeholder:"Search file names, projects, actions…",autoComplete:"off",spellCheck:!1,ref:A,value:f,onChange:E=>d(E.target.value)})]}),o.jsx("ul",{id:"palette-results",ref:p,children:y.length===0?o.jsx("li",{className:"pempty",children:"No matches — search covers file names, projects, and actions"}):y.map((E,x)=>o.jsxs("li",{className:x===m?"selected":void 0,onClick:()=>M(E),onMouseMove:()=>m!==x&&g(x),children:[o.jsx("span",{className:"picon",children:o.jsx(Kt,{name:E.icon})}),o.jsx(_g,{text:E.label,hits:E.hits}),o.jsx("span",{className:"pkind",children:E.kind})]},E.kind+":"+E.label))}),o.jsx("footer",{id:"palette-hint",children:"↑↓ navigate · ⏎ select · esc close"})]})}):null}const Zn=3,Va=30;function Rg(i,c){return pe({queryKey:["heatDevices",i],queryFn:()=>Ce(i+"heat?by=device&days=30"),enabled:c,retry:!1,staleTime:6e4}).data?.devices??null}function Kh(i){const[c,r]=Q.useState("all"),{flatFiles:f,heatMap:d,devices:m,scope:g}=i,A=x=>!g||x===g||x.startsWith(g+"/"),p=g?f.filter(x=>A(x.path)):f,y=m&&g?m.map(x=>{const q={};for(const[z,w]of Object.entries(x.folders||{}))A(z)&&(q[z]=w);return{...x,folders:q}}).filter(x=>Object.keys(x.folders).length>0):m,M=Date.now(),E=p.map(x=>{const q=d&&d[x.path]||{},z=x.time?Math.max(0,(M-new Date(x.time).getTime())/864e5):0,w=c==="all"?Pn(q):q[c]||0;return{path:x.path,reads:w,agent:q.agent||0,total:Pn(q),days:z,danger:w>=Zn&&z>=Va}});return o.jsxs("div",{className:"insights",children:[o.jsxs("h1",{className:"in-title",children:["Knowledge insights",g?o.jsxs("span",{className:"in-scope",children:[" · ",g]}):null]}),o.jsx("p",{className:"dl-sub",children:g?`Reads over the last 30 days × freshness, for ${g} and everything in it.`:"Reads over the last 30 days × how long since each file changed. Hot but stale knowledge — read a lot, maintained by nobody — is the danger zone."}),o.jsx("div",{className:"in-lens",children:["all","human","agent"].map(x=>o.jsx("button",{className:"in-lens-btn"+(x===c?" active":""),onClick:()=>r(x),children:x==="all"?"All reads":x==="human"?"Human reads":"Agent reads"},x))}),o.jsx("h3",{className:"dl-h3",children:"Map — cell size = reads, color = freshness"}),o.jsx(Hg,{pts:E,onOpenFile:i.onOpenFile,onOpenFolder:i.onOpenFolder,isFolder:i.isFolder}),o.jsx("h3",{className:"dl-h3",children:"Reads × freshness"}),o.jsx(qg,{pts:E,onOpenFile:i.onOpenFile}),o.jsx("h3",{className:"dl-h3",children:"Hot path — top files by reads"}),o.jsx(wg,{pts:E,lens:c,onOpenFile:i.onOpenFile}),y&&y.length>0&&o.jsxs(o.Fragment,{children:[o.jsx("h3",{className:"dl-h3",children:"Agent coverage — which agents read which areas"}),o.jsx(Qg,{devices:y})]})]})}function Ug(i){const c=[[76,195,138],[232,196,84],[224,93,93]],r=Math.min(1,Math.max(0,i/300))*(c.length-1),f=Math.min(c.length-2,Math.floor(r)),d=r-f,m=c[f].map((g,A)=>Math.round(g+(c[f+1][A]-g)*d));return`rgb(${m[0]},${m[1]},${m[2]})`}function Zh(i,c,r,f,d){const m=i.reduce((y,M)=>y+M.value,0);if(!m||f<=0||d<=0)return[];const g=i.slice().sort((y,M)=>M.value-y.value).map(y=>({it:y,a:y.value/m*f*d})),A=(y,M)=>{const x=y.reduce((z,w)=>z+w.a,0)/M;let q=0;for(const z of y){const w=z.a/x;q=Math.max(q,w/x,x/w)}return q},p=[];for(;g.length;){const y=f>=d,M=y?d:f,E=[g.shift()];for(;g.length&&A(E.concat(g[0]),M)<=A(E,M);)E.push(g.shift());const x=E.reduce((z,w)=>z+w.a,0)/M;let q=0;for(const z of E){const w=z.a/x;y?p.push({item:z.it,x:c,y:r+q,w:x,h:w}):p.push({item:z.it,x:c+q,y:r,w,h:x}),q+=w}y?(c+=x,f-=x):(r+=x,d-=x)}return p}const $s=15;function Hg({pts:i,onOpenFile:c,onOpenFolder:r,isFolder:f}){const g=new Map;for(const p of i){const y=p.path.includes("/")?p.path.split("/")[0]:"/";let M=g.get(y);M||g.set(y,M={name:y,files:[],value:0}),M.files.push(p),M.value+=p.reads+1}const A=[];for(const p of Zh([...g.values()],0,0,720,480)){const y=p.item,M=y.name==="/"?"":y.name;if(A.push(o.jsx("rect",{x:p.x+1,y:p.y+1,width:Math.max(0,p.w-2),height:Math.max(0,p.h-2),rx:3,className:"in-tm-group","data-dir":M},"g"+y.name)),p.w>46&&p.h>$s+10){let x=y.name==="/"?"(root)":y.name;const q=Math.floor((p.w-8)/6);x.length>q&&(x=x.slice(0,Math.max(1,q-1))+"…"),A.push(o.jsx("text",{x:p.x+5,y:p.y+12,className:"in-tm-glabel","data-dir":M,children:x},"gl"+y.name))}const E=Zh(y.files.map(x=>({...x,name:x.path.split("/").pop(),value:x.reads+1})),p.x+2,p.y+$s,Math.max(0,p.w-4),Math.max(0,p.h-$s-2));for(const x of E)if(A.push(o.jsx("rect",{x:x.x+.6,y:x.y+.6,width:Math.max(.4,x.w-1.2),height:Math.max(.4,x.h-1.2),rx:1.5,fill:Ug(x.item.days),className:"in-tm-cell","data-path":x.item.path,children:o.jsx("title",{children:`${x.item.path} — ${x.item.reads} read${x.item.reads===1?"":"s"}/30d · changed ${Math.round(x.item.days)}d ago`})},x.item.path)),x.w>54&&x.h>16){const q=Math.floor((x.w-8)/6);let z=(x.item.danger?"⚠ ":"")+x.item.name;z.length>q&&(z=z.slice(0,Math.max(1,q-1))+"…"),q>=5&&A.push(o.jsx("text",{x:x.x+4.5,y:x.y+12.5,className:"in-tm-label","data-path":x.item.path,children:z},"l"+x.item.path))}}return o.jsx("svg",{viewBox:"0 0 720 480",className:"in-chart in-treemap",onClick:p=>{const y=p.target.closest("[data-path], [data-dir]");if(!y)return;const M=y.getAttribute("data-path");if(M)return c(M);const E=y.getAttribute("data-dir");E&&f(E)&&r(E)},children:A})}function qg({pts:i,onOpenFile:c}){const d={l:44,r:16,t:20,b:34},m=Math.max(Va*2,...i.map(E=>E.days)),g=Math.max(Zn*2,...i.map(E=>E.reads)),A=E=>Math.log10(E+1)/Math.log10(m+1),p=E=>Math.log10(E+1)/Math.log10(g+1),y=E=>d.l+A(E)*(720-d.l-d.r),M=E=>360-d.b-p(E)*(360-d.t-d.b);return o.jsxs("svg",{viewBox:"0 0 720 360",className:"in-chart",children:[o.jsx("rect",{x:y(Va),y:d.t,width:720-d.r-y(Va),height:M(Zn)-d.t,className:"in-danger-zone"}),o.jsx("line",{x1:y(Va),y1:d.t,x2:y(Va),y2:360-d.b,className:"in-threshold"}),o.jsx("line",{x1:d.l,y1:M(Zn),x2:720-d.r,y2:M(Zn),className:"in-threshold"}),o.jsx("line",{x1:d.l,y1:360-d.b,x2:720-d.r,y2:360-d.b,className:"in-axis"}),o.jsx("line",{x1:d.l,y1:d.t,x2:d.l,y2:360-d.b,className:"in-axis"}),o.jsx("text",{x:(d.l+720-d.r)/2,y:352,className:"in-label",children:"days since last change →"}),o.jsx("text",{x:12,y:(d.t+360-d.b)/2,className:"in-label",transform:`rotate(-90 12 ${(d.t+360-d.b)/2})`,children:"reads / 30d →"}),o.jsx("text",{x:720-d.r-6,y:d.t+14,className:"in-quad in-quad-danger",textAnchor:"end",children:"hot + stale"}),o.jsx("text",{x:d.l+6,y:d.t+14,className:"in-quad",children:"hot + fresh"}),o.jsx("text",{x:720-d.r-6,y:360-d.b-8,className:"in-quad",textAnchor:"end",children:"cold + stale"}),o.jsx("text",{x:720-d.r-6,y:d.t+28,className:"in-label",textAnchor:"end",children:"dot size = agent share of reads"}),i.map(E=>{const x=E.total?(E.agent||0)/E.total:0;return o.jsx("circle",{cx:Number(y(E.days).toFixed(1)),cy:Number(M(E.reads).toFixed(1)),r:Number((3+4*x).toFixed(1)),className:"in-pt"+(E.danger?" danger":E.reads?"":" cold"),onClick:()=>c(E.path),children:o.jsx("title",{children:`${E.path} — ${E.reads} read${E.reads===1?"":"s"} / 30d · changed ${Math.round(E.days)}d ago`})},E.path)})]})}function wg({pts:i,lens:c,onOpenFile:r}){const f=i.filter(m=>m.reads>0).sort((m,g)=>g.reads-m.reads||g.days-m.days).slice(0,20);if(!f.length)return o.jsx("div",{className:"dl-empty",children:"No reads in the window yet."});const d=f[0].reads;return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"in-hotpath",children:f.map(m=>{const g=c==="agent"?1:c==="human"?0:m.total?m.agent/m.total:0,A=m.reads/d*100;return o.jsxs("div",{className:"in-hp-row",tabIndex:0,role:"button",title:m.danger?`${m.reads} read${m.reads===1?"":"s"}/30d · unchanged ${Math.round(m.days)}d — review this file`:m.path,onClick:()=>r(m.path),onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),r(m.path))},children:[o.jsx("span",{className:"in-hp-name"+(m.danger?" danger":""),children:m.path+(m.danger?" ⚠":"")}),o.jsxs("span",{className:"in-hp-bar",children:[o.jsx("span",{className:"in-hp-agent",style:{width:(A*g).toFixed(1)+"%"}}),o.jsx("span",{className:"in-hp-human",style:{width:(A*(1-g)).toFixed(1)+"%"}})]}),o.jsx("span",{className:"in-hp-count",children:m.reads})]},m.path)})}),o.jsxs("p",{className:"in-legend",children:[o.jsx("span",{className:"in-sw agent"})," agent reads ",o.jsx("span",{className:"in-sw human"})," human reads"]})]})}function Qg({devices:i}){const c=new Map;for(const x of i)for(const[q,z]of Object.entries(x.folders||{}))c.set(q,(c.get(q)||0)+z);const r=[...c.entries()].sort((x,q)=>q[1]-x[1]).slice(0,12).map(x=>x[0]),f=i.slice(0,12),d=140,m=6,g=Math.min(76,Math.max(34,(720-d-8)/r.length)),A=26,p=720,y=m+f.length*A+58,M=Math.max(1,...f.flatMap(x=>r.map(q=>(x.folders||{})[q]||0))),E=x=>{const q=[23,25,31],z=[245,166,35],w=q.map((Y,$)=>Math.round(Y+(z[$]-Y)*x));return`rgb(${w[0]},${w[1]},${w[2]})`};return o.jsxs("svg",{viewBox:`0 0 ${p} ${y}`,className:"in-chart in-matrix",children:[f.map((x,q)=>{let z=x.name||x.id||"";return z.length>20&&(z=z.slice(0,19)+"…"),o.jsxs("g",{children:[o.jsx("text",{x:d-8,y:m+q*A+17,textAnchor:"end",className:"in-label",children:z}),r.map((w,Y)=>{const $=(x.folders||{})[w]||0;return o.jsx("rect",{x:d+Y*g,y:m+q*A,width:g-4,height:A-4,rx:3,fill:E(Math.sqrt($/M)),children:o.jsx("title",{children:`${x.name||x.id} × ${w||"(root)"}: ${$} read${$===1?"":"s"}/30d`})},w)})]},x.id||q)}),r.map((x,q)=>{const z=d+q*g+(g-4)/2,w=m+f.length*A+14;return o.jsx("text",{x:z,y:w,className:"in-label",textAnchor:"end",transform:`rotate(-28 ${z} ${w})`,children:x||"(root)"},x)})]})}function Bg(i){const{apiBase:c,target:r,isFolder:f,onMeta:d,onRendered:m}=i,g=r?f(r)?{prefix:r+"/"}:{path:r}:{prefix:""},A="path"in g&&g.path!==void 0?"path="+encodeURIComponent(g.path):"prefix="+encodeURIComponent(g.prefix??""),{data:p,error:y}=pe({queryKey:["history",c,A,200],queryFn:()=>Ce(c+"history?"+A+"&n=200"),staleTime:15e3});if(Q.useEffect(()=>{y&&d("History unavailable: "+y.message)},[y,d]),Q.useEffect(()=>{p&&m?.()},[p,m]),!p)return null;const M=p.entries||[];return o.jsxs("div",{className:"history",children:[M.length===0&&o.jsx("div",{className:"empty",children:"No history yet."}),M.map((E,x)=>o.jsx(pm,{entry:E,onOpen:i.onOpen},x))]})}function Lg(i,c){return i?c(i)?i+"/ (folder)":i:"all changes"}function gm(i){const{config:c,apiBase:r,route:f,hub:d,project:m}=i,g=hr(),A=ei(),{tree:p,flatFiles:y,dirIndex:M,loaded:E}=fg(r,!d||!!m),x=og(r,d&&!!m&&!!c.reads?.enabled),q=d&&!!m&&!f.path&&!f.view,z=!!i.canInsights&&(f.view==="insights"||q),w=Rg(r,z);Q.useEffect(()=>{z&&A.invalidateQueries({queryKey:["heat",r]})},[z,r,A]);const Y=f.path,$=!!Y&&M.has(Y),yt=!!Y&&E&&!$&&y.some(P=>P.path===Y),ot=!!Y&&E&&!$&&!yt,Ct=$&&!f.view,[Rt,et]=Q.useState(()=>new Set),k=Q.useRef(!0);Q.useEffect(()=>{if(!p||!k.current)return;k.current=!1;const P=(p.children||[]).filter(ft=>ft.dir);P.length===1&&et(ft=>new Set(ft).add(P[0].path))},[p]),Q.useEffect(()=>{if(!Y||!E)return;et(ft=>{const xt=new Set(ft);for(const Fa of vg(Y))xt.add(Fa);return M.has(Y)&&xt.add(Y),xt});const P=document.querySelector(`#tree .row[data-path="${CSS.escape(Y)}"]`);P&&P.scrollIntoView({block:"nearest"})},[Y,E,M]);const gt=Q.useCallback(P=>{et(ft=>{const xt=new Set(ft);return xt.has(P)?xt.delete(P):xt.add(P),xt})},[]),wt=Q.useRef(null),ue=Q.useRef(new Map),le=Q.useRef({key:"",want:0,attempts:0});Q.useEffect(()=>{le.current={key:g,want:$p()==="POP"?ue.current.get(g)??0:0,attempts:0}},[g]);const _t=Q.useCallback(()=>{const P=wt.current,ft=le.current;!P||ft.key!==g||ft.attempts>=3||(ft.attempts++,P.scrollTo({top:ft.want,behavior:"instant"}))},[g]),ce=Q.useCallback(()=>{wt.current&&ue.current.set(g,wt.current.scrollTop)},[g]),Ut=Q.useCallback(P=>{Ae(Fp(P,m?.id)),hl()},[m?.id]),kt=Q.useCallback(P=>Ae(kn("history",m?.id,P)),[m?.id]),[D,B]=Q.useState(""),[V,vt]=Q.useState(null),[dt,S]=Q.useState(!1),[H,L]=Q.useState(!1),G=Q.useRef(null),J=i.panel??null,lt=!J&&d&&!!m&&yt,rt=!J&&d&&!!m,Vt=!J&&yt,Dt=!J&&(yt||d&&!!m&&$),Xl=r+"download?path="+encodeURIComponent(Y),ml=Q.useCallback(async()=>{try{const P=await fetch(r+"shares",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:Y})});if(!P.ok)throw new Error(await P.text());const ft=await P.json(),xt=await In(ft.url);vt({url:ft.url,copied:xt})}catch(P){st("Share failed: "+P.message,!0)}},[r,Y]),yl=Q.useCallback(()=>{if(!Y)return kt("");kt($?Y+"/":Y)},[Y,$,kt]);Q.useEffect(()=>{const P=ft=>{(ft.metaKey||ft.ctrlKey)&&ft.key.toLowerCase()==="k"&&(ft.preventDefault(),L(xt=>!xt))};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[]);const li=Q.useCallback(()=>{const P=[],ft=(xt,Fa,Cu,ne)=>P.push({icon:xt,label:Fa,kind:Cu,run:ne});if(d&&m&&Y&&(yt&&ft("share","Share: "+Y,"action",ml),ft("hist","History: "+Y,"action",yl),yt&&ft("download","Download: "+Y,"action",()=>G.current?.click())),d&&m&&ft("hist","History: whole project","action",()=>kt("")),d)for(const xt of i.projects||[])(!m||xt.id!==m.id)&&ft("folder","Switch to project: "+xt.name,"project",()=>Ae("/"+xt.id));c.auth?.enabled&&ft("power","Sign out","action",()=>window.location.href="/auth/logout");for(const xt of M.keys())ft("folder",xt,"folder",()=>Ut(xt));for(const xt of y)ft("doc",xt.path,"file",()=>Ut(xt.path));return P},[d,m,Y,yt,c.auth?.enabled,M,y,i.projects,ml,yl,kt,Ut]);Q.useEffect(()=>{if(!dt)return;const P=()=>S(!1);return document.addEventListener("click",P),()=>document.removeEventListener("click",P)},[dt]);const ze=Q.useCallback(P=>M.has(P),[M]);let Ye="markdown",se;J?(Ye="view",se=J.body):f.view==="insights"?(Ye="view",se=i.canInsights?o.jsx(Kh,{flatFiles:y,heatMap:x,devices:w,scope:f.viewTarget||"",onOpenFile:Ut,onOpenFolder:Ut,isFolder:ze}):o.jsx("div",{className:"empty",children:"Insights is for hub admins and org owners."})):f.view==="history"?(Ye="view",se=o.jsx(Bg,{apiBase:r,target:f.viewTarget||"",isFolder:ze,onOpen:Ut,onMeta:B,onRendered:_t})):Y?E?ot?(Ye="view",se=o.jsxs("div",{className:"notfound",children:[o.jsx("h1",{children:"Couldn't find that"}),o.jsxs("p",{children:[o.jsx("code",{children:Y})," isn't in this project right now."]}),o.jsx("p",{className:"nf-sub",children:"If it was just created, it may still be uploading or syncing from a teammate's device — this page checks again automatically every few seconds, so refresh or come back in a moment."}),o.jsx("button",{className:"pbtn",onClick:()=>A.invalidateQueries({queryKey:["tree",r]}),children:"Check again"})]})):$?(Ye="view",se=o.jsx(Sg,{node:M.get(Y),heatMap:x,hub:d&&!!m,apiBase:r,onOpen:Ut,onFullHistory:kt,onRendered:_t})):se=o.jsx(jg,{apiBase:r,path:Y,heatMap:x,flatFiles:y,onOpenFile:Ut,onMeta:B,onRendered:_t}):se=o.jsx("div",{className:"empty",children:"Loading…"}):q?(Ye="view",se=o.jsxs(o.Fragment,{children:[o.jsx(ym,{project:m}),i.canInsights&&o.jsx("div",{className:"home-insights",children:o.jsx(Kh,{flatFiles:y,heatMap:x,devices:w,onOpenFile:Ut,onOpenFolder:Ut,isFolder:ze})})]})):se=o.jsx("div",{className:"empty",children:"Select a file to read it."});const Au=J?J.crumb:Y?o.jsx(pg,{path:Y,onOpenFolder:Ut}):f.view==="insights"?"Insights — "+(f.viewTarget||m?.name||""):f.view==="history"?"History — "+Lg(f.viewTarget||"",ze):q?m.name:null,ai=o.jsx(Wn,{crumb:Au,meta:D,actions:o.jsxs(o.Fragment,{children:[o.jsxs("button",{id:"search-btn",className:"btn ghost",title:"Search (⌘K)",onClick:()=>L(!0),children:[o.jsx(Kt,{name:"search"})," ",o.jsx("span",{className:"lbl",children:"Search"})," ",o.jsx("kbd",{children:"⌘K"})]}),lt&&o.jsxs("button",{id:"share-btn",className:"btn",onClick:ml,children:[o.jsx(Kt,{name:"share"})," ",o.jsx("span",{className:"lbl",children:"Share"})]}),rt&&o.jsxs("button",{id:"history-btn",className:"btn",onClick:yl,children:[o.jsx(Kt,{name:"hist"})," ",o.jsx("span",{className:"lbl",children:"History"})]}),Vt&&o.jsxs("a",{id:"download",className:"btn",download:!0,href:Xl,ref:G,children:[o.jsx(Kt,{name:"download"})," ",o.jsx("span",{className:"lbl",children:"Download"})]}),Dt&&o.jsx("button",{id:"more-btn",className:"btn icon-only",title:"More actions","aria-label":"More actions",onClick:P=>{P.stopPropagation(),S(!dt)},children:o.jsx(Kt,{name:"dots"})}),dt&&o.jsxs("div",{id:"more-menu",role:"menu",children:[rt&&o.jsx("button",{className:"more-item",onClick:yl,children:"History"}),Vt&&o.jsx("button",{className:"more-item",onClick:()=>G.current?.click(),children:"Download"}),i.canInsights&&o.jsx("button",{className:"more-item",onClick:()=>{i.onClosePanel?.(),Ae(kn("insights",m?.id,Y))},children:"Insights"})]})]})});return o.jsxs(o.Fragment,{children:[o.jsx($n,{vault:i.sidebar.vault,projectsNav:i.sidebar.projectsNav,orgBar:i.sidebar.orgBar,tree:o.jsx(mg,{root:p,expanded:Rt,onToggle:gt,currentPath:Y,listingShowing:Ct,onOpen:Ut}),topbar:ai,contentClass:Ye,contentRef:wt,onContentScroll:ce,children:se}),V&&o.jsx(Cg,{url:V.url,copied:V.copied,onClose:()=>vt(null)}),o.jsx(Dg,{open:H,onClose:()=>L(!1),candidates:li})]})}function Yg({config:i}){const c=hr(),r=sm(),[f,d]=Q.useState(null),[m,g]=Q.useState(null);Q.useEffect(()=>g(null),[c]);const A=Q.useMemo(()=>{const et=c.match(/^\/join\/([0-9a-f]+)\/?$/);return et?et[1]:null},[c]),{data:p}=kp(!A),{data:y}=Vp(!A),M=!!i.auth.admin,{data:E}=cm(M),x=Q.useMemo(()=>fm(c,"hub"),[c]),q=Q.useMemo(()=>p&&(p.find(et=>et.id===x.project)||f&&p.find(et=>et.org===f)||p[0])||null,[p,x.project,f]);if(Q.useEffect(()=>{document.title=q?q.name+" — BearDrive":i.brand||i.volume||"BearDrive"},[q,i]),A)return o.jsx(Gg,{token:A,onDone:async et=>{d(et),await r(),Ae("/",{replace:!0})}});const z=i.brand||i.volume||"BearDrive",w=q&&y?.find(et=>et.id===q.org)||null,Y=M||(w?w.role==="owner":!1),$=o.jsx(Mu,{name:z,onHome:()=>Ae("/")}),yt=i.me?o.jsx(ng,{me:i.me,org:w,admin:M?{pending:E?.length||0,onClick:()=>{g({kind:"hub"}),hl()}}:void 0,onOrgSettings:et=>{g({kind:"org",orgId:et.id}),hl()}}):void 0;if(!p||!y)return o.jsx($n,{vault:$,topbar:o.jsx(Wn,{}),children:o.jsx("div",{className:"empty",children:"Loading…"})});if(!q)return o.jsx($n,{vault:$,projectsNav:o.jsx(Yh,{projects:p}),orgBar:yt,topbar:o.jsx(Wn,{}),contentClass:"view",children:o.jsx(rg,{authEnabled:i.auth.enabled,onCreate:async et=>{if(!et){st("Give the project a name.",!0);return}try{const k=await Ja("/api/projects",{name:et});await r(),Ae("/"+k.project.id),st(`Created “${k.project.name}”.`)}catch(k){st("Could not create the project: "+k.message,!0)}}})});const ot=m?.kind==="org"?y.find(et=>et.id===m.orgId):null,Ct=m?.kind==="hub"?{crumb:"Signup & access",body:o.jsx(ag,{})}:ot?{crumb:ot.name,body:o.jsx(lg,{org:ot,projects:p,myEmail:i.me?.email||"",onProjectsChanged:r})}:null,Rt=x.view==="settings"?{crumb:"Project settings",body:o.jsx(ig,{project:q,org:w})}:x.view==="install"?{crumb:"Installation",body:o.jsx("div",{className:"onboard",children:o.jsx(ym,{project:q})})}:null;return x.project!==q.id?o.jsx(Wp,{to:"/"+q.id}):o.jsx(gm,{config:i,apiBase:"/api/p/"+q.id+"/",route:x,hub:!0,project:q,projects:p,canInsights:Y,sidebar:{vault:$,projectsNav:o.jsx(Yh,{projects:p,currentId:q.id,menu:{active:m?null:x.view==="insights"?"dashboard":x.view==="install"?"install":x.view==="settings"?"settings":null,onDashboard:()=>{g(null),Ae(kn("insights",q.id)),hl()},onInstall:()=>{g(null),Ae(kn("install",q.id)),hl()},onSettings:()=>{g(null),Ae(kn("settings",q.id)),hl()}}}),orgBar:yt},panel:Ct||Rt,onClosePanel:()=>g(null)},q.id)}function Gg({token:i,onDone:c}){return Q.useEffect(()=>{let r=!1;return Ja("/api/invites/"+i).then(f=>{r||(st(`Welcome — you joined the “${f.org.name}” team. Opening its projects…`),c(f.org.id))}).catch(f=>{r||String(f.message).includes("signing in")||(st("Could not accept the invite: "+f.message,!0),c(null))}),()=>{r=!0}},[i]),o.jsx($n,{vault:o.jsx(Mu,{name:"BearDrive"}),topbar:o.jsx(Wn,{}),children:o.jsx("div",{className:"empty",children:"Joining…"})})}function Xg({config:i}){const c=hr(),r=i.volume||"BearDrive";Q.useEffect(()=>{document.title=i.brand||r},[i,r]);const f=Q.useMemo(()=>fm(c,"volume"),[c]);return o.jsx(gm,{config:i,apiBase:"/api/",route:f,hub:!1,sidebar:{vault:o.jsx(Mu,{name:r,showSignout:i.auth.enabled})}})}function Kg(){const{data:i}=R0();return o.jsxs(o.Fragment,{children:[i?i.mode==="hub"?o.jsx(Yg,{config:i}):o.jsx(Xg,{config:i}):o.jsx($n,{vault:o.jsx(Mu,{name:"…",showSignout:!1}),topbar:o.jsx(Wn,{}),children:o.jsx("div",{className:"empty",children:"Loading…"})}),o.jsx(Gp,{}),o.jsx(Xp,{})]})}const Zg=new S0({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}});Jv.createRoot(document.getElementById("root")).render(o.jsx(Q.StrictMode,{children:o.jsx(x0,{client:Zg,children:o.jsx(Kg,{})})})); diff --git a/internal/webapp/static/index.html b/internal/webapp/static/index.html index ac2f9a9..078a9c1 100644 --- a/internal/webapp/static/index.html +++ b/internal/webapp/static/index.html @@ -5,7 +5,7 @@ BearDrive - +