diff --git a/dashboard/src/main.test.tsx b/dashboard/src/main.test.tsx index 504e8f6..4f647f4 100644 --- a/dashboard/src/main.test.tsx +++ b/dashboard/src/main.test.tsx @@ -781,13 +781,13 @@ describe("MCP access page", () => { expect(screen.queryByText(/mcp-serve/)).not.toBeInTheDocument(); await user.type(screen.getByLabelText("Token name"), "local agent"); - await user.selectOptions(screen.getByLabelText("Owner"), "bob"); + await user.selectOptions(screen.getByLabelText("Lifecycle owner"), "bob"); await user.click(screen.getByRole("button", { name: "Create token" })); expect(onCreate).toHaveBeenCalledWith("local agent", "bob"); expect(screen.getAllByText("@bob").length).toBeGreaterThan(0); expect(await screen.findByText("gab_mcp_secret")).toBeInTheDocument(); - await user.selectOptions(screen.getAllByLabelText("Owner for local agent")[0], "admin"); + await user.selectOptions(screen.getAllByLabelText("Lifecycle owner for local agent")[0], "admin"); expect(onUpdateOwner).toHaveBeenCalledWith("token-1", "admin"); await user.click(screen.getAllByRole("button", { name: "Revoke" })[0]); @@ -841,8 +841,8 @@ describe("MCP access page", () => { />, ); - expect(screen.getByText("Issue and revoke read-only tokens linked to your user.")).toBeInTheDocument(); - expect(screen.queryByLabelText("Owner")).not.toBeInTheDocument(); + expect(screen.getByText("Issue and revoke globally readable knowledge tokens linked to your user.")).toBeInTheDocument(); + expect(screen.queryByLabelText("Lifecycle owner")).not.toBeInTheDocument(); await user.type(screen.getByLabelText("Token name"), "reader agent"); await user.click(screen.getByRole("button", { name: "Create token" })); diff --git a/dashboard/src/main.tsx b/dashboard/src/main.tsx index 35463ca..156bb7d 100644 --- a/dashboard/src/main.tsx +++ b/dashboard/src/main.tsx @@ -3070,7 +3070,7 @@ function McpPage({ const mcpEndpointUrl = `${publicBaseUrl}/api/mcp`; return (
- } title="MCP access" subtitle={user?.is_admin ? "Issue and revoke read-only tokens for any dashboard user." : "Issue and revoke read-only tokens linked to your user."} action={} /> + } title="MCP access" subtitle={user?.is_admin ? "Issue and revoke globally readable knowledge tokens for any dashboard user." : "Issue and revoke globally readable knowledge tokens linked to your user."} action={} /> {error ? : null} {actionError ? : null} @@ -3113,9 +3113,9 @@ function McpPage({ setName(event.target.value)} /> {user?.is_admin ? ( - + - {selectedOwner ? Token will be linked to @{selectedOwner.login}. : null} + {selectedOwner ? Token management will be linked to @{selectedOwner.login}; this does not restrict repository reads. : null} ) : null}
{avatar} + {user?.login ? ( +
+ +
+ ) : null} ); } diff --git a/docs/dashboard-github-oauth.md b/docs/dashboard-github-oauth.md index e78c37f..c02598e 100644 --- a/docs/dashboard-github-oauth.md +++ b/docs/dashboard-github-oauth.md @@ -63,6 +63,8 @@ GITHUB_AGENT_BRIDGE_DASHBOARD_ALLOWED_TEAMS= GITHUB_AGENT_BRIDGE_DASHBOARD_ADMIN_USERS=your-github-login GITHUB_AGENT_BRIDGE_DASHBOARD_ADMIN_TEAMS= GITHUB_AGENT_BRIDGE_DASHBOARD_PUBLIC_URL= +GITHUB_AGENT_BRIDGE_DASHBOARD_SESSION_MAX_AGE_SECONDS=28800 +GITHUB_AGENT_BRIDGE_DASHBOARD_SESSION_VERSION=1 GITHUB_AGENT_BRIDGE_WEB_PUSH_VAPID_PUBLIC_KEY= GITHUB_AGENT_BRIDGE_WEB_PUSH_VAPID_PRIVATE_KEY= GITHUB_AGENT_BRIDGE_WEB_PUSH_VAPID_CONTACT=mailto:admin@example.com @@ -96,6 +98,11 @@ Use at least one authorization allowlist: - `GITHUB_AGENT_BRIDGE_DASHBOARD_PUBLIC_URL`: optional external dashboard origin, for example `https://bridge.example.com`, used in shareable dashboard links when the service runs behind nginx or another reverse proxy. +- `GITHUB_AGENT_BRIDGE_DASHBOARD_SESSION_MAX_AGE_SECONDS`: absolute signed + session lifetime. The default is 28,800 seconds (8 hours). +- `GITHUB_AGENT_BRIDGE_DASHBOARD_SESSION_VERSION`: positive integer embedded in + new sessions. Increment it to revoke every existing dashboard session without + rotating the signing secret. - `GITHUB_AGENT_BRIDGE_WEB_PUSH_VAPID_PUBLIC_KEY`: browser Push API VAPID public key served to signed-in dashboard users. - `GITHUB_AGENT_BRIDGE_WEB_PUSH_VAPID_PRIVATE_KEY`: matching VAPID private key @@ -120,6 +127,16 @@ listed in an `ALLOWED_*` variable. Per-repository dashboard scopes are part of the issue #4 architecture but are not implemented in the current dashboard backend. +Dashboard sessions contain signed issue and expiry times. User and admin +allowlist configuration is re-evaluated on every authenticated request, so +removing a directly listed login takes effect immediately. Organization and +team memberships are captured during OAuth and are refreshed by requiring a +new OAuth login when the absolute session lifetime expires; removing an org or +team member therefore takes effect within at most the configured session +lifetime. The **Sign out** action clears the browser session. Rotate the signing +key or increment the session version when all outstanding sessions must be +invalidated immediately. + ## Browser Push Notifications Completion notifications use the browser Push API, not GitHub mention comments. @@ -168,6 +185,9 @@ When exposing the dashboard beyond localhost: - terminate TLS before the dashboard; - set the OAuth App homepage and callback URL to the public HTTPS origin; - keep cookies `Secure`, `HttpOnly`, and `SameSite=Lax`; +- preserve the browser `Origin` and `Referer` headers. Cookie-authenticated + `POST`, `PUT`, `PATCH`, and `DELETE` requests fail closed unless one of those + headers matches the configured/forwarded dashboard origin; - restrict proxy access to the intended operator network where possible; - do not publish the raw SQLite file or arbitrary filesystem paths; - rotate `GITHUB_OAUTH_CLIENT_SECRET` and diff --git a/docs/ingestion.md b/docs/ingestion.md index 0fd56b1..344584b 100644 --- a/docs/ingestion.md +++ b/docs/ingestion.md @@ -108,6 +108,10 @@ would couple rotation and increase the blast radius of a leak. `GITHUB_AGENT_BRIDGE_WEBHOOK_MAX_BYTES` defaults to 1 MiB. GitHub must send `Content-Type: application/json`, `X-GitHub-Delivery`, `X-GitHub-Event`, and a valid `X-Hub-Signature-256` computed over the unmodified request bytes. +The ingress enforces this as an incremental hard cap while streaming the body, +including requests without `Content-Length`; it does not buffer an oversized +body before returning `413`. Set the reverse proxy limit to the same value. The +packaged nginx example uses `client_max_body_size 1m`, matching the default. ### GitHub configuration diff --git a/docs/installation.md b/docs/installation.md index 9da96fe..dd065b4 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -290,6 +290,8 @@ GITHUB_AGENT_BRIDGE_DASHBOARD_ALLOWED_TEAMS= GITHUB_AGENT_BRIDGE_DASHBOARD_ADMIN_USERS=your-github-login GITHUB_AGENT_BRIDGE_DASHBOARD_ADMIN_TEAMS= GITHUB_AGENT_BRIDGE_DASHBOARD_PUBLIC_URL=https://bridge.example.com +GITHUB_AGENT_BRIDGE_DASHBOARD_SESSION_MAX_AGE_SECONDS=28800 +GITHUB_AGENT_BRIDGE_DASHBOARD_SESSION_VERSION=1 GITHUB_AGENT_BRIDGE_WEB_PUSH_VAPID_PUBLIC_KEY=replace-with-vapid-public-key GITHUB_AGENT_BRIDGE_WEB_PUSH_VAPID_PRIVATE_KEY=replace-with-vapid-private-key GITHUB_AGENT_BRIDGE_WEB_PUSH_VAPID_CONTACT=mailto:admin@example.com diff --git a/docs/mcp.md b/docs/mcp.md index 713c263..0e224f1 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -39,6 +39,15 @@ dashboard admins, the signed-in admin, and any users already linked to existing MCP tokens. Admins can use that selector to issue new tokens for a known user or link an existing active token to a user without exposing the token secret again. +The linked user is a **lifecycle owner**, used to decide who can list and revoke +the token. It is not a repository authorization scope. Repository knowledge is +currently a single deployment-wide read model, just like the signed-in +dashboard knowledge page: every valid MCP token can list and read every +repository stored in that bridge database. Do not share one bridge database or +its MCP endpoint across mutually untrusted tenants. A future repository ACL +must be enforced consistently by both the dashboard read model and MCP; deriving +access from incidental job authorship would not be a reliable security boundary. + The dashboard MCP page shows both a public dashboard URL for token management and the public MCP endpoint URL. Behind a reverse proxy, set `GITHUB_AGENT_BRIDGE_DASHBOARD_PUBLIC_URL` to the external origin, for example diff --git a/docs/nginx-dashboard.conf b/docs/nginx-dashboard.conf index eb0e88c..161073b 100644 --- a/docs/nginx-dashboard.conf +++ b/docs/nginx-dashboard.conf @@ -14,6 +14,9 @@ server { # Keep webhook ingestion independent from dashboard/UI restarts. systemd # owns this socket and queues short bursts while the ingress process swaps. location = /api/webhooks/github { + # Keep this aligned with GITHUB_AGENT_BRIDGE_WEBHOOK_MAX_BYTES. nginx + # rejects oversized bodies before proxy buffering or Python allocation. + client_max_body_size 1m; proxy_pass http://127.0.0.1:8766; proxy_http_version 1.1; proxy_set_header Host $host; diff --git a/docs/operations.md b/docs/operations.md index 4e22a10..84e3b74 100644 --- a/docs/operations.md +++ b/docs/operations.md @@ -538,6 +538,8 @@ GITHUB_AGENT_BRIDGE_DASHBOARD_ALLOWED_TEAMS=example-org/platform GITHUB_AGENT_BRIDGE_DASHBOARD_ADMIN_USERS=alice GITHUB_AGENT_BRIDGE_DASHBOARD_ADMIN_TEAMS=example-org/bridge-admins GITHUB_AGENT_BRIDGE_DASHBOARD_PUBLIC_URL=https://bridge.example.com +GITHUB_AGENT_BRIDGE_DASHBOARD_SESSION_MAX_AGE_SECONDS=28800 +GITHUB_AGENT_BRIDGE_DASHBOARD_SESSION_VERSION=1 GITHUB_AGENT_BRIDGE_WEB_PUSH_VAPID_PUBLIC_KEY=replace-with-vapid-public-key GITHUB_AGENT_BRIDGE_WEB_PUSH_VAPID_PRIVATE_KEY=replace-with-vapid-private-key GITHUB_AGENT_BRIDGE_WEB_PUSH_VAPID_CONTACT=mailto:admin@example.com diff --git a/src/github_agent_bridge/backend.py b/src/github_agent_bridge/backend.py index 7683367..73812b2 100644 --- a/src/github_agent_bridge/backend.py +++ b/src/github_agent_bridge/backend.py @@ -68,7 +68,8 @@ GITHUB_USER_URL = "https://api.github.com/user" GITHUB_TEAMS_URL = "https://api.github.com/user/teams" PROJECT_REPOSITORY_URL = "https://github.com/gisce/github-agent-bridge" -SESSION_VERSION = 1 +SESSION_VERSION = 2 +DEFAULT_SESSION_MAX_AGE_SECONDS = 8 * 60 * 60 WEBHOOK_TIMESERIES_MAX_DAYS = 366 WEBHOOK_TIMESERIES_MAX_HOURLY_DAYS = 31 def _expand_systemd_home_specifier(value: str) -> str: @@ -315,6 +316,8 @@ def __init__( allowed_teams: set[str] | None = None, admin_users: set[str] | None = None, admin_teams: set[str] | None = None, + session_max_age_seconds: int | None = None, + session_version: int | None = None, require_auth: bool = True, static_dir: str | Path | None = None, public_url: str | None = None, @@ -339,6 +342,20 @@ def __init__( self.allowed_teams = allowed_teams if allowed_teams is not None else _csv_env("GITHUB_AGENT_BRIDGE_DASHBOARD_ALLOWED_TEAMS") self.admin_users = admin_users if admin_users is not None else _csv_env("GITHUB_AGENT_BRIDGE_DASHBOARD_ADMIN_USERS") self.admin_teams = admin_teams if admin_teams is not None else _csv_env("GITHUB_AGENT_BRIDGE_DASHBOARD_ADMIN_TEAMS") + self.session_max_age_seconds = ( + session_max_age_seconds + if session_max_age_seconds is not None + else int(os.getenv("GITHUB_AGENT_BRIDGE_DASHBOARD_SESSION_MAX_AGE_SECONDS", str(DEFAULT_SESSION_MAX_AGE_SECONDS))) + ) + self.session_version = ( + session_version + if session_version is not None + else int(os.getenv("GITHUB_AGENT_BRIDGE_DASHBOARD_SESSION_VERSION", "1")) + ) + if self.session_max_age_seconds <= 0: + raise ValueError("GITHUB_AGENT_BRIDGE_DASHBOARD_SESSION_MAX_AGE_SECONDS must be greater than zero") + if self.session_version <= 0: + raise ValueError("GITHUB_AGENT_BRIDGE_DASHBOARD_SESSION_VERSION must be greater than zero") self.require_auth = require_auth self.static_dir = Path(static_dir or os.getenv("GITHUB_AGENT_BRIDGE_DASHBOARD_STATIC_DIR", Path(__file__).with_name("dashboard_static"))).expanduser() self.public_url = (public_url if public_url is not None else os.getenv("GITHUB_AGENT_BRIDGE_DASHBOARD_PUBLIC_URL", "")).rstrip("/") @@ -680,24 +697,55 @@ def _unsign(config: DashboardConfig, value: str) -> str | None: return raw if hmac.compare_digest(digest, expected) else None -def _encode_session(user: dict[str, Any], *, is_admin: bool = False) -> str: +def _encode_session( + user: dict[str, Any], + *, + is_admin: bool = False, + authorized_orgs: set[str] | None = None, + authorized_teams: set[str] | None = None, + issued_at: datetime | None = None, + max_age_seconds: int = DEFAULT_SESSION_MAX_AGE_SECONDS, + session_version: int = 1, +) -> str: + issued = int((issued_at or datetime.now(UTC)).timestamp()) payload = { "v": SESSION_VERSION, + "sv": session_version, + "iat": issued, + "exp": issued + max_age_seconds, "login": str(user.get("login", "")).lower(), "avatar_url": str(user.get("avatar_url", "")), "html_url": str(user.get("html_url", "")), "is_admin": bool(is_admin), + "orgs": sorted(str(org).lower() for org in (authorized_orgs or set()) if org), + "teams": sorted(str(team).lower() for team in (authorized_teams or set()) if team), } data = json.dumps(payload, separators=(",", ":"), sort_keys=True).encode("utf-8") return base64.urlsafe_b64encode(data).decode("ascii").rstrip("=") -def _decode_session(value: str) -> dict[str, Any] | None: +def _decode_session( + value: str, + *, + now: datetime | None = None, + session_version: int = 1, +) -> dict[str, Any] | None: try: padded = value + "=" * (-len(value) % 4) payload = json.loads(base64.urlsafe_b64decode(padded).decode("utf-8")) except (ValueError, TypeError, json.JSONDecodeError): - return _profile_from_login(value) if value else None + return None + if not isinstance(payload, dict) or payload.get("v") != SESSION_VERSION or payload.get("sv") != session_version: + return None + issued_at = payload.get("iat") + expires_at = payload.get("exp") + if isinstance(issued_at, bool) or not isinstance(issued_at, int): + return None + if isinstance(expires_at, bool) or not isinstance(expires_at, int) or expires_at <= issued_at: + return None + current_timestamp = int((now or datetime.now(UTC)).timestamp()) + if issued_at > current_timestamp + 60 or expires_at <= current_timestamp: + return None login = str(payload.get("login", "")).lower() if not login: return None @@ -707,6 +755,12 @@ def _decode_session(value: str) -> dict[str, Any] | None: "avatar_url": str(payload.get("avatar_url") or fallback["avatar_url"]), "html_url": str(payload.get("html_url") or fallback["html_url"]), "is_admin": bool(payload.get("is_admin", False)), + "authorized_orgs": { + str(org).lower() for org in payload.get("orgs", []) if isinstance(org, str) and org + }, + "authorized_teams": { + str(team).lower() for team in payload.get("teams", []) if isinstance(team, str) and team + }, } @@ -762,6 +816,65 @@ def _team_key(team: dict[str, Any]) -> str | None: return f"{org_login}/{slug}" +def _github_authorization_memberships( + config: DashboardConfig, + token: str, +) -> tuple[set[str], set[str]]: + orgs: set[str] = set() + teams: set[str] = set() + if config.allowed_orgs: + try: + payload = _github_json("https://api.github.com/user/orgs", token) + except (urllib.error.URLError, TimeoutError): + payload = [] + orgs = { + str(org.get("login", "")).lower() + for org in payload + if isinstance(org, dict) and org.get("login") + } + if config.allowed_teams or config.admin_teams: + try: + payload = _github_json(GITHUB_TEAMS_URL, token) + except (urllib.error.URLError, TimeoutError): + payload = [] + teams = { + key + for key in ( + _team_key(team) for team in payload if isinstance(team, dict) + ) + if key + } + return orgs, teams + + +def _is_admin_for_memberships( + config: DashboardConfig, + login: str, + teams: set[str], +) -> bool: + user = login.lower() + return bool( + (config.admin_users and user in config.admin_users) + or (config.admin_teams and config.admin_teams.intersection(teams)) + ) + + +def _is_allowed_for_memberships( + config: DashboardConfig, + login: str, + orgs: set[str], + teams: set[str], +) -> bool: + user = login.lower() + return bool( + _is_admin_for_memberships(config, login, teams) + or (config.allowed_users and user in config.allowed_users) + or (config.allowed_orgs and config.allowed_orgs.intersection(orgs)) + or (config.allowed_teams and config.allowed_teams.intersection(teams)) + or not config.has_authorization_policy + ) + + def _exchange_code(config: DashboardConfig, code: str) -> str: data = urllib.parse.urlencode({ "client_id": config.oauth_client_id, @@ -778,38 +891,66 @@ def _exchange_code(config: DashboardConfig, code: str) -> str: def _is_allowed(config: DashboardConfig, login: str, token: str | None = None) -> bool: - user = login.lower() - if _is_admin(config, login, token): - return True - if config.allowed_users and user in config.allowed_users: - return True - if config.allowed_orgs and token: - try: - orgs = _github_json("https://api.github.com/user/orgs", token) - except (urllib.error.URLError, TimeoutError): - return False - if any(str(org.get("login", "")).lower() in config.allowed_orgs for org in orgs if isinstance(org, dict)): - return True - if config.allowed_teams and token: - try: - teams = _github_json(GITHUB_TEAMS_URL, token) - except (urllib.error.URLError, TimeoutError): - return False - return any(key in config.allowed_teams for key in (_team_key(team) for team in teams if isinstance(team, dict)) if key) - return not config.has_authorization_policy + orgs, teams = _github_authorization_memberships(config, token) if token else (set(), set()) + return _is_allowed_for_memberships(config, login, orgs, teams) def _is_admin(config: DashboardConfig, login: str, token: str | None = None) -> bool: - user = login.lower() - if config.admin_users and user in config.admin_users: - return True - if config.admin_teams and token: - try: - teams = _github_json(GITHUB_TEAMS_URL, token) - except (urllib.error.URLError, TimeoutError): + _, teams = _github_authorization_memberships(config, token) if token else (set(), set()) + return _is_admin_for_memberships(config, login, teams) + + +def _same_origin(left: str, right: str) -> bool: + try: + left_url = urllib.parse.urlparse(left) + right_url = urllib.parse.urlparse(right) + if left_url.scheme not in {"http", "https"} or right_url.scheme not in {"http", "https"}: return False - return any(key in config.admin_teams for key in (_team_key(team) for team in teams if isinstance(team, dict)) if key) - return False + left_port = left_url.port or (443 if left_url.scheme == "https" else 80) + right_port = right_url.port or (443 if right_url.scheme == "https" else 80) + except ValueError: + return False + return ( + left_url.scheme.lower(), + (left_url.hostname or "").lower(), + left_port, + ) == ( + right_url.scheme.lower(), + (right_url.hostname or "").lower(), + right_port, + ) + + +def _require_same_origin_mutation(request: Request) -> None: + if request.method.upper() not in {"POST", "PUT", "PATCH", "DELETE"}: + return + source = request.headers.get("origin", "").strip() + if not source: + source = request.headers.get("referer", "").strip() + if not source: + raise HTTPException( + status_code=status.HTTP_403_FORBIDDEN, + detail="csrf_origin_required", + ) + if not _same_origin(source, _dashboard_public_url(request)): + raise HTTPException( + status_code=status.HTTP_403_FORBIDDEN, + detail="csrf_origin_mismatch", + ) + + +async def _read_request_body_limited(request: Request, max_bytes: int) -> bytes: + chunks: list[bytes] = [] + size = 0 + async for chunk in request.stream(): + size += len(chunk) + if size > max_bytes: + raise HTTPException( + status_code=status.HTTP_413_CONTENT_TOO_LARGE, + detail="payload_too_large", + ) + chunks.append(chunk) + return b"".join(chunks) def _webhook_schema_initializer(config: DashboardConfig): @@ -846,12 +987,10 @@ async def _receive_github_webhook( if content_length: try: if int(content_length) > config.webhook_max_bytes: - raise HTTPException(status_code=status.HTTP_413_REQUEST_ENTITY_TOO_LARGE, detail="payload_too_large") + raise HTTPException(status_code=status.HTTP_413_CONTENT_TOO_LARGE, detail="payload_too_large") except ValueError: raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail="invalid_content_length") - raw_payload = await request.body() - if len(raw_payload) > config.webhook_max_bytes: - raise HTTPException(status_code=status.HTTP_413_REQUEST_ENTITY_TOO_LARGE, detail="payload_too_large") + raw_payload = await _read_request_body_limited(request, config.webhook_max_bytes) try: payload = json.loads(raw_payload) except (json.JSONDecodeError, UnicodeDecodeError): @@ -1013,9 +1152,19 @@ async def current_profile(request: Request) -> dict[str, Any]: if not signed or not cfg.secret_key: raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="not_authenticated") raw = _unsign(cfg, signed) - profile = _decode_session(raw) if raw else None + profile = _decode_session(raw, session_version=cfg.session_version) if raw else None if not profile: + raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="session_invalid_or_expired") + orgs = profile.pop("authorized_orgs") + teams = profile.pop("authorized_teams") + if not _is_allowed_for_memberships(cfg, str(profile["login"]), orgs, teams): raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="not_authorized") + profile["is_admin"] = bool(profile.get("is_admin")) and _is_admin_for_memberships( + cfg, + str(profile["login"]), + teams, + ) + _require_same_origin_mutation(request) return profile def can_cancel_job(job_id: int, profile: dict[str, Any]) -> bool: @@ -1930,14 +2079,43 @@ def callback(code: str, state: str, request: Request) -> RedirectResponse: token = _exchange_code(config, code) user = _github_json(GITHUB_USER_URL, token) login = str(user.get("login", "")) - if not login or not _is_allowed(config, login, token): + orgs, teams = _github_authorization_memberships(config, token) + if not login or not _is_allowed_for_memberships(config, login, orgs, teams): raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="not_authorized") - is_admin = _is_admin(config, login, token) + is_admin = _is_admin_for_memberships(config, login, teams) response = RedirectResponse("/", status_code=status.HTTP_302_FOUND) - response.set_cookie(SESSION_COOKIE, _sign(config, _encode_session(user, is_admin=is_admin)), httponly=True, secure=True, samesite="lax") + response.set_cookie( + SESSION_COOKIE, + _sign( + config, + _encode_session( + user, + is_admin=is_admin, + authorized_orgs=orgs, + authorized_teams=teams, + max_age_seconds=config.session_max_age_seconds, + session_version=config.session_version, + ), + ), + httponly=True, + secure=True, + samesite="lax", + max_age=config.session_max_age_seconds, + ) response.delete_cookie(OAUTH_STATE_COOKIE) return response + @app.post("/auth/logout") + def logout(_: dict[str, Any] = Depends(current_profile)) -> RedirectResponse: + response = RedirectResponse("/auth/login", status_code=status.HTTP_303_SEE_OTHER) + response.delete_cookie( + SESSION_COOKIE, + httponly=True, + secure=True, + samesite="lax", + ) + return response + return app diff --git a/src/github_agent_bridge/dashboard_static/assets/index-m6C2vT6T.js b/src/github_agent_bridge/dashboard_static/assets/index-j9YYBdoS.js similarity index 75% rename from src/github_agent_bridge/dashboard_static/assets/index-m6C2vT6T.js rename to src/github_agent_bridge/dashboard_static/assets/index-j9YYBdoS.js index b1fac38..d0af7ce 100644 --- a/src/github_agent_bridge/dashboard_static/assets/index-m6C2vT6T.js +++ b/src/github_agent_bridge/dashboard_static/assets/index-j9YYBdoS.js @@ -6,7 +6,7 @@ var Ha=e=>{throw TypeError(e)};var Jr=(e,t,n)=>t.has(e)||Ha("Cannot "+n);var g=( * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Ka;function hu(){if(Ka)return Wn;Ka=1;var e=iu(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,i=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function o(l,c,u){var d,h={},m=null,p=null;u!==void 0&&(m=""+u),c.key!==void 0&&(m=""+c.key),c.ref!==void 0&&(p=c.ref);for(d in c)r.call(c,d)&&!a.hasOwnProperty(d)&&(h[d]=c[d]);if(l&&l.defaultProps)for(d in c=l.defaultProps,c)h[d]===void 0&&(h[d]=c[d]);return{$$typeof:t,type:l,key:m,ref:p,props:h,_owner:i.current}}return Wn.Fragment=n,Wn.jsx=o,Wn.jsxs=o,Wn}var Qa;function pu(){return Qa||(Qa=1,Xr.exports=hu()),Xr.exports}var s=pu(),Nr={},Wa;function mu(){if(Wa)return Nr;Wa=1;var e=au();return Nr.createRoot=e.createRoot,Nr.hydrateRoot=e.hydrateRoot,Nr}var fu=mu();const xu=Zs(fu);var gr=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Vt,At,wn,tl,gu=(tl=class extends gr{constructor(){super();H(this,Vt);H(this,At);H(this,wn);z(this,wn,t=>{if(typeof window<"u"&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){g(this,At)||this.setEventListener(g(this,wn))}onUnsubscribe(){var t;this.hasListeners()||((t=g(this,At))==null||t.call(this),z(this,At,void 0))}setEventListener(t){var n;z(this,wn,t),(n=g(this,At))==null||n.call(this),z(this,At,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){g(this,Vt)!==t&&(z(this,Vt,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof g(this,Vt)=="boolean"?g(this,Vt):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Vt=new WeakMap,At=new WeakMap,wn=new WeakMap,tl),ni=new gu,bu={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Lt,Ys,nl,yu=(nl=class{constructor(){H(this,Lt,bu);H(this,Ys,!1)}setTimeoutProvider(e){z(this,Lt,e)}setTimeout(e,t){return g(this,Lt).setTimeout(e,t)}clearTimeout(e){g(this,Lt).clearTimeout(e)}setInterval(e,t){return g(this,Lt).setInterval(e,t)}clearInterval(e){g(this,Lt).clearInterval(e)}},Lt=new WeakMap,Ys=new WeakMap,nl),Wt=new yu;function wu(e){setTimeout(e,0)}var vu=typeof window>"u"||"Deno"in globalThis;function Be(){}function ju(e,t){return typeof e=="function"?e(t):e}function ys(e){return typeof e=="number"&&e>=0&&e!==1/0}function hl(e,t){return Math.max(e+(t||0)-Date.now(),0)}function $t(e,t){return typeof e=="function"?e(t):e}function Ge(e,t){return typeof e=="function"?e(t):e}function Va(e,t){const{type:n="all",exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:l}=e;if(o){if(r){if(t.queryHash!==ri(o,t.options))return!1}else if(!or(t.queryKey,o))return!1}if(n!=="all"){const c=t.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof l=="boolean"&&t.isStale()!==l||i&&i!==t.state.fetchStatus||a&&!a(t))}function Ga(e,t){const{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(ar(t.options.mutationKey)!==ar(a))return!1}else if(!or(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function ri(e,t){return((t==null?void 0:t.queryKeyHashFn)||ar)(e)}function ar(e){return JSON.stringify(e,(t,n)=>vs(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function or(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>or(e[n],t[n])):!1}var ku=Object.prototype.hasOwnProperty;function pl(e,t,n=0){if(e===t)return e;if(n>500)return t;const r=Ja(e)&&Ja(t);if(!r&&!(vs(e)&&vs(t)))return t;const a=(r?e:Object.keys(e)).length,o=r?t:Object.keys(t),l=o.length,c=r?new Array(l):{};let u=0;for(let d=0;d{Wt.setTimeout(t,e)})}function js(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?pl(e,t):t}function Su(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function _u(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var si=Symbol();function ml(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===si?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function fl(e,t){return typeof e=="function"?e(...t):!!e}function Cu(e,t,n){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??(i=t()),r||(r=!0,i.aborted?n():i.addEventListener("abort",n,{once:!0})),i)}),e}var lr=(()=>{let e=()=>vu;return{isServer(){return e()},setIsServer(t){e=t}}})();function ks(){let e,t;const n=new Promise((i,a)=>{e=i,t=a});n.status="pending",n.catch(()=>{});function r(i){Object.assign(n,i),delete n.resolve,delete n.reject}return n.resolve=i=>{r({status:"fulfilled",value:i}),e(i)},n.reject=i=>{r({status:"rejected",reason:i}),t(i)},n}var Pu=wu;function Eu(){let e=[],t=0,n=l=>{l()},r=l=>{l()},i=Pu;const a=l=>{t?e.push(l):i(()=>{n(l)})},o=()=>{const l=e;e=[],l.length&&i(()=>{r(()=>{l.forEach(c=>{n(c)})})})};return{batch:l=>{let c;t++;try{c=l()}finally{t--,t||o()}return c},batchCalls:l=>(...c)=>{a(()=>{l(...c)})},schedule:a,setNotifyFunction:l=>{n=l},setBatchNotifyFunction:l=>{r=l},setScheduler:l=>{i=l}}}var _e=Eu(),vn,Mt,jn,rl,Ru=(rl=class extends gr{constructor(){super();H(this,vn,!0);H(this,Mt);H(this,jn);z(this,jn,t=>{if(typeof window<"u"&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){g(this,Mt)||this.setEventListener(g(this,jn))}onUnsubscribe(){var t;this.hasListeners()||((t=g(this,Mt))==null||t.call(this),z(this,Mt,void 0))}setEventListener(t){var n;z(this,jn,t),(n=g(this,Mt))==null||n.call(this),z(this,Mt,t(this.setOnline.bind(this)))}setOnline(t){g(this,vn)!==t&&(z(this,vn,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return g(this,vn)}},vn=new WeakMap,Mt=new WeakMap,jn=new WeakMap,rl),Mr=new Ru;function Iu(e){return Math.min(1e3*2**e,3e4)}function xl(e){return(e??"online")==="online"?Mr.isOnline():!0}var Ns=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function gl(e){let t=!1,n=0,r;const i=ks(),a=()=>i.status!=="pending",o=y=>{var v;if(!a()){const b=new Ns(y);m(b),(v=e.onCancel)==null||v.call(e,b)}},l=()=>{t=!0},c=()=>{t=!1},u=()=>ni.isFocused()&&(e.networkMode==="always"||Mr.isOnline())&&e.canRun(),d=()=>xl(e.networkMode)&&e.canRun(),h=y=>{a()||(r==null||r(),i.resolve(y))},m=y=>{a()||(r==null||r(),i.reject(y))},p=()=>new Promise(y=>{var v;r=b=>{(a()||u())&&y(b)},(v=e.onPause)==null||v.call(e)}).then(()=>{var y;r=void 0,a()||(y=e.onContinue)==null||y.call(e)}),w=()=>{if(a())return;let y;const v=n===0?e.initialPromise:void 0;try{y=v??e.fn()}catch(b){y=Promise.reject(b)}Promise.resolve(y).then(h).catch(b=>{var j;if(a())return;const N=e.retry??(lr.isServer()?0:3),k=e.retryDelay??Iu,_=typeof k=="function"?k(n,b):k,O=N===!0||typeof N=="number"&&nu()?void 0:p()).then(()=>{t?m(b):w()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r==null||r(),i),cancelRetry:l,continueRetry:c,canStart:d,start:()=>(d()?w():p().then(w),i)}}var Gt,sl,bl=(sl=class{constructor(){H(this,Gt)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),ys(this.gcTime)&&z(this,Gt,Wt.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(lr.isServer()?1/0:300*1e3))}clearGcTimeout(){g(this,Gt)!==void 0&&(Wt.clearTimeout(g(this,Gt)),z(this,Gt,void 0))}},Gt=new WeakMap,sl);function Tu(e){return{onFetch:(t,n)=>{var d,h,m,p,w;const r=t.options,i=(m=(h=(d=t.fetchOptions)==null?void 0:d.meta)==null?void 0:h.fetchMore)==null?void 0:m.direction,a=((p=t.state.data)==null?void 0:p.pages)||[],o=((w=t.state.data)==null?void 0:w.pageParams)||[];let l={pages:[],pageParams:[]},c=0;const u=async()=>{let y=!1;const v=k=>{Cu(k,()=>t.signal,()=>y=!0)},b=ml(t.options,t.fetchOptions),N=async(k,_,O)=>{if(y)return Promise.reject(t.signal.reason);if(_==null&&k.pages.length)return Promise.resolve(k);const B=(()=>{const D={client:t.client,queryKey:t.queryKey,pageParam:_,direction:O?"backward":"forward",meta:t.options.meta};return v(D),D})(),F=await b(B),{maxPages:C}=t.options,M=O?_u:Su;return{pages:M(k.pages,F,C),pageParams:M(k.pageParams,_,C)}};if(i&&a.length){const k=i==="backward",_=k?yl:Ss,O={pages:a,pageParams:o},j=_(r,O);l=await N(O,j,k)}else{const k=e??a.length;do{const _=c===0?o[0]??r.initialPageParam:Ss(r,l);if(c>0&&_==null)break;l=await N(l,_),c++}while(c{var y,v;return(v=(y=t.options).persister)==null?void 0:v.call(y,u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=u}}}function Ss(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function yl(e,{pages:t,pageParams:n}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n):void 0}function Au(e,t){return t?Ss(e,t)!=null:!1}function Lu(e,t){return!t||!e.getPreviousPageParam?!1:yl(e,t)!=null}var kn,Jt,Nn,Ze,Xt,Se,hr,Yt,Ve,wl,Nt,il,Mu=(il=class extends bl{constructor(t){super();H(this,Ve);H(this,kn);H(this,Jt);H(this,Nn);H(this,Ze);H(this,Xt);H(this,Se);H(this,hr);H(this,Yt);z(this,Yt,!1),z(this,hr,t.defaultOptions),this.setOptions(t.options),this.observers=[],z(this,Xt,t.client),z(this,Ze,g(this,Xt).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,z(this,Jt,Za(this.options)),this.state=t.state??g(this,Jt),this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return g(this,kn)}get promise(){var t;return(t=g(this,Se))==null?void 0:t.promise}setOptions(t){if(this.options={...g(this,hr),...t},t!=null&&t._type&&z(this,kn,t._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=Za(this.options);n.data!==void 0&&(this.setState(Ya(n.data,n.dataUpdatedAt)),z(this,Jt,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&g(this,Ze).remove(this)}setData(t,n){const r=js(this.state.data,t,this.options);return ne(this,Ve,Nt).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t){ne(this,Ve,Nt).call(this,{type:"setState",state:t})}cancel(t){var r,i;const n=(r=g(this,Se))==null?void 0:r.promise;return(i=g(this,Se))==null||i.cancel(t),n?n.then(Be).catch(Be):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return g(this,Jt)}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(t=>Ge(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===si||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>$t(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!hl(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=g(this,Se))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=g(this,Se))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),g(this,Ze).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(g(this,Se)&&(g(this,Yt)||ne(this,Ve,wl).call(this)?g(this,Se).cancel({revert:!0}):g(this,Se).cancelRetry()),this.scheduleGc()),g(this,Ze).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||ne(this,Ve,Nt).call(this,{type:"invalidate"})}async fetch(t,n){var u,d,h,m,p,w,y,v,b,N,k;if(this.state.fetchStatus!=="idle"&&((u=g(this,Se))==null?void 0:u.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(g(this,Se))return g(this,Se).continueRetry(),g(this,Se).promise}if(t&&this.setOptions(t),!this.options.queryFn){const _=this.observers.find(O=>O.options.queryFn);_&&this.setOptions(_.options)}const r=new AbortController,i=_=>{Object.defineProperty(_,"signal",{enumerable:!0,get:()=>(z(this,Yt,!0),r.signal)})},a=()=>{const _=ml(this.options,n),j=(()=>{const B={client:g(this,Xt),queryKey:this.queryKey,meta:this.meta};return i(B),B})();return z(this,Yt,!1),this.options.persister?this.options.persister(_,j,this):_(j)},l=(()=>{const _={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:g(this,Xt),state:this.state,fetchFn:a};return i(_),_})(),c=g(this,kn)==="infinite"?Tu(this.options.pages):this.options.behavior;c==null||c.onFetch(l,this),z(this,Nn,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((d=l.fetchOptions)==null?void 0:d.meta))&&ne(this,Ve,Nt).call(this,{type:"fetch",meta:(h=l.fetchOptions)==null?void 0:h.meta}),z(this,Se,gl({initialPromise:n==null?void 0:n.initialPromise,fn:l.fetchFn,onCancel:_=>{_ instanceof Ns&&_.revert&&this.setState({...g(this,Nn),fetchStatus:"idle"}),r.abort()},onFail:(_,O)=>{ne(this,Ve,Nt).call(this,{type:"failed",failureCount:_,error:O})},onPause:()=>{ne(this,Ve,Nt).call(this,{type:"pause"})},onContinue:()=>{ne(this,Ve,Nt).call(this,{type:"continue"})},retry:l.options.retry,retryDelay:l.options.retryDelay,networkMode:l.options.networkMode,canRun:()=>!0}));try{const _=await g(this,Se).start();if(_===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(_),(p=(m=g(this,Ze).config).onSuccess)==null||p.call(m,_,this),(y=(w=g(this,Ze).config).onSettled)==null||y.call(w,_,this.state.error,this),_}catch(_){if(_ instanceof Ns){if(_.silent)return g(this,Se).promise;if(_.revert){if(this.state.data===void 0)throw _;return this.state.data}}throw ne(this,Ve,Nt).call(this,{type:"error",error:_}),(b=(v=g(this,Ze).config).onError)==null||b.call(v,_,this),(k=(N=g(this,Ze).config).onSettled)==null||k.call(N,this.state.data,_,this),_}finally{this.scheduleGc()}}},kn=new WeakMap,Jt=new WeakMap,Nn=new WeakMap,Ze=new WeakMap,Xt=new WeakMap,Se=new WeakMap,hr=new WeakMap,Yt=new WeakMap,Ve=new WeakSet,wl=function(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"},Nt=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...vl(r.data,this.options),fetchMeta:t.meta??null};case"success":const i={...r,...Ya(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return z(this,Nn,t.manual?i:void 0),i;case"error":const a=t.error;return{...r,error:a,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:a,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),_e.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),g(this,Ze).notify({query:this,type:"updated",action:t})})},il);function vl(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:xl(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function Ya(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Za(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var qe,re,pr,De,Zt,Sn,St,Ot,mr,_n,Cn,en,tn,Dt,Pn,ae,tr,_s,Cs,Ps,Es,Rs,Is,Ts,kl,al,jl=(al=class extends gr{constructor(t,n){super();H(this,ae);H(this,qe);H(this,re);H(this,pr);H(this,De);H(this,Zt);H(this,Sn);H(this,St);H(this,Ot);H(this,mr);H(this,_n);H(this,Cn);H(this,en);H(this,tn);H(this,Dt);H(this,Pn,new Set);this.options=n,z(this,qe,t),z(this,Ot,null),z(this,St,ks()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(g(this,re).addObserver(this),eo(g(this,re),this.options)?ne(this,ae,tr).call(this):this.updateResult(),ne(this,ae,Es).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return As(g(this,re),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return As(g(this,re),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,ne(this,ae,Rs).call(this),ne(this,ae,Is).call(this),g(this,re).removeObserver(this)}setOptions(t){const n=this.options,r=g(this,re);if(this.options=g(this,qe).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Ge(this.options.enabled,g(this,re))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");ne(this,ae,Ts).call(this),g(this,re).setOptions(this.options),n._defaulted&&!ws(this.options,n)&&g(this,qe).getQueryCache().notify({type:"observerOptionsUpdated",query:g(this,re),observer:this});const i=this.hasListeners();i&&to(g(this,re),r,this.options,n)&&ne(this,ae,tr).call(this),this.updateResult(),i&&(g(this,re)!==r||Ge(this.options.enabled,g(this,re))!==Ge(n.enabled,g(this,re))||$t(this.options.staleTime,g(this,re))!==$t(n.staleTime,g(this,re)))&&ne(this,ae,_s).call(this);const a=ne(this,ae,Cs).call(this);i&&(g(this,re)!==r||Ge(this.options.enabled,g(this,re))!==Ge(n.enabled,g(this,re))||a!==g(this,Dt))&&ne(this,ae,Ps).call(this,a)}getOptimisticResult(t){const n=g(this,qe).getQueryCache().build(g(this,qe),t),r=this.createResult(n,t);return Du(this,r)&&(z(this,De,r),z(this,Sn,this.options),z(this,Zt,g(this,re).state)),r}getCurrentResult(){return g(this,De)}trackResult(t,n){return new Proxy(t,{get:(r,i)=>(this.trackProp(i),n==null||n(i),i==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&g(this,St).status==="pending"&&g(this,St).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,i))})}trackProp(t){g(this,Pn).add(t)}getCurrentQuery(){return g(this,re)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=g(this,qe).defaultQueryOptions(t),r=g(this,qe).getQueryCache().build(g(this,qe),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return ne(this,ae,tr).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),g(this,De)))}createResult(t,n){var C;const r=g(this,re),i=this.options,a=g(this,De),o=g(this,Zt),l=g(this,Sn),u=t!==r?t.state:g(this,pr),{state:d}=t;let h={...d},m=!1,p;if(n._optimisticResults){const M=this.hasListeners(),D=!M&&eo(t,n),I=M&&to(t,r,n,i);(D||I)&&(h={...h,...vl(d.data,t.options)}),n._optimisticResults==="isRestoring"&&(h.fetchStatus="idle")}let{error:w,errorUpdatedAt:y,status:v}=h;p=h.data;let b=!1;if(n.placeholderData!==void 0&&p===void 0&&v==="pending"){let M;a!=null&&a.isPlaceholderData&&n.placeholderData===(l==null?void 0:l.placeholderData)?(M=a.data,b=!0):M=typeof n.placeholderData=="function"?n.placeholderData((C=g(this,Cn))==null?void 0:C.state.data,g(this,Cn)):n.placeholderData,M!==void 0&&(v="success",p=js(a==null?void 0:a.data,M,n),m=!0)}if(n.select&&p!==void 0&&!b)if(a&&p===(o==null?void 0:o.data)&&n.select===g(this,mr))p=g(this,_n);else try{z(this,mr,n.select),p=n.select(p),p=js(a==null?void 0:a.data,p,n),z(this,_n,p),z(this,Ot,null)}catch(M){z(this,Ot,M)}g(this,Ot)&&(w=g(this,Ot),p=g(this,_n),y=Date.now(),v="error");const N=h.fetchStatus==="fetching",k=v==="pending",_=v==="error",O=k&&N,j=p!==void 0,F={status:v,fetchStatus:h.fetchStatus,isPending:k,isSuccess:v==="success",isError:_,isInitialLoading:O,isLoading:O,data:p,dataUpdatedAt:h.dataUpdatedAt,error:w,errorUpdatedAt:y,failureCount:h.fetchFailureCount,failureReason:h.fetchFailureReason,errorUpdateCount:h.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:h.dataUpdateCount>u.dataUpdateCount||h.errorUpdateCount>u.errorUpdateCount,isFetching:N,isRefetching:N&&!k,isLoadingError:_&&!j,isPaused:h.fetchStatus==="paused",isPlaceholderData:m,isRefetchError:_&&j,isStale:ii(t,n),refetch:this.refetch,promise:g(this,St),isEnabled:Ge(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const M=F.data!==void 0,D=F.status==="error"&&!M,I=P=>{D?P.reject(F.error):M&&P.resolve(F.data)},X=()=>{const P=z(this,St,F.promise=ks());I(P)},q=g(this,St);switch(q.status){case"pending":t.queryHash===r.queryHash&&I(q);break;case"fulfilled":(D||F.data!==q.value)&&X();break;case"rejected":(!D||F.error!==q.reason)&&X();break}}return F}updateResult(){const t=g(this,De),n=this.createResult(g(this,re),this.options);if(z(this,Zt,g(this,re).state),z(this,Sn,this.options),g(this,Zt).data!==void 0&&z(this,Cn,g(this,re)),ws(n,t))return;z(this,De,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:i}=this.options,a=typeof i=="function"?i():i;if(a==="all"||!a&&!g(this,Pn).size)return!0;const o=new Set(a??g(this,Pn));return this.options.throwOnError&&o.add("error"),Object.keys(g(this,De)).some(l=>{const c=l;return g(this,De)[c]!==t[c]&&o.has(c)})};ne(this,ae,kl).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&ne(this,ae,Es).call(this)}},qe=new WeakMap,re=new WeakMap,pr=new WeakMap,De=new WeakMap,Zt=new WeakMap,Sn=new WeakMap,St=new WeakMap,Ot=new WeakMap,mr=new WeakMap,_n=new WeakMap,Cn=new WeakMap,en=new WeakMap,tn=new WeakMap,Dt=new WeakMap,Pn=new WeakMap,ae=new WeakSet,tr=function(t){ne(this,ae,Ts).call(this);let n=g(this,re).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(Be)),n},_s=function(){ne(this,ae,Rs).call(this);const t=$t(this.options.staleTime,g(this,re));if(lr.isServer()||g(this,De).isStale||!ys(t))return;const r=hl(g(this,De).dataUpdatedAt,t)+1;z(this,en,Wt.setTimeout(()=>{g(this,De).isStale||this.updateResult()},r))},Cs=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(g(this,re)):this.options.refetchInterval)??!1},Ps=function(t){ne(this,ae,Is).call(this),z(this,Dt,t),!(lr.isServer()||Ge(this.options.enabled,g(this,re))===!1||!ys(g(this,Dt))||g(this,Dt)===0)&&z(this,tn,Wt.setInterval(()=>{(this.options.refetchIntervalInBackground||ni.isFocused())&&ne(this,ae,tr).call(this)},g(this,Dt)))},Es=function(){ne(this,ae,_s).call(this),ne(this,ae,Ps).call(this,ne(this,ae,Cs).call(this))},Rs=function(){g(this,en)!==void 0&&(Wt.clearTimeout(g(this,en)),z(this,en,void 0))},Is=function(){g(this,tn)!==void 0&&(Wt.clearInterval(g(this,tn)),z(this,tn,void 0))},Ts=function(){const t=g(this,qe).getQueryCache().build(g(this,qe),this.options);if(t===g(this,re))return;const n=g(this,re);z(this,re,t),z(this,pr,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},kl=function(t){_e.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(g(this,De))}),g(this,qe).getQueryCache().notify({query:g(this,re),type:"observerResultsUpdated"})})},al);function Ou(e,t){return Ge(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&Ge(t.retryOnMount,e)===!1)}function eo(e,t){return Ou(e,t)||e.state.data!==void 0&&As(e,t,t.refetchOnMount)}function As(e,t,n){if(Ge(t.enabled,e)!==!1&&$t(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&ii(e,t)}return!1}function to(e,t,n,r){return(e!==t||Ge(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&ii(e,n)}function ii(e,t){return Ge(t.enabled,e)!==!1&&e.isStaleByTime($t(t.staleTime,e))}function Du(e,t){return!ws(e.getCurrentResult(),t)}var Fu=class extends jl{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type="infinite",super.setOptions(e)}getOptimisticResult(e){return e._type="infinite",super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){var w,y;const{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:l}=r,c=(y=(w=n.fetchMeta)==null?void 0:w.fetchMore)==null?void 0:y.direction,u=o&&c==="forward",d=i&&c==="forward",h=o&&c==="backward",m=i&&c==="backward";return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:Au(t,n.data),hasPreviousPage:Lu(t,n.data),isFetchNextPageError:u,isFetchingNextPage:d,isFetchPreviousPageError:h,isFetchingPreviousPage:m,isRefetchError:l&&!u&&!h,isRefetching:a&&!d&&!m}}},fr,mt,Te,nn,ft,Tt,ol,zu=(ol=class extends bl{constructor(t){super();H(this,ft);H(this,fr);H(this,mt);H(this,Te);H(this,nn);z(this,fr,t.client),this.mutationId=t.mutationId,z(this,Te,t.mutationCache),z(this,mt,[]),this.state=t.state||qu(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){g(this,mt).includes(t)||(g(this,mt).push(t),this.clearGcTimeout(),g(this,Te).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){z(this,mt,g(this,mt).filter(n=>n!==t)),this.scheduleGc(),g(this,Te).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){g(this,mt).length||(this.state.status==="pending"?this.scheduleGc():g(this,Te).remove(this))}continue(){var t;return((t=g(this,nn))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,l,c,u,d,h,m,p,w,y,v,b,N,k,_,O,j,B;const n=()=>{ne(this,ft,Tt).call(this,{type:"continue"})},r={client:g(this,fr),meta:this.options.meta,mutationKey:this.options.mutationKey};z(this,nn,gl({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(F,C)=>{ne(this,ft,Tt).call(this,{type:"failed",failureCount:F,error:C})},onPause:()=>{ne(this,ft,Tt).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>g(this,Te).canRun(this)}));const i=this.state.status==="pending",a=!g(this,nn).canStart();try{if(i)n();else{ne(this,ft,Tt).call(this,{type:"pending",variables:t,isPaused:a}),g(this,Te).config.onMutate&&await g(this,Te).config.onMutate(t,this,r);const C=await((l=(o=this.options).onMutate)==null?void 0:l.call(o,t,r));C!==this.state.context&&ne(this,ft,Tt).call(this,{type:"pending",context:C,variables:t,isPaused:a})}const F=await g(this,nn).start();return await((u=(c=g(this,Te).config).onSuccess)==null?void 0:u.call(c,F,t,this.state.context,this,r)),await((h=(d=this.options).onSuccess)==null?void 0:h.call(d,F,t,this.state.context,r)),await((p=(m=g(this,Te).config).onSettled)==null?void 0:p.call(m,F,null,this.state.variables,this.state.context,this,r)),await((y=(w=this.options).onSettled)==null?void 0:y.call(w,F,null,t,this.state.context,r)),ne(this,ft,Tt).call(this,{type:"success",data:F}),F}catch(F){try{await((b=(v=g(this,Te).config).onError)==null?void 0:b.call(v,F,t,this.state.context,this,r))}catch(C){Promise.reject(C)}try{await((k=(N=this.options).onError)==null?void 0:k.call(N,F,t,this.state.context,r))}catch(C){Promise.reject(C)}try{await((O=(_=g(this,Te).config).onSettled)==null?void 0:O.call(_,void 0,F,this.state.variables,this.state.context,this,r))}catch(C){Promise.reject(C)}try{await((B=(j=this.options).onSettled)==null?void 0:B.call(j,void 0,F,t,this.state.context,r))}catch(C){Promise.reject(C)}throw ne(this,ft,Tt).call(this,{type:"error",error:F}),F}finally{g(this,Te).runNext(this)}}},fr=new WeakMap,mt=new WeakMap,Te=new WeakMap,nn=new WeakMap,ft=new WeakSet,Tt=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),_e.batch(()=>{g(this,mt).forEach(r=>{r.onMutationUpdate(t)}),g(this,Te).notify({mutation:this,type:"updated",action:t})})},ol);function qu(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var _t,at,xr,ll,Bu=(ll=class extends gr{constructor(t={}){super();H(this,_t);H(this,at);H(this,xr);this.config=t,z(this,_t,new Set),z(this,at,new Map),z(this,xr,0)}build(t,n,r){const i=new zu({client:t,mutationCache:this,mutationId:++kr(this,xr)._,options:t.defaultMutationOptions(n),state:r});return this.add(i),i}add(t){g(this,_t).add(t);const n=Sr(t);if(typeof n=="string"){const r=g(this,at).get(n);r?r.push(t):g(this,at).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(g(this,_t).delete(t)){const n=Sr(t);if(typeof n=="string"){const r=g(this,at).get(n);if(r)if(r.length>1){const i=r.indexOf(t);i!==-1&&r.splice(i,1)}else r[0]===t&&g(this,at).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=Sr(t);if(typeof n=="string"){const r=g(this,at).get(n),i=r==null?void 0:r.find(a=>a.state.status==="pending");return!i||i===t}else return!0}runNext(t){var r;const n=Sr(t);if(typeof n=="string"){const i=(r=g(this,at).get(n))==null?void 0:r.find(a=>a!==t&&a.state.isPaused);return(i==null?void 0:i.continue())??Promise.resolve()}else return Promise.resolve()}clear(){_e.batch(()=>{g(this,_t).forEach(t=>{this.notify({type:"removed",mutation:t})}),g(this,_t).clear(),g(this,at).clear()})}getAll(){return Array.from(g(this,_t))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>Ga(n,r))}findAll(t={}){return this.getAll().filter(n=>Ga(t,n))}notify(t){_e.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return _e.batch(()=>Promise.all(t.map(n=>n.continue().catch(Be))))}},_t=new WeakMap,at=new WeakMap,xr=new WeakMap,ll);function Sr(e){var t;return(t=e.options.scope)==null?void 0:t.id}var xt,cl,$u=(cl=class extends gr{constructor(t={}){super();H(this,xt);this.config=t,z(this,xt,new Map)}build(t,n,r){const i=n.queryKey,a=n.queryHash??ri(i,n);let o=this.get(a);return o||(o=new Mu({client:t,queryKey:i,queryHash:a,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(i)}),this.add(o)),o}add(t){g(this,xt).has(t.queryHash)||(g(this,xt).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=g(this,xt).get(t.queryHash);n&&(t.destroy(),n===t&&g(this,xt).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){_e.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return g(this,xt).get(t)}getAll(){return[...g(this,xt).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>Va(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>Va(t,r)):n}notify(t){_e.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){_e.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){_e.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},xt=new WeakMap,cl),we,Ft,zt,En,Rn,qt,In,Tn,ul,Uu=(ul=class{constructor(e={}){H(this,we);H(this,Ft);H(this,zt);H(this,En);H(this,Rn);H(this,qt);H(this,In);H(this,Tn);z(this,we,e.queryCache||new $u),z(this,Ft,e.mutationCache||new Bu),z(this,zt,e.defaultOptions||{}),z(this,En,new Map),z(this,Rn,new Map),z(this,qt,0)}mount(){kr(this,qt)._++,g(this,qt)===1&&(z(this,In,ni.subscribe(async e=>{e&&(await this.resumePausedMutations(),g(this,we).onFocus())})),z(this,Tn,Mr.subscribe(async e=>{e&&(await this.resumePausedMutations(),g(this,we).onOnline())})))}unmount(){var e,t;kr(this,qt)._--,g(this,qt)===0&&((e=g(this,In))==null||e.call(this),z(this,In,void 0),(t=g(this,Tn))==null||t.call(this),z(this,Tn,void 0))}isFetching(e){return g(this,we).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return g(this,Ft).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=g(this,we).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=g(this,we).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime($t(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return g(this,we).findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),i=g(this,we).get(r.queryHash),a=i==null?void 0:i.state.data,o=ju(t,a);if(o!==void 0)return g(this,we).build(this,r).setData(o,{...n,manual:!0})}setQueriesData(e,t,n){return _e.batch(()=>g(this,we).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=g(this,we).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=g(this,we);_e.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=g(this,we);return _e.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=_e.batch(()=>g(this,we).findAll(e).map(i=>i.cancel(n)));return Promise.all(r).then(Be).catch(Be)}invalidateQueries(e,t={}){return _e.batch(()=>(g(this,we).findAll(e).forEach(n=>{n.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=_e.batch(()=>g(this,we).findAll(e).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let a=i.fetch(void 0,n);return n.throwOnError||(a=a.catch(Be)),i.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(r).then(Be)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=g(this,we).build(this,t);return n.isStaleByTime($t(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Be).catch(Be)}fetchInfiniteQuery(e){return e._type="infinite",this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Be).catch(Be)}ensureInfiniteQueryData(e){return e._type="infinite",this.ensureQueryData(e)}resumePausedMutations(){return Mr.isOnline()?g(this,Ft).resumePausedMutations():Promise.resolve()}getQueryCache(){return g(this,we)}getMutationCache(){return g(this,Ft)}getDefaultOptions(){return g(this,zt)}setDefaultOptions(e){z(this,zt,e)}setQueryDefaults(e,t){g(this,En).set(ar(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...g(this,En).values()],n={};return t.forEach(r=>{or(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){g(this,Rn).set(ar(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...g(this,Rn).values()],n={};return t.forEach(r=>{or(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...g(this,zt).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=ri(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===si&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...g(this,zt).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){g(this,we).clear(),g(this,Ft).clear()}},we=new WeakMap,Ft=new WeakMap,zt=new WeakMap,En=new WeakMap,Rn=new WeakMap,qt=new WeakMap,In=new WeakMap,Tn=new WeakMap,ul),Nl=Ce.createContext(void 0),Sl=e=>{const t=Ce.useContext(Nl);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Hu=({client:e,children:t})=>(Ce.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),s.jsx(Nl.Provider,{value:e,children:t})),_l=Ce.createContext(!1),Ku=()=>Ce.useContext(_l);_l.Provider;function Qu(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Wu=Ce.createContext(Qu()),Vu=()=>Ce.useContext(Wu),Gu=(e,t,n)=>{const r=n!=null&&n.state.error&&typeof e.throwOnError=="function"?fl(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},Ju=e=>{Ce.useEffect(()=>{e.clearReset()},[e])},Xu=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||fl(n,[e.error,r])),Yu=e=>{if(e.suspense){const n=i=>i==="static"?i:Math.max(i??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...i)=>n(r(...i)):n(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},Zu=(e,t)=>e.isLoading&&e.isFetching&&!t,ed=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,no=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Cl(e,t,n){var m,p,w,y;const r=Ku(),i=Vu(),a=Sl(),o=a.defaultQueryOptions(e);(p=(m=a.getDefaultOptions().queries)==null?void 0:m._experimental_beforeQuery)==null||p.call(m,o);const l=a.getQueryCache().get(o.queryHash);o._optimisticResults=r?"isRestoring":"optimistic",Yu(o),Gu(o,i,l),Ju(i);const c=!a.getQueryCache().get(o.queryHash),[u]=Ce.useState(()=>new t(a,o)),d=u.getOptimisticResult(o),h=!r&&e.subscribed!==!1;if(Ce.useSyncExternalStore(Ce.useCallback(v=>{const b=h?u.subscribe(_e.batchCalls(v)):Be;return u.updateResult(),b},[u,h]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),Ce.useEffect(()=>{u.setOptions(o)},[o,u]),ed(o,d))throw no(o,u,i);if(Xu({result:d,errorResetBoundary:i,throwOnError:o.throwOnError,query:l,suspense:o.suspense}))throw d.error;if((y=(w=a.getDefaultOptions().queries)==null?void 0:w._experimental_afterQuery)==null||y.call(w,o,d),o.experimental_prefetchInRender&&!lr.isServer()&&Zu(d,r)){const v=c?no(o,u,i):l==null?void 0:l.promise;v==null||v.catch(Be).finally(()=>{u.updateResult()})}return o.notifyOnChangeProps?d:u.trackResult(d)}function ve(e,t){return Cl(e,jl)}function Yr(e,t){return Cl(e,Fu)}/** + */var Ka;function hu(){if(Ka)return Wn;Ka=1;var e=iu(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,i=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function o(l,c,u){var d,h={},m=null,p=null;u!==void 0&&(m=""+u),c.key!==void 0&&(m=""+c.key),c.ref!==void 0&&(p=c.ref);for(d in c)r.call(c,d)&&!a.hasOwnProperty(d)&&(h[d]=c[d]);if(l&&l.defaultProps)for(d in c=l.defaultProps,c)h[d]===void 0&&(h[d]=c[d]);return{$$typeof:t,type:l,key:m,ref:p,props:h,_owner:i.current}}return Wn.Fragment=n,Wn.jsx=o,Wn.jsxs=o,Wn}var Qa;function pu(){return Qa||(Qa=1,Xr.exports=hu()),Xr.exports}var s=pu(),Nr={},Wa;function mu(){if(Wa)return Nr;Wa=1;var e=au();return Nr.createRoot=e.createRoot,Nr.hydrateRoot=e.hydrateRoot,Nr}var fu=mu();const xu=Zs(fu);var gr=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Vt,At,wn,tl,gu=(tl=class extends gr{constructor(){super();H(this,Vt);H(this,At);H(this,wn);z(this,wn,t=>{if(typeof window<"u"&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){g(this,At)||this.setEventListener(g(this,wn))}onUnsubscribe(){var t;this.hasListeners()||((t=g(this,At))==null||t.call(this),z(this,At,void 0))}setEventListener(t){var n;z(this,wn,t),(n=g(this,At))==null||n.call(this),z(this,At,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){g(this,Vt)!==t&&(z(this,Vt,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof g(this,Vt)=="boolean"?g(this,Vt):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Vt=new WeakMap,At=new WeakMap,wn=new WeakMap,tl),ni=new gu,bu={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Lt,Ys,nl,yu=(nl=class{constructor(){H(this,Lt,bu);H(this,Ys,!1)}setTimeoutProvider(e){z(this,Lt,e)}setTimeout(e,t){return g(this,Lt).setTimeout(e,t)}clearTimeout(e){g(this,Lt).clearTimeout(e)}setInterval(e,t){return g(this,Lt).setInterval(e,t)}clearInterval(e){g(this,Lt).clearInterval(e)}},Lt=new WeakMap,Ys=new WeakMap,nl),Wt=new yu;function wu(e){setTimeout(e,0)}var vu=typeof window>"u"||"Deno"in globalThis;function Be(){}function ju(e,t){return typeof e=="function"?e(t):e}function ys(e){return typeof e=="number"&&e>=0&&e!==1/0}function hl(e,t){return Math.max(e+(t||0)-Date.now(),0)}function $t(e,t){return typeof e=="function"?e(t):e}function Ge(e,t){return typeof e=="function"?e(t):e}function Va(e,t){const{type:n="all",exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:l}=e;if(o){if(r){if(t.queryHash!==ri(o,t.options))return!1}else if(!or(t.queryKey,o))return!1}if(n!=="all"){const c=t.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof l=="boolean"&&t.isStale()!==l||i&&i!==t.state.fetchStatus||a&&!a(t))}function Ga(e,t){const{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(ar(t.options.mutationKey)!==ar(a))return!1}else if(!or(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function ri(e,t){return((t==null?void 0:t.queryKeyHashFn)||ar)(e)}function ar(e){return JSON.stringify(e,(t,n)=>vs(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function or(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>or(e[n],t[n])):!1}var ku=Object.prototype.hasOwnProperty;function pl(e,t,n=0){if(e===t)return e;if(n>500)return t;const r=Ja(e)&&Ja(t);if(!r&&!(vs(e)&&vs(t)))return t;const a=(r?e:Object.keys(e)).length,o=r?t:Object.keys(t),l=o.length,c=r?new Array(l):{};let u=0;for(let d=0;d{Wt.setTimeout(t,e)})}function js(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?pl(e,t):t}function Su(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function _u(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var si=Symbol();function ml(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===si?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function fl(e,t){return typeof e=="function"?e(...t):!!e}function Cu(e,t,n){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??(i=t()),r||(r=!0,i.aborted?n():i.addEventListener("abort",n,{once:!0})),i)}),e}var lr=(()=>{let e=()=>vu;return{isServer(){return e()},setIsServer(t){e=t}}})();function ks(){let e,t;const n=new Promise((i,a)=>{e=i,t=a});n.status="pending",n.catch(()=>{});function r(i){Object.assign(n,i),delete n.resolve,delete n.reject}return n.resolve=i=>{r({status:"fulfilled",value:i}),e(i)},n.reject=i=>{r({status:"rejected",reason:i}),t(i)},n}var Pu=wu;function Eu(){let e=[],t=0,n=l=>{l()},r=l=>{l()},i=Pu;const a=l=>{t?e.push(l):i(()=>{n(l)})},o=()=>{const l=e;e=[],l.length&&i(()=>{r(()=>{l.forEach(c=>{n(c)})})})};return{batch:l=>{let c;t++;try{c=l()}finally{t--,t||o()}return c},batchCalls:l=>(...c)=>{a(()=>{l(...c)})},schedule:a,setNotifyFunction:l=>{n=l},setBatchNotifyFunction:l=>{r=l},setScheduler:l=>{i=l}}}var _e=Eu(),vn,Mt,jn,rl,Ru=(rl=class extends gr{constructor(){super();H(this,vn,!0);H(this,Mt);H(this,jn);z(this,jn,t=>{if(typeof window<"u"&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){g(this,Mt)||this.setEventListener(g(this,jn))}onUnsubscribe(){var t;this.hasListeners()||((t=g(this,Mt))==null||t.call(this),z(this,Mt,void 0))}setEventListener(t){var n;z(this,jn,t),(n=g(this,Mt))==null||n.call(this),z(this,Mt,t(this.setOnline.bind(this)))}setOnline(t){g(this,vn)!==t&&(z(this,vn,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return g(this,vn)}},vn=new WeakMap,Mt=new WeakMap,jn=new WeakMap,rl),Mr=new Ru;function Iu(e){return Math.min(1e3*2**e,3e4)}function xl(e){return(e??"online")==="online"?Mr.isOnline():!0}var Ns=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function gl(e){let t=!1,n=0,r;const i=ks(),a=()=>i.status!=="pending",o=y=>{var v;if(!a()){const b=new Ns(y);m(b),(v=e.onCancel)==null||v.call(e,b)}},l=()=>{t=!0},c=()=>{t=!1},u=()=>ni.isFocused()&&(e.networkMode==="always"||Mr.isOnline())&&e.canRun(),d=()=>xl(e.networkMode)&&e.canRun(),h=y=>{a()||(r==null||r(),i.resolve(y))},m=y=>{a()||(r==null||r(),i.reject(y))},p=()=>new Promise(y=>{var v;r=b=>{(a()||u())&&y(b)},(v=e.onPause)==null||v.call(e)}).then(()=>{var y;r=void 0,a()||(y=e.onContinue)==null||y.call(e)}),w=()=>{if(a())return;let y;const v=n===0?e.initialPromise:void 0;try{y=v??e.fn()}catch(b){y=Promise.reject(b)}Promise.resolve(y).then(h).catch(b=>{var j;if(a())return;const N=e.retry??(lr.isServer()?0:3),k=e.retryDelay??Iu,_=typeof k=="function"?k(n,b):k,D=N===!0||typeof N=="number"&&nu()?void 0:p()).then(()=>{t?m(b):w()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r==null||r(),i),cancelRetry:l,continueRetry:c,canStart:d,start:()=>(d()?w():p().then(w),i)}}var Gt,sl,bl=(sl=class{constructor(){H(this,Gt)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),ys(this.gcTime)&&z(this,Gt,Wt.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(lr.isServer()?1/0:300*1e3))}clearGcTimeout(){g(this,Gt)!==void 0&&(Wt.clearTimeout(g(this,Gt)),z(this,Gt,void 0))}},Gt=new WeakMap,sl);function Tu(e){return{onFetch:(t,n)=>{var d,h,m,p,w;const r=t.options,i=(m=(h=(d=t.fetchOptions)==null?void 0:d.meta)==null?void 0:h.fetchMore)==null?void 0:m.direction,a=((p=t.state.data)==null?void 0:p.pages)||[],o=((w=t.state.data)==null?void 0:w.pageParams)||[];let l={pages:[],pageParams:[]},c=0;const u=async()=>{let y=!1;const v=k=>{Cu(k,()=>t.signal,()=>y=!0)},b=ml(t.options,t.fetchOptions),N=async(k,_,D)=>{if(y)return Promise.reject(t.signal.reason);if(_==null&&k.pages.length)return Promise.resolve(k);const B=(()=>{const O={client:t.client,queryKey:t.queryKey,pageParam:_,direction:D?"backward":"forward",meta:t.options.meta};return v(O),O})(),F=await b(B),{maxPages:C}=t.options,M=D?_u:Su;return{pages:M(k.pages,F,C),pageParams:M(k.pageParams,_,C)}};if(i&&a.length){const k=i==="backward",_=k?yl:Ss,D={pages:a,pageParams:o},j=_(r,D);l=await N(D,j,k)}else{const k=e??a.length;do{const _=c===0?o[0]??r.initialPageParam:Ss(r,l);if(c>0&&_==null)break;l=await N(l,_),c++}while(c{var y,v;return(v=(y=t.options).persister)==null?void 0:v.call(y,u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=u}}}function Ss(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function yl(e,{pages:t,pageParams:n}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n):void 0}function Au(e,t){return t?Ss(e,t)!=null:!1}function Lu(e,t){return!t||!e.getPreviousPageParam?!1:yl(e,t)!=null}var kn,Jt,Nn,Ze,Xt,Se,hr,Yt,Ve,wl,Nt,il,Mu=(il=class extends bl{constructor(t){super();H(this,Ve);H(this,kn);H(this,Jt);H(this,Nn);H(this,Ze);H(this,Xt);H(this,Se);H(this,hr);H(this,Yt);z(this,Yt,!1),z(this,hr,t.defaultOptions),this.setOptions(t.options),this.observers=[],z(this,Xt,t.client),z(this,Ze,g(this,Xt).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,z(this,Jt,Za(this.options)),this.state=t.state??g(this,Jt),this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return g(this,kn)}get promise(){var t;return(t=g(this,Se))==null?void 0:t.promise}setOptions(t){if(this.options={...g(this,hr),...t},t!=null&&t._type&&z(this,kn,t._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=Za(this.options);n.data!==void 0&&(this.setState(Ya(n.data,n.dataUpdatedAt)),z(this,Jt,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&g(this,Ze).remove(this)}setData(t,n){const r=js(this.state.data,t,this.options);return ne(this,Ve,Nt).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t){ne(this,Ve,Nt).call(this,{type:"setState",state:t})}cancel(t){var r,i;const n=(r=g(this,Se))==null?void 0:r.promise;return(i=g(this,Se))==null||i.cancel(t),n?n.then(Be).catch(Be):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return g(this,Jt)}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(t=>Ge(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===si||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>$t(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!hl(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=g(this,Se))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=g(this,Se))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),g(this,Ze).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(g(this,Se)&&(g(this,Yt)||ne(this,Ve,wl).call(this)?g(this,Se).cancel({revert:!0}):g(this,Se).cancelRetry()),this.scheduleGc()),g(this,Ze).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||ne(this,Ve,Nt).call(this,{type:"invalidate"})}async fetch(t,n){var u,d,h,m,p,w,y,v,b,N,k;if(this.state.fetchStatus!=="idle"&&((u=g(this,Se))==null?void 0:u.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(g(this,Se))return g(this,Se).continueRetry(),g(this,Se).promise}if(t&&this.setOptions(t),!this.options.queryFn){const _=this.observers.find(D=>D.options.queryFn);_&&this.setOptions(_.options)}const r=new AbortController,i=_=>{Object.defineProperty(_,"signal",{enumerable:!0,get:()=>(z(this,Yt,!0),r.signal)})},a=()=>{const _=ml(this.options,n),j=(()=>{const B={client:g(this,Xt),queryKey:this.queryKey,meta:this.meta};return i(B),B})();return z(this,Yt,!1),this.options.persister?this.options.persister(_,j,this):_(j)},l=(()=>{const _={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:g(this,Xt),state:this.state,fetchFn:a};return i(_),_})(),c=g(this,kn)==="infinite"?Tu(this.options.pages):this.options.behavior;c==null||c.onFetch(l,this),z(this,Nn,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((d=l.fetchOptions)==null?void 0:d.meta))&&ne(this,Ve,Nt).call(this,{type:"fetch",meta:(h=l.fetchOptions)==null?void 0:h.meta}),z(this,Se,gl({initialPromise:n==null?void 0:n.initialPromise,fn:l.fetchFn,onCancel:_=>{_ instanceof Ns&&_.revert&&this.setState({...g(this,Nn),fetchStatus:"idle"}),r.abort()},onFail:(_,D)=>{ne(this,Ve,Nt).call(this,{type:"failed",failureCount:_,error:D})},onPause:()=>{ne(this,Ve,Nt).call(this,{type:"pause"})},onContinue:()=>{ne(this,Ve,Nt).call(this,{type:"continue"})},retry:l.options.retry,retryDelay:l.options.retryDelay,networkMode:l.options.networkMode,canRun:()=>!0}));try{const _=await g(this,Se).start();if(_===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(_),(p=(m=g(this,Ze).config).onSuccess)==null||p.call(m,_,this),(y=(w=g(this,Ze).config).onSettled)==null||y.call(w,_,this.state.error,this),_}catch(_){if(_ instanceof Ns){if(_.silent)return g(this,Se).promise;if(_.revert){if(this.state.data===void 0)throw _;return this.state.data}}throw ne(this,Ve,Nt).call(this,{type:"error",error:_}),(b=(v=g(this,Ze).config).onError)==null||b.call(v,_,this),(k=(N=g(this,Ze).config).onSettled)==null||k.call(N,this.state.data,_,this),_}finally{this.scheduleGc()}}},kn=new WeakMap,Jt=new WeakMap,Nn=new WeakMap,Ze=new WeakMap,Xt=new WeakMap,Se=new WeakMap,hr=new WeakMap,Yt=new WeakMap,Ve=new WeakSet,wl=function(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"},Nt=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...vl(r.data,this.options),fetchMeta:t.meta??null};case"success":const i={...r,...Ya(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return z(this,Nn,t.manual?i:void 0),i;case"error":const a=t.error;return{...r,error:a,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:a,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),_e.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),g(this,Ze).notify({query:this,type:"updated",action:t})})},il);function vl(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:xl(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function Ya(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Za(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var qe,re,pr,Oe,Zt,Sn,St,Dt,mr,_n,Cn,en,tn,Ot,Pn,ae,tr,_s,Cs,Ps,Es,Rs,Is,Ts,kl,al,jl=(al=class extends gr{constructor(t,n){super();H(this,ae);H(this,qe);H(this,re);H(this,pr);H(this,Oe);H(this,Zt);H(this,Sn);H(this,St);H(this,Dt);H(this,mr);H(this,_n);H(this,Cn);H(this,en);H(this,tn);H(this,Ot);H(this,Pn,new Set);this.options=n,z(this,qe,t),z(this,Dt,null),z(this,St,ks()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(g(this,re).addObserver(this),eo(g(this,re),this.options)?ne(this,ae,tr).call(this):this.updateResult(),ne(this,ae,Es).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return As(g(this,re),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return As(g(this,re),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,ne(this,ae,Rs).call(this),ne(this,ae,Is).call(this),g(this,re).removeObserver(this)}setOptions(t){const n=this.options,r=g(this,re);if(this.options=g(this,qe).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Ge(this.options.enabled,g(this,re))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");ne(this,ae,Ts).call(this),g(this,re).setOptions(this.options),n._defaulted&&!ws(this.options,n)&&g(this,qe).getQueryCache().notify({type:"observerOptionsUpdated",query:g(this,re),observer:this});const i=this.hasListeners();i&&to(g(this,re),r,this.options,n)&&ne(this,ae,tr).call(this),this.updateResult(),i&&(g(this,re)!==r||Ge(this.options.enabled,g(this,re))!==Ge(n.enabled,g(this,re))||$t(this.options.staleTime,g(this,re))!==$t(n.staleTime,g(this,re)))&&ne(this,ae,_s).call(this);const a=ne(this,ae,Cs).call(this);i&&(g(this,re)!==r||Ge(this.options.enabled,g(this,re))!==Ge(n.enabled,g(this,re))||a!==g(this,Ot))&&ne(this,ae,Ps).call(this,a)}getOptimisticResult(t){const n=g(this,qe).getQueryCache().build(g(this,qe),t),r=this.createResult(n,t);return Ou(this,r)&&(z(this,Oe,r),z(this,Sn,this.options),z(this,Zt,g(this,re).state)),r}getCurrentResult(){return g(this,Oe)}trackResult(t,n){return new Proxy(t,{get:(r,i)=>(this.trackProp(i),n==null||n(i),i==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&g(this,St).status==="pending"&&g(this,St).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,i))})}trackProp(t){g(this,Pn).add(t)}getCurrentQuery(){return g(this,re)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=g(this,qe).defaultQueryOptions(t),r=g(this,qe).getQueryCache().build(g(this,qe),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return ne(this,ae,tr).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),g(this,Oe)))}createResult(t,n){var C;const r=g(this,re),i=this.options,a=g(this,Oe),o=g(this,Zt),l=g(this,Sn),u=t!==r?t.state:g(this,pr),{state:d}=t;let h={...d},m=!1,p;if(n._optimisticResults){const M=this.hasListeners(),O=!M&&eo(t,n),I=M&&to(t,r,n,i);(O||I)&&(h={...h,...vl(d.data,t.options)}),n._optimisticResults==="isRestoring"&&(h.fetchStatus="idle")}let{error:w,errorUpdatedAt:y,status:v}=h;p=h.data;let b=!1;if(n.placeholderData!==void 0&&p===void 0&&v==="pending"){let M;a!=null&&a.isPlaceholderData&&n.placeholderData===(l==null?void 0:l.placeholderData)?(M=a.data,b=!0):M=typeof n.placeholderData=="function"?n.placeholderData((C=g(this,Cn))==null?void 0:C.state.data,g(this,Cn)):n.placeholderData,M!==void 0&&(v="success",p=js(a==null?void 0:a.data,M,n),m=!0)}if(n.select&&p!==void 0&&!b)if(a&&p===(o==null?void 0:o.data)&&n.select===g(this,mr))p=g(this,_n);else try{z(this,mr,n.select),p=n.select(p),p=js(a==null?void 0:a.data,p,n),z(this,_n,p),z(this,Dt,null)}catch(M){z(this,Dt,M)}g(this,Dt)&&(w=g(this,Dt),p=g(this,_n),y=Date.now(),v="error");const N=h.fetchStatus==="fetching",k=v==="pending",_=v==="error",D=k&&N,j=p!==void 0,F={status:v,fetchStatus:h.fetchStatus,isPending:k,isSuccess:v==="success",isError:_,isInitialLoading:D,isLoading:D,data:p,dataUpdatedAt:h.dataUpdatedAt,error:w,errorUpdatedAt:y,failureCount:h.fetchFailureCount,failureReason:h.fetchFailureReason,errorUpdateCount:h.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:h.dataUpdateCount>u.dataUpdateCount||h.errorUpdateCount>u.errorUpdateCount,isFetching:N,isRefetching:N&&!k,isLoadingError:_&&!j,isPaused:h.fetchStatus==="paused",isPlaceholderData:m,isRefetchError:_&&j,isStale:ii(t,n),refetch:this.refetch,promise:g(this,St),isEnabled:Ge(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const M=F.data!==void 0,O=F.status==="error"&&!M,I=P=>{O?P.reject(F.error):M&&P.resolve(F.data)},X=()=>{const P=z(this,St,F.promise=ks());I(P)},q=g(this,St);switch(q.status){case"pending":t.queryHash===r.queryHash&&I(q);break;case"fulfilled":(O||F.data!==q.value)&&X();break;case"rejected":(!O||F.error!==q.reason)&&X();break}}return F}updateResult(){const t=g(this,Oe),n=this.createResult(g(this,re),this.options);if(z(this,Zt,g(this,re).state),z(this,Sn,this.options),g(this,Zt).data!==void 0&&z(this,Cn,g(this,re)),ws(n,t))return;z(this,Oe,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:i}=this.options,a=typeof i=="function"?i():i;if(a==="all"||!a&&!g(this,Pn).size)return!0;const o=new Set(a??g(this,Pn));return this.options.throwOnError&&o.add("error"),Object.keys(g(this,Oe)).some(l=>{const c=l;return g(this,Oe)[c]!==t[c]&&o.has(c)})};ne(this,ae,kl).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&ne(this,ae,Es).call(this)}},qe=new WeakMap,re=new WeakMap,pr=new WeakMap,Oe=new WeakMap,Zt=new WeakMap,Sn=new WeakMap,St=new WeakMap,Dt=new WeakMap,mr=new WeakMap,_n=new WeakMap,Cn=new WeakMap,en=new WeakMap,tn=new WeakMap,Ot=new WeakMap,Pn=new WeakMap,ae=new WeakSet,tr=function(t){ne(this,ae,Ts).call(this);let n=g(this,re).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(Be)),n},_s=function(){ne(this,ae,Rs).call(this);const t=$t(this.options.staleTime,g(this,re));if(lr.isServer()||g(this,Oe).isStale||!ys(t))return;const r=hl(g(this,Oe).dataUpdatedAt,t)+1;z(this,en,Wt.setTimeout(()=>{g(this,Oe).isStale||this.updateResult()},r))},Cs=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(g(this,re)):this.options.refetchInterval)??!1},Ps=function(t){ne(this,ae,Is).call(this),z(this,Ot,t),!(lr.isServer()||Ge(this.options.enabled,g(this,re))===!1||!ys(g(this,Ot))||g(this,Ot)===0)&&z(this,tn,Wt.setInterval(()=>{(this.options.refetchIntervalInBackground||ni.isFocused())&&ne(this,ae,tr).call(this)},g(this,Ot)))},Es=function(){ne(this,ae,_s).call(this),ne(this,ae,Ps).call(this,ne(this,ae,Cs).call(this))},Rs=function(){g(this,en)!==void 0&&(Wt.clearTimeout(g(this,en)),z(this,en,void 0))},Is=function(){g(this,tn)!==void 0&&(Wt.clearInterval(g(this,tn)),z(this,tn,void 0))},Ts=function(){const t=g(this,qe).getQueryCache().build(g(this,qe),this.options);if(t===g(this,re))return;const n=g(this,re);z(this,re,t),z(this,pr,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},kl=function(t){_e.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(g(this,Oe))}),g(this,qe).getQueryCache().notify({query:g(this,re),type:"observerResultsUpdated"})})},al);function Du(e,t){return Ge(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&Ge(t.retryOnMount,e)===!1)}function eo(e,t){return Du(e,t)||e.state.data!==void 0&&As(e,t,t.refetchOnMount)}function As(e,t,n){if(Ge(t.enabled,e)!==!1&&$t(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&ii(e,t)}return!1}function to(e,t,n,r){return(e!==t||Ge(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&ii(e,n)}function ii(e,t){return Ge(t.enabled,e)!==!1&&e.isStaleByTime($t(t.staleTime,e))}function Ou(e,t){return!ws(e.getCurrentResult(),t)}var Fu=class extends jl{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type="infinite",super.setOptions(e)}getOptimisticResult(e){return e._type="infinite",super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){var w,y;const{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:l}=r,c=(y=(w=n.fetchMeta)==null?void 0:w.fetchMore)==null?void 0:y.direction,u=o&&c==="forward",d=i&&c==="forward",h=o&&c==="backward",m=i&&c==="backward";return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:Au(t,n.data),hasPreviousPage:Lu(t,n.data),isFetchNextPageError:u,isFetchingNextPage:d,isFetchPreviousPageError:h,isFetchingPreviousPage:m,isRefetchError:l&&!u&&!h,isRefetching:a&&!d&&!m}}},fr,mt,Te,nn,ft,Tt,ol,zu=(ol=class extends bl{constructor(t){super();H(this,ft);H(this,fr);H(this,mt);H(this,Te);H(this,nn);z(this,fr,t.client),this.mutationId=t.mutationId,z(this,Te,t.mutationCache),z(this,mt,[]),this.state=t.state||qu(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){g(this,mt).includes(t)||(g(this,mt).push(t),this.clearGcTimeout(),g(this,Te).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){z(this,mt,g(this,mt).filter(n=>n!==t)),this.scheduleGc(),g(this,Te).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){g(this,mt).length||(this.state.status==="pending"?this.scheduleGc():g(this,Te).remove(this))}continue(){var t;return((t=g(this,nn))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,l,c,u,d,h,m,p,w,y,v,b,N,k,_,D,j,B;const n=()=>{ne(this,ft,Tt).call(this,{type:"continue"})},r={client:g(this,fr),meta:this.options.meta,mutationKey:this.options.mutationKey};z(this,nn,gl({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(F,C)=>{ne(this,ft,Tt).call(this,{type:"failed",failureCount:F,error:C})},onPause:()=>{ne(this,ft,Tt).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>g(this,Te).canRun(this)}));const i=this.state.status==="pending",a=!g(this,nn).canStart();try{if(i)n();else{ne(this,ft,Tt).call(this,{type:"pending",variables:t,isPaused:a}),g(this,Te).config.onMutate&&await g(this,Te).config.onMutate(t,this,r);const C=await((l=(o=this.options).onMutate)==null?void 0:l.call(o,t,r));C!==this.state.context&&ne(this,ft,Tt).call(this,{type:"pending",context:C,variables:t,isPaused:a})}const F=await g(this,nn).start();return await((u=(c=g(this,Te).config).onSuccess)==null?void 0:u.call(c,F,t,this.state.context,this,r)),await((h=(d=this.options).onSuccess)==null?void 0:h.call(d,F,t,this.state.context,r)),await((p=(m=g(this,Te).config).onSettled)==null?void 0:p.call(m,F,null,this.state.variables,this.state.context,this,r)),await((y=(w=this.options).onSettled)==null?void 0:y.call(w,F,null,t,this.state.context,r)),ne(this,ft,Tt).call(this,{type:"success",data:F}),F}catch(F){try{await((b=(v=g(this,Te).config).onError)==null?void 0:b.call(v,F,t,this.state.context,this,r))}catch(C){Promise.reject(C)}try{await((k=(N=this.options).onError)==null?void 0:k.call(N,F,t,this.state.context,r))}catch(C){Promise.reject(C)}try{await((D=(_=g(this,Te).config).onSettled)==null?void 0:D.call(_,void 0,F,this.state.variables,this.state.context,this,r))}catch(C){Promise.reject(C)}try{await((B=(j=this.options).onSettled)==null?void 0:B.call(j,void 0,F,t,this.state.context,r))}catch(C){Promise.reject(C)}throw ne(this,ft,Tt).call(this,{type:"error",error:F}),F}finally{g(this,Te).runNext(this)}}},fr=new WeakMap,mt=new WeakMap,Te=new WeakMap,nn=new WeakMap,ft=new WeakSet,Tt=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),_e.batch(()=>{g(this,mt).forEach(r=>{r.onMutationUpdate(t)}),g(this,Te).notify({mutation:this,type:"updated",action:t})})},ol);function qu(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var _t,at,xr,ll,Bu=(ll=class extends gr{constructor(t={}){super();H(this,_t);H(this,at);H(this,xr);this.config=t,z(this,_t,new Set),z(this,at,new Map),z(this,xr,0)}build(t,n,r){const i=new zu({client:t,mutationCache:this,mutationId:++kr(this,xr)._,options:t.defaultMutationOptions(n),state:r});return this.add(i),i}add(t){g(this,_t).add(t);const n=Sr(t);if(typeof n=="string"){const r=g(this,at).get(n);r?r.push(t):g(this,at).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(g(this,_t).delete(t)){const n=Sr(t);if(typeof n=="string"){const r=g(this,at).get(n);if(r)if(r.length>1){const i=r.indexOf(t);i!==-1&&r.splice(i,1)}else r[0]===t&&g(this,at).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=Sr(t);if(typeof n=="string"){const r=g(this,at).get(n),i=r==null?void 0:r.find(a=>a.state.status==="pending");return!i||i===t}else return!0}runNext(t){var r;const n=Sr(t);if(typeof n=="string"){const i=(r=g(this,at).get(n))==null?void 0:r.find(a=>a!==t&&a.state.isPaused);return(i==null?void 0:i.continue())??Promise.resolve()}else return Promise.resolve()}clear(){_e.batch(()=>{g(this,_t).forEach(t=>{this.notify({type:"removed",mutation:t})}),g(this,_t).clear(),g(this,at).clear()})}getAll(){return Array.from(g(this,_t))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>Ga(n,r))}findAll(t={}){return this.getAll().filter(n=>Ga(t,n))}notify(t){_e.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return _e.batch(()=>Promise.all(t.map(n=>n.continue().catch(Be))))}},_t=new WeakMap,at=new WeakMap,xr=new WeakMap,ll);function Sr(e){var t;return(t=e.options.scope)==null?void 0:t.id}var xt,cl,$u=(cl=class extends gr{constructor(t={}){super();H(this,xt);this.config=t,z(this,xt,new Map)}build(t,n,r){const i=n.queryKey,a=n.queryHash??ri(i,n);let o=this.get(a);return o||(o=new Mu({client:t,queryKey:i,queryHash:a,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(i)}),this.add(o)),o}add(t){g(this,xt).has(t.queryHash)||(g(this,xt).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=g(this,xt).get(t.queryHash);n&&(t.destroy(),n===t&&g(this,xt).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){_e.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return g(this,xt).get(t)}getAll(){return[...g(this,xt).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>Va(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>Va(t,r)):n}notify(t){_e.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){_e.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){_e.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},xt=new WeakMap,cl),we,Ft,zt,En,Rn,qt,In,Tn,ul,Uu=(ul=class{constructor(e={}){H(this,we);H(this,Ft);H(this,zt);H(this,En);H(this,Rn);H(this,qt);H(this,In);H(this,Tn);z(this,we,e.queryCache||new $u),z(this,Ft,e.mutationCache||new Bu),z(this,zt,e.defaultOptions||{}),z(this,En,new Map),z(this,Rn,new Map),z(this,qt,0)}mount(){kr(this,qt)._++,g(this,qt)===1&&(z(this,In,ni.subscribe(async e=>{e&&(await this.resumePausedMutations(),g(this,we).onFocus())})),z(this,Tn,Mr.subscribe(async e=>{e&&(await this.resumePausedMutations(),g(this,we).onOnline())})))}unmount(){var e,t;kr(this,qt)._--,g(this,qt)===0&&((e=g(this,In))==null||e.call(this),z(this,In,void 0),(t=g(this,Tn))==null||t.call(this),z(this,Tn,void 0))}isFetching(e){return g(this,we).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return g(this,Ft).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=g(this,we).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=g(this,we).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime($t(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return g(this,we).findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),i=g(this,we).get(r.queryHash),a=i==null?void 0:i.state.data,o=ju(t,a);if(o!==void 0)return g(this,we).build(this,r).setData(o,{...n,manual:!0})}setQueriesData(e,t,n){return _e.batch(()=>g(this,we).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=g(this,we).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=g(this,we);_e.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=g(this,we);return _e.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=_e.batch(()=>g(this,we).findAll(e).map(i=>i.cancel(n)));return Promise.all(r).then(Be).catch(Be)}invalidateQueries(e,t={}){return _e.batch(()=>(g(this,we).findAll(e).forEach(n=>{n.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=_e.batch(()=>g(this,we).findAll(e).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let a=i.fetch(void 0,n);return n.throwOnError||(a=a.catch(Be)),i.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(r).then(Be)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=g(this,we).build(this,t);return n.isStaleByTime($t(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Be).catch(Be)}fetchInfiniteQuery(e){return e._type="infinite",this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Be).catch(Be)}ensureInfiniteQueryData(e){return e._type="infinite",this.ensureQueryData(e)}resumePausedMutations(){return Mr.isOnline()?g(this,Ft).resumePausedMutations():Promise.resolve()}getQueryCache(){return g(this,we)}getMutationCache(){return g(this,Ft)}getDefaultOptions(){return g(this,zt)}setDefaultOptions(e){z(this,zt,e)}setQueryDefaults(e,t){g(this,En).set(ar(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...g(this,En).values()],n={};return t.forEach(r=>{or(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){g(this,Rn).set(ar(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...g(this,Rn).values()],n={};return t.forEach(r=>{or(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...g(this,zt).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=ri(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===si&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...g(this,zt).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){g(this,we).clear(),g(this,Ft).clear()}},we=new WeakMap,Ft=new WeakMap,zt=new WeakMap,En=new WeakMap,Rn=new WeakMap,qt=new WeakMap,In=new WeakMap,Tn=new WeakMap,ul),Nl=Ce.createContext(void 0),Sl=e=>{const t=Ce.useContext(Nl);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Hu=({client:e,children:t})=>(Ce.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),s.jsx(Nl.Provider,{value:e,children:t})),_l=Ce.createContext(!1),Ku=()=>Ce.useContext(_l);_l.Provider;function Qu(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Wu=Ce.createContext(Qu()),Vu=()=>Ce.useContext(Wu),Gu=(e,t,n)=>{const r=n!=null&&n.state.error&&typeof e.throwOnError=="function"?fl(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},Ju=e=>{Ce.useEffect(()=>{e.clearReset()},[e])},Xu=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||fl(n,[e.error,r])),Yu=e=>{if(e.suspense){const n=i=>i==="static"?i:Math.max(i??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...i)=>n(r(...i)):n(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},Zu=(e,t)=>e.isLoading&&e.isFetching&&!t,ed=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,no=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Cl(e,t,n){var m,p,w,y;const r=Ku(),i=Vu(),a=Sl(),o=a.defaultQueryOptions(e);(p=(m=a.getDefaultOptions().queries)==null?void 0:m._experimental_beforeQuery)==null||p.call(m,o);const l=a.getQueryCache().get(o.queryHash);o._optimisticResults=r?"isRestoring":"optimistic",Yu(o),Gu(o,i,l),Ju(i);const c=!a.getQueryCache().get(o.queryHash),[u]=Ce.useState(()=>new t(a,o)),d=u.getOptimisticResult(o),h=!r&&e.subscribed!==!1;if(Ce.useSyncExternalStore(Ce.useCallback(v=>{const b=h?u.subscribe(_e.batchCalls(v)):Be;return u.updateResult(),b},[u,h]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),Ce.useEffect(()=>{u.setOptions(o)},[o,u]),ed(o,d))throw no(o,u,i);if(Xu({result:d,errorResetBoundary:i,throwOnError:o.throwOnError,query:l,suspense:o.suspense}))throw d.error;if((y=(w=a.getDefaultOptions().queries)==null?void 0:w._experimental_afterQuery)==null||y.call(w,o,d),o.experimental_prefetchInRender&&!lr.isServer()&&Zu(d,r)){const v=c?no(o,u,i):l==null?void 0:l.promise;v==null||v.catch(Be).finally(()=>{u.updateResult()})}return o.notifyOnChangeProps?d:u.trackResult(d)}function ve(e,t){return Cl(e,jl)}function Yr(e,t){return Cl(e,Fu)}/** * @license lucide-react v0.468.0 - ISC * * This source code is licensed under the ISC license. @@ -51,12 +51,12 @@ var Ha=e=>{throw TypeError(e)};var Jr=(e,t,n)=>t.has(e)||Ha("Cannot "+n);var g=( * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const On=pe("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/** + */const Dn=pe("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/** * @license lucide-react v0.468.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const Dn=pe("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** + */const On=pe("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** * @license lucide-react v0.468.0 - ISC * * This source code is licensed under the ISC license. @@ -96,7 +96,7 @@ var Ha=e=>{throw TypeError(e)};var Jr=(e,t,n)=>t.has(e)||Ha("Cannot "+n);var g=( * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const Or=pe("KeyRound",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);/** + */const Dr=pe("KeyRound",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);/** * @license lucide-react v0.468.0 - ISC * * This source code is licensed under the ISC license. @@ -161,21 +161,21 @@ var Ha=e=>{throw TypeError(e)};var Jr=(e,t,n)=>t.has(e)||Ha("Cannot "+n);var g=( * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const un=pe("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function ud(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const dd=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,hd=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,pd={};function so(e,t){return(pd.jsx?hd:dd).test(e)}const md=/[ \t\n\f\r]/g;function fd(e){return typeof e=="object"?e.type==="text"?io(e.value):!1:io(e)}function io(e){return e.replace(md,"")===""}class br{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}br.prototype.normal={};br.prototype.property={};br.prototype.space=void 0;function Ml(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new br(n,r,t)}function Ms(e){return e.toLowerCase()}class Ue{constructor(t,n){this.attribute=n,this.property=t}}Ue.prototype.attribute="";Ue.prototype.booleanish=!1;Ue.prototype.boolean=!1;Ue.prototype.commaOrSpaceSeparated=!1;Ue.prototype.commaSeparated=!1;Ue.prototype.defined=!1;Ue.prototype.mustUseProperty=!1;Ue.prototype.number=!1;Ue.prototype.overloadedBoolean=!1;Ue.prototype.property="";Ue.prototype.spaceSeparated=!1;Ue.prototype.space=void 0;let xd=0;const V=dn(),je=dn(),Os=dn(),T=dn(),he=dn(),rn=dn(),We=dn();function dn(){return 2**++xd}const Ds=Object.freeze(Object.defineProperty({__proto__:null,boolean:V,booleanish:je,commaOrSpaceSeparated:We,commaSeparated:rn,number:T,overloadedBoolean:Os,spaceSeparated:he},Symbol.toStringTag,{value:"Module"})),Zr=Object.keys(Ds);class li extends Ue{constructor(t,n,r,i){let a=-1;if(super(t,n),ao(this,"space",i),typeof r=="number")for(;++a4&&n.slice(0,4)==="data"&&vd.test(t)){if(t.charAt(4)==="-"){const a=t.slice(5).replace(oo,Nd);r="data"+a.charAt(0).toUpperCase()+a.slice(1)}else{const a=t.slice(4);if(!oo.test(a)){let o=a.replace(wd,kd);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}i=li}return new i(r,t)}function kd(e){return"-"+e.toLowerCase()}function Nd(e){return e.charAt(1).toUpperCase()}const Sd=Ml([Ol,gd,zl,ql,Bl],"html"),ci=Ml([Ol,bd,zl,ql,Bl],"svg");function _d(e){return e.join(" ").trim()}var fn={},es,lo;function Cd(){if(lo)return es;lo=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,a=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,o=/^[;\s]*/,l=/^\s+|\s+$/g,c=` -`,u="/",d="*",h="",m="comment",p="declaration";function w(v,b){if(typeof v!="string")throw new TypeError("First argument must be a string");if(!v)return[];b=b||{};var N=1,k=1;function _(q){var P=q.match(t);P&&(N+=P.length);var U=q.lastIndexOf(c);k=~U?q.length-U:k+q.length}function O(){var q={line:N,column:k};return function(P){return P.position=new j(q),C(),P}}function j(q){this.start=q,this.end={line:N,column:k},this.source=b.source}j.prototype.content=v;function B(q){var P=new Error(b.source+":"+N+":"+k+": "+q);if(P.reason=q,P.filename=b.source,P.line=N,P.column=k,P.source=v,!b.silent)throw P}function F(q){var P=q.exec(v);if(P){var U=P[0];return _(U),v=v.slice(U.length),P}}function C(){F(n)}function M(q){var P;for(q=q||[];P=D();)P!==!1&&q.push(P);return q}function D(){var q=O();if(!(u!=v.charAt(0)||d!=v.charAt(1))){for(var P=2;h!=v.charAt(P)&&(d!=v.charAt(P)||u!=v.charAt(P+1));)++P;if(P+=2,h===v.charAt(P-1))return B("End of comment missing");var U=v.slice(2,P-2);return k+=2,_(U),v=v.slice(P),k+=2,q({type:m,comment:U})}}function I(){var q=O(),P=F(r);if(P){if(D(),!F(i))return B("property missing ':'");var U=F(a),te=q({type:p,property:y(P[0].replace(e,h)),value:U?y(U[0].replace(e,h)):h});return F(o),te}}function X(){var q=[];M(q);for(var P;P=I();)P!==!1&&(q.push(P),M(q));return q}return C(),X()}function y(v){return v?v.replace(l,h):h}return es=w,es}var co;function Pd(){if(co)return fn;co=1;var e=fn&&fn.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(fn,"__esModule",{value:!0}),fn.default=n;const t=e(Cd());function n(r,i){let a=null;if(!r||typeof r!="string")return a;const o=(0,t.default)(r),l=typeof i=="function";return o.forEach(c=>{if(c.type!=="declaration")return;const{property:u,value:d}=c;l?i(u,d,c):d&&(a=a||{},a[u]=d)}),a}return fn}var Vn={},uo;function Ed(){if(uo)return Vn;uo=1,Object.defineProperty(Vn,"__esModule",{value:!0}),Vn.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,a=function(u){return!u||n.test(u)||e.test(u)},o=function(u,d){return d.toUpperCase()},l=function(u,d){return"".concat(d,"-")},c=function(u,d){return d===void 0&&(d={}),a(u)?u:(u=u.toLowerCase(),d.reactCompat?u=u.replace(i,l):u=u.replace(r,l),u.replace(t,o))};return Vn.camelCase=c,Vn}var Gn,ho;function Rd(){if(ho)return Gn;ho=1;var e=Gn&&Gn.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(Pd()),n=Ed();function r(i,a){var o={};return!i||typeof i!="string"||(0,t.default)(i,function(l,c){l&&c&&(o[(0,n.camelCase)(l,a)]=c)}),o}return r.default=r,Gn=r,Gn}var Id=Rd();const Td=Zs(Id),$l=Ul("end"),ui=Ul("start");function Ul(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function Ad(e){const t=ui(e),n=$l(e);if(t&&n)return{start:t,end:n}}function nr(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?po(e.position):"start"in e||"end"in e?po(e):"line"in e||"column"in e?Fs(e):""}function Fs(e){return mo(e&&e.line)+":"+mo(e&&e.column)}function po(e){return Fs(e&&e.start)+"-"+Fs(e&&e.end)}function mo(e){return e&&typeof e=="number"?e:1}class Le extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",a={},o=!1;if(n&&("line"in n&&"column"in n?a={place:n}:"start"in n&&"end"in n?a={place:n}:"type"in n?a={ancestors:[n],place:n.position}:a={...n}),typeof t=="string"?i=t:!a.cause&&t&&(o=!0,i=t.message,a.cause=t),!a.ruleId&&!a.source&&typeof r=="string"){const c=r.indexOf(":");c===-1?a.ruleId=r:(a.source=r.slice(0,c),a.ruleId=r.slice(c+1))}if(!a.place&&a.ancestors&&a.ancestors){const c=a.ancestors[a.ancestors.length-1];c&&(a.place=c.position)}const l=a.place&&"start"in a.place?a.place.start:a.place;this.ancestors=a.ancestors||void 0,this.cause=a.cause||void 0,this.column=l?l.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=l?l.line:void 0,this.name=nr(a.place)||"1:1",this.place=a.place||void 0,this.reason=this.message,this.ruleId=a.ruleId||void 0,this.source=a.source||void 0,this.stack=o&&a.cause&&typeof a.cause.stack=="string"?a.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Le.prototype.file="";Le.prototype.name="";Le.prototype.reason="";Le.prototype.message="";Le.prototype.stack="";Le.prototype.column=void 0;Le.prototype.line=void 0;Le.prototype.ancestors=void 0;Le.prototype.cause=void 0;Le.prototype.fatal=void 0;Le.prototype.place=void 0;Le.prototype.ruleId=void 0;Le.prototype.source=void 0;const di={}.hasOwnProperty,Ld=new Map,Md=/[A-Z]/g,Od=new Set(["table","tbody","thead","tfoot","tr"]),Dd=new Set(["td","th"]),Hl="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Fd(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=Qd(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=Kd(n,t.jsx,t.jsxs)}const i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?ci:Sd,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=Kl(i,e,void 0);return a&&typeof a!="string"?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function Kl(e,t,n){if(t.type==="element")return zd(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return qd(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return $d(e,t,n);if(t.type==="mdxjsEsm")return Bd(e,t);if(t.type==="root")return Ud(e,t,n);if(t.type==="text")return Hd(e,t)}function zd(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=ci,e.schema=i),e.ancestors.push(t);const a=Wl(e,t.tagName,!1),o=Wd(e,t);let l=pi(e,t);return Od.has(t.tagName)&&(l=l.filter(function(c){return typeof c=="string"?!fd(c):!0})),Ql(e,o,a,t),hi(o,l),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function qd(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}ur(e,t.position)}function Bd(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);ur(e,t.position)}function $d(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=ci,e.schema=i),e.ancestors.push(t);const a=t.name===null?e.Fragment:Wl(e,t.name,!0),o=Vd(e,t),l=pi(e,t);return Ql(e,o,a,t),hi(o,l),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function Ud(e,t,n){const r={};return hi(r,pi(e,t)),e.create(t,e.Fragment,r,n)}function Hd(e,t){return t.value}function Ql(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function hi(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function Kd(e,t,n){return r;function r(i,a,o,l){const u=Array.isArray(o.children)?n:t;return l?u(a,o,l):u(a,o)}}function Qd(e,t){return n;function n(r,i,a,o){const l=Array.isArray(a.children),c=ui(r);return t(i,a,o,l,{columnNumber:c?c.column-1:void 0,fileName:e,lineNumber:c?c.line:void 0},void 0)}}function Wd(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&di.call(t.properties,i)){const a=Gd(e,i,t.properties[i]);if(a){const[o,l]=a;e.tableCellAlignToStyle&&o==="align"&&typeof l=="string"&&Dd.has(t.tagName)?r=l:n[o]=l}}if(r){const a=n.style||(n.style={});a[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function Vd(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const a=r.data.estree.body[0];a.type;const o=a.expression;o.type;const l=o.properties[0];l.type,Object.assign(n,e.evaluater.evaluateExpression(l.argument))}else ur(e,t.position);else{const i=r.name;let a;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const l=r.value.data.estree.body[0];l.type,a=e.evaluater.evaluateExpression(l.expression)}else ur(e,t.position);else a=r.value===null?!0:r.value;n[i]=a}return n}function pi(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:Ld;for(;++ri?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a0?(bt(e,e.length,0,t),e):t}const go={}.hasOwnProperty;function rh(e){const t={};let n=-1;for(;++n13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"๏ฟฝ":String.fromCodePoint(n)}function bn(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const gt=Ut(/[A-Za-z]/),Je=Ut(/[\dA-Za-z]/),ah=Ut(/[#-'*+\--9=?A-Z^-~]/);function zs(e){return e!==null&&(e<32||e===127)}const qs=Ut(/\d/),oh=Ut(/[\dA-Fa-f]/),lh=Ut(/[!-/:-@[-`{-~]/);function W(e){return e!==null&&e<-2}function $e(e){return e!==null&&(e<0||e===32)}function ie(e){return e===-2||e===-1||e===32}const ch=Ut(new RegExp("\\p{P}|\\p{S}","u")),uh=Ut(/\s/);function Ut(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Bn(e){const t=[];let n=-1,r=0,i=0;for(;++n55295&&a<57344){const l=e.charCodeAt(n+1);a<56320&&l>56319&&l<57344?(o=String.fromCharCode(a,l),i=1):o="๏ฟฝ"}else o=String.fromCharCode(a);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,o=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function xe(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let a=0;return o;function o(c){return ie(c)?(e.enter(n),l(c)):t(c)}function l(c){return ie(c)&&a++o))return;const B=t.events.length;let F=B,C,M;for(;F--;)if(t.events[F][0]==="exit"&&t.events[F][1].type==="chunkFlow"){if(C){M=t.events[F][1].end;break}C=!0}for(b(r),j=B;jk;){const O=n[_];t.containerState=O[1],O[0].exit.call(t,e)}n.length=k}function N(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function fh(e,t,n){return xe(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function yo(e){if(e===null||$e(e)||uh(e))return 1;if(ch(e))return 2}function fi(e,t,n){const r=[];let i=-1;for(;++i1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const h={...e[r][1].end},m={...e[n][1].start};wo(h,-c),wo(m,c),o={type:c>1?"strongSequence":"emphasisSequence",start:h,end:{...e[r][1].end}},l={type:c>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:m},a={type:c>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?"strong":"emphasis",start:{...o.start},end:{...l.end}},e[r][1].end={...o.start},e[n][1].start={...l.end},u=[],e[r][1].end.offset-e[r][1].start.offset&&(u=et(u,[["enter",e[r][1],t],["exit",e[r][1],t]])),u=et(u,[["enter",i,t],["enter",o,t],["exit",o,t],["enter",a,t]]),u=et(u,fi(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=et(u,[["exit",a,t],["enter",l,t],["exit",l,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(d=2,u=et(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):d=0,bt(e,r-1,n-r+3,u),n=r+u.length-d-2;break}}for(n=-1;++n0&&ie(j)?xe(e,N,"linePrefix",a+1)(j):N(j)}function N(j){return j===null||W(j)?e.check(vo,y,_)(j):(e.enter("codeFlowValue"),k(j))}function k(j){return j===null||W(j)?(e.exit("codeFlowValue"),N(j)):(e.consume(j),k)}function _(j){return e.exit("codeFenced"),t(j)}function O(j,B,F){let C=0;return M;function M(P){return j.enter("lineEnding"),j.consume(P),j.exit("lineEnding"),D}function D(P){return j.enter("codeFencedFence"),ie(P)?xe(j,I,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(P):I(P)}function I(P){return P===l?(j.enter("codeFencedFenceSequence"),X(P)):F(P)}function X(P){return P===l?(C++,j.consume(P),X):C>=o?(j.exit("codeFencedFenceSequence"),ie(P)?xe(j,q,"whitespace")(P):q(P)):F(P)}function q(P){return P===null||W(P)?(j.exit("codeFencedFence"),B(P)):F(P)}}}function Ch(e,t,n){const r=this;return i;function i(o){return o===null?n(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),a)}function a(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}const ns={name:"codeIndented",tokenize:Eh},Ph={partial:!0,tokenize:Rh};function Eh(e,t,n){const r=this;return i;function i(u){return e.enter("codeIndented"),xe(e,a,"linePrefix",5)(u)}function a(u){const d=r.events[r.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?o(u):n(u)}function o(u){return u===null?c(u):W(u)?e.attempt(Ph,o,c)(u):(e.enter("codeFlowValue"),l(u))}function l(u){return u===null||W(u)?(e.exit("codeFlowValue"),o(u)):(e.consume(u),l)}function c(u){return e.exit("codeIndented"),t(u)}}function Rh(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):W(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):xe(e,a,"linePrefix",5)(o)}function a(o){const l=r.events[r.events.length-1];return l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(o):W(o)?i(o):n(o)}}const Ih={name:"codeText",previous:Ah,resolve:Th,tokenize:Lh};function Th(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return tthis.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const a=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&Jn(this.left,r),a.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Jn(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Jn(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function ec(e,t,n,r,i,a,o,l,c){const u=c||Number.POSITIVE_INFINITY;let d=0;return h;function h(b){return b===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(b),e.exit(a),m):b===null||b===32||b===41||zs(b)?n(b):(e.enter(r),e.enter(o),e.enter(l),e.enter("chunkString",{contentType:"string"}),y(b))}function m(b){return b===62?(e.enter(a),e.consume(b),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(l),e.enter("chunkString",{contentType:"string"}),p(b))}function p(b){return b===62?(e.exit("chunkString"),e.exit(l),m(b)):b===null||b===60||W(b)?n(b):(e.consume(b),b===92?w:p)}function w(b){return b===60||b===62||b===92?(e.consume(b),p):p(b)}function y(b){return!d&&(b===null||b===41||$e(b))?(e.exit("chunkString"),e.exit(l),e.exit(o),e.exit(r),t(b)):d999||p===null||p===91||p===93&&!c||p===94&&!l&&"_hiddenFootnoteSupport"in o.parser.constructs?n(p):p===93?(e.exit(a),e.enter(i),e.consume(p),e.exit(i),e.exit(r),t):W(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),d):(e.enter("chunkString",{contentType:"string"}),h(p))}function h(p){return p===null||p===91||p===93||W(p)||l++>999?(e.exit("chunkString"),d(p)):(e.consume(p),c||(c=!ie(p)),p===92?m:h)}function m(p){return p===91||p===92||p===93?(e.consume(p),l++,h):h(p)}}function nc(e,t,n,r,i,a){let o;return l;function l(m){return m===34||m===39||m===40?(e.enter(r),e.enter(i),e.consume(m),e.exit(i),o=m===40?41:m,c):n(m)}function c(m){return m===o?(e.enter(i),e.consume(m),e.exit(i),e.exit(r),t):(e.enter(a),u(m))}function u(m){return m===o?(e.exit(a),c(o)):m===null?n(m):W(m)?(e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),xe(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),d(m))}function d(m){return m===o||m===null||W(m)?(e.exit("chunkString"),u(m)):(e.consume(m),m===92?h:d)}function h(m){return m===o||m===92?(e.consume(m),d):d(m)}}function rr(e,t){let n;return r;function r(i){return W(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):ie(i)?xe(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const $h={name:"definition",tokenize:Hh},Uh={partial:!0,tokenize:Kh};function Hh(e,t,n){const r=this;let i;return a;function a(p){return e.enter("definition"),o(p)}function o(p){return tc.call(r,e,l,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function l(p){return i=bn(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),c):n(p)}function c(p){return $e(p)?rr(e,u)(p):u(p)}function u(p){return ec(e,d,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function d(p){return e.attempt(Uh,h,h)(p)}function h(p){return ie(p)?xe(e,m,"whitespace")(p):m(p)}function m(p){return p===null||W(p)?(e.exit("definition"),r.parser.defined.push(i),t(p)):n(p)}}function Kh(e,t,n){return r;function r(l){return $e(l)?rr(e,i)(l):n(l)}function i(l){return nc(e,a,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function a(l){return ie(l)?xe(e,o,"whitespace")(l):o(l)}function o(l){return l===null||W(l)?t(l):n(l)}}const Qh={name:"hardBreakEscape",tokenize:Wh};function Wh(e,t,n){return r;function r(a){return e.enter("hardBreakEscape"),e.consume(a),i}function i(a){return W(a)?(e.exit("hardBreakEscape"),t(a)):n(a)}}const Vh={name:"headingAtx",resolve:Gh,tokenize:Jh};function Gh(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},a={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},bt(e,r,n-r+1,[["enter",i,t],["enter",a,t],["exit",a,t],["exit",i,t]])),e}function Jh(e,t,n){let r=0;return i;function i(d){return e.enter("atxHeading"),a(d)}function a(d){return e.enter("atxHeadingSequence"),o(d)}function o(d){return d===35&&r++<6?(e.consume(d),o):d===null||$e(d)?(e.exit("atxHeadingSequence"),l(d)):n(d)}function l(d){return d===35?(e.enter("atxHeadingSequence"),c(d)):d===null||W(d)?(e.exit("atxHeading"),t(d)):ie(d)?xe(e,l,"whitespace")(d):(e.enter("atxHeadingText"),u(d))}function c(d){return d===35?(e.consume(d),c):(e.exit("atxHeadingSequence"),l(d))}function u(d){return d===null||d===35||$e(d)?(e.exit("atxHeadingText"),l(d)):(e.consume(d),u)}}const Xh=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],ko=["pre","script","style","textarea"],Yh={concrete:!0,name:"htmlFlow",resolveTo:tp,tokenize:np},Zh={partial:!0,tokenize:sp},ep={partial:!0,tokenize:rp};function tp(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function np(e,t,n){const r=this;let i,a,o,l,c;return u;function u(x){return d(x)}function d(x){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(x),h}function h(x){return x===33?(e.consume(x),m):x===47?(e.consume(x),a=!0,y):x===63?(e.consume(x),i=3,r.interrupt?t:f):gt(x)?(e.consume(x),o=String.fromCharCode(x),v):n(x)}function m(x){return x===45?(e.consume(x),i=2,p):x===91?(e.consume(x),i=5,l=0,w):gt(x)?(e.consume(x),i=4,r.interrupt?t:f):n(x)}function p(x){return x===45?(e.consume(x),r.interrupt?t:f):n(x)}function w(x){const Pe="CDATA[";return x===Pe.charCodeAt(l++)?(e.consume(x),l===Pe.length?r.interrupt?t:I:w):n(x)}function y(x){return gt(x)?(e.consume(x),o=String.fromCharCode(x),v):n(x)}function v(x){if(x===null||x===47||x===62||$e(x)){const Pe=x===47,He=o.toLowerCase();return!Pe&&!a&&ko.includes(He)?(i=1,r.interrupt?t(x):I(x)):Xh.includes(o.toLowerCase())?(i=6,Pe?(e.consume(x),b):r.interrupt?t(x):I(x)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(x):a?N(x):k(x))}return x===45||Je(x)?(e.consume(x),o+=String.fromCharCode(x),v):n(x)}function b(x){return x===62?(e.consume(x),r.interrupt?t:I):n(x)}function N(x){return ie(x)?(e.consume(x),N):M(x)}function k(x){return x===47?(e.consume(x),M):x===58||x===95||gt(x)?(e.consume(x),_):ie(x)?(e.consume(x),k):M(x)}function _(x){return x===45||x===46||x===58||x===95||Je(x)?(e.consume(x),_):O(x)}function O(x){return x===61?(e.consume(x),j):ie(x)?(e.consume(x),O):k(x)}function j(x){return x===null||x===60||x===61||x===62||x===96?n(x):x===34||x===39?(e.consume(x),c=x,B):ie(x)?(e.consume(x),j):F(x)}function B(x){return x===c?(e.consume(x),c=null,C):x===null||W(x)?n(x):(e.consume(x),B)}function F(x){return x===null||x===34||x===39||x===47||x===60||x===61||x===62||x===96||$e(x)?O(x):(e.consume(x),F)}function C(x){return x===47||x===62||ie(x)?k(x):n(x)}function M(x){return x===62?(e.consume(x),D):n(x)}function D(x){return x===null||W(x)?I(x):ie(x)?(e.consume(x),D):n(x)}function I(x){return x===45&&i===2?(e.consume(x),U):x===60&&i===1?(e.consume(x),te):x===62&&i===4?(e.consume(x),A):x===63&&i===3?(e.consume(x),f):x===93&&i===5?(e.consume(x),ye):W(x)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(Zh,fe,X)(x)):x===null||W(x)?(e.exit("htmlFlowData"),X(x)):(e.consume(x),I)}function X(x){return e.check(ep,q,fe)(x)}function q(x){return e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),P}function P(x){return x===null||W(x)?X(x):(e.enter("htmlFlowData"),I(x))}function U(x){return x===45?(e.consume(x),f):I(x)}function te(x){return x===47?(e.consume(x),o="",me):I(x)}function me(x){if(x===62){const Pe=o.toLowerCase();return ko.includes(Pe)?(e.consume(x),A):I(x)}return gt(x)&&o.length<8?(e.consume(x),o+=String.fromCharCode(x),me):I(x)}function ye(x){return x===93?(e.consume(x),f):I(x)}function f(x){return x===62?(e.consume(x),A):x===45&&i===2?(e.consume(x),f):I(x)}function A(x){return x===null||W(x)?(e.exit("htmlFlowData"),fe(x)):(e.consume(x),A)}function fe(x){return e.exit("htmlFlow"),t(x)}}function rp(e,t,n){const r=this;return i;function i(o){return W(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),a):n(o)}function a(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function sp(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(Kr,t,n)}}const ip={name:"htmlText",tokenize:ap};function ap(e,t,n){const r=this;let i,a,o;return l;function l(f){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(f),c}function c(f){return f===33?(e.consume(f),u):f===47?(e.consume(f),O):f===63?(e.consume(f),k):gt(f)?(e.consume(f),F):n(f)}function u(f){return f===45?(e.consume(f),d):f===91?(e.consume(f),a=0,w):gt(f)?(e.consume(f),N):n(f)}function d(f){return f===45?(e.consume(f),p):n(f)}function h(f){return f===null?n(f):f===45?(e.consume(f),m):W(f)?(o=h,te(f)):(e.consume(f),h)}function m(f){return f===45?(e.consume(f),p):h(f)}function p(f){return f===62?U(f):f===45?m(f):h(f)}function w(f){const A="CDATA[";return f===A.charCodeAt(a++)?(e.consume(f),a===A.length?y:w):n(f)}function y(f){return f===null?n(f):f===93?(e.consume(f),v):W(f)?(o=y,te(f)):(e.consume(f),y)}function v(f){return f===93?(e.consume(f),b):y(f)}function b(f){return f===62?U(f):f===93?(e.consume(f),b):y(f)}function N(f){return f===null||f===62?U(f):W(f)?(o=N,te(f)):(e.consume(f),N)}function k(f){return f===null?n(f):f===63?(e.consume(f),_):W(f)?(o=k,te(f)):(e.consume(f),k)}function _(f){return f===62?U(f):k(f)}function O(f){return gt(f)?(e.consume(f),j):n(f)}function j(f){return f===45||Je(f)?(e.consume(f),j):B(f)}function B(f){return W(f)?(o=B,te(f)):ie(f)?(e.consume(f),B):U(f)}function F(f){return f===45||Je(f)?(e.consume(f),F):f===47||f===62||$e(f)?C(f):n(f)}function C(f){return f===47?(e.consume(f),U):f===58||f===95||gt(f)?(e.consume(f),M):W(f)?(o=C,te(f)):ie(f)?(e.consume(f),C):U(f)}function M(f){return f===45||f===46||f===58||f===95||Je(f)?(e.consume(f),M):D(f)}function D(f){return f===61?(e.consume(f),I):W(f)?(o=D,te(f)):ie(f)?(e.consume(f),D):C(f)}function I(f){return f===null||f===60||f===61||f===62||f===96?n(f):f===34||f===39?(e.consume(f),i=f,X):W(f)?(o=I,te(f)):ie(f)?(e.consume(f),I):(e.consume(f),q)}function X(f){return f===i?(e.consume(f),i=void 0,P):f===null?n(f):W(f)?(o=X,te(f)):(e.consume(f),X)}function q(f){return f===null||f===34||f===39||f===60||f===61||f===96?n(f):f===47||f===62||$e(f)?C(f):(e.consume(f),q)}function P(f){return f===47||f===62||$e(f)?C(f):n(f)}function U(f){return f===62?(e.consume(f),e.exit("htmlTextData"),e.exit("htmlText"),t):n(f)}function te(f){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),me}function me(f){return ie(f)?xe(e,ye,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(f):ye(f)}function ye(f){return e.enter("htmlTextData"),o(f)}}const xi={name:"labelEnd",resolveAll:up,resolveTo:dp,tokenize:hp},op={tokenize:pp},lp={tokenize:mp},cp={tokenize:fp};function up(e){let t=-1;const n=[];for(;++t=3&&(u===null||W(u))?(e.exit("thematicBreak"),t(u)):n(u)}function c(u){return u===i?(e.consume(u),r++,c):(e.exit("thematicBreakSequence"),ie(u)?xe(e,l,"whitespace")(u):l(u))}}const ze={continuation:{tokenize:Sp},exit:Cp,name:"list",tokenize:Np},jp={partial:!0,tokenize:Pp},kp={partial:!0,tokenize:_p};function Np(e,t,n){const r=this,i=r.events[r.events.length-1];let a=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,o=0;return l;function l(p){const w=r.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(w==="listUnordered"?!r.containerState.marker||p===r.containerState.marker:qs(p)){if(r.containerState.type||(r.containerState.type=w,e.enter(w,{_container:!0})),w==="listUnordered")return e.enter("listItemPrefix"),p===42||p===45?e.check(Ar,n,u)(p):u(p);if(!r.interrupt||p===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),c(p)}return n(p)}function c(p){return qs(p)&&++o<10?(e.consume(p),c):(!r.interrupt||o<2)&&(r.containerState.marker?p===r.containerState.marker:p===41||p===46)?(e.exit("listItemValue"),u(p)):n(p)}function u(p){return e.enter("listItemMarker"),e.consume(p),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||p,e.check(Kr,r.interrupt?n:d,e.attempt(jp,m,h))}function d(p){return r.containerState.initialBlankLine=!0,a++,m(p)}function h(p){return ie(p)?(e.enter("listItemPrefixWhitespace"),e.consume(p),e.exit("listItemPrefixWhitespace"),m):n(p)}function m(p){return r.containerState.size=a+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(p)}}function Sp(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Kr,i,a);function i(l){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,xe(e,t,"listItemIndent",r.containerState.size+1)(l)}function a(l){return r.containerState.furtherBlankLines||!ie(l)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(l)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(kp,t,o)(l))}function o(l){return r.containerState._closeFlow=!0,r.interrupt=void 0,xe(e,e.attempt(ze,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}function _p(e,t,n){const r=this;return xe(e,i,"listItemIndent",r.containerState.size+1);function i(a){const o=r.events[r.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(a):n(a)}}function Cp(e){e.exit(this.containerState.type)}function Pp(e,t,n){const r=this;return xe(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(a){const o=r.events[r.events.length-1];return!ie(a)&&o&&o[1].type==="listItemPrefixWhitespace"?t(a):n(a)}}const No={name:"setextUnderline",resolveTo:Ep,tokenize:Rp};function Ep(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!a&&e[n][1].type==="definition"&&(a=n);const o={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",a?(e.splice(i,0,["enter",o,t]),e.splice(a+1,0,["exit",e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push(["exit",o,t]),e}function Rp(e,t,n){const r=this;let i;return a;function a(u){let d=r.events.length,h;for(;d--;)if(r.events[d][1].type!=="lineEnding"&&r.events[d][1].type!=="linePrefix"&&r.events[d][1].type!=="content"){h=r.events[d][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||h)?(e.enter("setextHeadingLine"),i=u,o(u)):n(u)}function o(u){return e.enter("setextHeadingLineSequence"),l(u)}function l(u){return u===i?(e.consume(u),l):(e.exit("setextHeadingLineSequence"),ie(u)?xe(e,c,"lineSuffix")(u):c(u))}function c(u){return u===null||W(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const Ip={tokenize:Tp};function Tp(e){const t=this,n=e.attempt(Kr,r,e.attempt(this.parser.constructs.flowInitial,i,xe(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Dh,i)),"linePrefix")));return n;function r(a){if(a===null){e.consume(a);return}return e.enter("lineEndingBlank"),e.consume(a),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const Ap={resolveAll:sc()},Lp=rc("string"),Mp=rc("text");function rc(e){return{resolveAll:sc(e==="text"?Op:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],a=n.attempt(i,o,l);return o;function o(d){return u(d)?a(d):l(d)}function l(d){if(d===null){n.consume(d);return}return n.enter("data"),n.consume(d),c}function c(d){return u(d)?(n.exit("data"),a(d)):(n.consume(d),c)}function u(d){if(d===null)return!0;const h=i[d];let m=-1;if(h)for(;++m-1){const l=o[0];typeof l=="string"?o[0]=l.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function Gp(e,t){let n=-1;const r=[];let i;for(;++n4&&n.slice(0,4)==="data"&&vd.test(t)){if(t.charAt(4)==="-"){const a=t.slice(5).replace(oo,Nd);r="data"+a.charAt(0).toUpperCase()+a.slice(1)}else{const a=t.slice(4);if(!oo.test(a)){let o=a.replace(wd,kd);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}i=li}return new i(r,t)}function kd(e){return"-"+e.toLowerCase()}function Nd(e){return e.charAt(1).toUpperCase()}const Sd=Ml([Dl,gd,zl,ql,Bl],"html"),ci=Ml([Dl,bd,zl,ql,Bl],"svg");function _d(e){return e.join(" ").trim()}var fn={},es,lo;function Cd(){if(lo)return es;lo=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,a=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,o=/^[;\s]*/,l=/^\s+|\s+$/g,c=` +`,u="/",d="*",h="",m="comment",p="declaration";function w(v,b){if(typeof v!="string")throw new TypeError("First argument must be a string");if(!v)return[];b=b||{};var N=1,k=1;function _(q){var P=q.match(t);P&&(N+=P.length);var U=q.lastIndexOf(c);k=~U?q.length-U:k+q.length}function D(){var q={line:N,column:k};return function(P){return P.position=new j(q),C(),P}}function j(q){this.start=q,this.end={line:N,column:k},this.source=b.source}j.prototype.content=v;function B(q){var P=new Error(b.source+":"+N+":"+k+": "+q);if(P.reason=q,P.filename=b.source,P.line=N,P.column=k,P.source=v,!b.silent)throw P}function F(q){var P=q.exec(v);if(P){var U=P[0];return _(U),v=v.slice(U.length),P}}function C(){F(n)}function M(q){var P;for(q=q||[];P=O();)P!==!1&&q.push(P);return q}function O(){var q=D();if(!(u!=v.charAt(0)||d!=v.charAt(1))){for(var P=2;h!=v.charAt(P)&&(d!=v.charAt(P)||u!=v.charAt(P+1));)++P;if(P+=2,h===v.charAt(P-1))return B("End of comment missing");var U=v.slice(2,P-2);return k+=2,_(U),v=v.slice(P),k+=2,q({type:m,comment:U})}}function I(){var q=D(),P=F(r);if(P){if(O(),!F(i))return B("property missing ':'");var U=F(a),te=q({type:p,property:y(P[0].replace(e,h)),value:U?y(U[0].replace(e,h)):h});return F(o),te}}function X(){var q=[];M(q);for(var P;P=I();)P!==!1&&(q.push(P),M(q));return q}return C(),X()}function y(v){return v?v.replace(l,h):h}return es=w,es}var co;function Pd(){if(co)return fn;co=1;var e=fn&&fn.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(fn,"__esModule",{value:!0}),fn.default=n;const t=e(Cd());function n(r,i){let a=null;if(!r||typeof r!="string")return a;const o=(0,t.default)(r),l=typeof i=="function";return o.forEach(c=>{if(c.type!=="declaration")return;const{property:u,value:d}=c;l?i(u,d,c):d&&(a=a||{},a[u]=d)}),a}return fn}var Vn={},uo;function Ed(){if(uo)return Vn;uo=1,Object.defineProperty(Vn,"__esModule",{value:!0}),Vn.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,a=function(u){return!u||n.test(u)||e.test(u)},o=function(u,d){return d.toUpperCase()},l=function(u,d){return"".concat(d,"-")},c=function(u,d){return d===void 0&&(d={}),a(u)?u:(u=u.toLowerCase(),d.reactCompat?u=u.replace(i,l):u=u.replace(r,l),u.replace(t,o))};return Vn.camelCase=c,Vn}var Gn,ho;function Rd(){if(ho)return Gn;ho=1;var e=Gn&&Gn.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(Pd()),n=Ed();function r(i,a){var o={};return!i||typeof i!="string"||(0,t.default)(i,function(l,c){l&&c&&(o[(0,n.camelCase)(l,a)]=c)}),o}return r.default=r,Gn=r,Gn}var Id=Rd();const Td=Zs(Id),$l=Ul("end"),ui=Ul("start");function Ul(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function Ad(e){const t=ui(e),n=$l(e);if(t&&n)return{start:t,end:n}}function nr(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?po(e.position):"start"in e||"end"in e?po(e):"line"in e||"column"in e?Fs(e):""}function Fs(e){return mo(e&&e.line)+":"+mo(e&&e.column)}function po(e){return Fs(e&&e.start)+"-"+Fs(e&&e.end)}function mo(e){return e&&typeof e=="number"?e:1}class Le extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",a={},o=!1;if(n&&("line"in n&&"column"in n?a={place:n}:"start"in n&&"end"in n?a={place:n}:"type"in n?a={ancestors:[n],place:n.position}:a={...n}),typeof t=="string"?i=t:!a.cause&&t&&(o=!0,i=t.message,a.cause=t),!a.ruleId&&!a.source&&typeof r=="string"){const c=r.indexOf(":");c===-1?a.ruleId=r:(a.source=r.slice(0,c),a.ruleId=r.slice(c+1))}if(!a.place&&a.ancestors&&a.ancestors){const c=a.ancestors[a.ancestors.length-1];c&&(a.place=c.position)}const l=a.place&&"start"in a.place?a.place.start:a.place;this.ancestors=a.ancestors||void 0,this.cause=a.cause||void 0,this.column=l?l.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=l?l.line:void 0,this.name=nr(a.place)||"1:1",this.place=a.place||void 0,this.reason=this.message,this.ruleId=a.ruleId||void 0,this.source=a.source||void 0,this.stack=o&&a.cause&&typeof a.cause.stack=="string"?a.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Le.prototype.file="";Le.prototype.name="";Le.prototype.reason="";Le.prototype.message="";Le.prototype.stack="";Le.prototype.column=void 0;Le.prototype.line=void 0;Le.prototype.ancestors=void 0;Le.prototype.cause=void 0;Le.prototype.fatal=void 0;Le.prototype.place=void 0;Le.prototype.ruleId=void 0;Le.prototype.source=void 0;const di={}.hasOwnProperty,Ld=new Map,Md=/[A-Z]/g,Dd=new Set(["table","tbody","thead","tfoot","tr"]),Od=new Set(["td","th"]),Hl="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Fd(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=Qd(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=Kd(n,t.jsx,t.jsxs)}const i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?ci:Sd,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=Kl(i,e,void 0);return a&&typeof a!="string"?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function Kl(e,t,n){if(t.type==="element")return zd(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return qd(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return $d(e,t,n);if(t.type==="mdxjsEsm")return Bd(e,t);if(t.type==="root")return Ud(e,t,n);if(t.type==="text")return Hd(e,t)}function zd(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=ci,e.schema=i),e.ancestors.push(t);const a=Wl(e,t.tagName,!1),o=Wd(e,t);let l=pi(e,t);return Dd.has(t.tagName)&&(l=l.filter(function(c){return typeof c=="string"?!fd(c):!0})),Ql(e,o,a,t),hi(o,l),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function qd(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}ur(e,t.position)}function Bd(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);ur(e,t.position)}function $d(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=ci,e.schema=i),e.ancestors.push(t);const a=t.name===null?e.Fragment:Wl(e,t.name,!0),o=Vd(e,t),l=pi(e,t);return Ql(e,o,a,t),hi(o,l),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function Ud(e,t,n){const r={};return hi(r,pi(e,t)),e.create(t,e.Fragment,r,n)}function Hd(e,t){return t.value}function Ql(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function hi(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function Kd(e,t,n){return r;function r(i,a,o,l){const u=Array.isArray(o.children)?n:t;return l?u(a,o,l):u(a,o)}}function Qd(e,t){return n;function n(r,i,a,o){const l=Array.isArray(a.children),c=ui(r);return t(i,a,o,l,{columnNumber:c?c.column-1:void 0,fileName:e,lineNumber:c?c.line:void 0},void 0)}}function Wd(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&di.call(t.properties,i)){const a=Gd(e,i,t.properties[i]);if(a){const[o,l]=a;e.tableCellAlignToStyle&&o==="align"&&typeof l=="string"&&Od.has(t.tagName)?r=l:n[o]=l}}if(r){const a=n.style||(n.style={});a[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function Vd(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const a=r.data.estree.body[0];a.type;const o=a.expression;o.type;const l=o.properties[0];l.type,Object.assign(n,e.evaluater.evaluateExpression(l.argument))}else ur(e,t.position);else{const i=r.name;let a;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const l=r.value.data.estree.body[0];l.type,a=e.evaluater.evaluateExpression(l.expression)}else ur(e,t.position);else a=r.value===null?!0:r.value;n[i]=a}return n}function pi(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:Ld;for(;++ri?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a0?(bt(e,e.length,0,t),e):t}const go={}.hasOwnProperty;function rh(e){const t={};let n=-1;for(;++n13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"๏ฟฝ":String.fromCodePoint(n)}function bn(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const gt=Ut(/[A-Za-z]/),Je=Ut(/[\dA-Za-z]/),ah=Ut(/[#-'*+\--9=?A-Z^-~]/);function zs(e){return e!==null&&(e<32||e===127)}const qs=Ut(/\d/),oh=Ut(/[\dA-Fa-f]/),lh=Ut(/[!-/:-@[-`{-~]/);function W(e){return e!==null&&e<-2}function $e(e){return e!==null&&(e<0||e===32)}function ie(e){return e===-2||e===-1||e===32}const ch=Ut(new RegExp("\\p{P}|\\p{S}","u")),uh=Ut(/\s/);function Ut(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Bn(e){const t=[];let n=-1,r=0,i=0;for(;++n55295&&a<57344){const l=e.charCodeAt(n+1);a<56320&&l>56319&&l<57344?(o=String.fromCharCode(a,l),i=1):o="๏ฟฝ"}else o=String.fromCharCode(a);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,o=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function xe(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let a=0;return o;function o(c){return ie(c)?(e.enter(n),l(c)):t(c)}function l(c){return ie(c)&&a++o))return;const B=t.events.length;let F=B,C,M;for(;F--;)if(t.events[F][0]==="exit"&&t.events[F][1].type==="chunkFlow"){if(C){M=t.events[F][1].end;break}C=!0}for(b(r),j=B;jk;){const D=n[_];t.containerState=D[1],D[0].exit.call(t,e)}n.length=k}function N(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function fh(e,t,n){return xe(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function yo(e){if(e===null||$e(e)||uh(e))return 1;if(ch(e))return 2}function fi(e,t,n){const r=[];let i=-1;for(;++i1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const h={...e[r][1].end},m={...e[n][1].start};wo(h,-c),wo(m,c),o={type:c>1?"strongSequence":"emphasisSequence",start:h,end:{...e[r][1].end}},l={type:c>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:m},a={type:c>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?"strong":"emphasis",start:{...o.start},end:{...l.end}},e[r][1].end={...o.start},e[n][1].start={...l.end},u=[],e[r][1].end.offset-e[r][1].start.offset&&(u=et(u,[["enter",e[r][1],t],["exit",e[r][1],t]])),u=et(u,[["enter",i,t],["enter",o,t],["exit",o,t],["enter",a,t]]),u=et(u,fi(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=et(u,[["exit",a,t],["enter",l,t],["exit",l,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(d=2,u=et(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):d=0,bt(e,r-1,n-r+3,u),n=r+u.length-d-2;break}}for(n=-1;++n0&&ie(j)?xe(e,N,"linePrefix",a+1)(j):N(j)}function N(j){return j===null||W(j)?e.check(vo,y,_)(j):(e.enter("codeFlowValue"),k(j))}function k(j){return j===null||W(j)?(e.exit("codeFlowValue"),N(j)):(e.consume(j),k)}function _(j){return e.exit("codeFenced"),t(j)}function D(j,B,F){let C=0;return M;function M(P){return j.enter("lineEnding"),j.consume(P),j.exit("lineEnding"),O}function O(P){return j.enter("codeFencedFence"),ie(P)?xe(j,I,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(P):I(P)}function I(P){return P===l?(j.enter("codeFencedFenceSequence"),X(P)):F(P)}function X(P){return P===l?(C++,j.consume(P),X):C>=o?(j.exit("codeFencedFenceSequence"),ie(P)?xe(j,q,"whitespace")(P):q(P)):F(P)}function q(P){return P===null||W(P)?(j.exit("codeFencedFence"),B(P)):F(P)}}}function Ch(e,t,n){const r=this;return i;function i(o){return o===null?n(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),a)}function a(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}const ns={name:"codeIndented",tokenize:Eh},Ph={partial:!0,tokenize:Rh};function Eh(e,t,n){const r=this;return i;function i(u){return e.enter("codeIndented"),xe(e,a,"linePrefix",5)(u)}function a(u){const d=r.events[r.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?o(u):n(u)}function o(u){return u===null?c(u):W(u)?e.attempt(Ph,o,c)(u):(e.enter("codeFlowValue"),l(u))}function l(u){return u===null||W(u)?(e.exit("codeFlowValue"),o(u)):(e.consume(u),l)}function c(u){return e.exit("codeIndented"),t(u)}}function Rh(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):W(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):xe(e,a,"linePrefix",5)(o)}function a(o){const l=r.events[r.events.length-1];return l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(o):W(o)?i(o):n(o)}}const Ih={name:"codeText",previous:Ah,resolve:Th,tokenize:Lh};function Th(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return tthis.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const a=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&Jn(this.left,r),a.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Jn(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Jn(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function ec(e,t,n,r,i,a,o,l,c){const u=c||Number.POSITIVE_INFINITY;let d=0;return h;function h(b){return b===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(b),e.exit(a),m):b===null||b===32||b===41||zs(b)?n(b):(e.enter(r),e.enter(o),e.enter(l),e.enter("chunkString",{contentType:"string"}),y(b))}function m(b){return b===62?(e.enter(a),e.consume(b),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(l),e.enter("chunkString",{contentType:"string"}),p(b))}function p(b){return b===62?(e.exit("chunkString"),e.exit(l),m(b)):b===null||b===60||W(b)?n(b):(e.consume(b),b===92?w:p)}function w(b){return b===60||b===62||b===92?(e.consume(b),p):p(b)}function y(b){return!d&&(b===null||b===41||$e(b))?(e.exit("chunkString"),e.exit(l),e.exit(o),e.exit(r),t(b)):d999||p===null||p===91||p===93&&!c||p===94&&!l&&"_hiddenFootnoteSupport"in o.parser.constructs?n(p):p===93?(e.exit(a),e.enter(i),e.consume(p),e.exit(i),e.exit(r),t):W(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),d):(e.enter("chunkString",{contentType:"string"}),h(p))}function h(p){return p===null||p===91||p===93||W(p)||l++>999?(e.exit("chunkString"),d(p)):(e.consume(p),c||(c=!ie(p)),p===92?m:h)}function m(p){return p===91||p===92||p===93?(e.consume(p),l++,h):h(p)}}function nc(e,t,n,r,i,a){let o;return l;function l(m){return m===34||m===39||m===40?(e.enter(r),e.enter(i),e.consume(m),e.exit(i),o=m===40?41:m,c):n(m)}function c(m){return m===o?(e.enter(i),e.consume(m),e.exit(i),e.exit(r),t):(e.enter(a),u(m))}function u(m){return m===o?(e.exit(a),c(o)):m===null?n(m):W(m)?(e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),xe(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),d(m))}function d(m){return m===o||m===null||W(m)?(e.exit("chunkString"),u(m)):(e.consume(m),m===92?h:d)}function h(m){return m===o||m===92?(e.consume(m),d):d(m)}}function rr(e,t){let n;return r;function r(i){return W(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):ie(i)?xe(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const $h={name:"definition",tokenize:Hh},Uh={partial:!0,tokenize:Kh};function Hh(e,t,n){const r=this;let i;return a;function a(p){return e.enter("definition"),o(p)}function o(p){return tc.call(r,e,l,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function l(p){return i=bn(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),c):n(p)}function c(p){return $e(p)?rr(e,u)(p):u(p)}function u(p){return ec(e,d,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function d(p){return e.attempt(Uh,h,h)(p)}function h(p){return ie(p)?xe(e,m,"whitespace")(p):m(p)}function m(p){return p===null||W(p)?(e.exit("definition"),r.parser.defined.push(i),t(p)):n(p)}}function Kh(e,t,n){return r;function r(l){return $e(l)?rr(e,i)(l):n(l)}function i(l){return nc(e,a,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function a(l){return ie(l)?xe(e,o,"whitespace")(l):o(l)}function o(l){return l===null||W(l)?t(l):n(l)}}const Qh={name:"hardBreakEscape",tokenize:Wh};function Wh(e,t,n){return r;function r(a){return e.enter("hardBreakEscape"),e.consume(a),i}function i(a){return W(a)?(e.exit("hardBreakEscape"),t(a)):n(a)}}const Vh={name:"headingAtx",resolve:Gh,tokenize:Jh};function Gh(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},a={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},bt(e,r,n-r+1,[["enter",i,t],["enter",a,t],["exit",a,t],["exit",i,t]])),e}function Jh(e,t,n){let r=0;return i;function i(d){return e.enter("atxHeading"),a(d)}function a(d){return e.enter("atxHeadingSequence"),o(d)}function o(d){return d===35&&r++<6?(e.consume(d),o):d===null||$e(d)?(e.exit("atxHeadingSequence"),l(d)):n(d)}function l(d){return d===35?(e.enter("atxHeadingSequence"),c(d)):d===null||W(d)?(e.exit("atxHeading"),t(d)):ie(d)?xe(e,l,"whitespace")(d):(e.enter("atxHeadingText"),u(d))}function c(d){return d===35?(e.consume(d),c):(e.exit("atxHeadingSequence"),l(d))}function u(d){return d===null||d===35||$e(d)?(e.exit("atxHeadingText"),l(d)):(e.consume(d),u)}}const Xh=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],ko=["pre","script","style","textarea"],Yh={concrete:!0,name:"htmlFlow",resolveTo:tp,tokenize:np},Zh={partial:!0,tokenize:sp},ep={partial:!0,tokenize:rp};function tp(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function np(e,t,n){const r=this;let i,a,o,l,c;return u;function u(x){return d(x)}function d(x){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(x),h}function h(x){return x===33?(e.consume(x),m):x===47?(e.consume(x),a=!0,y):x===63?(e.consume(x),i=3,r.interrupt?t:f):gt(x)?(e.consume(x),o=String.fromCharCode(x),v):n(x)}function m(x){return x===45?(e.consume(x),i=2,p):x===91?(e.consume(x),i=5,l=0,w):gt(x)?(e.consume(x),i=4,r.interrupt?t:f):n(x)}function p(x){return x===45?(e.consume(x),r.interrupt?t:f):n(x)}function w(x){const Pe="CDATA[";return x===Pe.charCodeAt(l++)?(e.consume(x),l===Pe.length?r.interrupt?t:I:w):n(x)}function y(x){return gt(x)?(e.consume(x),o=String.fromCharCode(x),v):n(x)}function v(x){if(x===null||x===47||x===62||$e(x)){const Pe=x===47,He=o.toLowerCase();return!Pe&&!a&&ko.includes(He)?(i=1,r.interrupt?t(x):I(x)):Xh.includes(o.toLowerCase())?(i=6,Pe?(e.consume(x),b):r.interrupt?t(x):I(x)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(x):a?N(x):k(x))}return x===45||Je(x)?(e.consume(x),o+=String.fromCharCode(x),v):n(x)}function b(x){return x===62?(e.consume(x),r.interrupt?t:I):n(x)}function N(x){return ie(x)?(e.consume(x),N):M(x)}function k(x){return x===47?(e.consume(x),M):x===58||x===95||gt(x)?(e.consume(x),_):ie(x)?(e.consume(x),k):M(x)}function _(x){return x===45||x===46||x===58||x===95||Je(x)?(e.consume(x),_):D(x)}function D(x){return x===61?(e.consume(x),j):ie(x)?(e.consume(x),D):k(x)}function j(x){return x===null||x===60||x===61||x===62||x===96?n(x):x===34||x===39?(e.consume(x),c=x,B):ie(x)?(e.consume(x),j):F(x)}function B(x){return x===c?(e.consume(x),c=null,C):x===null||W(x)?n(x):(e.consume(x),B)}function F(x){return x===null||x===34||x===39||x===47||x===60||x===61||x===62||x===96||$e(x)?D(x):(e.consume(x),F)}function C(x){return x===47||x===62||ie(x)?k(x):n(x)}function M(x){return x===62?(e.consume(x),O):n(x)}function O(x){return x===null||W(x)?I(x):ie(x)?(e.consume(x),O):n(x)}function I(x){return x===45&&i===2?(e.consume(x),U):x===60&&i===1?(e.consume(x),te):x===62&&i===4?(e.consume(x),A):x===63&&i===3?(e.consume(x),f):x===93&&i===5?(e.consume(x),ye):W(x)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(Zh,fe,X)(x)):x===null||W(x)?(e.exit("htmlFlowData"),X(x)):(e.consume(x),I)}function X(x){return e.check(ep,q,fe)(x)}function q(x){return e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),P}function P(x){return x===null||W(x)?X(x):(e.enter("htmlFlowData"),I(x))}function U(x){return x===45?(e.consume(x),f):I(x)}function te(x){return x===47?(e.consume(x),o="",me):I(x)}function me(x){if(x===62){const Pe=o.toLowerCase();return ko.includes(Pe)?(e.consume(x),A):I(x)}return gt(x)&&o.length<8?(e.consume(x),o+=String.fromCharCode(x),me):I(x)}function ye(x){return x===93?(e.consume(x),f):I(x)}function f(x){return x===62?(e.consume(x),A):x===45&&i===2?(e.consume(x),f):I(x)}function A(x){return x===null||W(x)?(e.exit("htmlFlowData"),fe(x)):(e.consume(x),A)}function fe(x){return e.exit("htmlFlow"),t(x)}}function rp(e,t,n){const r=this;return i;function i(o){return W(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),a):n(o)}function a(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function sp(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(Kr,t,n)}}const ip={name:"htmlText",tokenize:ap};function ap(e,t,n){const r=this;let i,a,o;return l;function l(f){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(f),c}function c(f){return f===33?(e.consume(f),u):f===47?(e.consume(f),D):f===63?(e.consume(f),k):gt(f)?(e.consume(f),F):n(f)}function u(f){return f===45?(e.consume(f),d):f===91?(e.consume(f),a=0,w):gt(f)?(e.consume(f),N):n(f)}function d(f){return f===45?(e.consume(f),p):n(f)}function h(f){return f===null?n(f):f===45?(e.consume(f),m):W(f)?(o=h,te(f)):(e.consume(f),h)}function m(f){return f===45?(e.consume(f),p):h(f)}function p(f){return f===62?U(f):f===45?m(f):h(f)}function w(f){const A="CDATA[";return f===A.charCodeAt(a++)?(e.consume(f),a===A.length?y:w):n(f)}function y(f){return f===null?n(f):f===93?(e.consume(f),v):W(f)?(o=y,te(f)):(e.consume(f),y)}function v(f){return f===93?(e.consume(f),b):y(f)}function b(f){return f===62?U(f):f===93?(e.consume(f),b):y(f)}function N(f){return f===null||f===62?U(f):W(f)?(o=N,te(f)):(e.consume(f),N)}function k(f){return f===null?n(f):f===63?(e.consume(f),_):W(f)?(o=k,te(f)):(e.consume(f),k)}function _(f){return f===62?U(f):k(f)}function D(f){return gt(f)?(e.consume(f),j):n(f)}function j(f){return f===45||Je(f)?(e.consume(f),j):B(f)}function B(f){return W(f)?(o=B,te(f)):ie(f)?(e.consume(f),B):U(f)}function F(f){return f===45||Je(f)?(e.consume(f),F):f===47||f===62||$e(f)?C(f):n(f)}function C(f){return f===47?(e.consume(f),U):f===58||f===95||gt(f)?(e.consume(f),M):W(f)?(o=C,te(f)):ie(f)?(e.consume(f),C):U(f)}function M(f){return f===45||f===46||f===58||f===95||Je(f)?(e.consume(f),M):O(f)}function O(f){return f===61?(e.consume(f),I):W(f)?(o=O,te(f)):ie(f)?(e.consume(f),O):C(f)}function I(f){return f===null||f===60||f===61||f===62||f===96?n(f):f===34||f===39?(e.consume(f),i=f,X):W(f)?(o=I,te(f)):ie(f)?(e.consume(f),I):(e.consume(f),q)}function X(f){return f===i?(e.consume(f),i=void 0,P):f===null?n(f):W(f)?(o=X,te(f)):(e.consume(f),X)}function q(f){return f===null||f===34||f===39||f===60||f===61||f===96?n(f):f===47||f===62||$e(f)?C(f):(e.consume(f),q)}function P(f){return f===47||f===62||$e(f)?C(f):n(f)}function U(f){return f===62?(e.consume(f),e.exit("htmlTextData"),e.exit("htmlText"),t):n(f)}function te(f){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),me}function me(f){return ie(f)?xe(e,ye,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(f):ye(f)}function ye(f){return e.enter("htmlTextData"),o(f)}}const xi={name:"labelEnd",resolveAll:up,resolveTo:dp,tokenize:hp},op={tokenize:pp},lp={tokenize:mp},cp={tokenize:fp};function up(e){let t=-1;const n=[];for(;++t=3&&(u===null||W(u))?(e.exit("thematicBreak"),t(u)):n(u)}function c(u){return u===i?(e.consume(u),r++,c):(e.exit("thematicBreakSequence"),ie(u)?xe(e,l,"whitespace")(u):l(u))}}const ze={continuation:{tokenize:Sp},exit:Cp,name:"list",tokenize:Np},jp={partial:!0,tokenize:Pp},kp={partial:!0,tokenize:_p};function Np(e,t,n){const r=this,i=r.events[r.events.length-1];let a=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,o=0;return l;function l(p){const w=r.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(w==="listUnordered"?!r.containerState.marker||p===r.containerState.marker:qs(p)){if(r.containerState.type||(r.containerState.type=w,e.enter(w,{_container:!0})),w==="listUnordered")return e.enter("listItemPrefix"),p===42||p===45?e.check(Ar,n,u)(p):u(p);if(!r.interrupt||p===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),c(p)}return n(p)}function c(p){return qs(p)&&++o<10?(e.consume(p),c):(!r.interrupt||o<2)&&(r.containerState.marker?p===r.containerState.marker:p===41||p===46)?(e.exit("listItemValue"),u(p)):n(p)}function u(p){return e.enter("listItemMarker"),e.consume(p),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||p,e.check(Kr,r.interrupt?n:d,e.attempt(jp,m,h))}function d(p){return r.containerState.initialBlankLine=!0,a++,m(p)}function h(p){return ie(p)?(e.enter("listItemPrefixWhitespace"),e.consume(p),e.exit("listItemPrefixWhitespace"),m):n(p)}function m(p){return r.containerState.size=a+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(p)}}function Sp(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Kr,i,a);function i(l){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,xe(e,t,"listItemIndent",r.containerState.size+1)(l)}function a(l){return r.containerState.furtherBlankLines||!ie(l)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(l)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(kp,t,o)(l))}function o(l){return r.containerState._closeFlow=!0,r.interrupt=void 0,xe(e,e.attempt(ze,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}function _p(e,t,n){const r=this;return xe(e,i,"listItemIndent",r.containerState.size+1);function i(a){const o=r.events[r.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(a):n(a)}}function Cp(e){e.exit(this.containerState.type)}function Pp(e,t,n){const r=this;return xe(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(a){const o=r.events[r.events.length-1];return!ie(a)&&o&&o[1].type==="listItemPrefixWhitespace"?t(a):n(a)}}const No={name:"setextUnderline",resolveTo:Ep,tokenize:Rp};function Ep(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!a&&e[n][1].type==="definition"&&(a=n);const o={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",a?(e.splice(i,0,["enter",o,t]),e.splice(a+1,0,["exit",e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push(["exit",o,t]),e}function Rp(e,t,n){const r=this;let i;return a;function a(u){let d=r.events.length,h;for(;d--;)if(r.events[d][1].type!=="lineEnding"&&r.events[d][1].type!=="linePrefix"&&r.events[d][1].type!=="content"){h=r.events[d][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||h)?(e.enter("setextHeadingLine"),i=u,o(u)):n(u)}function o(u){return e.enter("setextHeadingLineSequence"),l(u)}function l(u){return u===i?(e.consume(u),l):(e.exit("setextHeadingLineSequence"),ie(u)?xe(e,c,"lineSuffix")(u):c(u))}function c(u){return u===null||W(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const Ip={tokenize:Tp};function Tp(e){const t=this,n=e.attempt(Kr,r,e.attempt(this.parser.constructs.flowInitial,i,xe(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Oh,i)),"linePrefix")));return n;function r(a){if(a===null){e.consume(a);return}return e.enter("lineEndingBlank"),e.consume(a),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const Ap={resolveAll:sc()},Lp=rc("string"),Mp=rc("text");function rc(e){return{resolveAll:sc(e==="text"?Dp:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],a=n.attempt(i,o,l);return o;function o(d){return u(d)?a(d):l(d)}function l(d){if(d===null){n.consume(d);return}return n.enter("data"),n.consume(d),c}function c(d){return u(d)?(n.exit("data"),a(d)):(n.consume(d),c)}function u(d){if(d===null)return!0;const h=i[d];let m=-1;if(h)for(;++m-1){const l=o[0];typeof l=="string"?o[0]=l.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function Gp(e,t){let n=-1;const r=[];let i;for(;++n0){const Re=K.tokenStack[K.tokenStack.length-1];(Re[1]||_o).call(K,void 0,Re[0])}for(L.position={start:Et(S.length>0?S[0][1].start:{line:1,column:1,offset:0}),end:Et(S.length>0?S[S.length-2][1].end:{line:1,column:1,offset:0})},le=-1;++le0){const Re=K.tokenStack[K.tokenStack.length-1];(Re[1]||_o).call(K,void 0,Re[0])}for(L.position={start:Et(S.length>0?S[0][1].start:{line:1,column:1,offset:0}),end:Et(S.length>0?S[S.length-2][1].end:{line:1,column:1,offset:0})},le=-1;++le0&&(r.className=["language-"+i[0]]);let a={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a=e.applyData(t,a),a={type:"element",tagName:"pre",properties:{},children:[a]},e.patch(t,a),a}function cm(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function um(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function dm(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),i=Bn(r.toLowerCase()),a=e.footnoteOrder.indexOf(r);let o,l=e.footnoteCounts.get(r);l===void 0?(l=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=a+1,l+=1,e.footnoteCounts.set(r,l);const c={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+i,id:n+"fnref-"+i+(l>1?"-"+l:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(o)}]};e.patch(t,c);const u={type:"element",tagName:"sup",properties:{},children:[c]};return e.patch(t,u),e.applyData(t,u)}function hm(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function pm(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function oc(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const i=e.all(t),a=i[0];a&&a.type==="text"?a.value="["+a.value:i.unshift({type:"text",value:"["});const o=i[i.length-1];return o&&o.type==="text"?o.value+=r:i.push({type:"text",value:r}),i}function mm(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return oc(e,t);const i={src:Bn(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);const a={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,a),e.applyData(t,a)}function fm(e,t){const n={src:Bn(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function xm(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function gm(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return oc(e,t);const i={href:Bn(r.url||"")};r.title!==null&&r.title!==void 0&&(i.title=r.title);const a={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function bm(e,t){const n={href:Bn(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function ym(e,t,n){const r=e.all(t),i=n?wm(n):lc(t),a={},o=[];if(typeof t.checked=="boolean"){const d=r[0];let h;d&&d.type==="element"&&d.tagName==="p"?h=d:(h={type:"element",tagName:"p",properties:{},children:[]},r.unshift(h)),h.children.length>0&&h.children.unshift({type:"text",value:" "}),h.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),a.className=["task-list-item"]}let l=-1;for(;++l1}function vm(e,t){const n={},r=e.all(t);let i=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++i0){const o={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},l=ui(t.children[1]),c=$l(t.children[t.children.length-1]);l&&c&&(o.position={start:l,end:c}),i.push(o)}const a={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,a),e.applyData(t,a)}function _m(e,t,n){const r=n?n.children:void 0,a=(r?r.indexOf(t):1)===0?"th":"td",o=n&&n.type==="table"?n.align:void 0,l=o?o.length:t.children.length;let c=-1;const u=[];for(;++c0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push(Eo(t.slice(i),i>0,!1)),a.join("")}function Eo(e,t,n){let r=0,i=e.length;if(t){let a=e.codePointAt(r);for(;a===Co||a===Po;)r++,a=e.codePointAt(r)}if(n){let a=e.codePointAt(i-1);for(;a===Co||a===Po;)i--,a=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}function Em(e,t){const n={type:"text",value:Pm(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function Rm(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const Im={blockquote:am,break:om,code:lm,delete:cm,emphasis:um,footnoteReference:dm,heading:hm,html:pm,imageReference:mm,image:fm,inlineCode:xm,linkReference:gm,link:bm,listItem:ym,list:vm,paragraph:jm,root:km,strong:Nm,table:Sm,tableCell:Cm,tableRow:_m,text:Em,thematicBreak:Rm,toml:_r,yaml:_r,definition:_r,footnoteDefinition:_r};function _r(){}const cc=-1,Qr=0,sr=1,Dr=2,gi=3,bi=4,yi=5,wi=6,uc=7,dc=8,Tm=typeof self=="object"?self:globalThis,Ro=(e,t)=>{switch(e){case"Function":case"SharedWorker":case"Worker":case"eval":case"setInterval":case"setTimeout":throw new TypeError("unable to deserialize "+e)}return new Tm[e](t)},Am=(e,t)=>{const n=(i,a)=>(e.set(a,i),i),r=i=>{if(e.has(i))return e.get(i);const[a,o]=t[i];switch(a){case Qr:case cc:return n(o,i);case sr:{const l=n([],i);for(const c of o)l.push(r(c));return l}case Dr:{const l=n({},i);for(const[c,u]of o)l[r(c)]=r(u);return l}case gi:return n(new Date(o),i);case bi:{const{source:l,flags:c}=o;return n(new RegExp(l,c),i)}case yi:{const l=n(new Map,i);for(const[c,u]of o)l.set(r(c),r(u));return l}case wi:{const l=n(new Set,i);for(const c of o)l.add(r(c));return l}case uc:{const{name:l,message:c}=o;return n(Ro(l,c),i)}case dc:return n(BigInt(o),i);case"BigInt":return n(Object(BigInt(o)),i);case"ArrayBuffer":return n(new Uint8Array(o).buffer,o);case"DataView":{const{buffer:l}=new Uint8Array(o);return n(new DataView(l),o)}}return n(Ro(a,o),i)};return r},Io=e=>Am(new Map,e)(0),xn="",{toString:Lm}={},{keys:Mm}=Object,Xn=e=>{const t=typeof e;if(t!=="object"||!e)return[Qr,t];const n=Lm.call(e).slice(8,-1);switch(n){case"Array":return[sr,xn];case"Object":return[Dr,xn];case"Date":return[gi,xn];case"RegExp":return[bi,xn];case"Map":return[yi,xn];case"Set":return[wi,xn];case"DataView":return[sr,n]}return n.includes("Array")?[sr,n]:n.includes("Error")?[uc,n]:[Dr,n]},Cr=([e,t])=>e===Qr&&(t==="function"||t==="symbol"),Om=(e,t,n,r)=>{const i=(o,l)=>{const c=r.push(o)-1;return n.set(l,c),c},a=o=>{if(n.has(o))return n.get(o);let[l,c]=Xn(o);switch(l){case Qr:{let d=o;switch(c){case"bigint":l=dc,d=o.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+c);d=null;break;case"undefined":return i([cc],o)}return i([l,d],o)}case sr:{if(c){let m=o;return c==="DataView"?m=new Uint8Array(o.buffer):c==="ArrayBuffer"&&(m=new Uint8Array(o)),i([c,[...m]],o)}const d=[],h=i([l,d],o);for(const m of o)d.push(a(m));return h}case Dr:{if(c)switch(c){case"BigInt":return i([c,o.toString()],o);case"Boolean":case"Number":case"String":return i([c,o.valueOf()],o)}if(t&&"toJSON"in o)return a(o.toJSON());const d=[],h=i([l,d],o);for(const m of Mm(o))(e||!Cr(Xn(o[m])))&&d.push([a(m),a(o[m])]);return h}case gi:return i([l,o.toISOString()],o);case bi:{const{source:d,flags:h}=o;return i([l,{source:d,flags:h}],o)}case yi:{const d=[],h=i([l,d],o);for(const[m,p]of o)(e||!(Cr(Xn(m))||Cr(Xn(p))))&&d.push([a(m),a(p)]);return h}case wi:{const d=[],h=i([l,d],o);for(const m of o)(e||!Cr(Xn(m)))&&d.push(a(m));return h}}const{message:u}=o;return i([l,{name:c,message:u}],o)};return a},To=(e,{json:t,lossy:n}={})=>{const r=[];return Om(!(t||n),!!t,new Map,r)(e),r},Fr=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?Io(To(e,t)):structuredClone(e):(e,t)=>Io(To(e,t));function Dm(e,t){const n=[{type:"text",value:"โ†ฉ"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function Fm(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function zm(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||Dm,r=e.options.footnoteBackLabel||Fm,i=e.options.footnoteLabel||"Footnotes",a=e.options.footnoteLabelTagName||"h2",o=e.options.footnoteLabelProperties||{className:["sr-only"]},l=[];let c=-1;for(;++c0&&w.push({type:"text",value:" "});let N=typeof n=="string"?n:n(c,p);typeof N=="string"&&(N={type:"text",value:N}),w.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+m+(p>1?"-"+p:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(c,p),className:["data-footnote-backref"]},children:Array.isArray(N)?N:[N]})}const v=d[d.length-1];if(v&&v.type==="element"&&v.tagName==="p"){const N=v.children[v.children.length-1];N&&N.type==="text"?N.value+=" ":v.children.push({type:"text",value:" "}),v.children.push(...w)}else d.push(...w);const b={type:"element",tagName:"li",properties:{id:t+"fn-"+m},children:e.wrap(d,!0)};e.patch(u,b),l.push(b)}if(l.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:a,properties:{...Fr(o),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:` +`});const u={type:"element",tagName:"li",properties:a,children:o};return e.patch(t,u),e.applyData(t,u)}function wm(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const n=e.children;let r=-1;for(;!t&&++r1}function vm(e,t){const n={},r=e.all(t);let i=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++i0){const o={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},l=ui(t.children[1]),c=$l(t.children[t.children.length-1]);l&&c&&(o.position={start:l,end:c}),i.push(o)}const a={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,a),e.applyData(t,a)}function _m(e,t,n){const r=n?n.children:void 0,a=(r?r.indexOf(t):1)===0?"th":"td",o=n&&n.type==="table"?n.align:void 0,l=o?o.length:t.children.length;let c=-1;const u=[];for(;++c0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push(Eo(t.slice(i),i>0,!1)),a.join("")}function Eo(e,t,n){let r=0,i=e.length;if(t){let a=e.codePointAt(r);for(;a===Co||a===Po;)r++,a=e.codePointAt(r)}if(n){let a=e.codePointAt(i-1);for(;a===Co||a===Po;)i--,a=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}function Em(e,t){const n={type:"text",value:Pm(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function Rm(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const Im={blockquote:am,break:om,code:lm,delete:cm,emphasis:um,footnoteReference:dm,heading:hm,html:pm,imageReference:mm,image:fm,inlineCode:xm,linkReference:gm,link:bm,listItem:ym,list:vm,paragraph:jm,root:km,strong:Nm,table:Sm,tableCell:Cm,tableRow:_m,text:Em,thematicBreak:Rm,toml:_r,yaml:_r,definition:_r,footnoteDefinition:_r};function _r(){}const cc=-1,Qr=0,sr=1,Or=2,gi=3,bi=4,yi=5,wi=6,uc=7,dc=8,Tm=typeof self=="object"?self:globalThis,Ro=(e,t)=>{switch(e){case"Function":case"SharedWorker":case"Worker":case"eval":case"setInterval":case"setTimeout":throw new TypeError("unable to deserialize "+e)}return new Tm[e](t)},Am=(e,t)=>{const n=(i,a)=>(e.set(a,i),i),r=i=>{if(e.has(i))return e.get(i);const[a,o]=t[i];switch(a){case Qr:case cc:return n(o,i);case sr:{const l=n([],i);for(const c of o)l.push(r(c));return l}case Or:{const l=n({},i);for(const[c,u]of o)l[r(c)]=r(u);return l}case gi:return n(new Date(o),i);case bi:{const{source:l,flags:c}=o;return n(new RegExp(l,c),i)}case yi:{const l=n(new Map,i);for(const[c,u]of o)l.set(r(c),r(u));return l}case wi:{const l=n(new Set,i);for(const c of o)l.add(r(c));return l}case uc:{const{name:l,message:c}=o;return n(Ro(l,c),i)}case dc:return n(BigInt(o),i);case"BigInt":return n(Object(BigInt(o)),i);case"ArrayBuffer":return n(new Uint8Array(o).buffer,o);case"DataView":{const{buffer:l}=new Uint8Array(o);return n(new DataView(l),o)}}return n(Ro(a,o),i)};return r},Io=e=>Am(new Map,e)(0),xn="",{toString:Lm}={},{keys:Mm}=Object,Xn=e=>{const t=typeof e;if(t!=="object"||!e)return[Qr,t];const n=Lm.call(e).slice(8,-1);switch(n){case"Array":return[sr,xn];case"Object":return[Or,xn];case"Date":return[gi,xn];case"RegExp":return[bi,xn];case"Map":return[yi,xn];case"Set":return[wi,xn];case"DataView":return[sr,n]}return n.includes("Array")?[sr,n]:n.includes("Error")?[uc,n]:[Or,n]},Cr=([e,t])=>e===Qr&&(t==="function"||t==="symbol"),Dm=(e,t,n,r)=>{const i=(o,l)=>{const c=r.push(o)-1;return n.set(l,c),c},a=o=>{if(n.has(o))return n.get(o);let[l,c]=Xn(o);switch(l){case Qr:{let d=o;switch(c){case"bigint":l=dc,d=o.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+c);d=null;break;case"undefined":return i([cc],o)}return i([l,d],o)}case sr:{if(c){let m=o;return c==="DataView"?m=new Uint8Array(o.buffer):c==="ArrayBuffer"&&(m=new Uint8Array(o)),i([c,[...m]],o)}const d=[],h=i([l,d],o);for(const m of o)d.push(a(m));return h}case Or:{if(c)switch(c){case"BigInt":return i([c,o.toString()],o);case"Boolean":case"Number":case"String":return i([c,o.valueOf()],o)}if(t&&"toJSON"in o)return a(o.toJSON());const d=[],h=i([l,d],o);for(const m of Mm(o))(e||!Cr(Xn(o[m])))&&d.push([a(m),a(o[m])]);return h}case gi:return i([l,o.toISOString()],o);case bi:{const{source:d,flags:h}=o;return i([l,{source:d,flags:h}],o)}case yi:{const d=[],h=i([l,d],o);for(const[m,p]of o)(e||!(Cr(Xn(m))||Cr(Xn(p))))&&d.push([a(m),a(p)]);return h}case wi:{const d=[],h=i([l,d],o);for(const m of o)(e||!Cr(Xn(m)))&&d.push(a(m));return h}}const{message:u}=o;return i([l,{name:c,message:u}],o)};return a},To=(e,{json:t,lossy:n}={})=>{const r=[];return Dm(!(t||n),!!t,new Map,r)(e),r},Fr=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?Io(To(e,t)):structuredClone(e):(e,t)=>Io(To(e,t));function Om(e,t){const n=[{type:"text",value:"โ†ฉ"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function Fm(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function zm(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||Om,r=e.options.footnoteBackLabel||Fm,i=e.options.footnoteLabel||"Footnotes",a=e.options.footnoteLabelTagName||"h2",o=e.options.footnoteLabelProperties||{className:["sr-only"]},l=[];let c=-1;for(;++c0&&w.push({type:"text",value:" "});let N=typeof n=="string"?n:n(c,p);typeof N=="string"&&(N={type:"text",value:N}),w.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+m+(p>1?"-"+p:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(c,p),className:["data-footnote-backref"]},children:Array.isArray(N)?N:[N]})}const v=d[d.length-1];if(v&&v.type==="element"&&v.tagName==="p"){const N=v.children[v.children.length-1];N&&N.type==="text"?N.value+=" ":v.children.push({type:"text",value:" "}),v.children.push(...w)}else d.push(...w);const b={type:"element",tagName:"li",properties:{id:t+"fn-"+m},children:e.wrap(d,!0)};e.patch(u,b),l.push(b)}if(l.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:a,properties:{...Fr(o),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:` `},{type:"element",tagName:"ol",properties:{},children:e.wrap(l,!0)},{type:"text",value:` `}]}}const hc=(function(e){if(e==null)return Um;if(typeof e=="function")return Wr(e);if(typeof e=="object")return Array.isArray(e)?qm(e):Bm(e);if(typeof e=="string")return $m(e);throw new Error("Expected function, string, or object as test")});function qm(e){const t=[];let n=-1;for(;++n":""))+")"})}return m;function m(){let p=pc,w,y,v;if((!t||a(c,u,d[d.length-1]||void 0))&&(p=Vm(n(c,d)),p[0]===Ao))return p;if("children"in c&&c.children){const b=c;if(b.children&&p[0]!==Qm)for(y=(r?b.children.length:-1)+o,v=d.concat(b);y>-1&&y0&&n.push({type:"text",value:` `}),n}function Lo(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function Mo(e,t){const n=Jm(e,t),r=n.one(e,void 0),i=zm(n),a=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return i&&a.children.push({type:"text",value:` -`},i),a}function tf(e,t){return e&&"run"in e?async function(n,r){const i=Mo(n,{file:r,...t});await e.run(i,r)}:function(n,r){return Mo(n,{file:r,...e||t})}}function Oo(e){if(e)throw e}var ss,Do;function nf(){if(Do)return ss;Do=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=function(u){return typeof Array.isArray=="function"?Array.isArray(u):t.call(u)==="[object Array]"},a=function(u){if(!u||t.call(u)!=="[object Object]")return!1;var d=e.call(u,"constructor"),h=u.constructor&&u.constructor.prototype&&e.call(u.constructor.prototype,"isPrototypeOf");if(u.constructor&&!d&&!h)return!1;var m;for(m in u);return typeof m>"u"||e.call(u,m)},o=function(u,d){n&&d.name==="__proto__"?n(u,d.name,{enumerable:!0,configurable:!0,value:d.newValue,writable:!0}):u[d.name]=d.newValue},l=function(u,d){if(d==="__proto__")if(e.call(u,d)){if(r)return r(u,d).value}else return;return u[d]};return ss=function c(){var u,d,h,m,p,w,y=arguments[0],v=1,b=arguments.length,N=!1;for(typeof y=="boolean"&&(N=y,y=arguments[1]||{},v=2),(y==null||typeof y!="object"&&typeof y!="function")&&(y={});vo.length;let c;l&&o.push(i);try{c=e.apply(this,o)}catch(u){const d=u;if(l&&n)throw d;return i(d)}l||(c&&c.then&&typeof c.then=="function"?c.then(a,i):c instanceof Error?i(c):a(c))}function i(o,...l){n||(n=!0,t(o,...l))}function a(o){i(null,o)}}const pt={basename:of,dirname:lf,extname:cf,join:uf,sep:"/"};function of(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');yr(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let o=-1,l=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),l>-1&&(e.codePointAt(i)===t.codePointAt(l--)?l<0&&(r=i):(l=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function lf(e){if(yr(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function cf(e){yr(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){const l=e.codePointAt(t);if(l===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),l===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?"":e.slice(i,n)}function uf(...e){let t=-1,n;for(;++t0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function hf(e,t){let n="",r=0,i=-1,a=0,o=-1,l,c;for(;++o<=e.length;){if(o2){if(c=n.lastIndexOf("/"),c!==n.length-1){c<0?(n="",r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf("/")),i=o,a=0;continue}}else if(n.length>0){n="",r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1;i=o,a=0}else l===46&&a>-1?a++:a=-1}return n}function yr(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const pf={cwd:mf};function mf(){return"/"}function Hs(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function ff(e){if(typeof e=="string")e=new URL(e);else if(!Hs(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return xf(e)}function xf(e){if(e.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const t=e.pathname;let n=-1;for(;++n0){let[p,...w]=d;const y=r[m][1];Us(y)&&Us(p)&&(p=is(!0,y,p)),r[m]=[u,p,...w]}}}}const wf=new vi().freeze();function cs(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function us(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function ds(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function zo(e){if(!Us(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function qo(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Pr(e){return vf(e)?e:new fc(e)}function vf(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function jf(e){return typeof e=="string"||kf(e)}function kf(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const Nf="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Bo=[],$o={allowDangerousHtml:!0},Sf=/^(https?|ircs?|mailto|xmpp)$/i,_f=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function Cf(e){const t=Pf(e),n=Ef(e);return Rf(t.runSync(t.parse(n),n),e)}function Pf(e){const t=e.rehypePlugins||Bo,n=e.remarkPlugins||Bo,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...$o}:$o;return wf().use(im).use(n).use(tf,r).use(t)}function Ef(e){const t=e.children||"",n=new fc;return typeof t=="string"&&(n.value=t),n}function Rf(e,t){const n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,l=t.unwrapDisallowed,c=t.urlTransform||If;for(const d of _f)Object.hasOwn(t,d.from)&&(""+d.from+(d.to?"use `"+d.to+"` instead":"remove it")+Nf+d.id,void 0);return mc(e,u),Fd(e,{Fragment:s.Fragment,components:i,ignoreInvalidStyle:!0,jsx:s.jsx,jsxs:s.jsxs,passKeys:!0,passNode:!0});function u(d,h,m){if(d.type==="raw"&&m&&typeof h=="number")return o?m.children.splice(h,1):m.children[h]={type:"text",value:d.value},h;if(d.type==="element"){let p;for(p in ts)if(Object.hasOwn(ts,p)&&Object.hasOwn(d.properties,p)){const w=d.properties[p],y=ts[p];(y===null||y.includes(d.tagName))&&(d.properties[p]=c(String(w||""),p,d))}}if(d.type==="element"){let p=n?!n.includes(d.tagName):a?a.includes(d.tagName):!1;if(!p&&r&&typeof h=="number"&&(p=!r(d,h,m)),p&&m&&typeof h=="number")return l&&d.children?m.children.splice(h,1,...d.children):m.children.splice(h,1),h}}}function If(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),i=e.indexOf("/");return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||Sf.test(e.slice(0,t))?e:""}const ji="-",Tf=e=>{const t=Lf(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:o=>{const l=o.split(ji);return l[0]===""&&l.length!==1&&l.shift(),xc(l,t)||Af(o)},getConflictingClassGroupIds:(o,l)=>{const c=n[o]||[];return l&&r[o]?[...c,...r[o]]:c}}},xc=(e,t)=>{var o;if(e.length===0)return t.classGroupId;const n=e[0],r=t.nextPart.get(n),i=r?xc(e.slice(1),r):void 0;if(i)return i;if(t.validators.length===0)return;const a=e.join(ji);return(o=t.validators.find(({validator:l})=>l(a)))==null?void 0:o.classGroupId},Uo=/^\[(.+)\]$/,Af=e=>{if(Uo.test(e)){const t=Uo.exec(e)[1],n=t==null?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},Lf=e=>{const{theme:t,prefix:n}=e,r={nextPart:new Map,validators:[]};return Of(Object.entries(e.classGroups),n).forEach(([a,o])=>{Ks(o,r,a,t)}),r},Ks=(e,t,n,r)=>{e.forEach(i=>{if(typeof i=="string"){const a=i===""?t:Ho(t,i);a.classGroupId=n;return}if(typeof i=="function"){if(Mf(i)){Ks(i(r),t,n,r);return}t.validators.push({validator:i,classGroupId:n});return}Object.entries(i).forEach(([a,o])=>{Ks(o,Ho(t,a),n,r)})})},Ho=(e,t)=>{let n=e;return t.split(ji).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},Mf=e=>e.isThemeGetter,Of=(e,t)=>t?e.map(([n,r])=>{const i=r.map(a=>typeof a=="string"?t+a:typeof a=="object"?Object.fromEntries(Object.entries(a).map(([o,l])=>[t+o,l])):a);return[n,i]}):e,Df=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=new Map,r=new Map;const i=(a,o)=>{n.set(a,o),t++,t>e&&(t=0,r=n,n=new Map)};return{get(a){let o=n.get(a);if(o!==void 0)return o;if((o=r.get(a))!==void 0)return i(a,o),o},set(a,o){n.has(a)?n.set(a,o):i(a,o)}}},gc="!",Ff=e=>{const{separator:t,experimentalParseClassName:n}=e,r=t.length===1,i=t[0],a=t.length,o=l=>{const c=[];let u=0,d=0,h;for(let v=0;vd?h-d:void 0;return{modifiers:c,hasImportantModifier:p,baseClassName:w,maybePostfixModifierPosition:y}};return n?l=>n({className:l,parseClassName:o}):o},zf=e=>{if(e.length<=1)return e;const t=[];let n=[];return e.forEach(r=>{r[0]==="["?(t.push(...n.sort(),r),n=[]):n.push(r)}),t.push(...n.sort()),t},qf=e=>({cache:Df(e.cacheSize),parseClassName:Ff(e),...Tf(e)}),Bf=/\s+/,$f=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i}=t,a=[],o=e.trim().split(Bf);let l="";for(let c=o.length-1;c>=0;c-=1){const u=o[c],{modifiers:d,hasImportantModifier:h,baseClassName:m,maybePostfixModifierPosition:p}=n(u);let w=!!p,y=r(w?m.substring(0,p):m);if(!y){if(!w){l=u+(l.length>0?" "+l:l);continue}if(y=r(m),!y){l=u+(l.length>0?" "+l:l);continue}w=!1}const v=zf(d).join(":"),b=h?v+gc:v,N=b+y;if(a.includes(N))continue;a.push(N);const k=i(y,w);for(let _=0;_0?" "+l:l)}return l};function Uf(){let e=0,t,n,r="";for(;e{if(typeof e=="string")return e;let t,n="";for(let r=0;rh(d),e());return n=qf(u),r=n.cache.get,i=n.cache.set,a=l,l(c)}function l(c){const u=r(c);if(u)return u;const d=$f(c,n);return i(c,d),d}return function(){return a(Uf.apply(null,arguments))}}const ge=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},yc=/^\[(?:([a-z-]+):)?(.+)\]$/i,Kf=/^\d+\/\d+$/,Qf=new Set(["px","full","screen"]),Wf=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Vf=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Gf=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Jf=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Xf=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,kt=e=>yn(e)||Qf.has(e)||Kf.test(e),Rt=e=>$n(e,"length",ix),yn=e=>!!e&&!Number.isNaN(Number(e)),hs=e=>$n(e,"number",yn),Yn=e=>!!e&&Number.isInteger(Number(e)),Yf=e=>e.endsWith("%")&&yn(e.slice(0,-1)),Y=e=>yc.test(e),It=e=>Wf.test(e),Zf=new Set(["length","size","percentage"]),ex=e=>$n(e,Zf,wc),tx=e=>$n(e,"position",wc),nx=new Set(["image","url"]),rx=e=>$n(e,nx,ox),sx=e=>$n(e,"",ax),Zn=()=>!0,$n=(e,t,n)=>{const r=yc.exec(e);return r?r[1]?typeof t=="string"?r[1]===t:t.has(r[1]):n(r[2]):!1},ix=e=>Vf.test(e)&&!Gf.test(e),wc=()=>!1,ax=e=>Jf.test(e),ox=e=>Xf.test(e),lx=()=>{const e=ge("colors"),t=ge("spacing"),n=ge("blur"),r=ge("brightness"),i=ge("borderColor"),a=ge("borderRadius"),o=ge("borderSpacing"),l=ge("borderWidth"),c=ge("contrast"),u=ge("grayscale"),d=ge("hueRotate"),h=ge("invert"),m=ge("gap"),p=ge("gradientColorStops"),w=ge("gradientColorStopPositions"),y=ge("inset"),v=ge("margin"),b=ge("opacity"),N=ge("padding"),k=ge("saturate"),_=ge("scale"),O=ge("sepia"),j=ge("skew"),B=ge("space"),F=ge("translate"),C=()=>["auto","contain","none"],M=()=>["auto","hidden","clip","visible","scroll"],D=()=>["auto",Y,t],I=()=>[Y,t],X=()=>["",kt,Rt],q=()=>["auto",yn,Y],P=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],U=()=>["solid","dashed","dotted","double","none"],te=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],me=()=>["start","end","center","between","around","evenly","stretch"],ye=()=>["","0",Y],f=()=>["auto","avoid","all","avoid-page","page","left","right","column"],A=()=>[yn,Y];return{cacheSize:500,separator:":",theme:{colors:[Zn],spacing:[kt,Rt],blur:["none","",It,Y],brightness:A(),borderColor:[e],borderRadius:["none","","full",It,Y],borderSpacing:I(),borderWidth:X(),contrast:A(),grayscale:ye(),hueRotate:A(),invert:ye(),gap:I(),gradientColorStops:[e],gradientColorStopPositions:[Yf,Rt],inset:D(),margin:D(),opacity:A(),padding:I(),saturate:A(),scale:A(),sepia:ye(),skew:A(),space:I(),translate:I()},classGroups:{aspect:[{aspect:["auto","square","video",Y]}],container:["container"],columns:[{columns:[It]}],"break-after":[{"break-after":f()}],"break-before":[{"break-before":f()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...P(),Y]}],overflow:[{overflow:M()}],"overflow-x":[{"overflow-x":M()}],"overflow-y":[{"overflow-y":M()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[y]}],"inset-x":[{"inset-x":[y]}],"inset-y":[{"inset-y":[y]}],start:[{start:[y]}],end:[{end:[y]}],top:[{top:[y]}],right:[{right:[y]}],bottom:[{bottom:[y]}],left:[{left:[y]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",Yn,Y]}],basis:[{basis:D()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",Y]}],grow:[{grow:ye()}],shrink:[{shrink:ye()}],order:[{order:["first","last","none",Yn,Y]}],"grid-cols":[{"grid-cols":[Zn]}],"col-start-end":[{col:["auto",{span:["full",Yn,Y]},Y]}],"col-start":[{"col-start":q()}],"col-end":[{"col-end":q()}],"grid-rows":[{"grid-rows":[Zn]}],"row-start-end":[{row:["auto",{span:[Yn,Y]},Y]}],"row-start":[{"row-start":q()}],"row-end":[{"row-end":q()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",Y]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",Y]}],gap:[{gap:[m]}],"gap-x":[{"gap-x":[m]}],"gap-y":[{"gap-y":[m]}],"justify-content":[{justify:["normal",...me()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...me(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...me(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[N]}],px:[{px:[N]}],py:[{py:[N]}],ps:[{ps:[N]}],pe:[{pe:[N]}],pt:[{pt:[N]}],pr:[{pr:[N]}],pb:[{pb:[N]}],pl:[{pl:[N]}],m:[{m:[v]}],mx:[{mx:[v]}],my:[{my:[v]}],ms:[{ms:[v]}],me:[{me:[v]}],mt:[{mt:[v]}],mr:[{mr:[v]}],mb:[{mb:[v]}],ml:[{ml:[v]}],"space-x":[{"space-x":[B]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[B]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",Y,t]}],"min-w":[{"min-w":[Y,t,"min","max","fit"]}],"max-w":[{"max-w":[Y,t,"none","full","min","max","fit","prose",{screen:[It]},It]}],h:[{h:[Y,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[Y,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[Y,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[Y,t,"auto","min","max","fit"]}],"font-size":[{text:["base",It,Rt]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",hs]}],"font-family":[{font:[Zn]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",Y]}],"line-clamp":[{"line-clamp":["none",yn,hs]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",kt,Y]}],"list-image":[{"list-image":["none",Y]}],"list-style-type":[{list:["none","disc","decimal",Y]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[b]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[b]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...U(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",kt,Rt]}],"underline-offset":[{"underline-offset":["auto",kt,Y]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:I()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Y]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Y]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[b]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...P(),tx]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",ex]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},rx]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[w]}],"gradient-via-pos":[{via:[w]}],"gradient-to-pos":[{to:[w]}],"gradient-from":[{from:[p]}],"gradient-via":[{via:[p]}],"gradient-to":[{to:[p]}],rounded:[{rounded:[a]}],"rounded-s":[{"rounded-s":[a]}],"rounded-e":[{"rounded-e":[a]}],"rounded-t":[{"rounded-t":[a]}],"rounded-r":[{"rounded-r":[a]}],"rounded-b":[{"rounded-b":[a]}],"rounded-l":[{"rounded-l":[a]}],"rounded-ss":[{"rounded-ss":[a]}],"rounded-se":[{"rounded-se":[a]}],"rounded-ee":[{"rounded-ee":[a]}],"rounded-es":[{"rounded-es":[a]}],"rounded-tl":[{"rounded-tl":[a]}],"rounded-tr":[{"rounded-tr":[a]}],"rounded-br":[{"rounded-br":[a]}],"rounded-bl":[{"rounded-bl":[a]}],"border-w":[{border:[l]}],"border-w-x":[{"border-x":[l]}],"border-w-y":[{"border-y":[l]}],"border-w-s":[{"border-s":[l]}],"border-w-e":[{"border-e":[l]}],"border-w-t":[{"border-t":[l]}],"border-w-r":[{"border-r":[l]}],"border-w-b":[{"border-b":[l]}],"border-w-l":[{"border-l":[l]}],"border-opacity":[{"border-opacity":[b]}],"border-style":[{border:[...U(),"hidden"]}],"divide-x":[{"divide-x":[l]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[l]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[b]}],"divide-style":[{divide:U()}],"border-color":[{border:[i]}],"border-color-x":[{"border-x":[i]}],"border-color-y":[{"border-y":[i]}],"border-color-s":[{"border-s":[i]}],"border-color-e":[{"border-e":[i]}],"border-color-t":[{"border-t":[i]}],"border-color-r":[{"border-r":[i]}],"border-color-b":[{"border-b":[i]}],"border-color-l":[{"border-l":[i]}],"divide-color":[{divide:[i]}],"outline-style":[{outline:["",...U()]}],"outline-offset":[{"outline-offset":[kt,Y]}],"outline-w":[{outline:[kt,Rt]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:X()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[b]}],"ring-offset-w":[{"ring-offset":[kt,Rt]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",It,sx]}],"shadow-color":[{shadow:[Zn]}],opacity:[{opacity:[b]}],"mix-blend":[{"mix-blend":[...te(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":te()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[c]}],"drop-shadow":[{"drop-shadow":["","none",It,Y]}],grayscale:[{grayscale:[u]}],"hue-rotate":[{"hue-rotate":[d]}],invert:[{invert:[h]}],saturate:[{saturate:[k]}],sepia:[{sepia:[O]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[c]}],"backdrop-grayscale":[{"backdrop-grayscale":[u]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[d]}],"backdrop-invert":[{"backdrop-invert":[h]}],"backdrop-opacity":[{"backdrop-opacity":[b]}],"backdrop-saturate":[{"backdrop-saturate":[k]}],"backdrop-sepia":[{"backdrop-sepia":[O]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[o]}],"border-spacing-x":[{"border-spacing-x":[o]}],"border-spacing-y":[{"border-spacing-y":[o]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",Y]}],duration:[{duration:A()}],ease:[{ease:["linear","in","out","in-out",Y]}],delay:[{delay:A()}],animate:[{animate:["none","spin","ping","pulse","bounce",Y]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[_]}],"scale-x":[{"scale-x":[_]}],"scale-y":[{"scale-y":[_]}],rotate:[{rotate:[Yn,Y]}],"translate-x":[{"translate-x":[F]}],"translate-y":[{"translate-y":[F]}],"skew-x":[{"skew-x":[j]}],"skew-y":[{"skew-y":[j]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",Y]}],accent:[{accent:["auto",e]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Y]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":I()}],"scroll-mx":[{"scroll-mx":I()}],"scroll-my":[{"scroll-my":I()}],"scroll-ms":[{"scroll-ms":I()}],"scroll-me":[{"scroll-me":I()}],"scroll-mt":[{"scroll-mt":I()}],"scroll-mr":[{"scroll-mr":I()}],"scroll-mb":[{"scroll-mb":I()}],"scroll-ml":[{"scroll-ml":I()}],"scroll-p":[{"scroll-p":I()}],"scroll-px":[{"scroll-px":I()}],"scroll-py":[{"scroll-py":I()}],"scroll-ps":[{"scroll-ps":I()}],"scroll-pe":[{"scroll-pe":I()}],"scroll-pt":[{"scroll-pt":I()}],"scroll-pr":[{"scroll-pr":I()}],"scroll-pb":[{"scroll-pb":I()}],"scroll-pl":[{"scroll-pl":I()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Y]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[kt,Rt,hs]}],stroke:[{stroke:[e,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},cx=Hf(lx),Qs={status:"",repo:"",thread:"",action:"",intent:"",actor:""},ux=new Uu({defaultOptions:{queries:{retry:1}}}),Ko=12,dx=12,hx=10080*60*1e3,px=1e3,Ws=Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC";function Q(...e){return cx(du(e))}async function ee(e,t){const n=new Headers(t==null?void 0:t.headers);n.set("Accept","application/json");const r=await fetch(e,{...t,headers:n});if(!r.ok)throw new Error(`${r.status} ${r.statusText}`);return r.json()}function Xe(e){if(e==null)return"n/a";const t=Math.max(0,Math.floor(e));if(t<60)return`${t}s`;const n=Math.floor(t/60);return n<60?`${n}m ${t%60}s`:`${Math.floor(n/60)}h ${n%60}m`}const mx=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:"short"}),fx=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});function wr(e){if(!e)return null;const t=new Date(e);return Number.isNaN(t.getTime())?null:t}function xx(e){const t=wr(e);return t?mx.format(t):e??""}function ir(e){const t=wr(e);return t?fx.format(t):e??""}function vc(e,t){const n=wr(e);if(!n)return e??"";const r=t-n.getTime(),i=Math.abs(r);if(i>hx)return ir(e);const a=r>=0?"ago":"from now",o=Math.round(i/1e3);if(o<45)return r>=0?"just now":"soon";if(o<90)return`1m ${a}`;const l=Math.round(o/60);if(l<60)return`${l}m ${a}`;if(l<90)return`1h ${a}`;const c=Math.round(l/60);return c<24?`${c}h ${a}`:c<36?`1d ${a}`:`${Math.round(c/24)}d ${a}`}function ue({value:e,compact:t=!1,relative:n=!1,now:r=Date.now()}){const i=wr(e);return i?s.jsx("time",{dateTime:i.toISOString(),title:`UTC: ${i.toISOString()}`,children:n?vc(e,r):t?ir(e):xx(e)}):s.jsx(s.Fragment,{children:e??""})}function jc(e,t){const n=wr(e);return n?Math.max(0,Math.floor((t-n.getTime())/1e3)):null}function ki(e,t){return e.status==="running"?jc(e.started_at,t)??e.runtime_seconds:e.runtime_seconds}function Ni(e,t){return e.status==="pending"?jc(e.created_at,t)??e.queue_wait_seconds:e.queue_wait_seconds}function gx(e){const[t,n]=R.useState(()=>Date.now());return R.useEffect(()=>{if(!e)return;n(Date.now());const r=window.setInterval(()=>n(Date.now()),px);return()=>window.clearInterval(r)},[e]),t}function bx(e){return(e??"").split(/\r?\n/).map(n=>n.trim()).find(Boolean)??""}function zr(e,t,n=1){const r=bx(t),i=n>1?` (${n})`:"";return r?`${e}${i}: ${r}`:`${e}${i}`}function qr(e){return e==="openclaw_stdout"||e==="openclaw_stderr"}function kc(e){return e.map(t=>t==null?void 0:t.trim()).filter(Boolean).join(` -`)}function yx(e){const t=[];for(const n of e){const r=t[t.length-1];if(r&&qr(n.event_type)&&r.eventType===n.event_type){r.count+=1,r.meta=n.ts,r.detail=kc([r.detail,n.detail]),r.summary=zr(n.summary,r.detail,r.count);continue}t.push({id:String(n.id),badge:n.event_type,meta:n.ts,summary:qr(n.event_type)?zr(n.summary,n.detail):n.summary,detail:n.detail,eventType:n.event_type,count:1})}return t}function wx(e){const t=[];return e.forEach((n,r)=>{const i=t[t.length-1];if(i&&qr(n.kind)&&i.kind===n.kind){i.count+=1,i.meta=n.timestamp,i.text=kc([i.text,n.text]),i.summary=zr(`${n.role} ยท ${n.kind}`,i.text,i.count);return}t.push({id:`${n.timestamp??"entry"}-${r}`,badge:n.title,meta:n.timestamp,summary:qr(n.kind)?zr(`${n.role} ยท ${n.kind}`,n.text):`${n.role} ยท ${n.kind}`,text:n.text,kind:n.kind,count:1})}),t}function Qo(e,t,n,r){return e==="openclaw_stdout"?!1:t||n>=r-2}function vx(e){return{pending:{badge:"border-amber-300 bg-amber-50 text-amber-800",dot:"bg-amber-500"},running:{badge:"border-blue-300 bg-blue-50 text-blue-700",dot:"bg-blue-600"},blocked:{badge:"border-red-300 bg-red-50 text-red-700",dot:"bg-red-600"},denied:{badge:"border-red-300 bg-red-50 text-red-700",dot:"bg-red-600"},done:{badge:"border-emerald-300 bg-emerald-50 text-emerald-700",dot:"bg-emerald-600"},waiting_approval:{badge:"border-slate-300 bg-slate-50 text-slate-700",dot:"bg-slate-500"}}[e]??{badge:"border-slate-300 bg-slate-50 text-slate-700",dot:"bg-slate-500"}}function jx(e,t){const n=new URLSearchParams;for(const[r,i]of Object.entries(e))i.trim()&&n.set(r,i.trim());return n.set("limit",String(t)),`/api/jobs?${n.toString()}`}function kx(e,t,n,r=50,i=0){const a=new URLSearchParams;return e.trim()&&a.set("repo",e.trim()),n==="proposals"&&t.trim()&&a.set("status",t.trim()),a.set("section",n),a.set("limit",String(r)),i>0&&a.set("offset",String(i)),`/api/knowledge?${a.toString()}`}function Nx(e){return{timeseries:e==="overview",hooks:e==="hooks",deliveries:e==="deliveries"}}function Sx(e,t,n="day"){return`/api/webhooks/github/timeseries?${new URLSearchParams({from:e,to:t,bucket:n}).toString()}`}function _x(e=50,t){const n=new URLSearchParams({limit:String(e)});return t&&n.set("cursor",t),`/api/webhooks/github/hooks?${n.toString()}`}function Cx(e=50,t,n){const r=new URLSearchParams({limit:String(e)});t&&r.set("cursor",t);for(const[i,a]of Object.entries(n??{}))a!=null&&a.trim()&&r.set(i,a.trim());return`/api/webhooks/github/deliveries?${r.toString()}`}function Er(e=new Date){return{from:new Date(e.getTime()-720*60*60*1e3).toISOString(),to:e.toISOString()}}function Px(e=Ws,t="7d",n="7d"){return`/api/metrics/summary?${new URLSearchParams({window:t,runtime_window:n,timezone:e}).toString()}`}function rt(e){try{const t=new URL(e);return t.protocol==="https:"||t.protocol==="http:"?t.href:"#"}catch{return"#"}}function Lr(){return"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window}function Ex(e){return!!(e&&typeof e=="object"&&"type"in e&&e.type==="github-agent-bridge:push")}function Rx(e){const t="=".repeat((4-e.length%4)%4),n=(e+t).replace(/-/g,"+").replace(/_/g,"/"),r=window.atob(n),i=new Uint8Array(r.length);for(let a=0;an.id===t.id)?e:[...e,t]}function Tx(e,t){const n=Wo(t);return e.some(r=>Wo(r)===n)?e:[...e,t]}function Wo(e){return`${e.timestamp??""}:${e.role}:${e.kind}:${e.title}:${e.text}`}function Ax(e){return["claimed","dispatch_started","dispatch_finished","done","blocked","denied","waiting_approval"].includes(e)}function Vs(e){return e==="blocked"}function Gs(e){return["blocked","denied","waiting_approval"].includes(e)}function Js(e,t){return e.status!=="running"?!1:t!=null&&t.is_admin?!0:!!(t!=null&&t.login&&e.trigger_actor&&t.login.toLowerCase()===e.trigger_actor.toLowerCase())}function Lx(e=window.location.pathname){const t=e.match(/^\/jobs\/(\d+)\/?$/);return t?Number(t[1]):null}function Mx(e=window.location.pathname){return/^\/knowledge\/?$/.test(e)}function Ox(e=window.location.pathname){return/^\/mcp\/?$/.test(e)}function Dx(e=window.location.pathname){return/^\/system\/?$/.test(e)}function Fx(e=window.location.pathname){const t=e.match(/^\/webhooks\/hooks\/([^/]+)\/?$/);return t?decodeURIComponent(t[1]):null}function zx(e=window.location.pathname){const t=e.match(/^\/webhooks\/deliveries\/([^/]+)\/?$/);return t?decodeURIComponent(t[1]):null}function ps(e=window.location.pathname){return/^\/webhooks(?:\/(?:hooks|deliveries)\/[^/]+)?\/?$/.test(e)}function Nc(e){return e.startsWith("repo:")?e.slice(5):e}function Vo(e){return Object.values(e).some(t=>t.trim()!=="")}function qx(e){return[{key:"status",label:"Status",value:e.status},{key:"repo",label:"Repo",value:e.repo},{key:"thread",label:"Thread",value:e.thread},{key:"action",label:"Action",value:e.action},{key:"actor",label:"Actor",value:e.actor.trim()?`@${e.actor.trim().replace(/^@/,"")}`:""},{key:"intent",label:"Intent",value:e.intent}].filter(t=>t.value.trim()!=="")}function Bx(){var Ti,Ai,Li,Mi,Oi,Di,Fi,zi,qi,Bi,$i,Ui,Hi,Ki,Qi,Wi,Vi,Gi,Ji,Xi,Yi,Zi,ea,ta,na,ra,sa,ia,aa,oa,la,ca,ua,da,ha,pa,ma,fa,xa,ga,ba,ya,wa,va,ja,ka,Na,Sa,_a,Ca,Pa,Ea,Ra,Ia,Ta,Aa,La,Ma,Oa,Da,Fa,za,qa,Ba,$a;const e=Sl(),[t,n]=R.useState(Qs),[r,i]=R.useState(Ko),a=R.useRef(!1),[o,l]=R.useState(""),[c,u]=R.useState("proposed"),[d,h]=R.useState("proposals"),[m,p]=R.useState("overview"),[w,y]=R.useState({hook_id:"",event_name:"",repository:"",result:"",enqueue_status:""}),[v,b]=R.useState(()=>Er()),[N,k]=R.useState(null),[_,O]=R.useState(""),[j,B]=R.useState(!1),[F,C]=R.useState(""),[M,D]=R.useState(!1),[I,X]=R.useState(""),[q,P]=R.useState("7d"),[U,te]=R.useState("7d"),[me,ye]=R.useState(()=>window.location.pathname),[f,A]=R.useState(null),fe=Lx(me),x=fe!==null,Pe=Mx(me),He=Ox(me),de=Dx(me),lt=ps(me),Me=Fx(me),Ke=zx(me),st=!x&&!Pe&&!He&&!de&&!lt,oe=fe,ke=ve({queryKey:["metrics",Ws,q,U],queryFn:()=>ee(Px(Ws,q,U)),enabled:st||de}),Ne=ve({queryKey:["dashboard-status"],queryFn:()=>ee("/api/status"),refetchInterval:de?1e4:!1}),Ee=ve({queryKey:["me"],queryFn:()=>ee("/api/me"),refetchInterval:!1}),ct=lt&&!!((Ai=(Ti=Ee.data)==null?void 0:Ti.user)!=null&&Ai.is_admin&&((Li=Ne.data)!=null&&Li.webhook_configured)),Ht=Nx(m),yt=ve({queryKey:["web-push-config"],queryFn:()=>ee("/api/web-push/config"),enabled:!!((Mi=Ee.data)!=null&&Mi.user)}),Vr=ve({queryKey:["about"],queryFn:()=>ee("/api/about")}),vr=ve({queryKey:["job-actors"],queryFn:()=>ee("/api/jobs/actors"),enabled:st}),Qe=ve({queryKey:["jobs",t,r],queryFn:()=>ee(jx(t,r)),enabled:st,placeholderData:E=>E}),it=ve({queryKey:["processes"],queryFn:()=>ee("/api/processes"),enabled:de,refetchInterval:de?1e4:!1}),hn=ve({queryKey:["systemd"],queryFn:()=>ee("/api/systemd"),enabled:de}),pn=ve({queryKey:["alerts"],queryFn:()=>ee("/api/alerts"),enabled:de}),mn=ve({queryKey:["webhook-summary"],queryFn:()=>ee("/api/webhooks/github/summary"),enabled:ct}),Kn=ve({queryKey:["webhook-timeseries",v.from,v.to,"day"],queryFn:()=>ee(Sx(v.from,v.to)),enabled:ct&&Ht.timeseries}),S=ve({queryKey:["webhook-exceptions"],queryFn:()=>ee("/api/webhooks/github/exceptions"),enabled:ct&&Ht.timeseries}),L=Yr({queryKey:["webhook-hooks"],queryFn:({pageParam:E})=>ee(_x(50,E)),initialPageParam:null,getNextPageParam:E=>E.next_cursor??void 0,enabled:ct&&Ht.hooks&&Me===null&&Ke===null}),K=Yr({queryKey:["webhook-deliveries",w],queryFn:({pageParam:E})=>ee(Cx(50,E,w)),initialPageParam:null,getNextPageParam:E=>E.next_cursor??void 0,enabled:ct&&Ht.deliveries&&Me===null&&Ke===null}),G=ve({queryKey:["webhook-hook",Me],queryFn:()=>ee(`/api/webhooks/github/hooks/${encodeURIComponent(Me??"")}`),enabled:ct&&Me!==null}),le=R.useCallback(async E=>{const Z=await ee(`/api/webhooks/github/hooks/${encodeURIComponent(E)}/ping`,{method:"POST"});return G.refetch(),window.setTimeout(()=>void G.refetch(),1500),Z.detail},[G]),Re=ve({queryKey:["webhook-delivery",Ke],queryFn:()=>ee(`/api/webhooks/github/deliveries/${encodeURIComponent(Ke??"")}`),enabled:ct&&Ke!==null}),Oe=Yr({queryKey:["knowledge",d,o,d==="proposals"?c:""],queryFn:({pageParam:E})=>ee(kx(o,c,d,50,E)),initialPageParam:0,getNextPageParam:E=>E.next_offset??void 0,enabled:Pe}),Fe=ve({queryKey:["mcp-tokens"],queryFn:()=>ee("/api/mcp/tokens"),enabled:He&&!!((Oi=Ee.data)!=null&&Oi.user)}),Kt=ve({queryKey:["mcp-users"],queryFn:()=>ee("/api/mcp/users"),enabled:He&&!!((Di=Ee.data)!=null&&Di.user)}),ut=ve({queryKey:["job",oe],queryFn:()=>ee(`/api/jobs/${oe}`),enabled:oe!==null}),Ie=ve({queryKey:["job-session",oe],queryFn:()=>ee(`/api/jobs/${oe}/session`),enabled:oe!==null}),wt=ve({queryKey:["job-session-events",oe],queryFn:()=>ee(`/api/jobs/${oe}/session/events`),enabled:oe!==null}),Ye=ve({queryKey:["job-session-transcript",oe],queryFn:()=>ee(`/api/jobs/${oe}/session/transcript`),enabled:oe!==null}),Ci=R.useCallback(async E=>{const Z=await ee(`/api/jobs/${E}/retry`,{method:"POST"});e.setQueryData(["job",E],{job:Z.job}),e.invalidateQueries({queryKey:["jobs"]}),e.invalidateQueries({queryKey:["metrics"]})},[e]),Pi=R.useCallback(async E=>{const Z=await ee(`/api/jobs/${E}/dismiss`,{method:"POST"});e.setQueryData(["job",E],{job:Z.job}),e.invalidateQueries({queryKey:["jobs"]}),e.invalidateQueries({queryKey:["metrics"]})},[e]),Ei=R.useCallback(async(E,Z)=>{const ce=await ee(`/api/jobs/${E}/cancel`,{method:"POST",body:JSON.stringify({reason:Z||""})});e.setQueryData(["job",E],{job:ce.job}),e.invalidateQueries({queryKey:["jobs"]}),e.invalidateQueries({queryKey:["metrics"]}),e.invalidateQueries({queryKey:["dashboard-status"]})},[e]),Ri=R.useCallback(async(E,Z)=>{await ee(`/api/knowledge/proposals/${encodeURIComponent(E)}/${Z}`,{method:"POST"}),e.invalidateQueries({queryKey:["knowledge"]}),e.invalidateQueries({queryKey:["dashboard-status"]})},[e]),Fc=R.useCallback(async E=>{await ee(`/api/knowledge/rules/${encodeURIComponent(E)}`,{method:"DELETE"}),e.invalidateQueries({queryKey:["knowledge"]})},[e]),zc=R.useCallback(async(E,Z)=>{await ee(`/api/knowledge/rules/${encodeURIComponent(E)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:Z})}),e.invalidateQueries({queryKey:["knowledge"]})},[e]),qc=R.useCallback(async(E,Z)=>{const ce=await ee("/api/mcp/tokens",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:E,user_login:Z||void 0})});return e.invalidateQueries({queryKey:["mcp-tokens"]}),ce},[e]),Bc=R.useCallback(async(E,Z)=>{await ee(`/api/mcp/tokens/${encodeURIComponent(E)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({user_login:Z})}),e.invalidateQueries({queryKey:["mcp-tokens"]}),e.invalidateQueries({queryKey:["mcp-users"]})},[e]),$c=R.useCallback(async E=>{await ee(`/api/mcp/tokens/${encodeURIComponent(E)}`,{method:"DELETE"}),e.invalidateQueries({queryKey:["mcp-tokens"]})},[e]),Gr=R.useCallback(async E=>{const Z={refresh:"/api/autoupdate/refresh",apply:"/api/autoupdate/apply",complete:"/api/autoupdate/complete-pending"}[E];k(E),O("");try{await ee(Z,{method:"POST"}),e.invalidateQueries({queryKey:["dashboard-status"]})}catch(ce){e.invalidateQueries({queryKey:["dashboard-status"]}),O(ce instanceof Error?ce.message:String(ce))}finally{k(null)}},[e]),Uc=R.useCallback(async E=>{B(!0),C("");try{const Z=await ee(`/api/executor/${E?"pause":"resume"}`,{method:"POST"});e.setQueryData(["dashboard-status"],ce=>ce&&{...ce,executor_pause:Z.executor_pause}),await e.invalidateQueries({queryKey:["dashboard-status"]})}catch(Z){C(Z instanceof Error?Z.message:String(Z))}finally{B(!1)}},[e]),Hc=R.useCallback(async E=>{D(!0),X("");try{await ee("/api/executor/resize",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workers:E})}),await Promise.all([e.invalidateQueries({queryKey:["dashboard-status"]}),e.invalidateQueries({queryKey:["processes"]})])}catch(Z){X(Z instanceof Error?Z.message:String(Z))}finally{D(!1)}},[e]),Kc=R.useCallback(async()=>{var Ua;const E=(Ua=yt.data)==null?void 0:Ua.public_key;if(!E)throw new Error("web_push_not_configured");if(!Lr())throw new Error("web_push_not_supported");if(await window.Notification.requestPermission()!=="granted")throw new Error("notification_permission_denied");const ce=await navigator.serviceWorker.register("/service-worker.js"),su=await ce.pushManager.getSubscription()??await ce.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:Rx(E)});await ee("/api/web-push/subscriptions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(su.toJSON())}),e.invalidateQueries({queryKey:["web-push-config"]})},[e,(Fi=yt.data)==null?void 0:Fi.public_key]),Qc=R.useCallback(async()=>{if(!Lr())return;const Z=await(await navigator.serviceWorker.ready).pushManager.getSubscription();if(!Z)return;const ce=Z.endpoint;await Z.unsubscribe(),await ee("/api/web-push/subscriptions",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({endpoint:ce})}),e.invalidateQueries({queryKey:["web-push-config"]})},[e]);R.useEffect(()=>{var E;!((E=yt.data)!=null&&E.status.enabled)||!Lr()||navigator.serviceWorker.register("/service-worker.js").catch(()=>{})},[(zi=yt.data)==null?void 0:zi.status.enabled]),R.useEffect(()=>{if(oe===null)return;const E=new EventSource(`/api/jobs/${oe}/session/stream`);return E.addEventListener("session_event",Z=>{const ce=Br(Z);ce&&(e.setQueryData(["job-session-events",oe],Pt=>({events:Ix((Pt==null?void 0:Pt.events)??[],ce)})),Ax(ce.event_type)&&(e.invalidateQueries({queryKey:["job",oe]}),e.invalidateQueries({queryKey:["jobs"]})))}),E.addEventListener("transcript_entry",Z=>{const ce=Br(Z);!ce||ce.job_id!==oe||e.setQueryData(["job-session-transcript",oe],Pt=>({entries:Tx((Pt==null?void 0:Pt.entries)??[],ce.entry)}))}),E.onerror=()=>{e.invalidateQueries({queryKey:["job",oe]}),e.invalidateQueries({queryKey:["job-session-events",oe]}),e.invalidateQueries({queryKey:["job-session-transcript",oe]})},()=>E.close()},[oe,e]),R.useEffect(()=>{const E=()=>{ps(window.location.pathname)&&b(Er()),ye(window.location.pathname)};return window.addEventListener("popstate",E),()=>window.removeEventListener("popstate",E)},[]),R.useEffect(()=>{if(!("serviceWorker"in navigator))return;const E=Z=>{if(!Ex(Z.data))return;const ce={...Z.data.payload,id:Date.now(),receivedAt:Date.now()};A(ce),ce.job_id&&(e.invalidateQueries({queryKey:["jobs"]}),e.invalidateQueries({queryKey:["job",ce.job_id]}),e.invalidateQueries({queryKey:["metrics"]}))};return navigator.serviceWorker.addEventListener("message",E),()=>navigator.serviceWorker.removeEventListener("message",E)},[e]),R.useEffect(()=>{if(!f)return;const E=window.setTimeout(()=>A(null),12e3);return()=>window.clearTimeout(E)},[f]);const Ii=R.useCallback(E=>{window.history.pushState({},"",Un(E)),ye(window.location.pathname)},[]),dt=R.useCallback(E=>{window.history.pushState({},"",E),ps(E)&&b(Er()),ye(window.location.pathname)},[]),Qt=((qi=ke.data)==null?void 0:qi.metrics.status_counts)??{},jr=((Bi=Qe.data)==null?void 0:Bi.jobs)??[],Wc=!!((Ui=($i=Ee.data)==null?void 0:$i.user)!=null&&Ui.is_admin&&Sc((Hi=Ne.data)==null?void 0:Hi.autoupdate)),Vc=R.useCallback(E=>{n(E),i(Ko),a.current=!1},[]);R.useEffect(()=>{Qe.isFetching||(a.current=!1)},[Qe.isFetching]);const Gc=R.useCallback(()=>{a.current||(a.current=!0,i(E=>E+dx))},[]),Ct=oe?((Ki=ut.data)==null?void 0:Ki.job)??null:null,Jc=jr.some(E=>E.status==="running"||E.status==="pending")||(Ct==null?void 0:Ct.status)==="running"||(Ct==null?void 0:Ct.status)==="pending"||!!((Qi=it.data)!=null&&Qi.running_jobs.length),Qn=gx(Jc),Xc=s.jsx(rg,{selectedJobId:oe,selectedJob:Ct,loading:ut.isLoading,error:ut.error,session:(Wi=Ie.data)==null?void 0:Wi.session,sessionEvents:(Vi=wt.data)==null?void 0:Vi.events,transcript:(Gi=Ye.data)==null?void 0:Gi.entries,now:Qn}),Yc=((Ji=L.data)==null?void 0:Ji.pages.flatMap(E=>E.hooks))??[],Zc=((Xi=K.data)==null?void 0:Xi.pages.flatMap(E=>E.deliveries))??[],vt=((Yi=Oe.data)==null?void 0:Yi.pages)??[],jt=vt[vt.length-1],eu=vt.length>0?{...vt[0],repositories:(jt==null?void 0:jt.repositories)??vt[0].repositories,summary:(jt==null?void 0:jt.summary)??vt[0].summary,proposals:vt.flatMap(E=>E.proposals),rules:vt.flatMap(E=>E.rules),events:vt.flatMap(E=>E.events),next_offset:(jt==null?void 0:jt.next_offset)??null}:void 0,tu=m==="overview"?Kn.isLoading:m==="hooks"?L.isLoading:K.isLoading,nu=m==="overview"?Kn.error:m==="hooks"?L.error:K.error,ru=()=>{mn.refetch(),m==="overview"&&S.refetch(),m==="overview"&&b(Er()),m==="hooks"&&L.refetch(),m==="deliveries"&&K.refetch()};return s.jsxs("div",{className:"min-h-screen bg-background text-foreground",children:[s.jsx("header",{className:"border-b border-slate-800 bg-slate-950 text-white",children:s.jsxs("div",{className:"mx-auto flex w-full max-w-[1440px] items-center justify-between gap-3 px-4 py-4 md:px-6",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("h1",{className:"truncate text-xl font-semibold",children:"GitHub Agent Bridge"}),s.jsx($x,{about:Vr.data})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[s.jsx(fg,{config:yt.data,loading:yt.isLoading,onEnable:Kc,onDisable:Qc}),s.jsx(mg,{user:(Zi=Ee.data)==null?void 0:Zi.user,loading:Ee.isLoading})]})]})}),s.jsxs("main",{className:"mx-auto grid w-full max-w-[1440px] gap-4 px-3 py-4 sm:px-4 md:px-6 md:py-5",children:[s.jsx(Vx,{isDashboardRoute:st,isSystemRoute:de,isKnowledgeRoute:Pe,isMcpRoute:He,isWebhooksRoute:lt,showWebhooks:!!((ta=(ea=Ee.data)==null?void 0:ea.user)!=null&&ta.is_admin&&((na=Ne.data)!=null&&na.webhook_configured)),knowledgeBadgeCount:((ia=(sa=(ra=Ne.data)==null?void 0:ra.metrics)==null?void 0:sa.knowledge)==null?void 0:ia.proposed)??0,systemUpdateAvailable:Wc,onNavigate:dt}),s.jsx(xg,{notification:f,onDismiss:()=>A(null),onNavigate:dt}),fe!==null?s.jsx(ng,{jobId:fe,detail:Xc,selectedJob:Ct,user:(aa=Ee.data)==null?void 0:aa.user,onBackToDashboard:()=>dt("/"),onRetry:Ci,onDismiss:Pi,onCancel:Ei,onRefresh:()=>{ut.refetch(),Ie.refetch(),wt.refetch(),Ye.refetch()}}):Pe?s.jsx(sg,{data:eu,loading:Oe.isLoading,error:Oe.error,repo:o,status:c,activeTab:d,user:(oa=Ee.data)==null?void 0:oa.user,now:Qn,onRepoChange:l,onStatusChange:u,onTabChange:h,onApprove:E=>Ri(E,"approve"),onReject:E=>Ri(E,"reject"),onUpdateRuleScope:zc,onDeleteRule:Fc,onRefresh:()=>Oe.refetch(),hasMore:!!Oe.hasNextPage,loadingMore:Oe.isFetchingNextPage,onLoadMore:()=>Oe.fetchNextPage()}):He?s.jsx(ug,{tokens:(la=Fe.data)==null?void 0:la.tokens,loading:Fe.isLoading,error:Fe.error,user:(ca=Ee.data)==null?void 0:ca.user,ownerOptions:((ua=Kt.data)==null?void 0:ua.users)??[],dashboardUrl:(da=Ne.data)==null?void 0:da.dashboard_url,dashboardUrlSource:(ha=Ne.data)==null?void 0:ha.dashboard_url_source,now:Qn,onCreate:qc,onUpdateOwner:Bc,onRevoke:$c,onRefresh:()=>Fe.refetch()}):lt?Ke?s.jsx(Zx,{data:Re.data,loading:Re.isLoading,error:Re.error,onBack:()=>{p("deliveries"),dt("/webhooks")},onRefresh:()=>Re.refetch(),onViewHook:E=>dt(`/webhooks/hooks/${encodeURIComponent(E)}`),onViewJob:Ii}):Me?s.jsx(Yx,{data:G.data,loading:G.isLoading,error:G.error,onBack:()=>{p("hooks"),dt("/webhooks")},onRefresh:()=>G.refetch(),onViewHook:E=>dt(`/webhooks/hooks/${encodeURIComponent(E)}`),onViewDelivery:E=>dt(`/webhooks/deliveries/${encodeURIComponent(E)}`),onPing:le}):s.jsx(Gx,{summary:mn.data,timeseries:(pa=Kn.data)==null?void 0:pa.points,exceptions:(ma=S.data)==null?void 0:ma.exceptions,hooks:Yc,deliveries:Zc,section:m,summaryLoading:mn.isLoading,sectionLoading:tu,loadingMore:m==="hooks"?L.isFetchingNextPage:K.isFetchingNextPage,hasMore:m==="hooks"?L.hasNextPage:K.hasNextPage,deliveryFilters:w,error:mn.error??nu,onSectionChange:p,onLoadMore:()=>m==="hooks"?L.fetchNextPage():K.fetchNextPage(),onDeliveryFiltersChange:y,onViewHook:E=>dt(`/webhooks/hooks/${encodeURIComponent(E)}`),onViewDelivery:E=>dt(`/webhooks/deliveries/${encodeURIComponent(E)}`),onRefresh:ru}):de?s.jsxs(s.Fragment,{children:[s.jsx(Ux,{state:(fa=Ne.data)==null?void 0:fa.autoupdate,isAdmin:!!((ga=(xa=Ee.data)==null?void 0:xa.user)!=null&&ga.is_admin),runningAction:N,actionError:_,onRefresh:()=>Gr("refresh"),onApply:()=>Gr("apply"),onCompletePending:()=>Gr("complete")}),s.jsx(eg,{executorPause:(ba=Ne.data)==null?void 0:ba.executor_pause,executorPauseLoading:Ne.isLoading,executorPauseStatusError:Ne.error,executorPausePending:j,executorPauseError:F,executorCapacity:{desired:((ya=it.data)==null?void 0:ya.executor.expected_workers)??((va=(wa=Ne.data)==null?void 0:wa.metrics)==null?void 0:va.executor_worker_count)??0,live:((ja=it.data)==null?void 0:ja.executor.live_workers)??((Na=(ka=Ne.data)==null?void 0:ka.metrics)==null?void 0:Na.executor_worker_live_count)??0,busy:((Sa=it.data)==null?void 0:Sa.executor.busy_workers)??((Ca=(_a=Ne.data)==null?void 0:_a.metrics)==null?void 0:Ca.executor_worker_busy_count)??0,draining:((Pa=it.data)==null?void 0:Pa.executor.draining_workers)??((Ra=(Ea=Ne.data)==null?void 0:Ea.metrics)==null?void 0:Ra.executor_worker_draining_count)??0},executorResizePending:M,executorResizeError:I,isAdmin:!!((Ta=(Ia=Ee.data)==null?void 0:Ia.user)!=null&&Ta.is_admin),onExecutorPauseChange:Uc,onExecutorResize:Hc,processes:it.data,processesLoading:it.isLoading,processesError:it.error,systemd:hn.data,systemdLoading:hn.isLoading,systemdError:hn.error,alerts:(Aa=pn.data)==null?void 0:Aa.alerts,alertsLoading:pn.isLoading,alertsError:pn.error,sloSummary:(La=ke.data)==null?void 0:La.metrics,sloLoading:ke.isLoading,sloError:ke.error,sloWindow:q,now:Qn,onRefreshProcesses:()=>it.refetch(),onRefreshSystemd:()=>hn.refetch(),onRefreshAlerts:()=>pn.refetch(),onSloWindowChange:P,onRefreshSlo:()=>ke.refetch()})]}):s.jsxs(s.Fragment,{children:[ke.error?s.jsx(be,{tone:"error",text:ke.error.message}):null,Ne.error?s.jsx(be,{tone:"error",text:Ne.error.message}):null,s.jsxs("section",{className:"grid grid-cols-2 gap-3 xl:grid-cols-4","aria-label":"Summary metrics",children:[s.jsx(Ae,{title:"Pending",value:Qt.pending??0,icon:s.jsx(Rl,{className:"h-5 w-5"})}),s.jsx(Ae,{title:"Running",value:Qt.running??0,icon:s.jsx(an,{className:"h-5 w-5"})}),s.jsx(Ae,{title:"Blocked",value:Qt.blocked??0,icon:s.jsx(Hr,{className:"h-5 w-5"})}),s.jsx(Ae,{title:"Done",value:Qt.done??0,icon:s.jsx(Dn,{className:"h-5 w-5"})})]}),s.jsxs("section",{className:"grid gap-3",children:[s.jsx(gg,{count:jr.length,limit:r,loading:Qe.isLoading,onRefresh:()=>Qe.refetch()}),s.jsxs(se,{title:"Recent jobs",flushHeader:!0,children:[s.jsx(kg,{filters:t,actorOptions:((Ma=vr.data)==null?void 0:Ma.actors)??[],onChange:Vc}),Qe.error?s.jsx(be,{tone:"error",text:Qe.error.message}):null,s.jsx(Sg,{jobs:jr,loading:Qe.isLoading,loadingMore:Qe.isFetching&&!Qe.isLoading,hasMore:jr.length>=r,onLoadMore:Gc,onViewJob:Ii,now:Qn,user:(Oa=Ee.data)==null?void 0:Oa.user,onRetry:Ci,onDismiss:Pi,onCancel:Ei})]}),s.jsx(se,{title:"Runtime & jobs",action:s.jsx(nt,{onClick:()=>ke.refetch()}),children:s.jsx(Dg,{usage:(Da=ke.data)==null?void 0:Da.metrics.runtime_usage,jobsByCreatedDay:(Fa=ke.data)==null?void 0:Fa.metrics.by_created_day,loading:ke.isLoading,totalJobs:gs(Qt)})}),s.jsx(se,{title:"Runtime by user",children:s.jsx(Bg,{usage:(za=ke.data)==null?void 0:za.metrics.runtime_usage_by_actor,loading:ke.isLoading,totalJobs:gs(Qt),window:U,onWindowChange:te})}),s.jsx(se,{title:"Runtime by repository",children:s.jsx($g,{usage:(qa=ke.data)==null?void 0:qa.metrics.runtime_usage_by_repo,loading:ke.isLoading,totalJobs:gs(Qt),window:U,onWindowChange:te})})]}),s.jsxs("section",{className:"grid gap-4 xl:grid-cols-2",children:[s.jsx(se,{title:"Runtime percentiles",children:s.jsx(Xo,{label:"runtime",values:(Ba=ke.data)==null?void 0:Ba.metrics.runtime_seconds})}),s.jsx(se,{title:"Queue wait percentiles",children:s.jsx(Xo,{label:"queue wait",values:($a=ke.data)==null?void 0:$a.metrics.queue_wait_seconds})})]})]})]})]})}function $x({about:e}){const t=e!=null&&e.version?`v${e.version}`:"version loading";return s.jsxs("p",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-slate-300",children:[s.jsx("span",{children:"Operational dashboard"}),s.jsx("span",{className:"font-mono text-xs text-slate-400",children:t}),e!=null&&e.repository_url?s.jsxs("a",{className:"inline-flex items-center gap-1 text-xs font-semibold text-slate-200 hover:underline",href:rt(e.repository_url),rel:"noreferrer",target:"_blank",children:[s.jsx(on,{className:"h-3.5 w-3.5","aria-hidden":!0}),"GitHub"]}):null]})}function Sc(e){var t,n;return!!((n=(t=e==null?void 0:e.target)==null?void 0:t.tag_name)!=null&&n.trim()&&e.decision!=="noop")}function Ux({state:e,isAdmin:t,runningAction:n=null,actionError:r="",onRefresh:i,onApply:a,onCompletePending:o}){var v,b,N,k,_,O,j,B,F,C,M;if(!e||!Sc(e))return null;const l=(b=(v=e==null?void 0:e.target)==null?void 0:v.tag_name)==null?void 0:b.trim();if(!t||!l)return null;const c=Hx(e.decision),u=((N=e.queue)==null?void 0:N.active_total)??0,d=Kx((k=e.classification)==null?void 0:k.risk),h=Qx((_=e.target)==null?void 0:_.body),m=((j=(O=e.classification)==null?void 0:O.migration_files)==null?void 0:j.length)??0,p=((F=(B=e.classification)==null?void 0:B.risky_files)==null?void 0:F.length)??0,w=!!(e.executor_reload_pending&&e.dashboard_applied_at&&o),y=!!(a&&(m===0||u===0));return s.jsxs("section",{className:"rounded-md border border-amber-300 bg-amber-50 p-3 text-amber-950 shadow-sm","aria-label":"Update available",children:[s.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-start lg:justify-between",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(Hr,{className:"h-4 w-4 text-amber-700","aria-hidden":!0}),s.jsx("h2",{className:"text-sm font-semibold",children:"Update available"}),s.jsx("span",{className:"rounded-sm border border-amber-300 bg-white px-1.5 py-0.5 font-mono text-[11px] text-amber-800",children:l}),(C=e.target)!=null&&C.url?s.jsxs("a",{className:"inline-flex items-center gap-1 text-xs font-semibold text-amber-800 hover:underline",href:rt(e.target.url),rel:"noreferrer",target:"_blank",children:[s.jsx(on,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Release"]}):null]}),s.jsxs("p",{className:"mt-1 text-sm text-amber-900",children:[c,e.installed_tag?s.jsxs("span",{className:"font-mono",children:[" from ",e.installed_tag]}):null]}),s.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[i?s.jsxs("button",{className:"inline-flex h-8 items-center justify-center gap-1.5 rounded-md border border-amber-300 bg-white px-2.5 text-xs font-semibold text-amber-900 hover:bg-amber-100 disabled:cursor-not-allowed disabled:opacity-60",type:"button",disabled:n!==null,onClick:i,children:[s.jsx(zn,{className:Q("h-3.5 w-3.5",n==="refresh"&&"animate-spin"),"aria-hidden":!0}),n==="refresh"?"Checking...":"Check now"]}):null,y?s.jsxs("button",{className:"inline-flex h-8 items-center justify-center gap-1.5 rounded-md bg-amber-800 px-2.5 text-xs font-semibold text-white hover:bg-amber-900 disabled:cursor-not-allowed disabled:opacity-60",type:"button",disabled:n!==null,onClick:()=>{window.confirm(`Apply ${l}? This can restart bridge services according to the recorded safe plan.`)&&(a==null||a())},children:[s.jsx(Dn,{className:"h-3.5 w-3.5","aria-hidden":!0}),n==="apply"?"Applying...":"Apply update"]}):null,w?s.jsxs("button",{className:"inline-flex h-8 items-center justify-center gap-1.5 rounded-md border border-amber-300 bg-white px-2.5 text-xs font-semibold text-amber-900 hover:bg-amber-100 disabled:cursor-not-allowed disabled:opacity-60",type:"button",disabled:n!==null,onClick:o,children:[s.jsx(cr,{className:"h-3.5 w-3.5","aria-hidden":!0}),n==="complete"?"Completing...":"Complete reload"]}):null]})]}),s.jsxs("div",{className:"grid gap-2 text-xs sm:grid-cols-3 lg:min-w-[420px]",children:[s.jsx(ms,{label:"Impact",value:d}),s.jsx(ms,{label:"Active jobs",value:String(u)}),s.jsx(ms,{label:"Admin only",value:"autoupdate"})]})]}),e.blocked_reason||e.executor_reload_pending||m>0||p>0?s.jsxs("div",{className:"mt-3 flex flex-wrap gap-2 text-xs",children:[e.executor_reload_pending?s.jsx("span",{className:"rounded-sm border border-amber-300 bg-white px-2 py-1 font-semibold",children:"executor reload pending"}):null,e.blocked_reason?s.jsx("span",{className:"rounded-sm border border-amber-300 bg-white px-2 py-1 font-mono",children:e.blocked_reason}):null,m>0?s.jsxs("span",{className:"rounded-sm border border-amber-300 bg-white px-2 py-1",children:[m," migration file",m===1?"":"s"]}):null,p>0?s.jsxs("span",{className:"rounded-sm border border-amber-300 bg-white px-2 py-1",children:[p," executor/shared file",p===1?"":"s"]}):null]}):null,h?s.jsxs("div",{className:"mt-3 rounded-md border border-amber-200 bg-white/70 p-2.5",children:[s.jsx("div",{className:"text-[11px] font-semibold uppercase text-amber-800",children:"Changelog preview"}),s.jsx(Wx,{markdown:h})]}):null,(M=e.warnings)!=null&&M.length?s.jsx("div",{className:"mt-2 font-mono text-xs text-amber-800",children:e.warnings[0]}):null,r?s.jsxs("div",{className:"mt-2 rounded-sm border border-amber-300 bg-white px-2 py-1 font-mono text-xs text-amber-900",children:["Action failed: ",r]}):null]})}function ms({label:e,value:t}){return s.jsxs("div",{className:"min-w-0 rounded-md border border-amber-200 bg-white/80 px-2 py-1.5",children:[s.jsx("div",{className:"text-[11px] font-semibold uppercase text-amber-700",children:e}),s.jsx("div",{className:"mt-0.5 truncate font-mono text-xs text-amber-950",children:t})]})}function Hx(e){return{stage_dashboard_reload:"Dashboard reload can be staged now",stage_defer_executor_reload:"Dashboard reload can be staged; executor reload waits for the queue",stage_full_reload:"Full reload can be staged now",defer_migration:"Migration release is waiting for a quiet queue"}[e??""]??"Update plan recorded"}function Kx(e){return{dashboard_only:"dashboard only",executor_or_queue:"executor or queue",executor_or_shared:"executor or shared",migration_required:"migration",none:"none"}[e??""]??"unknown"}function Qx(e){return(e??"").trim()}function Wx({markdown:e}){return s.jsx("div",{className:"mt-1 text-sm leading-relaxed text-amber-950",children:s.jsx(Cf,{allowedElements:["a","blockquote","code","em","h1","h2","h3","h4","li","ol","p","strong","ul"],components:{a:({href:t,children:n})=>s.jsx("a",{className:"font-semibold text-amber-800 underline underline-offset-2",href:rt(t??""),rel:"noreferrer",target:"_blank",children:n}),blockquote:({children:t})=>s.jsx("blockquote",{className:"mt-2 border-l-2 border-amber-300 pl-2 text-amber-900",children:t}),code:({children:t})=>s.jsx("code",{className:"rounded-sm bg-amber-100 px-1 py-0.5 font-mono text-[0.85em] text-amber-950",children:t}),h1:({children:t})=>s.jsx("h3",{className:"mt-2 text-sm font-semibold text-amber-950 first:mt-0",children:t}),h2:({children:t})=>s.jsx("h3",{className:"mt-2 text-sm font-semibold text-amber-950 first:mt-0",children:t}),h3:({children:t})=>s.jsx("h3",{className:"mt-2 text-sm font-semibold text-amber-950 first:mt-0",children:t}),h4:({children:t})=>s.jsx("h4",{className:"mt-2 text-xs font-semibold uppercase text-amber-800 first:mt-0",children:t}),li:({children:t})=>s.jsx("li",{className:"break-words pl-0.5 [overflow-wrap:anywhere]",children:t}),ol:({children:t})=>s.jsx("ol",{className:"mt-1 list-decimal space-y-1 pl-5 first:mt-0",children:t}),p:({children:t})=>s.jsx("p",{className:"mt-1 break-words [overflow-wrap:anywhere] first:mt-0",children:t}),strong:({children:t})=>s.jsx("strong",{className:"font-semibold",children:t}),em:({children:t})=>s.jsx("em",{className:"italic",children:t}),ul:({children:t})=>s.jsx("ul",{className:"mt-1 list-disc space-y-1 pl-5 first:mt-0",children:t})},children:e})})}function Vx({isDashboardRoute:e,isSystemRoute:t=!1,isKnowledgeRoute:n,isMcpRoute:r=!1,isWebhooksRoute:i=!1,showWebhooks:a=!1,knowledgeBadgeCount:o=0,systemUpdateAvailable:l=!1,onNavigate:c}){return s.jsxs("nav",{className:"flex min-w-0 rounded-lg border border-border bg-panel p-1 shadow-sm","aria-label":"Dashboard sections",children:[s.jsxs(er,{href:"/",active:e,onNavigate:c,children:[s.jsx(Al,{className:"h-4 w-4","aria-hidden":!0}),s.jsx("span",{children:"Jobs"})]}),s.jsxs(er,{href:"/system",active:t,onNavigate:c,children:[s.jsx(id,{className:"h-4 w-4","aria-hidden":!0}),s.jsx("span",{children:"System"}),l?s.jsx("span",{className:Q("inline-flex h-5 min-w-5 items-center justify-center rounded-full border px-1 font-mono text-[11px] leading-none",t?"border-white/40 bg-white/15 text-white":"border-amber-200 bg-amber-100 text-amber-800"),"aria-label":"System update available",children:"!"}):null]}),a?s.jsxs(er,{href:"/webhooks",active:i,onNavigate:c,children:[s.jsx(an,{className:"h-4 w-4","aria-hidden":!0}),s.jsx("span",{children:"Webhooks"})]}):null,s.jsxs(er,{href:"/knowledge",active:n,onNavigate:c,children:[s.jsx(oi,{className:"h-4 w-4","aria-hidden":!0}),s.jsx("span",{children:"Knowledge"}),o>0?s.jsx("span",{className:Q("inline-flex h-5 min-w-5 items-center justify-center rounded-full border px-1 font-mono text-[11px] leading-none",n?"border-white/40 bg-white/15 text-white":"border-amber-200 bg-amber-100 text-amber-800"),"aria-label":`${o} proposed knowledge ${o===1?"item":"items"}`,children:o}):null]}),s.jsxs(er,{href:"/mcp",active:r,onNavigate:c,children:[s.jsx(Or,{className:"h-4 w-4","aria-hidden":!0}),s.jsx("span",{children:"MCP"})]})]})}function gn({text:e}){return s.jsxs("div",{className:"flex items-center justify-center gap-2 py-10 text-sm text-muted",children:[s.jsx(zn,{className:"h-4 w-4 animate-spin","aria-hidden":!0}),e]})}function Gx({summary:e,timeseries:t,exceptions:n,hooks:r,deliveries:i,section:a,summaryLoading:o,sectionLoading:l,loadingMore:c,hasMore:u,deliveryFilters:d,error:h,onSectionChange:m,onLoadMore:p,onDeliveryFiltersChange:w,onViewHook:y,onViewDelivery:v=()=>{},onRefresh:b}){var B,F,C,M,D,I,X,q,P,U,te,me,ye,f;const N=Object.values((e==null?void 0:e.receipts)??{}).reduce((A,fe)=>A+fe,0),k=((B=e==null?void 0:e.coverage)==null?void 0:B.promotion_state)??((F=e==null?void 0:e.coverage)!=null&&F.promotion_ready?"ready":"blocked"),_=k==="insufficient_data"?"insufficient data":k,O=(e==null?void 0:e.mode)==="primary"?"Primary eligibility scope":(e==null?void 0:e.mode)==="canary"?"Canary rollout cohort":"Shadow rollout cohort",j=[{id:"overview",label:"Overview"},{id:"hooks",label:"Hooks",count:(C=e==null?void 0:e.totals)==null?void 0:C.hooks},{id:"deliveries",label:"Deliveries",count:(M=e==null?void 0:e.totals)==null?void 0:M.deliveries}];return s.jsxs("section",{className:"grid gap-4",children:[s.jsx(Cc,{icon:s.jsx(an,{className:"h-5 w-5 text-muted","aria-hidden":!0}),title:"GitHub webhooks",subtitle:(e==null?void 0:e.mode)==="primary"?"Primary webhook ingestion. IMAP remains active as an idempotent safety net.":(e==null?void 0:e.mode)==="canary"?"Canary ingestion health. Only the webhook canary allowlist may create jobs.":"Shadow ingestion health. Deliveries are observed but do not create jobs.",action:s.jsx(nt,{onClick:b})}),h?s.jsx(be,{tone:"error",text:h.message}):null,s.jsx("div",{className:"flex max-w-full flex-wrap rounded-md border border-border bg-white p-1",role:"tablist","aria-label":"Webhook dashboard section",children:j.map(A=>s.jsxs("button",{type:"button",role:"tab","aria-label":A.count===void 0?A.label:`${A.label} (${A.count} total)`,"aria-selected":a===A.id,className:Q("inline-flex h-8 items-center gap-2 rounded px-3 text-sm font-semibold",a===A.id?"bg-primary text-white":"text-muted hover:bg-slate-50 hover:text-foreground"),onClick:()=>m(A.id),children:[A.label,A.count!==void 0?s.jsx("span",{className:"rounded border border-current/30 px-1 font-mono text-[10px]",children:A.count}):null]},A.id))}),s.jsxs("div",{className:"grid grid-cols-2 gap-3 xl:grid-cols-4","aria-label":"Webhook status",children:[s.jsx(Ae,{title:"Receipts",value:N,icon:s.jsx(an,{className:"h-5 w-5"})}),s.jsx(Ae,{title:"Duplicates",value:(e==null?void 0:e.duplicate_deliveries)??0,icon:s.jsx(zn,{className:"h-5 w-5"})}),s.jsx(Ae,{title:"Cross-source matches",value:(e==null?void 0:e.cross_source_matches)??0,icon:s.jsx(Fn,{className:"h-5 w-5"})}),s.jsx(Ae,{title:"Mode",value:o?"โ€ฆ":(e==null?void 0:e.mode)??"unknown",icon:s.jsx(Il,{className:"h-5 w-5"})})]}),a==="overview"?s.jsxs(s.Fragment,{children:[s.jsx(se,{title:"Delivery activity",children:l?s.jsx(gn,{text:"Loading delivery activityโ€ฆ"}):t!=null&&t.length?s.jsx("div",{className:"h-72","aria-label":"Webhook deliveries over time",children:s.jsx(ln,{width:"100%",height:"100%",children:s.jsxs(ei,{data:t,children:[s.jsx(Ln,{strokeDasharray:"3 3"}),s.jsx(Mn,{dataKey:"bucket"}),s.jsx(sn,{allowDecimals:!1}),s.jsx(cn,{}),s.jsx(Ur,{}),s.jsx(Bt,{dataKey:"observed",stackId:"deliveries",fill:"#2563eb"}),s.jsx(Bt,{dataKey:"duplicate",stackId:"deliveries",fill:"#f59e0b"}),s.jsx(Bt,{dataKey:"unsupported",stackId:"deliveries",fill:"#94a3b8"})]})})}):s.jsx(J,{text:"No webhook activity in the selected 30-day window."})}),s.jsx(se,{title:"Receipt states",children:o?s.jsx(gn,{text:"Loading webhook summaryโ€ฆ"}):Object.keys((e==null?void 0:e.receipts)??{}).length?s.jsx("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:Object.entries((e==null?void 0:e.receipts)??{}).sort(([A],[fe])=>A.localeCompare(fe)).map(([A,fe])=>s.jsx($,{label:A,value:fe},A))}):s.jsx(J,{text:"No webhook deliveries observed yet."})}),s.jsxs(se,{title:"Cross-source coverage",children:[s.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-4",children:[s.jsx($,{label:"Both sources",value:((D=e==null?void 0:e.coverage)==null?void 0:D.both)??0}),s.jsx($,{label:"IMAP only",value:((I=e==null?void 0:e.coverage)==null?void 0:I.imap_only)??0}),s.jsx($,{label:"Webhook only",value:((X=e==null?void 0:e.coverage)==null?void 0:X.webhook_only)??0}),s.jsx($,{label:"Coverage",value:((q=e==null?void 0:e.coverage)==null?void 0:q.ratio)==null?"not measurable":`${Math.round(e.coverage.ratio*100)}%`}),s.jsx($,{label:"Decision mismatches",value:((P=e==null?void 0:e.coverage)==null?void 0:P.decision_mismatches)??0}),s.jsx($,{label:"Incomplete decision traces",value:((U=e==null?void 0:e.coverage)==null?void 0:U.incomplete_decision_traces)??0}),s.jsx($,{label:"Split identities",value:((te=e==null?void 0:e.coverage)==null?void 0:te.split_identities)??0}),s.jsx($,{label:"Promotion gate",value:_}),s.jsx($,{label:"Outside scope IMAP",value:((me=e==null?void 0:e.coverage)==null?void 0:me.outside_scope_imap_eligible)??0}),s.jsx($,{label:"Outside scope webhook",value:((ye=e==null?void 0:e.coverage)==null?void 0:ye.outside_scope_webhook_eligible)??0})]}),(f=e==null?void 0:e.coverage)!=null&&f.window_start&&e.coverage.window_end?s.jsxs("p",{className:"mt-3 font-mono text-xs text-muted",children:["Actionable IMAP events and comparable webhook events from ",s.jsx(ue,{value:e.coverage.window_start})," to ",s.jsx(ue,{value:e.coverage.window_end}),"; ",e.coverage.observation_days??7," observation days required and newest ",e.coverage.grace_seconds??0,"s excluded. ",O,": ",e.coverage.scope_repositories==null?"all repositories":`${e.coverage.scope_repositories.length} configured repositories`,e.coverage.observation_started_at?s.jsxs(s.Fragment,{children:["; observation epoch ",s.jsx(ue,{value:e.coverage.observation_started_at})]}):null,"."]}):null]}),Object.keys((e==null?void 0:e.enqueue)??{}).length?s.jsx(se,{title:"Canary ingestion decisions",children:s.jsx("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-4",children:Object.entries((e==null?void 0:e.enqueue)??{}).sort(([A],[fe])=>A.localeCompare(fe)).map(([A,fe])=>s.jsx($,{label:A,value:fe},A))})}):null,s.jsx(se,{title:"Exceptions requiring review",children:n!=null&&n.length?s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full min-w-[840px] text-left text-sm",children:[s.jsx("thead",{className:"border-b border-border text-xs text-muted",children:s.jsxs("tr",{children:[s.jsx("th",{className:"px-3 py-2",children:"Type"}),s.jsx("th",{className:"px-3 py-2",children:"Repository"}),s.jsx("th",{className:"px-3 py-2",children:"Event"}),s.jsx("th",{className:"px-3 py-2",children:"References"}),s.jsx("th",{className:"px-3 py-2",children:"Observed"})]})}),s.jsx("tbody",{children:n.map(A=>s.jsxs("tr",{className:"border-b border-border/70 last:border-0",children:[s.jsx("td",{className:"px-3 py-2 font-semibold",children:A.kind}),s.jsx("td",{className:"px-3 py-2 font-mono text-xs",children:A.repository??"unknown"}),s.jsx("td",{className:"px-3 py-2 font-mono text-xs",children:A.event_type?`${A.event_type}${A.event_action?`:${A.event_action}`:""}`:"unknown"}),s.jsxs("td",{className:"px-3 py-2 font-mono text-xs",children:[s.jsx("div",{children:A.reference}),A.related_reference?s.jsx("div",{children:A.related_reference}):null,A.event_key?s.jsxs("div",{className:"text-muted",children:[A.event_key,A.related_event_key?` โ†” ${A.related_event_key}`:""]}):null]}),s.jsx("td",{className:"px-3 py-2 font-mono text-xs text-muted",children:s.jsx(ue,{value:A.created_at,compact:!0})})]},`${A.kind}:${A.reference}:${A.related_reference??""}`))})]})}):s.jsx(J,{text:"No cross-source exceptions in retained data."})})]}):null,a==="hooks"?s.jsx(se,{title:"Hook inventory",children:l?s.jsx(gn,{text:"Loading hook inventoryโ€ฆ"}):r!=null&&r.length?s.jsx(Xs,{noun:"hooks",hasMore:u,loading:c,onLoadMore:p,children:s.jsxs("table",{className:"w-full min-w-[920px] text-left text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"sticky top-0 z-10 border-b border-border bg-panel text-left text-xs text-muted",children:[s.jsx("th",{className:"px-3 py-2",children:"Target"}),s.jsx("th",{className:"px-3 py-2",children:"State"}),s.jsx("th",{className:"px-3 py-2",children:"Configuration"}),s.jsx("th",{className:"px-3 py-2",children:"Last delivery"}),s.jsx("th",{className:"px-3 py-2",children:"Last ping"})]})}),s.jsx("tbody",{children:r.map(A=>s.jsxs("tr",{className:"cursor-pointer border-b border-border/70 last:border-0 hover:bg-slate-50",onClick:()=>y(A.id),children:[s.jsxs("td",{className:"px-3 py-3",children:[s.jsx("button",{type:"button",className:"text-left font-semibold text-primary hover:underline",onClick:fe=>{fe.stopPropagation(),y(A.id)},children:A.target}),s.jsxs("div",{className:"font-mono text-xs text-muted",children:[A.target_type," ยท #",A.id]})]}),s.jsx("td",{className:"px-3 py-3",children:s.jsx("span",{className:Q("rounded border px-2 py-1 text-xs font-semibold",A.status==="receiving"?"border-emerald-200 bg-emerald-50 text-emerald-700":A.status==="inactive"?"border-red-200 bg-red-50 text-red-700":"border-slate-200 bg-slate-50 text-slate-600"),children:A.status})}),s.jsxs("td",{className:"max-w-sm px-3 py-3 text-xs",children:[s.jsx("div",{children:A.events.join(", ")||"No event snapshot"}),s.jsxs("div",{className:"mt-1 font-mono text-muted",children:[A.content_type??"content type unknown"," ยท SSL ",A.ssl_verify===null||A.ssl_verify===void 0?"unknown":A.ssl_verify?"verified":"disabled"]})]}),s.jsxs("td",{className:"px-3 py-3 text-xs",children:[s.jsxs("div",{className:"font-semibold",children:[A.last_event_name??"Never",A.last_action?` ยท ${A.last_action}`:""]}),s.jsxs("div",{className:"mt-1 font-mono text-muted",children:[A.last_repository??"No repository",A.last_event_at?s.jsxs(s.Fragment,{children:[" ยท ",s.jsx(ue,{value:A.last_event_at,compact:!0})]}):null]})]}),s.jsx("td",{className:"px-3 py-3 font-mono text-xs text-muted",children:A.last_ping_at?s.jsx(ue,{value:A.last_ping_at,compact:!0}):"Never"})]},A.id))})]})}):s.jsx(J,{text:"No hook inventory is available. Redeliver a signed ping from GitHub to create the sanitized configuration snapshot."})}):null,a==="deliveries"?s.jsxs(se,{title:"Recent deliveries",children:[s.jsx(Jx,{filters:d,onChange:w}),l?s.jsx(gn,{text:"Loading deliveriesโ€ฆ"}):i!=null&&i.length?s.jsx(Xs,{noun:"deliveries",hasMore:u,loading:c,onLoadMore:p,children:s.jsx(_c,{deliveries:i,onViewHook:y,onViewDelivery:v})}):s.jsx(J,{text:"No deliveries match the current filters."})]}):null]})}function Jx({filters:e,onChange:t}){const n=[{key:"hook_id",label:"Hook ID",placeholder:"690954530"},{key:"event_name",label:"Event",placeholder:"issue_comment"},{key:"repository",label:"Repository",placeholder:"gisce/repository"},{key:"result",label:"Result",placeholder:"observed"},{key:"enqueue_status",label:"Ingestion",placeholder:"enqueued"}];return s.jsx("div",{className:"grid gap-2 border-b border-border p-3 sm:grid-cols-2 xl:grid-cols-5",children:n.map(r=>s.jsxs("label",{className:"grid gap-1 text-xs font-semibold text-muted",children:[r.label,s.jsx("input",{className:"h-9 rounded-md border border-border bg-white px-2 font-mono text-xs text-foreground",value:e[r.key],placeholder:r.placeholder,onChange:i=>t({...e,[r.key]:i.target.value})})]},r.key))})}function _c({deliveries:e,onViewHook:t,onViewDelivery:n=()=>{}}){return s.jsxs("table",{className:"w-full min-w-[1120px] text-left text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"sticky top-0 z-10 border-b border-border bg-panel text-left text-xs text-muted",children:[s.jsx("th",{className:"px-3 py-2",children:"Received"}),s.jsx("th",{className:"px-3 py-2",children:"Hook"}),s.jsx("th",{className:"px-3 py-2",children:"Event"}),s.jsx("th",{className:"px-3 py-2",children:"Repository"}),s.jsx("th",{className:"px-3 py-2",children:"Result"}),s.jsx("th",{className:"px-3 py-2",children:"Ingestion"}),s.jsx("th",{className:"px-3 py-2",children:"Delivery"})]})}),s.jsx("tbody",{children:e.map(r=>{var i;return s.jsxs("tr",{className:"border-b border-border/70 last:border-0 hover:bg-slate-50",children:[s.jsx("td",{className:"px-3 py-3 font-mono text-xs text-muted",children:s.jsx(ue,{value:r.created_at,compact:!0})}),s.jsx("td",{className:"px-3 py-3",children:r.hook_id?s.jsxs("button",{type:"button",className:"text-left text-primary hover:underline",onClick:()=>t(r.hook_id),children:[s.jsx("span",{className:"block font-semibold",children:((i=r.hook)==null?void 0:i.target)??`Hook #${r.hook_id}`}),s.jsxs("span",{className:"font-mono text-xs",children:["#",r.hook_id]})]}):s.jsx("span",{className:"text-xs text-muted",children:"Unknown (legacy)"})}),s.jsxs("td",{className:"px-3 py-3 font-semibold",children:[r.event_name,r.action?` ยท ${r.action}`:""]}),s.jsx("td",{className:"px-3 py-3",children:r.repository??"โ€”"}),s.jsxs("td",{className:"px-3 py-3",children:[s.jsx("span",{className:"rounded border border-border bg-slate-50 px-2 py-1 text-xs font-semibold",children:r.status}),r.duplicate_count?s.jsxs("span",{className:"ml-2 font-mono text-xs text-muted",children:[r.duplicate_count," retries"]}):null]}),s.jsx("td",{className:"px-3 py-3",children:r.enqueue_status?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"rounded border border-border bg-slate-50 px-2 py-1 text-xs font-semibold",children:r.enqueue_status}),r.job_id?s.jsxs("a",{className:"ml-2 font-mono text-xs font-semibold text-primary hover:underline",href:`/jobs/${r.job_id}`,children:["Job #",r.job_id]}):null]}):s.jsx("span",{className:"text-xs text-muted",children:"shadow"})}),s.jsx("td",{className:"max-w-[14rem] px-3 py-3",children:s.jsx("button",{type:"button",className:"block max-w-full truncate font-mono text-xs font-semibold text-primary hover:underline",title:r.delivery_id,onClick:()=>n(r.delivery_id),children:r.delivery_id})})]},r.delivery_id)})})]})}function Xs({noun:e,hasMore:t,loading:n,onLoadMore:r,children:i,className:a}){return s.jsxs("div",{"data-testid":`lazy-scroll-${e}`,className:Q("max-h-[640px] overflow-auto rounded-md border border-border",a),children:[i,s.jsx(Xx,{noun:e,hasMore:t,loading:n,onLoadMore:r})]})}function Xx({noun:e,hasMore:t,loading:n,onLoadMore:r}){const i=R.useRef(null),a=R.useRef(!1);return R.useEffect(()=>{n||(a.current=!1)},[n]),R.useEffect(()=>{const o=i.current;if(!o||!t||n||!r)return;const l=()=>{a.current||(a.current=!0,r())};if(!("IntersectionObserver"in window)){l();return}const c=new IntersectionObserver(u=>{u.some(d=>d.isIntersecting)&&l()},{rootMargin:"240px 0px"});return c.observe(o),()=>c.disconnect()},[t,n,e,r]),!t&&!n?null:s.jsx("div",{ref:i,className:"flex min-h-10 items-center justify-center border-t border-border px-3 py-2 text-xs font-medium text-muted","aria-live":"polite",children:n?`Loading more ${e}...`:`Scroll for more ${e}`})}function Yx({data:e,loading:t,error:n,onBack:r,onRefresh:i,onViewHook:a,onViewDelivery:o=()=>{},onPing:l}){const[c,u]=R.useState(!1),[d,h]=R.useState(""),[m,p]=R.useState("");if(t)return s.jsx(gn,{text:"Loading hook detailโ€ฆ"});if(n)return s.jsxs("div",{className:"grid gap-3",children:[s.jsx(be,{tone:"error",text:n.message}),s.jsx("button",{type:"button",className:"w-fit rounded border border-border px-3 py-2 text-sm font-semibold",onClick:r,children:"Back to hooks"})]});if(!e)return s.jsx(J,{text:"Hook detail is not available."});const w=e.hook,y={...w,github_created_at:w.github_created_at?s.jsx(ue,{value:w.github_created_at}):"unknown",github_updated_at:w.github_updated_at?s.jsx(ue,{value:w.github_updated_at}):"unknown",last_ping_at:w.last_ping_at?s.jsx(ue,{value:w.last_ping_at}):"never",last_event_at:w.last_event_at?s.jsx(ue,{value:w.last_event_at}):"never"},v=async()=>{if(!(!l||c)){u(!0),h(""),p("");try{h(await l(y.id))}catch(N){p(N instanceof Error?N.message:String(N))}finally{u(!1)}}},b=(e.recent_actions??[]).map(N=>({...N,created_at:s.jsx(ue,{value:N.created_at,compact:!0})}));return s.jsxs("section",{className:"grid gap-4",children:[s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[s.jsxs("div",{children:[s.jsxs("button",{type:"button",className:"mb-2 inline-flex items-center gap-2 text-sm font-semibold text-primary hover:underline",onClick:r,children:[s.jsx(ai,{className:"h-4 w-4","aria-hidden":!0}),"Back to hooks"]}),s.jsx("h2",{className:"text-xl font-semibold",children:y.target}),s.jsxs("p",{className:"font-mono text-xs text-muted",children:[y.target_type," webhook #",y.id]})]}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[y.ping_url&&l?s.jsxs("button",{type:"button",className:"inline-flex h-8 items-center gap-2 rounded-md border border-border px-3 text-sm font-semibold hover:bg-slate-50 disabled:cursor-wait disabled:opacity-60",disabled:c,onClick:()=>void v(),children:[s.jsx(an,{className:Q("h-4 w-4",c&&"animate-pulse"),"aria-hidden":!0}),c?"Sending pingโ€ฆ":"Send ping"]}):null,s.jsx(nt,{onClick:i}),y.admin_url?s.jsxs("a",{className:"inline-flex h-8 items-center gap-2 rounded-md border border-border px-3 text-sm font-semibold hover:bg-slate-50",href:rt(y.admin_url),target:"_blank",rel:"noreferrer",children:[s.jsx(on,{className:"h-4 w-4","aria-hidden":!0}),"Open in GitHub"]}):null]})]}),m?s.jsx(be,{tone:"error",text:m}):null,d?s.jsx("div",{className:"rounded-md border border-emerald-200 bg-emerald-50 p-3 text-sm text-emerald-700",children:d}):null,s.jsxs("div",{className:"grid grid-cols-2 gap-3 lg:grid-cols-4",children:[s.jsx(Ae,{title:"State",value:y.status,icon:s.jsx(an,{className:"h-5 w-5"})}),s.jsx(Ae,{title:"Deliveries",value:e.stats.deliveries,icon:s.jsx(Fn,{className:"h-5 w-5"})}),s.jsx(Ae,{title:"Retries",value:e.stats.duplicates,icon:s.jsx(zn,{className:"h-5 w-5"})}),s.jsx(Ae,{title:"Unsupported",value:e.stats.unsupported,icon:s.jsx(Hr,{className:"h-5 w-5"})})]}),s.jsxs(se,{title:"Sanitized configuration",children:[s.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:[s.jsx($,{label:"Active",value:y.active?"yes":"no"}),s.jsx($,{label:"Content type",value:y.content_type??"unknown"}),s.jsx($,{label:"SSL verification",value:y.ssl_verify===null||y.ssl_verify===void 0?"unknown":y.ssl_verify?"enabled":"disabled"}),s.jsx($,{label:"Destination URL",value:y.delivery_url??"unknown"}),s.jsx($,{label:"GitHub created",value:y.github_created_at??"unknown"}),s.jsx($,{label:"GitHub updated",value:y.github_updated_at??"unknown"}),s.jsx($,{label:"Last ping",value:y.last_ping_at??"never"}),s.jsx($,{label:"Last delivery",value:y.last_event_at??"never"}),s.jsx($,{label:"Last result",value:y.last_result??"unknown"})]}),s.jsxs("div",{className:"mt-3 rounded-md border border-border p-3",children:[s.jsx("div",{className:"text-xs font-semibold text-muted",children:"Subscribed events"}),s.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:y.events.length?y.events.map(N=>s.jsx("span",{className:"rounded border border-border bg-slate-50 px-2 py-1 font-mono text-xs",children:N},N)):s.jsx("span",{className:"text-sm text-muted",children:"No event snapshot; send a ping to refresh it."})})]})]}),s.jsx(se,{title:"Latest observed delivery",children:s.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:[s.jsx($,{label:"Event",value:y.last_event_name?`${y.last_event_name}${y.last_action?` ยท ${y.last_action}`:""}`:"none"}),s.jsx($,{label:"Repository",value:y.last_repository??"none"}),s.jsx($,{label:"Delivery ID",value:y.last_delivery_id??"none"})]})}),s.jsx(se,{title:"Recent administrative actions",children:b.length?s.jsx("div",{className:"divide-y divide-border rounded-md border border-border",children:b.map(N=>s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2 text-sm",children:[s.jsxs("div",{children:[s.jsx("span",{className:"font-semibold",children:N.action}),s.jsxs("span",{className:"ml-2 text-muted",children:["by @",N.actor]})]}),s.jsxs("span",{className:"font-mono text-xs text-muted",children:[N.status," ยท ",N.created_at]})]},N.id))}):s.jsx(J,{text:"No administrative actions recorded for this hook."})}),s.jsx(se,{title:"Recent deliveries",children:e.recent_deliveries.length?s.jsx(_c,{deliveries:e.recent_deliveries,onViewHook:a,onViewDelivery:o}):s.jsx(J,{text:"This hook has no retained deliveries."})})]})}function Zx({data:e,loading:t,error:n,onBack:r,onRefresh:i,onViewHook:a,onViewJob:o}){if(t)return s.jsx(gn,{text:"Loading delivery detailโ€ฆ"});if(n)return s.jsxs("div",{className:"grid gap-3",children:[s.jsx(be,{tone:"error",text:n.message}),s.jsx("button",{type:"button",className:"w-fit rounded border border-border px-3 py-2 text-sm font-semibold",onClick:r,children:"Back to deliveries"})]});if(!e)return s.jsx(J,{text:"Delivery detail is not available."});const l={...e.delivery,created_at:s.jsx(ue,{value:e.delivery.created_at})};return s.jsxs("section",{className:"grid gap-4",children:[s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[s.jsxs("div",{children:[s.jsxs("button",{type:"button",className:"mb-2 inline-flex items-center gap-2 text-sm font-semibold text-primary hover:underline",onClick:r,children:[s.jsx(ai,{className:"h-4 w-4","aria-hidden":!0}),"Back to deliveries"]}),s.jsxs("h2",{className:"text-xl font-semibold",children:[l.event_name,l.action?` ยท ${l.action}`:""]}),s.jsxs("p",{className:"font-mono text-xs text-muted",children:["Delivery ",l.delivery_id]})]}),s.jsx(nt,{onClick:i})]}),s.jsxs(se,{title:"Delivery",children:[s.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:[s.jsx($,{label:"Received",value:l.created_at}),s.jsx($,{label:"Repository",value:l.repository??"unknown"}),s.jsx($,{label:"Result",value:l.status}),s.jsx($,{label:"Event key",value:l.event_key??"unmatchable"}),s.jsx($,{label:"Payload SHA-256",value:e.payload_hash}),s.jsx($,{label:"Retries",value:l.duplicate_count??0})]}),l.hook_id?s.jsxs("button",{type:"button",className:"mt-3 text-sm font-semibold text-primary hover:underline",onClick:()=>a(l.hook_id),children:["View hook #",l.hook_id]}):null]}),s.jsx(se,{title:"Generated job",children:e.job?s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("div",{className:"font-semibold",children:e.job.work_key}),s.jsxs("div",{className:"mt-1 font-mono text-xs text-muted",children:["Job #",e.job.id," ยท ",e.job.status," ยท ",e.job.action," ยท ",e.job.work_intent]})]}),s.jsx("button",{type:"button",className:"rounded-md border border-border px-3 py-2 text-sm font-semibold hover:bg-slate-50",onClick:()=>o(e.job.id),children:"Open job"})]}):s.jsx(J,{text:"This delivery did not generate or coalesce into a job."})}),s.jsx(se,{title:"Full payload",children:e.payload===null?s.jsx(J,{text:"Payload was not retained for this legacy delivery."}):s.jsx("pre",{className:"max-h-[640px] overflow-auto rounded-md border border-border bg-slate-950 p-4 font-mono text-xs leading-relaxed text-slate-100",children:JSON.stringify(e.payload,null,2)})})]})}function eg({executorPause:e,executorPauseLoading:t,executorPauseStatusError:n,executorPausePending:r,executorPauseError:i,executorCapacity:a,executorResizePending:o,executorResizeError:l,isAdmin:c,onExecutorPauseChange:u,onExecutorResize:d,processes:h,processesLoading:m,processesError:p,systemd:w,systemdLoading:y,systemdError:v,alerts:b,alertsLoading:N,alertsError:k,sloSummary:_,sloLoading:O,sloError:j,sloWindow:B,now:F,onRefreshProcesses:C,onRefreshSystemd:M,onRefreshAlerts:D,onSloWindowChange:I,onRefreshSlo:X}){return s.jsxs("section",{className:"grid gap-4","aria-label":"Bridge system",children:[s.jsx(tg,{state:e,loading:t,statusError:n,pending:r,actionError:i,capacity:a,resizePending:o,resizeError:l,isAdmin:c,onChange:u,onResize:d}),j?s.jsx(be,{tone:"error",text:j.message}):null,s.jsx(wg,{summary:_,loading:O,window:B,onWindowChange:I,onRefresh:X}),s.jsxs(se,{title:"Systemd",action:s.jsx(nt,{onClick:M}),children:[v?s.jsx(be,{tone:"error",text:v.message}):null,s.jsx(Vg,{data:w,loading:y})]}),s.jsxs(se,{title:"Process activity",action:s.jsx(nt,{onClick:C}),children:[p?s.jsx(be,{tone:"error",text:p.message}):null,s.jsx(Xg,{data:h,loading:m})]}),s.jsxs(se,{title:"Monitor alerts",action:s.jsx(nt,{onClick:D}),children:[k?s.jsx(be,{tone:"error",text:k.message}):null,s.jsx(Yg,{alerts:b,loading:N,now:F})]})]})}function tg({state:e,loading:t,statusError:n,pending:r,actionError:i,capacity:a,resizePending:o=!1,resizeError:l="",isAdmin:c,onChange:u,onResize:d}){const h=!!(e!=null&&e.paused),[m,p]=R.useState(()=>String((a==null?void 0:a.desired)||1));R.useEffect(()=>{a!=null&&a.desired&&p(String(a.desired))},[a==null?void 0:a.desired]);const w=Number(m),y=Number.isInteger(w)&&w>=1;return s.jsxs(se,{title:"Executor",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-semibold",children:e?h?"Paused":"Accepting jobs":t?"Loading state...":"State unavailable"}),h?s.jsx("p",{className:"text-xs text-muted",children:"New jobs remain pending; running jobs continue."}):null,e!=null&&e.reason?s.jsxs("p",{className:"mt-1 text-xs text-muted",children:["Reason: ",e.reason]}):null,c?null:s.jsx("p",{className:"mt-1 text-xs text-muted",children:"Admin only"})]}),s.jsxs("label",{className:"inline-flex items-center gap-2 text-sm font-medium",children:[s.jsx("span",{children:"Pause"}),s.jsx("input",{"aria-label":"Pause executor",role:"switch",type:"checkbox",checked:h,disabled:!c||!e||!!e.error||!!n||r,onChange:()=>{const v=!h,b=v?"Pause executor? New jobs will remain pending; running jobs will continue.":"Resume executor? Pending jobs may start running.";window.confirm(b)&&u(v)},className:"peer sr-only"}),s.jsx("span",{"aria-hidden":!0,className:"relative h-6 w-11 rounded-full bg-slate-300 transition-colors peer-checked:bg-primary peer-focus-visible:outline peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2 peer-focus-visible:outline-primary peer-disabled:opacity-50 after:absolute after:left-0.5 after:top-0.5 after:h-5 after:w-5 after:rounded-full after:bg-white after:shadow-sm after:transition-transform peer-checked:after:translate-x-5"})]})]}),a?s.jsxs("div",{className:"mt-3 grid gap-3 border-t border-border pt-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4","aria-label":"Executor capacity",children:[s.jsx($,{label:"Desired",value:a.desired}),s.jsx($,{label:"Live",value:a.live}),s.jsx($,{label:"Busy",value:a.busy}),s.jsx($,{label:"Draining",value:a.draining})]}),s.jsxs("form",{className:"flex flex-wrap items-end gap-2",onSubmit:v=>{v.preventDefault(),y&&d&&d(w)},children:[s.jsxs("label",{className:"grid gap-1 text-xs font-semibold text-muted",children:["Desired workers",s.jsx("input",{"aria-label":"Desired workers",className:"control w-28",type:"number",min:"1",step:"1",value:m,disabled:!c||o,onChange:v=>p(v.target.value)})]}),s.jsx("button",{type:"submit",className:"h-9 rounded-md bg-primary px-3 text-sm font-semibold text-white disabled:cursor-not-allowed disabled:opacity-60",disabled:!c||o||!y||w===a.desired,children:o?"Resizingโ€ฆ":"Resize"})]})]}):null,n?s.jsx(be,{tone:"error",text:n.message}):null,e!=null&&e.error?s.jsx(be,{tone:"error",text:e.error}):null,i?s.jsx(be,{tone:"error",text:`Action failed: ${i}`}):null,l?s.jsx(be,{tone:"error",text:`Resize failed: ${l}`}):null]})}function er({href:e,active:t,children:n,onNavigate:r}){return s.jsx("a",{className:Q("inline-flex h-8 min-w-0 flex-1 items-center justify-center gap-1 rounded-md px-1.5 text-xs font-semibold sm:flex-none sm:gap-1.5 sm:px-3 sm:text-sm [&>span]:truncate [&>svg]:shrink-0",t?"bg-primary text-white shadow-sm":"text-muted hover:bg-slate-50 hover:text-foreground"),href:e,onClick:i=>{!r||i.defaultPrevented||i.button!==0||i.metaKey||i.ctrlKey||i.altKey||i.shiftKey||(i.preventDefault(),r(e))},children:n})}function ng({jobId:e,detail:t,selectedJob:n,user:r,onBackToDashboard:i,onRetry:a,onDismiss:o,onCancel:l,onRefresh:c}){const[u,d]=R.useState(!1),[h,m]=R.useState(!1),[p,w]=R.useState(!1),y=!!(r!=null&&r.is_admin&&n&&Vs(n.status)&&n.decision==="auto_trusted"),v=!!(r!=null&&r.is_admin&&n&&Gs(n.status)),b=!!(n&&Js(n,r)),N=u?"Retrying...":"Retry",k=h?"Dismissing...":"Dismiss",_=p?"Cancelling...":"Cancel";return s.jsxs("div",{className:"grid min-w-0 gap-3 sm:gap-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("a",{className:"inline-flex h-9 items-center gap-2 rounded-md border border-border px-3 text-sm font-semibold text-foreground hover:bg-slate-50",href:"/",onClick:O=>{O.defaultPrevented||O.button!==0||O.metaKey||O.ctrlKey||O.altKey||O.shiftKey||(O.preventDefault(),i())},children:[s.jsx(ai,{className:"h-4 w-4","aria-hidden":!0}),"Dashboard"]}),s.jsxs("div",{className:"flex items-center gap-2",children:[y?s.jsxs("button",{className:"inline-flex h-9 items-center justify-center gap-2 rounded-md bg-primary px-3 text-sm font-semibold text-white disabled:cursor-not-allowed disabled:opacity-60",type:"button",disabled:u,onClick:async()=>{if(window.confirm(`Retry job #${e}?`)){d(!0);try{await a(e)}finally{d(!1)}}},children:[s.jsx(cr,{className:"h-4 w-4","aria-hidden":!0}),N]}):null,v?s.jsxs("button",{className:"inline-flex h-9 items-center justify-center gap-2 rounded-md border border-border bg-white px-3 text-sm font-semibold text-foreground hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-60",type:"button",disabled:h,onClick:async()=>{if(window.confirm(`Dismiss job #${e}?`)){m(!0);try{await o(e)}finally{m(!1)}}},children:[s.jsx(Dn,{className:"h-4 w-4","aria-hidden":!0}),k]}):null,b?s.jsxs("button",{className:"inline-flex h-9 items-center justify-center gap-2 rounded-md border border-red-200 bg-red-50 px-3 text-sm font-semibold text-red-700 hover:bg-red-100 disabled:cursor-not-allowed disabled:opacity-60",type:"button",disabled:p,onClick:async()=>{const O=window.prompt(`Cancel job #${e}? Optional reason:`);if(O!==null){w(!0);try{await l(e,O)}finally{w(!1)}}},children:[s.jsx(un,{className:"h-4 w-4","aria-hidden":!0}),_]}):null,s.jsx(nt,{onClick:c})]})]}),s.jsx(se,{title:`Job #${e}`,className:"p-3 sm:p-4",children:t})]})}function rg({selectedJobId:e,selectedJob:t,loading:n,error:r,session:i,sessionEvents:a,transcript:o,now:l}){return t?s.jsx(Ag,{job:t,session:i,sessionEvents:a,transcript:o,now:l}):e!==null&&n?s.jsx(J,{text:"Loading selected job..."}):e!==null&&r?s.jsx(be,{tone:"error",text:`Job #${e}: ${r.message}`}):s.jsx(J,{text:"Select a job to inspect its timeline, worklog and GitHub links."})}function sg({data:e,loading:t,error:n,repo:r,status:i,activeTab:a,user:o,now:l,onRepoChange:c,onStatusChange:u,onTabChange:d,onApprove:h,onReject:m,onUpdateRuleScope:p,onDeleteRule:w,onRefresh:y,hasMore:v=!1,loadingMore:b=!1,onLoadMore:N=()=>{}}){const k=(e==null?void 0:e.summary)??{},[_,O]=R.useState("proposals"),j=a??_,B=M=>{O(M),d==null||d(M)},C=[{id:"proposals",label:"Proposals",count:k.proposals??(k.proposed??0)+(k.approved??0)+(k.rejected??0)+(k.errors??0)},{id:"rules",label:"Rules",count:k.rules??0},{id:"events",label:"Events",count:k.events??0}];return s.jsxs("div",{className:"grid min-w-0 gap-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("h2",{className:"flex items-center gap-2 text-base font-semibold",children:[s.jsx(oi,{className:"h-5 w-5 text-muted","aria-hidden":!0}),"Acquired knowledge"]}),s.jsx("p",{className:"text-xs text-muted",children:"Captured feedback, proposed rules and curated agent memory."})]}),s.jsx(nt,{onClick:y})]}),n?s.jsx(be,{tone:"error",text:n.message}):null,s.jsxs("section",{className:"grid grid-cols-2 gap-3 lg:grid-cols-4","aria-label":"Knowledge metrics",children:[s.jsx(Ae,{title:"Proposed",value:k.proposed??0,icon:s.jsx(Rl,{className:"h-5 w-5"})}),s.jsx(Ae,{title:"Approved",value:k.approved??0,icon:s.jsx(Dn,{className:"h-5 w-5"})}),s.jsx(Ae,{title:"Rules",value:k.rules??0,icon:s.jsx(Tl,{className:"h-5 w-5"})}),s.jsx(Ae,{title:"Events",value:k.events??0,icon:s.jsx(an,{className:"h-5 w-5"})})]}),s.jsx(se,{title:"Filters",className:"p-3",children:s.jsxs("div",{className:Q("grid gap-3",j==="proposals"?"md:grid-cols-[minmax(0,1fr)_220px]":"md:grid-cols-[minmax(0,1fr)]"),children:[s.jsx(ot,{label:"Repository",children:s.jsxs("select",{className:"control",value:r,onChange:M=>c(M.target.value),children:[s.jsx("option",{value:"",children:"All repositories"}),((e==null?void 0:e.repositories)??[]).map(M=>s.jsx("option",{value:M,children:M},M))]})}),j==="proposals"?s.jsx(ot,{label:"Proposal status",children:s.jsxs("select",{className:"control",value:i,onChange:M=>u(M.target.value),children:[s.jsx("option",{value:"",children:"All statuses"}),s.jsx("option",{value:"proposed",children:"proposed"}),s.jsx("option",{value:"approved",children:"approved"}),s.jsx("option",{value:"rejected",children:"rejected"}),s.jsx("option",{value:"error",children:"error"})]})}):null]})}),s.jsxs(se,{title:"Knowledge records",action:s.jsx("div",{className:"flex max-w-full flex-wrap rounded-md border border-border bg-white p-0.5",role:"tablist","aria-label":"Knowledge record type",children:C.map(M=>s.jsxs("button",{className:Q("inline-flex h-8 items-center gap-1.5 rounded px-2.5 text-xs font-semibold",j===M.id?"bg-primary text-white":"text-muted hover:bg-slate-50 hover:text-foreground"),type:"button",role:"tab","aria-label":`${M.label} (${M.count})`,"aria-selected":j===M.id,onClick:()=>B(M.id),children:[s.jsx("span",{children:M.label}),s.jsx("span",{className:Q("rounded-sm border px-1 font-mono text-[10px]",j===M.id?"border-white/40 text-white":"border-border text-muted"),children:M.count})]},M.id))}),children:[j==="proposals"?s.jsx(ig,{proposals:(e==null?void 0:e.proposals)??[],loading:t,isAdmin:!!(o!=null&&o.is_admin),now:l,onApprove:h,onReject:m}):null,j==="rules"?s.jsx(lg,{rules:(e==null?void 0:e.rules)??[],loading:t,now:l,onUpdateRuleScope:p,onDeleteRule:w}):null,j==="events"?s.jsx(cg,{events:(e==null?void 0:e.events)??[],loading:t,now:l}):null,v?s.jsx("div",{className:"mt-3 flex justify-center border-t border-border pt-3",children:s.jsx("button",{className:"button-secondary",type:"button",disabled:b,onClick:N,children:b?"Loading more...":"Load more knowledge records"})}):null]})]})}function ig({proposals:e,loading:t,isAdmin:n,now:r,onApprove:i,onReject:a}){const[o,l]=R.useState(null);return t&&e.length===0?s.jsx(J,{text:"Loading proposals..."}):e.length===0?s.jsx(J,{text:"No proposals match the current filters."}):s.jsx("div",{className:"grid gap-2",children:e.map(c=>s.jsxs("article",{className:"grid min-w-0 gap-2 rounded-md border border-border bg-white p-3",children:[s.jsx(Ec,{scope:c.scope,type:c.type,confidence:c.confidence,status:c.status,timestamp:c.updated_at,now:r}),s.jsx("p",{className:"min-w-0 break-words text-sm font-medium [overflow-wrap:anywhere]",children:c.rule||c.reason||"No reusable rule proposed."}),c.reason?s.jsx("p",{className:"min-w-0 break-words text-xs text-muted [overflow-wrap:anywhere]",children:c.reason}):null,c.source_event?s.jsx(ag,{event:c.source_event}):s.jsxs("p",{className:"font-mono text-xs text-muted",children:["Source event ",c.event_id]}),c.error?s.jsx(be,{tone:"error",text:c.error}):null,n&&c.status==="proposed"?s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsxs("button",{className:"inline-flex h-8 items-center gap-2 rounded-md bg-primary px-3 text-sm font-semibold text-white disabled:opacity-60",type:"button",disabled:o===c.id,onClick:async()=>{l(c.id);try{await i(c.id)}finally{l(null)}},children:[s.jsx(Dn,{className:"h-4 w-4","aria-hidden":!0}),"Approve"]}),s.jsxs("button",{className:"inline-flex h-8 items-center gap-2 rounded-md border border-border px-3 text-sm font-semibold text-foreground hover:bg-slate-50 disabled:opacity-60",type:"button",disabled:o===c.id,onClick:async()=>{l(c.id);try{await a(c.id)}finally{l(null)}},children:[s.jsx(un,{className:"h-4 w-4","aria-hidden":!0}),"Reject"]})]}):null]},c.id))})}function ag({event:e}){const t=e.trigger_actor||(e.actor!=="github"?e.actor:null);return s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2 rounded-md border border-border bg-slate-50 px-2 py-1.5",children:[s.jsx(Hn,{actor:t,avatarUrl:e.trigger_actor_avatar_url,framed:!0}),e.source_job_id?s.jsxs("a",{className:"inline-flex h-7 items-center gap-1 rounded-md border border-border bg-white px-2 text-xs font-semibold text-foreground hover:bg-slate-50",href:Un(e.source_job_id),children:[s.jsx(Fn,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Job #",e.source_job_id]}):null,e.github_urls.length>0?s.jsx(dr,{urls:e.github_urls,compact:!0}):s.jsx("span",{className:"font-mono text-xs text-muted",children:"No GitHub link"})]})}function og(e){const t=[{value:"global",label:"global"}];if(e.startsWith("repo:")){const n=e.slice(5),[r,i]=n.split("/",2);r&&i&&(t.push({value:`org:${r}`,label:`org:${r}`}),t.push({value:`repo:${r}/${i}`,label:`repo:${r}/${i}`}))}else e.startsWith("org:")&&t.push({value:e,label:e});return t.some(n=>n.value===e)||t.push({value:e,label:e}),t}function lg({rules:e,loading:t,now:n,onUpdateRuleScope:r,onDeleteRule:i}){const[a,o]=R.useState(null),[l,c]=R.useState(null),[u,d]=R.useState("");return t&&e.length===0?s.jsx(J,{text:"Loading curated rules..."}):e.length===0?s.jsx(J,{text:"No curated rules match the current filters."}):s.jsx("div",{className:"grid gap-2",children:e.map(h=>{const m=h.source_event_details??[],p=m[0],w=p?p.trigger_actor||(p.actor!=="github"?p.actor:null):null,y=m.flatMap(_=>_.github_urls??[]),v=og(h.scope),b=l===h.id,N=a===h.id,k=!!h.can_manage;return s.jsxs("article",{className:"grid min-w-0 gap-2 rounded-md border border-border bg-white p-3",children:[s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[s.jsx(Ec,{scope:h.scope,type:h.type,confidence:h.confidence,status:`${h.observations} observation${h.observations===1?"":"s"}`,timestamp:h.last_seen,now:n}),k?s.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[b?s.jsxs(s.Fragment,{children:[s.jsx(ot,{label:"Scope",children:s.jsx("select",{className:"control h-8 min-w-[180px] py-1 text-xs",value:u,disabled:N,onChange:_=>d(_.target.value),children:v.map(_=>s.jsx("option",{value:_.value,children:_.label},_.value))})}),s.jsxs("button",{className:"inline-flex h-8 items-center gap-2 rounded-md border border-border px-3 text-sm font-semibold text-foreground hover:bg-slate-50 disabled:opacity-60",type:"button",disabled:N||u===h.scope,title:"Save scope",onClick:async()=>{if(u!==h.scope){o(h.id);try{await r(h.id,u),c(null)}finally{o(null)}}},children:[s.jsx(od,{className:"h-4 w-4","aria-hidden":!0}),"Save"]}),s.jsxs("button",{className:"inline-flex h-8 items-center gap-2 rounded-md border border-border px-3 text-sm font-semibold text-muted hover:bg-slate-50 disabled:opacity-60",type:"button",disabled:N,title:"Cancel scope edit",onClick:()=>{c(null),d("")},children:[s.jsx(un,{className:"h-4 w-4","aria-hidden":!0}),"Cancel"]})]}):s.jsxs("button",{className:"inline-flex h-8 items-center gap-2 rounded-md border border-border px-3 text-sm font-semibold text-foreground hover:bg-slate-50 disabled:opacity-60",type:"button",disabled:N,title:"Edit scope",onClick:()=>{c(h.id),d(h.scope)},children:[s.jsx(ad,{className:"h-4 w-4","aria-hidden":!0}),"Edit"]}),s.jsxs("button",{className:"inline-flex h-8 items-center gap-2 rounded-md border border-red-200 px-3 text-sm font-semibold text-red-700 hover:bg-red-50 disabled:opacity-60",type:"button",disabled:N,onClick:async()=>{if(window.confirm("Delete this curated rule?")){o(h.id);try{await i(h.id)}finally{o(null)}}},children:[s.jsx(Ls,{className:"h-4 w-4","aria-hidden":!0}),"Delete"]})]}):null]}),s.jsx("p",{className:"min-w-0 break-words text-sm font-medium [overflow-wrap:anywhere]",children:h.rule}),s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[s.jsx(Hn,{actor:w,avatarUrl:p==null?void 0:p.trigger_actor_avatar_url,framed:!0}),p!=null&&p.source_job_id?s.jsxs("a",{className:"inline-flex h-7 items-center gap-1 rounded-md border border-border px-2 text-xs font-semibold text-foreground hover:bg-white",href:Un(p.source_job_id),children:[s.jsx(Fn,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Job #",p.source_job_id]}):null,y.length>0?s.jsx(dr,{urls:y,compact:!0}):s.jsx("span",{className:"font-mono text-xs text-muted",children:"No GitHub link"})]})]},h.id)})})}function cg({events:e,loading:t,now:n}){return t&&e.length===0?s.jsx(J,{text:"Loading captured events..."}):e.length===0?s.jsx(J,{text:"No captured feedback events match the current filters."}):s.jsx("div",{className:"grid gap-2",children:e.map(r=>{const i=r.trigger_actor||(r.actor!=="github"?r.actor:null);return s.jsxs("details",{className:"group rounded-md border border-border bg-white",children:[s.jsxs("summary",{className:"grid cursor-pointer list-none gap-2 px-3 py-2 marker:hidden hover:bg-slate-50",children:[s.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-2 font-mono text-xs font-semibold text-muted",children:[s.jsx(On,{className:"h-3.5 w-3.5 shrink-0 transition-transform group-open:rotate-180","aria-hidden":!0}),s.jsx("span",{className:"truncate",children:Nc(r.scope)})]}),s.jsx("span",{className:"shrink-0 font-mono text-xs text-muted",children:s.jsx(ue,{value:r.occurred_at,relative:!0,now:n})})]}),s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[s.jsx(Hn,{actor:i,avatarUrl:r.trigger_actor_avatar_url,framed:!0}),r.source_job_id?s.jsxs("a",{className:"inline-flex h-7 items-center gap-1 rounded-md border border-border px-2 text-xs font-semibold text-foreground hover:bg-white",href:Un(r.source_job_id),children:[s.jsx(Fn,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Job #",r.source_job_id]}):null,r.github_urls.length>0?s.jsx(dr,{urls:r.github_urls,compact:!0}):s.jsx("span",{className:"font-mono text-xs text-muted",children:"No GitHub link"})]}),s.jsx("p",{className:"line-clamp-2 break-words text-sm [overflow-wrap:anywhere]",children:r.comment})]}),s.jsxs("div",{className:"grid gap-2 border-t border-border px-3 py-2",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"mb-1 text-xs font-semibold text-muted",children:"GitHub links"}),r.github_urls.length>0?s.jsx(dr,{urls:r.github_urls}):s.jsx("p",{className:"text-xs text-muted",children:"No links recorded."})]}),s.jsx("pre",{className:"max-h-72 overflow-auto rounded-md bg-slate-950 px-3 py-2 font-mono text-xs leading-relaxed text-slate-100",children:JSON.stringify(r.context,null,2)})]})]},r.id)})})}function ug({tokens:e,loading:t,error:n,user:r,ownerOptions:i,dashboardUrl:a,dashboardUrlSource:o,now:l,onCreate:c,onUpdateOwner:u,onRevoke:d,onRefresh:h}){const[m,p]=R.useState(""),[w,y]=R.useState(""),[v,b]=R.useState(!1),[N,k]=R.useState(null),[_,O]=R.useState(null),[j,B]=R.useState(null),[F,C]=R.useState(""),M=e??[],D=i.find(P=>P.login===w);R.useEffect(()=>{var P;r!=null&&r.is_admin&&(w&&i.some(U=>U.login===w)||y((r==null?void 0:r.login)||((P=i[0])==null?void 0:P.login)||""))},[i,r==null?void 0:r.is_admin,r==null?void 0:r.login,w]);const I=(a||(typeof window>"u"?"":window.location.origin)).replace(/\/$/,""),X=`${I}/mcp`,q=`${I}/api/mcp`;return s.jsxs("div",{className:"grid min-w-0 gap-4",children:[s.jsx(Cc,{icon:s.jsx(Or,{className:"h-5 w-5 text-muted","aria-hidden":!0}),title:"MCP access",subtitle:r!=null&&r.is_admin?"Issue and revoke read-only tokens for any dashboard user.":"Issue and revoke read-only tokens linked to your user.",action:s.jsx(nt,{onClick:h})}),n?s.jsx(be,{tone:"error",text:n.message}):null,F?s.jsx(be,{tone:"error",text:F}):null,s.jsx(dg,{dashboardUrl:X,endpointUrl:q,dashboardUrlSource:o??"request"}),j?s.jsxs("section",{className:"rounded-md border border-emerald-300 bg-emerald-50 p-3 text-emerald-950","aria-label":"Created MCP token",children:[s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-sm font-semibold",children:"Token created"}),s.jsx("p",{className:"mt-1 text-xs text-emerald-800",children:"This secret is shown once. Store it in the local agent environment before leaving this page."})]}),s.jsxs("button",{className:"inline-flex h-8 items-center gap-2 rounded-md border border-emerald-300 bg-white px-3 text-sm font-semibold text-emerald-900 hover:bg-emerald-100",type:"button",onClick:()=>B(null),children:[s.jsx(un,{className:"h-4 w-4","aria-hidden":!0}),"Hide"]})]}),s.jsx("pre",{className:"mt-3 overflow-auto rounded bg-emerald-950 px-3 py-2 font-mono text-xs text-emerald-50",children:j.token})]}):null,s.jsx(se,{title:"Create token",children:s.jsxs("form",{className:r!=null&&r.is_admin?"grid gap-3 md:grid-cols-[minmax(0,1fr)_minmax(12rem,16rem)_auto]":"grid gap-3 md:grid-cols-[minmax(0,1fr)_auto]",onSubmit:async P=>{P.preventDefault();const U=m.trim();if(U){b(!0),C("");try{const te=await c(U,r!=null&&r.is_admin?w:void 0);B(te),p("")}catch(te){C(te instanceof Error?te.message:String(te))}finally{b(!1)}}},children:[s.jsx(ot,{label:"Token name",children:s.jsx("input",{className:"control",value:m,placeholder:"local agent",disabled:v,onChange:P=>p(P.target.value)})}),r!=null&&r.is_admin?s.jsxs(ot,{label:"Owner",children:[s.jsx(Pc,{ariaLabel:"Owner",value:w,ownerOptions:i,disabled:v||i.length===0,selectedSuffix:P=>P.login===(r==null?void 0:r.login)?" (you)":"",emptyLabel:"No known users",onChange:y}),D?s.jsxs("span",{className:"font-normal text-muted",children:["Token will be linked to @",D.login,"."]}):null]}):null,s.jsxs("button",{className:"inline-flex h-9 items-center justify-center gap-2 self-end rounded-md bg-primary px-3 text-sm font-semibold text-white disabled:cursor-not-allowed disabled:opacity-60",type:"submit",disabled:v||!m.trim()||!!(r!=null&&r.is_admin&&!w),children:[s.jsx(Or,{className:"h-4 w-4","aria-hidden":!0}),v?"Creating...":"Create token"]})]})}),s.jsx(se,{title:"Active tokens",children:s.jsx(hg,{tokens:M,loading:t,now:l,ownerOptions:i,canManageOwners:!!(r!=null&&r.is_admin),revokingId:N,updatingOwnerId:_,onUpdateOwner:async(P,U)=>{O(P),C("");try{await u(P,U)}catch(te){C(te instanceof Error?te.message:String(te))}finally{O(null)}},onRevoke:async P=>{if(window.confirm("Revoke this MCP token?")){k(P),C("");try{await d(P)}catch(U){C(U instanceof Error?U.message:String(U))}finally{k(null)}}}})})]})}function dg({dashboardUrl:e,endpointUrl:t,dashboardUrlSource:n}){const r=n==="configured"?"Configured public URL":n==="forwarded"?"Forwarded public URL":"Needs public URL",i=n==="request",a=i?"Set GITHUB_AGENT_BRIDGE_DASHBOARD_PUBLIC_URL or forward X-Forwarded-* headers":e,o=i?"Public dashboard URL required before connecting remote agents":t,c=`{ +`},i),a}function tf(e,t){return e&&"run"in e?async function(n,r){const i=Mo(n,{file:r,...t});await e.run(i,r)}:function(n,r){return Mo(n,{file:r,...e||t})}}function Do(e){if(e)throw e}var ss,Oo;function nf(){if(Oo)return ss;Oo=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=function(u){return typeof Array.isArray=="function"?Array.isArray(u):t.call(u)==="[object Array]"},a=function(u){if(!u||t.call(u)!=="[object Object]")return!1;var d=e.call(u,"constructor"),h=u.constructor&&u.constructor.prototype&&e.call(u.constructor.prototype,"isPrototypeOf");if(u.constructor&&!d&&!h)return!1;var m;for(m in u);return typeof m>"u"||e.call(u,m)},o=function(u,d){n&&d.name==="__proto__"?n(u,d.name,{enumerable:!0,configurable:!0,value:d.newValue,writable:!0}):u[d.name]=d.newValue},l=function(u,d){if(d==="__proto__")if(e.call(u,d)){if(r)return r(u,d).value}else return;return u[d]};return ss=function c(){var u,d,h,m,p,w,y=arguments[0],v=1,b=arguments.length,N=!1;for(typeof y=="boolean"&&(N=y,y=arguments[1]||{},v=2),(y==null||typeof y!="object"&&typeof y!="function")&&(y={});vo.length;let c;l&&o.push(i);try{c=e.apply(this,o)}catch(u){const d=u;if(l&&n)throw d;return i(d)}l||(c&&c.then&&typeof c.then=="function"?c.then(a,i):c instanceof Error?i(c):a(c))}function i(o,...l){n||(n=!0,t(o,...l))}function a(o){i(null,o)}}const pt={basename:of,dirname:lf,extname:cf,join:uf,sep:"/"};function of(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');yr(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let o=-1,l=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),l>-1&&(e.codePointAt(i)===t.codePointAt(l--)?l<0&&(r=i):(l=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function lf(e){if(yr(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function cf(e){yr(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){const l=e.codePointAt(t);if(l===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),l===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?"":e.slice(i,n)}function uf(...e){let t=-1,n;for(;++t0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function hf(e,t){let n="",r=0,i=-1,a=0,o=-1,l,c;for(;++o<=e.length;){if(o2){if(c=n.lastIndexOf("/"),c!==n.length-1){c<0?(n="",r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf("/")),i=o,a=0;continue}}else if(n.length>0){n="",r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1;i=o,a=0}else l===46&&a>-1?a++:a=-1}return n}function yr(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const pf={cwd:mf};function mf(){return"/"}function Hs(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function ff(e){if(typeof e=="string")e=new URL(e);else if(!Hs(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return xf(e)}function xf(e){if(e.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const t=e.pathname;let n=-1;for(;++n0){let[p,...w]=d;const y=r[m][1];Us(y)&&Us(p)&&(p=is(!0,y,p)),r[m]=[u,p,...w]}}}}const wf=new vi().freeze();function cs(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function us(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function ds(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function zo(e){if(!Us(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function qo(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Pr(e){return vf(e)?e:new fc(e)}function vf(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function jf(e){return typeof e=="string"||kf(e)}function kf(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const Nf="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Bo=[],$o={allowDangerousHtml:!0},Sf=/^(https?|ircs?|mailto|xmpp)$/i,_f=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function Cf(e){const t=Pf(e),n=Ef(e);return Rf(t.runSync(t.parse(n),n),e)}function Pf(e){const t=e.rehypePlugins||Bo,n=e.remarkPlugins||Bo,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...$o}:$o;return wf().use(im).use(n).use(tf,r).use(t)}function Ef(e){const t=e.children||"",n=new fc;return typeof t=="string"&&(n.value=t),n}function Rf(e,t){const n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,l=t.unwrapDisallowed,c=t.urlTransform||If;for(const d of _f)Object.hasOwn(t,d.from)&&(""+d.from+(d.to?"use `"+d.to+"` instead":"remove it")+Nf+d.id,void 0);return mc(e,u),Fd(e,{Fragment:s.Fragment,components:i,ignoreInvalidStyle:!0,jsx:s.jsx,jsxs:s.jsxs,passKeys:!0,passNode:!0});function u(d,h,m){if(d.type==="raw"&&m&&typeof h=="number")return o?m.children.splice(h,1):m.children[h]={type:"text",value:d.value},h;if(d.type==="element"){let p;for(p in ts)if(Object.hasOwn(ts,p)&&Object.hasOwn(d.properties,p)){const w=d.properties[p],y=ts[p];(y===null||y.includes(d.tagName))&&(d.properties[p]=c(String(w||""),p,d))}}if(d.type==="element"){let p=n?!n.includes(d.tagName):a?a.includes(d.tagName):!1;if(!p&&r&&typeof h=="number"&&(p=!r(d,h,m)),p&&m&&typeof h=="number")return l&&d.children?m.children.splice(h,1,...d.children):m.children.splice(h,1),h}}}function If(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),i=e.indexOf("/");return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||Sf.test(e.slice(0,t))?e:""}const ji="-",Tf=e=>{const t=Lf(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:o=>{const l=o.split(ji);return l[0]===""&&l.length!==1&&l.shift(),xc(l,t)||Af(o)},getConflictingClassGroupIds:(o,l)=>{const c=n[o]||[];return l&&r[o]?[...c,...r[o]]:c}}},xc=(e,t)=>{var o;if(e.length===0)return t.classGroupId;const n=e[0],r=t.nextPart.get(n),i=r?xc(e.slice(1),r):void 0;if(i)return i;if(t.validators.length===0)return;const a=e.join(ji);return(o=t.validators.find(({validator:l})=>l(a)))==null?void 0:o.classGroupId},Uo=/^\[(.+)\]$/,Af=e=>{if(Uo.test(e)){const t=Uo.exec(e)[1],n=t==null?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},Lf=e=>{const{theme:t,prefix:n}=e,r={nextPart:new Map,validators:[]};return Df(Object.entries(e.classGroups),n).forEach(([a,o])=>{Ks(o,r,a,t)}),r},Ks=(e,t,n,r)=>{e.forEach(i=>{if(typeof i=="string"){const a=i===""?t:Ho(t,i);a.classGroupId=n;return}if(typeof i=="function"){if(Mf(i)){Ks(i(r),t,n,r);return}t.validators.push({validator:i,classGroupId:n});return}Object.entries(i).forEach(([a,o])=>{Ks(o,Ho(t,a),n,r)})})},Ho=(e,t)=>{let n=e;return t.split(ji).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},Mf=e=>e.isThemeGetter,Df=(e,t)=>t?e.map(([n,r])=>{const i=r.map(a=>typeof a=="string"?t+a:typeof a=="object"?Object.fromEntries(Object.entries(a).map(([o,l])=>[t+o,l])):a);return[n,i]}):e,Of=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=new Map,r=new Map;const i=(a,o)=>{n.set(a,o),t++,t>e&&(t=0,r=n,n=new Map)};return{get(a){let o=n.get(a);if(o!==void 0)return o;if((o=r.get(a))!==void 0)return i(a,o),o},set(a,o){n.has(a)?n.set(a,o):i(a,o)}}},gc="!",Ff=e=>{const{separator:t,experimentalParseClassName:n}=e,r=t.length===1,i=t[0],a=t.length,o=l=>{const c=[];let u=0,d=0,h;for(let v=0;vd?h-d:void 0;return{modifiers:c,hasImportantModifier:p,baseClassName:w,maybePostfixModifierPosition:y}};return n?l=>n({className:l,parseClassName:o}):o},zf=e=>{if(e.length<=1)return e;const t=[];let n=[];return e.forEach(r=>{r[0]==="["?(t.push(...n.sort(),r),n=[]):n.push(r)}),t.push(...n.sort()),t},qf=e=>({cache:Of(e.cacheSize),parseClassName:Ff(e),...Tf(e)}),Bf=/\s+/,$f=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i}=t,a=[],o=e.trim().split(Bf);let l="";for(let c=o.length-1;c>=0;c-=1){const u=o[c],{modifiers:d,hasImportantModifier:h,baseClassName:m,maybePostfixModifierPosition:p}=n(u);let w=!!p,y=r(w?m.substring(0,p):m);if(!y){if(!w){l=u+(l.length>0?" "+l:l);continue}if(y=r(m),!y){l=u+(l.length>0?" "+l:l);continue}w=!1}const v=zf(d).join(":"),b=h?v+gc:v,N=b+y;if(a.includes(N))continue;a.push(N);const k=i(y,w);for(let _=0;_0?" "+l:l)}return l};function Uf(){let e=0,t,n,r="";for(;e{if(typeof e=="string")return e;let t,n="";for(let r=0;rh(d),e());return n=qf(u),r=n.cache.get,i=n.cache.set,a=l,l(c)}function l(c){const u=r(c);if(u)return u;const d=$f(c,n);return i(c,d),d}return function(){return a(Uf.apply(null,arguments))}}const ge=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},yc=/^\[(?:([a-z-]+):)?(.+)\]$/i,Kf=/^\d+\/\d+$/,Qf=new Set(["px","full","screen"]),Wf=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Vf=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Gf=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Jf=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Xf=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,kt=e=>yn(e)||Qf.has(e)||Kf.test(e),Rt=e=>$n(e,"length",ix),yn=e=>!!e&&!Number.isNaN(Number(e)),hs=e=>$n(e,"number",yn),Yn=e=>!!e&&Number.isInteger(Number(e)),Yf=e=>e.endsWith("%")&&yn(e.slice(0,-1)),Y=e=>yc.test(e),It=e=>Wf.test(e),Zf=new Set(["length","size","percentage"]),ex=e=>$n(e,Zf,wc),tx=e=>$n(e,"position",wc),nx=new Set(["image","url"]),rx=e=>$n(e,nx,ox),sx=e=>$n(e,"",ax),Zn=()=>!0,$n=(e,t,n)=>{const r=yc.exec(e);return r?r[1]?typeof t=="string"?r[1]===t:t.has(r[1]):n(r[2]):!1},ix=e=>Vf.test(e)&&!Gf.test(e),wc=()=>!1,ax=e=>Jf.test(e),ox=e=>Xf.test(e),lx=()=>{const e=ge("colors"),t=ge("spacing"),n=ge("blur"),r=ge("brightness"),i=ge("borderColor"),a=ge("borderRadius"),o=ge("borderSpacing"),l=ge("borderWidth"),c=ge("contrast"),u=ge("grayscale"),d=ge("hueRotate"),h=ge("invert"),m=ge("gap"),p=ge("gradientColorStops"),w=ge("gradientColorStopPositions"),y=ge("inset"),v=ge("margin"),b=ge("opacity"),N=ge("padding"),k=ge("saturate"),_=ge("scale"),D=ge("sepia"),j=ge("skew"),B=ge("space"),F=ge("translate"),C=()=>["auto","contain","none"],M=()=>["auto","hidden","clip","visible","scroll"],O=()=>["auto",Y,t],I=()=>[Y,t],X=()=>["",kt,Rt],q=()=>["auto",yn,Y],P=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],U=()=>["solid","dashed","dotted","double","none"],te=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],me=()=>["start","end","center","between","around","evenly","stretch"],ye=()=>["","0",Y],f=()=>["auto","avoid","all","avoid-page","page","left","right","column"],A=()=>[yn,Y];return{cacheSize:500,separator:":",theme:{colors:[Zn],spacing:[kt,Rt],blur:["none","",It,Y],brightness:A(),borderColor:[e],borderRadius:["none","","full",It,Y],borderSpacing:I(),borderWidth:X(),contrast:A(),grayscale:ye(),hueRotate:A(),invert:ye(),gap:I(),gradientColorStops:[e],gradientColorStopPositions:[Yf,Rt],inset:O(),margin:O(),opacity:A(),padding:I(),saturate:A(),scale:A(),sepia:ye(),skew:A(),space:I(),translate:I()},classGroups:{aspect:[{aspect:["auto","square","video",Y]}],container:["container"],columns:[{columns:[It]}],"break-after":[{"break-after":f()}],"break-before":[{"break-before":f()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...P(),Y]}],overflow:[{overflow:M()}],"overflow-x":[{"overflow-x":M()}],"overflow-y":[{"overflow-y":M()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[y]}],"inset-x":[{"inset-x":[y]}],"inset-y":[{"inset-y":[y]}],start:[{start:[y]}],end:[{end:[y]}],top:[{top:[y]}],right:[{right:[y]}],bottom:[{bottom:[y]}],left:[{left:[y]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",Yn,Y]}],basis:[{basis:O()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",Y]}],grow:[{grow:ye()}],shrink:[{shrink:ye()}],order:[{order:["first","last","none",Yn,Y]}],"grid-cols":[{"grid-cols":[Zn]}],"col-start-end":[{col:["auto",{span:["full",Yn,Y]},Y]}],"col-start":[{"col-start":q()}],"col-end":[{"col-end":q()}],"grid-rows":[{"grid-rows":[Zn]}],"row-start-end":[{row:["auto",{span:[Yn,Y]},Y]}],"row-start":[{"row-start":q()}],"row-end":[{"row-end":q()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",Y]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",Y]}],gap:[{gap:[m]}],"gap-x":[{"gap-x":[m]}],"gap-y":[{"gap-y":[m]}],"justify-content":[{justify:["normal",...me()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...me(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...me(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[N]}],px:[{px:[N]}],py:[{py:[N]}],ps:[{ps:[N]}],pe:[{pe:[N]}],pt:[{pt:[N]}],pr:[{pr:[N]}],pb:[{pb:[N]}],pl:[{pl:[N]}],m:[{m:[v]}],mx:[{mx:[v]}],my:[{my:[v]}],ms:[{ms:[v]}],me:[{me:[v]}],mt:[{mt:[v]}],mr:[{mr:[v]}],mb:[{mb:[v]}],ml:[{ml:[v]}],"space-x":[{"space-x":[B]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[B]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",Y,t]}],"min-w":[{"min-w":[Y,t,"min","max","fit"]}],"max-w":[{"max-w":[Y,t,"none","full","min","max","fit","prose",{screen:[It]},It]}],h:[{h:[Y,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[Y,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[Y,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[Y,t,"auto","min","max","fit"]}],"font-size":[{text:["base",It,Rt]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",hs]}],"font-family":[{font:[Zn]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",Y]}],"line-clamp":[{"line-clamp":["none",yn,hs]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",kt,Y]}],"list-image":[{"list-image":["none",Y]}],"list-style-type":[{list:["none","disc","decimal",Y]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[b]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[b]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...U(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",kt,Rt]}],"underline-offset":[{"underline-offset":["auto",kt,Y]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:I()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Y]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Y]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[b]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...P(),tx]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",ex]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},rx]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[w]}],"gradient-via-pos":[{via:[w]}],"gradient-to-pos":[{to:[w]}],"gradient-from":[{from:[p]}],"gradient-via":[{via:[p]}],"gradient-to":[{to:[p]}],rounded:[{rounded:[a]}],"rounded-s":[{"rounded-s":[a]}],"rounded-e":[{"rounded-e":[a]}],"rounded-t":[{"rounded-t":[a]}],"rounded-r":[{"rounded-r":[a]}],"rounded-b":[{"rounded-b":[a]}],"rounded-l":[{"rounded-l":[a]}],"rounded-ss":[{"rounded-ss":[a]}],"rounded-se":[{"rounded-se":[a]}],"rounded-ee":[{"rounded-ee":[a]}],"rounded-es":[{"rounded-es":[a]}],"rounded-tl":[{"rounded-tl":[a]}],"rounded-tr":[{"rounded-tr":[a]}],"rounded-br":[{"rounded-br":[a]}],"rounded-bl":[{"rounded-bl":[a]}],"border-w":[{border:[l]}],"border-w-x":[{"border-x":[l]}],"border-w-y":[{"border-y":[l]}],"border-w-s":[{"border-s":[l]}],"border-w-e":[{"border-e":[l]}],"border-w-t":[{"border-t":[l]}],"border-w-r":[{"border-r":[l]}],"border-w-b":[{"border-b":[l]}],"border-w-l":[{"border-l":[l]}],"border-opacity":[{"border-opacity":[b]}],"border-style":[{border:[...U(),"hidden"]}],"divide-x":[{"divide-x":[l]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[l]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[b]}],"divide-style":[{divide:U()}],"border-color":[{border:[i]}],"border-color-x":[{"border-x":[i]}],"border-color-y":[{"border-y":[i]}],"border-color-s":[{"border-s":[i]}],"border-color-e":[{"border-e":[i]}],"border-color-t":[{"border-t":[i]}],"border-color-r":[{"border-r":[i]}],"border-color-b":[{"border-b":[i]}],"border-color-l":[{"border-l":[i]}],"divide-color":[{divide:[i]}],"outline-style":[{outline:["",...U()]}],"outline-offset":[{"outline-offset":[kt,Y]}],"outline-w":[{outline:[kt,Rt]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:X()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[b]}],"ring-offset-w":[{"ring-offset":[kt,Rt]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",It,sx]}],"shadow-color":[{shadow:[Zn]}],opacity:[{opacity:[b]}],"mix-blend":[{"mix-blend":[...te(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":te()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[c]}],"drop-shadow":[{"drop-shadow":["","none",It,Y]}],grayscale:[{grayscale:[u]}],"hue-rotate":[{"hue-rotate":[d]}],invert:[{invert:[h]}],saturate:[{saturate:[k]}],sepia:[{sepia:[D]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[c]}],"backdrop-grayscale":[{"backdrop-grayscale":[u]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[d]}],"backdrop-invert":[{"backdrop-invert":[h]}],"backdrop-opacity":[{"backdrop-opacity":[b]}],"backdrop-saturate":[{"backdrop-saturate":[k]}],"backdrop-sepia":[{"backdrop-sepia":[D]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[o]}],"border-spacing-x":[{"border-spacing-x":[o]}],"border-spacing-y":[{"border-spacing-y":[o]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",Y]}],duration:[{duration:A()}],ease:[{ease:["linear","in","out","in-out",Y]}],delay:[{delay:A()}],animate:[{animate:["none","spin","ping","pulse","bounce",Y]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[_]}],"scale-x":[{"scale-x":[_]}],"scale-y":[{"scale-y":[_]}],rotate:[{rotate:[Yn,Y]}],"translate-x":[{"translate-x":[F]}],"translate-y":[{"translate-y":[F]}],"skew-x":[{"skew-x":[j]}],"skew-y":[{"skew-y":[j]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",Y]}],accent:[{accent:["auto",e]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Y]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":I()}],"scroll-mx":[{"scroll-mx":I()}],"scroll-my":[{"scroll-my":I()}],"scroll-ms":[{"scroll-ms":I()}],"scroll-me":[{"scroll-me":I()}],"scroll-mt":[{"scroll-mt":I()}],"scroll-mr":[{"scroll-mr":I()}],"scroll-mb":[{"scroll-mb":I()}],"scroll-ml":[{"scroll-ml":I()}],"scroll-p":[{"scroll-p":I()}],"scroll-px":[{"scroll-px":I()}],"scroll-py":[{"scroll-py":I()}],"scroll-ps":[{"scroll-ps":I()}],"scroll-pe":[{"scroll-pe":I()}],"scroll-pt":[{"scroll-pt":I()}],"scroll-pr":[{"scroll-pr":I()}],"scroll-pb":[{"scroll-pb":I()}],"scroll-pl":[{"scroll-pl":I()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Y]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[kt,Rt,hs]}],stroke:[{stroke:[e,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},cx=Hf(lx),Qs={status:"",repo:"",thread:"",action:"",intent:"",actor:""},ux=new Uu({defaultOptions:{queries:{retry:1}}}),Ko=12,dx=12,hx=10080*60*1e3,px=1e3,Ws=Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC";function Q(...e){return cx(du(e))}async function ee(e,t){const n=new Headers(t==null?void 0:t.headers);n.set("Accept","application/json");const r=await fetch(e,{...t,headers:n});if(!r.ok)throw new Error(`${r.status} ${r.statusText}`);return r.json()}function Xe(e){if(e==null)return"n/a";const t=Math.max(0,Math.floor(e));if(t<60)return`${t}s`;const n=Math.floor(t/60);return n<60?`${n}m ${t%60}s`:`${Math.floor(n/60)}h ${n%60}m`}const mx=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:"short"}),fx=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});function wr(e){if(!e)return null;const t=new Date(e);return Number.isNaN(t.getTime())?null:t}function xx(e){const t=wr(e);return t?mx.format(t):e??""}function ir(e){const t=wr(e);return t?fx.format(t):e??""}function vc(e,t){const n=wr(e);if(!n)return e??"";const r=t-n.getTime(),i=Math.abs(r);if(i>hx)return ir(e);const a=r>=0?"ago":"from now",o=Math.round(i/1e3);if(o<45)return r>=0?"just now":"soon";if(o<90)return`1m ${a}`;const l=Math.round(o/60);if(l<60)return`${l}m ${a}`;if(l<90)return`1h ${a}`;const c=Math.round(l/60);return c<24?`${c}h ${a}`:c<36?`1d ${a}`:`${Math.round(c/24)}d ${a}`}function ue({value:e,compact:t=!1,relative:n=!1,now:r=Date.now()}){const i=wr(e);return i?s.jsx("time",{dateTime:i.toISOString(),title:`UTC: ${i.toISOString()}`,children:n?vc(e,r):t?ir(e):xx(e)}):s.jsx(s.Fragment,{children:e??""})}function jc(e,t){const n=wr(e);return n?Math.max(0,Math.floor((t-n.getTime())/1e3)):null}function ki(e,t){return e.status==="running"?jc(e.started_at,t)??e.runtime_seconds:e.runtime_seconds}function Ni(e,t){return e.status==="pending"?jc(e.created_at,t)??e.queue_wait_seconds:e.queue_wait_seconds}function gx(e){const[t,n]=R.useState(()=>Date.now());return R.useEffect(()=>{if(!e)return;n(Date.now());const r=window.setInterval(()=>n(Date.now()),px);return()=>window.clearInterval(r)},[e]),t}function bx(e){return(e??"").split(/\r?\n/).map(n=>n.trim()).find(Boolean)??""}function zr(e,t,n=1){const r=bx(t),i=n>1?` (${n})`:"";return r?`${e}${i}: ${r}`:`${e}${i}`}function qr(e){return e==="openclaw_stdout"||e==="openclaw_stderr"}function kc(e){return e.map(t=>t==null?void 0:t.trim()).filter(Boolean).join(` +`)}function yx(e){const t=[];for(const n of e){const r=t[t.length-1];if(r&&qr(n.event_type)&&r.eventType===n.event_type){r.count+=1,r.meta=n.ts,r.detail=kc([r.detail,n.detail]),r.summary=zr(n.summary,r.detail,r.count);continue}t.push({id:String(n.id),badge:n.event_type,meta:n.ts,summary:qr(n.event_type)?zr(n.summary,n.detail):n.summary,detail:n.detail,eventType:n.event_type,count:1})}return t}function wx(e){const t=[];return e.forEach((n,r)=>{const i=t[t.length-1];if(i&&qr(n.kind)&&i.kind===n.kind){i.count+=1,i.meta=n.timestamp,i.text=kc([i.text,n.text]),i.summary=zr(`${n.role} ยท ${n.kind}`,i.text,i.count);return}t.push({id:`${n.timestamp??"entry"}-${r}`,badge:n.title,meta:n.timestamp,summary:qr(n.kind)?zr(`${n.role} ยท ${n.kind}`,n.text):`${n.role} ยท ${n.kind}`,text:n.text,kind:n.kind,count:1})}),t}function Qo(e,t,n,r){return e==="openclaw_stdout"?!1:t||n>=r-2}function vx(e){return{pending:{badge:"border-amber-300 bg-amber-50 text-amber-800",dot:"bg-amber-500"},running:{badge:"border-blue-300 bg-blue-50 text-blue-700",dot:"bg-blue-600"},blocked:{badge:"border-red-300 bg-red-50 text-red-700",dot:"bg-red-600"},denied:{badge:"border-red-300 bg-red-50 text-red-700",dot:"bg-red-600"},done:{badge:"border-emerald-300 bg-emerald-50 text-emerald-700",dot:"bg-emerald-600"},waiting_approval:{badge:"border-slate-300 bg-slate-50 text-slate-700",dot:"bg-slate-500"}}[e]??{badge:"border-slate-300 bg-slate-50 text-slate-700",dot:"bg-slate-500"}}function jx(e,t){const n=new URLSearchParams;for(const[r,i]of Object.entries(e))i.trim()&&n.set(r,i.trim());return n.set("limit",String(t)),`/api/jobs?${n.toString()}`}function kx(e,t,n,r=50,i=0){const a=new URLSearchParams;return e.trim()&&a.set("repo",e.trim()),n==="proposals"&&t.trim()&&a.set("status",t.trim()),a.set("section",n),a.set("limit",String(r)),i>0&&a.set("offset",String(i)),`/api/knowledge?${a.toString()}`}function Nx(e){return{timeseries:e==="overview",hooks:e==="hooks",deliveries:e==="deliveries"}}function Sx(e,t,n="day"){return`/api/webhooks/github/timeseries?${new URLSearchParams({from:e,to:t,bucket:n}).toString()}`}function _x(e=50,t){const n=new URLSearchParams({limit:String(e)});return t&&n.set("cursor",t),`/api/webhooks/github/hooks?${n.toString()}`}function Cx(e=50,t,n){const r=new URLSearchParams({limit:String(e)});t&&r.set("cursor",t);for(const[i,a]of Object.entries(n??{}))a!=null&&a.trim()&&r.set(i,a.trim());return`/api/webhooks/github/deliveries?${r.toString()}`}function Er(e=new Date){return{from:new Date(e.getTime()-720*60*60*1e3).toISOString(),to:e.toISOString()}}function Px(e=Ws,t="7d",n="7d"){return`/api/metrics/summary?${new URLSearchParams({window:t,runtime_window:n,timezone:e}).toString()}`}function rt(e){try{const t=new URL(e);return t.protocol==="https:"||t.protocol==="http:"?t.href:"#"}catch{return"#"}}function Lr(){return"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window}function Ex(e){return!!(e&&typeof e=="object"&&"type"in e&&e.type==="github-agent-bridge:push")}function Rx(e){const t="=".repeat((4-e.length%4)%4),n=(e+t).replace(/-/g,"+").replace(/_/g,"/"),r=window.atob(n),i=new Uint8Array(r.length);for(let a=0;an.id===t.id)?e:[...e,t]}function Tx(e,t){const n=Wo(t);return e.some(r=>Wo(r)===n)?e:[...e,t]}function Wo(e){return`${e.timestamp??""}:${e.role}:${e.kind}:${e.title}:${e.text}`}function Ax(e){return["claimed","dispatch_started","dispatch_finished","done","blocked","denied","waiting_approval"].includes(e)}function Vs(e){return e==="blocked"}function Gs(e){return["blocked","denied","waiting_approval"].includes(e)}function Js(e,t){return e.status!=="running"?!1:t!=null&&t.is_admin?!0:!!(t!=null&&t.login&&e.trigger_actor&&t.login.toLowerCase()===e.trigger_actor.toLowerCase())}function Lx(e=window.location.pathname){const t=e.match(/^\/jobs\/(\d+)\/?$/);return t?Number(t[1]):null}function Mx(e=window.location.pathname){return/^\/knowledge\/?$/.test(e)}function Dx(e=window.location.pathname){return/^\/mcp\/?$/.test(e)}function Ox(e=window.location.pathname){return/^\/system\/?$/.test(e)}function Fx(e=window.location.pathname){const t=e.match(/^\/webhooks\/hooks\/([^/]+)\/?$/);return t?decodeURIComponent(t[1]):null}function zx(e=window.location.pathname){const t=e.match(/^\/webhooks\/deliveries\/([^/]+)\/?$/);return t?decodeURIComponent(t[1]):null}function ps(e=window.location.pathname){return/^\/webhooks(?:\/(?:hooks|deliveries)\/[^/]+)?\/?$/.test(e)}function Nc(e){return e.startsWith("repo:")?e.slice(5):e}function Vo(e){return Object.values(e).some(t=>t.trim()!=="")}function qx(e){return[{key:"status",label:"Status",value:e.status},{key:"repo",label:"Repo",value:e.repo},{key:"thread",label:"Thread",value:e.thread},{key:"action",label:"Action",value:e.action},{key:"actor",label:"Actor",value:e.actor.trim()?`@${e.actor.trim().replace(/^@/,"")}`:""},{key:"intent",label:"Intent",value:e.intent}].filter(t=>t.value.trim()!=="")}function Bx(){var Ti,Ai,Li,Mi,Di,Oi,Fi,zi,qi,Bi,$i,Ui,Hi,Ki,Qi,Wi,Vi,Gi,Ji,Xi,Yi,Zi,ea,ta,na,ra,sa,ia,aa,oa,la,ca,ua,da,ha,pa,ma,fa,xa,ga,ba,ya,wa,va,ja,ka,Na,Sa,_a,Ca,Pa,Ea,Ra,Ia,Ta,Aa,La,Ma,Da,Oa,Fa,za,qa,Ba,$a;const e=Sl(),[t,n]=R.useState(Qs),[r,i]=R.useState(Ko),a=R.useRef(!1),[o,l]=R.useState(""),[c,u]=R.useState("proposed"),[d,h]=R.useState("proposals"),[m,p]=R.useState("overview"),[w,y]=R.useState({hook_id:"",event_name:"",repository:"",result:"",enqueue_status:""}),[v,b]=R.useState(()=>Er()),[N,k]=R.useState(null),[_,D]=R.useState(""),[j,B]=R.useState(!1),[F,C]=R.useState(""),[M,O]=R.useState(!1),[I,X]=R.useState(""),[q,P]=R.useState("7d"),[U,te]=R.useState("7d"),[me,ye]=R.useState(()=>window.location.pathname),[f,A]=R.useState(null),fe=Lx(me),x=fe!==null,Pe=Mx(me),He=Dx(me),de=Ox(me),lt=ps(me),Me=Fx(me),Ke=zx(me),st=!x&&!Pe&&!He&&!de&&!lt,oe=fe,ke=ve({queryKey:["metrics",Ws,q,U],queryFn:()=>ee(Px(Ws,q,U)),enabled:st||de}),Ne=ve({queryKey:["dashboard-status"],queryFn:()=>ee("/api/status"),refetchInterval:de?1e4:!1}),Ee=ve({queryKey:["me"],queryFn:()=>ee("/api/me"),refetchInterval:!1}),ct=lt&&!!((Ai=(Ti=Ee.data)==null?void 0:Ti.user)!=null&&Ai.is_admin&&((Li=Ne.data)!=null&&Li.webhook_configured)),Ht=Nx(m),yt=ve({queryKey:["web-push-config"],queryFn:()=>ee("/api/web-push/config"),enabled:!!((Mi=Ee.data)!=null&&Mi.user)}),Vr=ve({queryKey:["about"],queryFn:()=>ee("/api/about")}),vr=ve({queryKey:["job-actors"],queryFn:()=>ee("/api/jobs/actors"),enabled:st}),Qe=ve({queryKey:["jobs",t,r],queryFn:()=>ee(jx(t,r)),enabled:st,placeholderData:E=>E}),it=ve({queryKey:["processes"],queryFn:()=>ee("/api/processes"),enabled:de,refetchInterval:de?1e4:!1}),hn=ve({queryKey:["systemd"],queryFn:()=>ee("/api/systemd"),enabled:de}),pn=ve({queryKey:["alerts"],queryFn:()=>ee("/api/alerts"),enabled:de}),mn=ve({queryKey:["webhook-summary"],queryFn:()=>ee("/api/webhooks/github/summary"),enabled:ct}),Kn=ve({queryKey:["webhook-timeseries",v.from,v.to,"day"],queryFn:()=>ee(Sx(v.from,v.to)),enabled:ct&&Ht.timeseries}),S=ve({queryKey:["webhook-exceptions"],queryFn:()=>ee("/api/webhooks/github/exceptions"),enabled:ct&&Ht.timeseries}),L=Yr({queryKey:["webhook-hooks"],queryFn:({pageParam:E})=>ee(_x(50,E)),initialPageParam:null,getNextPageParam:E=>E.next_cursor??void 0,enabled:ct&&Ht.hooks&&Me===null&&Ke===null}),K=Yr({queryKey:["webhook-deliveries",w],queryFn:({pageParam:E})=>ee(Cx(50,E,w)),initialPageParam:null,getNextPageParam:E=>E.next_cursor??void 0,enabled:ct&&Ht.deliveries&&Me===null&&Ke===null}),G=ve({queryKey:["webhook-hook",Me],queryFn:()=>ee(`/api/webhooks/github/hooks/${encodeURIComponent(Me??"")}`),enabled:ct&&Me!==null}),le=R.useCallback(async E=>{const Z=await ee(`/api/webhooks/github/hooks/${encodeURIComponent(E)}/ping`,{method:"POST"});return G.refetch(),window.setTimeout(()=>void G.refetch(),1500),Z.detail},[G]),Re=ve({queryKey:["webhook-delivery",Ke],queryFn:()=>ee(`/api/webhooks/github/deliveries/${encodeURIComponent(Ke??"")}`),enabled:ct&&Ke!==null}),De=Yr({queryKey:["knowledge",d,o,d==="proposals"?c:""],queryFn:({pageParam:E})=>ee(kx(o,c,d,50,E)),initialPageParam:0,getNextPageParam:E=>E.next_offset??void 0,enabled:Pe}),Fe=ve({queryKey:["mcp-tokens"],queryFn:()=>ee("/api/mcp/tokens"),enabled:He&&!!((Di=Ee.data)!=null&&Di.user)}),Kt=ve({queryKey:["mcp-users"],queryFn:()=>ee("/api/mcp/users"),enabled:He&&!!((Oi=Ee.data)!=null&&Oi.user)}),ut=ve({queryKey:["job",oe],queryFn:()=>ee(`/api/jobs/${oe}`),enabled:oe!==null}),Ie=ve({queryKey:["job-session",oe],queryFn:()=>ee(`/api/jobs/${oe}/session`),enabled:oe!==null}),wt=ve({queryKey:["job-session-events",oe],queryFn:()=>ee(`/api/jobs/${oe}/session/events`),enabled:oe!==null}),Ye=ve({queryKey:["job-session-transcript",oe],queryFn:()=>ee(`/api/jobs/${oe}/session/transcript`),enabled:oe!==null}),Ci=R.useCallback(async E=>{const Z=await ee(`/api/jobs/${E}/retry`,{method:"POST"});e.setQueryData(["job",E],{job:Z.job}),e.invalidateQueries({queryKey:["jobs"]}),e.invalidateQueries({queryKey:["metrics"]})},[e]),Pi=R.useCallback(async E=>{const Z=await ee(`/api/jobs/${E}/dismiss`,{method:"POST"});e.setQueryData(["job",E],{job:Z.job}),e.invalidateQueries({queryKey:["jobs"]}),e.invalidateQueries({queryKey:["metrics"]})},[e]),Ei=R.useCallback(async(E,Z)=>{const ce=await ee(`/api/jobs/${E}/cancel`,{method:"POST",body:JSON.stringify({reason:Z||""})});e.setQueryData(["job",E],{job:ce.job}),e.invalidateQueries({queryKey:["jobs"]}),e.invalidateQueries({queryKey:["metrics"]}),e.invalidateQueries({queryKey:["dashboard-status"]})},[e]),Ri=R.useCallback(async(E,Z)=>{await ee(`/api/knowledge/proposals/${encodeURIComponent(E)}/${Z}`,{method:"POST"}),e.invalidateQueries({queryKey:["knowledge"]}),e.invalidateQueries({queryKey:["dashboard-status"]})},[e]),Fc=R.useCallback(async E=>{await ee(`/api/knowledge/rules/${encodeURIComponent(E)}`,{method:"DELETE"}),e.invalidateQueries({queryKey:["knowledge"]})},[e]),zc=R.useCallback(async(E,Z)=>{await ee(`/api/knowledge/rules/${encodeURIComponent(E)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:Z})}),e.invalidateQueries({queryKey:["knowledge"]})},[e]),qc=R.useCallback(async(E,Z)=>{const ce=await ee("/api/mcp/tokens",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:E,user_login:Z||void 0})});return e.invalidateQueries({queryKey:["mcp-tokens"]}),ce},[e]),Bc=R.useCallback(async(E,Z)=>{await ee(`/api/mcp/tokens/${encodeURIComponent(E)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({user_login:Z})}),e.invalidateQueries({queryKey:["mcp-tokens"]}),e.invalidateQueries({queryKey:["mcp-users"]})},[e]),$c=R.useCallback(async E=>{await ee(`/api/mcp/tokens/${encodeURIComponent(E)}`,{method:"DELETE"}),e.invalidateQueries({queryKey:["mcp-tokens"]})},[e]),Gr=R.useCallback(async E=>{const Z={refresh:"/api/autoupdate/refresh",apply:"/api/autoupdate/apply",complete:"/api/autoupdate/complete-pending"}[E];k(E),D("");try{await ee(Z,{method:"POST"}),e.invalidateQueries({queryKey:["dashboard-status"]})}catch(ce){e.invalidateQueries({queryKey:["dashboard-status"]}),D(ce instanceof Error?ce.message:String(ce))}finally{k(null)}},[e]),Uc=R.useCallback(async E=>{B(!0),C("");try{const Z=await ee(`/api/executor/${E?"pause":"resume"}`,{method:"POST"});e.setQueryData(["dashboard-status"],ce=>ce&&{...ce,executor_pause:Z.executor_pause}),await e.invalidateQueries({queryKey:["dashboard-status"]})}catch(Z){C(Z instanceof Error?Z.message:String(Z))}finally{B(!1)}},[e]),Hc=R.useCallback(async E=>{O(!0),X("");try{await ee("/api/executor/resize",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workers:E})}),await Promise.all([e.invalidateQueries({queryKey:["dashboard-status"]}),e.invalidateQueries({queryKey:["processes"]})])}catch(Z){X(Z instanceof Error?Z.message:String(Z))}finally{O(!1)}},[e]),Kc=R.useCallback(async()=>{var Ua;const E=(Ua=yt.data)==null?void 0:Ua.public_key;if(!E)throw new Error("web_push_not_configured");if(!Lr())throw new Error("web_push_not_supported");if(await window.Notification.requestPermission()!=="granted")throw new Error("notification_permission_denied");const ce=await navigator.serviceWorker.register("/service-worker.js"),su=await ce.pushManager.getSubscription()??await ce.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:Rx(E)});await ee("/api/web-push/subscriptions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(su.toJSON())}),e.invalidateQueries({queryKey:["web-push-config"]})},[e,(Fi=yt.data)==null?void 0:Fi.public_key]),Qc=R.useCallback(async()=>{if(!Lr())return;const Z=await(await navigator.serviceWorker.ready).pushManager.getSubscription();if(!Z)return;const ce=Z.endpoint;await Z.unsubscribe(),await ee("/api/web-push/subscriptions",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({endpoint:ce})}),e.invalidateQueries({queryKey:["web-push-config"]})},[e]);R.useEffect(()=>{var E;!((E=yt.data)!=null&&E.status.enabled)||!Lr()||navigator.serviceWorker.register("/service-worker.js").catch(()=>{})},[(zi=yt.data)==null?void 0:zi.status.enabled]),R.useEffect(()=>{if(oe===null)return;const E=new EventSource(`/api/jobs/${oe}/session/stream`);return E.addEventListener("session_event",Z=>{const ce=Br(Z);ce&&(e.setQueryData(["job-session-events",oe],Pt=>({events:Ix((Pt==null?void 0:Pt.events)??[],ce)})),Ax(ce.event_type)&&(e.invalidateQueries({queryKey:["job",oe]}),e.invalidateQueries({queryKey:["jobs"]})))}),E.addEventListener("transcript_entry",Z=>{const ce=Br(Z);!ce||ce.job_id!==oe||e.setQueryData(["job-session-transcript",oe],Pt=>({entries:Tx((Pt==null?void 0:Pt.entries)??[],ce.entry)}))}),E.onerror=()=>{e.invalidateQueries({queryKey:["job",oe]}),e.invalidateQueries({queryKey:["job-session-events",oe]}),e.invalidateQueries({queryKey:["job-session-transcript",oe]})},()=>E.close()},[oe,e]),R.useEffect(()=>{const E=()=>{ps(window.location.pathname)&&b(Er()),ye(window.location.pathname)};return window.addEventListener("popstate",E),()=>window.removeEventListener("popstate",E)},[]),R.useEffect(()=>{if(!("serviceWorker"in navigator))return;const E=Z=>{if(!Ex(Z.data))return;const ce={...Z.data.payload,id:Date.now(),receivedAt:Date.now()};A(ce),ce.job_id&&(e.invalidateQueries({queryKey:["jobs"]}),e.invalidateQueries({queryKey:["job",ce.job_id]}),e.invalidateQueries({queryKey:["metrics"]}))};return navigator.serviceWorker.addEventListener("message",E),()=>navigator.serviceWorker.removeEventListener("message",E)},[e]),R.useEffect(()=>{if(!f)return;const E=window.setTimeout(()=>A(null),12e3);return()=>window.clearTimeout(E)},[f]);const Ii=R.useCallback(E=>{window.history.pushState({},"",Un(E)),ye(window.location.pathname)},[]),dt=R.useCallback(E=>{window.history.pushState({},"",E),ps(E)&&b(Er()),ye(window.location.pathname)},[]),Qt=((qi=ke.data)==null?void 0:qi.metrics.status_counts)??{},jr=((Bi=Qe.data)==null?void 0:Bi.jobs)??[],Wc=!!((Ui=($i=Ee.data)==null?void 0:$i.user)!=null&&Ui.is_admin&&Sc((Hi=Ne.data)==null?void 0:Hi.autoupdate)),Vc=R.useCallback(E=>{n(E),i(Ko),a.current=!1},[]);R.useEffect(()=>{Qe.isFetching||(a.current=!1)},[Qe.isFetching]);const Gc=R.useCallback(()=>{a.current||(a.current=!0,i(E=>E+dx))},[]),Ct=oe?((Ki=ut.data)==null?void 0:Ki.job)??null:null,Jc=jr.some(E=>E.status==="running"||E.status==="pending")||(Ct==null?void 0:Ct.status)==="running"||(Ct==null?void 0:Ct.status)==="pending"||!!((Qi=it.data)!=null&&Qi.running_jobs.length),Qn=gx(Jc),Xc=s.jsx(rg,{selectedJobId:oe,selectedJob:Ct,loading:ut.isLoading,error:ut.error,session:(Wi=Ie.data)==null?void 0:Wi.session,sessionEvents:(Vi=wt.data)==null?void 0:Vi.events,transcript:(Gi=Ye.data)==null?void 0:Gi.entries,now:Qn}),Yc=((Ji=L.data)==null?void 0:Ji.pages.flatMap(E=>E.hooks))??[],Zc=((Xi=K.data)==null?void 0:Xi.pages.flatMap(E=>E.deliveries))??[],vt=((Yi=De.data)==null?void 0:Yi.pages)??[],jt=vt[vt.length-1],eu=vt.length>0?{...vt[0],repositories:(jt==null?void 0:jt.repositories)??vt[0].repositories,summary:(jt==null?void 0:jt.summary)??vt[0].summary,proposals:vt.flatMap(E=>E.proposals),rules:vt.flatMap(E=>E.rules),events:vt.flatMap(E=>E.events),next_offset:(jt==null?void 0:jt.next_offset)??null}:void 0,tu=m==="overview"?Kn.isLoading:m==="hooks"?L.isLoading:K.isLoading,nu=m==="overview"?Kn.error:m==="hooks"?L.error:K.error,ru=()=>{mn.refetch(),m==="overview"&&S.refetch(),m==="overview"&&b(Er()),m==="hooks"&&L.refetch(),m==="deliveries"&&K.refetch()};return s.jsxs("div",{className:"min-h-screen bg-background text-foreground",children:[s.jsx("header",{className:"border-b border-slate-800 bg-slate-950 text-white",children:s.jsxs("div",{className:"mx-auto flex w-full max-w-[1440px] items-center justify-between gap-3 px-4 py-4 md:px-6",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("h1",{className:"truncate text-xl font-semibold",children:"GitHub Agent Bridge"}),s.jsx($x,{about:Vr.data})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[s.jsx(fg,{config:yt.data,loading:yt.isLoading,onEnable:Kc,onDisable:Qc}),s.jsx(mg,{user:(Zi=Ee.data)==null?void 0:Zi.user,loading:Ee.isLoading})]})]})}),s.jsxs("main",{className:"mx-auto grid w-full max-w-[1440px] gap-4 px-3 py-4 sm:px-4 md:px-6 md:py-5",children:[s.jsx(Vx,{isDashboardRoute:st,isSystemRoute:de,isKnowledgeRoute:Pe,isMcpRoute:He,isWebhooksRoute:lt,showWebhooks:!!((ta=(ea=Ee.data)==null?void 0:ea.user)!=null&&ta.is_admin&&((na=Ne.data)!=null&&na.webhook_configured)),knowledgeBadgeCount:((ia=(sa=(ra=Ne.data)==null?void 0:ra.metrics)==null?void 0:sa.knowledge)==null?void 0:ia.proposed)??0,systemUpdateAvailable:Wc,onNavigate:dt}),s.jsx(xg,{notification:f,onDismiss:()=>A(null),onNavigate:dt}),fe!==null?s.jsx(ng,{jobId:fe,detail:Xc,selectedJob:Ct,user:(aa=Ee.data)==null?void 0:aa.user,onBackToDashboard:()=>dt("/"),onRetry:Ci,onDismiss:Pi,onCancel:Ei,onRefresh:()=>{ut.refetch(),Ie.refetch(),wt.refetch(),Ye.refetch()}}):Pe?s.jsx(sg,{data:eu,loading:De.isLoading,error:De.error,repo:o,status:c,activeTab:d,user:(oa=Ee.data)==null?void 0:oa.user,now:Qn,onRepoChange:l,onStatusChange:u,onTabChange:h,onApprove:E=>Ri(E,"approve"),onReject:E=>Ri(E,"reject"),onUpdateRuleScope:zc,onDeleteRule:Fc,onRefresh:()=>De.refetch(),hasMore:!!De.hasNextPage,loadingMore:De.isFetchingNextPage,onLoadMore:()=>De.fetchNextPage()}):He?s.jsx(ug,{tokens:(la=Fe.data)==null?void 0:la.tokens,loading:Fe.isLoading,error:Fe.error,user:(ca=Ee.data)==null?void 0:ca.user,ownerOptions:((ua=Kt.data)==null?void 0:ua.users)??[],dashboardUrl:(da=Ne.data)==null?void 0:da.dashboard_url,dashboardUrlSource:(ha=Ne.data)==null?void 0:ha.dashboard_url_source,now:Qn,onCreate:qc,onUpdateOwner:Bc,onRevoke:$c,onRefresh:()=>Fe.refetch()}):lt?Ke?s.jsx(Zx,{data:Re.data,loading:Re.isLoading,error:Re.error,onBack:()=>{p("deliveries"),dt("/webhooks")},onRefresh:()=>Re.refetch(),onViewHook:E=>dt(`/webhooks/hooks/${encodeURIComponent(E)}`),onViewJob:Ii}):Me?s.jsx(Yx,{data:G.data,loading:G.isLoading,error:G.error,onBack:()=>{p("hooks"),dt("/webhooks")},onRefresh:()=>G.refetch(),onViewHook:E=>dt(`/webhooks/hooks/${encodeURIComponent(E)}`),onViewDelivery:E=>dt(`/webhooks/deliveries/${encodeURIComponent(E)}`),onPing:le}):s.jsx(Gx,{summary:mn.data,timeseries:(pa=Kn.data)==null?void 0:pa.points,exceptions:(ma=S.data)==null?void 0:ma.exceptions,hooks:Yc,deliveries:Zc,section:m,summaryLoading:mn.isLoading,sectionLoading:tu,loadingMore:m==="hooks"?L.isFetchingNextPage:K.isFetchingNextPage,hasMore:m==="hooks"?L.hasNextPage:K.hasNextPage,deliveryFilters:w,error:mn.error??nu,onSectionChange:p,onLoadMore:()=>m==="hooks"?L.fetchNextPage():K.fetchNextPage(),onDeliveryFiltersChange:y,onViewHook:E=>dt(`/webhooks/hooks/${encodeURIComponent(E)}`),onViewDelivery:E=>dt(`/webhooks/deliveries/${encodeURIComponent(E)}`),onRefresh:ru}):de?s.jsxs(s.Fragment,{children:[s.jsx(Ux,{state:(fa=Ne.data)==null?void 0:fa.autoupdate,isAdmin:!!((ga=(xa=Ee.data)==null?void 0:xa.user)!=null&&ga.is_admin),runningAction:N,actionError:_,onRefresh:()=>Gr("refresh"),onApply:()=>Gr("apply"),onCompletePending:()=>Gr("complete")}),s.jsx(eg,{executorPause:(ba=Ne.data)==null?void 0:ba.executor_pause,executorPauseLoading:Ne.isLoading,executorPauseStatusError:Ne.error,executorPausePending:j,executorPauseError:F,executorCapacity:{desired:((ya=it.data)==null?void 0:ya.executor.expected_workers)??((va=(wa=Ne.data)==null?void 0:wa.metrics)==null?void 0:va.executor_worker_count)??0,live:((ja=it.data)==null?void 0:ja.executor.live_workers)??((Na=(ka=Ne.data)==null?void 0:ka.metrics)==null?void 0:Na.executor_worker_live_count)??0,busy:((Sa=it.data)==null?void 0:Sa.executor.busy_workers)??((Ca=(_a=Ne.data)==null?void 0:_a.metrics)==null?void 0:Ca.executor_worker_busy_count)??0,draining:((Pa=it.data)==null?void 0:Pa.executor.draining_workers)??((Ra=(Ea=Ne.data)==null?void 0:Ea.metrics)==null?void 0:Ra.executor_worker_draining_count)??0},executorResizePending:M,executorResizeError:I,isAdmin:!!((Ta=(Ia=Ee.data)==null?void 0:Ia.user)!=null&&Ta.is_admin),onExecutorPauseChange:Uc,onExecutorResize:Hc,processes:it.data,processesLoading:it.isLoading,processesError:it.error,systemd:hn.data,systemdLoading:hn.isLoading,systemdError:hn.error,alerts:(Aa=pn.data)==null?void 0:Aa.alerts,alertsLoading:pn.isLoading,alertsError:pn.error,sloSummary:(La=ke.data)==null?void 0:La.metrics,sloLoading:ke.isLoading,sloError:ke.error,sloWindow:q,now:Qn,onRefreshProcesses:()=>it.refetch(),onRefreshSystemd:()=>hn.refetch(),onRefreshAlerts:()=>pn.refetch(),onSloWindowChange:P,onRefreshSlo:()=>ke.refetch()})]}):s.jsxs(s.Fragment,{children:[ke.error?s.jsx(be,{tone:"error",text:ke.error.message}):null,Ne.error?s.jsx(be,{tone:"error",text:Ne.error.message}):null,s.jsxs("section",{className:"grid grid-cols-2 gap-3 xl:grid-cols-4","aria-label":"Summary metrics",children:[s.jsx(Ae,{title:"Pending",value:Qt.pending??0,icon:s.jsx(Rl,{className:"h-5 w-5"})}),s.jsx(Ae,{title:"Running",value:Qt.running??0,icon:s.jsx(an,{className:"h-5 w-5"})}),s.jsx(Ae,{title:"Blocked",value:Qt.blocked??0,icon:s.jsx(Hr,{className:"h-5 w-5"})}),s.jsx(Ae,{title:"Done",value:Qt.done??0,icon:s.jsx(On,{className:"h-5 w-5"})})]}),s.jsxs("section",{className:"grid gap-3",children:[s.jsx(gg,{count:jr.length,limit:r,loading:Qe.isLoading,onRefresh:()=>Qe.refetch()}),s.jsxs(se,{title:"Recent jobs",flushHeader:!0,children:[s.jsx(kg,{filters:t,actorOptions:((Ma=vr.data)==null?void 0:Ma.actors)??[],onChange:Vc}),Qe.error?s.jsx(be,{tone:"error",text:Qe.error.message}):null,s.jsx(Sg,{jobs:jr,loading:Qe.isLoading,loadingMore:Qe.isFetching&&!Qe.isLoading,hasMore:jr.length>=r,onLoadMore:Gc,onViewJob:Ii,now:Qn,user:(Da=Ee.data)==null?void 0:Da.user,onRetry:Ci,onDismiss:Pi,onCancel:Ei})]}),s.jsx(se,{title:"Runtime & jobs",action:s.jsx(nt,{onClick:()=>ke.refetch()}),children:s.jsx(Og,{usage:(Oa=ke.data)==null?void 0:Oa.metrics.runtime_usage,jobsByCreatedDay:(Fa=ke.data)==null?void 0:Fa.metrics.by_created_day,loading:ke.isLoading,totalJobs:gs(Qt)})}),s.jsx(se,{title:"Runtime by user",children:s.jsx(Bg,{usage:(za=ke.data)==null?void 0:za.metrics.runtime_usage_by_actor,loading:ke.isLoading,totalJobs:gs(Qt),window:U,onWindowChange:te})}),s.jsx(se,{title:"Runtime by repository",children:s.jsx($g,{usage:(qa=ke.data)==null?void 0:qa.metrics.runtime_usage_by_repo,loading:ke.isLoading,totalJobs:gs(Qt),window:U,onWindowChange:te})})]}),s.jsxs("section",{className:"grid gap-4 xl:grid-cols-2",children:[s.jsx(se,{title:"Runtime percentiles",children:s.jsx(Xo,{label:"runtime",values:(Ba=ke.data)==null?void 0:Ba.metrics.runtime_seconds})}),s.jsx(se,{title:"Queue wait percentiles",children:s.jsx(Xo,{label:"queue wait",values:($a=ke.data)==null?void 0:$a.metrics.queue_wait_seconds})})]})]})]})]})}function $x({about:e}){const t=e!=null&&e.version?`v${e.version}`:"version loading";return s.jsxs("p",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-slate-300",children:[s.jsx("span",{children:"Operational dashboard"}),s.jsx("span",{className:"font-mono text-xs text-slate-400",children:t}),e!=null&&e.repository_url?s.jsxs("a",{className:"inline-flex items-center gap-1 text-xs font-semibold text-slate-200 hover:underline",href:rt(e.repository_url),rel:"noreferrer",target:"_blank",children:[s.jsx(on,{className:"h-3.5 w-3.5","aria-hidden":!0}),"GitHub"]}):null]})}function Sc(e){var t,n;return!!((n=(t=e==null?void 0:e.target)==null?void 0:t.tag_name)!=null&&n.trim()&&e.decision!=="noop")}function Ux({state:e,isAdmin:t,runningAction:n=null,actionError:r="",onRefresh:i,onApply:a,onCompletePending:o}){var v,b,N,k,_,D,j,B,F,C,M;if(!e||!Sc(e))return null;const l=(b=(v=e==null?void 0:e.target)==null?void 0:v.tag_name)==null?void 0:b.trim();if(!t||!l)return null;const c=Hx(e.decision),u=((N=e.queue)==null?void 0:N.active_total)??0,d=Kx((k=e.classification)==null?void 0:k.risk),h=Qx((_=e.target)==null?void 0:_.body),m=((j=(D=e.classification)==null?void 0:D.migration_files)==null?void 0:j.length)??0,p=((F=(B=e.classification)==null?void 0:B.risky_files)==null?void 0:F.length)??0,w=!!(e.executor_reload_pending&&e.dashboard_applied_at&&o),y=!!(a&&(m===0||u===0));return s.jsxs("section",{className:"rounded-md border border-amber-300 bg-amber-50 p-3 text-amber-950 shadow-sm","aria-label":"Update available",children:[s.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-start lg:justify-between",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(Hr,{className:"h-4 w-4 text-amber-700","aria-hidden":!0}),s.jsx("h2",{className:"text-sm font-semibold",children:"Update available"}),s.jsx("span",{className:"rounded-sm border border-amber-300 bg-white px-1.5 py-0.5 font-mono text-[11px] text-amber-800",children:l}),(C=e.target)!=null&&C.url?s.jsxs("a",{className:"inline-flex items-center gap-1 text-xs font-semibold text-amber-800 hover:underline",href:rt(e.target.url),rel:"noreferrer",target:"_blank",children:[s.jsx(on,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Release"]}):null]}),s.jsxs("p",{className:"mt-1 text-sm text-amber-900",children:[c,e.installed_tag?s.jsxs("span",{className:"font-mono",children:[" from ",e.installed_tag]}):null]}),s.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[i?s.jsxs("button",{className:"inline-flex h-8 items-center justify-center gap-1.5 rounded-md border border-amber-300 bg-white px-2.5 text-xs font-semibold text-amber-900 hover:bg-amber-100 disabled:cursor-not-allowed disabled:opacity-60",type:"button",disabled:n!==null,onClick:i,children:[s.jsx(zn,{className:Q("h-3.5 w-3.5",n==="refresh"&&"animate-spin"),"aria-hidden":!0}),n==="refresh"?"Checking...":"Check now"]}):null,y?s.jsxs("button",{className:"inline-flex h-8 items-center justify-center gap-1.5 rounded-md bg-amber-800 px-2.5 text-xs font-semibold text-white hover:bg-amber-900 disabled:cursor-not-allowed disabled:opacity-60",type:"button",disabled:n!==null,onClick:()=>{window.confirm(`Apply ${l}? This can restart bridge services according to the recorded safe plan.`)&&(a==null||a())},children:[s.jsx(On,{className:"h-3.5 w-3.5","aria-hidden":!0}),n==="apply"?"Applying...":"Apply update"]}):null,w?s.jsxs("button",{className:"inline-flex h-8 items-center justify-center gap-1.5 rounded-md border border-amber-300 bg-white px-2.5 text-xs font-semibold text-amber-900 hover:bg-amber-100 disabled:cursor-not-allowed disabled:opacity-60",type:"button",disabled:n!==null,onClick:o,children:[s.jsx(cr,{className:"h-3.5 w-3.5","aria-hidden":!0}),n==="complete"?"Completing...":"Complete reload"]}):null]})]}),s.jsxs("div",{className:"grid gap-2 text-xs sm:grid-cols-3 lg:min-w-[420px]",children:[s.jsx(ms,{label:"Impact",value:d}),s.jsx(ms,{label:"Active jobs",value:String(u)}),s.jsx(ms,{label:"Admin only",value:"autoupdate"})]})]}),e.blocked_reason||e.executor_reload_pending||m>0||p>0?s.jsxs("div",{className:"mt-3 flex flex-wrap gap-2 text-xs",children:[e.executor_reload_pending?s.jsx("span",{className:"rounded-sm border border-amber-300 bg-white px-2 py-1 font-semibold",children:"executor reload pending"}):null,e.blocked_reason?s.jsx("span",{className:"rounded-sm border border-amber-300 bg-white px-2 py-1 font-mono",children:e.blocked_reason}):null,m>0?s.jsxs("span",{className:"rounded-sm border border-amber-300 bg-white px-2 py-1",children:[m," migration file",m===1?"":"s"]}):null,p>0?s.jsxs("span",{className:"rounded-sm border border-amber-300 bg-white px-2 py-1",children:[p," executor/shared file",p===1?"":"s"]}):null]}):null,h?s.jsxs("div",{className:"mt-3 rounded-md border border-amber-200 bg-white/70 p-2.5",children:[s.jsx("div",{className:"text-[11px] font-semibold uppercase text-amber-800",children:"Changelog preview"}),s.jsx(Wx,{markdown:h})]}):null,(M=e.warnings)!=null&&M.length?s.jsx("div",{className:"mt-2 font-mono text-xs text-amber-800",children:e.warnings[0]}):null,r?s.jsxs("div",{className:"mt-2 rounded-sm border border-amber-300 bg-white px-2 py-1 font-mono text-xs text-amber-900",children:["Action failed: ",r]}):null]})}function ms({label:e,value:t}){return s.jsxs("div",{className:"min-w-0 rounded-md border border-amber-200 bg-white/80 px-2 py-1.5",children:[s.jsx("div",{className:"text-[11px] font-semibold uppercase text-amber-700",children:e}),s.jsx("div",{className:"mt-0.5 truncate font-mono text-xs text-amber-950",children:t})]})}function Hx(e){return{stage_dashboard_reload:"Dashboard reload can be staged now",stage_defer_executor_reload:"Dashboard reload can be staged; executor reload waits for the queue",stage_full_reload:"Full reload can be staged now",defer_migration:"Migration release is waiting for a quiet queue"}[e??""]??"Update plan recorded"}function Kx(e){return{dashboard_only:"dashboard only",executor_or_queue:"executor or queue",executor_or_shared:"executor or shared",migration_required:"migration",none:"none"}[e??""]??"unknown"}function Qx(e){return(e??"").trim()}function Wx({markdown:e}){return s.jsx("div",{className:"mt-1 text-sm leading-relaxed text-amber-950",children:s.jsx(Cf,{allowedElements:["a","blockquote","code","em","h1","h2","h3","h4","li","ol","p","strong","ul"],components:{a:({href:t,children:n})=>s.jsx("a",{className:"font-semibold text-amber-800 underline underline-offset-2",href:rt(t??""),rel:"noreferrer",target:"_blank",children:n}),blockquote:({children:t})=>s.jsx("blockquote",{className:"mt-2 border-l-2 border-amber-300 pl-2 text-amber-900",children:t}),code:({children:t})=>s.jsx("code",{className:"rounded-sm bg-amber-100 px-1 py-0.5 font-mono text-[0.85em] text-amber-950",children:t}),h1:({children:t})=>s.jsx("h3",{className:"mt-2 text-sm font-semibold text-amber-950 first:mt-0",children:t}),h2:({children:t})=>s.jsx("h3",{className:"mt-2 text-sm font-semibold text-amber-950 first:mt-0",children:t}),h3:({children:t})=>s.jsx("h3",{className:"mt-2 text-sm font-semibold text-amber-950 first:mt-0",children:t}),h4:({children:t})=>s.jsx("h4",{className:"mt-2 text-xs font-semibold uppercase text-amber-800 first:mt-0",children:t}),li:({children:t})=>s.jsx("li",{className:"break-words pl-0.5 [overflow-wrap:anywhere]",children:t}),ol:({children:t})=>s.jsx("ol",{className:"mt-1 list-decimal space-y-1 pl-5 first:mt-0",children:t}),p:({children:t})=>s.jsx("p",{className:"mt-1 break-words [overflow-wrap:anywhere] first:mt-0",children:t}),strong:({children:t})=>s.jsx("strong",{className:"font-semibold",children:t}),em:({children:t})=>s.jsx("em",{className:"italic",children:t}),ul:({children:t})=>s.jsx("ul",{className:"mt-1 list-disc space-y-1 pl-5 first:mt-0",children:t})},children:e})})}function Vx({isDashboardRoute:e,isSystemRoute:t=!1,isKnowledgeRoute:n,isMcpRoute:r=!1,isWebhooksRoute:i=!1,showWebhooks:a=!1,knowledgeBadgeCount:o=0,systemUpdateAvailable:l=!1,onNavigate:c}){return s.jsxs("nav",{className:"flex min-w-0 rounded-lg border border-border bg-panel p-1 shadow-sm","aria-label":"Dashboard sections",children:[s.jsxs(er,{href:"/",active:e,onNavigate:c,children:[s.jsx(Al,{className:"h-4 w-4","aria-hidden":!0}),s.jsx("span",{children:"Jobs"})]}),s.jsxs(er,{href:"/system",active:t,onNavigate:c,children:[s.jsx(id,{className:"h-4 w-4","aria-hidden":!0}),s.jsx("span",{children:"System"}),l?s.jsx("span",{className:Q("inline-flex h-5 min-w-5 items-center justify-center rounded-full border px-1 font-mono text-[11px] leading-none",t?"border-white/40 bg-white/15 text-white":"border-amber-200 bg-amber-100 text-amber-800"),"aria-label":"System update available",children:"!"}):null]}),a?s.jsxs(er,{href:"/webhooks",active:i,onNavigate:c,children:[s.jsx(an,{className:"h-4 w-4","aria-hidden":!0}),s.jsx("span",{children:"Webhooks"})]}):null,s.jsxs(er,{href:"/knowledge",active:n,onNavigate:c,children:[s.jsx(oi,{className:"h-4 w-4","aria-hidden":!0}),s.jsx("span",{children:"Knowledge"}),o>0?s.jsx("span",{className:Q("inline-flex h-5 min-w-5 items-center justify-center rounded-full border px-1 font-mono text-[11px] leading-none",n?"border-white/40 bg-white/15 text-white":"border-amber-200 bg-amber-100 text-amber-800"),"aria-label":`${o} proposed knowledge ${o===1?"item":"items"}`,children:o}):null]}),s.jsxs(er,{href:"/mcp",active:r,onNavigate:c,children:[s.jsx(Dr,{className:"h-4 w-4","aria-hidden":!0}),s.jsx("span",{children:"MCP"})]})]})}function gn({text:e}){return s.jsxs("div",{className:"flex items-center justify-center gap-2 py-10 text-sm text-muted",children:[s.jsx(zn,{className:"h-4 w-4 animate-spin","aria-hidden":!0}),e]})}function Gx({summary:e,timeseries:t,exceptions:n,hooks:r,deliveries:i,section:a,summaryLoading:o,sectionLoading:l,loadingMore:c,hasMore:u,deliveryFilters:d,error:h,onSectionChange:m,onLoadMore:p,onDeliveryFiltersChange:w,onViewHook:y,onViewDelivery:v=()=>{},onRefresh:b}){var B,F,C,M,O,I,X,q,P,U,te,me,ye,f;const N=Object.values((e==null?void 0:e.receipts)??{}).reduce((A,fe)=>A+fe,0),k=((B=e==null?void 0:e.coverage)==null?void 0:B.promotion_state)??((F=e==null?void 0:e.coverage)!=null&&F.promotion_ready?"ready":"blocked"),_=k==="insufficient_data"?"insufficient data":k,D=(e==null?void 0:e.mode)==="primary"?"Primary eligibility scope":(e==null?void 0:e.mode)==="canary"?"Canary rollout cohort":"Shadow rollout cohort",j=[{id:"overview",label:"Overview"},{id:"hooks",label:"Hooks",count:(C=e==null?void 0:e.totals)==null?void 0:C.hooks},{id:"deliveries",label:"Deliveries",count:(M=e==null?void 0:e.totals)==null?void 0:M.deliveries}];return s.jsxs("section",{className:"grid gap-4",children:[s.jsx(Cc,{icon:s.jsx(an,{className:"h-5 w-5 text-muted","aria-hidden":!0}),title:"GitHub webhooks",subtitle:(e==null?void 0:e.mode)==="primary"?"Primary webhook ingestion. IMAP remains active as an idempotent safety net.":(e==null?void 0:e.mode)==="canary"?"Canary ingestion health. Only the webhook canary allowlist may create jobs.":"Shadow ingestion health. Deliveries are observed but do not create jobs.",action:s.jsx(nt,{onClick:b})}),h?s.jsx(be,{tone:"error",text:h.message}):null,s.jsx("div",{className:"flex max-w-full flex-wrap rounded-md border border-border bg-white p-1",role:"tablist","aria-label":"Webhook dashboard section",children:j.map(A=>s.jsxs("button",{type:"button",role:"tab","aria-label":A.count===void 0?A.label:`${A.label} (${A.count} total)`,"aria-selected":a===A.id,className:Q("inline-flex h-8 items-center gap-2 rounded px-3 text-sm font-semibold",a===A.id?"bg-primary text-white":"text-muted hover:bg-slate-50 hover:text-foreground"),onClick:()=>m(A.id),children:[A.label,A.count!==void 0?s.jsx("span",{className:"rounded border border-current/30 px-1 font-mono text-[10px]",children:A.count}):null]},A.id))}),s.jsxs("div",{className:"grid grid-cols-2 gap-3 xl:grid-cols-4","aria-label":"Webhook status",children:[s.jsx(Ae,{title:"Receipts",value:N,icon:s.jsx(an,{className:"h-5 w-5"})}),s.jsx(Ae,{title:"Duplicates",value:(e==null?void 0:e.duplicate_deliveries)??0,icon:s.jsx(zn,{className:"h-5 w-5"})}),s.jsx(Ae,{title:"Cross-source matches",value:(e==null?void 0:e.cross_source_matches)??0,icon:s.jsx(Fn,{className:"h-5 w-5"})}),s.jsx(Ae,{title:"Mode",value:o?"โ€ฆ":(e==null?void 0:e.mode)??"unknown",icon:s.jsx(Il,{className:"h-5 w-5"})})]}),a==="overview"?s.jsxs(s.Fragment,{children:[s.jsx(se,{title:"Delivery activity",children:l?s.jsx(gn,{text:"Loading delivery activityโ€ฆ"}):t!=null&&t.length?s.jsx("div",{className:"h-72","aria-label":"Webhook deliveries over time",children:s.jsx(ln,{width:"100%",height:"100%",children:s.jsxs(ei,{data:t,children:[s.jsx(Ln,{strokeDasharray:"3 3"}),s.jsx(Mn,{dataKey:"bucket"}),s.jsx(sn,{allowDecimals:!1}),s.jsx(cn,{}),s.jsx(Ur,{}),s.jsx(Bt,{dataKey:"observed",stackId:"deliveries",fill:"#2563eb"}),s.jsx(Bt,{dataKey:"duplicate",stackId:"deliveries",fill:"#f59e0b"}),s.jsx(Bt,{dataKey:"unsupported",stackId:"deliveries",fill:"#94a3b8"})]})})}):s.jsx(J,{text:"No webhook activity in the selected 30-day window."})}),s.jsx(se,{title:"Receipt states",children:o?s.jsx(gn,{text:"Loading webhook summaryโ€ฆ"}):Object.keys((e==null?void 0:e.receipts)??{}).length?s.jsx("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:Object.entries((e==null?void 0:e.receipts)??{}).sort(([A],[fe])=>A.localeCompare(fe)).map(([A,fe])=>s.jsx($,{label:A,value:fe},A))}):s.jsx(J,{text:"No webhook deliveries observed yet."})}),s.jsxs(se,{title:"Cross-source coverage",children:[s.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-4",children:[s.jsx($,{label:"Both sources",value:((O=e==null?void 0:e.coverage)==null?void 0:O.both)??0}),s.jsx($,{label:"IMAP only",value:((I=e==null?void 0:e.coverage)==null?void 0:I.imap_only)??0}),s.jsx($,{label:"Webhook only",value:((X=e==null?void 0:e.coverage)==null?void 0:X.webhook_only)??0}),s.jsx($,{label:"Coverage",value:((q=e==null?void 0:e.coverage)==null?void 0:q.ratio)==null?"not measurable":`${Math.round(e.coverage.ratio*100)}%`}),s.jsx($,{label:"Decision mismatches",value:((P=e==null?void 0:e.coverage)==null?void 0:P.decision_mismatches)??0}),s.jsx($,{label:"Incomplete decision traces",value:((U=e==null?void 0:e.coverage)==null?void 0:U.incomplete_decision_traces)??0}),s.jsx($,{label:"Split identities",value:((te=e==null?void 0:e.coverage)==null?void 0:te.split_identities)??0}),s.jsx($,{label:"Promotion gate",value:_}),s.jsx($,{label:"Outside scope IMAP",value:((me=e==null?void 0:e.coverage)==null?void 0:me.outside_scope_imap_eligible)??0}),s.jsx($,{label:"Outside scope webhook",value:((ye=e==null?void 0:e.coverage)==null?void 0:ye.outside_scope_webhook_eligible)??0})]}),(f=e==null?void 0:e.coverage)!=null&&f.window_start&&e.coverage.window_end?s.jsxs("p",{className:"mt-3 font-mono text-xs text-muted",children:["Actionable IMAP events and comparable webhook events from ",s.jsx(ue,{value:e.coverage.window_start})," to ",s.jsx(ue,{value:e.coverage.window_end}),"; ",e.coverage.observation_days??7," observation days required and newest ",e.coverage.grace_seconds??0,"s excluded. ",D,": ",e.coverage.scope_repositories==null?"all repositories":`${e.coverage.scope_repositories.length} configured repositories`,e.coverage.observation_started_at?s.jsxs(s.Fragment,{children:["; observation epoch ",s.jsx(ue,{value:e.coverage.observation_started_at})]}):null,"."]}):null]}),Object.keys((e==null?void 0:e.enqueue)??{}).length?s.jsx(se,{title:"Canary ingestion decisions",children:s.jsx("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-4",children:Object.entries((e==null?void 0:e.enqueue)??{}).sort(([A],[fe])=>A.localeCompare(fe)).map(([A,fe])=>s.jsx($,{label:A,value:fe},A))})}):null,s.jsx(se,{title:"Exceptions requiring review",children:n!=null&&n.length?s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full min-w-[840px] text-left text-sm",children:[s.jsx("thead",{className:"border-b border-border text-xs text-muted",children:s.jsxs("tr",{children:[s.jsx("th",{className:"px-3 py-2",children:"Type"}),s.jsx("th",{className:"px-3 py-2",children:"Repository"}),s.jsx("th",{className:"px-3 py-2",children:"Event"}),s.jsx("th",{className:"px-3 py-2",children:"References"}),s.jsx("th",{className:"px-3 py-2",children:"Observed"})]})}),s.jsx("tbody",{children:n.map(A=>s.jsxs("tr",{className:"border-b border-border/70 last:border-0",children:[s.jsx("td",{className:"px-3 py-2 font-semibold",children:A.kind}),s.jsx("td",{className:"px-3 py-2 font-mono text-xs",children:A.repository??"unknown"}),s.jsx("td",{className:"px-3 py-2 font-mono text-xs",children:A.event_type?`${A.event_type}${A.event_action?`:${A.event_action}`:""}`:"unknown"}),s.jsxs("td",{className:"px-3 py-2 font-mono text-xs",children:[s.jsx("div",{children:A.reference}),A.related_reference?s.jsx("div",{children:A.related_reference}):null,A.event_key?s.jsxs("div",{className:"text-muted",children:[A.event_key,A.related_event_key?` โ†” ${A.related_event_key}`:""]}):null]}),s.jsx("td",{className:"px-3 py-2 font-mono text-xs text-muted",children:s.jsx(ue,{value:A.created_at,compact:!0})})]},`${A.kind}:${A.reference}:${A.related_reference??""}`))})]})}):s.jsx(J,{text:"No cross-source exceptions in retained data."})})]}):null,a==="hooks"?s.jsx(se,{title:"Hook inventory",children:l?s.jsx(gn,{text:"Loading hook inventoryโ€ฆ"}):r!=null&&r.length?s.jsx(Xs,{noun:"hooks",hasMore:u,loading:c,onLoadMore:p,children:s.jsxs("table",{className:"w-full min-w-[920px] text-left text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"sticky top-0 z-10 border-b border-border bg-panel text-left text-xs text-muted",children:[s.jsx("th",{className:"px-3 py-2",children:"Target"}),s.jsx("th",{className:"px-3 py-2",children:"State"}),s.jsx("th",{className:"px-3 py-2",children:"Configuration"}),s.jsx("th",{className:"px-3 py-2",children:"Last delivery"}),s.jsx("th",{className:"px-3 py-2",children:"Last ping"})]})}),s.jsx("tbody",{children:r.map(A=>s.jsxs("tr",{className:"cursor-pointer border-b border-border/70 last:border-0 hover:bg-slate-50",onClick:()=>y(A.id),children:[s.jsxs("td",{className:"px-3 py-3",children:[s.jsx("button",{type:"button",className:"text-left font-semibold text-primary hover:underline",onClick:fe=>{fe.stopPropagation(),y(A.id)},children:A.target}),s.jsxs("div",{className:"font-mono text-xs text-muted",children:[A.target_type," ยท #",A.id]})]}),s.jsx("td",{className:"px-3 py-3",children:s.jsx("span",{className:Q("rounded border px-2 py-1 text-xs font-semibold",A.status==="receiving"?"border-emerald-200 bg-emerald-50 text-emerald-700":A.status==="inactive"?"border-red-200 bg-red-50 text-red-700":"border-slate-200 bg-slate-50 text-slate-600"),children:A.status})}),s.jsxs("td",{className:"max-w-sm px-3 py-3 text-xs",children:[s.jsx("div",{children:A.events.join(", ")||"No event snapshot"}),s.jsxs("div",{className:"mt-1 font-mono text-muted",children:[A.content_type??"content type unknown"," ยท SSL ",A.ssl_verify===null||A.ssl_verify===void 0?"unknown":A.ssl_verify?"verified":"disabled"]})]}),s.jsxs("td",{className:"px-3 py-3 text-xs",children:[s.jsxs("div",{className:"font-semibold",children:[A.last_event_name??"Never",A.last_action?` ยท ${A.last_action}`:""]}),s.jsxs("div",{className:"mt-1 font-mono text-muted",children:[A.last_repository??"No repository",A.last_event_at?s.jsxs(s.Fragment,{children:[" ยท ",s.jsx(ue,{value:A.last_event_at,compact:!0})]}):null]})]}),s.jsx("td",{className:"px-3 py-3 font-mono text-xs text-muted",children:A.last_ping_at?s.jsx(ue,{value:A.last_ping_at,compact:!0}):"Never"})]},A.id))})]})}):s.jsx(J,{text:"No hook inventory is available. Redeliver a signed ping from GitHub to create the sanitized configuration snapshot."})}):null,a==="deliveries"?s.jsxs(se,{title:"Recent deliveries",children:[s.jsx(Jx,{filters:d,onChange:w}),l?s.jsx(gn,{text:"Loading deliveriesโ€ฆ"}):i!=null&&i.length?s.jsx(Xs,{noun:"deliveries",hasMore:u,loading:c,onLoadMore:p,children:s.jsx(_c,{deliveries:i,onViewHook:y,onViewDelivery:v})}):s.jsx(J,{text:"No deliveries match the current filters."})]}):null]})}function Jx({filters:e,onChange:t}){const n=[{key:"hook_id",label:"Hook ID",placeholder:"690954530"},{key:"event_name",label:"Event",placeholder:"issue_comment"},{key:"repository",label:"Repository",placeholder:"gisce/repository"},{key:"result",label:"Result",placeholder:"observed"},{key:"enqueue_status",label:"Ingestion",placeholder:"enqueued"}];return s.jsx("div",{className:"grid gap-2 border-b border-border p-3 sm:grid-cols-2 xl:grid-cols-5",children:n.map(r=>s.jsxs("label",{className:"grid gap-1 text-xs font-semibold text-muted",children:[r.label,s.jsx("input",{className:"h-9 rounded-md border border-border bg-white px-2 font-mono text-xs text-foreground",value:e[r.key],placeholder:r.placeholder,onChange:i=>t({...e,[r.key]:i.target.value})})]},r.key))})}function _c({deliveries:e,onViewHook:t,onViewDelivery:n=()=>{}}){return s.jsxs("table",{className:"w-full min-w-[1120px] text-left text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"sticky top-0 z-10 border-b border-border bg-panel text-left text-xs text-muted",children:[s.jsx("th",{className:"px-3 py-2",children:"Received"}),s.jsx("th",{className:"px-3 py-2",children:"Hook"}),s.jsx("th",{className:"px-3 py-2",children:"Event"}),s.jsx("th",{className:"px-3 py-2",children:"Repository"}),s.jsx("th",{className:"px-3 py-2",children:"Result"}),s.jsx("th",{className:"px-3 py-2",children:"Ingestion"}),s.jsx("th",{className:"px-3 py-2",children:"Delivery"})]})}),s.jsx("tbody",{children:e.map(r=>{var i;return s.jsxs("tr",{className:"border-b border-border/70 last:border-0 hover:bg-slate-50",children:[s.jsx("td",{className:"px-3 py-3 font-mono text-xs text-muted",children:s.jsx(ue,{value:r.created_at,compact:!0})}),s.jsx("td",{className:"px-3 py-3",children:r.hook_id?s.jsxs("button",{type:"button",className:"text-left text-primary hover:underline",onClick:()=>t(r.hook_id),children:[s.jsx("span",{className:"block font-semibold",children:((i=r.hook)==null?void 0:i.target)??`Hook #${r.hook_id}`}),s.jsxs("span",{className:"font-mono text-xs",children:["#",r.hook_id]})]}):s.jsx("span",{className:"text-xs text-muted",children:"Unknown (legacy)"})}),s.jsxs("td",{className:"px-3 py-3 font-semibold",children:[r.event_name,r.action?` ยท ${r.action}`:""]}),s.jsx("td",{className:"px-3 py-3",children:r.repository??"โ€”"}),s.jsxs("td",{className:"px-3 py-3",children:[s.jsx("span",{className:"rounded border border-border bg-slate-50 px-2 py-1 text-xs font-semibold",children:r.status}),r.duplicate_count?s.jsxs("span",{className:"ml-2 font-mono text-xs text-muted",children:[r.duplicate_count," retries"]}):null]}),s.jsx("td",{className:"px-3 py-3",children:r.enqueue_status?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"rounded border border-border bg-slate-50 px-2 py-1 text-xs font-semibold",children:r.enqueue_status}),r.job_id?s.jsxs("a",{className:"ml-2 font-mono text-xs font-semibold text-primary hover:underline",href:`/jobs/${r.job_id}`,children:["Job #",r.job_id]}):null]}):s.jsx("span",{className:"text-xs text-muted",children:"shadow"})}),s.jsx("td",{className:"max-w-[14rem] px-3 py-3",children:s.jsx("button",{type:"button",className:"block max-w-full truncate font-mono text-xs font-semibold text-primary hover:underline",title:r.delivery_id,onClick:()=>n(r.delivery_id),children:r.delivery_id})})]},r.delivery_id)})})]})}function Xs({noun:e,hasMore:t,loading:n,onLoadMore:r,children:i,className:a}){return s.jsxs("div",{"data-testid":`lazy-scroll-${e}`,className:Q("max-h-[640px] overflow-auto rounded-md border border-border",a),children:[i,s.jsx(Xx,{noun:e,hasMore:t,loading:n,onLoadMore:r})]})}function Xx({noun:e,hasMore:t,loading:n,onLoadMore:r}){const i=R.useRef(null),a=R.useRef(!1);return R.useEffect(()=>{n||(a.current=!1)},[n]),R.useEffect(()=>{const o=i.current;if(!o||!t||n||!r)return;const l=()=>{a.current||(a.current=!0,r())};if(!("IntersectionObserver"in window)){l();return}const c=new IntersectionObserver(u=>{u.some(d=>d.isIntersecting)&&l()},{rootMargin:"240px 0px"});return c.observe(o),()=>c.disconnect()},[t,n,e,r]),!t&&!n?null:s.jsx("div",{ref:i,className:"flex min-h-10 items-center justify-center border-t border-border px-3 py-2 text-xs font-medium text-muted","aria-live":"polite",children:n?`Loading more ${e}...`:`Scroll for more ${e}`})}function Yx({data:e,loading:t,error:n,onBack:r,onRefresh:i,onViewHook:a,onViewDelivery:o=()=>{},onPing:l}){const[c,u]=R.useState(!1),[d,h]=R.useState(""),[m,p]=R.useState("");if(t)return s.jsx(gn,{text:"Loading hook detailโ€ฆ"});if(n)return s.jsxs("div",{className:"grid gap-3",children:[s.jsx(be,{tone:"error",text:n.message}),s.jsx("button",{type:"button",className:"w-fit rounded border border-border px-3 py-2 text-sm font-semibold",onClick:r,children:"Back to hooks"})]});if(!e)return s.jsx(J,{text:"Hook detail is not available."});const w=e.hook,y={...w,github_created_at:w.github_created_at?s.jsx(ue,{value:w.github_created_at}):"unknown",github_updated_at:w.github_updated_at?s.jsx(ue,{value:w.github_updated_at}):"unknown",last_ping_at:w.last_ping_at?s.jsx(ue,{value:w.last_ping_at}):"never",last_event_at:w.last_event_at?s.jsx(ue,{value:w.last_event_at}):"never"},v=async()=>{if(!(!l||c)){u(!0),h(""),p("");try{h(await l(y.id))}catch(N){p(N instanceof Error?N.message:String(N))}finally{u(!1)}}},b=(e.recent_actions??[]).map(N=>({...N,created_at:s.jsx(ue,{value:N.created_at,compact:!0})}));return s.jsxs("section",{className:"grid gap-4",children:[s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[s.jsxs("div",{children:[s.jsxs("button",{type:"button",className:"mb-2 inline-flex items-center gap-2 text-sm font-semibold text-primary hover:underline",onClick:r,children:[s.jsx(ai,{className:"h-4 w-4","aria-hidden":!0}),"Back to hooks"]}),s.jsx("h2",{className:"text-xl font-semibold",children:y.target}),s.jsxs("p",{className:"font-mono text-xs text-muted",children:[y.target_type," webhook #",y.id]})]}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[y.ping_url&&l?s.jsxs("button",{type:"button",className:"inline-flex h-8 items-center gap-2 rounded-md border border-border px-3 text-sm font-semibold hover:bg-slate-50 disabled:cursor-wait disabled:opacity-60",disabled:c,onClick:()=>void v(),children:[s.jsx(an,{className:Q("h-4 w-4",c&&"animate-pulse"),"aria-hidden":!0}),c?"Sending pingโ€ฆ":"Send ping"]}):null,s.jsx(nt,{onClick:i}),y.admin_url?s.jsxs("a",{className:"inline-flex h-8 items-center gap-2 rounded-md border border-border px-3 text-sm font-semibold hover:bg-slate-50",href:rt(y.admin_url),target:"_blank",rel:"noreferrer",children:[s.jsx(on,{className:"h-4 w-4","aria-hidden":!0}),"Open in GitHub"]}):null]})]}),m?s.jsx(be,{tone:"error",text:m}):null,d?s.jsx("div",{className:"rounded-md border border-emerald-200 bg-emerald-50 p-3 text-sm text-emerald-700",children:d}):null,s.jsxs("div",{className:"grid grid-cols-2 gap-3 lg:grid-cols-4",children:[s.jsx(Ae,{title:"State",value:y.status,icon:s.jsx(an,{className:"h-5 w-5"})}),s.jsx(Ae,{title:"Deliveries",value:e.stats.deliveries,icon:s.jsx(Fn,{className:"h-5 w-5"})}),s.jsx(Ae,{title:"Retries",value:e.stats.duplicates,icon:s.jsx(zn,{className:"h-5 w-5"})}),s.jsx(Ae,{title:"Unsupported",value:e.stats.unsupported,icon:s.jsx(Hr,{className:"h-5 w-5"})})]}),s.jsxs(se,{title:"Sanitized configuration",children:[s.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:[s.jsx($,{label:"Active",value:y.active?"yes":"no"}),s.jsx($,{label:"Content type",value:y.content_type??"unknown"}),s.jsx($,{label:"SSL verification",value:y.ssl_verify===null||y.ssl_verify===void 0?"unknown":y.ssl_verify?"enabled":"disabled"}),s.jsx($,{label:"Destination URL",value:y.delivery_url??"unknown"}),s.jsx($,{label:"GitHub created",value:y.github_created_at??"unknown"}),s.jsx($,{label:"GitHub updated",value:y.github_updated_at??"unknown"}),s.jsx($,{label:"Last ping",value:y.last_ping_at??"never"}),s.jsx($,{label:"Last delivery",value:y.last_event_at??"never"}),s.jsx($,{label:"Last result",value:y.last_result??"unknown"})]}),s.jsxs("div",{className:"mt-3 rounded-md border border-border p-3",children:[s.jsx("div",{className:"text-xs font-semibold text-muted",children:"Subscribed events"}),s.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:y.events.length?y.events.map(N=>s.jsx("span",{className:"rounded border border-border bg-slate-50 px-2 py-1 font-mono text-xs",children:N},N)):s.jsx("span",{className:"text-sm text-muted",children:"No event snapshot; send a ping to refresh it."})})]})]}),s.jsx(se,{title:"Latest observed delivery",children:s.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:[s.jsx($,{label:"Event",value:y.last_event_name?`${y.last_event_name}${y.last_action?` ยท ${y.last_action}`:""}`:"none"}),s.jsx($,{label:"Repository",value:y.last_repository??"none"}),s.jsx($,{label:"Delivery ID",value:y.last_delivery_id??"none"})]})}),s.jsx(se,{title:"Recent administrative actions",children:b.length?s.jsx("div",{className:"divide-y divide-border rounded-md border border-border",children:b.map(N=>s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2 text-sm",children:[s.jsxs("div",{children:[s.jsx("span",{className:"font-semibold",children:N.action}),s.jsxs("span",{className:"ml-2 text-muted",children:["by @",N.actor]})]}),s.jsxs("span",{className:"font-mono text-xs text-muted",children:[N.status," ยท ",N.created_at]})]},N.id))}):s.jsx(J,{text:"No administrative actions recorded for this hook."})}),s.jsx(se,{title:"Recent deliveries",children:e.recent_deliveries.length?s.jsx(_c,{deliveries:e.recent_deliveries,onViewHook:a,onViewDelivery:o}):s.jsx(J,{text:"This hook has no retained deliveries."})})]})}function Zx({data:e,loading:t,error:n,onBack:r,onRefresh:i,onViewHook:a,onViewJob:o}){if(t)return s.jsx(gn,{text:"Loading delivery detailโ€ฆ"});if(n)return s.jsxs("div",{className:"grid gap-3",children:[s.jsx(be,{tone:"error",text:n.message}),s.jsx("button",{type:"button",className:"w-fit rounded border border-border px-3 py-2 text-sm font-semibold",onClick:r,children:"Back to deliveries"})]});if(!e)return s.jsx(J,{text:"Delivery detail is not available."});const l={...e.delivery,created_at:s.jsx(ue,{value:e.delivery.created_at})};return s.jsxs("section",{className:"grid gap-4",children:[s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[s.jsxs("div",{children:[s.jsxs("button",{type:"button",className:"mb-2 inline-flex items-center gap-2 text-sm font-semibold text-primary hover:underline",onClick:r,children:[s.jsx(ai,{className:"h-4 w-4","aria-hidden":!0}),"Back to deliveries"]}),s.jsxs("h2",{className:"text-xl font-semibold",children:[l.event_name,l.action?` ยท ${l.action}`:""]}),s.jsxs("p",{className:"font-mono text-xs text-muted",children:["Delivery ",l.delivery_id]})]}),s.jsx(nt,{onClick:i})]}),s.jsxs(se,{title:"Delivery",children:[s.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:[s.jsx($,{label:"Received",value:l.created_at}),s.jsx($,{label:"Repository",value:l.repository??"unknown"}),s.jsx($,{label:"Result",value:l.status}),s.jsx($,{label:"Event key",value:l.event_key??"unmatchable"}),s.jsx($,{label:"Payload SHA-256",value:e.payload_hash}),s.jsx($,{label:"Retries",value:l.duplicate_count??0})]}),l.hook_id?s.jsxs("button",{type:"button",className:"mt-3 text-sm font-semibold text-primary hover:underline",onClick:()=>a(l.hook_id),children:["View hook #",l.hook_id]}):null]}),s.jsx(se,{title:"Generated job",children:e.job?s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("div",{className:"font-semibold",children:e.job.work_key}),s.jsxs("div",{className:"mt-1 font-mono text-xs text-muted",children:["Job #",e.job.id," ยท ",e.job.status," ยท ",e.job.action," ยท ",e.job.work_intent]})]}),s.jsx("button",{type:"button",className:"rounded-md border border-border px-3 py-2 text-sm font-semibold hover:bg-slate-50",onClick:()=>o(e.job.id),children:"Open job"})]}):s.jsx(J,{text:"This delivery did not generate or coalesce into a job."})}),s.jsx(se,{title:"Full payload",children:e.payload===null?s.jsx(J,{text:"Payload was not retained for this legacy delivery."}):s.jsx("pre",{className:"max-h-[640px] overflow-auto rounded-md border border-border bg-slate-950 p-4 font-mono text-xs leading-relaxed text-slate-100",children:JSON.stringify(e.payload,null,2)})})]})}function eg({executorPause:e,executorPauseLoading:t,executorPauseStatusError:n,executorPausePending:r,executorPauseError:i,executorCapacity:a,executorResizePending:o,executorResizeError:l,isAdmin:c,onExecutorPauseChange:u,onExecutorResize:d,processes:h,processesLoading:m,processesError:p,systemd:w,systemdLoading:y,systemdError:v,alerts:b,alertsLoading:N,alertsError:k,sloSummary:_,sloLoading:D,sloError:j,sloWindow:B,now:F,onRefreshProcesses:C,onRefreshSystemd:M,onRefreshAlerts:O,onSloWindowChange:I,onRefreshSlo:X}){return s.jsxs("section",{className:"grid gap-4","aria-label":"Bridge system",children:[s.jsx(tg,{state:e,loading:t,statusError:n,pending:r,actionError:i,capacity:a,resizePending:o,resizeError:l,isAdmin:c,onChange:u,onResize:d}),j?s.jsx(be,{tone:"error",text:j.message}):null,s.jsx(wg,{summary:_,loading:D,window:B,onWindowChange:I,onRefresh:X}),s.jsxs(se,{title:"Systemd",action:s.jsx(nt,{onClick:M}),children:[v?s.jsx(be,{tone:"error",text:v.message}):null,s.jsx(Vg,{data:w,loading:y})]}),s.jsxs(se,{title:"Process activity",action:s.jsx(nt,{onClick:C}),children:[p?s.jsx(be,{tone:"error",text:p.message}):null,s.jsx(Xg,{data:h,loading:m})]}),s.jsxs(se,{title:"Monitor alerts",action:s.jsx(nt,{onClick:O}),children:[k?s.jsx(be,{tone:"error",text:k.message}):null,s.jsx(Yg,{alerts:b,loading:N,now:F})]})]})}function tg({state:e,loading:t,statusError:n,pending:r,actionError:i,capacity:a,resizePending:o=!1,resizeError:l="",isAdmin:c,onChange:u,onResize:d}){const h=!!(e!=null&&e.paused),[m,p]=R.useState(()=>String((a==null?void 0:a.desired)||1));R.useEffect(()=>{a!=null&&a.desired&&p(String(a.desired))},[a==null?void 0:a.desired]);const w=Number(m),y=Number.isInteger(w)&&w>=1;return s.jsxs(se,{title:"Executor",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-semibold",children:e?h?"Paused":"Accepting jobs":t?"Loading state...":"State unavailable"}),h?s.jsx("p",{className:"text-xs text-muted",children:"New jobs remain pending; running jobs continue."}):null,e!=null&&e.reason?s.jsxs("p",{className:"mt-1 text-xs text-muted",children:["Reason: ",e.reason]}):null,c?null:s.jsx("p",{className:"mt-1 text-xs text-muted",children:"Admin only"})]}),s.jsxs("label",{className:"inline-flex items-center gap-2 text-sm font-medium",children:[s.jsx("span",{children:"Pause"}),s.jsx("input",{"aria-label":"Pause executor",role:"switch",type:"checkbox",checked:h,disabled:!c||!e||!!e.error||!!n||r,onChange:()=>{const v=!h,b=v?"Pause executor? New jobs will remain pending; running jobs will continue.":"Resume executor? Pending jobs may start running.";window.confirm(b)&&u(v)},className:"peer sr-only"}),s.jsx("span",{"aria-hidden":!0,className:"relative h-6 w-11 rounded-full bg-slate-300 transition-colors peer-checked:bg-primary peer-focus-visible:outline peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2 peer-focus-visible:outline-primary peer-disabled:opacity-50 after:absolute after:left-0.5 after:top-0.5 after:h-5 after:w-5 after:rounded-full after:bg-white after:shadow-sm after:transition-transform peer-checked:after:translate-x-5"})]})]}),a?s.jsxs("div",{className:"mt-3 grid gap-3 border-t border-border pt-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4","aria-label":"Executor capacity",children:[s.jsx($,{label:"Desired",value:a.desired}),s.jsx($,{label:"Live",value:a.live}),s.jsx($,{label:"Busy",value:a.busy}),s.jsx($,{label:"Draining",value:a.draining})]}),s.jsxs("form",{className:"flex flex-wrap items-end gap-2",onSubmit:v=>{v.preventDefault(),y&&d&&d(w)},children:[s.jsxs("label",{className:"grid gap-1 text-xs font-semibold text-muted",children:["Desired workers",s.jsx("input",{"aria-label":"Desired workers",className:"control w-28",type:"number",min:"1",step:"1",value:m,disabled:!c||o,onChange:v=>p(v.target.value)})]}),s.jsx("button",{type:"submit",className:"h-9 rounded-md bg-primary px-3 text-sm font-semibold text-white disabled:cursor-not-allowed disabled:opacity-60",disabled:!c||o||!y||w===a.desired,children:o?"Resizingโ€ฆ":"Resize"})]})]}):null,n?s.jsx(be,{tone:"error",text:n.message}):null,e!=null&&e.error?s.jsx(be,{tone:"error",text:e.error}):null,i?s.jsx(be,{tone:"error",text:`Action failed: ${i}`}):null,l?s.jsx(be,{tone:"error",text:`Resize failed: ${l}`}):null]})}function er({href:e,active:t,children:n,onNavigate:r}){return s.jsx("a",{className:Q("inline-flex h-8 min-w-0 flex-1 items-center justify-center gap-1 rounded-md px-1.5 text-xs font-semibold sm:flex-none sm:gap-1.5 sm:px-3 sm:text-sm [&>span]:truncate [&>svg]:shrink-0",t?"bg-primary text-white shadow-sm":"text-muted hover:bg-slate-50 hover:text-foreground"),href:e,onClick:i=>{!r||i.defaultPrevented||i.button!==0||i.metaKey||i.ctrlKey||i.altKey||i.shiftKey||(i.preventDefault(),r(e))},children:n})}function ng({jobId:e,detail:t,selectedJob:n,user:r,onBackToDashboard:i,onRetry:a,onDismiss:o,onCancel:l,onRefresh:c}){const[u,d]=R.useState(!1),[h,m]=R.useState(!1),[p,w]=R.useState(!1),y=!!(r!=null&&r.is_admin&&n&&Vs(n.status)&&n.decision==="auto_trusted"),v=!!(r!=null&&r.is_admin&&n&&Gs(n.status)),b=!!(n&&Js(n,r)),N=u?"Retrying...":"Retry",k=h?"Dismissing...":"Dismiss",_=p?"Cancelling...":"Cancel";return s.jsxs("div",{className:"grid min-w-0 gap-3 sm:gap-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("a",{className:"inline-flex h-9 items-center gap-2 rounded-md border border-border px-3 text-sm font-semibold text-foreground hover:bg-slate-50",href:"/",onClick:D=>{D.defaultPrevented||D.button!==0||D.metaKey||D.ctrlKey||D.altKey||D.shiftKey||(D.preventDefault(),i())},children:[s.jsx(ai,{className:"h-4 w-4","aria-hidden":!0}),"Dashboard"]}),s.jsxs("div",{className:"flex items-center gap-2",children:[y?s.jsxs("button",{className:"inline-flex h-9 items-center justify-center gap-2 rounded-md bg-primary px-3 text-sm font-semibold text-white disabled:cursor-not-allowed disabled:opacity-60",type:"button",disabled:u,onClick:async()=>{if(window.confirm(`Retry job #${e}?`)){d(!0);try{await a(e)}finally{d(!1)}}},children:[s.jsx(cr,{className:"h-4 w-4","aria-hidden":!0}),N]}):null,v?s.jsxs("button",{className:"inline-flex h-9 items-center justify-center gap-2 rounded-md border border-border bg-white px-3 text-sm font-semibold text-foreground hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-60",type:"button",disabled:h,onClick:async()=>{if(window.confirm(`Dismiss job #${e}?`)){m(!0);try{await o(e)}finally{m(!1)}}},children:[s.jsx(On,{className:"h-4 w-4","aria-hidden":!0}),k]}):null,b?s.jsxs("button",{className:"inline-flex h-9 items-center justify-center gap-2 rounded-md border border-red-200 bg-red-50 px-3 text-sm font-semibold text-red-700 hover:bg-red-100 disabled:cursor-not-allowed disabled:opacity-60",type:"button",disabled:p,onClick:async()=>{const D=window.prompt(`Cancel job #${e}? Optional reason:`);if(D!==null){w(!0);try{await l(e,D)}finally{w(!1)}}},children:[s.jsx(un,{className:"h-4 w-4","aria-hidden":!0}),_]}):null,s.jsx(nt,{onClick:c})]})]}),s.jsx(se,{title:`Job #${e}`,className:"p-3 sm:p-4",children:t})]})}function rg({selectedJobId:e,selectedJob:t,loading:n,error:r,session:i,sessionEvents:a,transcript:o,now:l}){return t?s.jsx(Ag,{job:t,session:i,sessionEvents:a,transcript:o,now:l}):e!==null&&n?s.jsx(J,{text:"Loading selected job..."}):e!==null&&r?s.jsx(be,{tone:"error",text:`Job #${e}: ${r.message}`}):s.jsx(J,{text:"Select a job to inspect its timeline, worklog and GitHub links."})}function sg({data:e,loading:t,error:n,repo:r,status:i,activeTab:a,user:o,now:l,onRepoChange:c,onStatusChange:u,onTabChange:d,onApprove:h,onReject:m,onUpdateRuleScope:p,onDeleteRule:w,onRefresh:y,hasMore:v=!1,loadingMore:b=!1,onLoadMore:N=()=>{}}){const k=(e==null?void 0:e.summary)??{},[_,D]=R.useState("proposals"),j=a??_,B=M=>{D(M),d==null||d(M)},C=[{id:"proposals",label:"Proposals",count:k.proposals??(k.proposed??0)+(k.approved??0)+(k.rejected??0)+(k.errors??0)},{id:"rules",label:"Rules",count:k.rules??0},{id:"events",label:"Events",count:k.events??0}];return s.jsxs("div",{className:"grid min-w-0 gap-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("h2",{className:"flex items-center gap-2 text-base font-semibold",children:[s.jsx(oi,{className:"h-5 w-5 text-muted","aria-hidden":!0}),"Acquired knowledge"]}),s.jsx("p",{className:"text-xs text-muted",children:"Captured feedback, proposed rules and curated agent memory."})]}),s.jsx(nt,{onClick:y})]}),n?s.jsx(be,{tone:"error",text:n.message}):null,s.jsxs("section",{className:"grid grid-cols-2 gap-3 lg:grid-cols-4","aria-label":"Knowledge metrics",children:[s.jsx(Ae,{title:"Proposed",value:k.proposed??0,icon:s.jsx(Rl,{className:"h-5 w-5"})}),s.jsx(Ae,{title:"Approved",value:k.approved??0,icon:s.jsx(On,{className:"h-5 w-5"})}),s.jsx(Ae,{title:"Rules",value:k.rules??0,icon:s.jsx(Tl,{className:"h-5 w-5"})}),s.jsx(Ae,{title:"Events",value:k.events??0,icon:s.jsx(an,{className:"h-5 w-5"})})]}),s.jsx(se,{title:"Filters",className:"p-3",children:s.jsxs("div",{className:Q("grid gap-3",j==="proposals"?"md:grid-cols-[minmax(0,1fr)_220px]":"md:grid-cols-[minmax(0,1fr)]"),children:[s.jsx(ot,{label:"Repository",children:s.jsxs("select",{className:"control",value:r,onChange:M=>c(M.target.value),children:[s.jsx("option",{value:"",children:"All repositories"}),((e==null?void 0:e.repositories)??[]).map(M=>s.jsx("option",{value:M,children:M},M))]})}),j==="proposals"?s.jsx(ot,{label:"Proposal status",children:s.jsxs("select",{className:"control",value:i,onChange:M=>u(M.target.value),children:[s.jsx("option",{value:"",children:"All statuses"}),s.jsx("option",{value:"proposed",children:"proposed"}),s.jsx("option",{value:"approved",children:"approved"}),s.jsx("option",{value:"rejected",children:"rejected"}),s.jsx("option",{value:"error",children:"error"})]})}):null]})}),s.jsxs(se,{title:"Knowledge records",action:s.jsx("div",{className:"flex max-w-full flex-wrap rounded-md border border-border bg-white p-0.5",role:"tablist","aria-label":"Knowledge record type",children:C.map(M=>s.jsxs("button",{className:Q("inline-flex h-8 items-center gap-1.5 rounded px-2.5 text-xs font-semibold",j===M.id?"bg-primary text-white":"text-muted hover:bg-slate-50 hover:text-foreground"),type:"button",role:"tab","aria-label":`${M.label} (${M.count})`,"aria-selected":j===M.id,onClick:()=>B(M.id),children:[s.jsx("span",{children:M.label}),s.jsx("span",{className:Q("rounded-sm border px-1 font-mono text-[10px]",j===M.id?"border-white/40 text-white":"border-border text-muted"),children:M.count})]},M.id))}),children:[j==="proposals"?s.jsx(ig,{proposals:(e==null?void 0:e.proposals)??[],loading:t,isAdmin:!!(o!=null&&o.is_admin),now:l,onApprove:h,onReject:m}):null,j==="rules"?s.jsx(lg,{rules:(e==null?void 0:e.rules)??[],loading:t,now:l,onUpdateRuleScope:p,onDeleteRule:w}):null,j==="events"?s.jsx(cg,{events:(e==null?void 0:e.events)??[],loading:t,now:l}):null,v?s.jsx("div",{className:"mt-3 flex justify-center border-t border-border pt-3",children:s.jsx("button",{className:"button-secondary",type:"button",disabled:b,onClick:N,children:b?"Loading more...":"Load more knowledge records"})}):null]})]})}function ig({proposals:e,loading:t,isAdmin:n,now:r,onApprove:i,onReject:a}){const[o,l]=R.useState(null);return t&&e.length===0?s.jsx(J,{text:"Loading proposals..."}):e.length===0?s.jsx(J,{text:"No proposals match the current filters."}):s.jsx("div",{className:"grid gap-2",children:e.map(c=>s.jsxs("article",{className:"grid min-w-0 gap-2 rounded-md border border-border bg-white p-3",children:[s.jsx(Ec,{scope:c.scope,type:c.type,confidence:c.confidence,status:c.status,timestamp:c.updated_at,now:r}),s.jsx("p",{className:"min-w-0 break-words text-sm font-medium [overflow-wrap:anywhere]",children:c.rule||c.reason||"No reusable rule proposed."}),c.reason?s.jsx("p",{className:"min-w-0 break-words text-xs text-muted [overflow-wrap:anywhere]",children:c.reason}):null,c.source_event?s.jsx(ag,{event:c.source_event}):s.jsxs("p",{className:"font-mono text-xs text-muted",children:["Source event ",c.event_id]}),c.error?s.jsx(be,{tone:"error",text:c.error}):null,n&&c.status==="proposed"?s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsxs("button",{className:"inline-flex h-8 items-center gap-2 rounded-md bg-primary px-3 text-sm font-semibold text-white disabled:opacity-60",type:"button",disabled:o===c.id,onClick:async()=>{l(c.id);try{await i(c.id)}finally{l(null)}},children:[s.jsx(On,{className:"h-4 w-4","aria-hidden":!0}),"Approve"]}),s.jsxs("button",{className:"inline-flex h-8 items-center gap-2 rounded-md border border-border px-3 text-sm font-semibold text-foreground hover:bg-slate-50 disabled:opacity-60",type:"button",disabled:o===c.id,onClick:async()=>{l(c.id);try{await a(c.id)}finally{l(null)}},children:[s.jsx(un,{className:"h-4 w-4","aria-hidden":!0}),"Reject"]})]}):null]},c.id))})}function ag({event:e}){const t=e.trigger_actor||(e.actor!=="github"?e.actor:null);return s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2 rounded-md border border-border bg-slate-50 px-2 py-1.5",children:[s.jsx(Hn,{actor:t,avatarUrl:e.trigger_actor_avatar_url,framed:!0}),e.source_job_id?s.jsxs("a",{className:"inline-flex h-7 items-center gap-1 rounded-md border border-border bg-white px-2 text-xs font-semibold text-foreground hover:bg-slate-50",href:Un(e.source_job_id),children:[s.jsx(Fn,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Job #",e.source_job_id]}):null,e.github_urls.length>0?s.jsx(dr,{urls:e.github_urls,compact:!0}):s.jsx("span",{className:"font-mono text-xs text-muted",children:"No GitHub link"})]})}function og(e){const t=[{value:"global",label:"global"}];if(e.startsWith("repo:")){const n=e.slice(5),[r,i]=n.split("/",2);r&&i&&(t.push({value:`org:${r}`,label:`org:${r}`}),t.push({value:`repo:${r}/${i}`,label:`repo:${r}/${i}`}))}else e.startsWith("org:")&&t.push({value:e,label:e});return t.some(n=>n.value===e)||t.push({value:e,label:e}),t}function lg({rules:e,loading:t,now:n,onUpdateRuleScope:r,onDeleteRule:i}){const[a,o]=R.useState(null),[l,c]=R.useState(null),[u,d]=R.useState("");return t&&e.length===0?s.jsx(J,{text:"Loading curated rules..."}):e.length===0?s.jsx(J,{text:"No curated rules match the current filters."}):s.jsx("div",{className:"grid gap-2",children:e.map(h=>{const m=h.source_event_details??[],p=m[0],w=p?p.trigger_actor||(p.actor!=="github"?p.actor:null):null,y=m.flatMap(_=>_.github_urls??[]),v=og(h.scope),b=l===h.id,N=a===h.id,k=!!h.can_manage;return s.jsxs("article",{className:"grid min-w-0 gap-2 rounded-md border border-border bg-white p-3",children:[s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[s.jsx(Ec,{scope:h.scope,type:h.type,confidence:h.confidence,status:`${h.observations} observation${h.observations===1?"":"s"}`,timestamp:h.last_seen,now:n}),k?s.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[b?s.jsxs(s.Fragment,{children:[s.jsx(ot,{label:"Scope",children:s.jsx("select",{className:"control h-8 min-w-[180px] py-1 text-xs",value:u,disabled:N,onChange:_=>d(_.target.value),children:v.map(_=>s.jsx("option",{value:_.value,children:_.label},_.value))})}),s.jsxs("button",{className:"inline-flex h-8 items-center gap-2 rounded-md border border-border px-3 text-sm font-semibold text-foreground hover:bg-slate-50 disabled:opacity-60",type:"button",disabled:N||u===h.scope,title:"Save scope",onClick:async()=>{if(u!==h.scope){o(h.id);try{await r(h.id,u),c(null)}finally{o(null)}}},children:[s.jsx(od,{className:"h-4 w-4","aria-hidden":!0}),"Save"]}),s.jsxs("button",{className:"inline-flex h-8 items-center gap-2 rounded-md border border-border px-3 text-sm font-semibold text-muted hover:bg-slate-50 disabled:opacity-60",type:"button",disabled:N,title:"Cancel scope edit",onClick:()=>{c(null),d("")},children:[s.jsx(un,{className:"h-4 w-4","aria-hidden":!0}),"Cancel"]})]}):s.jsxs("button",{className:"inline-flex h-8 items-center gap-2 rounded-md border border-border px-3 text-sm font-semibold text-foreground hover:bg-slate-50 disabled:opacity-60",type:"button",disabled:N,title:"Edit scope",onClick:()=>{c(h.id),d(h.scope)},children:[s.jsx(ad,{className:"h-4 w-4","aria-hidden":!0}),"Edit"]}),s.jsxs("button",{className:"inline-flex h-8 items-center gap-2 rounded-md border border-red-200 px-3 text-sm font-semibold text-red-700 hover:bg-red-50 disabled:opacity-60",type:"button",disabled:N,onClick:async()=>{if(window.confirm("Delete this curated rule?")){o(h.id);try{await i(h.id)}finally{o(null)}}},children:[s.jsx(Ls,{className:"h-4 w-4","aria-hidden":!0}),"Delete"]})]}):null]}),s.jsx("p",{className:"min-w-0 break-words text-sm font-medium [overflow-wrap:anywhere]",children:h.rule}),s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[s.jsx(Hn,{actor:w,avatarUrl:p==null?void 0:p.trigger_actor_avatar_url,framed:!0}),p!=null&&p.source_job_id?s.jsxs("a",{className:"inline-flex h-7 items-center gap-1 rounded-md border border-border px-2 text-xs font-semibold text-foreground hover:bg-white",href:Un(p.source_job_id),children:[s.jsx(Fn,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Job #",p.source_job_id]}):null,y.length>0?s.jsx(dr,{urls:y,compact:!0}):s.jsx("span",{className:"font-mono text-xs text-muted",children:"No GitHub link"})]})]},h.id)})})}function cg({events:e,loading:t,now:n}){return t&&e.length===0?s.jsx(J,{text:"Loading captured events..."}):e.length===0?s.jsx(J,{text:"No captured feedback events match the current filters."}):s.jsx("div",{className:"grid gap-2",children:e.map(r=>{const i=r.trigger_actor||(r.actor!=="github"?r.actor:null);return s.jsxs("details",{className:"group rounded-md border border-border bg-white",children:[s.jsxs("summary",{className:"grid cursor-pointer list-none gap-2 px-3 py-2 marker:hidden hover:bg-slate-50",children:[s.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-2 font-mono text-xs font-semibold text-muted",children:[s.jsx(Dn,{className:"h-3.5 w-3.5 shrink-0 transition-transform group-open:rotate-180","aria-hidden":!0}),s.jsx("span",{className:"truncate",children:Nc(r.scope)})]}),s.jsx("span",{className:"shrink-0 font-mono text-xs text-muted",children:s.jsx(ue,{value:r.occurred_at,relative:!0,now:n})})]}),s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[s.jsx(Hn,{actor:i,avatarUrl:r.trigger_actor_avatar_url,framed:!0}),r.source_job_id?s.jsxs("a",{className:"inline-flex h-7 items-center gap-1 rounded-md border border-border px-2 text-xs font-semibold text-foreground hover:bg-white",href:Un(r.source_job_id),children:[s.jsx(Fn,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Job #",r.source_job_id]}):null,r.github_urls.length>0?s.jsx(dr,{urls:r.github_urls,compact:!0}):s.jsx("span",{className:"font-mono text-xs text-muted",children:"No GitHub link"})]}),s.jsx("p",{className:"line-clamp-2 break-words text-sm [overflow-wrap:anywhere]",children:r.comment})]}),s.jsxs("div",{className:"grid gap-2 border-t border-border px-3 py-2",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"mb-1 text-xs font-semibold text-muted",children:"GitHub links"}),r.github_urls.length>0?s.jsx(dr,{urls:r.github_urls}):s.jsx("p",{className:"text-xs text-muted",children:"No links recorded."})]}),s.jsx("pre",{className:"max-h-72 overflow-auto rounded-md bg-slate-950 px-3 py-2 font-mono text-xs leading-relaxed text-slate-100",children:JSON.stringify(r.context,null,2)})]})]},r.id)})})}function ug({tokens:e,loading:t,error:n,user:r,ownerOptions:i,dashboardUrl:a,dashboardUrlSource:o,now:l,onCreate:c,onUpdateOwner:u,onRevoke:d,onRefresh:h}){const[m,p]=R.useState(""),[w,y]=R.useState(""),[v,b]=R.useState(!1),[N,k]=R.useState(null),[_,D]=R.useState(null),[j,B]=R.useState(null),[F,C]=R.useState(""),M=e??[],O=i.find(P=>P.login===w);R.useEffect(()=>{var P;r!=null&&r.is_admin&&(w&&i.some(U=>U.login===w)||y((r==null?void 0:r.login)||((P=i[0])==null?void 0:P.login)||""))},[i,r==null?void 0:r.is_admin,r==null?void 0:r.login,w]);const I=(a||(typeof window>"u"?"":window.location.origin)).replace(/\/$/,""),X=`${I}/mcp`,q=`${I}/api/mcp`;return s.jsxs("div",{className:"grid min-w-0 gap-4",children:[s.jsx(Cc,{icon:s.jsx(Dr,{className:"h-5 w-5 text-muted","aria-hidden":!0}),title:"MCP access",subtitle:r!=null&&r.is_admin?"Issue and revoke globally readable knowledge tokens for any dashboard user.":"Issue and revoke globally readable knowledge tokens linked to your user.",action:s.jsx(nt,{onClick:h})}),n?s.jsx(be,{tone:"error",text:n.message}):null,F?s.jsx(be,{tone:"error",text:F}):null,s.jsx(dg,{dashboardUrl:X,endpointUrl:q,dashboardUrlSource:o??"request"}),j?s.jsxs("section",{className:"rounded-md border border-emerald-300 bg-emerald-50 p-3 text-emerald-950","aria-label":"Created MCP token",children:[s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-sm font-semibold",children:"Token created"}),s.jsx("p",{className:"mt-1 text-xs text-emerald-800",children:"This secret is shown once. Store it in the local agent environment before leaving this page."})]}),s.jsxs("button",{className:"inline-flex h-8 items-center gap-2 rounded-md border border-emerald-300 bg-white px-3 text-sm font-semibold text-emerald-900 hover:bg-emerald-100",type:"button",onClick:()=>B(null),children:[s.jsx(un,{className:"h-4 w-4","aria-hidden":!0}),"Hide"]})]}),s.jsx("pre",{className:"mt-3 overflow-auto rounded bg-emerald-950 px-3 py-2 font-mono text-xs text-emerald-50",children:j.token})]}):null,s.jsx(se,{title:"Create token",children:s.jsxs("form",{className:r!=null&&r.is_admin?"grid gap-3 md:grid-cols-[minmax(0,1fr)_minmax(12rem,16rem)_auto]":"grid gap-3 md:grid-cols-[minmax(0,1fr)_auto]",onSubmit:async P=>{P.preventDefault();const U=m.trim();if(U){b(!0),C("");try{const te=await c(U,r!=null&&r.is_admin?w:void 0);B(te),p("")}catch(te){C(te instanceof Error?te.message:String(te))}finally{b(!1)}}},children:[s.jsx(ot,{label:"Token name",children:s.jsx("input",{className:"control",value:m,placeholder:"local agent",disabled:v,onChange:P=>p(P.target.value)})}),r!=null&&r.is_admin?s.jsxs(ot,{label:"Lifecycle owner",children:[s.jsx(Pc,{ariaLabel:"Lifecycle owner",value:w,ownerOptions:i,disabled:v||i.length===0,selectedSuffix:P=>P.login===(r==null?void 0:r.login)?" (you)":"",emptyLabel:"No known users",onChange:y}),O?s.jsxs("span",{className:"font-normal text-muted",children:["Token management will be linked to @",O.login,"; this does not restrict repository reads."]}):null]}):null,s.jsxs("button",{className:"inline-flex h-9 items-center justify-center gap-2 self-end rounded-md bg-primary px-3 text-sm font-semibold text-white disabled:cursor-not-allowed disabled:opacity-60",type:"submit",disabled:v||!m.trim()||!!(r!=null&&r.is_admin&&!w),children:[s.jsx(Dr,{className:"h-4 w-4","aria-hidden":!0}),v?"Creating...":"Create token"]})]})}),s.jsx(se,{title:"Active tokens",children:s.jsx(hg,{tokens:M,loading:t,now:l,ownerOptions:i,canManageOwners:!!(r!=null&&r.is_admin),revokingId:N,updatingOwnerId:_,onUpdateOwner:async(P,U)=>{D(P),C("");try{await u(P,U)}catch(te){C(te instanceof Error?te.message:String(te))}finally{D(null)}},onRevoke:async P=>{if(window.confirm("Revoke this MCP token?")){k(P),C("");try{await d(P)}catch(U){C(U instanceof Error?U.message:String(U))}finally{k(null)}}}})})]})}function dg({dashboardUrl:e,endpointUrl:t,dashboardUrlSource:n}){const r=n==="configured"?"Configured public URL":n==="forwarded"?"Forwarded public URL":"Needs public URL",i=n==="request",a=i?"Set GITHUB_AGENT_BRIDGE_DASHBOARD_PUBLIC_URL or forward X-Forwarded-* headers":e,o=i?"Public dashboard URL required before connecting remote agents":t,c=`{ "mcpServers": { "github-agent-bridge": { "url": "${i?"https://bridge.example.com/api/mcp":t}", @@ -184,4 +184,4 @@ var Ha=e=>{throw TypeError(e)};var Jr=(e,t,n)=>t.has(e)||Ha("Cannot "+n);var g=( } } } -}`;return s.jsxs(se,{title:"Connect an agent",children:[i?s.jsx(be,{tone:"warning",text:"Set GITHUB_AGENT_BRIDGE_DASHBOARD_PUBLIC_URL, or forward X-Forwarded-* headers from the proxy, before connecting remote agents."}):null,s.jsxs("div",{className:"grid gap-4 lg:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]",children:[s.jsxs("div",{className:"grid min-w-0 gap-3",children:[s.jsxs("div",{className:"min-w-0 rounded-md border border-border bg-white p-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm font-semibold",children:[s.jsx(on,{className:"h-4 w-4 text-muted","aria-hidden":!0}),"Public dashboard URL",s.jsx("span",{className:"rounded-sm border border-border bg-slate-50 px-1.5 py-0.5 font-mono text-[11px] font-normal text-muted",children:r})]}),s.jsx("p",{className:"mt-1 text-xs text-muted",children:"Share this page URL with bridge admins only after it resolves to the external dashboard origin."}),s.jsx("pre",{className:"mt-3 overflow-auto rounded-md bg-slate-950 px-3 py-2 font-mono text-xs text-slate-100",children:a})]}),s.jsxs("div",{className:"min-w-0 rounded-md border border-border bg-white p-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[s.jsx(on,{className:"h-4 w-4 text-muted","aria-hidden":!0}),"HTTP MCP endpoint"]}),s.jsx("p",{className:"mt-1 text-xs text-muted",children:"Remote agents connect directly with a bearer token; no local `gab` binary is required on the agent host."}),s.jsx("pre",{className:"mt-3 overflow-auto rounded-md bg-slate-950 px-3 py-2 font-mono text-xs text-slate-100",children:o})]})]}),s.jsxs("div",{className:"grid min-w-0 gap-3",children:[s.jsxs("div",{className:"min-w-0 rounded-md border border-border bg-white p-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[s.jsx(Or,{className:"h-4 w-4 text-muted","aria-hidden":!0}),"Agent config"]}),s.jsx("p",{className:"mt-1 text-xs text-muted",children:"Create a token below, then store the one-time secret as `GITHUB_AGENT_BRIDGE_MCP_TOKEN` for the agent."}),s.jsx("pre",{className:"mt-3 max-h-64 overflow-auto rounded-md bg-slate-950 px-3 py-2 font-mono text-xs leading-relaxed text-slate-100",children:c})]}),s.jsxs("div",{className:"min-w-0 rounded-md border border-border bg-white p-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[s.jsx(oi,{className:"h-4 w-4 text-muted","aria-hidden":!0}),"Agent prompt"]}),s.jsx("p",{className:"mt-1 text-xs text-muted",children:"Ask the agent to use the read-only bridge knowledge server before acting on repository work."}),s.jsx("pre",{className:"mt-3 max-h-40 overflow-auto rounded-md bg-slate-950 px-3 py-2 font-mono text-xs leading-relaxed text-slate-100",children:"Use the github-agent-bridge MCP server for repository knowledge. Query list_repositories and list_knowledge before making repository decisions."})]})]})]})]})}function Cc({icon:e,title:t,subtitle:n,action:r}){return s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("h2",{className:"flex items-center gap-2 text-base font-semibold",children:[e,t]}),s.jsx("p",{className:"text-xs text-muted",children:n})]}),r]})}function hg({tokens:e,loading:t,now:n,ownerOptions:r,canManageOwners:i,revokingId:a,updatingOwnerId:o,onUpdateOwner:l,onRevoke:c}){return t&&e.length===0?s.jsx(J,{text:"Loading MCP tokens..."}):e.length===0?s.jsx(J,{text:"No active MCP tokens."}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"grid gap-2 md:hidden",children:e.map(u=>s.jsxs("article",{className:"grid min-w-0 gap-3 rounded-md border border-border bg-white p-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("h3",{className:"break-words text-sm font-semibold [overflow-wrap:anywhere]",children:u.name}),s.jsx("div",{className:"mt-1 break-all font-mono text-xs text-muted",children:u.id}),i?s.jsx(Go,{token:u,ownerOptions:r,disabled:o===u.id,onUpdateOwner:l}):u.user_login?s.jsxs("div",{className:"mt-1 text-xs text-muted",children:["Owner: @",u.user_login]}):null]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[s.jsx($,{label:"Created",value:s.jsx(ue,{value:u.created_at,relative:!0,now:n})}),s.jsx($,{label:"Last used",value:u.last_used_at?s.jsx(ue,{value:u.last_used_at,relative:!0,now:n}):"never"})]}),s.jsxs("button",{className:"inline-flex h-8 items-center justify-center gap-2 rounded-md border border-red-200 px-3 text-sm font-semibold text-red-700 hover:bg-red-50 disabled:cursor-not-allowed disabled:opacity-60",type:"button",disabled:a===u.id,onClick:()=>c(u.id),children:[s.jsx(Ls,{className:"h-4 w-4","aria-hidden":!0}),a===u.id?"Revoking...":"Revoke"]})]},u.id))}),s.jsx("div",{className:"hidden overflow-auto rounded-md border border-border md:block",children:s.jsxs("table",{className:"min-w-full border-collapse text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-border bg-slate-50 text-left text-xs text-muted",children:[s.jsx("th",{className:"px-3 py-2 font-semibold",children:"Name"}),s.jsx("th",{className:"px-3 py-2 font-semibold",children:"Owner"}),s.jsx("th",{className:"px-3 py-2 font-semibold",children:"Created"}),s.jsx("th",{className:"px-3 py-2 font-semibold",children:"Last used"}),s.jsx("th",{className:"px-3 py-2 font-semibold",children:"ID"}),s.jsx("th",{className:"px-3 py-2 text-right font-semibold",children:"Actions"})]})}),s.jsx("tbody",{children:e.map(u=>s.jsxs("tr",{className:"border-b border-border last:border-b-0",children:[s.jsx("td",{className:"px-3 py-3 font-semibold",children:u.name}),s.jsx("td",{className:"px-3 py-3 text-xs text-muted",children:i?s.jsx(Go,{token:u,ownerOptions:r,disabled:o===u.id,onUpdateOwner:l}):u.user_login?`@${u.user_login}`:"unassigned"}),s.jsx("td",{className:"px-3 py-3 font-mono text-xs",children:s.jsx(ue,{value:u.created_at,relative:!0,now:n})}),s.jsx("td",{className:"px-3 py-3 font-mono text-xs",children:u.last_used_at?s.jsx(ue,{value:u.last_used_at,relative:!0,now:n}):"never"}),s.jsx("td",{className:"px-3 py-3 font-mono text-xs text-muted",children:u.id}),s.jsx("td",{className:"px-3 py-3 text-right",children:s.jsxs("button",{className:"inline-flex h-8 items-center gap-2 rounded-md border border-red-200 px-3 text-sm font-semibold text-red-700 hover:bg-red-50 disabled:cursor-not-allowed disabled:opacity-60",type:"button",disabled:a===u.id,onClick:()=>c(u.id),children:[s.jsx(Ls,{className:"h-4 w-4","aria-hidden":!0}),a===u.id?"Revoking...":"Revoke"]})})]},u.id))})]})})]})}function Go({token:e,ownerOptions:t,disabled:n,onUpdateOwner:r}){const i=e.user_login??"";return s.jsx(Pc,{ariaLabel:`Owner for ${e.name}`,value:i,ownerOptions:t,disabled:n||t.length===0,emptyLabel:"Select owner",size:"compact",onChange:a=>{!a||a===e.user_login||r(e.id,a)}})}function Pc({value:e,ownerOptions:t,disabled:n,onChange:r,ariaLabel:i,selectedSuffix:a,emptyLabel:o,size:l="default"}){const c=t.find(d=>d.login===e),u=c?`@${c.login}${(a==null?void 0:a(c))??""}`:o;return s.jsxs("div",{className:Q("relative flex min-w-0 items-center gap-2 rounded-md border border-border bg-panel text-foreground focus-within:border-primary focus-within:ring-1 focus-within:ring-primary",n?"opacity-60":"",l==="compact"?"h-8 w-44 max-w-full px-2":"h-9 w-full px-2.5"),children:[s.jsx("span",{className:Q("pointer-events-none flex shrink-0 items-center justify-center",l==="compact"?"h-5 w-5":"h-6 w-6"),children:c!=null&&c.avatar_url?s.jsx("img",{className:"h-full w-full rounded-full bg-slate-100",src:rt(c.avatar_url),alt:"",referrerPolicy:"no-referrer"}):s.jsx(An,{className:Q("text-muted",l==="compact"?"h-4 w-4":"h-5 w-5"),"aria-hidden":!0})}),s.jsx("span",{className:Q("pointer-events-none min-w-0 flex-1 truncate font-mono",c?"text-foreground":"text-muted",l==="compact"?"text-xs":"text-sm"),children:u}),s.jsxs("select",{className:"absolute inset-0 h-full w-full cursor-pointer opacity-0 disabled:cursor-not-allowed","aria-label":i,value:e,disabled:n,onChange:d=>r(d.target.value),children:[t.length===0||!e?s.jsx("option",{value:"",children:o}):null,t.map(d=>s.jsxs("option",{value:d.login,children:["@",d.login,(a==null?void 0:a(d))??""]},d.login))]}),s.jsx(On,{className:Q("pointer-events-none shrink-0 text-muted",l==="compact"?"h-3.5 w-3.5":"h-4 w-4"),"aria-hidden":!0})]})}function dr({urls:e,compact:t=!1}){const n=t?e.slice(0,2):e,r=e.length-n.length;return s.jsxs("div",{className:"flex min-w-0 max-w-full flex-wrap gap-1.5",children:[n.map(i=>s.jsxs("a",{className:Q("inline-flex max-w-full items-center gap-1 rounded-md border border-border font-semibold text-primary hover:bg-white hover:underline",t?"h-7 px-2 text-xs":"min-h-7 px-2 py-1 text-xs"),href:rt(i),"aria-label":i,rel:"noreferrer",target:"_blank",children:[s.jsx(on,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),s.jsx("span",{className:"truncate",children:t?pg(i):i})]},i)),r>0?s.jsxs("span",{className:"inline-flex h-7 items-center rounded-md border border-border px-2 font-mono text-xs text-muted",children:["+",r]}):null]})}function pg(e){try{const t=new URL(e);return t.pathname.replace(/^\//,"")+t.hash}catch{return e}}function Ec({scope:e,type:t,confidence:n,status:r,timestamp:i,now:a}){return s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2 text-xs text-muted",children:[s.jsx("span",{className:"truncate font-mono font-semibold text-foreground",children:Nc(e)}),s.jsx("span",{className:"rounded-sm border border-border px-1.5 py-0.5 font-mono",children:t}),s.jsxs("span",{className:"rounded-sm border border-border px-1.5 py-0.5 font-mono",children:[Math.round(n*100),"%"]}),s.jsx("span",{className:"rounded-sm border border-border px-1.5 py-0.5 font-mono",children:r}),s.jsx("span",{className:"font-mono",children:s.jsx(ue,{value:i,relative:!0,now:a})})]})}function mg({user:e,loading:t}){const n=e!=null&&e.login?`@${e.login}`:t?"Loading profile...":"GitHub OAuth",r=e!=null&&e.is_admin?"admin":"read-only",i=e!=null&&e.avatar_url?s.jsx("img",{className:"h-10 w-10 rounded-full border border-slate-700 bg-slate-800",src:e.avatar_url,alt:e.login?`${e.login} avatar`:"",referrerPolicy:"no-referrer"}):s.jsx("span",{className:"inline-flex h-10 w-10 items-center justify-center rounded-full border border-slate-700 bg-slate-900",children:s.jsx(An,{className:"h-5 w-5","aria-hidden":!0})}),a=e!=null&&e.html_url?s.jsx("a",{className:"truncate font-semibold text-white hover:underline",href:rt(e.html_url),rel:"noreferrer",target:"_blank",children:n}):s.jsx("div",{className:"truncate font-semibold text-white",children:n});return s.jsxs("div",{className:"flex max-w-full shrink-0 items-center gap-3 text-sm text-slate-300","aria-label":e!=null&&e.login?`Signed in as ${e.login}`:"Dashboard account",children:[s.jsx(Tl,{className:"hidden h-4 w-4 shrink-0 sm:block","aria-hidden":!0}),s.jsxs("div",{className:"hidden min-w-0 text-right sm:block",children:[a,s.jsxs("div",{className:"text-xs text-slate-400",children:["Signed in ยท ",r]})]}),i]})}function fg({config:e,loading:t,onEnable:n,onDisable:r}){const[i,a]=R.useState(!1),[o,l]=R.useState(""),c=!!(e!=null&&e.status.enabled),u=typeof navigator<"u"&&typeof window<"u"&&Lr(),d=t||i||!(e!=null&&e.configured)||!u,h=u?e!=null&&e.configured?c?"Disable notifications":"Enable notifications":"Notifications not configured":"Notifications unavailable";return s.jsx("div",{className:"relative",children:s.jsx("button",{className:Q("inline-flex h-9 w-9 items-center justify-center rounded-md border text-sm font-semibold",c?"border-emerald-400 bg-emerald-50 text-emerald-700":"border-slate-700 bg-slate-900 text-slate-200",d&&"cursor-not-allowed opacity-60"),type:"button","aria-label":h,title:o||h,disabled:d,onClick:async()=>{a(!0),l("");try{c?await r():await n()}catch(m){l(m instanceof Error?m.message:String(m))}finally{a(!1)}},children:s.jsx(El,{className:Q("h-4 w-4",i&&"animate-live-pulse"),"aria-hidden":!0})})})}function xg({notification:e,onDismiss:t,onNavigate:n}){if(!e)return null;const r=e.title||"GitHub Agent Bridge",i=e.body||e.summary||"Bridge job finished",a=e.url||e.job_url||(e.job_id?Un(e.job_id):"/"),o=a.startsWith("/");return s.jsx("aside",{className:"fixed right-3 top-20 z-50 w-[min(calc(100vw-1.5rem),28rem)] rounded-md border border-emerald-300 bg-white shadow-xl shadow-slate-950/15","aria-live":"assertive","aria-label":"Bridge notification",children:s.jsxs("div",{className:"flex items-start gap-3 p-3",children:[s.jsx("div",{className:"mt-0.5 flex h-9 w-9 shrink-0 items-center justify-center rounded-md bg-emerald-50 text-emerald-700",children:s.jsx(El,{className:"h-4 w-4","aria-hidden":!0})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsx("h2",{className:"min-w-0 break-words text-sm font-semibold text-foreground",children:r}),s.jsx("button",{className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted hover:bg-slate-100 hover:text-foreground",type:"button","aria-label":"Dismiss notification",onClick:t,children:s.jsx(un,{className:"h-4 w-4","aria-hidden":!0})})]}),s.jsx("p",{className:"mt-1 min-w-0 break-words text-sm text-muted",children:i}),e.detail?s.jsx("p",{className:"mt-1 line-clamp-2 min-w-0 break-words text-xs text-muted",children:e.detail}):null,s.jsxs("button",{className:"mt-3 inline-flex h-8 items-center gap-1.5 rounded-md border border-border px-2.5 text-xs font-semibold text-foreground hover:bg-slate-50",type:"button",onClick:()=>{t(),o?n(a):window.open(rt(a),"_blank","noopener,noreferrer")},children:[s.jsx(on,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Open"]})]})]})})}function gg({count:e,limit:t,loading:n,onRefresh:r}){return s.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-center gap-3 rounded-lg border border-border bg-white px-3 py-3 shadow-sm md:px-4",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("h2",{className:"text-base font-semibold",children:"Jobs"}),s.jsx("p",{className:"text-xs text-muted",children:n?"Refreshing latest jobs...":`Showing ${e} of the latest ${t} requested jobs`})]}),s.jsx(nt,{onClick:r,compactOnMobile:!0})]})}function se({title:e,action:t,children:n,className:r,flushHeader:i=!1}){return s.jsxs("section",{className:Q("min-w-0 rounded-lg border border-border bg-panel p-4 shadow-sm",r),children:[s.jsxs("div",{className:Q("flex flex-wrap items-center justify-between gap-3",!i&&"mb-4"),children:[s.jsx("h2",{className:"text-sm font-semibold",children:e}),t]}),n]})}function Ae({title:e,value:t,icon:n}){return s.jsxs("div",{className:"rounded-lg border border-border bg-panel p-3 shadow-sm md:p-4",children:[s.jsxs("div",{className:"flex items-center justify-between text-muted",children:[s.jsx("span",{className:"text-sm font-medium",children:e}),n]}),s.jsx("strong",{className:"mt-3 block text-2xl leading-none md:mt-4 md:text-3xl",children:t})]})}const bg=[{value:"24h",label:"24 hours"},{value:"7d",label:"7 days"},{value:"30d",label:"30 days"}],fs=[{key:"blocked",label:"Blocked",detail:"finished service jobs",color:"#dc2626"},{key:"no_op",label:"No-op",detail:"finished service jobs",color:"#7c3aed"},{key:"retry",label:"Retried",detail:"claimed service jobs",color:"#d97706"},{key:"coalescing",label:"Coalesced",detail:"ingested notifications",color:"#0284c7"}],yg=[{key:"source_received_to_queued",label:"Source โ†’ queue"},{key:"queued_to_claimed",label:"Queue โ†’ claim"},{key:"claimed_to_first_output",label:"Claim โ†’ first output"},{key:"claimed_to_done",label:"Claim โ†’ done"}];function wg({summary:e,loading:t,window:n,onWindowChange:r,onRefresh:i}){const a=s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("div",{className:"inline-flex h-8 rounded-md border border-border bg-white p-0.5",role:"group","aria-label":"SLO window",children:bg.map(c=>s.jsx("button",{className:Q("rounded px-2.5 text-xs font-semibold",n===c.value?"bg-primary text-white":"text-muted hover:bg-slate-50"),type:"button","aria-label":c.label,"aria-pressed":n===c.value,onClick:()=>r(c.value),children:c.value},c.value))}),s.jsx(nt,{onClick:i,compactOnMobile:!0})]});if(t&&!(e!=null&&e.slo))return s.jsx(se,{title:"Service SLOs",action:a,children:s.jsxs("div",{className:"flex min-h-24 items-center justify-center gap-2 rounded-md border border-dashed border-border text-sm text-muted",children:[s.jsx(zn,{className:"h-4 w-4 animate-spin","aria-hidden":!0}),"Loading SLO metricsโ€ฆ"]})});if((e==null?void 0:e.schema_ok)===!1)return s.jsx(se,{title:"Service SLOs",action:a,children:s.jsx(be,{tone:"warning",text:`SLO metrics are unavailable until the database schema is migrated${e.schema_error?`: ${e.schema_error}`:"."}`})});if(!(e!=null&&e.slo))return s.jsx(se,{title:"Service SLOs",action:a,children:s.jsx(J,{text:"No SLO read model is available."})});const o=e.slo,l=o.trends.daily.map(c=>({bucket:c.bucket,blocked:c.rates.blocked.percent,no_op:c.rates.no_op.percent,retry:c.rates.retry.percent,coalescing:c.rates.coalescing.percent}));return s.jsx(se,{title:"Service SLOs",action:a,children:s.jsxs("div",{className:"grid gap-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-x-4 gap-y-1 text-xs text-muted",children:[s.jsxs("span",{children:[s.jsx("strong",{className:"text-foreground",children:o.cohort.sample_count})," finished auto-trusted service job",o.cohort.sample_count===1?"":"s",o.cohort.missing_count>0?` ยท ${o.cohort.missing_count} missing outcome`:"",o.cohort.excluded_count>0?` ยท ${o.cohort.excluded_count} excluded`:""]}),s.jsx("span",{className:"font-mono",children:o.window.timezone})]}),s.jsx("section",{className:"grid gap-2 sm:grid-cols-2 xl:grid-cols-4","aria-label":"SLO reliability rates",children:fs.map(c=>s.jsx(vg,{definition:c,rate:o.rates[c.key]},c.key))}),s.jsxs("section",{"aria-labelledby":"slo-latency-heading",children:[s.jsx("h3",{id:"slo-latency-heading",className:"mb-2 text-xs font-semibold uppercase tracking-wide text-muted",children:"Latency percentiles"}),s.jsx("div",{className:"grid gap-2 sm:grid-cols-2 xl:grid-cols-4",children:yg.map(c=>s.jsx(jg,{label:c.label,latency:o.latencies[c.key]},c.key))})]}),s.jsxs("section",{"aria-labelledby":"slo-trend-heading",children:[s.jsxs("div",{className:"mb-2 flex flex-wrap items-center justify-between gap-2",children:[s.jsx("h3",{id:"slo-trend-heading",className:"text-xs font-semibold uppercase tracking-wide text-muted",children:"Daily reliability trend"}),s.jsx("span",{className:"text-xs text-muted",children:"Percent of each daily cohort"})]}),s.jsx("div",{className:"h-64",role:"img","aria-label":"Daily SLO reliability rates chart",children:s.jsx(ln,{width:"100%",height:"100%",children:s.jsxs(dl,{data:l,children:[s.jsx(Ln,{strokeDasharray:"3 3"}),s.jsx(Mn,{dataKey:"bucket",minTickGap:20,tick:{fontSize:11}}),s.jsx(sn,{domain:[0,100],tickFormatter:c=>`${c}%`,width:44}),s.jsx(Ur,{}),s.jsx(cn,{formatter:(c,u)=>{var d;return[c==null?"n/a":`${Number(c).toLocaleString(void 0,{maximumFractionDigits:2})}%`,((d=fs.find(h=>h.key===u))==null?void 0:d.label)??u]}}),fs.map(c=>s.jsx(ti,{type:"monotone",dataKey:c.key,name:c.label,stroke:c.color,strokeWidth:2,dot:{r:2},activeDot:{r:4},connectNulls:!1,isAnimationActive:!1},c.key))]})})})]})]})})}function vg({definition:e,rate:t}){const n=t.percent===null?"n/a":`${t.percent.toLocaleString(void 0,{maximumFractionDigits:2})}%`;return s.jsxs("div",{className:"rounded-md border border-border bg-slate-50/70 p-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"text-xs font-semibold text-muted",children:e.label}),s.jsx("span",{className:"h-2.5 w-2.5 rounded-full",style:{backgroundColor:e.color},"aria-hidden":!0})]}),s.jsx("strong",{className:"mt-2 block text-2xl leading-none",children:n}),s.jsxs("p",{className:"mt-2 text-xs text-muted",children:[t.numerator," / ",t.denominator," ",e.detail]}),t.missing_count>0?s.jsxs("p",{className:"mt-1 text-xs text-amber-700",children:[t.missing_count," missing sample",t.missing_count===1?"":"s"]}):null,e.key==="retry"&&t.requeued_runs?s.jsxs("p",{className:"mt-1 text-xs text-muted",children:[t.requeued_runs," requeued run",t.requeued_runs===1?"":"s"]}):null]})}function jg({label:e,latency:t}){return s.jsxs("div",{className:"rounded-md border border-border p-3",children:[s.jsx("h4",{className:"text-xs font-semibold text-muted",children:e}),s.jsxs("div",{className:"mt-3 grid grid-cols-3 gap-2 text-center",children:[s.jsx(xs,{label:"p50",value:t.p50}),s.jsx(xs,{label:"p90",value:t.p90}),s.jsx(xs,{label:"p99",value:t.p99})]}),s.jsxs("p",{className:"mt-3 text-xs text-muted",children:[t.sample_count," sample",t.sample_count===1?"":"s",t.missing_count>0?` ยท ${t.missing_count} missing`:""]})]})}function xs({label:e,value:t}){return s.jsxs("div",{children:[s.jsx("div",{className:"font-mono text-sm font-semibold",children:Xe(t)}),s.jsx("div",{className:"mt-0.5 text-[10px] font-semibold uppercase text-muted",children:e})]})}function kg({filters:e,actorOptions:t,onChange:n}){const[r,i]=R.useState(e);R.useEffect(()=>i(e),[e]);const a=qx(e),o=Vo(e)||Vo(r),l=()=>{i(Qs),n(Qs)};return s.jsxs("details",{className:"my-3 rounded-md border border-border bg-slate-50/70",children:[s.jsxs("summary",{className:"grid cursor-pointer list-none grid-cols-[minmax(0,1fr)_auto] items-center gap-3 px-3 py-2 text-sm font-semibold marker:hidden",children:[s.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[s.jsxs("span",{className:"inline-flex shrink-0 items-center gap-2",children:[s.jsx(sd,{className:"h-4 w-4 text-muted","aria-hidden":!0}),"Filters"]}),a.length>0?s.jsx("span",{className:"flex min-w-0 flex-wrap items-center gap-1.5","aria-label":"Applied filters",children:a.map(c=>s.jsxs("span",{className:"inline-flex max-w-full items-center gap-1 rounded-full border border-blue-200 bg-blue-50 px-2 py-0.5 text-xs font-semibold text-blue-700",children:[s.jsx("span",{className:"text-blue-700/70",children:c.label}),s.jsx("span",{className:"max-w-40 truncate font-mono",children:c.value.trim()})]},c.key))}):null]}),s.jsxs("span",{className:"inline-flex shrink-0 items-center gap-2",children:[o?s.jsxs("button",{className:"inline-flex h-8 items-center justify-center gap-1.5 rounded-md border border-border bg-white px-2.5 text-xs font-semibold text-foreground hover:bg-slate-50",type:"button",onClick:c=>{c.preventDefault(),c.stopPropagation(),l()},children:[s.jsx(cr,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Clear filters"]}):null,s.jsx(On,{className:"h-4 w-4 text-muted","aria-hidden":!0})]})]}),s.jsxs("form",{className:"grid gap-3 border-t border-border bg-white p-3 md:grid-cols-3 xl:grid-cols-9",onSubmit:c=>{c.preventDefault(),n(r)},children:[s.jsx(ot,{label:"Status",children:s.jsxs("select",{className:"control",value:r.status,onChange:c=>i({...r,status:c.target.value}),children:[s.jsx("option",{value:"",children:"All"}),s.jsx("option",{value:"pending",children:"pending"}),s.jsx("option",{value:"running",children:"running"}),s.jsx("option",{value:"blocked",children:"blocked"}),s.jsx("option",{value:"done",children:"done"}),s.jsx("option",{value:"denied",children:"denied"}),s.jsx("option",{value:"waiting_approval",children:"waiting_approval"})]})}),s.jsx(ot,{label:"Repository",children:s.jsx("input",{className:"control",value:r.repo,placeholder:"owner/repo",onChange:c=>i({...r,repo:c.target.value})})}),s.jsx(ot,{label:"Thread",children:s.jsx("input",{className:"control",value:r.thread,inputMode:"numeric",placeholder:"issue or PR",onChange:c=>i({...r,thread:c.target.value})})}),s.jsx(ot,{label:"Action",children:s.jsx("input",{className:"control",value:r.action,placeholder:"reply_comment",onChange:c=>i({...r,action:c.target.value})})}),s.jsx(ot,{label:"Actor",className:"xl:col-span-2",children:s.jsx(Ng,{value:r.actor,options:t,onChange:c=>i({...r,actor:c})})}),s.jsx(ot,{label:"Intent",children:s.jsxs("select",{className:"control",value:r.intent,onChange:c=>i({...r,intent:c.target.value}),children:[s.jsx("option",{value:"",children:"All"}),s.jsx("option",{value:"review_only",children:"review_only"}),s.jsx("option",{value:"work_allowed",children:"work_allowed"})]})}),s.jsxs("div",{className:"grid grid-cols-2 gap-2 self-end xl:col-span-2",children:[s.jsxs("button",{className:"inline-flex h-9 items-center justify-center gap-2 rounded-md border border-border px-3 text-sm font-semibold text-foreground hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-white",type:"button",disabled:!o,onClick:l,children:[s.jsx(cr,{className:"h-4 w-4","aria-hidden":!0}),"Clear"]}),s.jsxs("button",{className:"inline-flex h-9 items-center justify-center gap-2 rounded-md bg-primary px-3 text-sm font-semibold text-white",type:"submit",children:[s.jsx(ld,{className:"h-4 w-4","aria-hidden":!0}),"Apply"]})]})]})]})}function Ng({value:e,options:t,onChange:n}){const[r,i]=R.useState(!1),a=e.trim().replace(/^@/,"").toLowerCase(),o=t.filter(c=>!a||c.login.toLowerCase().includes(a)).slice(0,8),l=t.find(c=>c.login.toLowerCase()===a);return s.jsxs("div",{className:"relative min-w-0",children:[s.jsxs("div",{className:"control flex items-center gap-2 px-2",children:[l?s.jsx("img",{className:"h-5 w-5 shrink-0 rounded-full bg-slate-100",src:rt(l.avatar_url??""),alt:`${l.login} avatar`,referrerPolicy:"no-referrer"}):s.jsx(An,{className:"h-4 w-4 shrink-0 text-muted","aria-hidden":!0}),s.jsx("input",{className:"min-w-0 flex-1 bg-transparent font-mono text-sm outline-none",value:e,placeholder:"@login",onChange:c=>{n(c.target.value),i(!0)},onFocus:()=>i(!0),onBlur:()=>window.setTimeout(()=>i(!1),100)}),e?s.jsx("button",{className:"rounded-sm p-1 text-muted hover:bg-slate-100",type:"button","aria-label":"Clear actor filter",onClick:()=>n(""),children:s.jsx(un,{className:"h-3.5 w-3.5","aria-hidden":!0})}):null]}),r&&o.length>0?s.jsx("div",{className:"absolute left-0 right-0 z-20 mt-1 max-h-72 overflow-auto rounded-md border border-border bg-white p-1 shadow-lg",children:o.map(c=>s.jsxs("button",{className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-left hover:bg-slate-50",type:"button",onMouseDown:u=>u.preventDefault(),onClick:()=>{n(c.login),i(!1)},children:[c.avatar_url?s.jsx("img",{className:"h-6 w-6 shrink-0 rounded-full bg-slate-100",src:rt(c.avatar_url),alt:`${c.login} avatar`,referrerPolicy:"no-referrer"}):s.jsx(An,{className:"h-5 w-5 shrink-0 text-muted","aria-hidden":!0}),s.jsxs("span",{className:"min-w-0 flex-1 truncate font-mono text-xs text-foreground",children:["@",c.login]}),s.jsx("span",{className:"shrink-0 rounded-full bg-slate-100 px-1.5 py-0.5 text-[10px] font-semibold text-muted",children:c.job_count})]},c.login))}):null]})}function ot({label:e,children:t,className:n}){return s.jsxs("label",{className:Q("grid min-w-0 gap-1 text-xs font-semibold text-muted",n),children:[e,t]})}function Sg({jobs:e,loading:t,loadingMore:n=!1,hasMore:r=!1,onLoadMore:i,onViewJob:a,now:o,user:l,onRetry:c,onDismiss:u,onCancel:d}){const[h,m]=R.useState(null),[p,w]=R.useState(null),[y,v]=R.useState(null),b=R.useRef(!1),N=R.useRef(n),k=!!(l!=null&&l.is_admin&&c),_=!!(l!=null&&l.is_admin&&u);R.useEffect(()=>{N.current&&!n&&(b.current=!1),N.current=n},[n]);const O=R.useCallback(()=>{b.current||(b.current=!0,i==null||i())},[i]),j=R.useCallback(async C=>{if(c){m(C);try{await c(C)}finally{m(null)}}},[c]),B=R.useCallback(async C=>{if(u){w(C);try{await u(C)}finally{w(null)}}},[u]),F=R.useCallback(async(C,M)=>{if(d){v(C);try{await d(C,M)}finally{v(null)}}},[d]);return t&&e.length===0?s.jsx(J,{text:"Loading jobs..."}):e.length===0?s.jsx(J,{text:"No jobs match the current filters."}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"grid gap-2 md:hidden",children:[e.map(C=>s.jsx(Pg,{job:C,onViewJob:a,now:o,canRetry:k&&Vs(C.status)&&C.decision==="auto_trusted",retrying:h===C.id,onRetry:j,canDismiss:_&&Gs(C.status),dismissing:p===C.id,onDismiss:B,canCancel:!!(d&&Js(C,l)),cancelling:y===C.id,onCancel:F},C.id)),s.jsx(Cg,{hasMore:r,loading:n,onLoadMore:O})]}),s.jsx(Xs,{noun:"jobs",hasMore:r,loading:n,onLoadMore:O,className:"hidden md:block",children:s.jsxs("table",{className:"min-w-[1080px] table-fixed border-collapse text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"sticky top-0 z-10 border-b border-border bg-panel text-left text-xs text-muted",children:[s.jsx("th",{className:"w-[42%] px-3 py-2 font-semibold",children:"Job"}),s.jsx("th",{className:"w-32 px-3 py-2 font-semibold",children:"Status"}),s.jsx("th",{className:"w-40 px-3 py-2 font-semibold",children:"Action"}),s.jsx("th",{className:"w-36 px-3 py-2 font-semibold",children:"Actor"}),s.jsx("th",{className:"w-36 px-3 py-2 font-semibold",children:"Timing"}),s.jsx("th",{className:"w-28 px-3 py-2 font-semibold",children:"Updated"}),s.jsx("th",{className:"w-24 px-3 py-2 text-right font-semibold",children:"Actions"})]})}),s.jsx("tbody",{children:e.map(C=>s.jsx(_g,{job:C,now:o,onViewJob:a,canRetry:k&&Vs(C.status)&&C.decision==="auto_trusted",retrying:h===C.id,onRetry:j,canDismiss:_&&Gs(C.status),dismissing:p===C.id,onDismiss:B,canCancel:!!(d&&Js(C,l)),cancelling:y===C.id,onCancel:F},C.id))})]})})]})}function _g({job:e,now:t,onViewJob:n,canRetry:r,retrying:i,onRetry:a,canDismiss:o,dismissing:l,onDismiss:c,canCancel:u,cancelling:d,onCancel:h}){return s.jsxs("tr",{className:"cursor-pointer border-b border-border align-top hover:bg-slate-50",onClick:()=>n(e.id),children:[s.jsx("td",{className:"min-w-0 px-3 py-3",children:s.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[s.jsxs("span",{className:"mt-0.5 shrink-0 font-mono text-xs font-semibold text-muted",children:["#",e.id]}),s.jsxs("div",{className:"min-w-0 space-y-1",children:[s.jsx("div",{className:"line-clamp-2 text-sm font-semibold leading-snug text-foreground [overflow-wrap:anywhere]",title:e.subject,children:e.subject}),s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted",children:[s.jsx("span",{className:"min-w-0 max-w-full truncate font-mono",children:e.repo??e.work_key}),s.jsxs("span",{className:"shrink-0",children:["thread ",e.thread??"n/a"]})]})]})]})}),s.jsx("td",{className:"px-3 py-3",children:s.jsx(_i,{status:e.status})}),s.jsxs("td",{className:"px-3 py-3",children:[s.jsx("div",{className:"min-w-0 truncate text-sm text-foreground",title:e.action,children:e.action}),s.jsx("div",{className:"mt-1",children:s.jsx(Si,{intent:e.intent,actionMode:e.action_mode,display:"intent",compact:!0})})]}),s.jsx("td",{className:"px-3 py-3",children:s.jsx(Hn,{actor:e.trigger_actor,avatarUrl:e.trigger_actor_avatar_url})}),s.jsxs("td",{className:"px-3 py-3 text-xs text-muted",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{children:"wait"}),s.jsx("span",{className:"font-mono text-foreground",children:Xe(Ni(e,t))})]}),s.jsxs("div",{className:"mt-1 flex items-center justify-between gap-2",children:[s.jsx("span",{children:"run"}),s.jsx("span",{className:"font-mono text-foreground",children:Xe(ki(e,t))})]}),s.jsxs("div",{className:"mt-1 flex items-center justify-between gap-2",children:[s.jsx("span",{children:"tries"}),s.jsx("span",{className:"font-mono text-foreground",children:e.attempts})]})]}),s.jsx("td",{className:"px-3 py-3 font-mono text-xs",children:s.jsx(ue,{value:e.updated_at,compact:!0,relative:!0,now:t})}),s.jsx("td",{className:"px-3 py-3 text-right",children:s.jsxs("div",{className:"inline-flex items-center gap-1",children:[s.jsx(Rc,{jobId:e.id,canRetry:r,retrying:i,onRetry:a,compact:!0}),s.jsx(Ic,{jobId:e.id,canDismiss:o,dismissing:l,onDismiss:c,compact:!0}),s.jsx(Tc,{jobId:e.id,canCancel:u,cancelling:d,onCancel:h,compact:!0})]})})]})}function Cg({hasMore:e,loading:t,onLoadMore:n}){return!e&&!t?null:s.jsxs("button",{className:"inline-flex min-h-10 w-full items-center justify-center gap-2 rounded-md border border-border px-3 py-2 text-sm font-semibold text-foreground hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-60 md:hidden",type:"button",disabled:t||!e,onClick:()=>n==null?void 0:n(),children:[s.jsx(On,{className:"h-4 w-4","aria-hidden":!0}),t?"Loading more jobs...":"Load more jobs"]})}function Pg({job:e,onViewJob:t,now:n,canRetry:r,retrying:i,onRetry:a,canDismiss:o,dismissing:l,onDismiss:c,canCancel:u,cancelling:d,onCancel:h}){return s.jsxs("article",{className:"rounded-md border border-border bg-white shadow-[0_1px_0_rgba(15,23,42,0.03)]",children:[s.jsxs("button",{className:"grid w-full gap-2 p-3 text-left hover:bg-slate-50",type:"button",onClick:()=>t(e.id),children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"min-w-0 space-y-1",children:[s.jsxs("div",{className:"grid min-w-0 grid-cols-[auto_minmax(0,1fr)] items-center gap-2",children:[s.jsxs("span",{className:"shrink-0 font-mono text-xs font-semibold text-muted",children:["#",e.id]}),s.jsx("span",{className:"truncate font-mono text-sm",children:e.repo??e.work_key})]}),s.jsx("div",{className:"line-clamp-2 text-sm leading-snug text-foreground",children:e.subject}),s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted",children:[s.jsxs("span",{children:["thread ",e.thread??"n/a"," ยท ",e.action]}),s.jsx(Si,{intent:e.intent,actionMode:e.action_mode,compact:!0,display:"intent"}),s.jsx(Hn,{actor:e.trigger_actor,avatarUrl:e.trigger_actor_avatar_url})]})]}),s.jsx(_i,{status:e.status})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-2 text-xs",children:[s.jsx($,{label:"Wait",value:Xe(Ni(e,n))}),s.jsx($,{label:"Runtime",value:Xe(ki(e,n))}),s.jsx($,{label:"Updated",value:s.jsx(ue,{value:e.updated_at,compact:!0,relative:!0,now:n})})]})]}),r||o||u?s.jsxs("div",{className:"flex flex-wrap gap-2 border-t border-border px-3 py-2",children:[s.jsx(Rc,{jobId:e.id,canRetry:r,retrying:i,onRetry:a}),s.jsx(Ic,{jobId:e.id,canDismiss:o,dismissing:l,onDismiss:c}),s.jsx(Tc,{jobId:e.id,canCancel:u,cancelling:d,onCancel:h})]}):null]})}function Rc({jobId:e,canRetry:t,retrying:n,onRetry:r,compact:i=!1}){if(!t)return null;const a=n?"Retrying...":"Retry";return s.jsxs("button",{className:Q("inline-flex h-8 items-center justify-center gap-2 rounded-md border border-border text-sm font-semibold text-foreground hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-60",i?"w-8 px-0":"px-3"),type:"button",disabled:n,"aria-label":`Retry job #${e}`,title:`Retry job #${e}`,onClick:async o=>{o.stopPropagation(),window.confirm(`Retry job #${e}?`)&&await r(e)},children:[s.jsx(cr,{className:"h-4 w-4","aria-hidden":!0}),s.jsx("span",{className:Q(i&&"sr-only"),children:a})]})}function Ic({jobId:e,canDismiss:t,dismissing:n,onDismiss:r,compact:i=!1}){if(!t)return null;const a=n?"Dismissing...":"Dismiss";return s.jsxs("button",{className:Q("inline-flex h-8 items-center justify-center gap-2 rounded-md border border-border text-sm font-semibold text-foreground hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-60",i?"w-8 px-0":"px-3"),type:"button",disabled:n,"aria-label":`Dismiss job #${e}`,title:`Dismiss job #${e}`,onClick:async o=>{o.stopPropagation(),window.confirm(`Dismiss job #${e}?`)&&await r(e)},children:[s.jsx(Dn,{className:"h-4 w-4","aria-hidden":!0}),s.jsx("span",{className:Q(i&&"sr-only"),children:a})]})}function Tc({jobId:e,canCancel:t,cancelling:n,onCancel:r,compact:i=!1}){if(!t)return null;const a=n?"Cancelling...":"Cancel";return s.jsxs("button",{className:Q("inline-flex h-8 items-center justify-center gap-2 rounded-md border border-red-200 bg-red-50 text-sm font-semibold text-red-700 hover:bg-red-100 disabled:cursor-not-allowed disabled:opacity-60",i?"w-8 px-0":"px-3"),type:"button",disabled:n,"aria-label":`Cancel job #${e}`,title:`Cancel job #${e}`,onClick:async o=>{o.stopPropagation();const l=window.prompt(`Cancel job #${e}? Optional reason:`);l!==null&&await r(e,l)},children:[s.jsx(un,{className:"h-4 w-4","aria-hidden":!0}),s.jsx("span",{className:Q(i&&"sr-only"),children:a})]})}function Hn({actor:e,avatarUrl:t,framed:n=!1}){const r=t?s.jsx("img",{className:"h-4 w-4 shrink-0 rounded-full bg-slate-100",src:rt(t),alt:e?`${e} avatar`:"",referrerPolicy:"no-referrer"}):s.jsx(An,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),i=s.jsxs(s.Fragment,{children:[r,s.jsx("span",{className:"min-w-0 truncate",children:e?`@${e}`:"unknown actor"})]});return n?s.jsx("span",{className:"inline-flex h-7 max-w-full items-center gap-1 rounded-md border border-border px-2 text-xs font-semibold text-muted",children:i}):s.jsx("span",{className:"inline-flex min-w-0 max-w-full items-center gap-1 font-mono text-xs text-muted",children:i})}function Eg(e){return(e==null?void 0:e.model)??"OpenClaw default"}function Rg(e){return(e==null?void 0:e.thinking)??"OpenClaw default"}function Ig(e){return e?e.configured?"configured":e.summary:"n/a"}function Tg(e,t){const n=t||(e==="work_allowed"?"fix_allowed":"review_only");return n==="fix_allowed"||!t&&e==="work_allowed"?{mode:n,intentLabel:"work_allowed",title:"Work allowed"}:{mode:n,intentLabel:"review_only",title:"Review only"}}function Si({intent:e,actionMode:t,compact:n=!1,display:r="mode"}){const i=Tg(e,t),a=i.intentLabel==="work_allowed"?cd:Il,o=r==="intent"?i.intentLabel:i.mode;return s.jsxs("span",{className:Q("inline-flex min-h-6 max-w-full items-center gap-1.5 rounded-md border px-2 text-xs font-semibold",i.intentLabel==="work_allowed"?"border-blue-200 bg-blue-50 text-blue-700":"border-violet-200 bg-violet-50 text-violet-700",n&&"min-h-5 px-1.5 text-[11px]"),title:`${i.title}: ${i.mode}`,"aria-label":`${i.title}: ${o}`,children:[s.jsx(a,{className:Q("h-3.5 w-3.5 shrink-0",n&&"h-3 w-3"),"aria-hidden":!0}),s.jsx("span",{className:"truncate font-mono",children:o})]})}function Ag({job:e,session:t,sessionEvents:n,transcript:r,now:i,compact:a=!1}){var p;const o=Un(e.id),l=n??[],c=r??[],u=yx(l),d=wx(c),h=ki(e,i),m=Ni(e,i);return s.jsxs("div",{className:"grid min-w-0 gap-4",children:[s.jsxs("div",{className:"sticky top-0 z-20 -mx-3 -mt-3 grid gap-2 border-b border-border bg-panel/95 px-3 py-2 shadow-sm backdrop-blur sm:-mx-4 sm:-mt-4 sm:px-4","aria-label":"Sticky job header",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[s.jsx(_i,{status:e.status}),s.jsxs("a",{className:"inline-flex h-7 items-center gap-1 rounded-md border border-border bg-white px-2 text-xs font-semibold text-foreground hover:bg-slate-50",href:o,children:[s.jsx(Fn,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Job #",e.id]}),s.jsx(Hn,{actor:e.trigger_actor,avatarUrl:e.trigger_actor_avatar_url,framed:!0}),s.jsx("span",{className:"min-w-0 break-words font-mono text-xs text-muted [overflow-wrap:anywhere]",children:e.work_key})]}),s.jsxs("div",{className:"grid min-w-0 gap-2 lg:grid-cols-[minmax(0,1fr)_minmax(280px,auto)] lg:items-start",children:[s.jsx("p",{className:"min-w-0 break-words text-sm text-muted [overflow-wrap:anywhere]",children:e.subject}),s.jsxs("div",{className:"grid min-w-0 gap-1",children:[s.jsx("h3",{className:"text-xs font-semibold text-muted",children:"GitHub links"}),e.github_urls.length>0?s.jsx(dr,{urls:e.github_urls,compact:!0}):s.jsx("p",{className:"text-xs text-muted",children:"No links recorded."})]})]})]}),s.jsxs("div",{className:Q("grid gap-2 text-sm sm:gap-3",a?"grid-cols-1":"grid-cols-3"),children:[s.jsx($,{label:"Queue wait",value:Xe(m)}),s.jsx($,{label:e.status==="running"?"Running for":"Runtime",value:Xe(h)}),s.jsx($,{label:"Coalesced",value:String(e.coalesced_count)})]}),e.queue_state==="serialized_by_work_key"?s.jsxs("p",{className:"rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-sm text-amber-900",children:["Serialized behind running job #",e.blocked_by_job_id," for this work key."]}):null,s.jsxs("div",{className:Q("grid gap-2 text-sm sm:gap-3",a?"grid-cols-1":"grid-cols-3"),children:[s.jsx($,{label:"Model",value:Eg(e.model_route)}),s.jsx($,{label:"Reasoning",value:Rg(e.model_route)}),s.jsx($,{label:"Route",value:Ig(e.model_route)})]}),s.jsx(Lg,{job:e,compact:a}),s.jsxs("div",{className:Q("grid gap-2 text-sm sm:gap-3",a?"grid-cols-1":"grid-cols-2 xl:grid-cols-4"),children:[s.jsx($,{label:"Created",value:s.jsx(ue,{value:e.created_at,compact:!0,relative:!0,now:i})}),s.jsx($,{label:"Started",value:e.started_at?s.jsx(ue,{value:e.started_at,compact:!0,relative:!0,now:i}):"n/a"}),s.jsx($,{label:"Updated",value:s.jsx(ue,{value:e.updated_at,compact:!0,relative:!0,now:i})}),s.jsx($,{label:"Finished",value:e.finished_at?s.jsx(ue,{value:e.finished_at,compact:!0,relative:!0,now:i}):"n/a"})]}),s.jsxs("div",{children:[s.jsx("h3",{className:"mb-2 text-sm font-semibold",children:"Timeline"}),s.jsx("div",{className:"grid min-w-0 gap-3",children:(e.worklog??[]).length>0?(p=e.worklog)==null?void 0:p.map(w=>s.jsxs("div",{className:"min-w-0 border-l-2 border-primary pl-3",children:[s.jsx("div",{className:"text-sm font-semibold",children:w.phase}),s.jsx("div",{className:"font-mono text-xs text-muted",children:s.jsx(ue,{value:w.ts,relative:!0,now:i})}),s.jsx("div",{className:"break-words text-sm [overflow-wrap:anywhere]",children:w.summary}),w.detail?s.jsx("div",{className:"mt-1 break-words font-mono text-xs text-muted [overflow-wrap:anywhere]",children:w.detail}):null]},w.id)):s.jsx(J,{text:"No worklog entries."})})]}),s.jsxs("div",{children:[s.jsxs("h3",{className:"mb-2 flex items-center gap-2 text-sm font-semibold",children:[s.jsx(Al,{className:"h-4 w-4","aria-hidden":!0}),"OpenClaw session"]}),t?s.jsxs("div",{className:"grid gap-3",children:[s.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[s.jsx($,{label:"Session ID",value:t.id}),s.jsx($,{label:"Source",value:t.source})]}),s.jsx("p",{className:"break-words text-xs text-muted [overflow-wrap:anywhere]",children:t.detail})]}):s.jsx(J,{text:"Session correlation is loading."})]}),s.jsxs("div",{children:[s.jsx("h3",{className:"mb-2 text-sm font-semibold",children:"Agent activity"}),s.jsx("div",{className:"grid max-h-[460px] min-w-0 gap-2 overflow-auto pr-1",children:u.length>0?u.map((w,y)=>s.jsx(Og,{event:w,defaultOpen:Qo(w.eventType,e.status==="running",y,u.length),now:i},w.id)):s.jsx(J,{text:e.status==="running"?"Waiting for live agent output...":"No agent activity has been recorded for this session."})})]}),s.jsxs("div",{children:[s.jsx("h3",{className:"mb-2 text-sm font-semibold",children:"Session transcript"}),s.jsx("div",{className:"grid max-h-[620px] min-w-0 gap-2 overflow-auto pr-1",children:d.length>0?d.map((w,y)=>s.jsx(Mg,{entry:w,defaultOpen:Qo(w.kind,e.status==="running",y,d.length),now:i},w.id)):s.jsx(J,{text:e.status==="running"?"Waiting for live transcript entries...":"No OpenClaw transcript entries are available for this session."})})]})]})}function Lg({job:e,compact:t=!1}){const n=e.intent_classifier??null,r=(n==null?void 0:n.llm)??{},i=(n==null?void 0:n.parser)??{},a=typeof r.confidence=="number"?`${Math.round(r.confidence*100)}%`:"n/a";return s.jsxs("div",{className:"grid gap-2",children:[s.jsx("h3",{className:"text-sm font-semibold",children:"Action mode"}),s.jsxs("div",{className:Q("grid gap-2 text-sm sm:gap-3",t?"grid-cols-1":"grid-cols-2 xl:grid-cols-4"),children:[s.jsx($,{label:"Mode",value:s.jsx(Si,{intent:e.intent,actionMode:e.action_mode})}),s.jsx($,{label:"Intent",value:e.intent}),s.jsx($,{label:"Addressed",value:n?Jo(r.addressed_to_agent):"n/a"}),s.jsx($,{label:"Write",value:n?r.write_permission??"none":e.intent==="work_allowed"?"allowed":"none"})]}),n?s.jsxs("div",{className:"grid gap-2 rounded-md border border-border bg-panel p-3 text-xs",children:[s.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-4",children:[s.jsx(ht,{label:"Classifier",value:n.enabled?"enabled":"disabled"}),s.jsx(ht,{label:"Applied",value:Jo(r.applied)}),s.jsx(ht,{label:"Confidence",value:a}),s.jsx(ht,{label:"Parser",value:`${i.action??"n/a"} / ${i.work_intent??"n/a"}`})]}),s.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[s.jsx(ht,{label:"LLM",value:`${r.action??"n/a"} / ${r.work_intent??"n/a"}`}),s.jsx(ht,{label:"Scope",value:r.scope||"n/a"})]}),r.main_request?s.jsx(ht,{label:"Main request",value:r.main_request}):null,r.subordinate_reason?s.jsx(ht,{label:"Subordinate reason",value:r.subordinate_reason}):null,r.reason?s.jsx(ht,{label:"Reason",value:r.reason}):null,n.error?s.jsx(ht,{label:"Error",value:n.error,tone:"danger"}):null]}):s.jsx("p",{className:"text-xs text-muted",children:"No intent classifier metadata recorded for this job."})]})}function Jo(e){return e===!0?"yes":e===!1?"no":"n/a"}function ht({label:e,value:t,tone:n="neutral"}){return s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[11px] font-semibold uppercase text-muted",children:e}),s.jsx("div",{className:Q("mt-0.5 min-w-0 break-words font-mono text-xs [overflow-wrap:anywhere]",n==="danger"?"text-red-700":"text-foreground"),children:t})]})}function Mg({entry:e,defaultOpen:t,now:n}){return s.jsx(Ac,{badge:e.badge,meta:s.jsx(ue,{value:e.meta,relative:!0,now:n}),count:e.count,summary:e.summary,defaultOpen:t,children:s.jsx("pre",{className:"max-h-72 max-w-full overflow-auto whitespace-pre-wrap break-words rounded bg-slate-950 px-2 py-1.5 font-mono text-xs leading-relaxed text-slate-100 [overflow-wrap:anywhere]",children:e.text})})}function Og({event:e,defaultOpen:t,now:n}){return s.jsx(Ac,{badge:e.badge,meta:s.jsx(ue,{value:e.meta,relative:!0,now:n}),count:e.count,summary:e.summary,defaultOpen:t,children:e.detail?s.jsx("pre",{className:"max-h-56 max-w-full overflow-auto whitespace-pre-wrap break-words rounded bg-slate-950 px-2 py-1.5 font-mono text-xs leading-relaxed text-slate-100 [overflow-wrap:anywhere]",children:e.detail}):null})}function Ac({badge:e,meta:t,count:n,summary:r,defaultOpen:i,children:a}){const[o,l]=R.useState(!!i);return s.jsxs("details",{className:"group min-w-0 rounded border border-border bg-slate-50/60",open:o,onToggle:c=>l(c.currentTarget.open),children:[s.jsxs("summary",{className:"grid cursor-pointer list-none gap-1 px-2 py-1.5 marker:hidden hover:bg-white",children:[s.jsxs("div",{className:"grid min-w-0 gap-1 sm:flex sm:items-center sm:justify-between sm:gap-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx(On,{className:"h-3.5 w-3.5 shrink-0 text-muted transition-transform group-open:rotate-180","aria-hidden":!0}),s.jsx("span",{className:"truncate font-mono text-[11px] font-semibold text-muted",children:e}),n&&n>1?s.jsx("span",{className:"rounded-sm border border-border px-1 font-mono text-[10px] text-muted",children:n}):null]}),s.jsx("span",{className:"min-w-0 truncate pl-5 font-mono text-[11px] text-muted sm:shrink-0 sm:pl-0",children:t})]}),s.jsx("div",{className:"min-w-0 break-words pl-5 text-xs text-foreground [overflow-wrap:anywhere] sm:truncate",children:r})]}),s.jsx("div",{className:"min-w-0 border-t border-border bg-white px-2 py-2",children:a})]})}function Xo({label:e,values:t}){const n=[{name:"median",seconds:(t==null?void 0:t.median)??0},{name:"p90",seconds:(t==null?void 0:t.p90)??0},{name:"p99",seconds:(t==null?void 0:t.p99)??0}];return s.jsx("div",{className:"h-56",children:s.jsx(ln,{width:"100%",height:"100%",children:s.jsxs(ei,{data:n,children:[s.jsx(Ln,{strokeDasharray:"3 3"}),s.jsx(Mn,{dataKey:"name"}),s.jsx(sn,{tickFormatter:Xe}),s.jsx(cn,{formatter:r=>[Xe(Number(r)),e]}),s.jsx(Bt,{dataKey:"seconds",fill:"#0969da",radius:[4,4,0,0]})]})})})}function Dg({usage:e,jobsByCreatedDay:t,loading:n,totalJobs:r}){const[i,a]=R.useState("day"),o=(e==null?void 0:e[i])??[],l=Fg(e,t,i),c=o.reduce((d,h)=>d+h.seconds,0),u=o.reduce((d,h)=>d+(h.runs??h.jobs),0);return n&&l.length===0?s.jsx(J,{text:"Loading runtime and job history..."}):l.length===0?s.jsx(J,{text:r>0?"No jobs have valid runtime or creation dates.":"No job history available."}):s.jsxs("div",{className:"grid gap-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted",children:[s.jsx(Ll,{className:"h-4 w-4","aria-hidden":!0}),s.jsxs("span",{children:[tt(c)," consumed across ",u," run",u===1?"":"s"]})]}),s.jsx("div",{className:"inline-flex h-8 rounded-md border border-border bg-white p-0.5","aria-label":"Runtime grouping",children:["day","month"].map(d=>s.jsx("button",{className:Q("rounded px-2.5 text-xs font-semibold capitalize",i===d?"bg-primary text-white":"text-muted hover:bg-slate-50"),type:"button",onClick:()=>a(d),children:d},d))})]}),s.jsx("div",{className:"h-64",role:"img","aria-label":"Runtime and jobs activity chart",children:s.jsx(ln,{width:"100%",height:"100%",children:s.jsxs(ou,{data:l,children:[s.jsx(Ln,{strokeDasharray:"3 3"}),s.jsx(Mn,{dataKey:"label",minTickGap:16,tick:{fontSize:11}}),s.jsx(sn,{yAxisId:"runtime",tickFormatter:d=>tt(Number(d))}),s.jsx(sn,{yAxisId:"jobs",orientation:"right",allowDecimals:!1}),s.jsx(Ur,{}),s.jsx(cn,{formatter:(d,h)=>h==="Work"?[tt(Number(d)),"work"]:h==="Review"?[tt(Number(d)),"review"]:h==="Jobs"?[Number(d),"jobs"]:[Number(d),String(h)],labelFormatter:d=>String(d)}),s.jsx(Bt,{yAxisId:"runtime",dataKey:"work_seconds",name:"Work",stackId:"runtime",fill:"#0969da",isAnimationActive:!1}),s.jsx(Bt,{yAxisId:"runtime",dataKey:"review_seconds",name:"Review",stackId:"runtime",fill:"#8250df",radius:[4,4,0,0],isAnimationActive:!1}),s.jsx(ti,{yAxisId:"jobs",type:"monotone",dataKey:"jobs",name:"Jobs",stroke:"#16a34a",strokeWidth:2,dot:{r:3},activeDot:{r:5},isAnimationActive:!1})]})})})]})}function Fg(e,t,n){const r=new Map;for(const a of(e==null?void 0:e[n])??[])r.set(a.bucket,{...a});const i=new Map;for(const[a,o]of Object.entries(t??{})){const l=n==="month"?a.slice(0,7):a;i.set(l,(i.get(l)??0)+o)}for(const a of i.keys())r.has(a)||r.set(a,zg(a));return[...r.values()].sort((a,o)=>a.bucket.localeCompare(o.bucket)).map(a=>({...a,jobs:i.get(a.bucket)??0,label:Wg(a.bucket,n)}))}function zg(e){return{bucket:e,seconds:0,minutes:0,runs:0,jobs:0,work_seconds:0,review_seconds:0,work_runs:0,review_runs:0,work_jobs:0,review_jobs:0}}const Lc=[{value:"7d",label:"Last 7 days"},{value:"30d",label:"Last 30 days"},{value:"all",label:"All time"}],qg=2,Rr=["#0969da","#8250df","#1a7f37","#bf8700","#cf222e","#0550ae","#6e40c9","#0a7f68"];function Bg({usage:e,loading:t,totalJobs:n,window:r,onWindowChange:i}){const a=e??[],o=a.reduce((l,c)=>l+c.seconds,0);return s.jsxs("div",{className:"grid gap-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[a.length>0?s.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted",children:[s.jsx(An,{className:"h-4 w-4","aria-hidden":!0}),s.jsxs("span",{children:[tt(o)," consumed across ",a.length," user",a.length===1?"":"s"]})]}):s.jsx("span",{}),s.jsx("div",{className:"inline-flex h-8 rounded-md border border-border bg-white p-0.5",role:"group","aria-label":"Runtime by user window",children:Lc.map(l=>s.jsx("button",{className:Q("rounded px-2.5 text-xs font-semibold",r===l.value?"bg-primary text-white":"text-muted hover:bg-slate-50"),type:"button","aria-label":l.label,"aria-pressed":r===l.value,onClick:()=>i(l.value),children:l.value==="all"?"All":l.value},l.value))})]}),t&&a.length===0?s.jsx(J,{text:"Loading runtime by user..."}):a.length===0?s.jsx(J,{text:n>0?"No jobs have recorded user runtime in this window.":"No job history available."}):s.jsx("div",{className:"overflow-x-auto",role:"img","aria-label":"Runtime usage by user chart",children:s.jsx("div",{className:"h-64",style:{minWidth:`${Math.max(720,a.length*112)}px`},children:s.jsx(ln,{width:"100%",height:"100%",children:s.jsxs(ei,{data:a,children:[s.jsx(Ln,{strokeDasharray:"3 3"}),s.jsx(Mn,{dataKey:"actor",interval:0,height:68,tick:s.jsx(Kg,{usage:a}),tickLine:!1}),s.jsx(sn,{tickFormatter:l=>tt(Number(l))}),s.jsx(Ur,{}),s.jsx(cn,{formatter:(l,c)=>[tt(Number(l)),String(c).toLowerCase()],labelFormatter:l=>l==="unknown"?"unknown":`@${String(l)}`}),s.jsx(Bt,{dataKey:"work_seconds",name:"Work",stackId:"runtime",fill:"#0969da",isAnimationActive:!1}),s.jsx(Bt,{dataKey:"review_seconds",name:"Review",stackId:"runtime",fill:"#8250df",radius:[4,4,0,0],isAnimationActive:!1})]})})})})]})}function $g({usage:e,loading:t,totalJobs:n,window:r,onWindowChange:i}){const a=e??[],o=a.reduce((c,u)=>c+u.seconds,0),l=Ug(a);return s.jsxs("div",{className:"grid gap-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[a.length>0?s.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted",children:[s.jsx(Ll,{className:"h-4 w-4","aria-hidden":!0}),s.jsxs("span",{children:[tt(o)," consumed across ",a.length," repositor",a.length===1?"y":"ies"]})]}):s.jsx("span",{}),s.jsx("div",{className:"inline-flex h-8 rounded-md border border-border bg-white p-0.5",role:"group","aria-label":"Runtime by repository window",children:Lc.map(c=>s.jsx("button",{className:Q("rounded px-2.5 text-xs font-semibold",r===c.value?"bg-primary text-white":"text-muted hover:bg-slate-50"),type:"button","aria-label":c.label,"aria-pressed":r===c.value,onClick:()=>i(c.value),children:c.value==="all"?"All":c.value},c.value))})]}),t&&a.length===0?s.jsx(J,{text:"Loading runtime by repository..."}):a.length===0?s.jsx(J,{text:n>0?"No jobs have recorded repository runtime in this window.":"No job history available."}):s.jsxs("div",{className:"grid items-center gap-4 md:grid-cols-[minmax(0,1fr)_minmax(240px,0.8fr)]",role:"img","aria-label":"Runtime usage by repository chart",children:[s.jsx("div",{className:"h-72 min-w-0",children:s.jsx(ln,{width:"100%",height:"100%",children:s.jsxs(lu,{children:[s.jsx(cu,{data:l,dataKey:"seconds",nameKey:"repo",innerRadius:"54%",outerRadius:"86%",paddingAngle:1,stroke:"#ffffff",strokeWidth:2,labelLine:!1,label:({percent:c})=>$r((c??0)*100),isAnimationActive:!1,children:l.map((c,u)=>s.jsx(uu,{fill:c.repo==="Other"?"#94a3b8":Rr[u%Rr.length]},c.repo))}),s.jsx(cn,{content:s.jsx(Hg,{totalSeconds:o})})]})})}),s.jsx("ul",{className:"grid min-w-0 gap-2","aria-label":"Repository runtime percentages",children:l.map((c,u)=>s.jsxs("li",{className:"grid min-w-0 grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-2 text-sm",children:[s.jsx("span",{className:"h-3 w-3 rounded-sm",style:{backgroundColor:c.repo==="Other"?"#94a3b8":Rr[u%Rr.length]},"aria-hidden":!0}),s.jsx("span",{className:"truncate font-mono text-xs",title:c.repo,children:c.repo==="Other"?`Other (${c.repositories.length})`:c.repo}),s.jsx("span",{className:"font-semibold tabular-nums",children:$r(c.percentage)})]},c.repo))})]})]})}function Ug(e){const t=e.filter(a=>a.seconds>0).sort((a,o)=>o.seconds-a.seconds),n=t.reduce((a,o)=>a+o.seconds,0);if(n<=0)return[];const r=[],i=[];for(const a of t){const o=a.seconds/n*100;o0){const a=i.reduce((o,l)=>({repo:"Other",seconds:o.seconds+l.seconds,minutes:o.minutes+l.minutes,runs:o.runs+l.runs,work_seconds:o.work_seconds+l.work_seconds,review_seconds:o.review_seconds+l.review_seconds,work_runs:o.work_runs+l.work_runs,review_runs:o.review_runs+l.review_runs}),{repo:"Other",seconds:0,minutes:0,runs:0,work_seconds:0,review_seconds:0,work_runs:0,review_runs:0});r.push({...a,percentage:a.seconds/n*100,repositories:i})}return r}function Hg({active:e,payload:t,totalSeconds:n}){var i;const r=(i=t==null?void 0:t[0])==null?void 0:i.payload;return!e||!r?null:s.jsxs("div",{className:"min-w-56 rounded-md border border-border bg-white p-3 text-xs shadow-lg",children:[s.jsx("div",{className:"font-mono font-semibold text-foreground",children:r.repo==="Other"?`Other (${r.repositories.length} repositor${r.repositories.length===1?"y":"ies"})`:r.repo}),s.jsxs("div",{className:"mt-2 grid grid-cols-2 gap-x-4 gap-y-1 text-muted",children:[s.jsx("span",{children:"Total"}),s.jsxs("span",{className:"text-right font-semibold text-foreground",children:[tt(r.seconds)," ยท ",$r(r.seconds/n*100)]}),s.jsx("span",{children:"Work"}),s.jsx("span",{className:"text-right text-foreground",children:tt(r.work_seconds)}),s.jsx("span",{children:"Review"}),s.jsx("span",{className:"text-right text-foreground",children:tt(r.review_seconds)}),s.jsx("span",{children:"Runs"}),s.jsx("span",{className:"text-right text-foreground",children:r.runs})]}),r.repo==="Other"?s.jsx("div",{className:"mt-2 max-h-40 overflow-auto border-t border-border pt-2",children:r.repositories.map(a=>s.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] gap-3 py-0.5",children:[s.jsx("span",{className:"truncate font-mono",title:a.repo,children:a.repo}),s.jsxs("span",{className:"tabular-nums text-muted",children:[$r(a.seconds/n*100)," ยท ",tt(a.seconds)]})]},a.repo))}):null]})}function $r(e){return`${e.toFixed(1)}%`}function Kg({x:e=0,y:t=0,payload:n,usage:r}){const i=String((n==null?void 0:n.value)??"unknown"),a=r.find(h=>h.actor===i),o=Qg(a),l=i==="unknown"?"unknown user":`@${i}`,c=i==="unknown"?"unknown":`@${i}`,u=c.length>18?`${c.slice(0,17)}โ€ฆ`:c,d=R.useId().replace(/:/g,"");return s.jsxs("g",{transform:`translate(${e},${t})`,children:[s.jsx("title",{children:l}),s.jsx("defs",{children:s.jsx("clipPath",{id:d,children:s.jsx("circle",{cx:"0",cy:"18",r:"14"})})}),s.jsx("circle",{cx:"0",cy:"18",r:"14",fill:"#f1f5f9",stroke:"#cbd5e1"}),o?s.jsx("image",{x:"-14",y:"4",width:"28",height:"28",href:o,clipPath:`url(#${d})`,preserveAspectRatio:"xMidYMid slice",role:"img","aria-label":`${l} avatar`}):s.jsx("text",{x:"0",y:"22",textAnchor:"middle",fontSize:"12",fill:"#64748b","aria-label":l,children:"?"}),s.jsx("text",{x:"0",y:"49",textAnchor:"middle",fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:"11",fontWeight:"600",fill:"#475569",children:u})]})}function Qg(e){if(!e)return null;const t=rt(e.avatar_url??"");return t!=="#"?t:!e.actor||e.actor==="unknown"?null:`https://github.com/${encodeURIComponent(e.actor)}.png?size=80`}function Wg(e,t){if(t==="month"){const[a,o]=e.split("-").map(Number);return!a||!o?e:new Intl.DateTimeFormat(void 0,{month:"short",year:"numeric"}).format(new Date(a,o-1,1))}const[n,r,i]=e.split("-").map(Number);return!n||!r||!i?e:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric"}).format(new Date(n,r-1,i))}function tt(e){const t=Math.max(0,Math.round(e));if(t<60)return`${t}s`;const n=Math.round(t/60);if(n<60)return`${n}m`;const r=Math.floor(n/60),i=n%60;return i===0?`${r}h`:`${r}h ${i}m`}function gs(e){return Object.values(e).reduce((t,n)=>t+n,0)}function Vg({data:e,loading:t}){if(t&&!e)return s.jsx(J,{text:"Loading systemd units..."});if(!e)return s.jsx(J,{text:"No systemd snapshot available."});const n=e.units??[],r=n.filter(o=>o.active_state==="active").length,i=n.filter(o=>o.active_state==="failed"||o.result==="failed").length,a=n.filter(o=>o.kind==="timer").length;return s.jsxs("div",{className:"grid min-w-0 gap-3",children:[e.errors.length>0?s.jsx(be,{tone:"error",text:e.errors[0]}):null,n.length===0?s.jsx(J,{text:"No configured bridge units found."}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-4",children:[s.jsx(Ir,{label:"Units",value:String(n.length)}),s.jsx(Ir,{label:"Active",value:String(r)}),s.jsx(Ir,{label:"Failed",value:String(i),tone:i>0?"bad":"neutral"}),s.jsx(Ir,{label:"Timers",value:String(a)})]}),s.jsxs("div",{className:"overflow-hidden rounded-md border border-border bg-white",children:[s.jsxs("div",{className:"hidden grid-cols-[minmax(0,1.35fr)_90px_120px_90px_minmax(0,1fr)] gap-3 border-b border-border bg-slate-50 px-3 py-2 text-[11px] font-semibold uppercase text-muted md:grid",children:[s.jsx("span",{children:"Unit"}),s.jsx("span",{children:"Status"}),s.jsx("span",{children:"State"}),s.jsx("span",{children:"PID"}),s.jsx("span",{children:"Schedule"})]}),s.jsx("div",{className:"divide-y divide-border",children:n.map(o=>s.jsx(Gg,{unit:o},o.unit))})]})]})]})}function Ir({label:e,value:t,tone:n="neutral"}){return s.jsxs("div",{className:Q("min-w-0 rounded-md border bg-white px-3 py-2",n==="bad"?"border-red-200":"border-border"),children:[s.jsx("div",{className:Q("font-mono text-lg font-semibold",n==="bad"?"text-red-700":"text-foreground"),children:t}),s.jsx("div",{className:"mt-0.5 text-[11px] font-semibold uppercase text-muted",children:e})]})}function Gg({unit:e}){const[t,n]=R.useState(!1),r=e.active_state==="active",i=e.active_state==="failed"||e.result==="failed",a=e.next_elapse||e.last_trigger||"n/a";return s.jsxs("details",{className:"group min-w-0",open:t,onToggle:o=>n(o.currentTarget.open),children:[s.jsxs("summary",{className:"grid min-w-0 cursor-pointer list-none grid-cols-2 gap-2 px-3 py-3 text-sm marker:hidden hover:bg-slate-50 md:grid-cols-[minmax(0,1.35fr)_90px_120px_90px_minmax(0,1fr)] md:items-center md:gap-3",children:[s.jsxs("div",{className:"col-span-2 min-w-0 md:col-span-1",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx(On,{className:"h-3.5 w-3.5 shrink-0 text-muted transition-transform group-open:rotate-180","aria-hidden":!0}),s.jsx("span",{className:"truncate font-mono text-xs font-semibold text-foreground",children:e.unit})]}),s.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1.5 pl-5 text-[11px] font-semibold uppercase text-muted",children:[s.jsx("span",{children:e.role}),s.jsx("span",{children:e.kind}),s.jsx("span",{children:e.load_state}),s.jsx("span",{children:t?"following log":"expand log"})]})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2 md:block",children:[s.jsx("span",{className:"text-[11px] font-semibold uppercase text-muted md:hidden",children:"Status"}),s.jsx("span",{className:Q("inline-flex h-6 items-center rounded-full border px-2 text-xs font-semibold",i?"border-red-300 bg-red-50 text-red-700":r?"border-emerald-300 bg-emerald-50 text-emerald-700":"border-slate-300 bg-slate-50 text-slate-700"),children:e.active_state})]}),s.jsx(Yo,{label:"State",value:e.sub_state,detail:e.result||"unknown"}),s.jsx(Yo,{label:"PID",value:e.main_pid?String(e.main_pid):"n/a",detail:Xe(e.uptime_seconds)}),s.jsxs("div",{className:"col-span-2 min-w-0 md:col-span-1",children:[s.jsx("div",{className:"text-[11px] font-semibold uppercase text-muted md:hidden",children:"Schedule"}),s.jsx("div",{className:"truncate font-mono text-[11px] text-foreground",title:a,children:e.next_elapse?`next ${e.next_elapse}`:a})]})]}),s.jsx("div",{className:"border-t border-border bg-slate-50 px-3 pb-3 pt-2",children:s.jsx(Jg,{unit:e.unit,active:t})})]})}function Yo({label:e,value:t,detail:n}){return s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[11px] font-semibold uppercase text-muted md:hidden",children:e}),s.jsx("div",{className:"truncate font-mono text-[11px] text-foreground",children:t}),n?s.jsx("div",{className:"truncate font-mono text-[11px] text-muted",children:n}):null]})}function Jg({unit:e,active:t}){const[n,r]=R.useState([]),[i,a]=R.useState(""),o=R.useRef(null);return R.useEffect(()=>{if(!t){r([]),a("");return}r([]),a("");const l=new EventSource(`/api/systemd/journal/stream?unit=${encodeURIComponent(e)}`);return l.addEventListener("journal_line",c=>{const u=Br(c);u&&r(d=>[...d.slice(-199),u])}),l.addEventListener("journal_error",c=>{const u=Br(c);a((u==null?void 0:u.error)??"journal stream failed")}),l.onerror=()=>{},()=>l.close()},[t,e]),R.useEffect(()=>{const l=o.current;l&&(l.scrollTop=l.scrollHeight)},[n]),s.jsxs("div",{className:"grid min-w-0 gap-2",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[11px] font-semibold uppercase text-muted",children:"Live journal"}),s.jsx("div",{className:"mt-0.5 truncate font-mono text-[11px] text-muted",children:n.length>0?`${n.length} lines streamed`:"waiting for journal output"})]}),s.jsx("div",{className:"font-mono text-[11px] text-muted",children:"journalctl -f"})]}),i?s.jsx(be,{tone:"error",text:i}):null,s.jsx("div",{ref:o,className:"h-72 overflow-auto rounded-md border border-slate-800 bg-slate-950 p-3 font-mono text-xs leading-relaxed text-slate-100",children:n.length>0?n.map((l,c)=>s.jsx("div",{className:"break-words [overflow-wrap:anywhere]",children:l.line},`${l.unit}-${c}`)):s.jsx("div",{className:"text-slate-400",children:"No journal lines received yet."})})]})}function Xg({data:e,loading:t}){var h,m,p,w,y,v;if(t&&!e)return s.jsx(J,{text:"Loading process activity..."});if(!e)return s.jsx(J,{text:"No process snapshot available."});const n=e.executor.children??[],r=n.flatMap(b=>Oc(b)),i=r.reduce((b,N)=>b+N.cpu_ticks,0),a=r.reduce((b,N)=>b+Zg(N),0),o=e.executor.service==="active",l=r.slice(0,8).map(b=>({label:`pid ${b.pid}`,ticks:b.cpu_ticks})),c=(e.samples??[]).map(b=>({label:ir(b.ts),ticks:b.cpu_ticks,io:b.io_bytes,active:b.active_since_last_sample?"active":"quiet"})),u=c.length>0?c:l,d=(h=e.samples)==null?void 0:h[e.samples.length-1];return s.jsxs("div",{className:"grid gap-4",children:[s.jsx("div",{className:"rounded-md border border-slate-200 bg-slate-50 p-3",children:s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("span",{className:Q("inline-flex h-6 items-center rounded-full border px-2 text-xs font-semibold",o?"border-emerald-300 bg-emerald-50 text-emerald-700":"border-slate-300 bg-white text-slate-600"),children:o?"active":"idle"}),s.jsxs("span",{className:"font-mono text-xs text-muted",children:["service ",e.executor.service]})]}),s.jsx("div",{className:"mt-2 text-sm font-semibold text-foreground",children:e.running_jobs.length>0?`${e.running_jobs.length} running job${e.running_jobs.length===1?"":"s"}`:"No running jobs"}),e.running_jobs.length>0?s.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:e.running_jobs.slice(0,4).map(b=>s.jsxs("span",{className:"inline-flex min-h-6 items-center gap-1.5 rounded-full border border-blue-200 bg-white px-2 font-mono text-[11px] font-semibold text-blue-700",children:[s.jsx("span",{className:"h-2 w-2 rounded-full bg-blue-600 animate-live-pulse","aria-hidden":!0}),"#",b.id," ",Xe(b.age_seconds)]},b.id))}):null,d?s.jsxs("p",{className:"mt-1 text-xs text-muted",children:["Last persisted sample ",ir(d.ts)," ยท ",d.active_since_last_sample?"activity observed":`quiet ${Xe(d.idle_seconds)}`]}):null,s.jsx("p",{className:"mt-1 text-xs text-muted",children:e.detail})]}),s.jsxs("div",{className:"grid min-w-[190px] grid-cols-3 gap-2 text-center text-xs",children:[s.jsx(bs,{label:"PID",value:e.executor.pid?String(e.executor.pid):"n/a"}),s.jsx(bs,{label:"Children",value:String(r.length)}),s.jsx(bs,{label:"CPU ticks",value:String(i)})]})]})}),s.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[s.jsx(Tr,{label:"Live process",value:((m=e.signals)==null?void 0:m.live_process.state)??(r.length>0?"live":"no_child_process"),detail:`${((p=e.signals)==null?void 0:p.live_process.child_count)??r.length} children`}),s.jsx(Tr,{label:"Process activity",value:((w=e.signals)==null?void 0:w.process_activity.state)??(d!=null&&d.active_since_last_sample?"active":"quiet"),detail:d?`sample ${ir(d.ts)}`:"no sample"}),s.jsx(Tr,{label:"Semantic progress",value:(y=e.signals)!=null&&y.semantic_progress.length?"recent":"none",detail:Zo(e.running_jobs,"semantic_progress")}),s.jsx(Tr,{label:"Visible progress",value:(v=e.signals)!=null&&v.visible_progress.length?"streaming":"none",detail:Zo(e.running_jobs,"visible_progress")})]}),e.alerts.length>0?s.jsx(be,{tone:"error",text:e.alerts[0]}):null,s.jsxs("div",{className:"grid gap-4 lg:grid-cols-[minmax(0,0.9fr)_minmax(0,1.1fr)]",children:[s.jsxs("div",{className:"min-w-0 rounded-md border border-border p-3",children:[s.jsxs("div",{className:"mb-3 flex items-center justify-between gap-3",children:[s.jsxs("h3",{className:"flex items-center gap-2 text-sm font-semibold",children:[s.jsx(ro,{className:"h-4 w-4","aria-hidden":!0}),c.length>0?"CPU history":"CPU ticks"]}),s.jsxs("span",{className:"font-mono text-xs text-muted",children:[Dc(a)," I/O"]})]}),u.length>0?s.jsx("div",{className:"h-40",children:s.jsx(ln,{width:"100%",height:"100%",children:s.jsxs(dl,{data:u,children:[s.jsx(Ln,{strokeDasharray:"3 3"}),s.jsx(Mn,{dataKey:"label",tick:!1}),s.jsx(sn,{allowDecimals:!1,tick:{fontSize:11}}),s.jsx(cn,{formatter:b=>[Number(b),"cpu ticks"]}),s.jsx(ti,{type:"monotone",dataKey:"ticks",stroke:"#0f766e",strokeWidth:2,dot:{r:3},activeDot:{r:5},isAnimationActive:!1})]})})}):s.jsx(J,{text:"No executor CPU samples available."})]}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("h3",{className:"mb-2 flex items-center gap-2 text-sm font-semibold",children:[s.jsx(ro,{className:"h-4 w-4","aria-hidden":!0}),"Executor children"]}),n.length>0?s.jsx("div",{className:"grid gap-2",children:n.map(b=>s.jsx(Mc,{process:b},b.pid))}):s.jsx(J,{text:"No child process detected for the executor."})]})]})]})}function Yg({alerts:e,loading:t,now:n}){if(t&&!e)return s.jsx(J,{text:"Loading monitor alerts..."});const r=e??[];return r.length===0?s.jsx(J,{text:"No active monitor alerts."}):s.jsx("div",{className:"grid gap-2",children:r.slice(0,5).map(i=>s.jsxs("div",{className:"rounded-md border border-red-200 bg-red-50 p-2.5",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs font-semibold text-red-700",children:[s.jsx(Hr,{className:"h-3.5 w-3.5","aria-hidden":!0}),s.jsx("span",{children:i.severity}),s.jsx("span",{className:"font-normal text-red-600",children:vc(i.last_seen,n)}),i.observations>1?s.jsxs("span",{className:"rounded-full border border-red-200 bg-white px-1.5",children:[i.observations,"x"]}):null]}),s.jsx("p",{className:"mt-1 break-words text-sm font-medium text-red-950 [overflow-wrap:anywhere]",children:i.message})]},i.fingerprint))})}function Mc({process:e}){var r,i;const t=((r=e.io_bytes)==null?void 0:r.read_bytes)??0,n=((i=e.io_bytes)==null?void 0:i.write_bytes)??0;return s.jsxs("div",{className:"rounded-md border border-border bg-white p-2.5",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[s.jsxs("span",{className:"font-mono",children:["pid ",e.pid]}),s.jsxs("span",{className:"rounded-full border border-border px-2 text-xs text-muted",children:["state ",e.state]}),s.jsxs("span",{className:"rounded-full border border-border px-2 text-xs text-muted",children:["cpu ",e.cpu_ticks]}),s.jsxs("span",{className:"rounded-full border border-border px-2 text-xs text-muted",children:["I/O ",Dc(t+n)]})]}),s.jsx("div",{className:"mt-2 break-words font-mono text-xs text-muted",children:e.cmd||"unknown command"}),e.children&&e.children.length>0?s.jsx("div",{className:"mt-3 border-l-2 border-border pl-3",children:e.children.map(a=>s.jsx(Mc,{process:a},a.pid))}):null]})}function bs({label:e,value:t}){return s.jsxs("div",{className:"rounded-md border border-border bg-white px-2 py-2",children:[s.jsx("div",{className:"font-mono text-sm font-semibold text-foreground",children:t}),s.jsx("div",{className:"mt-0.5 text-[11px] font-semibold uppercase text-muted",children:e})]})}function Tr({label:e,value:t,detail:n}){return s.jsxs("div",{className:"min-w-0 rounded-md border border-border bg-white p-2.5",children:[s.jsx("div",{className:"text-[11px] font-semibold uppercase text-muted",children:e}),s.jsx("div",{className:"mt-1 truncate text-sm font-semibold text-foreground",children:t}),s.jsx("div",{className:"mt-1 truncate font-mono text-[11px] text-muted",children:n})]})}function Zo(e,t){const n=e.find(i=>i[t]),r=n==null?void 0:n[t];return!n||!r?"no running heartbeat":`#${n.id} ${r.phase} ${Xe(r.age_seconds??null)}`}function Oc(e){return[e,...(e.children??[]).flatMap(t=>Oc(t))]}function Zg(e){var t,n;return(((t=e.io_bytes)==null?void 0:t.read_bytes)??0)+(((n=e.io_bytes)==null?void 0:n.write_bytes)??0)}function Dc(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KiB`:`${(e/(1024*1024)).toFixed(1)} MiB`}function $({label:e,value:t}){return s.jsxs("div",{className:"min-w-0 rounded-md border border-border p-3",children:[s.jsx("div",{className:"text-xs font-semibold text-muted",children:e}),s.jsx("div",{className:"mt-1 min-w-0 break-words text-sm [overflow-wrap:anywhere]",children:t})]})}function _i({status:e}){const t=vx(e),n=e==="running"||e==="pending";return s.jsxs("span",{className:Q("inline-flex min-h-6 items-center gap-1.5 rounded-full border px-2 text-xs font-semibold",t.badge),children:[s.jsx("span",{className:Q("h-2.5 w-2.5 rounded-full",t.dot,n&&"animate-live-pulse"),"aria-hidden":!0}),e]})}function J({text:e}){return s.jsx("div",{className:"rounded-md border border-dashed border-border p-6 text-center text-sm text-muted",children:e})}function be({tone:e,text:t}){return s.jsx("div",{className:Q("rounded-md border p-3 text-sm",e==="error"&&"border-red-300 bg-red-50 text-red-700",e==="warning"&&"border-amber-300 bg-amber-50 text-amber-800"),children:t})}function nt({onClick:e,compactOnMobile:t=!1}){return s.jsxs("button",{className:Q("inline-flex h-8 items-center justify-center gap-2 rounded-md border border-border text-sm font-semibold text-foreground hover:bg-slate-50",t?"w-8 px-0 sm:w-auto sm:px-3":"px-3"),onClick:e,type:"button","aria-label":"Refresh",children:[s.jsx(zn,{className:"h-4 w-4","aria-hidden":!0}),s.jsx("span",{className:Q(t&&"hidden sm:inline"),children:"Refresh"})]})}const el=document.getElementById("root");el&&xu.createRoot(el).render(s.jsx(R.StrictMode,{children:s.jsx(Hu,{client:ux,children:s.jsx(Bx,{})})})); +}`;return s.jsxs(se,{title:"Connect an agent",children:[i?s.jsx(be,{tone:"warning",text:"Set GITHUB_AGENT_BRIDGE_DASHBOARD_PUBLIC_URL, or forward X-Forwarded-* headers from the proxy, before connecting remote agents."}):null,s.jsxs("div",{className:"grid gap-4 lg:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]",children:[s.jsxs("div",{className:"grid min-w-0 gap-3",children:[s.jsxs("div",{className:"min-w-0 rounded-md border border-border bg-white p-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm font-semibold",children:[s.jsx(on,{className:"h-4 w-4 text-muted","aria-hidden":!0}),"Public dashboard URL",s.jsx("span",{className:"rounded-sm border border-border bg-slate-50 px-1.5 py-0.5 font-mono text-[11px] font-normal text-muted",children:r})]}),s.jsx("p",{className:"mt-1 text-xs text-muted",children:"Share this page URL with bridge admins only after it resolves to the external dashboard origin."}),s.jsx("pre",{className:"mt-3 overflow-auto rounded-md bg-slate-950 px-3 py-2 font-mono text-xs text-slate-100",children:a})]}),s.jsxs("div",{className:"min-w-0 rounded-md border border-border bg-white p-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[s.jsx(on,{className:"h-4 w-4 text-muted","aria-hidden":!0}),"HTTP MCP endpoint"]}),s.jsx("p",{className:"mt-1 text-xs text-muted",children:"Remote agents connect directly with a bearer token; no local `gab` binary is required on the agent host."}),s.jsx("pre",{className:"mt-3 overflow-auto rounded-md bg-slate-950 px-3 py-2 font-mono text-xs text-slate-100",children:o})]})]}),s.jsxs("div",{className:"grid min-w-0 gap-3",children:[s.jsxs("div",{className:"min-w-0 rounded-md border border-border bg-white p-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[s.jsx(Dr,{className:"h-4 w-4 text-muted","aria-hidden":!0}),"Agent config"]}),s.jsx("p",{className:"mt-1 text-xs text-muted",children:"Create a token below, then store the one-time secret as `GITHUB_AGENT_BRIDGE_MCP_TOKEN` for the agent."}),s.jsx("pre",{className:"mt-3 max-h-64 overflow-auto rounded-md bg-slate-950 px-3 py-2 font-mono text-xs leading-relaxed text-slate-100",children:c})]}),s.jsxs("div",{className:"min-w-0 rounded-md border border-border bg-white p-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[s.jsx(oi,{className:"h-4 w-4 text-muted","aria-hidden":!0}),"Agent prompt"]}),s.jsx("p",{className:"mt-1 text-xs text-muted",children:"Ask the agent to use the read-only bridge knowledge server before acting on repository work."}),s.jsx("pre",{className:"mt-3 max-h-40 overflow-auto rounded-md bg-slate-950 px-3 py-2 font-mono text-xs leading-relaxed text-slate-100",children:"Use the github-agent-bridge MCP server for repository knowledge. Query list_repositories and list_knowledge before making repository decisions."})]})]})]})]})}function Cc({icon:e,title:t,subtitle:n,action:r}){return s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("h2",{className:"flex items-center gap-2 text-base font-semibold",children:[e,t]}),s.jsx("p",{className:"text-xs text-muted",children:n})]}),r]})}function hg({tokens:e,loading:t,now:n,ownerOptions:r,canManageOwners:i,revokingId:a,updatingOwnerId:o,onUpdateOwner:l,onRevoke:c}){return t&&e.length===0?s.jsx(J,{text:"Loading MCP tokens..."}):e.length===0?s.jsx(J,{text:"No active MCP tokens."}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"grid gap-2 md:hidden",children:e.map(u=>s.jsxs("article",{className:"grid min-w-0 gap-3 rounded-md border border-border bg-white p-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("h3",{className:"break-words text-sm font-semibold [overflow-wrap:anywhere]",children:u.name}),s.jsx("div",{className:"mt-1 break-all font-mono text-xs text-muted",children:u.id}),i?s.jsx(Go,{token:u,ownerOptions:r,disabled:o===u.id,onUpdateOwner:l}):u.user_login?s.jsxs("div",{className:"mt-1 text-xs text-muted",children:["Lifecycle owner: @",u.user_login]}):null]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[s.jsx($,{label:"Created",value:s.jsx(ue,{value:u.created_at,relative:!0,now:n})}),s.jsx($,{label:"Last used",value:u.last_used_at?s.jsx(ue,{value:u.last_used_at,relative:!0,now:n}):"never"})]}),s.jsxs("button",{className:"inline-flex h-8 items-center justify-center gap-2 rounded-md border border-red-200 px-3 text-sm font-semibold text-red-700 hover:bg-red-50 disabled:cursor-not-allowed disabled:opacity-60",type:"button",disabled:a===u.id,onClick:()=>c(u.id),children:[s.jsx(Ls,{className:"h-4 w-4","aria-hidden":!0}),a===u.id?"Revoking...":"Revoke"]})]},u.id))}),s.jsx("div",{className:"hidden overflow-auto rounded-md border border-border md:block",children:s.jsxs("table",{className:"min-w-full border-collapse text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-border bg-slate-50 text-left text-xs text-muted",children:[s.jsx("th",{className:"px-3 py-2 font-semibold",children:"Name"}),s.jsx("th",{className:"px-3 py-2 font-semibold",children:"Lifecycle owner"}),s.jsx("th",{className:"px-3 py-2 font-semibold",children:"Created"}),s.jsx("th",{className:"px-3 py-2 font-semibold",children:"Last used"}),s.jsx("th",{className:"px-3 py-2 font-semibold",children:"ID"}),s.jsx("th",{className:"px-3 py-2 text-right font-semibold",children:"Actions"})]})}),s.jsx("tbody",{children:e.map(u=>s.jsxs("tr",{className:"border-b border-border last:border-b-0",children:[s.jsx("td",{className:"px-3 py-3 font-semibold",children:u.name}),s.jsx("td",{className:"px-3 py-3 text-xs text-muted",children:i?s.jsx(Go,{token:u,ownerOptions:r,disabled:o===u.id,onUpdateOwner:l}):u.user_login?`@${u.user_login}`:"unassigned"}),s.jsx("td",{className:"px-3 py-3 font-mono text-xs",children:s.jsx(ue,{value:u.created_at,relative:!0,now:n})}),s.jsx("td",{className:"px-3 py-3 font-mono text-xs",children:u.last_used_at?s.jsx(ue,{value:u.last_used_at,relative:!0,now:n}):"never"}),s.jsx("td",{className:"px-3 py-3 font-mono text-xs text-muted",children:u.id}),s.jsx("td",{className:"px-3 py-3 text-right",children:s.jsxs("button",{className:"inline-flex h-8 items-center gap-2 rounded-md border border-red-200 px-3 text-sm font-semibold text-red-700 hover:bg-red-50 disabled:cursor-not-allowed disabled:opacity-60",type:"button",disabled:a===u.id,onClick:()=>c(u.id),children:[s.jsx(Ls,{className:"h-4 w-4","aria-hidden":!0}),a===u.id?"Revoking...":"Revoke"]})})]},u.id))})]})})]})}function Go({token:e,ownerOptions:t,disabled:n,onUpdateOwner:r}){const i=e.user_login??"";return s.jsx(Pc,{ariaLabel:`Lifecycle owner for ${e.name}`,value:i,ownerOptions:t,disabled:n||t.length===0,emptyLabel:"Select owner",size:"compact",onChange:a=>{!a||a===e.user_login||r(e.id,a)}})}function Pc({value:e,ownerOptions:t,disabled:n,onChange:r,ariaLabel:i,selectedSuffix:a,emptyLabel:o,size:l="default"}){const c=t.find(d=>d.login===e),u=c?`@${c.login}${(a==null?void 0:a(c))??""}`:o;return s.jsxs("div",{className:Q("relative flex min-w-0 items-center gap-2 rounded-md border border-border bg-panel text-foreground focus-within:border-primary focus-within:ring-1 focus-within:ring-primary",n?"opacity-60":"",l==="compact"?"h-8 w-44 max-w-full px-2":"h-9 w-full px-2.5"),children:[s.jsx("span",{className:Q("pointer-events-none flex shrink-0 items-center justify-center",l==="compact"?"h-5 w-5":"h-6 w-6"),children:c!=null&&c.avatar_url?s.jsx("img",{className:"h-full w-full rounded-full bg-slate-100",src:rt(c.avatar_url),alt:"",referrerPolicy:"no-referrer"}):s.jsx(An,{className:Q("text-muted",l==="compact"?"h-4 w-4":"h-5 w-5"),"aria-hidden":!0})}),s.jsx("span",{className:Q("pointer-events-none min-w-0 flex-1 truncate font-mono",c?"text-foreground":"text-muted",l==="compact"?"text-xs":"text-sm"),children:u}),s.jsxs("select",{className:"absolute inset-0 h-full w-full cursor-pointer opacity-0 disabled:cursor-not-allowed","aria-label":i,value:e,disabled:n,onChange:d=>r(d.target.value),children:[t.length===0||!e?s.jsx("option",{value:"",children:o}):null,t.map(d=>s.jsxs("option",{value:d.login,children:["@",d.login,(a==null?void 0:a(d))??""]},d.login))]}),s.jsx(Dn,{className:Q("pointer-events-none shrink-0 text-muted",l==="compact"?"h-3.5 w-3.5":"h-4 w-4"),"aria-hidden":!0})]})}function dr({urls:e,compact:t=!1}){const n=t?e.slice(0,2):e,r=e.length-n.length;return s.jsxs("div",{className:"flex min-w-0 max-w-full flex-wrap gap-1.5",children:[n.map(i=>s.jsxs("a",{className:Q("inline-flex max-w-full items-center gap-1 rounded-md border border-border font-semibold text-primary hover:bg-white hover:underline",t?"h-7 px-2 text-xs":"min-h-7 px-2 py-1 text-xs"),href:rt(i),"aria-label":i,rel:"noreferrer",target:"_blank",children:[s.jsx(on,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),s.jsx("span",{className:"truncate",children:t?pg(i):i})]},i)),r>0?s.jsxs("span",{className:"inline-flex h-7 items-center rounded-md border border-border px-2 font-mono text-xs text-muted",children:["+",r]}):null]})}function pg(e){try{const t=new URL(e);return t.pathname.replace(/^\//,"")+t.hash}catch{return e}}function Ec({scope:e,type:t,confidence:n,status:r,timestamp:i,now:a}){return s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2 text-xs text-muted",children:[s.jsx("span",{className:"truncate font-mono font-semibold text-foreground",children:Nc(e)}),s.jsx("span",{className:"rounded-sm border border-border px-1.5 py-0.5 font-mono",children:t}),s.jsxs("span",{className:"rounded-sm border border-border px-1.5 py-0.5 font-mono",children:[Math.round(n*100),"%"]}),s.jsx("span",{className:"rounded-sm border border-border px-1.5 py-0.5 font-mono",children:r}),s.jsx("span",{className:"font-mono",children:s.jsx(ue,{value:i,relative:!0,now:a})})]})}function mg({user:e,loading:t}){const n=e!=null&&e.login?`@${e.login}`:t?"Loading profile...":"GitHub OAuth",r=e!=null&&e.is_admin?"admin":"read-only",i=e!=null&&e.avatar_url?s.jsx("img",{className:"h-10 w-10 rounded-full border border-slate-700 bg-slate-800",src:e.avatar_url,alt:e.login?`${e.login} avatar`:"",referrerPolicy:"no-referrer"}):s.jsx("span",{className:"inline-flex h-10 w-10 items-center justify-center rounded-full border border-slate-700 bg-slate-900",children:s.jsx(An,{className:"h-5 w-5","aria-hidden":!0})}),a=e!=null&&e.html_url?s.jsx("a",{className:"truncate font-semibold text-white hover:underline",href:rt(e.html_url),rel:"noreferrer",target:"_blank",children:n}):s.jsx("div",{className:"truncate font-semibold text-white",children:n});return s.jsxs("div",{className:"flex max-w-full shrink-0 items-center gap-3 text-sm text-slate-300","aria-label":e!=null&&e.login?`Signed in as ${e.login}`:"Dashboard account",children:[s.jsx(Tl,{className:"hidden h-4 w-4 shrink-0 sm:block","aria-hidden":!0}),s.jsxs("div",{className:"hidden min-w-0 text-right sm:block",children:[a,s.jsxs("div",{className:"text-xs text-slate-400",children:["Signed in ยท ",r]})]}),i,e!=null&&e.login?s.jsx("form",{action:"/auth/logout",method:"post",children:s.jsx("button",{className:"rounded-md border border-slate-700 px-2 py-1 text-xs font-semibold text-slate-300 hover:bg-slate-800 hover:text-white",type:"submit",children:"Sign out"})}):null]})}function fg({config:e,loading:t,onEnable:n,onDisable:r}){const[i,a]=R.useState(!1),[o,l]=R.useState(""),c=!!(e!=null&&e.status.enabled),u=typeof navigator<"u"&&typeof window<"u"&&Lr(),d=t||i||!(e!=null&&e.configured)||!u,h=u?e!=null&&e.configured?c?"Disable notifications":"Enable notifications":"Notifications not configured":"Notifications unavailable";return s.jsx("div",{className:"relative",children:s.jsx("button",{className:Q("inline-flex h-9 w-9 items-center justify-center rounded-md border text-sm font-semibold",c?"border-emerald-400 bg-emerald-50 text-emerald-700":"border-slate-700 bg-slate-900 text-slate-200",d&&"cursor-not-allowed opacity-60"),type:"button","aria-label":h,title:o||h,disabled:d,onClick:async()=>{a(!0),l("");try{c?await r():await n()}catch(m){l(m instanceof Error?m.message:String(m))}finally{a(!1)}},children:s.jsx(El,{className:Q("h-4 w-4",i&&"animate-live-pulse"),"aria-hidden":!0})})})}function xg({notification:e,onDismiss:t,onNavigate:n}){if(!e)return null;const r=e.title||"GitHub Agent Bridge",i=e.body||e.summary||"Bridge job finished",a=e.url||e.job_url||(e.job_id?Un(e.job_id):"/"),o=a.startsWith("/");return s.jsx("aside",{className:"fixed right-3 top-20 z-50 w-[min(calc(100vw-1.5rem),28rem)] rounded-md border border-emerald-300 bg-white shadow-xl shadow-slate-950/15","aria-live":"assertive","aria-label":"Bridge notification",children:s.jsxs("div",{className:"flex items-start gap-3 p-3",children:[s.jsx("div",{className:"mt-0.5 flex h-9 w-9 shrink-0 items-center justify-center rounded-md bg-emerald-50 text-emerald-700",children:s.jsx(El,{className:"h-4 w-4","aria-hidden":!0})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsx("h2",{className:"min-w-0 break-words text-sm font-semibold text-foreground",children:r}),s.jsx("button",{className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted hover:bg-slate-100 hover:text-foreground",type:"button","aria-label":"Dismiss notification",onClick:t,children:s.jsx(un,{className:"h-4 w-4","aria-hidden":!0})})]}),s.jsx("p",{className:"mt-1 min-w-0 break-words text-sm text-muted",children:i}),e.detail?s.jsx("p",{className:"mt-1 line-clamp-2 min-w-0 break-words text-xs text-muted",children:e.detail}):null,s.jsxs("button",{className:"mt-3 inline-flex h-8 items-center gap-1.5 rounded-md border border-border px-2.5 text-xs font-semibold text-foreground hover:bg-slate-50",type:"button",onClick:()=>{t(),o?n(a):window.open(rt(a),"_blank","noopener,noreferrer")},children:[s.jsx(on,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Open"]})]})]})})}function gg({count:e,limit:t,loading:n,onRefresh:r}){return s.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-center gap-3 rounded-lg border border-border bg-white px-3 py-3 shadow-sm md:px-4",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("h2",{className:"text-base font-semibold",children:"Jobs"}),s.jsx("p",{className:"text-xs text-muted",children:n?"Refreshing latest jobs...":`Showing ${e} of the latest ${t} requested jobs`})]}),s.jsx(nt,{onClick:r,compactOnMobile:!0})]})}function se({title:e,action:t,children:n,className:r,flushHeader:i=!1}){return s.jsxs("section",{className:Q("min-w-0 rounded-lg border border-border bg-panel p-4 shadow-sm",r),children:[s.jsxs("div",{className:Q("flex flex-wrap items-center justify-between gap-3",!i&&"mb-4"),children:[s.jsx("h2",{className:"text-sm font-semibold",children:e}),t]}),n]})}function Ae({title:e,value:t,icon:n}){return s.jsxs("div",{className:"rounded-lg border border-border bg-panel p-3 shadow-sm md:p-4",children:[s.jsxs("div",{className:"flex items-center justify-between text-muted",children:[s.jsx("span",{className:"text-sm font-medium",children:e}),n]}),s.jsx("strong",{className:"mt-3 block text-2xl leading-none md:mt-4 md:text-3xl",children:t})]})}const bg=[{value:"24h",label:"24 hours"},{value:"7d",label:"7 days"},{value:"30d",label:"30 days"}],fs=[{key:"blocked",label:"Blocked",detail:"finished service jobs",color:"#dc2626"},{key:"no_op",label:"No-op",detail:"finished service jobs",color:"#7c3aed"},{key:"retry",label:"Retried",detail:"claimed service jobs",color:"#d97706"},{key:"coalescing",label:"Coalesced",detail:"ingested notifications",color:"#0284c7"}],yg=[{key:"source_received_to_queued",label:"Source โ†’ queue"},{key:"queued_to_claimed",label:"Queue โ†’ claim"},{key:"claimed_to_first_output",label:"Claim โ†’ first output"},{key:"claimed_to_done",label:"Claim โ†’ done"}];function wg({summary:e,loading:t,window:n,onWindowChange:r,onRefresh:i}){const a=s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("div",{className:"inline-flex h-8 rounded-md border border-border bg-white p-0.5",role:"group","aria-label":"SLO window",children:bg.map(c=>s.jsx("button",{className:Q("rounded px-2.5 text-xs font-semibold",n===c.value?"bg-primary text-white":"text-muted hover:bg-slate-50"),type:"button","aria-label":c.label,"aria-pressed":n===c.value,onClick:()=>r(c.value),children:c.value},c.value))}),s.jsx(nt,{onClick:i,compactOnMobile:!0})]});if(t&&!(e!=null&&e.slo))return s.jsx(se,{title:"Service SLOs",action:a,children:s.jsxs("div",{className:"flex min-h-24 items-center justify-center gap-2 rounded-md border border-dashed border-border text-sm text-muted",children:[s.jsx(zn,{className:"h-4 w-4 animate-spin","aria-hidden":!0}),"Loading SLO metricsโ€ฆ"]})});if((e==null?void 0:e.schema_ok)===!1)return s.jsx(se,{title:"Service SLOs",action:a,children:s.jsx(be,{tone:"warning",text:`SLO metrics are unavailable until the database schema is migrated${e.schema_error?`: ${e.schema_error}`:"."}`})});if(!(e!=null&&e.slo))return s.jsx(se,{title:"Service SLOs",action:a,children:s.jsx(J,{text:"No SLO read model is available."})});const o=e.slo,l=o.trends.daily.map(c=>({bucket:c.bucket,blocked:c.rates.blocked.percent,no_op:c.rates.no_op.percent,retry:c.rates.retry.percent,coalescing:c.rates.coalescing.percent}));return s.jsx(se,{title:"Service SLOs",action:a,children:s.jsxs("div",{className:"grid gap-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-x-4 gap-y-1 text-xs text-muted",children:[s.jsxs("span",{children:[s.jsx("strong",{className:"text-foreground",children:o.cohort.sample_count})," finished auto-trusted service job",o.cohort.sample_count===1?"":"s",o.cohort.missing_count>0?` ยท ${o.cohort.missing_count} missing outcome`:"",o.cohort.excluded_count>0?` ยท ${o.cohort.excluded_count} excluded`:""]}),s.jsx("span",{className:"font-mono",children:o.window.timezone})]}),s.jsx("section",{className:"grid gap-2 sm:grid-cols-2 xl:grid-cols-4","aria-label":"SLO reliability rates",children:fs.map(c=>s.jsx(vg,{definition:c,rate:o.rates[c.key]},c.key))}),s.jsxs("section",{"aria-labelledby":"slo-latency-heading",children:[s.jsx("h3",{id:"slo-latency-heading",className:"mb-2 text-xs font-semibold uppercase tracking-wide text-muted",children:"Latency percentiles"}),s.jsx("div",{className:"grid gap-2 sm:grid-cols-2 xl:grid-cols-4",children:yg.map(c=>s.jsx(jg,{label:c.label,latency:o.latencies[c.key]},c.key))})]}),s.jsxs("section",{"aria-labelledby":"slo-trend-heading",children:[s.jsxs("div",{className:"mb-2 flex flex-wrap items-center justify-between gap-2",children:[s.jsx("h3",{id:"slo-trend-heading",className:"text-xs font-semibold uppercase tracking-wide text-muted",children:"Daily reliability trend"}),s.jsx("span",{className:"text-xs text-muted",children:"Percent of each daily cohort"})]}),s.jsx("div",{className:"h-64",role:"img","aria-label":"Daily SLO reliability rates chart",children:s.jsx(ln,{width:"100%",height:"100%",children:s.jsxs(dl,{data:l,children:[s.jsx(Ln,{strokeDasharray:"3 3"}),s.jsx(Mn,{dataKey:"bucket",minTickGap:20,tick:{fontSize:11}}),s.jsx(sn,{domain:[0,100],tickFormatter:c=>`${c}%`,width:44}),s.jsx(Ur,{}),s.jsx(cn,{formatter:(c,u)=>{var d;return[c==null?"n/a":`${Number(c).toLocaleString(void 0,{maximumFractionDigits:2})}%`,((d=fs.find(h=>h.key===u))==null?void 0:d.label)??u]}}),fs.map(c=>s.jsx(ti,{type:"monotone",dataKey:c.key,name:c.label,stroke:c.color,strokeWidth:2,dot:{r:2},activeDot:{r:4},connectNulls:!1,isAnimationActive:!1},c.key))]})})})]})]})})}function vg({definition:e,rate:t}){const n=t.percent===null?"n/a":`${t.percent.toLocaleString(void 0,{maximumFractionDigits:2})}%`;return s.jsxs("div",{className:"rounded-md border border-border bg-slate-50/70 p-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"text-xs font-semibold text-muted",children:e.label}),s.jsx("span",{className:"h-2.5 w-2.5 rounded-full",style:{backgroundColor:e.color},"aria-hidden":!0})]}),s.jsx("strong",{className:"mt-2 block text-2xl leading-none",children:n}),s.jsxs("p",{className:"mt-2 text-xs text-muted",children:[t.numerator," / ",t.denominator," ",e.detail]}),t.missing_count>0?s.jsxs("p",{className:"mt-1 text-xs text-amber-700",children:[t.missing_count," missing sample",t.missing_count===1?"":"s"]}):null,e.key==="retry"&&t.requeued_runs?s.jsxs("p",{className:"mt-1 text-xs text-muted",children:[t.requeued_runs," requeued run",t.requeued_runs===1?"":"s"]}):null]})}function jg({label:e,latency:t}){return s.jsxs("div",{className:"rounded-md border border-border p-3",children:[s.jsx("h4",{className:"text-xs font-semibold text-muted",children:e}),s.jsxs("div",{className:"mt-3 grid grid-cols-3 gap-2 text-center",children:[s.jsx(xs,{label:"p50",value:t.p50}),s.jsx(xs,{label:"p90",value:t.p90}),s.jsx(xs,{label:"p99",value:t.p99})]}),s.jsxs("p",{className:"mt-3 text-xs text-muted",children:[t.sample_count," sample",t.sample_count===1?"":"s",t.missing_count>0?` ยท ${t.missing_count} missing`:""]})]})}function xs({label:e,value:t}){return s.jsxs("div",{children:[s.jsx("div",{className:"font-mono text-sm font-semibold",children:Xe(t)}),s.jsx("div",{className:"mt-0.5 text-[10px] font-semibold uppercase text-muted",children:e})]})}function kg({filters:e,actorOptions:t,onChange:n}){const[r,i]=R.useState(e);R.useEffect(()=>i(e),[e]);const a=qx(e),o=Vo(e)||Vo(r),l=()=>{i(Qs),n(Qs)};return s.jsxs("details",{className:"my-3 rounded-md border border-border bg-slate-50/70",children:[s.jsxs("summary",{className:"grid cursor-pointer list-none grid-cols-[minmax(0,1fr)_auto] items-center gap-3 px-3 py-2 text-sm font-semibold marker:hidden",children:[s.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[s.jsxs("span",{className:"inline-flex shrink-0 items-center gap-2",children:[s.jsx(sd,{className:"h-4 w-4 text-muted","aria-hidden":!0}),"Filters"]}),a.length>0?s.jsx("span",{className:"flex min-w-0 flex-wrap items-center gap-1.5","aria-label":"Applied filters",children:a.map(c=>s.jsxs("span",{className:"inline-flex max-w-full items-center gap-1 rounded-full border border-blue-200 bg-blue-50 px-2 py-0.5 text-xs font-semibold text-blue-700",children:[s.jsx("span",{className:"text-blue-700/70",children:c.label}),s.jsx("span",{className:"max-w-40 truncate font-mono",children:c.value.trim()})]},c.key))}):null]}),s.jsxs("span",{className:"inline-flex shrink-0 items-center gap-2",children:[o?s.jsxs("button",{className:"inline-flex h-8 items-center justify-center gap-1.5 rounded-md border border-border bg-white px-2.5 text-xs font-semibold text-foreground hover:bg-slate-50",type:"button",onClick:c=>{c.preventDefault(),c.stopPropagation(),l()},children:[s.jsx(cr,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Clear filters"]}):null,s.jsx(Dn,{className:"h-4 w-4 text-muted","aria-hidden":!0})]})]}),s.jsxs("form",{className:"grid gap-3 border-t border-border bg-white p-3 md:grid-cols-3 xl:grid-cols-9",onSubmit:c=>{c.preventDefault(),n(r)},children:[s.jsx(ot,{label:"Status",children:s.jsxs("select",{className:"control",value:r.status,onChange:c=>i({...r,status:c.target.value}),children:[s.jsx("option",{value:"",children:"All"}),s.jsx("option",{value:"pending",children:"pending"}),s.jsx("option",{value:"running",children:"running"}),s.jsx("option",{value:"blocked",children:"blocked"}),s.jsx("option",{value:"done",children:"done"}),s.jsx("option",{value:"denied",children:"denied"}),s.jsx("option",{value:"waiting_approval",children:"waiting_approval"})]})}),s.jsx(ot,{label:"Repository",children:s.jsx("input",{className:"control",value:r.repo,placeholder:"owner/repo",onChange:c=>i({...r,repo:c.target.value})})}),s.jsx(ot,{label:"Thread",children:s.jsx("input",{className:"control",value:r.thread,inputMode:"numeric",placeholder:"issue or PR",onChange:c=>i({...r,thread:c.target.value})})}),s.jsx(ot,{label:"Action",children:s.jsx("input",{className:"control",value:r.action,placeholder:"reply_comment",onChange:c=>i({...r,action:c.target.value})})}),s.jsx(ot,{label:"Actor",className:"xl:col-span-2",children:s.jsx(Ng,{value:r.actor,options:t,onChange:c=>i({...r,actor:c})})}),s.jsx(ot,{label:"Intent",children:s.jsxs("select",{className:"control",value:r.intent,onChange:c=>i({...r,intent:c.target.value}),children:[s.jsx("option",{value:"",children:"All"}),s.jsx("option",{value:"review_only",children:"review_only"}),s.jsx("option",{value:"work_allowed",children:"work_allowed"})]})}),s.jsxs("div",{className:"grid grid-cols-2 gap-2 self-end xl:col-span-2",children:[s.jsxs("button",{className:"inline-flex h-9 items-center justify-center gap-2 rounded-md border border-border px-3 text-sm font-semibold text-foreground hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-white",type:"button",disabled:!o,onClick:l,children:[s.jsx(cr,{className:"h-4 w-4","aria-hidden":!0}),"Clear"]}),s.jsxs("button",{className:"inline-flex h-9 items-center justify-center gap-2 rounded-md bg-primary px-3 text-sm font-semibold text-white",type:"submit",children:[s.jsx(ld,{className:"h-4 w-4","aria-hidden":!0}),"Apply"]})]})]})]})}function Ng({value:e,options:t,onChange:n}){const[r,i]=R.useState(!1),a=e.trim().replace(/^@/,"").toLowerCase(),o=t.filter(c=>!a||c.login.toLowerCase().includes(a)).slice(0,8),l=t.find(c=>c.login.toLowerCase()===a);return s.jsxs("div",{className:"relative min-w-0",children:[s.jsxs("div",{className:"control flex items-center gap-2 px-2",children:[l?s.jsx("img",{className:"h-5 w-5 shrink-0 rounded-full bg-slate-100",src:rt(l.avatar_url??""),alt:`${l.login} avatar`,referrerPolicy:"no-referrer"}):s.jsx(An,{className:"h-4 w-4 shrink-0 text-muted","aria-hidden":!0}),s.jsx("input",{className:"min-w-0 flex-1 bg-transparent font-mono text-sm outline-none",value:e,placeholder:"@login",onChange:c=>{n(c.target.value),i(!0)},onFocus:()=>i(!0),onBlur:()=>window.setTimeout(()=>i(!1),100)}),e?s.jsx("button",{className:"rounded-sm p-1 text-muted hover:bg-slate-100",type:"button","aria-label":"Clear actor filter",onClick:()=>n(""),children:s.jsx(un,{className:"h-3.5 w-3.5","aria-hidden":!0})}):null]}),r&&o.length>0?s.jsx("div",{className:"absolute left-0 right-0 z-20 mt-1 max-h-72 overflow-auto rounded-md border border-border bg-white p-1 shadow-lg",children:o.map(c=>s.jsxs("button",{className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-left hover:bg-slate-50",type:"button",onMouseDown:u=>u.preventDefault(),onClick:()=>{n(c.login),i(!1)},children:[c.avatar_url?s.jsx("img",{className:"h-6 w-6 shrink-0 rounded-full bg-slate-100",src:rt(c.avatar_url),alt:`${c.login} avatar`,referrerPolicy:"no-referrer"}):s.jsx(An,{className:"h-5 w-5 shrink-0 text-muted","aria-hidden":!0}),s.jsxs("span",{className:"min-w-0 flex-1 truncate font-mono text-xs text-foreground",children:["@",c.login]}),s.jsx("span",{className:"shrink-0 rounded-full bg-slate-100 px-1.5 py-0.5 text-[10px] font-semibold text-muted",children:c.job_count})]},c.login))}):null]})}function ot({label:e,children:t,className:n}){return s.jsxs("label",{className:Q("grid min-w-0 gap-1 text-xs font-semibold text-muted",n),children:[e,t]})}function Sg({jobs:e,loading:t,loadingMore:n=!1,hasMore:r=!1,onLoadMore:i,onViewJob:a,now:o,user:l,onRetry:c,onDismiss:u,onCancel:d}){const[h,m]=R.useState(null),[p,w]=R.useState(null),[y,v]=R.useState(null),b=R.useRef(!1),N=R.useRef(n),k=!!(l!=null&&l.is_admin&&c),_=!!(l!=null&&l.is_admin&&u);R.useEffect(()=>{N.current&&!n&&(b.current=!1),N.current=n},[n]);const D=R.useCallback(()=>{b.current||(b.current=!0,i==null||i())},[i]),j=R.useCallback(async C=>{if(c){m(C);try{await c(C)}finally{m(null)}}},[c]),B=R.useCallback(async C=>{if(u){w(C);try{await u(C)}finally{w(null)}}},[u]),F=R.useCallback(async(C,M)=>{if(d){v(C);try{await d(C,M)}finally{v(null)}}},[d]);return t&&e.length===0?s.jsx(J,{text:"Loading jobs..."}):e.length===0?s.jsx(J,{text:"No jobs match the current filters."}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"grid gap-2 md:hidden",children:[e.map(C=>s.jsx(Pg,{job:C,onViewJob:a,now:o,canRetry:k&&Vs(C.status)&&C.decision==="auto_trusted",retrying:h===C.id,onRetry:j,canDismiss:_&&Gs(C.status),dismissing:p===C.id,onDismiss:B,canCancel:!!(d&&Js(C,l)),cancelling:y===C.id,onCancel:F},C.id)),s.jsx(Cg,{hasMore:r,loading:n,onLoadMore:D})]}),s.jsx(Xs,{noun:"jobs",hasMore:r,loading:n,onLoadMore:D,className:"hidden md:block",children:s.jsxs("table",{className:"min-w-[1080px] table-fixed border-collapse text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"sticky top-0 z-10 border-b border-border bg-panel text-left text-xs text-muted",children:[s.jsx("th",{className:"w-[42%] px-3 py-2 font-semibold",children:"Job"}),s.jsx("th",{className:"w-32 px-3 py-2 font-semibold",children:"Status"}),s.jsx("th",{className:"w-40 px-3 py-2 font-semibold",children:"Action"}),s.jsx("th",{className:"w-36 px-3 py-2 font-semibold",children:"Actor"}),s.jsx("th",{className:"w-36 px-3 py-2 font-semibold",children:"Timing"}),s.jsx("th",{className:"w-28 px-3 py-2 font-semibold",children:"Updated"}),s.jsx("th",{className:"w-24 px-3 py-2 text-right font-semibold",children:"Actions"})]})}),s.jsx("tbody",{children:e.map(C=>s.jsx(_g,{job:C,now:o,onViewJob:a,canRetry:k&&Vs(C.status)&&C.decision==="auto_trusted",retrying:h===C.id,onRetry:j,canDismiss:_&&Gs(C.status),dismissing:p===C.id,onDismiss:B,canCancel:!!(d&&Js(C,l)),cancelling:y===C.id,onCancel:F},C.id))})]})})]})}function _g({job:e,now:t,onViewJob:n,canRetry:r,retrying:i,onRetry:a,canDismiss:o,dismissing:l,onDismiss:c,canCancel:u,cancelling:d,onCancel:h}){return s.jsxs("tr",{className:"cursor-pointer border-b border-border align-top hover:bg-slate-50",onClick:()=>n(e.id),children:[s.jsx("td",{className:"min-w-0 px-3 py-3",children:s.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[s.jsxs("span",{className:"mt-0.5 shrink-0 font-mono text-xs font-semibold text-muted",children:["#",e.id]}),s.jsxs("div",{className:"min-w-0 space-y-1",children:[s.jsx("div",{className:"line-clamp-2 text-sm font-semibold leading-snug text-foreground [overflow-wrap:anywhere]",title:e.subject,children:e.subject}),s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted",children:[s.jsx("span",{className:"min-w-0 max-w-full truncate font-mono",children:e.repo??e.work_key}),s.jsxs("span",{className:"shrink-0",children:["thread ",e.thread??"n/a"]})]})]})]})}),s.jsx("td",{className:"px-3 py-3",children:s.jsx(_i,{status:e.status})}),s.jsxs("td",{className:"px-3 py-3",children:[s.jsx("div",{className:"min-w-0 truncate text-sm text-foreground",title:e.action,children:e.action}),s.jsx("div",{className:"mt-1",children:s.jsx(Si,{intent:e.intent,actionMode:e.action_mode,display:"intent",compact:!0})})]}),s.jsx("td",{className:"px-3 py-3",children:s.jsx(Hn,{actor:e.trigger_actor,avatarUrl:e.trigger_actor_avatar_url})}),s.jsxs("td",{className:"px-3 py-3 text-xs text-muted",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{children:"wait"}),s.jsx("span",{className:"font-mono text-foreground",children:Xe(Ni(e,t))})]}),s.jsxs("div",{className:"mt-1 flex items-center justify-between gap-2",children:[s.jsx("span",{children:"run"}),s.jsx("span",{className:"font-mono text-foreground",children:Xe(ki(e,t))})]}),s.jsxs("div",{className:"mt-1 flex items-center justify-between gap-2",children:[s.jsx("span",{children:"tries"}),s.jsx("span",{className:"font-mono text-foreground",children:e.attempts})]})]}),s.jsx("td",{className:"px-3 py-3 font-mono text-xs",children:s.jsx(ue,{value:e.updated_at,compact:!0,relative:!0,now:t})}),s.jsx("td",{className:"px-3 py-3 text-right",children:s.jsxs("div",{className:"inline-flex items-center gap-1",children:[s.jsx(Rc,{jobId:e.id,canRetry:r,retrying:i,onRetry:a,compact:!0}),s.jsx(Ic,{jobId:e.id,canDismiss:o,dismissing:l,onDismiss:c,compact:!0}),s.jsx(Tc,{jobId:e.id,canCancel:u,cancelling:d,onCancel:h,compact:!0})]})})]})}function Cg({hasMore:e,loading:t,onLoadMore:n}){return!e&&!t?null:s.jsxs("button",{className:"inline-flex min-h-10 w-full items-center justify-center gap-2 rounded-md border border-border px-3 py-2 text-sm font-semibold text-foreground hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-60 md:hidden",type:"button",disabled:t||!e,onClick:()=>n==null?void 0:n(),children:[s.jsx(Dn,{className:"h-4 w-4","aria-hidden":!0}),t?"Loading more jobs...":"Load more jobs"]})}function Pg({job:e,onViewJob:t,now:n,canRetry:r,retrying:i,onRetry:a,canDismiss:o,dismissing:l,onDismiss:c,canCancel:u,cancelling:d,onCancel:h}){return s.jsxs("article",{className:"rounded-md border border-border bg-white shadow-[0_1px_0_rgba(15,23,42,0.03)]",children:[s.jsxs("button",{className:"grid w-full gap-2 p-3 text-left hover:bg-slate-50",type:"button",onClick:()=>t(e.id),children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"min-w-0 space-y-1",children:[s.jsxs("div",{className:"grid min-w-0 grid-cols-[auto_minmax(0,1fr)] items-center gap-2",children:[s.jsxs("span",{className:"shrink-0 font-mono text-xs font-semibold text-muted",children:["#",e.id]}),s.jsx("span",{className:"truncate font-mono text-sm",children:e.repo??e.work_key})]}),s.jsx("div",{className:"line-clamp-2 text-sm leading-snug text-foreground",children:e.subject}),s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted",children:[s.jsxs("span",{children:["thread ",e.thread??"n/a"," ยท ",e.action]}),s.jsx(Si,{intent:e.intent,actionMode:e.action_mode,compact:!0,display:"intent"}),s.jsx(Hn,{actor:e.trigger_actor,avatarUrl:e.trigger_actor_avatar_url})]})]}),s.jsx(_i,{status:e.status})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-2 text-xs",children:[s.jsx($,{label:"Wait",value:Xe(Ni(e,n))}),s.jsx($,{label:"Runtime",value:Xe(ki(e,n))}),s.jsx($,{label:"Updated",value:s.jsx(ue,{value:e.updated_at,compact:!0,relative:!0,now:n})})]})]}),r||o||u?s.jsxs("div",{className:"flex flex-wrap gap-2 border-t border-border px-3 py-2",children:[s.jsx(Rc,{jobId:e.id,canRetry:r,retrying:i,onRetry:a}),s.jsx(Ic,{jobId:e.id,canDismiss:o,dismissing:l,onDismiss:c}),s.jsx(Tc,{jobId:e.id,canCancel:u,cancelling:d,onCancel:h})]}):null]})}function Rc({jobId:e,canRetry:t,retrying:n,onRetry:r,compact:i=!1}){if(!t)return null;const a=n?"Retrying...":"Retry";return s.jsxs("button",{className:Q("inline-flex h-8 items-center justify-center gap-2 rounded-md border border-border text-sm font-semibold text-foreground hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-60",i?"w-8 px-0":"px-3"),type:"button",disabled:n,"aria-label":`Retry job #${e}`,title:`Retry job #${e}`,onClick:async o=>{o.stopPropagation(),window.confirm(`Retry job #${e}?`)&&await r(e)},children:[s.jsx(cr,{className:"h-4 w-4","aria-hidden":!0}),s.jsx("span",{className:Q(i&&"sr-only"),children:a})]})}function Ic({jobId:e,canDismiss:t,dismissing:n,onDismiss:r,compact:i=!1}){if(!t)return null;const a=n?"Dismissing...":"Dismiss";return s.jsxs("button",{className:Q("inline-flex h-8 items-center justify-center gap-2 rounded-md border border-border text-sm font-semibold text-foreground hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-60",i?"w-8 px-0":"px-3"),type:"button",disabled:n,"aria-label":`Dismiss job #${e}`,title:`Dismiss job #${e}`,onClick:async o=>{o.stopPropagation(),window.confirm(`Dismiss job #${e}?`)&&await r(e)},children:[s.jsx(On,{className:"h-4 w-4","aria-hidden":!0}),s.jsx("span",{className:Q(i&&"sr-only"),children:a})]})}function Tc({jobId:e,canCancel:t,cancelling:n,onCancel:r,compact:i=!1}){if(!t)return null;const a=n?"Cancelling...":"Cancel";return s.jsxs("button",{className:Q("inline-flex h-8 items-center justify-center gap-2 rounded-md border border-red-200 bg-red-50 text-sm font-semibold text-red-700 hover:bg-red-100 disabled:cursor-not-allowed disabled:opacity-60",i?"w-8 px-0":"px-3"),type:"button",disabled:n,"aria-label":`Cancel job #${e}`,title:`Cancel job #${e}`,onClick:async o=>{o.stopPropagation();const l=window.prompt(`Cancel job #${e}? Optional reason:`);l!==null&&await r(e,l)},children:[s.jsx(un,{className:"h-4 w-4","aria-hidden":!0}),s.jsx("span",{className:Q(i&&"sr-only"),children:a})]})}function Hn({actor:e,avatarUrl:t,framed:n=!1}){const r=t?s.jsx("img",{className:"h-4 w-4 shrink-0 rounded-full bg-slate-100",src:rt(t),alt:e?`${e} avatar`:"",referrerPolicy:"no-referrer"}):s.jsx(An,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),i=s.jsxs(s.Fragment,{children:[r,s.jsx("span",{className:"min-w-0 truncate",children:e?`@${e}`:"unknown actor"})]});return n?s.jsx("span",{className:"inline-flex h-7 max-w-full items-center gap-1 rounded-md border border-border px-2 text-xs font-semibold text-muted",children:i}):s.jsx("span",{className:"inline-flex min-w-0 max-w-full items-center gap-1 font-mono text-xs text-muted",children:i})}function Eg(e){return(e==null?void 0:e.model)??"OpenClaw default"}function Rg(e){return(e==null?void 0:e.thinking)??"OpenClaw default"}function Ig(e){return e?e.configured?"configured":e.summary:"n/a"}function Tg(e,t){const n=t||(e==="work_allowed"?"fix_allowed":"review_only");return n==="fix_allowed"||!t&&e==="work_allowed"?{mode:n,intentLabel:"work_allowed",title:"Work allowed"}:{mode:n,intentLabel:"review_only",title:"Review only"}}function Si({intent:e,actionMode:t,compact:n=!1,display:r="mode"}){const i=Tg(e,t),a=i.intentLabel==="work_allowed"?cd:Il,o=r==="intent"?i.intentLabel:i.mode;return s.jsxs("span",{className:Q("inline-flex min-h-6 max-w-full items-center gap-1.5 rounded-md border px-2 text-xs font-semibold",i.intentLabel==="work_allowed"?"border-blue-200 bg-blue-50 text-blue-700":"border-violet-200 bg-violet-50 text-violet-700",n&&"min-h-5 px-1.5 text-[11px]"),title:`${i.title}: ${i.mode}`,"aria-label":`${i.title}: ${o}`,children:[s.jsx(a,{className:Q("h-3.5 w-3.5 shrink-0",n&&"h-3 w-3"),"aria-hidden":!0}),s.jsx("span",{className:"truncate font-mono",children:o})]})}function Ag({job:e,session:t,sessionEvents:n,transcript:r,now:i,compact:a=!1}){var p;const o=Un(e.id),l=n??[],c=r??[],u=yx(l),d=wx(c),h=ki(e,i),m=Ni(e,i);return s.jsxs("div",{className:"grid min-w-0 gap-4",children:[s.jsxs("div",{className:"sticky top-0 z-20 -mx-3 -mt-3 grid gap-2 border-b border-border bg-panel/95 px-3 py-2 shadow-sm backdrop-blur sm:-mx-4 sm:-mt-4 sm:px-4","aria-label":"Sticky job header",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[s.jsx(_i,{status:e.status}),s.jsxs("a",{className:"inline-flex h-7 items-center gap-1 rounded-md border border-border bg-white px-2 text-xs font-semibold text-foreground hover:bg-slate-50",href:o,children:[s.jsx(Fn,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Job #",e.id]}),s.jsx(Hn,{actor:e.trigger_actor,avatarUrl:e.trigger_actor_avatar_url,framed:!0}),s.jsx("span",{className:"min-w-0 break-words font-mono text-xs text-muted [overflow-wrap:anywhere]",children:e.work_key})]}),s.jsxs("div",{className:"grid min-w-0 gap-2 lg:grid-cols-[minmax(0,1fr)_minmax(280px,auto)] lg:items-start",children:[s.jsx("p",{className:"min-w-0 break-words text-sm text-muted [overflow-wrap:anywhere]",children:e.subject}),s.jsxs("div",{className:"grid min-w-0 gap-1",children:[s.jsx("h3",{className:"text-xs font-semibold text-muted",children:"GitHub links"}),e.github_urls.length>0?s.jsx(dr,{urls:e.github_urls,compact:!0}):s.jsx("p",{className:"text-xs text-muted",children:"No links recorded."})]})]})]}),s.jsxs("div",{className:Q("grid gap-2 text-sm sm:gap-3",a?"grid-cols-1":"grid-cols-3"),children:[s.jsx($,{label:"Queue wait",value:Xe(m)}),s.jsx($,{label:e.status==="running"?"Running for":"Runtime",value:Xe(h)}),s.jsx($,{label:"Coalesced",value:String(e.coalesced_count)})]}),e.queue_state==="serialized_by_work_key"?s.jsxs("p",{className:"rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-sm text-amber-900",children:["Serialized behind running job #",e.blocked_by_job_id," for this work key."]}):null,s.jsxs("div",{className:Q("grid gap-2 text-sm sm:gap-3",a?"grid-cols-1":"grid-cols-3"),children:[s.jsx($,{label:"Model",value:Eg(e.model_route)}),s.jsx($,{label:"Reasoning",value:Rg(e.model_route)}),s.jsx($,{label:"Route",value:Ig(e.model_route)})]}),s.jsx(Lg,{job:e,compact:a}),s.jsxs("div",{className:Q("grid gap-2 text-sm sm:gap-3",a?"grid-cols-1":"grid-cols-2 xl:grid-cols-4"),children:[s.jsx($,{label:"Created",value:s.jsx(ue,{value:e.created_at,compact:!0,relative:!0,now:i})}),s.jsx($,{label:"Started",value:e.started_at?s.jsx(ue,{value:e.started_at,compact:!0,relative:!0,now:i}):"n/a"}),s.jsx($,{label:"Updated",value:s.jsx(ue,{value:e.updated_at,compact:!0,relative:!0,now:i})}),s.jsx($,{label:"Finished",value:e.finished_at?s.jsx(ue,{value:e.finished_at,compact:!0,relative:!0,now:i}):"n/a"})]}),s.jsxs("div",{children:[s.jsx("h3",{className:"mb-2 text-sm font-semibold",children:"Timeline"}),s.jsx("div",{className:"grid min-w-0 gap-3",children:(e.worklog??[]).length>0?(p=e.worklog)==null?void 0:p.map(w=>s.jsxs("div",{className:"min-w-0 border-l-2 border-primary pl-3",children:[s.jsx("div",{className:"text-sm font-semibold",children:w.phase}),s.jsx("div",{className:"font-mono text-xs text-muted",children:s.jsx(ue,{value:w.ts,relative:!0,now:i})}),s.jsx("div",{className:"break-words text-sm [overflow-wrap:anywhere]",children:w.summary}),w.detail?s.jsx("div",{className:"mt-1 break-words font-mono text-xs text-muted [overflow-wrap:anywhere]",children:w.detail}):null]},w.id)):s.jsx(J,{text:"No worklog entries."})})]}),s.jsxs("div",{children:[s.jsxs("h3",{className:"mb-2 flex items-center gap-2 text-sm font-semibold",children:[s.jsx(Al,{className:"h-4 w-4","aria-hidden":!0}),"OpenClaw session"]}),t?s.jsxs("div",{className:"grid gap-3",children:[s.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[s.jsx($,{label:"Session ID",value:t.id}),s.jsx($,{label:"Source",value:t.source})]}),s.jsx("p",{className:"break-words text-xs text-muted [overflow-wrap:anywhere]",children:t.detail})]}):s.jsx(J,{text:"Session correlation is loading."})]}),s.jsxs("div",{children:[s.jsx("h3",{className:"mb-2 text-sm font-semibold",children:"Agent activity"}),s.jsx("div",{className:"grid max-h-[460px] min-w-0 gap-2 overflow-auto pr-1",children:u.length>0?u.map((w,y)=>s.jsx(Dg,{event:w,defaultOpen:Qo(w.eventType,e.status==="running",y,u.length),now:i},w.id)):s.jsx(J,{text:e.status==="running"?"Waiting for live agent output...":"No agent activity has been recorded for this session."})})]}),s.jsxs("div",{children:[s.jsx("h3",{className:"mb-2 text-sm font-semibold",children:"Session transcript"}),s.jsx("div",{className:"grid max-h-[620px] min-w-0 gap-2 overflow-auto pr-1",children:d.length>0?d.map((w,y)=>s.jsx(Mg,{entry:w,defaultOpen:Qo(w.kind,e.status==="running",y,d.length),now:i},w.id)):s.jsx(J,{text:e.status==="running"?"Waiting for live transcript entries...":"No OpenClaw transcript entries are available for this session."})})]})]})}function Lg({job:e,compact:t=!1}){const n=e.intent_classifier??null,r=(n==null?void 0:n.llm)??{},i=(n==null?void 0:n.parser)??{},a=typeof r.confidence=="number"?`${Math.round(r.confidence*100)}%`:"n/a";return s.jsxs("div",{className:"grid gap-2",children:[s.jsx("h3",{className:"text-sm font-semibold",children:"Action mode"}),s.jsxs("div",{className:Q("grid gap-2 text-sm sm:gap-3",t?"grid-cols-1":"grid-cols-2 xl:grid-cols-4"),children:[s.jsx($,{label:"Mode",value:s.jsx(Si,{intent:e.intent,actionMode:e.action_mode})}),s.jsx($,{label:"Intent",value:e.intent}),s.jsx($,{label:"Addressed",value:n?Jo(r.addressed_to_agent):"n/a"}),s.jsx($,{label:"Write",value:n?r.write_permission??"none":e.intent==="work_allowed"?"allowed":"none"})]}),n?s.jsxs("div",{className:"grid gap-2 rounded-md border border-border bg-panel p-3 text-xs",children:[s.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-4",children:[s.jsx(ht,{label:"Classifier",value:n.enabled?"enabled":"disabled"}),s.jsx(ht,{label:"Applied",value:Jo(r.applied)}),s.jsx(ht,{label:"Confidence",value:a}),s.jsx(ht,{label:"Parser",value:`${i.action??"n/a"} / ${i.work_intent??"n/a"}`})]}),s.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[s.jsx(ht,{label:"LLM",value:`${r.action??"n/a"} / ${r.work_intent??"n/a"}`}),s.jsx(ht,{label:"Scope",value:r.scope||"n/a"})]}),r.main_request?s.jsx(ht,{label:"Main request",value:r.main_request}):null,r.subordinate_reason?s.jsx(ht,{label:"Subordinate reason",value:r.subordinate_reason}):null,r.reason?s.jsx(ht,{label:"Reason",value:r.reason}):null,n.error?s.jsx(ht,{label:"Error",value:n.error,tone:"danger"}):null]}):s.jsx("p",{className:"text-xs text-muted",children:"No intent classifier metadata recorded for this job."})]})}function Jo(e){return e===!0?"yes":e===!1?"no":"n/a"}function ht({label:e,value:t,tone:n="neutral"}){return s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[11px] font-semibold uppercase text-muted",children:e}),s.jsx("div",{className:Q("mt-0.5 min-w-0 break-words font-mono text-xs [overflow-wrap:anywhere]",n==="danger"?"text-red-700":"text-foreground"),children:t})]})}function Mg({entry:e,defaultOpen:t,now:n}){return s.jsx(Ac,{badge:e.badge,meta:s.jsx(ue,{value:e.meta,relative:!0,now:n}),count:e.count,summary:e.summary,defaultOpen:t,children:s.jsx("pre",{className:"max-h-72 max-w-full overflow-auto whitespace-pre-wrap break-words rounded bg-slate-950 px-2 py-1.5 font-mono text-xs leading-relaxed text-slate-100 [overflow-wrap:anywhere]",children:e.text})})}function Dg({event:e,defaultOpen:t,now:n}){return s.jsx(Ac,{badge:e.badge,meta:s.jsx(ue,{value:e.meta,relative:!0,now:n}),count:e.count,summary:e.summary,defaultOpen:t,children:e.detail?s.jsx("pre",{className:"max-h-56 max-w-full overflow-auto whitespace-pre-wrap break-words rounded bg-slate-950 px-2 py-1.5 font-mono text-xs leading-relaxed text-slate-100 [overflow-wrap:anywhere]",children:e.detail}):null})}function Ac({badge:e,meta:t,count:n,summary:r,defaultOpen:i,children:a}){const[o,l]=R.useState(!!i);return s.jsxs("details",{className:"group min-w-0 rounded border border-border bg-slate-50/60",open:o,onToggle:c=>l(c.currentTarget.open),children:[s.jsxs("summary",{className:"grid cursor-pointer list-none gap-1 px-2 py-1.5 marker:hidden hover:bg-white",children:[s.jsxs("div",{className:"grid min-w-0 gap-1 sm:flex sm:items-center sm:justify-between sm:gap-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx(Dn,{className:"h-3.5 w-3.5 shrink-0 text-muted transition-transform group-open:rotate-180","aria-hidden":!0}),s.jsx("span",{className:"truncate font-mono text-[11px] font-semibold text-muted",children:e}),n&&n>1?s.jsx("span",{className:"rounded-sm border border-border px-1 font-mono text-[10px] text-muted",children:n}):null]}),s.jsx("span",{className:"min-w-0 truncate pl-5 font-mono text-[11px] text-muted sm:shrink-0 sm:pl-0",children:t})]}),s.jsx("div",{className:"min-w-0 break-words pl-5 text-xs text-foreground [overflow-wrap:anywhere] sm:truncate",children:r})]}),s.jsx("div",{className:"min-w-0 border-t border-border bg-white px-2 py-2",children:a})]})}function Xo({label:e,values:t}){const n=[{name:"median",seconds:(t==null?void 0:t.median)??0},{name:"p90",seconds:(t==null?void 0:t.p90)??0},{name:"p99",seconds:(t==null?void 0:t.p99)??0}];return s.jsx("div",{className:"h-56",children:s.jsx(ln,{width:"100%",height:"100%",children:s.jsxs(ei,{data:n,children:[s.jsx(Ln,{strokeDasharray:"3 3"}),s.jsx(Mn,{dataKey:"name"}),s.jsx(sn,{tickFormatter:Xe}),s.jsx(cn,{formatter:r=>[Xe(Number(r)),e]}),s.jsx(Bt,{dataKey:"seconds",fill:"#0969da",radius:[4,4,0,0]})]})})})}function Og({usage:e,jobsByCreatedDay:t,loading:n,totalJobs:r}){const[i,a]=R.useState("day"),o=(e==null?void 0:e[i])??[],l=Fg(e,t,i),c=o.reduce((d,h)=>d+h.seconds,0),u=o.reduce((d,h)=>d+(h.runs??h.jobs),0);return n&&l.length===0?s.jsx(J,{text:"Loading runtime and job history..."}):l.length===0?s.jsx(J,{text:r>0?"No jobs have valid runtime or creation dates.":"No job history available."}):s.jsxs("div",{className:"grid gap-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted",children:[s.jsx(Ll,{className:"h-4 w-4","aria-hidden":!0}),s.jsxs("span",{children:[tt(c)," consumed across ",u," run",u===1?"":"s"]})]}),s.jsx("div",{className:"inline-flex h-8 rounded-md border border-border bg-white p-0.5","aria-label":"Runtime grouping",children:["day","month"].map(d=>s.jsx("button",{className:Q("rounded px-2.5 text-xs font-semibold capitalize",i===d?"bg-primary text-white":"text-muted hover:bg-slate-50"),type:"button",onClick:()=>a(d),children:d},d))})]}),s.jsx("div",{className:"h-64",role:"img","aria-label":"Runtime and jobs activity chart",children:s.jsx(ln,{width:"100%",height:"100%",children:s.jsxs(ou,{data:l,children:[s.jsx(Ln,{strokeDasharray:"3 3"}),s.jsx(Mn,{dataKey:"label",minTickGap:16,tick:{fontSize:11}}),s.jsx(sn,{yAxisId:"runtime",tickFormatter:d=>tt(Number(d))}),s.jsx(sn,{yAxisId:"jobs",orientation:"right",allowDecimals:!1}),s.jsx(Ur,{}),s.jsx(cn,{formatter:(d,h)=>h==="Work"?[tt(Number(d)),"work"]:h==="Review"?[tt(Number(d)),"review"]:h==="Jobs"?[Number(d),"jobs"]:[Number(d),String(h)],labelFormatter:d=>String(d)}),s.jsx(Bt,{yAxisId:"runtime",dataKey:"work_seconds",name:"Work",stackId:"runtime",fill:"#0969da",isAnimationActive:!1}),s.jsx(Bt,{yAxisId:"runtime",dataKey:"review_seconds",name:"Review",stackId:"runtime",fill:"#8250df",radius:[4,4,0,0],isAnimationActive:!1}),s.jsx(ti,{yAxisId:"jobs",type:"monotone",dataKey:"jobs",name:"Jobs",stroke:"#16a34a",strokeWidth:2,dot:{r:3},activeDot:{r:5},isAnimationActive:!1})]})})})]})}function Fg(e,t,n){const r=new Map;for(const a of(e==null?void 0:e[n])??[])r.set(a.bucket,{...a});const i=new Map;for(const[a,o]of Object.entries(t??{})){const l=n==="month"?a.slice(0,7):a;i.set(l,(i.get(l)??0)+o)}for(const a of i.keys())r.has(a)||r.set(a,zg(a));return[...r.values()].sort((a,o)=>a.bucket.localeCompare(o.bucket)).map(a=>({...a,jobs:i.get(a.bucket)??0,label:Wg(a.bucket,n)}))}function zg(e){return{bucket:e,seconds:0,minutes:0,runs:0,jobs:0,work_seconds:0,review_seconds:0,work_runs:0,review_runs:0,work_jobs:0,review_jobs:0}}const Lc=[{value:"7d",label:"Last 7 days"},{value:"30d",label:"Last 30 days"},{value:"all",label:"All time"}],qg=2,Rr=["#0969da","#8250df","#1a7f37","#bf8700","#cf222e","#0550ae","#6e40c9","#0a7f68"];function Bg({usage:e,loading:t,totalJobs:n,window:r,onWindowChange:i}){const a=e??[],o=a.reduce((l,c)=>l+c.seconds,0);return s.jsxs("div",{className:"grid gap-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[a.length>0?s.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted",children:[s.jsx(An,{className:"h-4 w-4","aria-hidden":!0}),s.jsxs("span",{children:[tt(o)," consumed across ",a.length," user",a.length===1?"":"s"]})]}):s.jsx("span",{}),s.jsx("div",{className:"inline-flex h-8 rounded-md border border-border bg-white p-0.5",role:"group","aria-label":"Runtime by user window",children:Lc.map(l=>s.jsx("button",{className:Q("rounded px-2.5 text-xs font-semibold",r===l.value?"bg-primary text-white":"text-muted hover:bg-slate-50"),type:"button","aria-label":l.label,"aria-pressed":r===l.value,onClick:()=>i(l.value),children:l.value==="all"?"All":l.value},l.value))})]}),t&&a.length===0?s.jsx(J,{text:"Loading runtime by user..."}):a.length===0?s.jsx(J,{text:n>0?"No jobs have recorded user runtime in this window.":"No job history available."}):s.jsx("div",{className:"overflow-x-auto",role:"img","aria-label":"Runtime usage by user chart",children:s.jsx("div",{className:"h-64",style:{minWidth:`${Math.max(720,a.length*112)}px`},children:s.jsx(ln,{width:"100%",height:"100%",children:s.jsxs(ei,{data:a,children:[s.jsx(Ln,{strokeDasharray:"3 3"}),s.jsx(Mn,{dataKey:"actor",interval:0,height:68,tick:s.jsx(Kg,{usage:a}),tickLine:!1}),s.jsx(sn,{tickFormatter:l=>tt(Number(l))}),s.jsx(Ur,{}),s.jsx(cn,{formatter:(l,c)=>[tt(Number(l)),String(c).toLowerCase()],labelFormatter:l=>l==="unknown"?"unknown":`@${String(l)}`}),s.jsx(Bt,{dataKey:"work_seconds",name:"Work",stackId:"runtime",fill:"#0969da",isAnimationActive:!1}),s.jsx(Bt,{dataKey:"review_seconds",name:"Review",stackId:"runtime",fill:"#8250df",radius:[4,4,0,0],isAnimationActive:!1})]})})})})]})}function $g({usage:e,loading:t,totalJobs:n,window:r,onWindowChange:i}){const a=e??[],o=a.reduce((c,u)=>c+u.seconds,0),l=Ug(a);return s.jsxs("div",{className:"grid gap-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[a.length>0?s.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted",children:[s.jsx(Ll,{className:"h-4 w-4","aria-hidden":!0}),s.jsxs("span",{children:[tt(o)," consumed across ",a.length," repositor",a.length===1?"y":"ies"]})]}):s.jsx("span",{}),s.jsx("div",{className:"inline-flex h-8 rounded-md border border-border bg-white p-0.5",role:"group","aria-label":"Runtime by repository window",children:Lc.map(c=>s.jsx("button",{className:Q("rounded px-2.5 text-xs font-semibold",r===c.value?"bg-primary text-white":"text-muted hover:bg-slate-50"),type:"button","aria-label":c.label,"aria-pressed":r===c.value,onClick:()=>i(c.value),children:c.value==="all"?"All":c.value},c.value))})]}),t&&a.length===0?s.jsx(J,{text:"Loading runtime by repository..."}):a.length===0?s.jsx(J,{text:n>0?"No jobs have recorded repository runtime in this window.":"No job history available."}):s.jsxs("div",{className:"grid items-center gap-4 md:grid-cols-[minmax(0,1fr)_minmax(240px,0.8fr)]",role:"img","aria-label":"Runtime usage by repository chart",children:[s.jsx("div",{className:"h-72 min-w-0",children:s.jsx(ln,{width:"100%",height:"100%",children:s.jsxs(lu,{children:[s.jsx(cu,{data:l,dataKey:"seconds",nameKey:"repo",innerRadius:"54%",outerRadius:"86%",paddingAngle:1,stroke:"#ffffff",strokeWidth:2,labelLine:!1,label:({percent:c})=>$r((c??0)*100),isAnimationActive:!1,children:l.map((c,u)=>s.jsx(uu,{fill:c.repo==="Other"?"#94a3b8":Rr[u%Rr.length]},c.repo))}),s.jsx(cn,{content:s.jsx(Hg,{totalSeconds:o})})]})})}),s.jsx("ul",{className:"grid min-w-0 gap-2","aria-label":"Repository runtime percentages",children:l.map((c,u)=>s.jsxs("li",{className:"grid min-w-0 grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-2 text-sm",children:[s.jsx("span",{className:"h-3 w-3 rounded-sm",style:{backgroundColor:c.repo==="Other"?"#94a3b8":Rr[u%Rr.length]},"aria-hidden":!0}),s.jsx("span",{className:"truncate font-mono text-xs",title:c.repo,children:c.repo==="Other"?`Other (${c.repositories.length})`:c.repo}),s.jsx("span",{className:"font-semibold tabular-nums",children:$r(c.percentage)})]},c.repo))})]})]})}function Ug(e){const t=e.filter(a=>a.seconds>0).sort((a,o)=>o.seconds-a.seconds),n=t.reduce((a,o)=>a+o.seconds,0);if(n<=0)return[];const r=[],i=[];for(const a of t){const o=a.seconds/n*100;o0){const a=i.reduce((o,l)=>({repo:"Other",seconds:o.seconds+l.seconds,minutes:o.minutes+l.minutes,runs:o.runs+l.runs,work_seconds:o.work_seconds+l.work_seconds,review_seconds:o.review_seconds+l.review_seconds,work_runs:o.work_runs+l.work_runs,review_runs:o.review_runs+l.review_runs}),{repo:"Other",seconds:0,minutes:0,runs:0,work_seconds:0,review_seconds:0,work_runs:0,review_runs:0});r.push({...a,percentage:a.seconds/n*100,repositories:i})}return r}function Hg({active:e,payload:t,totalSeconds:n}){var i;const r=(i=t==null?void 0:t[0])==null?void 0:i.payload;return!e||!r?null:s.jsxs("div",{className:"min-w-56 rounded-md border border-border bg-white p-3 text-xs shadow-lg",children:[s.jsx("div",{className:"font-mono font-semibold text-foreground",children:r.repo==="Other"?`Other (${r.repositories.length} repositor${r.repositories.length===1?"y":"ies"})`:r.repo}),s.jsxs("div",{className:"mt-2 grid grid-cols-2 gap-x-4 gap-y-1 text-muted",children:[s.jsx("span",{children:"Total"}),s.jsxs("span",{className:"text-right font-semibold text-foreground",children:[tt(r.seconds)," ยท ",$r(r.seconds/n*100)]}),s.jsx("span",{children:"Work"}),s.jsx("span",{className:"text-right text-foreground",children:tt(r.work_seconds)}),s.jsx("span",{children:"Review"}),s.jsx("span",{className:"text-right text-foreground",children:tt(r.review_seconds)}),s.jsx("span",{children:"Runs"}),s.jsx("span",{className:"text-right text-foreground",children:r.runs})]}),r.repo==="Other"?s.jsx("div",{className:"mt-2 max-h-40 overflow-auto border-t border-border pt-2",children:r.repositories.map(a=>s.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] gap-3 py-0.5",children:[s.jsx("span",{className:"truncate font-mono",title:a.repo,children:a.repo}),s.jsxs("span",{className:"tabular-nums text-muted",children:[$r(a.seconds/n*100)," ยท ",tt(a.seconds)]})]},a.repo))}):null]})}function $r(e){return`${e.toFixed(1)}%`}function Kg({x:e=0,y:t=0,payload:n,usage:r}){const i=String((n==null?void 0:n.value)??"unknown"),a=r.find(h=>h.actor===i),o=Qg(a),l=i==="unknown"?"unknown user":`@${i}`,c=i==="unknown"?"unknown":`@${i}`,u=c.length>18?`${c.slice(0,17)}โ€ฆ`:c,d=R.useId().replace(/:/g,"");return s.jsxs("g",{transform:`translate(${e},${t})`,children:[s.jsx("title",{children:l}),s.jsx("defs",{children:s.jsx("clipPath",{id:d,children:s.jsx("circle",{cx:"0",cy:"18",r:"14"})})}),s.jsx("circle",{cx:"0",cy:"18",r:"14",fill:"#f1f5f9",stroke:"#cbd5e1"}),o?s.jsx("image",{x:"-14",y:"4",width:"28",height:"28",href:o,clipPath:`url(#${d})`,preserveAspectRatio:"xMidYMid slice",role:"img","aria-label":`${l} avatar`}):s.jsx("text",{x:"0",y:"22",textAnchor:"middle",fontSize:"12",fill:"#64748b","aria-label":l,children:"?"}),s.jsx("text",{x:"0",y:"49",textAnchor:"middle",fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:"11",fontWeight:"600",fill:"#475569",children:u})]})}function Qg(e){if(!e)return null;const t=rt(e.avatar_url??"");return t!=="#"?t:!e.actor||e.actor==="unknown"?null:`https://github.com/${encodeURIComponent(e.actor)}.png?size=80`}function Wg(e,t){if(t==="month"){const[a,o]=e.split("-").map(Number);return!a||!o?e:new Intl.DateTimeFormat(void 0,{month:"short",year:"numeric"}).format(new Date(a,o-1,1))}const[n,r,i]=e.split("-").map(Number);return!n||!r||!i?e:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric"}).format(new Date(n,r-1,i))}function tt(e){const t=Math.max(0,Math.round(e));if(t<60)return`${t}s`;const n=Math.round(t/60);if(n<60)return`${n}m`;const r=Math.floor(n/60),i=n%60;return i===0?`${r}h`:`${r}h ${i}m`}function gs(e){return Object.values(e).reduce((t,n)=>t+n,0)}function Vg({data:e,loading:t}){if(t&&!e)return s.jsx(J,{text:"Loading systemd units..."});if(!e)return s.jsx(J,{text:"No systemd snapshot available."});const n=e.units??[],r=n.filter(o=>o.active_state==="active").length,i=n.filter(o=>o.active_state==="failed"||o.result==="failed").length,a=n.filter(o=>o.kind==="timer").length;return s.jsxs("div",{className:"grid min-w-0 gap-3",children:[e.errors.length>0?s.jsx(be,{tone:"error",text:e.errors[0]}):null,n.length===0?s.jsx(J,{text:"No configured bridge units found."}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-4",children:[s.jsx(Ir,{label:"Units",value:String(n.length)}),s.jsx(Ir,{label:"Active",value:String(r)}),s.jsx(Ir,{label:"Failed",value:String(i),tone:i>0?"bad":"neutral"}),s.jsx(Ir,{label:"Timers",value:String(a)})]}),s.jsxs("div",{className:"overflow-hidden rounded-md border border-border bg-white",children:[s.jsxs("div",{className:"hidden grid-cols-[minmax(0,1.35fr)_90px_120px_90px_minmax(0,1fr)] gap-3 border-b border-border bg-slate-50 px-3 py-2 text-[11px] font-semibold uppercase text-muted md:grid",children:[s.jsx("span",{children:"Unit"}),s.jsx("span",{children:"Status"}),s.jsx("span",{children:"State"}),s.jsx("span",{children:"PID"}),s.jsx("span",{children:"Schedule"})]}),s.jsx("div",{className:"divide-y divide-border",children:n.map(o=>s.jsx(Gg,{unit:o},o.unit))})]})]})]})}function Ir({label:e,value:t,tone:n="neutral"}){return s.jsxs("div",{className:Q("min-w-0 rounded-md border bg-white px-3 py-2",n==="bad"?"border-red-200":"border-border"),children:[s.jsx("div",{className:Q("font-mono text-lg font-semibold",n==="bad"?"text-red-700":"text-foreground"),children:t}),s.jsx("div",{className:"mt-0.5 text-[11px] font-semibold uppercase text-muted",children:e})]})}function Gg({unit:e}){const[t,n]=R.useState(!1),r=e.active_state==="active",i=e.active_state==="failed"||e.result==="failed",a=e.next_elapse||e.last_trigger||"n/a";return s.jsxs("details",{className:"group min-w-0",open:t,onToggle:o=>n(o.currentTarget.open),children:[s.jsxs("summary",{className:"grid min-w-0 cursor-pointer list-none grid-cols-2 gap-2 px-3 py-3 text-sm marker:hidden hover:bg-slate-50 md:grid-cols-[minmax(0,1.35fr)_90px_120px_90px_minmax(0,1fr)] md:items-center md:gap-3",children:[s.jsxs("div",{className:"col-span-2 min-w-0 md:col-span-1",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx(Dn,{className:"h-3.5 w-3.5 shrink-0 text-muted transition-transform group-open:rotate-180","aria-hidden":!0}),s.jsx("span",{className:"truncate font-mono text-xs font-semibold text-foreground",children:e.unit})]}),s.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1.5 pl-5 text-[11px] font-semibold uppercase text-muted",children:[s.jsx("span",{children:e.role}),s.jsx("span",{children:e.kind}),s.jsx("span",{children:e.load_state}),s.jsx("span",{children:t?"following log":"expand log"})]})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2 md:block",children:[s.jsx("span",{className:"text-[11px] font-semibold uppercase text-muted md:hidden",children:"Status"}),s.jsx("span",{className:Q("inline-flex h-6 items-center rounded-full border px-2 text-xs font-semibold",i?"border-red-300 bg-red-50 text-red-700":r?"border-emerald-300 bg-emerald-50 text-emerald-700":"border-slate-300 bg-slate-50 text-slate-700"),children:e.active_state})]}),s.jsx(Yo,{label:"State",value:e.sub_state,detail:e.result||"unknown"}),s.jsx(Yo,{label:"PID",value:e.main_pid?String(e.main_pid):"n/a",detail:Xe(e.uptime_seconds)}),s.jsxs("div",{className:"col-span-2 min-w-0 md:col-span-1",children:[s.jsx("div",{className:"text-[11px] font-semibold uppercase text-muted md:hidden",children:"Schedule"}),s.jsx("div",{className:"truncate font-mono text-[11px] text-foreground",title:a,children:e.next_elapse?`next ${e.next_elapse}`:a})]})]}),s.jsx("div",{className:"border-t border-border bg-slate-50 px-3 pb-3 pt-2",children:s.jsx(Jg,{unit:e.unit,active:t})})]})}function Yo({label:e,value:t,detail:n}){return s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[11px] font-semibold uppercase text-muted md:hidden",children:e}),s.jsx("div",{className:"truncate font-mono text-[11px] text-foreground",children:t}),n?s.jsx("div",{className:"truncate font-mono text-[11px] text-muted",children:n}):null]})}function Jg({unit:e,active:t}){const[n,r]=R.useState([]),[i,a]=R.useState(""),o=R.useRef(null);return R.useEffect(()=>{if(!t){r([]),a("");return}r([]),a("");const l=new EventSource(`/api/systemd/journal/stream?unit=${encodeURIComponent(e)}`);return l.addEventListener("journal_line",c=>{const u=Br(c);u&&r(d=>[...d.slice(-199),u])}),l.addEventListener("journal_error",c=>{const u=Br(c);a((u==null?void 0:u.error)??"journal stream failed")}),l.onerror=()=>{},()=>l.close()},[t,e]),R.useEffect(()=>{const l=o.current;l&&(l.scrollTop=l.scrollHeight)},[n]),s.jsxs("div",{className:"grid min-w-0 gap-2",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[11px] font-semibold uppercase text-muted",children:"Live journal"}),s.jsx("div",{className:"mt-0.5 truncate font-mono text-[11px] text-muted",children:n.length>0?`${n.length} lines streamed`:"waiting for journal output"})]}),s.jsx("div",{className:"font-mono text-[11px] text-muted",children:"journalctl -f"})]}),i?s.jsx(be,{tone:"error",text:i}):null,s.jsx("div",{ref:o,className:"h-72 overflow-auto rounded-md border border-slate-800 bg-slate-950 p-3 font-mono text-xs leading-relaxed text-slate-100",children:n.length>0?n.map((l,c)=>s.jsx("div",{className:"break-words [overflow-wrap:anywhere]",children:l.line},`${l.unit}-${c}`)):s.jsx("div",{className:"text-slate-400",children:"No journal lines received yet."})})]})}function Xg({data:e,loading:t}){var h,m,p,w,y,v;if(t&&!e)return s.jsx(J,{text:"Loading process activity..."});if(!e)return s.jsx(J,{text:"No process snapshot available."});const n=e.executor.children??[],r=n.flatMap(b=>Dc(b)),i=r.reduce((b,N)=>b+N.cpu_ticks,0),a=r.reduce((b,N)=>b+Zg(N),0),o=e.executor.service==="active",l=r.slice(0,8).map(b=>({label:`pid ${b.pid}`,ticks:b.cpu_ticks})),c=(e.samples??[]).map(b=>({label:ir(b.ts),ticks:b.cpu_ticks,io:b.io_bytes,active:b.active_since_last_sample?"active":"quiet"})),u=c.length>0?c:l,d=(h=e.samples)==null?void 0:h[e.samples.length-1];return s.jsxs("div",{className:"grid gap-4",children:[s.jsx("div",{className:"rounded-md border border-slate-200 bg-slate-50 p-3",children:s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("span",{className:Q("inline-flex h-6 items-center rounded-full border px-2 text-xs font-semibold",o?"border-emerald-300 bg-emerald-50 text-emerald-700":"border-slate-300 bg-white text-slate-600"),children:o?"active":"idle"}),s.jsxs("span",{className:"font-mono text-xs text-muted",children:["service ",e.executor.service]})]}),s.jsx("div",{className:"mt-2 text-sm font-semibold text-foreground",children:e.running_jobs.length>0?`${e.running_jobs.length} running job${e.running_jobs.length===1?"":"s"}`:"No running jobs"}),e.running_jobs.length>0?s.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:e.running_jobs.slice(0,4).map(b=>s.jsxs("span",{className:"inline-flex min-h-6 items-center gap-1.5 rounded-full border border-blue-200 bg-white px-2 font-mono text-[11px] font-semibold text-blue-700",children:[s.jsx("span",{className:"h-2 w-2 rounded-full bg-blue-600 animate-live-pulse","aria-hidden":!0}),"#",b.id," ",Xe(b.age_seconds)]},b.id))}):null,d?s.jsxs("p",{className:"mt-1 text-xs text-muted",children:["Last persisted sample ",ir(d.ts)," ยท ",d.active_since_last_sample?"activity observed":`quiet ${Xe(d.idle_seconds)}`]}):null,s.jsx("p",{className:"mt-1 text-xs text-muted",children:e.detail})]}),s.jsxs("div",{className:"grid min-w-[190px] grid-cols-3 gap-2 text-center text-xs",children:[s.jsx(bs,{label:"PID",value:e.executor.pid?String(e.executor.pid):"n/a"}),s.jsx(bs,{label:"Children",value:String(r.length)}),s.jsx(bs,{label:"CPU ticks",value:String(i)})]})]})}),s.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[s.jsx(Tr,{label:"Live process",value:((m=e.signals)==null?void 0:m.live_process.state)??(r.length>0?"live":"no_child_process"),detail:`${((p=e.signals)==null?void 0:p.live_process.child_count)??r.length} children`}),s.jsx(Tr,{label:"Process activity",value:((w=e.signals)==null?void 0:w.process_activity.state)??(d!=null&&d.active_since_last_sample?"active":"quiet"),detail:d?`sample ${ir(d.ts)}`:"no sample"}),s.jsx(Tr,{label:"Semantic progress",value:(y=e.signals)!=null&&y.semantic_progress.length?"recent":"none",detail:Zo(e.running_jobs,"semantic_progress")}),s.jsx(Tr,{label:"Visible progress",value:(v=e.signals)!=null&&v.visible_progress.length?"streaming":"none",detail:Zo(e.running_jobs,"visible_progress")})]}),e.alerts.length>0?s.jsx(be,{tone:"error",text:e.alerts[0]}):null,s.jsxs("div",{className:"grid gap-4 lg:grid-cols-[minmax(0,0.9fr)_minmax(0,1.1fr)]",children:[s.jsxs("div",{className:"min-w-0 rounded-md border border-border p-3",children:[s.jsxs("div",{className:"mb-3 flex items-center justify-between gap-3",children:[s.jsxs("h3",{className:"flex items-center gap-2 text-sm font-semibold",children:[s.jsx(ro,{className:"h-4 w-4","aria-hidden":!0}),c.length>0?"CPU history":"CPU ticks"]}),s.jsxs("span",{className:"font-mono text-xs text-muted",children:[Oc(a)," I/O"]})]}),u.length>0?s.jsx("div",{className:"h-40",children:s.jsx(ln,{width:"100%",height:"100%",children:s.jsxs(dl,{data:u,children:[s.jsx(Ln,{strokeDasharray:"3 3"}),s.jsx(Mn,{dataKey:"label",tick:!1}),s.jsx(sn,{allowDecimals:!1,tick:{fontSize:11}}),s.jsx(cn,{formatter:b=>[Number(b),"cpu ticks"]}),s.jsx(ti,{type:"monotone",dataKey:"ticks",stroke:"#0f766e",strokeWidth:2,dot:{r:3},activeDot:{r:5},isAnimationActive:!1})]})})}):s.jsx(J,{text:"No executor CPU samples available."})]}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("h3",{className:"mb-2 flex items-center gap-2 text-sm font-semibold",children:[s.jsx(ro,{className:"h-4 w-4","aria-hidden":!0}),"Executor children"]}),n.length>0?s.jsx("div",{className:"grid gap-2",children:n.map(b=>s.jsx(Mc,{process:b},b.pid))}):s.jsx(J,{text:"No child process detected for the executor."})]})]})]})}function Yg({alerts:e,loading:t,now:n}){if(t&&!e)return s.jsx(J,{text:"Loading monitor alerts..."});const r=e??[];return r.length===0?s.jsx(J,{text:"No active monitor alerts."}):s.jsx("div",{className:"grid gap-2",children:r.slice(0,5).map(i=>s.jsxs("div",{className:"rounded-md border border-red-200 bg-red-50 p-2.5",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs font-semibold text-red-700",children:[s.jsx(Hr,{className:"h-3.5 w-3.5","aria-hidden":!0}),s.jsx("span",{children:i.severity}),s.jsx("span",{className:"font-normal text-red-600",children:vc(i.last_seen,n)}),i.observations>1?s.jsxs("span",{className:"rounded-full border border-red-200 bg-white px-1.5",children:[i.observations,"x"]}):null]}),s.jsx("p",{className:"mt-1 break-words text-sm font-medium text-red-950 [overflow-wrap:anywhere]",children:i.message})]},i.fingerprint))})}function Mc({process:e}){var r,i;const t=((r=e.io_bytes)==null?void 0:r.read_bytes)??0,n=((i=e.io_bytes)==null?void 0:i.write_bytes)??0;return s.jsxs("div",{className:"rounded-md border border-border bg-white p-2.5",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[s.jsxs("span",{className:"font-mono",children:["pid ",e.pid]}),s.jsxs("span",{className:"rounded-full border border-border px-2 text-xs text-muted",children:["state ",e.state]}),s.jsxs("span",{className:"rounded-full border border-border px-2 text-xs text-muted",children:["cpu ",e.cpu_ticks]}),s.jsxs("span",{className:"rounded-full border border-border px-2 text-xs text-muted",children:["I/O ",Oc(t+n)]})]}),s.jsx("div",{className:"mt-2 break-words font-mono text-xs text-muted",children:e.cmd||"unknown command"}),e.children&&e.children.length>0?s.jsx("div",{className:"mt-3 border-l-2 border-border pl-3",children:e.children.map(a=>s.jsx(Mc,{process:a},a.pid))}):null]})}function bs({label:e,value:t}){return s.jsxs("div",{className:"rounded-md border border-border bg-white px-2 py-2",children:[s.jsx("div",{className:"font-mono text-sm font-semibold text-foreground",children:t}),s.jsx("div",{className:"mt-0.5 text-[11px] font-semibold uppercase text-muted",children:e})]})}function Tr({label:e,value:t,detail:n}){return s.jsxs("div",{className:"min-w-0 rounded-md border border-border bg-white p-2.5",children:[s.jsx("div",{className:"text-[11px] font-semibold uppercase text-muted",children:e}),s.jsx("div",{className:"mt-1 truncate text-sm font-semibold text-foreground",children:t}),s.jsx("div",{className:"mt-1 truncate font-mono text-[11px] text-muted",children:n})]})}function Zo(e,t){const n=e.find(i=>i[t]),r=n==null?void 0:n[t];return!n||!r?"no running heartbeat":`#${n.id} ${r.phase} ${Xe(r.age_seconds??null)}`}function Dc(e){return[e,...(e.children??[]).flatMap(t=>Dc(t))]}function Zg(e){var t,n;return(((t=e.io_bytes)==null?void 0:t.read_bytes)??0)+(((n=e.io_bytes)==null?void 0:n.write_bytes)??0)}function Oc(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KiB`:`${(e/(1024*1024)).toFixed(1)} MiB`}function $({label:e,value:t}){return s.jsxs("div",{className:"min-w-0 rounded-md border border-border p-3",children:[s.jsx("div",{className:"text-xs font-semibold text-muted",children:e}),s.jsx("div",{className:"mt-1 min-w-0 break-words text-sm [overflow-wrap:anywhere]",children:t})]})}function _i({status:e}){const t=vx(e),n=e==="running"||e==="pending";return s.jsxs("span",{className:Q("inline-flex min-h-6 items-center gap-1.5 rounded-full border px-2 text-xs font-semibold",t.badge),children:[s.jsx("span",{className:Q("h-2.5 w-2.5 rounded-full",t.dot,n&&"animate-live-pulse"),"aria-hidden":!0}),e]})}function J({text:e}){return s.jsx("div",{className:"rounded-md border border-dashed border-border p-6 text-center text-sm text-muted",children:e})}function be({tone:e,text:t}){return s.jsx("div",{className:Q("rounded-md border p-3 text-sm",e==="error"&&"border-red-300 bg-red-50 text-red-700",e==="warning"&&"border-amber-300 bg-amber-50 text-amber-800"),children:t})}function nt({onClick:e,compactOnMobile:t=!1}){return s.jsxs("button",{className:Q("inline-flex h-8 items-center justify-center gap-2 rounded-md border border-border text-sm font-semibold text-foreground hover:bg-slate-50",t?"w-8 px-0 sm:w-auto sm:px-3":"px-3"),onClick:e,type:"button","aria-label":"Refresh",children:[s.jsx(zn,{className:"h-4 w-4","aria-hidden":!0}),s.jsx("span",{className:Q(t&&"hidden sm:inline"),children:"Refresh"})]})}const el=document.getElementById("root");el&&xu.createRoot(el).render(s.jsx(R.StrictMode,{children:s.jsx(Hu,{client:ux,children:s.jsx(Bx,{})})})); diff --git a/src/github_agent_bridge/dashboard_static/assets/index-CZVECYxY.css b/src/github_agent_bridge/dashboard_static/assets/index-wGNxHObK.css similarity index 77% rename from src/github_agent_bridge/dashboard_static/assets/index-CZVECYxY.css rename to src/github_agent_bridge/dashboard_static/assets/index-wGNxHObK.css index 2d56ff7..5351e9e 100644 --- a/src/github_agent_bridge/dashboard_static/assets/index-CZVECYxY.css +++ b/src/github_agent_bridge/dashboard_static/assets/index-wGNxHObK.css @@ -1 +1 @@ -/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reverse:0;--tw-divide-y-reverse:0;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-outline-style:solid;--tw-content:"";--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0}}}@layer theme{:root,:host{--font-sans:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--color-red-50:oklch(97.1% .013 17.38);--color-red-100:oklch(93.6% .032 17.717);--color-red-200:oklch(88.5% .062 18.334);--color-red-300:oklch(80.8% .114 19.571);--color-red-600:oklch(57.7% .245 27.325);--color-red-700:oklch(50.5% .213 27.518);--color-red-950:oklch(25.8% .092 26.042);--color-amber-50:oklch(98.7% .022 95.277);--color-amber-100:oklch(96.2% .059 95.617);--color-amber-200:oklch(92.4% .12 95.746);--color-amber-300:oklch(87.9% .169 91.605);--color-amber-500:oklch(76.9% .188 70.08);--color-amber-700:oklch(55.5% .163 48.998);--color-amber-800:oklch(47.3% .137 46.201);--color-amber-900:oklch(41.4% .112 45.904);--color-amber-950:oklch(27.9% .077 45.635);--color-emerald-50:oklch(97.9% .021 166.113);--color-emerald-100:oklch(95% .052 163.051);--color-emerald-200:oklch(90.5% .093 164.15);--color-emerald-300:oklch(84.5% .143 164.978);--color-emerald-400:oklch(76.5% .177 163.223);--color-emerald-600:oklch(59.6% .145 163.225);--color-emerald-700:oklch(50.8% .118 165.612);--color-emerald-800:oklch(43.2% .095 166.913);--color-emerald-900:oklch(37.8% .077 168.94);--color-emerald-950:oklch(26.2% .051 172.552);--color-blue-50:oklch(97% .014 254.604);--color-blue-200:oklch(88.2% .059 254.128);--color-blue-300:oklch(80.9% .105 251.813);--color-blue-600:oklch(54.6% .245 262.881);--color-blue-700:oklch(48.8% .243 264.376);--color-violet-50:oklch(96.9% .016 293.756);--color-violet-200:oklch(89.4% .057 293.283);--color-violet-700:oklch(49.1% .27 292.581);--color-slate-50:oklch(98.4% .003 247.858);--color-slate-100:oklch(96.8% .007 247.896);--color-slate-200:oklch(92.9% .013 255.508);--color-slate-300:oklch(86.9% .022 252.894);--color-slate-400:oklch(70.4% .04 256.788);--color-slate-500:oklch(55.4% .046 257.417);--color-slate-600:oklch(44.6% .043 257.281);--color-slate-700:oklch(37.2% .044 257.287);--color-slate-800:oklch(27.9% .041 260.031);--color-slate-900:oklch(20.8% .042 265.755);--color-slate-950:oklch(12.9% .042 264.695);--color-white:#fff;--spacing:.25rem;--container-sm:24rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-base:1rem;--text-base--line-height: 1.5 ;--text-lg:1.125rem;--text-lg--line-height:calc(1.75 / 1.125);--text-xl:1.25rem;--text-xl--line-height:calc(1.75 / 1.25);--text-2xl:1.5rem;--text-2xl--line-height:calc(2 / 1.5);--text-3xl:1.875rem;--text-3xl--line-height: 1.2 ;--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--tracking-wide:.025em;--leading-snug:1.375;--leading-relaxed:1.625;--radius-sm:.25rem;--radius-md:.375rem;--animate-spin:spin 1s linear infinite;--animate-pulse:pulse 2s cubic-bezier(.4, 0, .6, 1) infinite;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4;line-height:1.5;font-family:var(--default-font-family,-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring:where(:not(iframe)){outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){-webkit-appearance:button;-moz-appearance:button;appearance:button}::file-selector-button{-webkit-appearance:button;-moz-appearance:button;appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}:root{color-scheme:light;--color-border:214 20% 88%;--color-background:210 20% 98%;--color-foreground:216 28% 14%;--color-muted:215 16% 47%;--color-panel:0 0% 100%;--color-primary:212 92% 42%}@media(prefers-color-scheme:dark){:root{color-scheme:dark;--color-border:217 24% 25%;--color-background:222 33% 8%;--color-foreground:214 30% 92%;--color-muted:215 18% 68%;--color-panel:222 31% 13%;--color-primary:212 92% 58%}}*{box-sizing:border-box}body{letter-spacing:0;min-width:320px;margin:0;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif;overflow-x:clip}#root{overflow-x:clip}}@layer components{.animate-live-pulse{animation:1.25s ease-in-out infinite live-pulse}.control{border:1px solid hsl(var(--color-border));background:hsl(var(--color-panel));width:100%;height:36px;color:hsl(var(--color-foreground));font:inherit;border-radius:6px;padding:0 10px}}@layer utilities{.pointer-events-none{pointer-events:none}.visible{visibility:visible}.sr-only{clip-path:inset(50%);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.sticky{position:sticky}.inset-0{top:0;right:0;bottom:0;left:0}.top-0{top:0}.top-20{top:calc(var(--spacing) * 20)}.right-0{right:0}.right-3{right:calc(var(--spacing) * 3)}.left-0{left:0}.z-10{z-index:10}.z-20{z-index:20}.z-50{z-index:50}.col-span-2{grid-column:span 2/span 2}.container{width:100%}@media(min-width:40rem){.container{max-width:40rem}}@media(min-width:48rem){.container{max-width:48rem}}@media(min-width:64rem){.container{max-width:64rem}}@media(min-width:80rem){.container{max-width:80rem}}@media(min-width:96rem){.container{max-width:96rem}}.-mx-3{margin-inline:calc(var(--spacing) * -3)}.mx-auto{margin-inline:auto}.my-3{margin-block:calc(var(--spacing) * 3)}.-mt-3{margin-top:calc(var(--spacing) * -3)}.mt-0\.5{margin-top:calc(var(--spacing) * .5)}.mt-1{margin-top:var(--spacing)}.mt-2{margin-top:calc(var(--spacing) * 2)}.mt-3{margin-top:calc(var(--spacing) * 3)}.mb-1{margin-bottom:var(--spacing)}.mb-2{margin-bottom:calc(var(--spacing) * 2)}.mb-3{margin-bottom:calc(var(--spacing) * 3)}.mb-4{margin-bottom:calc(var(--spacing) * 4)}.ml-2{margin-left:calc(var(--spacing) * 2)}.line-clamp-2{-webkit-line-clamp:2;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.block{display:block}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline-flex{display:inline-flex}.table{display:table}.h-2{height:calc(var(--spacing) * 2)}.h-2\.5{height:calc(var(--spacing) * 2.5)}.h-3{height:calc(var(--spacing) * 3)}.h-3\.5{height:calc(var(--spacing) * 3.5)}.h-4{height:calc(var(--spacing) * 4)}.h-5{height:calc(var(--spacing) * 5)}.h-6{height:calc(var(--spacing) * 6)}.h-7{height:calc(var(--spacing) * 7)}.h-8{height:calc(var(--spacing) * 8)}.h-9{height:calc(var(--spacing) * 9)}.h-10{height:calc(var(--spacing) * 10)}.h-40{height:calc(var(--spacing) * 40)}.h-56{height:calc(var(--spacing) * 56)}.h-64{height:calc(var(--spacing) * 64)}.h-72{height:calc(var(--spacing) * 72)}.h-full{height:100%}.max-h-40{max-height:calc(var(--spacing) * 40)}.max-h-56{max-height:calc(var(--spacing) * 56)}.max-h-64{max-height:calc(var(--spacing) * 64)}.max-h-72{max-height:calc(var(--spacing) * 72)}.max-h-\[460px\]{max-height:460px}.max-h-\[620px\]{max-height:620px}.max-h-\[640px\]{max-height:640px}.min-h-5{min-height:calc(var(--spacing) * 5)}.min-h-6{min-height:calc(var(--spacing) * 6)}.min-h-7{min-height:calc(var(--spacing) * 7)}.min-h-10{min-height:calc(var(--spacing) * 10)}.min-h-24{min-height:calc(var(--spacing) * 24)}.min-h-screen{min-height:100vh}.w-2{width:calc(var(--spacing) * 2)}.w-2\.5{width:calc(var(--spacing) * 2.5)}.w-3{width:calc(var(--spacing) * 3)}.w-3\.5{width:calc(var(--spacing) * 3.5)}.w-4{width:calc(var(--spacing) * 4)}.w-5{width:calc(var(--spacing) * 5)}.w-6{width:calc(var(--spacing) * 6)}.w-7{width:calc(var(--spacing) * 7)}.w-8{width:calc(var(--spacing) * 8)}.w-9{width:calc(var(--spacing) * 9)}.w-10{width:calc(var(--spacing) * 10)}.w-11{width:calc(var(--spacing) * 11)}.w-24{width:calc(var(--spacing) * 24)}.w-28{width:calc(var(--spacing) * 28)}.w-32{width:calc(var(--spacing) * 32)}.w-36{width:calc(var(--spacing) * 36)}.w-40{width:calc(var(--spacing) * 40)}.w-44{width:calc(var(--spacing) * 44)}.w-\[42\%\]{width:42%}.w-\[min\(calc\(100vw-1\.5rem\)\,28rem\)\]{width:min(100vw - 1.5rem,28rem)}.w-fit{width:fit-content}.w-full{width:100%}.max-w-40{max-width:calc(var(--spacing) * 40)}.max-w-\[14rem\]{max-width:14rem}.max-w-\[1440px\]{max-width:1440px}.max-w-full{max-width:100%}.max-w-sm{max-width:var(--container-sm)}.min-w-0{min-width:0}.min-w-5{min-width:calc(var(--spacing) * 5)}.min-w-56{min-width:calc(var(--spacing) * 56)}.min-w-\[180px\]{min-width:180px}.min-w-\[190px\]{min-width:190px}.min-w-\[840px\]{min-width:840px}.min-w-\[920px\]{min-width:920px}.min-w-\[1080px\]{min-width:1080px}.min-w-\[1120px\]{min-width:1120px}.min-w-full{min-width:100%}.flex-1{flex:1}.shrink-0{flex-shrink:0}.table-fixed{table-layout:fixed}.border-collapse{border-collapse:collapse}.transform{transform:var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,)}.animate-pulse{animation:var(--animate-pulse)}.animate-spin{animation:var(--animate-spin)}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.list-decimal{list-style-type:decimal}.list-disc{list-style-type:disc}.list-none{list-style-type:none}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-\[auto_minmax\(0\,1fr\)\]{grid-template-columns:auto minmax(0,1fr)}.grid-cols-\[auto_minmax\(0\,1fr\)_auto\]{grid-template-columns:auto minmax(0,1fr) auto}.grid-cols-\[minmax\(0\,1\.35fr\)_90px_120px_90px_minmax\(0\,1fr\)\]{grid-template-columns:minmax(0,1.35fr) 90px 120px 90px minmax(0,1fr)}.grid-cols-\[minmax\(0\,1fr\)_auto\]{grid-template-columns:minmax(0,1fr) auto}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.gap-1{gap:var(--spacing)}.gap-1\.5{gap:calc(var(--spacing) * 1.5)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-3{gap:calc(var(--spacing) * 3)}.gap-4{gap:calc(var(--spacing) * 4)}:where(.space-y-1>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(var(--spacing) * var(--tw-space-y-reverse));margin-block-end:calc(var(--spacing) * calc(1 - var(--tw-space-y-reverse)))}.gap-x-2{column-gap:calc(var(--spacing) * 2)}.gap-x-4{column-gap:calc(var(--spacing) * 4)}.gap-y-1{row-gap:var(--spacing)}:where(.divide-y>:not(:last-child)){--tw-divide-y-reverse:0;border-bottom-style:var(--tw-border-style);border-top-style:var(--tw-border-style);border-top-width:calc(1px * var(--tw-divide-y-reverse));border-bottom-width:calc(1px * calc(1 - var(--tw-divide-y-reverse)))}:where(.divide-border>:not(:last-child)){border-color:hsl(var(--color-border))}.self-end{align-self:flex-end}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.rounded{border-radius:.25rem}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:8px}.rounded-md{border-radius:var(--radius-md)}.rounded-sm{border-radius:var(--radius-sm)}.border{border-style:var(--tw-border-style);border-width:1px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-l-2{border-left-style:var(--tw-border-style);border-left-width:2px}.border-dashed{--tw-border-style:dashed;border-style:dashed}.border-amber-200{border-color:var(--color-amber-200)}.border-amber-300{border-color:var(--color-amber-300)}.border-blue-200{border-color:var(--color-blue-200)}.border-blue-300{border-color:var(--color-blue-300)}.border-border{border-color:hsl(var(--color-border))}.border-border\/70{border-color:color-mix(in srgb,hsl(hsl(var(--color-border))) 70%,transparent)}@supports (color:color-mix(in lab,red,red)){.border-border\/70{border-color:color-mix(in oklab,hsl(var(--color-border)) 70%,transparent)}}.border-current\/30{border-color:currentColor}@supports (color:color-mix(in lab,red,red)){.border-current\/30{border-color:color-mix(in oklab,currentcolor 30%,transparent)}}.border-emerald-200{border-color:var(--color-emerald-200)}.border-emerald-300{border-color:var(--color-emerald-300)}.border-emerald-400{border-color:var(--color-emerald-400)}.border-primary{border-color:hsl(var(--color-primary))}.border-red-200{border-color:var(--color-red-200)}.border-red-300{border-color:var(--color-red-300)}.border-slate-200{border-color:var(--color-slate-200)}.border-slate-300{border-color:var(--color-slate-300)}.border-slate-700{border-color:var(--color-slate-700)}.border-slate-800{border-color:var(--color-slate-800)}.border-violet-200{border-color:var(--color-violet-200)}.border-white\/40{border-color:#fff6}@supports (color:color-mix(in lab,red,red)){.border-white\/40{border-color:color-mix(in oklab,var(--color-white) 40%,transparent)}}.bg-amber-50{background-color:var(--color-amber-50)}.bg-amber-100{background-color:var(--color-amber-100)}.bg-amber-500{background-color:var(--color-amber-500)}.bg-amber-800{background-color:var(--color-amber-800)}.bg-background{background-color:hsl(var(--color-background))}.bg-blue-50{background-color:var(--color-blue-50)}.bg-blue-600{background-color:var(--color-blue-600)}.bg-emerald-50{background-color:var(--color-emerald-50)}.bg-emerald-600{background-color:var(--color-emerald-600)}.bg-emerald-950{background-color:var(--color-emerald-950)}.bg-panel{background-color:hsl(var(--color-panel))}.bg-panel\/95{background-color:color-mix(in srgb,hsl(hsl(var(--color-panel))) 95%,transparent)}@supports (color:color-mix(in lab,red,red)){.bg-panel\/95{background-color:color-mix(in oklab,hsl(var(--color-panel)) 95%,transparent)}}.bg-primary{background-color:hsl(var(--color-primary))}.bg-red-50{background-color:var(--color-red-50)}.bg-red-600{background-color:var(--color-red-600)}.bg-slate-50{background-color:var(--color-slate-50)}.bg-slate-50\/60{background-color:#f8fafc99}@supports (color:color-mix(in lab,red,red)){.bg-slate-50\/60{background-color:color-mix(in oklab,var(--color-slate-50) 60%,transparent)}}.bg-slate-50\/70{background-color:#f8fafcb3}@supports (color:color-mix(in lab,red,red)){.bg-slate-50\/70{background-color:color-mix(in oklab,var(--color-slate-50) 70%,transparent)}}.bg-slate-100{background-color:var(--color-slate-100)}.bg-slate-300{background-color:var(--color-slate-300)}.bg-slate-500{background-color:var(--color-slate-500)}.bg-slate-800{background-color:var(--color-slate-800)}.bg-slate-900{background-color:var(--color-slate-900)}.bg-slate-950{background-color:var(--color-slate-950)}.bg-transparent{background-color:#0000}.bg-violet-50{background-color:var(--color-violet-50)}.bg-white{background-color:var(--color-white)}.bg-white\/15{background-color:#ffffff26}@supports (color:color-mix(in lab,red,red)){.bg-white\/15{background-color:color-mix(in oklab,var(--color-white) 15%,transparent)}}.bg-white\/70{background-color:#ffffffb3}@supports (color:color-mix(in lab,red,red)){.bg-white\/70{background-color:color-mix(in oklab,var(--color-white) 70%,transparent)}}.bg-white\/80{background-color:#fffc}@supports (color:color-mix(in lab,red,red)){.bg-white\/80{background-color:color-mix(in oklab,var(--color-white) 80%,transparent)}}.p-0\.5{padding:calc(var(--spacing) * .5)}.p-1{padding:var(--spacing)}.p-2\.5{padding:calc(var(--spacing) * 2.5)}.p-3{padding:calc(var(--spacing) * 3)}.p-4{padding:calc(var(--spacing) * 4)}.p-6{padding:calc(var(--spacing) * 6)}.px-0{padding-inline:0}.px-1{padding-inline:var(--spacing)}.px-1\.5{padding-inline:calc(var(--spacing) * 1.5)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-2\.5{padding-inline:calc(var(--spacing) * 2.5)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-4{padding-inline:calc(var(--spacing) * 4)}.py-0\.5{padding-block:calc(var(--spacing) * .5)}.py-1{padding-block:var(--spacing)}.py-1\.5{padding-block:calc(var(--spacing) * 1.5)}.py-2{padding-block:calc(var(--spacing) * 2)}.py-3{padding-block:calc(var(--spacing) * 3)}.py-4{padding-block:calc(var(--spacing) * 4)}.py-10{padding-block:calc(var(--spacing) * 10)}.pt-2{padding-top:calc(var(--spacing) * 2)}.pt-3{padding-top:calc(var(--spacing) * 3)}.pr-1{padding-right:var(--spacing)}.pb-3{padding-bottom:calc(var(--spacing) * 3)}.pl-0\.5{padding-left:calc(var(--spacing) * .5)}.pl-2{padding-left:calc(var(--spacing) * 2)}.pl-3{padding-left:calc(var(--spacing) * 3)}.pl-5{padding-left:calc(var(--spacing) * 5)}.text-center{text-align:center}.text-left{text-align:left}.text-right{text-align:right}.align-top{vertical-align:top}.font-mono{font-family:var(--font-mono)}.text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height))}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xl{font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\[0\.85em\]{font-size:.85em}.text-\[10px\]{font-size:10px}.text-\[11px\]{font-size:11px}.leading-none{--tw-leading:1;line-height:1}.leading-relaxed{--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.leading-snug{--tw-leading:var(--leading-snug);line-height:var(--leading-snug)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.\[overflow-wrap\:anywhere\]{overflow-wrap:anywhere}.break-words{overflow-wrap:break-word}.break-all{word-break:break-all}.whitespace-pre-wrap{white-space:pre-wrap}.text-amber-700{color:var(--color-amber-700)}.text-amber-800{color:var(--color-amber-800)}.text-amber-900{color:var(--color-amber-900)}.text-amber-950{color:var(--color-amber-950)}.text-blue-700{color:var(--color-blue-700)}.text-blue-700\/70{color:#1447e6b3}@supports (color:color-mix(in lab,red,red)){.text-blue-700\/70{color:color-mix(in oklab,var(--color-blue-700) 70%,transparent)}}.text-emerald-50{color:var(--color-emerald-50)}.text-emerald-700{color:var(--color-emerald-700)}.text-emerald-800{color:var(--color-emerald-800)}.text-emerald-900{color:var(--color-emerald-900)}.text-emerald-950{color:var(--color-emerald-950)}.text-foreground{color:hsl(var(--color-foreground))}.text-muted{color:hsl(var(--color-muted))}.text-primary{color:hsl(var(--color-primary))}.text-red-600{color:var(--color-red-600)}.text-red-700{color:var(--color-red-700)}.text-red-950{color:var(--color-red-950)}.text-slate-100{color:var(--color-slate-100)}.text-slate-200{color:var(--color-slate-200)}.text-slate-300{color:var(--color-slate-300)}.text-slate-400{color:var(--color-slate-400)}.text-slate-600{color:var(--color-slate-600)}.text-slate-700{color:var(--color-slate-700)}.text-violet-700{color:var(--color-violet-700)}.text-white{color:var(--color-white)}.capitalize{text-transform:capitalize}.uppercase{text-transform:uppercase}.italic{font-style:italic}.tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal,) var(--tw-slashed-zero,) var(--tw-numeric-figure,) var(--tw-numeric-spacing,) var(--tw-numeric-fraction,)}.underline{text-decoration-line:underline}.underline-offset-2{text-underline-offset:2px}.opacity-0{opacity:0}.opacity-60{opacity:.6}.shadow{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[0_1px_0_rgba\(15\,23\,42\,0\.03\)\]{--tw-shadow:0 1px 0 var(--tw-shadow-color,#0f172a08);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a), 0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-xl{--tw-shadow:0 20px 25px -5px var(--tw-shadow-color,#0000001a), 0 8px 10px -6px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-slate-950\/15{--tw-shadow-color:#02061826}@supports (color:color-mix(in lab,red,red)){.shadow-slate-950\/15{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-slate-950) 15%, transparent) var(--tw-shadow-alpha), transparent)}}.filter{filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.backdrop-blur{--tw-backdrop-blur:blur(8px);-webkit-backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,)}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.outline-none{--tw-outline-style:none;outline-style:none}.group-open\:rotate-180:is(:where(.group):is([open],:popover-open,:open) *){rotate:180deg}.peer-checked\:bg-primary:is(:where(.peer):checked~*){background-color:hsl(var(--color-primary))}.peer-focus-visible\:outline:is(:where(.peer):focus-visible~*){outline-style:var(--tw-outline-style);outline-width:1px}.peer-focus-visible\:outline-2:is(:where(.peer):focus-visible~*){outline-style:var(--tw-outline-style);outline-width:2px}.peer-focus-visible\:outline-offset-2:is(:where(.peer):focus-visible~*){outline-offset:2px}.peer-focus-visible\:outline-primary:is(:where(.peer):focus-visible~*){outline-color:hsl(var(--color-primary))}.peer-disabled\:opacity-50:is(:where(.peer):disabled~*){opacity:.5}.marker\:hidden ::marker{display:none}.marker\:hidden::marker{display:none}.marker\:hidden ::-webkit-details-marker{display:none}.marker\:hidden::-webkit-details-marker{display:none}.after\:absolute:after{content:var(--tw-content);position:absolute}.after\:top-0\.5:after{content:var(--tw-content);top:calc(var(--spacing) * .5)}.after\:left-0\.5:after{content:var(--tw-content);left:calc(var(--spacing) * .5)}.after\:h-5:after{content:var(--tw-content);height:calc(var(--spacing) * 5)}.after\:w-5:after{content:var(--tw-content);width:calc(var(--spacing) * 5)}.after\:rounded-full:after{content:var(--tw-content);border-radius:3.40282e38px}.after\:bg-white:after{content:var(--tw-content);background-color:var(--color-white)}.after\:shadow-sm:after{content:var(--tw-content);--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.after\:transition-transform:after{content:var(--tw-content);transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.peer-checked\:after\:translate-x-5:is(:where(.peer):checked~*):after{content:var(--tw-content);--tw-translate-x:calc(var(--spacing) * 5);translate:var(--tw-translate-x) var(--tw-translate-y)}.first\:mt-0:first-child{margin-top:0}.last\:border-0:last-child{border-style:var(--tw-border-style);border-width:0}.last\:border-b-0:last-child{border-bottom-style:var(--tw-border-style);border-bottom-width:0}.focus-within\:border-primary:focus-within{border-color:hsl(var(--color-primary))}.focus-within\:ring-1:focus-within{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus-within\:ring-primary:focus-within{--tw-ring-color:hsl(var(--color-primary))}@media(hover:hover){.hover\:bg-amber-100:hover{background-color:var(--color-amber-100)}.hover\:bg-amber-900:hover{background-color:var(--color-amber-900)}.hover\:bg-emerald-100:hover{background-color:var(--color-emerald-100)}.hover\:bg-red-50:hover{background-color:var(--color-red-50)}.hover\:bg-red-100:hover{background-color:var(--color-red-100)}.hover\:bg-slate-50:hover{background-color:var(--color-slate-50)}.hover\:bg-slate-100:hover{background-color:var(--color-slate-100)}.hover\:bg-white:hover{background-color:var(--color-white)}.hover\:text-foreground:hover{color:hsl(var(--color-foreground))}.hover\:underline:hover{text-decoration-line:underline}}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:cursor-wait:disabled{cursor:wait}.disabled\:opacity-50:disabled{opacity:.5}.disabled\:opacity-60:disabled{opacity:.6}@media(hover:hover){.disabled\:hover\:bg-white:disabled:hover{background-color:var(--color-white)}}@media(min-width:40rem){.sm\:-mx-4{margin-inline:calc(var(--spacing) * -4)}.sm\:-mt-4{margin-top:calc(var(--spacing) * -4)}.sm\:block{display:block}.sm\:flex{display:flex}.sm\:inline{display:inline}.sm\:w-auto{width:auto}.sm\:flex-none{flex:none}.sm\:shrink-0{flex-shrink:0}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.sm\:items-center{align-items:center}.sm\:justify-between{justify-content:space-between}.sm\:gap-1\.5{gap:calc(var(--spacing) * 1.5)}.sm\:gap-2{gap:calc(var(--spacing) * 2)}.sm\:gap-3{gap:calc(var(--spacing) * 3)}.sm\:gap-4{gap:calc(var(--spacing) * 4)}.sm\:truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.sm\:p-4{padding:calc(var(--spacing) * 4)}.sm\:px-3{padding-inline:calc(var(--spacing) * 3)}.sm\:px-4{padding-inline:calc(var(--spacing) * 4)}.sm\:pl-0{padding-left:0}.sm\:text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}}@media(min-width:48rem){.md\:col-span-1{grid-column:span 1/span 1}.md\:mt-4{margin-top:calc(var(--spacing) * 4)}.md\:block{display:block}.md\:grid{display:grid}.md\:hidden{display:none}.md\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.md\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.md\:grid-cols-\[minmax\(0\,1\.35fr\)_90px_120px_90px_minmax\(0\,1fr\)\]{grid-template-columns:minmax(0,1.35fr) 90px 120px 90px minmax(0,1fr)}.md\:grid-cols-\[minmax\(0\,1fr\)\]{grid-template-columns:minmax(0,1fr)}.md\:grid-cols-\[minmax\(0\,1fr\)_220px\]{grid-template-columns:minmax(0,1fr) 220px}.md\:grid-cols-\[minmax\(0\,1fr\)_auto\]{grid-template-columns:minmax(0,1fr) auto}.md\:grid-cols-\[minmax\(0\,1fr\)_minmax\(12rem\,16rem\)_auto\]{grid-template-columns:minmax(0,1fr) minmax(12rem,16rem) auto}.md\:grid-cols-\[minmax\(0\,1fr\)_minmax\(240px\,0\.8fr\)\]{grid-template-columns:minmax(0,1fr) minmax(240px,.8fr)}.md\:items-center{align-items:center}.md\:gap-3{gap:calc(var(--spacing) * 3)}.md\:p-4{padding:calc(var(--spacing) * 4)}.md\:px-4{padding-inline:calc(var(--spacing) * 4)}.md\:px-6{padding-inline:calc(var(--spacing) * 6)}.md\:py-5{padding-block:calc(var(--spacing) * 5)}.md\:text-3xl{font-size:var(--text-3xl);line-height:var(--tw-leading,var(--text-3xl--line-height))}}@media(min-width:64rem){.lg\:min-w-\[420px\]{min-width:420px}.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.lg\:grid-cols-\[minmax\(0\,0\.9fr\)_minmax\(0\,1\.1fr\)\]{grid-template-columns:minmax(0,.9fr) minmax(0,1.1fr)}.lg\:grid-cols-\[minmax\(0\,1fr\)_minmax\(0\,1fr\)\]{grid-template-columns:minmax(0,1fr) minmax(0,1fr)}.lg\:grid-cols-\[minmax\(0\,1fr\)_minmax\(280px\,auto\)\]{grid-template-columns:minmax(0,1fr) minmax(280px,auto)}.lg\:flex-row{flex-direction:row}.lg\:items-start{align-items:flex-start}.lg\:justify-between{justify-content:space-between}}@media(min-width:80rem){.xl\:col-span-2{grid-column:span 2/span 2}.xl\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.xl\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.xl\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.xl\:grid-cols-9{grid-template-columns:repeat(9,minmax(0,1fr))}}.\[\&\>span\]\:truncate>span{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.\[\&\>svg\]\:shrink-0>svg{flex-shrink:0}@media(prefers-color-scheme:dark){.bg-white,.bg-white\/70,.bg-white\/80,.hover\:bg-white:hover{background-color:hsl(var(--color-panel))}.bg-slate-50,.bg-slate-50\/60,.bg-slate-50\/70,.bg-slate-100,.hover\:bg-slate-50:hover,.hover\:bg-slate-100:hover{background-color:#1f2637}.bg-blue-50{background-color:#152847}.bg-amber-50,.bg-amber-100,.hover\:bg-amber-100:hover{background-color:#46310b}.bg-red-50,.hover\:bg-red-50:hover{background-color:#441818}.bg-emerald-50,.hover\:bg-emerald-100:hover{background-color:#163b2b}.border-slate-200,.border-slate-300,.border-slate-700,.border-slate-800{border-color:hsl(var(--color-border))}.border-amber-200,.border-amber-300{border-color:#956b23}.border-blue-200,.border-blue-300{border-color:#2757a5}.border-red-200,.border-red-300{border-color:#a72f2f}.border-emerald-300{border-color:#30976a}.text-slate-600,.text-slate-700,.text-slate-800,.text-slate-900,.hover\:text-slate-900:hover{color:hsl(var(--color-foreground))}.text-slate-300,.text-slate-400,.text-slate-500,.hover\:text-slate-500:hover{color:hsl(var(--color-muted))}.text-blue-700{color:#92c2fc}.text-amber-700,.text-amber-800,.text-amber-900,.text-amber-950{color:#fde7af}.text-red-600,.text-red-700,.text-red-950{color:#fbacac}.text-emerald-700,.text-emerald-800,.text-emerald-900,.text-emerald-950{color:#a3f5cd}}}@keyframes live-pulse{0%,to{opacity:1;transform:scale(1)}50%{opacity:.35;transform:scale(.72)}}@media(prefers-reduced-motion:reduce){.animate-live-pulse{animation:none}}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-divide-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-ordinal{syntax:"*";inherits:false}@property --tw-slashed-zero{syntax:"*";inherits:false}@property --tw-numeric-figure{syntax:"*";inherits:false}@property --tw-numeric-spacing{syntax:"*";inherits:false}@property --tw-numeric-fraction{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-backdrop-blur{syntax:"*";inherits:false}@property --tw-backdrop-brightness{syntax:"*";inherits:false}@property --tw-backdrop-contrast{syntax:"*";inherits:false}@property --tw-backdrop-grayscale{syntax:"*";inherits:false}@property --tw-backdrop-hue-rotate{syntax:"*";inherits:false}@property --tw-backdrop-invert{syntax:"*";inherits:false}@property --tw-backdrop-opacity{syntax:"*";inherits:false}@property --tw-backdrop-saturate{syntax:"*";inherits:false}@property --tw-backdrop-sepia{syntax:"*";inherits:false}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-content{syntax:"*";inherits:false;initial-value:""}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@keyframes spin{to{transform:rotate(360deg)}}@keyframes pulse{50%{opacity:.5}} +/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reverse:0;--tw-divide-y-reverse:0;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-outline-style:solid;--tw-content:"";--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0}}}@layer theme{:root,:host{--font-sans:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--color-red-50:oklch(97.1% .013 17.38);--color-red-100:oklch(93.6% .032 17.717);--color-red-200:oklch(88.5% .062 18.334);--color-red-300:oklch(80.8% .114 19.571);--color-red-600:oklch(57.7% .245 27.325);--color-red-700:oklch(50.5% .213 27.518);--color-red-950:oklch(25.8% .092 26.042);--color-amber-50:oklch(98.7% .022 95.277);--color-amber-100:oklch(96.2% .059 95.617);--color-amber-200:oklch(92.4% .12 95.746);--color-amber-300:oklch(87.9% .169 91.605);--color-amber-500:oklch(76.9% .188 70.08);--color-amber-700:oklch(55.5% .163 48.998);--color-amber-800:oklch(47.3% .137 46.201);--color-amber-900:oklch(41.4% .112 45.904);--color-amber-950:oklch(27.9% .077 45.635);--color-emerald-50:oklch(97.9% .021 166.113);--color-emerald-100:oklch(95% .052 163.051);--color-emerald-200:oklch(90.5% .093 164.15);--color-emerald-300:oklch(84.5% .143 164.978);--color-emerald-400:oklch(76.5% .177 163.223);--color-emerald-600:oklch(59.6% .145 163.225);--color-emerald-700:oklch(50.8% .118 165.612);--color-emerald-800:oklch(43.2% .095 166.913);--color-emerald-900:oklch(37.8% .077 168.94);--color-emerald-950:oklch(26.2% .051 172.552);--color-blue-50:oklch(97% .014 254.604);--color-blue-200:oklch(88.2% .059 254.128);--color-blue-300:oklch(80.9% .105 251.813);--color-blue-600:oklch(54.6% .245 262.881);--color-blue-700:oklch(48.8% .243 264.376);--color-violet-50:oklch(96.9% .016 293.756);--color-violet-200:oklch(89.4% .057 293.283);--color-violet-700:oklch(49.1% .27 292.581);--color-slate-50:oklch(98.4% .003 247.858);--color-slate-100:oklch(96.8% .007 247.896);--color-slate-200:oklch(92.9% .013 255.508);--color-slate-300:oklch(86.9% .022 252.894);--color-slate-400:oklch(70.4% .04 256.788);--color-slate-500:oklch(55.4% .046 257.417);--color-slate-600:oklch(44.6% .043 257.281);--color-slate-700:oklch(37.2% .044 257.287);--color-slate-800:oklch(27.9% .041 260.031);--color-slate-900:oklch(20.8% .042 265.755);--color-slate-950:oklch(12.9% .042 264.695);--color-white:#fff;--spacing:.25rem;--container-sm:24rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-base:1rem;--text-base--line-height: 1.5 ;--text-lg:1.125rem;--text-lg--line-height:calc(1.75 / 1.125);--text-xl:1.25rem;--text-xl--line-height:calc(1.75 / 1.25);--text-2xl:1.5rem;--text-2xl--line-height:calc(2 / 1.5);--text-3xl:1.875rem;--text-3xl--line-height: 1.2 ;--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--tracking-wide:.025em;--leading-snug:1.375;--leading-relaxed:1.625;--radius-sm:.25rem;--radius-md:.375rem;--animate-spin:spin 1s linear infinite;--animate-pulse:pulse 2s cubic-bezier(.4, 0, .6, 1) infinite;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4;line-height:1.5;font-family:var(--default-font-family,-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring:where(:not(iframe)){outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){-webkit-appearance:button;-moz-appearance:button;appearance:button}::file-selector-button{-webkit-appearance:button;-moz-appearance:button;appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}:root{color-scheme:light;--color-border:214 20% 88%;--color-background:210 20% 98%;--color-foreground:216 28% 14%;--color-muted:215 16% 47%;--color-panel:0 0% 100%;--color-primary:212 92% 42%}@media(prefers-color-scheme:dark){:root{color-scheme:dark;--color-border:217 24% 25%;--color-background:222 33% 8%;--color-foreground:214 30% 92%;--color-muted:215 18% 68%;--color-panel:222 31% 13%;--color-primary:212 92% 58%}}*{box-sizing:border-box}body{letter-spacing:0;min-width:320px;margin:0;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif;overflow-x:clip}#root{overflow-x:clip}}@layer components{.animate-live-pulse{animation:1.25s ease-in-out infinite live-pulse}.control{border:1px solid hsl(var(--color-border));background:hsl(var(--color-panel));width:100%;height:36px;color:hsl(var(--color-foreground));font:inherit;border-radius:6px;padding:0 10px}}@layer utilities{.pointer-events-none{pointer-events:none}.visible{visibility:visible}.sr-only{clip-path:inset(50%);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.sticky{position:sticky}.inset-0{top:0;right:0;bottom:0;left:0}.top-0{top:0}.top-20{top:calc(var(--spacing) * 20)}.right-0{right:0}.right-3{right:calc(var(--spacing) * 3)}.left-0{left:0}.z-10{z-index:10}.z-20{z-index:20}.z-50{z-index:50}.col-span-2{grid-column:span 2/span 2}.container{width:100%}@media(min-width:40rem){.container{max-width:40rem}}@media(min-width:48rem){.container{max-width:48rem}}@media(min-width:64rem){.container{max-width:64rem}}@media(min-width:80rem){.container{max-width:80rem}}@media(min-width:96rem){.container{max-width:96rem}}.-mx-3{margin-inline:calc(var(--spacing) * -3)}.mx-auto{margin-inline:auto}.my-3{margin-block:calc(var(--spacing) * 3)}.-mt-3{margin-top:calc(var(--spacing) * -3)}.mt-0\.5{margin-top:calc(var(--spacing) * .5)}.mt-1{margin-top:var(--spacing)}.mt-2{margin-top:calc(var(--spacing) * 2)}.mt-3{margin-top:calc(var(--spacing) * 3)}.mb-1{margin-bottom:var(--spacing)}.mb-2{margin-bottom:calc(var(--spacing) * 2)}.mb-3{margin-bottom:calc(var(--spacing) * 3)}.mb-4{margin-bottom:calc(var(--spacing) * 4)}.ml-2{margin-left:calc(var(--spacing) * 2)}.line-clamp-2{-webkit-line-clamp:2;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.block{display:block}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline-flex{display:inline-flex}.table{display:table}.h-2{height:calc(var(--spacing) * 2)}.h-2\.5{height:calc(var(--spacing) * 2.5)}.h-3{height:calc(var(--spacing) * 3)}.h-3\.5{height:calc(var(--spacing) * 3.5)}.h-4{height:calc(var(--spacing) * 4)}.h-5{height:calc(var(--spacing) * 5)}.h-6{height:calc(var(--spacing) * 6)}.h-7{height:calc(var(--spacing) * 7)}.h-8{height:calc(var(--spacing) * 8)}.h-9{height:calc(var(--spacing) * 9)}.h-10{height:calc(var(--spacing) * 10)}.h-40{height:calc(var(--spacing) * 40)}.h-56{height:calc(var(--spacing) * 56)}.h-64{height:calc(var(--spacing) * 64)}.h-72{height:calc(var(--spacing) * 72)}.h-full{height:100%}.max-h-40{max-height:calc(var(--spacing) * 40)}.max-h-56{max-height:calc(var(--spacing) * 56)}.max-h-64{max-height:calc(var(--spacing) * 64)}.max-h-72{max-height:calc(var(--spacing) * 72)}.max-h-\[460px\]{max-height:460px}.max-h-\[620px\]{max-height:620px}.max-h-\[640px\]{max-height:640px}.min-h-5{min-height:calc(var(--spacing) * 5)}.min-h-6{min-height:calc(var(--spacing) * 6)}.min-h-7{min-height:calc(var(--spacing) * 7)}.min-h-10{min-height:calc(var(--spacing) * 10)}.min-h-24{min-height:calc(var(--spacing) * 24)}.min-h-screen{min-height:100vh}.w-2{width:calc(var(--spacing) * 2)}.w-2\.5{width:calc(var(--spacing) * 2.5)}.w-3{width:calc(var(--spacing) * 3)}.w-3\.5{width:calc(var(--spacing) * 3.5)}.w-4{width:calc(var(--spacing) * 4)}.w-5{width:calc(var(--spacing) * 5)}.w-6{width:calc(var(--spacing) * 6)}.w-7{width:calc(var(--spacing) * 7)}.w-8{width:calc(var(--spacing) * 8)}.w-9{width:calc(var(--spacing) * 9)}.w-10{width:calc(var(--spacing) * 10)}.w-11{width:calc(var(--spacing) * 11)}.w-24{width:calc(var(--spacing) * 24)}.w-28{width:calc(var(--spacing) * 28)}.w-32{width:calc(var(--spacing) * 32)}.w-36{width:calc(var(--spacing) * 36)}.w-40{width:calc(var(--spacing) * 40)}.w-44{width:calc(var(--spacing) * 44)}.w-\[42\%\]{width:42%}.w-\[min\(calc\(100vw-1\.5rem\)\,28rem\)\]{width:min(100vw - 1.5rem,28rem)}.w-fit{width:fit-content}.w-full{width:100%}.max-w-40{max-width:calc(var(--spacing) * 40)}.max-w-\[14rem\]{max-width:14rem}.max-w-\[1440px\]{max-width:1440px}.max-w-full{max-width:100%}.max-w-sm{max-width:var(--container-sm)}.min-w-0{min-width:0}.min-w-5{min-width:calc(var(--spacing) * 5)}.min-w-56{min-width:calc(var(--spacing) * 56)}.min-w-\[180px\]{min-width:180px}.min-w-\[190px\]{min-width:190px}.min-w-\[840px\]{min-width:840px}.min-w-\[920px\]{min-width:920px}.min-w-\[1080px\]{min-width:1080px}.min-w-\[1120px\]{min-width:1120px}.min-w-full{min-width:100%}.flex-1{flex:1}.shrink-0{flex-shrink:0}.table-fixed{table-layout:fixed}.border-collapse{border-collapse:collapse}.transform{transform:var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,)}.animate-pulse{animation:var(--animate-pulse)}.animate-spin{animation:var(--animate-spin)}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.list-decimal{list-style-type:decimal}.list-disc{list-style-type:disc}.list-none{list-style-type:none}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-\[auto_minmax\(0\,1fr\)\]{grid-template-columns:auto minmax(0,1fr)}.grid-cols-\[auto_minmax\(0\,1fr\)_auto\]{grid-template-columns:auto minmax(0,1fr) auto}.grid-cols-\[minmax\(0\,1\.35fr\)_90px_120px_90px_minmax\(0\,1fr\)\]{grid-template-columns:minmax(0,1.35fr) 90px 120px 90px minmax(0,1fr)}.grid-cols-\[minmax\(0\,1fr\)_auto\]{grid-template-columns:minmax(0,1fr) auto}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.gap-1{gap:var(--spacing)}.gap-1\.5{gap:calc(var(--spacing) * 1.5)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-3{gap:calc(var(--spacing) * 3)}.gap-4{gap:calc(var(--spacing) * 4)}:where(.space-y-1>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(var(--spacing) * var(--tw-space-y-reverse));margin-block-end:calc(var(--spacing) * calc(1 - var(--tw-space-y-reverse)))}.gap-x-2{column-gap:calc(var(--spacing) * 2)}.gap-x-4{column-gap:calc(var(--spacing) * 4)}.gap-y-1{row-gap:var(--spacing)}:where(.divide-y>:not(:last-child)){--tw-divide-y-reverse:0;border-bottom-style:var(--tw-border-style);border-top-style:var(--tw-border-style);border-top-width:calc(1px * var(--tw-divide-y-reverse));border-bottom-width:calc(1px * calc(1 - var(--tw-divide-y-reverse)))}:where(.divide-border>:not(:last-child)){border-color:hsl(var(--color-border))}.self-end{align-self:flex-end}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.rounded{border-radius:.25rem}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:8px}.rounded-md{border-radius:var(--radius-md)}.rounded-sm{border-radius:var(--radius-sm)}.border{border-style:var(--tw-border-style);border-width:1px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-l-2{border-left-style:var(--tw-border-style);border-left-width:2px}.border-dashed{--tw-border-style:dashed;border-style:dashed}.border-amber-200{border-color:var(--color-amber-200)}.border-amber-300{border-color:var(--color-amber-300)}.border-blue-200{border-color:var(--color-blue-200)}.border-blue-300{border-color:var(--color-blue-300)}.border-border{border-color:hsl(var(--color-border))}.border-border\/70{border-color:color-mix(in srgb,hsl(hsl(var(--color-border))) 70%,transparent)}@supports (color:color-mix(in lab,red,red)){.border-border\/70{border-color:color-mix(in oklab,hsl(var(--color-border)) 70%,transparent)}}.border-current\/30{border-color:currentColor}@supports (color:color-mix(in lab,red,red)){.border-current\/30{border-color:color-mix(in oklab,currentcolor 30%,transparent)}}.border-emerald-200{border-color:var(--color-emerald-200)}.border-emerald-300{border-color:var(--color-emerald-300)}.border-emerald-400{border-color:var(--color-emerald-400)}.border-primary{border-color:hsl(var(--color-primary))}.border-red-200{border-color:var(--color-red-200)}.border-red-300{border-color:var(--color-red-300)}.border-slate-200{border-color:var(--color-slate-200)}.border-slate-300{border-color:var(--color-slate-300)}.border-slate-700{border-color:var(--color-slate-700)}.border-slate-800{border-color:var(--color-slate-800)}.border-violet-200{border-color:var(--color-violet-200)}.border-white\/40{border-color:#fff6}@supports (color:color-mix(in lab,red,red)){.border-white\/40{border-color:color-mix(in oklab,var(--color-white) 40%,transparent)}}.bg-amber-50{background-color:var(--color-amber-50)}.bg-amber-100{background-color:var(--color-amber-100)}.bg-amber-500{background-color:var(--color-amber-500)}.bg-amber-800{background-color:var(--color-amber-800)}.bg-background{background-color:hsl(var(--color-background))}.bg-blue-50{background-color:var(--color-blue-50)}.bg-blue-600{background-color:var(--color-blue-600)}.bg-emerald-50{background-color:var(--color-emerald-50)}.bg-emerald-600{background-color:var(--color-emerald-600)}.bg-emerald-950{background-color:var(--color-emerald-950)}.bg-panel{background-color:hsl(var(--color-panel))}.bg-panel\/95{background-color:color-mix(in srgb,hsl(hsl(var(--color-panel))) 95%,transparent)}@supports (color:color-mix(in lab,red,red)){.bg-panel\/95{background-color:color-mix(in oklab,hsl(var(--color-panel)) 95%,transparent)}}.bg-primary{background-color:hsl(var(--color-primary))}.bg-red-50{background-color:var(--color-red-50)}.bg-red-600{background-color:var(--color-red-600)}.bg-slate-50{background-color:var(--color-slate-50)}.bg-slate-50\/60{background-color:#f8fafc99}@supports (color:color-mix(in lab,red,red)){.bg-slate-50\/60{background-color:color-mix(in oklab,var(--color-slate-50) 60%,transparent)}}.bg-slate-50\/70{background-color:#f8fafcb3}@supports (color:color-mix(in lab,red,red)){.bg-slate-50\/70{background-color:color-mix(in oklab,var(--color-slate-50) 70%,transparent)}}.bg-slate-100{background-color:var(--color-slate-100)}.bg-slate-300{background-color:var(--color-slate-300)}.bg-slate-500{background-color:var(--color-slate-500)}.bg-slate-800{background-color:var(--color-slate-800)}.bg-slate-900{background-color:var(--color-slate-900)}.bg-slate-950{background-color:var(--color-slate-950)}.bg-transparent{background-color:#0000}.bg-violet-50{background-color:var(--color-violet-50)}.bg-white{background-color:var(--color-white)}.bg-white\/15{background-color:#ffffff26}@supports (color:color-mix(in lab,red,red)){.bg-white\/15{background-color:color-mix(in oklab,var(--color-white) 15%,transparent)}}.bg-white\/70{background-color:#ffffffb3}@supports (color:color-mix(in lab,red,red)){.bg-white\/70{background-color:color-mix(in oklab,var(--color-white) 70%,transparent)}}.bg-white\/80{background-color:#fffc}@supports (color:color-mix(in lab,red,red)){.bg-white\/80{background-color:color-mix(in oklab,var(--color-white) 80%,transparent)}}.p-0\.5{padding:calc(var(--spacing) * .5)}.p-1{padding:var(--spacing)}.p-2\.5{padding:calc(var(--spacing) * 2.5)}.p-3{padding:calc(var(--spacing) * 3)}.p-4{padding:calc(var(--spacing) * 4)}.p-6{padding:calc(var(--spacing) * 6)}.px-0{padding-inline:0}.px-1{padding-inline:var(--spacing)}.px-1\.5{padding-inline:calc(var(--spacing) * 1.5)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-2\.5{padding-inline:calc(var(--spacing) * 2.5)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-4{padding-inline:calc(var(--spacing) * 4)}.py-0\.5{padding-block:calc(var(--spacing) * .5)}.py-1{padding-block:var(--spacing)}.py-1\.5{padding-block:calc(var(--spacing) * 1.5)}.py-2{padding-block:calc(var(--spacing) * 2)}.py-3{padding-block:calc(var(--spacing) * 3)}.py-4{padding-block:calc(var(--spacing) * 4)}.py-10{padding-block:calc(var(--spacing) * 10)}.pt-2{padding-top:calc(var(--spacing) * 2)}.pt-3{padding-top:calc(var(--spacing) * 3)}.pr-1{padding-right:var(--spacing)}.pb-3{padding-bottom:calc(var(--spacing) * 3)}.pl-0\.5{padding-left:calc(var(--spacing) * .5)}.pl-2{padding-left:calc(var(--spacing) * 2)}.pl-3{padding-left:calc(var(--spacing) * 3)}.pl-5{padding-left:calc(var(--spacing) * 5)}.text-center{text-align:center}.text-left{text-align:left}.text-right{text-align:right}.align-top{vertical-align:top}.font-mono{font-family:var(--font-mono)}.text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height))}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xl{font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\[0\.85em\]{font-size:.85em}.text-\[10px\]{font-size:10px}.text-\[11px\]{font-size:11px}.leading-none{--tw-leading:1;line-height:1}.leading-relaxed{--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.leading-snug{--tw-leading:var(--leading-snug);line-height:var(--leading-snug)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.\[overflow-wrap\:anywhere\]{overflow-wrap:anywhere}.break-words{overflow-wrap:break-word}.break-all{word-break:break-all}.whitespace-pre-wrap{white-space:pre-wrap}.text-amber-700{color:var(--color-amber-700)}.text-amber-800{color:var(--color-amber-800)}.text-amber-900{color:var(--color-amber-900)}.text-amber-950{color:var(--color-amber-950)}.text-blue-700{color:var(--color-blue-700)}.text-blue-700\/70{color:#1447e6b3}@supports (color:color-mix(in lab,red,red)){.text-blue-700\/70{color:color-mix(in oklab,var(--color-blue-700) 70%,transparent)}}.text-emerald-50{color:var(--color-emerald-50)}.text-emerald-700{color:var(--color-emerald-700)}.text-emerald-800{color:var(--color-emerald-800)}.text-emerald-900{color:var(--color-emerald-900)}.text-emerald-950{color:var(--color-emerald-950)}.text-foreground{color:hsl(var(--color-foreground))}.text-muted{color:hsl(var(--color-muted))}.text-primary{color:hsl(var(--color-primary))}.text-red-600{color:var(--color-red-600)}.text-red-700{color:var(--color-red-700)}.text-red-950{color:var(--color-red-950)}.text-slate-100{color:var(--color-slate-100)}.text-slate-200{color:var(--color-slate-200)}.text-slate-300{color:var(--color-slate-300)}.text-slate-400{color:var(--color-slate-400)}.text-slate-600{color:var(--color-slate-600)}.text-slate-700{color:var(--color-slate-700)}.text-violet-700{color:var(--color-violet-700)}.text-white{color:var(--color-white)}.capitalize{text-transform:capitalize}.uppercase{text-transform:uppercase}.italic{font-style:italic}.tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal,) var(--tw-slashed-zero,) var(--tw-numeric-figure,) var(--tw-numeric-spacing,) var(--tw-numeric-fraction,)}.underline{text-decoration-line:underline}.underline-offset-2{text-underline-offset:2px}.opacity-0{opacity:0}.opacity-60{opacity:.6}.shadow{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[0_1px_0_rgba\(15\,23\,42\,0\.03\)\]{--tw-shadow:0 1px 0 var(--tw-shadow-color,#0f172a08);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a), 0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-xl{--tw-shadow:0 20px 25px -5px var(--tw-shadow-color,#0000001a), 0 8px 10px -6px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-slate-950\/15{--tw-shadow-color:#02061826}@supports (color:color-mix(in lab,red,red)){.shadow-slate-950\/15{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-slate-950) 15%, transparent) var(--tw-shadow-alpha), transparent)}}.filter{filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.backdrop-blur{--tw-backdrop-blur:blur(8px);-webkit-backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,)}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.outline-none{--tw-outline-style:none;outline-style:none}.group-open\:rotate-180:is(:where(.group):is([open],:popover-open,:open) *){rotate:180deg}.peer-checked\:bg-primary:is(:where(.peer):checked~*){background-color:hsl(var(--color-primary))}.peer-focus-visible\:outline:is(:where(.peer):focus-visible~*){outline-style:var(--tw-outline-style);outline-width:1px}.peer-focus-visible\:outline-2:is(:where(.peer):focus-visible~*){outline-style:var(--tw-outline-style);outline-width:2px}.peer-focus-visible\:outline-offset-2:is(:where(.peer):focus-visible~*){outline-offset:2px}.peer-focus-visible\:outline-primary:is(:where(.peer):focus-visible~*){outline-color:hsl(var(--color-primary))}.peer-disabled\:opacity-50:is(:where(.peer):disabled~*){opacity:.5}.marker\:hidden ::marker{display:none}.marker\:hidden::marker{display:none}.marker\:hidden ::-webkit-details-marker{display:none}.marker\:hidden::-webkit-details-marker{display:none}.after\:absolute:after{content:var(--tw-content);position:absolute}.after\:top-0\.5:after{content:var(--tw-content);top:calc(var(--spacing) * .5)}.after\:left-0\.5:after{content:var(--tw-content);left:calc(var(--spacing) * .5)}.after\:h-5:after{content:var(--tw-content);height:calc(var(--spacing) * 5)}.after\:w-5:after{content:var(--tw-content);width:calc(var(--spacing) * 5)}.after\:rounded-full:after{content:var(--tw-content);border-radius:3.40282e38px}.after\:bg-white:after{content:var(--tw-content);background-color:var(--color-white)}.after\:shadow-sm:after{content:var(--tw-content);--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.after\:transition-transform:after{content:var(--tw-content);transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.peer-checked\:after\:translate-x-5:is(:where(.peer):checked~*):after{content:var(--tw-content);--tw-translate-x:calc(var(--spacing) * 5);translate:var(--tw-translate-x) var(--tw-translate-y)}.first\:mt-0:first-child{margin-top:0}.last\:border-0:last-child{border-style:var(--tw-border-style);border-width:0}.last\:border-b-0:last-child{border-bottom-style:var(--tw-border-style);border-bottom-width:0}.focus-within\:border-primary:focus-within{border-color:hsl(var(--color-primary))}.focus-within\:ring-1:focus-within{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus-within\:ring-primary:focus-within{--tw-ring-color:hsl(var(--color-primary))}@media(hover:hover){.hover\:bg-amber-100:hover{background-color:var(--color-amber-100)}.hover\:bg-amber-900:hover{background-color:var(--color-amber-900)}.hover\:bg-emerald-100:hover{background-color:var(--color-emerald-100)}.hover\:bg-red-50:hover{background-color:var(--color-red-50)}.hover\:bg-red-100:hover{background-color:var(--color-red-100)}.hover\:bg-slate-50:hover{background-color:var(--color-slate-50)}.hover\:bg-slate-100:hover{background-color:var(--color-slate-100)}.hover\:bg-slate-800:hover{background-color:var(--color-slate-800)}.hover\:bg-white:hover{background-color:var(--color-white)}.hover\:text-foreground:hover{color:hsl(var(--color-foreground))}.hover\:text-white:hover{color:var(--color-white)}.hover\:underline:hover{text-decoration-line:underline}}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:cursor-wait:disabled{cursor:wait}.disabled\:opacity-50:disabled{opacity:.5}.disabled\:opacity-60:disabled{opacity:.6}@media(hover:hover){.disabled\:hover\:bg-white:disabled:hover{background-color:var(--color-white)}}@media(min-width:40rem){.sm\:-mx-4{margin-inline:calc(var(--spacing) * -4)}.sm\:-mt-4{margin-top:calc(var(--spacing) * -4)}.sm\:block{display:block}.sm\:flex{display:flex}.sm\:inline{display:inline}.sm\:w-auto{width:auto}.sm\:flex-none{flex:none}.sm\:shrink-0{flex-shrink:0}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.sm\:items-center{align-items:center}.sm\:justify-between{justify-content:space-between}.sm\:gap-1\.5{gap:calc(var(--spacing) * 1.5)}.sm\:gap-2{gap:calc(var(--spacing) * 2)}.sm\:gap-3{gap:calc(var(--spacing) * 3)}.sm\:gap-4{gap:calc(var(--spacing) * 4)}.sm\:truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.sm\:p-4{padding:calc(var(--spacing) * 4)}.sm\:px-3{padding-inline:calc(var(--spacing) * 3)}.sm\:px-4{padding-inline:calc(var(--spacing) * 4)}.sm\:pl-0{padding-left:0}.sm\:text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}}@media(min-width:48rem){.md\:col-span-1{grid-column:span 1/span 1}.md\:mt-4{margin-top:calc(var(--spacing) * 4)}.md\:block{display:block}.md\:grid{display:grid}.md\:hidden{display:none}.md\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.md\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.md\:grid-cols-\[minmax\(0\,1\.35fr\)_90px_120px_90px_minmax\(0\,1fr\)\]{grid-template-columns:minmax(0,1.35fr) 90px 120px 90px minmax(0,1fr)}.md\:grid-cols-\[minmax\(0\,1fr\)\]{grid-template-columns:minmax(0,1fr)}.md\:grid-cols-\[minmax\(0\,1fr\)_220px\]{grid-template-columns:minmax(0,1fr) 220px}.md\:grid-cols-\[minmax\(0\,1fr\)_auto\]{grid-template-columns:minmax(0,1fr) auto}.md\:grid-cols-\[minmax\(0\,1fr\)_minmax\(12rem\,16rem\)_auto\]{grid-template-columns:minmax(0,1fr) minmax(12rem,16rem) auto}.md\:grid-cols-\[minmax\(0\,1fr\)_minmax\(240px\,0\.8fr\)\]{grid-template-columns:minmax(0,1fr) minmax(240px,.8fr)}.md\:items-center{align-items:center}.md\:gap-3{gap:calc(var(--spacing) * 3)}.md\:p-4{padding:calc(var(--spacing) * 4)}.md\:px-4{padding-inline:calc(var(--spacing) * 4)}.md\:px-6{padding-inline:calc(var(--spacing) * 6)}.md\:py-5{padding-block:calc(var(--spacing) * 5)}.md\:text-3xl{font-size:var(--text-3xl);line-height:var(--tw-leading,var(--text-3xl--line-height))}}@media(min-width:64rem){.lg\:min-w-\[420px\]{min-width:420px}.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.lg\:grid-cols-\[minmax\(0\,0\.9fr\)_minmax\(0\,1\.1fr\)\]{grid-template-columns:minmax(0,.9fr) minmax(0,1.1fr)}.lg\:grid-cols-\[minmax\(0\,1fr\)_minmax\(0\,1fr\)\]{grid-template-columns:minmax(0,1fr) minmax(0,1fr)}.lg\:grid-cols-\[minmax\(0\,1fr\)_minmax\(280px\,auto\)\]{grid-template-columns:minmax(0,1fr) minmax(280px,auto)}.lg\:flex-row{flex-direction:row}.lg\:items-start{align-items:flex-start}.lg\:justify-between{justify-content:space-between}}@media(min-width:80rem){.xl\:col-span-2{grid-column:span 2/span 2}.xl\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.xl\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.xl\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.xl\:grid-cols-9{grid-template-columns:repeat(9,minmax(0,1fr))}}.\[\&\>span\]\:truncate>span{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.\[\&\>svg\]\:shrink-0>svg{flex-shrink:0}@media(prefers-color-scheme:dark){.bg-white,.bg-white\/70,.bg-white\/80,.hover\:bg-white:hover{background-color:hsl(var(--color-panel))}.bg-slate-50,.bg-slate-50\/60,.bg-slate-50\/70,.bg-slate-100,.hover\:bg-slate-50:hover,.hover\:bg-slate-100:hover{background-color:#1f2637}.bg-blue-50{background-color:#152847}.bg-amber-50,.bg-amber-100,.hover\:bg-amber-100:hover{background-color:#46310b}.bg-red-50,.hover\:bg-red-50:hover{background-color:#441818}.bg-emerald-50,.hover\:bg-emerald-100:hover{background-color:#163b2b}.border-slate-200,.border-slate-300,.border-slate-700,.border-slate-800{border-color:hsl(var(--color-border))}.border-amber-200,.border-amber-300{border-color:#956b23}.border-blue-200,.border-blue-300{border-color:#2757a5}.border-red-200,.border-red-300{border-color:#a72f2f}.border-emerald-300{border-color:#30976a}.text-slate-600,.text-slate-700,.text-slate-800,.text-slate-900,.hover\:text-slate-900:hover{color:hsl(var(--color-foreground))}.text-slate-300,.text-slate-400,.text-slate-500,.hover\:text-slate-500:hover{color:hsl(var(--color-muted))}.text-blue-700{color:#92c2fc}.text-amber-700,.text-amber-800,.text-amber-900,.text-amber-950{color:#fde7af}.text-red-600,.text-red-700,.text-red-950{color:#fbacac}.text-emerald-700,.text-emerald-800,.text-emerald-900,.text-emerald-950{color:#a3f5cd}}}@keyframes live-pulse{0%,to{opacity:1;transform:scale(1)}50%{opacity:.35;transform:scale(.72)}}@media(prefers-reduced-motion:reduce){.animate-live-pulse{animation:none}}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-divide-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-ordinal{syntax:"*";inherits:false}@property --tw-slashed-zero{syntax:"*";inherits:false}@property --tw-numeric-figure{syntax:"*";inherits:false}@property --tw-numeric-spacing{syntax:"*";inherits:false}@property --tw-numeric-fraction{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-backdrop-blur{syntax:"*";inherits:false}@property --tw-backdrop-brightness{syntax:"*";inherits:false}@property --tw-backdrop-contrast{syntax:"*";inherits:false}@property --tw-backdrop-grayscale{syntax:"*";inherits:false}@property --tw-backdrop-hue-rotate{syntax:"*";inherits:false}@property --tw-backdrop-invert{syntax:"*";inherits:false}@property --tw-backdrop-opacity{syntax:"*";inherits:false}@property --tw-backdrop-saturate{syntax:"*";inherits:false}@property --tw-backdrop-sepia{syntax:"*";inherits:false}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-content{syntax:"*";inherits:false;initial-value:""}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@keyframes spin{to{transform:rotate(360deg)}}@keyframes pulse{50%{opacity:.5}} diff --git a/src/github_agent_bridge/dashboard_static/index.html b/src/github_agent_bridge/dashboard_static/index.html index 1989de5..5d2e2ae 100644 --- a/src/github_agent_bridge/dashboard_static/index.html +++ b/src/github_agent_bridge/dashboard_static/index.html @@ -4,9 +4,9 @@ GitHub Agent Bridge Dashboard - + - +
diff --git a/systemd/env.example b/systemd/env.example index 23f63a2..7f9c822 100644 --- a/systemd/env.example +++ b/systemd/env.example @@ -91,6 +91,10 @@ GITHUB_AGENT_BRIDGE_DASHBOARD_ALLOWED_TEAMS= GITHUB_AGENT_BRIDGE_DASHBOARD_ADMIN_USERS= GITHUB_AGENT_BRIDGE_DASHBOARD_ADMIN_TEAMS= GITHUB_AGENT_BRIDGE_DASHBOARD_PUBLIC_URL= +# Signed sessions expire after 8 hours by default. Increment the version to +# revoke all existing sessions without rotating the signing key. +GITHUB_AGENT_BRIDGE_DASHBOARD_SESSION_MAX_AGE_SECONDS=28800 +GITHUB_AGENT_BRIDGE_DASHBOARD_SESSION_VERSION=1 # Used only when running the dedicated ingress without socket activation. GITHUB_AGENT_BRIDGE_WEBHOOK_HOST=127.0.0.1 GITHUB_AGENT_BRIDGE_WEBHOOK_PORT=8766 diff --git a/tests/test_backend.py b/tests/test_backend.py index c4a83f1..444ac13 100644 --- a/tests/test_backend.py +++ b/tests/test_backend.py @@ -3,7 +3,7 @@ import asyncio import json import sqlite3 -from datetime import UTC, datetime +from datetime import UTC, datetime, timedelta from urllib.parse import parse_qs, urlparse import pytest @@ -13,7 +13,7 @@ from github_agent_bridge import __version__ from github_agent_bridge import feedback -from github_agent_bridge.backend import DashboardConfig, _encode_session, _is_admin, _is_allowed, _journal_stream_events, _session_stream_events, _sign, create_app +from github_agent_bridge.backend import DashboardConfig, _decode_session, _encode_session, _is_admin, _is_allowed, _journal_stream_events, _session_stream_events, _sign, _unsign, create_app from github_agent_bridge.dashboard_data import DashboardQueries, JOB_LIST_ORDER_SQL, get_job_detail, job_session, job_session_events, job_session_transcript, jobs_select_sql, list_all_job_actor_logins, list_job_actors, list_jobs, metrics_summary from github_agent_bridge.monitor import MonitorReport from github_agent_bridge.models import GitHubContext, Notification @@ -198,7 +198,7 @@ def test_dashboard_executor_pause_is_visible_but_only_admin_can_change_it(tmp_pa db = tmp_path / "bridge.sqlite3" queue = JobQueue(db) app = create_app(DashboardConfig(db=db, secret_key="secret", allowed_users={"alice"}, admin_users={"admin"})) - client = TestClient(app) + client = TestClient(app, headers={"origin": "http://testserver"}) assert client.post("/api/executor/pause").status_code == 401 client.cookies.set("gab_dashboard_session", _sign(app.state.dashboard_config, _encode_session({"login": "Alice"}))) @@ -233,7 +233,7 @@ def test_dashboard_autoupdate_refresh_requires_admin_and_records_plan(tmp_path, db = tmp_path / "bridge.sqlite3" JobQueue(db) app = create_app(DashboardConfig(db=db, secret_key="secret", allowed_users={"alice"}, admin_users={"alice"})) - client = TestClient(app) + client = TestClient(app, headers={"origin": "http://testserver"}) plan = { "installed_version": "0.27.0", "installed_tag": "v0.27.0", @@ -583,7 +583,7 @@ def test_dashboard_job_owner_can_cancel_running_job(tmp_path, monkeypatch): claimed = q.claim_next("worker") assert claimed is not None app = create_app(DashboardConfig(db=db, secret_key="secret", allowed_users={"ecarreras"})) - client = TestClient(app) + client = TestClient(app, headers={"origin": "http://testserver"}) client.cookies.set("gab_dashboard_session", _sign(app.state.dashboard_config, _encode_session({"login": "ecarreras"}))) def fake_cancel(queue, job_id, *, actor, reason): @@ -610,7 +610,7 @@ def test_dashboard_cancel_rejects_non_owner_reader(tmp_path, monkeypatch): job, _ = q.enqueue(notif(from_addr="ecarreras "), Policy(trusted_orgs=["gisce"])) q.claim_next("worker") app = create_app(DashboardConfig(db=db, secret_key="secret", allowed_users={"marc"})) - client = TestClient(app) + client = TestClient(app, headers={"origin": "http://testserver"}) client.cookies.set("gab_dashboard_session", _sign(app.state.dashboard_config, _encode_session({"login": "marc"}))) monkeypatch.setattr("github_agent_bridge.backend.cancel_running_job", lambda *args, **kwargs: (_ for _ in ()).throw(AssertionError("should not cancel"))) @@ -1324,7 +1324,7 @@ def test_dashboard_requires_auth_by_default(tmp_path): assert response.status_code == 401 -def test_dashboard_session_authorization_allows_configured_user(tmp_path): +def test_dashboard_rejects_legacy_session_without_expiry(tmp_path): db = tmp_path / "bridge.sqlite3" static_dir = tmp_path / "static" static_dir.mkdir() @@ -1335,11 +1335,13 @@ def test_dashboard_session_authorization_allows_configured_user(tmp_path): client = TestClient(app) client.cookies.set("gab_dashboard_session", _sign(app.state.dashboard_config, "alice")) - assert client.get("/api/jobs").status_code == 200 - assert client.get("/").status_code == 200 + response = client.get("/api/jobs") + + assert response.status_code == 401 + assert response.json()["detail"] == "session_invalid_or_expired" -def test_dashboard_me_backfills_legacy_session_avatar(tmp_path): +def test_dashboard_me_rejects_legacy_session_payload(tmp_path): db = tmp_path / "bridge.sqlite3" JobQueue(db) app = create_app(DashboardConfig(db=db, secret_key="secret", allowed_users={"alice"})) @@ -1348,13 +1350,8 @@ def test_dashboard_me_backfills_legacy_session_avatar(tmp_path): response = client.get("/api/me") - assert response.status_code == 200 - assert response.json()["user"] == { - "login": "alice", - "avatar_url": "https://github.com/alice.png?size=80", - "html_url": "https://github.com/alice", - "is_admin": False, - } + assert response.status_code == 401 + assert response.json()["detail"] == "session_invalid_or_expired" def test_dashboard_me_exposes_safe_oauth_profile(tmp_path): @@ -1397,6 +1394,173 @@ def test_dashboard_me_exposes_admin_mode_from_signed_session(tmp_path): assert response.json()["user"]["is_admin"] is True +def test_dashboard_session_has_absolute_expiry_and_version(): + issued_at = datetime(2026, 11, 7, 10, 0, tzinfo=UTC) + encoded = _encode_session( + {"login": "alice"}, + issued_at=issued_at, + max_age_seconds=300, + session_version=4, + ) + + active = _decode_session( + encoded, + now=issued_at + timedelta(seconds=299), + session_version=4, + ) + expired = _decode_session( + encoded, + now=issued_at + timedelta(seconds=300), + session_version=4, + ) + + assert active is not None + assert active["login"] == "alice" + assert expired is None + assert _decode_session(encoded, now=issued_at, session_version=5) is None + + +def test_dashboard_rechecks_user_allowlist_on_every_request(tmp_path): + allowed_users = {"alice"} + config = DashboardConfig( + db=tmp_path / "bridge.sqlite3", + secret_key="secret", + allowed_users=allowed_users, + ) + JobQueue(config.db) + client = TestClient(create_app(config)) + client.cookies.set( + "gab_dashboard_session", + _sign(config, _encode_session({"login": "alice"})), + ) + + assert client.get("/api/me").status_code == 200 + allowed_users.clear() + config.allowed_orgs.add("different-org") + + response = client.get("/api/me") + + assert response.status_code == 403 + assert response.json()["detail"] == "not_authorized" + + +def test_dashboard_rechecks_admin_allowlist_on_every_request(tmp_path): + admin_users = {"alice"} + config = DashboardConfig( + db=tmp_path / "bridge.sqlite3", + secret_key="secret", + allowed_users={"alice"}, + admin_users=admin_users, + ) + JobQueue(config.db) + client = TestClient(create_app(config)) + client.cookies.set( + "gab_dashboard_session", + _sign(config, _encode_session({"login": "alice"}, is_admin=True)), + ) + + assert client.get("/api/me").json()["user"]["is_admin"] is True + admin_users.clear() + + response = client.get("/api/me") + + assert response.status_code == 200 + assert response.json()["user"]["is_admin"] is False + + +def test_dashboard_key_rotation_invalidates_existing_session(tmp_path): + config = DashboardConfig( + db=tmp_path / "bridge.sqlite3", + secret_key="old-secret", + allowed_users={"alice"}, + ) + JobQueue(config.db) + client = TestClient(create_app(config)) + client.cookies.set( + "gab_dashboard_session", + _sign(config, _encode_session({"login": "alice"})), + ) + config.secret_key = "new-secret" + + response = client.get("/api/me") + + assert response.status_code == 401 + assert response.json()["detail"] == "session_invalid_or_expired" + + +@pytest.mark.parametrize( + ("method", "path", "payload"), + [ + ("POST", "/api/executor/pause", None), + ("POST", "/api/autoupdate/refresh", None), + ("POST", "/api/web-push/subscriptions", {}), + ("POST", "/api/jobs/999/cancel", {"reason": "cross-origin"}), + ("POST", "/api/knowledge/proposals/missing/approve", None), + ("PATCH", "/api/knowledge/rules/missing", {"scope": "global"}), + ("DELETE", "/api/knowledge/rules/missing", None), + ("POST", "/api/mcp/tokens", {"name": "cross-origin"}), + ("POST", "/api/webhooks/github/hooks/42/ping", None), + ("POST", "/auth/logout", None), + ], +) +def test_dashboard_cookie_mutations_require_same_origin(tmp_path, method, path, payload): + config = DashboardConfig( + db=tmp_path / "bridge.sqlite3", + secret_key="secret", + allowed_users={"alice"}, + admin_users={"alice"}, + ) + JobQueue(config.db) + client = TestClient(create_app(config)) + client.cookies.set( + "gab_dashboard_session", + _sign(config, _encode_session({"login": "alice"}, is_admin=True)), + ) + + missing = client.request(method, path, json=payload) + cross_origin = client.request( + method, + path, + json=payload, + headers={"origin": "https://untrusted.example"}, + ) + + assert missing.status_code == 403 + assert missing.json()["detail"] == "csrf_origin_required" + assert cross_origin.status_code == 403 + assert cross_origin.json()["detail"] == "csrf_origin_mismatch" + + +def test_dashboard_same_origin_referer_allows_cookie_mutation_and_logout(tmp_path): + config = DashboardConfig( + db=tmp_path / "bridge.sqlite3", + secret_key="secret", + allowed_users={"alice"}, + ) + JobQueue(config.db) + client = TestClient(create_app(config), follow_redirects=False) + client.cookies.set( + "gab_dashboard_session", + _sign(config, _encode_session({"login": "alice"})), + ) + + created = client.post( + "/api/mcp/tokens", + json={"name": "same-origin"}, + headers={"referer": "http://testserver/mcp"}, + ) + logged_out = client.post( + "/auth/logout", + headers={"origin": "http://testserver"}, + ) + + assert created.status_code == 200 + assert logged_out.status_code == 303 + assert logged_out.headers["location"] == "/auth/login" + assert "gab_dashboard_session=\"\"" in logged_out.headers["set-cookie"] + assert "Max-Age=0" in logged_out.headers["set-cookie"] + + def test_dashboard_knowledge_lists_and_admin_moderates_feedback(tmp_path): db = tmp_path / "bridge.sqlite3" JobQueue(db) @@ -1424,7 +1588,7 @@ def test_dashboard_knowledge_lists_and_admin_moderates_feedback(tmp_path): auto_approve_confidence=0.9, ) app = create_app(DashboardConfig(db=db, secret_key="secret", allowed_users={"alice"}, admin_users={"alice"})) - client = TestClient(app) + client = TestClient(app, headers={"origin": "http://testserver"}) client.cookies.set("gab_dashboard_session", _sign(app.state.dashboard_config, _encode_session({"login": "Alice"}))) listing = client.get("/api/knowledge", params={"repo": "gisce/erp"}).json() @@ -1507,7 +1671,7 @@ def test_dashboard_admin_can_change_knowledge_rule_scope(tmp_path): JobQueue(db) rule = feedback.add_rule(db, "repo:gisce/erp", "operating_rule", "Keep knowledge management auditable.", 0.8) app = create_app(DashboardConfig(db=db, secret_key="secret", allowed_users={"alice"}, admin_users={"alice"})) - client = TestClient(app) + client = TestClient(app, headers={"origin": "http://testserver"}) client.cookies.set("gab_dashboard_session", _sign(app.state.dashboard_config, _encode_session({"login": "Alice"}))) forbidden = client.patch(f"/api/knowledge/rules/{rule['id']}", json={"scope": "global"}) @@ -1586,7 +1750,7 @@ def test_dashboard_user_can_manage_only_owned_knowledge_rules(tmp_path): alice_rule = feedback.add_rule(db, "repo:gisce/erp", "operating_rule", "Alice owned rule.", 0.8, [alice_event["id"]]) bob_rule = feedback.add_rule(db, "repo:gisce/erp", "operating_rule", "Bob owned rule.", 0.8, [bob_event["id"]]) app = create_app(DashboardConfig(db=db, secret_key="secret", allowed_users={"alice"}, admin_users={"admin"})) - client = TestClient(app) + client = TestClient(app, headers={"origin": "http://testserver"}) client.cookies.set("gab_dashboard_session", _sign(app.state.dashboard_config, _encode_session({"login": "Alice"}))) updated = client.patch(f"/api/knowledge/rules/{alice_rule['id']}", json={"scope": "org:gisce"}) @@ -1613,7 +1777,7 @@ def test_dashboard_admin_manages_mcp_tokens(tmp_path): con.execute("UPDATE jobs SET trigger_actor=?, trigger_actor_avatar_url=? WHERE id=1", ("pilipilisbot", "https://github.com/pilipilisbot.png?size=80")) legacy = create_token(db, "legacy agent") app = create_app(DashboardConfig(db=db, secret_key="secret", allowed_users={"alice", "bob"}, admin_users={"alice"})) - client = TestClient(app) + client = TestClient(app, headers={"origin": "http://testserver"}) client.cookies.set("gab_dashboard_session", _sign(app.state.dashboard_config, _encode_session({"login": "Alice"}))) reader_created = client.post("/api/mcp/tokens", json={"name": "reader agent"}) @@ -1675,7 +1839,7 @@ def test_dashboard_user_manages_only_own_mcp_tokens(tmp_path): alice = create_token(db, "alice agent", user_login="alice") bob = create_token(db, "bob agent", user_login="bob") app = create_app(DashboardConfig(db=db, secret_key="secret", allowed_users={"alice", "bob"}, admin_users={"admin"})) - client = TestClient(app) + client = TestClient(app, headers={"origin": "http://testserver"}) client.cookies.set("gab_dashboard_session", _sign(app.state.dashboard_config, _encode_session({"login": "Alice"}))) listed = client.get("/api/mcp/tokens") @@ -1694,7 +1858,7 @@ def test_http_mcp_uses_bearer_tokens_and_shared_server(tmp_path): JobQueue(db) feedback.add_rule(db, "repo:gisce/erp", "technical_criterion", "Prefer the HTTP MCP endpoint for remote agents.", 0.9) token = create_token(db, "remote agent")["token"] - app = create_app(DashboardConfig(db=db, require_auth=False)) + app = create_app(DashboardConfig(db=db, secret_key="secret", allowed_users={"alice"})) client = TestClient(app) missing = client.post("/api/mcp", json={"jsonrpc": "2.0", "id": 1, "method": "tools/list", "params": {}}) @@ -1721,13 +1885,54 @@ def test_http_mcp_uses_bearer_tokens_and_shared_server(tmp_path): assert knowledge["rules"][0]["rule"] == "Prefer the HTTP MCP endpoint for remote agents." +def test_http_mcp_lifecycle_owners_share_global_repository_knowledge(tmp_path): + db = tmp_path / "bridge.sqlite3" + JobQueue(db) + feedback.add_rule(db, "repo:gisce/erp", "technical_criterion", "ERP rule.", 0.9) + feedback.add_rule(db, "repo:other/project", "technical_criterion", "Other rule.", 0.9) + alice_token = create_token(db, "alice agent", user_login="alice")["token"] + bob_token = create_token(db, "bob agent", user_login="bob")["token"] + client = TestClient(create_app(DashboardConfig(db=db, secret_key="secret"))) + + for token in (alice_token, bob_token): + repositories_response = client.post( + "/api/mcp", + headers={"Authorization": f"Bearer {token}"}, + json={ + "jsonrpc": "2.0", + "id": 1, + "method": "tools/call", + "params": {"name": "list_repositories", "arguments": {}}, + }, + ) + knowledge_response = client.post( + "/api/mcp", + headers={"Authorization": f"Bearer {token}"}, + json={ + "jsonrpc": "2.0", + "id": 2, + "method": "resources/read", + "params": {"uri": "gab://knowledge/other/project"}, + }, + ) + + repositories = json.loads( + repositories_response.json()["result"]["content"][0]["text"] + ) + knowledge = json.loads( + knowledge_response.json()["result"]["contents"][0]["text"] + ) + assert repositories["repositories"] == ["gisce/erp", "other/project"] + assert knowledge["rules"][0]["rule"] == "Other rule." + + def test_dashboard_retry_requires_admin_and_requeues_retryable_job(tmp_path): db = tmp_path / "bridge.sqlite3" q = JobQueue(db) job, _ = q.enqueue(notif(), Policy(trusted_orgs=["gisce"])) q.finish(job.id, "blocked", "failed", "boom") app = create_app(DashboardConfig(db=db, secret_key="secret", allowed_users={"alice"}, admin_users={"alice"})) - client = TestClient(app) + client = TestClient(app, headers={"origin": "http://testserver"}) client.cookies.set("gab_dashboard_session", _sign(app.state.dashboard_config, _encode_session({"login": "Alice"}))) forbidden = client.post(f"/api/jobs/{job.id}/retry") @@ -1747,7 +1952,7 @@ def test_dashboard_retry_rejects_non_retryable_jobs(tmp_path): q = JobQueue(db) job, _ = q.enqueue(notif(), Policy(trusted_orgs=["gisce"])) app = create_app(DashboardConfig(db=db, secret_key="secret", allowed_users={"alice"}, admin_users={"alice"})) - client = TestClient(app) + client = TestClient(app, headers={"origin": "http://testserver"}) client.cookies.set("gab_dashboard_session", _sign(app.state.dashboard_config, _encode_session({"login": "Alice"}, is_admin=True))) response = client.post(f"/api/jobs/{job.id}/retry") @@ -1764,7 +1969,7 @@ def test_dashboard_retry_cannot_override_policy_decision(tmp_path, decision, sta with q.connect() as con: con.execute("UPDATE jobs SET decision=?, status=? WHERE id=?", (decision, status, job.id)) app = create_app(DashboardConfig(db=db, secret_key="secret", allowed_users={"alice"}, admin_users={"alice"})) - client = TestClient(app) + client = TestClient(app, headers={"origin": "http://testserver"}) client.cookies.set("gab_dashboard_session", _sign(app.state.dashboard_config, _encode_session({"login": "Alice"}, is_admin=True))) response = client.post(f"/api/jobs/{job.id}/retry") @@ -1780,7 +1985,7 @@ def test_dashboard_dismiss_requires_admin_and_marks_recoverable_job_done(tmp_pat job, _ = q.enqueue(notif(), Policy(trusted_orgs=["gisce"])) q.finish(job.id, "blocked", "failed", "boom") app = create_app(DashboardConfig(db=db, secret_key="secret", allowed_users={"alice"}, admin_users={"alice"})) - client = TestClient(app) + client = TestClient(app, headers={"origin": "http://testserver"}) client.cookies.set("gab_dashboard_session", _sign(app.state.dashboard_config, _encode_session({"login": "Alice"}))) forbidden = client.post(f"/api/jobs/{job.id}/dismiss") @@ -1801,7 +2006,7 @@ def test_dashboard_dismiss_rejects_non_recoverable_jobs(tmp_path): q = JobQueue(db) job, _ = q.enqueue(notif(), Policy(trusted_orgs=["gisce"])) app = create_app(DashboardConfig(db=db, secret_key="secret", allowed_users={"alice"}, admin_users={"alice"})) - client = TestClient(app) + client = TestClient(app, headers={"origin": "http://testserver"}) client.cookies.set("gab_dashboard_session", _sign(app.state.dashboard_config, _encode_session({"login": "Alice"}, is_admin=True))) response = client.post(f"/api/jobs/{job.id}/dismiss") @@ -1891,6 +2096,48 @@ def test_dashboard_oauth_login_requests_org_scope_for_admin_team(tmp_path): assert query["scope"] == ["read:user read:org"] +def test_dashboard_oauth_callback_sets_bounded_session_with_memberships(tmp_path, monkeypatch): + config = DashboardConfig( + db=tmp_path / "bridge.sqlite3", + secret_key="secret", + oauth_client_id="client-id", + oauth_client_secret="client-secret", + allowed_teams={"example/platform"}, + admin_teams={"example/platform"}, + session_max_age_seconds=600, + session_version=3, + ) + JobQueue(config.db) + app = create_app(config) + client = TestClient(app, follow_redirects=False) + client.cookies.set("gab_dashboard_oauth_state", _sign(config, "state")) + monkeypatch.setattr("github_agent_bridge.backend._exchange_code", lambda cfg, code: "token") + + def fake_github_json(url, token): + assert token == "token" + if url.endswith("/user/teams"): + return [{"slug": "platform", "organization": {"login": "Example"}}] + if url.endswith("/user"): + return {"login": "Alice"} + raise AssertionError(url) + + monkeypatch.setattr("github_agent_bridge.backend._github_json", fake_github_json) + + response = client.get("/auth/callback", params={"code": "code", "state": "state"}) + signed_session = response.cookies.get("gab_dashboard_session") + decoded = _decode_session( + _unsign(config, signed_session), + session_version=config.session_version, + ) + + assert response.status_code == 302 + assert "Max-Age=600" in response.headers["set-cookie"] + assert decoded is not None + assert decoded["login"] == "alice" + assert decoded["is_admin"] is True + assert decoded["authorized_teams"] == {"example/platform"} + + def test_dashboard_session_authorization_allows_configured_team(monkeypatch): def fake_github_json(url, token): assert token == "token" diff --git a/tests/test_webhook.py b/tests/test_webhook.py index c145122..d8af3d4 100644 --- a/tests/test_webhook.py +++ b/tests/test_webhook.py @@ -1,5 +1,6 @@ from __future__ import annotations +import asyncio import hashlib import hmac import json @@ -7,11 +8,13 @@ import subprocess from datetime import UTC, datetime, timedelta +import pytest +from fastapi import HTTPException, Request from fastapi.testclient import TestClient from github_agent_bridge import backend from github_agent_bridge.actors import TriggerActor -from github_agent_bridge.backend import DashboardConfig, _encode_session, _sign, create_app, create_webhook_app +from github_agent_bridge.backend import DashboardConfig, _encode_session, _read_request_body_limited, _sign, create_app, create_webhook_app from github_agent_bridge.models import Notification, ResolvedGitHubEvent from github_agent_bridge.parser import extract_github_context from github_agent_bridge.policy import Policy @@ -26,6 +29,32 @@ SECRET = "test-secret" +def test_webhook_body_limit_stops_before_consuming_remaining_chunks(): + messages = [ + {"type": "http.request", "body": b"1234", "more_body": True}, + {"type": "http.request", "body": b"5678", "more_body": True}, + {"type": "http.request", "body": b"must-not-be-read", "more_body": False}, + ] + received = [] + + async def receive(): + message = messages.pop(0) + received.append(message["body"]) + return message + + request = Request( + {"type": "http", "method": "POST", "path": "/api/webhooks/github", "headers": []}, + receive, + ) + + with pytest.raises(HTTPException) as raised: + asyncio.run(_read_request_body_limited(request, 6)) + + assert raised.value.status_code == 413 + assert raised.value.detail == "payload_too_large" + assert received == [b"1234", b"5678"] + + def test_dedicated_webhook_ingress_exposes_only_health_and_delivery(tmp_path): client = TestClient(create_webhook_app(DashboardConfig( db=tmp_path / "bridge.sqlite3", webhook_secrets=(SECRET,), @@ -1819,7 +1848,7 @@ def test_webhook_status_requires_dashboard_admin(tmp_path): admin_users={"operator"}, webhook_secrets=(SECRET,), ) - client = TestClient(create_app(config)) + client = TestClient(create_app(config), headers={"origin": "http://testserver"}) paths = ( "/api/webhooks/github/status",