From f229f5de2e6ff47cfb2015e336f66e03b56c1e3d Mon Sep 17 00:00:00 2001 From: GISCE Bot Date: Sun, 1 Nov 2026 18:20:42 +0100 Subject: [PATCH 1/2] fix: scope webhook promotion to rollout cohort Filter coverage and exceptions to webhookCanaryRepos, report out-of-scope actionable traffic separately, and allow an explicit auditable observation epoch. Refs #299 Co-authored-by: Eduard Carreras --- dashboard/src/main.test.tsx | 4 +- dashboard/src/main.tsx | 8 +- docs/ingestion.md | 7 + docs/shadow-canary.md | 5 + src/github_agent_bridge/backend.py | 73 +++++++++- .../{index-B_l0AfBV.js => index-HMx7WSp8.js} | 76 +++++------ .../dashboard_static/index.html | 2 +- .../persistence/webhooks.py | 128 +++++++++++++++++- systemd/env.example | 3 + tests/test_webhook.py | 108 +++++++++++++++ 10 files changed, 365 insertions(+), 49 deletions(-) rename src/github_agent_bridge/dashboard_static/assets/{index-B_l0AfBV.js => index-HMx7WSp8.js} (58%) diff --git a/dashboard/src/main.test.tsx b/dashboard/src/main.test.tsx index f7b8736..eed4d66 100644 --- a/dashboard/src/main.test.tsx +++ b/dashboard/src/main.test.tsx @@ -236,7 +236,7 @@ describe("dashboard routing and API query helpers", () => { }); it("renders the webhook status exported by the backend", () => { - render(); + render(); expect(screen.getByRole("heading", { name: "GitHub webhooks" })).toBeInTheDocument(); expect(screen.getByText("shadow")).toBeInTheDocument(); @@ -250,6 +250,8 @@ describe("dashboard routing and API query helpers", () => { expect(screen.getByText("Decision mismatches")).toBeInTheDocument(); expect(screen.getByText("Incomplete decision traces")).toBeInTheDocument(); expect(screen.getByText("Split identities")).toBeInTheDocument(); + expect(screen.getByText("Outside scope IMAP")).toBeInTheDocument(); + expect(screen.getByText(/Promotion scope: 1 configured repositories/)).toBeInTheDocument(); expect(screen.getByText("blocked")).toBeInTheDocument(); }); diff --git a/dashboard/src/main.tsx b/dashboard/src/main.tsx index 2a1a75d..99b9cee 100644 --- a/dashboard/src/main.tsx +++ b/dashboard/src/main.tsx @@ -204,6 +204,7 @@ type WebhookSummary = { incomplete_decision_traces?: number; split_identities?: number; observation_complete?: boolean; + observation_started_at?: string | null; promotion_state?: "insufficient_data" | "blocked" | "ready"; promotion_ready?: boolean; imap_eligible: number; @@ -213,6 +214,9 @@ type WebhookSummary = { window_end?: string; observation_days?: number; grace_seconds?: number; + scope_repositories?: string[] | null; + outside_scope_imap_eligible?: number; + outside_scope_webhook_eligible?: number; }; }; @@ -2129,8 +2133,10 @@ function WebhookPage({ + + - {summary?.coverage?.window_start && summary.coverage.window_end ?

Actionable IMAP events and comparable webhook events from to ; {summary.coverage.observation_days ?? 7} observation days required and newest {summary.coverage.grace_seconds ?? 0}s excluded.

: null} + {summary?.coverage?.window_start && summary.coverage.window_end ?

Actionable IMAP events and comparable webhook events from to ; {summary.coverage.observation_days ?? 7} observation days required and newest {summary.coverage.grace_seconds ?? 0}s excluded. Promotion scope: {summary.coverage.scope_repositories == null ? "all repositories" : `${summary.coverage.scope_repositories.length} configured repositories`}{summary.coverage.observation_started_at ? <>; observation epoch : null}.

: null} {Object.keys(summary?.enqueue ?? {}).length ?
{Object.entries(summary?.enqueue ?? {}).sort(([left], [right]) => left.localeCompare(right)).map(([state, count]) => )}
: null} diff --git a/docs/ingestion.md b/docs/ingestion.md index 385e3f2..77a807c 100644 --- a/docs/ingestion.md +++ b/docs/ingestion.md @@ -258,6 +258,13 @@ duration and `GITHUB_AGENT_BRIDGE_WEBHOOK_COVERAGE_GRACE_SECONDS` to change the default ten-minute grace period. Receipt retention must cover the full window plus its grace period or the gate remains `insufficient_data`. +When corrected code or configuration starts a new rollout epoch, set +`GITHUB_AGENT_BRIDGE_WEBHOOK_OBSERVATION_STARTED_AT` to that deployment's +ISO-8601 UTC timestamp. The gate then ignores earlier evidence and remains +`insufficient_data` until a complete new window has elapsed. In canary mode, +coverage and exceptions are limited to `webhookCanaryRepos`; actionable events +outside that scope are reported separately and cannot block the canary gate. + Every durable ingestion receipt also records the normalized repository, work key, event descriptor, bridge action, policy decision and work intent. The dashboard compares those receipt-scoped decisions when both transports share a diff --git a/docs/shadow-canary.md b/docs/shadow-canary.md index 7a44072..16f22c4 100644 --- a/docs/shadow-canary.md +++ b/docs/shadow-canary.md @@ -87,6 +87,11 @@ Set `GITHUB_AGENT_BRIDGE_WEBHOOK_MODE=canary`, point canonical event identity, the first receipt creates the job and the second is recorded as a duplicate of it. +Set `GITHUB_AGENT_BRIDGE_WEBHOOK_OBSERVATION_STARTED_AT` to the ISO-8601 UTC +deployment instant for the code and configuration being validated. Promotion +metrics and exceptions use only `webhookCanaryRepos`; out-of-scope actionable +events remain visible as separate counters but do not block this cohort. + Inspect webhook summary, exceptions and deliveries in the administrator dashboard. Do not widen the canary while there are unexplained actionable IMAP-only events, split jobs, or action/intent mismatches. diff --git a/src/github_agent_bridge/backend.py b/src/github_agent_bridge/backend.py index a716b94..11b6108 100644 --- a/src/github_agent_bridge/backend.py +++ b/src/github_agent_bridge/backend.py @@ -129,14 +129,17 @@ def _webhook_coverage_window( retention_days: int, observation_days: int, grace_seconds: int, -) -> tuple[str, str, bool]: + configured_observation_start: str | None = None, +) -> tuple[str, str, bool, str | None]: now = datetime.now(UTC) end = now - timedelta(seconds=grace_seconds) requested_start = end - timedelta(days=observation_days) retained_start = now - timedelta(days=retention_days) start = max(requested_start, retained_start) observation_complete = False - observation_started_at = repository.observation_started_at() + observation_started_at = ( + configured_observation_start or repository.observation_started_at() + ) if observation_started_at: first_observed = _parse_webhook_datetime( str(observation_started_at), "webhook_observation_started_at" @@ -150,9 +153,16 @@ def _webhook_coverage_window( _webhook_datetime_value(start), _webhook_datetime_value(end), observation_complete, + observation_started_at, ) +def _webhook_promotion_scope(config: DashboardConfig) -> set[str] | None: + if config.webhook_policy is None: + return None + return Policy.from_file(config.webhook_policy).webhook_canary_repos + + def _encode_webhook_delivery_cursor(created_at: str, delivery_id: str) -> str: payload = json.dumps([created_at, delivery_id], separators=(",", ":")).encode("utf-8") return base64.urlsafe_b64encode(payload).decode("ascii").rstrip("=") @@ -311,6 +321,7 @@ def __init__( webhook_retention_days: int | None = None, webhook_promotion_observation_days: int | None = None, webhook_coverage_grace_seconds: int | None = None, + webhook_observation_started_at: str | None = None, webhook_mode: str | None = None, webhook_policy: str | Path | None = None, webhook_primary_ack: bool | None = None, @@ -353,6 +364,27 @@ def __init__( else int(os.getenv("GITHUB_AGENT_BRIDGE_WEBHOOK_COVERAGE_GRACE_SECONDS", "600")) ), ) + observation_start = ( + webhook_observation_started_at + if webhook_observation_started_at is not None + else os.getenv("GITHUB_AGENT_BRIDGE_WEBHOOK_OBSERVATION_STARTED_AT", "") + ) + if observation_start: + try: + parsed_observation_start = datetime.fromisoformat( + observation_start.replace("Z", "+00:00") + ) + except ValueError as exc: + raise ValueError( + "GITHUB_AGENT_BRIDGE_WEBHOOK_OBSERVATION_STARTED_AT must be an ISO-8601 datetime" + ) from exc + if parsed_observation_start.tzinfo is None: + parsed_observation_start = parsed_observation_start.replace(tzinfo=UTC) + self.webhook_observation_started_at = _webhook_datetime_value( + parsed_observation_start.astimezone(UTC) + ) + else: + self.webhook_observation_started_at = None self.webhook_mode = (webhook_mode or os.getenv("GITHUB_AGENT_BRIDGE_WEBHOOK_MODE", "shadow")).lower() if self.webhook_mode not in {"shadow", "canary", "primary"}: raise ValueError("GITHUB_AGENT_BRIDGE_WEBHOOK_MODE must be shadow, canary, or primary") @@ -1000,13 +1032,25 @@ async def github_webhook_shadow(request: Request) -> dict[str, Any]: @app.get("/api/webhooks/github/summary") def github_webhook_shadow_summary(_: dict[str, Any] = Depends(current_admin_profile)) -> dict[str, Any]: ensure_webhook_schema() - window_start, window_end, observation_complete = _webhook_coverage_window( + ( + window_start, + window_end, + observation_complete, + observation_started_at, + ) = _webhook_coverage_window( webhook_repository, retention_days=config.webhook_retention_days, observation_days=config.webhook_promotion_observation_days, grace_seconds=config.webhook_coverage_grace_seconds, + configured_observation_start=config.webhook_observation_started_at, + ) + scope_repositories = _webhook_promotion_scope(config) + summary = webhook_repository.summary( + window_start, window_end, scope_repositories + ) + outside_scope = webhook_repository.outside_scope_counts( + window_start, window_end, scope_repositories ) - summary = webhook_repository.summary(window_start, window_end) has_comparable_events = ( summary["both_events"] > 0 and summary["incomplete_decision_traces"] == 0 @@ -1051,6 +1095,7 @@ def github_webhook_shadow_summary(_: dict[str, Any] = Depends(current_admin_prof "incomplete_decision_traces": summary["incomplete_decision_traces"], "split_identities": summary["split_identities"], "observation_complete": observation_complete, + "observation_started_at": observation_started_at, "promotion_state": promotion_state, "promotion_ready": promotion_state == "ready", "imap_eligible": summary["imap_events"], @@ -1066,6 +1111,13 @@ def github_webhook_shadow_summary(_: dict[str, Any] = Depends(current_admin_prof "window_end": window_end, "observation_days": config.webhook_promotion_observation_days, "grace_seconds": config.webhook_coverage_grace_seconds, + "scope_repositories": ( + sorted(scope_repositories) + if scope_repositories is not None + else None + ), + "outside_scope_imap_eligible": outside_scope["imap_events"], + "outside_scope_webhook_eligible": outside_scope["webhook_events"], }, } @@ -1076,18 +1128,27 @@ def github_webhook_shadow_exceptions( ) -> dict[str, Any]: """Return bounded, actionable shadow divergences without loading all receipts.""" ensure_webhook_schema() - window_start, window_end, _ = _webhook_coverage_window( + window_start, window_end, _, _ = _webhook_coverage_window( webhook_repository, retention_days=config.webhook_retention_days, observation_days=config.webhook_promotion_observation_days, grace_seconds=config.webhook_coverage_grace_seconds, + configured_observation_start=config.webhook_observation_started_at, + ) + scope_repositories = _webhook_promotion_scope(config) + rows = webhook_repository.exceptions( + window_start, window_end, limit, scope_repositories ) - rows = webhook_repository.exceptions(window_start, window_end, limit) return { "exceptions": rows, "window_start": window_start, "window_end": window_end, "grace_seconds": config.webhook_coverage_grace_seconds, + "scope_repositories": ( + sorted(scope_repositories) + if scope_repositories is not None + else None + ), } @app.get("/api/webhooks/github/timeseries") diff --git a/src/github_agent_bridge/dashboard_static/assets/index-B_l0AfBV.js b/src/github_agent_bridge/dashboard_static/assets/index-HMx7WSp8.js similarity index 58% rename from src/github_agent_bridge/dashboard_static/assets/index-B_l0AfBV.js rename to src/github_agent_bridge/dashboard_static/assets/index-HMx7WSp8.js index 9f9d746..2607afa 100644 --- a/src/github_agent_bridge/dashboard_static/assets/index-B_l0AfBV.js +++ b/src/github_agent_bridge/dashboard_static/assets/index-HMx7WSp8.js @@ -1,4 +1,4 @@ -var Ha=e=>{throw TypeError(e)};var Jr=(e,t,n)=>t.has(e)||Ha("Cannot "+n);var g=(e,t,n)=>(Jr(e,t,"read from private field"),n?n.call(e):t.get(e)),H=(e,t,n)=>t.has(e)?Ha("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),z=(e,t,n,r)=>(Jr(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),ne=(e,t,n)=>(Jr(e,t,"access private method"),n);var kr=(e,t,n,r)=>({set _(i){z(e,t,i,n)},get _(){return g(e,t,r)}});import{j as iu,k as au,i as Zs,r as _e,R,g as ln,a as ei,C as Ln,X as Mn,Y as sn,T as cn,L as Ur,B as Bt,c as ou,d as ti,f as lu,P as cu,b as uu,h as du,e as dl}from"./charts-DntrVYl4.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const a of i)if(a.type==="childList")for(const o of a.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?a.credentials="include":i.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(i){if(i.ep)return;i.ep=!0;const a=n(i);fetch(i.href,a)}})();var Xr={exports:{}},Wn={};/** +var Ha=e=>{throw TypeError(e)};var Jr=(e,t,n)=>t.has(e)||Ha("Cannot "+n);var g=(e,t,n)=>(Jr(e,t,"read from private field"),n?n.call(e):t.get(e)),U=(e,t,n)=>t.has(e)?Ha("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),F=(e,t,n,r)=>(Jr(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),ne=(e,t,n)=>(Jr(e,t,"access private method"),n);var kr=(e,t,n,r)=>({set _(i){F(e,t,i,n)},get _(){return g(e,t,r)}});import{j as iu,k as au,i as Zs,r as _e,R,g as ln,a as ei,C as Ln,X as Mn,Y as sn,T as cn,L as Ur,B as Bt,c as ou,d as ti,f as lu,P as cu,b as uu,h as du,e as dl}from"./charts-DntrVYl4.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const a of i)if(a.type==="childList")for(const o of a.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?a.credentials="include":i.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(i){if(i.ep)return;i.ep=!0;const a=n(i);fetch(i.href,a)}})();var Xr={exports:{}},Wn={};/** * @license React * react-jsx-runtime.production.min.js * @@ -6,12 +6,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 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 Eu=wu;function Pu(){let e=[],t=0,n=l=>{l()},r=l=>{l()},i=Eu;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 Se=Pu(),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,Ne,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,Ne);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,Ne))==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,Ne))==null?void 0:r.promise;return(i=g(this,Ne))==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,Ne))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=g(this,Ne))==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,Ne)&&(g(this,Yt)||ne(this,Ve,wl).call(this)?g(this,Ne).cancel({revert:!0}):g(this,Ne).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,Ne))==null?void 0:u.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(g(this,Ne))return g(this,Ne).continueRetry(),g(this,Ne).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,Ne,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,Ne).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,Ne).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,Ne=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),Se.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,Ot,mr,_n,Cn,en,tn,Dt,En,oe,tr,_s,Cs,Es,Ps,Rs,Is,Ts,kl,al,jl=(al=class extends gr{constructor(t,n){super();H(this,oe);H(this,qe);H(this,re);H(this,pr);H(this,Oe);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,En,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,oe,tr).call(this):this.updateResult(),ne(this,oe,Ps).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,oe,Rs).call(this),ne(this,oe,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,oe,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,oe,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,oe,_s).call(this);const a=ne(this,oe,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,oe,Es).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,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,En).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,oe,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(),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=E=>{D?E.reject(F.error):M&&E.resolve(F.data)},X=()=>{const E=z(this,St,F.promise=ks());I(E)},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,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,En).size)return!0;const o=new Set(a??g(this,En));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,oe,kl).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&ne(this,oe,Ps).call(this)}},qe=new WeakMap,re=new WeakMap,pr=new WeakMap,Oe=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,En=new WeakMap,oe=new WeakSet,tr=function(t){ne(this,oe,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,oe,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},Es=function(t){ne(this,oe,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,oe,tr).call(this)},g(this,Dt)))},Ps=function(){ne(this,oe,_s).call(this),ne(this,oe,Es).call(this,ne(this,oe,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){Se.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(g(this,Oe))}),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,Ie,nn,ft,Tt,ol,zu=(ol=class extends bl{constructor(t){super();H(this,ft);H(this,fr);H(this,mt);H(this,Ie);H(this,nn);z(this,fr,t.client),this.mutationId=t.mutationId,z(this,Ie,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,Ie).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){z(this,mt,g(this,mt).filter(n=>n!==t)),this.scheduleGc(),g(this,Ie).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){g(this,mt).length||(this.state.status==="pending"?this.scheduleGc():g(this,Ie).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,Ie).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,Ie).config.onMutate&&await g(this,Ie).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,Ie).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,Ie).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,Ie).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,Ie).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,Ie).runNext(this)}}},fr=new WeakMap,mt=new WeakMap,Ie=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),Se.batch(()=>{g(this,mt).forEach(r=>{r.onMutationUpdate(t)}),g(this,Ie).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(){Se.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){Se.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return Se.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(){Se.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){Se.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){Se.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Se.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},xt=new WeakMap,cl),ye,Ft,zt,Pn,Rn,qt,In,Tn,ul,Uu=(ul=class{constructor(e={}){H(this,ye);H(this,Ft);H(this,zt);H(this,Pn);H(this,Rn);H(this,qt);H(this,In);H(this,Tn);z(this,ye,e.queryCache||new $u),z(this,Ft,e.mutationCache||new Bu),z(this,zt,e.defaultOptions||{}),z(this,Pn,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,ye).onFocus())})),z(this,Tn,Mr.subscribe(async e=>{e&&(await this.resumePausedMutations(),g(this,ye).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,ye).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,ye).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=g(this,ye).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,ye).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,ye).get(r.queryHash),a=i==null?void 0:i.state.data,o=ju(t,a);if(o!==void 0)return g(this,ye).build(this,r).setData(o,{...n,manual:!0})}setQueriesData(e,t,n){return Se.batch(()=>g(this,ye).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,ye).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=g(this,ye);Se.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=g(this,ye);return Se.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=Se.batch(()=>g(this,ye).findAll(e).map(i=>i.cancel(n)));return Promise.all(r).then(Be).catch(Be)}invalidateQueries(e,t={}){return Se.batch(()=>(g(this,ye).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=Se.batch(()=>g(this,ye).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,ye).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,ye)}getMutationCache(){return g(this,Ft)}getDefaultOptions(){return g(this,zt)}setDefaultOptions(e){z(this,zt,e)}setQueryDefaults(e,t){g(this,Pn).set(ar(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...g(this,Pn).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,ye).clear(),g(this,Ft).clear()}},ye=new WeakMap,Ft=new WeakMap,zt=new WeakMap,Pn=new WeakMap,Rn=new WeakMap,qt=new WeakMap,In=new WeakMap,Tn=new WeakMap,ul),Nl=_e.createContext(void 0),Sl=e=>{const t=_e.useContext(Nl);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Hu=({client:e,children:t})=>(_e.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),s.jsx(Nl.Provider,{value:e,children:t})),_l=_e.createContext(!1),Ku=()=>_e.useContext(_l);_l.Provider;function Qu(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Wu=_e.createContext(Qu()),Vu=()=>_e.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=>{_e.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]=_e.useState(()=>new t(a,o)),d=u.getOptimisticResult(o),h=!r&&e.subscribed!==!1;if(_e.useSyncExternalStore(_e.useCallback(v=>{const b=h?u.subscribe(Se.batchCalls(v)):Be;return u.updateResult(),b},[u,h]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),_e.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 we(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();U(this,Vt);U(this,At);U(this,wn);F(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),F(this,At,void 0))}setEventListener(t){var n;F(this,wn,t),(n=g(this,At))==null||n.call(this),F(this,At,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){g(this,Vt)!==t&&(F(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(){U(this,Lt,bu);U(this,Ys,!1)}setTimeoutProvider(e){F(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 Se=Eu(),vn,Mt,jn,rl,Ru=(rl=class extends gr{constructor(){super();U(this,vn,!0);U(this,Mt);U(this,jn);F(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),F(this,Mt,void 0))}setEventListener(t){var n;F(this,jn,t),(n=g(this,Mt))==null||n.call(this),F(this,Mt,t(this.setOnline.bind(this)))}setOnline(t){g(this,vn)!==t&&(F(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,M=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(){U(this,Gt)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),ys(this.gcTime)&&F(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)),F(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,_,M)=>{if(y)return Promise.reject(t.signal.reason);if(_==null&&k.pages.length)return Promise.resolve(k);const q=(()=>{const O={client:t.client,queryKey:t.queryKey,pageParam:_,direction:M?"backward":"forward",meta:t.options.meta};return v(O),O})(),D=await b(q),{maxPages:C}=t.options,L=M?_u:Su;return{pages:L(k.pages,D,C),pageParams:L(k.pageParams,_,C)}};if(i&&a.length){const k=i==="backward",_=k?yl:Ss,M={pages:a,pageParams:o},j=_(r,M);l=await N(M,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,Ne,hr,Yt,Ve,wl,Nt,il,Mu=(il=class extends bl{constructor(t){super();U(this,Ve);U(this,kn);U(this,Jt);U(this,Nn);U(this,Ze);U(this,Xt);U(this,Ne);U(this,hr);U(this,Yt);F(this,Yt,!1),F(this,hr,t.defaultOptions),this.setOptions(t.options),this.observers=[],F(this,Xt,t.client),F(this,Ze,g(this,Xt).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,F(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,Ne))==null?void 0:t.promise}setOptions(t){if(this.options={...g(this,hr),...t},t!=null&&t._type&&F(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)),F(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,Ne))==null?void 0:r.promise;return(i=g(this,Ne))==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,Ne))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=g(this,Ne))==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,Ne)&&(g(this,Yt)||ne(this,Ve,wl).call(this)?g(this,Ne).cancel({revert:!0}):g(this,Ne).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,Ne))==null?void 0:u.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(g(this,Ne))return g(this,Ne).continueRetry(),g(this,Ne).promise}if(t&&this.setOptions(t),!this.options.queryFn){const _=this.observers.find(M=>M.options.queryFn);_&&this.setOptions(_.options)}const r=new AbortController,i=_=>{Object.defineProperty(_,"signal",{enumerable:!0,get:()=>(F(this,Yt,!0),r.signal)})},a=()=>{const _=ml(this.options,n),j=(()=>{const q={client:g(this,Xt),queryKey:this.queryKey,meta:this.meta};return i(q),q})();return F(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),F(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}),F(this,Ne,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:(_,M)=>{ne(this,Ve,Nt).call(this,{type:"failed",failureCount:_,error:M})},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,Ne).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,Ne).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,Ne=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 F(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),Se.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,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();U(this,ae);U(this,qe);U(this,re);U(this,pr);U(this,Oe);U(this,Zt);U(this,Sn);U(this,St);U(this,Ot);U(this,mr);U(this,_n);U(this,Cn);U(this,en);U(this,tn);U(this,Dt);U(this,Pn,new Set);this.options=n,F(this,qe,t),F(this,Ot,null),F(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)&&(F(this,Oe,r),F(this,Sn,this.options),F(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 L=this.hasListeners(),O=!L&&eo(t,n),I=L&&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 L;a!=null&&a.isPlaceholderData&&n.placeholderData===(l==null?void 0:l.placeholderData)?(L=a.data,b=!0):L=typeof n.placeholderData=="function"?n.placeholderData((C=g(this,Cn))==null?void 0:C.state.data,g(this,Cn)):n.placeholderData,L!==void 0&&(v="success",p=js(a==null?void 0:a.data,L,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{F(this,mr,n.select),p=n.select(p),p=js(a==null?void 0:a.data,p,n),F(this,_n,p),F(this,Ot,null)}catch(L){F(this,Ot,L)}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",M=k&&N,j=p!==void 0,D={status:v,fetchStatus:h.fetchStatus,isPending:k,isSuccess:v==="success",isError:_,isInitialLoading:M,isLoading:M,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 L=D.data!==void 0,O=D.status==="error"&&!L,I=P=>{O?P.reject(D.error):L&&P.resolve(D.data)},J=()=>{const P=F(this,St,D.promise=ks());I(P)},z=g(this,St);switch(z.status){case"pending":t.queryHash===r.queryHash&&I(z);break;case"fulfilled":(O||D.data!==z.value)&&J();break;case"rejected":(!O||D.error!==z.reason)&&J();break}}return D}updateResult(){const t=g(this,Oe),n=this.createResult(g(this,re),this.options);if(F(this,Zt,g(this,re).state),F(this,Sn,this.options),g(this,Zt).data!==void 0&&F(this,Cn,g(this,re)),ws(n,t))return;F(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,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,Oe).isStale||!ys(t))return;const r=hl(g(this,Oe).dataUpdatedAt,t)+1;F(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),F(this,Dt,t),!(lr.isServer()||Ge(this.options.enabled,g(this,re))===!1||!ys(g(this,Dt))||g(this,Dt)===0)&&F(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)),F(this,en,void 0))},Is=function(){g(this,tn)!==void 0&&(Wt.clearInterval(g(this,tn)),F(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);F(this,re,t),F(this,pr,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},kl=function(t){Se.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(g(this,Oe))}),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,Ie,nn,ft,Tt,ol,zu=(ol=class extends bl{constructor(t){super();U(this,ft);U(this,fr);U(this,mt);U(this,Ie);U(this,nn);F(this,fr,t.client),this.mutationId=t.mutationId,F(this,Ie,t.mutationCache),F(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,Ie).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){F(this,mt,g(this,mt).filter(n=>n!==t)),this.scheduleGc(),g(this,Ie).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){g(this,mt).length||(this.state.status==="pending"?this.scheduleGc():g(this,Ie).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,_,M,j,q;const n=()=>{ne(this,ft,Tt).call(this,{type:"continue"})},r={client:g(this,fr),meta:this.options.meta,mutationKey:this.options.mutationKey};F(this,nn,gl({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(D,C)=>{ne(this,ft,Tt).call(this,{type:"failed",failureCount:D,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,Ie).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,Ie).config.onMutate&&await g(this,Ie).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 D=await g(this,nn).start();return await((u=(c=g(this,Ie).config).onSuccess)==null?void 0:u.call(c,D,t,this.state.context,this,r)),await((h=(d=this.options).onSuccess)==null?void 0:h.call(d,D,t,this.state.context,r)),await((p=(m=g(this,Ie).config).onSettled)==null?void 0:p.call(m,D,null,this.state.variables,this.state.context,this,r)),await((y=(w=this.options).onSettled)==null?void 0:y.call(w,D,null,t,this.state.context,r)),ne(this,ft,Tt).call(this,{type:"success",data:D}),D}catch(D){try{await((b=(v=g(this,Ie).config).onError)==null?void 0:b.call(v,D,t,this.state.context,this,r))}catch(C){Promise.reject(C)}try{await((k=(N=this.options).onError)==null?void 0:k.call(N,D,t,this.state.context,r))}catch(C){Promise.reject(C)}try{await((M=(_=g(this,Ie).config).onSettled)==null?void 0:M.call(_,void 0,D,this.state.variables,this.state.context,this,r))}catch(C){Promise.reject(C)}try{await((q=(j=this.options).onSettled)==null?void 0:q.call(j,void 0,D,t,this.state.context,r))}catch(C){Promise.reject(C)}throw ne(this,ft,Tt).call(this,{type:"error",error:D}),D}finally{g(this,Ie).runNext(this)}}},fr=new WeakMap,mt=new WeakMap,Ie=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),Se.batch(()=>{g(this,mt).forEach(r=>{r.onMutationUpdate(t)}),g(this,Ie).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();U(this,_t);U(this,at);U(this,xr);this.config=t,F(this,_t,new Set),F(this,at,new Map),F(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(){Se.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){Se.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return Se.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();U(this,xt);this.config=t,F(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(){Se.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){Se.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){Se.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Se.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},xt=new WeakMap,cl),ye,Ft,zt,En,Rn,qt,In,Tn,ul,Uu=(ul=class{constructor(e={}){U(this,ye);U(this,Ft);U(this,zt);U(this,En);U(this,Rn);U(this,qt);U(this,In);U(this,Tn);F(this,ye,e.queryCache||new $u),F(this,Ft,e.mutationCache||new Bu),F(this,zt,e.defaultOptions||{}),F(this,En,new Map),F(this,Rn,new Map),F(this,qt,0)}mount(){kr(this,qt)._++,g(this,qt)===1&&(F(this,In,ni.subscribe(async e=>{e&&(await this.resumePausedMutations(),g(this,ye).onFocus())})),F(this,Tn,Mr.subscribe(async e=>{e&&(await this.resumePausedMutations(),g(this,ye).onOnline())})))}unmount(){var e,t;kr(this,qt)._--,g(this,qt)===0&&((e=g(this,In))==null||e.call(this),F(this,In,void 0),(t=g(this,Tn))==null||t.call(this),F(this,Tn,void 0))}isFetching(e){return g(this,ye).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,ye).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=g(this,ye).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,ye).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,ye).get(r.queryHash),a=i==null?void 0:i.state.data,o=ju(t,a);if(o!==void 0)return g(this,ye).build(this,r).setData(o,{...n,manual:!0})}setQueriesData(e,t,n){return Se.batch(()=>g(this,ye).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,ye).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=g(this,ye);Se.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=g(this,ye);return Se.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=Se.batch(()=>g(this,ye).findAll(e).map(i=>i.cancel(n)));return Promise.all(r).then(Be).catch(Be)}invalidateQueries(e,t={}){return Se.batch(()=>(g(this,ye).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=Se.batch(()=>g(this,ye).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,ye).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,ye)}getMutationCache(){return g(this,Ft)}getDefaultOptions(){return g(this,zt)}setDefaultOptions(e){F(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,ye).clear(),g(this,Ft).clear()}},ye=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=_e.createContext(void 0),Sl=e=>{const t=_e.useContext(Nl);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Hu=({client:e,children:t})=>(_e.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),s.jsx(Nl.Provider,{value:e,children:t})),_l=_e.createContext(!1),Ku=()=>_e.useContext(_l);_l.Provider;function Qu(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Wu=_e.createContext(Qu()),Vu=()=>_e.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=>{_e.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]=_e.useState(()=>new t(a,o)),d=u.getOptimisticResult(o),h=!r&&e.subscribed!==!1;if(_e.useSyncExternalStore(_e.useCallback(v=>{const b=h?u.subscribe(Se.batchCalls(v)):Be;return u.updateResult(),b},[u,h]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),_e.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 we(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. * See the LICENSE file in the root directory of this source tree. - */const td=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),El=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim();/** + */const td=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Pl=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim();/** * @license lucide-react v0.468.0 - ISC * * This source code is licensed under the ISC license. @@ -21,161 +21,161 @@ 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 rd=_e.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:a,iconNode:o,...l},c)=>_e.createElement("svg",{ref:c,...nd,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:El("lucide",i),...l},[...o.map(([u,d])=>_e.createElement(u,d)),...Array.isArray(a)?a:[a]]));/** + */const rd=_e.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:a,iconNode:o,...l},c)=>_e.createElement("svg",{ref:c,...nd,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:Pl("lucide",i),...l},[...o.map(([u,d])=>_e.createElement(u,d)),...Array.isArray(a)?a:[a]]));/** * @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 me=(e,t)=>{const n=_e.forwardRef(({className:r,...i},a)=>_e.createElement(rd,{ref:a,iconNode:t,className:El(`lucide-${td(e)}`,r),...i}));return n.displayName=`${e}`,n};/** + */const pe=(e,t)=>{const n=_e.forwardRef(({className:r,...i},a)=>_e.createElement(rd,{ref:a,iconNode:t,className:Pl(`lucide-${td(e)}`,r),...i}));return n.displayName=`${e}`,n};/** * @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 an=me("Activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);/** + */const an=pe("Activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);/** * @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 ai=me("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/** + */const ai=pe("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/** * @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 Pl=me("Bell",[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]]);/** + */const El=pe("Bell",[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]]);/** * @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 oi=me("Brain",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z",key:"ep3f8r"}],["path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4",key:"1p4c4q"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}]]);/** + */const oi=pe("Brain",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z",key:"ep3f8r"}],["path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4",key:"1p4c4q"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}]]);/** * @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 On=me("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/** + */const On=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=me("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** + */const Dn=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. * See the LICENSE file in the root directory of this source tree. - */const An=me("CircleUserRound",[["path",{d:"M18 20a6 6 0 0 0-12 0",key:"1qehca"}],["circle",{cx:"12",cy:"10",r:"4",key:"1h16sb"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** + */const An=pe("CircleUserRound",[["path",{d:"M18 20a6 6 0 0 0-12 0",key:"1qehca"}],["circle",{cx:"12",cy:"10",r:"4",key:"1h16sb"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @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 Rl=me("Clock3",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16.5 12",key:"1aq6pp"}]]);/** + */const Rl=pe("Clock3",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16.5 12",key:"1aq6pp"}]]);/** * @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 ro=me("Cpu",[["rect",{width:"16",height:"16",x:"4",y:"4",rx:"2",key:"14l7u7"}],["rect",{width:"6",height:"6",x:"9",y:"9",rx:"1",key:"5aljv4"}],["path",{d:"M15 2v2",key:"13l42r"}],["path",{d:"M15 20v2",key:"15mkzm"}],["path",{d:"M2 15h2",key:"1gxd5l"}],["path",{d:"M2 9h2",key:"1bbxkp"}],["path",{d:"M20 15h2",key:"19e6y8"}],["path",{d:"M20 9h2",key:"19tzq7"}],["path",{d:"M9 2v2",key:"165o2o"}],["path",{d:"M9 20v2",key:"i2bqo8"}]]);/** + */const ro=pe("Cpu",[["rect",{width:"16",height:"16",x:"4",y:"4",rx:"2",key:"14l7u7"}],["rect",{width:"6",height:"6",x:"9",y:"9",rx:"1",key:"5aljv4"}],["path",{d:"M15 2v2",key:"13l42r"}],["path",{d:"M15 20v2",key:"15mkzm"}],["path",{d:"M2 15h2",key:"1gxd5l"}],["path",{d:"M2 9h2",key:"1bbxkp"}],["path",{d:"M20 15h2",key:"19e6y8"}],["path",{d:"M20 9h2",key:"19tzq7"}],["path",{d:"M9 2v2",key:"165o2o"}],["path",{d:"M9 20v2",key:"i2bqo8"}]]);/** * @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 on=me("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/** + */const on=pe("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/** * @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 Il=me("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** + */const Il=pe("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** * @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 sd=me("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]]);/** + */const sd=pe("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]]);/** * @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 id=me("Gauge",[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]]);/** + */const id=pe("Gauge",[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]]);/** * @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 Or=me("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 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"}]]);/** * @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 Fn=me("Link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);/** + */const Fn=pe("Link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);/** * @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 ad=me("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/** + */const ad=pe("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/** * @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 zn=me("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/** + */const zn=pe("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/** * @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 cr=me("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);/** + */const cr=pe("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);/** * @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 od=me("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);/** + */const od=pe("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);/** * @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 ld=me("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** + */const ld=pe("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** * @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 Tl=me("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** + */const Tl=pe("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["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. * See the LICENSE file in the root directory of this source tree. - */const Al=me("SquareTerminal",[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]]);/** + */const Al=pe("SquareTerminal",[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]]);/** * @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 Ll=me("TimerReset",[["path",{d:"M10 2h4",key:"n1abiw"}],["path",{d:"M12 14v-4",key:"1evpnu"}],["path",{d:"M4 13a8 8 0 0 1 8-7 8 8 0 1 1-5.3 14L4 17.6",key:"1ts96g"}],["path",{d:"M9 17H4v5",key:"8t5av"}]]);/** + */const Ll=pe("TimerReset",[["path",{d:"M10 2h4",key:"n1abiw"}],["path",{d:"M12 14v-4",key:"1evpnu"}],["path",{d:"M4 13a8 8 0 0 1 8-7 8 8 0 1 1-5.3 14L4 17.6",key:"1ts96g"}],["path",{d:"M9 17H4v5",key:"8t5av"}]]);/** * @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 Ls=me("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/** + */const Ls=pe("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/** * @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 Hr=me("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** + */const Hr=pe("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** * @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 cd=me("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]);/** + */const cd=pe("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]);/** * @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 un=me("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(),ve=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:ve,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 E=q.match(t);E&&(N+=E.length);var U=q.lastIndexOf(c);k=~U?q.length-U:k+q.length}function O(){var q={line:N,column:k};return function(E){return E.position=new j(q),C(),E}}function j(q){this.start=q,this.end={line:N,column:k},this.source=b.source}j.prototype.content=v;function B(q){var E=new Error(b.source+":"+N+":"+k+": "+q);if(E.reason=q,E.filename=b.source,E.line=N,E.column=k,E.source=v,!b.silent)throw E}function F(q){var E=q.exec(v);if(E){var U=E[0];return _(U),v=v.slice(U.length),E}}function C(){F(n)}function M(q){var E;for(q=q||[];E=D();)E!==!1&&q.push(E);return q}function D(){var q=O();if(!(u!=v.charAt(0)||d!=v.charAt(1))){for(var E=2;h!=v.charAt(E)&&(d!=v.charAt(E)||u!=v.charAt(E+1));)++E;if(E+=2,h===v.charAt(E-1))return B("End of comment missing");var U=v.slice(2,E-2);return k+=2,_(U),v=v.slice(E),k+=2,q({type:m,comment:U})}}function I(){var q=O(),E=F(r);if(E){if(D(),!F(i))return B("property missing ':'");var U=F(a),te=q({type:p,property:y(E[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 E;E=I();)E!==!1&&(q.push(E),M(q));return q}return C(),X()}function y(v){return v?v.replace(l,h):h}return es=w,es}var co;function Ed(){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 Pd(){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(Ed()),n=Pd();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 Ae 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}}Ae.prototype.file="";Ae.prototype.name="";Ae.prototype.reason="";Ae.prototype.message="";Ae.prototype.stack="";Ae.prototype.column=void 0;Ae.prototype.line=void 0;Ae.prototype.ancestors=void 0;Ae.prototype.cause=void 0;Ae.prototype.fatal=void 0;Ae.prototype.place=void 0;Ae.prototype.ruleId=void 0;Ae.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 ae(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 fe(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let a=0;return o;function o(c){return ae(c)?(e.enter(n),l(c)):t(c)}function l(c){return ae(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 fe(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&&ae(j)?fe(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(E){return j.enter("lineEnding"),j.consume(E),j.exit("lineEnding"),D}function D(E){return j.enter("codeFencedFence"),ae(E)?fe(j,I,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(E):I(E)}function I(E){return E===l?(j.enter("codeFencedFenceSequence"),X(E)):F(E)}function X(E){return E===l?(C++,j.consume(E),X):C>=o?(j.exit("codeFencedFenceSequence"),ae(E)?fe(j,q,"whitespace")(E):q(E)):F(E)}function q(E){return E===null||W(E)?(j.exit("codeFencedFence"),B(E)):F(E)}}}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:Ph},Eh={partial:!0,tokenize:Rh};function Ph(e,t,n){const r=this;return i;function i(u){return e.enter("codeIndented"),fe(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(Eh,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):fe(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=!ae(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"),fe(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):ae(i)?fe(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 ae(p)?fe(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 ae(l)?fe(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)):ae(d)?fe(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 Ce="CDATA[";return x===Ce.charCodeAt(l++)?(e.consume(x),l===Ce.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 Ce=x===47,He=o.toLowerCase();return!Ce&&!a&&ko.includes(He)?(i=1,r.interrupt?t(x):I(x)):Xh.includes(o.toLowerCase())?(i=6,Ce?(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 ae(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),_):ae(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):ae(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):ae(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||ae(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):ae(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),xe):x===63&&i===3?(e.consume(x),f):x===93&&i===5?(e.consume(x),ie):W(x)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(Zh,De,X)(x)):x===null||W(x)?(e.exit("htmlFlowData"),X(x)):(e.consume(x),I)}function X(x){return e.check(ep,q,De)(x)}function q(x){return e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),E}function E(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="",A):I(x)}function A(x){if(x===62){const Ce=o.toLowerCase();return ko.includes(Ce)?(e.consume(x),xe):I(x)}return gt(x)&&o.length<8?(e.consume(x),o+=String.fromCharCode(x),A):I(x)}function ie(x){return x===93?(e.consume(x),f):I(x)}function f(x){return x===62?(e.consume(x),xe):x===45&&i===2?(e.consume(x),f):I(x)}function xe(x){return x===null||W(x)?(e.exit("htmlFlowData"),De(x)):(e.consume(x),xe)}function De(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 xe="CDATA[";return f===xe.charCodeAt(a++)?(e.consume(f),a===xe.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)):ae(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)):ae(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)):ae(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)):ae(f)?(e.consume(f),I):(e.consume(f),q)}function X(f){return f===i?(e.consume(f),i=void 0,E):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 E(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"),A}function A(f){return ae(f)?fe(e,ie,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(f):ie(f)}function ie(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"),ae(u)?fe(e,l,"whitespace")(u):l(u))}}const ze={continuation:{tokenize:Sp},exit:Cp,name:"list",tokenize:Np},jp={partial:!0,tokenize:Ep},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 ae(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,fe(e,t,"listItemIndent",r.containerState.size+1)(l)}function a(l){return r.containerState.furtherBlankLines||!ae(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,fe(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 fe(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 Ep(e,t,n){const r=this;return fe(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!ae(a)&&o&&o[1].type==="listItemPrefixWhitespace"?t(a):n(a)}}const No={name:"setextUnderline",resolveTo:Pp,tokenize:Rp};function Pp(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"),ae(u)?fe(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,fe(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([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 _(z){var P=z.match(t);P&&(N+=P.length);var $=z.lastIndexOf(c);k=~$?z.length-$:k+z.length}function M(){var z={line:N,column:k};return function(P){return P.position=new j(z),C(),P}}function j(z){this.start=z,this.end={line:N,column:k},this.source=b.source}j.prototype.content=v;function q(z){var P=new Error(b.source+":"+N+":"+k+": "+z);if(P.reason=z,P.filename=b.source,P.line=N,P.column=k,P.source=v,!b.silent)throw P}function D(z){var P=z.exec(v);if(P){var $=P[0];return _($),v=v.slice($.length),P}}function C(){D(n)}function L(z){var P;for(z=z||[];P=O();)P!==!1&&z.push(P);return z}function O(){var z=M();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 q("End of comment missing");var $=v.slice(2,P-2);return k+=2,_($),v=v.slice(P),k+=2,z({type:m,comment:$})}}function I(){var z=M(),P=D(r);if(P){if(O(),!D(i))return q("property missing ':'");var $=D(a),ee=z({type:p,property:y(P[0].replace(e,h)),value:$?y($[0].replace(e,h)):h});return D(o),ee}}function J(){var z=[];L(z);for(var P;P=I();)P!==!1&&(z.push(P),L(z));return z}return C(),J()}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 Ae 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}}Ae.prototype.file="";Ae.prototype.name="";Ae.prototype.reason="";Ae.prototype.message="";Ae.prototype.stack="";Ae.prototype.column=void 0;Ae.prototype.line=void 0;Ae.prototype.ancestors=void 0;Ae.prototype.cause=void 0;Ae.prototype.fatal=void 0;Ae.prototype.place=void 0;Ae.prototype.ruleId=void 0;Ae.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 Q(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 fe(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 q=t.events.length;let D=q,C,L;for(;D--;)if(t.events[D][0]==="exit"&&t.events[D][1].type==="chunkFlow"){if(C){L=t.events[D][1].end;break}C=!0}for(b(r),j=q;jk;){const M=n[_];t.containerState=M[1],M[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 fe(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)?fe(e,N,"linePrefix",a+1)(j):N(j)}function N(j){return j===null||Q(j)?e.check(vo,y,_)(j):(e.enter("codeFlowValue"),k(j))}function k(j){return j===null||Q(j)?(e.exit("codeFlowValue"),N(j)):(e.consume(j),k)}function _(j){return e.exit("codeFenced"),t(j)}function M(j,q,D){let C=0;return L;function L(P){return j.enter("lineEnding"),j.consume(P),j.exit("lineEnding"),O}function O(P){return j.enter("codeFencedFence"),ie(P)?fe(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"),J(P)):D(P)}function J(P){return P===l?(C++,j.consume(P),J):C>=o?(j.exit("codeFencedFenceSequence"),ie(P)?fe(j,z,"whitespace")(P):z(P)):D(P)}function z(P){return P===null||Q(P)?(j.exit("codeFencedFence"),q(P)):D(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"),fe(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):Q(u)?e.attempt(Ph,o,c)(u):(e.enter("codeFlowValue"),l(u))}function l(u){return u===null||Q(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):Q(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):fe(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):Q(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||Q(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):Q(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||Q(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):Q(m)?(e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),fe(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),d(m))}function d(m){return m===o||m===null||Q(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 Q(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):ie(i)?fe(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)?fe(e,m,"whitespace")(p):m(p)}function m(p){return p===null||Q(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)?fe(e,o,"whitespace")(l):o(l)}function o(l){return l===null||Q(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 Q(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||Q(d)?(e.exit("atxHeading"),t(d)):ie(d)?fe(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 Ce="CDATA[";return x===Ce.charCodeAt(l++)?(e.consume(x),l===Ce.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 Ce=x===47,He=o.toLowerCase();return!Ce&&!a&&ko.includes(He)?(i=1,r.interrupt?t(x):I(x)):Xh.includes(o.toLowerCase())?(i=6,Ce?(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):L(x)}function k(x){return x===47?(e.consume(x),L):x===58||x===95||gt(x)?(e.consume(x),_):ie(x)?(e.consume(x),k):L(x)}function _(x){return x===45||x===46||x===58||x===95||Je(x)?(e.consume(x),_):M(x)}function M(x){return x===61?(e.consume(x),j):ie(x)?(e.consume(x),M):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,q):ie(x)?(e.consume(x),j):D(x)}function q(x){return x===c?(e.consume(x),c=null,C):x===null||Q(x)?n(x):(e.consume(x),q)}function D(x){return x===null||x===34||x===39||x===47||x===60||x===61||x===62||x===96||$e(x)?M(x):(e.consume(x),D)}function C(x){return x===47||x===62||ie(x)?k(x):n(x)}function L(x){return x===62?(e.consume(x),O):n(x)}function O(x){return x===null||Q(x)?I(x):ie(x)?(e.consume(x),O):n(x)}function I(x){return x===45&&i===2?(e.consume(x),$):x===60&&i===1?(e.consume(x),ee):x===62&&i===4?(e.consume(x),te):x===63&&i===3?(e.consume(x),f):x===93&&i===5?(e.consume(x),be):Q(x)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(Zh,De,J)(x)):x===null||Q(x)?(e.exit("htmlFlowData"),J(x)):(e.consume(x),I)}function J(x){return e.check(ep,z,De)(x)}function z(x){return e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),P}function P(x){return x===null||Q(x)?J(x):(e.enter("htmlFlowData"),I(x))}function $(x){return x===45?(e.consume(x),f):I(x)}function ee(x){return x===47?(e.consume(x),o="",me):I(x)}function me(x){if(x===62){const Ce=o.toLowerCase();return ko.includes(Ce)?(e.consume(x),te):I(x)}return gt(x)&&o.length<8?(e.consume(x),o+=String.fromCharCode(x),me):I(x)}function be(x){return x===93?(e.consume(x),f):I(x)}function f(x){return x===62?(e.consume(x),te):x===45&&i===2?(e.consume(x),f):I(x)}function te(x){return x===null||Q(x)?(e.exit("htmlFlowData"),De(x)):(e.consume(x),te)}function De(x){return e.exit("htmlFlow"),t(x)}}function rp(e,t,n){const r=this;return i;function i(o){return Q(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),M):f===63?(e.consume(f),k):gt(f)?(e.consume(f),D):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):Q(f)?(o=h,ee(f)):(e.consume(f),h)}function m(f){return f===45?(e.consume(f),p):h(f)}function p(f){return f===62?$(f):f===45?m(f):h(f)}function w(f){const te="CDATA[";return f===te.charCodeAt(a++)?(e.consume(f),a===te.length?y:w):n(f)}function y(f){return f===null?n(f):f===93?(e.consume(f),v):Q(f)?(o=y,ee(f)):(e.consume(f),y)}function v(f){return f===93?(e.consume(f),b):y(f)}function b(f){return f===62?$(f):f===93?(e.consume(f),b):y(f)}function N(f){return f===null||f===62?$(f):Q(f)?(o=N,ee(f)):(e.consume(f),N)}function k(f){return f===null?n(f):f===63?(e.consume(f),_):Q(f)?(o=k,ee(f)):(e.consume(f),k)}function _(f){return f===62?$(f):k(f)}function M(f){return gt(f)?(e.consume(f),j):n(f)}function j(f){return f===45||Je(f)?(e.consume(f),j):q(f)}function q(f){return Q(f)?(o=q,ee(f)):ie(f)?(e.consume(f),q):$(f)}function D(f){return f===45||Je(f)?(e.consume(f),D):f===47||f===62||$e(f)?C(f):n(f)}function C(f){return f===47?(e.consume(f),$):f===58||f===95||gt(f)?(e.consume(f),L):Q(f)?(o=C,ee(f)):ie(f)?(e.consume(f),C):$(f)}function L(f){return f===45||f===46||f===58||f===95||Je(f)?(e.consume(f),L):O(f)}function O(f){return f===61?(e.consume(f),I):Q(f)?(o=O,ee(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,J):Q(f)?(o=I,ee(f)):ie(f)?(e.consume(f),I):(e.consume(f),z)}function J(f){return f===i?(e.consume(f),i=void 0,P):f===null?n(f):Q(f)?(o=J,ee(f)):(e.consume(f),J)}function z(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),z)}function P(f){return f===47||f===62||$e(f)?C(f):n(f)}function $(f){return f===62?(e.consume(f),e.exit("htmlTextData"),e.exit("htmlText"),t):n(f)}function ee(f){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),me}function me(f){return ie(f)?fe(e,be,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(f):be(f)}function be(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||Q(u))?(e.exit("thematicBreak"),t(u)):n(u)}function c(u){return u===i?(e.consume(u),r++,c):(e.exit("thematicBreakSequence"),ie(u)?fe(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,fe(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,fe(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 fe(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 fe(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)?fe(e,c,"lineSuffix")(u):c(u))}function c(u){return u===null||Q(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,fe(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(;++n0){const Pe=K.tokenStack[K.tokenStack.length-1];(Pe[1]||_o).call(K,void 0,Pe[0])}for(L.position={start:Pt(S.length>0?S[0][1].start:{line:1,column:1,offset:0}),end:Pt(S.length>0?S[S.length-2][1].end:{line:1,column:1,offset:0})},ce=-1;++ce0){const Ee=H.tokenStack[H.tokenStack.length-1];(Ee[1]||_o).call(H,void 0,Ee[0])}for(A.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(Po(t.slice(i),i>0,!1)),a.join("")}function Po(e,t,n){let r=0,i=e.length;if(t){let a=e.codePointAt(r);for(;a===Co||a===Eo;)r++,a=e.codePointAt(r)}if(n){let a=e.codePointAt(i-1);for(;a===Co||a===Eo;)i--,a=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}function Pm(e,t){const n={type:"text",value:Em(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:Pm,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,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:` `},{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 Er(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=Ef(e),n=Pf(e);return Rf(t.runSync(t.parse(n),n),e)}function Ef(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 Pf(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],E=()=>["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"],A=()=>["start","end","center","between","around","evenly","stretch"],ie=()=>["","0",Y],f=()=>["auto","avoid","all","avoid-page","page","left","right","column"],xe=()=>[yn,Y];return{cacheSize:500,separator:":",theme:{colors:[Zn],spacing:[kt,Rt],blur:["none","",It,Y],brightness:xe(),borderColor:[e],borderRadius:["none","","full",It,Y],borderSpacing:I(),borderWidth:X(),contrast:xe(),grayscale:ie(),hueRotate:xe(),invert:ie(),gap:I(),gradientColorStops:[e],gradientColorStopPositions:[Yf,Rt],inset:D(),margin:D(),opacity:xe(),padding:I(),saturate:xe(),scale:xe(),sepia:ie(),skew:xe(),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:[...E(),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:ie()}],shrink:[{shrink:ie()}],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",...A()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...A(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...A(),"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:[...E(),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:xe()}],ease:[{ease:["linear","in","out","in-out",Y]}],delay:[{delay:xe()}],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 pe({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 Pr(e=new Date){return{from:new Date(e.getTime()-720*60*60*1e3).toISOString(),to:e.toISOString()}}function Ex(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 Px(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,Ea,Pa,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(()=>Pr()),[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,E]=R.useState("7d"),[U,te]=R.useState("7d"),[A,ie]=R.useState(()=>window.location.pathname),[f,xe]=R.useState(null),De=Lx(A),x=De!==null,Ce=Mx(A),He=Ox(A),de=Dx(A),lt=ps(A),Le=Fx(A),Ke=zx(A),st=!x&&!Ce&&!He&&!de&&!lt,le=De,je=we({queryKey:["metrics",Ws,q,U],queryFn:()=>ee(Ex(Ws,q,U)),enabled:st||de}),ke=we({queryKey:["dashboard-status"],queryFn:()=>ee("/api/status"),refetchInterval:de?1e4:!1}),Ee=we({queryKey:["me"],queryFn:()=>ee("/api/me"),refetchInterval:!1}),ct=lt&&!!((Ai=(Ti=Ee.data)==null?void 0:Ti.user)!=null&&Ai.is_admin&&((Li=ke.data)!=null&&Li.webhook_configured)),Ht=Nx(m),yt=we({queryKey:["web-push-config"],queryFn:()=>ee("/api/web-push/config"),enabled:!!((Mi=Ee.data)!=null&&Mi.user)}),Vr=we({queryKey:["about"],queryFn:()=>ee("/api/about")}),vr=we({queryKey:["job-actors"],queryFn:()=>ee("/api/jobs/actors"),enabled:st}),Qe=we({queryKey:["jobs",t,r],queryFn:()=>ee(jx(t,r)),enabled:st,placeholderData:P=>P}),it=we({queryKey:["processes"],queryFn:()=>ee("/api/processes"),enabled:de,refetchInterval:de?1e4:!1}),hn=we({queryKey:["systemd"],queryFn:()=>ee("/api/systemd"),enabled:de}),pn=we({queryKey:["alerts"],queryFn:()=>ee("/api/alerts"),enabled:de}),mn=we({queryKey:["webhook-summary"],queryFn:()=>ee("/api/webhooks/github/summary"),enabled:ct}),Kn=we({queryKey:["webhook-timeseries",v.from,v.to,"day"],queryFn:()=>ee(Sx(v.from,v.to)),enabled:ct&&Ht.timeseries}),S=we({queryKey:["webhook-exceptions"],queryFn:()=>ee("/api/webhooks/github/exceptions"),enabled:ct&&Ht.timeseries}),L=Yr({queryKey:["webhook-hooks"],queryFn:({pageParam:P})=>ee(_x(50,P)),initialPageParam:null,getNextPageParam:P=>P.next_cursor??void 0,enabled:ct&&Ht.hooks&&Le===null&&Ke===null}),K=Yr({queryKey:["webhook-deliveries",w],queryFn:({pageParam:P})=>ee(Cx(50,P,w)),initialPageParam:null,getNextPageParam:P=>P.next_cursor??void 0,enabled:ct&&Ht.deliveries&&Le===null&&Ke===null}),G=we({queryKey:["webhook-hook",Le],queryFn:()=>ee(`/api/webhooks/github/hooks/${encodeURIComponent(Le??"")}`),enabled:ct&&Le!==null}),ce=R.useCallback(async P=>{const Z=await ee(`/api/webhooks/github/hooks/${encodeURIComponent(P)}/ping`,{method:"POST"});return G.refetch(),window.setTimeout(()=>void G.refetch(),1500),Z.detail},[G]),Pe=we({queryKey:["webhook-delivery",Ke],queryFn:()=>ee(`/api/webhooks/github/deliveries/${encodeURIComponent(Ke??"")}`),enabled:ct&&Ke!==null}),Me=Yr({queryKey:["knowledge",d,o,d==="proposals"?c:""],queryFn:({pageParam:P})=>ee(kx(o,c,d,50,P)),initialPageParam:0,getNextPageParam:P=>P.next_offset??void 0,enabled:Ce}),Fe=we({queryKey:["mcp-tokens"],queryFn:()=>ee("/api/mcp/tokens"),enabled:He&&!!((Oi=Ee.data)!=null&&Oi.user)}),Kt=we({queryKey:["mcp-users"],queryFn:()=>ee("/api/mcp/users"),enabled:He&&!!((Di=Ee.data)!=null&&Di.user)}),ut=we({queryKey:["job",le],queryFn:()=>ee(`/api/jobs/${le}`),enabled:le!==null}),Re=we({queryKey:["job-session",le],queryFn:()=>ee(`/api/jobs/${le}/session`),enabled:le!==null}),wt=we({queryKey:["job-session-events",le],queryFn:()=>ee(`/api/jobs/${le}/session/events`),enabled:le!==null}),Ye=we({queryKey:["job-session-transcript",le],queryFn:()=>ee(`/api/jobs/${le}/session/transcript`),enabled:le!==null}),Ci=R.useCallback(async P=>{const Z=await ee(`/api/jobs/${P}/retry`,{method:"POST"});e.setQueryData(["job",P],{job:Z.job}),e.invalidateQueries({queryKey:["jobs"]}),e.invalidateQueries({queryKey:["metrics"]})},[e]),Ei=R.useCallback(async P=>{const Z=await ee(`/api/jobs/${P}/dismiss`,{method:"POST"});e.setQueryData(["job",P],{job:Z.job}),e.invalidateQueries({queryKey:["jobs"]}),e.invalidateQueries({queryKey:["metrics"]})},[e]),Pi=R.useCallback(async(P,Z)=>{const ue=await ee(`/api/jobs/${P}/cancel`,{method:"POST",body:JSON.stringify({reason:Z||""})});e.setQueryData(["job",P],{job:ue.job}),e.invalidateQueries({queryKey:["jobs"]}),e.invalidateQueries({queryKey:["metrics"]}),e.invalidateQueries({queryKey:["dashboard-status"]})},[e]),Ri=R.useCallback(async(P,Z)=>{await ee(`/api/knowledge/proposals/${encodeURIComponent(P)}/${Z}`,{method:"POST"}),e.invalidateQueries({queryKey:["knowledge"]}),e.invalidateQueries({queryKey:["dashboard-status"]})},[e]),Fc=R.useCallback(async P=>{await ee(`/api/knowledge/rules/${encodeURIComponent(P)}`,{method:"DELETE"}),e.invalidateQueries({queryKey:["knowledge"]})},[e]),zc=R.useCallback(async(P,Z)=>{await ee(`/api/knowledge/rules/${encodeURIComponent(P)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:Z})}),e.invalidateQueries({queryKey:["knowledge"]})},[e]),qc=R.useCallback(async(P,Z)=>{const ue=await ee("/api/mcp/tokens",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:P,user_login:Z||void 0})});return e.invalidateQueries({queryKey:["mcp-tokens"]}),ue},[e]),Bc=R.useCallback(async(P,Z)=>{await ee(`/api/mcp/tokens/${encodeURIComponent(P)}`,{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 P=>{await ee(`/api/mcp/tokens/${encodeURIComponent(P)}`,{method:"DELETE"}),e.invalidateQueries({queryKey:["mcp-tokens"]})},[e]),Gr=R.useCallback(async P=>{const Z={refresh:"/api/autoupdate/refresh",apply:"/api/autoupdate/apply",complete:"/api/autoupdate/complete-pending"}[P];k(P),O("");try{await ee(Z,{method:"POST"}),e.invalidateQueries({queryKey:["dashboard-status"]})}catch(ue){e.invalidateQueries({queryKey:["dashboard-status"]}),O(ue instanceof Error?ue.message:String(ue))}finally{k(null)}},[e]),Uc=R.useCallback(async P=>{B(!0),C("");try{const Z=await ee(`/api/executor/${P?"pause":"resume"}`,{method:"POST"});e.setQueryData(["dashboard-status"],ue=>ue&&{...ue,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 P=>{D(!0),X("");try{await ee("/api/executor/resize",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workers:P})}),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 P=(Ua=yt.data)==null?void 0:Ua.public_key;if(!P)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 ue=await navigator.serviceWorker.register("/service-worker.js"),su=await ue.pushManager.getSubscription()??await ue.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:Rx(P)});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 ue=Z.endpoint;await Z.unsubscribe(),await ee("/api/web-push/subscriptions",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({endpoint:ue})}),e.invalidateQueries({queryKey:["web-push-config"]})},[e]);R.useEffect(()=>{var P;!((P=yt.data)!=null&&P.status.enabled)||!Lr()||navigator.serviceWorker.register("/service-worker.js").catch(()=>{})},[(zi=yt.data)==null?void 0:zi.status.enabled]),R.useEffect(()=>{if(le===null)return;const P=new EventSource(`/api/jobs/${le}/session/stream`);return P.addEventListener("session_event",Z=>{const ue=Br(Z);ue&&(e.setQueryData(["job-session-events",le],Et=>({events:Ix((Et==null?void 0:Et.events)??[],ue)})),Ax(ue.event_type)&&(e.invalidateQueries({queryKey:["job",le]}),e.invalidateQueries({queryKey:["jobs"]})))}),P.addEventListener("transcript_entry",Z=>{const ue=Br(Z);!ue||ue.job_id!==le||e.setQueryData(["job-session-transcript",le],Et=>({entries:Tx((Et==null?void 0:Et.entries)??[],ue.entry)}))}),P.onerror=()=>{e.invalidateQueries({queryKey:["job",le]}),e.invalidateQueries({queryKey:["job-session-events",le]}),e.invalidateQueries({queryKey:["job-session-transcript",le]})},()=>P.close()},[le,e]),R.useEffect(()=>{const P=()=>{ps(window.location.pathname)&&b(Pr()),ie(window.location.pathname)};return window.addEventListener("popstate",P),()=>window.removeEventListener("popstate",P)},[]),R.useEffect(()=>{if(!("serviceWorker"in navigator))return;const P=Z=>{if(!Px(Z.data))return;const ue={...Z.data.payload,id:Date.now(),receivedAt:Date.now()};xe(ue),ue.job_id&&(e.invalidateQueries({queryKey:["jobs"]}),e.invalidateQueries({queryKey:["job",ue.job_id]}),e.invalidateQueries({queryKey:["metrics"]}))};return navigator.serviceWorker.addEventListener("message",P),()=>navigator.serviceWorker.removeEventListener("message",P)},[e]),R.useEffect(()=>{if(!f)return;const P=window.setTimeout(()=>xe(null),12e3);return()=>window.clearTimeout(P)},[f]);const Ii=R.useCallback(P=>{window.history.pushState({},"",Un(P)),ie(window.location.pathname)},[]),dt=R.useCallback(P=>{window.history.pushState({},"",P),ps(P)&&b(Pr()),ie(window.location.pathname)},[]),Qt=((qi=je.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=ke.data)==null?void 0:Hi.autoupdate)),Vc=R.useCallback(P=>{n(P),i(Ko),a.current=!1},[]);R.useEffect(()=>{Qe.isFetching||(a.current=!1)},[Qe.isFetching]);const Gc=R.useCallback(()=>{a.current||(a.current=!0,i(P=>P+dx))},[]),Ct=le?((Ki=ut.data)==null?void 0:Ki.job)??null:null,Jc=jr.some(P=>P.status==="running"||P.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:le,selectedJob:Ct,loading:ut.isLoading,error:ut.error,session:(Wi=Re.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(P=>P.hooks))??[],Zc=((Xi=K.data)==null?void 0:Xi.pages.flatMap(P=>P.deliveries))??[],vt=((Yi=Me.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(P=>P.proposals),rules:vt.flatMap(P=>P.rules),events:vt.flatMap(P=>P.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(Pr()),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:Ce,isMcpRoute:He,isWebhooksRoute:lt,showWebhooks:!!((ta=(ea=Ee.data)==null?void 0:ea.user)!=null&&ta.is_admin&&((na=ke.data)!=null&&na.webhook_configured)),knowledgeBadgeCount:((ia=(sa=(ra=ke.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:()=>xe(null),onNavigate:dt}),De!==null?s.jsx(ng,{jobId:De,detail:Xc,selectedJob:Ct,user:(aa=Ee.data)==null?void 0:aa.user,onBackToDashboard:()=>dt("/"),onRetry:Ci,onDismiss:Ei,onCancel:Pi,onRefresh:()=>{ut.refetch(),Re.refetch(),wt.refetch(),Ye.refetch()}}):Ce?s.jsx(sg,{data:eu,loading:Me.isLoading,error:Me.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:P=>Ri(P,"approve"),onReject:P=>Ri(P,"reject"),onUpdateRuleScope:zc,onDeleteRule:Fc,onRefresh:()=>Me.refetch(),hasMore:!!Me.hasNextPage,loadingMore:Me.isFetchingNextPage,onLoadMore:()=>Me.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=ke.data)==null?void 0:da.dashboard_url,dashboardUrlSource:(ha=ke.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:Pe.data,loading:Pe.isLoading,error:Pe.error,onBack:()=>{p("deliveries"),dt("/webhooks")},onRefresh:()=>Pe.refetch(),onViewHook:P=>dt(`/webhooks/hooks/${encodeURIComponent(P)}`),onViewJob:Ii}):Le?s.jsx(Yx,{data:G.data,loading:G.isLoading,error:G.error,onBack:()=>{p("hooks"),dt("/webhooks")},onRefresh:()=>G.refetch(),onViewHook:P=>dt(`/webhooks/hooks/${encodeURIComponent(P)}`),onViewDelivery:P=>dt(`/webhooks/deliveries/${encodeURIComponent(P)}`),onPing:ce}):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:P=>dt(`/webhooks/hooks/${encodeURIComponent(P)}`),onViewDelivery:P=>dt(`/webhooks/deliveries/${encodeURIComponent(P)}`),onRefresh:ru}):de?s.jsxs(s.Fragment,{children:[s.jsx(Ux,{state:(fa=ke.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=ke.data)==null?void 0:ba.executor_pause,executorPauseLoading:ke.isLoading,executorPauseStatusError:ke.error,executorPausePending:j,executorPauseError:F,executorCapacity:{desired:((ya=it.data)==null?void 0:ya.executor.expected_workers)??((va=(wa=ke.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=ke.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=ke.data)==null?void 0:_a.metrics)==null?void 0:Ca.executor_worker_busy_count)??0,draining:((Ea=it.data)==null?void 0:Ea.executor.draining_workers)??((Ra=(Pa=ke.data)==null?void 0:Pa.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=je.data)==null?void 0:La.metrics,sloLoading:je.isLoading,sloError:je.error,sloWindow:q,now:Qn,onRefreshProcesses:()=>it.refetch(),onRefreshSystemd:()=>hn.refetch(),onRefreshAlerts:()=>pn.refetch(),onSloWindowChange:E,onRefreshSlo:()=>je.refetch()})]}):s.jsxs(s.Fragment,{children:[je.error?s.jsx(be,{tone:"error",text:je.error.message}):null,ke.error?s.jsx(be,{tone:"error",text:ke.error.message}):null,s.jsxs("section",{className:"grid grid-cols-2 gap-3 xl:grid-cols-4","aria-label":"Summary metrics",children:[s.jsx(Te,{title:"Pending",value:Qt.pending??0,icon:s.jsx(Rl,{className:"h-5 w-5"})}),s.jsx(Te,{title:"Running",value:Qt.running??0,icon:s.jsx(an,{className:"h-5 w-5"})}),s.jsx(Te,{title:"Blocked",value:Qt.blocked??0,icon:s.jsx(Hr,{className:"h-5 w-5"})}),s.jsx(Te,{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:Ei,onCancel:Pi})]}),s.jsx(se,{title:"Runtime & jobs",action:s.jsx(nt,{onClick:()=>je.refetch()}),children:s.jsx(Dg,{usage:(Da=je.data)==null?void 0:Da.metrics.runtime_usage,jobsByCreatedDay:(Fa=je.data)==null?void 0:Fa.metrics.by_created_day,loading:je.isLoading,totalJobs:gs(Qt)})}),s.jsx(se,{title:"Runtime by user",children:s.jsx(Bg,{usage:(za=je.data)==null?void 0:za.metrics.runtime_usage_by_actor,loading:je.isLoading,totalJobs:gs(Qt),window:U,onWindowChange:te})}),s.jsx(se,{title:"Runtime by repository",children:s.jsx($g,{usage:(qa=je.data)==null?void 0:qa.metrics.runtime_usage_by_repo,loading:je.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=je.data)==null?void 0:Ba.metrics.runtime_seconds})}),s.jsx(se,{title:"Queue wait percentiles",children:s.jsx(Xo,{label:"queue wait",values:($a=je.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 j,B,F,C,M,D,I,X,q,E,U,te;const N=Object.values((e==null?void 0:e.receipts)??{}).reduce((A,ie)=>A+ie,0),k=((j=e==null?void 0:e.coverage)==null?void 0:j.promotion_state)??((B=e==null?void 0:e.coverage)!=null&&B.promotion_ready?"ready":"blocked"),_=k==="insufficient_data"?"insufficient data":k,O=[{id:"overview",label:"Overview"},{id:"hooks",label:"Hooks",count:(F=e==null?void 0:e.totals)==null?void 0:F.hooks},{id:"deliveries",label:"Deliveries",count:(C=e==null?void 0:e.totals)==null?void 0:C.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:O.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(Te,{title:"Receipts",value:N,icon:s.jsx(an,{className:"h-5 w-5"})}),s.jsx(Te,{title:"Duplicates",value:(e==null?void 0:e.duplicate_deliveries)??0,icon:s.jsx(zn,{className:"h-5 w-5"})}),s.jsx(Te,{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(Te,{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],[ie])=>A.localeCompare(ie)).map(([A,ie])=>s.jsx($,{label:A,value:ie},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:((M=e==null?void 0:e.coverage)==null?void 0:M.both)??0}),s.jsx($,{label:"IMAP only",value:((D=e==null?void 0:e.coverage)==null?void 0:D.imap_only)??0}),s.jsx($,{label:"Webhook only",value:((I=e==null?void 0:e.coverage)==null?void 0:I.webhook_only)??0}),s.jsx($,{label:"Coverage",value:((X=e==null?void 0:e.coverage)==null?void 0:X.ratio)==null?"not measurable":`${Math.round(e.coverage.ratio*100)}%`}),s.jsx($,{label:"Decision mismatches",value:((q=e==null?void 0:e.coverage)==null?void 0:q.decision_mismatches)??0}),s.jsx($,{label:"Incomplete decision traces",value:((E=e==null?void 0:e.coverage)==null?void 0:E.incomplete_decision_traces)??0}),s.jsx($,{label:"Split identities",value:((U=e==null?void 0:e.coverage)==null?void 0:U.split_identities)??0}),s.jsx($,{label:"Promotion gate",value:_})]}),(te=e==null?void 0:e.coverage)!=null&&te.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(pe,{value:e.coverage.window_start})," to ",s.jsx(pe,{value:e.coverage.window_end}),"; ",e.coverage.observation_days??7," observation days required and newest ",e.coverage.grace_seconds??0,"s excluded."]}):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],[ie])=>A.localeCompare(ie)).map(([A,ie])=>s.jsx($,{label:A,value:ie},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(pe,{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:ie=>{ie.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(pe,{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(pe,{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(pe,{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(pe,{value:w.github_created_at}):"unknown",github_updated_at:w.github_updated_at?s.jsx(pe,{value:w.github_updated_at}):"unknown",last_ping_at:w.last_ping_at?s.jsx(pe,{value:w.last_ping_at}):"never",last_event_at:w.last_event_at?s.jsx(pe,{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(pe,{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(Te,{title:"State",value:y.status,icon:s.jsx(an,{className:"h-5 w-5"})}),s.jsx(Te,{title:"Deliveries",value:e.stats.deliveries,icon:s.jsx(Fn,{className:"h-5 w-5"})}),s.jsx(Te,{title:"Retries",value:e.stats.duplicates,icon:s.jsx(zn,{className:"h-5 w-5"})}),s.jsx(Te,{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(pe,{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(Te,{title:"Proposed",value:k.proposed??0,icon:s.jsx(Rl,{className:"h-5 w-5"})}),s.jsx(Te,{title:"Approved",value:k.approved??0,icon:s.jsx(Dn,{className:"h-5 w-5"})}),s.jsx(Te,{title:"Rules",value:k.rules??0,icon:s.jsx(Tl,{className:"h-5 w-5"})}),s.jsx(Te,{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(Pc,{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(Pc,{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(pe,{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(E=>E.login===w);R.useEffect(()=>{var E;r!=null&&r.is_admin&&(w&&i.some(U=>U.login===w)||y((r==null?void 0:r.login)||((E=i[0])==null?void 0:E.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 E=>{E.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:E=>p(E.target.value)})}),r!=null&&r.is_admin?s.jsxs(ot,{label:"Owner",children:[s.jsx(Ec,{ariaLabel:"Owner",value:w,ownerOptions:i,disabled:v||i.length===0,selectedSuffix:E=>E.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(E,U)=>{O(E),C("");try{await u(E,U)}catch(te){C(te instanceof Error?te.message:String(te))}finally{O(null)}},onRevoke:async E=>{if(window.confirm("Revoke this MCP token?")){k(E),C("");try{await d(E)}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 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 xe=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)),X=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=xe("colors"),t=xe("spacing"),n=xe("blur"),r=xe("brightness"),i=xe("borderColor"),a=xe("borderRadius"),o=xe("borderSpacing"),l=xe("borderWidth"),c=xe("contrast"),u=xe("grayscale"),d=xe("hueRotate"),h=xe("invert"),m=xe("gap"),p=xe("gradientColorStops"),w=xe("gradientColorStopPositions"),y=xe("inset"),v=xe("margin"),b=xe("opacity"),N=xe("padding"),k=xe("saturate"),_=xe("scale"),M=xe("sepia"),j=xe("skew"),q=xe("space"),D=xe("translate"),C=()=>["auto","contain","none"],L=()=>["auto","hidden","clip","visible","scroll"],O=()=>["auto",X,t],I=()=>[X,t],J=()=>["",kt,Rt],z=()=>["auto",yn,X],P=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],$=()=>["solid","dashed","dotted","double","none"],ee=()=>["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"],be=()=>["","0",X],f=()=>["auto","avoid","all","avoid-page","page","left","right","column"],te=()=>[yn,X];return{cacheSize:500,separator:":",theme:{colors:[Zn],spacing:[kt,Rt],blur:["none","",It,X],brightness:te(),borderColor:[e],borderRadius:["none","","full",It,X],borderSpacing:I(),borderWidth:J(),contrast:te(),grayscale:be(),hueRotate:te(),invert:be(),gap:I(),gradientColorStops:[e],gradientColorStopPositions:[Yf,Rt],inset:O(),margin:O(),opacity:te(),padding:I(),saturate:te(),scale:te(),sepia:be(),skew:te(),space:I(),translate:I()},classGroups:{aspect:[{aspect:["auto","square","video",X]}],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(),X]}],overflow:[{overflow:L()}],"overflow-x":[{"overflow-x":L()}],"overflow-y":[{"overflow-y":L()}],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,X]}],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",X]}],grow:[{grow:be()}],shrink:[{shrink:be()}],order:[{order:["first","last","none",Yn,X]}],"grid-cols":[{"grid-cols":[Zn]}],"col-start-end":[{col:["auto",{span:["full",Yn,X]},X]}],"col-start":[{"col-start":z()}],"col-end":[{"col-end":z()}],"grid-rows":[{"grid-rows":[Zn]}],"row-start-end":[{row:["auto",{span:[Yn,X]},X]}],"row-start":[{"row-start":z()}],"row-end":[{"row-end":z()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",X]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",X]}],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":[q]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[q]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",X,t]}],"min-w":[{"min-w":[X,t,"min","max","fit"]}],"max-w":[{"max-w":[X,t,"none","full","min","max","fit","prose",{screen:[It]},It]}],h:[{h:[X,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[X,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[X,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[X,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",X]}],"line-clamp":[{"line-clamp":["none",yn,hs]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",kt,X]}],"list-image":[{"list-image":["none",X]}],"list-style-type":[{list:["none","disc","decimal",X]}],"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:[...$(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",kt,Rt]}],"underline-offset":[{"underline-offset":["auto",kt,X]}],"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",X]}],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",X]}],"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:[...$(),"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:$()}],"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:["",...$()]}],"outline-offset":[{"outline-offset":[kt,X]}],"outline-w":[{outline:[kt,Rt]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:J()}],"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":[...ee(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":ee()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[c]}],"drop-shadow":[{"drop-shadow":["","none",It,X]}],grayscale:[{grayscale:[u]}],"hue-rotate":[{"hue-rotate":[d]}],invert:[{invert:[h]}],saturate:[{saturate:[k]}],sepia:[{sepia:[M]}],"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":[M]}],"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",X]}],duration:[{duration:te()}],ease:[{ease:["linear","in","out","in-out",X]}],delay:[{delay:te()}],animate:[{animate:["none","spin","ping","pulse","bounce",X]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[_]}],"scale-x":[{"scale-x":[_]}],"scale-y":[{"scale-y":[_]}],rotate:[{rotate:[Yn,X]}],"translate-x":[{"translate-x":[D]}],"translate-y":[{"translate-y":[D]}],"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",X]}],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",X]}],"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",X]}],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 K(...e){return cx(du(e))}async function Z(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),[_,M]=R.useState(""),[j,q]=R.useState(!1),[D,C]=R.useState(""),[L,O]=R.useState(!1),[I,J]=R.useState(""),[z,P]=R.useState("7d"),[$,ee]=R.useState("7d"),[me,be]=R.useState(()=>window.location.pathname),[f,te]=R.useState(null),De=Lx(me),x=De!==null,Ce=Mx(me),He=Ox(me),de=Dx(me),lt=ps(me),Le=Fx(me),Ke=zx(me),st=!x&&!Ce&&!He&&!de&&!lt,oe=De,je=we({queryKey:["metrics",Ws,z,$],queryFn:()=>Z(Px(Ws,z,$)),enabled:st||de}),ke=we({queryKey:["dashboard-status"],queryFn:()=>Z("/api/status"),refetchInterval:de?1e4:!1}),Pe=we({queryKey:["me"],queryFn:()=>Z("/api/me"),refetchInterval:!1}),ct=lt&&!!((Ai=(Ti=Pe.data)==null?void 0:Ti.user)!=null&&Ai.is_admin&&((Li=ke.data)!=null&&Li.webhook_configured)),Ht=Nx(m),yt=we({queryKey:["web-push-config"],queryFn:()=>Z("/api/web-push/config"),enabled:!!((Mi=Pe.data)!=null&&Mi.user)}),Vr=we({queryKey:["about"],queryFn:()=>Z("/api/about")}),vr=we({queryKey:["job-actors"],queryFn:()=>Z("/api/jobs/actors"),enabled:st}),Qe=we({queryKey:["jobs",t,r],queryFn:()=>Z(jx(t,r)),enabled:st,placeholderData:E=>E}),it=we({queryKey:["processes"],queryFn:()=>Z("/api/processes"),enabled:de,refetchInterval:de?1e4:!1}),hn=we({queryKey:["systemd"],queryFn:()=>Z("/api/systemd"),enabled:de}),pn=we({queryKey:["alerts"],queryFn:()=>Z("/api/alerts"),enabled:de}),mn=we({queryKey:["webhook-summary"],queryFn:()=>Z("/api/webhooks/github/summary"),enabled:ct}),Kn=we({queryKey:["webhook-timeseries",v.from,v.to,"day"],queryFn:()=>Z(Sx(v.from,v.to)),enabled:ct&&Ht.timeseries}),S=we({queryKey:["webhook-exceptions"],queryFn:()=>Z("/api/webhooks/github/exceptions"),enabled:ct&&Ht.timeseries}),A=Yr({queryKey:["webhook-hooks"],queryFn:({pageParam:E})=>Z(_x(50,E)),initialPageParam:null,getNextPageParam:E=>E.next_cursor??void 0,enabled:ct&&Ht.hooks&&Le===null&&Ke===null}),H=Yr({queryKey:["webhook-deliveries",w],queryFn:({pageParam:E})=>Z(Cx(50,E,w)),initialPageParam:null,getNextPageParam:E=>E.next_cursor??void 0,enabled:ct&&Ht.deliveries&&Le===null&&Ke===null}),V=we({queryKey:["webhook-hook",Le],queryFn:()=>Z(`/api/webhooks/github/hooks/${encodeURIComponent(Le??"")}`),enabled:ct&&Le!==null}),le=R.useCallback(async E=>{const Y=await Z(`/api/webhooks/github/hooks/${encodeURIComponent(E)}/ping`,{method:"POST"});return V.refetch(),window.setTimeout(()=>void V.refetch(),1500),Y.detail},[V]),Ee=we({queryKey:["webhook-delivery",Ke],queryFn:()=>Z(`/api/webhooks/github/deliveries/${encodeURIComponent(Ke??"")}`),enabled:ct&&Ke!==null}),Me=Yr({queryKey:["knowledge",d,o,d==="proposals"?c:""],queryFn:({pageParam:E})=>Z(kx(o,c,d,50,E)),initialPageParam:0,getNextPageParam:E=>E.next_offset??void 0,enabled:Ce}),Fe=we({queryKey:["mcp-tokens"],queryFn:()=>Z("/api/mcp/tokens"),enabled:He&&!!((Oi=Pe.data)!=null&&Oi.user)}),Kt=we({queryKey:["mcp-users"],queryFn:()=>Z("/api/mcp/users"),enabled:He&&!!((Di=Pe.data)!=null&&Di.user)}),ut=we({queryKey:["job",oe],queryFn:()=>Z(`/api/jobs/${oe}`),enabled:oe!==null}),Re=we({queryKey:["job-session",oe],queryFn:()=>Z(`/api/jobs/${oe}/session`),enabled:oe!==null}),wt=we({queryKey:["job-session-events",oe],queryFn:()=>Z(`/api/jobs/${oe}/session/events`),enabled:oe!==null}),Ye=we({queryKey:["job-session-transcript",oe],queryFn:()=>Z(`/api/jobs/${oe}/session/transcript`),enabled:oe!==null}),Ci=R.useCallback(async E=>{const Y=await Z(`/api/jobs/${E}/retry`,{method:"POST"});e.setQueryData(["job",E],{job:Y.job}),e.invalidateQueries({queryKey:["jobs"]}),e.invalidateQueries({queryKey:["metrics"]})},[e]),Pi=R.useCallback(async E=>{const Y=await Z(`/api/jobs/${E}/dismiss`,{method:"POST"});e.setQueryData(["job",E],{job:Y.job}),e.invalidateQueries({queryKey:["jobs"]}),e.invalidateQueries({queryKey:["metrics"]})},[e]),Ei=R.useCallback(async(E,Y)=>{const ce=await Z(`/api/jobs/${E}/cancel`,{method:"POST",body:JSON.stringify({reason:Y||""})});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,Y)=>{await Z(`/api/knowledge/proposals/${encodeURIComponent(E)}/${Y}`,{method:"POST"}),e.invalidateQueries({queryKey:["knowledge"]}),e.invalidateQueries({queryKey:["dashboard-status"]})},[e]),Fc=R.useCallback(async E=>{await Z(`/api/knowledge/rules/${encodeURIComponent(E)}`,{method:"DELETE"}),e.invalidateQueries({queryKey:["knowledge"]})},[e]),zc=R.useCallback(async(E,Y)=>{await Z(`/api/knowledge/rules/${encodeURIComponent(E)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:Y})}),e.invalidateQueries({queryKey:["knowledge"]})},[e]),qc=R.useCallback(async(E,Y)=>{const ce=await Z("/api/mcp/tokens",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:E,user_login:Y||void 0})});return e.invalidateQueries({queryKey:["mcp-tokens"]}),ce},[e]),Bc=R.useCallback(async(E,Y)=>{await Z(`/api/mcp/tokens/${encodeURIComponent(E)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({user_login:Y})}),e.invalidateQueries({queryKey:["mcp-tokens"]}),e.invalidateQueries({queryKey:["mcp-users"]})},[e]),$c=R.useCallback(async E=>{await Z(`/api/mcp/tokens/${encodeURIComponent(E)}`,{method:"DELETE"}),e.invalidateQueries({queryKey:["mcp-tokens"]})},[e]),Gr=R.useCallback(async E=>{const Y={refresh:"/api/autoupdate/refresh",apply:"/api/autoupdate/apply",complete:"/api/autoupdate/complete-pending"}[E];k(E),M("");try{await Z(Y,{method:"POST"}),e.invalidateQueries({queryKey:["dashboard-status"]})}catch(ce){e.invalidateQueries({queryKey:["dashboard-status"]}),M(ce instanceof Error?ce.message:String(ce))}finally{k(null)}},[e]),Uc=R.useCallback(async E=>{q(!0),C("");try{const Y=await Z(`/api/executor/${E?"pause":"resume"}`,{method:"POST"});e.setQueryData(["dashboard-status"],ce=>ce&&{...ce,executor_pause:Y.executor_pause}),await e.invalidateQueries({queryKey:["dashboard-status"]})}catch(Y){C(Y instanceof Error?Y.message:String(Y))}finally{q(!1)}},[e]),Hc=R.useCallback(async E=>{O(!0),J("");try{await Z("/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(Y){J(Y instanceof Error?Y.message:String(Y))}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 Z("/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 Y=await(await navigator.serviceWorker.ready).pushManager.getSubscription();if(!Y)return;const ce=Y.endpoint;await Y.unsubscribe(),await Z("/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",Y=>{const ce=Br(Y);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",Y=>{const ce=Br(Y);!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()),be(window.location.pathname)};return window.addEventListener("popstate",E),()=>window.removeEventListener("popstate",E)},[]),R.useEffect(()=>{if(!("serviceWorker"in navigator))return;const E=Y=>{if(!Ex(Y.data))return;const ce={...Y.data.payload,id:Date.now(),receivedAt:Date.now()};te(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(()=>te(null),12e3);return()=>window.clearTimeout(E)},[f]);const Ii=R.useCallback(E=>{window.history.pushState({},"",Un(E)),be(window.location.pathname)},[]),dt=R.useCallback(E=>{window.history.pushState({},"",E),ps(E)&&b(Er()),be(window.location.pathname)},[]),Qt=((qi=je.data)==null?void 0:qi.metrics.status_counts)??{},jr=((Bi=Qe.data)==null?void 0:Bi.jobs)??[],Wc=!!((Ui=($i=Pe.data)==null?void 0:$i.user)!=null&&Ui.is_admin&&Sc((Hi=ke.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=Re.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=A.data)==null?void 0:Ji.pages.flatMap(E=>E.hooks))??[],Zc=((Xi=H.data)==null?void 0:Xi.pages.flatMap(E=>E.deliveries))??[],vt=((Yi=Me.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"?A.isLoading:H.isLoading,nu=m==="overview"?Kn.error:m==="hooks"?A.error:H.error,ru=()=>{mn.refetch(),m==="overview"&&S.refetch(),m==="overview"&&b(Er()),m==="hooks"&&A.refetch(),m==="deliveries"&&H.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=Pe.data)==null?void 0:Zi.user,loading:Pe.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:Ce,isMcpRoute:He,isWebhooksRoute:lt,showWebhooks:!!((ta=(ea=Pe.data)==null?void 0:ea.user)!=null&&ta.is_admin&&((na=ke.data)!=null&&na.webhook_configured)),knowledgeBadgeCount:((ia=(sa=(ra=ke.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:()=>te(null),onNavigate:dt}),De!==null?s.jsx(ng,{jobId:De,detail:Xc,selectedJob:Ct,user:(aa=Pe.data)==null?void 0:aa.user,onBackToDashboard:()=>dt("/"),onRetry:Ci,onDismiss:Pi,onCancel:Ei,onRefresh:()=>{ut.refetch(),Re.refetch(),wt.refetch(),Ye.refetch()}}):Ce?s.jsx(sg,{data:eu,loading:Me.isLoading,error:Me.error,repo:o,status:c,activeTab:d,user:(oa=Pe.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:()=>Me.refetch(),hasMore:!!Me.hasNextPage,loadingMore:Me.isFetchingNextPage,onLoadMore:()=>Me.fetchNextPage()}):He?s.jsx(ug,{tokens:(la=Fe.data)==null?void 0:la.tokens,loading:Fe.isLoading,error:Fe.error,user:(ca=Pe.data)==null?void 0:ca.user,ownerOptions:((ua=Kt.data)==null?void 0:ua.users)??[],dashboardUrl:(da=ke.data)==null?void 0:da.dashboard_url,dashboardUrlSource:(ha=ke.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:Ee.data,loading:Ee.isLoading,error:Ee.error,onBack:()=>{p("deliveries"),dt("/webhooks")},onRefresh:()=>Ee.refetch(),onViewHook:E=>dt(`/webhooks/hooks/${encodeURIComponent(E)}`),onViewJob:Ii}):Le?s.jsx(Yx,{data:V.data,loading:V.isLoading,error:V.error,onBack:()=>{p("hooks"),dt("/webhooks")},onRefresh:()=>V.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"?A.isFetchingNextPage:H.isFetchingNextPage,hasMore:m==="hooks"?A.hasNextPage:H.hasNextPage,deliveryFilters:w,error:mn.error??nu,onSectionChange:p,onLoadMore:()=>m==="hooks"?A.fetchNextPage():H.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=ke.data)==null?void 0:fa.autoupdate,isAdmin:!!((ga=(xa=Pe.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=ke.data)==null?void 0:ba.executor_pause,executorPauseLoading:ke.isLoading,executorPauseStatusError:ke.error,executorPausePending:j,executorPauseError:D,executorCapacity:{desired:((ya=it.data)==null?void 0:ya.executor.expected_workers)??((va=(wa=ke.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=ke.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=ke.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=ke.data)==null?void 0:Ea.metrics)==null?void 0:Ra.executor_worker_draining_count)??0},executorResizePending:L,executorResizeError:I,isAdmin:!!((Ta=(Ia=Pe.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=je.data)==null?void 0:La.metrics,sloLoading:je.isLoading,sloError:je.error,sloWindow:z,now:Qn,onRefreshProcesses:()=>it.refetch(),onRefreshSystemd:()=>hn.refetch(),onRefreshAlerts:()=>pn.refetch(),onSloWindowChange:P,onRefreshSlo:()=>je.refetch()})]}):s.jsxs(s.Fragment,{children:[je.error?s.jsx(ge,{tone:"error",text:je.error.message}):null,ke.error?s.jsx(ge,{tone:"error",text:ke.error.message}):null,s.jsxs("section",{className:"grid grid-cols-2 gap-3 xl:grid-cols-4","aria-label":"Summary metrics",children:[s.jsx(Te,{title:"Pending",value:Qt.pending??0,icon:s.jsx(Rl,{className:"h-5 w-5"})}),s.jsx(Te,{title:"Running",value:Qt.running??0,icon:s.jsx(an,{className:"h-5 w-5"})}),s.jsx(Te,{title:"Blocked",value:Qt.blocked??0,icon:s.jsx(Hr,{className:"h-5 w-5"})}),s.jsx(Te,{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(ge,{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=Pe.data)==null?void 0:Oa.user,onRetry:Ci,onDismiss:Pi,onCancel:Ei})]}),s.jsx(se,{title:"Runtime & jobs",action:s.jsx(nt,{onClick:()=>je.refetch()}),children:s.jsx(Dg,{usage:(Da=je.data)==null?void 0:Da.metrics.runtime_usage,jobsByCreatedDay:(Fa=je.data)==null?void 0:Fa.metrics.by_created_day,loading:je.isLoading,totalJobs:gs(Qt)})}),s.jsx(se,{title:"Runtime by user",children:s.jsx(Bg,{usage:(za=je.data)==null?void 0:za.metrics.runtime_usage_by_actor,loading:je.isLoading,totalJobs:gs(Qt),window:$,onWindowChange:ee})}),s.jsx(se,{title:"Runtime by repository",children:s.jsx($g,{usage:(qa=je.data)==null?void 0:qa.metrics.runtime_usage_by_repo,loading:je.isLoading,totalJobs:gs(Qt),window:$,onWindowChange:ee})})]}),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=je.data)==null?void 0:Ba.metrics.runtime_seconds})}),s.jsx(se,{title:"Queue wait percentiles",children:s.jsx(Xo,{label:"queue wait",values:($a=je.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,_,M,j,q,D,C,L;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=(M=e.classification)==null?void 0:M.migration_files)==null?void 0:j.length)??0,p=((D=(q=e.classification)==null?void 0:q.risky_files)==null?void 0:D.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:K("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,(L=e.warnings)!=null&&L.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:K("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:K("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 j,q,D,C,L,O,I,J,z,P,$,ee,me,be;const N=Object.values((e==null?void 0:e.receipts)??{}).reduce((f,te)=>f+te,0),k=((j=e==null?void 0:e.coverage)==null?void 0:j.promotion_state)??((q=e==null?void 0:e.coverage)!=null&&q.promotion_ready?"ready":"blocked"),_=k==="insufficient_data"?"insufficient data":k,M=[{id:"overview",label:"Overview"},{id:"hooks",label:"Hooks",count:(D=e==null?void 0:e.totals)==null?void 0:D.hooks},{id:"deliveries",label:"Deliveries",count:(C=e==null?void 0:e.totals)==null?void 0:C.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(ge,{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:M.map(f=>s.jsxs("button",{type:"button",role:"tab","aria-label":f.count===void 0?f.label:`${f.label} (${f.count} total)`,"aria-selected":a===f.id,className:K("inline-flex h-8 items-center gap-2 rounded px-3 text-sm font-semibold",a===f.id?"bg-primary text-white":"text-muted hover:bg-slate-50 hover:text-foreground"),onClick:()=>m(f.id),children:[f.label,f.count!==void 0?s.jsx("span",{className:"rounded border border-current/30 px-1 font-mono text-[10px]",children:f.count}):null]},f.id))}),s.jsxs("div",{className:"grid grid-cols-2 gap-3 xl:grid-cols-4","aria-label":"Webhook status",children:[s.jsx(Te,{title:"Receipts",value:N,icon:s.jsx(an,{className:"h-5 w-5"})}),s.jsx(Te,{title:"Duplicates",value:(e==null?void 0:e.duplicate_deliveries)??0,icon:s.jsx(zn,{className:"h-5 w-5"})}),s.jsx(Te,{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(Te,{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(G,{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(([f],[te])=>f.localeCompare(te)).map(([f,te])=>s.jsx(B,{label:f,value:te},f))}):s.jsx(G,{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(B,{label:"Both sources",value:((L=e==null?void 0:e.coverage)==null?void 0:L.both)??0}),s.jsx(B,{label:"IMAP only",value:((O=e==null?void 0:e.coverage)==null?void 0:O.imap_only)??0}),s.jsx(B,{label:"Webhook only",value:((I=e==null?void 0:e.coverage)==null?void 0:I.webhook_only)??0}),s.jsx(B,{label:"Coverage",value:((J=e==null?void 0:e.coverage)==null?void 0:J.ratio)==null?"not measurable":`${Math.round(e.coverage.ratio*100)}%`}),s.jsx(B,{label:"Decision mismatches",value:((z=e==null?void 0:e.coverage)==null?void 0:z.decision_mismatches)??0}),s.jsx(B,{label:"Incomplete decision traces",value:((P=e==null?void 0:e.coverage)==null?void 0:P.incomplete_decision_traces)??0}),s.jsx(B,{label:"Split identities",value:(($=e==null?void 0:e.coverage)==null?void 0:$.split_identities)??0}),s.jsx(B,{label:"Promotion gate",value:_}),s.jsx(B,{label:"Outside scope IMAP",value:((ee=e==null?void 0:e.coverage)==null?void 0:ee.outside_scope_imap_eligible)??0}),s.jsx(B,{label:"Outside scope webhook",value:((me=e==null?void 0:e.coverage)==null?void 0:me.outside_scope_webhook_eligible)??0})]}),(be=e==null?void 0:e.coverage)!=null&&be.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. Promotion scope: ",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(([f],[te])=>f.localeCompare(te)).map(([f,te])=>s.jsx(B,{label:f,value:te},f))})}):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(f=>s.jsxs("tr",{className:"border-b border-border/70 last:border-0",children:[s.jsx("td",{className:"px-3 py-2 font-semibold",children:f.kind}),s.jsx("td",{className:"px-3 py-2 font-mono text-xs",children:f.repository??"unknown"}),s.jsx("td",{className:"px-3 py-2 font-mono text-xs",children:f.event_type?`${f.event_type}${f.event_action?`:${f.event_action}`:""}`:"unknown"}),s.jsxs("td",{className:"px-3 py-2 font-mono text-xs",children:[s.jsx("div",{children:f.reference}),f.related_reference?s.jsx("div",{children:f.related_reference}):null,f.event_key?s.jsxs("div",{className:"text-muted",children:[f.event_key,f.related_event_key?` ↔ ${f.related_event_key}`:""]}):null]}),s.jsx("td",{className:"px-3 py-2 font-mono text-xs text-muted",children:s.jsx(ue,{value:f.created_at,compact:!0})})]},`${f.kind}:${f.reference}:${f.related_reference??""}`))})]})}):s.jsx(G,{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(f=>s.jsxs("tr",{className:"cursor-pointer border-b border-border/70 last:border-0 hover:bg-slate-50",onClick:()=>y(f.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:te=>{te.stopPropagation(),y(f.id)},children:f.target}),s.jsxs("div",{className:"font-mono text-xs text-muted",children:[f.target_type," · #",f.id]})]}),s.jsx("td",{className:"px-3 py-3",children:s.jsx("span",{className:K("rounded border px-2 py-1 text-xs font-semibold",f.status==="receiving"?"border-emerald-200 bg-emerald-50 text-emerald-700":f.status==="inactive"?"border-red-200 bg-red-50 text-red-700":"border-slate-200 bg-slate-50 text-slate-600"),children:f.status})}),s.jsxs("td",{className:"max-w-sm px-3 py-3 text-xs",children:[s.jsx("div",{children:f.events.join(", ")||"No event snapshot"}),s.jsxs("div",{className:"mt-1 font-mono text-muted",children:[f.content_type??"content type unknown"," · SSL ",f.ssl_verify===null||f.ssl_verify===void 0?"unknown":f.ssl_verify?"verified":"disabled"]})]}),s.jsxs("td",{className:"px-3 py-3 text-xs",children:[s.jsxs("div",{className:"font-semibold",children:[f.last_event_name??"Never",f.last_action?` · ${f.last_action}`:""]}),s.jsxs("div",{className:"mt-1 font-mono text-muted",children:[f.last_repository??"No repository",f.last_event_at?s.jsxs(s.Fragment,{children:[" · ",s.jsx(ue,{value:f.last_event_at,compact:!0})]}):null]})]}),s.jsx("td",{className:"px-3 py-3 font-mono text-xs text-muted",children:f.last_ping_at?s.jsx(ue,{value:f.last_ping_at,compact:!0}):"Never"})]},f.id))})]})}):s.jsx(G,{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(G,{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:K("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(ge,{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(G,{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:K("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(ge,{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(Te,{title:"State",value:y.status,icon:s.jsx(an,{className:"h-5 w-5"})}),s.jsx(Te,{title:"Deliveries",value:e.stats.deliveries,icon:s.jsx(Fn,{className:"h-5 w-5"})}),s.jsx(Te,{title:"Retries",value:e.stats.duplicates,icon:s.jsx(zn,{className:"h-5 w-5"})}),s.jsx(Te,{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(B,{label:"Active",value:y.active?"yes":"no"}),s.jsx(B,{label:"Content type",value:y.content_type??"unknown"}),s.jsx(B,{label:"SSL verification",value:y.ssl_verify===null||y.ssl_verify===void 0?"unknown":y.ssl_verify?"enabled":"disabled"}),s.jsx(B,{label:"Destination URL",value:y.delivery_url??"unknown"}),s.jsx(B,{label:"GitHub created",value:y.github_created_at??"unknown"}),s.jsx(B,{label:"GitHub updated",value:y.github_updated_at??"unknown"}),s.jsx(B,{label:"Last ping",value:y.last_ping_at??"never"}),s.jsx(B,{label:"Last delivery",value:y.last_event_at??"never"}),s.jsx(B,{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(B,{label:"Event",value:y.last_event_name?`${y.last_event_name}${y.last_action?` · ${y.last_action}`:""}`:"none"}),s.jsx(B,{label:"Repository",value:y.last_repository??"none"}),s.jsx(B,{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(G,{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(G,{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(ge,{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(G,{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(B,{label:"Received",value:l.created_at}),s.jsx(B,{label:"Repository",value:l.repository??"unknown"}),s.jsx(B,{label:"Result",value:l.status}),s.jsx(B,{label:"Event key",value:l.event_key??"unmatchable"}),s.jsx(B,{label:"Payload SHA-256",value:e.payload_hash}),s.jsx(B,{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(G,{text:"This delivery did not generate or coalesce into a job."})}),s.jsx(se,{title:"Full payload",children:e.payload===null?s.jsx(G,{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:M,sloError:j,sloWindow:q,now:D,onRefreshProcesses:C,onRefreshSystemd:L,onRefreshAlerts:O,onSloWindowChange:I,onRefreshSlo:J}){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(ge,{tone:"error",text:j.message}):null,s.jsx(wg,{summary:_,loading:M,window:q,onWindowChange:I,onRefresh:J}),s.jsxs(se,{title:"Systemd",action:s.jsx(nt,{onClick:L}),children:[v?s.jsx(ge,{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(ge,{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(ge,{tone:"error",text:k.message}):null,s.jsx(Yg,{alerts:b,loading:N,now:D})]})]})}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(B,{label:"Desired",value:a.desired}),s.jsx(B,{label:"Live",value:a.live}),s.jsx(B,{label:"Busy",value:a.busy}),s.jsx(B,{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(ge,{tone:"error",text:n.message}):null,e!=null&&e.error?s.jsx(ge,{tone:"error",text:e.error}):null,i?s.jsx(ge,{tone:"error",text:`Action failed: ${i}`}):null,l?s.jsx(ge,{tone:"error",text:`Resize failed: ${l}`}):null]})}function er({href:e,active:t,children:n,onNavigate:r}){return s.jsx("a",{className:K("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:M=>{M.defaultPrevented||M.button!==0||M.metaKey||M.ctrlKey||M.altKey||M.shiftKey||(M.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 M=window.prompt(`Cancel job #${e}? Optional reason:`);if(M!==null){w(!0);try{await l(e,M)}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(G,{text:"Loading selected job..."}):e!==null&&r?s.jsx(ge,{tone:"error",text:`Job #${e}: ${r.message}`}):s.jsx(G,{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)??{},[_,M]=R.useState("proposals"),j=a??_,q=L=>{M(L),d==null||d(L)},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(ge,{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(Te,{title:"Proposed",value:k.proposed??0,icon:s.jsx(Rl,{className:"h-5 w-5"})}),s.jsx(Te,{title:"Approved",value:k.approved??0,icon:s.jsx(Dn,{className:"h-5 w-5"})}),s.jsx(Te,{title:"Rules",value:k.rules??0,icon:s.jsx(Tl,{className:"h-5 w-5"})}),s.jsx(Te,{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:K("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:L=>c(L.target.value),children:[s.jsx("option",{value:"",children:"All repositories"}),((e==null?void 0:e.repositories)??[]).map(L=>s.jsx("option",{value:L,children:L},L))]})}),j==="proposals"?s.jsx(ot,{label:"Proposal status",children:s.jsxs("select",{className:"control",value:i,onChange:L=>u(L.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(L=>s.jsxs("button",{className:K("inline-flex h-8 items-center gap-1.5 rounded px-2.5 text-xs font-semibold",j===L.id?"bg-primary text-white":"text-muted hover:bg-slate-50 hover:text-foreground"),type:"button",role:"tab","aria-label":`${L.label} (${L.count})`,"aria-selected":j===L.id,onClick:()=>q(L.id),children:[s.jsx("span",{children:L.label}),s.jsx("span",{className:K("rounded-sm border px-1 font-mono text-[10px]",j===L.id?"border-white/40 text-white":"border-border text-muted"),children:L.count})]},L.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(G,{text:"Loading proposals..."}):e.length===0?s.jsx(G,{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(ge,{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(G,{text:"Loading curated rules..."}):e.length===0?s.jsx(G,{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(G,{text:"Loading captured events..."}):e.length===0?s.jsx(G,{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),[_,M]=R.useState(null),[j,q]=R.useState(null),[D,C]=R.useState(""),L=e??[],O=i.find(P=>P.login===w);R.useEffect(()=>{var P;r!=null&&r.is_admin&&(w&&i.some($=>$.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(/\/$/,""),J=`${I}/mcp`,z=`${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(ge,{tone:"error",text:n.message}):null,D?s.jsx(ge,{tone:"error",text:D}):null,s.jsx(dg,{dashboardUrl:J,endpointUrl:z,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:()=>q(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 $=m.trim();if($){b(!0),C("");try{const ee=await c($,r!=null&&r.is_admin?w:void 0);q(ee),p("")}catch(ee){C(ee instanceof Error?ee.message:String(ee))}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}),O?s.jsxs("span",{className:"font-normal text-muted",children:["Token will be linked to @",O.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:L,loading:t,now:l,ownerOptions:i,canManageOwners:!!(r!=null&&r.is_admin),revokingId:N,updatingOwnerId:_,onUpdateOwner:async(P,$)=>{M(P),C("");try{await u(P,$)}catch(ee){C(ee instanceof Error?ee.message:String(ee))}finally{M(null)}},onRevoke:async P=>{if(window.confirm("Revoke this MCP token?")){k(P),C("");try{await d(P)}catch($){C($ instanceof Error?$.message:String($))}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(pe,{value:u.created_at,relative:!0,now:n})}),s.jsx($,{label:"Last used",value:u.last_used_at?s.jsx(pe,{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(pe,{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(pe,{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(Ec,{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 Ec({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 Pc({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(pe,{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(Pl,{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(Pl,{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 Te({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(Eg,{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(pe,{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 Eg({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(pe,{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 Pg(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:Pg(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(pe,{value:e.created_at,compact:!0,relative:!0,now:i})}),s.jsx($,{label:"Started",value:e.started_at?s.jsx(pe,{value:e.started_at,compact:!0,relative:!0,now:i}):"n/a"}),s.jsx($,{label:"Updated",value:s.jsx(pe,{value:e.updated_at,compact:!0,relative:!0,now:i})}),s.jsx($,{label:"Finished",value:e.finished_at?s.jsx(pe,{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(pe,{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(pe,{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(pe,{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(ge,{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(G,{text:"Loading MCP tokens..."}):e.length===0?s.jsx(G,{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(B,{label:"Created",value:s.jsx(ue,{value:u.created_at,relative:!0,now:n})}),s.jsx(B,{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:K("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:K("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:K("text-muted",l==="compact"?"h-4 w-4":"h-5 w-5"),"aria-hidden":!0})}),s.jsx("span",{className:K("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:K("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:K("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:K("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:K("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:K("min-w-0 rounded-lg border border-border bg-panel p-4 shadow-sm",r),children:[s.jsxs("div",{className:K("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 Te({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:K("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(ge,{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(G,{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:K("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 M=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]),q=R.useCallback(async C=>{if(u){w(C);try{await u(C)}finally{w(null)}}},[u]),D=R.useCallback(async(C,L)=>{if(d){v(C);try{await d(C,L)}finally{v(null)}}},[d]);return t&&e.length===0?s.jsx(G,{text:"Loading jobs..."}):e.length===0?s.jsx(G,{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:q,canCancel:!!(d&&Js(C,l)),cancelling:y===C.id,onCancel:D},C.id)),s.jsx(Cg,{hasMore:r,loading:n,onLoadMore:M})]}),s.jsx(Xs,{noun:"jobs",hasMore:r,loading:n,onLoadMore:M,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:q,canCancel:!!(d&&Js(C,l)),cancelling:y===C.id,onCancel:D},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(B,{label:"Wait",value:Xe(Ni(e,n))}),s.jsx(B,{label:"Runtime",value:Xe(ki(e,n))}),s.jsx(B,{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:K("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:K(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:K("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:K(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:K("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:K(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:K("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:K("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:K("grid gap-2 text-sm sm:gap-3",a?"grid-cols-1":"grid-cols-3"),children:[s.jsx(B,{label:"Queue wait",value:Xe(m)}),s.jsx(B,{label:e.status==="running"?"Running for":"Runtime",value:Xe(h)}),s.jsx(B,{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:K("grid gap-2 text-sm sm:gap-3",a?"grid-cols-1":"grid-cols-3"),children:[s.jsx(B,{label:"Model",value:Eg(e.model_route)}),s.jsx(B,{label:"Reasoning",value:Rg(e.model_route)}),s.jsx(B,{label:"Route",value:Ig(e.model_route)})]}),s.jsx(Lg,{job:e,compact:a}),s.jsxs("div",{className:K("grid gap-2 text-sm sm:gap-3",a?"grid-cols-1":"grid-cols-2 xl:grid-cols-4"),children:[s.jsx(B,{label:"Created",value:s.jsx(ue,{value:e.created_at,compact:!0,relative:!0,now:i})}),s.jsx(B,{label:"Started",value:e.started_at?s.jsx(ue,{value:e.started_at,compact:!0,relative:!0,now:i}):"n/a"}),s.jsx(B,{label:"Updated",value:s.jsx(ue,{value:e.updated_at,compact:!0,relative:!0,now:i})}),s.jsx(B,{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(G,{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(B,{label:"Session ID",value:t.id}),s.jsx(B,{label:"Source",value:t.source})]}),s.jsx("p",{className:"break-words text-xs text-muted [overflow-wrap:anywhere]",children:t.detail})]}):s.jsx(G,{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(G,{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(G,{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:K("grid gap-2 text-sm sm:gap-3",t?"grid-cols-1":"grid-cols-2 xl:grid-cols-4"),children:[s.jsx(B,{label:"Mode",value:s.jsx(Si,{intent:e.intent,actionMode:e.action_mode})}),s.jsx(B,{label:"Intent",value:e.intent}),s.jsx(B,{label:"Addressed",value:n?Jo(r.addressed_to_agent):"n/a"}),s.jsx(B,{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:K("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(G,{text:"Loading runtime and job history..."}):l.length===0?s.jsx(G,{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:K("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:K("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(G,{text:"Loading runtime by user..."}):a.length===0?s.jsx(G,{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:K("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(G,{text:"Loading runtime by repository..."}):a.length===0?s.jsx(G,{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(G,{text:"Loading systemd units..."});if(!e)return s.jsx(G,{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(ge,{tone:"error",text:e.errors[0]}):null,n.length===0?s.jsx(G,{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:K("min-w-0 rounded-md border bg-white px-3 py-2",n==="bad"?"border-red-200":"border-border"),children:[s.jsx("div",{className:K("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:K("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(ge,{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(G,{text:"Loading process activity..."});if(!e)return s.jsx(G,{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:K("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(ge,{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(G,{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(G,{text:"No child process detected for the executor."})]})]})]})}function Yg({alerts:e,loading:t,now:n}){if(t&&!e)return s.jsx(G,{text:"Loading monitor alerts..."});const r=e??[];return r.length===0?s.jsx(G,{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 B({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:K("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:K("h-2.5 w-2.5 rounded-full",t.dot,n&&"animate-live-pulse"),"aria-hidden":!0}),e]})}function G({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 ge({tone:e,text:t}){return s.jsx("div",{className:K("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:K("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:K(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/index.html b/src/github_agent_bridge/dashboard_static/index.html index 9536004..052120c 100644 --- a/src/github_agent_bridge/dashboard_static/index.html +++ b/src/github_agent_bridge/dashboard_static/index.html @@ -4,7 +4,7 @@ GitHub Agent Bridge Dashboard - + diff --git a/src/github_agent_bridge/persistence/webhooks.py b/src/github_agent_bridge/persistence/webhooks.py index 0aa85ab..a969b78 100644 --- a/src/github_agent_bridge/persistence/webhooks.py +++ b/src/github_agent_bridge/persistence/webhooks.py @@ -56,6 +56,27 @@ def _actionable_ingest_predicate(receipt_alias: str, job_alias: str) -> str: ) +def _repository_scope_predicate( + expression: str, + repositories: set[str] | None, + *, + included: bool = True, +) -> tuple[str, tuple[str, ...]]: + if repositories is None: + return "", () + normalized = tuple( + sorted(repo.strip().lower() for repo in repositories if repo.strip()) + ) + if not normalized: + return (" AND 0", ()) if included else ("", ()) + placeholders = ",".join("?" for _ in normalized) + operator = "IN" if included else "NOT IN" + return ( + f" AND LOWER(COALESCE({expression},'')) {operator} ({placeholders})", + normalized, + ) + + @dataclass(frozen=True) class WebhookReceipt: delivery_id: str @@ -198,7 +219,24 @@ def observation_started_at(self) -> str | None: else None ) - def summary(self, window_start: str, window_end: str) -> dict[str, Any]: + def summary( + self, + window_start: str, + window_end: str, + repositories: set[str] | None = None, + ) -> dict[str, Any]: + email_scope, email_scope_args = _repository_scope_predicate( + "i.repository,j.repo", repositories + ) + webhook_scope, webhook_scope_args = _repository_scope_predicate( + "w.repository", repositories + ) + split_email_scope, split_email_scope_args = _repository_scope_predicate( + "e.repository,ej.repo", repositories + ) + split_webhook_scope, split_webhook_scope_args = _repository_scope_predicate( + "w.repository,wj.repo", repositories + ) with self.database.read("webhooks.summary") as con: receipt = con.execute( "SELECT COALESCE(SUM(CASE WHEN status='observed' THEN 1 ELSE 0 END),0) observed," @@ -214,6 +252,7 @@ def summary(self, window_start: str, window_end: str) -> dict[str, Any]: " WHERE i.source='email' AND i.event_key IS NOT NULL" " AND julianday(i.created_at)>=julianday(?) AND julianday(i.created_at)<=julianday(?)" f" AND {_actionable_ingest_predicate('i', 'j')}" + f"{email_scope}" " GROUP BY i.event_key" "), webhook_events AS (" " SELECT w.event_key,MIN(w.created_at) created_at," @@ -227,6 +266,7 @@ def summary(self, window_start: str, window_end: str) -> dict[str, Any]: " WHERE w.event_key IS NOT NULL" " AND julianday(w.created_at)>=julianday(?) AND julianday(w.created_at)<=julianday(?)" f" AND {_actionable_ingest_predicate('wi', 'j')}" + f"{webhook_scope}" " GROUP BY w.event_key" "), decision_traces AS (" " SELECT e.event_key," @@ -263,6 +303,8 @@ def summary(self, window_start: str, window_end: str) -> dict[str, Any]: f" AND {_actionable_ingest_predicate('w', 'wj')}" " AND julianday(e.created_at)>=julianday(?) AND julianday(e.created_at)<=julianday(?)" " AND julianday(w.created_at)>=julianday(?) AND julianday(w.created_at)<=julianday(?)" + f"{split_email_scope}" + f"{split_webhook_scope}" " AND ABS((julianday(w.created_at)-julianday(e.created_at))*86400.0)<=?" " GROUP BY e.event_key,w.event_key" ") SELECT" @@ -277,8 +319,10 @@ def summary(self, window_start: str, window_end: str) -> dict[str, Any]: ( window_start, window_end, + *email_scope_args, window_start, window_end, + *webhook_scope_args, window_start, window_end, window_start, @@ -287,6 +331,8 @@ def summary(self, window_start: str, window_end: str) -> dict[str, Any]: window_end, window_start, window_end, + *split_email_scope_args, + *split_webhook_scope_args, SPLIT_IDENTITY_MAX_DELAY_SECONDS, ), ).fetchone() @@ -318,9 +364,77 @@ def summary(self, window_start: str, window_end: str) -> dict[str, Any]: "enqueue": enqueue, } + def outside_scope_counts( + self, + window_start: str, + window_end: str, + repositories: set[str] | None, + ) -> dict[str, int]: + if repositories is None: + return {"imap_events": 0, "webhook_events": 0} + email_scope, email_scope_args = _repository_scope_predicate( + "i.repository,j.repo", repositories, included=False + ) + webhook_scope, webhook_scope_args = _repository_scope_predicate( + "w.repository", repositories, included=False + ) + with self.database.read("webhooks.outside_scope_counts") as con: + row = con.execute( + "WITH email_events AS (" + " SELECT i.event_key FROM ingest_receipts i" + " LEFT JOIN jobs j ON j.id=i.job_id" + " WHERE i.source='email' AND i.event_key IS NOT NULL" + " AND julianday(i.created_at)>=julianday(?) AND julianday(i.created_at)<=julianday(?)" + f" AND {_actionable_ingest_predicate('i', 'j')}" + f"{email_scope}" + " GROUP BY i.event_key" + "), webhook_events AS (" + " SELECT w.event_key FROM webhook_shadow_receipts w INDEXED BY idx_webhook_shadow_coverage" + " JOIN ingest_receipts wi ON wi.source='webhook' AND wi.source_key=w.delivery_id" + " LEFT JOIN jobs j ON j.id=COALESCE(w.job_id,wi.job_id)" + " WHERE w.event_key IS NOT NULL" + " AND julianday(w.created_at)>=julianday(?) AND julianday(w.created_at)<=julianday(?)" + f" AND {_actionable_ingest_predicate('wi', 'j')}" + f"{webhook_scope}" + " GROUP BY w.event_key" + ") SELECT (SELECT COUNT(*) FROM email_events) imap_events," + " (SELECT COUNT(*) FROM webhook_events) webhook_events", + ( + window_start, + window_end, + *email_scope_args, + window_start, + window_end, + *webhook_scope_args, + ), + ).fetchone() + return { + "imap_events": int(row["imap_events"]), + "webhook_events": int(row["webhook_events"]), + } + def exceptions( - self, window_start: str, window_end: str, limit: int + self, + window_start: str, + window_end: str, + limit: int, + repositories: set[str] | None = None, ) -> list[dict[str, Any]]: + email_scope, email_scope_args = _repository_scope_predicate( + "i.repository,j.repo", repositories + ) + webhook_scope, webhook_scope_args = _repository_scope_predicate( + "w.repository", repositories + ) + split_email_scope, split_email_scope_args = _repository_scope_predicate( + "e.repository,ej.repo", repositories + ) + split_webhook_scope, split_webhook_scope_args = _repository_scope_predicate( + "w.repository,wj.repo", repositories + ) + unmatchable_scope, unmatchable_scope_args = _repository_scope_predicate( + "w.repository", repositories + ) with self.database.read("webhooks.exceptions") as con: rows = con.execute( "WITH email_events AS MATERIALIZED (" @@ -332,6 +446,7 @@ def exceptions( " WHERE i.source='email' AND i.event_key IS NOT NULL" " AND julianday(i.created_at)>=julianday(?) AND julianday(i.created_at)<=julianday(?)" f" AND {_actionable_ingest_predicate('i', 'j')}" + f"{email_scope}" " GROUP BY i.event_key" "), webhook_events AS MATERIALIZED (" " SELECT w.event_key,MIN(w.delivery_id) reference,MIN(w.created_at) created_at," @@ -343,6 +458,7 @@ def exceptions( " WHERE w.event_key IS NOT NULL" " AND julianday(w.created_at)>=julianday(?) AND julianday(w.created_at)<=julianday(?)" f" AND {_actionable_ingest_predicate('wi', 'j')}" + f"{webhook_scope}" " GROUP BY w.event_key" "), decision_traces AS (" " SELECT e.event_key,MIN(e.source_key) reference," @@ -394,6 +510,8 @@ def exceptions( f" AND {_actionable_ingest_predicate('w', 'wj')}" " AND julianday(e.created_at)>=julianday(?) AND julianday(e.created_at)<=julianday(?)" " AND julianday(w.created_at)>=julianday(?) AND julianday(w.created_at)<=julianday(?)" + f"{split_email_scope}" + f"{split_webhook_scope}" " AND ABS((julianday(w.created_at)-julianday(e.created_at))*86400.0)<=?" " GROUP BY e.event_key,w.event_key" "), candidates AS (" @@ -409,6 +527,7 @@ def exceptions( " w.repository,w.event_name,w.action" " FROM webhook_shadow_receipts w INDEXED BY idx_webhook_shadow_coverage WHERE w.event_key IS NULL" " AND julianday(w.created_at)>=julianday(?) AND julianday(w.created_at)<=julianday(?)" + f"{unmatchable_scope}" " UNION ALL SELECT 'decision_mismatch',event_key,NULL,reference," " related_reference,created_at,repository,event_type,event_action" " FROM decision_traces WHERE mismatch=1 UNION ALL " @@ -424,8 +543,10 @@ def exceptions( ( window_start, window_end, + *email_scope_args, window_start, window_end, + *webhook_scope_args, window_start, window_end, window_start, @@ -434,9 +555,12 @@ def exceptions( window_end, window_start, window_end, + *split_email_scope_args, + *split_webhook_scope_args, SPLIT_IDENTITY_MAX_DELAY_SECONDS, window_start, window_end, + *unmatchable_scope_args, limit, ), ).fetchall() diff --git a/systemd/env.example b/systemd/env.example index b2d0f07..23f63a2 100644 --- a/systemd/env.example +++ b/systemd/env.example @@ -116,3 +116,6 @@ GITHUB_AGENT_BRIDGE_WEBHOOK_PRIMARY_ACK= GITHUB_AGENT_BRIDGE_WEBHOOK_COVERAGE_GRACE_SECONDS=600 # Require this many complete days before the promotion gate can become ready. GITHUB_AGENT_BRIDGE_WEBHOOK_PROMOTION_OBSERVATION_DAYS=7 +# Set this to the UTC deployment instant that starts a clean validation epoch. +# Changing it resets the promotion window without deleting retained evidence. +GITHUB_AGENT_BRIDGE_WEBHOOK_OBSERVATION_STARTED_AT= diff --git a/tests/test_webhook.py b/tests/test_webhook.py index 6a16e49..10fbf4f 100644 --- a/tests/test_webhook.py +++ b/tests/test_webhook.py @@ -2538,3 +2538,111 @@ def test_submitted_review_uses_same_canonical_key_as_email_ingestion(tmp_path): ) assert response.json()["event_key"] == "pull_request_review:created:gisce/github-agent-bridge:1234" + + +def test_webhook_promotion_gate_is_scoped_to_canary_repositories(tmp_path): + db = tmp_path / "bridge.sqlite3" + JobQueue(db) + policy_path = tmp_path / "policy.json" + policy_path.write_text(json.dumps({ + "trustedOrgs": ["gisce"], + "webhookCanaryRepos": ["gisce/in-scope"], + })) + observation_start = (datetime.now(UTC) - timedelta(days=2)).replace( + microsecond=0 + ).isoformat().replace("+00:00", "Z") + observed_at = (datetime.now(UTC) - timedelta(hours=1)).isoformat() + rows = [ + ("in", "gisce/in-scope"), + ("out", "gisce/out-of-scope"), + ] + with sqlite3.connect(db) as con: + con.executemany( + "INSERT INTO webhook_shadow_receipts(" + "delivery_id,event_name,action,event_key,repository,payload_hash," + "payload_json,status,created_at) VALUES(?,?,?,?,?,?,?,?,?)", + [ + ( + f"delivery-{label}", "issue_comment", "created", + f"issue_comment:created:{repository}:1", repository, + f"hash-{label}", "{}", "observed", observed_at, + ) + for label, repository in rows + ], + ) + con.executemany( + "INSERT INTO ingest_receipts(" + "source,source_key,payload_hash,event_key,repository,work_key," + "event_type,event_action,bridge_action,decision,work_intent," + "status,created_at,updated_at) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?)", + [ + ( + source, + f"delivery-{label}" if source == "webhook" else f"email-{label}", + f"{source}-{label}", + f"issue_comment:created:{repository}:1", + repository, + f"{repository}#1", + "issue_comment", + "created", + "reply_comment", + "auto_trusted", + "work_allowed", + "duplicate" if source == "webhook" else "accepted", + observed_at, + observed_at, + ) + for label, repository in rows + for source in ("email", "webhook") + ], + ) + client = TestClient(create_app(DashboardConfig( + db=db, + require_auth=False, + webhook_secrets=(SECRET,), + webhook_mode="canary", + webhook_policy=policy_path, + webhook_promotion_observation_days=1, + webhook_coverage_grace_seconds=0, + webhook_observation_started_at=observation_start, + ))) + + summary = client.get("/api/webhooks/github/summary").json()["coverage"] + exceptions = client.get("/api/webhooks/github/exceptions").json() + + assert summary["scope_repositories"] == ["gisce/in-scope"] + assert summary["both"] == 1 + assert summary["imap_only"] == 0 + assert summary["webhook_only"] == 0 + assert summary["outside_scope_imap_eligible"] == 1 + assert summary["outside_scope_webhook_eligible"] == 1 + assert summary["promotion_state"] == "ready" + assert exceptions["scope_repositories"] == ["gisce/in-scope"] + assert exceptions["exceptions"] == [] + + +def test_explicit_webhook_observation_start_resets_promotion_window(tmp_path): + db = tmp_path / "bridge.sqlite3" + queue = JobQueue(db) + queue.set_state( + "webhook_observation_started_at", + (datetime.now(UTC) - timedelta(days=30)).isoformat(), + ) + observation_start = (datetime.now(UTC) - timedelta(hours=1)).replace( + microsecond=0 + ).isoformat().replace("+00:00", "Z") + client = TestClient(create_app(DashboardConfig( + db=db, + require_auth=False, + webhook_secrets=(SECRET,), + webhook_promotion_observation_days=1, + webhook_coverage_grace_seconds=0, + webhook_observation_started_at=observation_start, + ))) + + coverage = client.get("/api/webhooks/github/summary").json()["coverage"] + + assert coverage["observation_started_at"] == observation_start + assert coverage["window_start"] == observation_start + assert coverage["observation_complete"] is False + assert coverage["promotion_state"] == "insufficient_data" From c3cbda0a28c78c28f236c15723d5d001b83d488b Mon Sep 17 00:00:00 2001 From: GISCE Bot Date: Mon, 2 Nov 2026 11:52:56 +0100 Subject: [PATCH 2/2] fix: use primary eligibility scope for promotion gate Resolve promotion coverage and exceptions from the active webhook mode so primary observation cannot ignore repositories outside the former canary.\n\nCo-authored-by: ecarreras --- dashboard/src/main.test.tsx | 8 +- dashboard/src/main.tsx | 7 +- docs/ingestion.md | 13 +- docs/shadow-canary.md | 4 + src/github_agent_bridge/backend.py | 5 +- .../{index-HMx7WSp8.js => index-m6C2vT6T.js} | 20 +-- .../dashboard_static/index.html | 2 +- tests/test_webhook.py | 123 ++++++++++++++++++ 8 files changed, 164 insertions(+), 18 deletions(-) rename src/github_agent_bridge/dashboard_static/assets/{index-HMx7WSp8.js => index-m6C2vT6T.js} (58%) diff --git a/dashboard/src/main.test.tsx b/dashboard/src/main.test.tsx index eed4d66..504e8f6 100644 --- a/dashboard/src/main.test.tsx +++ b/dashboard/src/main.test.tsx @@ -251,10 +251,16 @@ describe("dashboard routing and API query helpers", () => { expect(screen.getByText("Incomplete decision traces")).toBeInTheDocument(); expect(screen.getByText("Split identities")).toBeInTheDocument(); expect(screen.getByText("Outside scope IMAP")).toBeInTheDocument(); - expect(screen.getByText(/Promotion scope: 1 configured repositories/)).toBeInTheDocument(); + expect(screen.getByText(/Shadow rollout cohort: 1 configured repositories/)).toBeInTheDocument(); expect(screen.getByText("blocked")).toBeInTheDocument(); }); + it("labels the primary promotion scope as global eligibility", () => { + render(); + + expect(screen.getByText(/Primary eligibility scope: all repositories/)).toBeInTheDocument(); + }); + it("navigates webhook hook inventory and delivery details", async () => { const user = userEvent.setup(); const onSectionChange = vi.fn(); diff --git a/dashboard/src/main.tsx b/dashboard/src/main.tsx index 99b9cee..35463ca 100644 --- a/dashboard/src/main.tsx +++ b/dashboard/src/main.tsx @@ -2098,6 +2098,11 @@ function WebhookPage({ const promotionState = summary?.coverage?.promotion_state ?? (summary?.coverage?.promotion_ready ? "ready" : "blocked"); const promotionLabel = promotionState === "insufficient_data" ? "insufficient data" : promotionState; + const promotionScopeLabel = summary?.mode === "primary" + ? "Primary eligibility scope" + : summary?.mode === "canary" + ? "Canary rollout cohort" + : "Shadow rollout cohort"; const sections = [ { id: "overview" as const, label: "Overview" }, { id: "hooks" as const, label: "Hooks", count: summary?.totals?.hooks }, @@ -2136,7 +2141,7 @@ function WebhookPage({ - {summary?.coverage?.window_start && summary.coverage.window_end ?

Actionable IMAP events and comparable webhook events from to ; {summary.coverage.observation_days ?? 7} observation days required and newest {summary.coverage.grace_seconds ?? 0}s excluded. Promotion scope: {summary.coverage.scope_repositories == null ? "all repositories" : `${summary.coverage.scope_repositories.length} configured repositories`}{summary.coverage.observation_started_at ? <>; observation epoch : null}.

: null} + {summary?.coverage?.window_start && summary.coverage.window_end ?

Actionable IMAP events and comparable webhook events from to ; {summary.coverage.observation_days ?? 7} observation days required and newest {summary.coverage.grace_seconds ?? 0}s excluded. {promotionScopeLabel}: {summary.coverage.scope_repositories == null ? "all repositories" : `${summary.coverage.scope_repositories.length} configured repositories`}{summary.coverage.observation_started_at ? <>; observation epoch : null}.

: null}
{Object.keys(summary?.enqueue ?? {}).length ?
{Object.entries(summary?.enqueue ?? {}).sort(([left], [right]) => left.localeCompare(right)).map(([state, count]) => )}
: null} diff --git a/docs/ingestion.md b/docs/ingestion.md index 77a807c..0fd56b1 100644 --- a/docs/ingestion.md +++ b/docs/ingestion.md @@ -261,9 +261,12 @@ plus its grace period or the gate remains `insufficient_data`. When corrected code or configuration starts a new rollout epoch, set `GITHUB_AGENT_BRIDGE_WEBHOOK_OBSERVATION_STARTED_AT` to that deployment's ISO-8601 UTC timestamp. The gate then ignores earlier evidence and remains -`insufficient_data` until a complete new window has elapsed. In canary mode, -coverage and exceptions are limited to `webhookCanaryRepos`; actionable events -outside that scope are reported separately and cannot block the canary gate. +`insufficient_data` until a complete new window has elapsed. In shadow and +canary modes, coverage and exceptions are limited to the intended rollout +cohort in `webhookCanaryRepos`; actionable events outside that scope are +reported separately and cannot block the cohort gate. In primary mode, the +same queries use the global `enabledRepos` scope. An empty `enabledRepos` is +unrestricted, so primary coverage and exceptions include every repository. Every durable ingestion receipt also records the normalized repository, work key, event descriptor, bridge action, policy decision and work intent. The @@ -294,7 +297,9 @@ both `GITHUB_AGENT_BRIDGE_WEBHOOK_MODE=primary` and operator acknowledgement; `primary` fails closed without both it and `GITHUB_AGENT_BRIDGE_WEBHOOK_POLICY`. The configured policy remains authoritative for trust, action, routing and the global `enabledRepos` guardrail. Primary mode -does not use the narrower `webhookCanaryRepos` allowlist. +does not use the narrower `webhookCanaryRepos` allowlist. Its second observation +window and exception queue cover `enabledRepos`, or all repositories when that +global allowlist is empty. Primary changes which source is expected to win, not the idempotency model. Keep the IMAP reader enabled during the stable fallback phase. If webhook diff --git a/docs/shadow-canary.md b/docs/shadow-canary.md index 16f22c4..7df71cf 100644 --- a/docs/shadow-canary.md +++ b/docs/shadow-canary.md @@ -91,6 +91,7 @@ Set `GITHUB_AGENT_BRIDGE_WEBHOOK_OBSERVATION_STARTED_AT` to the ISO-8601 UTC deployment instant for the code and configuration being validated. Promotion metrics and exceptions use only `webhookCanaryRepos`; out-of-scope actionable events remain visible as separate counters but do not block this cohort. +Shadow mode uses the same intended rollout cohort for observational coverage. Inspect webhook summary, exceptions and deliveries in the administrator dashboard. Do not widen the canary while there are unexplained actionable @@ -119,6 +120,9 @@ GITHUB_AGENT_BRIDGE_WEBHOOK_PRIMARY_ACK=true `primary` fails closed without the explicit acknowledgement and policy path. It stops applying the narrower `webhookCanaryRepos` list, but the global `enabledRepos`, trust, action and routing policy still apply. +Promotion metrics and exceptions therefore cover `enabledRepos` during this +second window. If `enabledRepos` is empty, policy semantics are unrestricted +and the gate covers every repository. Keep the IMAP reader active during a second stable observation window. Primary changes which source is expected to win; it does not remove the idempotency or diff --git a/src/github_agent_bridge/backend.py b/src/github_agent_bridge/backend.py index 11b6108..a051dcd 100644 --- a/src/github_agent_bridge/backend.py +++ b/src/github_agent_bridge/backend.py @@ -160,7 +160,10 @@ def _webhook_coverage_window( def _webhook_promotion_scope(config: DashboardConfig) -> set[str] | None: if config.webhook_policy is None: return None - return Policy.from_file(config.webhook_policy).webhook_canary_repos + policy = Policy.from_file(config.webhook_policy) + if config.webhook_mode == "primary": + return policy.enabled_repos or None + return policy.webhook_canary_repos def _encode_webhook_delivery_cursor(created_at: str, delivery_id: str) -> str: diff --git a/src/github_agent_bridge/dashboard_static/assets/index-HMx7WSp8.js b/src/github_agent_bridge/dashboard_static/assets/index-m6C2vT6T.js similarity index 58% rename from src/github_agent_bridge/dashboard_static/assets/index-HMx7WSp8.js rename to src/github_agent_bridge/dashboard_static/assets/index-m6C2vT6T.js index 2607afa..b1fac38 100644 --- a/src/github_agent_bridge/dashboard_static/assets/index-HMx7WSp8.js +++ b/src/github_agent_bridge/dashboard_static/assets/index-m6C2vT6T.js @@ -1,4 +1,4 @@ -var Ha=e=>{throw TypeError(e)};var Jr=(e,t,n)=>t.has(e)||Ha("Cannot "+n);var g=(e,t,n)=>(Jr(e,t,"read from private field"),n?n.call(e):t.get(e)),U=(e,t,n)=>t.has(e)?Ha("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),F=(e,t,n,r)=>(Jr(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),ne=(e,t,n)=>(Jr(e,t,"access private method"),n);var kr=(e,t,n,r)=>({set _(i){F(e,t,i,n)},get _(){return g(e,t,r)}});import{j as iu,k as au,i as Zs,r as _e,R,g as ln,a as ei,C as Ln,X as Mn,Y as sn,T as cn,L as Ur,B as Bt,c as ou,d as ti,f as lu,P as cu,b as uu,h as du,e as dl}from"./charts-DntrVYl4.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const a of i)if(a.type==="childList")for(const o of a.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?a.credentials="include":i.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(i){if(i.ep)return;i.ep=!0;const a=n(i);fetch(i.href,a)}})();var Xr={exports:{}},Wn={};/** +var Ha=e=>{throw TypeError(e)};var Jr=(e,t,n)=>t.has(e)||Ha("Cannot "+n);var g=(e,t,n)=>(Jr(e,t,"read from private field"),n?n.call(e):t.get(e)),H=(e,t,n)=>t.has(e)?Ha("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),z=(e,t,n,r)=>(Jr(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),ne=(e,t,n)=>(Jr(e,t,"access private method"),n);var kr=(e,t,n,r)=>({set _(i){z(e,t,i,n)},get _(){return g(e,t,r)}});import{j as iu,k as au,i as Zs,r as Ce,R,g as ln,a as ei,C as Ln,X as Mn,Y as sn,T as cn,L as Ur,B as Bt,c as ou,d as ti,f as lu,P as cu,b as uu,h as du,e as dl}from"./charts-DntrVYl4.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const a of i)if(a.type==="childList")for(const o of a.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?a.credentials="include":i.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(i){if(i.ep)return;i.ep=!0;const a=n(i);fetch(i.href,a)}})();var Xr={exports:{}},Wn={};/** * @license React * react-jsx-runtime.production.min.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();U(this,Vt);U(this,At);U(this,wn);F(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),F(this,At,void 0))}setEventListener(t){var n;F(this,wn,t),(n=g(this,At))==null||n.call(this),F(this,At,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){g(this,Vt)!==t&&(F(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(){U(this,Lt,bu);U(this,Ys,!1)}setTimeoutProvider(e){F(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 Se=Eu(),vn,Mt,jn,rl,Ru=(rl=class extends gr{constructor(){super();U(this,vn,!0);U(this,Mt);U(this,jn);F(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),F(this,Mt,void 0))}setEventListener(t){var n;F(this,jn,t),(n=g(this,Mt))==null||n.call(this),F(this,Mt,t(this.setOnline.bind(this)))}setOnline(t){g(this,vn)!==t&&(F(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,M=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(){U(this,Gt)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),ys(this.gcTime)&&F(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)),F(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,_,M)=>{if(y)return Promise.reject(t.signal.reason);if(_==null&&k.pages.length)return Promise.resolve(k);const q=(()=>{const O={client:t.client,queryKey:t.queryKey,pageParam:_,direction:M?"backward":"forward",meta:t.options.meta};return v(O),O})(),D=await b(q),{maxPages:C}=t.options,L=M?_u:Su;return{pages:L(k.pages,D,C),pageParams:L(k.pageParams,_,C)}};if(i&&a.length){const k=i==="backward",_=k?yl:Ss,M={pages:a,pageParams:o},j=_(r,M);l=await N(M,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,Ne,hr,Yt,Ve,wl,Nt,il,Mu=(il=class extends bl{constructor(t){super();U(this,Ve);U(this,kn);U(this,Jt);U(this,Nn);U(this,Ze);U(this,Xt);U(this,Ne);U(this,hr);U(this,Yt);F(this,Yt,!1),F(this,hr,t.defaultOptions),this.setOptions(t.options),this.observers=[],F(this,Xt,t.client),F(this,Ze,g(this,Xt).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,F(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,Ne))==null?void 0:t.promise}setOptions(t){if(this.options={...g(this,hr),...t},t!=null&&t._type&&F(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)),F(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,Ne))==null?void 0:r.promise;return(i=g(this,Ne))==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,Ne))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=g(this,Ne))==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,Ne)&&(g(this,Yt)||ne(this,Ve,wl).call(this)?g(this,Ne).cancel({revert:!0}):g(this,Ne).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,Ne))==null?void 0:u.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(g(this,Ne))return g(this,Ne).continueRetry(),g(this,Ne).promise}if(t&&this.setOptions(t),!this.options.queryFn){const _=this.observers.find(M=>M.options.queryFn);_&&this.setOptions(_.options)}const r=new AbortController,i=_=>{Object.defineProperty(_,"signal",{enumerable:!0,get:()=>(F(this,Yt,!0),r.signal)})},a=()=>{const _=ml(this.options,n),j=(()=>{const q={client:g(this,Xt),queryKey:this.queryKey,meta:this.meta};return i(q),q})();return F(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),F(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}),F(this,Ne,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:(_,M)=>{ne(this,Ve,Nt).call(this,{type:"failed",failureCount:_,error:M})},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,Ne).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,Ne).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,Ne=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 F(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),Se.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,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();U(this,ae);U(this,qe);U(this,re);U(this,pr);U(this,Oe);U(this,Zt);U(this,Sn);U(this,St);U(this,Ot);U(this,mr);U(this,_n);U(this,Cn);U(this,en);U(this,tn);U(this,Dt);U(this,Pn,new Set);this.options=n,F(this,qe,t),F(this,Ot,null),F(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)&&(F(this,Oe,r),F(this,Sn,this.options),F(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 L=this.hasListeners(),O=!L&&eo(t,n),I=L&&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 L;a!=null&&a.isPlaceholderData&&n.placeholderData===(l==null?void 0:l.placeholderData)?(L=a.data,b=!0):L=typeof n.placeholderData=="function"?n.placeholderData((C=g(this,Cn))==null?void 0:C.state.data,g(this,Cn)):n.placeholderData,L!==void 0&&(v="success",p=js(a==null?void 0:a.data,L,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{F(this,mr,n.select),p=n.select(p),p=js(a==null?void 0:a.data,p,n),F(this,_n,p),F(this,Ot,null)}catch(L){F(this,Ot,L)}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",M=k&&N,j=p!==void 0,D={status:v,fetchStatus:h.fetchStatus,isPending:k,isSuccess:v==="success",isError:_,isInitialLoading:M,isLoading:M,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 L=D.data!==void 0,O=D.status==="error"&&!L,I=P=>{O?P.reject(D.error):L&&P.resolve(D.data)},J=()=>{const P=F(this,St,D.promise=ks());I(P)},z=g(this,St);switch(z.status){case"pending":t.queryHash===r.queryHash&&I(z);break;case"fulfilled":(O||D.data!==z.value)&&J();break;case"rejected":(!O||D.error!==z.reason)&&J();break}}return D}updateResult(){const t=g(this,Oe),n=this.createResult(g(this,re),this.options);if(F(this,Zt,g(this,re).state),F(this,Sn,this.options),g(this,Zt).data!==void 0&&F(this,Cn,g(this,re)),ws(n,t))return;F(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,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,Oe).isStale||!ys(t))return;const r=hl(g(this,Oe).dataUpdatedAt,t)+1;F(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),F(this,Dt,t),!(lr.isServer()||Ge(this.options.enabled,g(this,re))===!1||!ys(g(this,Dt))||g(this,Dt)===0)&&F(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)),F(this,en,void 0))},Is=function(){g(this,tn)!==void 0&&(Wt.clearInterval(g(this,tn)),F(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);F(this,re,t),F(this,pr,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},kl=function(t){Se.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(g(this,Oe))}),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,Ie,nn,ft,Tt,ol,zu=(ol=class extends bl{constructor(t){super();U(this,ft);U(this,fr);U(this,mt);U(this,Ie);U(this,nn);F(this,fr,t.client),this.mutationId=t.mutationId,F(this,Ie,t.mutationCache),F(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,Ie).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){F(this,mt,g(this,mt).filter(n=>n!==t)),this.scheduleGc(),g(this,Ie).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){g(this,mt).length||(this.state.status==="pending"?this.scheduleGc():g(this,Ie).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,_,M,j,q;const n=()=>{ne(this,ft,Tt).call(this,{type:"continue"})},r={client:g(this,fr),meta:this.options.meta,mutationKey:this.options.mutationKey};F(this,nn,gl({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(D,C)=>{ne(this,ft,Tt).call(this,{type:"failed",failureCount:D,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,Ie).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,Ie).config.onMutate&&await g(this,Ie).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 D=await g(this,nn).start();return await((u=(c=g(this,Ie).config).onSuccess)==null?void 0:u.call(c,D,t,this.state.context,this,r)),await((h=(d=this.options).onSuccess)==null?void 0:h.call(d,D,t,this.state.context,r)),await((p=(m=g(this,Ie).config).onSettled)==null?void 0:p.call(m,D,null,this.state.variables,this.state.context,this,r)),await((y=(w=this.options).onSettled)==null?void 0:y.call(w,D,null,t,this.state.context,r)),ne(this,ft,Tt).call(this,{type:"success",data:D}),D}catch(D){try{await((b=(v=g(this,Ie).config).onError)==null?void 0:b.call(v,D,t,this.state.context,this,r))}catch(C){Promise.reject(C)}try{await((k=(N=this.options).onError)==null?void 0:k.call(N,D,t,this.state.context,r))}catch(C){Promise.reject(C)}try{await((M=(_=g(this,Ie).config).onSettled)==null?void 0:M.call(_,void 0,D,this.state.variables,this.state.context,this,r))}catch(C){Promise.reject(C)}try{await((q=(j=this.options).onSettled)==null?void 0:q.call(j,void 0,D,t,this.state.context,r))}catch(C){Promise.reject(C)}throw ne(this,ft,Tt).call(this,{type:"error",error:D}),D}finally{g(this,Ie).runNext(this)}}},fr=new WeakMap,mt=new WeakMap,Ie=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),Se.batch(()=>{g(this,mt).forEach(r=>{r.onMutationUpdate(t)}),g(this,Ie).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();U(this,_t);U(this,at);U(this,xr);this.config=t,F(this,_t,new Set),F(this,at,new Map),F(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(){Se.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){Se.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return Se.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();U(this,xt);this.config=t,F(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(){Se.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){Se.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){Se.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Se.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},xt=new WeakMap,cl),ye,Ft,zt,En,Rn,qt,In,Tn,ul,Uu=(ul=class{constructor(e={}){U(this,ye);U(this,Ft);U(this,zt);U(this,En);U(this,Rn);U(this,qt);U(this,In);U(this,Tn);F(this,ye,e.queryCache||new $u),F(this,Ft,e.mutationCache||new Bu),F(this,zt,e.defaultOptions||{}),F(this,En,new Map),F(this,Rn,new Map),F(this,qt,0)}mount(){kr(this,qt)._++,g(this,qt)===1&&(F(this,In,ni.subscribe(async e=>{e&&(await this.resumePausedMutations(),g(this,ye).onFocus())})),F(this,Tn,Mr.subscribe(async e=>{e&&(await this.resumePausedMutations(),g(this,ye).onOnline())})))}unmount(){var e,t;kr(this,qt)._--,g(this,qt)===0&&((e=g(this,In))==null||e.call(this),F(this,In,void 0),(t=g(this,Tn))==null||t.call(this),F(this,Tn,void 0))}isFetching(e){return g(this,ye).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,ye).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=g(this,ye).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,ye).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,ye).get(r.queryHash),a=i==null?void 0:i.state.data,o=ju(t,a);if(o!==void 0)return g(this,ye).build(this,r).setData(o,{...n,manual:!0})}setQueriesData(e,t,n){return Se.batch(()=>g(this,ye).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,ye).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=g(this,ye);Se.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=g(this,ye);return Se.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=Se.batch(()=>g(this,ye).findAll(e).map(i=>i.cancel(n)));return Promise.all(r).then(Be).catch(Be)}invalidateQueries(e,t={}){return Se.batch(()=>(g(this,ye).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=Se.batch(()=>g(this,ye).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,ye).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,ye)}getMutationCache(){return g(this,Ft)}getDefaultOptions(){return g(this,zt)}setDefaultOptions(e){F(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,ye).clear(),g(this,Ft).clear()}},ye=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=_e.createContext(void 0),Sl=e=>{const t=_e.useContext(Nl);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Hu=({client:e,children:t})=>(_e.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),s.jsx(Nl.Provider,{value:e,children:t})),_l=_e.createContext(!1),Ku=()=>_e.useContext(_l);_l.Provider;function Qu(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Wu=_e.createContext(Qu()),Vu=()=>_e.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=>{_e.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]=_e.useState(()=>new t(a,o)),d=u.getOptimisticResult(o),h=!r&&e.subscribed!==!1;if(_e.useSyncExternalStore(_e.useCallback(v=>{const b=h?u.subscribe(Se.batchCalls(v)):Be;return u.updateResult(),b},[u,h]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),_e.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 we(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,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)}/** * @license lucide-react v0.468.0 - ISC * * This source code is licensed under the ISC license. @@ -21,12 +21,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 rd=_e.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:a,iconNode:o,...l},c)=>_e.createElement("svg",{ref:c,...nd,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:Pl("lucide",i),...l},[...o.map(([u,d])=>_e.createElement(u,d)),...Array.isArray(a)?a:[a]]));/** + */const rd=Ce.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:a,iconNode:o,...l},c)=>Ce.createElement("svg",{ref:c,...nd,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:Pl("lucide",i),...l},[...o.map(([u,d])=>Ce.createElement(u,d)),...Array.isArray(a)?a:[a]]));/** * @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 pe=(e,t)=>{const n=_e.forwardRef(({className:r,...i},a)=>_e.createElement(rd,{ref:a,iconNode:t,className:Pl(`lucide-${td(e)}`,r),...i}));return n.displayName=`${e}`,n};/** + */const pe=(e,t)=>{const n=Ce.forwardRef(({className:r,...i},a)=>Ce.createElement(rd,{ref:a,iconNode:t,className:Pl(`lucide-${td(e)}`,r),...i}));return n.displayName=`${e}`,n};/** * @license lucide-react v0.468.0 - ISC * * This source code is licensed under the ISC license. @@ -161,10 +161,10 @@ 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 W=dn(),ve=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:W,booleanish:ve,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 _(z){var P=z.match(t);P&&(N+=P.length);var $=z.lastIndexOf(c);k=~$?z.length-$:k+z.length}function M(){var z={line:N,column:k};return function(P){return P.position=new j(z),C(),P}}function j(z){this.start=z,this.end={line:N,column:k},this.source=b.source}j.prototype.content=v;function q(z){var P=new Error(b.source+":"+N+":"+k+": "+z);if(P.reason=z,P.filename=b.source,P.line=N,P.column=k,P.source=v,!b.silent)throw P}function D(z){var P=z.exec(v);if(P){var $=P[0];return _($),v=v.slice($.length),P}}function C(){D(n)}function L(z){var P;for(z=z||[];P=O();)P!==!1&&z.push(P);return z}function O(){var z=M();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 q("End of comment missing");var $=v.slice(2,P-2);return k+=2,_($),v=v.slice(P),k+=2,z({type:m,comment:$})}}function I(){var z=M(),P=D(r);if(P){if(O(),!D(i))return q("property missing ':'");var $=D(a),ee=z({type:p,property:y(P[0].replace(e,h)),value:$?y($[0].replace(e,h)):h});return D(o),ee}}function J(){var z=[];L(z);for(var P;P=I();)P!==!1&&(z.push(P),L(z));return z}return C(),J()}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 Ae 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}}Ae.prototype.file="";Ae.prototype.name="";Ae.prototype.reason="";Ae.prototype.message="";Ae.prototype.stack="";Ae.prototype.column=void 0;Ae.prototype.line=void 0;Ae.prototype.ancestors=void 0;Ae.prototype.cause=void 0;Ae.prototype.fatal=void 0;Ae.prototype.place=void 0;Ae.prototype.ruleId=void 0;Ae.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 Q(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 fe(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 q=t.events.length;let D=q,C,L;for(;D--;)if(t.events[D][0]==="exit"&&t.events[D][1].type==="chunkFlow"){if(C){L=t.events[D][1].end;break}C=!0}for(b(r),j=q;jk;){const M=n[_];t.containerState=M[1],M[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 fe(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)?fe(e,N,"linePrefix",a+1)(j):N(j)}function N(j){return j===null||Q(j)?e.check(vo,y,_)(j):(e.enter("codeFlowValue"),k(j))}function k(j){return j===null||Q(j)?(e.exit("codeFlowValue"),N(j)):(e.consume(j),k)}function _(j){return e.exit("codeFenced"),t(j)}function M(j,q,D){let C=0;return L;function L(P){return j.enter("lineEnding"),j.consume(P),j.exit("lineEnding"),O}function O(P){return j.enter("codeFencedFence"),ie(P)?fe(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"),J(P)):D(P)}function J(P){return P===l?(C++,j.consume(P),J):C>=o?(j.exit("codeFencedFenceSequence"),ie(P)?fe(j,z,"whitespace")(P):z(P)):D(P)}function z(P){return P===null||Q(P)?(j.exit("codeFencedFence"),q(P)):D(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"),fe(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):Q(u)?e.attempt(Ph,o,c)(u):(e.enter("codeFlowValue"),l(u))}function l(u){return u===null||Q(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):Q(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):fe(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):Q(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||Q(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):Q(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||Q(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):Q(m)?(e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),fe(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),d(m))}function d(m){return m===o||m===null||Q(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 Q(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):ie(i)?fe(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)?fe(e,m,"whitespace")(p):m(p)}function m(p){return p===null||Q(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)?fe(e,o,"whitespace")(l):o(l)}function o(l){return l===null||Q(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 Q(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||Q(d)?(e.exit("atxHeading"),t(d)):ie(d)?fe(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 Ce="CDATA[";return x===Ce.charCodeAt(l++)?(e.consume(x),l===Ce.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 Ce=x===47,He=o.toLowerCase();return!Ce&&!a&&ko.includes(He)?(i=1,r.interrupt?t(x):I(x)):Xh.includes(o.toLowerCase())?(i=6,Ce?(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):L(x)}function k(x){return x===47?(e.consume(x),L):x===58||x===95||gt(x)?(e.consume(x),_):ie(x)?(e.consume(x),k):L(x)}function _(x){return x===45||x===46||x===58||x===95||Je(x)?(e.consume(x),_):M(x)}function M(x){return x===61?(e.consume(x),j):ie(x)?(e.consume(x),M):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,q):ie(x)?(e.consume(x),j):D(x)}function q(x){return x===c?(e.consume(x),c=null,C):x===null||Q(x)?n(x):(e.consume(x),q)}function D(x){return x===null||x===34||x===39||x===47||x===60||x===61||x===62||x===96||$e(x)?M(x):(e.consume(x),D)}function C(x){return x===47||x===62||ie(x)?k(x):n(x)}function L(x){return x===62?(e.consume(x),O):n(x)}function O(x){return x===null||Q(x)?I(x):ie(x)?(e.consume(x),O):n(x)}function I(x){return x===45&&i===2?(e.consume(x),$):x===60&&i===1?(e.consume(x),ee):x===62&&i===4?(e.consume(x),te):x===63&&i===3?(e.consume(x),f):x===93&&i===5?(e.consume(x),be):Q(x)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(Zh,De,J)(x)):x===null||Q(x)?(e.exit("htmlFlowData"),J(x)):(e.consume(x),I)}function J(x){return e.check(ep,z,De)(x)}function z(x){return e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),P}function P(x){return x===null||Q(x)?J(x):(e.enter("htmlFlowData"),I(x))}function $(x){return x===45?(e.consume(x),f):I(x)}function ee(x){return x===47?(e.consume(x),o="",me):I(x)}function me(x){if(x===62){const Ce=o.toLowerCase();return ko.includes(Ce)?(e.consume(x),te):I(x)}return gt(x)&&o.length<8?(e.consume(x),o+=String.fromCharCode(x),me):I(x)}function be(x){return x===93?(e.consume(x),f):I(x)}function f(x){return x===62?(e.consume(x),te):x===45&&i===2?(e.consume(x),f):I(x)}function te(x){return x===null||Q(x)?(e.exit("htmlFlowData"),De(x)):(e.consume(x),te)}function De(x){return e.exit("htmlFlow"),t(x)}}function rp(e,t,n){const r=this;return i;function i(o){return Q(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),M):f===63?(e.consume(f),k):gt(f)?(e.consume(f),D):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):Q(f)?(o=h,ee(f)):(e.consume(f),h)}function m(f){return f===45?(e.consume(f),p):h(f)}function p(f){return f===62?$(f):f===45?m(f):h(f)}function w(f){const te="CDATA[";return f===te.charCodeAt(a++)?(e.consume(f),a===te.length?y:w):n(f)}function y(f){return f===null?n(f):f===93?(e.consume(f),v):Q(f)?(o=y,ee(f)):(e.consume(f),y)}function v(f){return f===93?(e.consume(f),b):y(f)}function b(f){return f===62?$(f):f===93?(e.consume(f),b):y(f)}function N(f){return f===null||f===62?$(f):Q(f)?(o=N,ee(f)):(e.consume(f),N)}function k(f){return f===null?n(f):f===63?(e.consume(f),_):Q(f)?(o=k,ee(f)):(e.consume(f),k)}function _(f){return f===62?$(f):k(f)}function M(f){return gt(f)?(e.consume(f),j):n(f)}function j(f){return f===45||Je(f)?(e.consume(f),j):q(f)}function q(f){return Q(f)?(o=q,ee(f)):ie(f)?(e.consume(f),q):$(f)}function D(f){return f===45||Je(f)?(e.consume(f),D):f===47||f===62||$e(f)?C(f):n(f)}function C(f){return f===47?(e.consume(f),$):f===58||f===95||gt(f)?(e.consume(f),L):Q(f)?(o=C,ee(f)):ie(f)?(e.consume(f),C):$(f)}function L(f){return f===45||f===46||f===58||f===95||Je(f)?(e.consume(f),L):O(f)}function O(f){return f===61?(e.consume(f),I):Q(f)?(o=O,ee(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,J):Q(f)?(o=I,ee(f)):ie(f)?(e.consume(f),I):(e.consume(f),z)}function J(f){return f===i?(e.consume(f),i=void 0,P):f===null?n(f):Q(f)?(o=J,ee(f)):(e.consume(f),J)}function z(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),z)}function P(f){return f===47||f===62||$e(f)?C(f):n(f)}function $(f){return f===62?(e.consume(f),e.exit("htmlTextData"),e.exit("htmlText"),t):n(f)}function ee(f){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),me}function me(f){return ie(f)?fe(e,be,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(f):be(f)}function be(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||Q(u))?(e.exit("thematicBreak"),t(u)):n(u)}function c(u){return u===i?(e.consume(u),r++,c):(e.exit("thematicBreakSequence"),ie(u)?fe(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,fe(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,fe(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 fe(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 fe(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)?fe(e,c,"lineSuffix")(u):c(u))}function c(u){return u===null||Q(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,fe(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([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(;++n0){const Ee=H.tokenStack[H.tokenStack.length-1];(Ee[1]||_o).call(H,void 0,Ee[0])}for(A.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(;++l{throw TypeError(e)};var Jr=(e,t,n)=>t.has(e)||Ha("Cannot "+n);var g=( `});++r0&&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 xe=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)),X=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=xe("colors"),t=xe("spacing"),n=xe("blur"),r=xe("brightness"),i=xe("borderColor"),a=xe("borderRadius"),o=xe("borderSpacing"),l=xe("borderWidth"),c=xe("contrast"),u=xe("grayscale"),d=xe("hueRotate"),h=xe("invert"),m=xe("gap"),p=xe("gradientColorStops"),w=xe("gradientColorStopPositions"),y=xe("inset"),v=xe("margin"),b=xe("opacity"),N=xe("padding"),k=xe("saturate"),_=xe("scale"),M=xe("sepia"),j=xe("skew"),q=xe("space"),D=xe("translate"),C=()=>["auto","contain","none"],L=()=>["auto","hidden","clip","visible","scroll"],O=()=>["auto",X,t],I=()=>[X,t],J=()=>["",kt,Rt],z=()=>["auto",yn,X],P=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],$=()=>["solid","dashed","dotted","double","none"],ee=()=>["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"],be=()=>["","0",X],f=()=>["auto","avoid","all","avoid-page","page","left","right","column"],te=()=>[yn,X];return{cacheSize:500,separator:":",theme:{colors:[Zn],spacing:[kt,Rt],blur:["none","",It,X],brightness:te(),borderColor:[e],borderRadius:["none","","full",It,X],borderSpacing:I(),borderWidth:J(),contrast:te(),grayscale:be(),hueRotate:te(),invert:be(),gap:I(),gradientColorStops:[e],gradientColorStopPositions:[Yf,Rt],inset:O(),margin:O(),opacity:te(),padding:I(),saturate:te(),scale:te(),sepia:be(),skew:te(),space:I(),translate:I()},classGroups:{aspect:[{aspect:["auto","square","video",X]}],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(),X]}],overflow:[{overflow:L()}],"overflow-x":[{"overflow-x":L()}],"overflow-y":[{"overflow-y":L()}],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,X]}],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",X]}],grow:[{grow:be()}],shrink:[{shrink:be()}],order:[{order:["first","last","none",Yn,X]}],"grid-cols":[{"grid-cols":[Zn]}],"col-start-end":[{col:["auto",{span:["full",Yn,X]},X]}],"col-start":[{"col-start":z()}],"col-end":[{"col-end":z()}],"grid-rows":[{"grid-rows":[Zn]}],"row-start-end":[{row:["auto",{span:[Yn,X]},X]}],"row-start":[{"row-start":z()}],"row-end":[{"row-end":z()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",X]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",X]}],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":[q]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[q]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",X,t]}],"min-w":[{"min-w":[X,t,"min","max","fit"]}],"max-w":[{"max-w":[X,t,"none","full","min","max","fit","prose",{screen:[It]},It]}],h:[{h:[X,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[X,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[X,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[X,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",X]}],"line-clamp":[{"line-clamp":["none",yn,hs]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",kt,X]}],"list-image":[{"list-image":["none",X]}],"list-style-type":[{list:["none","disc","decimal",X]}],"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:[...$(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",kt,Rt]}],"underline-offset":[{"underline-offset":["auto",kt,X]}],"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",X]}],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",X]}],"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:[...$(),"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:$()}],"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:["",...$()]}],"outline-offset":[{"outline-offset":[kt,X]}],"outline-w":[{outline:[kt,Rt]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:J()}],"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":[...ee(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":ee()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[c]}],"drop-shadow":[{"drop-shadow":["","none",It,X]}],grayscale:[{grayscale:[u]}],"hue-rotate":[{"hue-rotate":[d]}],invert:[{invert:[h]}],saturate:[{saturate:[k]}],sepia:[{sepia:[M]}],"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":[M]}],"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",X]}],duration:[{duration:te()}],ease:[{ease:["linear","in","out","in-out",X]}],delay:[{delay:te()}],animate:[{animate:["none","spin","ping","pulse","bounce",X]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[_]}],"scale-x":[{"scale-x":[_]}],"scale-y":[{"scale-y":[_]}],rotate:[{rotate:[Yn,X]}],"translate-x":[{"translate-x":[D]}],"translate-y":[{"translate-y":[D]}],"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",X]}],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",X]}],"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",X]}],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 K(...e){return cx(du(e))}async function Z(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),[_,M]=R.useState(""),[j,q]=R.useState(!1),[D,C]=R.useState(""),[L,O]=R.useState(!1),[I,J]=R.useState(""),[z,P]=R.useState("7d"),[$,ee]=R.useState("7d"),[me,be]=R.useState(()=>window.location.pathname),[f,te]=R.useState(null),De=Lx(me),x=De!==null,Ce=Mx(me),He=Ox(me),de=Dx(me),lt=ps(me),Le=Fx(me),Ke=zx(me),st=!x&&!Ce&&!He&&!de&&!lt,oe=De,je=we({queryKey:["metrics",Ws,z,$],queryFn:()=>Z(Px(Ws,z,$)),enabled:st||de}),ke=we({queryKey:["dashboard-status"],queryFn:()=>Z("/api/status"),refetchInterval:de?1e4:!1}),Pe=we({queryKey:["me"],queryFn:()=>Z("/api/me"),refetchInterval:!1}),ct=lt&&!!((Ai=(Ti=Pe.data)==null?void 0:Ti.user)!=null&&Ai.is_admin&&((Li=ke.data)!=null&&Li.webhook_configured)),Ht=Nx(m),yt=we({queryKey:["web-push-config"],queryFn:()=>Z("/api/web-push/config"),enabled:!!((Mi=Pe.data)!=null&&Mi.user)}),Vr=we({queryKey:["about"],queryFn:()=>Z("/api/about")}),vr=we({queryKey:["job-actors"],queryFn:()=>Z("/api/jobs/actors"),enabled:st}),Qe=we({queryKey:["jobs",t,r],queryFn:()=>Z(jx(t,r)),enabled:st,placeholderData:E=>E}),it=we({queryKey:["processes"],queryFn:()=>Z("/api/processes"),enabled:de,refetchInterval:de?1e4:!1}),hn=we({queryKey:["systemd"],queryFn:()=>Z("/api/systemd"),enabled:de}),pn=we({queryKey:["alerts"],queryFn:()=>Z("/api/alerts"),enabled:de}),mn=we({queryKey:["webhook-summary"],queryFn:()=>Z("/api/webhooks/github/summary"),enabled:ct}),Kn=we({queryKey:["webhook-timeseries",v.from,v.to,"day"],queryFn:()=>Z(Sx(v.from,v.to)),enabled:ct&&Ht.timeseries}),S=we({queryKey:["webhook-exceptions"],queryFn:()=>Z("/api/webhooks/github/exceptions"),enabled:ct&&Ht.timeseries}),A=Yr({queryKey:["webhook-hooks"],queryFn:({pageParam:E})=>Z(_x(50,E)),initialPageParam:null,getNextPageParam:E=>E.next_cursor??void 0,enabled:ct&&Ht.hooks&&Le===null&&Ke===null}),H=Yr({queryKey:["webhook-deliveries",w],queryFn:({pageParam:E})=>Z(Cx(50,E,w)),initialPageParam:null,getNextPageParam:E=>E.next_cursor??void 0,enabled:ct&&Ht.deliveries&&Le===null&&Ke===null}),V=we({queryKey:["webhook-hook",Le],queryFn:()=>Z(`/api/webhooks/github/hooks/${encodeURIComponent(Le??"")}`),enabled:ct&&Le!==null}),le=R.useCallback(async E=>{const Y=await Z(`/api/webhooks/github/hooks/${encodeURIComponent(E)}/ping`,{method:"POST"});return V.refetch(),window.setTimeout(()=>void V.refetch(),1500),Y.detail},[V]),Ee=we({queryKey:["webhook-delivery",Ke],queryFn:()=>Z(`/api/webhooks/github/deliveries/${encodeURIComponent(Ke??"")}`),enabled:ct&&Ke!==null}),Me=Yr({queryKey:["knowledge",d,o,d==="proposals"?c:""],queryFn:({pageParam:E})=>Z(kx(o,c,d,50,E)),initialPageParam:0,getNextPageParam:E=>E.next_offset??void 0,enabled:Ce}),Fe=we({queryKey:["mcp-tokens"],queryFn:()=>Z("/api/mcp/tokens"),enabled:He&&!!((Oi=Pe.data)!=null&&Oi.user)}),Kt=we({queryKey:["mcp-users"],queryFn:()=>Z("/api/mcp/users"),enabled:He&&!!((Di=Pe.data)!=null&&Di.user)}),ut=we({queryKey:["job",oe],queryFn:()=>Z(`/api/jobs/${oe}`),enabled:oe!==null}),Re=we({queryKey:["job-session",oe],queryFn:()=>Z(`/api/jobs/${oe}/session`),enabled:oe!==null}),wt=we({queryKey:["job-session-events",oe],queryFn:()=>Z(`/api/jobs/${oe}/session/events`),enabled:oe!==null}),Ye=we({queryKey:["job-session-transcript",oe],queryFn:()=>Z(`/api/jobs/${oe}/session/transcript`),enabled:oe!==null}),Ci=R.useCallback(async E=>{const Y=await Z(`/api/jobs/${E}/retry`,{method:"POST"});e.setQueryData(["job",E],{job:Y.job}),e.invalidateQueries({queryKey:["jobs"]}),e.invalidateQueries({queryKey:["metrics"]})},[e]),Pi=R.useCallback(async E=>{const Y=await Z(`/api/jobs/${E}/dismiss`,{method:"POST"});e.setQueryData(["job",E],{job:Y.job}),e.invalidateQueries({queryKey:["jobs"]}),e.invalidateQueries({queryKey:["metrics"]})},[e]),Ei=R.useCallback(async(E,Y)=>{const ce=await Z(`/api/jobs/${E}/cancel`,{method:"POST",body:JSON.stringify({reason:Y||""})});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,Y)=>{await Z(`/api/knowledge/proposals/${encodeURIComponent(E)}/${Y}`,{method:"POST"}),e.invalidateQueries({queryKey:["knowledge"]}),e.invalidateQueries({queryKey:["dashboard-status"]})},[e]),Fc=R.useCallback(async E=>{await Z(`/api/knowledge/rules/${encodeURIComponent(E)}`,{method:"DELETE"}),e.invalidateQueries({queryKey:["knowledge"]})},[e]),zc=R.useCallback(async(E,Y)=>{await Z(`/api/knowledge/rules/${encodeURIComponent(E)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({scope:Y})}),e.invalidateQueries({queryKey:["knowledge"]})},[e]),qc=R.useCallback(async(E,Y)=>{const ce=await Z("/api/mcp/tokens",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:E,user_login:Y||void 0})});return e.invalidateQueries({queryKey:["mcp-tokens"]}),ce},[e]),Bc=R.useCallback(async(E,Y)=>{await Z(`/api/mcp/tokens/${encodeURIComponent(E)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({user_login:Y})}),e.invalidateQueries({queryKey:["mcp-tokens"]}),e.invalidateQueries({queryKey:["mcp-users"]})},[e]),$c=R.useCallback(async E=>{await Z(`/api/mcp/tokens/${encodeURIComponent(E)}`,{method:"DELETE"}),e.invalidateQueries({queryKey:["mcp-tokens"]})},[e]),Gr=R.useCallback(async E=>{const Y={refresh:"/api/autoupdate/refresh",apply:"/api/autoupdate/apply",complete:"/api/autoupdate/complete-pending"}[E];k(E),M("");try{await Z(Y,{method:"POST"}),e.invalidateQueries({queryKey:["dashboard-status"]})}catch(ce){e.invalidateQueries({queryKey:["dashboard-status"]}),M(ce instanceof Error?ce.message:String(ce))}finally{k(null)}},[e]),Uc=R.useCallback(async E=>{q(!0),C("");try{const Y=await Z(`/api/executor/${E?"pause":"resume"}`,{method:"POST"});e.setQueryData(["dashboard-status"],ce=>ce&&{...ce,executor_pause:Y.executor_pause}),await e.invalidateQueries({queryKey:["dashboard-status"]})}catch(Y){C(Y instanceof Error?Y.message:String(Y))}finally{q(!1)}},[e]),Hc=R.useCallback(async E=>{O(!0),J("");try{await Z("/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(Y){J(Y instanceof Error?Y.message:String(Y))}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 Z("/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 Y=await(await navigator.serviceWorker.ready).pushManager.getSubscription();if(!Y)return;const ce=Y.endpoint;await Y.unsubscribe(),await Z("/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",Y=>{const ce=Br(Y);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",Y=>{const ce=Br(Y);!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()),be(window.location.pathname)};return window.addEventListener("popstate",E),()=>window.removeEventListener("popstate",E)},[]),R.useEffect(()=>{if(!("serviceWorker"in navigator))return;const E=Y=>{if(!Ex(Y.data))return;const ce={...Y.data.payload,id:Date.now(),receivedAt:Date.now()};te(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(()=>te(null),12e3);return()=>window.clearTimeout(E)},[f]);const Ii=R.useCallback(E=>{window.history.pushState({},"",Un(E)),be(window.location.pathname)},[]),dt=R.useCallback(E=>{window.history.pushState({},"",E),ps(E)&&b(Er()),be(window.location.pathname)},[]),Qt=((qi=je.data)==null?void 0:qi.metrics.status_counts)??{},jr=((Bi=Qe.data)==null?void 0:Bi.jobs)??[],Wc=!!((Ui=($i=Pe.data)==null?void 0:$i.user)!=null&&Ui.is_admin&&Sc((Hi=ke.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=Re.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=A.data)==null?void 0:Ji.pages.flatMap(E=>E.hooks))??[],Zc=((Xi=H.data)==null?void 0:Xi.pages.flatMap(E=>E.deliveries))??[],vt=((Yi=Me.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"?A.isLoading:H.isLoading,nu=m==="overview"?Kn.error:m==="hooks"?A.error:H.error,ru=()=>{mn.refetch(),m==="overview"&&S.refetch(),m==="overview"&&b(Er()),m==="hooks"&&A.refetch(),m==="deliveries"&&H.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=Pe.data)==null?void 0:Zi.user,loading:Pe.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:Ce,isMcpRoute:He,isWebhooksRoute:lt,showWebhooks:!!((ta=(ea=Pe.data)==null?void 0:ea.user)!=null&&ta.is_admin&&((na=ke.data)!=null&&na.webhook_configured)),knowledgeBadgeCount:((ia=(sa=(ra=ke.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:()=>te(null),onNavigate:dt}),De!==null?s.jsx(ng,{jobId:De,detail:Xc,selectedJob:Ct,user:(aa=Pe.data)==null?void 0:aa.user,onBackToDashboard:()=>dt("/"),onRetry:Ci,onDismiss:Pi,onCancel:Ei,onRefresh:()=>{ut.refetch(),Re.refetch(),wt.refetch(),Ye.refetch()}}):Ce?s.jsx(sg,{data:eu,loading:Me.isLoading,error:Me.error,repo:o,status:c,activeTab:d,user:(oa=Pe.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:()=>Me.refetch(),hasMore:!!Me.hasNextPage,loadingMore:Me.isFetchingNextPage,onLoadMore:()=>Me.fetchNextPage()}):He?s.jsx(ug,{tokens:(la=Fe.data)==null?void 0:la.tokens,loading:Fe.isLoading,error:Fe.error,user:(ca=Pe.data)==null?void 0:ca.user,ownerOptions:((ua=Kt.data)==null?void 0:ua.users)??[],dashboardUrl:(da=ke.data)==null?void 0:da.dashboard_url,dashboardUrlSource:(ha=ke.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:Ee.data,loading:Ee.isLoading,error:Ee.error,onBack:()=>{p("deliveries"),dt("/webhooks")},onRefresh:()=>Ee.refetch(),onViewHook:E=>dt(`/webhooks/hooks/${encodeURIComponent(E)}`),onViewJob:Ii}):Le?s.jsx(Yx,{data:V.data,loading:V.isLoading,error:V.error,onBack:()=>{p("hooks"),dt("/webhooks")},onRefresh:()=>V.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"?A.isFetchingNextPage:H.isFetchingNextPage,hasMore:m==="hooks"?A.hasNextPage:H.hasNextPage,deliveryFilters:w,error:mn.error??nu,onSectionChange:p,onLoadMore:()=>m==="hooks"?A.fetchNextPage():H.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=ke.data)==null?void 0:fa.autoupdate,isAdmin:!!((ga=(xa=Pe.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=ke.data)==null?void 0:ba.executor_pause,executorPauseLoading:ke.isLoading,executorPauseStatusError:ke.error,executorPausePending:j,executorPauseError:D,executorCapacity:{desired:((ya=it.data)==null?void 0:ya.executor.expected_workers)??((va=(wa=ke.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=ke.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=ke.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=ke.data)==null?void 0:Ea.metrics)==null?void 0:Ra.executor_worker_draining_count)??0},executorResizePending:L,executorResizeError:I,isAdmin:!!((Ta=(Ia=Pe.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=je.data)==null?void 0:La.metrics,sloLoading:je.isLoading,sloError:je.error,sloWindow:z,now:Qn,onRefreshProcesses:()=>it.refetch(),onRefreshSystemd:()=>hn.refetch(),onRefreshAlerts:()=>pn.refetch(),onSloWindowChange:P,onRefreshSlo:()=>je.refetch()})]}):s.jsxs(s.Fragment,{children:[je.error?s.jsx(ge,{tone:"error",text:je.error.message}):null,ke.error?s.jsx(ge,{tone:"error",text:ke.error.message}):null,s.jsxs("section",{className:"grid grid-cols-2 gap-3 xl:grid-cols-4","aria-label":"Summary metrics",children:[s.jsx(Te,{title:"Pending",value:Qt.pending??0,icon:s.jsx(Rl,{className:"h-5 w-5"})}),s.jsx(Te,{title:"Running",value:Qt.running??0,icon:s.jsx(an,{className:"h-5 w-5"})}),s.jsx(Te,{title:"Blocked",value:Qt.blocked??0,icon:s.jsx(Hr,{className:"h-5 w-5"})}),s.jsx(Te,{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(ge,{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=Pe.data)==null?void 0:Oa.user,onRetry:Ci,onDismiss:Pi,onCancel:Ei})]}),s.jsx(se,{title:"Runtime & jobs",action:s.jsx(nt,{onClick:()=>je.refetch()}),children:s.jsx(Dg,{usage:(Da=je.data)==null?void 0:Da.metrics.runtime_usage,jobsByCreatedDay:(Fa=je.data)==null?void 0:Fa.metrics.by_created_day,loading:je.isLoading,totalJobs:gs(Qt)})}),s.jsx(se,{title:"Runtime by user",children:s.jsx(Bg,{usage:(za=je.data)==null?void 0:za.metrics.runtime_usage_by_actor,loading:je.isLoading,totalJobs:gs(Qt),window:$,onWindowChange:ee})}),s.jsx(se,{title:"Runtime by repository",children:s.jsx($g,{usage:(qa=je.data)==null?void 0:qa.metrics.runtime_usage_by_repo,loading:je.isLoading,totalJobs:gs(Qt),window:$,onWindowChange:ee})})]}),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=je.data)==null?void 0:Ba.metrics.runtime_seconds})}),s.jsx(se,{title:"Queue wait percentiles",children:s.jsx(Xo,{label:"queue wait",values:($a=je.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,_,M,j,q,D,C,L;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=(M=e.classification)==null?void 0:M.migration_files)==null?void 0:j.length)??0,p=((D=(q=e.classification)==null?void 0:q.risky_files)==null?void 0:D.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:K("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,(L=e.warnings)!=null&&L.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:K("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:K("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 j,q,D,C,L,O,I,J,z,P,$,ee,me,be;const N=Object.values((e==null?void 0:e.receipts)??{}).reduce((f,te)=>f+te,0),k=((j=e==null?void 0:e.coverage)==null?void 0:j.promotion_state)??((q=e==null?void 0:e.coverage)!=null&&q.promotion_ready?"ready":"blocked"),_=k==="insufficient_data"?"insufficient data":k,M=[{id:"overview",label:"Overview"},{id:"hooks",label:"Hooks",count:(D=e==null?void 0:e.totals)==null?void 0:D.hooks},{id:"deliveries",label:"Deliveries",count:(C=e==null?void 0:e.totals)==null?void 0:C.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(ge,{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:M.map(f=>s.jsxs("button",{type:"button",role:"tab","aria-label":f.count===void 0?f.label:`${f.label} (${f.count} total)`,"aria-selected":a===f.id,className:K("inline-flex h-8 items-center gap-2 rounded px-3 text-sm font-semibold",a===f.id?"bg-primary text-white":"text-muted hover:bg-slate-50 hover:text-foreground"),onClick:()=>m(f.id),children:[f.label,f.count!==void 0?s.jsx("span",{className:"rounded border border-current/30 px-1 font-mono text-[10px]",children:f.count}):null]},f.id))}),s.jsxs("div",{className:"grid grid-cols-2 gap-3 xl:grid-cols-4","aria-label":"Webhook status",children:[s.jsx(Te,{title:"Receipts",value:N,icon:s.jsx(an,{className:"h-5 w-5"})}),s.jsx(Te,{title:"Duplicates",value:(e==null?void 0:e.duplicate_deliveries)??0,icon:s.jsx(zn,{className:"h-5 w-5"})}),s.jsx(Te,{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(Te,{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(G,{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(([f],[te])=>f.localeCompare(te)).map(([f,te])=>s.jsx(B,{label:f,value:te},f))}):s.jsx(G,{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(B,{label:"Both sources",value:((L=e==null?void 0:e.coverage)==null?void 0:L.both)??0}),s.jsx(B,{label:"IMAP only",value:((O=e==null?void 0:e.coverage)==null?void 0:O.imap_only)??0}),s.jsx(B,{label:"Webhook only",value:((I=e==null?void 0:e.coverage)==null?void 0:I.webhook_only)??0}),s.jsx(B,{label:"Coverage",value:((J=e==null?void 0:e.coverage)==null?void 0:J.ratio)==null?"not measurable":`${Math.round(e.coverage.ratio*100)}%`}),s.jsx(B,{label:"Decision mismatches",value:((z=e==null?void 0:e.coverage)==null?void 0:z.decision_mismatches)??0}),s.jsx(B,{label:"Incomplete decision traces",value:((P=e==null?void 0:e.coverage)==null?void 0:P.incomplete_decision_traces)??0}),s.jsx(B,{label:"Split identities",value:(($=e==null?void 0:e.coverage)==null?void 0:$.split_identities)??0}),s.jsx(B,{label:"Promotion gate",value:_}),s.jsx(B,{label:"Outside scope IMAP",value:((ee=e==null?void 0:e.coverage)==null?void 0:ee.outside_scope_imap_eligible)??0}),s.jsx(B,{label:"Outside scope webhook",value:((me=e==null?void 0:e.coverage)==null?void 0:me.outside_scope_webhook_eligible)??0})]}),(be=e==null?void 0:e.coverage)!=null&&be.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. Promotion scope: ",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(([f],[te])=>f.localeCompare(te)).map(([f,te])=>s.jsx(B,{label:f,value:te},f))})}):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(f=>s.jsxs("tr",{className:"border-b border-border/70 last:border-0",children:[s.jsx("td",{className:"px-3 py-2 font-semibold",children:f.kind}),s.jsx("td",{className:"px-3 py-2 font-mono text-xs",children:f.repository??"unknown"}),s.jsx("td",{className:"px-3 py-2 font-mono text-xs",children:f.event_type?`${f.event_type}${f.event_action?`:${f.event_action}`:""}`:"unknown"}),s.jsxs("td",{className:"px-3 py-2 font-mono text-xs",children:[s.jsx("div",{children:f.reference}),f.related_reference?s.jsx("div",{children:f.related_reference}):null,f.event_key?s.jsxs("div",{className:"text-muted",children:[f.event_key,f.related_event_key?` ↔ ${f.related_event_key}`:""]}):null]}),s.jsx("td",{className:"px-3 py-2 font-mono text-xs text-muted",children:s.jsx(ue,{value:f.created_at,compact:!0})})]},`${f.kind}:${f.reference}:${f.related_reference??""}`))})]})}):s.jsx(G,{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(f=>s.jsxs("tr",{className:"cursor-pointer border-b border-border/70 last:border-0 hover:bg-slate-50",onClick:()=>y(f.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:te=>{te.stopPropagation(),y(f.id)},children:f.target}),s.jsxs("div",{className:"font-mono text-xs text-muted",children:[f.target_type," · #",f.id]})]}),s.jsx("td",{className:"px-3 py-3",children:s.jsx("span",{className:K("rounded border px-2 py-1 text-xs font-semibold",f.status==="receiving"?"border-emerald-200 bg-emerald-50 text-emerald-700":f.status==="inactive"?"border-red-200 bg-red-50 text-red-700":"border-slate-200 bg-slate-50 text-slate-600"),children:f.status})}),s.jsxs("td",{className:"max-w-sm px-3 py-3 text-xs",children:[s.jsx("div",{children:f.events.join(", ")||"No event snapshot"}),s.jsxs("div",{className:"mt-1 font-mono text-muted",children:[f.content_type??"content type unknown"," · SSL ",f.ssl_verify===null||f.ssl_verify===void 0?"unknown":f.ssl_verify?"verified":"disabled"]})]}),s.jsxs("td",{className:"px-3 py-3 text-xs",children:[s.jsxs("div",{className:"font-semibold",children:[f.last_event_name??"Never",f.last_action?` · ${f.last_action}`:""]}),s.jsxs("div",{className:"mt-1 font-mono text-muted",children:[f.last_repository??"No repository",f.last_event_at?s.jsxs(s.Fragment,{children:[" · ",s.jsx(ue,{value:f.last_event_at,compact:!0})]}):null]})]}),s.jsx("td",{className:"px-3 py-3 font-mono text-xs text-muted",children:f.last_ping_at?s.jsx(ue,{value:f.last_ping_at,compact:!0}):"Never"})]},f.id))})]})}):s.jsx(G,{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(G,{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:K("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(ge,{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(G,{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:K("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(ge,{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(Te,{title:"State",value:y.status,icon:s.jsx(an,{className:"h-5 w-5"})}),s.jsx(Te,{title:"Deliveries",value:e.stats.deliveries,icon:s.jsx(Fn,{className:"h-5 w-5"})}),s.jsx(Te,{title:"Retries",value:e.stats.duplicates,icon:s.jsx(zn,{className:"h-5 w-5"})}),s.jsx(Te,{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(B,{label:"Active",value:y.active?"yes":"no"}),s.jsx(B,{label:"Content type",value:y.content_type??"unknown"}),s.jsx(B,{label:"SSL verification",value:y.ssl_verify===null||y.ssl_verify===void 0?"unknown":y.ssl_verify?"enabled":"disabled"}),s.jsx(B,{label:"Destination URL",value:y.delivery_url??"unknown"}),s.jsx(B,{label:"GitHub created",value:y.github_created_at??"unknown"}),s.jsx(B,{label:"GitHub updated",value:y.github_updated_at??"unknown"}),s.jsx(B,{label:"Last ping",value:y.last_ping_at??"never"}),s.jsx(B,{label:"Last delivery",value:y.last_event_at??"never"}),s.jsx(B,{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(B,{label:"Event",value:y.last_event_name?`${y.last_event_name}${y.last_action?` · ${y.last_action}`:""}`:"none"}),s.jsx(B,{label:"Repository",value:y.last_repository??"none"}),s.jsx(B,{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(G,{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(G,{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(ge,{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(G,{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(B,{label:"Received",value:l.created_at}),s.jsx(B,{label:"Repository",value:l.repository??"unknown"}),s.jsx(B,{label:"Result",value:l.status}),s.jsx(B,{label:"Event key",value:l.event_key??"unmatchable"}),s.jsx(B,{label:"Payload SHA-256",value:e.payload_hash}),s.jsx(B,{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(G,{text:"This delivery did not generate or coalesce into a job."})}),s.jsx(se,{title:"Full payload",children:e.payload===null?s.jsx(G,{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:M,sloError:j,sloWindow:q,now:D,onRefreshProcesses:C,onRefreshSystemd:L,onRefreshAlerts:O,onSloWindowChange:I,onRefreshSlo:J}){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(ge,{tone:"error",text:j.message}):null,s.jsx(wg,{summary:_,loading:M,window:q,onWindowChange:I,onRefresh:J}),s.jsxs(se,{title:"Systemd",action:s.jsx(nt,{onClick:L}),children:[v?s.jsx(ge,{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(ge,{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(ge,{tone:"error",text:k.message}):null,s.jsx(Yg,{alerts:b,loading:N,now:D})]})]})}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(B,{label:"Desired",value:a.desired}),s.jsx(B,{label:"Live",value:a.live}),s.jsx(B,{label:"Busy",value:a.busy}),s.jsx(B,{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(ge,{tone:"error",text:n.message}):null,e!=null&&e.error?s.jsx(ge,{tone:"error",text:e.error}):null,i?s.jsx(ge,{tone:"error",text:`Action failed: ${i}`}):null,l?s.jsx(ge,{tone:"error",text:`Resize failed: ${l}`}):null]})}function er({href:e,active:t,children:n,onNavigate:r}){return s.jsx("a",{className:K("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:M=>{M.defaultPrevented||M.button!==0||M.metaKey||M.ctrlKey||M.altKey||M.shiftKey||(M.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 M=window.prompt(`Cancel job #${e}? Optional reason:`);if(M!==null){w(!0);try{await l(e,M)}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(G,{text:"Loading selected job..."}):e!==null&&r?s.jsx(ge,{tone:"error",text:`Job #${e}: ${r.message}`}):s.jsx(G,{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)??{},[_,M]=R.useState("proposals"),j=a??_,q=L=>{M(L),d==null||d(L)},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(ge,{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(Te,{title:"Proposed",value:k.proposed??0,icon:s.jsx(Rl,{className:"h-5 w-5"})}),s.jsx(Te,{title:"Approved",value:k.approved??0,icon:s.jsx(Dn,{className:"h-5 w-5"})}),s.jsx(Te,{title:"Rules",value:k.rules??0,icon:s.jsx(Tl,{className:"h-5 w-5"})}),s.jsx(Te,{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:K("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:L=>c(L.target.value),children:[s.jsx("option",{value:"",children:"All repositories"}),((e==null?void 0:e.repositories)??[]).map(L=>s.jsx("option",{value:L,children:L},L))]})}),j==="proposals"?s.jsx(ot,{label:"Proposal status",children:s.jsxs("select",{className:"control",value:i,onChange:L=>u(L.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(L=>s.jsxs("button",{className:K("inline-flex h-8 items-center gap-1.5 rounded px-2.5 text-xs font-semibold",j===L.id?"bg-primary text-white":"text-muted hover:bg-slate-50 hover:text-foreground"),type:"button",role:"tab","aria-label":`${L.label} (${L.count})`,"aria-selected":j===L.id,onClick:()=>q(L.id),children:[s.jsx("span",{children:L.label}),s.jsx("span",{className:K("rounded-sm border px-1 font-mono text-[10px]",j===L.id?"border-white/40 text-white":"border-border text-muted"),children:L.count})]},L.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(G,{text:"Loading proposals..."}):e.length===0?s.jsx(G,{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(ge,{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(G,{text:"Loading curated rules..."}):e.length===0?s.jsx(G,{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(G,{text:"Loading captured events..."}):e.length===0?s.jsx(G,{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),[_,M]=R.useState(null),[j,q]=R.useState(null),[D,C]=R.useState(""),L=e??[],O=i.find(P=>P.login===w);R.useEffect(()=>{var P;r!=null&&r.is_admin&&(w&&i.some($=>$.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(/\/$/,""),J=`${I}/mcp`,z=`${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(ge,{tone:"error",text:n.message}):null,D?s.jsx(ge,{tone:"error",text:D}):null,s.jsx(dg,{dashboardUrl:J,endpointUrl:z,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:()=>q(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 $=m.trim();if($){b(!0),C("");try{const ee=await c($,r!=null&&r.is_admin?w:void 0);q(ee),p("")}catch(ee){C(ee instanceof Error?ee.message:String(ee))}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}),O?s.jsxs("span",{className:"font-normal text-muted",children:["Token will be linked to @",O.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:L,loading:t,now:l,ownerOptions:i,canManageOwners:!!(r!=null&&r.is_admin),revokingId:N,updatingOwnerId:_,onUpdateOwner:async(P,$)=>{M(P),C("");try{await u(P,$)}catch(ee){C(ee instanceof Error?ee.message:String(ee))}finally{M(null)}},onRevoke:async P=>{if(window.confirm("Revoke this MCP token?")){k(P),C("");try{await d(P)}catch($){C($ instanceof Error?$.message:String($))}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 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=`{ "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(ge,{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(G,{text:"Loading MCP tokens..."}):e.length===0?s.jsx(G,{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(B,{label:"Created",value:s.jsx(ue,{value:u.created_at,relative:!0,now:n})}),s.jsx(B,{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:K("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:K("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:K("text-muted",l==="compact"?"h-4 w-4":"h-5 w-5"),"aria-hidden":!0})}),s.jsx("span",{className:K("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:K("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:K("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:K("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:K("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:K("min-w-0 rounded-lg border border-border bg-panel p-4 shadow-sm",r),children:[s.jsxs("div",{className:K("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 Te({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:K("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(ge,{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(G,{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:K("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 M=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]),q=R.useCallback(async C=>{if(u){w(C);try{await u(C)}finally{w(null)}}},[u]),D=R.useCallback(async(C,L)=>{if(d){v(C);try{await d(C,L)}finally{v(null)}}},[d]);return t&&e.length===0?s.jsx(G,{text:"Loading jobs..."}):e.length===0?s.jsx(G,{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:q,canCancel:!!(d&&Js(C,l)),cancelling:y===C.id,onCancel:D},C.id)),s.jsx(Cg,{hasMore:r,loading:n,onLoadMore:M})]}),s.jsx(Xs,{noun:"jobs",hasMore:r,loading:n,onLoadMore:M,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:q,canCancel:!!(d&&Js(C,l)),cancelling:y===C.id,onCancel:D},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(B,{label:"Wait",value:Xe(Ni(e,n))}),s.jsx(B,{label:"Runtime",value:Xe(ki(e,n))}),s.jsx(B,{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:K("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:K(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:K("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:K(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:K("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:K(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:K("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:K("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:K("grid gap-2 text-sm sm:gap-3",a?"grid-cols-1":"grid-cols-3"),children:[s.jsx(B,{label:"Queue wait",value:Xe(m)}),s.jsx(B,{label:e.status==="running"?"Running for":"Runtime",value:Xe(h)}),s.jsx(B,{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:K("grid gap-2 text-sm sm:gap-3",a?"grid-cols-1":"grid-cols-3"),children:[s.jsx(B,{label:"Model",value:Eg(e.model_route)}),s.jsx(B,{label:"Reasoning",value:Rg(e.model_route)}),s.jsx(B,{label:"Route",value:Ig(e.model_route)})]}),s.jsx(Lg,{job:e,compact:a}),s.jsxs("div",{className:K("grid gap-2 text-sm sm:gap-3",a?"grid-cols-1":"grid-cols-2 xl:grid-cols-4"),children:[s.jsx(B,{label:"Created",value:s.jsx(ue,{value:e.created_at,compact:!0,relative:!0,now:i})}),s.jsx(B,{label:"Started",value:e.started_at?s.jsx(ue,{value:e.started_at,compact:!0,relative:!0,now:i}):"n/a"}),s.jsx(B,{label:"Updated",value:s.jsx(ue,{value:e.updated_at,compact:!0,relative:!0,now:i})}),s.jsx(B,{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(G,{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(B,{label:"Session ID",value:t.id}),s.jsx(B,{label:"Source",value:t.source})]}),s.jsx("p",{className:"break-words text-xs text-muted [overflow-wrap:anywhere]",children:t.detail})]}):s.jsx(G,{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(G,{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(G,{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:K("grid gap-2 text-sm sm:gap-3",t?"grid-cols-1":"grid-cols-2 xl:grid-cols-4"),children:[s.jsx(B,{label:"Mode",value:s.jsx(Si,{intent:e.intent,actionMode:e.action_mode})}),s.jsx(B,{label:"Intent",value:e.intent}),s.jsx(B,{label:"Addressed",value:n?Jo(r.addressed_to_agent):"n/a"}),s.jsx(B,{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:K("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(G,{text:"Loading runtime and job history..."}):l.length===0?s.jsx(G,{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:K("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:K("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(G,{text:"Loading runtime by user..."}):a.length===0?s.jsx(G,{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:K("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(G,{text:"Loading runtime by repository..."}):a.length===0?s.jsx(G,{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(G,{text:"Loading systemd units..."});if(!e)return s.jsx(G,{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(ge,{tone:"error",text:e.errors[0]}):null,n.length===0?s.jsx(G,{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:K("min-w-0 rounded-md border bg-white px-3 py-2",n==="bad"?"border-red-200":"border-border"),children:[s.jsx("div",{className:K("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:K("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(ge,{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(G,{text:"Loading process activity..."});if(!e)return s.jsx(G,{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:K("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(ge,{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(G,{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(G,{text:"No child process detected for the executor."})]})]})]})}function Yg({alerts:e,loading:t,now:n}){if(t&&!e)return s.jsx(G,{text:"Loading monitor alerts..."});const r=e??[];return r.length===0?s.jsx(G,{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 B({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:K("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:K("h-2.5 w-2.5 rounded-full",t.dot,n&&"animate-live-pulse"),"aria-hidden":!0}),e]})}function G({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 ge({tone:e,text:t}){return s.jsx("div",{className:K("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:K("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:K(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(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,{})})})); diff --git a/src/github_agent_bridge/dashboard_static/index.html b/src/github_agent_bridge/dashboard_static/index.html index 052120c..1989de5 100644 --- a/src/github_agent_bridge/dashboard_static/index.html +++ b/src/github_agent_bridge/dashboard_static/index.html @@ -4,7 +4,7 @@ GitHub Agent Bridge Dashboard - + diff --git a/tests/test_webhook.py b/tests/test_webhook.py index 10fbf4f..d88091a 100644 --- a/tests/test_webhook.py +++ b/tests/test_webhook.py @@ -2621,6 +2621,129 @@ def test_webhook_promotion_gate_is_scoped_to_canary_repositories(tmp_path): assert exceptions["exceptions"] == [] +def test_webhook_primary_gate_uses_global_enabled_repository_scope(tmp_path): + db = tmp_path / "bridge.sqlite3" + JobQueue(db) + policy_path = tmp_path / "policy.json" + policy_path.write_text(json.dumps({ + "trustedOrgs": ["gisce"], + "enabledRepos": ["gisce/in-scope", "gisce/out-of-canary"], + "webhookCanaryRepos": ["gisce/in-scope"], + })) + observation_start = (datetime.now(UTC) - timedelta(days=2)).replace( + microsecond=0 + ).isoformat().replace("+00:00", "Z") + observed_at = (datetime.now(UTC) - timedelta(hours=1)).isoformat() + rows = [ + ("in", "gisce/in-scope", "work_allowed", "work_allowed"), + ("out", "gisce/out-of-canary", "work_allowed", "review_only"), + ] + with sqlite3.connect(db) as con: + con.executemany( + "INSERT INTO webhook_shadow_receipts(" + "delivery_id,event_name,action,event_key,repository,payload_hash," + "payload_json,status,created_at) VALUES(?,?,?,?,?,?,?,?,?)", + [ + ( + f"delivery-{label}", "issue_comment", "created", + f"issue_comment:created:{repository}:1", repository, + f"hash-{label}", "{}", "observed", observed_at, + ) + for label, repository, _email_intent, _webhook_intent in rows + ], + ) + con.executemany( + "INSERT INTO ingest_receipts(" + "source,source_key,payload_hash,event_key,repository,work_key," + "event_type,event_action,bridge_action,decision,work_intent," + "status,created_at,updated_at) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?)", + [ + ( + source, + f"delivery-{label}" if source == "webhook" else f"email-{label}", + f"{source}-{label}", + f"issue_comment:created:{repository}:1", + repository, + f"{repository}#1", + "issue_comment", + "created", + "reply_comment", + "auto_trusted", + email_intent if source == "email" else webhook_intent, + "duplicate" if source == "webhook" else "accepted", + observed_at, + observed_at, + ) + for label, repository, email_intent, webhook_intent in rows + for source in ("email", "webhook") + ], + ) + client = TestClient(create_app(DashboardConfig( + db=db, + require_auth=False, + webhook_secrets=(SECRET,), + webhook_mode="primary", + webhook_policy=policy_path, + webhook_primary_ack=True, + webhook_promotion_observation_days=1, + webhook_coverage_grace_seconds=0, + webhook_observation_started_at=observation_start, + ))) + + summary = client.get("/api/webhooks/github/summary").json()["coverage"] + exceptions = client.get("/api/webhooks/github/exceptions").json() + + assert summary["scope_repositories"] == [ + "gisce/in-scope", "gisce/out-of-canary", + ] + assert summary["both"] == 2 + assert summary["decision_mismatches"] == 1 + assert summary["outside_scope_imap_eligible"] == 0 + assert summary["outside_scope_webhook_eligible"] == 0 + assert summary["promotion_state"] == "blocked" + assert exceptions["scope_repositories"] == [ + "gisce/in-scope", "gisce/out-of-canary", + ] + assert { + (item["kind"], item["repository"]) + for item in exceptions["exceptions"] + } == {("decision_mismatch", "gisce/out-of-canary")} + + policy_path.write_text(json.dumps({ + "trustedOrgs": ["gisce"], + "enabledRepos": [], + "webhookCanaryRepos": ["gisce/in-scope"], + })) + unrestricted_client = TestClient(create_app(DashboardConfig( + db=db, + require_auth=False, + webhook_secrets=(SECRET,), + webhook_mode="primary", + webhook_policy=policy_path, + webhook_primary_ack=True, + webhook_promotion_observation_days=1, + webhook_coverage_grace_seconds=0, + webhook_observation_started_at=observation_start, + ))) + + unrestricted_summary = unrestricted_client.get( + "/api/webhooks/github/summary" + ).json()["coverage"] + unrestricted_exceptions = unrestricted_client.get( + "/api/webhooks/github/exceptions" + ).json() + + assert unrestricted_summary["scope_repositories"] is None + assert unrestricted_summary["both"] == 2 + assert unrestricted_summary["decision_mismatches"] == 1 + assert unrestricted_summary["promotion_state"] == "blocked" + assert unrestricted_exceptions["scope_repositories"] is None + assert { + (item["kind"], item["repository"]) + for item in unrestricted_exceptions["exceptions"] + } == {("decision_mismatch", "gisce/out-of-canary")} + + def test_explicit_webhook_observation_start_resets_promotion_window(tmp_path): db = tmp_path / "bridge.sqlite3" queue = JobQueue(db)