@overdeck/desktop 0.41.0 → 0.41.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/server/public/assets/{chunk-BO2N2NFS-66nJvb0Y.js → chunk-BO2N2NFS-qb3jozf8.js} +4 -4
- package/server/public/assets/{diagram-OG6HWLK6-CnpgVLBi.js → diagram-OG6HWLK6-DCxQdIR-.js} +1 -1
- package/server/public/assets/{dist-CHQsz1no.js → dist--I-KHxVY.js} +1 -1
- package/server/public/assets/{dist-BFQhMul-.js → dist-99bVzL85.js} +3 -3
- package/server/public/assets/{ganttDiagram-6RSMTGT7-CFA1TEUl.js → ganttDiagram-6RSMTGT7-CZQ5wmbx.js} +1 -1
- package/server/public/assets/{highlighted-body-OFNGDK62-DbRNyBRD.js → highlighted-body-OFNGDK62-gddTgxaL.js} +1 -1
- package/server/public/assets/{index-Cc9hNbWG.js → index-w0Cnkax8.js} +7 -7
- package/server/public/assets/{linear-CveL56V8.js → linear-BchPtO53.js} +1 -1
- package/server/public/assets/mermaid-GHXKKRXX-CxNSCT26.js +1 -0
- package/server/public/assets/{pieDiagram-4H26LBE5-BWMp3bl2.js → pieDiagram-4H26LBE5-COGFoOPX.js} +1 -1
- package/server/public/assets/{prod-BtqEDkif.js → prod-CnNbvojd.js} +4 -4
- package/server/public/assets/{quadrantDiagram-W4KKPZXB-BXfFUtKT.js → quadrantDiagram-W4KKPZXB-6DBILYRJ.js} +1 -1
- package/server/public/assets/{sankeyDiagram-5OEKKPKP-D2A4SsFI.js → sankeyDiagram-5OEKKPKP-DTpZ_e2a.js} +1 -1
- package/server/public/assets/{xychartDiagram-2RQKCTM6-BQuEJ-Sx.js → xychartDiagram-2RQKCTM6-guNhhdvI.js} +1 -1
- package/server/public/index.html +1 -1
- package/server/server.js +203 -82
- package/server/public/assets/mermaid-GHXKKRXX-BM8E6NEr.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist--I-KHxVY.js","assets/chunk-BO2N2NFS-qb3jozf8.js","assets/chunk-jRWAZmH_.js","assets/preload-helper-DWTEM3RW.js","assets/html-void-elements-QR3T3anA.js","assets/react-dom-DnbdNgHn.js","assets/jsx-runtime-CEixWuwE.js","assets/styles-DkK0ymA2.css","assets/angular-html-YFZ-qEo2.js","assets/html-CUX3CWXm.js","assets/css-U8jIwd7B.js","assets/javascript-CMCEf6AT.js","assets/angular-ts-B54r7V_n.js","assets/scss-B9l_DMkG.js","assets/apl-CbIltIfi.js","assets/json-C8nZKV3Z.js","assets/xml-DuJ43izn.js","assets/java-DwXGFxfd.js","assets/astro-kQmek0SS.js","assets/postcss-BnjjGg21.js","assets/tsx-BNeRNgay.js","assets/typescript-IaFVOaio.js","assets/blade-_Uc4zzSO.js","assets/html-derivative-UiwgJSUF.js","assets/sql-BoZjwy0s.js","assets/bsl-tWlfQbW2.js","assets/sdbl-Djwdbzuv.js","assets/c-W33irP5E.js","assets/cairo-Cv4i2rVj.js","assets/python-D2TsaySt.js","assets/cobol-Bc0FYmxA.js","assets/coffee-BBgjALtO.js","assets/cpp-_HuA19qD.js","assets/glsl-DB7rO3Hv.js","assets/regexp-Cg9yhs1s.js","assets/crystal-BDsQiQxo.js","assets/shellscript-CtJe2GoF.js","assets/edge-44NINB_l.js","assets/elixir-BvFudoM5.js","assets/elm-Bcvevfeb.js","assets/erb-BOi8y-XV.js","assets/ruby-DXW7M0u6.js","assets/graphql-DtareNVU.js","assets/jsx-7jEc9fS2.js","assets/haml-B_eT_igf.js","assets/lua-DUN8k3vI.js","assets/yaml-C_3EjdK_.js","assets/erlang-BX7w0Ok9.js","assets/markdown-hvmaQbLY.js","assets/fortran-fixed-form-Ctf_ysKA.js","assets/fortran-free-form-BtoOII28.js","assets/fsharp-AvjR9D4f.js","assets/gdresource-Dgj9cWOp.js","assets/gdscript-Cd6RKS1c.js","assets/gdshader-CwGO0jWu.js","assets/git-commit-A3P_opqa.js","assets/diff-B0RdNoYb.js","assets/git-rebase-BCNwX-BV.js","assets/glimmer-js-JE9OX7en.js","assets/glimmer-ts-BlJ_q6LG.js","assets/hack-DxMpTO_4.js","assets/handlebars-CSFAnckr.js","assets/http-ggBV9BA7.js","assets/hurl-Bo3fRJZD.js","assets/csv-7edT5GDb.js","assets/hxml-Y8hs-mDA.js","assets/haxe-Bn69brdB.js","assets/jinja-BNgjwVV6.js","assets/jison-DJFHLmTv.js","assets/julia-CHAVw5nA.js","assets/r-CFG-KSi0.js","assets/just-DA7G4JJf.js","assets/perl-DJbpw6Wl.js","assets/latex-BBzosFBn.js","assets/tex-Djb_8T3k.js","assets/liquid-C5QiuOs4.js","assets/marko-DyeIi_wM.js","assets/less-10_el3T9.js","assets/mdc-B7Bu1-dB.js","assets/nextflow-1Nm7UTNp.js","assets/nextflow-groovy-Dlq_Tqm0.js","assets/nginx-BGk8nZGn.js","assets/nim-Bpgzjh-p.js","assets/php-DQ9BfS13.js","assets/pug-QFMWku9O.js","assets/qml-DbNxxmb8.js","assets/razor-Bm_20ylP.js","assets/csharp-CcF8oQ2Z.js","assets/rst-DiKxgtQw.js","assets/cmake-DbRlIs2B.js","assets/sas-CHMyqMwI.js","assets/shaderlab-BfgwlY9N.js","assets/hlsl-D98WkMKb.js","assets/shellsession-XD3n0AXo.js","assets/soy-B4SQpYLQ.js","assets/sparql-C3_E314U.js","assets/turtle-BQazhbah.js","assets/stata-Dco15DDQ.js","assets/surrealql-DyNEi36w.js","assets/svelte-CQE0K2YM.js","assets/templ-DBGKqxq2.js","assets/go-CfRdqiLh.js","assets/ts-tags-BMQuJI7H.js","assets/twig-CO1mu8ZY.js","assets/vue-BRWc8zFO.js","assets/vue-html-DeoYv0pp.js","assets/vue-vine-DCaC4v_2.js","assets/stylus-DbiVYBZ3.js","assets/xsl-gLKQE284.js","assets/prod-CnNbvojd.js","assets/chunk-K2UTITRG--5Jdo2C5.js","assets/chunk-SRAX5OIU-BDhmsJ9Z.js","assets/chunk-ZUYEQ4TG-B82Qm37l.js","assets/chunk-6U3AYISY-WI_aJXfI.js","assets/chunk-Z3N5DIM6-eUM55sD5.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{a as e,n as t,o as n,r,t as i}from"./chunk-jRWAZmH_.js";import{n as a,t as o}from"./jsx-runtime-CEixWuwE.js";import{t as s}from"./react-dom-DnbdNgHn.js";import{C as c,E as l,S as u,T as d,_ as f,a as p,b as m,d as h,g,h as _,l as v,m as y,n as b,o as x,p as S,s as C,t as w,u as T,v as E,w as D,x as O,y as k}from"./src-CsT-wIyx.js";import{a as A,c as j,d as M,l as N,n as P,o as F,p as I,r as ee,s as te,t as ne}from"./html-void-elements-QR3T3anA.js";import{t as L}from"./preload-helper-DWTEM3RW.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var re=i((e=>{var t=s();e.createRoot=t.createRoot,e.hydrateRoot=t.hydrateRoot})),ie=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(){}},ae=new class extends ie{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},oe={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},se=new class{#e=oe;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function ce(e){setTimeout(e,0)}var le=typeof window>`u`||`Deno`in globalThis;function ue(){}function de(e,t){return typeof e==`function`?e(t):e}function fe(e){return typeof e==`number`&&e>=0&&e!==1/0}function pe(e,t){return Math.max(e+(t||0)-Date.now(),0)}function me(e,t){return typeof e==`function`?e(t):e}function he(e,t){return typeof e==`function`?e(t):e}function ge(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==ve(o,t.options))return!1}else if(!be(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function _e(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(ye(t.options.mutationKey)!==ye(a))return!1}else if(!be(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function ve(e,t){return(t?.queryKeyHashFn||ye)(e)}function ye(e){return JSON.stringify(e,(e,t)=>Te(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function be(e,t){return e===t?!0:typeof e==typeof t&&e&&t&&typeof e==`object`&&typeof t==`object`?Object.keys(t).every(n=>be(e[n],t[n])):!1}var xe=Object.prototype.hasOwnProperty;function Se(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=we(e)&&we(t);if(!r&&!(Te(e)&&Te(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:xe.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=Se(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function Ce(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function we(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Te(e){if(!Ee(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!Ee(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function Ee(e){return Object.prototype.toString.call(e)===`[object Object]`}function De(e){return new Promise(t=>{se.setTimeout(t,e)})}function Oe(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:Se(e,t)}function ke(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function Ae(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var je=Symbol();function Me(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===je?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Ne(e,t){return typeof e==`function`?e(...t):!!e}function Pe(e,t,n){let r=!1,i;return Object.defineProperty(e,`signal`,{enumerable:!0,get:()=>(i??=t(),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var Fe=(()=>{let e=()=>le;return{isServer(){return e()},setIsServer(t){e=t}}})();function Ie(){let e,t,n=new Promise((n,r)=>{e=n,t=r});n.status=`pending`,n.catch(()=>{});function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.resolve=t=>{r({status:`fulfilled`,value:t}),e(t)},n.reject=e=>{r({status:`rejected`,reason:e}),t(e)},n}var Le=ce;function Re(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=Le,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var ze=Re(),Be=new class extends ie{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function Ve(e){return Math.min(1e3*2**e,3e4)}function He(e){return(e??`online`)===`online`?Be.isOnline():!0}var Ue=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function We(e){let t=!1,n=0,r,i=Ie(),a=()=>i.status!==`pending`,o=t=>{if(!a()){let n=new Ue(t);f(n),e.onCancel?.(n)}},s=()=>{t=!0},c=()=>{t=!1},l=()=>ae.isFocused()&&(e.networkMode===`always`||Be.isOnline())&&e.canRun(),u=()=>He(e.networkMode)&&e.canRun(),d=e=>{a()||(r?.(),i.resolve(e))},f=e=>{a()||(r?.(),i.reject(e))},p=()=>new Promise(t=>{r=e=>{(a()||l())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,a()||e.onContinue?.()}),m=()=>{if(a())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(d).catch(r=>{if(a())return;let i=e.retry??(Fe.isServer()?0:3),o=e.retryDelay??Ve,s=typeof o==`function`?o(n,r):o,c=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!c){f(r);return}n++,e.onFail?.(n,r),De(s).then(()=>l()?void 0:p()).then(()=>{t?f(r):m()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:s,continueRetry:c,canStart:u,start:()=>(u()?m():p().then(m),i)}}var Ge=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),fe(this.gcTime)&&(this.#e=se.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Fe.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e!==void 0&&(se.clearTimeout(this.#e),this.#e=void 0)}};function Ke(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{Pe(e,()=>t.signal,()=>n=!0)},u=Me(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject(t.signal.reason);if(r==null&&e.pages.length)return Promise.resolve(e);let a=await u((()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})()),{maxPages:o}=t.options,s=i?Ae:ke;return{pages:s(e.pages,a,o),pageParams:s(e.pageParams,r,o)}};if(i&&a.length){let e=i===`backward`,t=e?Je:qe,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:qe(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.options.persister?t.fetchFn=()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=l}}}function qe(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function Je(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var Ye=class extends Ge{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e){super(),this.#s=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#i=e.client,this.#r=this.#i.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=Qe(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#a?.promise}setOptions(e){if(this.options={...this.#o,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=Qe(this.options);e.data!==void 0&&(this.setState(Ze(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=Oe(this.state.data,e,this.options);return this.#l({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#l({type:`setState`,state:e})}cancel(e){let t=this.#a?.promise;return this.#a?.cancel(e),t?t.then(ue).catch(ue):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>he(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===je||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>me(e.options.staleTime,this)===`static`):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!pe(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#a?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#a?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#a&&(this.#s||this.#c()?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}#c(){return this.state.fetchStatus===`paused`&&this.state.status===`pending`}invalidate(){this.state.isInvalidated||this.#l({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#a?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#a)return this.#a.continueRetry(),this.#a.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,`signal`,{enumerable:!0,get:()=>(this.#s=!0,n.signal)})},i=()=>{let e=Me(this.options,t),n=(()=>{let e={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#s=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(e),e})();(this.#e===`infinite`?Ke(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#n=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#l({type:`fetch`,meta:a.fetchOptions?.meta}),this.#a=We({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof Ue&&e.revert&&this.setState({...this.#n,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#l({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#l({type:`pause`})},onContinue:()=>{this.#l({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await this.#a.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#r.config.onSuccess?.(e,this),this.#r.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof Ue){if(e.silent)return this.#a.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#l({type:`error`,error:e}),this.#r.config.onError?.(e,this),this.#r.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#l(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...Xe(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...Ze(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#n=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),ze.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function Xe(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:He(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function Ze(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function Qe(e){let 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 $e=class extends ie{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=Ie(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),tt(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return nt(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return nt(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof he(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!Ce(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&rt(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||he(this.options.enabled,this.#t)!==he(t.enabled,this.#t)||me(this.options.staleTime,this.#t)!==me(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||he(this.options.enabled,this.#t)!==he(t.enabled,this.#t)||i!==this.#p)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return at(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&(this.trackProp(`data`),!this.options.experimental_prefetchInRender&&this.#o.status===`pending`&&this.#o.reject(Error(`experimental_prefetchInRender feature flag is not enabled`))),Reflect.get(e,n))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(ue)),t}#g(){this.#b();let e=me(this.options.staleTime,this.#t);if(Fe.isServer()||this.#r.isStale||!fe(e))return;let t=pe(this.#r.dataUpdatedAt,e)+1;this.#d=se.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#p=e,!(Fe.isServer()||he(this.options.enabled,this.#t)===!1||!fe(this.#p)||this.#p===0)&&(this.#f=se.setInterval(()=>{(this.options.refetchIntervalInBackground||ae.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d!==void 0&&(se.clearTimeout(this.#d),this.#d=void 0)}#x(){this.#f!==void 0&&(se.clearInterval(this.#f),this.#f=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&tt(e,t),o=i&&rt(e,n,t,r);(a||o)&&(l={...l,...Xe(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,e!==void 0&&(m=`success`,d=Oe(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h)if(i&&d===a?.data&&t.select===this.#c)d=this.#l;else try{this.#c=t.select,d=t.select(d),d=Oe(i?.data,d,t),this.#l=d,this.#s=null}catch(e){this.#s=e}this.#s&&(f=this.#s,d=this.#l,p=Date.now(),m=`error`);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,b=d!==void 0,x={status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:y,isLoading:y,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!b,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&b,isStale:it(e,t),refetch:this.refetch,promise:this.#o,isEnabled:he(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=x.data!==void 0,r=x.status===`error`&&!t,i=e=>{r?e.reject(x.error):t&&e.resolve(x.data)},a=()=>{i(this.#o=x.promise=Ie())},o=this.#o;switch(o.status){case`pending`:e.queryHash===n.queryHash&&i(o);break;case`fulfilled`:(r||x.data!==o.value)&&a();break;case`rejected`:(!r||x.error!==o.reason)&&a();break}}return x}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#u=this.#t),!Ce(t,e)&&(this.#r=t,this.#C({listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#m.size)return!0;let r=new Set(n??this.#m);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})()}))}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#C(e){ze.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function et(e,t){return he(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status===`error`&&he(t.retryOnMount,e)===!1)}function tt(e,t){return et(e,t)||e.state.data!==void 0&&nt(e,t,t.refetchOnMount)}function nt(e,t,n){if(he(t.enabled,e)!==!1&&me(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&it(e,t)}return!1}function rt(e,t,n,r){return(e!==t||he(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&it(e,n)}function it(e,t){return he(t.enabled,e)!==!1&&e.isStaleByTime(me(t.staleTime,e))}function at(e,t){return!Ce(e.getCurrentResult(),t)}var ot=class extends Ge{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||st(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=We({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});let r=this.state.status===`pending`,i=!this.#r.canStart();try{if(r)t();else{this.#i({type:`pending`,variables:e,isPaused:i}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:i})}let a=await this.#r.start();return await this.#n.config.onSuccess?.(a,e,this.state.context,this,n),await this.options.onSuccess?.(a,e,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,e,this.state.context,n),this.#i({type:`success`,data:a}),a}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#n.runNext(this)}}#i(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),ze.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function st(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var ct=class extends ie{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new ot({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=lt(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=lt(e);if(typeof t==`string`){let n=this.#t.get(t);if(n)if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=lt(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}else return!0}runNext(e){let t=lt(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){ze.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>_e(t,e))}findAll(e={}){return this.getAll().filter(t=>_e(e,t))}notify(e){ze.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return ze.batch(()=>Promise.all(e.map(e=>e.continue().catch(ue))))}};function lt(e){return e.options.scope?.id}var ut=class extends ie{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),Ce(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&ye(t.mutationKey)!==ye(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??st();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){ze.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}};function dt(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function ft(e,t,n){let r=e.slice(0);return r[t]=n,r}var pt=class extends ie{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=[];constructor(e,t,n){super(),this.#e=e,this.#r=n,this.#n=[],this.#i=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#i.forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#i.forEach(e=>{e.destroy()})}setQueries(e,t){this.#n=e,this.#r=t,ze.batch(()=>{let e=this.#i,t=this.#p(this.#n);t.forEach(e=>e.observer.setOptions(e.defaultedQueryOptions));let n=t.map(e=>e.observer),r=n.map(e=>e.getCurrentResult()),i=e.length!==n.length,a=n.some((t,n)=>t!==e[n]),o=i||a,s=o?!0:r.some((e,t)=>{let n=this.#t[t];return!n||!Ce(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(dt(e,n).forEach(e=>{e.destroy()}),dt(n,e).forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})),this.#h()))})}getCurrentResult(){return this.#t}getQueries(){return this.#i.map(e=>e.getCurrentQuery())}getObservers(){return this.#i}getOptimisticResult(e,t){let n=this.#p(e),r=n.map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions)),i=n.map(e=>e.defaultedQueryOptions.queryHash);return[r,e=>this.#d(e??r,t,i),()=>this.#u(r,n)]}#u(e,t){return t.map((n,r)=>{let i=e[r];return n.defaultedQueryOptions.notifyOnChangeProps?i:n.observer.trackResult(i,e=>{t.forEach(t=>{t.observer.trackProp(e)})})})}#d(e,t,n){if(t){let r=this.#c,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((e,t)=>e!==r[t]));return(!this.#a||this.#t!==this.#s||i||t!==this.#o)&&(this.#o=t,this.#s=this.#t,n!==void 0&&(this.#c=n),this.#a=Se(this.#a,t(e))),this.#a}return e}#f(){return this.#r?.combine!==void 0&&this.#i.some((e,t)=>e.options.suspense&&this.#t[t]?.data===void 0)}#p(e){let t=new Map;this.#i.forEach(e=>{let n=e.options.queryHash;if(!n)return;let r=t.get(n);r?r.push(e):t.set(n,[e])});let n=[];return e.forEach(e=>{let r=this.#e.defaultQueryOptions(e),i=t.get(r.queryHash)?.shift()??new $e(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=ft(this.#t,n,t),this.#h())}#h(){if(this.hasListeners()){let e=this.#u(this.#t,this.#l),t=this.#f(),n=this.#a,r=t?n:this.#d(e,this.#r?.combine);(t||n!==r)&&ze.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},mt=class extends ie{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??ve(r,t),a=this.get(i);return a||(a=new Ye({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){ze.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>ge(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>ge(e,t)):t}notify(e){ze.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){ze.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){ze.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},ht=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new mt,this.#t=e.mutationCache||new ct,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=ae.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=Be.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(me(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=de(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return ze.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;ze.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return ze.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=ze.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(ue).catch(ue)}invalidateQueries(e,t={}){return ze.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=ze.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(ue)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(ue)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(me(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(ue).catch(ue)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(ue).catch(ue)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return Be.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(ye(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{be(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(ye(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{be(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=ve(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===je&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},R=n(a(),1),z=o(),gt=R.createContext(void 0),_t=e=>{let t=R.useContext(gt);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},vt=({client:e,children:t})=>(R.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,z.jsx)(gt.Provider,{value:e,children:t})),yt=R.createContext(!1),bt=()=>R.useContext(yt);yt.Provider;function xt(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var St=R.createContext(xt()),Ct=()=>R.useContext(St),wt=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?Ne(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},Tt=e=>{R.useEffect(()=>{e.clearReset()},[e])},Et=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||Ne(n,[e.error,r])),Dt=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},Ot=(e,t)=>e.isLoading&&e.isFetching&&!t,kt=(e,t)=>e?.suspense&&t.isPending,At=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function jt({queries:e,...t},n){let r=_t(n),i=bt(),a=Ct(),o=R.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{Dt(e),wt(e,a,r.getQueryCache().get(e.queryHash))}),Tt(a);let[s]=R.useState(()=>new pt(r,o,t)),[c,l,u]=s.getOptimisticResult(o,t.combine),d=!i&&t.subscribed!==!1;R.useSyncExternalStore(R.useCallback(e=>d?s.subscribe(ze.batchCalls(e)):ue,[s,d]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),R.useEffect(()=>{s.setQueries(o,t)},[o,t,s]);let f=c.some((e,t)=>kt(o[t],e))?c.flatMap((e,t)=>{let n=o[t];return n&&kt(n,e)?At(n,new $e(r,n),a):[]}):[];if(f.length>0)throw Promise.all(f);let p=c.find((e,t)=>{let n=o[t];return n&&Et({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(p?.error)throw p.error;return l(u())}function Mt(e,t,n){let r=bt(),i=Ct(),a=_t(n),o=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o);let s=a.getQueryCache().get(o.queryHash);o._optimisticResults=r?`isRestoring`:`optimistic`,Dt(o),wt(o,i,s),Tt(i);let c=!a.getQueryCache().get(o.queryHash),[l]=R.useState(()=>new t(a,o)),u=l.getOptimisticResult(o),d=!r&&e.subscribed!==!1;if(R.useSyncExternalStore(R.useCallback(e=>{let t=d?l.subscribe(ze.batchCalls(e)):ue;return l.updateResult(),t},[l,d]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),R.useEffect(()=>{l.setOptions(o)},[o,l]),kt(o,u))throw At(o,l,i);if(Et({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw u.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,u),o.experimental_prefetchInRender&&!Fe.isServer()&&Ot(u,r)&&(c?At(o,l,i):s?.promise)?.catch(ue).finally(()=>{l.updateResult()}),o.notifyOnChangeProps?u:l.trackResult(u)}function B(e,t){return Mt(e,$e,t)}function Nt(e,t){let n=_t(t),[r]=R.useState(()=>new ut(n,e));R.useEffect(()=>{r.setOptions(e)},[r,e]);let i=R.useSyncExternalStore(R.useCallback(e=>r.subscribe(ze.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=R.useCallback((e,t)=>{r.mutate(e,t).catch(ue)},[r]);if(i.error&&Ne(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}var eee=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),Pt=(...e)=>e.filter((e,t,n)=>!!e&&n.indexOf(e)===t).join(` `),Ft={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},It=(0,R.forwardRef)(({color:e=`currentColor`,size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...s},c)=>(0,R.createElement)(`svg`,{ref:c,...Ft,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:Pt(`lucide`,i),...s},[...o.map(([e,t])=>(0,R.createElement)(e,t)),...Array.isArray(a)?a:[a]])),V=(e,t)=>{let n=(0,R.forwardRef)(({className:n,...r},i)=>(0,R.createElement)(It,{ref:i,iconNode:t,className:Pt(`lucide-${eee(e)}`,n),...r}));return n.displayName=`${e}`,n},Lt=V(`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`}]]),Rt=V(`Anchor`,[[`path`,{d:`M12 22V8`,key:`qkxhtm`}],[`path`,{d:`M5 12H2a10 10 0 0 0 20 0h-3`,key:`1hv3nh`}],[`circle`,{cx:`12`,cy:`5`,r:`3`,key:`rqqgnr`}]]),zt=V(`Archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]),Bt=V(`ArrowLeftRight`,[[`path`,{d:`M8 3 4 7l4 4`,key:`9rb6wj`}],[`path`,{d:`M4 7h16`,key:`6tx8e3`}],[`path`,{d:`m16 21 4-4-4-4`,key:`siv7j2`}],[`path`,{d:`M20 17H4`,key:`h6l3hr`}]]),Vt=V(`ArrowRightLeft`,[[`path`,{d:`m16 3 4 4-4 4`,key:`1x1c3m`}],[`path`,{d:`M20 7H4`,key:`zbl0bi`}],[`path`,{d:`m8 21-4-4 4-4`,key:`h9nckh`}],[`path`,{d:`M4 17h16`,key:`g4d7ey`}]]),tee=V(`ArrowRight`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),Ht=V(`BadgeCheck`,[[`path`,{d:`M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z`,key:`3c2336`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),Ut=V(`BarChart3`,[[`path`,{d:`M3 3v18h18`,key:`1s2lah`}],[`path`,{d:`M18 17V9`,key:`2bz60n`}],[`path`,{d:`M13 17V5`,key:`1frdt8`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]]),Wt=V(`Beaker`,[[`path`,{d:`M4.5 3h15`,key:`c7n0jr`}],[`path`,{d:`M6 3v16a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V3`,key:`m1uhx7`}],[`path`,{d:`M6 14h12`,key:`4cwo0f`}]]),Gt=V(`BellOff`,[[`path`,{d:`M8.7 3A6 6 0 0 1 18 8a21.3 21.3 0 0 0 .6 5`,key:`o7mx20`}],[`path`,{d:`M17 17H3s3-2 3-9a4.67 4.67 0 0 1 .3-1.7`,key:`16f1lm`}],[`path`,{d:`M10.3 21a1.94 1.94 0 0 0 3.4 0`,key:`qgo35s`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),Kt=V(`Bell`,[[`path`,{d:`M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9`,key:`1qo2s2`}],[`path`,{d:`M10.3 21a1.94 1.94 0 0 0 3.4 0`,key:`qgo35s`}]]),qt=V(`BookOpen`,[[`path`,{d:`M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z`,key:`vv98re`}],[`path`,{d:`M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z`,key:`1cyq3y`}]]),Jt=V(`BookText`,[[`path`,{d:`M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H20v20H6.5a2.5 2.5 0 0 1 0-5H20`,key:`t4utmx`}],[`path`,{d:`M8 7h6`,key:`1f0q6e`}],[`path`,{d:`M8 11h8`,key:`vwpz6n`}]]),Yt=V(`Bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),Xt=V(`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`}]]),Zt=V(`Brush`,[[`path`,{d:`m9.06 11.9 8.07-8.06a2.85 2.85 0 1 1 4.03 4.03l-8.06 8.08`,key:`1styjt`}],[`path`,{d:`M7.07 14.94c-1.66 0-3 1.35-3 3.02 0 1.33-2.5 1.52-2 2.02 1.08 1.1 2.49 2.02 4 2.02 2.2 0 4-1.8 4-4.04a3.01 3.01 0 0 0-3-3.02z`,key:`z0l1mu`}]]),Qt=V(`Bug`,[[`path`,{d:`m8 2 1.88 1.88`,key:`fmnt4t`}],[`path`,{d:`M14.12 3.88 16 2`,key:`qol33r`}],[`path`,{d:`M9 7.13v-1a3.003 3.003 0 1 1 6 0v1`,key:`d7y7pr`}],[`path`,{d:`M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6`,key:`xs1cw7`}],[`path`,{d:`M12 20v-9`,key:`1qisl0`}],[`path`,{d:`M6.53 9C4.6 8.8 3 7.1 3 5`,key:`32zzws`}],[`path`,{d:`M6 13H2`,key:`82j7cp`}],[`path`,{d:`M3 21c0-2.1 1.7-3.9 3.8-4`,key:`4p0ekp`}],[`path`,{d:`M20.97 5c0 2.1-1.6 3.8-3.5 4`,key:`18gb23`}],[`path`,{d:`M22 13h-4`,key:`1jl80f`}],[`path`,{d:`M17.2 17c2.1.1 3.8 1.9 3.8 4`,key:`k3fwyw`}]]),$t=V(`Check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),en=V(`ChevronDown`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),tn=V(`ChevronLeft`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),nn=V(`ChevronRight`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),rn=V(`ChevronUp`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),nee=V(`ChevronsLeft`,[[`path`,{d:`m11 17-5-5 5-5`,key:`13zhaf`}],[`path`,{d:`m18 17-5-5 5-5`,key:`h8a8et`}]]),ree=V(`ChevronsRight`,[[`path`,{d:`m6 17 5-5-5-5`,key:`xnjwq`}],[`path`,{d:`m13 17 5-5-5-5`,key:`17xmmf`}]]),an=V(`CircleAlert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),on=V(`CircleCheckBig`,[[`path`,{d:`M22 11.08V12a10 10 0 1 1-5.93-9.14`,key:`g774vq`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]),sn=V(`CircleCheck`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),iee=V(`CircleDot`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}]]),cn=V(`CircleHelp`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),ln=V(`CircleStop`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`rect`,{width:`6`,height:`6`,x:`9`,y:`9`,key:`1wrtvo`}]]),un=V(`CircleX`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),dn=V(`Circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),fn=V(`ClipboardCheck`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}],[`path`,{d:`m9 14 2 2 4-4`,key:`df797q`}]]),pn=V(`ClipboardCopy`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2`,key:`4jdomd`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v4`,key:`3hqy98`}],[`path`,{d:`M21 14H11`,key:`1bme5i`}],[`path`,{d:`m15 10-4 4 4 4`,key:`5dvupr`}]]),mn=V(`ClipboardList`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}],[`path`,{d:`M12 11h4`,key:`1jrz19`}],[`path`,{d:`M12 16h4`,key:`n85exb`}],[`path`,{d:`M8 11h.01`,key:`1dfujw`}],[`path`,{d:`M8 16h.01`,key:`18s6g9`}]]),hn=V(`Clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`polyline`,{points:`12 6 12 12 16 14`,key:`68esgv`}]]),gn=V(`CodeXml`,[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]]),_n=V(`Code`,[[`polyline`,{points:`16 18 22 12 16 6`,key:`z7tu5w`}],[`polyline`,{points:`8 6 2 12 8 18`,key:`1eg1df`}]]),vn=V(`Columns2`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M12 3v18`,key:`108xh3`}]]),yn=V(`Compass`,[[`path`,{d:`m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z`,key:`9ktpf1`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),bn=V(`Container`,[[`path`,{d:`M22 7.7c0-.6-.4-1.2-.8-1.5l-6.3-3.9a1.72 1.72 0 0 0-1.7 0l-10.3 6c-.5.2-.9.8-.9 1.4v6.6c0 .5.4 1.2.8 1.5l6.3 3.9a1.72 1.72 0 0 0 1.7 0l10.3-6c.5-.3.9-1 .9-1.5Z`,key:`1t2lqe`}],[`path`,{d:`M10 21.9V14L2.1 9.1`,key:`o7czzq`}],[`path`,{d:`m10 14 11.9-6.9`,key:`zm5e20`}],[`path`,{d:`M14 19.8v-8.1`,key:`159ecu`}],[`path`,{d:`M18 17.5V9.4`,key:`11uown`}]]),xn=V(`Copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),Sn=V(`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`}]]),Cn=V(`Database`,[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]),wn=V(`DollarSign`,[[`line`,{x1:`12`,x2:`12`,y1:`2`,y2:`22`,key:`7eqyqh`}],[`path`,{d:`M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6`,key:`1b0p4s`}]]),Tn=V(`Download`,[[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`polyline`,{points:`7 10 12 15 17 10`,key:`2ggqvy`}],[`line`,{x1:`12`,x2:`12`,y1:`15`,y2:`3`,key:`1vk2je`}]]),En=V(`DraftingCompass`,[[`circle`,{cx:`12`,cy:`5`,r:`2`,key:`f1ur92`}],[`path`,{d:`m3 21 8.02-14.26`,key:`1ssaw4`}],[`path`,{d:`m12.99 6.74 1.93 3.44`,key:`iwagvd`}],[`path`,{d:`M19 12c-3.87 4-10.13 4-14 0`,key:`1tsu18`}],[`path`,{d:`m21 21-2.16-3.84`,key:`vylbct`}]]),Dn=V(`EllipsisVertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),On=V(`Ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),kn=V(`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`}]]),aee=V(`EyeOff`,[[`path`,{d:`M9.88 9.88a3 3 0 1 0 4.24 4.24`,key:`1jxqfv`}],[`path`,{d:`M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68`,key:`9wicm4`}],[`path`,{d:`M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61`,key:`1jreej`}],[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}]]),An=V(`Eye`,[[`path`,{d:`M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z`,key:`rwhkz3`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),oee=V(`FileArchive`,[[`path`,{d:`M10 12v-1`,key:`v7bkov`}],[`path`,{d:`M10 18v-2`,key:`1cjy8d`}],[`path`,{d:`M10 7V6`,key:`dljcrl`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M15.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v16a2 2 0 0 0 .274 1.01`,key:`gkbcor`}],[`circle`,{cx:`10`,cy:`20`,r:`2`,key:`1xzdoj`}]]),see=V(`FileCode2`,[[`path`,{d:`M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4`,key:`1pf5j1`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`m5 12-3 3 3 3`,key:`oke12k`}],[`path`,{d:`m9 18 3-3-3-3`,key:`112psh`}]]),jn=V(`FileCode`,[[`path`,{d:`M10 12.5 8 15l2 2.5`,key:`1tg20x`}],[`path`,{d:`m14 12.5 2 2.5-2 2.5`,key:`yinavb`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z`,key:`1mlx9k`}]]),cee=V(`FileCog`,[[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`m3.2 12.9-.9-.4`,key:`1i3dj5`}],[`path`,{d:`m3.2 15.1-.9.4`,key:`1fvgj0`}],[`path`,{d:`M4.677 21.5a2 2 0 0 0 1.313.5H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v2.5`,key:`1yo3oz`}],[`path`,{d:`m4.9 11.2-.4-.9`,key:`otmhb9`}],[`path`,{d:`m4.9 16.8-.4.9`,key:`1b8z07`}],[`path`,{d:`m7.5 10.3-.4.9`,key:`11k65u`}],[`path`,{d:`m7.5 17.7-.4-.9`,key:`431x55`}],[`path`,{d:`m9.7 12.5-.9.4`,key:`87sjan`}],[`path`,{d:`m9.7 15.5-.9-.4`,key:`khqm91`}],[`circle`,{cx:`6`,cy:`14`,r:`3`,key:`a1xfv6`}]]),lee=V(`FileImage`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`circle`,{cx:`10`,cy:`12`,r:`2`,key:`737tya`}],[`path`,{d:`m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22`,key:`wt3hpn`}]]),uee=V(`FileJson`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1`,key:`1oajmo`}],[`path`,{d:`M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1`,key:`mpwhp6`}]]),dee=V(`FilePenLine`,[[`path`,{d:`m18 5-2.414-2.414A2 2 0 0 0 14.172 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2`,key:`142zxg`}],[`path`,{d:`M21.378 12.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z`,key:`2t3380`}],[`path`,{d:`M8 18h1`,key:`13wk12`}]]),fee=V(`FileSearch`,[[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M4.268 21a2 2 0 0 0 1.727 1H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3`,key:`ms7g94`}],[`path`,{d:`m9 18-1.5-1.5`,key:`1j6qii`}],[`circle`,{cx:`5`,cy:`14`,r:`3`,key:`ufru5t`}]]),Mn=V(`FileText`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),pee=V(`File`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}]]),Nn=V(`Filter`,[[`polygon`,{points:`22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3`,key:`1yg77f`}]]),Pn=V(`Flag`,[[`path`,{d:`M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z`,key:`i9b6wo`}],[`line`,{x1:`4`,x2:`4`,y1:`22`,y2:`15`,key:`1cm3nv`}]]),Fn=V(`FlaskConical`,[[`path`,{d:`M10 2v7.527a2 2 0 0 1-.211.896L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-5.069-10.127A2 2 0 0 1 14 9.527V2`,key:`pzvekw`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}],[`path`,{d:`M7 16h10`,key:`wp8him`}]]),mee=V(`FolderClosed`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}],[`path`,{d:`M2 10h20`,key:`1ir3d8`}]]),In=V(`FolderOpen`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),Ln=V(`FolderPlus`,[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),Rn=V(`Folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),zn=V(`Gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),Bn=V(`Gem`,[[`path`,{d:`M6 3h12l4 6-10 13L2 9Z`,key:`1pcd5k`}],[`path`,{d:`M11 3 8 9l4 13 4-13-3-6`,key:`1fcu3u`}],[`path`,{d:`M2 9h20`,key:`16fsjt`}]]),Vn=V(`GitBranchPlus`,[[`path`,{d:`M6 3v12`,key:`qpgusn`}],[`path`,{d:`M18 9a3 3 0 1 0 0-6 3 3 0 0 0 0 6z`,key:`1d02ji`}],[`path`,{d:`M6 21a3 3 0 1 0 0-6 3 3 0 0 0 0 6z`,key:`chk6ph`}],[`path`,{d:`M15 6a9 9 0 0 0-9 9`,key:`or332x`}],[`path`,{d:`M18 15v6`,key:`9wciyi`}],[`path`,{d:`M21 18h-6`,key:`139f0c`}]]),Hn=V(`GitBranch`,[[`line`,{x1:`6`,x2:`6`,y1:`3`,y2:`15`,key:`17qcm7`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`path`,{d:`M18 9a9 9 0 0 1-9 9`,key:`n2h4wq`}]]),Un=V(`GitCommitHorizontal`,[[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}],[`line`,{x1:`3`,x2:`9`,y1:`12`,y2:`12`,key:`1dyftd`}],[`line`,{x1:`15`,x2:`21`,y1:`12`,y2:`12`,key:`oup4p8`}]]),Wn=V(`GitFork`,[[`circle`,{cx:`12`,cy:`18`,r:`3`,key:`1mpf1b`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`path`,{d:`M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9`,key:`1uq4wg`}],[`path`,{d:`M12 12v3`,key:`158kv8`}]]),Gn=V(`GitMerge`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 21V9a9 9 0 0 0 9 9`,key:`7kw0sc`}]]),Kn=V(`GitPullRequest`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v7`,key:`1yeb86`}],[`line`,{x1:`6`,x2:`6`,y1:`9`,y2:`21`,key:`rroup`}]]),qn=V(`Github`,[[`path`,{d:`M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4`,key:`tonef`}],[`path`,{d:`M9 18c-4.51 2-5-2-7-2`,key:`9comsn`}]]),Jn=V(`Globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),Yn=V(`Hammer`,[[`path`,{d:`m15 12-8.373 8.373a1 1 0 1 1-3-3L12 9`,key:`eefl8a`}],[`path`,{d:`m18 15 4-4`,key:`16gjal`}],[`path`,{d:`m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172V7l-2.26-2.26a6 6 0 0 0-4.202-1.756L9 2.96l.92.82A6.18 6.18 0 0 1 12 8.4V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5`,key:`b7pghm`}]]),hee=V(`HeartPulse`,[[`path`,{d:`M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z`,key:`c3ymky`}],[`path`,{d:`M3.22 12H9.5l.5-1 2 4.5 2-7 1.5 3.5h5.27`,key:`1uw2ng`}]]),Xn=V(`History`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),Zn=V(`House`,[[`path`,{d:`M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8`,key:`5wwlr5`}],[`path`,{d:`M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`1d0kgt`}]]),gee=V(`Infinity`,[[`path`,{d:`M12 12c-2-2.67-4-4-6-4a4 4 0 1 0 0 8c2 0 4-1.33 6-4Zm0 0c2 2.67 4 4 6 4a4 4 0 0 0 0-8c-2 0-4 1.33-6 4Z`,key:`1z0uae`}]]),Qn=V(`Info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),$n=V(`Key`,[[`path`,{d:`m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4`,key:`g0fldk`}],[`path`,{d:`m21 2-9.6 9.6`,key:`1j0ho8`}],[`circle`,{cx:`7.5`,cy:`15.5`,r:`5.5`,key:`yqb3hr`}]]),er=V(`Layers`,[[`path`,{d:`m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z`,key:`8b97xw`}],[`path`,{d:`m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65`,key:`dd6zsq`}],[`path`,{d:`m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65`,key:`ep9fru`}]]),tr=V(`LayoutGrid`,[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]),nr=V(`ListOrdered`,[[`line`,{x1:`10`,x2:`21`,y1:`6`,y2:`6`,key:`76qw6h`}],[`line`,{x1:`10`,x2:`21`,y1:`12`,y2:`12`,key:`16nom4`}],[`line`,{x1:`10`,x2:`21`,y1:`18`,y2:`18`,key:`u3jurt`}],[`path`,{d:`M4 6h1v4`,key:`cnovpq`}],[`path`,{d:`M4 10h2`,key:`16xx2s`}],[`path`,{d:`M6 18H4c0-1 2-2 2-3s-1-1.5-2-1`,key:`m9a95d`}]]),rr=V(`ListTodo`,[[`rect`,{x:`3`,y:`5`,width:`6`,height:`6`,rx:`1`,key:`1defrl`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`M13 6h8`,key:`15sg57`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 18h8`,key:`oe0vm4`}]]),ir=V(`List`,[[`line`,{x1:`8`,x2:`21`,y1:`6`,y2:`6`,key:`7ey8pc`}],[`line`,{x1:`8`,x2:`21`,y1:`12`,y2:`12`,key:`rjfblc`}],[`line`,{x1:`8`,x2:`21`,y1:`18`,y2:`18`,key:`c3b1m8`}],[`line`,{x1:`3`,x2:`3.01`,y1:`6`,y2:`6`,key:`1g7gq3`}],[`line`,{x1:`3`,x2:`3.01`,y1:`12`,y2:`12`,key:`1pjlvk`}],[`line`,{x1:`3`,x2:`3.01`,y1:`18`,y2:`18`,key:`28t2mc`}]]),ar=V(`LoaderCircle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),or=V(`Lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),_ee=V(`Maximize2`,[[`polyline`,{points:`15 3 21 3 21 9`,key:`mznyad`}],[`polyline`,{points:`9 21 3 21 3 15`,key:`1avn1i`}],[`line`,{x1:`21`,x2:`14`,y1:`3`,y2:`10`,key:`ota7mn`}],[`line`,{x1:`3`,x2:`10`,y1:`21`,y2:`14`,key:`1atl0r`}]]),vee=V(`MemoryStick`,[[`path`,{d:`M6 19v-3`,key:`1nvgqn`}],[`path`,{d:`M10 19v-3`,key:`iu8nkm`}],[`path`,{d:`M14 19v-3`,key:`kcehxu`}],[`path`,{d:`M18 19v-3`,key:`1vh91z`}],[`path`,{d:`M8 11V9`,key:`63erz4`}],[`path`,{d:`M16 11V9`,key:`fru6f3`}],[`path`,{d:`M12 11V9`,key:`ha00sb`}],[`path`,{d:`M2 15h20`,key:`16ne18`}],[`path`,{d:`M2 7a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v1.1a2 2 0 0 0 0 3.837V17a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-5.1a2 2 0 0 0 0-3.837Z`,key:`lhddv3`}]]),yee=V(`Menu`,[[`line`,{x1:`4`,x2:`20`,y1:`12`,y2:`12`,key:`1e0a9i`}],[`line`,{x1:`4`,x2:`20`,y1:`6`,y2:`6`,key:`1owob3`}],[`line`,{x1:`4`,x2:`20`,y1:`18`,y2:`18`,key:`yk5zj1`}]]),bee=V(`MessageCircleQuestion`,[[`path`,{d:`M7.9 20A9 9 0 1 0 4 16.1L2 22Z`,key:`vv11sd`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),sr=V(`MessageCircle`,[[`path`,{d:`M7.9 20A9 9 0 1 0 4 16.1L2 22Z`,key:`vv11sd`}]]),xee=V(`MessageSquarePlus`,[[`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`,key:`1lielz`}],[`path`,{d:`M12 7v6`,key:`lw1j43`}],[`path`,{d:`M9 10h6`,key:`9gxzsh`}]]),cr=V(`MessageSquare`,[[`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`,key:`1lielz`}]]),See=V(`MessagesSquare`,[[`path`,{d:`M14 9a2 2 0 0 1-2 2H6l-4 4V4c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2z`,key:`jj09z8`}],[`path`,{d:`M18 9h2a2 2 0 0 1 2 2v11l-4-4h-6a2 2 0 0 1-2-2v-1`,key:`1cx29u`}]]),lr=V(`MicOff`,[[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}],[`path`,{d:`M18.89 13.23A7.12 7.12 0 0 0 19 12v-2`,key:`80xlxr`}],[`path`,{d:`M5 10v2a7 7 0 0 0 12 5`,key:`p2k8kg`}],[`path`,{d:`M15 9.34V5a3 3 0 0 0-5.68-1.33`,key:`1gzdoj`}],[`path`,{d:`M9 9v3a3 3 0 0 0 5.12 2.12`,key:`r2i35w`}],[`line`,{x1:`12`,x2:`12`,y1:`19`,y2:`22`,key:`x3vr5v`}]]),ur=V(`Mic`,[[`path`,{d:`M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z`,key:`131961`}],[`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`,key:`1vc78b`}],[`line`,{x1:`12`,x2:`12`,y1:`19`,y2:`22`,key:`x3vr5v`}]]),Cee=V(`Minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),dr=V(`Monitor`,[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]),fr=V(`Moon`,[[`path`,{d:`M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z`,key:`a7tn18`}]]),pr=V(`Network`,[[`rect`,{x:`16`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`4q2zg0`}],[`rect`,{x:`2`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`8cvhb9`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`6`,rx:`1`,key:`1egb70`}],[`path`,{d:`M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3`,key:`1jsf9p`}],[`path`,{d:`M12 12V8`,key:`2874zd`}]]),wee=V(`Package`,[[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}],[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]),Tee=V(`Palette`,[[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`path`,{d:`M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z`,key:`12rzf8`}]]),Eee=V(`Pause`,[[`rect`,{x:`14`,y:`4`,width:`4`,height:`16`,rx:`1`,key:`zuxfzm`}],[`rect`,{x:`6`,y:`4`,width:`4`,height:`16`,rx:`1`,key:`1okwgv`}]]),Dee=V(`PenLine`,[[`path`,{d:`M12 20h9`,key:`t2du7b`}],[`path`,{d:`M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z`,key:`1ykcvy`}]]),mr=V(`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`}]]),Oee=V(`PinOff`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89`,key:`znwnzq`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11`,key:`c9qhm2`}]]),kee=V(`Pin`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]),hr=V(`Play`,[[`polygon`,{points:`6 3 20 12 6 21 6 3`,key:`1oa8hb`}]]),gr=V(`Plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),Aee=V(`Radio`,[[`path`,{d:`M4.9 19.1C1 15.2 1 8.8 4.9 4.9`,key:`1vaf9d`}],[`path`,{d:`M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5`,key:`u1ii0m`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}],[`path`,{d:`M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5`,key:`1j5fej`}],[`path`,{d:`M19.1 4.9C23 8.8 23 15.1 19.1 19`,key:`10b0cb`}]]),_r=V(`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`}]]),vr=V(`Rocket`,[[`path`,{d:`M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z`,key:`m3kijz`}],[`path`,{d:`m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z`,key:`1fmvmk`}],[`path`,{d:`M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0`,key:`1f8sc4`}],[`path`,{d:`M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5`,key:`qeys4`}]]),yr=V(`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`}]]),jee=V(`RotateCw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]),Mee=V(`Route`,[[`circle`,{cx:`6`,cy:`19`,r:`3`,key:`1kj8tv`}],[`path`,{d:`M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15`,key:`1d8sl`}],[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}]]),br=V(`Rows2`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}]]),Nee=V(`Rows3`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M21 9H3`,key:`1338ky`}],[`path`,{d:`M21 15H3`,key:`9uk58r`}]]),xr=V(`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`}]]),Sr=V(`Scissors`,[[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M8.12 8.12 12 12`,key:`1alkpv`}],[`path`,{d:`M20 4 8.12 15.88`,key:`xgtan2`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`path`,{d:`M14.8 14.8 20 20`,key:`ptml3r`}]]),Cr=V(`ScrollText`,[[`path`,{d:`M15 12h-5`,key:`r7krc0`}],[`path`,{d:`M15 8h-5`,key:`1khuty`}],[`path`,{d:`M19 17V5a2 2 0 0 0-2-2H4`,key:`zz82l3`}],[`path`,{d:`M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3`,key:`1ph1d7`}]]),wr=V(`Search`,[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]),Pee=V(`SendHorizontal`,[[`path`,{d:`m3 3 3 9-3 9 19-9Z`,key:`1aobqy`}],[`path`,{d:`M6 12h16`,key:`s4cdu5`}]]),Fee=V(`Server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),Tr=V(`Settings`,[[`path`,{d:`M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z`,key:`1qme2f`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),Er=V(`Share2`,[[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}],[`circle`,{cx:`6`,cy:`12`,r:`3`,key:`w7nqdw`}],[`circle`,{cx:`18`,cy:`19`,r:`3`,key:`1xt0gg`}],[`line`,{x1:`8.59`,x2:`15.42`,y1:`13.51`,y2:`17.49`,key:`47mynk`}],[`line`,{x1:`15.41`,x2:`8.59`,y1:`6.51`,y2:`10.49`,key:`1n3mei`}]]),Dr=V(`ShieldAlert`,[[`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:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),Or=V(`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`}]]),kr=V(`Shield`,[[`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`}]]),Iee=V(`ShipWheel`,[[`circle`,{cx:`12`,cy:`12`,r:`8`,key:`46899m`}],[`path`,{d:`M12 2v7.5`,key:`1e5rl5`}],[`path`,{d:`m19 5-5.23 5.23`,key:`1ezxxf`}],[`path`,{d:`M22 12h-7.5`,key:`le1719`}],[`path`,{d:`m19 19-5.23-5.23`,key:`p3fmgn`}],[`path`,{d:`M12 14.5V22`,key:`dgcmos`}],[`path`,{d:`M10.23 13.77 5 19`,key:`qwopd4`}],[`path`,{d:`M9.5 12H2`,key:`r7bup8`}],[`path`,{d:`M10.23 10.23 5 5`,key:`k2y7lj`}],[`circle`,{cx:`12`,cy:`12`,r:`2.5`,key:`ix0uyj`}]]),Lee=V(`SkipForward`,[[`polygon`,{points:`5 4 15 12 5 20 5 4`,key:`16p6eg`}],[`line`,{x1:`19`,x2:`19`,y1:`5`,y2:`19`,key:`futhcm`}]]),Ree=V(`Skull`,[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`path`,{d:`M8 20v2h8v-2`,key:`ded4og`}],[`path`,{d:`m12.5 17-.5-1-.5 1h1z`,key:`3me087`}],[`path`,{d:`M16 20a2 2 0 0 0 1.56-3.25 8 8 0 1 0-11.12 0A2 2 0 0 0 8 20`,key:`xq9p5u`}]]),zee=V(`SlidersHorizontal`,[[`line`,{x1:`21`,x2:`14`,y1:`4`,y2:`4`,key:`obuewd`}],[`line`,{x1:`10`,x2:`3`,y1:`4`,y2:`4`,key:`1q6298`}],[`line`,{x1:`21`,x2:`12`,y1:`12`,y2:`12`,key:`1iu8h1`}],[`line`,{x1:`8`,x2:`3`,y1:`12`,y2:`12`,key:`ntss68`}],[`line`,{x1:`21`,x2:`16`,y1:`20`,y2:`20`,key:`14d8ph`}],[`line`,{x1:`12`,x2:`3`,y1:`20`,y2:`20`,key:`m0wm8r`}],[`line`,{x1:`14`,x2:`14`,y1:`2`,y2:`6`,key:`14e1ph`}],[`line`,{x1:`8`,x2:`8`,y1:`10`,y2:`14`,key:`1i6ji0`}],[`line`,{x1:`16`,x2:`16`,y1:`18`,y2:`22`,key:`1lctlv`}]]),Bee=V(`Snowflake`,[[`line`,{x1:`2`,x2:`22`,y1:`12`,y2:`12`,key:`1dnqot`}],[`line`,{x1:`12`,x2:`12`,y1:`2`,y2:`22`,key:`7eqyqh`}],[`path`,{d:`m20 16-4-4 4-4`,key:`rquw4f`}],[`path`,{d:`m4 8 4 4-4 4`,key:`12s3z9`}],[`path`,{d:`m16 4-4 4-4-4`,key:`1tumq1`}],[`path`,{d:`m8 20 4-4 4 4`,key:`9p200w`}]]),Ar=V(`Sparkles`,[[`path`,{d:`M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z`,key:`4pj2yx`}],[`path`,{d:`M20 3v4`,key:`1olli1`}],[`path`,{d:`M22 5h-4`,key:`1gvqau`}],[`path`,{d:`M4 17v2`,key:`vumght`}],[`path`,{d:`M5 18H3`,key:`zchphs`}]]),Vee=V(`SquareSplitHorizontal`,[[`path`,{d:`M8 19H5c-1 0-2-1-2-2V7c0-1 1-2 2-2h3`,key:`lubmu8`}],[`path`,{d:`M16 5h3c1 0 2 1 2 2v10c0 1-1 2-2 2h-3`,key:`1ag34g`}],[`line`,{x1:`12`,x2:`12`,y1:`4`,y2:`20`,key:`1tx1rr`}]]),Hee=V(`SquareSplitVertical`,[[`path`,{d:`M5 8V5c0-1 1-2 2-2h10c1 0 2 1 2 2v3`,key:`1pi83i`}],[`path`,{d:`M19 16v3c0 1-1 2-2 2H7c-1 0-2-1-2-2v-3`,key:`ido5k7`}],[`line`,{x1:`4`,x2:`20`,y1:`12`,y2:`12`,key:`1e0a9i`}]]),Uee=V(`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`}]]),jr=V(`Square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),Wee=V(`StarOff`,[[`path`,{d:`M8.34 8.34 2 9.27l5 4.87L5.82 21 12 17.77 18.18 21l-.59-3.43`,key:`16m0ql`}],[`path`,{d:`M18.42 12.76 22 9.27l-6.91-1L12 2l-1.44 2.91`,key:`1vt8nq`}],[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}]]),Mr=V(`Star`,[[`polygon`,{points:`12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2`,key:`8f66p6`}]]),Gee=V(`SunMoon`,[[`path`,{d:`M12 8a2.83 2.83 0 0 0 4 4 4 4 0 1 1-4-4`,key:`1fu5g2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.9 4.9 1.4 1.4`,key:`b9915j`}],[`path`,{d:`m17.7 17.7 1.4 1.4`,key:`qc3ed3`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.3 17.7-1.4 1.4`,key:`5gca6`}],[`path`,{d:`m19.1 4.9-1.4 1.4`,key:`wpu9u6`}]]),Nr=V(`Sun`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]),Kee=V(`Tag`,[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]),Pr=V(`Terminal`,[[`polyline`,{points:`4 17 10 11 4 5`,key:`akl6gq`}],[`line`,{x1:`12`,x2:`20`,y1:`19`,y2:`19`,key:`q2wloq`}]]),qee=V(`ThumbsUp`,[[`path`,{d:`M7 10v12`,key:`1qc93n`}],[`path`,{d:`M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z`,key:`emmmcr`}]]),Jee=V(`ToggleLeft`,[[`rect`,{width:`20`,height:`12`,x:`2`,y:`6`,rx:`6`,ry:`6`,key:`f2vt7d`}],[`circle`,{cx:`8`,cy:`12`,r:`2`,key:`1nvbw3`}]]),Yee=V(`ToggleRight`,[[`rect`,{width:`20`,height:`12`,x:`2`,y:`6`,rx:`6`,ry:`6`,key:`f2vt7d`}],[`circle`,{cx:`16`,cy:`12`,r:`2`,key:`4ma0v8`}]]),Fr=V(`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`}]]),Xee=V(`TrendingUp`,[[`polyline`,{points:`22 7 13.5 15.5 8.5 10.5 2 17`,key:`126l90`}],[`polyline`,{points:`16 7 22 7 22 13`,key:`kwv8wd`}]]),Ir=V(`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`}]]),Zee=V(`Undo`,[[`path`,{d:`M3 7v6h6`,key:`1v2h90`}],[`path`,{d:`M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13`,key:`1r6uu6`}]]),Qee=V(`User`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),$ee=V(`Users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`path`,{d:`M16 3.13a4 4 0 0 1 0 7.75`,key:`1da9ce`}]]),Lr=V(`Volume2`,[[`polygon`,{points:`11 5 6 9 2 9 2 15 6 15 11 19 11 5`,key:`16drj5`}],[`path`,{d:`M15.54 8.46a5 5 0 0 1 0 7.07`,key:`ltjumu`}],[`path`,{d:`M19.07 4.93a10 10 0 0 1 0 14.14`,key:`1kegas`}]]),ete=V(`Workflow`,[[`rect`,{width:`8`,height:`8`,x:`3`,y:`3`,rx:`2`,key:`by2w9f`}],[`path`,{d:`M7 11v4a2 2 0 0 0 2 2h4`,key:`xkn7yn`}],[`rect`,{width:`8`,height:`8`,x:`13`,y:`13`,rx:`2`,key:`1cgmvn`}]]),tte=V(`WrapText`,[[`line`,{x1:`3`,x2:`21`,y1:`6`,y2:`6`,key:`4m8b97`}],[`path`,{d:`M3 12h15a3 3 0 1 1 0 6h-4`,key:`1cl7v7`}],[`polyline`,{points:`16 16 14 18 16 20`,key:`1jznyi`}],[`line`,{x1:`3`,x2:`10`,y1:`18`,y2:`18`,key:`1h33wv`}]]),Rr=V(`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`}]]),zr=V(`X`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),Br=V(`Zap`,[[`path`,{d:`M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z`,key:`1xq2db`}]]),nte=n(re(),1),Vr=(0,R.createContext)(null);function Hr(){let e=(0,R.useContext)(Vr);if(!e)throw Error(`useConfirm must be used within DialogProvider`);return e.confirm}function Ur(){let e=(0,R.useContext)(Vr);if(!e)throw Error(`useAlert must be used within DialogProvider`);return e.alert}var Wr=0;function rte(){let[e,t]=(0,R.useState)(0);return(0,R.useEffect)(()=>(Wr+=1,t(Wr),()=>{--Wr}),[]),e}function Gr({children:e,onDismiss:t}){let n=rte(),[r,i]=(0,R.useState)(!1);return(0,R.useEffect)(()=>{requestAnimationFrame(()=>i(!0))},[]),(0,R.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]),(0,z.jsx)(`div`,{className:`fixed inset-0 bg-black/32 backdrop-blur-sm flex items-center justify-center z-[100]`,onClick:t,style:{"--nested-dialogs":n},children:(0,z.jsx)(`div`,{className:`bg-popover text-popover-foreground rounded-2xl border border-border shadow-lg w-full max-w-md mx-4 transition-all duration-200 ease-in-out ${r?`scale-100 opacity-100`:`scale-[0.98] opacity-0`}`,style:{transform:`scale(${r?`calc(1 - 0.1 * ${n})`:`0.98`})`},onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-modal":`true`,children:e})})}function ite({options:e,onConfirm:t,onCancel:n}){let r=(0,R.useRef)(null),i=(0,R.useRef)(null),[a,o]=(0,R.useState)(``),s=e.variant===`destructive`,c=!!e.requiredText,l=!c||a===e.requiredText;return(0,R.useEffect)(()=>{s?r.current?.focus():i.current?.focus()},[s]),(0,z.jsxs)(Gr,{onDismiss:n,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 px-6 py-4 border-b border-border`,children:[s?(0,z.jsx)(Ir,{className:`w-5 h-5 text-destructive shrink-0`}):(0,z.jsx)(Qn,{className:`w-5 h-5 text-info shrink-0`}),(0,z.jsx)(`h3`,{id:`dialog-title`,className:`text-lg font-semibold text-foreground`,children:e.title})]}),(0,z.jsxs)(`div`,{className:`px-6 py-5 space-y-3`,children:[(0,z.jsx)(`p`,{id:`dialog-message`,className:`text-sm text-foreground whitespace-pre-line`,children:e.message}),c?(0,z.jsxs)(`label`,{className:`block text-xs text-muted-foreground`,children:[`Type `,(0,z.jsx)(`span`,{className:`font-mono text-foreground`,children:e.requiredText}),` to confirm`,(0,z.jsx)(`input`,{className:`mt-1 w-full rounded border border-border bg-background px-2 py-1.5 text-sm text-foreground focus:outline-none focus:ring-1 focus:ring-primary`,value:a,onChange:e=>o(e.target.value),"aria-label":`Confirmation text`,autoFocus:!0})]}):null]}),(0,z.jsxs)(`div`,{className:`flex items-center justify-end gap-2 px-6 py-4 border-t border-border`,children:[(0,z.jsx)(`button`,{ref:r,onClick:n,className:`px-4 py-2 rounded-lg text-sm bg-secondary text-secondary-foreground hover:bg-secondary/80 transition-colors`,children:e.cancelLabel||`Cancel`}),(0,z.jsx)(`button`,{ref:i,onClick:t,disabled:!l,className:`px-4 py-2 rounded-lg text-sm font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed ${s?`bg-destructive text-destructive-foreground hover:bg-destructive/90`:`bg-primary text-primary-foreground hover:bg-primary/90`}`,children:e.confirmLabel||`Confirm`})]})]})}function ate({options:e,onClose:t}){let n=(0,R.useRef)(null);(0,R.useEffect)(()=>{n.current?.focus()},[]);let r={info:(0,z.jsx)(Qn,{className:`w-5 h-5 text-info shrink-0`}),error:(0,z.jsx)(un,{className:`w-5 h-5 text-destructive shrink-0`}),success:(0,z.jsx)(on,{className:`w-5 h-5 text-success shrink-0`})},i=e.variant||`info`;return(0,z.jsxs)(Gr,{onDismiss:t,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 border-b border-border`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[r[i],(0,z.jsx)(`h3`,{id:`alert-title`,className:`text-lg font-semibold text-foreground`,children:e.title||(i===`error`?`Error`:i===`success`?`Success`:`Notice`)})]}),(0,z.jsx)(`button`,{onClick:t,className:`text-muted-foreground hover:text-foreground transition-colors`,children:(0,z.jsx)(zr,{className:`w-5 h-5`})})]}),(0,z.jsx)(`div`,{className:`px-6 py-5`,children:(0,z.jsx)(`p`,{id:`alert-message`,className:`text-sm text-foreground whitespace-pre-line`,children:e.message})}),(0,z.jsx)(`div`,{className:`flex items-center justify-end px-6 py-4 border-t border-border`,children:(0,z.jsx)(`button`,{ref:n,onClick:t,className:`px-4 py-2 rounded-lg text-sm bg-primary text-primary-foreground hover:bg-primary/90 transition-colors font-medium`,children:`OK`})})]})}function ote({children:e}){let[t,n]=(0,R.useState)(null),r=(0,R.useRef)(null),i=(0,R.useCallback)(()=>{r.current&&=(r.current.resolve(!1),null)},[]),a=(0,R.useCallback)(e=>(i(),new Promise(t=>{let i={type:`confirm`,options:e,resolve:t};r.current=i,n(i)})),[i]),o=(0,R.useCallback)(e=>(i(),new Promise(t=>{let i={type:`alert`,options:e,resolve:()=>t()};r.current=i,n(i)})),[i]),s=(0,R.useCallback)(()=>{t?.resolve(!0),r.current=null,n(null)},[t]),c=(0,R.useCallback)(()=>{t?.resolve(!1),r.current=null,n(null)},[t]),l=(0,R.useCallback)(()=>{t?.resolve(!1),r.current=null,n(null)},[t]);return(0,z.jsxs)(Vr.Provider,{value:{confirm:a,alert:o},children:[e,t?.type===`confirm`&&(0,z.jsx)(ite,{options:t.options,onConfirm:s,onCancel:c}),t?.type===`alert`&&(0,z.jsx)(ate,{options:t.options,onClose:l})]})}var Kr=n(s(),1),ste=e=>{switch(e){case`success`:return ute;case`info`:return fte;case`warning`:return dte;case`error`:return pte;default:return null}},cte=Array(12).fill(0),lte=({visible:e,className:t})=>R.createElement(`div`,{className:[`sonner-loading-wrapper`,t].filter(Boolean).join(` `),"data-visible":e},R.createElement(`div`,{className:`sonner-spinner`},cte.map((e,t)=>R.createElement(`div`,{className:`sonner-loading-bar`,key:`spinner-bar-${t}`})))),ute=R.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},R.createElement(`path`,{fillRule:`evenodd`,d:`M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z`,clipRule:`evenodd`})),dte=R.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`currentColor`,height:`20`,width:`20`},R.createElement(`path`,{fillRule:`evenodd`,d:`M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z`,clipRule:`evenodd`})),fte=R.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},R.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z`,clipRule:`evenodd`})),pte=R.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},R.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z`,clipRule:`evenodd`})),mte=R.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`},R.createElement(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),R.createElement(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})),hte=()=>{let[e,t]=R.useState(document.hidden);return R.useEffect(()=>{let e=()=>{t(document.hidden)};return document.addEventListener(`visibilitychange`,e),()=>window.removeEventListener(`visibilitychange`,e)},[]),e},qr=1,Jr=new class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{let{message:t,...n}=e,r=typeof e?.id==`number`||e.id?.length>0?e.id:qr++,i=this.toasts.find(e=>e.id===r),a=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(r)&&this.dismissedToasts.delete(r),i?this.toasts=this.toasts.map(n=>n.id===r?(this.publish({...n,...e,id:r,title:t}),{...n,...e,id:r,dismissible:a,title:t}):n):this.addToast({title:t,...n,dismissible:a,id:r}),r},this.dismiss=e=>(this.dismissedToasts.add(e),e||this.toasts.forEach(e=>{this.subscribers.forEach(t=>t({id:e.id,dismiss:!0}))}),this.subscribers.forEach(t=>t({id:e,dismiss:!0})),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:`error`}),this.success=(e,t)=>this.create({...t,type:`success`,message:e}),this.info=(e,t)=>this.create({...t,type:`info`,message:e}),this.warning=(e,t)=>this.create({...t,type:`warning`,message:e}),this.loading=(e,t)=>this.create({...t,type:`loading`,message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:`loading`,message:t.loading,description:typeof t.description==`function`?void 0:t.description}));let r=e instanceof Promise?e:e(),i=n!==void 0,a,o=r.then(async e=>{if(a=[`resolve`,e],R.isValidElement(e))i=!1,this.create({id:n,type:`default`,message:e});else if(_te(e)&&!e.ok){i=!1;let r=typeof t.error==`function`?await t.error(`HTTP error! status: ${e.status}`):t.error,a=typeof t.description==`function`?await t.description(`HTTP error! status: ${e.status}`):t.description;this.create({id:n,type:`error`,message:r,description:a})}else if(t.success!==void 0){i=!1;let r=typeof t.success==`function`?await t.success(e):t.success,a=typeof t.description==`function`?await t.description(e):t.description;this.create({id:n,type:`success`,message:r,description:a})}}).catch(async e=>{if(a=[`reject`,e],t.error!==void 0){i=!1;let r=typeof t.error==`function`?await t.error(e):t.error,a=typeof t.description==`function`?await t.description(e):t.description;this.create({id:n,type:`error`,message:r,description:a})}}).finally(()=>{var e;i&&(this.dismiss(n),n=void 0),(e=t.finally)==null||e.call(t)}),s=()=>new Promise((e,t)=>o.then(()=>a[0]===`reject`?t(a[1]):e(a[1])).catch(t));return typeof n!=`string`&&typeof n!=`number`?{unwrap:s}:Object.assign(n,{unwrap:s})},this.custom=(e,t)=>{let n=t?.id||qr++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},gte=(e,t)=>{let n=t?.id||qr++;return Jr.addToast({title:e,...t,id:n}),n},_te=e=>e&&typeof e==`object`&&`ok`in e&&typeof e.ok==`boolean`&&`status`in e&&typeof e.status==`number`,H=Object.assign(gte,{success:Jr.success,info:Jr.info,warning:Jr.warning,error:Jr.error,custom:Jr.custom,message:Jr.message,promise:Jr.promise,dismiss:Jr.dismiss,loading:Jr.loading},{getHistory:()=>Jr.toasts,getToasts:()=>Jr.getActiveToasts()});function vte(e,{insertAt:t}={}){if(!e||typeof document>`u`)return;let n=document.head||document.getElementsByTagName(`head`)[0],r=document.createElement(`style`);r.type=`text/css`,t===`top`&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}vte(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}
|
|
3
3
|
`);function Yr(e){return e.label!==void 0}var yte=3,bte=`32px`,xte=`16px`,Xr=4e3,Ste=356,Cte=14,wte=20,Tte=200;function Zr(...e){return e.filter(Boolean).join(` `)}function Ete(e){let[t,n]=e.split(`-`),r=[];return t&&r.push(t),n&&r.push(n),r}var Dte=e=>{let{invert:t,toast:n,unstyled:r,interacting:i,setHeights:a,visibleToasts:o,heights:s,index:c,toasts:l,expanded:u,removeToast:d,defaultRichColors:f,closeButton:p,style:m,cancelButtonStyle:h,actionButtonStyle:g,className:_=``,descriptionClassName:v=``,duration:y,position:b,gap:x,loadingIcon:S,expandByDefault:C,classNames:w,icons:T,closeButtonAriaLabel:E=`Close toast`,pauseWhenPageIsHidden:D}=e,[O,k]=R.useState(null),[A,j]=R.useState(null),[M,N]=R.useState(!1),[P,F]=R.useState(!1),[I,ee]=R.useState(!1),[te,ne]=R.useState(!1),[L,re]=R.useState(!1),[ie,ae]=R.useState(0),[oe,se]=R.useState(0),ce=R.useRef(n.duration||y||Xr),le=R.useRef(null),ue=R.useRef(null),de=c===0,fe=c+1<=o,pe=n.type,me=n.dismissible!==!1,he=n.className||``,ge=n.descriptionClassName||``,_e=R.useMemo(()=>s.findIndex(e=>e.toastId===n.id)||0,[s,n.id]),ve=R.useMemo(()=>n.closeButton??p,[n.closeButton,p]),ye=R.useMemo(()=>n.duration||y||Xr,[n.duration,y]),be=R.useRef(0),xe=R.useRef(0),Se=R.useRef(0),Ce=R.useRef(null),[we,Te]=b.split(`-`),Ee=R.useMemo(()=>s.reduce((e,t,n)=>n>=_e?e:e+t.height,0),[s,_e]),De=hte(),Oe=n.invert||t,ke=pe===`loading`;xe.current=R.useMemo(()=>_e*x+Ee,[_e,Ee]),R.useEffect(()=>{ce.current=ye},[ye]),R.useEffect(()=>{N(!0)},[]),R.useEffect(()=>{let e=ue.current;if(e){let t=e.getBoundingClientRect().height;return se(t),a(e=>[{toastId:n.id,height:t,position:n.position},...e]),()=>a(e=>e.filter(e=>e.toastId!==n.id))}},[a,n.id]),R.useLayoutEffect(()=>{if(!M)return;let e=ue.current,t=e.style.height;e.style.height=`auto`;let r=e.getBoundingClientRect().height;e.style.height=t,se(r),a(e=>e.find(e=>e.toastId===n.id)?e.map(e=>e.toastId===n.id?{...e,height:r}:e):[{toastId:n.id,height:r,position:n.position},...e])},[M,n.title,n.description,a,n.id]);let Ae=R.useCallback(()=>{F(!0),ae(xe.current),a(e=>e.filter(e=>e.toastId!==n.id)),setTimeout(()=>{d(n)},Tte)},[n,d,a,xe]);R.useEffect(()=>{if(n.promise&&pe===`loading`||n.duration===1/0||n.type===`loading`)return;let e;return u||i||D&&De?(()=>{if(Se.current<be.current){let e=new Date().getTime()-be.current;ce.current-=e}Se.current=new Date().getTime()})():ce.current!==1/0&&(be.current=new Date().getTime(),e=setTimeout(()=>{var e;(e=n.onAutoClose)==null||e.call(n,n),Ae()},ce.current)),()=>clearTimeout(e)},[u,i,n,pe,D,De,Ae]),R.useEffect(()=>{n.delete&&Ae()},[Ae,n.delete]);function je(){return T!=null&&T.loading?R.createElement(`div`,{className:Zr(w?.loader,n?.classNames?.loader,`sonner-loader`),"data-visible":pe===`loading`},T.loading):S?R.createElement(`div`,{className:Zr(w?.loader,n?.classNames?.loader,`sonner-loader`),"data-visible":pe===`loading`},S):R.createElement(lte,{className:Zr(w?.loader,n?.classNames?.loader),visible:pe===`loading`})}return R.createElement(`li`,{tabIndex:0,ref:ue,className:Zr(_,he,w?.toast,n?.classNames?.toast,w?.default,w?.[pe],n?.classNames?.[pe]),"data-sonner-toast":``,"data-rich-colors":n.richColors??f,"data-styled":!(n.jsx||n.unstyled||r),"data-mounted":M,"data-promise":!!n.promise,"data-swiped":L,"data-removed":P,"data-visible":fe,"data-y-position":we,"data-x-position":Te,"data-index":c,"data-front":de,"data-swiping":I,"data-dismissible":me,"data-type":pe,"data-invert":Oe,"data-swipe-out":te,"data-swipe-direction":A,"data-expanded":!!(u||C&&M),style:{"--index":c,"--toasts-before":c,"--z-index":l.length-c,"--offset":`${P?ie:xe.current}px`,"--initial-height":C?`auto`:`${oe}px`,...m,...n.style},onDragEnd:()=>{ee(!1),k(null),Ce.current=null},onPointerDown:e=>{ke||!me||(le.current=new Date,ae(xe.current),e.target.setPointerCapture(e.pointerId),e.target.tagName!==`BUTTON`&&(ee(!0),Ce.current={x:e.clientX,y:e.clientY}))},onPointerUp:()=>{var e;if(te||!me)return;Ce.current=null;let t=Number(ue.current?.style.getPropertyValue(`--swipe-amount-x`).replace(`px`,``)||0),r=Number(ue.current?.style.getPropertyValue(`--swipe-amount-y`).replace(`px`,``)||0),i=new Date().getTime()-le.current?.getTime(),a=O===`x`?t:r,o=Math.abs(a)/i;if(Math.abs(a)>=wte||o>.11){ae(xe.current),(e=n.onDismiss)==null||e.call(n,n),j(O===`x`?t>0?`right`:`left`:r>0?`down`:`up`),Ae(),ne(!0),re(!1);return}ee(!1),k(null)},onPointerMove:t=>{var n,r;if(!Ce.current||!me||window.getSelection()?.toString().length>0)return;let i=t.clientY-Ce.current.y,a=t.clientX-Ce.current.x,o=e.swipeDirections??Ete(b);!O&&(Math.abs(a)>1||Math.abs(i)>1)&&k(Math.abs(a)>Math.abs(i)?`x`:`y`);let s={x:0,y:0};O===`y`?(o.includes(`top`)||o.includes(`bottom`))&&(o.includes(`top`)&&i<0||o.includes(`bottom`)&&i>0)&&(s.y=i):O===`x`&&(o.includes(`left`)||o.includes(`right`))&&(o.includes(`left`)&&a<0||o.includes(`right`)&&a>0)&&(s.x=a),(Math.abs(s.x)>0||Math.abs(s.y)>0)&&re(!0),(n=ue.current)==null||n.style.setProperty(`--swipe-amount-x`,`${s.x}px`),(r=ue.current)==null||r.style.setProperty(`--swipe-amount-y`,`${s.y}px`)}},ve&&!n.jsx?R.createElement(`button`,{"aria-label":E,"data-disabled":ke,"data-close-button":!0,onClick:ke||!me?()=>{}:()=>{var e;Ae(),(e=n.onDismiss)==null||e.call(n,n)},className:Zr(w?.closeButton,n?.classNames?.closeButton)},T?.close??mte):null,n.jsx||(0,R.isValidElement)(n.title)?n.jsx?n.jsx:typeof n.title==`function`?n.title():n.title:R.createElement(R.Fragment,null,pe||n.icon||n.promise?R.createElement(`div`,{"data-icon":``,className:Zr(w?.icon,n?.classNames?.icon)},n.promise||n.type===`loading`&&!n.icon?n.icon||je():null,n.type===`loading`?null:n.icon||T?.[pe]||ste(pe)):null,R.createElement(`div`,{"data-content":``,className:Zr(w?.content,n?.classNames?.content)},R.createElement(`div`,{"data-title":``,className:Zr(w?.title,n?.classNames?.title)},typeof n.title==`function`?n.title():n.title),n.description?R.createElement(`div`,{"data-description":``,className:Zr(v,ge,w?.description,n?.classNames?.description)},typeof n.description==`function`?n.description():n.description):null),(0,R.isValidElement)(n.cancel)?n.cancel:n.cancel&&Yr(n.cancel)?R.createElement(`button`,{"data-button":!0,"data-cancel":!0,style:n.cancelButtonStyle||h,onClick:e=>{var t,r;Yr(n.cancel)&&me&&((r=(t=n.cancel).onClick)==null||r.call(t,e),Ae())},className:Zr(w?.cancelButton,n?.classNames?.cancelButton)},n.cancel.label):null,(0,R.isValidElement)(n.action)?n.action:n.action&&Yr(n.action)?R.createElement(`button`,{"data-button":!0,"data-action":!0,style:n.actionButtonStyle||g,onClick:e=>{var t,r;Yr(n.action)&&((r=(t=n.action).onClick)==null||r.call(t,e),!e.defaultPrevented&&Ae())},className:Zr(w?.actionButton,n?.classNames?.actionButton)},n.action.label):null))};function Qr(){if(typeof window>`u`||typeof document>`u`)return`ltr`;let e=document.documentElement.getAttribute(`dir`);return e===`auto`||!e?window.getComputedStyle(document.documentElement).direction:e}function Ote(e,t){let n={};return[e,t].forEach((e,t)=>{let r=t===1,i=r?`--mobile-offset`:`--offset`,a=r?xte:bte;function o(e){[`top`,`right`,`bottom`,`left`].forEach(t=>{n[`${i}-${t}`]=typeof e==`number`?`${e}px`:e})}typeof e==`number`||typeof e==`string`?o(e):typeof e==`object`?[`top`,`right`,`bottom`,`left`].forEach(t=>{e[t]===void 0?n[`${i}-${t}`]=a:n[`${i}-${t}`]=typeof e[t]==`number`?`${e[t]}px`:e[t]}):o(a)}),n}var kte=(0,R.forwardRef)(function(e,t){let{invert:n,position:r=`bottom-right`,hotkey:i=[`altKey`,`KeyT`],expand:a,closeButton:o,className:s,offset:c,mobileOffset:l,theme:u=`light`,richColors:d,duration:f,style:p,visibleToasts:m=yte,toastOptions:h,dir:g=Qr(),gap:_=Cte,loadingIcon:v,icons:y,containerAriaLabel:b=`Notifications`,pauseWhenPageIsHidden:x}=e,[S,C]=R.useState([]),w=R.useMemo(()=>Array.from(new Set([r].concat(S.filter(e=>e.position).map(e=>e.position)))),[S,r]),[T,E]=R.useState([]),[D,O]=R.useState(!1),[k,A]=R.useState(!1),[j,M]=R.useState(u===`system`?typeof window<`u`&&window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:u),N=R.useRef(null),P=i.join(`+`).replace(/Key/g,``).replace(/Digit/g,``),F=R.useRef(null),I=R.useRef(!1),ee=R.useCallback(e=>{C(t=>{var n;return(n=t.find(t=>t.id===e.id))!=null&&n.delete||Jr.dismiss(e.id),t.filter(({id:t})=>t!==e.id)})},[]);return R.useEffect(()=>Jr.subscribe(e=>{if(e.dismiss){C(t=>t.map(t=>t.id===e.id?{...t,delete:!0}:t));return}setTimeout(()=>{Kr.flushSync(()=>{C(t=>{let n=t.findIndex(t=>t.id===e.id);return n===-1?[e,...t]:[...t.slice(0,n),{...t[n],...e},...t.slice(n+1)]})})})}),[]),R.useEffect(()=>{if(u!==`system`){M(u);return}if(u===`system`&&(window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?M(`dark`):M(`light`)),typeof window>`u`)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`);try{e.addEventListener(`change`,({matches:e})=>{M(e?`dark`:`light`)})}catch{e.addListener(({matches:e})=>{try{M(e?`dark`:`light`)}catch(e){console.error(e)}})}},[u]),R.useEffect(()=>{S.length<=1&&O(!1)},[S]),R.useEffect(()=>{let e=e=>{var t,n;i.every(t=>e[t]||e.code===t)&&(O(!0),(t=N.current)==null||t.focus()),e.code===`Escape`&&(document.activeElement===N.current||(n=N.current)!=null&&n.contains(document.activeElement))&&O(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[i]),R.useEffect(()=>{if(N.current)return()=>{F.current&&(F.current.focus({preventScroll:!0}),F.current=null,I.current=!1)}},[N.current]),R.createElement(`section`,{ref:t,"aria-label":`${b} ${P}`,tabIndex:-1,"aria-live":`polite`,"aria-relevant":`additions text`,"aria-atomic":`false`,suppressHydrationWarning:!0},w.map((t,r)=>{let[i,u]=t.split(`-`);return S.length?R.createElement(`ol`,{key:t,dir:g===`auto`?Qr():g,tabIndex:-1,ref:N,className:s,"data-sonner-toaster":!0,"data-theme":j,"data-y-position":i,"data-lifted":D&&S.length>1&&!a,"data-x-position":u,style:{"--front-toast-height":`${T[0]?.height||0}px`,"--width":`${Ste}px`,"--gap":`${_}px`,...p,...Ote(c,l)},onBlur:e=>{I.current&&!e.currentTarget.contains(e.relatedTarget)&&(I.current=!1,F.current&&=(F.current.focus({preventScroll:!0}),null))},onFocus:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||I.current||(I.current=!0,F.current=e.relatedTarget)},onMouseEnter:()=>O(!0),onMouseMove:()=>O(!0),onMouseLeave:()=>{k||O(!1)},onDragEnd:()=>O(!1),onPointerDown:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||A(!0)},onPointerUp:()=>A(!1)},S.filter(e=>!e.position&&r===0||e.position===t).map((r,i)=>R.createElement(Dte,{key:r.id,icons:y,index:i,toast:r,defaultRichColors:d,duration:h?.duration??f,className:h?.className,descriptionClassName:h?.descriptionClassName,invert:n,visibleToasts:m,closeButton:h?.closeButton??o,interacting:k,position:t,style:h?.style,unstyled:h?.unstyled,classNames:h?.classNames,cancelButtonStyle:h?.cancelButtonStyle,actionButtonStyle:h?.actionButtonStyle,removeToast:ee,toasts:S.filter(e=>e.position==r.position),heights:T.filter(e=>e.position==r.position),setHeights:E,expandByDefault:a,gap:_,loadingIcon:v,expanded:D,pauseWhenPageIsHidden:x,swipeDirections:e.swipeDirections}))):null}))}),$r=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e)),destroy:()=>{n.clear()}},o=t=e(r,i,a);return a},ei=e=>e?$r(e):$r,Ate=i((e=>{var t=a();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,o=t.useEffect,s=t.useLayoutEffect,c=t.useDebugValue;function l(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),a=r[0].inst,l=r[1];return s(function(){a.value=n,a.getSnapshot=t,u(a)&&l({inst:a})},[e,n,t]),o(function(){return u(a)&&l({inst:a}),e(function(){u(a)&&l({inst:a})})},[e]),c(n),n}function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function d(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?d:l;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),jte=i(((e,t)=>{t.exports=Ate()})),Mte=i((e=>{var t=a(),n=jte();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,o=n.useSyncExternalStore,s=t.useRef,c=t.useEffect,l=t.useMemo,u=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,a){var d=s(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=l(function(){function e(e){if(!o){if(o=!0,s=e,e=r(e),a!==void 0&&f.hasValue){var t=f.value;if(a(t,e))return c=t}return c=e}if(t=c,i(s,e))return t;var n=r(e);return a!==void 0&&a(t,n)?(s=e,t):(s=e,c=n)}var o=!1,s,c,l=n===void 0?null:n;return[function(){return e(t())},l===null?void 0:function(){return e(l())}]},[t,n,r,a]);var p=o(e,d[0],d[1]);return c(function(){f.hasValue=!0,f.value=p},[p]),u(p),p}})),ti=n(i(((e,t)=>{t.exports=Mte()}))(),1),{useDebugValue:Nte}=R.default,{useSyncExternalStoreWithSelector:Pte}=ti.default,Fte=e=>e;function Ite(e,t=Fte,n){let r=Pte(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Nte(r),r}var ni=e=>{let t=typeof e==`function`?ei(e):e,n=(e,n)=>Ite(t,e,n);return Object.assign(n,t),n},ri=e=>e?ni(e):ni,ii=(e,t)=>{switch(t.length){case 0:return e;case 1:return t[0](e);case 2:return t[1](t[0](e));case 3:return t[2](t[1](t[0](e)));case 4:return t[3](t[2](t[1](t[0](e))));case 5:return t[4](t[3](t[2](t[1](t[0](e)))));case 6:return t[5](t[4](t[3](t[2](t[1](t[0](e))))));case 7:return t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))));case 8:return t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e))))))));case 9:return t[8](t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))))));default:{let n=e;for(let e=0,r=t.length;e<r;e++)n=t[e](n);return n}}},Lte={pipe(){return ii(this,arguments)}},ai=function(){function e(){}return e.prototype=Lte,e}(),oi=function(e,t){if(typeof e==`function`)return function(){return e(arguments)?t.apply(this,arguments):e=>t(e,...arguments)};switch(e){case 0:case 1:throw RangeError(`Invalid arity ${e}`);case 2:return function(e,n){return arguments.length>=2?t(e,n):function(n){return t(n,e)}};case 3:return function(e,n,r){return arguments.length>=3?t(e,n,r):function(r){return t(r,e,n)}};default:return function(){if(arguments.length>=e)return t.apply(this,arguments);let n=arguments;return function(e){return t(e,...n)}}}},si=e=>e,ci=e=>()=>e,li=ci(!0),Rte=ci(!1),ui=ci(void 0),di=ui;function fi(e,t,n,r,i,a,o,s,c){switch(arguments.length){case 1:return e;case 2:return function(){return t(e.apply(this,arguments))};case 3:return function(){return n(t(e.apply(this,arguments)))};case 4:return function(){return r(n(t(e.apply(this,arguments))))};case 5:return function(){return i(r(n(t(e.apply(this,arguments)))))};case 6:return function(){return a(i(r(n(t(e.apply(this,arguments))))))};case 7:return function(){return o(a(i(r(n(t(e.apply(this,arguments)))))))};case 8:return function(){return s(o(a(i(r(n(t(e.apply(this,arguments))))))))};case 9:return function(){return c(s(o(a(i(r(n(t(e.apply(this,arguments)))))))))}}}function pi(e){let t=new WeakMap;return n=>{if(t.has(n))return t.get(n);let r=e(n);return t.set(n,r),r}}var mi=e=>{let t=new Set(Reflect.ownKeys(e));if(e.constructor===Object)return t;e instanceof Error&&t.delete(`stack`);let n=Object.getPrototypeOf(e),r=n;for(;r!==null&&r!==Object.prototype;){let e=Reflect.ownKeys(r);for(let n=0;n<e.length;n++)t.add(e[n]);r=Object.getPrototypeOf(r)}return t.has(`constructor`)&&typeof e.constructor==`function`&&n===e.constructor.prototype&&t.delete(`constructor`),t},hi=new WeakSet;function gi(e){return typeof e==`string`}function _i(e){return typeof e==`number`}function zte(e){return typeof e==`boolean`}function Bte(e){return typeof e==`symbol`}function Vte(e){return gi(e)||_i(e)||Bte(e)}function vi(e){return typeof e==`function`}function Hte(e){return e!==void 0}function Ute(e){return e!=null}function Wte(e){return!1}function yi(e){return!0}function Gte(e){return typeof e==`object`&&!!e||vi(e)}var bi=oi(2,(e,t)=>Gte(e)&&t in e);function Kte(e){return bi(e,Symbol.iterator)||gi(e)}var xi=`~effect/interfaces/Hash`,Si=e=>{switch(typeof e){case`number`:return Ei(e);case`bigint`:return Di(e.toString(10));case`boolean`:return Di(String(e));case`symbol`:return Di(String(e));case`string`:return Di(e);case`undefined`:return Di(`undefined`);case`function`:case`object`:if(e===null)return Di(`null`);if(e instanceof Date)return Di(e.toISOString());if(e instanceof RegExp)return Di(e.toString());{if(hi.has(e))return Ci(e);if(Mi.has(e))return Mi.get(e);let t=Zte(e,()=>qte(e)?e[xi]():typeof e==`function`?Ci(e):Array.isArray(e)||ArrayBuffer.isView(e)?Ai(e):e instanceof Map?Yte(e):e instanceof Set?Xte(e):Oi(e));return Mi.set(e,t),t}default:throw Error(`BUG: unhandled typeof ${typeof e} - please report an issue at https://github.com/Effect-TS/effect/issues`)}},Ci=e=>(ji.has(e)||ji.set(e,Ei(Math.floor(Math.random()*(2**53-1)))),ji.get(e)),wi=oi(2,(e,t)=>e*53^t),Ti=e=>e&3221225471|e>>>1&1073741824,qte=e=>bi(e,xi),Ei=e=>{if(e!==e)return Di(`NaN`);if(e===1/0)return Di(`Infinity`);if(e===-1/0)return Di(`-Infinity`);let t=e|0;for(t!==e&&(t^=e*4294967295);e>4294967295;)t^=e/=4294967295;return Ti(t)},Di=e=>{let t=5381,n=e.length;for(;n;)t=t*33^e.charCodeAt(--n);return Ti(t)},Jte=(e,t)=>{let n=12289;for(let r of t)n^=wi(Si(r),Si(e[r]));return Ti(n)},Oi=e=>Jte(e,mi(e)),ki=(e,t)=>n=>{let r=e;for(let e of n)r^=t(e);return Ti(r)},Ai=ki(6151,Si),Yte=ki(Di(`Map`),([e,t])=>wi(Si(e),Si(t))),Xte=ki(Di(`Set`),Si),ji=new WeakMap,Mi=new WeakMap,Ni=new WeakSet;function Zte(e,t){if(Ni.has(e))return Di(`[Circular]`);Ni.add(e);let n=t();return Ni.delete(e),n}var Pi=`~effect/interfaces/Equal`;function Fi(){return arguments.length===1?e=>Ii(e,arguments[0]):Ii(arguments[0],arguments[1])}function Ii(e,t){if(e===t)return!0;if(e==null||t==null)return!1;let n=typeof e;return n===typeof t?n===`number`&&e!==e&&t!==t?!0:n!==`object`&&n!==`function`||hi.has(e)||hi.has(t)?!1:ene(e,t,$te):!1}function Qte(e,t,n){let r=Li.has(e),i=Ri.has(t);if(r&&i)return!0;if(r||i)return!1;Li.add(e),Ri.add(t);let a=n();return Li.delete(e),Ri.delete(t),a}var Li=new WeakSet,Ri=new WeakSet;function $te(e,t){if(Si(e)!==Si(t))return!1;if(e instanceof Date)return t instanceof Date?e.toISOString()===t.toISOString():!1;if(e instanceof RegExp)return t instanceof RegExp?e.toString()===t.toString():!1;let n=Bi(e),r=Bi(t);if(n!==r)return!1;let i=n&&r;return typeof e==`function`&&!i?!1:Qte(e,t,()=>i?e[Pi](t):Array.isArray(e)?!Array.isArray(t)||e.length!==t.length?!1:tne(e,t):ArrayBuffer.isView(e)?!ArrayBuffer.isView(t)||e.byteLength!==t.byteLength?!1:nne(e,t):e instanceof Map?!(t instanceof Map)||e.size!==t.size?!1:ane(e,t):e instanceof Set?!(t instanceof Set)||e.size!==t.size?!1:sne(e,t):rne(e,t))}function ene(e,t,n){let r=zi.get(e);if(!r)r=new WeakMap,zi.set(e,r);else if(r.has(t))return r.get(t);let i=n(e,t);r.set(t,i);let a=zi.get(t);return a||(a=new WeakMap,zi.set(t,a)),a.set(e,i),i}var zi=new WeakMap;function tne(e,t){for(let n=0;n<e.length;n++)if(!Ii(e[n],t[n]))return!1;return!0}function nne(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function rne(e,t){let n=mi(e),r=mi(t);if(n.size!==r.size)return!1;for(let i of n)if(!r.has(i)||!Ii(e[i],t[i]))return!1;return!0}function ine(e,t){return function(n,r){for(let[i,a]of n){let n=!1;for(let[o,s]of r)if(e(i,o)&&t(a,s)){n=!0;break}if(!n)return!1}return!0}}var ane=ine(Ii,Ii);function one(e){return function(t,n){for(let r of t){let t=!1;for(let i of n)if(e(r,i)){t=!0;break}if(!t)return!1}return!0}}var sne=one(Ii),Bi=e=>bi(e,Pi),cne=()=>Fi,Vi=e=>(t,n)=>t===n||e(t,n),lne=(e,t)=>e===t,une=()=>lne;function dne(e){return Vi((t,n)=>{if(t.length!==n.length)return!1;for(let r=0;r<t.length;r++)if(!e(t[r],n[r]))return!1;return!0})}var Hi=e=>e.length>0,Ui=Symbol.for(`~effect/Redactable`),fne=e=>bi(e,Ui);function Wi(e){return fne(e)?Gi(e):e}function Gi(e){return e[Ui](globalThis[`~effect/Fiber/currentFiber`]?.context??pne)}var Ki=`~effect/Fiber/currentFiber`,pne={"~effect/Context":{},mapUnsafe:new Map,pipe(){return ii(this,arguments)}};function qi(e,t){let n=t?.space??0,r=new WeakSet,i=n?typeof n==`number`?` `.repeat(n):n:``,a=e=>i.repeat(e),o=(e,t)=>{let n=e?.constructor;return n&&n!==Object.prototype.constructor&&n.name?`${n.name}(${t})`:t},s=e=>{try{return Reflect.ownKeys(e)}catch{return[`[ownKeys threw]`]}};function c(e,n=0){if(Array.isArray(e)){if(r.has(e))return Ji;if(r.add(e),!i||e.length<=1)return`[${e.map(e=>c(e,n)).join(`,`)}]`;let t=e.map(e=>c(e,n+1)).join(`,
|
|
4
4
|
`+a(n+1));return`[\n${a(n+1)}${t}\n${a(n)}]`}if(e instanceof Date)return hne(e);if(!t?.ignoreToString&&bi(e,`toString`)&&typeof e.toString==`function`&&e.toString!==Object.prototype.toString&&e.toString!==Array.prototype.toString){let t=gne(e);return e instanceof Error&&e.cause?`${t} (cause: ${c(e.cause,n)})`:t}if(typeof e==`string`)return JSON.stringify(e);if(typeof e==`number`||e==null||typeof e==`boolean`||typeof e==`symbol`)return String(e);if(typeof e==`bigint`)return String(e)+`n`;if(typeof e==`object`||typeof e==`function`){if(r.has(e))return Ji;if(r.add(e),Ui in e)return qi(Gi(e));if(Symbol.iterator in e)return`${e.constructor.name}(${c(Array.from(e),n)})`;let t=s(e);return!i||t.length<=1?o(e,`{${t.map(t=>`${Yi(t)}:${c(e[t],n)}`).join(`,`)}}`):o(e,`{\n${t.map(t=>`${a(n+1)}${Yi(t)}: ${c(e[t],n+1)}`).join(`,
|
|
@@ -311,7 +311,7 @@ The model the **new conversation** will run on. Completely independent of the su
|
|
|
311
311
|
font-size: .6rem;
|
|
312
312
|
font-weight: bold;
|
|
313
313
|
color: hsl(${Math.max(0,Math.min(120-120*r,120))}deg 100% 31%);`,n?.key)}return n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i}return o.updateDeps=e=>{r=e},o}function tY(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var h9e=(e,t)=>Math.abs(e-t)<1.01,g9e=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},nY=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},_9e=e=>e,v9e=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let e=t;e<=n;e++)r.push(e);return r},y9e=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(nY(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(nY(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},rY={passive:!0},iY=typeof window>`u`?!0:`onscrollend`in window,b9e=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=0,a=e.options.useScrollendEvent&&iY?()=>void 0:g9e(r,()=>{t(i,!1)},e.options.isScrollingResetDelay),o=r=>()=>{let{horizontal:o,isRtl:s}=e.options;i=o?n.scrollLeft*(s&&-1||1):n.scrollTop,a(),t(i,r)},s=o(!0),c=o(!1);n.addEventListener(`scroll`,s,rY);let l=e.options.useScrollendEvent&&iY;return l&&n.addEventListener(`scrollend`,c,rY),()=>{n.removeEventListener(`scroll`,s),l&&n.removeEventListener(`scrollend`,c)}},x9e=(e,t,n)=>{if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},S9e=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;let o=e+t;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:o,behavior:n})},C9e=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{Object.entries(e).forEach(([t,n])=>{n===void 0&&delete e[t]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:_9e,rangeExtractor:v9e,onChange:()=>{},measureElement:x9e,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`,...e}},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=eY(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=eY(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(e,t,n,r,i,a,o)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMeasuredCacheIndexes=[],{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o}),{key:!1}),this.getMeasurements=eY(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o},s)=>{if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let c=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1);let l=this.measurementsCache.slice(0,c),u=Array(a).fill(void 0);for(let e=0;e<c;e++){let t=l[e];t&&(u[t.lane]=e)}for(let i=c;i<e;i++){let e=r(i),a=this.laneAssignments.get(i),c,d,f=o===`estimate`||s.has(e);if(a!==void 0&&this.options.lanes>1){c=a;let e=u[c],r=e===void 0?void 0:l[e];d=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?l[i-1]:this.getFurthestMeasurement(l,i);d=e?e.end+this.options.gap:t+n,c=e?e.lane:i%this.options.lanes,this.options.lanes>1&&f&&this.laneAssignments.set(i,c)}let p=s.get(e),m=typeof p==`number`?p:this.options.estimateSize(i),h=d+m;l[i]={index:i,start:d,size:m,end:h,key:e,lane:c},u[c]=i}return this.measurementsCache=l,l},{key:!1,debug:()=>this.options.debug}),this.calculateRange=eY(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?w9e({measurements:e,outerSize:t,scrollOffset:n,lanes:r}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=eY(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{let n=this.measurementsCache[e];if(!n)return;let r=t-(this.itemSizeCache.get(n.key)??n.size);r!==0&&(this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?n.start<this.getScrollOffset()+this.scrollAdjustments:this.shouldAdjustScrollPositionOnItemSizeChange(n,r,this))&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=r,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(n.index),this.itemSizeCache=new Map(this.itemSizeCache.set(n.key,t)),this.notify(!1))},this.getVirtualItems=eY(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length!==0)return tY(t[aY(0,t.length-1,e=>tY(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:`start`,behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1)t=e[e.length-1]?.end??0;else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&h9e(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.scrollState=null;return}}else this.scrollState.stableFrames=0,n&&(this.scrollState.lastTargetOffset=t,this.scrollState.behavior=`auto`,this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}));this.scheduleScrollReconcile()}},aY=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function w9e({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){let i=e.length-1,a=t=>e[t].start;if(e.length<=r)return{startIndex:0,endIndex:i};let o=aY(0,i,a,n),s=o;if(r===1)for(;s<i&&e[s].end<n+t;)s++;else if(r>1){let a=Array(r).fill(0);for(;s<i&&a.some(e=>e<n+t);){let t=e[s];a[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(i,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var oY=typeof document<`u`?R.useLayoutEffect:R.useEffect;function T9e({useFlushSync:e=!0,...t}){let n=R.useReducer(()=>({}),{})[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,Kr.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=R.useState(()=>new C9e(r));return i.setOptions(r),oY(()=>i._didMount(),[]),oY(()=>i._willUpdate()),i}function sY(e){return T9e({observeElementRect:y9e,observeElementOffset:b9e,scrollToFn:S9e,...e})}var E9e=17;function cY(e){let t=(e.conclusion||e.state||e.status||``).toUpperCase();return t===`SUCCESS`||t===`COMPLETED`?{bg:`color-mix(in srgb, var(--success, #10b981) 18%, transparent)`,fg:`var(--success, #10b981)`,label:`pass`}:t===`FAILURE`||t===`CANCELLED`||t===`TIMED_OUT`||t===`ACTION_REQUIRED`||t===`STARTUP_FAILURE`?{bg:`color-mix(in srgb, var(--destructive) 18%, transparent)`,fg:`var(--destructive)`,label:`fail`}:t===`PENDING`||t===`IN_PROGRESS`||t===`QUEUED`||t===`WAITING`?{bg:`color-mix(in srgb, var(--primary) 18%, transparent)`,fg:`var(--primary)`,label:`run`}:t===`NEUTRAL`||t===`SKIPPED`||t===`STALE`?{bg:`color-mix(in srgb, var(--muted-foreground) 18%, transparent)`,fg:`var(--muted-foreground)`,label:`skip`}:{bg:`var(--muted)`,fg:`var(--muted-foreground)`,label:t.toLowerCase()||`unknown`}}function lY(e){if(e.startsWith(`+++ `)||e.startsWith(`--- `))return`var(--muted-foreground)`;if(e.startsWith(`+`))return`var(--success, #10b981)`;if(e.startsWith(`-`))return`var(--destructive)`;if(e.startsWith(`@@`))return`var(--primary)`;if(e.startsWith(`diff `))return`var(--foreground)`}function D9e({pr:e}){let t=e.state.toUpperCase(),n=`var(--muted)`,r=`var(--muted-foreground)`,i=e.state;return t===`OPEN`?(n=e.isDraft?`color-mix(in srgb, var(--muted-foreground) 18%, transparent)`:`color-mix(in srgb, var(--success, #10b981) 18%, transparent)`,r=e.isDraft?`var(--muted-foreground)`:`var(--success, #10b981)`,i=e.isDraft?`draft`:`open`):t===`MERGED`?(n=`color-mix(in srgb, #a855f7 18%, transparent)`,r=`#a855f7`,i=`merged`):t===`CLOSED`&&(n=`color-mix(in srgb, var(--destructive) 18%, transparent)`,r=`var(--destructive)`,i=`closed`),(0,z.jsx)(`span`,{"data-testid":`pr-state-badge`,style:{background:n,color:r,fontSize:11,fontWeight:600,textTransform:`uppercase`,letterSpacing:`0.04em`,padding:`2px 8px`,borderRadius:999},children:i})}function O9e({issueId:e}){let{data:t,isLoading:n,isError:r}=Dj(e),i=Oj(e),a=(0,R.useMemo)(()=>{let e=t?.pr?.files?.map(e=>e.additions+e.deletions)??[];if(e.length===0)return 1;let n=[...e].sort((e,t)=>e-t),r=Math.min(n.length-1,Math.floor(n.length*.95));return Math.max(1,n[r]??1)},[t]),o=(0,R.useMemo)(()=>i.data?.diff?.split(`
|
|
314
|
-
`)??[],[i.data?.diff]),s=(0,R.useRef)(null),c=sY({count:o.length,getScrollElement:()=>s.current,estimateSize:()=>E9e,overscan:12});if(n)return(0,z.jsx)(`div`,{"data-testid":`prdiff-tab-loading`,style:{padding:16,fontSize:12,color:`var(--muted-foreground)`},children:`Loading pull request…`});if(r||!t)return(0,z.jsx)(`div`,{"data-testid":`prdiff-tab-error`,style:{padding:16,fontSize:12,color:`var(--destructive)`},children:`Failed to load pull request.`});if(!t.pr)return(0,z.jsxs)(`div`,{"data-testid":`prdiff-tab-empty`,style:{padding:16,display:`flex`,flexDirection:`column`,gap:6},children:[(0,z.jsx)(`div`,{style:{fontSize:14,fontWeight:600},children:`No pull request yet`}),(0,z.jsxs)(`div`,{style:{fontSize:12,color:`var(--muted-foreground)`},children:[`No PR found for branch `,(0,z.jsxs)(`code`,{children:[`feature/`,e.toLowerCase()]}),`.`,t.error?(0,z.jsxs)(z.Fragment,{children:[` `,(0,z.jsxs)(`span`,{"data-testid":`prdiff-tab-error-msg`,style:{color:`var(--destructive)`},children:[`(`,t.error,`)`]})]}):null]})]});let l=t.pr,u=l.statusCheckRollup??[],d=l.reviewRequests??[];return(0,z.jsxs)(`div`,{"data-testid":`prdiff-tab`,style:{padding:16,display:`flex`,flexDirection:`column`,gap:12,fontSize:13},children:[(0,z.jsxs)(`header`,{"data-testid":`prdiff-tab-header`,style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,flexWrap:`wrap`},children:[(0,z.jsxs)(`a`,{href:l.url,target:`_blank`,rel:`noreferrer`,"data-testid":`prdiff-tab-link`,style:{fontSize:16,fontWeight:700,color:`var(--foreground)`,textDecoration:`none`},children:[`#`,l.number,` `,l.title]}),(0,z.jsx)(D9e,{pr:l})]}),(0,z.jsxs)(`div`,{style:{fontSize:12,color:`var(--muted-foreground)`},children:[(0,z.jsx)(`code`,{children:l.headRefName}),` → `,(0,z.jsx)(`code`,{children:l.baseRefName}),l.author?.login?(0,z.jsxs)(z.Fragment,{children:[` · @`,l.author.login]}):null,` · `,(0,z.jsxs)(`span`,{"data-testid":`prdiff-tab-changes`,children:[`+`,l.additions,` −`,l.deletions,` across `,l.changedFiles,` `,`file`,l.changedFiles===1?``:`s`]})]})]}),(0,z.jsxs)(`section`,{"data-testid":`prdiff-tab-checks`,style:{background:`var(--card)`,border:`1px solid var(--border)`,borderRadius:8,padding:12,display:`flex`,flexDirection:`column`,gap:8},children:[(0,z.jsxs)(`header`,{style:{fontSize:12,fontWeight:600,color:`var(--muted-foreground)`,textTransform:`uppercase`,letterSpacing:`0.04em`},children:[`CI checks`,l.reviewDecision?(0,z.jsxs)(`span`,{"data-testid":`prdiff-tab-review-decision`,style:{marginLeft:8,color:`var(--foreground)`,textTransform:`none`,fontWeight:500},children:[`· review: `,l.reviewDecision.toLowerCase().replace(/_/g,` `)]}):null]}),u.length===0?(0,z.jsx)(`div`,{"data-testid":`prdiff-tab-checks-empty`,style:{fontSize:12,color:`var(--muted-foreground)`},children:`No checks reported.`}):(0,z.jsx)(`ul`,{style:{margin:0,padding:0,listStyle:`none`,display:`flex`,flexWrap:`wrap`,gap:6},children:u.map((e,t)=>{let n=cY(e),r=e.name||e.workflowName||e.__typename||`check-${t}`;return(0,z.jsxs)(`li`,{"data-testid":`prdiff-check-${r}`,style:{background:n.bg,color:n.fg,fontSize:11,fontWeight:600,padding:`3px 8px`,borderRadius:999,whiteSpace:`nowrap`},children:[(0,z.jsx)(`span`,{style:{textTransform:`uppercase`,letterSpacing:`0.04em`,marginRight:4},children:n.label}),(0,z.jsx)(`span`,{style:{color:`var(--foreground)`,fontWeight:500},children:r})]},`${r}-${t}`)})})]}),d.length>0&&(0,z.jsxs)(`section`,{"data-testid":`prdiff-tab-reviewers`,style:{background:`var(--card)`,border:`1px solid var(--border)`,borderRadius:8,padding:12,display:`flex`,flexDirection:`column`,gap:6},children:[(0,z.jsx)(`header`,{style:{fontSize:12,fontWeight:600,color:`var(--muted-foreground)`,textTransform:`uppercase`,letterSpacing:`0.04em`},children:`Reviewers requested`}),(0,z.jsx)(`div`,{style:{display:`flex`,gap:6,flexWrap:`wrap`},children:d.map((e,t)=>(0,z.jsxs)(`span`,{"data-testid":`prdiff-reviewer-${e.login||e.name||t}`,style:{background:`var(--accent)`,fontSize:11,padding:`2px 8px`,borderRadius:999},children:[`@`,e.login||e.name||`reviewer`]},`${e.login||e.name||t}`))})]}),(0,z.jsxs)(`section`,{"data-testid":`prdiff-tab-files`,style:{background:`var(--card)`,border:`1px solid var(--border)`,borderRadius:8,padding:12,display:`flex`,flexDirection:`column`,gap:6},children:[(0,z.jsxs)(`header`,{style:{fontSize:12,fontWeight:600,color:`var(--muted-foreground)`,textTransform:`uppercase`,letterSpacing:`0.04em`},children:[`Files (`,l.files.length,`)`]}),l.files.length===0?(0,z.jsx)(`div`,{"data-testid":`prdiff-tab-files-empty`,style:{fontSize:12,color:`var(--muted-foreground)`},children:`No file metadata returned.`}):(0,z.jsx)(`ul`,{style:{margin:0,padding:0,listStyle:`none`,display:`flex`,flexDirection:`column`,gap:3},children:l.files.map(e=>{let t=e.additions+e.deletions,n=t===0?0:e.additions/a*100,r=t===0?0:e.deletions/a*100,i=Math.min(100,t>0&&e.additions>0?Math.max(n,4):n),o=Math.min(100-i,t>0&&e.deletions>0?Math.max(r,4):r);return(0,z.jsxs)(`li`,{"data-testid":`prdiff-file-${e.path}`,style:{display:`flex`,alignItems:`center`,gap:8,fontSize:12},children:[(0,z.jsx)(`span`,{style:{flex:1,fontFamily:`var(--font-mono, monospace)`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e.path}),(0,z.jsxs)(`span`,{style:{flex:`0 0 90px`,textAlign:`right`,fontVariantNumeric:`tabular-nums`,fontSize:11},children:[(0,z.jsxs)(`span`,{style:{color:`var(--success, #10b981)`},children:[`+`,e.additions]}),` `,(0,z.jsxs)(`span`,{style:{color:`var(--destructive)`},children:[`−`,e.deletions]})]}),(0,z.jsxs)(`div`,{style:{flex:`0 0 80px`,height:6,background:`var(--accent)`,borderRadius:3,overflow:`hidden`,display:`flex`},children:[(0,z.jsx)(`div`,{style:{width:`${i}%`,height:`100%`,background:`var(--success, #10b981)`}}),(0,z.jsx)(`div`,{style:{width:`${o}%`,height:`100%`,background:`var(--destructive)`}})]})]},e.path)})})]}),i.data?.diff&&(0,z.jsxs)(`section`,{"data-testid":`prdiff-tab-diff`,style:{background:`var(--card)`,border:`1px solid var(--border)`,borderRadius:8,padding:0,overflow:`hidden`},children:[(0,z.jsxs)(`header`,{style:{padding:`8px 12px`,fontSize:12,fontWeight:600,color:`var(--muted-foreground)`,textTransform:`uppercase`,letterSpacing:`0.04em`,borderBottom:`1px solid var(--border)`},children:[`Patch (`,o.length,` line`,o.length===1?``:`s`,`)`]}),(0,z.jsx)(`div`,{ref:s,"data-testid":`prdiff-tab-diff-body`,style:{fontSize:11,fontFamily:`var(--font-mono, monospace)`,lineHeight:1.5,overflowX:`auto`,maxHeight:480},children:c.getVirtualItems().length===0?(0,z.jsx)(`div`,{style:{padding:`0 12px`},children:o.map((e,t)=>(0,z.jsx)(`div`,{style:{color:lY(e)},children:e||`\xA0`},t))}):(0,z.jsx)(`div`,{style:{height:c.getTotalSize(),position:`relative`},children:c.getVirtualItems().map(e=>{let t=o[e.index],n=lY(t);return(0,z.jsx)(`div`,{style:{position:`absolute`,top:0,left:0,width:`100%`,padding:`0 12px`,transform:`translateY(${e.start}px)`,color:n,whiteSpace:`pre`},children:t||`\xA0`},e.key)})})})]})]})}function k9e({pane:e,ctx:t}){return(0,z.jsx)(O9e,{issueId:e.issueId??t.workspaceId})}async function A9e(e){let t=await fetch(`/api/workspaces/${e}/plan`);if(t.status===404)return null;if(!t.ok)throw Error(`HTTP ${t.status} ${t.statusText} — /api/workspaces/${e}/plan`);return t.json()}function uY({issueId:e}){let t=_t(),n=[`workspace-plan`,e],{data:r,isLoading:i,isError:a}=B({queryKey:n,queryFn:()=>A9e(e),refetchInterval:3e4}),o=Nt({mutationFn:async t=>{let n=await fetch(`/api/workspaces/${e}/plan/inspection-policy`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({inspectionPolicy:t})});if(!n.ok)throw Error(`HTTP ${n.status} ${n.statusText}`);return n.json()},onSuccess:e=>{t.setQueryData(n,e)}});return i?(0,z.jsx)(`div`,{"data-testid":`vbrief-tab-loading`,style:{padding:16,fontSize:12,color:`var(--muted-foreground)`},children:`Loading plan…`}):a?(0,z.jsx)(`div`,{"data-testid":`vbrief-tab-error`,style:{padding:16,fontSize:12,color:`var(--destructive)`},children:`Failed to load plan.`}):(0,z.jsx)(`div`,{"data-testid":`vbrief-tab`,style:{padding:16},children:(0,z.jsx)(ak,{doc:r??null,onInspectionPolicyChange:e=>o.mutate(e),isUpdatingInspectionPolicy:o.isPending})})}function dY({issueId:e}){return(0,z.jsx)(`div`,{"data-testid":`beads-tab`,style:{padding:16},children:(0,z.jsx)($T,{issueId:e})})}function j9e({pane:e,ctx:t}){let n=e.issueId??t.workspaceId,[r,i]=(0,R.useState)(`plan`);return(0,z.jsxs)(`div`,{className:Q.subPane,children:[(0,z.jsxs)(`div`,{className:Q.subTabs,role:`tablist`,"aria-label":`Plan view`,children:[(0,z.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":r===`plan`,className:`${Q.subTab} ${r===`plan`?Q.subTabActive:``}`,onClick:()=>i(`plan`),children:`Plan`}),(0,z.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":r===`beads`,className:`${Q.subTab} ${r===`beads`?Q.subTabActive:``}`,onClick:()=>i(`beads`),children:`Beads`})]}),(0,z.jsx)(`div`,{className:Q.subBody,children:r===`plan`?(0,z.jsx)(uY,{issueId:n}):(0,z.jsx)(dY,{issueId:n})})]})}var fY=[`ariaDescribedBy`,`ariaLabel`,`ariaLabelledBy`],pY={ancestors:{tbody:[`table`],td:[`table`],th:[`table`],thead:[`table`],tfoot:[`table`],tr:[`table`]},attributes:{a:[...fY,`dataFootnoteBackref`,`dataFootnoteRef`,[`className`,`data-footnote-backref`],`href`],blockquote:[`cite`],code:[[`className`,/^language-./]],del:[`cite`],div:[`itemScope`,`itemType`],dl:[...fY],h2:[[`className`,`sr-only`]],img:[...fY,`longDesc`,`src`],input:[[`disabled`,!0],[`type`,`checkbox`]],ins:[`cite`],li:[[`className`,`task-list-item`]],ol:[...fY,[`className`,`contains-task-list`]],q:[`cite`],section:[`dataFootnotes`,[`className`,`footnotes`]],source:[`srcSet`],summary:[...fY],table:[...fY],ul:[...fY,[`className`,`contains-task-list`]],"*":`abbr.accept.acceptCharset.accessKey.action.align.alt.axis.border.cellPadding.cellSpacing.char.charOff.charSet.checked.clear.colSpan.color.cols.compact.coords.dateTime.dir.encType.frame.hSpace.headers.height.hrefLang.htmlFor.id.isMap.itemProp.label.lang.maxLength.media.method.multiple.name.noHref.noShade.noWrap.open.prompt.readOnly.rev.rowSpan.rows.rules.scope.selected.shape.size.span.start.summary.tabIndex.title.useMap.vAlign.value.width`.split(`.`)},clobber:[`ariaDescribedBy`,`ariaLabelledBy`,`id`,`name`],clobberPrefix:`user-content-`,protocols:{cite:[`http`,`https`],href:[`http`,`https`,`irc`,`ircs`,`mailto`,`xmpp`],longDesc:[`http`,`https`],src:[`http`,`https`]},required:{input:{disabled:!0,type:`checkbox`}},strip:[`script`],tagNames:`a.b.blockquote.br.code.dd.del.details.div.dl.dt.em.h1.h2.h3.h4.h5.h6.hr.i.img.input.ins.kbd.li.ol.p.picture.pre.q.rp.rt.ruby.s.samp.section.source.span.strike.strong.sub.summary.sup.table.tbody.td.tfoot.th.thead.tr.tt.ul.var`.split(`.`)};function M9e(e){let t=e,n,r,i=t.match(/:(\d+)$/);if(!i?.[1])return{path:t,line:void 0,column:void 0};n=i[1],t=t.slice(0,-i[0].length);let a=t.match(/:(\d+)$/);return a?.[1]?(r=a[1],t=t.slice(0,-a[0].length)):(r=n,n=void 0),{path:t,line:r,column:n}}function mY(e){return e.replace(/\\/g,`/`)}function hY(e){return/^\/[A-Za-z]:\//.test(e)?e.slice(1):e}function N9e(e){return e.replace(/[\\/]+$/,``)}function P9e(e){let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`));return t>=0?e.slice(t+1):e}function F9e(e){return e.replace(/^\.\/+/u,``).replace(/^\/+/u,``)}function I9e(e,t){let{path:n,line:r,column:i}=M9e(e),a=hY(mY(n)),o=a;if(t){let e=hY(mY(N9e(t))),n=P9e(e),r=a.toLowerCase(),i=e.toLowerCase(),s=`${i}/`,c=`${n.toLowerCase()}/`;if(r===i)o=n;else if(r.startsWith(s))o=`${n}/${a.slice(e.length+1)}`;else if(!a.startsWith(`/`)){let e=F9e(a);o=r.startsWith(c)?a:`${n}/${e}`}}return r?`${o}:${r}${i?`:${i}`:``}`:o}var gY=/^[A-Za-z]:[\\/]/,_Y=/^\\\\/,L9e=/^([A-Za-z][A-Za-z0-9+.-]*):(.*)$/,vY=/^(~\/|\.{1,2}\/)/,R9e=/^[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)+(?::\d+){0,2}$/,z9e=/^[A-Za-z0-9._-]+\.[A-Za-z0-9_-]+(?::\d+){0,2}$/,yY=/:\d+(?::\d+)?$/,B9e=/^\d+(?::\d+)?$/,V9e=[`/Users/`,`/home/`,`/tmp/`,`/var/`,`/etc/`,`/opt/`,`/mnt/`,`/Volumes/`,`/private/`,`/root/`],bY=/(^|[\s([{"'`])((?:\/(?:Users|home|tmp|var|etc|opt|mnt|Volumes|private|root)\/[A-Za-z0-9._~+@%/=-]+|(?:~\/|\.{1,2}\/)?[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)+|[A-Za-z0-9._-]+\.[A-Za-z0-9_-]+)(?::\d+(?::\d+)?)?)/g;function xY(e){try{return decodeURIComponent(e)}catch{return e}}function H9e(e){return e.startsWith(`<`)&&e.endsWith(`>`)?e.slice(1,-1):e}function U9e(e){return H9e(e.trim())}function W9e(e){let t=e.indexOf(`#`),n=t>=0?e.slice(0,t):e,r=t>=0?e.slice(t):``,i=n.indexOf(`?`);return{path:i>=0?n.slice(0,i):n,hash:r}}function SY(e){return/^\/[A-Za-z]:[\\/]/.test(e)?e.slice(1):e}function G9e(e,t){try{let n=new URL(e);if(n.protocol.toLowerCase()!==`file:`)return null;let r=n.pathname;if(r.length===0)return null;let i=SY(r);return{path:t?.decodePath===!1?i:xY(i),hash:n.hash}}catch{return null}}function K9e(e){if(!e.startsWith(`/`))return!1;if(V9e.some(t=>e.startsWith(t))||yY.test(e))return!0;let t=e.slice(e.lastIndexOf(`/`)+1);return/\.[A-Za-z0-9_-]+$/.test(t)}function q9e(e,t){if(!t||yY.test(e))return e;let n=t.match(/^#L(\d+)(?:C(\d+))?$/i);if(!n?.[1])return e;let r=n[1],i=n[2];return`${e}:${r}${i?`:${i}`:``}`}function J9e(e){return gY.test(e)||_Y.test(e)||vY.test(e)?!0:e.startsWith(`/`)?K9e(e):R9e.test(e)||z9e.test(e)}function Y9e(e){return vY.test(e)||!e.startsWith(`/`)&&!gY.test(e)&&!_Y.test(e)}function X9e(e){let t=e.match(L9e);if(!t)return!1;let n=t[2]??``;return n.startsWith(`//`)?!0:!B9e.test(n)}function CY(e){return/^[A-Za-z]:[\\/]/.test(e)||e.startsWith(`\\\\`)}function Z9e(e){return e.startsWith(`/`)||CY(e)}function wY(e){return CY(e)||/[A-Za-z]:\\/.test(e)}function TY(e,t,n){let r=e.replace(/[\\/]+$/,``);return n===`\\`?`${r}\\${t.replace(/\//g,`\\`)}`:`${r}/${t.replace(/^\/+/,``)}`}function Q9e(e){let t=e.match(/^\/Users\/([^/]+)/);if(t?.[1])return`/Users/${t[1]}`;let n=e.match(/^\/home\/([^/]+)/);if(n?.[1])return`/home/${n[1]}`;let r=e.match(/^([A-Za-z]:\\Users\\[^\\]+)/);if(r?.[1])return r[1]}function EY(e){let t=e,n,r,i=t.match(/:(\d+)$/);if(!i?.[1])return{path:t,line:void 0,column:void 0};n=i[1],t=t.slice(0,-i[0].length);let a=t.match(/:(\d+)$/);return a?.[1]?(r=a[1],t=t.slice(0,-a[0].length)):(r=n,n=void 0),{path:t,line:r,column:n}}function $9e(e,t){let{path:n,line:r,column:i}=EY(e),a=n;if(n.startsWith(`~/`)){let e=Q9e(t);if(e){let t=wY(e)?`\\`:`/`;a=TY(e,n.slice(2),t)}}else Z9e(n)||(a=TY(t,n,wY(t)?`\\`:`/`));return r?`${a}:${r}${i?`:${i}`:``}`:a}function DY(e){if(!e)return null;let t=U9e(e);if(t.length===0||t.startsWith(`#`))return null;let n=t.toLowerCase().startsWith(`file:`)?G9e(t):null,r=n??W9e(t),i=SY(n?r.path.trim():xY(r.path.trim())),a=xY(r.hash.trim());return i.length===0||!gY.test(i)&&!_Y.test(i)&&X9e(i)||!J9e(i)?null:q9e(i,a)}function eet(e){return DY(e)!==null}function tet(e,t){let n=DY(e);return!n||!t?null:Y9e(n)?$9e(n,t):n}function net(e){let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`));return t>=0?e.slice(t+1):e}function ret(e,t){if(!t||e.length===0)return[{text:e}];let n=[],r=0;bY.lastIndex=0;for(let i of e.matchAll(bY)){let a=i[1]??``,o=i[2];if(!o)continue;let s=i.index+a.length,c=s+o.length;s<r||!OY(o,t)||(s>r&&n.push({text:e.slice(r,s)}),n.push({text:o,href:o}),r=c)}return r===0?[{text:e}]:(r<e.length&&n.push({text:e.slice(r)}),n)}function OY(e,t){let n=tet(e,t);if(!n)return null;let{path:r,line:i,column:a}=EY(n),o=i?Number.parseInt(i,10):NaN,s=a?Number.parseInt(a,10):NaN,c=Number.isFinite(o)?o:void 0,l=Number.isFinite(s)?s:void 0;return{filePath:r,targetPath:n,displayPath:I9e(n,t),basename:net(r),...c===void 0?{}:{line:c},...l===void 0?{}:{column:l}}}var kY=null;function iet(e,t,n){let r=e.getBoundingClientRect(),i=Math.min(Math.max(4,t),Math.max(4,window.innerWidth-r.width-4)),a=Math.min(Math.max(4,n),Math.max(4,window.innerHeight-r.height-4));e.style.left=`${i}px`,e.style.top=`${a}px`}function aet({items:e,x:t,y:n}){kY?.();let r=document.createElement(`div`);r.style.cssText=`position:fixed;inset:0;z-index:9999`,r.dataset.testid=`context-menu-overlay`;let i=document.createElement(`div`);i.className=`fixed z-[10000] min-w-[160px] rounded-md border border-border bg-popover py-1 shadow-xl animate-in fade-in zoom-in-95`,i.style.left=`${t}px`,i.style.top=`${n}px`,i.setAttribute(`role`,`menu`);let a=()=>{document.removeEventListener(`keydown`,o),document.removeEventListener(`mousedown`,s),r.remove(),i.remove(),kY===a&&(kY=null)},o=e=>{e.key===`Escape`&&(e.preventDefault(),a())},s=e=>{i.contains(e.target)||a()};for(let t of e){let e=document.createElement(`button`);e.type=`button`,e.textContent=t.label,e.disabled=t.disabled===!0,e.setAttribute(`role`,`menuitem`),e.className=t.disabled===!0?`flex w-full items-center gap-2 px-3 py-1.5 text-left text-[11px] text-muted-foreground/60 cursor-not-allowed`:t.destructive===!0?`flex w-full items-center gap-2 px-3 py-1.5 text-left text-[11px] text-destructive hover:bg-accent cursor-default`:`flex w-full items-center gap-2 px-3 py-1.5 text-left text-[11px] text-popover-foreground hover:bg-accent cursor-default`,t.disabled!==!0&&e.addEventListener(`click`,()=>{a(),t.onClick()}),i.appendChild(e)}kY=a,document.body.appendChild(r),document.body.appendChild(i),document.addEventListener(`keydown`,o),document.addEventListener(`mousedown`,s),(window.requestAnimationFrame??(e=>window.setTimeout(e,0)))(()=>iet(i,t,n))}var AY=8,oet=240;function jY(e,t,{estimatedWidth:n=280,preferredHeight:r=400}={}){let[i,a]=(0,R.useState)({openUp:!1,align:`left`,maxHeight:r});return(0,R.useLayoutEffect)(()=>{if(!e||!t.current)return;let i=t.current.getBoundingClientRect(),o=window.innerHeight-i.bottom-AY,s=i.top-AY,c=o<Math.min(r,oet)&&s>o;a({openUp:c,align:i.left+n>window.innerWidth-AY?`right`:`left`,maxHeight:Math.max(120,Math.min(r,c?s:o))})},[e,t,n,r]),i}var set=`size-3.5 shrink-0 text-muted-foreground`,cet=12,uet=new Set([`c`,`cc`,`cpp`,`cs`,`css`,`go`,`html`,`java`,`js`,`jsx`,`kt`,`mjs`,`php`,`py`,`rb`,`rs`,`scss`,`sh`,`sql`,`swift`,`ts`,`tsx`,`vue`]),det=new Set([`log`,`md`,`mdx`,`txt`]),fet=new Set([`avif`,`gif`,`jpeg`,`jpg`,`png`,`svg`,`webp`]),pet=new Set([`7z`,`gz`,`rar`,`tar`,`tgz`,`zip`]),met=new Set([`env`,`toml`,`yaml`,`yml`]),MY=null;function het(e){let t=e.replace(/\\/g,`/`).split(`/`).at(-1)??``,n=t.lastIndexOf(`.`);return n>0?t.slice(n+1).toLowerCase():``}function get(e){let t=het(e);return t===`json`?uee:uet.has(t)?see:det.has(t)?Mn:fet.has(t)?lee:pet.has(t)?oee:met.has(t)?cee:pee}function _et({displayPath:e,line:t,column:n}){let r=t?e.replace(/:\d+(?::\d+)?$/,``):e,i=t?`L${t}${n?`:C${n}`:``}`:null;return i?`${r} · ${i}`:r}async function vet(){let e=(await hj().request(e=>e[Pp.getAvailableEditors]())).editors,t=Mj(),n=t&&e.includes(t)?t:Mp.find(t=>e.includes(t.id))?.id;if(!n)throw Error(`No available editors found.`);return Nj(n),n}function yet(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`)}async function bet(e,t){try{return MY||=L(()=>Promise.resolve().then(()=>qht).then(e=>e.getSharedHighlighter({themes:[`github-dark`],langs:[]})),void 0),(await MY).codeToHtml(e,{lang:t||`text`,theme:`github-light`})}catch{return`<pre><code>${yet(e)}</code></pre>`}}function xet(e){let t=e.replace(/:\d+(?::\d+)?$/,``).replace(/\\/g,`/`),n=t.split(`/`).filter(Boolean);return n.length>1?n.slice(1).join(`/`):t}function Cet(e){return e.replace(/\\/g,`/`).match(/\/workspaces\/feature-([a-z]+-\d+)(?:\/|:|$)/i)?.[1]?.toUpperCase()}var wet=(0,R.memo)(function({filePath:e,targetPath:t,displayPath:n,basename:r,line:i,column:a,className:o,issueId:s}){let c=get(e),l=_et({filePath:e,targetPath:t,displayPath:n,basename:r,line:i,column:a}),u=(0,R.useRef)(null),d=(0,R.useRef)(0),f=(0,R.useRef)(!1),[p,m]=(0,R.useState)(!1),[h,g]=(0,R.useState)({status:`loading`}),{openUp:_,align:v,maxHeight:y}=jY(p,u,{estimatedWidth:520,preferredHeight:360}),b=s??Cet(t),x=(0,R.useMemo)(()=>xet(n),[n]),S=(0,R.useCallback)(()=>{vet().then(e=>hj().request(n=>n[Pp.shellOpenInEditor]({cwd:t,editor:e}))).then(()=>{H.success(`Opened in editor`)}).catch(e=>{H.error(`Failed to open file: ${e instanceof Error?e.message:String(e)}`)})},[t]),C=(0,R.useCallback)(()=>{d.current++,m(!1)},[]),w=(0,R.useCallback)(()=>{let e=b;if(!e){let e=`No issue context available for Quickview`;g({status:`error`,message:e}),m(!0),H.error(e);return}let t=++d.current;g({status:`loading`}),m(!0),hj().request(t=>t[Pp.readWorkspaceFile]({issueId:e,relativePath:x,...i?{line:i}:{},contextLines:cet})).then(e=>bet(e.text,e.lang).then(t=>({html:t,result:e}))).then(({html:e,result:n})=>{t===d.current&&g({status:`ready`,html:e,truncated:n.truncated,totalLines:n.totalLines})}).catch(e=>{if(t!==d.current)return;let n=e instanceof Error?e.message:String(e);g({status:`error`,message:n}),H.error(`Failed to load Quickview: ${n}`)})},[i,b,x]),T=(0,R.useCallback)((e,t)=>{navigator.clipboard.writeText(e).then(()=>{H.success(`Copied ${t}`)}).catch(e=>{H.error(`Failed to copy ${t}: ${e instanceof Error?e.message:String(e)}`)})},[]);return(0,R.useEffect)(()=>{let e=e=>{e.key===`Shift`&&f.current&&!p&&w()},t=e=>{e.key===`Shift`&&C()};return window.addEventListener(`keydown`,e),window.addEventListener(`keyup`,t),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`keyup`,t)}},[C,w,p]),(0,z.jsxs)(`span`,{ref:u,className:`relative inline-flex max-w-full align-baseline`,"data-testid":`markdown-file-link-container`,onMouseEnter:e=>{f.current=!0,e.shiftKey&&w()},onMouseLeave:()=>{f.current=!1,C()},children:[(0,z.jsxs)(`a`,{href:t,title:t,className:vj(`chat-markdown-file-link relative top-[2px] inline-flex max-w-full items-center gap-1.5 rounded-md border border-border bg-card px-2 py-0.5 font-mono text-[11px] leading-5 text-foreground no-underline transition-colors hover:border-primary/50 hover:bg-accent`,o),onClick:e=>{e.preventDefault(),e.stopPropagation(),S()},onContextMenu:e=>{e.preventDefault(),e.stopPropagation(),aet({x:e.clientX,y:e.clientY,items:[{label:`Open in editor`,onClick:S},{label:`Copy relative path`,onClick:()=>T(n,`relative path`)},{label:`Copy full path`,onClick:()=>T(t,`full path`)}]})},children:[(0,z.jsx)(c,{className:set,"aria-hidden":`true`,"data-testid":`markdown-file-link-icon`}),(0,z.jsx)(`span`,{className:`truncate`,"data-testid":`markdown-file-link-label`,children:l})]}),p&&(0,z.jsxs)(`div`,{"data-testid":`markdown-file-quickview`,className:`absolute z-50 w-[min(520px,calc(100vw-16px))] overflow-hidden rounded-lg border border-border bg-popover text-popover-foreground shadow-xl`,style:{maxHeight:`${y}px`,..._?{bottom:`100%`,marginBottom:6}:{top:`100%`,marginTop:6},...v===`right`?{right:0}:{left:0}},children:[h.status===`loading`&&(0,z.jsxs)(`div`,{className:`flex items-center gap-2 p-3 text-xs text-muted-foreground`,"data-testid":`markdown-file-quickview-loading`,children:[(0,z.jsx)(ar,{size:13,className:`animate-spin`,"aria-hidden":`true`}),`Loading preview…`]}),h.status===`error`&&(0,z.jsx)(`div`,{className:`p-3 text-xs text-destructive`,"data-testid":`markdown-file-quickview-error`,children:h.message}),h.status===`ready`&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{"data-testid":`markdown-file-quickview-content`,className:`max-h-[300px] overflow-auto text-xs [&_pre]:m-0 [&_pre]:p-3 [&_pre]:text-xs`,dangerouslySetInnerHTML:{__html:h.html}}),(0,z.jsxs)(`div`,{className:`flex items-center justify-between border-t border-border px-3 py-1.5 text-[10px] text-muted-foreground`,children:[(0,z.jsxs)(`span`,{children:[i?`line ${i}`:`top of file`,` · `,h.totalLines,` lines`]}),h.truncated&&(0,z.jsx)(`span`,{"data-testid":`markdown-file-quickview-truncated`,children:`truncated — first 256 KiB`})]})]})]})]})}),Tet=300*1e3,Eet=30*1e3,Det=5e3,NY=new Map;function PY(e,t){return`${e}\0${t}`}function FY(e,t){let n=PY(e,t),r=NY.get(n);return r?r.expiresAt<Date.now()?(NY.delete(n),null):(NY.delete(n),NY.set(n,r),{exists:r.exists,kind:r.kind}):null}function Oet(e,t,n,r){if(NY.size>=Det){let e=NY.keys().next().value;e!==void 0&&NY.delete(e)}let i=n?Tet:Eet;NY.set(PY(e,t),{exists:n,kind:r,expiresAt:Date.now()+i})}var IY=new Map;function ket(e,t){return`${e}\0${t}`}function Aet(e,t){if(!e||!t)return{state:`missing`};let n=FY(e,t);return n?n.exists?{state:`exists`,kind:n.kind}:{state:`missing`}:{state:`loading`}}function jet(e,t){let[n,r]=(0,R.useState)(()=>Aet(e,t));return(0,R.useEffect)(()=>{if(!e||!t){r({state:`missing`});return}let n=FY(e,t);if(n){r(n.exists?{state:`exists`,kind:n.kind}:{state:`missing`});return}r({state:`loading`});let i=!1,a=ket(e,t),o=IY.get(a);return o||(o=hj().request(n=>n[Pp.resolveFilePathExists]({cwd:e,path:t})).then(e=>({exists:e.exists,kind:e.kind})).catch(()=>({exists:!1,kind:null})),IY.set(a,o),o.finally(()=>{IY.get(a)===o&&IY.delete(a)})),o.then(n=>{Oet(e,t,n.exists,n.kind),!i&&r(n.exists?{state:`exists`,kind:n.kind}:{state:`missing`})}),()=>{i=!0}},[e,t]),n}var LY=new class{maxEntries;maxMemoryBytes;cache=new Map;totalSize=0;constructor(e,t){this.maxEntries=e,this.maxMemoryBytes=t}get(e){let t=this.cache.get(e);return t?(this.promote(e,t),t.value):null}set(e,t,n){let r=this.cache.get(e);r&&(this.totalSize-=r.approximateSize,this.cache.delete(e)),this.evictIfNeeded(n),this.cache.set(e,{value:t,approximateSize:n}),this.totalSize+=n}clear(){this.cache.clear(),this.totalSize=0}promote(e,t){this.cache.delete(e),this.cache.set(e,t)}evictIfNeeded(e){for(;(this.cache.size>=this.maxEntries||this.totalSize+e>this.maxMemoryBytes)&&this.cache.size>0;){let e=this.cache.keys().next().value;if(e===void 0)break;let t=this.cache.get(e);t&&(this.totalSize-=t.approximateSize),this.cache.delete(e)}}}(500,50*1024*1024);function Met(e,t){return Math.max(e.length*2,t.length*3)}function Net(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=t*16777619>>>0;return t}function Pet(e,t){return`${Net(e)}:${e.length}:${t}`}var Fet=new Set([`span`,`pre`,`code`,`div`,`br`]),Iet=new Set([`class`,`style`]),Let=new Set([`color`,`background-color`,`font-style`,`font-weight`,`text-decoration`,`opacity`]);function Ret(e){return e.split(`;`).map(e=>e.trim()).filter(Boolean).filter(e=>{let[t]=e.split(`:`);return t&&Let.has(t.trim().toLowerCase())}).join(`; `)}var RY=null;function zet(){return RY||=new DOMParser,RY}function Bet(e){let t=zet().parseFromString(e,`text/html`);function n(e){if(e.nodeType===Node.TEXT_NODE)return document.createTextNode(e.textContent||``);if(e.nodeType!==Node.ELEMENT_NODE)return null;let t=e,r=t.tagName.toLowerCase();if(!Fet.has(r))return null;let i=document.createElement(r);for(let e of Array.from(t.attributes))if(Iet.has(e.name.toLowerCase()))if(e.name===`style`){let t=Ret(e.value);t&&i.setAttribute(`style`,t)}else i.setAttribute(e.name,e.value);for(let e of Array.from(t.childNodes)){let t=n(e);t&&i.appendChild(t)}return i}let r=document.createDocumentFragment();for(let e of Array.from(t.body.childNodes)){let t=n(e);t&&r.appendChild(t)}let i=document.createElement(`div`);return i.appendChild(r),i.innerHTML}var zY=null;async function Vet(){return zY||=L(()=>Promise.resolve().then(()=>qht).then(e=>e.getSharedHighlighter({themes:[`github-dark`],langs:[]})),void 0),zY}async function Het(e,t,n){let r=Pet(e,t);if(!n){let e=LY.get(r);if(e!==null)return e}try{let i=(await Vet()).codeToHtml(e,{lang:t||`text`,theme:`github-light`});return n||LY.set(r,i,Met(i,e)),i}catch{return`<pre><code>${e.replace(/</g,`<`).replace(/>/g,`>`)}</code></pre>`}}var BY=class extends R.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?this.props.fallback:this.props.children}};function Uet({code:e,lang:t,isStreaming:n}){let[r,i]=(0,R.useState)(null),[a,o]=(0,R.useState)(!1),s=(0,R.useRef)(!1);(0,R.useEffect)(()=>(s.current=!1,Het(e,t,n).then(e=>{s.current||i(e)}),()=>{s.current=!0}),[e,t,n]);let c=(0,R.useMemo)(()=>r?Bet(r):null,[r]),l=(0,R.useCallback)(()=>{navigator.clipboard.writeText(e).then(()=>{o(!0),setTimeout(()=>o(!1),2e3)})},[e]);return(0,z.jsxs)(`div`,{className:J.codeBlock,children:[(0,z.jsx)(`button`,{className:J.copyButton,onClick:l,title:`Copy code`,children:a?(0,z.jsx)($t,{size:13}):(0,z.jsx)(xn,{size:13})}),c?(0,z.jsx)(`div`,{className:J.shikiOutput,dangerouslySetInnerHTML:{__html:c}}):(0,z.jsx)(`pre`,{className:J.codePlain,children:(0,z.jsx)(`code`,{children:e})})]})}function VY(e){return eet(e)?e:uO(e)}async function Wet(){let e=await fetch(`/api/settings`);if(!e.ok)throw Error(`settings fetch failed`);return e.json()}var HY=(0,R.createContext)(!1);function Get({children:e}){let{data:t}=B({queryKey:[`settings`],queryFn:Wet,retry:!1});return(0,z.jsx)(HY.Provider,{value:t?.experimental?.streamdownRenderer===!0,children:e})}var Ket=new Set([`code`,`inlineCode`,`link`,`linkReference`,`definition`]),qet={...pY,protocols:{...pY.protocols,href:void 0}},Jet=R.lazy(async()=>{let[{Streamdown:e,defaultRehypePlugins:t}]=await Promise.all([L(()=>import(`./dist-CHQsz1no.js`),__vite__mapDeps([0,1,2,3,4,5,6])),L(()=>Promise.resolve({}),__vite__mapDeps([7]))]),n=[t.raw,[t.sanitize[0],qet],t.harden];return{default:t=>R.createElement(e,{...t,rehypePlugins:n})}});function Yet({meta:e,cwd:t,issueId:n,fallback:r}){let{state:i}=jet(t,e.filePath);return i===`exists`?(0,z.jsx)(wet,{...e,issueId:n}):(0,z.jsx)(z.Fragment,{children:r})}function Xet(e={}){return t=>{let n=t=>{if(!t.children||Ket.has(t.type))return;let r=[];for(let i of t.children)if(i.type===`text`&&i.value!==void 0)for(let t of ret(i.value,e.cwd))r.push(t.href?{type:`link`,url:t.href,title:null,children:[{type:`text`,value:t.text}]}:{type:`text`,value:t.text});else n(i),r.push(i);t.children=r};n(t)}}function Zet(e,t,n){return{pre({children:t}){let n=R.Children.toArray(t)[0];if(!R.isValidElement(n))return(0,z.jsx)(`pre`,{children:t});let r=n,i=r.props.className??``,a=/language-(\w+)/.exec(i)?.[1]??``,o=String(r.props.children??``).trimEnd();return(0,z.jsx)(BY,{fallback:(0,z.jsx)(`pre`,{className:J.codePlain,children:(0,z.jsx)(`code`,{children:o})}),children:(0,z.jsx)(Uet,{code:o,lang:a,isStreaming:e})})},a({href:e,children:r}){let i=OY(e,t);return i?(0,z.jsx)(Yet,{meta:i,cwd:t,issueId:n,fallback:r}):(0,z.jsx)(`a`,{href:typeof e==`string`&&e.trim().length>0&&!/^(javascript|data|vbscript):/i.test(e.trim())?e:void 0,target:`_blank`,rel:`noopener noreferrer`,className:J.mdLink,children:r})}}}var Qet=5e4,UY=8e3;function $et({text:e}){let[t,n]=(0,R.useState)(!1),r=Math.round(e.length/1024),i=e.length>UY,a=t||!i?e:e.slice(0,UY);return(0,z.jsxs)(`div`,{className:J.chatMarkdown,children:[(0,z.jsxs)(`div`,{style:{fontSize:`0.8em`,opacity:.6,marginBottom:6},children:[`Large message (`,r,` KB) — rendered as plain text to keep the panel responsive.`]}),(0,z.jsxs)(`pre`,{className:J.mdFallback,style:{whiteSpace:`pre-wrap`,wordBreak:`break-word`},children:[a,!t&&i?`
|
|
314
|
+
`)??[],[i.data?.diff]),s=(0,R.useRef)(null),c=sY({count:o.length,getScrollElement:()=>s.current,estimateSize:()=>E9e,overscan:12});if(n)return(0,z.jsx)(`div`,{"data-testid":`prdiff-tab-loading`,style:{padding:16,fontSize:12,color:`var(--muted-foreground)`},children:`Loading pull request…`});if(r||!t)return(0,z.jsx)(`div`,{"data-testid":`prdiff-tab-error`,style:{padding:16,fontSize:12,color:`var(--destructive)`},children:`Failed to load pull request.`});if(!t.pr)return(0,z.jsxs)(`div`,{"data-testid":`prdiff-tab-empty`,style:{padding:16,display:`flex`,flexDirection:`column`,gap:6},children:[(0,z.jsx)(`div`,{style:{fontSize:14,fontWeight:600},children:`No pull request yet`}),(0,z.jsxs)(`div`,{style:{fontSize:12,color:`var(--muted-foreground)`},children:[`No PR found for branch `,(0,z.jsxs)(`code`,{children:[`feature/`,e.toLowerCase()]}),`.`,t.error?(0,z.jsxs)(z.Fragment,{children:[` `,(0,z.jsxs)(`span`,{"data-testid":`prdiff-tab-error-msg`,style:{color:`var(--destructive)`},children:[`(`,t.error,`)`]})]}):null]})]});let l=t.pr,u=l.statusCheckRollup??[],d=l.reviewRequests??[];return(0,z.jsxs)(`div`,{"data-testid":`prdiff-tab`,style:{padding:16,display:`flex`,flexDirection:`column`,gap:12,fontSize:13},children:[(0,z.jsxs)(`header`,{"data-testid":`prdiff-tab-header`,style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,flexWrap:`wrap`},children:[(0,z.jsxs)(`a`,{href:l.url,target:`_blank`,rel:`noreferrer`,"data-testid":`prdiff-tab-link`,style:{fontSize:16,fontWeight:700,color:`var(--foreground)`,textDecoration:`none`},children:[`#`,l.number,` `,l.title]}),(0,z.jsx)(D9e,{pr:l})]}),(0,z.jsxs)(`div`,{style:{fontSize:12,color:`var(--muted-foreground)`},children:[(0,z.jsx)(`code`,{children:l.headRefName}),` → `,(0,z.jsx)(`code`,{children:l.baseRefName}),l.author?.login?(0,z.jsxs)(z.Fragment,{children:[` · @`,l.author.login]}):null,` · `,(0,z.jsxs)(`span`,{"data-testid":`prdiff-tab-changes`,children:[`+`,l.additions,` −`,l.deletions,` across `,l.changedFiles,` `,`file`,l.changedFiles===1?``:`s`]})]})]}),(0,z.jsxs)(`section`,{"data-testid":`prdiff-tab-checks`,style:{background:`var(--card)`,border:`1px solid var(--border)`,borderRadius:8,padding:12,display:`flex`,flexDirection:`column`,gap:8},children:[(0,z.jsxs)(`header`,{style:{fontSize:12,fontWeight:600,color:`var(--muted-foreground)`,textTransform:`uppercase`,letterSpacing:`0.04em`},children:[`CI checks`,l.reviewDecision?(0,z.jsxs)(`span`,{"data-testid":`prdiff-tab-review-decision`,style:{marginLeft:8,color:`var(--foreground)`,textTransform:`none`,fontWeight:500},children:[`· review: `,l.reviewDecision.toLowerCase().replace(/_/g,` `)]}):null]}),u.length===0?(0,z.jsx)(`div`,{"data-testid":`prdiff-tab-checks-empty`,style:{fontSize:12,color:`var(--muted-foreground)`},children:`No checks reported.`}):(0,z.jsx)(`ul`,{style:{margin:0,padding:0,listStyle:`none`,display:`flex`,flexWrap:`wrap`,gap:6},children:u.map((e,t)=>{let n=cY(e),r=e.name||e.workflowName||e.__typename||`check-${t}`;return(0,z.jsxs)(`li`,{"data-testid":`prdiff-check-${r}`,style:{background:n.bg,color:n.fg,fontSize:11,fontWeight:600,padding:`3px 8px`,borderRadius:999,whiteSpace:`nowrap`},children:[(0,z.jsx)(`span`,{style:{textTransform:`uppercase`,letterSpacing:`0.04em`,marginRight:4},children:n.label}),(0,z.jsx)(`span`,{style:{color:`var(--foreground)`,fontWeight:500},children:r})]},`${r}-${t}`)})})]}),d.length>0&&(0,z.jsxs)(`section`,{"data-testid":`prdiff-tab-reviewers`,style:{background:`var(--card)`,border:`1px solid var(--border)`,borderRadius:8,padding:12,display:`flex`,flexDirection:`column`,gap:6},children:[(0,z.jsx)(`header`,{style:{fontSize:12,fontWeight:600,color:`var(--muted-foreground)`,textTransform:`uppercase`,letterSpacing:`0.04em`},children:`Reviewers requested`}),(0,z.jsx)(`div`,{style:{display:`flex`,gap:6,flexWrap:`wrap`},children:d.map((e,t)=>(0,z.jsxs)(`span`,{"data-testid":`prdiff-reviewer-${e.login||e.name||t}`,style:{background:`var(--accent)`,fontSize:11,padding:`2px 8px`,borderRadius:999},children:[`@`,e.login||e.name||`reviewer`]},`${e.login||e.name||t}`))})]}),(0,z.jsxs)(`section`,{"data-testid":`prdiff-tab-files`,style:{background:`var(--card)`,border:`1px solid var(--border)`,borderRadius:8,padding:12,display:`flex`,flexDirection:`column`,gap:6},children:[(0,z.jsxs)(`header`,{style:{fontSize:12,fontWeight:600,color:`var(--muted-foreground)`,textTransform:`uppercase`,letterSpacing:`0.04em`},children:[`Files (`,l.files.length,`)`]}),l.files.length===0?(0,z.jsx)(`div`,{"data-testid":`prdiff-tab-files-empty`,style:{fontSize:12,color:`var(--muted-foreground)`},children:`No file metadata returned.`}):(0,z.jsx)(`ul`,{style:{margin:0,padding:0,listStyle:`none`,display:`flex`,flexDirection:`column`,gap:3},children:l.files.map(e=>{let t=e.additions+e.deletions,n=t===0?0:e.additions/a*100,r=t===0?0:e.deletions/a*100,i=Math.min(100,t>0&&e.additions>0?Math.max(n,4):n),o=Math.min(100-i,t>0&&e.deletions>0?Math.max(r,4):r);return(0,z.jsxs)(`li`,{"data-testid":`prdiff-file-${e.path}`,style:{display:`flex`,alignItems:`center`,gap:8,fontSize:12},children:[(0,z.jsx)(`span`,{style:{flex:1,fontFamily:`var(--font-mono, monospace)`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e.path}),(0,z.jsxs)(`span`,{style:{flex:`0 0 90px`,textAlign:`right`,fontVariantNumeric:`tabular-nums`,fontSize:11},children:[(0,z.jsxs)(`span`,{style:{color:`var(--success, #10b981)`},children:[`+`,e.additions]}),` `,(0,z.jsxs)(`span`,{style:{color:`var(--destructive)`},children:[`−`,e.deletions]})]}),(0,z.jsxs)(`div`,{style:{flex:`0 0 80px`,height:6,background:`var(--accent)`,borderRadius:3,overflow:`hidden`,display:`flex`},children:[(0,z.jsx)(`div`,{style:{width:`${i}%`,height:`100%`,background:`var(--success, #10b981)`}}),(0,z.jsx)(`div`,{style:{width:`${o}%`,height:`100%`,background:`var(--destructive)`}})]})]},e.path)})})]}),i.data?.diff&&(0,z.jsxs)(`section`,{"data-testid":`prdiff-tab-diff`,style:{background:`var(--card)`,border:`1px solid var(--border)`,borderRadius:8,padding:0,overflow:`hidden`},children:[(0,z.jsxs)(`header`,{style:{padding:`8px 12px`,fontSize:12,fontWeight:600,color:`var(--muted-foreground)`,textTransform:`uppercase`,letterSpacing:`0.04em`,borderBottom:`1px solid var(--border)`},children:[`Patch (`,o.length,` line`,o.length===1?``:`s`,`)`]}),(0,z.jsx)(`div`,{ref:s,"data-testid":`prdiff-tab-diff-body`,style:{fontSize:11,fontFamily:`var(--font-mono, monospace)`,lineHeight:1.5,overflowX:`auto`,maxHeight:480},children:c.getVirtualItems().length===0?(0,z.jsx)(`div`,{style:{padding:`0 12px`},children:o.map((e,t)=>(0,z.jsx)(`div`,{style:{color:lY(e)},children:e||`\xA0`},t))}):(0,z.jsx)(`div`,{style:{height:c.getTotalSize(),position:`relative`},children:c.getVirtualItems().map(e=>{let t=o[e.index],n=lY(t);return(0,z.jsx)(`div`,{style:{position:`absolute`,top:0,left:0,width:`100%`,padding:`0 12px`,transform:`translateY(${e.start}px)`,color:n,whiteSpace:`pre`},children:t||`\xA0`},e.key)})})})]})]})}function k9e({pane:e,ctx:t}){return(0,z.jsx)(O9e,{issueId:e.issueId??t.workspaceId})}async function A9e(e){let t=await fetch(`/api/workspaces/${e}/plan`);if(t.status===404)return null;if(!t.ok)throw Error(`HTTP ${t.status} ${t.statusText} — /api/workspaces/${e}/plan`);return t.json()}function uY({issueId:e}){let t=_t(),n=[`workspace-plan`,e],{data:r,isLoading:i,isError:a}=B({queryKey:n,queryFn:()=>A9e(e),refetchInterval:3e4}),o=Nt({mutationFn:async t=>{let n=await fetch(`/api/workspaces/${e}/plan/inspection-policy`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({inspectionPolicy:t})});if(!n.ok)throw Error(`HTTP ${n.status} ${n.statusText}`);return n.json()},onSuccess:e=>{t.setQueryData(n,e)}});return i?(0,z.jsx)(`div`,{"data-testid":`vbrief-tab-loading`,style:{padding:16,fontSize:12,color:`var(--muted-foreground)`},children:`Loading plan…`}):a?(0,z.jsx)(`div`,{"data-testid":`vbrief-tab-error`,style:{padding:16,fontSize:12,color:`var(--destructive)`},children:`Failed to load plan.`}):(0,z.jsx)(`div`,{"data-testid":`vbrief-tab`,style:{padding:16},children:(0,z.jsx)(ak,{doc:r??null,onInspectionPolicyChange:e=>o.mutate(e),isUpdatingInspectionPolicy:o.isPending})})}function dY({issueId:e}){return(0,z.jsx)(`div`,{"data-testid":`beads-tab`,style:{padding:16},children:(0,z.jsx)($T,{issueId:e})})}function j9e({pane:e,ctx:t}){let n=e.issueId??t.workspaceId,[r,i]=(0,R.useState)(`plan`);return(0,z.jsxs)(`div`,{className:Q.subPane,children:[(0,z.jsxs)(`div`,{className:Q.subTabs,role:`tablist`,"aria-label":`Plan view`,children:[(0,z.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":r===`plan`,className:`${Q.subTab} ${r===`plan`?Q.subTabActive:``}`,onClick:()=>i(`plan`),children:`Plan`}),(0,z.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":r===`beads`,className:`${Q.subTab} ${r===`beads`?Q.subTabActive:``}`,onClick:()=>i(`beads`),children:`Beads`})]}),(0,z.jsx)(`div`,{className:Q.subBody,children:r===`plan`?(0,z.jsx)(uY,{issueId:n}):(0,z.jsx)(dY,{issueId:n})})]})}var fY=[`ariaDescribedBy`,`ariaLabel`,`ariaLabelledBy`],pY={ancestors:{tbody:[`table`],td:[`table`],th:[`table`],thead:[`table`],tfoot:[`table`],tr:[`table`]},attributes:{a:[...fY,`dataFootnoteBackref`,`dataFootnoteRef`,[`className`,`data-footnote-backref`],`href`],blockquote:[`cite`],code:[[`className`,/^language-./]],del:[`cite`],div:[`itemScope`,`itemType`],dl:[...fY],h2:[[`className`,`sr-only`]],img:[...fY,`longDesc`,`src`],input:[[`disabled`,!0],[`type`,`checkbox`]],ins:[`cite`],li:[[`className`,`task-list-item`]],ol:[...fY,[`className`,`contains-task-list`]],q:[`cite`],section:[`dataFootnotes`,[`className`,`footnotes`]],source:[`srcSet`],summary:[...fY],table:[...fY],ul:[...fY,[`className`,`contains-task-list`]],"*":`abbr.accept.acceptCharset.accessKey.action.align.alt.axis.border.cellPadding.cellSpacing.char.charOff.charSet.checked.clear.colSpan.color.cols.compact.coords.dateTime.dir.encType.frame.hSpace.headers.height.hrefLang.htmlFor.id.isMap.itemProp.label.lang.maxLength.media.method.multiple.name.noHref.noShade.noWrap.open.prompt.readOnly.rev.rowSpan.rows.rules.scope.selected.shape.size.span.start.summary.tabIndex.title.useMap.vAlign.value.width`.split(`.`)},clobber:[`ariaDescribedBy`,`ariaLabelledBy`,`id`,`name`],clobberPrefix:`user-content-`,protocols:{cite:[`http`,`https`],href:[`http`,`https`,`irc`,`ircs`,`mailto`,`xmpp`],longDesc:[`http`,`https`],src:[`http`,`https`]},required:{input:{disabled:!0,type:`checkbox`}},strip:[`script`],tagNames:`a.b.blockquote.br.code.dd.del.details.div.dl.dt.em.h1.h2.h3.h4.h5.h6.hr.i.img.input.ins.kbd.li.ol.p.picture.pre.q.rp.rt.ruby.s.samp.section.source.span.strike.strong.sub.summary.sup.table.tbody.td.tfoot.th.thead.tr.tt.ul.var`.split(`.`)};function M9e(e){let t=e,n,r,i=t.match(/:(\d+)$/);if(!i?.[1])return{path:t,line:void 0,column:void 0};n=i[1],t=t.slice(0,-i[0].length);let a=t.match(/:(\d+)$/);return a?.[1]?(r=a[1],t=t.slice(0,-a[0].length)):(r=n,n=void 0),{path:t,line:r,column:n}}function mY(e){return e.replace(/\\/g,`/`)}function hY(e){return/^\/[A-Za-z]:\//.test(e)?e.slice(1):e}function N9e(e){return e.replace(/[\\/]+$/,``)}function P9e(e){let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`));return t>=0?e.slice(t+1):e}function F9e(e){return e.replace(/^\.\/+/u,``).replace(/^\/+/u,``)}function I9e(e,t){let{path:n,line:r,column:i}=M9e(e),a=hY(mY(n)),o=a;if(t){let e=hY(mY(N9e(t))),n=P9e(e),r=a.toLowerCase(),i=e.toLowerCase(),s=`${i}/`,c=`${n.toLowerCase()}/`;if(r===i)o=n;else if(r.startsWith(s))o=`${n}/${a.slice(e.length+1)}`;else if(!a.startsWith(`/`)){let e=F9e(a);o=r.startsWith(c)?a:`${n}/${e}`}}return r?`${o}:${r}${i?`:${i}`:``}`:o}var gY=/^[A-Za-z]:[\\/]/,_Y=/^\\\\/,L9e=/^([A-Za-z][A-Za-z0-9+.-]*):(.*)$/,vY=/^(~\/|\.{1,2}\/)/,R9e=/^[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)+(?::\d+){0,2}$/,z9e=/^[A-Za-z0-9._-]+\.[A-Za-z0-9_-]+(?::\d+){0,2}$/,yY=/:\d+(?::\d+)?$/,B9e=/^\d+(?::\d+)?$/,V9e=[`/Users/`,`/home/`,`/tmp/`,`/var/`,`/etc/`,`/opt/`,`/mnt/`,`/Volumes/`,`/private/`,`/root/`],bY=/(^|[\s([{"'`])((?:\/(?:Users|home|tmp|var|etc|opt|mnt|Volumes|private|root)\/[A-Za-z0-9._~+@%/=-]+|(?:~\/|\.{1,2}\/)?[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)+|[A-Za-z0-9._-]+\.[A-Za-z0-9_-]+)(?::\d+(?::\d+)?)?)/g;function xY(e){try{return decodeURIComponent(e)}catch{return e}}function H9e(e){return e.startsWith(`<`)&&e.endsWith(`>`)?e.slice(1,-1):e}function U9e(e){return H9e(e.trim())}function W9e(e){let t=e.indexOf(`#`),n=t>=0?e.slice(0,t):e,r=t>=0?e.slice(t):``,i=n.indexOf(`?`);return{path:i>=0?n.slice(0,i):n,hash:r}}function SY(e){return/^\/[A-Za-z]:[\\/]/.test(e)?e.slice(1):e}function G9e(e,t){try{let n=new URL(e);if(n.protocol.toLowerCase()!==`file:`)return null;let r=n.pathname;if(r.length===0)return null;let i=SY(r);return{path:t?.decodePath===!1?i:xY(i),hash:n.hash}}catch{return null}}function K9e(e){if(!e.startsWith(`/`))return!1;if(V9e.some(t=>e.startsWith(t))||yY.test(e))return!0;let t=e.slice(e.lastIndexOf(`/`)+1);return/\.[A-Za-z0-9_-]+$/.test(t)}function q9e(e,t){if(!t||yY.test(e))return e;let n=t.match(/^#L(\d+)(?:C(\d+))?$/i);if(!n?.[1])return e;let r=n[1],i=n[2];return`${e}:${r}${i?`:${i}`:``}`}function J9e(e){return gY.test(e)||_Y.test(e)||vY.test(e)?!0:e.startsWith(`/`)?K9e(e):R9e.test(e)||z9e.test(e)}function Y9e(e){return vY.test(e)||!e.startsWith(`/`)&&!gY.test(e)&&!_Y.test(e)}function X9e(e){let t=e.match(L9e);if(!t)return!1;let n=t[2]??``;return n.startsWith(`//`)?!0:!B9e.test(n)}function CY(e){return/^[A-Za-z]:[\\/]/.test(e)||e.startsWith(`\\\\`)}function Z9e(e){return e.startsWith(`/`)||CY(e)}function wY(e){return CY(e)||/[A-Za-z]:\\/.test(e)}function TY(e,t,n){let r=e.replace(/[\\/]+$/,``);return n===`\\`?`${r}\\${t.replace(/\//g,`\\`)}`:`${r}/${t.replace(/^\/+/,``)}`}function Q9e(e){let t=e.match(/^\/Users\/([^/]+)/);if(t?.[1])return`/Users/${t[1]}`;let n=e.match(/^\/home\/([^/]+)/);if(n?.[1])return`/home/${n[1]}`;let r=e.match(/^([A-Za-z]:\\Users\\[^\\]+)/);if(r?.[1])return r[1]}function EY(e){let t=e,n,r,i=t.match(/:(\d+)$/);if(!i?.[1])return{path:t,line:void 0,column:void 0};n=i[1],t=t.slice(0,-i[0].length);let a=t.match(/:(\d+)$/);return a?.[1]?(r=a[1],t=t.slice(0,-a[0].length)):(r=n,n=void 0),{path:t,line:r,column:n}}function $9e(e,t){let{path:n,line:r,column:i}=EY(e),a=n;if(n.startsWith(`~/`)){let e=Q9e(t);if(e){let t=wY(e)?`\\`:`/`;a=TY(e,n.slice(2),t)}}else Z9e(n)||(a=TY(t,n,wY(t)?`\\`:`/`));return r?`${a}:${r}${i?`:${i}`:``}`:a}function DY(e){if(!e)return null;let t=U9e(e);if(t.length===0||t.startsWith(`#`))return null;let n=t.toLowerCase().startsWith(`file:`)?G9e(t):null,r=n??W9e(t),i=SY(n?r.path.trim():xY(r.path.trim())),a=xY(r.hash.trim());return i.length===0||!gY.test(i)&&!_Y.test(i)&&X9e(i)||!J9e(i)?null:q9e(i,a)}function eet(e){return DY(e)!==null}function tet(e,t){let n=DY(e);return!n||!t?null:Y9e(n)?$9e(n,t):n}function net(e){let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`));return t>=0?e.slice(t+1):e}function ret(e,t){if(!t||e.length===0)return[{text:e}];let n=[],r=0;bY.lastIndex=0;for(let i of e.matchAll(bY)){let a=i[1]??``,o=i[2];if(!o)continue;let s=i.index+a.length,c=s+o.length;s<r||!OY(o,t)||(s>r&&n.push({text:e.slice(r,s)}),n.push({text:o,href:o}),r=c)}return r===0?[{text:e}]:(r<e.length&&n.push({text:e.slice(r)}),n)}function OY(e,t){let n=tet(e,t);if(!n)return null;let{path:r,line:i,column:a}=EY(n),o=i?Number.parseInt(i,10):NaN,s=a?Number.parseInt(a,10):NaN,c=Number.isFinite(o)?o:void 0,l=Number.isFinite(s)?s:void 0;return{filePath:r,targetPath:n,displayPath:I9e(n,t),basename:net(r),...c===void 0?{}:{line:c},...l===void 0?{}:{column:l}}}var kY=null;function iet(e,t,n){let r=e.getBoundingClientRect(),i=Math.min(Math.max(4,t),Math.max(4,window.innerWidth-r.width-4)),a=Math.min(Math.max(4,n),Math.max(4,window.innerHeight-r.height-4));e.style.left=`${i}px`,e.style.top=`${a}px`}function aet({items:e,x:t,y:n}){kY?.();let r=document.createElement(`div`);r.style.cssText=`position:fixed;inset:0;z-index:9999`,r.dataset.testid=`context-menu-overlay`;let i=document.createElement(`div`);i.className=`fixed z-[10000] min-w-[160px] rounded-md border border-border bg-popover py-1 shadow-xl animate-in fade-in zoom-in-95`,i.style.left=`${t}px`,i.style.top=`${n}px`,i.setAttribute(`role`,`menu`);let a=()=>{document.removeEventListener(`keydown`,o),document.removeEventListener(`mousedown`,s),r.remove(),i.remove(),kY===a&&(kY=null)},o=e=>{e.key===`Escape`&&(e.preventDefault(),a())},s=e=>{i.contains(e.target)||a()};for(let t of e){let e=document.createElement(`button`);e.type=`button`,e.textContent=t.label,e.disabled=t.disabled===!0,e.setAttribute(`role`,`menuitem`),e.className=t.disabled===!0?`flex w-full items-center gap-2 px-3 py-1.5 text-left text-[11px] text-muted-foreground/60 cursor-not-allowed`:t.destructive===!0?`flex w-full items-center gap-2 px-3 py-1.5 text-left text-[11px] text-destructive hover:bg-accent cursor-default`:`flex w-full items-center gap-2 px-3 py-1.5 text-left text-[11px] text-popover-foreground hover:bg-accent cursor-default`,t.disabled!==!0&&e.addEventListener(`click`,()=>{a(),t.onClick()}),i.appendChild(e)}kY=a,document.body.appendChild(r),document.body.appendChild(i),document.addEventListener(`keydown`,o),document.addEventListener(`mousedown`,s),(window.requestAnimationFrame??(e=>window.setTimeout(e,0)))(()=>iet(i,t,n))}var AY=8,oet=240;function jY(e,t,{estimatedWidth:n=280,preferredHeight:r=400}={}){let[i,a]=(0,R.useState)({openUp:!1,align:`left`,maxHeight:r});return(0,R.useLayoutEffect)(()=>{if(!e||!t.current)return;let i=t.current.getBoundingClientRect(),o=window.innerHeight-i.bottom-AY,s=i.top-AY,c=o<Math.min(r,oet)&&s>o;a({openUp:c,align:i.left+n>window.innerWidth-AY?`right`:`left`,maxHeight:Math.max(120,Math.min(r,c?s:o))})},[e,t,n,r]),i}var set=`size-3.5 shrink-0 text-muted-foreground`,cet=12,uet=new Set([`c`,`cc`,`cpp`,`cs`,`css`,`go`,`html`,`java`,`js`,`jsx`,`kt`,`mjs`,`php`,`py`,`rb`,`rs`,`scss`,`sh`,`sql`,`swift`,`ts`,`tsx`,`vue`]),det=new Set([`log`,`md`,`mdx`,`txt`]),fet=new Set([`avif`,`gif`,`jpeg`,`jpg`,`png`,`svg`,`webp`]),pet=new Set([`7z`,`gz`,`rar`,`tar`,`tgz`,`zip`]),met=new Set([`env`,`toml`,`yaml`,`yml`]),MY=null;function het(e){let t=e.replace(/\\/g,`/`).split(`/`).at(-1)??``,n=t.lastIndexOf(`.`);return n>0?t.slice(n+1).toLowerCase():``}function get(e){let t=het(e);return t===`json`?uee:uet.has(t)?see:det.has(t)?Mn:fet.has(t)?lee:pet.has(t)?oee:met.has(t)?cee:pee}function _et({displayPath:e,line:t,column:n}){let r=t?e.replace(/:\d+(?::\d+)?$/,``):e,i=t?`L${t}${n?`:C${n}`:``}`:null;return i?`${r} · ${i}`:r}async function vet(){let e=(await hj().request(e=>e[Pp.getAvailableEditors]())).editors,t=Mj(),n=t&&e.includes(t)?t:Mp.find(t=>e.includes(t.id))?.id;if(!n)throw Error(`No available editors found.`);return Nj(n),n}function yet(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`)}async function bet(e,t){try{return MY||=L(()=>Promise.resolve().then(()=>qht).then(e=>e.getSharedHighlighter({themes:[`github-dark`],langs:[]})),void 0),(await MY).codeToHtml(e,{lang:t||`text`,theme:`github-light`})}catch{return`<pre><code>${yet(e)}</code></pre>`}}function xet(e){let t=e.replace(/:\d+(?::\d+)?$/,``).replace(/\\/g,`/`),n=t.split(`/`).filter(Boolean);return n.length>1?n.slice(1).join(`/`):t}function Cet(e){return e.replace(/\\/g,`/`).match(/\/workspaces\/feature-([a-z]+-\d+)(?:\/|:|$)/i)?.[1]?.toUpperCase()}var wet=(0,R.memo)(function({filePath:e,targetPath:t,displayPath:n,basename:r,line:i,column:a,className:o,issueId:s}){let c=get(e),l=_et({filePath:e,targetPath:t,displayPath:n,basename:r,line:i,column:a}),u=(0,R.useRef)(null),d=(0,R.useRef)(0),f=(0,R.useRef)(!1),[p,m]=(0,R.useState)(!1),[h,g]=(0,R.useState)({status:`loading`}),{openUp:_,align:v,maxHeight:y}=jY(p,u,{estimatedWidth:520,preferredHeight:360}),b=s??Cet(t),x=(0,R.useMemo)(()=>xet(n),[n]),S=(0,R.useCallback)(()=>{vet().then(e=>hj().request(n=>n[Pp.shellOpenInEditor]({cwd:t,editor:e}))).then(()=>{H.success(`Opened in editor`)}).catch(e=>{H.error(`Failed to open file: ${e instanceof Error?e.message:String(e)}`)})},[t]),C=(0,R.useCallback)(()=>{d.current++,m(!1)},[]),w=(0,R.useCallback)(()=>{let e=b;if(!e){let e=`No issue context available for Quickview`;g({status:`error`,message:e}),m(!0),H.error(e);return}let t=++d.current;g({status:`loading`}),m(!0),hj().request(t=>t[Pp.readWorkspaceFile]({issueId:e,relativePath:x,...i?{line:i}:{},contextLines:cet})).then(e=>bet(e.text,e.lang).then(t=>({html:t,result:e}))).then(({html:e,result:n})=>{t===d.current&&g({status:`ready`,html:e,truncated:n.truncated,totalLines:n.totalLines})}).catch(e=>{if(t!==d.current)return;let n=e instanceof Error?e.message:String(e);g({status:`error`,message:n}),H.error(`Failed to load Quickview: ${n}`)})},[i,b,x]),T=(0,R.useCallback)((e,t)=>{navigator.clipboard.writeText(e).then(()=>{H.success(`Copied ${t}`)}).catch(e=>{H.error(`Failed to copy ${t}: ${e instanceof Error?e.message:String(e)}`)})},[]);return(0,R.useEffect)(()=>{let e=e=>{e.key===`Shift`&&f.current&&!p&&w()},t=e=>{e.key===`Shift`&&C()};return window.addEventListener(`keydown`,e),window.addEventListener(`keyup`,t),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`keyup`,t)}},[C,w,p]),(0,z.jsxs)(`span`,{ref:u,className:`relative inline-flex max-w-full align-baseline`,"data-testid":`markdown-file-link-container`,onMouseEnter:e=>{f.current=!0,e.shiftKey&&w()},onMouseLeave:()=>{f.current=!1,C()},children:[(0,z.jsxs)(`a`,{href:t,title:t,className:vj(`chat-markdown-file-link relative top-[2px] inline-flex max-w-full items-center gap-1.5 rounded-md border border-border bg-card px-2 py-0.5 font-mono text-[11px] leading-5 text-foreground no-underline transition-colors hover:border-primary/50 hover:bg-accent`,o),onClick:e=>{e.preventDefault(),e.stopPropagation(),S()},onContextMenu:e=>{e.preventDefault(),e.stopPropagation(),aet({x:e.clientX,y:e.clientY,items:[{label:`Open in editor`,onClick:S},{label:`Copy relative path`,onClick:()=>T(n,`relative path`)},{label:`Copy full path`,onClick:()=>T(t,`full path`)}]})},children:[(0,z.jsx)(c,{className:set,"aria-hidden":`true`,"data-testid":`markdown-file-link-icon`}),(0,z.jsx)(`span`,{className:`truncate`,"data-testid":`markdown-file-link-label`,children:l})]}),p&&(0,z.jsxs)(`div`,{"data-testid":`markdown-file-quickview`,className:`absolute z-50 w-[min(520px,calc(100vw-16px))] overflow-hidden rounded-lg border border-border bg-popover text-popover-foreground shadow-xl`,style:{maxHeight:`${y}px`,..._?{bottom:`100%`,marginBottom:6}:{top:`100%`,marginTop:6},...v===`right`?{right:0}:{left:0}},children:[h.status===`loading`&&(0,z.jsxs)(`div`,{className:`flex items-center gap-2 p-3 text-xs text-muted-foreground`,"data-testid":`markdown-file-quickview-loading`,children:[(0,z.jsx)(ar,{size:13,className:`animate-spin`,"aria-hidden":`true`}),`Loading preview…`]}),h.status===`error`&&(0,z.jsx)(`div`,{className:`p-3 text-xs text-destructive`,"data-testid":`markdown-file-quickview-error`,children:h.message}),h.status===`ready`&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{"data-testid":`markdown-file-quickview-content`,className:`max-h-[300px] overflow-auto text-xs [&_pre]:m-0 [&_pre]:p-3 [&_pre]:text-xs`,dangerouslySetInnerHTML:{__html:h.html}}),(0,z.jsxs)(`div`,{className:`flex items-center justify-between border-t border-border px-3 py-1.5 text-[10px] text-muted-foreground`,children:[(0,z.jsxs)(`span`,{children:[i?`line ${i}`:`top of file`,` · `,h.totalLines,` lines`]}),h.truncated&&(0,z.jsx)(`span`,{"data-testid":`markdown-file-quickview-truncated`,children:`truncated — first 256 KiB`})]})]})]})]})}),Tet=300*1e3,Eet=30*1e3,Det=5e3,NY=new Map;function PY(e,t){return`${e}\0${t}`}function FY(e,t){let n=PY(e,t),r=NY.get(n);return r?r.expiresAt<Date.now()?(NY.delete(n),null):(NY.delete(n),NY.set(n,r),{exists:r.exists,kind:r.kind}):null}function Oet(e,t,n,r){if(NY.size>=Det){let e=NY.keys().next().value;e!==void 0&&NY.delete(e)}let i=n?Tet:Eet;NY.set(PY(e,t),{exists:n,kind:r,expiresAt:Date.now()+i})}var IY=new Map;function ket(e,t){return`${e}\0${t}`}function Aet(e,t){if(!e||!t)return{state:`missing`};let n=FY(e,t);return n?n.exists?{state:`exists`,kind:n.kind}:{state:`missing`}:{state:`loading`}}function jet(e,t){let[n,r]=(0,R.useState)(()=>Aet(e,t));return(0,R.useEffect)(()=>{if(!e||!t){r({state:`missing`});return}let n=FY(e,t);if(n){r(n.exists?{state:`exists`,kind:n.kind}:{state:`missing`});return}r({state:`loading`});let i=!1,a=ket(e,t),o=IY.get(a);return o||(o=hj().request(n=>n[Pp.resolveFilePathExists]({cwd:e,path:t})).then(e=>({exists:e.exists,kind:e.kind})).catch(()=>({exists:!1,kind:null})),IY.set(a,o),o.finally(()=>{IY.get(a)===o&&IY.delete(a)})),o.then(n=>{Oet(e,t,n.exists,n.kind),!i&&r(n.exists?{state:`exists`,kind:n.kind}:{state:`missing`})}),()=>{i=!0}},[e,t]),n}var LY=new class{maxEntries;maxMemoryBytes;cache=new Map;totalSize=0;constructor(e,t){this.maxEntries=e,this.maxMemoryBytes=t}get(e){let t=this.cache.get(e);return t?(this.promote(e,t),t.value):null}set(e,t,n){let r=this.cache.get(e);r&&(this.totalSize-=r.approximateSize,this.cache.delete(e)),this.evictIfNeeded(n),this.cache.set(e,{value:t,approximateSize:n}),this.totalSize+=n}clear(){this.cache.clear(),this.totalSize=0}promote(e,t){this.cache.delete(e),this.cache.set(e,t)}evictIfNeeded(e){for(;(this.cache.size>=this.maxEntries||this.totalSize+e>this.maxMemoryBytes)&&this.cache.size>0;){let e=this.cache.keys().next().value;if(e===void 0)break;let t=this.cache.get(e);t&&(this.totalSize-=t.approximateSize),this.cache.delete(e)}}}(500,50*1024*1024);function Met(e,t){return Math.max(e.length*2,t.length*3)}function Net(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=t*16777619>>>0;return t}function Pet(e,t){return`${Net(e)}:${e.length}:${t}`}var Fet=new Set([`span`,`pre`,`code`,`div`,`br`]),Iet=new Set([`class`,`style`]),Let=new Set([`color`,`background-color`,`font-style`,`font-weight`,`text-decoration`,`opacity`]);function Ret(e){return e.split(`;`).map(e=>e.trim()).filter(Boolean).filter(e=>{let[t]=e.split(`:`);return t&&Let.has(t.trim().toLowerCase())}).join(`; `)}var RY=null;function zet(){return RY||=new DOMParser,RY}function Bet(e){let t=zet().parseFromString(e,`text/html`);function n(e){if(e.nodeType===Node.TEXT_NODE)return document.createTextNode(e.textContent||``);if(e.nodeType!==Node.ELEMENT_NODE)return null;let t=e,r=t.tagName.toLowerCase();if(!Fet.has(r))return null;let i=document.createElement(r);for(let e of Array.from(t.attributes))if(Iet.has(e.name.toLowerCase()))if(e.name===`style`){let t=Ret(e.value);t&&i.setAttribute(`style`,t)}else i.setAttribute(e.name,e.value);for(let e of Array.from(t.childNodes)){let t=n(e);t&&i.appendChild(t)}return i}let r=document.createDocumentFragment();for(let e of Array.from(t.body.childNodes)){let t=n(e);t&&r.appendChild(t)}let i=document.createElement(`div`);return i.appendChild(r),i.innerHTML}var zY=null;async function Vet(){return zY||=L(()=>Promise.resolve().then(()=>qht).then(e=>e.getSharedHighlighter({themes:[`github-dark`],langs:[]})),void 0),zY}async function Het(e,t,n){let r=Pet(e,t);if(!n){let e=LY.get(r);if(e!==null)return e}try{let i=(await Vet()).codeToHtml(e,{lang:t||`text`,theme:`github-light`});return n||LY.set(r,i,Met(i,e)),i}catch{return`<pre><code>${e.replace(/</g,`<`).replace(/>/g,`>`)}</code></pre>`}}var BY=class extends R.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?this.props.fallback:this.props.children}};function Uet({code:e,lang:t,isStreaming:n}){let[r,i]=(0,R.useState)(null),[a,o]=(0,R.useState)(!1),s=(0,R.useRef)(!1);(0,R.useEffect)(()=>(s.current=!1,Het(e,t,n).then(e=>{s.current||i(e)}),()=>{s.current=!0}),[e,t,n]);let c=(0,R.useMemo)(()=>r?Bet(r):null,[r]),l=(0,R.useCallback)(()=>{navigator.clipboard.writeText(e).then(()=>{o(!0),setTimeout(()=>o(!1),2e3)})},[e]);return(0,z.jsxs)(`div`,{className:J.codeBlock,children:[(0,z.jsx)(`button`,{className:J.copyButton,onClick:l,title:`Copy code`,children:a?(0,z.jsx)($t,{size:13}):(0,z.jsx)(xn,{size:13})}),c?(0,z.jsx)(`div`,{className:J.shikiOutput,dangerouslySetInnerHTML:{__html:c}}):(0,z.jsx)(`pre`,{className:J.codePlain,children:(0,z.jsx)(`code`,{children:e})})]})}function VY(e){return eet(e)?e:uO(e)}async function Wet(){let e=await fetch(`/api/settings`);if(!e.ok)throw Error(`settings fetch failed`);return e.json()}var HY=(0,R.createContext)(!1);function Get({children:e}){let{data:t}=B({queryKey:[`settings`],queryFn:Wet,retry:!1});return(0,z.jsx)(HY.Provider,{value:t?.experimental?.streamdownRenderer===!0,children:e})}var Ket=new Set([`code`,`inlineCode`,`link`,`linkReference`,`definition`]),qet={...pY,protocols:{...pY.protocols,href:void 0}},Jet=R.lazy(async()=>{let[{Streamdown:e,defaultRehypePlugins:t}]=await Promise.all([L(()=>import(`./dist--I-KHxVY.js`),__vite__mapDeps([0,1,2,3,4,5,6])),L(()=>Promise.resolve({}),__vite__mapDeps([7]))]),n=[t.raw,[t.sanitize[0],qet],t.harden];return{default:t=>R.createElement(e,{...t,rehypePlugins:n})}});function Yet({meta:e,cwd:t,issueId:n,fallback:r}){let{state:i}=jet(t,e.filePath);return i===`exists`?(0,z.jsx)(wet,{...e,issueId:n}):(0,z.jsx)(z.Fragment,{children:r})}function Xet(e={}){return t=>{let n=t=>{if(!t.children||Ket.has(t.type))return;let r=[];for(let i of t.children)if(i.type===`text`&&i.value!==void 0)for(let t of ret(i.value,e.cwd))r.push(t.href?{type:`link`,url:t.href,title:null,children:[{type:`text`,value:t.text}]}:{type:`text`,value:t.text});else n(i),r.push(i);t.children=r};n(t)}}function Zet(e,t,n){return{pre({children:t}){let n=R.Children.toArray(t)[0];if(!R.isValidElement(n))return(0,z.jsx)(`pre`,{children:t});let r=n,i=r.props.className??``,a=/language-(\w+)/.exec(i)?.[1]??``,o=String(r.props.children??``).trimEnd();return(0,z.jsx)(BY,{fallback:(0,z.jsx)(`pre`,{className:J.codePlain,children:(0,z.jsx)(`code`,{children:o})}),children:(0,z.jsx)(Uet,{code:o,lang:a,isStreaming:e})})},a({href:e,children:r}){let i=OY(e,t);return i?(0,z.jsx)(Yet,{meta:i,cwd:t,issueId:n,fallback:r}):(0,z.jsx)(`a`,{href:typeof e==`string`&&e.trim().length>0&&!/^(javascript|data|vbscript):/i.test(e.trim())?e:void 0,target:`_blank`,rel:`noopener noreferrer`,className:J.mdLink,children:r})}}}var Qet=5e4,UY=8e3;function $et({text:e}){let[t,n]=(0,R.useState)(!1),r=Math.round(e.length/1024),i=e.length>UY,a=t||!i?e:e.slice(0,UY);return(0,z.jsxs)(`div`,{className:J.chatMarkdown,children:[(0,z.jsxs)(`div`,{style:{fontSize:`0.8em`,opacity:.6,marginBottom:6},children:[`Large message (`,r,` KB) — rendered as plain text to keep the panel responsive.`]}),(0,z.jsxs)(`pre`,{className:J.mdFallback,style:{whiteSpace:`pre-wrap`,wordBreak:`break-word`},children:[a,!t&&i?`
|
|
315
315
|
…`:``]}),i&&(0,z.jsx)(`button`,{type:`button`,onClick:()=>n(e=>!e),style:{marginTop:6,fontSize:`0.8em`,background:`none`,border:`none`,color:`var(--color-accent)`,cursor:`pointer`,padding:0},children:t?`Show less`:`Show full message (${r} KB)`})]})}var WY=(0,R.memo)(function({text:e,isStreaming:t=!1,cwd:n,issueId:r,useStreamdown:i}){let a=(0,R.useMemo)(()=>Zet(t,n,r),[t,n,r]),o=(0,R.useMemo)(()=>[tk,[Xet,{cwd:n}]],[n]),s=(0,R.useContext)(HY),c=i??s;return e.length>Qet?(0,z.jsx)(BY,{fallback:(0,z.jsx)(`pre`,{className:J.mdFallback,children:e}),children:(0,z.jsx)($et,{text:e})}):(0,z.jsx)(BY,{fallback:(0,z.jsx)(`pre`,{className:J.mdFallback,children:e}),children:(0,z.jsx)(`div`,{className:J.chatMarkdown,children:c?(0,z.jsx)(R.Suspense,{fallback:(0,z.jsx)(lO,{remarkPlugins:o,components:a,urlTransform:VY,children:e}),children:(0,z.jsx)(Jet,{mode:t?`streaming`:`static`,remarkPlugins:o,components:a,urlTransform:e=>VY(e),children:e})}):(0,z.jsx)(lO,{remarkPlugins:o,components:a,urlTransform:VY,children:e})})})});function GY({body:e,isLoading:t,emptyLabel:n=`No content available.`}){return t?(0,z.jsx)(`div`,{"data-testid":`markdown-tab-loading`,style:{padding:16,fontSize:12,color:`var(--muted-foreground)`},children:`Loading…`}):!e||e.trim()===``?(0,z.jsx)(`div`,{"data-testid":`markdown-tab-empty`,style:{padding:16,fontSize:12,color:`var(--muted-foreground)`},children:n}):(0,z.jsx)(`div`,{"data-testid":`markdown-tab`,style:{padding:16,fontSize:13,lineHeight:1.55},children:(0,z.jsx)(WY,{text:e,cwd:void 0})})}var ett=[{key:`prd`,label:`PRD`,empty:`No PRD recorded for this issue.`},{key:`state`,label:`STATE`,empty:`No STATE recorded for this issue.`},{key:`inference`,label:`INFERENCE`,empty:`No INFERENCE.md recorded for this issue.`}];function ttt({pane:e,ctx:t}){let n=e.issueId??t.workspaceId,r=pBe(n),i=Sj(n),a=!!r.data?.hasInference,o=ett.filter(e=>e.key!==`inference`||a),[s,c]=(0,R.useState)(e.docFilePath&&o.some(t=>t.key===e.docFilePath)?e.docFilePath:`prd`),l=o.some(e=>e.key===s)?s:`prd`,u=o.find(e=>e.key===l);return(0,z.jsxs)(`div`,{className:Q.subPane,children:[(0,z.jsx)(`div`,{className:Q.subTabs,role:`tablist`,"aria-label":`Docs`,children:o.map(e=>(0,z.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":e.key===l,className:`${Q.subTab} ${e.key===l?Q.subTabActive:``}`,onClick:()=>c(e.key),children:e.label},e.key))}),(0,z.jsx)(`div`,{className:Q.subBody,children:(0,z.jsx)(GY,{body:i.data?.[l],isLoading:i.isLoading,emptyLabel:u.empty})})]})}var KY=`overdeck:conversation-ui:v1`;function qY(){try{let e=localStorage.getItem(KY);if(e)return{hideToolCallsById:JSON.parse(e).hideToolCallsById??{}}}catch{}return{hideToolCallsById:{}}}function ntt(e){try{let t={};for(let[n,r]of Object.entries(e.hideToolCallsById))r&&(t[n]=!0);localStorage.setItem(KY,JSON.stringify({hideToolCallsById:t}))}catch{}}function JY(e){let[t,n]=(0,R.useState)(qY);(0,R.useEffect)(()=>{n(qY())},[e]);let r=t.hideToolCallsById[e]??!1,i=(0,R.useCallback)(t=>{n(n=>{let r={hideToolCallsById:{...n.hideToolCallsById}};return t?r.hideToolCallsById[e]=!0:delete r.hideToolCallsById[e],ntt(r),r})},[e]);return{hideToolCalls:r,setHideToolCalls:i,toggleHideToolCalls:(0,R.useCallback)(()=>{i(!r)},[r,i])}}var rtt={numeric:!0,sensitivity:`base`};function itt(e){return e.replace(/\\/g,`/`).split(`/`).filter(e=>e.length>0)}function YY(e,t){return e.name.localeCompare(t.name,void 0,rtt)}function XY(e){return typeof e.additions!=`number`||typeof e.deletions!=`number`?null:{additions:e.additions,deletions:e.deletions}}function ZY(e){let t=e.children.map(e=>e.kind===`directory`?ZY(e):e),n={...e,children:t};for(;n.children.length===1&&n.children[0]?.kind===`directory`;){let e=n.children[0];n={kind:`directory`,name:`${n.name}/${e.name}`,path:e.path,stat:e.stat,children:e.children}}return n}function QY(e){let t=[...Array.from(e.directories.values())].sort(YY).map(e=>({kind:`directory`,name:e.name,path:e.path,stat:{additions:e.stat.additions,deletions:e.stat.deletions},children:QY(e)})).map(e=>ZY(e)),n=[...e.files].sort(YY);return[...t,...n]}function $Y(e){return e.reduce((e,t)=>{let n=XY(t);return n?{additions:e.additions+n.additions,deletions:e.deletions+n.deletions}:e},{additions:0,deletions:0})}function att(e){let t={name:``,path:``,stat:{additions:0,deletions:0},directories:new Map,files:[]};for(let n of e){let e=itt(n.path);if(e.length===0)continue;let r=e.join(`/`),i=e.at(-1);if(!i)continue;let a=XY(n),o=[t],s=t;for(let t of e.slice(0,-1)){let e=s.path?`${s.path}/${t}`:t,n=s.directories.get(t);if(n)s=n;else{let n={name:t,path:e,stat:{additions:0,deletions:0},directories:new Map,files:[]};s.directories.set(t,n),s=n}o.push(s)}if(s.files.push({kind:`file`,name:i,path:r,stat:a}),a)for(let e of o)e.stat.additions+=a.additions,e.stat.deletions+=a.deletions}return QY(t)}function ott(e){return e.additions>0||e.deletions>0}var eX=(0,R.memo)(function(e){let{additions:t,deletions:n,showParentheses:r=!1}=e;return(0,z.jsxs)(z.Fragment,{children:[r&&(0,z.jsx)(`span`,{className:`text-muted-foreground/70`,children:`(`}),(0,z.jsxs)(`span`,{className:`text-green-500`,children:[`+`,t]}),(0,z.jsx)(`span`,{className:`mx-0.5 text-muted-foreground/70`,children:`/`}),(0,z.jsxs)(`span`,{className:`text-red-500`,children:[`-`,n]}),r&&(0,z.jsx)(`span`,{className:`text-muted-foreground/70`,children:`)`})]})}),stt={},ctt=(0,R.memo)(function(e){let{files:t,allDirectoriesExpanded:n,onOpenTurnDiff:r,turnId:i}=e,a=(0,R.useMemo)(()=>att(t),[t]),o=(0,R.useMemo)(()=>tX(a).join(`\0`),[a]),s=`${n?`expanded`:`collapsed`}${o}`,[c,l]=(0,R.useState)(()=>({key:s,overrides:{}})),u=c.key===s?c.overrides:stt,d=(0,R.useCallback)(e=>{l(t=>{let r=t.key===s?t.overrides:{};return{key:s,overrides:{...r,[e]:!(r[e]??n)}}})},[n,s]),f=(e,t)=>{let a=8+t*14;if(e.kind===`directory`){let r=u[e.path]??n;return(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`button`,{type:`button`,className:`group flex w-full items-center gap-1.5 rounded-md py-1 pr-2 text-left hover:bg-muted/50`,style:{paddingLeft:`${a}px`},onClick:()=>d(e.path),children:[(0,z.jsx)(nn,{"aria-hidden":`true`,className:vj(`size-3.5 shrink-0 text-muted-foreground/70 transition-transform group-hover:text-foreground/80`,r&&`rotate-90`)}),r?(0,z.jsx)(Rn,{className:`size-3.5 shrink-0 text-muted-foreground/75`}):(0,z.jsx)(mee,{className:`size-3.5 shrink-0 text-muted-foreground/75`}),(0,z.jsx)(`span`,{className:`truncate font-mono text-[11px] text-muted-foreground/90 group-hover:text-foreground/90`,children:e.name}),ott(e.stat)&&(0,z.jsx)(`span`,{className:`ml-auto shrink-0 font-mono text-[10px] tabular-nums`,children:(0,z.jsx)(eX,{additions:e.stat.additions,deletions:e.stat.deletions})})]}),r&&(0,z.jsx)(`div`,{className:`space-y-0.5`,children:e.children.map(e=>f(e,t+1))})]},`dir:${e.path}`)}return(0,z.jsxs)(`button`,{type:`button`,className:`group flex w-full items-center gap-1.5 rounded-md py-1 pr-2 text-left hover:bg-muted/50`,style:{paddingLeft:`${a}px`},onClick:()=>r(i,e.path),children:[(0,z.jsx)(`span`,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,z.jsx)(jn,{className:`size-3.5 shrink-0 text-muted-foreground/70`}),(0,z.jsx)(`span`,{className:`truncate font-mono text-[11px] text-muted-foreground/80 group-hover:text-foreground/90`,children:e.name}),e.stat&&(0,z.jsx)(`span`,{className:`ml-auto shrink-0 font-mono text-[10px] tabular-nums`,children:(0,z.jsx)(eX,{additions:e.stat.additions,deletions:e.stat.deletions})})]},`file:${e.path}`)};return(0,z.jsx)(`div`,{className:`space-y-0.5`,children:a.map(e=>f(e,0))})});function tX(e){let t=[];for(let n of e)n.kind===`directory`&&(t.push(n.path),t.push(...tX(n.children)));return t}async function ltt(e,t,n){let r=await fetch(`/api/conversations/${encodeURIComponent(e)}/plan-action`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:t,feedback:n})});if(!r.ok){let e=await r.text().catch(()=>``);throw Error(`Plan action failed (${r.status})${e?`: ${e}`:``}`)}}function utt({plan:e,conversationName:t}){let[n,r]=(0,R.useState)(!1),[i,a]=(0,R.useState)(!1),[o,s]=(0,R.useState)(``),c=e.status===`pending`,[l,u]=(0,R.useState)(c),d=(0,R.useCallback)(async(e,n)=>{r(!0);try{await ltt(t,e,n)}catch(e){H.error(e instanceof Error?e.message:`Failed to send plan action`)}finally{r(!1)}},[t]),f=(0,R.useCallback)(()=>d(`approve-manual`),[d]),p=(0,R.useCallback)(()=>{if(!o.trim()){H.error(`Please enter feedback`);return}d(`reject-feedback`,o.trim()),a(!1),s(``)},[d,o]),m=e.status===`approved`?J.planCardBadgeApproved:e.status===`rejected`?J.planCardBadgeRejected:J.planCardBadge,h=e.status===`approved`?`Approved`:e.status===`rejected`?`Changes requested`:`Awaiting approval`,g=e.status===`approved`?sn:e.status===`rejected`?un:null;return(0,z.jsxs)(`div`,{className:`${J.planCard} ${c?``:J.planCardResolved}`,children:[(0,z.jsxs)(`div`,{className:J.planCardHeader,children:[(0,z.jsxs)(`button`,{type:`button`,className:J.planCardToggle,onClick:()=>u(e=>!e),children:[l?(0,z.jsx)(en,{size:14}):(0,z.jsx)(nn,{size:14}),(0,z.jsx)(`span`,{className:J.planCardTitle,children:c?`Proposed Plan`:`Plan`})]}),(0,z.jsxs)(`span`,{className:m,children:[g&&(0,z.jsx)(g,{size:12}),h]})]}),l&&(0,z.jsx)(`div`,{className:J.planCardBody,children:(0,z.jsx)(WY,{text:e.plan,cwd:void 0})}),c&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:J.planCardActions,children:[(0,z.jsxs)(`button`,{className:J.planCardApproveBtn,onClick:f,disabled:n,title:`Approve plan and begin implementation`,children:[(0,z.jsx)($t,{size:14}),`Approve`]}),(0,z.jsxs)(`button`,{className:J.planCardFeedbackBtn,onClick:()=>a(e=>!e),disabled:n,title:`Request changes to the plan`,children:[(0,z.jsx)(cr,{size:14}),`Request Changes`]})]}),i&&(0,z.jsxs)(`div`,{className:J.planCardFeedbackArea,children:[(0,z.jsx)(`textarea`,{className:J.planCardTextarea,value:o,onChange:e=>s(e.target.value),placeholder:`Describe what to change...`,rows:3,disabled:n,onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&p()}}),(0,z.jsxs)(`div`,{className:J.planCardFeedbackActions,children:[(0,z.jsx)(`button`,{className:J.planCardApproveBtn,onClick:p,disabled:n||!o.trim(),children:`Send Feedback`}),(0,z.jsx)(`button`,{className:J.planCardCancelBtn,onClick:()=>{a(!1),s(``)},disabled:n,children:`Cancel`})]})]})]})]})}function dtt(e,t){return[...e.map(e=>({id:e.id,kind:`message`,createdAt:e.createdAt,sequence:e.sequence,message:e})),...t.map(e=>({id:e.id,kind:`work`,createdAt:e.createdAt,sequence:e.sequence,entry:e}))].sort((e,t)=>e.createdAt<t.createdAt?-1:e.createdAt>t.createdAt?1:e.sequence!==void 0&&t.sequence!==void 0?e.sequence-t.sequence:0)}function ftt(e){let t=new Map,n=null;for(let r of e)r.role===`user`&&(n=r.createdAt),t.set(r.id,n??r.createdAt),r.role===`assistant`&&r.completedAt&&(n=r.completedAt);return t}function ptt(e,t){let n=[],r=0,i=ftt(e.flatMap(e=>e.kind===`message`?[e.message]:[]));for(;r<e.length;){let t=e[r];if(t.kind===`work`){let i=[t.entry],a=r+1;for(;a<e.length&&e[a].kind===`work`;)i.push(e[a].entry),a++;n.push({kind:`work`,id:t.id,createdAt:t.createdAt,groupedEntries:i}),r=a}else n.push({kind:`message`,id:t.id,createdAt:t.createdAt,message:t.message,durationStart:i.get(t.message.id)??t.message.createdAt}),r++}if(t){let t=e[e.length-1];n.push({kind:`working`,id:`working-indicator`,createdAt:t?.createdAt??null})}return n}var mtt=6;function htt(e,t={}){let{timelineWidth:n=800,hideToolCalls:r=!1}=t;if(e.kind===`working`||e.kind===`compact-boundary`||e.kind===`compacting`)return 40;if(e.kind===`proposed-plan`)return 120+Math.max(3,Math.ceil(e.plan.plan.length/60))*20;if(e.kind===`work`){let t=e.groupedEntries.every(e=>e.tone===`tool`||e.tone===`error`);return r&&t?32:28+Math.min(e.groupedEntries.length,mtt)*32}let{message:i}=e;if(i.role===`system`)return 28;if(i.role===`user`){let e=Math.max(4,Math.floor((n*.8-32)/8.4));return 96+Math.max(1,Math.ceil(i.text.length/e))*22}let a=Math.max(20,Math.floor((n-8)/7.2));return 41+Math.max(1,Math.ceil(i.text.length/a))*22.75}var nX=6,gtt=8,_tt=64;function vtt(e){if(!e)return``;try{return JSON.stringify(e)}catch{return``}}function ytt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function btt(e){let t=e.match(/[\p{L}\p{N}_-]+/gu)??[],n=new Set;for(let e of t)e.length>0&&n.add(e);return[...n].sort((e,t)=>t.length-e.length)}var xtt=`rounded-sm px-px text-inherit bg-amber-300/40 dark:bg-amber-400/20`,rX=`data-conversation-search-highlight`;function iX(e){let t=typeof CSS<`u`&&typeof CSS.escape==`function`?CSS.escape:null;return t?t(e):e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}function aX(e){let t=Array.from(e.querySelectorAll(`[${rX}]`));for(let e of t)e.replaceWith(document.createTextNode(e.textContent??``))}function Stt(e,t){if(aX(e),t.length===0)return;let n=RegExp(`(${t.map(ytt).join(`|`)})`,`gi`),r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode:e=>{if(n.lastIndex=0,!e.textContent||!n.test(e.textContent))return NodeFilter.FILTER_REJECT;n.lastIndex=0;let t=e.parentElement;return!t||t.closest(`[${rX}]`)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),i=[];for(;r.nextNode();)i.push(r.currentNode);for(let e of i){let r=(e.textContent??``).split(n);if(r.length<=1)continue;let i=document.createDocumentFragment();for(let e of r)if(e)if(t.some(t=>e.toLocaleLowerCase()===t.toLocaleLowerCase())){let t=document.createElement(`span`);t.className=xtt,t.setAttribute(rX,`true`),t.textContent=e,i.appendChild(t)}else i.appendChild(document.createTextNode(e));e.replaceWith(i)}}function Ctt(e){return e.kind===`message`?e.message.text:e.kind===`work`?e.groupedEntries.map(e=>[e.label,e.detail,e.result,e.command,e.toolTitle,e.changedFiles?.join(`
|
|
316
316
|
`),vtt(e.toolInput)].filter(Boolean).join(`
|
|
317
317
|
`)).join(`
|
|
@@ -664,8 +664,8 @@ XID_Start XIDS`.split(/\s/).map(e=>[h6(e),e])),Sft=new Map([[`s`,O6(383)],[O6(38
|
|
|
664
664
|
}
|
|
665
665
|
`;function Ngt(e,t=`diff-panel`){if(!e)return null;let n=e.trim();if(n.length===0)return null;try{let e=pht(n,wgt(n,t)).flatMap(e=>e.files);return e.length>0?{kind:`files`,files:e}:{kind:`raw`,text:n,reason:`Unsupported diff format. Showing raw patch.`}}catch{return{kind:`raw`,text:n,reason:`Failed to parse patch. Showing raw patch.`}}}function t5(e){let t=e.name??e.prevName??``;return t.startsWith(`a/`)||t.startsWith(`b/`)?t.slice(2):t}function Pgt(e){return e.cacheKey??`${e.prevName??`none`}:${e.name}`}function Fgt(e){try{return new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`})}catch{return``}}function n5(){return Q8(Object.fromEntries(new URLSearchParams(window.location.search)))}function r5(e){let t=new URLSearchParams(window.location.search);t.delete(`diff`),t.delete(`diffTurnId`),t.delete(`diffFilePath`),e.diff&&t.set(`diff`,e.diff),e.diffTurnId&&t.set(`diffTurnId`,e.diffTurnId),e.diffFilePath&&t.set(`diffFilePath`,e.diffFilePath);let n=t.toString(),r=n?`${window.location.pathname}?${n}`:window.location.pathname;window.history.pushState({},``,r)}function Igt(){let e=new URLSearchParams(window.location.search);e.delete(`diff`),e.delete(`diffTurnId`),e.delete(`diffFilePath`);let t=e.toString(),n=t?`${window.location.pathname}?${t}`:window.location.pathname;window.history.pushState({},``,n)}function i5(e){return(0,z.jsx)(`button`,{type:`button`,role:`button`,"aria-label":e.ariaLabel,title:e.title,"aria-pressed":e.pressed,className:vj(`inline-flex size-7 items-center justify-center rounded-md border text-muted-foreground transition-colors`,e.pressed?`border-border bg-accent text-accent-foreground`:`border-border/70 bg-background/70 hover:border-border hover:text-foreground/80`),onClick:()=>e.onPressedChange(!e.pressed),children:e.children})}function Lgt({files:e,onSelectFile:t,isLoading:n}){if(n)return(0,z.jsx)(jgt,{label:`Loading file list...`});if(e.length===0)return(0,z.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-5 text-center text-xs text-muted-foreground/70`,children:`No changed files in this selection.`});let r=[...e].sort((e,t)=>e.path.localeCompare(t.path,void 0,{numeric:!0,sensitivity:`base`}));return(0,z.jsxs)(`div`,{className:`flex-1 overflow-auto px-2 py-2`,children:[(0,z.jsxs)(`p`,{className:`mb-2 px-1 text-[11px] text-muted-foreground/70`,children:[e.length,` changed file`,e.length===1?``:`s`,` — select a file to view its diff`]}),(0,z.jsx)(`div`,{className:`space-y-px`,children:r.map(e=>{let n=e.path.split(`/`),r=n.pop()??e.path,i=n.join(`/`);return(0,z.jsxs)(`button`,{type:`button`,className:`group flex w-full items-center gap-2 rounded-md px-2 py-1 text-left text-[11px] transition-colors hover:bg-accent`,onClick:()=>t(e.path),children:[(0,z.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[i&&(0,z.jsxs)(`span`,{className:`text-muted-foreground/60`,children:[i,`/`]}),(0,z.jsx)(`span`,{className:`text-foreground/90`,children:r})]}),(0,z.jsxs)(`span`,{className:`shrink-0 tabular-nums`,children:[e.additions!=null&&e.additions>0&&(0,z.jsxs)(`span`,{className:`text-green-500`,children:[`+`,e.additions]}),e.deletions!=null&&e.deletions>0&&(0,z.jsxs)(`span`,{className:`ml-1 text-red-400`,children:[`-`,e.deletions]})]})]},e.path)})})]})}function Rgt({mode:e=`inline`,agentId:t,turnDiffSummaries:n,onClose:r,diffUrlPrefix:i}){let{resolvedTheme:a}=MS(),{prefs:o,update:s}=mYe(),c=o.diffRenderMode,l=o.diffWordWrap,u=(0,R.useRef)(null),d=(0,R.useRef)(null),[f,p]=(0,R.useState)(!1),[m,h]=(0,R.useState)(!1),[g,_]=(0,R.useState)(n5);(0,R.useEffect)(()=>{let e=()=>_(n5());return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[]);let v=g.diff===`1`,y=g.diffTurnId??null,b=y===null?null:g.diffFilePath??null,x=(0,R.useMemo)(()=>[...n].sort((e,t)=>{let n=e.checkpointTurnCount??0,r=t.checkpointTurnCount??0;return n===r?t.completedAt.localeCompare(e.completedAt):r-n}),[n]),S=y===`vs-main`,C=y===null||S?void 0:x.find(e=>e.turnId===y)??x[0],w=i??`/api/agents/${encodeURIComponent(t)}/diffs`,T=!b,E=T&&!!C,{data:D,isLoading:O}=B({queryKey:S?[`diff-vs-main`,t,b??null]:C?[`diff-turn`,t,C.turnId,b??null]:[`diff-full`,t,b??null],queryFn:async()=>{let e=S?`${w}/vs-main`:C?`${w}/${encodeURIComponent(C.turnId)}`:`${w}/full`;b&&(e+=`?file=${encodeURIComponent(b)}`);let t=await fetch(e);if(!t.ok)throw Error(`Failed to fetch diff`);return t.json()},enabled:v&&!E}),k=T?C?.files??D?.files:void 0,A=D?.diff,j=typeof A==`string`&&A.trim().length===0,M=(0,R.useMemo)(()=>Ngt(A,`diff-panel:${a}`),[a,A]),N=(0,R.useMemo)(()=>!M||M.kind!==`files`?[]:[...M.files].sort((e,t)=>t5(e).localeCompare(t5(t),void 0,{numeric:!0,sensitivity:`base`})),[M]);(0,R.useEffect)(()=>{!b||!u.current||Array.from(u.current.querySelectorAll(`[data-diff-file-path]`)).find(e=>e.dataset.diffFilePath===b)?.scrollIntoView({block:`nearest`})},[b,N]);let P=(0,R.useCallback)(()=>{let e=d.current;if(!e){p(!1),h(!1);return}let t=Math.max(0,e.scrollWidth-e.clientWidth);p(e.scrollLeft>4),h(e.scrollLeft<t-4)},[]),F=(0,R.useCallback)(e=>{let t=d.current;t&&t.scrollBy({left:e,behavior:`smooth`})},[]),I=(0,R.useCallback)(e=>{let t=d.current;t&&(t.scrollWidth<=t.clientWidth+1||Math.abs(e.deltaY)<=Math.abs(e.deltaX)||(e.preventDefault(),t.scrollBy({left:e.deltaY,behavior:`auto`})))},[]);(0,R.useEffect)(()=>{let e=d.current;if(!e)return;let t=window.requestAnimationFrame(()=>P()),n=()=>P();e.addEventListener(`scroll`,n,{passive:!0});let r=new ResizeObserver(()=>P());return r.observe(e),()=>{window.cancelAnimationFrame(t),e.removeEventListener(`scroll`,n),r.disconnect()}},[P]),(0,R.useEffect)(()=>{let e=window.requestAnimationFrame(()=>P());return()=>window.cancelAnimationFrame(e)},[x,y,P]),(0,R.useEffect)(()=>{let e=d.current;e&&e.querySelector(`[data-turn-chip-selected='true']`)?.scrollIntoView({block:`nearest`,inline:`nearest`,behavior:`smooth`})},[C?.turnId,y]);let ee=e=>{r5({diff:`1`,diffTurnId:e}),_(n5())},te=e=>{let t=y??void 0;r5({diff:`1`,...t&&{diffTurnId:t},diffFilePath:e}),_(n5())},ne=(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[f&&(0,z.jsx)(`div`,{className:`pointer-events-none absolute inset-y-0 left-8 z-10 w-7 bg-gradient-to-r from-card to-transparent`}),m&&(0,z.jsx)(`div`,{className:`pointer-events-none absolute inset-y-0 right-8 z-10 w-7 bg-gradient-to-l from-card to-transparent`}),(0,z.jsx)(`button`,{type:`button`,className:vj(`absolute left-0 top-1/2 z-20 inline-flex size-6 -translate-y-1/2 items-center justify-center rounded-md border bg-background/90 text-muted-foreground transition-colors`,f?`border-border/70 hover:border-border hover:text-foreground`:`cursor-not-allowed border-border/40 text-muted-foreground/40`),onClick:()=>F(-180),disabled:!f,"aria-label":`Scroll turn list left`,children:(0,z.jsx)(tn,{className:`size-3.5`})}),(0,z.jsx)(`button`,{type:`button`,className:vj(`absolute right-0 top-1/2 z-20 inline-flex size-6 -translate-y-1/2 items-center justify-center rounded-md border bg-background/90 text-muted-foreground transition-colors`,m?`border-border/70 hover:border-border hover:text-foreground`:`cursor-not-allowed border-border/40 text-muted-foreground/40`),onClick:()=>F(180),disabled:!m,"aria-label":`Scroll turn list right`,children:(0,z.jsx)(nn,{className:`size-3.5`})}),(0,z.jsxs)(`div`,{ref:d,className:`turn-chip-strip flex gap-1 overflow-x-auto px-8 py-0.5`,onWheel:I,children:[(0,z.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-md`,onClick:()=>{r5({diff:`1`}),_(n5())},"data-turn-chip-selected":y===null,children:(0,z.jsx)(`div`,{className:vj(`rounded-md border px-2 py-1 text-left transition-colors`,y===null?`border-border bg-accent text-accent-foreground`:`border-border/70 bg-background/70 text-muted-foreground/80 hover:border-border hover:text-foreground/80`),children:(0,z.jsx)(`div`,{className:`text-[10px] leading-tight font-medium`,children:`All turns`})})}),(0,z.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-md`,onClick:()=>{r5({diff:`1`,diffTurnId:`vs-main`}),_(n5())},"data-turn-chip-selected":S,children:(0,z.jsx)(`div`,{className:vj(`rounded-md border px-2 py-1 text-left transition-colors`,S?`border-border bg-accent text-accent-foreground`:`border-border/70 bg-background/70 text-muted-foreground/80 hover:border-border hover:text-foreground/80`),children:(0,z.jsx)(`div`,{className:`text-[10px] leading-tight font-medium`,children:`vs main`})})}),x.map((e,t)=>(0,z.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-md`,onClick:()=>ee(e.turnId),title:e.turnId,"data-turn-chip-selected":e.turnId===C?.turnId,children:(0,z.jsx)(`div`,{className:vj(`rounded-md border px-2 py-1 text-left transition-colors`,e.turnId===C?.turnId?`border-border bg-accent text-accent-foreground`:`border-border/70 bg-background/70 text-muted-foreground/80 hover:border-border hover:text-foreground/80`),children:(0,z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,z.jsxs)(`span`,{className:`text-[10px] leading-tight font-medium`,children:[`Turn `,e.checkpointTurnCount??x.length-t]}),(0,z.jsx)(`span`,{className:`text-[9px] leading-tight opacity-70`,children:Fgt(e.completedAt)})]})})},e.turnId))]})]}),(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,z.jsx)(i5,{pressed:c===`stacked`,onPressedChange:()=>s({diffRenderMode:`stacked`}),ariaLabel:`Stacked diff view`,children:(0,z.jsx)(Nee,{className:`size-3`})}),(0,z.jsx)(i5,{pressed:c===`split`,onPressedChange:()=>s({diffRenderMode:`split`}),ariaLabel:`Split diff view`,children:(0,z.jsx)(vn,{className:`size-3`})}),(0,z.jsx)(i5,{pressed:l,onPressedChange:e=>s({diffWordWrap:e}),ariaLabel:l?`Disable diff line wrapping`:`Enable diff line wrapping`,title:l?`Disable line wrapping`:`Enable line wrapping`,children:(0,z.jsx)(tte,{className:`size-3`})}),e===`inline`&&(0,z.jsx)(`button`,{type:`button`,className:`inline-flex size-7 items-center justify-center rounded-md border border-border/70 bg-background/70 text-muted-foreground transition-colors hover:border-border hover:text-foreground/80`,onClick:()=>{let e=new URLSearchParams;e.set(`diff`,`1`),e.set(`prefix`,w),e.set(`agentId`,t),y&&e.set(`diffTurnId`,y),b&&e.set(`diffFilePath`,b),window.open(`/popout/diff?${e.toString()}`,`_blank`,`width=1000,height=800`)},"aria-label":`Open diff in new window`,title:`Pop out`,children:(0,z.jsx)(kn,{className:`size-3`})}),r&&(0,z.jsx)(`button`,{type:`button`,className:`inline-flex size-7 items-center justify-center rounded-md border border-border/70 bg-background/70 text-muted-foreground transition-colors hover:border-border hover:text-foreground/80`,onClick:()=>{Igt(),_(n5()),r?.()},"aria-label":`Close diff panel`,children:(0,z.jsx)(zr,{className:`size-3`})})]})]});return v?(0,z.jsx)(Agt,{mode:e,header:ne,children:x.length===0?(0,z.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-5 text-center text-xs text-muted-foreground/70`,children:`No completed turns yet.`}):T?(0,z.jsx)(Lgt,{files:k??[],onSelectFile:te,isLoading:O&&!k}):(0,z.jsx)(`div`,{ref:u,className:`diff-panel-viewport min-h-0 min-w-0 flex-1 overflow-hidden`,children:M?M.kind===`files`?(0,z.jsx)($ht,{className:`diff-render-surface h-full min-h-0 overflow-auto px-2 pb-2`,config:{overscrollSize:600,intersectionObserverMargin:1200},children:N.map(e=>{let t=t5(e),n=`${Pgt(e)}:${a}`;return(0,z.jsx)(`div`,{"data-diff-file-path":t,className:`diff-render-file mb-2 rounded-md first:mt-2 last:mb-0`,children:(0,z.jsx)(mgt,{fileDiff:e,options:{diffStyle:o.diffRenderMode===`split`?`split`:`unified`,lineDiffType:o.lineDiffType,overflow:o.diffWordWrap?`wrap`:`scroll`,diffIndicators:o.diffIndicators,hunkSeparators:o.hunkSeparators,expandUnchanged:o.expandUnchanged,collapsedContextThreshold:o.collapsedContextThreshold,lineHoverHighlight:o.lineHoverHighlight,disableLineNumbers:o.disableLineNumbers,enableLineSelection:o.enableLineSelection,theme:vgt(a),themeType:a,unsafeCSS:Mgt}})},n)})}):(0,z.jsx)(`div`,{className:`h-full overflow-auto p-2`,children:(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(`p`,{className:`text-[11px] text-muted-foreground/75`,children:M.reason}),(0,z.jsx)(`pre`,{className:vj(`max-h-[72vh] rounded-md border border-border/70 bg-background/70 p-3 font-mono text-[11px] leading-relaxed text-muted-foreground/90`,l?`overflow-auto whitespace-pre-wrap break-words`:`overflow-auto`),children:M.text})]})}):O?(0,z.jsx)(jgt,{label:`Loading checkpoint diff...`}):(0,z.jsx)(`div`,{className:`flex h-full items-center justify-center px-3 py-2 text-xs text-muted-foreground/70`,children:(0,z.jsx)(`p`,{children:j?`No net changes in this selection.`:`No patch available for this selection.`})})})}):null}function zgt(e){return new Worker(`/assets/worker-C-69Fj6S.js`,{name:e?.name})}function Bgt({themeName:e}){let t=cgt(),n=(0,R.useRef)(!1);return(0,R.useEffect)(()=>{if(!t)return;let r=t.getDiffRenderOptions();n.current&&r.theme===e||(n.current=!0,t.setRenderOptions({...r,theme:e}).catch(()=>void 0))},[e,t]),null}function Vgt({children:e}){let{resolvedTheme:t}=MS(),n=vgt(t);return(0,z.jsxs)(sgt,{poolOptions:{workerFactory:()=>new zgt,poolSize:(0,R.useMemo)(()=>{let e=typeof navigator>`u`?4:Math.max(1,navigator.hardwareConcurrency||4);return Math.max(2,Math.min(6,Math.floor(e/2)))},[]),totalASTLRUCacheSize:240},highlighterOptions:{theme:n,tokenizeMaxLineLength:1e3},children:[(0,z.jsx)(Bgt,{themeName:n}),e]})}var a5=e=>[`conversation-messages`,e];function Hgt(e,t){let n=e;for(let e of t){if(typeof e.sequence!=`number`||e.sequence<=n)return!1;n=e.sequence}return!0}function o5(e,t){if(t.length===0)return e;if(e.length===0)return t;let n=e[e.length-1],r=t[0];if(r.id===n.id){let n=[...e.slice(0,-1),r],i=t.slice(1);if(i.length===0)return n;if(typeof r.sequence==`number`&&Hgt(r.sequence,i))return[...n,...i]}else if(typeof n.sequence==`number`&&Hgt(n.sequence,t))return[...e,...t];let i=new Set(e.map(e=>e.id));if(t.every(e=>!i.has(e.id)))return[...e,...t];let a=new Map;for(let t of e)a.set(t.id,t);for(let e of t)a.set(e.id,e);return Array.from(a.values())}function Ugt(e,t){if(t.kind===`discovering`)return e?.discovering?e:{messages:e?.messages??[],workLog:e?.workLog??[],streaming:e?.streaming??!0,...e,discovering:!0};let n=t.snapshot!==!1,r=n&&t.messages.length<(e?.messages.length??0),i=n&&!r;return{...e,messages:i?t.messages:o5(e?.messages??[],t.messages),workLog:i?t.workLog:o5(e?.workLog??[],t.workLog),streaming:t.streaming,proposedPlan:t.proposedPlan??e?.proposedPlan,compactBoundaries:i?t.compactBoundaries:o5(e?.compactBoundaries??[],t.compactBoundaries??[]),contextUsage:`contextUsage`in t?t.contextUsage:e?.contextUsage,discovering:!1}}function Wgt(e){if(e.id!==void 0&&e.id>=0)return e.endedAt?!1:e.harness===`claude-code`||e.harness===`ohmypi`||e.harness===`codex`||e.harness==null;if(!e.sessionAlive)return!1;let t=e.name??``,n=/^(agent-|planning-|specialist-)/.test(t),r=e.harness===`ohmypi`||e.harness===`codex`;return n&&r}function Ggt(e){let t=_t(),n=Wgt(e);return(0,R.useEffect)(()=>{if(!n)return;let r=a5(e.name);t.cancelQueries({queryKey:r});let i=hj().subscribe(t=>t[Pp.subscribeConversationMessages]({conversationName:e.name}),e=>{t.setQueryData(r,t=>Ugt(t,e))});return()=>{i()}},[e.name,n,t]),n}var Kgt=4*6e4;function qgt(e){if(!e)return!0;let t=Date.parse(e.completedAt||e.createdAt||``);return Number.isNaN(t)?!0:Date.now()-t<Kgt}var Jgt={init:Br,thinking:ar,bash:Pr,file:jn,search:wr,web:Jn,agent:ar,tool:Rr,processing:ar};async function Ygt(e,t){let n=await fetch(`/api/conversations/${encodeURIComponent(e)}/delivery-method`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({deliveryMethod:t})});if(!n.ok){let e=await n.text().catch(()=>``);throw Error(`Failed to update delivery method (${n.status})${e?`: ${e}`:``}`)}}async function Xgt(e,t,n,r){let i=await fetch(`/api/conversations/${encodeURIComponent(e)}/resume`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({model:t,effort:n,harness:r})});if(!i.ok)throw Error(`Failed to resume conversation`);return i.json()}function s5({conversation:e,viewMode:t=`conversation`,onViewModeChange:n,onArchived:r,roundMarkers:i,roundMetadata:a,embedded:o=!1,agentId:s,targetMessageId:c,targetMessageIndex:l,targetMessageNonce:u,onTargetMessageHandled:d,hideToolCalls:f,onToggleHideToolCalls:p,onEmbeddedResume:m,embeddedResumeLabel:h,onSendFailed:g}){let[_,v]=(0,R.useState)(!1),[y,b]=(0,R.useState)(!1),[x,S]=(0,R.useState)(!1),C=Hr(),w=bJ(e.name,()=>{}),[T,E]=(0,R.useState)(()=>e.model||oE()),[D,O]=(0,R.useState)(()=>(e.harness===`pi`?`ohmypi`:e.harness)??`claude-code`),[k,A]=(0,R.useState)(!1),[j,M]=(0,R.useState)(``),N=(0,R.useRef)(null),P=(0,R.useRef)(``),F=(0,R.useRef)(!1),I=_t(),ee=(0,R.useMemo)(()=>a5(e.name),[e.name]),te=Ggt(e),ne=(0,R.useRef)(te);ne.current=te;let[L,re]=(0,R.useState)(e.deliveryMethod??`auto`),[ie,ae]=(0,R.useState)(!1),[oe,se]=(0,R.useState)(!1);(0,R.useEffect)(()=>{se(!1)},[e.name]),(0,R.useEffect)(()=>{e.model&&e.model!==T&&E(e.model)},[e.model]),(0,R.useEffect)(()=>{e.harness&&e.harness!==D&&O(e.harness===`pi`?`ohmypi`:e.harness)},[e.harness]),(0,R.useEffect)(()=>{e.deliveryMethod&&e.deliveryMethod!==L&&re(e.deliveryMethod)},[e.deliveryMethod]),(0,R.useEffect)(()=>{te&&I.cancelQueries({queryKey:ee})},[ee,I,te]);let{data:ce,isLoading:le}=B({queryKey:ee,queryFn:async({signal:t})=>{let n=await Qgt(e.name,t);if(ne.current){let e=I.getQueryData(ee);if(e&&e.messages.length>=n.messages.length)return e}return n},enabled:!te,refetchInterval:te?!1:e.sessionAlive?2e3:!1}),ue=ce?.messages??[],de=ce?.workLog??[],fe=ue[ue.length-1],pe=!s&&!e.sessionAlive&&!e.claudeSessionId&&ue.length===0,me=e.sessionAlive&&(ce==null||ue.length===0||qgt(fe)&&(fe?.role===`user`||fe?.role===`assistant`&&!fe.completedAt)),he=me?H$e(ue,de):`thinking`,ge=zR(he,me?U$e(de):void 0),_e=Jgt[he],ve=BR(he)?J.spinnerIcon:J.pulseIcon,{resolvedTheme:ye}=MS(),be=e.id<0,{data:xe}=B({queryKey:[`conversation-diffs`,e.name],queryFn:async()=>{let t=await fetch(`/api/conversations/${encodeURIComponent(e.name)}/diffs`);return t.ok?t.json():null},enabled:!be,refetchInterval:5e3}),Se=(0,R.useMemo)(()=>{let e=new Map;if(!xe?.summaries)return e;let t=(ce?.messages??[]).filter(e=>e.role===`assistant`).sort((e,t)=>new Date(e.createdAt).getTime()-new Date(t.createdAt).getTime());for(let n of xe.summaries){if(n.assistantMessageId){e.set(n.assistantMessageId,n);continue}if(t.length>0&&n.completedAt){let r=new Date(n.completedAt).getTime(),i=null,a=1/0;for(let e of t){let t=r-new Date(e.createdAt).getTime();t>=0&&t<a&&(a=t,i=e.id)}i&&a<10080*60*1e3&&e.set(i,n)}}return e},[xe?.summaries,ce?.messages]),[Ce,we]=(0,R.useState)(()=>Q8(Object.fromEntries(new URLSearchParams(window.location.search))).diff===`1`);(0,R.useEffect)(()=>{let e=()=>{we(Q8(Object.fromEntries(new URLSearchParams(window.location.search))).diff===`1`)};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[]);let Te=(0,R.useCallback)((e,t)=>{let n=new URLSearchParams(window.location.search);n.set(`diff`,`1`),n.set(`diffTurnId`,e),t?n.set(`diffFilePath`,t):n.delete(`diffFilePath`);let r=`${window.location.pathname}?${n.toString()}`;window.history.pushState({},``,r),window.dispatchEvent(new PopStateEvent(`popstate`)),we(!0)},[]),Ee=(0,R.useCallback)(()=>{let e=new URLSearchParams(window.location.search);e.delete(`diff`),e.delete(`diffTurnId`),e.delete(`diffFilePath`);let t=e.toString(),n=t?`${window.location.pathname}?${t}`:window.location.pathname;window.history.pushState({},``,n),window.dispatchEvent(new PopStateEvent(`popstate`)),we(!1)},[]),De=Nt({mutationFn:()=>Xgt(e.name,T,e.effort??void 0,D),onSuccess:()=>{I.invalidateQueries({queryKey:[`conversations`]}),I.invalidateQueries({queryKey:a5(e.name)}),v(!0)}}),Oe=Nt({mutationFn:({model:t,harness:n})=>{if(s)throw Error(`Agent models are locked after spawn`);return fetch(`/api/conversations/${encodeURIComponent(e.name)}/switch-model`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({model:t,harness:n})}).then(e=>{if(!e.ok)throw Error(`Failed to switch model`);return e.json()})},onSuccess:(t,{model:n,harness:r})=>{o4(n),s4(r),I.invalidateQueries({queryKey:[`conversations`]}),I.invalidateQueries({queryKey:a5(e.name)})}}),ke=Nt({mutationFn:t=>_J(e.name,t),onSuccess:()=>{I.invalidateQueries({queryKey:[`conversations`]})}}),Ae=Nt({mutationFn:async()=>{let t=await fetch(`/api/conversations/${encodeURIComponent(e.name)}/retitle`,{method:`POST`}),n=await t.json().catch(()=>null);if(!t.ok)throw Error(n?.error||`Failed to regenerate title`);return n},onSuccess:e=>{I.invalidateQueries({queryKey:[`conversations`]}),H.success(`Renamed to "${e.title}"`,{duration:4e3})},onError:e=>{H.error(e.message,{duration:6e3})}}),je=B({queryKey:[`conversation-about`,e.name],queryFn:async()=>{let t=await fetch(`/api/conversations/${encodeURIComponent(e.name)}/about`);if(!t.ok)throw Error(`Failed to load conversation summary`);return t.json()},enabled:oe&&!o,staleTime:6e4}),Me=Nt({mutationFn:async()=>{let t=await fetch(`/api/conversations/${encodeURIComponent(e.name)}/about?refresh=1`),n=await t.json().catch(()=>null);if(!t.ok)throw Error(n?.error||`Failed to refresh summary`);return n},onSuccess:t=>{I.setQueryData([`conversation-about`,e.name],t)},onError:e=>{H.error(e.message,{duration:6e3})}}),Ne=(0,R.useCallback)(()=>{F.current=!1;let t=e.title??e.name;P.current=t,M(t),A(!0),setTimeout(()=>{N.current?.select()},0)},[e.title,e.name]),Pe=(0,R.useCallback)(()=>{if(F.current)return;F.current=!0;let t=P.current.trim(),n=e.title??e.name;A(!1),t&&t!==n&&ke.mutate(t)},[e.title,e.name,ke]),Fe=(0,R.useCallback)(()=>{A(!1),M(``)},[]),Ie=(0,R.useCallback)(()=>{De.mutate()},[De]),Le=(0,R.useCallback)(async()=>{try{await fetch(`/api/conversations/${encodeURIComponent(e.name)}/archive`,{method:`POST`}),I.invalidateQueries({queryKey:[`conversations`]}),r?.()}catch(e){console.error(`[ConversationPanel] Archive failed:`,e)}},[e.name,I,r]),Re=(0,R.useCallback)(()=>{let t=ce?.messages??[];if(t.length===0){H.error(`No messages to export yet`);return}let n=t.map(e=>`## ${e.role}\n\n${e.text??``}\n`).join(`
|
|
666
666
|
`),r=`# ${e.title??e.name}\n\n`,i=new Blob([r+n],{type:`text/markdown`}),a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=`${(e.title??e.name).replace(/[^\w.-]+/g,`-`)}.md`,document.body.appendChild(o),o.click(),o.remove(),URL.revokeObjectURL(a),H.success(`Transcript exported`)},[ce,e.title,e.name]),ze=(0,R.useCallback)(t=>{if(t===`terminal`){let t=window;t.__panTerminalClickAt=performance.now();try{localStorage.getItem(`OVERDECK_TERMINAL_PROFILE`)===`1`&&console.log(`[xterm-click] conv=${e.name} t=${t.__panTerminalClickAt.toFixed(1)}`)}catch{}}n?.(t)},[n,e.name]),Be=(0,R.useCallback)(async t=>{ae(!0);try{await Ygt(e.name,t),re(t)}catch(e){console.error(`[ConversationPanel] Failed to update delivery method:`,e)}finally{ae(!1)}},[e.name]),Ve=JY(e.name),He=f??Ve.hideToolCalls,Ue=p??Ve.toggleHideToolCalls,We=(0,R.useCallback)(()=>{let n=new URLSearchParams;t===`terminal`&&n.set(`view`,`terminal`);let r=n.toString(),i=`${window.location.origin}/conv/${e.id}${r?`?${r}`:``}`;navigator.clipboard.writeText(i).then(()=>{b(!0),setTimeout(()=>b(!1),2e3)})},[e.id,t]),Ge=(0,R.useCallback)(()=>{let n=new URLSearchParams;t===`terminal`&&n.set(`view`,`terminal`);let r=n.toString(),i=`/popout/conversation/${e.id}${r?`?${r}`:``}`;window.open(i,`_blank`,`popup=yes,width=920,height=1040`)},[e.id,t]),Ke=(0,R.useCallback)(()=>{window.open(`/api/conversations/${encodeURIComponent(e.name)}/handoff-doc`,`_blank`,`noopener,noreferrer`)},[e.name]),qe=(0,R.useCallback)(()=>{e.handoffTargetConvId&&(window.location.href=`/conv/${e.handoffTargetConvId}`)},[e.handoffTargetConvId]),Je=e.sessionAlive||_,Ye=Ce?`conversation`:t,Xe=!!e.forkStatus&&e.forkStatus!==`failed`,Ze=e.forkStatus===`failed`,Qe=!!e.spawnError,$e=!e.sessionAlive&&!e.endedAt&&!Qe,et=Xe||$e?`var(--info)`:Ze||Qe?`var(--destructive)`:e.sessionAlive?`var(--info)`:`var(--muted-foreground)`,tt=Xe?`forking`:$e?`starting`:Ze||Qe?`failed`:e.sessionAlive?`active`:`ended`;return(0,z.jsxs)(`div`,{className:J.conversationTerminal,children:[!o&&(0,z.jsxs)(`div`,{className:`${J.conversationHeaderShell} ${J.conversationHeaderContainer}`,onContextMenu:e=>{k||(e.preventDefault(),S(!0))},children:[(0,z.jsxs)(`div`,{className:J.conversationHeaderPrimary,children:[(0,z.jsxs)(`span`,{className:J.conversationTerminalTitle,children:[me&&(0,z.jsx)(`span`,{title:ge,style:{display:`contents`},children:(0,z.jsx)(_e,{size:14,className:ve,"aria-label":ge})}),k?(0,z.jsx)(`input`,{ref:N,className:J.conversationTitleInput,value:j,onChange:e=>{M(e.target.value),P.current=e.target.value},onKeyDown:e=>{e.key===`Enter`&&Pe(),e.key===`Escape`&&Fe()},onBlur:Pe,"aria-label":`Rename ${e.name}`}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`${J.conversationTerminalTitleText} ${Ae.isPending?J.titleRegenerating:``}`,children:e.title??e.name}),(0,z.jsx)(`button`,{className:J.conversationTitleEditBtn,onClick:Ne,title:`Rename conversation`,"aria-label":`Rename ${e.name}`,children:(0,z.jsx)(mr,{size:12})})]})]}),(0,z.jsxs)(`div`,{className:J.conversationHeaderActions,children:[Je&&(0,z.jsxs)(`div`,{className:J.viewToggle,children:[(0,z.jsx)(`button`,{className:`${J.viewToggleBtn} ${Ye===`conversation`?J.viewToggleBtnActive:``}`,onClick:()=>ze(`conversation`),children:`Conversation`}),(0,z.jsx)(`button`,{className:`${J.viewToggleBtn} ${Ye===`terminal`?J.viewToggleBtnActive:``}`,onClick:()=>ze(`terminal`),children:`Terminal`})]}),(0,z.jsxs)(`button`,{className:`${J.conversationAboutToggle} ${oe?J.conversationAboutToggleActive:``}`,onClick:()=>se(e=>!e),title:oe?`Hide conversation summary`:`Show conversation summary`,"aria-label":oe?`Hide about this conversation`:`Show about this conversation`,"aria-pressed":oe,children:[(0,z.jsx)(Qn,{size:14}),(0,z.jsx)(`span`,{children:`About`})]}),(0,z.jsxs)(`button`,{className:`${J.conversationAboutToggle} ${He?J.conversationAboutToggleActive:``}`,onClick:Ue,title:He?`Show tool calls`:`Hide tool calls`,"aria-label":He?`Show tool calls`:`Hide tool calls`,"aria-pressed":He,children:[(0,z.jsx)(Rr,{size:14}),(0,z.jsx)(`span`,{children:`Tools`})]}),(0,z.jsx)(`button`,{className:J.copyLinkButton,onClick:We,title:`Copy link to conversation`,"aria-label":`Copy link to conversation`,children:y?(0,z.jsx)($t,{size:14}):(0,z.jsx)(xn,{size:14})}),(0,z.jsx)(`button`,{className:J.copyLinkButton,onClick:Ge,title:`Detach conversation`,"aria-label":`Detach conversation`,children:(0,z.jsx)(kn,{size:14})}),(0,z.jsxs)(`div`,{className:J.headerMenuWrap,children:[(0,z.jsx)(`button`,{className:J.copyLinkButton,onClick:()=>S(e=>!e),title:`More actions`,"aria-label":`More conversation actions`,"aria-haspopup":`menu`,"aria-expanded":x,children:(0,z.jsx)(Dn,{size:16})}),x&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:J.headerMenuOverlay,onClick:()=>S(!1)}),(0,z.jsxs)(`div`,{role:`menu`,className:J.headerMenu,children:[(0,z.jsxs)(`button`,{role:`menuitem`,className:`${J.headerMenuItem} ${e.isFavorited?J.headerMenuItemActive:``}`,onClick:()=>{w.toggleFavorite({name:e.name,favorited:!!e.isFavorited}),S(!1)},children:[(0,z.jsx)(Mr,{size:14,style:{fill:e.isFavorited?`currentColor`:`none`}}),e.isFavorited?`Unfavorite`:`Favorite`]}),(0,z.jsxs)(`button`,{role:`menuitem`,className:J.headerMenuItem,onClick:()=>{Ae.mutate(),S(!1)},disabled:Ae.isPending,children:[Ae.isPending?(0,z.jsx)(ar,{size:14,className:J.spinnerIcon}):(0,z.jsx)(Ar,{size:14}),`Regenerate title`]}),e.harness===`claude-code`&&(0,z.jsxs)(`div`,{className:J.headerMenuDeliveryRow,children:[(0,z.jsx)(`span`,{children:`Delivery method`}),(0,z.jsxs)(`select`,{className:J.deliveryMethodSelect,value:L,onChange:e=>Be(e.target.value),disabled:ie,title:`Message delivery method`,"aria-label":`Message delivery method`,children:[(0,z.jsx)(`option`,{value:`auto`,children:`Auto`}),(0,z.jsx)(`option`,{value:`channels`,children:`Channels`}),(0,z.jsx)(`option`,{value:`tmux`,children:`Tmux`})]})]}),(0,z.jsx)(`div`,{className:J.headerMenuDivider}),e.claudeSessionId&&(0,z.jsxs)(`button`,{role:`menuitem`,className:J.headerMenuItem,onClick:()=>{w.openForkModal(e,{mode:`handoff`}),S(!1)},children:[(0,z.jsx)(Er,{size:14}),`Hand off to new conversation`]}),e.claudeSessionId&&e.harness!==`pi`&&(0,z.jsxs)(`button`,{role:`menuitem`,className:J.headerMenuItem,onClick:()=>{w.openForkModal(e),S(!1)},children:[(0,z.jsx)(Vn,{size:14}),`Create summary fork`]}),(0,z.jsxs)(`button`,{role:`menuitem`,className:J.headerMenuItem,onClick:()=>{Re(),S(!1)},children:[(0,z.jsx)(Tn,{size:14}),`Export transcript`]}),(e.handoffDocPath||e.handoffTargetConvId)&&(0,z.jsx)(`div`,{className:J.headerMenuDivider}),e.handoffDocPath&&(0,z.jsxs)(`button`,{role:`menuitem`,className:J.headerMenuItem,onClick:()=>{Ke(),S(!1)},children:[(0,z.jsx)(Mn,{size:14}),`Open handoff doc`]}),e.handoffTargetConvId&&(0,z.jsxs)(`button`,{role:`menuitem`,className:J.headerMenuItem,onClick:()=>{qe(),S(!1)},children:[(0,z.jsx)(kn,{size:14}),`Open handoff target`]}),(e.sessionAlive||r)&&(0,z.jsx)(`div`,{className:J.headerMenuDivider}),e.sessionAlive&&(0,z.jsxs)(`button`,{role:`menuitem`,className:J.headerMenuItem,onClick:()=>{w.stop(e.name),S(!1)},children:[(0,z.jsx)(jr,{size:14}),`Stop agent`]}),r&&(0,z.jsxs)(`button`,{role:`menuitem`,className:`${J.headerMenuItem} ${J.headerMenuItemDestructive}`,onClick:async()=>{S(!1),await C({title:e.isFavorited?`Archive favorited conversation`:`Archive conversation`,message:e.isFavorited?`"${e.title??e.name}" is favorited.\n\nArchiving will remove the favorite, end the session, and move it to the archive.`:`Archive "${e.title??e.name}"? This ends the session and moves it to the archive.`,confirmLabel:`Archive`,cancelLabel:`Cancel`,variant:`destructive`})&&Le()},children:[(0,z.jsx)(zt,{size:14}),`Archive conversation`]})]})]})]})]})]}),(0,z.jsxs)(`div`,{className:J.conversationMetaRow,children:[(0,z.jsxs)(`span`,{className:J.conversationTerminalStatus,children:[(0,z.jsx)(dn,{size:7,style:{fill:et,color:et}}),tt]}),e.branch&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:J.conversationMetaSep,"aria-hidden":!0,children:`·`}),(0,z.jsxs)(`span`,{className:J.terminalBranchBar,title:`${e.isWorktree?`Worktree`:`Local`} · ${e.cwd}`,children:[e.isWorktree?(0,z.jsx)(Wn,{size:12}):(0,z.jsx)(Rn,{size:12}),(0,z.jsx)(`span`,{className:J.terminalBranchBarMode,children:e.isWorktree?`Worktree`:`Local`}),(0,z.jsx)(`span`,{className:J.terminalBranchBarText,children:e.branch})]})]}),(0,z.jsx)(`span`,{className:J.conversationMetaSep,"aria-hidden":!0,children:`·`}),(0,z.jsx)(zj,{openInCwd:e.cwd}),e.totalCost!==void 0&&e.totalCost>0&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:J.conversationMetaSep,"aria-hidden":!0,children:`·`}),(0,z.jsx)(`span`,{className:J.featureCost,children:e.totalCost<.01?`<$0.01`:`$${e.totalCost.toFixed(2)}`})]}),(0,z.jsx)(`span`,{className:J.conversationMetaSep,"aria-hidden":!0,children:`·`}),(0,z.jsx)(`span`,{className:J.conversationSessionId,children:e.sessionFile?.split(`/`).pop()?.replace(`.jsonl`,``)??e.name})]})]}),!o&&oe&&(0,z.jsx)(`div`,{className:J.conversationAboutDrawer,children:je.isLoading||Me.isPending?(0,z.jsxs)(`span`,{className:J.conversationAboutMuted,children:[(0,z.jsx)(ar,{size:12,className:J.spinnerIcon}),`Summarizing conversation…`]}):je.isError?(0,z.jsx)(`span`,{className:J.conversationAboutMuted,children:`Couldn't load the conversation summary.`}):je.data?.summary?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`p`,{className:J.conversationAboutText,children:je.data.summary}),(0,z.jsxs)(`div`,{className:J.conversationAboutMeta,children:[(0,z.jsxs)(`span`,{children:[`Summary of `,je.data.messageCount,` `,je.data.messageCount===1?`message`:`messages`]}),(0,z.jsx)(`button`,{className:J.copyLinkButton,onClick:()=>Me.mutate(),disabled:Me.isPending,title:`Regenerate summary`,"aria-label":`Regenerate conversation summary`,children:(0,z.jsx)(_r,{size:12})})]})]}):(0,z.jsx)(`span`,{className:J.conversationAboutMuted,children:`Not enough conversation yet to summarize.`})}),(0,z.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,children:[(0,z.jsxs)(`div`,{className:J.conversationTerminalBody,children:[Je&&Ye===`terminal`&&(0,z.jsx)(IS,{sessionName:e.tmuxSession}),(Ye===`conversation`||!Je)&&(0,z.jsx)($gt,{conversation:e,onResume:m??(!o&&!Je&&!$e?Ie:void 0),onArchive:o?void 0:Le,resumePending:De.isPending,resumeLabel:h,onSendFailed:g,roundMarkers:i,roundMetadata:a,turnDiffSummaryByAssistantMessageId:Se,onOpenTurnDiff:Te,resolvedTheme:ye,agentId:s,hideToolCalls:He,workingPhase:me?he:void 0,streamMessagesEnabled:te,messagesData:ce,messagesLoading:le,targetMessageId:c,targetMessageIndex:l,targetMessageNonce:u,onTargetMessageHandled:d,modelPicker:o?void 0:(0,z.jsx)(l4,{value:T,harness:D,liveConversation:e.sessionAlive,disabled:!pe,onHarnessChange:e=>{pe&&(O(e),Oe.mutate({model:T,harness:e}))},onChange:e=>{pe&&(E(e),Oe.mutate({model:e,harness:D}))}})})]}),Ce&&xe?.summaries&&(0,z.jsx)(Vgt,{children:(0,z.jsx)(Rgt,{mode:`inline`,agentId:s??e.name,turnDiffSummaries:xe.summaries,onClose:Ee,diffUrlPrefix:`/api/conversations/${encodeURIComponent(e.name)}/diffs`})})]}),w.forkTarget&&(0,z.jsx)(uJ,{conversation:w.forkTarget,initialMode:w.forkTargetMode,initialFocus:w.forkTargetFocus,isPending:w.isForkPending,onClose:w.closeForkModal,onConfirm:(e,t,n,r,i,a,o,s,c,l,u,d,f)=>{w.submitFork(e,t,n,r,i,a,o,s,c,l,u,d,f)}})]})}var c5=[{key:`summarizing`,label:`Summarizing`,description:`Generating a concise summary of the parent conversation`},{key:`spawning`,label:`Spawning`,description:`Starting a new Claude Code session`},{key:`injecting`,label:`Injecting`,description:`Seeding the new session with conversation context`}];function Zgt({forkStatus:e,forkError:t,parentTitle:n}){let r=e===`failed`,i=c5.findIndex(t=>t.key===e);return(0,z.jsx)(`div`,{className:J.forkProgressView,children:(0,z.jsxs)(`div`,{className:J.forkProgressCard,children:[(0,z.jsxs)(`div`,{className:J.forkProgressHeader,children:[(0,z.jsx)(Vn,{size:20,className:J.forkProgressIcon}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{className:J.forkProgressTitle,children:r?`Fork Failed`:`Setting up fork…`}),n&&(0,z.jsxs)(`p`,{className:J.forkProgressSubtitle,children:[`Forking from `,(0,z.jsx)(`strong`,{children:n})]})]})]}),(0,z.jsx)(`div`,{className:J.forkProgressTimeline,children:c5.map((e,t)=>{let n;return n=r?t<i?`done`:t===i||i===-1&&t===0?`failed`:`pending`:t<i?`done`:t===i?`active`:`pending`,(0,z.jsxs)(`div`,{className:`${J.forkProgressStep} ${J[`forkProgressStep--${n}`]}`,children:[(0,z.jsxs)(`div`,{className:J.forkProgressStepIndicator,children:[n===`done`&&(0,z.jsx)(sn,{size:18}),n===`active`&&(0,z.jsx)(ar,{size:18,className:J.forkProgressSpinner}),n===`pending`&&(0,z.jsx)(dn,{size:18}),n===`failed`&&(0,z.jsx)(an,{size:18}),t<c5.length-1&&(0,z.jsx)(`div`,{className:J.forkProgressStepLine})]}),(0,z.jsxs)(`div`,{className:J.forkProgressStepContent,children:[(0,z.jsx)(`span`,{className:J.forkProgressStepLabel,children:e.label}),(0,z.jsx)(`span`,{className:J.forkProgressStepDesc,children:e.description})]})]},e.key)})}),r&&t&&(0,z.jsxs)(`div`,{className:J.forkProgressError,children:[(0,z.jsx)(an,{size:14}),(0,z.jsx)(`span`,{children:t})]})]})})}async function Qgt(e,t){let n=await fJ(`/api/conversations/${encodeURIComponent(e)}/messages`,{signal:t});if(!n.ok)throw Error(`Failed to fetch messages`);return n.json()}function $gt({conversation:e,onResume:t,onArchive:n,resumePending:r,resumeLabel:i,onSendFailed:a,modelPicker:o,roundMarkers:s,roundMetadata:c,turnDiffSummaryByAssistantMessageId:l,onOpenTurnDiff:u,resolvedTheme:d,agentId:f,hideToolCalls:p,workingPhase:m,streamMessagesEnabled:h,messagesData:g,messagesLoading:_,targetMessageId:v,targetMessageIndex:y,targetMessageNonce:b,onTargetMessageHandled:x}){let S=sm(t=>t.conversationsCompactingByName?.[e.name]??!1),C=Jat(e.name),w=Yat(e.name),T=Xat(e.name),E=b4(e=>e.addOptimistic),D=b4(e=>e.clearOptimistic),O=b4(e=>e.failSend),k=b4(e=>e.addFailed),A=b4(e=>e.removeFailed),j=_t(),M=(0,R.useRef)(e.forkStatus);(0,R.useEffect)(()=>{let t=M.current;M.current=e.forkStatus,t&&!e.forkStatus&&j.invalidateQueries({queryKey:a5(e.name)})},[e.forkStatus,e.name,j]);let N=g,P=_??!1,F=N?.messages??[],I=N?.workLog??[],ee=jat(N?.contextUsage??e.contextUsage??null),te=F.slice(w).filter(e=>e.role===`user`).length,ne=Math.min(C.length,te),L=C.slice(ne),re=C.length>0&&L.length===0,ie=[...F,...L],ae=(0,R.useCallback)(t=>{E(e.name,t,F.length)},[E,e.name,F.length]),oe=(0,R.useCallback)(t=>{O(e.name,t),a?.()},[O,e.name,a]),se=(0,R.useCallback)(async(t,n)=>{A(e.name,t);try{let t=f?`/api/agents/${encodeURIComponent(f)}/message`:`/api/conversations/${encodeURIComponent(e.name)}/message`,r=await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({message:n})});if(!r.ok){let e=await r.text().catch(()=>``);throw Error(`Failed to send message (${r.status})${e?`: ${e}`:``}`)}}catch{k(e.name,n)}},[e.name,f,A,k]),ce=(0,R.useCallback)(t=>{A(e.name,t)},[A,e.name]);(0,R.useEffect)(()=>{re&&D(e.name)},[re,D,e.name]),(0,R.useEffect)(()=>{if(L.length===0)return;let t=L[0],n=Date.parse(t.createdAt||``);if(Number.isNaN(n))return;let r=n+((N?.compactBoundaries??[]).some(e=>{let t=Date.parse(e.timestamp);return!Number.isNaN(t)&&t>=n})?2e4:Kgt),i=setTimeout(()=>O(e.name,t.text),Math.max(0,r-Date.now()));return()=>clearTimeout(i)},[L,N?.compactBoundaries,O,e.name]);let le=!!e.forkStatus&&e.forkStatus!==`failed`,ue=e.forkStatus===`failed`,de=le||ue,fe=!!e.spawnError,pe=!e.sessionAlive&&!e.endedAt&&!fe&&!de,me=h&&N?.discovering===!0&&ie.length===0,he=!P&&!me&&ie.length===0&&e.sessionAlive,ge=!P&&!me&&ie.length===0&&!e.sessionAlive&&!fe&&!pe,_e=ie[ie.length-1],ve=e.sessionAlive&&(S||ie.length===0||qgt(_e)&&(_e?.role===`user`||_e?.role===`assistant`&&!_e.completedAt)),ye=e.title?.replace(/^Summary Fork:\s*/,``)||void 0,be=(0,R.useMemo)(()=>{let e=eot(c,ie);return e.length>0?e:s??[]},[c,ie,s]);return(0,z.jsxs)(`div`,{className:J.conversationView,children:[P||me?(0,z.jsx)(`div`,{className:J.conversationConnecting,children:(0,z.jsx)(`span`,{children:me?`Discovering conversation…`:`Loading…`})}):N?.error?(0,z.jsxs)(`div`,{className:J.conversationEmptyState,children:[(0,z.jsx)(`p`,{className:J.conversationEmptyStateTitle,style:{color:`var(--warning)`},children:`⚠ Session could not be resolved`}),(0,z.jsx)(`p`,{className:J.conversationEmptyStateSubtitle,children:N.error})]}):pe?(0,z.jsxs)(`div`,{className:J.conversationEmptyState,children:[(0,z.jsxs)(`p`,{className:J.conversationEmptyStateTitle,children:[(0,z.jsx)(ar,{size:16,style:{display:`inline`,verticalAlign:`middle`,marginRight:6,animation:`spin 1s linear infinite`}}),`Starting…`]}),(0,z.jsx)(`p`,{className:J.conversationEmptyStateSubtitle,children:`Waiting for the session to start.`})]}):fe?(0,z.jsxs)(`div`,{className:J.conversationEmptyState,children:[(0,z.jsx)(`p`,{className:J.conversationEmptyStateTitle,children:`Failed to start`}),(0,z.jsx)(`p`,{className:J.conversationEmptyStateSubtitle,children:e.spawnError}),(0,z.jsx)(`div`,{style:{display:`flex`,gap:8,marginTop:12,alignItems:`center`},children:(0,z.jsx)(`button`,{className:J.conversationArchiveBtnLarge,onClick:()=>n?.(),children:`Archive`})})]}):de&&ie.length===0?(0,z.jsx)(Zgt,{forkStatus:e.forkStatus,forkError:e.forkError,parentTitle:ye}):ge?(0,z.jsxs)(`div`,{className:J.conversationEmptyState,children:[(0,z.jsx)(`p`,{className:J.conversationEmptyStateSubtitle,children:`This conversation has no saved history. The session may have ended before any messages were exchanged.`}),(0,z.jsxs)(`div`,{style:{display:`flex`,gap:8,marginTop:12,alignItems:`center`},children:[t&&(0,z.jsxs)(z.Fragment,{children:[o,(0,z.jsx)(`button`,{className:J.conversationResumeBtn,onClick:t,disabled:r,children:r?`Resuming…`:i??`Resume Session`})]}),(0,z.jsx)(`button`,{className:J.conversationArchiveBtnLarge,onClick:()=>n?.(),children:`Archive`})]})]}):he?(0,z.jsxs)(`div`,{className:J.conversationEmptyState,children:[(0,z.jsx)(`p`,{className:J.conversationEmptyStateTitle,children:`How can I help you?`}),(0,z.jsx)(`p`,{className:J.conversationEmptyStateSubtitle,children:`Type a message below to start the conversation.`})]}):(0,z.jsx)(Ttt,{messages:ie,workLog:I,streaming:ve,roundMarkers:be,failedMessages:T,onRetryFailed:se,onDiscardFailed:ce,proposedPlan:N?.proposedPlan,compactBoundaries:N?.compactBoundaries,compacting:S,conversationName:e.name,cwd:e.cwd,issueId:e.issueId,turnDiffSummaryByAssistantMessageId:l,onOpenTurnDiff:u,resolvedTheme:d,hideToolCalls:p,workingPhase:m,targetMessageId:v,targetMessageIndex:y,targetMessageNonce:b,onTargetMessageHandled:x}),e.clearedToConvId?(0,z.jsxs)(`button`,{type:`button`,className:J.conversationClearedBanner,onClick:()=>{window.location.href=`/conv/${e.clearedToConvId}`},title:`Open conv/${e.clearedToConvId}`,"aria-label":`Open conversation that continues after /clear (conv/${e.clearedToConvId})`,children:[(0,z.jsx)(yr,{size:14}),(0,z.jsxs)(`span`,{className:J.conversationClearedBannerText,children:[`Conversation cleared — continued in `,(0,z.jsxs)(`strong`,{children:[`conv/`,e.clearedToConvId]})]}),(0,z.jsx)(tee,{size:14})]}):de?null:t?(0,z.jsxs)(`div`,{className:J.conversationResumeBar,children:[o,(0,z.jsx)(`button`,{className:J.conversationResumeBtn,onClick:t,disabled:r,children:r?`Resuming…`:i??`Resume Session`})]}):(0,z.jsx)($at,{conversation:e,onSend:ae,onSendFailed:oe,agentId:f,contextWindowUsage:ee})]})}function e_t({kinds:e,size:t=14,onClick:n,className:r}){let i=tM(e),a=(0,z.jsx)(Ir,{size:t,className:`text-amber-500 ${n?``:`animate-pulse`} ${r??``}`,"aria-hidden":`true`});return n?(0,z.jsx)(`button`,{type:`button`,onClick:n,title:i,"aria-label":i,className:`inline-flex items-center justify-center rounded p-0.5 text-amber-500 transition-colors hover:bg-amber-500/15`,children:a}):(0,z.jsx)(`span`,{title:i,"aria-label":i,style:{display:`inline-flex`},children:a})}var t_t={pending:`var(--muted-foreground)`,passed:`var(--success)`,failed:`var(--destructive)`,running:`var(--primary)`},n_t={pending:`Pending`,passed:`Passed`,failed:`Failed`,running:`Running`};function r_t(e){return e==null?`—`:e<60?`${Math.round(e)}s`:e<3600?`${Math.round(e/60)}m`:`${Math.round(e/3600)}h`}function i_t(e){return e==null?`—`:`$${e.toFixed(2)}`}function a_t({round:e,active:t=!1,onClick:n,className:r}){let[i,a]=(0,R.useState)(!1),o=t_t[e.verdict],s=!!n,c=t?`anim-round-active`:``;return(0,z.jsxs)(`div`,{"data-testid":`round-card`,"data-round":e.round,"data-verdict":e.verdict,"data-active":t||void 0,onClick:n,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),role:s?`button`:void 0,tabIndex:s?0:void 0,onKeyDown:s?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),n())}:void 0,className:[c,r].filter(Boolean).join(` `),style:{width:140,padding:`8px 10px`,borderRadius:8,border:`1px solid ${t?o:`var(--border)`}`,background:t?void 0:i?`var(--accent)`:`var(--card)`,cursor:s?`pointer`:`default`,display:`flex`,flexDirection:`column`,gap:4,fontSize:12,lineHeight:1.3,color:`var(--foreground)`,transition:`background 150ms ease-out, border-color 150ms ease-out`},children:[(0,z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`},children:[(0,z.jsxs)(`span`,{style:{fontWeight:600},children:[`Round `,e.round]}),(0,z.jsx)(`span`,{style:{color:o,fontWeight:600,fontSize:11,textTransform:`uppercase`,letterSpacing:`0.04em`},children:n_t[e.verdict]})]}),(typeof e.findings==`number`||e.duration!=null||e.cost!=null)&&(0,z.jsxs)(`div`,{style:{display:`flex`,gap:8,color:`var(--muted-foreground)`,fontSize:11},children:[typeof e.findings==`number`&&(0,z.jsxs)(`span`,{"data-testid":`round-card-findings`,children:[e.findings,` finding`,e.findings===1?``:`s`]}),e.duration!=null&&(0,z.jsx)(`span`,{"data-testid":`round-card-duration`,children:r_t(e.duration)}),e.cost!=null&&(0,z.jsx)(`span`,{"data-testid":`round-card-cost`,children:i_t(e.cost)})]})]})}var o_t={correctness:{icon:Or,label:`Correctness`,color:`var(--primary)`},security:{icon:or,label:`Security`,color:`var(--destructive)`},performance:{icon:zn,label:`Performance`,color:`var(--warning)`},requirements:{icon:mn,label:`Requirements`,color:`var(--success)`}};function s_t(e){switch(e){case`active`:return`active`;case`idle`:return`idle`;case`suspended`:return`waiting`;case`ended`:return`ended`;default:return`ended`}}function c_t(e){switch(e){case`running`:return`Running`;case`stopped`:return`Done`;case`error`:return`Error`;case`starting`:return`Starting`;case`unknown`:return`Pending`;default:return e}}function l_t(e){switch(e){case`running`:return`var(--primary)`;case`stopped`:return`var(--success)`;case`error`:return`var(--destructive)`;default:return`var(--muted-foreground)`}}function u_t(e){return e==null||!Number.isFinite(e)||e<=0?``:e<60?`${Math.round(e)}s`:e<3600?`${Math.round(e/60)}m`:`${Math.round(e/3600)}h`}function d_t(e){return e==null?``:`$${e.toFixed(2)}`}function f_t({session:e,reviewers:t,roundData:n}){let r=(0,R.useMemo)(()=>{let n=0,r=e.roundMetadata?.history[e.roundMetadata.history.length-1];r?.findings&&(n+=r.findings);for(let e of t){let t=e.roundMetadata?.history[e.roundMetadata.history.length-1];t?.findings&&(n+=t.findings)}return n},[t,e.roundMetadata]),i=(0,R.useMemo)(()=>{let n=0;if(e.roundMetadata)for(let t of e.roundMetadata.history)t.cost&&(n+=t.cost);for(let e of t)if(e.roundMetadata)for(let t of e.roundMetadata.history)t.cost&&(n+=t.cost);return n},[t,e.roundMetadata]),a=(0,R.useMemo)(()=>e.roundMetadata?e.roundMetadata.history[e.roundMetadata.history.length-1]?.summary??null:null,[e.roundMetadata]),o=t.length>0&&t.every(e=>e.status===`stopped`),s=t.some(e=>e.status===`running`),c=t.some(e=>e.status===`error`),l=o?`completed`:c?`issues`:s?`running`:`pending`,u=l===`completed`?`Review Complete`:l===`issues`?`Issues Detected`:l===`running`?`Review In Progress`:`Pending`,d=l===`completed`?`var(--success)`:l===`issues`?`var(--destructive)`:l===`running`?`var(--primary)`:`var(--muted-foreground)`;return(0,z.jsxs)(`div`,{className:J.reviewSummary,children:[(0,z.jsxs)(`div`,{className:J.reviewSummaryBanner,children:[(0,z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10},children:[(0,z.jsx)(`span`,{style:{fontSize:15,fontWeight:700,color:d},children:u}),t.length>0&&(0,z.jsxs)(`span`,{style:{fontSize:12,color:`var(--muted-foreground)`},children:[t.filter(e=>e.status===`stopped`).length,`/`,t.length,` reviewers done`]})]}),(0,z.jsxs)(`div`,{style:{display:`flex`,gap:16,fontSize:12,color:`var(--muted-foreground)`},children:[r>0&&(0,z.jsxs)(`span`,{children:[r,` finding`,r===1?``:`s`]}),i>0&&(0,z.jsx)(`span`,{children:d_t(i)}),e.duration!=null&&e.duration>0&&(0,z.jsx)(`span`,{children:u_t(e.duration)})]})]}),t.length>0&&(0,z.jsx)(`div`,{className:J.reviewerStrip,children:t.map(e=>{let t=o_t[e.role??``],n=t?.icon??Or,r=t?.label??e.role??`Unknown`,i=t?.color??`var(--muted-foreground)`,a=e.roundMetadata?.history[e.roundMetadata.history.length-1];return(0,z.jsxs)(`div`,{className:J.reviewerCard,children:[(0,z.jsxs)(`div`,{className:J.reviewerCardLabel,children:[(0,z.jsx)(n,{size:14,style:{color:i,flexShrink:0}}),(0,z.jsx)(`span`,{style:{fontWeight:600,fontSize:12},children:r}),(0,z.jsx)(NR,{status:s_t(e.presence),size:`sm`})]}),(0,z.jsxs)(`div`,{className:J.reviewerCardStats,children:[(0,z.jsx)(`span`,{style:{color:l_t(e.status),fontWeight:500},children:c_t(e.status)}),a?.findings!=null&&a.findings>0&&(0,z.jsxs)(`span`,{children:[a.findings,` finding`,a.findings===1?``:`s`]}),a?.durationSec!=null&&(0,z.jsx)(`span`,{children:u_t(a.durationSec)}),a?.cost!=null&&(0,z.jsx)(`span`,{children:d_t(a.cost)}),e.status===`error`&&e.roundMetadata?.latestStatus&&e.roundMetadata.latestStatus!==`error`&&(0,z.jsx)(`span`,{style:{color:`var(--destructive)`,fontFamily:`var(--font-mono)`,fontSize:10},children:e.roundMetadata.latestStatus})]})]},e.sessionId)})}),n.length>0&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{style:{fontSize:11,fontWeight:600,color:`var(--muted-foreground)`,textTransform:`uppercase`,letterSpacing:`0.04em`,marginBottom:8},children:`Rounds`}),(0,z.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:10},children:n.map(t=>(0,z.jsx)(a_t,{round:t,active:t.round===e.roundMetadata?.latestRound},t.round))})]}),a&&(0,z.jsxs)(`div`,{className:J.reviewSynthesis,children:[(0,z.jsx)(`div`,{className:J.reviewSynthesisHeading,children:`Findings`}),(0,z.jsx)(WY,{text:a,isStreaming:!1,cwd:void 0})]}),t.length===0&&n.length===0&&(0,z.jsx)(`div`,{style:{padding:`40px 20px`,textAlign:`center`,color:`var(--muted-foreground)`,fontSize:13},children:`No review data yet. Reviewers will appear here once the review starts.`})]})}async function p_t(e){let t=await fetch(`/api/agents/${encodeURIComponent(e)}/git-info`);return t.ok?t.json():null}function m_t(e){return`mc-session-panel-view:${e}`}function h_t(e){try{let t=localStorage.getItem(m_t(e));return t===`terminal`||t===`findings`?t:`conversation`}catch{return`conversation`}}function g_t(e,t){try{localStorage.setItem(m_t(e),t)}catch{}}function __t(e){switch(e){case`passed`:case`approved`:return`passed`;case`failed`:case`blocked`:return`failed`;case`running`:case`active`:return`running`;default:return`pending`}}function v_t(e){return!e||e.history.length===0?[]:e.history.map(e=>({round:e.round,verdict:__t(e.status),findings:e.findings,duration:e.durationSec??null,cost:e.cost??null}))}async function y_t(e,t){let n=await fetch(`/api/agents/${encodeURIComponent(e)}/delivery-method`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({deliveryMethod:t})});if(!n.ok){let e=await n.text().catch(()=>``);throw Error(`Failed to update delivery method (${n.status})${e?`: ${e}`:``}`)}}function b_t({sessionId:e}){let{data:t}=B({queryKey:[`agent-git-info`,e],queryFn:()=>p_t(e),enabled:!!e,staleTime:3e4,refetchInterval:3e4});if(!t||!(t.actualBranch||t.workspaceMissing))return null;let n=t.branchDrifted,r=t.workspaceMissing;return(0,z.jsx)(`span`,{className:`${J.terminalBranchBar} ${r?J.terminalBranchBarMissing:n?J.terminalBranchBarDrift:``}`,title:r?`Workspace missing on disk: ${t.workspacePath??`(unknown path)`}`:n?`Expected ${t.expectedBranch??`(none)`}, on ${t.actualBranch??`(none)`}`:`${t.workspacePath??``}`,"data-testid":`session-panel-branch-chip`,children:r?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(an,{size:12}),(0,z.jsx)(`span`,{className:J.terminalBranchBarMode,children:`Worktree missing`})]}):(0,z.jsxs)(z.Fragment,{children:[n?(0,z.jsx)(Ir,{size:12}):(0,z.jsx)(Wn,{size:12}),(0,z.jsx)(`span`,{className:J.terminalBranchBarMode,children:n?`Drifted`:`Worktree`}),(0,z.jsx)(`span`,{className:J.terminalBranchBarText,children:t.actualBranch})]})})}function x_t({sessionId:e,deliveryMethod:t}){let[n,r]=(0,R.useState)(t??`auto`),[i,a]=(0,R.useState)(!1);(0,R.useEffect)(()=>{t&&t!==n&&r(t)},[t]);let o=(0,R.useCallback)(async t=>{let n=t.target.value;a(!0);try{await y_t(e,n),r(n)}catch(e){console.error(`[DeliveryMethodToggle] Failed:`,e)}finally{a(!1)}},[e]);return(0,z.jsxs)(`select`,{className:J.deliveryMethodSelect,value:n,onChange:o,disabled:i,title:`Message delivery method`,"aria-label":`Message delivery method`,children:[(0,z.jsx)(`option`,{value:`auto`,children:`Auto`}),(0,z.jsx)(`option`,{value:`channels`,children:`Channels`}),(0,z.jsx)(`option`,{value:`tmux`,children:`Tmux`})]})}function S_t({session:e,issueId:t,roundMarkers:n,reviewers:r}){let i=e.type===`review`,a=IR(),{hideToolCalls:o,toggleHideToolCalls:s}=JY(e.sessionId),[c,l]=(0,R.useState)(()=>{let t=h_t(e.sessionId);return i&&t===`conversation`&&!e.hasJsonl?`findings`:t}),u=t=>{if(t===`terminal`){let t=window;t.__panTerminalClickAt=performance.now();try{localStorage.getItem(`OVERDECK_TERMINAL_PROFILE`)===`1`&&console.log(`[xterm-click] session=${e.sessionId} t=${t.__panTerminalClickAt.toFixed(1)}`)}catch{}}l(t),g_t(e.sessionId,t)},d=(0,R.useMemo)(()=>{if(!e.hasJsonl)return null;let n=e.model&&e.model!==`unknown`&&e.model!==`specialist`?e.model:void 0,r=n?void 0:a[LR(e)??``]??void 0,i=e.presence===`ended`?e.endedAt??e.startedAt??new Date().toISOString():e.endedAt??null;return{id:-1,name:e.sessionId,tmuxSession:e.tmuxSession||e.sessionId,status:e.presence===`ended`?`ended`:`active`,cwd:``,issueId:t||null,createdAt:e.startedAt,endedAt:i,lastAttachedAt:null,sessionAlive:e.presence!==`ended`,sessionFile:e.sessionId,model:n??r,deliveryMethod:e.deliveryMethod??null,harness:e.harness}},[e,t,a]),f=!!e.hasJsonl,p=!!e.transcript,m=e.tmuxSession||(e.presence===`active`?e.sessionId:void 0),h=!!m&&e.presence!==`ended`,g=e.presence===`ended`,_=(0,R.useMemo)(()=>v_t(e.roundMetadata),[e.roundMetadata]),v=_.length>0,y=(0,R.useRef)(null),b=(0,R.useRef)(!0),x=(0,R.useRef)(null),S=(0,R.useCallback)(()=>{let e=y.current;e&&(b.current=e.scrollHeight-e.clientHeight-e.scrollTop<48)},[]);return(0,R.useLayoutEffect)(()=>{let t=y.current;if(!t||(x.current!==e.sessionId&&(x.current=e.sessionId,b.current=!0),!b.current))return;t.scrollTop=t.scrollHeight;let n=requestAnimationFrame(()=>{y.current&&(y.current.scrollTop=y.current.scrollHeight)});return()=>cancelAnimationFrame(n)},[e.sessionId,e.transcript,c]),(0,z.jsxs)(`div`,{className:J.sessionPanel,children:[(0,z.jsxs)(`div`,{className:J.sessionPanelHeader,children:[e.awaitingInput&&(0,z.jsx)(e_t,{kinds:[`askUserQuestion`]}),(0,z.jsx)(b_t,{sessionId:e.sessionId}),(0,z.jsxs)(`div`,{className:J.sessionPanelToggle,children:[(f||!i)&&(0,z.jsx)(`button`,{className:`${J.sessionPanelToggleBtn} ${c===`conversation`?J.sessionPanelToggleBtnActive:``}`,onClick:()=>u(`conversation`),children:`Conversation`}),i&&(0,z.jsx)(`button`,{className:`${J.sessionPanelToggleBtn} ${c===`findings`?J.sessionPanelToggleBtnActive:``}`,onClick:()=>u(`findings`),children:`Summary`}),!i&&v&&(0,z.jsx)(`button`,{className:`${J.sessionPanelToggleBtn} ${c===`findings`?J.sessionPanelToggleBtnActive:``}`,onClick:()=>u(`findings`),children:`Findings`}),(0,z.jsx)(`button`,{className:`${J.sessionPanelToggleBtn} ${c===`terminal`?J.sessionPanelToggleBtnActive:``}`,onClick:()=>u(`terminal`),children:`Terminal`})]}),(0,z.jsxs)(`button`,{className:`${J.conversationAboutToggle} ${o?J.conversationAboutToggleActive:``}`,onClick:s,title:o?`Show tool calls`:`Hide tool calls`,"aria-label":o?`Show tool calls`:`Hide tool calls`,"aria-pressed":o,children:[(0,z.jsx)(Rr,{size:14}),(0,z.jsx)(`span`,{children:`Tools`})]}),e.deliveryMethod!==void 0&&(0,z.jsx)(x_t,{sessionId:e.sessionId,deliveryMethod:e.deliveryMethod})]}),(0,z.jsxs)(`div`,{className:J.sessionPanelContent,children:[c===`conversation`&&(f&&d?(0,z.jsx)(s5,{conversation:d,viewMode:`conversation`,roundMarkers:n,roundMetadata:e.roundMetadata,embedded:!0,agentId:e.sessionId,hideToolCalls:o,onToggleHideToolCalls:s}):p?(0,z.jsx)(`div`,{ref:y,onScroll:S,className:J.sessionPanelTranscript,children:(0,z.jsx)(WY,{text:e.transcript,isStreaming:!1,cwd:void 0})}):(0,z.jsx)(`div`,{className:J.sessionPanelEmpty,children:`No conversation data available for this session.`})),c===`findings`&&i&&(0,z.jsx)(f_t,{session:e,reviewers:r??[],roundData:_}),c===`findings`&&!i&&(0,z.jsx)(`div`,{style:{padding:16,display:`flex`,flexDirection:`column`,gap:12,overflowY:`auto`},children:_.length===0?(0,z.jsx)(`div`,{className:J.sessionPanelEmpty,children:`No review rounds recorded.`}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{style:{fontSize:12,fontWeight:600,color:`var(--muted-foreground)`,textTransform:`uppercase`,letterSpacing:`0.04em`},children:`Review rounds`}),(0,z.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:10},children:_.map(t=>(0,z.jsx)(a_t,{round:t,active:t.round===e.roundMetadata?.latestRound},t.round))}),e.roundMetadata?.history.map(e=>e.summary?(0,z.jsxs)(`div`,{style:{borderTop:`1px solid var(--border)`,paddingTop:12},children:[(0,z.jsxs)(`div`,{style:{fontSize:11,fontWeight:600,color:`var(--muted-foreground)`,marginBottom:6},children:[`Round `,e.round,` — `,e.status]}),(0,z.jsx)(WY,{text:e.summary,isStreaming:!1,cwd:void 0})]},`summary-${e.round}`):null)]})}),c===`terminal`&&(e.harness===`ohmypi`||e.harness===`pi`?(0,z.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 px-8 py-10 text-center`,children:[(0,z.jsxs)(`div`,{className:`relative`,children:[(0,z.jsx)(Uee,{className:`h-9 w-9 text-muted-foreground/40`}),(0,z.jsx)(`span`,{className:`absolute -bottom-1 -right-1 flex h-4 w-4 items-center justify-center rounded-full bg-card text-[10px] font-bold text-muted-foreground/60`,children:`×`})]}),(0,z.jsx)(`div`,{className:`text-sm font-semibold text-foreground`,children:`No live terminal for this agent`}),(0,z.jsxs)(`p`,{className:`max-w-sm text-xs leading-relaxed text-muted-foreground`,children:[`Pi agents run in `,(0,z.jsx)(`span`,{className:`rounded bg-muted px-1 py-0.5 font-mono text-[11px]`,children:`--mode rpc`}),` — there is no interactive terminal, so this pane would only stream raw JSON-RPC protocol. Use the `,(0,z.jsx)(`strong`,{className:`text-foreground`,children:`Conversation`}),` tab, which renders the same transcript as readable messages.`]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>u(`conversation`),className:`mt-1 inline-flex items-center gap-1.5 rounded-md border border-border bg-card px-3 py-1.5 text-xs font-medium text-foreground hover:bg-muted transition-colors`,children:[(0,z.jsx)(See,{className:`h-3.5 w-3.5`}),`Open Conversation`]})]}):h&&m?(0,z.jsx)(IS,{sessionName:m}):(0,z.jsx)(`div`,{className:J.sessionPanelEmpty,children:g?`Session ended`:`No terminal session available.`}))]})]})}function C_t({pane:e,ctx:t}){let n=FH(e=>e.updatePane),r=t.resolveAgentPane?.(e);if(r?.session)return(0,z.jsx)(S_t,{session:r.session,issueId:e.issueId??t.workspaceId});if(r?.conversation){let i=e.viewMode===`terminal`?`terminal`:`conversation`;return(0,z.jsx)(s5,{conversation:r.conversation,viewMode:i,onViewModeChange:r=>n(t.workspaceId,e.paneId,{viewMode:r}),targetMessageId:e.targetMessageId,targetMessageIndex:e.targetMessageIndex,targetMessageNonce:e.targetMessageNonce,onTargetMessageHandled:()=>n(t.workspaceId,e.paneId,{targetMessageId:void 0,targetMessageIndex:void 0,targetMessageNonce:void 0})})}return e.agentId||e.conversationId||e.isRunning?(0,z.jsxs)(`div`,{className:Q.placeholder,children:[(0,z.jsxs)(`div`,{className:Q.placeholderTitle,children:[(0,z.jsx)(ar,{size:14,className:`inline-block animate-spin align-[-2px] mr-1.5`}),`Starting...`]}),(0,z.jsx)(`div`,{className:Q.placeholderHint,children:`Waiting for the agent conversation to become available.`})]}):(0,z.jsx)(`div`,{className:Q.placeholder,children:`Agent conversation unavailable.`})}async function w_t(e){let t=await fetch(`/api/agents/${encodeURIComponent(e)}/diffs/vs-main`);if(!t.ok)throw Error(`diff fetch failed: ${t.status}`);return(await t.json()).files??[]}function T_t({pane:e,ctx:t}){let n=e.agentId??t.agentId,r=FH(e=>e.setActivePane),{data:i=[],isLoading:a,isError:o}=B({queryKey:[`stage-files-vs-main`,n],queryFn:()=>w_t(n),enabled:!!n});if(!n)return(0,z.jsx)(`div`,{className:Q.placeholder,children:`No agent workspace to inspect.`});if(a)return(0,z.jsx)(`div`,{className:Q.placeholder,children:`Loading changed files…`});if(o)return(0,z.jsx)(`div`,{className:Q.placeholder,children:`Couldn’t load changed files.`});if(i.length===0)return(0,z.jsx)(`div`,{className:Q.placeholder,children:`No changed files vs main.`});let s=()=>{let i=(FH.getState().panesByWorkspace[t.workspaceId]??[]).find(t=>t.paneType===`commits`&&t.issueId===e.issueId);i?r(t.workspaceId,i.paneId):t.openPane({paneType:`commits`,label:`Commits`,issueId:e.issueId,agentId:n})};return(0,z.jsx)(`div`,{className:Q.filesPane,children:i.map(e=>(0,z.jsxs)(`button`,{type:`button`,className:Q.fileRow,onClick:s,children:[(0,z.jsx)(jn,{size:14}),(0,z.jsx)(`span`,{className:Q.filePath,children:e.path}),(e.additions!=null||e.deletions!=null)&&(0,z.jsxs)(`span`,{className:Q.fileStat,children:[(0,z.jsxs)(`span`,{className:Q.chipAdd,children:[`+`,e.additions??0]}),` `,(0,z.jsxs)(`span`,{className:Q.chipDel,children:[`−`,e.deletions??0]})]})]},e.path))})}function E_t(e){if(!e)return null;try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`?t.href:null}catch{return null}}function D_t({pane:e}){let t=E_t(e.browserInitialUrl);return t?(0,z.jsx)(`iframe`,{className:Q.browserFrame,src:t,title:e.label,sandbox:`allow-scripts allow-forms allow-popups`}):(0,z.jsx)(`div`,{className:Q.placeholder,children:`No web page to display.`})}var O_t={home:`Home`,issue:`Issue`,agent:`Agent`,terminal:`Terminal`,files:`Files`,commits:`Commits`,plan:`Plan`,docs:`Docs`,browser:`Web`};function k_t({pane:e}){return(0,z.jsxs)(`div`,{className:Q.placeholder,"data-pane-type":e.paneType,children:[(0,z.jsx)(`div`,{className:Q.placeholderTitle,children:e.label}),(0,z.jsxs)(`div`,{className:Q.placeholderHint,children:[`This `,e.paneType,` pane is not implemented yet.`]})]})}function A_t(e,t){switch(e.paneType){case`terminal`:return(0,z.jsx)(m9e,{pane:e,ctx:t});case`commits`:return(0,z.jsx)(k9e,{pane:e,ctx:t});case`plan`:return(0,z.jsx)(j9e,{pane:e,ctx:t});case`docs`:return(0,z.jsx)(ttt,{pane:e,ctx:t});case`agent`:return(0,z.jsx)(C_t,{pane:e,ctx:t});case`files`:return(0,z.jsx)(T_t,{pane:e,ctx:t});case`browser`:return(0,z.jsx)(D_t,{pane:e,ctx:t});default:return(0,z.jsx)(k_t,{pane:e,ctx:t})}}function j_t({deckKey:e,conversations:t=[],resolveSession:n,terminalCwd:r,onCreateConversation:i,renderHome:a,renderIssue:o,onActiveConversationChange:s}){let c=FH(e=>e.ensureHome),l=FH(e=>e.addPane),u=FH(e=>e.closePane),d=FH(e=>e.setActivePane),f=FH(K4e(e)),p=FH(q4e(e)),m=p??``,h=JJ(t=>qJ(t.terminalStateByThreadId,e).terminalOpen),g=JJ(e=>e.setTerminalOpen),_=(0,R.useCallback)(()=>g(e,!h),[g,e,h]);(0,R.useEffect)(()=>{c(e)},[e,c]),(0,R.useEffect)(()=>{let t=FH.getState().panesByWorkspace[e]??[],n=new Set,r=new Set([`files`,`commits`,`plan`,`docs`]);for(let i of t){if(i.paneType===`terminal`){u(e,i.paneId);continue}if(r.has(i.paneType)&&!i.issueId){u(e,i.paneId);continue}i.paneType===`agent`&&i.conversationId&&(n.has(i.conversationId)?u(e,i.paneId):n.add(i.conversationId))}},[e,u]),l9e(e);let v=(0,R.useCallback)(t=>l(e,t),[l,e]),y=(0,R.useCallback)((t,n)=>l(e,{paneType:t,label:O_t[t],...t===`terminal`?{terminalId:n?.terminalId??null}:{}}),[l,e]),b=(0,R.useCallback)((t,n)=>{let r=(FH.getState().panesByWorkspace[e]??[]).find(e=>e.paneType===`agent`&&e.conversationId===t);r?d(e,r.paneId):l(e,{paneType:`agent`,label:n,conversationId:t})},[e,d,l]),x=(0,R.useCallback)((t,n)=>{let r=(FH.getState().panesByWorkspace[e]??[]).find(e=>e.paneType===`issue`&&e.issueId===t);r?d(e,r.paneId):l(e,{paneType:`issue`,label:n,issueId:t})},[e,d,l]),S=(0,R.useMemo)(()=>({deckKey:e,openPane:v,openTypedPane:y,openIssue:x,openOrFocusAgentPane:b,toggleTerminal:_}),[e,v,y,x,b,_]),C=(0,R.useMemo)(()=>({workspaceId:e,openPane:v,resolveAgentPane:e=>{if(e.agentId&&n){let t=n(e.agentId);if(t)return{session:t}}if(!e.conversationId)return;let r=t.find(t=>t.name===e.conversationId);return r?{conversation:r}:void 0}}),[e,v,t,n]),w=`pan-layout:${e}`,[T,E]=(0,R.useState)(null);(0,R.useEffect)(()=>{try{let t=localStorage.getItem(`pan-layout:${e}`),n=t?JSON.parse(t):null;E(MJ(n)&&EJ(n)>1?n:null)}catch{E(null)}},[e]);let D=(0,R.useCallback)(e=>{let t=e&&EJ(e)>1?e:null;E(t);try{t?localStorage.setItem(w,JSON.stringify(t)):localStorage.removeItem(w)}catch{}},[w]),O=(0,R.useCallback)(t=>{if(T&&EJ(T)>1&&!TJ(T,t)){let e=wJ(T),n=e.includes(m)?m:e[0];n&&D(AJ(T,n,t))}d(e,t)},[T,m,e,d,D]),k=(0,R.useCallback)(t=>u(e,t),[u,e]),A=bJ(null,()=>{}),[j,M]=(0,R.useState)(null),[N,P]=(0,R.useState)(null),F=(0,R.useCallback)((e,n)=>{n.preventDefault();let r=Math.min(n.clientY,window.innerHeight-360),i=Math.min(n.clientX,window.innerWidth-240);e.paneType===`agent`&&e.conversationId&&t.some(t=>t.name===e.conversationId)?M({conversationName:e.conversationId,paneId:e.paneId,top:r,left:i}):P({paneId:e.paneId,permanent:e.paneType===`home`||!!e.isPermanent,top:r,left:i})},[t]),I=(0,R.useCallback)((e,n)=>{let r=t.find(e=>e.name===n)?.id??n;window.open(`/popout/conversation/${r}`,`_blank`,`popup=yes,width=920,height=1040`)},[t]),ee=(0,R.useCallback)(()=>_(),[_]),te=(0,R.useMemo)(()=>{let t=[];return i&&t.push({key:`conversation`,label:`New conversation`,icon:Yt,onSelect:()=>{i(`claude-code`).then(e=>{e&&b(e,`Agent`)})}}),t.push({key:`terminal`,label:`New terminal`,icon:Pr,onSelect:()=>g(e,!0)}),t.push({key:`web`,label:`Web`,icon:Jn,onSelect:()=>v({paneType:`browser`,label:`Web`})}),t},[i,b,g,e,v]),ne=(0,R.useMemo)(()=>f.filter(e=>e.paneType!==`terminal`).map(e=>{if(e.paneType!==`agent`)return e;if(e.agentId&&!e.conversationId){let t=n?.(e.agentId)?.role??n?.(e.agentId)?.type,r=t?t.charAt(0).toUpperCase()+t.slice(1):null,i=r?e.issueId?`${r} · ${e.issueId.toUpperCase()}`:r:e.label;return i===e.label?e:{...e,label:i}}let r=t.find(t=>t.name===e.conversationId)?.title?.trim(),i=!r||r.toLowerCase()===`new conversation`?`Chat ${(e.conversationId??``).split(`-`).pop()??``}`.trim():r;return i===e.label?e:{...e,label:i}}),[f,t,n]),L=ne.find(e=>e.paneId===p)??ne[0]??null,re=(0,R.useCallback)(e=>e.paneType===`home`?a(S):e.paneType===`issue`?o(e.issueId??``,S):A_t(e,C),[a,o,S,C]),ie=z7e(T),ae=(0,R.useMemo)(()=>new Map(ne.map(e=>[e.paneId,e])),[ne]),oe=(0,R.useMemo)(()=>T?wJ(T):[],[T]),se=ie?oe.includes(m)?m:oe[0]??null:null;(0,R.useEffect)(()=>{if(!T)return;let e=kJ(T,new Set(ne.map(e=>e.paneId)));wJ(T).join(`,`)!==(e?wJ(e).join(`,`):``)&&D(e)},[T,ne,D]);let ce=(0,R.useCallback)((t,n)=>{if(T&&EJ(T)>1){if(TJ(T,t)){d(e,t);return}let r=oe.includes(m)?m:oe[0];if(!r)return;D(DJ(T,r,t,n))}else{if(!m||t===m)return;D({kind:`split`,dir:n,a:CJ(m),b:CJ(t),ratio:.5})}d(e,t)},[T,oe,m,e,d,D]),le=(0,R.useCallback)(t=>{if(!T)return;let n=OJ(T,t);if(n&&EJ(n)>1)D(n),m===t&&d(e,wJ(n)[0]);else{let t=n?wJ(n)[0]:m;D(null),t&&d(e,t)}},[T,m,e,d,D]),ue=(0,R.useCallback)((e,t)=>{D(T?jJ(T,e,t):null)},[T,D]),[de,fe]=(0,R.useState)(null),pe=(0,R.useCallback)((t,n,r)=>{let i=T??(L?CJ(L.paneId):null);if(!i)return;if(r===`center`){if(n===t)return;if(TJ(i,n)){d(e,n);return}D(AJ(i,t,n)),d(e,n);return}if(n===t)return;let a=r===`left`||r===`right`?`row`:`col`,o=r===`left`||r===`top`;D(DJ(TJ(i,n)?OJ(i,n)??i:i,t,n,a,o)),d(e,n)},[T,L,e,d,D]),me=T??(L?CJ(L.paneId):null),he=(0,R.useCallback)(()=>{let t=FH.getState().panesByWorkspace[e]??[];for(let n of t)!n.isPermanent&&n.paneType!==`home`&&u(e,n.paneId);D(null)},[e,u,D]);(0,R.useEffect)(()=>{L?.paneType===`agent`&&L.conversationId&&s?.(L.conversationId)},[L?.paneId,L?.paneType,L?.conversationId,s]);let ge=j?t.find(e=>e.name===j.conversationName)??null:null;return(0,z.jsxs)(`div`,{className:Q.stage,children:[(0,z.jsx)(V7e,{panes:ne,activePaneId:L?.paneId??p,onSelect:O,onClose:k,onAdd:ee,newActions:te,onPaneContextMenu:F,onTabDragStart:fe,onTabDragEnd:()=>fe(null),onTabDetach:I}),(0,z.jsx)(`div`,{className:Q.paneArea,children:me&&(0,z.jsx)(SJ,{node:me,path:[],panesById:ae,renderPaneContent:re,focusedPaneId:se,showHeaders:ie,draggingPaneId:de,onFocus:t=>d(e,t),onCloseLeaf:le,onRatioChange:ue,onDropTab:pe})}),h&&(0,z.jsx)(p9e,{threadId:e,cwd:r}),j&&ge&&(0,z.jsx)(I7e,{conversation:ge,mutations:A,position:{top:j.top,left:j.left},onClose:()=>M(null),onCloseTab:()=>u(e,j.paneId),onOpenInSplit:()=>ce(j.paneId,`row`),onSplitDown:()=>ce(j.paneId,`col`),onCloseOthers:()=>{let t=FH.getState().panesByWorkspace[e]??[];for(let n of t)n.paneId!==j.paneId&&!n.isPermanent&&n.paneType!==`home`&&u(e,n.paneId)},onCloseRight:()=>{let t=FH.getState().panesByWorkspace[e]??[],n=t.findIndex(e=>e.paneId===j.paneId);if(!(n<0))for(let r of t.slice(n+1))!r.isPermanent&&r.paneType!==`home`&&u(e,r.paneId)},onCloseAll:he}),N&&(0,z.jsx)(L7e,{position:{top:N.top,left:N.left},onClose:()=>P(null),onOpenInSplit:()=>ce(N.paneId,`row`),onSplitDown:()=>ce(N.paneId,`col`),onCloseTab:N.permanent?void 0:()=>u(e,N.paneId),onCloseAll:he}),A.forkTarget&&(0,z.jsx)(uJ,{conversation:A.forkTarget,initialMode:A.forkTargetMode,initialFocus:A.forkTargetFocus,isPending:A.isForkPending,onClose:A.closeForkModal,onConfirm:(e,t,n,r,i,a,o,s,c,l,u,d,f)=>{A.submitFork(e,t,n,r,i,a,o,s,c,l,u,d,f)}})]})}var M_t=[`header`,`launcher`,`agentDock`,`actionDock`,`detail`,`timeline`],N_t=[`header`,`detail`,`launcher`,`agentDock`,`actionDock`,`timeline`];function P_t(e){let t=e.detailFirst?N_t:M_t;return(0,z.jsx)(`div`,{className:e.wide?`${Q.home} ${Q.homeWide}`:Q.home,children:t.map(t=>(0,z.jsx)(`section`,{"data-section":t,className:Q.homeSection,children:e[t]},t))})}function F_t({name:e,branch:t,iconLabel:n,onSetParent:r,variant:i=`issue`}){let a=i===`project`;return(0,z.jsxs)(`div`,{className:Q.wsHead,children:[(0,z.jsx)(`div`,{className:Q.wsTitle,children:a?(0,z.jsxs)(`h3`,{className:Q.wsName,children:[(0,z.jsx)(`span`,{className:Q.wsHash,children:`#`}),` `,e]}):(0,z.jsxs)(z.Fragment,{children:[n&&(0,z.jsx)(`span`,{className:Q.wsIcon,children:n}),(0,z.jsx)(`h3`,{className:Q.wsName,children:e})]})}),(0,z.jsxs)(`div`,{className:Q.wsBranch,children:[t&&(0,z.jsxs)(`span`,{className:Q.wsBranchName,children:[(0,z.jsx)(Hn,{size:13}),` `,t]}),r&&(0,z.jsx)(`button`,{type:`button`,className:Q.wsLink,onClick:r,children:`↗ set parent`})]})]})}var I_t=864e5;function L_t(e){if(e==null)return null;let t=typeof e==`number`?e:Date.parse(e);return Number.isFinite(t)?t:null}function R_t(e){let t=L_t(e.createdAt),n=e.now??Date.now(),r=`—`;if(t!=null&&n>=t){let e=Math.floor((n-t)/I_t);r=e===0?`today`:e===1?`1 day`:`${e} days`}return{ageLabel:r,additions:e.additions??0,deletions:e.deletions??0,filesChanged:e.filesChanged??0,conversationCount:e.conversationCount??0}}function z_t(e){let t=R_t(e);return(0,z.jsxs)(`div`,{className:Q.stats,"data-testid":`home-stats`,children:[(0,z.jsxs)(`span`,{className:Q.chip,children:[(0,z.jsx)(hn,{size:13}),` `,t.ageLabel]}),(0,z.jsxs)(`span`,{className:Q.chip,children:[(0,z.jsx)(Bt,{size:13}),` `,(0,z.jsxs)(`span`,{className:Q.chipAdd,children:[`+`,t.additions]}),` `,(0,z.jsxs)(`span`,{className:Q.chipDel,children:[`−`,t.deletions]})]}),(0,z.jsxs)(`span`,{className:Q.chip,children:[(0,z.jsx)(Mn,{size:13}),` `,t.filesChanged,` files`]}),(0,z.jsxs)(`span`,{className:Q.chip,children:[(0,z.jsx)(cr,{size:13}),` `,t.conversationCount,` convos`]}),e.costUsd!=null&&(e.onCostClick?(0,z.jsxs)(`button`,{type:`button`,className:Q.chip,onClick:e.onCostClick,title:`View cost breakdown`,"data-testid":`home-cost-chip`,children:[(0,z.jsx)(wn,{size:13}),` $`,e.costUsd.toFixed(2)]}):(0,z.jsxs)(`span`,{className:Q.chip,"data-testid":`home-cost-chip`,children:[(0,z.jsx)(wn,{size:13}),` $`,e.costUsd.toFixed(2)]}))]})}function B_t(e){let t=e.toLowerCase();return t===`ohmypi`||t===`pi`||t.includes(`pi-`)?`ohmypi`:t.includes(`claude`)||t.includes(`anthropic`)?`claude-code`:t.includes(`codex`)||t.includes(`openai`)||t.includes(`gpt`)?`codex`:null}function V_t({id:e,size:t=14}){let n=B_t(e);return n?(0,z.jsx)(`span`,{className:Q.agentLogo,style:{width:t,height:t},children:(0,z.jsx)(hE,{harness:n,className:Q.agentLogoSvg})}):(0,z.jsx)(Yt,{"data-testid":`agent-icon-bot`,size:t})}function H_t(e){let t=e.trim();return!t||/\s/.test(t)?!1:/^(https?:\/\/|www\.)/i.test(t)?!0:/^[^\s/]+\.[a-z]{2,}([/?#].*)?$/i.test(t)}function U_t(e,t){let n=e.findIndex(t);if(n<=0)return e;let r=e.slice(),[i]=r.splice(n,1);return r.unshift(i),r}function W_t({intents:e,query:t,lastUsedAgentId:n}){return H_t(t)?U_t(e,e=>e.kind===`web`):n&&n!==`claude-code`?U_t(e,e=>e.kind===`agent`&&e.id===n):e}var G_t=e=>`pan-launcher-agent:${e}`;function K_t(e){try{return localStorage.getItem(G_t(e))}catch{return null}}function l5(e,t){try{localStorage.setItem(G_t(e),t)}catch{}}var q_t=[{id:`claude-code`,kind:`agent`,agentName:`Claude Code`,keys:`⌘↵`},{id:`terminal`,kind:`terminal`,keys:`⌃↵`},{id:`web`,kind:`web`,keys:`⌥↵`},{id:`codex`,kind:`agent`,agentName:`Codex`,keys:`⌘⇧↵`}];function J_t(e){switch(e.kind){case`terminal`:return`Run in terminal:`;case`web`:return`Search the web:`;case`agent`:return`Ask ${e.agentName??`agent`}:`}}function Y_t({kind:e,id:t,label:n}){return e===`agent`?(0,z.jsx)(V_t,{id:t,label:n,size:14}):(0,z.jsx)(e===`terminal`?Pr:Jn,{size:14})}function X_t({intents:e=q_t,onSelect:t,compact:n=!1,extras:r,placeholder:i=`Ask, run, or search…`,lastUsedAgentId:a}){let[o,s]=(0,R.useState)(``),[c,l]=(0,R.useState)(0),u=o.length>0,d=W_t({intents:e,query:o,lastUsedAgentId:a}),f=e=>{let n=d[e];n&&t?.(n,o)},p=e=>{e&&t?.(e,o)};return(0,z.jsxs)(`div`,{className:Q.launcher,children:[(0,z.jsx)(`div`,{className:Q.launchBar,children:(0,z.jsx)(`input`,{className:Q.launchInput,value:o,placeholder:i,onChange:e=>{s(e.target.value),l(0)},onKeyDown:e=>{if(u){if(e.key===`ArrowDown`){e.preventDefault(),l(e=>Math.min(e+1,d.length-1));return}if(e.key===`ArrowUp`){e.preventDefault(),l(e=>Math.max(e-1,0));return}e.key===`Enter`&&(e.metaKey&&e.shiftKey?(e.preventDefault(),p(d.find(e=>e.id===`codex`))):e.metaKey?(e.preventDefault(),p(d[0])):e.ctrlKey?(e.preventDefault(),p(d.find(e=>e.kind===`terminal`))):e.altKey?(e.preventDefault(),p(d.find(e=>e.kind===`web`))):f(c))}}})}),u&&(0,z.jsxs)(`div`,{className:Q.dropdown,role:`listbox`,"aria-label":`Quick actions`,children:[d.map((e,t)=>(0,z.jsxs)(`div`,{role:`option`,"aria-selected":t===c,className:`${Q.ddRow} ${t===c?Q.ddRowSel:``}`,onMouseEnter:()=>l(t),onMouseDown:e=>{e.preventDefault(),f(t)},children:[(0,z.jsx)(`span`,{className:Q.gicon,children:(0,z.jsx)(Y_t,{kind:e.kind,id:e.id,label:e.agentName})}),(0,z.jsxs)(`span`,{className:Q.ddLab,children:[(0,z.jsx)(`b`,{children:J_t(e)}),` `,o]}),e.keys&&(0,z.jsx)(`span`,{className:Q.ddKeys,children:e.keys})]},e.id)),!n&&r]})]})}var Z_t=[{id:`claude-code`,label:`Claude Code`},{id:`codex`,label:`Codex`}];function u5({agents:e=Z_t,onSelectAgent:t,onMore:n}){return(0,z.jsxs)(`div`,{className:Q.dock,role:`group`,"aria-label":`Agents`,children:[e.map(e=>(0,z.jsxs)(`button`,{type:`button`,className:Q.pill,onClick:()=>t(e.id),children:[(0,z.jsx)(V_t,{id:e.id,label:e.label,size:14}),e.label]},e.id)),(0,z.jsxs)(`button`,{type:`button`,className:`${Q.pill} ${Q.pillGhost}`,onClick:()=>n?.(),children:[(0,z.jsx)(gr,{size:13}),`More Agents`]})]})}var Q_t=[`terminal`,`files`,`browser`,`commits`,`plan`,`docs`];function d5({onOpen:e,actions:t=Q_t}){let[n,r]=(0,R.useState)(!1),i=e=>t.includes(e),a=i(`plan`)||i(`docs`);return(0,z.jsxs)(`div`,{className:`${Q.dock} ${Q.actionDock}`,role:`group`,"aria-label":`Actions`,children:[i(`terminal`)&&(0,z.jsxs)(`button`,{type:`button`,className:`${Q.pill} ${Q.pillTool}`,onClick:()=>e(`terminal`),children:[(0,z.jsx)(Pr,{size:14}),`Terminal`]}),i(`files`)&&(0,z.jsxs)(`button`,{type:`button`,className:`${Q.pill} ${Q.pillTool}`,onClick:()=>e(`files`),children:[(0,z.jsx)(jn,{size:14}),`Files`]}),i(`browser`)&&(0,z.jsxs)(`button`,{type:`button`,className:`${Q.pill} ${Q.pillTool}`,onClick:()=>e(`browser`),children:[(0,z.jsx)(Jn,{size:14}),`Web`]}),i(`commits`)&&(0,z.jsxs)(`button`,{type:`button`,className:`${Q.pill} ${Q.pillTool}`,onClick:()=>e(`commits`),children:[(0,z.jsx)(Un,{size:14}),`Commits`]}),a&&(0,z.jsxs)(`button`,{type:`button`,className:`${Q.pill} ${Q.pillGhost}`,"aria-expanded":n,onClick:()=>r(e=>!e),children:[(0,z.jsx)(gr,{size:13}),`Actions`]}),a&&n&&(0,z.jsxs)(`div`,{className:Q.actionOverflow,role:`menu`,children:[i(`plan`)&&(0,z.jsxs)(`button`,{type:`button`,role:`menuitem`,className:Q.actionOverflowItem,onClick:()=>e(`plan`),children:[(0,z.jsx)(rr,{size:14}),`Plan`]}),i(`docs`)&&(0,z.jsxs)(`button`,{type:`button`,role:`menuitem`,className:Q.actionOverflowItem,onClick:()=>e(`docs`),children:[(0,z.jsx)(Mn,{size:14}),`Docs`]})]})]})}var $_t=864e5,evt=[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],tvt=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`];function f5(e){if(e==null)return 0;let t=typeof e==`number`?e:Date.parse(e);return Number.isFinite(t)?t:0}function nvt(e){let t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}function rvt(e,t){let n=Math.round((nvt(t)-nvt(e))/$_t);if(n<=0)return`Today`;if(n===1)return`Yesterday`;if(n<7)return evt[new Date(e).getDay()];let r=new Date(e);return`${tvt[r.getMonth()]} ${r.getDate()}`}function ivt(e,t){if(!Number.isFinite(e)||e<=0)return`—`;let n=Math.max(0,Math.floor((t-e)/1e3));if(n<60)return`just now`;let r=Math.floor(n/60);if(r<60)return`${r}m ago`;let i=Math.floor(r/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function avt(e,t){let n=[...e].sort((e,t)=>f5(t.timestamp)-f5(e.timestamp)),r=[];for(let e of n){let n=rvt(f5(e.timestamp),t),i=r[r.length-1];i&&i.label===n?i.items.push(e):r.push({label:n,items:[e]})}return r}function p5({conversations:e,onOpen:t,now:n=Date.now()}){let r=(0,R.useMemo)(()=>avt(e,n),[e,n]);return e.length===0?(0,z.jsx)(`div`,{className:Q.timelineEmpty,children:`No conversations yet.`}):(0,z.jsx)(`div`,{className:Q.timeline,children:r.map(e=>(0,z.jsxs)(`section`,{className:Q.timelineGroup,children:[(0,z.jsx)(`h4`,{className:Q.timelineLabel,children:e.label}),e.items.map(e=>(0,z.jsxs)(`button`,{type:`button`,className:Q.timelineCard,onClick:()=>t(e.id),children:[(0,z.jsxs)(`div`,{className:Q.timelineCardHead,children:[(0,z.jsxs)(`span`,{className:Q.timelineAgentWrap,children:[(0,z.jsx)(`span`,{className:Q.timelineModelIcon,children:(0,z.jsx)(gE,{provider:ovt(e),label:e.model??e.harness??`model`})}),(0,z.jsx)(`span`,{className:Q.timelineAgent,children:e.agentLabel??`Agent`})]}),(0,z.jsx)(`span`,{className:Q.timelineTime,children:ivt(f5(e.timestamp),n)})]}),e.model&&(0,z.jsx)(`div`,{className:Q.timelineModel,children:svt(e.model)}),e.preview&&(0,z.jsx)(`div`,{className:Q.timelinePreview,children:e.preview})]},e.id))]},e.items[0]?.id??e.label))})}function ovt(e){let t=e.model?.toLowerCase()??``,n=e.harness?.toLowerCase()??``;return t.startsWith(`claude`)||n===`claude-code`?`anthropic`:t.startsWith(`gpt`)||t.startsWith(`o`)||n===`codex`?`openai`:t.includes(`gemini`)?`google`:t.includes(`kimi`)?`kimi`:t.includes(`minimax`)?`minimax`:t.includes(`zai`)||t.includes(`glm`)?`zai`:t.includes(`mimo`)?`mimo`:t.includes(`nous`)?`nous`:t.includes(`dashscope`)||t.includes(`qwen`)?`dashscope`:t.includes(`/`)||n===`ohmypi`||n===`pi`?`openrouter`:`openai`}function svt(e){return e.replace(/-20\d{6}$/,``).replace(/-/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function cvt(e,t,n){switch(e.kind){case`terminal`:n.openTerminal(t);return;case`web`:n.openWeb(t,lvt(t));return;case`agent`:n.onAgentRun?.(e.id),n.openAgent(e,t)}}function lvt(e){let t=e.trim();return H_t(t)?/^https?:\/\//i.test(t)?t:`https://${t}`:`https://www.google.com/search?q=${encodeURIComponent(t)}`}var uvt={PAN:`eltmon/overdeck`,KRUX:`eltmon/krux`};function dvt(e,t){if(t)return t;let n=/^([A-Za-z]+)-(\d+)$/.exec(e.trim());if(!n)return null;let r=uvt[n[1].toUpperCase()];return r?`https://github.com/${r}/issues/${n[2]}`:null}var fvt={todo:`text-muted-foreground`,ready:`text-info-foreground`,plan:`text-signal-review-foreground`,work:`text-info-foreground`,review:`text-warning-foreground`,verifying:`text-info-foreground`,ship:`text-signal-review-foreground`,done:`text-success-foreground`};function pvt(e){switch(e){case`todo`:return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`circle`,{cx:`7`,cy:`7`,r:`4.5`}),(0,z.jsx)(`path`,{d:`M5 7h4`})]});case`ready`:return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`circle`,{cx:`7`,cy:`7`,r:`4.5`}),(0,z.jsx)(`path`,{d:`M6 5.2 9 7l-3 1.8Z`})]});case`plan`:return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`path`,{d:`M3.5 10.5V3.8c0-.7.5-1.1 1.2-.8l5.8 2.4c.7.3.7 1.2 0 1.5L4.7 9.3c-.7.3-1.2-.1-1.2-.8`}),(0,z.jsx)(`path`,{d:`M3.5 10.5v1.5`})]});case`work`:return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`path`,{d:`M2.5 8.2 5.2 11 11.5 4`}),(0,z.jsx)(`path`,{d:`M2.5 4h4`})]});case`review`:return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`path`,{d:`M7 2.5 12 5v3.4c0 2.1-1.9 3.3-5 4-3.1-.7-5-1.9-5-4V5l5-2.5Z`}),(0,z.jsx)(`path`,{d:`M5 7h4`})]});case`verifying`:return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`circle`,{cx:`7`,cy:`7`,r:`4.5`}),(0,z.jsx)(`path`,{d:`M7 4v3.5l2.5 1.5`})]});case`ship`:return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`path`,{d:`M7 2.5 10.5 6H8.2v3.2H5.8V6H3.5L7 2.5Z`}),(0,z.jsx)(`path`,{d:`M3.5 11.5h7`})]});case`done`:return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`circle`,{cx:`7`,cy:`7`,r:`4.8`}),(0,z.jsx)(`path`,{d:`m4.8 7.2 1.4 1.4 3-3.2`})]})}}function mvt({phase:e,className:t,...n}){return(0,z.jsx)(`svg`,{"aria-hidden":`true`,"data-component":`phase-glyph`,"data-phase":e,viewBox:`0 0 14 14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,className:vj(`h-[14px] w-[14px] shrink-0`,fvt[e],t),...n,children:pvt(e)})}var hvt={pipeline:`14px 78px 14px minmax(96px, 1.6fr) minmax(0, 220px) minmax(0, 84px) 30px`,"command-deck":`14px 78px 14px minmax(96px, 1.6fr) minmax(0, 220px) minmax(0, 84px) 26px`},gvt={pipeline:`gap-[14px] py-[10px] pl-[18px] pr-[22px]`,"command-deck":`gap-[12px] py-[9px] pl-[18px] pr-[22px]`},_vt={urgent:`before:bg-destructive`,high:`before:bg-warning`,medium:`before:bg-[rgb(255_255_255_/_22%)]`,low:`before:bg-transparent`},vvt=[`bg-primary text-primary-foreground`,`bg-warning text-warning-foreground`,`bg-success text-success-foreground`,`bg-info text-info-foreground`,`bg-destructive text-destructive-foreground`];function yvt(e){let t=0;for(let n=0;n<e.length;n+=1)t=t*31+e.charCodeAt(n)>>>0;return t}function bvt(e){let t=e.trim().split(/\s+/).filter(Boolean);return(t.length>1?`${t[0][0]}${t[1][0]}`:e.slice(0,2)).toUpperCase()}function xvt({issueId:e,trackerUrl:t,phase:n,priority:r,title:i,project:a,labels:o=[],verbBadge:s,trailingBadge:c,agent:l,ledger:u,assignee:d,variant:f=`pipeline`,onOpen:p,onContextMenu:m,actionMenu:h,className:g}){let _=d?.name??e,v=vvt[yvt(_)%vvt.length],y=!!(u?.runtime||u?.cost),b=!!l?.name,x=h?`${hvt[f]} 30px`:hvt[f],S=()=>p?.(e);return(0,z.jsxs)(`div`,{role:`button`,tabIndex:0,"data-component":`issue-row`,"data-issue-id":e,"data-phase":n,"data-priority":r,"data-variant":f,className:vj(`group relative grid w-full items-center border-b border-border text-left transition-colors duration-200 last:border-b-0 hover:bg-accent before:absolute before:bottom-[8px] before:left-[10px] before:top-[8px] before:w-[2px] before:rounded-[2px]`,gvt[f],_vt[r],g),style:{gridTemplateColumns:x},onClick:S,onKeyDown:e=>{e.target===e.currentTarget&&(e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),S()))},onContextMenu:e=>{m&&(e.preventDefault(),e.stopPropagation(),m())},children:[(0,z.jsx)(`span`,{"aria-hidden":`true`}),(()=>{let n=dvt(e,t),r=`truncate font-mono text-[11px] leading-none tracking-[0.02em] text-muted-foreground`;return n?(0,z.jsx)(`a`,{href:n,target:`_blank`,rel:`noopener noreferrer`,title:`Open ${e} on its tracker`,onClick:e=>e.stopPropagation(),className:vj(r,`hover:text-foreground hover:underline`),children:e}):(0,z.jsx)(`span`,{className:r,children:e})})(),(0,z.jsx)(mvt,{phase:n}),(0,z.jsxs)(`span`,{className:`min-w-0`,children:[(0,z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-[8px]`,children:[(0,z.jsx)(`span`,{className:`truncate text-[13px] leading-none text-foreground`,children:i}),s&&(0,z.jsx)(`span`,{className:`shrink-0`,children:s}),c&&(0,z.jsx)(`span`,{className:`shrink-0`,children:c})]}),(0,z.jsxs)(`span`,{className:`mt-[7px] flex min-w-0 flex-wrap items-center gap-[6px] text-[11px] leading-none text-muted-foreground`,children:[a&&(0,z.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-[6px]`,children:[(0,z.jsx)(`span`,{className:vj(`h-[14px] w-[14px] shrink-0 rounded-[3px] bg-muted`,a.markClassName)}),(0,z.jsx)(`span`,{className:`truncate`,children:a.name})]}),a&&o.length>0&&(0,z.jsx)(`span`,{className:`h-[3px] w-[3px] rounded-full bg-muted-foreground/50`}),o.map((e,t)=>(0,z.jsx)(`span`,{className:`rounded-[var(--radius-sm)] border border-border bg-muted px-[6px] py-[1px] text-[10px] font-medium leading-none text-muted-foreground`,children:e},t))]})]}),(0,z.jsxs)(`span`,{className:`min-w-0 font-mono leading-none`,children:[(0,z.jsx)(`span`,{"data-component":`issue-row-agent-name`,className:vj(`block truncate text-[11px]`,b?`text-foreground`:`font-sans italic text-muted-foreground`),children:l?.name??`Unassigned`}),(0,z.jsx)(`span`,{className:`mt-[3px] block truncate text-[10px] text-muted-foreground`,children:l?.sub??`—`})]}),(0,z.jsxs)(`span`,{"data-component":`issue-row-ledger`,className:vj(`min-w-0 text-right font-mono leading-none [font-variant-numeric:tabular-nums]`,!y&&`opacity-55`),children:[(0,z.jsx)(`span`,{className:`block truncate text-[11px] text-muted-foreground`,children:u?.runtime??`—`}),(0,z.jsx)(`span`,{className:`mt-[2px] block truncate text-[10px] text-signal-cost-foreground`,children:u?.cost??`—`})]}),(0,z.jsx)(`span`,{"data-component":`issue-row-avatar`,className:vj(`flex h-[22px] w-[22px] items-center justify-center rounded-full border border-border text-[9px] font-semibold leading-none`,v),children:bvt(_)}),h?(0,z.jsx)(`span`,{"data-component":`issue-row-action-menu`,className:`opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100`,onClick:e=>e.stopPropagation(),children:h}):null]})}var Svt={ship:`Ship`,review:`Review`,verifying:`Verifying`,work:`Work`,plan:`Plan`,ready:`Ready`,todo:`Todo`},Cvt={ship:`border-t-success`,review:`border-t-warning`,verifying:`border-t-info`,work:`border-t-info`,plan:`border-t-signal-review`,ready:`border-t-info`,todo:`border-t-[rgb(255_255_255_/_15%)]`},wvt={ship:`bg-success`,review:`bg-warning`,verifying:`bg-info`,work:`bg-info`,plan:`bg-signal-review`,ready:`bg-info`,todo:`bg-muted-foreground/30`},Tvt={pipeline:`px-[22px] pt-[12px] pb-[10px]`,"command-deck":`px-[22px] pt-[10px] pb-[8px]`};function Evt(e){return e}function Dvt({phase:e,count:t,variant:n=`pipeline`,title:r,subLine:i,rightMeta:a,className:o}){return(0,z.jsxs)(`div`,{"data-component":`phase-header`,"data-phase":e,"data-variant":n,className:vj(`sticky top-0 z-[2] flex items-center gap-[12px] border-b border-t-2 border-b-border bg-background/95 backdrop-blur-[6px]`,Cvt[e],Tvt[n],o),children:[(0,z.jsx)(`span`,{className:vj(`h-[8px] w-[8px] rounded-full`,wvt[e])}),(0,z.jsx)(mvt,{phase:Evt(e)}),(0,z.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-[8px]`,children:[(0,z.jsx)(`span`,{className:`truncate text-[14px] font-medium leading-none text-foreground`,children:r??Svt[e]}),(0,z.jsx)(`span`,{className:`rounded-[var(--radius-sm)] bg-accent px-[6px] py-[1px] text-[11px] leading-none text-muted-foreground`,children:t}),i&&(0,z.jsx)(`span`,{className:`ml-[4px] truncate text-[12px] leading-none text-muted-foreground`,children:i})]}),a&&(0,z.jsx)(`div`,{className:`ml-auto min-w-0 font-mono text-[11px] leading-none text-muted-foreground [font-variant-numeric:tabular-nums]`,children:a})]})}var Ovt=[`ship`,`review`,`work`,`plan`,`todo`],kvt=new Set([`active`,`running`,`starting`]),Avt=new Set([`failed`,`blocked`]),m5=new Set([`failed`,`dispatch_failed`]),h5=new Set([`failed`]),g5=new Set([`failed`]);function jvt(e){return e.sessions?.some(e=>e.type===`work`&&e.presence===`active`)??!1}function Mvt(e){return e.sessions?.some(e=>e.type===`work`)??!1}function _5(e){return jvt(e)||kvt.has(e.agentStatus??``)}function Nvt(e,t){return e.readyForMerge?{...t??{issueId:e.issueId},readyForMerge:t?.readyForMerge??!0}:t}function Pvt(e){let t=`${e.status} ${e.stateLabel}`.toLowerCase();return t.includes(`verifying`)?`verifying_on_main`:t.includes(`review`)?`in_review`:t.includes(`progress`)||_5(e)?`in_progress`:t.includes(`done`)||t.includes(`complete`)?`done`:t.includes(`cancel`)?`canceled`:e.status}function Fvt(e,t){let n=Pvt(e);return{status:e.status,state:n,stateType:n===`done`?`completed`:n===`canceled`?`canceled`:void 0,hasPlan:e.hasPlanning,planningComplete:e.hasPlanning&&!Mvt(e),mergeStatus:t?.mergeStatus,labels:[]}}function Ivt(e){return _5(e)?{role:`work`,status:`running`}:null}function Lvt(e,t){let n=Nvt(e,t);return _h(Fvt(e,n),n,Ivt(e))}function Rvt(e,t){return t[e.issueId]??t[e.issueId.toUpperCase()]??t[e.issueId.toLowerCase()]}function v5(e,t){return!!(e.agentStatus===`failed`||t?.stuck||(t?.blockerReasons?.length??0)>0||Avt.has(t?.reviewStatus??``)||m5.has(t?.testStatus??``)||h5.has(t?.mergeStatus??``)||g5.has(t?.verificationStatus??``))}function zvt(e,t){return(e?.blockerReasons??[]).some(e=>t.has(e.type))}var y5=new Set([`failing_checks`]),Bvt=new Set([`merge_conflict`,`not_mergeable`,`draft_pr`]),Vvt=4;function Hvt(e){return!!(zvt(e,y5)||m5.has(e?.testStatus??``)||g5.has(e?.verificationStatus??``))}function Uvt(e){return!!(zvt(e,Bvt)||h5.has(e?.mergeStatus??``))}function b5(e){switch(e){case`failing_checks`:return`Checks`;case`merge_conflict`:return`Merge conflict`;case`not_mergeable`:return`Not mergeable`;case`draft_pr`:return`Draft PR`;case`test_status`:return`Test gate`;case`verification_status`:return`Verification`;case`merge_status`:return`Merge`;default:return`Blocker`}}function Wvt({feature:e,reviewStatus:t}){let n=[];for(let r of t?.blockerReasons??[])!y5.has(r.type)&&!Bvt.has(r.type)||n.push({issueId:e.issueId,title:e.title,label:b5(r.type),summary:r.summary,details:r.details,tone:y5.has(r.type)?`bad`:`warn`});return n.length>0?n:(m5.has(t?.testStatus??``)&&n.push({issueId:e.issueId,title:e.title,label:b5(`test_status`),summary:t?.testStatus===`dispatch_failed`?`Test dispatch failed`:`Test failed`,tone:`bad`}),g5.has(t?.verificationStatus??``)&&n.push({issueId:e.issueId,title:e.title,label:b5(`verification_status`),summary:`Verification failed`,details:t?.verificationNotes,tone:`bad`}),h5.has(t?.mergeStatus??``)&&n.push({issueId:e.issueId,title:e.title,label:b5(`merge_status`),summary:`Merge failed`,details:t?.mergeNotes,tone:`warn`}),n)}function Gvt(e){let t=new Set((e?.blockerReasons??[]).map(e=>e.type));return t.has(`merge_conflict`)||t.has(`not_mergeable`)||t.has(`draft_pr`)?`MERGE BLOCKED`:t.has(`failing_checks`)?`CI BLOCKED`:t.has(`changes_requested`)||t.has(`unresolved_conversations`)?`CHANGES REQUESTED`:h5.has(e?.mergeStatus??``)?`MERGE BLOCKED`:m5.has(e?.testStatus??``)?`CI BLOCKED`:`CHANGES REQUESTED`}function Kvt(e,t){let n=new Set(t.map(e=>e.issueId.split(`-`)[0]?.toUpperCase()).filter(Boolean));if(n.size===0)return 0;let r=0;for(let[t,i]of Object.entries(e)){if(t!==t.toUpperCase())continue;let e=t.split(`-`)[0]?.toUpperCase();e&&n.has(e)&&(r+=i)}return r}function qvt({projectKey:e}){let t=_t(),{data:n}=B({queryKey:[`project-auto-merge-default`,e],queryFn:async()=>{let t=await fetch(`/api/projects/${encodeURIComponent(e)}/auto-merge-default`);return t.ok?t.json():{value:null}},enabled:!!e}),r=n?.value??null,i=Nt({mutationFn:async t=>{let n=await fetch(`/api/projects/${encodeURIComponent(e)}/auto-merge-default`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({value:t})});if(!n.ok)throw Error(`Failed to save project setting`);return n.json()},onSuccess:()=>t.invalidateQueries({queryKey:[`project-auto-merge-default`,e]})});return(0,z.jsxs)(`div`,{style:{border:`1px solid var(--border)`,borderRadius:10,padding:14,display:`flex`,flexDirection:`column`,gap:8},children:[(0,z.jsx)(`div`,{style:{fontSize:11,fontWeight:650,textTransform:`uppercase`,letterSpacing:`0.04em`,color:`var(--muted-foreground)`},children:`Project settings`}),(0,z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10,flexWrap:`wrap`},children:[(0,z.jsx)(`span`,{style:{fontSize:13,color:`var(--foreground)`},children:`Auto-merge default`}),(0,z.jsx)(`div`,{style:{display:`inline-flex`,border:`1px solid var(--border)`,borderRadius:8,overflow:`hidden`},children:[{v:`auto`,label:`⚡ Auto`,color:`var(--success)`},{v:`hold`,label:`🔒 Hold for UAT`,color:`var(--warning)`},{v:null,label:`Global default`,color:`var(--muted-foreground)`}].map((e,t)=>{let n=r===e.v;return(0,z.jsx)(`button`,{type:`button`,disabled:i.isPending,onClick:()=>i.mutate(e.v),style:{appearance:`none`,border:0,borderLeft:t===0?0:`1px solid var(--border)`,padding:`6px 12px`,fontSize:12,fontWeight:600,cursor:`pointer`,background:n?`color-mix(in srgb, ${e.color} 16%, transparent)`:`transparent`,color:n?e.color:`var(--muted-foreground)`},children:e.label},String(e.v))})})]}),(0,z.jsx)(`div`,{style:{fontSize:11,color:`var(--muted-foreground)`},children:`Applies to this project's issues that have no explicit per-issue auto-merge setting.`})]})}function Jvt({projectName:e,projectKey:t,features:n,issueCosts:r,issueCostDetails:i,collapsePipelineSections:a=!0,onSelectFeature:o}){let s=sm(e=>e.reviewStatusByIssueId),c=(0,R.useMemo)(()=>Kvt(r,n),[n,r]),l=(0,R.useMemo)(()=>{let e=new Set(n.map(e=>e.issueId.split(`-`)[0]?.toUpperCase()).filter(Boolean));return e.size===1?[...e][0]:null},[n]),{data:u}=B({queryKey:[`project-recent-spend`,l],queryFn:async()=>{let e=await fetch(`/api/costs/summary?project=${encodeURIComponent(l)}`);if(!e.ok)throw Error(`Failed to fetch project spend`);return e.json()},enabled:!!l,refetchInterval:6e4}),d=u?.week?.totalCost??null,f=(0,R.useMemo)(()=>n.filter(_5).length,[n]),p=(0,R.useMemo)(()=>n.map(e=>{let t=Rvt(e,s);return{feature:e,reviewStatus:t,phase:Lvt(e,t)}}),[n,s]),m=(0,R.useMemo)(()=>{let e=new Map;for(let t of Ovt)e.set(t,[]);for(let t of p)e.get(t.phase)?.push(t);return e},[p]),h=(0,R.useMemo)(()=>{let e=p.filter(({reviewStatus:e})=>Hvt(e)).length,t=p.filter(({reviewStatus:e})=>Uvt(e)).length,n=p.filter(({feature:e,phase:t,reviewStatus:n})=>t===`ship`&&(e.readyForMerge||n?.readyForMerge)&&!v5(e,n)).length,r=p.filter(({feature:e})=>_5(e)).length,i=p.flatMap(Wvt);return{failingChecks:e,mergeBlocked:t,shipReadyClear:n,workRunning:r,errors:i.slice(0,Vvt),hiddenErrorCount:Math.max(0,i.length-Vvt)}},[p]),g=(0,R.useMemo)(()=>{let e=p.filter(({phase:e})=>e===`ship`).length,t=p.filter(e=>v5(e.feature,e.reviewStatus)).length;return[{label:`Active issues`,value:n.length,sub:`in pipeline`,tone:`info`},{label:`Stuck`,value:t,sub:t>0?`need attention`:`all clear`,tone:t>0?`destructive`:`muted`},{label:`Agents`,value:f,sub:`running now`,tone:`success`},{label:`Ship-ready`,value:e,sub:`awaiting merge`,tone:`success`},d==null?{label:`Spend`,value:S5(c),sub:`project total`,tone:`cost`}:{label:`Spend`,value:S5(d),sub:`last 7 days`,tone:`cost`}]},[f,p,n.length,c,d]);return(0,z.jsxs)(`section`,{"aria-label":`${e} project overview`,style:{display:`flex`,flexDirection:`column`,gap:10,padding:12,overflow:`auto`},children:[(0,z.jsx)(tyt,{projectName:e,metrics:g}),(0,z.jsx)(Qvt,{health:h}),t&&(0,z.jsx)($vt,{title:`Project settings`,summary:`Auto-merge default and project-level merge policy`,badges:[`collapsed`],children:(0,z.jsx)(qvt,{projectKey:t})}),(0,z.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:14},children:Ovt.map(e=>{let t=m.get(e)??[];if(t.length===0)return null;let n=t.filter(e=>v5(e.feature,e.reviewStatus)).length;return a?(0,z.jsx)($vt,{title:Yvt(e),summary:Xvt(e,t.length,n),badges:Zvt(e,t.length,n),children:(0,z.jsx)(nyt,{phase:e,entries:t,issueCosts:r,issueCostDetails:i,onSelectFeature:o})},e):(0,z.jsx)(nyt,{phase:e,entries:t,issueCosts:r,issueCostDetails:i,onSelectFeature:o,flat:!0},e)})})]})}function Yvt(e){switch(e){case`ship`:return`Ship`;case`review`:return`Review`;case`work`:return`Work`;case`plan`:return`Plan`;case`todo`:return`Todo`;case`verifying`:return`Verifying`;default:return e}}function Xvt(e,t,n){return n>0?`${n} blocked`:e===`work`?`${t} active implementation lane${t===1?``:`s`}`:e===`review`?`${t} review lane${t===1?``:`s`}`:`${t} issue${t===1?``:`s`}`}function Zvt(e,t,n){let r=[`${t}`];return n>0&&r.push(`${n} blocked`),e===`work`&&r.push(`work`),r}function Qvt({health:e}){let t=e.failingChecks>0||e.mergeBlocked>0,n=t?`Needs attention`:`Clear`;return(0,z.jsxs)(`section`,{"aria-label":`Current CI health`,style:{border:`1px solid var(--border)`,borderRadius:10,background:`var(--card)`,overflow:`hidden`},children:[(0,z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:12,padding:`10px 12px`},children:[(0,z.jsxs)(`div`,{style:{minWidth:0},children:[(0,z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,fontSize:13,fontWeight:700,color:`var(--foreground)`},children:[(0,z.jsx)(`span`,{"aria-hidden":`true`,style:{width:8,height:8,borderRadius:`999px`,background:t?`var(--warning)`:`var(--success)`,flex:`0 0 auto`}}),`Current CI health`]}),(0,z.jsxs)(`div`,{style:{marginTop:3,fontSize:12,color:`var(--muted-foreground)`},children:[e.failingChecks,` failing checks · `,e.mergeBlocked,` merge blocked · `,e.shipReadyClear,` ship-ready clear`]})]}),(0,z.jsx)(`span`,{style:{flex:`0 0 auto`,border:`1px solid var(--border)`,borderRadius:999,padding:`4px 9px`,fontSize:12,fontWeight:700,color:t?`var(--warning)`:`var(--success)`,background:t?`color-mix(in srgb, var(--warning) 12%, transparent)`:`color-mix(in srgb, var(--success) 12%, transparent)`},children:n})]}),(0,z.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(auto-fit, minmax(90px, 1fr))`,gap:8,borderTop:`1px solid var(--border)`,padding:10,background:`var(--background)`},children:[(0,z.jsx)(x5,{label:`Required checks`,value:`${e.failingChecks} failing`,tone:e.failingChecks>0?`bad`:`good`}),(0,z.jsx)(x5,{label:`Mergeability`,value:`${e.mergeBlocked} blocked`,tone:e.mergeBlocked>0?`warn`:`good`}),(0,z.jsx)(x5,{label:`Ship-ready`,value:`${e.shipReadyClear} clear`,tone:`good`}),(0,z.jsx)(x5,{label:`Work agents`,value:`${e.workRunning} running`,tone:e.workRunning>0?`good`:`neutral`})]}),e.errors.length>0&&(0,z.jsxs)(`div`,{style:{borderTop:`1px solid var(--border)`,padding:`9px 12px 11px`,display:`flex`,flexDirection:`column`,gap:7},children:[(0,z.jsx)(`div`,{style:{fontSize:11,fontWeight:700,color:`var(--foreground)`},children:`Blocking details`}),e.errors.map(e=>(0,z.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`8px minmax(0, 1fr)`,gap:8,alignItems:`start`},children:[(0,z.jsx)(`span`,{"aria-hidden":`true`,style:{width:7,height:7,marginTop:5,borderRadius:999,background:e.tone===`bad`?`var(--destructive)`:`var(--warning)`}}),(0,z.jsxs)(`div`,{style:{minWidth:0,display:`flex`,flexDirection:`column`,gap:2},children:[(0,z.jsxs)(`div`,{style:{minWidth:0,display:`flex`,alignItems:`baseline`,gap:7},children:[(0,z.jsxs)(`span`,{style:{flex:`0 0 auto`,fontSize:11,fontWeight:750,color:`var(--foreground)`},children:[`Issue `,e.issueId]}),(0,z.jsx)(`span`,{style:{minWidth:0,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,fontSize:10,fontWeight:650,color:`var(--muted-foreground)`},children:e.label})]}),(0,z.jsxs)(`div`,{style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,fontSize:11,color:`var(--foreground)`},title:e.summary,children:[`Problem: `,e.summary]}),e.details&&(0,z.jsx)(`div`,{style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,fontSize:10,color:`var(--muted-foreground)`},title:e.details,children:e.details}),(0,z.jsxs)(`div`,{style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,fontSize:10,color:`var(--muted-foreground)`},title:e.title,children:[`Feature: `,e.title]})]})]},`${e.issueId}-${e.label}-${e.summary}`)),e.hiddenErrorCount>0&&(0,z.jsxs)(`div`,{style:{paddingLeft:16,fontSize:10,color:`var(--muted-foreground)`},children:[`+`,e.hiddenErrorCount,` more blocker`,e.hiddenErrorCount===1?``:`s`]})]})]})}function x5({label:e,value:t,tone:n}){return(0,z.jsxs)(`div`,{style:{border:`1px solid var(--border)`,borderRadius:8,padding:`7px 8px`,background:`var(--card)`},children:[(0,z.jsx)(`div`,{style:{fontSize:10,color:`var(--muted-foreground)`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e}),(0,z.jsx)(`div`,{style:{marginTop:3,fontSize:12,fontWeight:700,color:n===`bad`?`var(--destructive)`:n===`warn`?`var(--warning)`:n===`good`?`var(--success)`:`var(--foreground)`},children:t})]})}function $vt({title:e,summary:t,badges:n,defaultOpen:r=!1,children:i}){return(0,z.jsxs)(`details`,{open:r,style:{border:`1px solid var(--border)`,borderRadius:10,background:`var(--card)`,overflow:`hidden`},children:[(0,z.jsxs)(`summary`,{style:{cursor:`pointer`,display:`grid`,gridTemplateColumns:`1fr auto`,alignItems:`center`,gap:10,padding:`11px 12px`,listStyle:`none`},children:[(0,z.jsxs)(`span`,{style:{minWidth:0,display:`flex`,alignItems:`baseline`,gap:8},children:[(0,z.jsx)(`span`,{style:{fontSize:13,fontWeight:700,color:`var(--foreground)`},children:e}),(0,z.jsx)(`span`,{style:{minWidth:0,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,fontSize:12,color:`var(--muted-foreground)`},children:t})]}),n&&n.length>0&&(0,z.jsx)(`span`,{style:{display:`flex`,gap:6,flexWrap:`wrap`,justifyContent:`flex-end`},children:n.map(e=>(0,z.jsx)(`span`,{style:{border:`1px solid var(--border)`,borderRadius:999,padding:`2px 7px`,background:`var(--secondary)`,color:`var(--foreground)`,fontSize:11,fontWeight:650,whiteSpace:`nowrap`},children:e},e))})]}),(0,z.jsx)(`div`,{style:{borderTop:`1px solid var(--border)`,padding:12,background:`var(--background)`},children:i})]})}var eyt={info:`var(--info-foreground)`,success:`var(--success-foreground)`,warning:`var(--warning-foreground)`,destructive:`var(--destructive-foreground)`,cost:`var(--signal-cost-foreground)`,muted:`var(--foreground)`};function tyt({projectName:e,metrics:t}){return(0,z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:10},children:[(0,z.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,z.jsx)(`h2`,{style:{margin:0,fontSize:15,fontWeight:700,color:`var(--foreground)`},children:e}),(0,z.jsx)(`span`,{style:{fontSize:11,color:`var(--muted-foreground)`},children:`pipeline overview`})]}),(0,z.jsx)(`div`,{style:{display:`grid`,gridTemplateColumns:`repeat(auto-fill, minmax(96px, 1fr))`,gap:6},children:t.map(e=>(0,z.jsxs)(`div`,{style:{border:`1px solid var(--border)`,borderRadius:10,padding:`7px 9px`,background:`color-mix(in srgb, white 1.5%, transparent)`},children:[(0,z.jsx)(`div`,{style:{fontSize:10,textTransform:`uppercase`,letterSpacing:`0.05em`,color:`var(--muted-foreground)`},children:e.label}),(0,z.jsx)(`div`,{style:{marginTop:2,fontSize:17,fontWeight:600,fontFamily:`"SF Mono", Consolas, monospace`,fontVariantNumeric:`tabular-nums`,color:eyt[e.tone]},children:e.value}),e.sub&&(0,z.jsx)(`div`,{style:{marginTop:1,fontSize:10,color:`var(--muted-foreground)`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e.sub})]},e.label))})]})}function nyt({phase:e,entries:t,issueCosts:n,issueCostDetails:r,onSelectFeature:i,flat:a=!1}){return(0,z.jsxs)(`section`,{"aria-label":`${e} pipeline phase`,"data-component":`command-deck-pipeline-phase`,"data-phase":e,style:{border:a?`none`:`1px solid var(--border)`,borderRadius:a?0:14,padding:a?0:14,background:a?`transparent`:`var(--card)`},children:[(0,z.jsx)(Dvt,{phase:e,count:t.length,variant:`command-deck`,className:`static`}),(0,z.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:a?6:0,border:a?`none`:`1px solid var(--border)`,borderTop:a?`none`:`1px solid var(--border)`,borderRadius:a?0:12,overflow:a?`visible`:`hidden`,background:a?`transparent`:`var(--card)`},children:t.map(e=>(0,z.jsx)(oyt,{entry:e,issueCosts:n,issueCostDetails:r,onSelectFeature:i,reason:hyt(e)},e.feature.issueId))})]})}function ryt(e){return v5(e.feature,e.reviewStatus)?{variant:Gvt(e.reviewStatus)}:e.phase===`ship`&&(e.reviewStatus?.readyForMerge||e.feature.readyForMerge)?{variant:`READY TO MERGE`}:e.phase===`ship`?{variant:`SHIP RUNNING`}:e.phase===`review`?{variant:`REVIEW RUNNING`}:e.phase===`work`?{variant:`WORK RUNNING`}:e.phase===`plan`?{variant:`PLANNING`}:{variant:`QUEUED FOR PLAN`}}function iyt(e){return e.readyForMerge?`high`:e.agentStatus===`failed`?`urgent`:_5(e)?`high`:`medium`}function ayt(e){let t=e.sessions?.find(e=>e.presence===`active`)??e.sessions?.[0];return t?.sessionId?{name:t.sessionId,sub:[t.type,t.status].filter(Boolean).join(` · `)}:e.agentStatus?{name:e.agentStatus,sub:e.stateLabel}:null}function oyt({entry:e,issueCosts:t,issueCostDetails:n,onSelectFeature:r,reason:i}){let a=t[e.feature.issueId],o=n?.[e.feature.issueId],s=ayt(e.feature);return(0,z.jsx)(xvt,{issueId:e.feature.issueId,phase:e.phase,priority:iyt(e.feature),title:e.feature.title,project:{name:e.feature.projectName},labels:i?[(0,z.jsx)(pyt,{children:i},`reason`)]:[],verbBadge:(0,z.jsx)(qj,{...ryt(e)}),agent:s?{name:s.name,sub:s.sub}:void 0,ledger:a===void 0?void 0:{cost:(0,z.jsx)(syt,{cost:a,details:o})},variant:`command-deck`,onOpen:()=>r(e.feature)})}function syt({cost:e,details:t}){let[n,r]=(0,R.useState)(!1),i=!!t;return(0,z.jsxs)(`span`,{tabIndex:i?0:void 0,onMouseEnter:()=>i&&r(!0),onMouseLeave:()=>i&&r(!1),onFocus:()=>i&&r(!0),onBlur:()=>i&&r(!1),style:{position:`relative`,borderRadius:`999px`,padding:`2px 6px`,fontSize:11,fontWeight:700,color:`var(--success)`,background:`color-mix(in srgb, var(--success) 12%, transparent)`,whiteSpace:`nowrap`},children:[S5(e),t&&n&&(0,z.jsx)(cyt,{details:t})]})}function cyt({details:e}){let t=uyt(e.byModel).map(([e,t])=>({key:e,label:dyt(e),cost:t.cost})),n=uyt(e.byStage).map(([e,t])=>({key:e,label:fyt(e),cost:t.cost}));return(0,z.jsxs)(`span`,{role:`tooltip`,style:{position:`absolute`,right:0,top:`calc(100% + 6px)`,zIndex:30,width:240,border:`1px solid var(--border)`,borderRadius:12,padding:10,background:`var(--popover)`,color:`var(--popover-foreground)`,boxShadow:`var(--shadow-lg)`,display:`flex`,flexDirection:`column`,gap:10},children:[(0,z.jsx)(lyt,{title:`Models`,rows:t}),(0,z.jsx)(lyt,{title:`Stages`,rows:n})]})}function lyt({title:e,rows:t}){return(0,z.jsxs)(`span`,{style:{display:`flex`,flexDirection:`column`,gap:5},children:[(0,z.jsx)(`span`,{style:{fontSize:10,color:`var(--muted-foreground)`,textTransform:`uppercase`,letterSpacing:`0.04em`},children:e}),t.length>0?t.map(e=>(0,z.jsxs)(`span`,{style:{display:`flex`,justifyContent:`space-between`,gap:10,fontSize:11,color:`var(--popover-foreground)`},children:[(0,z.jsx)(`span`,{style:{overflow:`hidden`,textOverflow:`ellipsis`},children:e.label}),(0,z.jsx)(`span`,{style:{color:`var(--success)`,fontVariantNumeric:`tabular-nums`},children:S5(e.cost)})]},e.key)):(0,z.jsx)(`span`,{style:{fontSize:11,color:`var(--muted-foreground)`},children:`No cost data`})]})}function uyt(e){return Object.entries(e??{}).sort(([,e],[,t])=>t.cost-e.cost)}function S5(e){return e>=100?`$${e.toFixed(0)}`:e>=10?`$${e.toFixed(1)}`:e>=.01?`$${e.toFixed(2)}`:e>0?`$${e.toFixed(4)}`:`$0`}function dyt(e){return e.replace(`claude-`,``).replace(/-20\d{6}$/,``).replace(/-/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function fyt(e){return{planning:`Planning`,implementation:`Implementation`,review:`Review`,test:`Testing`,testing:`Testing`,merge:`Merge`,interactive:`Interactive`,other:`Other`,unknown:`Other`}[e]??e.replace(/-/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function pyt({children:e}){return(0,z.jsx)(`span`,{style:{alignSelf:`flex-start`,maxWidth:`100%`,borderRadius:`999px`,padding:`2px 7px`,fontSize:11,color:`var(--muted-foreground)`,background:`var(--muted)`,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`},children:e})}function myt(e){return e?.stuckReason?e.stuckReason:e?.blockerReasons?.[0]?e.blockerReasons[0].summary:e?.reviewStatus===`blocked`?`Review blocked`:e?.reviewStatus===`failed`?`Review failed`:e?.testStatus===`dispatch_failed`?`Test dispatch failed`:e?.testStatus===`failed`?`Tests failed`:e?.mergeStatus===`failed`?`Merge failed`:e?.verificationStatus===`failed`?`Verification failed`:`Needs attention`}function hyt(e){let{reviewStatus:t,phase:n}=e;if(v5(e.feature,t))return myt(t);if(n===`review`&&t?.reviewSubStatuses)return Object.entries(t.reviewSubStatuses).map(([e,t])=>`${e}: ${t}`).join(`, `);if(n===`ship`&&t?.mergeStep)return t.mergeStep;if(n===`review`&&t?.verificationCycleCount&&t.verificationCycleCount>1)return`Cycle ${t.verificationCycleCount}`}function gyt({projectName:e,projectKey:t,branch:n=`main`,conversations:r=[],onCreateConversation:i,features:a,issueCosts:o,issueCostDetails:s,onSelectFeature:c,api:l}){let u=(0,R.useMemo)(()=>r.map(e=>({id:e.name,agentLabel:e.title??e.model??`Agent`,model:e.model,harness:e.harness,timestamp:e.lastAttachedAt??e.createdAt,preview:e.title??void 0})),[r]),d=(0,R.useMemo)(()=>o&&a&&a.length>0?Kvt(o,a):void 0,[o,a]),f=()=>{window.history.pushState({tab:`costs`},``,`/costs`),window.dispatchEvent(new PopStateEvent(`popstate`))},p=async(e,t)=>{l5(l.deckKey,e);let n=await i?.(e,t,`terminal`);n&&l.openOrFocusAgentPane(n,`Agent`)},m=(0,z.jsx)(X_t,{lastUsedAgentId:K_t(l.deckKey),onSelect:(e,t)=>cvt(e,t,{openAgent:(e,t)=>p(e.id,t),openTerminal:()=>l.openTypedPane(`terminal`),openWeb:(e,t)=>l.openPane({paneType:`browser`,label:`Web`,browserInitialUrl:t}),onAgentRun:e=>l5(l.deckKey,e)})});if(a&&a.length>0&&c){let i=(0,z.jsx)(p5,{conversations:u,onOpen:e=>{let t=r.find(t=>t.name===e);l.openOrFocusAgentPane(e,t?.title??`Agent`)}});return(0,z.jsx)(P_t,{workspaceId:l.deckKey,openPane:l.openPane,wide:!0,detailFirst:!0,header:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(F_t,{variant:`project`,name:e,branch:n}),(0,z.jsx)(z_t,{conversationCount:r.length,costUsd:d,onCostClick:f})]}),launcher:m,agentDock:(0,z.jsx)(u5,{onSelectAgent:p}),actionDock:(0,z.jsx)(d5,{actions:[`terminal`,`browser`],onOpen:e=>e===`terminal`?l.toggleTerminal():l.openPane({paneType:`browser`,label:`Web`})}),detail:(0,z.jsxs)(`div`,{className:Q.projectHomeColumns,children:[(0,z.jsx)(`div`,{className:Q.projectHomeStages,children:(0,z.jsx)(Jvt,{projectName:e,projectKey:t,features:a,issueCosts:o??{},issueCostDetails:s,collapsePipelineSections:!1,onSelectFeature:c})}),(0,z.jsx)(`aside`,{className:Q.projectHomeConversations,"aria-label":`Project conversations`,children:i})]})})}return(0,z.jsx)(P_t,{workspaceId:l.deckKey,openPane:l.openPane,header:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(F_t,{variant:`project`,name:e,branch:n}),(0,z.jsx)(z_t,{conversationCount:r.length,costUsd:d,onCostClick:f})]}),launcher:m,agentDock:(0,z.jsx)(u5,{onSelectAgent:p}),actionDock:(0,z.jsx)(d5,{actions:[`terminal`,`browser`],onOpen:e=>e===`terminal`?l.toggleTerminal():l.openPane({paneType:`browser`,label:`Web`})}),timeline:(0,z.jsx)(p5,{conversations:u,onOpen:e=>{let t=r.find(t=>t.name===e);l.openOrFocusAgentPane(e,t?.title??`Agent`)}})})}function _yt(e,t,n=new Date){let r={justNow:[],earlierToday:[],yesterday:[],thisWeek:[],thisMonth:[],older:[]},i=yyt(n);for(let n of e)r[vyt(yyt(t(n)),i)].push(n);return r}function vyt(e,t=new Date){let n=t.getTime()-e.getTime();if(n<=3600*1e3&&n>=0)return`justNow`;if(byt(e,t))return`earlierToday`;let r=new Date(t);return r.setDate(t.getDate()-1),byt(e,r)?`yesterday`:n>=0&&n<=10080*60*1e3?`thisWeek`:e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()?`thisMonth`:`older`}function yyt(e){return e instanceof Date?e:new Date(e)}function byt(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function C5({status:e,className:t=``}){return(0,z.jsx)(`span`,{"data-testid":`action-status-chip`,className:`shrink-0 rounded-full border border-border px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground ${t}`.trim(),children:e})}var xyt={justNow:`Just Now`,earlierToday:`Earlier Today`,yesterday:`Yesterday`,thisWeek:`This Week`,thisMonth:`This Month`,older:`Older`},Syt=[`justNow`,`earlierToday`,`yesterday`,`thisWeek`,`thisMonth`,`older`],Cyt=[];function wyt(e){let t,n;return r=>{let i=r.observationsByIssueId[e]??Cyt;return i===t&&n?n:(t=i,n=i.filter(e=>e.actionStatus!==null).sort((e,t)=>t.timestamp.localeCompare(e.timestamp)),n)}}function Tyt(e){let t,n;return r=>{let i=e.map(e=>r.observationsByIssueId[e]??Cyt);return t!==void 0&&t.length===i.length&&i.every((e,n)=>e===t[n])&&n?n:(t=i,n=i.flat().filter(e=>e.actionStatus!==null).sort((e,t)=>t.timestamp.localeCompare(e.timestamp)),n)}}function Eyt({issueId:e,issueIds:t,now:n=new Date}){let r=sm((0,R.useMemo)(()=>t?Tyt(t):wyt(e??``),[t?t.join(`,`):e??``,t,e])),i=(0,R.useMemo)(()=>_yt(r,e=>e.timestamp,n),[r,n]);return(0,z.jsxs)(`aside`,{"data-testid":`activity-feed-sidebar`,className:`flex h-full min-h-0 flex-col gap-3 p-3`,children:[(0,z.jsxs)(`div`,{className:`shrink-0`,children:[(0,z.jsx)(`h3`,{className:`text-xs font-bold uppercase tracking-widest text-muted-foreground`,children:`Activity`}),(0,z.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground/80`,children:`Recent workspace action updates`})]}),(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:r.length===0?(0,z.jsx)(`div`,{"data-testid":`activity-feed-empty`,className:`rounded-lg border border-dashed border-border p-4 text-center text-xs text-muted-foreground`,children:`No action status updates yet.`}):(0,z.jsx)(`div`,{className:`space-y-4`,children:Syt.map(e=>{let t=i[e];return t.length===0?null:(0,z.jsxs)(`section`,{"data-testid":`activity-feed-bucket-${e}`,children:[(0,z.jsx)(`h4`,{className:`mb-2 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:xyt[e]}),(0,z.jsx)(`ul`,{className:`space-y-1.5`,children:t.map(e=>(0,z.jsx)(`li`,{className:`rounded-lg border border-border bg-card p-2 text-xs`,children:(0,z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,z.jsx)(`span`,{className:`mt-1.5 h-1.5 w-1.5 shrink-0 rounded-full bg-primary`}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`p`,{className:`truncate font-medium text-foreground`,title:e.summary,children:e.summary}),(0,z.jsxs)(`div`,{className:`mt-1 flex min-w-0 items-center gap-1 text-[10px] text-muted-foreground`,children:[e.actionStatus?(0,z.jsx)(C5,{status:e.actionStatus}):null,(0,z.jsxs)(`span`,{className:`truncate`,children:[e.workspaceId,` · `,e.issueId]}),(0,z.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,z.jsx)(`time`,{dateTime:e.timestamp,className:`shrink-0`,children:oM(e.timestamp,n)})]}),(0,z.jsx)(`div`,{className:`mt-1 flex justify-end`,children:(0,z.jsx)(PM,{kind:`memory`})})]})]})},e.id))})]},e)})})})]})}function Dyt({issueId:e}){return(0,z.jsx)(`div`,{"data-testid":`activity-tab`,style:{display:`flex`,flexDirection:`column`,flex:1,minHeight:0},children:(0,z.jsx)(Eyt,{issueId:e})})}function Oyt(e){return e?Object.entries(e).map(([e,t])=>({label:e,cost:t.cost??0,tokens:t.tokens??0})).sort((e,t)=>t.cost-e.cost):[]}function w5(e){return e===0?`$0.00`:e<.01?`<$0.01`:`$${e.toFixed(2)}`}function kyt(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:`${e}`}function Ayt({testid:e,title:t,rows:n,total:r}){let i=Math.max(1e-4,...n.map(e=>e.cost));return(0,z.jsxs)(`section`,{"data-testid":e,style:{background:`var(--card)`,border:`1px solid var(--border)`,borderRadius:8,padding:12,display:`flex`,flexDirection:`column`,gap:8},children:[(0,z.jsxs)(`header`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,fontSize:12,fontWeight:600,color:`var(--muted-foreground)`,textTransform:`uppercase`,letterSpacing:`0.04em`},children:[(0,z.jsx)(`span`,{children:t}),(0,z.jsx)(`span`,{"data-testid":`${e}-total`,style:{color:`var(--foreground)`},children:w5(r)})]}),n.length===0?(0,z.jsx)(`div`,{"data-testid":`${e}-empty`,style:{fontSize:12,color:`var(--muted-foreground)`},children:`No data yet.`}):(0,z.jsx)(`ul`,{style:{margin:0,padding:0,listStyle:`none`,display:`flex`,flexDirection:`column`,gap:4},children:n.map(t=>{let n=t.cost/i*100;return(0,z.jsxs)(`li`,{"data-testid":`${e}-row-${t.label}`,style:{display:`flex`,alignItems:`center`,gap:8,fontSize:12},children:[(0,z.jsx)(`span`,{style:{flex:`0 0 120px`,textTransform:`capitalize`},children:t.label}),(0,z.jsx)(`div`,{style:{flex:1,height:6,background:`var(--accent)`,borderRadius:3,position:`relative`,overflow:`hidden`},children:(0,z.jsx)(`div`,{style:{width:`${n}%`,height:`100%`,background:`var(--primary)`,borderRadius:3}})}),(0,z.jsx)(`span`,{style:{flex:`0 0 80px`,textAlign:`right`,fontVariantNumeric:`tabular-nums`,fontWeight:600},children:w5(t.cost)}),(0,z.jsx)(`span`,{style:{flex:`0 0 60px`,textAlign:`right`,fontSize:11,color:`var(--muted-foreground)`,fontVariantNumeric:`tabular-nums`},children:kyt(t.tokens)})]},t.label)})})]})}function jyt({issueId:e}){let t=yVe(e),{data:n,isLoading:r,isError:i}=Tj(e);if(r||t.isLoading)return(0,z.jsx)(`div`,{"data-testid":`costs-tab-loading`,style:{padding:16,fontSize:12,color:`var(--muted-foreground)`},children:`Loading costs…`});if(i||!n)return(0,z.jsx)(`div`,{"data-testid":`costs-tab-error`,style:{padding:16,fontSize:12,color:`var(--destructive)`},children:`Failed to load costs.`});let a=n,o=Oyt(a.byStage),s=Oyt(a.byModel);return(0,z.jsxs)(`div`,{"data-testid":`costs-tab`,style:{padding:16,display:`flex`,flexDirection:`column`,gap:12,fontSize:13},children:[(0,z.jsxs)(`header`,{style:{display:`flex`,alignItems:`baseline`,justifyContent:`space-between`,gap:8},children:[(0,z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,z.jsx)(`div`,{style:{fontSize:18,fontWeight:700},"data-testid":`costs-total`,children:w5(a.totalCost)}),(0,z.jsxs)(`div`,{"data-testid":`costs-stream-total`,style:{fontSize:11,color:`var(--muted-foreground)`},children:[`Live stream: `,w5(t.issueCost),` · `,t.issueEvents.length,` event`,t.issueEvents.length===1?``:`s`,t.error?` · live updates temporarily unavailable`:``]})]}),(0,z.jsxs)(`div`,{style:{fontSize:12,color:`var(--muted-foreground)`},children:[kyt(a.totalTokens),` tokens · `,a.sessions.length,` session`,a.sessions.length===1?``:`s`]})]}),(0,z.jsx)(Ayt,{testid:`costs-by-stage`,title:`By stage`,rows:o,total:o.reduce((e,t)=>e+t.cost,0)}),(0,z.jsx)(Ayt,{testid:`costs-by-model`,title:`By model`,rows:s,total:s.reduce((e,t)=>e+t.cost,0)})]})}function Myt(e,t){switch(e){case`linear`:return{bg:`color-mix(in srgb, #5e6ad2 18%, transparent)`,fg:`#5e6ad2`,label:`linear`};case`github-issue`:return{bg:`color-mix(in srgb, var(--muted-foreground) 18%, transparent)`,fg:`var(--foreground)`,label:`issue`};case`github-pr-conversation`:return{bg:`color-mix(in srgb, var(--primary) 18%, transparent)`,fg:`var(--primary)`,label:`pr`};case`github-pr-review`:{let e=(t.reviewState??``).toUpperCase();return e===`APPROVED`?{bg:`color-mix(in srgb, var(--success, #10b981) 18%, transparent)`,fg:`var(--success, #10b981)`,label:`approved`}:e===`CHANGES_REQUESTED`?{bg:`color-mix(in srgb, var(--destructive) 18%, transparent)`,fg:`var(--destructive)`,label:`changes`}:e===`DISMISSED`?{bg:`color-mix(in srgb, var(--muted-foreground) 18%, transparent)`,fg:`var(--muted-foreground)`,label:`dismissed`}:{bg:`color-mix(in srgb, var(--primary) 18%, transparent)`,fg:`var(--primary)`,label:`review`}}case`github-pr-review-comment`:return{bg:`color-mix(in srgb, #a855f7 18%, transparent)`,fg:`#a855f7`,label:`inline`};default:return{bg:`var(--muted)`,fg:`var(--muted-foreground)`,label:e}}}function Nyt(e){if(!e)return``;let t=new Date(e).getTime();if(!Number.isFinite(t))return e;let n=(Date.now()-t)/1e3;return n<60?`just now`:n<3600?`${Math.floor(n/60)}m ago`:n<86400?`${Math.floor(n/3600)}h ago`:n<86400*30?`${Math.floor(n/86400)}d ago`:new Date(t).toISOString().slice(0,10)}function Pyt({item:e}){let t=Myt(e.source,e);return(0,z.jsx)(`span`,{"data-testid":`discussion-chip-${e.source}`,style:{background:t.bg,color:t.fg,fontSize:10,fontWeight:600,textTransform:`uppercase`,letterSpacing:`0.04em`,padding:`2px 6px`,borderRadius:4},children:t.label})}function Fyt({item:e}){let t=e.source===`github-pr-review-comment`;return(0,z.jsxs)(`li`,{"data-testid":`discussion-row-${e.id}`,style:{listStyle:`none`,padding:`12px 14px`,borderBottom:`1px solid var(--border)`,display:`flex`,flexDirection:`column`,gap:6,contentVisibility:`auto`,containIntrinsicHeight:`60px`},children:[(0,z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,fontSize:12},children:[(0,z.jsx)(Pyt,{item:e}),(0,z.jsx)(`span`,{style:{fontWeight:600,color:`var(--foreground)`},children:e.author||`unknown`}),(0,z.jsx)(`span`,{style:{color:`var(--muted-foreground)`},children:Nyt(e.createdAt)}),t&&e.filePath&&(0,z.jsxs)(`span`,{"data-testid":`discussion-file-${e.id}`,style:{marginLeft:`auto`,fontFamily:`var(--font-mono, ui-monospace)`,fontSize:11,color:`var(--muted-foreground)`},children:[e.filePath,e.line?`:${e.line}`:``]}),e.url&&!t&&(0,z.jsx)(`a`,{"data-testid":`discussion-link-${e.id}`,href:e.url,target:`_blank`,rel:`noreferrer noopener`,style:{marginLeft:`auto`,fontSize:11,color:`var(--muted-foreground)`,textDecoration:`none`},children:`↗`})]}),(0,z.jsx)(`div`,{style:{fontSize:13,lineHeight:1.5},children:e.body&&e.body.trim()!==``?(0,z.jsx)(WY,{text:e.body,cwd:void 0}):(0,z.jsx)(`span`,{style:{fontStyle:`italic`,color:`var(--muted-foreground)`,fontSize:12},children:`(no body)`})})]})}function Iyt({issueId:e}){let{data:t,isLoading:n,isError:r}=mBe(e),i=(0,R.useMemo)(()=>t?.items?[...t.items].sort((e,t)=>t.createdAt.localeCompare(e.createdAt)):[],[t?.items]);if(n)return(0,z.jsx)(`div`,{"data-testid":`discussions-tab-loading`,style:{padding:16,fontSize:12,color:`var(--muted-foreground)`},children:`Loading discussions…`});if(r)return(0,z.jsxs)(`div`,{"data-testid":`discussions-tab-error`,style:{padding:16,fontSize:12,color:`var(--destructive)`,background:`color-mix(in srgb, var(--destructive) 8%, transparent)`},children:[`Failed to load discussions for `,e,`.`]});let a=t?.errors??[],o=i.length===0;return(0,z.jsxs)(`div`,{"data-testid":`discussions-tab`,style:{display:`flex`,flexDirection:`column`,flex:1,minHeight:0},children:[(0,z.jsx)(`div`,{style:{padding:`10px 14px`,borderBottom:`1px solid var(--border)`,fontSize:12,color:`var(--muted-foreground)`,display:`flex`,alignItems:`center`,gap:8},children:(0,z.jsxs)(`span`,{"data-testid":`discussions-tab-summary`,children:[i.length,` `,i.length===1?`message`:`messages`,t?.prNumber?` · PR #${t.prNumber}`:``]})}),a.length>0&&(0,z.jsx)(`div`,{"data-testid":`discussions-tab-warnings`,style:{padding:`8px 14px`,fontSize:11,color:`var(--destructive)`,background:`color-mix(in srgb, var(--destructive) 8%, transparent)`,borderBottom:`1px solid color-mix(in srgb, var(--destructive) 24%, transparent)`,display:`flex`,flexDirection:`column`,gap:2},children:a.map((e,t)=>(0,z.jsx)(`span`,{"data-testid":`discussions-tab-warning-${t}`,children:e},t))}),o?(0,z.jsxs)(`div`,{"data-testid":`discussions-tab-empty`,style:{padding:16,fontSize:12,color:`var(--muted-foreground)`},children:[`No discussions yet for `,e,`.`]}):(0,z.jsx)(`ul`,{"data-testid":`discussions-tab-feed`,style:{margin:0,padding:0,overflowY:`auto`,flex:1,minHeight:0},children:i.map(e=>(0,z.jsx)(Fyt,{item:e},e.id))})]})}function T5(e){return e.artifact.title||e.artifact.slug}function Lyt(e){if(!e)return`—`;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleDateString([],{month:`2-digit`,day:`2-digit`,year:`2-digit`})}function Ryt(e){return`Made by ${e.artifact.agentRole??`user`} via ${e.artifact.agentHarness??`user`} for ${e.artifact.issueId??e.artifact.workspaceId??`unscoped work`}`}function zyt(e,t){return t===`pending`?e.pendingChanges:t===`unshared`?e.status===`unshared`:t===`published`?e.status===`published`:!0}function Byt(e,t,n){if(n===`title`)return T5(e).localeCompare(T5(t));let r=new Date(e.artifact.publishedAt??e.artifact.createdAt).getTime(),i=new Date(t.artifact.publishedAt??t.artifact.createdAt).getTime();return(Number.isNaN(i)?0:i)-(Number.isNaN(r)?0:r)}function E5({children:e,tone:t}){return(0,z.jsx)(`span`,{"data-testid":`artifact-badge-${t}`,className:vj(`rounded-full border px-[7px] py-[2px] text-[10px] font-medium leading-none`,t===`published`&&`border-success/40 bg-success/10 text-success-foreground`,t===`pending`&&`border-warning/40 bg-warning/10 text-warning-foreground`,t===`unshared`&&`border-muted-foreground/30 bg-muted/40 text-muted-foreground`),children:e})}function Vyt(e,t,n){return e&&{artifacts:e.artifacts.map(e=>e.artifact.slug===t?{...e,artifact:n.artifact,status:`unshared`}:e)}}function Hyt({issueId:e}){let t=_t(),[n,r]=(0,R.useState)(`all`),[i,a]=(0,R.useState)(`recent`),[o,s]=(0,R.useState)(null),c=[`drawer-artifacts`,e],{data:l,isLoading:u,isError:d}=B({queryKey:c,queryFn:async()=>{let t=await fetch(`/api/workspaces/${e}/artifacts`);if(!t.ok)throw Error(`Failed to load artifacts for ${e}`);return t.json()},retry:!1}),f=Nt({mutationFn:async e=>{let t=await fetch(`/api/artifacts/${e}/unshare`,{method:`POST`,headers:await uj()});if(!t.ok)throw Error(`Failed to unshare artifact ${e}`);return{slug:e,response:await t.json()}},onSuccess:({slug:e,response:n})=>{t.setQueryData(c,t=>Vyt(t,e,n))}}),p=(0,R.useMemo)(()=>[...l?.artifacts??[]].filter(e=>zyt(e,n)).sort((e,t)=>Byt(e,t,i)),[l?.artifacts,n,i]),m=async e=>{await navigator.clipboard?.writeText(e.urls.wrapperUrl),s(e.artifact.slug)};return(0,z.jsxs)(`div`,{"data-testid":`drawer-tab-panel-artifacts`,className:`space-y-[14px]`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-[10px] rounded-[var(--radius)] border border-border bg-card p-[12px]`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground`,children:`Artifacts`}),(0,z.jsx)(`div`,{className:`mt-[2px] text-[13px] text-muted-foreground`,children:`Browser-viewable work products for this issue.`})]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-[8px]`,children:[(0,z.jsxs)(`label`,{className:`flex items-center gap-[6px] text-[12px] text-muted-foreground`,children:[`Filter`,(0,z.jsxs)(`select`,{"aria-label":`Filter artifacts`,className:`rounded-[var(--radius-sm)] border border-border bg-background px-[8px] py-[5px] text-[12px] text-foreground`,value:n,onChange:e=>r(e.target.value),children:[(0,z.jsx)(`option`,{value:`all`,children:`All`}),(0,z.jsx)(`option`,{value:`published`,children:`Published`}),(0,z.jsx)(`option`,{value:`pending`,children:`Pending changes`}),(0,z.jsx)(`option`,{value:`unshared`,children:`Unshared`})]})]}),(0,z.jsxs)(`label`,{className:`flex items-center gap-[6px] text-[12px] text-muted-foreground`,children:[`Sort`,(0,z.jsxs)(`select`,{"aria-label":`Sort artifacts`,className:`rounded-[var(--radius-sm)] border border-border bg-background px-[8px] py-[5px] text-[12px] text-foreground`,value:i,onChange:e=>a(e.target.value),children:[(0,z.jsx)(`option`,{value:`recent`,children:`Most recent`}),(0,z.jsx)(`option`,{value:`title`,children:`Title`})]})]})]})]}),u?(0,z.jsx)(`div`,{className:`rounded-[var(--radius)] border border-dashed border-border bg-card/60 p-[18px] text-[13px] text-muted-foreground`,children:`Loading artifacts…`}):d?(0,z.jsx)(`div`,{className:`rounded-[var(--radius)] border border-dashed border-destructive/40 bg-card/60 p-[18px] text-[13px] text-destructive-foreground`,children:`Failed to load artifacts`}):p.length===0?(0,z.jsx)(`div`,{className:`rounded-[var(--radius)] border border-dashed border-border bg-card/60 p-[18px] text-[13px] text-muted-foreground`,children:`No artifacts published for this issue yet.`}):(0,z.jsx)(`div`,{className:`grid gap-[12px] md:grid-cols-2`,"data-testid":`drawer-artifact-grid`,children:p.map(e=>(0,z.jsxs)(`article`,{"data-testid":`drawer-artifact-card-${e.artifact.slug}`,className:`overflow-hidden rounded-[var(--radius)] border border-border bg-card`,children:[(0,z.jsx)(`div`,{className:`aspect-video border-b border-border bg-muted/30`,children:e.thumbnailUrl?(0,z.jsx)(`img`,{src:e.thumbnailUrl,alt:`Thumbnail for ${T5(e)}`,className:`h-full w-full object-cover`}):(0,z.jsx)(`div`,{className:`flex h-full items-center justify-center font-mono text-[11px] text-muted-foreground`,children:e.artifact.slug})}),(0,z.jsxs)(`div`,{className:`space-y-[10px] p-[12px]`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`h3`,{className:`truncate text-[15px] font-medium text-foreground`,title:T5(e),children:T5(e)}),(0,z.jsx)(`div`,{className:`mt-[3px] text-[12px] text-muted-foreground`,"data-testid":`drawer-artifact-maker`,children:Ryt(e)})]}),(0,z.jsxs)(`div`,{className:`grid grid-cols-2 gap-[8px] font-mono text-[10px] text-muted-foreground`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`span`,{className:`block uppercase tracking-[0.08em]`,children:`Created`}),(0,z.jsx)(`span`,{className:`text-foreground`,children:Lyt(e.artifact.createdAt)})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`span`,{className:`block uppercase tracking-[0.08em]`,children:`Workspace`}),(0,z.jsx)(`span`,{className:`text-foreground`,children:e.artifact.workspaceId??`—`})]})]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-[6px]`,children:[e.status===`published`?(0,z.jsx)(E5,{tone:`published`,children:`Published`}):null,e.pendingChanges?(0,z.jsx)(E5,{tone:`pending`,children:`Pending Changes`}):null,e.status===`unshared`?(0,z.jsx)(E5,{tone:`unshared`,children:`Unshared`}):null]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-[8px] pt-[2px]`,children:[(0,z.jsx)(`a`,{href:e.urls.wrapperUrl,target:`_blank`,rel:`noreferrer`,className:`rounded-[var(--radius-sm)] border border-border px-[9px] py-[5px] text-[12px] text-foreground transition-colors hover:bg-accent`,children:`Open Wrapper`}),(0,z.jsx)(`button`,{type:`button`,className:`rounded-[var(--radius-sm)] border border-border px-[9px] py-[5px] text-[12px] text-foreground transition-colors hover:bg-accent`,onClick:()=>void m(e),children:o===e.artifact.slug?`Copied`:`Copy Link`}),(0,z.jsx)(`button`,{type:`button`,className:`rounded-[var(--radius-sm)] border border-border px-[9px] py-[5px] text-[12px] text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,disabled:e.status===`unshared`||f.isPending,onClick:()=>f.mutate(e.artifact.slug),children:`Unshare`})]})]})]},e.artifact.artifactId))})]})}function Uyt(e){return e?e.reviewStatus===`blocked`||e.reviewStatus===`failed`?{tone:`blocked`,title:e.reviewStatus===`blocked`?`Review blocked`:`Review failed`,detail:e.reviewNotes,actionKeys:[`restartReview`,`tell`,`viewPr`]}:e.verificationStatus===`failed`?{tone:`blocked`,title:`Verification failed`,detail:e.verificationNotes,actionKeys:[`recoverReview`,`tell`]}:e.testStatus===`failed`||e.testStatus===`dispatch_failed`?{tone:`blocked`,title:`Tests failed`,detail:e.testNotes,actionKeys:[`reviewTest`,`recoverReview`,`tell`]}:e.mergeStatus===`failed`?{tone:`blocked`,title:`Merge failed`,detail:e.mergeNotes,actionKeys:[`syncMain`,`recoverReview`]}:e.readyForMerge?{tone:`ready`,title:`Ready to merge`,detail:`Review and tests passed — clear to merge.`,actionKeys:[`viewPr`]}:null:null}function Wyt({issueId:e}){let t=wj(e),n=Bj(e),[r,i]=(0,R.useState)(!1),a=Uyt(t.data);if(!a)return null;let o=a.tone===`blocked`,s=a.actionKeys.map(e=>n.all.find(t=>t.action.key===e)).filter(e=>!!e&&e.enabled).slice(0,3),c=t.data?.verificationCycleCount,l=t.data?.verificationMaxCycles,u=a.detail?.trim(),d=(u?.length??0)>160,f=u&&d&&!r?`${u.slice(0,160)}…`:u;return(0,z.jsxs)(`div`,{className:`mt-3.5 flex items-start gap-3 rounded-[14px] border px-3.5 py-3 ${o?`badge-border-destructive badge-bg-destructive`:`badge-border-success badge-bg-success`}`,children:[(0,z.jsx)(`div`,{className:`mt-0.5 shrink-0 ${o?`text-destructive-foreground`:`text-success-foreground`}`,children:o?(0,z.jsx)(Ir,{className:`h-[18px] w-[18px]`}):(0,z.jsx)(sn,{className:`h-[18px] w-[18px]`})}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`div`,{className:`text-[12.5px] font-semibold ${o?`text-destructive-foreground`:`text-success-foreground`}`,children:a.title}),u&&(0,z.jsxs)(`div`,{className:`mt-0.5 text-[12px] leading-snug text-foreground/85`,children:[f,d&&(0,z.jsx)(`button`,{type:`button`,className:`ml-1.5 text-[11px] text-muted-foreground underline-offset-2 hover:underline`,onClick:()=>i(e=>!e),children:r?`less`:`more`})]}),s.length>0&&(0,z.jsx)(`div`,{className:`mt-2.5 flex flex-wrap gap-2`,children:s.map((e,t)=>(0,z.jsx)(`button`,{type:`button`,disabled:e.isPending,onClick:e.invoke,className:`inline-flex items-center gap-1.5 rounded-[var(--radius-sm)] border px-2.5 py-1.5 text-[12px] font-medium transition-colors disabled:opacity-50 ${t===0&&o?`badge-border-destructive text-destructive-foreground hover:bg-destructive/10`:`border-border text-foreground hover:bg-accent`}`,children:e.action.label},e.action.key))})]}),typeof c==`number`&&(0,z.jsxs)(`span`,{className:`shrink-0 rounded-[var(--radius-sm)] border border-border bg-muted px-[7px] py-[2px] text-[10px] font-semibold uppercase tracking-[0.05em] text-muted-foreground`,children:[`cycle `,c,l?`/${l}`:``]})]})}var D5={header:`_header_o6mqy_8`,n:`_n_o6mqy_12`,row:`_row_o6mqy_14`,sel:`_sel_o6mqy_21`,child:`_child_o6mqy_22`,caret:`_caret_o6mqy_24`,caretBtn:`_caretBtn_o6mqy_25`,tile:`_tile_o6mqy_27`,work:`_work_o6mqy_33`,review:`_review_o6mqy_34`,ver:`_ver_o6mqy_35`,ok:`_ok_o6mqy_36`,bad:`_bad_o6mqy_37`,pending:`_pending_o6mqy_38`,body:`_body_o6mqy_40`,l1:`_l1_o6mqy_41`,name:`_name_o6mqy_42`,status:`_status_o6mqy_43`,info:`_info_o6mqy_44`,muted:`_muted_o6mqy_47`,l2:`_l2_o6mqy_48`,model:`_model_o6mqy_49`,sub:`_sub_o6mqy_50`,pulse:`_pulse_o6mqy_52`,agentsLanePulse:`_agentsLanePulse_o6mqy_1`,resources:`_resources_o6mqy_57`,resToggle:`_resToggle_o6mqy_58`,sum:`_sum_o6mqy_64`,resList:`_resList_o6mqy_65`,resRow:`_resRow_o6mqy_66`,ri:`_ri_o6mqy_67`,rmeta:`_rmeta_o6mqy_68`,dot:`_dot_o6mqy_69`,off:`_off_o6mqy_71`,resLink:`_resLink_o6mqy_74`,resActions:`_resActions_o6mqy_76`,resBtn:`_resBtn_o6mqy_77`,resSub:`_resSub_o6mqy_83`},Gyt={correctness:Or,security:or,performance:zn,requirements:mn,synthesis:er};function O5(e){switch(e.type){case`work`:return gn;case`strike`:return Br;case`planning`:return yn;case`legacy`:return zt;case`review`:return An;case`reviewer`:return e.role&&Gyt[e.role]||Or;case`test`:return Fn;case`ship`:case`merge`:return Gn;default:return gn}}var k5=e=>e&&e[0].toUpperCase()+e.slice(1);function Kyt(e){switch(e.type){case`planning`:case`legacy`:return`Plan`;case`work`:return`Work`;case`strike`:return`Strike`;case`review`:return`Review`;case`reviewer`:return e.role?k5(e.role):`Reviewer`;case`test`:return`Test`;case`ship`:case`merge`:return`Ship`;default:return k5(e.type)}}var qyt=new Set([``,`unknown`,`specialist`,`planning`,`idle`,`none`]);function A5(e){let t=(e??``).trim();return qyt.has(t.toLowerCase())?``:t.replace(/^claude-/,``)}function j5(e){if(!e||!Number.isFinite(e)||e<=0)return``;let t=Math.round(e/60);if(t<60)return`${t}m`;let n=Math.round(t/60);return n<48?`${n}h`:`${Math.round(n/24)}d`}var Jyt=new Set([`running`,`starting`,`working`,`thinking`]);function M5(e){return Jyt.has(e.status)?{label:`running`,tone:`info`}:e.status===`error`?{label:`error`,tone:`bad`}:{label:`done`,tone:`muted`}}function Yyt(e){let{latestReviewResult:t,latestStatus:n}=e.roundMetadata??{};return t===`APPROVED`?{label:`approved`,tone:`ok`}:t===`CHANGES_REQUESTED`||n===`failed`||e.status===`error`?{label:`changes`,tone:`bad`}:Jyt.has(e.status)?{label:`reviewing`,tone:`info`}:{label:`done`,tone:`muted`}}var Xyt={pending:{label:`not run`,tone:`muted`},running:{label:`running`,tone:`info`},passed:{label:`passed`,tone:`ok`},failed:{label:`failed`,tone:`bad`},skipped:{label:`skipped`,tone:`muted`}},Zyt={pending:{label:`not run`,tone:`muted`},testing:{label:`running`,tone:`info`},passed:{label:`passed`,tone:`ok`},failed:{label:`failed`,tone:`bad`},dispatch_failed:{label:`failed`,tone:`bad`},skipped:{label:`skipped`,tone:`muted`}},Qyt=[`typecheck`,`lint`,`test`];function $yt(e){let t=e?.verificationNotes?.match(/Verification FAILED at (typecheck|lint|test)\b/i),n=t?Qyt.indexOf(t[1].toLowerCase()):-1;return Qyt.map((e,t)=>n<0?{id:e,tone:`bad`,label:`failed`}:t<n?{id:e,tone:`ok`,label:`passed`}:t===n?{id:e,tone:`bad`,label:`failed`}:{id:e,tone:`muted`,label:`pending`})}function N5({icon:e,tileClass:t,name:n,status:r,model:i,sub:a,indent:o,selected:s,expandable:c,expanded:l,onToggle:u,onClick:d,verdictTile:f}){return(0,z.jsxs)(`button`,{type:`button`,className:`${D5.row} ${o?D5.child:``} ${s?D5.sel:``}`,onClick:d,children:[(0,z.jsx)(`span`,{className:D5.caret,children:c&&(0,z.jsx)(`span`,{role:`button`,tabIndex:-1,className:D5.caretBtn,onClick:e=>{e.stopPropagation(),u?.()},children:l?(0,z.jsx)(en,{size:11}):(0,z.jsx)(nn,{size:11})})}),(0,z.jsx)(`span`,{className:`${D5.tile} ${f?D5[f]:t??``}`,children:f===`ok`?(0,z.jsx)(sn,{size:11}):f===`bad`?(0,z.jsx)(un,{size:11}):(0,z.jsx)(e,{})}),(0,z.jsxs)(`span`,{className:D5.body,children:[(0,z.jsxs)(`span`,{className:D5.l1,children:[(0,z.jsx)(`span`,{className:D5.name,children:n}),(0,z.jsx)(`span`,{className:`${D5.status} ${D5[r.tone]}`,children:r.label})]}),i||a?(0,z.jsxs)(`span`,{className:D5.l2,children:[(0,z.jsx)(`span`,{className:D5.model,children:i??``}),a?(0,z.jsx)(`span`,{className:D5.sub,children:a}):null]}):null]})]})}function ebt({issueId:e,feature:t,branch:n}){let[r,i]=(0,R.useState)(!1),a=kj(e).data,o=Bj(e),s=t?.resourceDetails,c=s?.prs??[];if(!a?.exists&&!s)return null;let l=a?.containers??null,u=a?.stackHealth,d=oH({containers:l,stackHealth:u}),f=d?.totalCount??0,p=!!d&&(u?.healthy===!1||d.healthyCount<d.totalCount),m=d?p?`var(--destructive)`:`var(--success)`:`var(--muted-foreground)`,h=a?.git,g=h?.branch??n,_=h?.ahead??0,v=h?.behind??0,y=(a?.services?.filter(e=>e.url)??[]).slice();y.length===0&&(a?.frontendUrl&&y.push({name:`Frontend`,url:a.frontendUrl}),a?.apiUrl&&y.push({name:`API`,url:a.apiUrl}));let b=[`rebuildAndStart`,`syncMain`,`createWorkspace`].map(e=>o.all.find(t=>t.action.key===e)).filter(e=>!!e&&e.enabled);return(0,z.jsxs)(`div`,{className:D5.resources,children:[(0,z.jsxs)(`button`,{type:`button`,className:D5.resToggle,onClick:()=>i(e=>!e),children:[r?(0,z.jsx)(en,{size:11}):(0,z.jsx)(nn,{size:11}),`Stack`,(0,z.jsxs)(`span`,{className:`sum`,style:{display:`inline-flex`,alignItems:`center`,gap:6},children:[(0,z.jsx)(`span`,{className:D5.dot,style:{background:m}}),f>0?`${f} ctr`:`no ctr`,_>0?` · +${_}`:``,` · `,c.length,` PR`]})]}),r&&(0,z.jsxs)(`div`,{className:D5.resList,children:[y.length>0&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:D5.resSub,children:`Services`}),(0,z.jsx)(`div`,{className:D5.resRow,style:{gap:12},children:y.map(e=>(0,z.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:D5.resLink,children:[e.name,` ↗`]},e.name))})]}),(l||u)&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:D5.resSub,children:[`Containers`,f?` · ${f}`:``]}),(0,z.jsx)(sH,{density:`compact`,containers:l,stackHealth:u,frontendUrl:a?.frontendUrl,apiUrl:a?.apiUrl})]}),c.length>0&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:D5.resSub,children:`Pull requests`}),c.map(e=>(0,z.jsxs)(`div`,{className:D5.resRow,children:[(0,z.jsx)(Kn,{className:`ri`}),(0,z.jsxs)(`span`,{children:[`#`,e.number]}),(0,z.jsx)(`span`,{className:`rmeta`,children:e.isDraft?`draft`:e.state.toLowerCase()})]},e.number))]}),(0,z.jsx)(`div`,{className:D5.resSub,children:`Git`}),(0,z.jsxs)(`div`,{className:D5.resRow,children:[(0,z.jsx)(Hn,{className:`ri`}),(0,z.jsx)(`span`,{style:{fontFamily:`var(--mono)`,fontSize:`10px`},children:g}),(0,z.jsxs)(`span`,{className:`rmeta`,children:[_>0?`+${_}`:``,v>0?` -${v}`:``,h?.dirty?` dirty`:!_&&!v?`clean`:``]})]}),b.length>0&&(0,z.jsx)(`div`,{className:D5.resActions,children:b.map(e=>(0,z.jsx)(`button`,{type:`button`,disabled:e.isPending,onClick:e.invoke,className:D5.resBtn,children:e.action.label},e.action.key))})]})]})}function tbt({issueId:e,sessions:t,feature:n,branch:r,selectedSessionId:i,onSelectSession:a,onOpenVerification:o}){let[s,c]=(0,R.useState)(!0),[l,u]=(0,R.useState)(!0),d=wj(e).data,f=t.find(e=>e.type===`planning`||e.type===`legacy`),p=t.filter(e=>e.type===`work`||e.type===`strike`),m=t.find(e=>e.type===`review`),h=t.filter(e=>e.type===`reviewer`),g=t.find(e=>e.type===`test`),_=t.filter(e=>e.type===`ship`||e.type===`merge`),v=h.filter(e=>Yyt(e).tone===`bad`).length,y=Xyt[d?.verificationStatus??`pending`]??Xyt.pending,b=d?.verificationStatus===`failed`,x=[f,...p,m,g,..._].filter(Boolean).length+1+ +!g;return(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`div`,{className:D5.header,children:[`Agents & steps `,(0,z.jsx)(`span`,{className:`n`,children:x})]}),f&&(0,z.jsx)(N5,{icon:O5(f),verdictTile:f.status===`error`?`bad`:`ok`,name:`Plan`,status:M5(f),model:A5(f.model),sub:j5(f.duration),selected:f.sessionId===i,onClick:()=>a(f)}),p.map(e=>(0,z.jsx)(N5,{icon:O5(e),tileClass:D5.work,name:Kyt(e),status:M5(e),model:A5(e.model),sub:j5(e.duration),selected:e.sessionId===i,onClick:()=>a(e)},e.sessionId)),m&&(0,z.jsx)(N5,{icon:An,tileClass:D5.review,name:`Review`,status:h.length?{label:`${h.length} reviewers`,tone:`muted`}:M5(m),model:A5(m.model),sub:h.length?`convoy · ${v} changes`:j5(m.duration),expandable:h.length>0,expanded:s,onToggle:()=>c(e=>!e),selected:m.sessionId===i,onClick:()=>a(m)}),m&&s&&h.map(e=>(0,z.jsx)(N5,{icon:O5(e),indent:!0,name:Kyt(e),status:Yyt(e),model:A5(e.model),selected:e.sessionId===i,onClick:()=>a(e)},e.sessionId)),(0,z.jsx)(N5,{icon:Ht,tileClass:D5.ver,name:`Verification`,status:y,model:`build gate`,sub:d?.verificationCycleCount?`cycle ${d.verificationCycleCount}${d.verificationMaxCycles?`/${d.verificationMaxCycles}`:``}`:void 0,expandable:b,expanded:l,onToggle:()=>u(e=>!e),onClick:o}),b&&l&&$yt(d).map(e=>(0,z.jsx)(N5,{icon:dn,indent:!0,name:k5(e.id),status:{label:e.label,tone:e.tone},verdictTile:e.tone===`ok`?`ok`:e.tone===`bad`?`bad`:void 0,onClick:o},e.id)),g?(0,z.jsx)(N5,{icon:Fn,name:`Test`,status:M5(g),model:A5(g.model),sub:j5(g.duration),selected:g.sessionId===i,onClick:()=>a(g)}):(0,z.jsx)(N5,{icon:Fn,name:`Test`,status:Zyt[d?.testStatus??`pending`]??Zyt.pending,model:`pipeline`,onClick:o}),_.map(e=>(0,z.jsx)(N5,{icon:O5(e),name:`Ship`,status:M5(e),model:A5(e.model),sub:j5(e.duration),selected:e.sessionId===i,onClick:()=>a(e)},e.sessionId)),(0,z.jsx)(ebt,{issueId:e,feature:n,branch:r})]})}var P5={rail:`_rail_1hr9s_5`,header:`_header_1hr9s_14`,title:`_title_1hr9s_21`,counts:`_counts_1hr9s_22`,count:`_count_1hr9s_22`,cdot:`_cdot_1hr9s_24`,open:`_open_1hr9s_25`,active:`_active_1hr9s_26`,done:`_done_1hr9s_27`,muted:`_muted_1hr9s_28`,iconBtn:`_iconBtn_1hr9s_29`,progressWrap:`_progressWrap_1hr9s_37`,progressTop:`_progressTop_1hr9s_38`,track:`_track_1hr9s_40`,fillDone:`_fillDone_1hr9s_41`,fillActive:`_fillActive_1hr9s_42`,empty:`_empty_1hr9s_44`,body:`_body_1hr9s_47`,groupHeader:`_groupHeader_1hr9s_48`,groupHeaderActive:`_groupHeaderActive_1hr9s_52`,spine:`_spine_1hr9s_54`,bead:`_bead_1hr9s_61`,node:`_node_1hr9s_67`,beadTitle:`_beadTitle_1hr9s_72`,meta:`_meta_1hr9s_73`,badge:`_badge_1hr9s_75`,blocked:`_blocked_1hr9s_81`,beadDone:`_beadDone_1hr9s_84`,beadOpen:`_beadOpen_1hr9s_88`,beadActive:`_beadActive_1hr9s_91`,workingTag:`_workingTag_1hr9s_102`,agentLine:`_agentLine_1hr9s_107`,pulse:`_pulse_1hr9s_109`,beadsRailRing:`_beadsRailRing_1hr9s_1`,more:`_more_1hr9s_123`,allDone:`_allDone_1hr9s_130`},nbt=[`trivial`,`simple`,`medium`,`complex`,`expert`];function rbt(e){for(let t of e){let e=/^difficulty:(.+)$/i.exec(t);if(e)return e[1].toLowerCase()}for(let t of e)if(nbt.includes(t.toLowerCase()))return t.toLowerCase();return null}var F5=e=>e.title||e.name||e.id,ibt=3;function I5({labels:e}){let t=rbt(e);return t?(0,z.jsx)(`span`,{className:P5.badge,children:t}):null}function abt({blockedBy:e}){return e?.length?(0,z.jsxs)(`div`,{className:P5.blocked,children:[`⤷ blocked by `,e.length,` upstream bead`,e.length===1?``:`s`]}):null}function obt({issueId:e,onOpenFull:t}){let[n,r]=(0,R.useState)(!1),{data:i,isLoading:a,refetch:o,isRefetching:s}=B({queryKey:[`beads`,e],queryFn:async()=>{let t=await fetch(`/api/issues/${e}/beads`);if(!t.ok)throw Error(`Failed to fetch beads`);return t.json()},refetchInterval:1e4}),c=i?.tasks??[],l=c.filter(e=>e.status===`closed`),u=c.filter(e=>e.status===`in_progress`),d=c.filter(e=>e.status!==`closed`&&e.status!==`in_progress`),f=c.length,p=f?Math.round(l.length/f*100):0,m=f?Math.round(u.length/f*100):0,h=n?l:l.slice(Math.max(0,l.length-ibt)),g=l.length-h.length,_=new Date;return(0,z.jsxs)(`aside`,{className:P5.rail,"aria-label":`Beads progress`,children:[(0,z.jsxs)(`div`,{className:P5.header,children:[(0,z.jsx)(`span`,{className:P5.title,children:`Beads`}),(0,z.jsxs)(`div`,{className:P5.counts,children:[f>0?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`span`,{className:P5.count,title:`upcoming`,children:[(0,z.jsx)(`span`,{className:`${P5.cdot} ${P5.open}`}),d.length]}),u.length>0&&(0,z.jsxs)(`span`,{className:P5.count,title:`in progress`,children:[(0,z.jsx)(`span`,{className:`${P5.cdot} ${P5.active}`}),u.length]}),(0,z.jsxs)(`span`,{className:P5.count,title:`completed`,children:[(0,z.jsx)(`span`,{className:`${P5.cdot} ${P5.done}`}),l.length]})]}):(0,z.jsx)(`span`,{className:P5.muted,children:`—`}),(0,z.jsx)(`button`,{type:`button`,className:P5.iconBtn,title:`Open full beads / graph view`,onClick:t,"aria-label":`Open full beads view`,children:`⌥`}),(0,z.jsx)(`button`,{type:`button`,className:P5.iconBtn,title:`Refresh`,onClick:()=>o(),"aria-label":`Refresh beads`,disabled:s,children:`⟳`})]})]}),f>0&&(0,z.jsxs)(`div`,{className:P5.progressWrap,children:[(0,z.jsxs)(`div`,{className:P5.progressTop,children:[(0,z.jsx)(`span`,{children:`Plan progress`}),(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`b`,{children:l.length}),` / `,f,` · `,p,`%`]})]}),(0,z.jsxs)(`div`,{className:P5.track,children:[(0,z.jsx)(`div`,{className:P5.fillDone,style:{width:`${p}%`}}),(0,z.jsx)(`div`,{className:P5.fillActive,style:{width:`${m}%`}})]})]}),a&&(0,z.jsx)(`div`,{className:P5.empty,children:`Loading beads…`}),!a&&f===0&&(0,z.jsxs)(`div`,{className:P5.empty,children:[`No beads yet.`,(0,z.jsx)(`div`,{className:P5.muted,children:`Planning hasn’t created tasks for this issue.`})]}),!a&&f>0&&(0,z.jsxs)(`div`,{className:P5.body,children:[l.length>0&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:P5.groupHeader,children:[l.length,` completed`]}),(0,z.jsxs)(`div`,{className:P5.spine,children:[g>0&&!n&&(0,z.jsxs)(`button`,{type:`button`,className:P5.more,onClick:()=>r(!0),children:[`↑ show `,g,` earlier completed`]}),h.map(e=>(0,z.jsxs)(`button`,{type:`button`,className:`${P5.bead} ${P5.beadDone}`,onClick:t,title:F5(e),children:[(0,z.jsx)(`span`,{className:P5.node,children:`✓`}),(0,z.jsx)(`span`,{className:P5.beadTitle,children:F5(e)}),(0,z.jsx)(`span`,{className:P5.meta,children:(0,z.jsx)(I5,{labels:e.labels})})]},e.id))]})]}),u.length>0&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`${P5.groupHeader} ${P5.groupHeaderActive}`,children:`working now`}),(0,z.jsx)(`div`,{className:P5.spine,children:u.map(e=>(0,z.jsxs)(`button`,{type:`button`,className:`${P5.bead} ${P5.beadActive}`,onClick:t,title:F5(e),children:[(0,z.jsx)(`span`,{className:P5.node,children:(0,z.jsx)(`span`,{className:P5.pulse})}),(0,z.jsxs)(`span`,{className:P5.workingTag,children:[(0,z.jsx)(`span`,{className:P5.pulse}),` in progress`]}),(0,z.jsx)(`span`,{className:P5.beadTitle,children:F5(e)}),e.startedAt&&(0,z.jsxs)(`span`,{className:P5.agentLine,children:[`started `,oM(e.startedAt,_)]}),(0,z.jsx)(`span`,{className:P5.meta,children:(0,z.jsx)(I5,{labels:e.labels})})]},e.id))})]}),d.length>0&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:P5.groupHeader,children:[d.length,` upcoming`]}),(0,z.jsx)(`div`,{className:P5.spine,children:d.map(e=>(0,z.jsxs)(`button`,{type:`button`,className:`${P5.bead} ${P5.beadOpen}`,onClick:t,title:F5(e),children:[(0,z.jsx)(`span`,{className:P5.node}),(0,z.jsx)(`span`,{className:P5.beadTitle,children:F5(e)}),(0,z.jsx)(`span`,{className:P5.meta,children:(0,z.jsx)(I5,{labels:e.labels})}),(0,z.jsx)(abt,{blockedBy:e.blockedBy})]},e.id))})]}),l.length===f&&f>0&&(0,z.jsx)(`div`,{className:P5.allDone,children:`✓ All planned beads complete`})]})]})}var L5={wrap:`_wrap_1xoim_5`,head:`_head_1xoim_13`,title:`_title_1xoim_14`,sum:`_sum_1xoim_15`,files:`_files_1xoim_17`,acts:`_acts_1xoim_18`,add:`_add_1xoim_19`,del:`_del_1xoim_20`,btn:`_btn_1xoim_22`,grid:`_grid_1xoim_25`,tree:`_tree_1xoim_28`,row:`_row_1xoim_32`,sel:`_sel_1xoim_39`,car:`_car_1xoim_40`,ftype:`_ftype_1xoim_41`,nm:`_nm_1xoim_42`,cnt:`_cnt_1xoim_43`,dirrow:`_dirrow_1xoim_44`,dirname:`_dirname_1xoim_45`,fileIndent:`_fileIndent_1xoim_46`,bar:`_bar_1xoim_48`,g:`_g_1xoim_25`,r:`_r_1xoim_32`,diff:`_diff_1xoim_53`,dhead:`_dhead_1xoim_54`,path:`_path_1xoim_56`,lines:`_lines_1xoim_59`,dl:`_dl_1xoim_60`,ln:`_ln_1xoim_61`,tx:`_tx_1xoim_62`,hunk:`_hunk_1xoim_67`,empty:`_empty_1xoim_70`,sub:`_sub_1xoim_71`,loading:`_loading_1xoim_72`},sbt={ts:`TS`,tsx:`TSX`,js:`JS`,jsx:`JSX`,mjs:`JS`,cjs:`JS`,json:`{}`,css:`CSS`,scss:`CSS`,md:`MD`,mdx:`MD`,yaml:`YML`,yml:`YML`,html:`HTM`,sh:`SH`,py:`PY`,go:`GO`,rs:`RS`,sql:`SQL`,toml:`TOM`,lock:`LCK`,png:`IMG`,jpg:`IMG`,jpeg:`IMG`,svg:`SVG`,gif:`IMG`};function cbt(e){let t=e.slice(e.lastIndexOf(`/`)+1),n=t.includes(`.`)?t.slice(t.lastIndexOf(`.`)+1).toLowerCase():``;return sbt[n]??(n?n.slice(0,3).toUpperCase():`·`)}var lbt=e=>e.slice(e.lastIndexOf(`/`)+1),ubt=e=>{let t=e.lastIndexOf(`/`);return t>=0?e.slice(0,t):``};function dbt({add:e,del:t}){let n=e+t,r=n?Math.round(e/n*100):0;return(0,z.jsxs)(`span`,{className:L5.bar,children:[(0,z.jsx)(`span`,{className:L5.g,style:{width:`${r}%`}}),(0,z.jsx)(`span`,{className:L5.r,style:{width:`${n?100-r:0}%`}})]})}function fbt(e){let t=new Map;if(!e)return t;let n=``,r=[];for(let i of e.split(`
|
|
667
|
-
`))if(i.startsWith(`diff --git `)){n&&t.set(n,r),r=[];let e=/\sb\/(.+)$/.exec(i);n=e?e[1]:``}else n&&r.push(i);return n&&t.set(n,r),t}function pbt(e){let t=[],n=0;for(let r of e)if(r.startsWith(`@@`)){let e=r.split(`@@`)[1]??``,i=/\+(\d+)/.exec(e);n=i?parseInt(i[1],10):n,t.push({kind:`hunk`,n:null,text:r})}else r.startsWith(`+`)&&!r.startsWith(`+++`)?t.push({kind:`add`,n:n++,text:r}):r.startsWith(`-`)&&!r.startsWith(`---`)?t.push({kind:`del`,n:null,text:r}):r.startsWith(`--- `)||r.startsWith(`+++ `)||r.startsWith(`index `)||r.startsWith(`new file`)||r.startsWith(`deleted file`)||r.startsWith(`rename `)||r.startsWith(`similarity `)||r.startsWith(`Binary `)||r.startsWith(`old mode`)||r.startsWith(`new mode`)||t.push({kind:`ctx`,n:n++,text:r});return t}function R5({add:e,del:t}){return(0,z.jsxs)(`span`,{className:L5.cnt,children:[e?(0,z.jsxs)(`span`,{className:L5.add,children:[`+`,e]}):null,e&&t?` `:null,t?(0,z.jsxs)(`span`,{className:L5.del,children:[`−`,t]}):null]})}function mbt({issueId:e}){let t=Dj(e),n=Oj(e),r=t.data?.pr?.files??[],[i,a]=(0,R.useState)(null),[o,s]=(0,R.useState)(new Set),c=i??r[0]?.path??null,l=(0,R.useMemo)(()=>{let e=new Map;for(let t of r){let n=ubt(t.path);e.has(n)||e.set(n,[]),e.get(n).push(t)}return[...e.entries()].sort((e,t)=>e[0].localeCompare(t[0]))},[r]),u=(0,R.useMemo)(()=>fbt(n.data?.diff),[n.data?.diff]),d=(0,R.useMemo)(()=>c?pbt(u.get(c)??[]):[],[u,c]),f=r.find(e=>e.path===c);if(t.isLoading)return(0,z.jsx)(`div`,{className:L5.wrap,children:(0,z.jsx)(`div`,{className:L5.loading,children:`Loading changed files…`})});if(!t.data?.pr)return(0,z.jsx)(`div`,{className:L5.wrap,children:(0,z.jsx)(`div`,{className:L5.empty,children:`No pull request for this issue yet.`})});let p=t.data.pr.additions??r.reduce((e,t)=>e+t.additions,0),m=t.data.pr.deletions??r.reduce((e,t)=>e+t.deletions,0);return(0,z.jsxs)(`div`,{className:L5.wrap,children:[(0,z.jsxs)(`div`,{className:L5.head,children:[(0,z.jsx)(`span`,{className:L5.title,children:`Changed files`}),(0,z.jsxs)(`span`,{className:L5.sum,children:[(0,z.jsx)(`b`,{children:r.length}),` `,(0,z.jsx)(`span`,{className:L5.files,children:`files`}),` · `,(0,z.jsxs)(`span`,{className:L5.add,children:[`+`,p]}),` `,(0,z.jsxs)(`span`,{className:L5.del,children:[`−`,m]})]}),(0,z.jsxs)(`span`,{className:L5.acts,children:[(0,z.jsx)(`button`,{type:`button`,className:L5.btn,onClick:()=>s(new Set(l.map(e=>e[0]).filter(Boolean))),children:`Collapse all`}),(0,z.jsx)(`button`,{type:`button`,className:L5.btn,onClick:()=>s(new Set),children:`Expand all`}),t.data.pr.url&&(0,z.jsx)(`a`,{className:L5.btn,href:t.data.pr.url,target:`_blank`,rel:`noreferrer`,children:`Open PR ↗`})]})]}),(0,z.jsxs)(`div`,{className:L5.grid,children:[(0,z.jsxs)(`div`,{className:L5.tree,children:[r.length===0&&(0,z.jsx)(`div`,{className:L5.empty,children:`No files changed.`}),l.map(([e,t])=>{let n=o.has(e),r=t.reduce((e,t)=>e+t.additions,0),i=t.reduce((e,t)=>e+t.deletions,0);return(0,z.jsxs)(`div`,{children:[e&&(0,z.jsxs)(`button`,{type:`button`,className:`${L5.row} ${L5.dirrow}`,onClick:()=>s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),children:[(0,z.jsx)(`span`,{className:L5.car,children:n?`▸`:`▾`}),(0,z.jsx)(`span`,{className:L5.ftype,children:`📁`}),(0,z.jsx)(`span`,{className:L5.nm,children:(0,z.jsx)(`span`,{className:L5.dirname,children:e})}),(0,z.jsx)(dbt,{add:r,del:i}),(0,z.jsx)(R5,{add:r,del:i})]}),!n&&t.map(t=>(0,z.jsxs)(`button`,{type:`button`,className:`${L5.row} ${e?L5.fileIndent:``} ${t.path===c?L5.sel:``}`,onClick:()=>a(t.path),title:t.path,children:[(0,z.jsx)(`span`,{className:L5.car}),(0,z.jsx)(`span`,{className:L5.ftype,children:cbt(t.path)}),(0,z.jsx)(`span`,{className:L5.nm,children:lbt(t.path)}),(0,z.jsx)(dbt,{add:t.additions,del:t.deletions}),(0,z.jsx)(R5,{add:t.additions,del:t.deletions})]},t.path))]},e||`__root`)})]}),(0,z.jsx)(`div`,{className:L5.diff,children:c?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:L5.dhead,children:[(0,z.jsx)(`span`,{className:L5.ftype,children:cbt(c)}),(0,z.jsx)(`span`,{className:L5.path,children:c}),f&&(0,z.jsx)(R5,{add:f.additions,del:f.deletions})]}),n.isLoading?(0,z.jsx)(`div`,{className:L5.loading,children:`Loading diff…`}):d.length===0?(0,z.jsxs)(`div`,{className:L5.empty,children:[`No text diff for this file`,(0,z.jsx)(`span`,{className:L5.sub,children:`(binary, renamed, or no line changes)`})]}):(0,z.jsx)(`div`,{className:L5.lines,children:d.map((e,t)=>{let n=e.kind===`hunk`?L5.hunk:e.kind===`add`?L5.add:e.kind===`del`?L5.del:``;return(0,z.jsxs)(`div`,{className:`${L5.dl} ${n}`,children:[(0,z.jsx)(`span`,{className:L5.ln,children:e.n??``}),(0,z.jsx)(`span`,{className:L5.tx,children:e.text})]},t)})})]}):(0,z.jsxs)(`div`,{className:L5.empty,children:[`Select a file to view its diff`,(0,z.jsx)(`span`,{className:L5.sub,children:`or “Open PR ↗” for the full review`})]})})]})]})}var hbt={info:`bg-info`,success:`bg-success`,warning:`bg-warning`,destructive:`bg-destructive`,review:`bg-signal-review`,cost:`bg-signal-cost`,muted:`bg-muted-foreground`};function z5({tone:e,title:t,right:n,children:r,className:i=``}){return(0,z.jsxs)(`div`,{className:`rounded-[18px] border border-border bg-card p-4 shadow-sm ${i}`,children:[(0,z.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`h-[7px] w-[7px] rounded-full ${hbt[e]}`}),(0,z.jsx)(`h3`,{className:`font-display text-[13px] font-semibold text-foreground`,children:t}),n!=null&&(0,z.jsx)(`div`,{className:`ml-auto flex items-center gap-2`,children:n})]}),r]})}var gbt={info:`text-info-foreground badge-bg-info badge-border-info`,success:`text-success-foreground badge-bg-success badge-border-success`,warning:`text-warning-foreground badge-bg-warning badge-border-warning`,destructive:`text-destructive-foreground badge-bg-destructive badge-border-destructive`,review:`text-signal-review-foreground badge-bg-signal-review badge-border-signal-review`,cost:`text-signal-cost-foreground badge-bg-signal-cost badge-border-signal-cost`,muted:`text-muted-foreground badge-bg-muted badge-border-muted`};function B5({tone:e,children:t,className:n=``}){let r=gbt[e];return(0,z.jsx)(`span`,{className:`inline-flex items-center gap-1 rounded-[var(--radius-sm)] border px-[7px] py-[2px] text-[10px] font-semibold uppercase tracking-[0.05em] ${r} ${n}`,children:t})}function V5(e){return[`passed`,`merged`,`done`,`completed`].includes(e)?`success`:[`blocked`,`failed`,`dispatch_failed`].includes(e)?`destructive`:[`reviewing`,`testing`,`merging`,`verifying`,`running`,`queued`].includes(e)?`info`:`muted`}var _bt={review:`review`,test:`warning`,merge:`success`,inspect:`info`,uat:`info`};function vbt(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString([],{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function ybt({issueId:e}){let t=wj(e),n=(0,R.useMemo)(()=>[...t.data?.history??[]].reverse(),[t.data?.history]);return n.length===0?(0,z.jsx)(`div`,{className:`px-1 py-4 text-[12px] text-muted-foreground`,children:t.isLoading?`Loading…`:`No status history yet.`}):(0,z.jsxs)(`div`,{className:`relative py-2 pl-4`,children:[(0,z.jsx)(`div`,{className:`absolute bottom-2 left-[6px] top-2 w-px bg-border`}),(0,z.jsx)(`div`,{className:`flex flex-col gap-3`,children:n.map((e,t)=>(0,z.jsxs)(`div`,{className:`relative`,children:[(0,z.jsx)(`span`,{className:`absolute -left-4 top-1 h-[9px] w-[9px] rounded-full border-2 border-background ${V5(e.status)===`success`?`bg-success`:V5(e.status)===`destructive`?`bg-destructive`:V5(e.status)===`info`?`bg-info`:`bg-muted-foreground`}`}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,z.jsx)(B5,{tone:_bt[e.type]??`muted`,children:e.type}),(0,z.jsx)(B5,{tone:V5(e.status),children:e.status}),(0,z.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:vbt(e.timestamp)})]}),e.notes&&(0,z.jsx)(`div`,{className:`mt-1 text-[12px] leading-snug text-foreground/85`,children:e.notes})]},`${e.type}-${e.timestamp}-${t}`))})]})}var H5={wrap:`_wrap_4ie0a_5`,scan:`_scan_4ie0a_9`,missionWrap:`_missionWrap_4ie0a_22`,headerTop:`_headerTop_4ie0a_35`,headerTitle:`_headerTitle_4ie0a_41`,headerMeta:`_headerMeta_4ie0a_45`,missionBody:`_missionBody_4ie0a_66`},bbt=[{id:`overview`,label:`Overview`},{id:`code`,label:`Code`},{id:`plan`,label:`PRD / Plan`},{id:`timeline`,label:`Timeline`},{id:`discussion`,label:`Discussion`},{id:`costs`,label:`Costs`},{id:`artifacts`,label:`Artifacts`},{id:`conversation`,label:`Conversation`},{id:`files`,label:`Files`},{id:`terminal`,label:`Terminal`}],xbt={planning:`Planning`,work:`Work`,review:`Review & Test`,agent:`Agent`,workspace:`Workspace`,artifacts:`Artifacts`,navigation:`Navigation`,danger:`Danger`,preserved:`Preserved`},Sbt=[`planning`,`work`,`review`,`agent`,`workspace`,`artifacts`,`navigation`,`danger`,`preserved`],Cbt={done:`bg-success`,active:`bg-info animate-pulse`,fail:`bg-destructive`,todo:`bg-muted-foreground/20`},wbt={done:`border-success/50 bg-success/15 text-success-foreground`,active:`border-info/50 bg-info/15 text-info-foreground`,fail:`border-destructive/50 bg-destructive/15 text-destructive-foreground`,todo:`border-border bg-muted/30 text-muted-foreground`},Tbt={ok:`bg-success`,bad:`bg-destructive`,run:`bg-info`,wait:`bg-muted-foreground`};function Ebt(e){let t=(e??``).toLowerCase();return[`passed`,`success`,`completed`,`merged`,`ready`].includes(t)?`success`:[`failed`,`blocked`,`dispatch_failed`,`timed_out`,`action_required`,`startup_failure`,`failure`].includes(t)?`destructive`:[`running`,`reviewing`,`testing`,`queued`,`merging`,`verifying`,`in_progress`].includes(t)?`info`:[`skipped`,`neutral`,`cancelled`].includes(t)?`muted`:`warning`}function Dbt(e){return e===`done`?`✓`:e===`fail`?`✕`:e===`active`?`◆`:`○`}function Obt(e){return e.status===`completed`?(e.conclusion??`unknown`).replace(/_/g,` `):e.status.replace(/_/g,` `)}function kbt(e){return e?e.mergeStatus===`merged`?`merged`:e.mergeStatus===`merging`||e.mergeStatus===`queued`||e.mergeStatus===`verifying`?e.mergeStatus:e.testStatus===`testing`?`testing`:e.reviewStatus===`reviewing`?`reviewing`:e.reviewStatus===`blocked`||e.reviewStatus===`failed`?e.reviewStatus:e.testStatus===`failed`||e.testStatus===`dispatch_failed`?e.testStatus:e.readyForMerge?`ready`:e.reviewStatus??`pending`:`pending`}function Abt(e){let{hasPlan:t,rs:n,ci:r,work:i}=e,a=n?.reviewStatus===`blocked`||n?.reviewStatus===`failed`?`fail`:n?.reviewStatus===`reviewing`?`active`:n?.reviewStatus===`passed`?`done`:`todo`,o=n?.testStatus===`failed`||n?.testStatus===`dispatch_failed`?`fail`:n?.testStatus===`testing`?`active`:n?.testStatus===`passed`||n?.testStatus===`skipped`?`done`:`todo`,s=r?.summary,c=s&&(s.failed||s.cancelled)?`fail`:s&&(s.running||s.pending)?`active`:s&&s.total?`done`:`todo`,l=n?.mergeStatus===`failed`?`fail`:n?.mergeStatus===`queued`||n?.mergeStatus===`merging`||n?.mergeStatus===`verifying`?`active`:n?.mergeStatus===`merged`?`done`:`todo`;return{plan:t?`done`:`todo`,work:i?.status===`running`?`active`:i?`done`:`todo`,review:a,test:o,ci:c,ship:l,merge:n?.mergeStatus===`merged`?`done`:n?.readyForMerge?`active`:`todo`}}function jbt(e){return e?e.mergeStatus===`merged`?`merged — close out`:e.readyForMerge?`merge to main`:e.reviewStatus===`blocked`||e.reviewStatus===`failed`?`work agent fixes → re-review`:e.reviewStatus===`reviewing`?`review in progress`:e.testStatus===`testing`?`test in progress`:e.testStatus===`failed`||e.testStatus===`dispatch_failed`?`fix tests → re-run`:e.reviewStatus===`passed`&&e.testStatus!==`passed`&&e.testStatus!==`skipped`?`dispatch test`:`awaiting pipeline`:`start work`}function Mbt(e){return e?e.mergeStatus===`merged`?`merged`:e.reviewStatus===`blocked`||e.reviewStatus===`failed`?`blocked by review`:e.testStatus===`failed`||e.testStatus===`dispatch_failed`?`test failed`:e.reviewStatus===`passed`?e.testStatus===`pending`||e.testStatus===`testing`?`test pending`:`not ready`:`review pending`:`status unknown`}function Nbt(e,t,n){let r=e?.reviewStatus===`blocked`||e?.reviewStatus===`failed`?{value:(e?.reviewStatus??``).toUpperCase(),tone:`bad`}:e?.reviewStatus===`reviewing`?{value:`reviewing`,tone:`run`}:e?.reviewStatus===`passed`?{value:`passed`,tone:`ok`}:{value:`pending`,tone:`wait`},i=e?.testStatus===`failed`||e?.testStatus===`dispatch_failed`?{value:`failed`,tone:`bad`}:e?.testStatus===`testing`?{value:`testing`,tone:`run`}:e?.testStatus===`passed`||e?.testStatus===`skipped`?{value:e.testStatus,tone:`ok`}:{value:`pending`,tone:`wait`},a=e?.verificationStatus===`passed`?{value:`passed`,tone:`ok`}:e?.verificationStatus===`failed`?{value:`failed`,tone:`bad`}:e?.verificationStatus===`running`?{value:`running`,tone:`run`}:{value:`pending`,tone:`wait`},o=t?.summary,s=!o||o.total===0?{value:`no checks`,tone:`wait`}:o.failed||o.cancelled?{value:`${o.passed}/${o.total}`,tone:`bad`}:o.running||o.pending?{value:`${o.passed}/${o.total}`,tone:`run`}:{value:`${o.passed}/${o.total} ✓`,tone:`ok`},c=(n?.mergeable??``).toUpperCase(),l=n?c===`MERGEABLE`||c===`CLEAN`?{value:`mergeable`,tone:`ok`}:c===`CONFLICTING`?{value:`conflicting`,tone:`bad`}:{value:`unknown`,tone:`wait`}:{value:`no PR`,tone:`wait`},u=e?.readyForMerge?{value:`yes`,tone:`ok`}:{value:`no`,tone:`bad`};return[{label:`Review`,...r},{label:`Test`,...i},{label:`Verification`,...a},{label:`CI`,...s},{label:`PR`,...l},{label:`Merge-ready`,...u}]}function U5({label:e,value:t}){return(0,z.jsxs)(`div`,{className:`flex flex-col gap-px text-right`,children:[(0,z.jsx)(`div`,{className:`text-[9px] uppercase tracking-[0.06em] text-muted-foreground`,children:e}),(0,z.jsx)(`div`,{className:`text-[11.5px] text-foreground`,children:t})]})}function Pbt({issueId:e,rs:t}){if(t?.mergeStatus===`merged`)return(0,z.jsx)(`span`,{className:`inline-flex items-center gap-1.5 rounded-[var(--radius-sm)] border badge-border-success badge-bg-success px-3 py-2 text-[12px] font-medium text-success-foreground`,children:`✓ Merged`});if(t?.readyForMerge)return(0,z.jsx)(cH,{issueId:e,reviewStatus:t,variant:`inspector`,tone:`primary`});let n=Mbt(t);return(0,z.jsxs)(`button`,{type:`button`,disabled:!0,title:`Merge gated: ${n}`,className:`inline-flex cursor-not-allowed items-center gap-1.5 rounded-[var(--radius-sm)] border border-border bg-muted/40 px-3 py-2 text-[12px] font-medium text-muted-foreground opacity-80`,children:[`⛔ Merge — `,n]})}function Fbt({issueId:e,onPhase:t}){let n=wj(e),r=Ej(e),i=Cj(e),a=Bj(e),o=i.data?.sections.find(e=>e.type===`work`),s=Abt({hasPlan:a.state.hasPlan,rs:n.data,ci:r.data,work:o}),c=r.data?.summary;return(0,z.jsx)(`div`,{className:`flex items-stretch gap-1.5`,"data-testid":`cockpit-pipeline-progress`,children:[{key:`plan`,label:`Plan`,sub:s.plan===`done`?`approved`:void 0,state:s.plan},{key:`work`,label:`Work`,sub:s.work===`done`?`done`:s.work===`active`?`running`:void 0,state:s.work},{key:`review`,label:`Review`,sub:n.data?.reviewStatus,state:s.review},{key:`test`,label:`Test`,sub:n.data?.testStatus,state:s.test},{key:`ci`,label:`CI/CD`,sub:c?.total?`${c.passed}/${c.total}`:void 0,state:s.ci},{key:`ship`,label:`Ship`,sub:n.data?.mergeStatus&&n.data.mergeStatus!==`pending`?n.data.mergeStatus:void 0,state:s.ship},{key:`merge`,label:`Merge`,sub:s.merge===`active`?`ready`:void 0,state:s.merge}].map(e=>(0,z.jsxs)(`button`,{type:`button`,onClick:()=>t(e.key),className:`flex min-w-0 flex-1 flex-col gap-1.5 rounded-[8px] p-1 text-left transition-colors hover:bg-accent`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,z.jsx)(`span`,{className:`grid h-[15px] w-[15px] shrink-0 place-items-center rounded-full border text-[9px] ${wbt[e.state]}`,children:Dbt(e.state)}),(0,z.jsxs)(`span`,{className:`min-w-0 truncate text-[10.5px] text-muted-foreground`,children:[(0,z.jsx)(`span`,{className:`font-medium text-foreground`,children:e.label}),e.sub?` ${e.sub}`:``]})]}),(0,z.jsx)(`div`,{className:`h-[5px] rounded-full ${Cbt[e.state]}`})]},e.key))})}function Ibt({issueId:e}){let t=wj(e),n=Ej(e),r=Dj(e);return(0,z.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,"data-testid":`cockpit-gates`,children:Nbt(t.data,n.data,r.data?.pr??null).map(e=>(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full border border-border bg-card px-2.5 py-1 text-[11px]`,children:[(0,z.jsx)(`span`,{className:`h-2 w-2 rounded-[2px] ${Tbt[e.tone]}`}),(0,z.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:e.label}),(0,z.jsx)(`span`,{className:`text-foreground`,children:e.value})]},e.label))})}function Lbt({issueId:e}){let[t,n]=(0,R.useState)(!1),r=Bj(e),i=(0,R.useMemo)(()=>new Map(r.all.map(e=>[e.action.key,e])),[r.all]);(0,R.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Escape`&&n(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let a=(0,R.useMemo)(()=>Sbt.map(e=>({group:e,views:Ck.filter(t=>t.group===e).map(e=>i.get(e.key)).filter(e=>!!e)})).filter(e=>e.views.length>0),[i]);return(0,z.jsxs)(`div`,{className:`relative`,children:[(0,z.jsx)(`button`,{type:`button`,"aria-expanded":t,"aria-label":`Issue actions`,className:`inline-flex items-center rounded-[var(--radius-sm)] border border-border bg-card px-3 py-2 text-[12px] font-semibold text-foreground transition-colors hover:bg-accent`,onClick:()=>n(e=>!e),children:`⌘ Actions ▾`}),t&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>n(!1)}),(0,z.jsx)(`div`,{className:`absolute right-0 top-full z-50 mt-2 grid w-[min(560px,calc(100vw-48px))] grid-cols-1 gap-x-5 gap-y-2 rounded-[18px] border border-border bg-popover p-3 shadow-xl md:grid-cols-2`,children:a.map(({group:e,views:t})=>(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`h4`,{className:`mb-1.5 px-1 text-[10px] font-semibold uppercase tracking-[0.08em] text-muted-foreground`,children:xbt[e]}),(0,z.jsx)(`div`,{className:`flex flex-col gap-1`,children:t.map(e=>(0,z.jsx)(`button`,{type:`button`,disabled:!e.enabled||e.isPending,title:e.disabledReason??e.action.label,onClick:()=>{e.invoke(),e.action.kind!==`dialog`&&n(!1)},className:`rounded-[8px] px-2 py-1.5 text-left text-[12px] transition-colors disabled:cursor-not-allowed disabled:opacity-45 ${e.action.kind===`destructive`||e.action.group===`danger`?`text-destructive-foreground hover:bg-destructive/10`:`text-foreground hover:bg-accent`}`,children:e.isPending?`${e.action.label}…`:e.action.label},e.action.key))})]},e))})]}),(0,z.jsx)(Wj,{issueId:e,actions:r})]})}function Rbt(e){let t=e.type===`reviewer`?`reviewer`:e.type===`review`?`review`:e.type===`test`?`test`:e.type===`ship`?`ship`:e.type===`merge`?`merge`:e.type===`planning`?`planning`:e.type===`legacy`?`legacy`:e.type===`strike`?`strike`:e.type===`work`?`work`:null;if(!t)return null;let n=e.status===`completed`?`stopped`:e.status===`running`||e.status===`starting`||e.status===`error`||e.status===`stopped`?e.status:e.status?.toLowerCase().includes(`fail`)?`error`:e.status?.toLowerCase().includes(`run`)?`running`:`stopped`;return{type:t,sessionId:e.sessionId||`${t}-session`,model:e.model||`unknown`,startedAt:e.startedAt||new Date(0).toISOString(),duration:e.duration??null,status:n,presence:n===`running`||n===`starting`?`active`:`ended`}}function zbt(e){return e?.mergeStatus===`merged`?`Done`:e?.readyForMerge?`In Review`:e?.testStatus===`testing`?`Testing`:e?.reviewStatus===`reviewing`||e?.reviewStatus===`passed`||e?.reviewStatus===`blocked`||e?.reviewStatus===`failed`?`In Review`:`In Progress`}async function Bbt(e,t){let n=t.toLowerCase(),r=await fetch(`/api/issues/resource-allocated`);if(!r.ok)return null;let i=(await r.json()).find(t=>t.issueId.toLowerCase()===n&&(!e||t.projectName===e))??null,a=e??i?.projectName;if(!a)return i;let o=await fetch(`/api/session-trees?projects=${encodeURIComponent(a)}`);if(!o.ok)return i;let s=((await o.json()).trees??[]).find(e=>e.projectKey===a)?.features.find(e=>e.issueId.toLowerCase()===n);return!i&&!s?null:i?{...i,sessions:s?.sessions??i.sessions}:{issueId:t,title:s?.title??t,projectName:a,branch:``,status:s?.sessions.some(e=>e.presence===`active`)?`running`:`has_state`,stateLabel:`In Progress`,agentStatus:s?.sessions.some(e=>e.presence===`active`)?`running`:null,hasPlanning:s?.sessions.some(e=>e.type===`planning`||e.type===`legacy`)??!1,hasPrd:!1,hasState:!1,isShadow:!1,sessions:s?.sessions??[]}}function Vbt({issueId:e,title:t,projectName:n,selectedSessionId:r,onSelectSession:i,onSessionsChange:a,onOpenVerification:o}){let s=wj(e),c=Cj(e),l=Bj(e),u=B({queryKey:[`cockpit-project-feature`,n,e],queryFn:()=>Bbt(n,e),enabled:!0,staleTime:1e4}),d=(0,R.useMemo)(()=>{let t=(c.data?.sections??[]).map(e=>Rbt(e)).filter(e=>!!e);return l.state.hasPlan&&!t.some(e=>e.type===`planning`||e.type===`legacy`)&&t.push({type:`legacy`,sessionId:`${e}-planning-state`,model:`planning`,startedAt:new Date(0).toISOString(),duration:null,status:`stopped`,presence:`ended`}),t},[l.state.hasPlan,c.data?.sections,e]),f=(0,R.useMemo)(()=>({issueId:e,title:t,projectName:n??`Project`,branch:``,status:d.some(e=>e.presence===`active`)?`running`:l.state.hasPlan?`has_state`:`idle`,stateLabel:zbt(s.data),agentStatus:d.some(e=>e.presence===`active`)?`running`:null,hasPlanning:l.state.hasPlan,hasPrd:l.state.hasPlan,hasState:l.state.hasPlan,isShadow:!1,readyForMerge:s.data?.readyForMerge,sessions:d,resourceSources:[...l.state.hasPlan?[`vbrief`]:[],...l.state.hasBeads?[`beads`]:[],`workspace`],resourceDetails:{hasWorkspace:!0,localBranchCount:0,remoteBranchCount:0,tmuxSessionCount:d.length,prs:[],hasVbrief:l.state.hasPlan,hasBeads:l.state.hasBeads,dockerContainerCount:0}}),[l.state.hasBeads,l.state.hasPlan,e,n,s.data,d,t]),p=u.data??f,m=(0,R.useMemo)(()=>p.sessions??[],[p.sessions]),h=(0,R.useMemo)(()=>m.filter(e=>e.type===`reviewer`),[m]);return(0,R.useEffect)(()=>{a(m)},[a,m]),(0,z.jsxs)(`aside`,{className:`min-w-0 rounded-[20px] border border-border bg-card/50 p-2`,"aria-label":`Issue tree`,children:[h.length>0?(0,z.jsxs)(`div`,{className:`mb-2 rounded-[var(--radius-sm)] border border-amber-500/40 bg-amber-500/10 px-2.5 py-2 text-[11px]`,role:`alert`,children:[(0,z.jsx)(`div`,{className:`font-semibold text-amber-600 dark:text-amber-400`,children:`⚠ Stale review state`}),(0,z.jsxs)(`div`,{className:`mt-0.5 text-muted-foreground`,children:[h.length,` leftover review agent`,h.length===1?``:`s`,` from a previous cycle (extended-review sub-reviewers). A fresh review can’t run cleanly until they’re cleared.`]}),(0,z.jsx)(`button`,{type:`button`,className:`mt-1.5 rounded-[var(--radius-sm)] border border-destructive/50 px-2 py-1 text-[11px] font-medium text-destructive hover:bg-destructive hover:text-destructive-foreground`,onClick:()=>l.all.find(e=>e.action.key===`purgeReview`)?.invoke(),children:`Complete review reset`})]}):null,(0,z.jsx)(tbt,{issueId:e,sessions:m,feature:p,branch:p.branch||`feature/${e.toLowerCase()}`,selectedSessionId:r,onSelectSession:i,onOpenVerification:o})]})}function Hbt({context:e,issueId:t,selectedSession:n,treeSessions:r,launcher:i,agentDock:a,actionDock:o,timeline:s,onBackToIssue:c,onTab:l,onOpenAgent:u}){let d={issue:{title:t,summary:`Issue overview from the tree. Workspace tabs stay visible above this pane.`}},f=n?(0,z.jsx)(S_t,{session:n,issueId:t,reviewers:r.filter(e=>e.type===`reviewer`)}):e===`issue`?(0,z.jsx)(ext,{issueId:t,onTab:l,onOpenAgent:u}):(0,z.jsx)(txt,{launcher:i,agentDock:a,actionDock:o,timeline:s}),p=n?n.role?`${n.role[0]?.toUpperCase()??``}${n.role.slice(1)} reviewer`:`${n.type[0]?.toUpperCase()??``}${n.type.slice(1)} session`:d[e].title,m=n?`${n.sessionId} · ${n.status}`:d[e].summary;return(0,z.jsxs)(`div`,{className:`space-y-3.5`,"data-testid":`issue-tree-context-panel`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3 rounded-[16px] border border-border bg-card px-4 py-3`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`h2`,{className:`truncate text-[16px] font-semibold text-foreground`,children:p}),(0,z.jsx)(`p`,{className:`mt-1 truncate text-[12px] text-muted-foreground`,children:m})]}),(0,z.jsx)(`button`,{type:`button`,onClick:c,className:`shrink-0 rounded-[var(--radius-sm)] border border-border px-2.5 py-1.5 text-[12px] font-semibold text-foreground hover:bg-accent`,children:`Issue overview`})]}),f]})}function Ubt({checkRuns:e,compact:t=!1}){return e.length===0?(0,z.jsx)(`div`,{className:`text-[12px] text-muted-foreground`,children:`No GitHub check runs reported.`}):(0,z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e.slice(0,t?5:void 0).map(e=>{let t=cY({status:e.status,conclusion:e.conclusion??void 0}),n=(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`grid h-[18px] w-[18px] shrink-0 place-items-center rounded-full text-[10px]`,style:{background:t.bg,color:t.fg},children:t.label===`pass`?`✓`:t.label===`fail`?`✕`:t.label===`skip`?`–`:`•`}),(0,z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[12px] font-medium text-foreground`,children:e.name}),(0,z.jsx)(`span`,{className:`shrink-0 text-[10px] uppercase text-muted-foreground`,children:Obt(e)})]});return e.htmlUrl||e.detailsUrl?(0,z.jsx)(`a`,{href:e.htmlUrl??e.detailsUrl??`#`,target:`_blank`,rel:`noreferrer`,className:`flex items-center gap-2 rounded-[10px] border border-border bg-background/40 px-2.5 py-2 hover:bg-accent`,children:n},e.id||e.name):(0,z.jsx)(`div`,{className:`flex items-center gap-2 rounded-[10px] border border-border bg-background/40 px-2.5 py-2`,children:n},e.id||e.name)}),t&&e.length>5&&(0,z.jsxs)(`div`,{className:`text-[11px] text-muted-foreground`,children:[`+`,e.length-5,` more checks in PR & CI`]})]})}function Wbt({issueId:e}){let t=Ej(e),n=t.data,r=n?.summary,i=r?.failed||r?.cancelled?`destructive`:r?.running||r?.pending?`info`:r?.total?`success`:`muted`;return(0,z.jsxs)(z5,{tone:i,title:`GitHub CI/CD`,right:r?(0,z.jsxs)(B5,{tone:i,children:[r.passed,`/`,r.total,` pass`]}):void 0,children:[t.isLoading?(0,z.jsx)(`div`,{className:`text-[12px] text-muted-foreground`,children:`Loading GitHub checks…`}):null,!t.isLoading&&!n?.pr?(0,z.jsx)(`div`,{className:`text-[12px] text-muted-foreground`,children:`No pull request found for this issue.`}):null,n?.pr&&(0,z.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2 text-[12px] text-muted-foreground`,children:[(0,z.jsxs)(`a`,{href:n.pr.url,target:`_blank`,rel:`noreferrer`,className:`font-semibold text-foreground hover:underline`,children:[`PR #`,n.pr.number]}),(0,z.jsx)(`span`,{children:`·`}),(0,z.jsx)(`span`,{children:n.pr.mergeable??`mergeability unknown`}),(0,z.jsx)(`span`,{children:`·`}),(0,z.jsx)(`code`,{className:`text-[11px]`,children:n.pr.headRefName})]}),n?.error&&(0,z.jsx)(`div`,{className:`mb-3 rounded-[10px] border border-destructive/40 bg-destructive/10 px-3 py-2 text-[12px] text-destructive-foreground`,children:n.error}),(0,z.jsx)(Ubt,{checkRuns:n?.checkRuns??[]}),r&&r.total>0&&(0,z.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2 text-[11px] text-muted-foreground`,children:[(0,z.jsxs)(`span`,{children:[r.failed,` failed`]}),(0,z.jsxs)(`span`,{children:[r.running,` running`]}),(0,z.jsxs)(`span`,{children:[r.pending,` pending`]}),(0,z.jsxs)(`span`,{children:[r.skipped,` skipped`]})]})]})}function Gbt({issueId:e,field:t}){let n=Sj(e,{enabled:!0});return(0,z.jsx)(GY,{body:n.data?.[t],isLoading:n.isLoading,emptyLabel:`No ${t.toUpperCase()} document.`})}function Kbt({issueId:e}){return(0,z.jsxs)(`div`,{className:`grid gap-3 xl:grid-cols-2`,children:[(0,z.jsx)(z5,{tone:`info`,title:`vBRIEF`,children:(0,z.jsx)(uY,{issueId:e})}),(0,z.jsx)(z5,{tone:`muted`,title:`PRD draft`,children:(0,z.jsx)(Gbt,{issueId:e,field:`prd`})}),(0,z.jsx)(z5,{tone:`muted`,title:`STATE`,children:(0,z.jsx)(Gbt,{issueId:e,field:`state`})})]})}function qbt({title:e,description:t,action:n,onOpen:r}){return(0,z.jsxs)(z5,{tone:`muted`,title:e,children:[(0,z.jsx)(`p`,{className:`text-[12px] text-muted-foreground`,children:t}),(0,z.jsx)(`button`,{type:`button`,className:`mt-3 rounded-[var(--radius-sm)] border border-border px-3 py-2 text-[12px] font-semibold hover:bg-accent`,onClick:r,children:n})]})}var Jbt={work:`Work`,strike:`Strike`,review:`Review`,reviewer:`Reviewer`,test:`Test`,ship:`Ship`,merge:`Ship`,planning:`Plan`,legacy:`Plan`},Ybt=new Set([``,`unknown`,`specialist`,`planning`,`idle`,`none`]);function Xbt(e){let t=(e??``).trim();return Ybt.has(t.toLowerCase())?``:t.replace(/^claude-/,``)}var Zbt={info:`bg-info`,success:`bg-success`,warning:`bg-warning`,destructive:`bg-destructive`,review:`bg-signal-review`,cost:`bg-signal-cost`,muted:`bg-muted-foreground`};function Qbt(e,t){let n=t?Jbt[t.type]??t.type:``,r=t?Xbt(t.model):``,i=t?r?`${n.toLowerCase()} · ${r}`:n.toLowerCase():void 0;if(e?.mergeStatus===`merged`)return{tone:`success`,text:`Merged — ready to close out`};if(e?.readyForMerge)return{tone:`success`,text:`Review & tests passed — ready to merge`};if(e?.reviewStatus===`blocked`||e?.reviewStatus===`failed`){let e=t?.type===`work`;return{tone:`destructive`,text:e?`Review blocked — work agent is fixing it`:`Review blocked — awaiting the work agent`,agentType:e?`work`:void 0,agentLabel:e?i:void 0}}return e?.testStatus===`testing`?{tone:`info`,text:`Tests running`}:e?.verificationStatus===`running`?{tone:`info`,text:`Verification running`}:t?{tone:`info`,text:`${n} agent is working`,agentType:t.type,agentLabel:i}:{tone:`muted`,text:`Idle — awaiting the pipeline`}}function $bt({issueId:e,onTab:t,onOpenAgent:n}){let r=wj(e),i=Dj(e),a=Cj(e),o=r.data,s=i.data?.pr,c=a.data?.sections??[],l=c.find(e=>e.status===`running`||e.status===`active`||e.status===`starting`),u=c.some(e=>e.type===`work`),d=Qbt(o,l),f=[...o?.history??[]].sort((e,t)=>new Date(t.timestamp).getTime()-new Date(e.timestamp).getTime()).slice(0,3),p=new Date,m=`rounded-[8px] border border-border px-2.5 py-1 text-[11.5px] text-muted-foreground transition-colors hover:bg-accent`;return(0,z.jsxs)(`div`,{className:`rounded-[16px] border border-border bg-card p-4`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5 text-[13px]`,children:[(0,z.jsx)(`span`,{className:`h-[9px] w-[9px] shrink-0 rounded-full ${Zbt[d.tone]}`}),(0,z.jsx)(`span`,{children:d.text}),d.agentLabel&&(0,z.jsx)(`button`,{type:`button`,onClick:()=>d.agentType&&n(d.agentType),className:`rounded-[6px] border border-info/40 bg-info/10 px-1.5 font-mono text-[11px] text-info-foreground`,children:d.agentLabel})]}),(0,z.jsxs)(`div`,{className:`mt-2.5 text-[12.5px]`,children:[(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`Next:`}),` `,jbt(o),s&&(0,z.jsxs)(z.Fragment,{children:[` · `,(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`diff`}),` `,(0,z.jsxs)(`span`,{className:`text-success-foreground`,children:[`+`,s.additions]}),` `,(0,z.jsxs)(`span`,{className:`text-destructive-foreground`,children:[`−`,s.deletions]}),` · `,s.changedFiles,` file`,s.changedFiles===1?``:`s`]})]}),(0,z.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[u&&(0,z.jsx)(`button`,{type:`button`,className:m,onClick:()=>n(`work`),children:`Open work agent ↗`}),s&&(0,z.jsx)(`button`,{type:`button`,className:m,onClick:()=>t(`code`),children:`Open diff →`}),s?.url&&(0,z.jsx)(`a`,{className:m,href:s.url,target:`_blank`,rel:`noreferrer`,children:`Open PR ↗`})]}),f.length>0&&(0,z.jsxs)(`div`,{className:`mt-3.5`,children:[(0,z.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between text-[10px] uppercase tracking-[0.06em] text-muted-foreground`,children:[(0,z.jsx)(`span`,{children:`Recent activity`}),(0,z.jsx)(`button`,{type:`button`,className:`text-[10px] normal-case tracking-normal text-muted-foreground hover:text-foreground`,onClick:()=>t(`timeline`),children:`→ Timeline`})]}),f.map((e,t)=>(0,z.jsxs)(`div`,{className:`flex items-baseline gap-2.5 py-1 text-[12.5px]`,children:[(0,z.jsx)(`span`,{className:`mt-1.5 h-[7px] w-[7px] shrink-0 rounded-full ${Zbt[Ebt(e.status)]}`}),(0,z.jsxs)(`span`,{className:`capitalize`,children:[e.type,` `,e.status]}),(0,z.jsx)(`span`,{className:`ml-auto text-[10.5px] text-muted-foreground`,children:oM(e.timestamp,p)})]},`${e.type}-${e.timestamp}-${t}`))]})]})}function ext({issueId:e,onTab:t,onOpenAgent:n}){return(0,z.jsxs)(`div`,{className:`space-y-3.5`,children:[(0,z.jsx)(Wyt,{issueId:e}),(0,z.jsx)($bt,{issueId:e,onTab:t,onOpenAgent:n})]})}function txt({launcher:e,agentDock:t,actionDock:n,timeline:r}){return(0,z.jsxs)(`div`,{className:`space-y-3.5`,children:[(0,z.jsx)(z5,{tone:`info`,title:`Launch`,children:e}),(0,z.jsxs)(`div`,{className:`grid gap-3.5 xl:grid-cols-2`,children:[(0,z.jsx)(z5,{tone:`success`,title:`Agents`,children:t}),(0,z.jsx)(z5,{tone:`muted`,title:`Quick tools`,children:n})]}),(0,z.jsx)(z5,{tone:`warning`,title:`Conversation timeline`,children:r})]})}function nxt(e,t){return e===`code`&&t?.summary.total?{label:t.summary.failed?`!`:t.summary.running||t.summary.pending?`…`:`✓`,tone:t.summary.failed?`destructive`:t.summary.running||t.summary.pending?`info`:`success`}:null}function rxt({issueId:e,title:t,branch:n,projectName:r,launcher:i,agentDock:a,actionDock:o,timeline:s,onOpenPane:c}){let[l,u]=(0,R.useState)(`overview`),[d,f]=(0,R.useState)(null),[p,m]=(0,R.useState)(null),[h,g]=(0,R.useState)([]),_=wj(e),v=Dj(e),y=Ej(e),b=Tj(e),x=kbt(_.data),S=b.data?.resolvedTotalCost??b.data?.totalCost??0,C=e=>{u(e),f(null),m(null)},w=()=>{f(`issue`),m(null),u(null)},T=e=>{m(e),f(null),u(null)},E=e=>{let t=h.find(t=>t.type===e);return t?(T(t),!0):!1},D=e=>{if(e===`work`){E(`work`)||C(`overview`);return}if(e===`review`){E(`review`)||C(`overview`);return}if(e===`test`){E(`test`)||C(`overview`);return}if(e===`plan`){C(`plan`);return}if(e===`ci`){C(`code`);return}C(`overview`)},O=(0,R.useCallback)(e=>{g(e),m(t=>t&&(e.find(e=>e.sessionId===t.sessionId)??t))},[]);return(0,z.jsxs)(`div`,{className:H5.missionWrap,children:[(0,z.jsxs)(`header`,{className:`rounded-[22px] border border-border bg-card p-4`,children:[(0,z.jsxs)(`div`,{className:H5.headerTop,children:[(0,z.jsxs)(`div`,{className:H5.headerTitle,children:[(0,z.jsxs)(`div`,{className:`text-[11px] text-muted-foreground/70`,children:[r?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:r}),` / `]}):null,`Issues`]}),(0,z.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`font-mono text-[13px] font-medium text-foreground`,children:e}),(0,z.jsx)(`h1`,{className:`min-w-0 max-w-full break-words text-[16px] font-medium leading-snug text-foreground`,children:t}),(0,z.jsx)(B5,{tone:Ebt(x),children:x})]})]}),(0,z.jsxs)(`div`,{className:H5.headerMeta,children:[(0,z.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,z.jsx)(U5,{label:`Branch`,value:(0,z.jsx)(`span`,{className:`font-mono`,children:n})}),(0,z.jsx)(U5,{label:`PR / CI`,value:v.data?.pr?`#${v.data.pr.number}${y.data?.summary.total?` · ${y.data.summary.passed}/${y.data.summary.total}`:``}`:`no PR`}),(0,z.jsx)(U5,{label:`Cost`,value:(0,z.jsx)(`span`,{className:`text-signal-cost-foreground tabular-nums`,children:S>0?`$${S.toFixed(2)}`:`—`})})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(Pbt,{issueId:e,rs:_.data}),(0,z.jsx)(Lbt,{issueId:e})]})]})]}),(0,z.jsx)(`div`,{className:`mt-4 border-t border-border pt-4`,children:(0,z.jsx)(Fbt,{issueId:e,onPhase:D})}),(0,z.jsx)(`div`,{className:`mt-3`,children:(0,z.jsx)(Ibt,{issueId:e})})]}),(0,z.jsxs)(`div`,{className:H5.missionBody,children:[(0,z.jsx)(Vbt,{issueId:e,title:t,projectName:r,selectedSessionId:p?.sessionId??null,onSelectSession:T,onSessionsChange:O,onOpenVerification:()=>C(`overview`)}),(0,z.jsxs)(`main`,{className:`min-w-0 rounded-[20px] border border-border bg-card/30`,children:[(0,z.jsx)(`nav`,{className:`flex flex-wrap gap-1 border-b border-border bg-card px-3 pt-2`,"aria-label":`Issue cockpit tabs`,children:bbt.map(e=>{let t=nxt(e.id,y.data);return(0,z.jsxs)(`button`,{type:`button`,"aria-selected":l===e.id,onClick:()=>C(e.id),className:`relative top-px flex shrink-0 items-center gap-1.5 rounded-t-[10px] border px-3 py-2 text-[12px] font-semibold transition-colors ${l===e.id?`border-border border-b-card bg-card text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`}`,children:[e.label,t&&(0,z.jsx)(B5,{tone:t.tone,className:`px-[5px] py-0 text-[9px]`,children:t.label})]},e.id)})}),(0,z.jsxs)(`div`,{className:`p-4`,children:[(d||p)&&(0,z.jsx)(Hbt,{context:d??`issue`,issueId:e,selectedSession:p,treeSessions:h,launcher:i,agentDock:a,actionDock:o,timeline:s,onBackToIssue:w,onTab:C,onOpenAgent:E}),l===`overview`&&(0,z.jsx)(ext,{issueId:e,onTab:C,onOpenAgent:E}),l===`code`&&(0,z.jsxs)(`div`,{className:`space-y-3.5`,children:[(0,z.jsx)(Wbt,{issueId:e}),(0,z.jsx)(mbt,{issueId:e})]}),l===`plan`&&(0,z.jsx)(Kbt,{issueId:e}),l===`timeline`&&(0,z.jsxs)(`div`,{className:`space-y-4`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{className:`mb-2 text-[11px] font-medium uppercase tracking-[0.06em] text-muted-foreground`,children:`Status history`}),(0,z.jsx)(ybt,{issueId:e})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{className:`mb-2 text-[11px] font-medium uppercase tracking-[0.06em] text-muted-foreground`,children:`Activity`}),(0,z.jsx)(Dyt,{issueId:e})]})]}),l===`discussion`&&(0,z.jsx)(Iyt,{issueId:e}),l===`costs`&&(0,z.jsx)(jyt,{issueId:e}),l===`artifacts`&&(0,z.jsx)(Hyt,{issueId:e}),l===`conversation`&&(0,z.jsx)(txt,{launcher:i,agentDock:a,actionDock:o,timeline:s}),l===`files`&&(0,z.jsx)(qbt,{title:`Files`,description:`Open the issue-scoped workspace file browser in a deck pane.`,action:`Open files pane`,onOpen:()=>c(`files`)}),l===`terminal`&&(0,z.jsx)(qbt,{title:`Terminal`,description:`Open the issue terminal drawer for the current workspace.`,action:`Open terminal`,onOpen:()=>c(`terminal`)}),l===`beads`&&(0,z.jsx)(dY,{issueId:e})]})]}),(0,z.jsx)(obt,{issueId:e,onOpenFull:()=>C(`beads`)})]})]})}function ixt({issueId:e,title:t,branch:n,projectName:r,agentId:i,conversations:a=[],onCreateConversation:o,api:s}){let c=(0,R.useMemo)(()=>a.filter(t=>(t.issueId??``).toUpperCase()===e.toUpperCase()),[a,e]),l=(0,R.useMemo)(()=>c.map(e=>({id:e.name,agentLabel:e.title??e.model??`Agent`,timestamp:e.lastAttachedAt??e.createdAt,preview:e.title??void 0})),[c]),u=async(t,n)=>{l5(e,t);let r=await o?.(t,n,`terminal`);r&&s.openOrFocusAgentPane(r,`Agent`)},d=()=>s.toggleTerminal(),f={files:`Files`,commits:`Commits`,plan:`Plan`,docs:`Docs`},p=t=>{if(t===`terminal`)return s.toggleTerminal();if(t===`browser`)return s.openPane({paneType:`browser`,label:`Web`});s.openPane({paneType:t,label:f[t]??`Pane`,issueId:e,agentId:i})},m=(0,z.jsx)(X_t,{lastUsedAgentId:K_t(e),onSelect:(t,n)=>cvt(t,n,{openAgent:(e,t)=>u(e.id,t),openTerminal:d,openWeb:(e,t)=>s.openPane({paneType:`browser`,label:`Web`,browserInitialUrl:t}),onAgentRun:t=>l5(e,t)})}),h=(0,z.jsx)(p5,{conversations:l,onOpen:e=>{let t=c.find(t=>t.name===e);s.openOrFocusAgentPane(e,t?.title??`Agent`)}});return(0,z.jsx)(rxt,{issueId:e,title:t,branch:n??`feature/${e.toLowerCase()}`,projectName:r,launcher:m,agentDock:(0,z.jsx)(u5,{onSelectAgent:u}),actionDock:(0,z.jsx)(d5,{onOpen:p}),timeline:h,onOpenPane:p})}function axt(e,t){let n=e instanceof Date?e:new Date(e),r=t.getTime()-n.getTime();if(r<=3e5)return`Just Now`;if(sxt(n,t))return cxt(n);let i=new Date(t);return i.setDate(t.getDate()-1),sxt(n,i)?`Yesterday ${lxt(n)} · ${cxt(n)}`:r>=0&&r<=10080*60*1e3?`${uxt(n)} ${lxt(n)}`:n.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,...n.getFullYear()===t.getFullYear()?{}:{year:`numeric`}})}function oxt(e,t){let n=[];for(let r of e){let e=t(r),i=n.at(-1);i?.label===e?i.items.push(r):n.push({label:e,items:[r]})}return n}function sxt(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function cxt(e){return e.toLocaleTimeString(`en-US`,{hour:`numeric`})}function lxt(e){return e.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`})}function uxt(e){return e.toLocaleDateString(`en-US`,{weekday:`long`})}function dxt({entry:e,onSelect:t,now:n=new Date}){let r=[e.workspaceId,e.issueId].filter(Boolean),i=r.length>0?r.join(` · `):e.summary;return(0,z.jsx)(`button`,{type:`button`,className:`w-full rounded-lg border border-border bg-card p-2.5 text-left text-xs transition-colors hover:bg-accent/40 focus:outline-none focus:ring-2 focus:ring-ring`,onClick:()=>t(e.id),title:e.headline,children:(0,z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,z.jsx)(`span`,{className:`mt-1.5 h-1.5 w-1.5 shrink-0 rounded-full bg-primary`}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`p`,{className:`break-words font-medium text-foreground`,children:e.headline}),(0,z.jsxs)(`div`,{className:`mt-1 flex min-w-0 items-center justify-between gap-2 text-[10px] text-muted-foreground`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[e.statusLabel?(0,z.jsx)(C5,{status:e.statusLabel}):null,(0,z.jsx)(`span`,{className:`truncate`,children:i}),(0,z.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:`·`}),(0,z.jsx)(`time`,{dateTime:e.timestamp,className:`shrink-0`,children:oM(e.timestamp,n)})]}),(0,z.jsx)(PM,{kind:e.activityClass??`operational`,className:`shrink-0`})]})]})]})})}var fxt={active:`bg-info`,waiting:`bg-warning`,idle:`bg-muted-foreground/60`},pxt={claude_code:`Claude Code`,pi:`Pi`,unknown:`Unknown`};function mxt({entry:e,onSelect:t,now:n=new Date}){let r=gxt(e),i=pxt[e.agent]??e.agent;return(0,z.jsx)(`button`,{type:`button`,className:`w-full rounded-lg border border-border bg-card p-2.5 text-left text-xs transition-colors hover:bg-accent/40 focus:outline-none focus:ring-2 focus:ring-ring`,onClick:()=>t(e.id),children:(0,z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,z.jsx)(`span`,{"data-testid":`conversation-feed-agent-icon`,className:`mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center`,children:(0,z.jsx)(hE,{harness:hxt(e.agent),className:`h-4 w-4`})}),(0,z.jsx)(`span`,{className:`mt-2 h-1.5 w-1.5 shrink-0 rounded-full ${fxt[r]}`}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`max-w-[120px] truncate font-medium text-foreground`,children:i}),(0,z.jsx)(`time`,{dateTime:e.lastMessageDate,className:`shrink-0 text-[10px] text-muted-foreground`,children:oM(e.lastMessageDate,n)})]}),(0,z.jsx)(`p`,{className:`mt-1 line-clamp-2 text-muted-foreground`,children:e.lastMessageSnippet}),(e.messageCount!==void 0||e.threadLabel&&e.threadIsPrimary===!1)&&(0,z.jsxs)(`div`,{className:`mt-2 flex items-center gap-2 text-[10px] text-muted-foreground`,children:[e.messageCount!==void 0&&(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,z.jsx)(sr,{className:`h-3 w-3`,"aria-hidden":`true`}),e.messageCount]}),e.threadLabel&&e.threadIsPrimary===!1&&(0,z.jsx)(`span`,{className:`rounded-full bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground`,children:e.threadLabel})]})]})]})})}function hxt(e){return e===`ohmypi`||e===`pi`?`ohmypi`:e===`codex`?`codex`:`claude-code`}function gxt(e){let t=e.agentState;return t===`active`||t===`waiting`||t===`idle`?t:`idle`}function _xt({entry:e,onSelect:t,now:n=new Date}){return(0,z.jsx)(`button`,{type:`button`,className:`w-full rounded-lg border border-border bg-card p-2.5 text-left text-xs transition-colors hover:bg-accent/40 focus:outline-none focus:ring-2 focus:ring-ring`,onClick:()=>t(e.id),children:(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,z.jsx)(vxt(e.source),{"data-testid":`git-feed-icon`,className:`h-4 w-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,z.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-foreground`,children:e.message}),e.issueId&&(0,z.jsx)(`span`,{className:`shrink-0 rounded-full bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground`,children:e.issueId}),(0,z.jsx)(`time`,{dateTime:e.timestamp,className:`shrink-0 text-[10px] text-muted-foreground`,children:oM(e.timestamp,n)})]})})}function vxt(e){return e.toLowerCase().includes(`branch`)?Hn:Un}function yxt({label:e,items:t,onSelect:n,now:r}){return(0,z.jsxs)(`section`,{className:`space-y-2`,children:[(0,z.jsx)(`h3`,{className:`px-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:e}),(0,z.jsx)(`div`,{className:`space-y-2`,children:t.map(e=>bxt(e,n,r))})]})}function bxt(e,t,n){let r=()=>t(e);switch(e.kind){case`conversation`:return(0,z.jsx)(mxt,{entry:e,onSelect:r,now:n},e.id);case`activity`:return(0,z.jsx)(dxt,{entry:e,onSelect:r,now:n},e.id);case`git`:return(0,z.jsx)(_xt,{entry:e,onSelect:r,now:n},e.id);case`file_change`:case`comment`:case`placeholder`:return null}}var xxt=new Set([`dashboard`,`supervisor`,`deploy-script`]);function Sxt(){let e,t;return n=>{let r=n.recentActivity;if(r===e&&t)return t;e=r,t=r.map(e=>{let t=typeof e.id==`string`?e.id:null,n=typeof e.timestamp==`string`?e.timestamp:null;if(!t||!n)return null;let r=typeof e.message==`string`?e.message:``,i=typeof e.source==`string`?e.source:`unknown`,a=typeof e.level==`string`?e.level:``,o=typeof e.details==`string`?e.details:void 0,s=typeof e.issueId==`string`?e.issueId:null,c=typeof e.link==`string`?e.link:void 0;return{kind:`activity`,activityClass:`operational`,id:t,timestamp:n,workspaceId:null,issueId:s,headline:r||i,summary:i,narrative:o,files:[],tags:a?[i,a]:[i],link:c,systemWide:xxt.has(i)}}).filter(e=>e!==null).sort((e,t)=>t.timestamp.localeCompare(e.timestamp));let i=new Set;return t=t.filter(e=>{if(e.issueId&&e.headline.startsWith(`Review role spawned`)){if(i.has(e.issueId))return!1;i.add(e.issueId)}return!0}).slice(0,500),t}}var Cxt=Sxt();function wxt(){return sm(Cxt)}async function Txt(){let e=await fJ(`/api/conversations`);if(!e.ok)throw Error(`Failed to fetch conversations`);return e.json()}function Ext(e){let t=e.lastActivityAt??e.lastAttachedAt??e.createdAt;return{kind:`conversation`,id:`conversation:${e.name}`,timestamp:t,workspaceId:e.cwd??null,issueId:e.issueId,conversationId:e.id,conversationName:e.name,agent:kxt(e.harness),lastMessageDate:t,lastMessageSnippet:e.title??`No messages yet`,...e.messageCount===void 0?{}:{messageCount:e.messageCount}}}function Dxt(e){return e.filter(e=>e.archivedAt==null).map(Ext)}function Oxt(){let e=B({queryKey:[`conversations`],queryFn:Txt,refetchInterval:3e4,staleTime:5e3}),t=e.data??[];return{entries:(0,R.useMemo)(()=>Dxt(t),[t]),isLoading:e.isLoading,error:e.error instanceof Error?e.error:null}}function kxt(e){return e===`claude-code`?`claude_code`:e===`ohmypi`?`pi`:e===`codex`?`codex`:`unknown`}async function Axt(){try{let e=await fetch(`/api/git-activity`);return e.ok?{entries:await e.json(),error:null}:{entries:[],error:Error(`Failed to fetch git activity`)}}catch(e){return{entries:[],error:e instanceof Error?e:Error(String(e))}}}function jxt(e){return{kind:`git`,id:e.id,timestamp:e.timestamp,workspaceId:null,issueId:e.issueId??null,source:e.source,level:e.level,message:e.message,details:e.details,category:e.category,triggeringEvent:e.triggeringEvent}}function Mxt(){let e=B({queryKey:[`session-feed-git`],queryFn:Axt,refetchInterval:15e3,staleTime:5e3}),t=e.data?.entries??[];return{entries:(0,R.useMemo)(()=>t.map(jxt),[t]),isLoading:e.isLoading,error:e.data?.error??(e.error instanceof Error?e.error:null)}}function Nxt(){let e,t;return n=>{let r=n.observationsByIssueId;return r===e&&t?t:(e=r,t=Object.values(r).flatMap(e=>e).filter(e=>e.actionStatus!==null).sort((e,t)=>t.timestamp.localeCompare(e.timestamp)).slice(0,500).map(e=>({kind:`activity`,activityClass:`memory`,id:e.id,timestamp:e.timestamp,workspaceId:e.workspaceId,issueId:e.issueId,headline:e.summary,statusLabel:e.actionStatus,summary:e.summary,narrative:e.narrative,files:e.files,tags:e.tags})),t)}}var Pxt=Nxt();function Fxt(){return sm(Pxt)}function Ixt(...e){let t=new Map;for(let n of e)for(let e of n)t.has(e.id)||t.set(e.id,e);return[...t.values()].sort((e,t)=>t.timestamp.localeCompare(e.timestamp))}function Lxt(e,t){switch(t){case`all`:return[...e];case`chats`:return e.filter(e=>e.kind===`conversation`);case`activity`:return e.filter(e=>e.kind===`activity`);case`git`:return e.filter(e=>e.kind===`git`);case`files`:case`comments`:return[]}}function Rxt(e){let t=Oxt(),n=Fxt(),r=wxt(),i=Mxt(),a=(0,R.useMemo)(()=>Ixt(t.entries,r,n,i.entries),[t.entries,r,n,i.entries]);return{entries:(0,R.useMemo)(()=>Lxt(a,e),[a,e]),allEntries:a,isLoading:t.isLoading||i.isLoading,error:t.error??i.error}}function zxt(e,t){if(e.has(t))return e;let n=new Set(e);return n.add(t),n}function Bxt(e,t){if(!e.has(t))return e;let n=new Set(e);return n.delete(t),n}function Vxt(e,t){let n=!1,r=new Set;for(let i of e)t.has(i)?r.add(i):n=!0;return n?r:e}var W5=ri(e=>({reopenId:null,reopenNonce:0,requestReopen:t=>e(e=>({reopenId:t,reopenNonce:e.reopenNonce+1})),answeredToolUseIds:new Set,dismissedSubjectIds:new Set,markAnswered:t=>e(e=>({answeredToolUseIds:zxt(e.answeredToolUseIds,t)})),unmarkAnswered:t=>e(e=>({answeredToolUseIds:Bxt(e.answeredToolUseIds,t)})),markDismissed:t=>e(e=>({dismissedSubjectIds:zxt(e.dismissedSubjectIds,t)})),undismiss:t=>e(e=>({dismissedSubjectIds:Bxt(e.dismissedSubjectIds,t)})),reconcileAnswered:t=>e(e=>({answeredToolUseIds:Vxt(e.answeredToolUseIds,t)})),reconcileDismissed:t=>e(e=>({dismissedSubjectIds:Vxt(e.dismissedSubjectIds,t)}))})),Hxt=`overdeck.ui.sessionFeedSidebarTab`,Uxt=`overdeck.ui.awarenessScope`,Wxt=[{id:`all`,label:`All`},{id:`chats`,label:`Chats`},{id:`files`,label:`Files`},{id:`git`,label:`Git`},{id:`comments`,label:`Comments`},{id:`activity`,label:`Activity`}],Gxt={all:`No session activity yet.`,chats:`No chats yet.`,files:`Files feed coming soon.`,git:`No git activity yet.`,comments:`Comments feed coming soon.`,activity:`No activity updates yet.`},Kxt=!1;function qxt({onClose:e,onSelect:t=tSt,now:n=new Date,issueIds:r,unscoped:i,heading:a=`Activity Feed`,embedded:o=!1,scopeSwitcher:s=!1,projectIssueIds:c}){let[l,u]=(0,R.useState)(Qxt),[d,f]=(0,R.useState)($xt);(0,R.useEffect)(()=>{typeof window>`u`||window.localStorage.setItem(Hxt,l)},[l]),(0,R.useEffect)(()=>{typeof window>`u`||window.localStorage.setItem(Uxt,d)},[d]);let p=sm(dm),m=s?p.length:0,h=s?d===`project`?c:void 0:r,g=s?!1:i,_=!s||d!==`needs`;return(0,z.jsxs)(`aside`,{className:`flex h-full min-h-0 flex-col bg-background ${o?`w-full`:`w-80 shrink-0 border-l border-border`}`,"aria-label":`Session activity feed`,children:[(0,z.jsxs)(`header`,{className:`flex items-center justify-between border-b border-border px-3 py-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-foreground`,children:[(0,z.jsx)(Xn,{className:`h-4 w-4`,"aria-hidden":`true`}),a]}),e&&(0,z.jsx)(`button`,{type:`button`,className:`rounded p-1 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus:outline-none focus:ring-2 focus:ring-ring`,"aria-label":`Close activity feed`,onClick:e,children:(0,z.jsx)(zr,{className:`h-4 w-4`,"aria-hidden":`true`})})]}),s&&(0,z.jsx)(`div`,{role:`tablist`,"aria-label":`Awareness scope`,className:`grid grid-cols-3 gap-1 border-b border-border p-2`,children:[{id:`needs`,label:`Needs you`,badge:m},{id:`project`,label:`Project`,badge:0},{id:`global`,label:`Global`,badge:0}].map(e=>(0,z.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":d===e.id,className:d===e.id?`flex items-center justify-center gap-1.5 rounded-md bg-accent px-2 py-1 text-xs font-medium text-foreground`:`flex items-center justify-center gap-1.5 rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-accent/60 hover:text-foreground`,onClick:()=>f(e.id),children:[e.label,e.badge>0&&(0,z.jsx)(`span`,{className:`rounded bg-amber-500/20 px-1 text-[10px] font-semibold text-amber-600 dark:text-amber-400`,children:e.badge})]},e.id))}),(0,z.jsx)(Jxt,{issueIds:h,unscoped:g,showEmpty:s&&d===`needs`}),_&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{role:`tablist`,"aria-label":`Session feed tabs`,className:`grid grid-cols-3 gap-1 border-b border-border p-2`,children:Wxt.map(e=>(0,z.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":l===e.id,className:l===e.id?`rounded-md bg-accent px-2 py-1 text-xs font-medium text-foreground`:`rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-accent/60 hover:text-foreground`,onClick:()=>u(e.id),children:e.label},e.id))}),(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-3`,children:Zxt(l)?(0,z.jsx)(Xxt,{tab:l}):(0,z.jsx)(Yxt,{tab:l,onSelect:t,now:n,issueIds:h,unscoped:g})})]})]})}function Jxt({issueIds:e,unscoped:t,showEmpty:n=!1}){let r=sm(dm),i=sm(fm),a=W5(e=>e.requestReopen),o=W5(e=>e.answeredToolUseIds),s=W5(e=>e.dismissedSubjectIds),c=(0,R.useMemo)(()=>{let e=new Map;for(let t of i)t?.id&&t.title&&e.set(t.id,t.title);return e},[i]),l=(0,R.useMemo)(()=>{if(t||!e||e.length===0)return r;let n=new Set(e.map(e=>e.toLowerCase()));return r.filter(e=>e.issueId&&n.has(e.issueId.toLowerCase()))},[r,e,t]),u=(0,R.useMemo)(()=>{let e=new Set,t=[];for(let n of l){let r=n.pendingAskUserQuestion?.toolUseId;if(r&&o.has(r)||s.has(n.agentId))continue;let i=n.pendingAskUserQuestion,a=i?.questions?.length??0,l=i?.questions?.[0]?.question??tM(n.kinds),u=n.issueId&&c.get(n.issueId)||n.issueId||n.agentId,d=r??`${n.issueId??n.agentId}::${u}::${l}`;e.has(d)||(e.add(d),t.push({key:d,agentId:n.agentId,label:u,detail:l,count:a,title:tM(n.kinds)}))}return t},[l,o,s,c]);return l.length===0?n?(0,z.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-6 text-center text-xs text-muted-foreground`,children:`Nothing needs you right now.`}):null:(0,z.jsxs)(`div`,{className:`border-b border-amber-500/30 bg-amber-500/5 px-2 py-2`,children:[(0,z.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 px-1 text-xs font-semibold uppercase tracking-wide text-amber-600 dark:text-amber-400`,children:[(0,z.jsx)(Ir,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),`Needs you`]}),(0,z.jsx)(`div`,{className:`flex flex-col gap-1`,children:(0,z.jsx)(GH,{initial:!1,children:u.map(e=>(0,z.jsxs)(cJ.button,{layout:!0,initial:{opacity:0,height:0,y:-4},animate:{opacity:1,height:`auto`,y:0},exit:{opacity:0,height:0,y:-4},transition:{duration:.18,ease:`easeOut`},type:`button`,onClick:()=>a(e.agentId),className:`flex w-full flex-col items-start gap-0.5 overflow-hidden rounded border border-amber-500/30 bg-background px-2 py-1.5 text-left transition-colors hover:border-amber-500/60 hover:bg-amber-500/10`,title:e.title,children:[(0,z.jsxs)(`span`,{className:`text-xs font-medium text-foreground`,children:[e.label,e.count>1?` · ${e.count} questions`:``]}),(0,z.jsx)(`span`,{className:`w-full truncate text-xs text-muted-foreground`,children:e.detail})]},e.key))})})]})}function Yxt({tab:e,onSelect:t,now:n,issueIds:r,unscoped:i}){let a=Rxt(e),o=(0,R.useMemo)(()=>r?new Set(r.map(e=>e.toLowerCase())):null,[r]),s=(0,R.useMemo)(()=>{let e=e=>e.kind===`activity`&&e.systemWide?!0:i?e.issueId==null:!o||!!e.issueId&&o.has(e.issueId.toLowerCase());return{entries:i||o?a.entries.filter(e):a.entries,allEntries:i||o?a.allEntries.filter(e):a.allEntries}},[a.entries,a.allEntries,o,i]),c=s.entries,l=s.allEntries,u=(0,R.useMemo)(()=>oxt(c,e=>axt(e.timestamp,n)),[c,n]),d=e===`all`?l.length===0:c.length===0;return a.error?(0,z.jsx)(`p`,{className:`text-xs text-destructive`,children:a.error.message}):a.isLoading?(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Loading activity…`}):d?(0,z.jsx)(`div`,{"data-testid":`session-feed-empty-${e}`,className:`rounded-lg border border-dashed border-border p-4 text-center text-xs text-muted-foreground`,children:Gxt[e]}):(0,z.jsx)(`div`,{className:`space-y-4`,children:u.map(e=>(0,z.jsx)(yxt,{label:e.label,items:e.items,onSelect:t,now:n},`${e.label}-${e.items[0]?.id??`empty`}`))})}function Xxt({tab:e}){let t=e===`files`?`Aggregate file changes are not wired into the session feed yet.`:`Issue comments are not cached for the session feed yet.`;return(0,z.jsxs)(`div`,{"data-testid":`session-feed-empty-${e}`,className:`rounded-lg border border-dashed border-border p-4 text-center text-xs text-muted-foreground`,children:[(0,z.jsx)(`p`,{className:`font-medium text-foreground`,children:Gxt[e]}),(0,z.jsx)(`p`,{className:`mt-1`,children:t})]})}function Zxt(e){return e===`files`||e===`comments`}function Qxt(){if(typeof window>`u`)return`all`;let e=window.localStorage.getItem(Hxt);return eSt(e)?e:`all`}function $xt(){if(typeof window>`u`)return`project`;let e=window.localStorage.getItem(Uxt);return e===`needs`||e===`project`||e===`global`?e:`project`}function eSt(e){return e===`all`||e===`chats`||e===`files`||e===`git`||e===`comments`||e===`activity`}function tSt(e){if(!(typeof window>`u`))switch(e.kind){case`conversation`:G5(`/conv/${encodeURIComponent(e.conversationName)}`);return;case`activity`:if(e.link){G5(e.link);return}e.issueId&&G5(`/command-deck?issue=${encodeURIComponent(e.issueId)}&tab=activity`);return;case`git`:Kxt||=(console.debug(`Session feed git entries do not have a destination yet.`),!0);return;case`file_change`:case`comment`:case`placeholder`:return}}function G5(e){window.history.pushState(null,``,e),window.dispatchEvent(new PopStateEvent(`popstate`))}var nSt=`__no-project__`,rSt=`No project`;function iSt(e,t){let n=e.cwd;return n?!t.some(e=>e.path&&(n===e.path||n.startsWith(e.path+`/`))):!0}function aSt(e){let t=new Map;for(let n of e){let e=t.get(n.projectName);if(e){e.features.push(n);continue}t.set(n.projectName,{name:n.projectName,path:n.projectName,features:[n]})}return[...t.values()].map(e=>({...e,features:[...e.features].sort((e,t)=>e.issueId.localeCompare(t.issueId))})).sort((e,t)=>e.name.localeCompare(t.name))}async function K5(){let[e,t]=await Promise.all([fetch(`/api/issues/resource-allocated`),fetch(`/api/registered-projects`)]);if(!e.ok)throw Error(`Failed to fetch resource-allocated issues`);if(!t.ok)throw Error(`Failed to fetch registered projects`);let n=await e.json(),r=await t.json(),i=new Map(aSt(n).map(e=>[e.name,e]));for(let e of r){let t=e.name??e.key;i.has(t)||i.set(t,{name:t,path:e.path,features:[]})}return[...i.values()].sort((e,t)=>e.name.localeCompare(t.name))}function oSt({issueId:e,isOpen:t,onClose:n}){let{data:r,isLoading:i,isFetching:a,error:o}=B({queryKey:[`beads`,e],queryFn:async()=>{let t=await fetch(`/api/issues/${e}/beads`);if(!t.ok)throw Error(`Failed to fetch tasks`);return t.json()},enabled:t,staleTime:0,refetchOnMount:`always`});if(!t)return null;let s=r?.tasks?.filter(e=>e.status!==`closed`)||[],c=r?.tasks?.filter(e=>e.status===`closed`)||[];return(0,z.jsxs)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center`,children:[(0,z.jsx)(`div`,{className:`absolute inset-0 bg-black/70 backdrop-blur-sm`,onClick:n}),(0,z.jsxs)(`div`,{className:`relative bg-card rounded-xl shadow-2xl w-full max-w-lg mx-4 max-h-[70vh] overflow-hidden flex flex-col`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b border-border`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(ir,{className:`w-5 h-5 text-success`}),(0,z.jsxs)(`h2`,{className:`font-semibold text-foreground`,children:[`Tasks: `,e]})]}),(0,z.jsx)(`button`,{onClick:n,className:`p-1 text-muted-foreground hover:text-foreground hover:bg-popover rounded transition-colors`,children:(0,z.jsx)(zr,{className:`w-5 h-5`})})]}),(0,z.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4`,children:[(i||a)&&!r?.tasks?.length&&(0,z.jsxs)(`div`,{className:`space-y-2`,children:[[1,2,3].map(e=>(0,z.jsxs)(`div`,{className:`flex items-start gap-3 p-3 rounded-lg border border-border bg-popover/30 animate-pulse`,children:[(0,z.jsx)(`div`,{className:`w-4 h-4 bg-card rounded-full mt-0.5`}),(0,z.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,z.jsx)(`div`,{className:`h-4 bg-card rounded w-3/4`}),(0,z.jsx)(`div`,{className:`h-3 bg-popover rounded w-1/4`})]})]},e)),(0,z.jsxs)(`div`,{className:`flex items-center justify-center py-2 text-muted-foreground text-sm`,children:[(0,z.jsx)(ar,{className:`w-4 h-4 animate-spin mr-2`}),`Loading tasks from workspace...`]})]}),o&&(0,z.jsx)(`div`,{className:`text-destructive text-center py-8`,children:`Failed to load tasks`}),r&&r.tasks?.length===0&&!a&&(0,z.jsxs)(`div`,{className:`text-muted-foreground text-center py-8`,children:[(0,z.jsx)(ir,{className:`w-8 h-8 mx-auto mb-2 opacity-50`}),(0,z.jsx)(`p`,{children:`No tasks created yet`}),(0,z.jsx)(`p`,{className:`text-xs mt-2`,children:`Tasks will appear here once created using beads.`})]}),r&&r.tasks?.length>0&&(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-4 text-xs text-muted-foreground mb-3 pb-3 border-b border-border`,children:[(0,z.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,z.jsx)(`div`,{className:`w-2 h-2 bg-primary rounded-full`}),s.length,` open`]}),(0,z.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,z.jsx)(on,{className:`w-3 h-3 text-success`}),c.length,` closed`]})]}),s.map(e=>(0,z.jsx)(sSt,{task:e},e.id)),c.length>0&&s.length>0&&(0,z.jsx)(`div`,{className:`text-xs text-muted-foreground mt-4 mb-2`,children:`Completed`}),c.map(e=>(0,z.jsx)(sSt,{task:e},e.id))]})]}),(0,z.jsxs)(`div`,{className:`px-4 py-3 border-t border-border text-xs text-muted-foreground flex items-center justify-between`,children:[(0,z.jsxs)(`span`,{children:[r?.count||0,` task`,r?.count===1?``:`s`]}),(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`Beads`})]})]})]})}function sSt({task:e}){let t={open:`bg-popover/50 border-border`,in_progress:`badge-bg-primary border-primary/40`,closed:`badge-bg-success border-success/30 opacity-60`},n={open:(0,z.jsx)(`div`,{className:`w-4 h-4 border-2 border-border rounded-full`}),in_progress:(0,z.jsx)(ar,{className:`w-4 h-4 text-primary animate-spin`}),closed:(0,z.jsx)(on,{className:`w-4 h-4 text-success`})};return(0,z.jsxs)(`div`,{className:`flex items-start gap-3 p-3 rounded-lg border ${t[e.status]}`,children:[(0,z.jsx)(`div`,{className:`mt-0.5`,children:n[e.status]}),(0,z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,z.jsx)(`div`,{className:`text-sm text-foreground`,children:e.title}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2 mt-1 flex-wrap`,children:[(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.id}),e.blockedBy.length>0&&(0,z.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-warning`,children:[(0,z.jsx)(hn,{className:`w-3 h-3`}),`Blocked`]}),e.labels.filter(e=>e.startsWith(`difficulty:`)).map(e=>(0,z.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded ${e.includes(`simple`)||e.includes(`trivial`)?`badge-bg-success text-success`:e.includes(`medium`)?`badge-bg-warning text-warning`:e.includes(`complex`)||e.includes(`hard`)?`badge-bg-destructive text-destructive`:`bg-popover text-foreground`}`,children:e.replace(`difficulty:`,``)},e))]})]})]})}var cSt={selectedSessionByIssue:{},draftTexts:{}},lSt=ri(e=>({...cSt,selectSession:(t,n)=>e(e=>({selectedSessionByIssue:{...e.selectedSessionByIssue,[t]:n}})),clearIssue:t=>e(e=>{if(!(t in e.selectedSessionByIssue))return e;let{[t]:n,...r}=e.selectedSessionByIssue;return{selectedSessionByIssue:r}}),clearAll:()=>e({selectedSessionByIssue:{}}),setDraft:(t,n)=>e(e=>({draftTexts:{...e.draftTexts,[t]:n}})),clearDraft:t=>e(e=>{if(!(t in e.draftTexts))return e;let{[t]:n,...r}=e.draftTexts;return{draftTexts:r}})})),uSt=new Set([`review`,`reviewer`]),dSt=new Set([`test`,`ship`,`merge`]);function fSt(e){if(!e.sessionType||e.sessionType===`work`)return null;if(uSt.has(e.sessionType)){if(!e.projectKey)throw Error(`Cannot find project for ${e.issueId}`);return{endpoint:`/api/specialists/${encodeURIComponent(e.projectKey)}/${encodeURIComponent(e.issueId)}/review/restart`,body:{...e.model?{model:e.model}:{},...e.harness?{harness:e.harness}:{}},successMessage:`Review restarted`,errorMessage:`Failed to restart review`}}if(dSt.has(e.sessionType)){let t=e.sessionType.charAt(0).toUpperCase()+e.sessionType.slice(1);return{endpoint:`/api/agents/${encodeURIComponent(e.sessionId)}/restart`,body:{...e.model?{model:e.model}:{},...e.harness?{harness:e.harness}:{},graceful:!1},successMessage:`${t} restarted`,errorMessage:`Failed to restart ${e.sessionType} agent`}}return null}async function pSt(){let e=await fJ(`/api/conversations`);if(!e.ok)throw Error(`Failed to fetch conversations`);return e.json()}async function mSt(){let e=await fetch(`/api/costs/by-issue`);if(!e.ok)throw Error(`Failed to fetch costs`);return e.json()}async function hSt(){let e=await fetch(`/api/version`);if(!e.ok)throw Error(`Failed to fetch version`);return e.json()}async function gSt(){let e=await fetch(`/api/registered-projects`);if(!e.ok)throw Error(`Failed to fetch registered projects`);let t=await e.json();return Array.isArray(t)?t:[]}async function _St(e){if(e.length===0)return[];let t=await fetch(`/api/session-trees?projects=${encodeURIComponent(e.join(`,`))}`);if(!t.ok)throw Error(`Failed to fetch session trees`);return(await t.json()).trees}function vSt(e,t){let n=t.issueId.toLowerCase(),r=e.features.findIndex(e=>e.issueId.toLowerCase()===n);if(r===-1)return e;let i=e.features[r];if(!i)return e;switch(t.kind){case`session_added`:return e;case`session_removed`:{let n=i.sessions.filter(e=>e.sessionId!==t.sessionId);if(n.length===i.sessions.length)return e;let a=[...e.features];return a[r]={...i,sessions:n},{...e,features:a}}case`presence_changed`:case`status_changed`:{let n=i.sessions.findIndex(e=>e.sessionId===t.sessionId);if(n===-1)return e;let a=[...i.sessions];a[n]={...i.sessions[n],...t.presence!==void 0&&{presence:t.presence},...t.status!==void 0&&{status:t.status}};let o=[...e.features];return o[r]={...i,sessions:a},{...e,features:o}}default:return e}}var ySt=`mc-convs-collapsed`,bSt=`mc-projects-collapsed`,xSt=`mc-section-split`;function SSt({issues:e=[],convId:t,pendingConversationTarget:n=null,onPendingConversationTargetConsumed:r,onConvIdChange:i,selectedProject:a=null,onSelectProject:o,onProjectPrefixChange:s,cockpitIssue:c=null,onCockpitChange:l}){let[u,d]=(0,R.useReducer)(e=>e+1,0),[f,p]=(0,R.useState)(null),[m,h]=(0,R.useState)(null),[g,_]=(0,R.useState)(()=>typeof window<`u`&&localStorage.getItem(`overdeck.ui.awarenessCollapsed`)===`true`),v=(0,R.useCallback)(e=>{_(e);try{localStorage.setItem(`overdeck.ui.awarenessCollapsed`,String(e))}catch{}},[]),[y,b]=(0,R.useState)(!1),[x,S]=(0,R.useState)(null),[C,w]=(0,R.useState)(()=>{try{return localStorage.getItem(ySt)===`true`}catch{return!1}}),[T,E]=(0,R.useState)(()=>{try{return localStorage.getItem(bSt)===`true`}catch{return!1}}),D=(0,R.useCallback)(()=>{w(e=>{let t=!e;try{localStorage.setItem(ySt,String(t))}catch{}return t})},[]),O=(0,R.useCallback)(()=>{E(e=>{let t=!e;try{localStorage.setItem(bSt,String(t))}catch{}return t})},[]),[k,A]=(0,R.useState)(()=>{try{let e=localStorage.getItem(xSt);return e?Math.max(20,Math.min(80,Number(e))):50}catch{return 50}}),j=(0,R.useRef)(!1),M=(0,R.useRef)(0),N=(0,R.useRef)(50),P=(0,R.useRef)(null),[F,I]=(0,R.useState)(`all`),[ee,te]=(0,R.useState)(Cat),[ne,L]=(0,R.useState)(wat),re=lSt(e=>e.selectSession),ie=lSt(e=>e.selectedSessionByIssue),ae=f?ie[f]??null:null,[oe,se]=(0,R.useState)(()=>{let e=localStorage.getItem(`mc-sidebar-width`);return e?Math.max(280,Number(e)):320}),ce=(0,R.useRef)(!1),le=(0,R.useRef)(0),ue=(0,R.useRef)(0),de=(0,R.useRef)(oe),fe=_t(),{data:pe=[],isLoading:me}=B({queryKey:[`command-deck-projects`,u],queryFn:K5,refetchInterval:3e4}),{data:he}=B({queryKey:[`costs-by-issue`],queryFn:mSt,refetchInterval:15e3}),{data:ge=[]}=B({queryKey:[`registered-projects`],queryFn:gSt,staleTime:6e4}),{data:_e}=B({queryKey:[`version`],queryFn:hSt,staleTime:1/0}),ve=(0,R.useMemo)(()=>pe.map(e=>e.name).join(`,`),[pe]),{data:ye=[]}=B({queryKey:[`session-trees`,ve],queryFn:()=>_St(pe.map(e=>e.name)),enabled:pe.length>0}),be=(0,R.useRef)({}),xe=(0,R.useMemo)(()=>{let e={},t=!1;for(let n of ye)e[n.projectKey]=n,be.current[n.projectKey]!==n&&(t=!0);return!t&&Object.keys(e).length===Object.keys(be.current).length?be.current:(be.current=e,e)},[ye]);(0,R.useEffect)(()=>{let e=hj(),t=[];for(let n of pe){let r=e.subscribe(e=>e[Pp.subscribeProjectSessionTree]({projectKey:n.name}),e=>{let t=[`session-trees`,ve],r=fe.getQueryData(t);if(!r)return;let i=r.find(e=>e.projectKey===n.name);if(!i)return;if(e.kind===`session_added`){fe.invalidateQueries({queryKey:t,exact:!0});return}let a=vSt(i,e);if(a===i)return;let o=r.map(e=>e.projectKey===n.name?a:e);fe.setQueryData(t,o)});t.push(r)}return()=>{for(let e of t)e()}},[ve,pe,fe]);let Se=(0,R.useMemo)(()=>pe.map(e=>{let t=xe[e.name];if(!t)return e;let n=new Map;for(let e of t.features)n.set(e.issueId.toLowerCase(),e.sessions);let r=!1,i=e.features.map(e=>{let t=n.get(e.issueId.toLowerCase());return!t&&!e.sessions||t===e.sessions?e:(r=!0,{...e,sessions:t??e.sessions})});return r?{...e,features:i}:e}),[pe,xe]);(0,R.useEffect)(()=>{if(a||!o)return;let e=Se.filter(e=>e.features.length>0);e.length===1&&o(e[0].name)},[o,Se,a]);let[Ce,we]=(0,R.useState)({});(0,R.useEffect)(()=>{if(!Se.some(e=>e.features.some(e=>(e.resourceDetails?.dockerContainerCount??0)>0)))return;let e=async()=>{try{let e=await fetch(`/api/resources`);if(!e.ok)return;let t=await e.json(),n={};for(let e of t.containers)n[e.name]=e;we(n)}catch{}};e();let t=setInterval(e,5e3);return()=>clearInterval(t)},[Se]);let Te=sm(lm),Ee=Hr(),{issueCosts:De,issueCostDetails:Oe}=(0,R.useMemo)(()=>{let e={},t={};for(let n of he?.issues||[]){e[n.issueId]=n.totalCost,e[n.issueId.toLowerCase()]=n.totalCost;let r={byModel:n.byModel??{},byStage:n.byStage??{}};t[n.issueId]=r,t[n.issueId.toLowerCase()]=r}return{issueCosts:e,issueCostDetails:t}},[he]),ke=(0,R.useMemo)(()=>{let t={};for(let n of e)n.identifier&&(t[n.identifier.toLowerCase()]=n.title,t[n.identifier]=n.title);return t},[e]),{data:Ae=[]}=B({queryKey:[`conversations`],queryFn:pSt,refetchInterval:1e4}),{projectConversations:je}=(0,R.useMemo)(()=>{let e={},t=new Set;if(!Array.isArray(ge)||ge.length===0)return{projectConversations:e,excludeConvIds:t};let n=new Map;for(let e of ge){if(!e.path)continue;let t=Array.from(new Set([e.key,e.name].filter(e=>!!e)));n.set(e.path.replace(/\/+$/,``),t)}for(let r of Ae){if(!r.cwd)continue;let i=r.cwd.replace(/\/+$/,``);for(let[a,o]of n)if(i===a||i.startsWith(a+`/`)){for(let t of o)e[t]||(e[t]=[]),e[t].push(r);t.add(r.id);break}}return{projectConversations:e,excludeConvIds:t}},[Ae,ge]),Me=(0,R.useRef)(null),Ne=(0,R.useRef)(null),Pe=(0,R.useCallback)(e=>{if(!e?.cwd)return null;let t=e.cwd,n=ge.find(e=>!!e.path&&(t===e.path||t.startsWith(e.path+`/`)));return n?n.name??n.key:null},[ge]),Fe=(0,R.useCallback)((e,t,n)=>{let r=FH.getState();r.ensureHome(e);let i=(r.panesByWorkspace[e]??[]).find(e=>e.paneType===`issue`&&e.issueId===t);i?r.setActivePane(e,i.paneId):r.addPane(e,{paneType:`issue`,label:n,issueId:t})},[]),Ie=(0,R.useCallback)((e,t,n,r,i)=>{let a=FH.getState();a.ensureHome(e);let o=(a.panesByWorkspace[e]??[]).find(e=>e.paneType===`agent`&&e.conversationId===t),s=o?o.paneId:a.addPane(e,{paneType:`agent`,label:n,conversationId:t,...i?{viewMode:i}:{}});a.setActivePane(e,s),r&&FH.getState().updatePane(e,s,{targetMessageId:r.messageId,targetMessageIndex:r.messageIndex,targetMessageNonce:r.nonce})},[]),Le=(0,R.useCallback)((e,t)=>{let n=FH.getState();n.ensureHome(e),n.addPane(e,{paneType:`terminal`,label:`Terminal`,terminalId:t})},[]),Re=(0,R.useCallback)((e,t,n,r)=>{let i=FH.getState();i.ensureHome(e);let a=(i.panesByWorkspace[e]??[]).find(e=>e.paneType===`agent`&&e.agentId===t);a?i.setActivePane(e,a.paneId):i.addPane(e,{paneType:`agent`,label:r,agentId:t,issueId:n})},[]);(0,R.useEffect)(()=>{if(!t||Ae.length===0||t===Me.current)return;let e=Ae.find(e=>String(e.id)===t||e.name===t);if(e){h(e.name),p(null);let i=Pe(e)??`__no-project__`,a=n?.conversationName===e.name?{messageId:n.messageId,messageIndex:n.messageIndex,nonce:n.nonce}:void 0;o?.(i),Ie(i,e.name,n?.label??e.title??`Agent`,a),a&&r?.(),Me.current=t}},[t,Ae,Pe,o,Ie,n,r]);let ze=(0,R.useRef)(!1);(0,R.useEffect)(()=>{if(ze.current)return;let e=new URLSearchParams(window.location.search).has(`issue`);Ae.length===0||t||e||m!==null||f!==null||a!==null||(h(Ae[0].name),ze.current=!0)},[Ae,t,m,f,a]);let Be=(0,R.useRef)(null);(0,R.useEffect)(()=>{if(!i||m===Be.current)return;if(Be.current=m,!m){i(null);return}let e=Ae.find(e=>e.name===m);if(e){if(t===String(e.id)||t===e.name)return;i(String(e.id))}},[m,Ae,i,t]),(0,R.useEffect)(()=>{if(!c||ge.length===0)return;let e=`${c.project}/${c.issue}`;if(e===Ne.current)return;Ne.current=e;let t=c.project,n=t.includes(`/`)?t.split(`/`).pop():t,r=ge.find(e=>e.key===t||e.name===t||e.key===n||e.name===n),i=r?r.name??r.key:t;p(c.issue),h(null),o?.(i),Fe(i,c.issue,c.issue)},[c,o,Fe,ge]);let Ve=(0,R.useRef)(null);(0,R.useEffect)(()=>{l&&f!==Ve.current&&(Ve.current=f,f&&a&&l(a,f))},[f,a,l]);let He=(0,R.useCallback)(e=>{p(e),h(null),a&&Fe(a,e,e);let t=Se.flatMap(e=>e.features).find(t=>t.issueId===e)?.sessions?.find(e=>e.presence===`active`&&e.type===`work`);re(e,t?.sessionId??null)},[re,Se,a,Fe]),Ue=(0,R.useCallback)((e,t)=>{if(p(e),re(e,t),h(null),!a)return;let n=Se.flatMap(e=>e.features).flatMap(e=>e.sessions??[]).find(e=>e.sessionId===t),r=n?.role??n?.type??`Agent`;Re(a,t,e,r.charAt(0).toUpperCase()+r.slice(1))},[re,a,Se,Re]),We=(0,R.useCallback)(e=>Se.flatMap(e=>e.features).flatMap(e=>e.sessions??[]).find(t=>t.sessionId===e),[Se]),Ge=(0,R.useCallback)(async e=>{try{if(!(await fetch(`/api/agents/${e}`,{method:`DELETE`})).ok)throw Error(`Failed to stop session`);await _j(fe)}catch(e){H.error(e instanceof Error?e.message:`Failed to stop session`)}},[fe]),Ke=(0,R.useCallback)(async e=>{if(window.confirm(`Clean up orphaned resources for ${e}? This removes leftover local workspace state for a closed issue.`))try{if(!(await fetch(`/api/issues/${encodeURIComponent(e)}/cleanup-workspace`,{method:`POST`})).ok)throw Error(`Failed to clean up orphaned resources`);d(),await _j(fe)}catch(e){H.error(e instanceof Error?e.message:`Failed to clean up resources`)}},[fe]),qe=(0,R.useCallback)(e=>{for(let t of Se)for(let n of t.features)if(n.sessions?.some(t=>t.sessionId===e)){p(n.issueId),re(n.issueId,e),h(null),a&&Le(a,e);return}},[Se,re,a,Le]),Je=(0,R.useCallback)(async e=>{try{if(!(await fetch(`/api/agents/${e}/suspend`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:e})})).ok)throw Error(`Failed to pause session`);await _j(fe)}catch(e){H.error(e instanceof Error?e.message:`Failed to pause session`)}},[fe]),Ye=(0,R.useCallback)(async e=>{try{console.log(`[command-deck] handleResumeSession ${e}`);let t=await fetch(`/api/agents/${e}/resume`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({message:`Resumed from dashboard`})}),n=await t.json().catch(()=>({}));if(!t.ok)throw console.warn(`[command-deck] handleResumeSession ${e} failed: ${t.status} ${n.error??`no body`}`),Error(n.error||`Failed to resume session`);console.log(`[command-deck] handleResumeSession ${e} ok: messageDelivered=${n.messageDelivered}`),H.success(n.messageDelivered===!1?`Agent resumed; message queued in mail (PTY echo-confirm timed out)`:`Agent resumed`),await _j(fe)}catch(e){H.error(e instanceof Error?e.message:`Failed to resume session`)}},[fe]),Xe=(0,R.useCallback)(async e=>{try{let t=await fetch(`/api/agents/${e}/unpause`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})}),n=await t.json().catch(()=>({}));if(!t.ok)throw Error(n.error||`Failed to unpause agent`);H.success(`Agent unpaused — deacon will resume it on the next patrol`),await _j(fe)}catch(e){H.error(e instanceof Error?e.message:`Failed to unpause agent`)}},[fe]),Ze=(0,R.useCallback)(async(e,t,n,r,i,a)=>{try{let o=Se.find(e=>e.features.some(e=>e.issueId===t))?.name??Object.entries(xe).find(([,e])=>e.features.some(e=>e.issueId.toLowerCase()===t.toLowerCase()))?.[0],s=!n||n===`work`,c=s?Te.find(t=>t.id===e):void 0,l=c?.harness??void 0,u=c?.model??void 0,d=s&&a!==void 0&&a!==l&&l!==void 0,f=d||s&&i!==void 0&&i!==u&&u!==void 0&&!d,p=n===`review`||n===`reviewer`;if(f||p){let e=p?`Restart review with new harness/model`:`Restart work agent with new harness/model`,n=`This will delete the review agent's state for ${t} (sessions, activity, logs) and start a fresh review run with the chosen harness/model.\n\nThe workspace, vBRIEF, beads, and commit history are kept. The review will have to re-research the diff from scratch — this is a deliberate cost of switching harness/model or force-restarting the review.`,r=`This will delete the work agent's state for ${t} (sessions, activity, logs) and start a fresh ${a??l??``} + ${i??u??``} agent.\n\nThe workspace, vBRIEF, beads, and commit history are kept. The new agent will read .pan/continue.json and the branch to continue. The agent will have to re-research the diff from scratch — this is a deliberate cost of switching harness/model.`;if(!await Ee({title:e,message:p?n:r,confirmLabel:p?`Restart review`:`Restart work agent`,variant:`destructive`})){H.info(`Restart canceled`);return}}let m=fSt({projectKey:o,issueId:t,sessionId:e,sessionType:n,role:r,model:i,harness:a});if(m&&!f){let e=await fetch(m.endpoint,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(m.body)}),t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t.error||m.errorMessage);H.success(m.successMessage),await _j(fe);return}if(f){let t=await fetch(`/api/agents/${e}/restart-fresh`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({spawn:!0,...i?{model:i}:{},...a?{harness:a}:{}})}),n=await t.json().catch(()=>({}));if(!t.ok)throw Error(n.error||`Failed to restart agent with new harness/model`);H.success(`Agent restarted: ${n.spawnedHarness??a} + ${n.spawnedModel??i}`),await _j(fe);return}let h=await fetch(`/api/agents/${e}/resume`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...i?{model:i}:{},...a?{harness:a}:{}})}),g=await h.json().catch(()=>({}));if(h.ok){H.success(`Agent resumed`),await _j(fe);return}if(g.lifecycle?.isRunning){if(!(await fetch(`/api/agents/${e}`,{method:`DELETE`})).ok)throw Error(`Failed to stop agent before restart`);let t=await fetch(`/api/agents/${e}/resume`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...i?{model:i}:{},...a?{harness:a}:{}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||`Failed to restart agent`)}H.success(`Agent restarted`),await _j(fe);return}if(!(g.lifecycle?.canResumeSession===!1&&!g.lifecycle?.hasLiveTmuxSession))throw Error(g.error||`Failed to resume agent`);await fetch(`/api/agents/${e}`,{method:`DELETE`});let _={issueId:t};i&&(_.model=i),a&&(_.harness=a);let v=_,y=await fetch(`/api/agents`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(v)}),b=await y.json().catch(()=>({}));if(y.status===409&&b.requiresAcknowledgement){if(!window.confirm((b.guardrails?.warnings??[]).map(e=>`• ${e.message}`).join(`
|
|
668
|
-
`)))throw Error(`Agent start canceled`);v={..._,guardrailAcknowledged:!0},y=await fetch(`/api/agents`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(v)}),b=await y.json().catch(()=>({}))}if(!y.ok)throw SYe(y,b)?(vYe(v),Error(b.hint||b.error||`Codex authentication expired — re-authenticate to continue`)):Error(b.error||b.hint||`Failed to start agent`);b.guardrails?.warnings?.length&&H.success(`Agent started after acknowledging system health warnings.`,{duration:6e3}),await _j(fe)}catch(e){H.error(e instanceof Error?e.message:`Failed to restart session`)}},[fe,Se,xe,Ee,Te]),Qe=(0,R.useCallback)(async e=>{try{if(!(await fetch(`/api/issues/${encodeURIComponent(e)}/deep-wipe`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({deleteWorkspace:!0})})).ok)throw Error(`Failed to deep wipe`);await _j(fe),p(null),re(e,null)}catch(e){H.error(e instanceof Error?e.message:`Failed to deep wipe`)}},[fe,re]),$e=(0,R.useCallback)(e=>{let t=`~/.overdeck/agents/${e}/`;navigator.clipboard?.writeText(t).catch(()=>{})},[]),et=(0,R.useCallback)(t=>{S(e.find(e=>e.identifier.toLowerCase()===t.toLowerCase())??{id:t,identifier:t,title:t,status:`Todo`,priority:0,labels:[],url:``,createdAt:``,updatedAt:``})},[e]),tt=(0,R.useCallback)(e=>{for(let t of Se)for(let n of t.features)if(n.sessions?.some(t=>t.sessionId===e)){p(n.issueId),re(n.issueId,e),h(null),a&&Fe(a,n.issueId,n.issueId);return}},[Se,re,a,Fe]),nt=(0,R.useCallback)(e=>{o?.(e),p(null),h(null)},[o]),rt=(0,R.useCallback)(e=>{if(h(e),f&&re(f,null),e){p(null);let t=Ae.find(t=>t.name===e),n=Pe(t)??`__no-project__`;n!==a&&o?.(n),Ie(n,e,t?.title??`Agent`)}},[re,f,Ae,Pe,a,o,Ie]),it=bJ(m,rt);(0,R.useEffect)(()=>{let e=e=>{let t=e.detail;t?.conversation&&it.openForkModal(t.conversation,{mode:t.mode,focus:t.focus})};return window.addEventListener(`overdeck:open-fork-modal`,e),()=>window.removeEventListener(`overdeck:open-fork-modal`,e)},[it]);let at=(0,R.useCallback)(async(e,t,n,r)=>{try{let o={model:ee,harness:t??ne};e&&(o.projectKey=e);let s=n?.trim();s&&(o.message=s);let c=await fetch(`/api/conversations`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(o)});if(!c.ok){let e=await c.json().catch(()=>({error:`Request failed`}));throw Error(e.error||`Failed to create conversation`)}let l=await c.json();h(l.name),C&&w(!1);let u=e??a;if(u&&Ie(u,l.name,l.title??`Agent`,void 0,r),i){let e=String(l.id);i(e),Me.current=e,Be.current=l.name}return fe.invalidateQueries({queryKey:[`conversations`]}),l.name}catch(e){console.error(`[CommandDeck] Failed to create conversation:`,e),H.error(e instanceof Error?e.message:`Failed to create conversation`);return}},[ee,ne,fe,i,C,a,Ie]),ot=(0,R.useCallback)(()=>{at(a&&a!==`__no-project__`?a:void 0)},[at,a]),st=(0,R.useCallback)(e=>{at(e)},[at]),ct=(0,R.useCallback)((e,t,n)=>at(a&&a!==`__no-project__`?a:void 0,e===`codex`?`codex`:e===`ohmypi`?`ohmypi`:`claude-code`,t,n),[at,a]),lt=(0,R.useCallback)(e=>{j.current=!0,M.current=e.clientY,N.current=k,document.body.style.cursor=`row-resize`,document.body.style.userSelect=`none`,e.preventDefault()},[k]);(0,R.useEffect)(()=>{let e=e=>{if(!j.current||!P.current)return;let t=P.current.getBoundingClientRect().height;if(t<=0)return;let n=(e.clientY-M.current)/t*100;A(Math.max(15,Math.min(85,N.current+n)))},t=()=>{j.current&&(j.current=!1,document.body.style.cursor=``,document.body.style.userSelect=``,A(e=>{try{localStorage.setItem(xSt,String(Math.round(e)))}catch{}return e}))};return document.addEventListener(`mousemove`,e),document.addEventListener(`mouseup`,t),()=>{document.removeEventListener(`mousemove`,e),document.removeEventListener(`mouseup`,t)}},[]);let ut=(0,R.useCallback)(e=>{ce.current=!0,le.current=e.clientX,ue.current=oe,document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`,e.preventDefault()},[oe]);(0,R.useEffect)(()=>{let e=e=>{if(!ce.current)return;let t=e.clientX-le.current,n=Math.max(280,Math.min(500,ue.current+t));se(n),de.current=n},t=()=>{ce.current&&localStorage.setItem(`mc-sidebar-width`,String(de.current)),ce.current=!1,document.body.style.cursor=``,document.body.style.userSelect=``};return document.addEventListener(`mousemove`,e),document.addEventListener(`mouseup`,t),()=>{document.removeEventListener(`mousemove`,e),document.removeEventListener(`mouseup`,t)}},[]),(0,R.useEffect)(()=>{let e=()=>{console.log(`[CommandDeck] transport reconnected — invalidating query caches`),fe.invalidateQueries()};return window.addEventListener(`overdeck:reconnected`,e),()=>window.removeEventListener(`overdeck:reconnected`,e)},[fe]);let dt=(0,R.useMemo)(()=>a?Se.find(e=>e.name===a)??null:null,[Se,a]),ft=a===nSt,pt=(0,R.useMemo)(()=>Ae.filter(e=>iSt(e,ge)),[Ae,ge]),mt=(0,R.useMemo)(()=>ft?pt:a?je[a]??[]:[],[ft,pt,a,je]),ht=(0,R.useMemo)(()=>new Set(mt.map(e=>e.id)),[mt]),gt=(0,R.useMemo)(()=>(dt?.features??[]).map(e=>e.issueId),[dt]),vt=(0,R.useMemo)(()=>{let e=new Set(gt.map(e=>e.split(`-`)[0]?.toUpperCase()).filter(Boolean));return e.size===1?[...e][0]:null},[gt]);(0,R.useEffect)(()=>{s?.(vt)},[vt,s]);let yt=(0,R.useCallback)(t=>{let n=t.toLowerCase();return{title:ke[n]||ke[t]||t,createdAt:e.find(e=>e.identifier===t)?.createdAt,branch:dt?.features.find(e=>e.issueId===t)?.branch,agentId:Te.find(e=>e.issueId?.toLowerCase()===n&&e.id.startsWith(`agent-`))?.id??Te.find(e=>e.issueId?.toLowerCase()===n)?.id}},[ke,e,dt,Te]);return(0,z.jsxs)(`div`,{className:J.commandDeck,children:[(0,z.jsxs)(`div`,{className:J.layout,children:[(0,z.jsxs)(`div`,{className:J.sidebar,style:{width:oe,minWidth:oe},children:[(0,z.jsx)(`div`,{className:J.sidebarHeader,children:(0,z.jsxs)(`div`,{className:J.sidebarHeaderRow,children:[(0,z.jsx)(`h2`,{className:J.sidebarTitle,children:`Command Deck`}),(0,z.jsxs)(`div`,{className:J.sidebarHeaderGroup,children:[(0,z.jsx)(l4,{value:ee,onChange:e=>{te(e),o4(e)},harness:ne,onHarnessChange:e=>{L(e),s4(e)}}),(0,z.jsx)(`button`,{className:J.conversationAddBtn,onClick:ot,title:`New conversation`,"aria-label":`New conversation`,children:(0,z.jsx)(gr,{size:13})})]})]})}),(0,z.jsxs)(`div`,{ref:P,style:{display:`flex`,flexDirection:`column`,flex:1,minHeight:0,overflow:`hidden`},children:[(0,z.jsxs)(`div`,{className:`${J.sidebarSection} ${C?J.sidebarSectionCollapsed:``}`,style:!C&&!T?{flex:`0 0 ${k}%`}:void 0,children:[(0,z.jsxs)(`div`,{className:J.sectionHeader,onClick:D,children:[C?(0,z.jsx)(nn,{size:14}):(0,z.jsx)(en,{size:14}),(0,z.jsx)(`span`,{className:J.sectionTitle,children:`Conversations`}),(0,z.jsx)(`span`,{className:J.segmentCount,children:mt.length})]}),!C&&(0,z.jsx)(`div`,{className:J.sectionBody,children:a?(0,z.jsx)(k7e,{selectedConversation:m,onSelectConversation:rt,includeIds:ht}):(0,z.jsx)(`div`,{className:J.emptyProject,children:`Select a project to see its conversations`})})]}),!C&&!T&&(0,z.jsx)(`div`,{className:J.sectionDivider,onMouseDown:lt}),(0,z.jsxs)(`div`,{className:`${J.sidebarSection} ${T?J.sidebarSectionCollapsed:``}`,style:!C&&!T?{flex:`0 0 ${100-k}%`}:void 0,children:[(0,z.jsxs)(`div`,{className:J.sectionHeader,onClick:O,children:[T?(0,z.jsx)(nn,{size:14}):(0,z.jsx)(en,{size:14}),(0,z.jsx)(`span`,{className:J.sectionTitle,children:`Issues`}),(0,z.jsx)(`span`,{className:J.segmentCount,children:dt?.features.length??0})]}),!T&&(0,z.jsxs)(`div`,{className:J.sectionBody,children:[(0,z.jsx)(`div`,{className:J.treeFilterRow,children:[`all`,`alive`,`failed`].map(e=>(0,z.jsx)(`button`,{onClick:()=>I(e),className:`${J.treeFilterButton} ${F===e?J.treeFilterButtonActive:``}`,children:e===`all`?`All`:e===`alive`?`Alive`:`Failed`},e))}),a?me&&!dt?(0,z.jsxs)(`div`,{className:J.skeletonList,children:[(0,z.jsx)(`div`,{className:J.skeletonItem,style:{width:`60%`}}),(0,z.jsx)(`div`,{className:J.skeletonItem,style:{width:`80%`}}),(0,z.jsx)(`div`,{className:J.skeletonItem,style:{width:`45%`}})]}):dt?(0,z.jsx)(L4e,{name:dt.name,features:dt.features,selectedFeature:f,onSelectFeature:He,onSelectProject:nt,selectedProject:a,selectedSessionId:ae,onSelectSession:Ue,issueTitles:ke,issueCosts:De,filter:F,onStopSession:Ge,onViewTerminal:qe,onPauseSession:Je,onResumeSession:Ye,onUnpauseSession:Xe,onRestartSession:Ze,onDeepWipe:Qe,onOpenStateDir:$e,onViewJsonl:tt,onCleanupOrphanedResources:Ke,onOpenPlanDialog:et,onNewConversation:st,containerStats:Ce},dt.path):(0,z.jsx)(`div`,{className:J.emptyProject,children:`No issues for this project`}):(0,z.jsx)(`div`,{className:J.emptyProject,children:`Select a project to see its issues`})]})]})]}),it.forkTarget&&(0,z.jsx)(uJ,{conversation:it.forkTarget,initialMode:it.forkTargetMode,initialFocus:it.forkTargetFocus,isPending:it.isForkPending,onClose:it.closeForkModal,onConfirm:(e,t,n,r,i,a,o,s,c,l,u,d,f)=>{it.submitFork(e,t,n,r,i,a,o,s,c,l,u,d,f)}}),_e&&(0,z.jsx)(`div`,{className:J.sidebarFooter,children:(0,z.jsxs)(`span`,{className:J.versionLabel,children:[`v`,_e.version]})})]}),(0,z.jsx)(`div`,{className:J.resizeHandle,onMouseDown:ut}),(0,z.jsx)(`div`,{className:J.content,children:a?(0,z.jsx)(j_t,{deckKey:a,conversations:Ae,resolveSession:We,onCreateConversation:ct,onActiveConversationChange:h,terminalCwd:ge.find(e=>(e.name??e.key)===a)?.path,renderHome:e=>(0,z.jsx)(gyt,{projectName:ft?rSt:a,projectKey:ge.find(e=>(e.name??e.key)===a)?.key,conversations:mt,onCreateConversation:ct,features:dt?.features,issueCosts:De,issueCostDetails:Oe,onSelectFeature:e=>He(e.issueId),api:e}),renderIssue:(e,t)=>{let n=yt(e);return(0,z.jsx)(ixt,{issueId:e,title:n.title,branch:n.branch,projectName:a??void 0,createdAt:n.createdAt,agentId:n.agentId,conversations:Ae,onCreateConversation:ct,api:t})}},a):(0,z.jsx)(`div`,{className:J.contentEmpty,children:(0,z.jsxs)(`div`,{style:{textAlign:`center`},children:[(0,z.jsx)(yn,{size:48,style:{marginBottom:`16px`,opacity:.3}}),(0,z.jsx)(`p`,{children:`Select a project to open its deck`})]})})}),a&&(g?(0,z.jsxs)(`button`,{type:`button`,className:J.activityColumnCollapsed,onClick:()=>v(!1),title:`Show Awareness`,"aria-label":`Show Awareness rail`,children:[(0,z.jsx)(tn,{size:16}),(0,z.jsx)(`span`,{className:J.activityCollapsedLabel,children:`Awareness`})]}):(0,z.jsx)(`div`,{className:J.activityColumn,children:(0,z.jsx)(qxt,{embedded:!0,heading:`Awareness`,scopeSwitcher:!0,projectIssueIds:ft?void 0:gt,onClose:()=>v(!0)})}))]}),y&&f&&(0,z.jsx)(oSt,{issueId:f,isOpen:y,onClose:()=>b(!1)}),x&&(0,z.jsx)(OE,{issue:x,isOpen:!0,onClose:()=>S(null),onComplete:async()=>{S(null),await _j(fe)}})]})}async function CSt(e,t){let n=await fetch(`/api/workspaces/${encodeURIComponent(e)}/auto-merge`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({autoMerge:t})});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error??n.statusText)}}function wSt(e,t){let n=sm.getState(),r=e.toUpperCase(),i=n.reviewStatusByIssueId[r]?r:e,a=n.reviewStatusByIssueId[i];a&&sm.setState(e=>({reviewStatusByIssueId:{...e.reviewStatusByIssueId,[i]:{...a,autoMerge:t}}}))}function TSt(){let{data:e}=B({queryKey:[`flywheel`,`config`,`require-uat`],queryFn:async()=>{let e=await fetch(`/api/flywheel/config`);return e.ok?!!(await e.json()).require_uat_before_merge:void 0},staleTime:3e4});return e}function q5({issueId:e,autoMerge:t,variant:n=`segmented`,compact:r=!1,className:i=``}){let[a,o]=(0,R.useState)(!1),s=TSt(),c=s===void 0?`the project default`:s?`hold for UAT`:`auto-merge`,l=async n=>{if(!(a||t===n)){o(!0);try{await CSt(e,n),wSt(e,n)}catch(e){H.error(e instanceof Error?e.message:`Failed to update auto-merge`)}finally{o(!1)}}},u=r?`w-3 h-3`:`w-3.5 h-3.5`;if(n===`badge`){let e=t===!0,n=!e,r=e?`auto`:t===!1?`hold`:`default`,o=e?`text-emerald-400 bg-emerald-500/10 border-emerald-500/40`:t===!1?`text-amber-400 bg-amber-500/10 border-amber-500/40`:`text-muted-foreground bg-transparent border-border`;return(0,z.jsxs)(`button`,{type:`button`,disabled:a,onClick:e=>{e.stopPropagation(),l(n)},title:e?`Auto-merge ON — click to hold for UAT`:t===!1?`Holding for UAT — click to auto-merge`:`Follows the global default (currently: ${c}) — click to set Auto`,className:`inline-flex items-center gap-1 rounded-md border px-2 py-0.5 text-xs font-semibold transition disabled:opacity-50 hover:brightness-110 ${o} ${i}`,children:[e?(0,z.jsx)(Br,{className:u}):(0,z.jsx)(or,{className:u}),r]})}let d=(e,t)=>`inline-flex items-center gap-1.5 ${r?`px-2 py-1`:`px-2.5 py-1.5`} text-xs font-semibold transition disabled:opacity-50 `+(e?t:`text-muted-foreground hover:text-foreground hover:bg-accent/40`);return(0,z.jsxs)(`div`,{role:`group`,"aria-label":`Auto-merge policy`,title:t===void 0?`Default follows the global setting (currently: ${c})`:void 0,className:`inline-flex overflow-hidden rounded-lg border border-border bg-background ${i}`,children:[(0,z.jsxs)(`button`,{type:`button`,disabled:a,"aria-pressed":t===!0,onClick:e=>{e.stopPropagation(),l(!0)},className:d(t===!0,`text-emerald-400 bg-emerald-500/10`),title:`Auto-merge — ride the train, ship when green`,children:[(0,z.jsx)(Br,{className:u}),` Auto`]}),(0,z.jsxs)(`button`,{type:`button`,disabled:a,"aria-pressed":t===!1,onClick:e=>{e.stopPropagation(),l(!1)},className:`border-l border-border ${d(t===!1,`text-amber-400 bg-amber-500/10`)}`,title:`Hold for UAT — wait for human batch review`,children:[(0,z.jsx)(or,{className:u}),` Hold`]})]})}var J5=[`ship`,`review`,`verifying`,`work`,`plan`,`ready`],ESt=[`all`,...J5],DSt={1:`urgent`,2:`high`,3:`medium`,4:`low`};function OSt(e){return Object.values(e).reduce((e,t)=>e+t.reduce((e,t)=>e+t.cost,0),0)}function kSt(e,t){return e[t.identifier]??e[t.identifier.toUpperCase()]}function ASt(e){return DSt[e]??`low`}function jSt(e){return[e.model,e.status].filter(Boolean).join(` · `)}function MSt(e){return 5-e}function NSt(e,t){let n=MSt(t.priority)-MSt(e.priority);return n===0?t.updatedAt.localeCompare(e.updatedAt):n}function PSt(){if(typeof window>`u`)return{phase:`all`,projects:[],blocked:!1,noPr:!1};let e=new URLSearchParams(window.location.search),t=e.get(`phase`);return{phase:J5.includes(t)?t:`all`,projects:e.get(`projects`)?.split(`,`).map(e=>e.trim()).filter(Boolean)??[],blocked:e.has(`blocked`),noPr:e.has(`noPr`)}}function FSt(e){if(typeof window>`u`)return;let t=new URL(window.location.href);e.phase===`all`?t.searchParams.delete(`phase`):t.searchParams.set(`phase`,e.phase),e.projects.length>0?t.searchParams.set(`projects`,e.projects.join(`,`)):t.searchParams.delete(`projects`),e.blocked?t.searchParams.set(`blocked`,`1`):t.searchParams.delete(`blocked`),e.noPr?t.searchParams.set(`noPr`,`1`):t.searchParams.delete(`noPr`),window.history.replaceState(null,``,`${t.pathname}${t.search}${t.hash}`)}function ISt(e){return e.project?{id:e.project.id||e.project.name,name:e.project.name}:null}function LSt(e){return!!(e&&(e.blockerReasons?.length??0)>0&&e.mergeStatus!==`merged`&&e.reviewStatus===`passed`&&(e.testStatus===`passed`||e.testStatus===`skipped`))}function RSt(e){return!!(e?.prUrl&&e.readyForMerge!==!0&&e.mergeStatus!==`merged`)}function zSt(e,t){return e.phase===`ship`?!(e.blocked&&!LSt(t)||e.noPr&&!RSt(t)):!0}function BSt(e){let t=e.state??e.status;return e.stateType===`completed`||e.stateType===`canceled`||t===`done`||t===`canceled`||t===`Canceled`||t===`Closed`||t===`Completed`}function VSt(e){return hh(e.status)}function HSt(e){return e>=100?`$${e.toFixed(0)}`:e>=10?`$${e.toFixed(1)}`:e>=1?`$${e.toFixed(2)}`:e>0?`$${e.toFixed(3)}`:`$0`}function USt(e){if(!Number.isFinite(e)||e<0)return`—`;let t=Math.max(0,e),n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4);return n>0?`${n}h ${r}m`:`${r}m`}function Y5({label:e}){return(0,z.jsx)(`span`,{"aria-hidden":`true`,children:e})}function WSt(e){return e===`ship`?(0,z.jsx)(qj,{variant:`READY TO MERGE`}):e===`review`?(0,z.jsx)(qj,{variant:`REVIEW RUNNING`}):e===`verifying`?(0,z.jsx)(qj,{variant:`MERGED`}):e===`work`?(0,z.jsx)(qj,{variant:`WORK RUNNING`}):e===`plan`?(0,z.jsx)(qj,{variant:`PLANNING`}):e===`ready`?(0,z.jsx)(qj,{variant:`READY`}):(0,z.jsx)(qj,{variant:`QUEUED FOR PLAN`})}function GSt({issue:e,phase:t,agent:n,costEvents:r,now:i,onOpen:a}){let[o,s]=(0,R.useState)(0),c=sm(t=>(t.reviewStatusByIssueId[e.identifier]??t.reviewStatusByIssueId[e.identifier.toUpperCase()])?.autoMerge),l=r?.reduce((e,t)=>e+t.cost,0)??0,u={runtime:n?.startedAt?USt(i.getTime()-new Date(n.startedAt).getTime()):void 0,cost:l>0?HSt(l):void 0};return(0,z.jsx)(xvt,{issueId:e.identifier,phase:t,priority:ASt(e.priority),title:e.title,project:e.project?{name:e.project.name}:void 0,labels:e.labels.slice(0,3),verbBadge:WSt(t),agent:n?{name:n.id,sub:jSt(n)}:void 0,ledger:u,assignee:e.assignee?{name:e.assignee.name}:void 0,onOpen:a,onContextMenu:()=>s(e=>e+1),actionMenu:(0,z.jsx)(Gj,{issueId:e.identifier,mode:`overflow-only`,className:`inline-flex`,openSignal:o}),trailingBadge:(0,z.jsx)(q5,{issueId:e.identifier,autoMerge:c,variant:`badge`,compact:!0})})}function KSt({onSearchOpen:e,onTabChange:t}={}){let n=sm(fm),r=sm(e=>e.reviewStatusByIssueId),i=sm(lm),a=sm(e=>e.openIssue),o=sm(e=>e.drawer.issueId),[s,c]=(0,R.useState)(PSt),{eventsByIssue:l}=eM({limit:500}),u=aM(3e4),d=(0,R.useRef)({ship:null,review:null,verifying:null,work:null,plan:null,ready:null,todo:null}),f=(0,R.useRef)(null),p=(0,R.useRef)(0);(0,R.useEffect)(()=>{if(o===null&&p.current>0){let e=f.current;e&&window.requestAnimationFrame(()=>{e.scrollTop=p.current})}},[o]),(0,R.useEffect)(()=>{let e=()=>c(PSt());return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[]);let m=(0,R.useMemo)(()=>{let e=new Map;for(let t of i){let n=t.issueId?.toLowerCase();n&&!e.has(n)&&e.set(n,t)}return e},[i]),h=(0,R.useMemo)(()=>{let e=new Map;for(let t of n){let n=ISt(t);n&&!e.has(n.id)&&e.set(n.id,n)}return Array.from(e.values()).sort((e,t)=>e.name.localeCompare(t.name))},[n]),g=(0,R.useMemo)(()=>{let e={ship:[],review:[],verifying:[],work:[],plan:[],ready:[],todo:[]};for(let t of n){if(BSt(t))continue;let n=ISt(t);if(s.projects.length>0&&(!n||!s.projects.includes(n.id)))continue;let i=m.get(t.identifier.toLowerCase())??null,a=kSt(r,t),o=_h(t,a,i);s.phase===`ship`&&(LSt(a)||RSt(a))&&(o=`ship`),!(s.phase!==`all`&&o!==s.phase)&&zSt(s,a)&&e[o].push(t)}for(let t of J5)e[t].sort(NSt);return e},[m,s,n,r]),_=(0,R.useMemo)(()=>{let e=n.filter(e=>{if(BSt(e))return!1;let t=m.get(e.identifier.toLowerCase())??null;return _h(e,kSt(r,e),t)!==`todo`}).length,t=i.filter(e=>e.role===`work`&&VSt(e)).length,a=new Set;for(let e of i)(e.role===`review`||e.role===`test`)&&VSt(e)&&e.issueId&&a.add(e.issueId);for(let e of Object.values(r))(e.reviewStatus===`reviewing`||e.testStatus===`testing`||e.verificationStatus===`running`)&&a.add(e.issueId);let o=Object.values(r).filter(e=>e.readyForMerge===!0&&e.mergeStatus!==`merged`).length,s=OSt(l);return[{id:`active`,eyebrow:`Active issues`,value:e,sub:`open pipeline`,icon:(0,z.jsx)(Y5,{label:`●`}),signal:`info`},{id:`work`,eyebrow:`Work running`,value:t,sub:`work agents`,icon:(0,z.jsx)(Y5,{label:`▶`}),signal:`info`},{id:`review`,eyebrow:`Review running`,value:a.size,sub:`review gates`,icon:(0,z.jsx)(Y5,{label:`◆`}),signal:`review`},{id:`ship`,eyebrow:`Ship`,value:o,sub:`ready to merge`,icon:(0,z.jsx)(Y5,{label:`↑`}),signal:`success`},{id:`spend`,eyebrow:`Spend`,value:HSt(s),sub:`24h spend`,icon:(0,z.jsx)(Y5,{label:`$`}),signal:`cost`}]},[i,m,l,n,r]),v=s.phase===`all`?J5:[s.phase];function y(e,t){c(e),FSt(e),t&&window.requestAnimationFrame(()=>d.current[t]?.scrollIntoView?.({block:`start`}))}function b(e){y({...s,phase:e},e===`all`?void 0:e)}function x(e){let t=s.projects.includes(e)?s.projects.filter(t=>t!==e):[...s.projects,e];y({...s,projects:t})}function S(e){y({...s,phase:`ship`,[e]:!s[e]},`ship`)}return(0,z.jsxs)(`section`,{className:`flex h-full w-full flex-col overflow-hidden bg-background`,"data-component":`pipeline-view`,children:[(0,z.jsx)(cM,{title:`Pipeline`,breadcrumb:`Unified operations`,search:e?(0,z.jsx)(`button`,{type:`button`,"data-component":`pipeline-search-trigger`,onClick:e,className:`flex h-[32px] w-full min-w-[280px] items-center gap-[8px] rounded-[var(--radius-lg)] border border-border bg-card px-[10px] text-[12px] text-muted-foreground hover:border-primary/40 hover:text-foreground`,children:`Search issues, agents, branches…`}):void 0,segmentedControl:t?(0,z.jsx)(`div`,{"data-component":`pipeline-segmented-control`,className:`flex items-center gap-[2px] rounded-[var(--radius-lg)] border border-border bg-card p-[2px]`,children:[`List`,`Board`,`Analytics`].map(e=>(0,z.jsx)(`button`,{type:`button`,"aria-pressed":e===`List`,onClick:()=>{e===`Board`?t(`kanban`):e===`Analytics`&&t(`metrics`)},className:vj(`rounded-[calc(var(--radius-lg)-2px)] px-[10px] py-[5px] text-[12px] font-medium leading-none text-muted-foreground transition-colors hover:text-foreground`,e===`List`&&`bg-accent text-foreground`),children:e},e))}):void 0,actions:e?(0,z.jsxs)(`button`,{type:`button`,"data-component":`pipeline-start-agent`,onClick:e,className:`flex h-[32px] items-center gap-[6px] rounded-[var(--radius-lg)] bg-primary px-[14px] text-[12px] font-medium text-primary-foreground hover:bg-primary/90`,children:[(0,z.jsx)(`span`,{"aria-hidden":`true`,children:`▶`}),`Start agent`]}):void 0}),(0,z.jsx)(sM,{columns:5,tiles:_}),(0,z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-[8px] border-b border-border bg-background px-[22px] py-[10px]`,"data-component":`pipeline-filter-row`,children:[(0,z.jsx)(`div`,{className:`flex items-center gap-[4px] rounded-[var(--radius-sm)] border border-border bg-card p-[2px]`,"aria-label":`Pipeline phase filter`,children:ESt.map(e=>(0,z.jsx)(`button`,{type:`button`,className:vj(`rounded-[calc(var(--radius-sm)-2px)] px-[9px] py-[5px] text-[11px] font-medium capitalize text-muted-foreground transition-colors hover:text-foreground`,s.phase===e&&`bg-accent text-foreground`),"aria-pressed":s.phase===e,onClick:()=>b(e),children:e},e))}),h.length>0&&(0,z.jsx)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-[6px]`,"aria-label":`Pipeline project filter`,children:h.map(e=>{let t=s.projects.includes(e.id);return(0,z.jsx)(`button`,{type:`button`,className:vj(`rounded-full border border-border px-[9px] py-[5px] text-[11px] font-medium text-muted-foreground transition-colors hover:text-foreground`,t&&`border-primary/50 bg-primary/10 text-foreground`),"aria-pressed":t,onClick:()=>x(e.id),children:e.name},e.id)})}),(0,z.jsxs)(`div`,{className:`ml-auto flex items-center gap-[6px]`,"aria-label":`Pipeline merge modifiers`,children:[(0,z.jsx)(`button`,{type:`button`,className:vj(`rounded-[var(--radius-sm)] border border-border px-[9px] py-[5px] text-[11px] font-medium text-muted-foreground transition-colors hover:text-foreground`,s.phase===`ship`&&s.blocked&&`border-warning/50 bg-warning/10 text-foreground`),"aria-pressed":s.phase===`ship`&&s.blocked,onClick:()=>S(`blocked`),children:`Blocked`}),(0,z.jsx)(`button`,{type:`button`,className:vj(`rounded-[var(--radius-sm)] border border-border px-[9px] py-[5px] text-[11px] font-medium text-muted-foreground transition-colors hover:text-foreground`,s.phase===`ship`&&s.noPr&&`border-info/50 bg-info/10 text-foreground`),"aria-pressed":s.phase===`ship`&&s.noPr,onClick:()=>S(`noPr`),children:`No PR`})]})]}),(0,z.jsxs)(`div`,{ref:f,className:`flex-1 overflow-auto`,children:[v.every(e=>g[e].length===0)?(0,z.jsx)(`div`,{"data-component":`pipeline-empty-state`,className:`mx-[22px] mt-[24px] rounded-[18px] border border-dashed border-border bg-card px-6 py-10 text-center text-sm text-muted-foreground`,children:`No issues match the selected filters.`}):v.map(e=>(0,z.jsxs)(`section`,{ref:t=>{d.current[e]=t},"data-component":`pipeline-phase`,"data-phase":e,children:[(0,z.jsx)(Dvt,{phase:e,count:g[e].length}),g[e].map(t=>(0,z.jsx)(GSt,{issue:t,phase:e,agent:m.get(t.identifier.toLowerCase()),costEvents:l[t.identifier],now:u,onOpen:e=>{p.current=f.current?.scrollTop??0,a(e)}},t.identifier))]},e)),(0,z.jsx)(`div`,{className:`h-[72px]`,"data-component":`pipeline-footer-empty`})]})]})}async function qSt(e){let t=await fetch(`/api/workspaces/${e}`);return t.ok?t.json():{}}async function JSt(e){let t=await fetch(`/api/workspaces/${e}/uat-context`);return t.ok?t.json():{}}async function YSt(e){let t=await fetch(`/api/workspaces/${e}/rebuild-stack`,{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||`Rebuild failed (${t.status})`)}}async function XSt(e){let t=await fetch(`/api/issues/${e}/forge-merge`,{method:`POST`,headers:{"Content-Type":`application/json`}});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||`Merge failed (${t.status})`)}return t.json()}async function ZSt(e){let t=await fetch(`/api/issues/${e}/forge-approve`,{method:`POST`,headers:{"Content-Type":`application/json`}});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||`Approve failed (${t.status})`)}return t.json()}function QSt(e){let t=(e?.state??e?.status??``).trim().toLowerCase().replace(/[-\s]+/g,`_`);return t===`verifying`||t===`verifying_on_main`}async function $St(e){let t=await fetch(`/api/issues/${e}/merge`,{method:`POST`,headers:{"Content-Type":`application/json`}});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||`Merge failed (${t.status})`)}return t.json()}function eCt(){let e=_t(),t=sm(Dhe),n=sm(fm),r=(0,R.useMemo)(()=>{let e=new Map;for(let t of n)t?.identifier&&e.set(t.identifier.toLowerCase(),t),t?.id&&e.set(String(t.id).toLowerCase(),t);return e},[n]),i=(0,R.useMemo)(()=>{let e=e=>{let t=e.toUpperCase().split(`-`)[0];return t===`PAN`?0:t===`KRUX`?1:2};return t.filter(e=>{let t=r.get(e.issueId.toLowerCase());return!(t?.state===`canceled`||QSt(t)||t?.state===`done`&&(e.mergeStatus===`failed`||t?.mergeStatus===`failed`||Array.isArray(t?.labels)&&t.labels.includes(`merged`))||(e.blockerReasons?.length??0)>0)}).sort((t,n)=>{let r=e(t.issueId),i=e(n.issueId);return r===i?(t.updatedAt??``).localeCompare(n.updatedAt??``):r-i})},[t,r]),a=sm(Ohe),o=sm(khe),s=(0,R.useMemo)(()=>o.filter(e=>!QSt(r.get(e.issueId.toLowerCase()))),[o,r]),c=jt({queries:i.map(e=>({queryKey:[`workspace`,e.issueId],queryFn:()=>qSt(e.issueId),staleTime:3e4}))});return(0,z.jsx)(`div`,{className:`flex-1 overflow-y-auto bg-background`,children:(0,z.jsxs)(`div`,{className:`max-w-5xl mx-auto p-6`,children:[(0,z.jsxs)(`header`,{className:`mb-6`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-3 mb-1`,children:[(0,z.jsx)(Gn,{className:`w-6 h-6 text-primary`}),(0,z.jsx)(`h1`,{className:`text-2xl font-semibold text-foreground`,children:`Awaiting Merge`}),(0,z.jsx)(`span`,{className:`ml-2 text-xs px-2 py-0.5 rounded-full bg-accent text-muted-foreground`,children:i.length})]}),(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Issues that have passed review and test and are waiting for a human UAT + merge click. Open the frontend link to verify, then merge.`})]}),i.length===0?(0,z.jsx)(tCt,{}):(0,z.jsx)(`ul`,{className:`space-y-3`,children:i.map((t,n)=>{let i=r.get(t.issueId.toLowerCase()),a=c[n]?.data;return(0,z.jsx)(iCt,{issueId:t.issueId,title:i?.title??t.issueId,description:i?.description,identifier:i?.identifier??t.issueId,trackerUrl:i?.url,frontendUrl:a?.frontendUrl,apiUrl:a?.apiUrl,stackHealthy:a?.stackHealth?.healthy,stackHealth:a?.stackHealth,stackReason:a?.stackHealth?.reasons?.[0],containers:a?.containers,pendingOperation:a?.pendingOperation,prUrl:t.prUrl??a?.mrUrl,updatedAt:t.updatedAt,mergeStatus:t.mergeStatus,mergeStep:t.mergeStep,mergeNotes:t.mergeNotes,autoMerge:t.autoMerge,uatNotes:t.uatNotes,onMerged:()=>{e.invalidateQueries({queryKey:[`workspace`,t.issueId]}),e.invalidateQueries({queryKey:[`review-status`,t.issueId]}),e.invalidateQueries({queryKey:[`command-deck-projects`]})}},t.issueId)})}),a.length>0&&(0,z.jsxs)(`div`,{className:`mt-10`,children:[(0,z.jsxs)(`header`,{className:`mb-4`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-3 mb-1`,children:[(0,z.jsx)(Dr,{className:`w-5 h-5 text-destructive`}),(0,z.jsx)(`h2`,{className:`text-lg font-semibold text-foreground`,children:`Blocked from Merge`}),(0,z.jsx)(`span`,{className:`ml-2 text-xs px-2 py-0.5 rounded-full bg-destructive/15 text-destructive`,children:a.length})]}),(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`These issues were ready to merge but GitHub is blocking them. Resolve the blocker on GitHub and the issue will re-enter the queue automatically.`})]}),(0,z.jsx)(`ul`,{className:`space-y-3`,children:a.map(e=>{let t=r.get(e.issueId.toLowerCase());return(0,z.jsx)(oCt,{issueId:e.issueId,title:t?.title??e.issueId,identifier:t?.identifier??e.issueId,trackerUrl:t?.url,blockerReasons:e.blockerReasons??[],updatedAt:e.updatedAt},e.issueId)})})]}),s.length>0&&(0,z.jsx)(sCt,{openMergeRequests:s,issuesById:r})]})})}function tCt(){return(0,z.jsxs)(`div`,{className:`border border-dashed border-border rounded-lg p-10 text-center`,children:[(0,z.jsx)(on,{className:`w-10 h-10 text-muted-foreground mx-auto mb-3`}),(0,z.jsx)(`p`,{className:`text-sm text-foreground mb-1`,children:`Nothing awaiting merge.`}),(0,z.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`The flywheel is idling — kick off more work or run `,(0,z.jsx)(`code`,{children:`/all-up`}),`.`]})]})}var nCt=[{key:`queued`,label:`Queued in merge queue`},{key:`validating-pr`,label:`Validating PR state`},{key:`rebasing`,label:`Rebasing onto main`},{key:`stripping-planning`,label:`Stripping .planning/ artifacts`},{key:`verifying`,label:`Post-rebase verification`},{key:`reporting-statuses`,label:`Reporting commit statuses`},{key:`squash-merging`,label:`Squash merge via forge`},{key:`post-merge-cleanup`,label:`Post-merge cleanup`}];function rCt({mergeStep:e,mergeStatus:t,mergeNotes:n}){if(!e&&t!==`merging`&&t!==`verifying`&&t!==`queued`)return null;let r=nCt.findIndex(t=>t.key===e),i=t===`failed`;return(0,z.jsxs)(`div`,{className:`mt-3 pl-1 border-l-2 border-primary/20 ml-1`,children:[(0,z.jsx)(`div`,{className:`space-y-1.5 pl-3`,children:nCt.map((e,n)=>{let a,o;return i&&n===r?(a=(0,z.jsx)(un,{className:`w-3.5 h-3.5 text-destructive shrink-0`}),o=`text-destructive`):n<r||t===`merged`&&r===-1?(a=(0,z.jsx)(on,{className:`w-3.5 h-3.5 text-success shrink-0`}),o=`text-muted-foreground`):n===r?(a=(0,z.jsx)(ar,{className:`w-3.5 h-3.5 text-primary animate-spin shrink-0`}),o=`text-foreground font-medium`):(a=(0,z.jsx)(dn,{className:`w-3.5 h-3.5 text-muted-foreground/40 shrink-0`}),o=`text-muted-foreground/60`),(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[a,(0,z.jsx)(`span`,{className:`text-[11px] ${o}`,children:e.label})]},e.key)})}),i&&n&&(0,z.jsx)(`p`,{className:`text-[11px] text-destructive mt-2 pl-3`,children:n})]})}function iCt({issueId:e,identifier:t,title:n,description:r,trackerUrl:i,frontendUrl:a,apiUrl:o,stackHealthy:s,stackHealth:c,stackReason:l,containers:u,pendingOperation:d,prUrl:f,updatedAt:p,mergeStatus:m,mergeStep:h,mergeNotes:g,autoMerge:_,uatContext:v,uatNotes:y,onMerged:b}){let x=_t(),S=Nt({mutationFn:()=>$St(e),onSuccess:()=>{H.success(`Merge started for ${t}`),b()},onError:e=>{H.error(`Merge failed for ${t}`,{description:e.message})}}),C=Nt({mutationFn:()=>YSt(e),onSuccess:()=>{x.invalidateQueries({queryKey:[`workspace`,e]}),H.success(`Rebuilding stack for ${t}`,{description:`UAT environment status is now shown in this row, the issue tree, and the issue slide-out.`})},onError:e=>{H.error(`Stack rebuild failed for ${t}`,{description:e.message})}}),w=m===`merging`||m===`queued`||m===`verifying`||S.isPending,T=m===`failed`,E=d?.type===`rebuild-stack`&&d.status===`failed`,D=C.isPending||d?.status===`running`&&(d.type===`containerize`||d.type===`start`||d.type===`rebuild-stack`),[O,k]=(0,R.useState)(!1),A=B({queryKey:[`uat-context`,e],queryFn:()=>JSt(e),enabled:O&&!v,staleTime:5*6e4,refetchInterval:!1,refetchOnWindowFocus:!1}),j=v??A.data,M=j?.acceptanceCriteria?.filter(e=>e.title.trim())??[],N=j?.deliverables?.filter(e=>e.title.trim())??[],P=j?.changedFiles??[],F=j?.changedFilesOmitted??Math.max(0,(j?.changedFilesTotal??0)-P.length),I=j?.proposal?.trim(),ee=r?.trim()||n,te=!!(A.isLoading&&!A.isError&&!v);return(0,z.jsxs)(`li`,{className:`border border-border rounded-lg bg-card p-4`,"data-testid":`merge-row-${t}`,children:[(0,z.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[i?(0,z.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,className:`text-xs font-mono px-1.5 py-0.5 rounded bg-accent text-foreground hover:underline`,children:t}):(0,z.jsx)(`span`,{className:`text-xs font-mono px-1.5 py-0.5 rounded bg-accent text-foreground`,children:t}),T&&(0,z.jsxs)(`span`,{className:`text-[10px] uppercase tracking-wider px-1.5 py-0.5 rounded bg-destructive/15 text-destructive flex items-center gap-1`,title:`A previous merge attempt failed`,children:[(0,z.jsx)(Ir,{className:`w-3 h-3`}),`Last merge failed`]}),w&&(0,z.jsxs)(`span`,{className:`text-[10px] uppercase tracking-wider px-1.5 py-0.5 rounded bg-primary/15 text-primary flex items-center gap-1`,children:[(0,z.jsx)(ar,{className:`w-3 h-3 animate-spin`}),`Merge in progress`]}),p&&!w&&(0,z.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[`ready `,Z5(p)]})]}),(0,z.jsx)(`p`,{className:`text-sm text-foreground truncate`,title:n,children:n}),f&&(0,z.jsx)(`a`,{href:f,target:`_blank`,rel:`noreferrer`,className:`text-[11px] text-muted-foreground hover:text-foreground hover:underline mt-1 inline-block`,"data-testid":`merge-pr-link-${t}`,children:`View PR ↗`})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[s===!1?(0,z.jsxs)(`button`,{type:`button`,onClick:()=>C.mutate(),disabled:C.isPending,title:l?`Workspace stack is down: ${l}`:`Workspace stack is down — rebuild it to UAT`,className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md text-sm border border-amber-500/30 text-amber-600 dark:text-amber-400 hover:bg-amber-500/10 transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,children:[C.isPending?(0,z.jsx)(ar,{className:`w-3.5 h-3.5 animate-spin`}):(0,z.jsx)(jee,{className:`w-3.5 h-3.5`}),C.isPending?`Rebuilding…`:`Rebuild to UAT`]}):a?(0,z.jsxs)(`a`,{href:a,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md text-sm border border-border text-foreground hover:bg-accent transition-colors`,title:`Open the workspace frontend for UAT`,children:[(0,z.jsx)(kn,{className:`w-3.5 h-3.5`}),`UAT`]}):(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md text-sm border border-border text-muted-foreground/60 cursor-not-allowed`,title:`No frontend URL — workspace info unavailable`,children:[(0,z.jsx)(kn,{className:`w-3.5 h-3.5`}),`UAT`]}),(0,z.jsx)(q5,{issueId:e,autoMerge:_,compact:!0}),(0,z.jsxs)(`button`,{onClick:()=>S.mutate(),disabled:w,className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md text-sm bg-primary text-primary-foreground hover:opacity-90 transition-opacity disabled:opacity-50 disabled:cursor-not-allowed`,"data-testid":`merge-btn-${t}`,children:[w?(0,z.jsx)(ar,{className:`w-3.5 h-3.5 animate-spin`}):(0,z.jsx)(Gn,{className:`w-3.5 h-3.5`}),w?`Merging��`:`Merge`]})]})]}),(D||s===!1||u)&&(0,z.jsxs)(`div`,{className:`mt-3`,"data-testid":`merge-uat-stack-${t}`,children:[(0,z.jsx)(sH,{containers:u,stackHealth:c,frontendUrl:a,apiUrl:o,pending:D,density:`compact`}),E&&d?.error?(0,z.jsxs)(`p`,{className:`mt-2 rounded-md border border-destructive/30 bg-destructive/10 px-2.5 py-2 text-[11px] text-destructive`,children:[`Rebuild failed: `,d.error]}):null]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>k(e=>!e),className:`mt-3 inline-flex items-center gap-1.5 text-[11px] font-medium text-muted-foreground hover:text-foreground transition-colors`,"data-testid":`merge-uat-toggle-${t}`,children:[O?(0,z.jsx)(rn,{className:`w-3.5 h-3.5`}):(0,z.jsx)(en,{className:`w-3.5 h-3.5`}),`What to test / Expected changes`]}),O&&(0,z.jsxs)(`div`,{className:`mt-3 rounded-md border border-border/70 bg-muted/20 p-3`,"data-testid":`merge-uat-context-${t}`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,z.jsx)(qee,{className:`w-3.5 h-3.5 text-primary`}),(0,z.jsx)(`h3`,{className:`text-xs font-semibold text-foreground`,children:`What to test (UAT)`})]}),te&&(0,z.jsx)(`p`,{className:`text-[11px] text-muted-foreground mb-2`,children:`Loading UAT context…`}),M.length>0?(0,z.jsx)(`ul`,{className:`space-y-1.5`,children:M.map(e=>(0,z.jsxs)(`li`,{className:`flex items-start gap-2 text-xs text-foreground`,children:[(0,z.jsx)(dn,{className:`w-3.5 h-3.5 text-muted-foreground mt-0.5 shrink-0`}),(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`span`,{children:e.title}),e.itemTitle&&(0,z.jsxs)(`span`,{className:`ml-1 text-[11px] text-muted-foreground`,children:[`(`,e.itemTitle,`)`]})]})]},e.id))}):(0,z.jsx)(`p`,{className:`text-xs text-foreground whitespace-pre-wrap`,children:ee}),(0,z.jsxs)(`div`,{className:`mt-4 border-t border-border/60 pt-3`,children:[(0,z.jsx)(`h3`,{className:`text-xs font-semibold text-foreground mb-2`,children:`Expected changes`}),N.length>0?(0,z.jsx)(`ul`,{className:`space-y-1.5 mb-3`,children:N.map(e=>(0,z.jsxs)(`li`,{className:`text-xs text-foreground`,children:[(0,z.jsx)(`span`,{className:`font-medium`,children:e.title}),e.action&&(0,z.jsx)(`span`,{className:`block text-[11px] text-muted-foreground mt-0.5`,children:e.action})]},e.id))}):I?(0,z.jsx)(`p`,{className:`text-xs text-foreground whitespace-pre-wrap mb-3`,children:I}):(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground mb-3`,children:`No deliverables available.`}),(0,z.jsx)(`div`,{className:`space-y-1.5`,children:P.length>0?(0,z.jsxs)(z.Fragment,{children:[P.map(e=>(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] text-muted-foreground`,children:[(0,z.jsx)(`span`,{className:`font-mono px-1 py-0.5 rounded bg-accent text-foreground`,children:e.status}),(0,z.jsx)(`span`,{className:`font-mono text-foreground truncate`,children:e.path}),(0,z.jsxs)(`span`,{className:`ml-auto font-mono text-success`,children:[`+`,e.additions]}),(0,z.jsxs)(`span`,{className:`font-mono text-destructive`,children:[`-`,e.deletions]})]},`${e.status}:${e.path}`)),F>0&&(0,z.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,children:[`+`,F,` more files`]})]}):(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No file changes available.`})})]}),y?.trim()&&(0,z.jsxs)(`div`,{className:`mt-3 rounded border border-primary/20 bg-primary/5 px-2.5 py-2`,children:[(0,z.jsx)(`p`,{className:`text-[10px] uppercase tracking-wider text-primary mb-1`,children:`Reviewer UAT notes`}),(0,z.jsx)(`p`,{className:`text-xs text-foreground whitespace-pre-wrap`,children:y.trim()})]})]}),(w||T)&&(0,z.jsx)(rCt,{mergeStep:h,mergeStatus:m,mergeNotes:g})]})}function aCt(e){switch(e){case`failing_checks`:return(0,z.jsx)(un,{className:`w-3 h-3`});case`merge_conflict`:return(0,z.jsx)(Kn,{className:`w-3 h-3`});case`unresolved_conversations`:return(0,z.jsx)(cr,{className:`w-3 h-3`});case`changes_requested`:return(0,z.jsx)(dee,{className:`w-3 h-3`});case`draft_pr`:return(0,z.jsx)(Dee,{className:`w-3 h-3`});case`not_mergeable`:return(0,z.jsx)(Ir,{className:`w-3 h-3`});default:return(0,z.jsx)(Dr,{className:`w-3 h-3`})}}function oCt({identifier:e,title:t,trackerUrl:n,blockerReasons:r,updatedAt:i}){let[a,o]=(0,R.useState)(!1);return(0,z.jsxs)(`li`,{className:`border border-destructive/30 rounded-lg bg-card p-4 opacity-80`,children:[(0,z.jsx)(`div`,{className:`flex items-start gap-4`,children:(0,z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[n?(0,z.jsx)(`a`,{href:n,target:`_blank`,rel:`noreferrer`,className:`text-xs font-mono px-1.5 py-0.5 rounded bg-accent text-foreground hover:underline`,children:e}):(0,z.jsx)(`span`,{className:`text-xs font-mono px-1.5 py-0.5 rounded bg-accent text-foreground`,children:e}),i&&(0,z.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[`ready `,Z5(i)]})]}),(0,z.jsx)(`p`,{className:`text-sm text-foreground truncate`,title:t,children:t}),(0,z.jsx)(`div`,{className:`flex flex-wrap gap-2 mt-2`,children:r.map(e=>(0,z.jsxs)(`span`,{className:`text-[10px] uppercase tracking-wider px-2 py-0.5 rounded bg-destructive/15 text-destructive flex items-center gap-1`,title:e.details??e.summary,children:[aCt(e.type),e.type,`: `,e.summary]},e.type))})]})}),r.some(e=>e.details)&&(0,z.jsxs)(`button`,{onClick:()=>o(!a),className:`mt-2 flex items-center gap-1 text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:[a?(0,z.jsx)(rn,{className:`w-3 h-3`}):(0,z.jsx)(en,{className:`w-3 h-3`}),a?`Hide details`:`Show details`]}),a&&(0,z.jsx)(`div`,{className:`mt-2 space-y-1`,children:r.filter(e=>e.details).map(e=>(0,z.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,children:[(0,z.jsxs)(`span`,{className:`font-medium text-foreground`,children:[e.type,`:`]}),` `,e.details]},e.type))})]})}function X5(e,t){return!t||t===`pending`?(0,z.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider px-1.5 py-0.5 rounded bg-accent text-muted-foreground`,children:e}):t===`running`?(0,z.jsxs)(`span`,{className:`text-[10px] uppercase tracking-wider px-1.5 py-0.5 rounded bg-primary/15 text-primary flex items-center gap-1`,children:[(0,z.jsx)(ar,{className:`w-3 h-3 animate-spin`}),e]}):t===`passed`||t===`skipped`?(0,z.jsxs)(`span`,{className:`text-[10px] uppercase tracking-wider px-1.5 py-0.5 rounded bg-success/15 text-success flex items-center gap-1`,children:[(0,z.jsx)(on,{className:`w-3 h-3`}),e]}):t===`failed`?(0,z.jsxs)(`span`,{className:`text-[10px] uppercase tracking-wider px-1.5 py-0.5 rounded bg-destructive/15 text-destructive flex items-center gap-1`,children:[(0,z.jsx)(un,{className:`w-3 h-3`}),e]}):(0,z.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider px-1.5 py-0.5 rounded bg-accent text-muted-foreground`,children:e})}function sCt({openMergeRequests:e,issuesById:t}){let[n,r]=(0,R.useState)(!1);return(0,z.jsxs)(`div`,{className:`mt-10`,children:[(0,z.jsx)(`button`,{onClick:()=>r(!n),className:`w-full text-left`,children:(0,z.jsxs)(`header`,{className:`mb-4`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-3 mb-1`,children:[(0,z.jsx)(Ir,{className:`w-5 h-5 text-amber-500`}),(0,z.jsx)(`h2`,{className:`text-lg font-semibold text-foreground`,children:`Pipeline Override`}),(0,z.jsx)(`span`,{className:`ml-2 text-xs px-2 py-0.5 rounded-full bg-amber-500/15 text-amber-600 dark:text-amber-400`,children:e.length}),(0,z.jsx)(`span`,{className:`ml-auto text-muted-foreground`,children:n?(0,z.jsx)(rn,{className:`w-4 h-4`}):(0,z.jsx)(en,{className:`w-4 h-4`})})]}),!n&&(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`PRs still going through the review/test pipeline. Click to expand override actions.`})]})}),n&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`rounded-md border border-amber-500/30 bg-amber-500/5 p-3 mb-4 text-[12px] text-amber-700 dark:text-amber-300`,children:`These issues have open PRs but haven't completed the review/test pipeline. Merging here bypasses Overdeck's rebase, verification, and cleanup steps.`}),(0,z.jsx)(`ul`,{className:`space-y-3`,children:e.map(e=>{let n=t.get(e.issueId.toLowerCase());return(0,z.jsx)(cCt,{issueId:e.issueId,identifier:n?.identifier??e.issueId,title:n?.title??e.issueId,trackerUrl:n?.url,prUrl:e.prUrl,reviewStatus:e.reviewStatus,testStatus:e.testStatus,verificationStatus:e.verificationStatus,updatedAt:e.updatedAt},e.issueId)})})]})]})}function cCt({issueId:e,identifier:t,title:n,trackerUrl:r,prUrl:i,reviewStatus:a,testStatus:o,verificationStatus:s,updatedAt:c}){let l=Hr(),u=i?.includes(`gitlab`)?`GitLab`:`GitHub`,d=Nt({mutationFn:()=>ZSt(e),onSuccess:()=>{H.success(`Approved ${t}`)},onError:e=>{H.error(`Approve failed for ${t}`,{description:e.message})}}),f=Nt({mutationFn:()=>XSt(e),onSuccess:()=>{H.success(`Force merge started for ${t}`)},onError:e=>{H.error(`Force merge failed for ${t}`,{description:e.message})}});return(0,z.jsxs)(`li`,{className:`border border-amber-500/20 rounded-lg bg-card p-4 flex items-start gap-4`,children:[(0,z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[r?(0,z.jsx)(`a`,{href:r,target:`_blank`,rel:`noreferrer`,className:`text-xs font-mono px-1.5 py-0.5 rounded bg-accent text-foreground hover:underline`,children:t}):(0,z.jsx)(`span`,{className:`text-xs font-mono px-1.5 py-0.5 rounded bg-accent text-foreground`,children:t}),c&&(0,z.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[`opened `,Z5(c)]})]}),(0,z.jsx)(`p`,{className:`text-sm text-foreground truncate`,title:n,children:n}),(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-1.5 mt-2`,children:[X5(`review`,a),X5(`test`,o),X5(`verify`,s)]})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[i&&(0,z.jsxs)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md text-sm border border-border text-foreground hover:bg-accent transition-colors`,children:[(0,z.jsx)(kn,{className:`w-3.5 h-3.5`}),`View PR`]}),(0,z.jsxs)(`button`,{onClick:async()=>{await l({title:`Force Approve ${t}`,message:`This bypasses Overdeck's review pipeline and submits an approving review directly on ${u}.\n\nThe automated review/test pipeline will continue running independently.`,confirmLabel:`Force Approve`})&&d.mutate()},disabled:d.isPending,className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md text-sm border border-amber-500/30 text-amber-600 dark:text-amber-400 hover:bg-amber-500/10 transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,children:[d.isPending?(0,z.jsx)(ar,{className:`w-3.5 h-3.5 animate-spin`}):(0,z.jsx)(qee,{className:`w-3.5 h-3.5`}),`Force Approve`]}),(0,z.jsxs)(`button`,{onClick:async()=>{await l({title:`Force Merge ${t} (Skip Pipeline)`,message:`This will squash-merge directly via ${u}, bypassing:\n\n• Rebasing onto main\n• Post-rebase verification (typecheck/lint/test)\n• Post-merge cleanup (labels, issue close, Docker teardown)\n\nYou'll need to handle cleanup manually. Use this only when the issue was handled outside the automated pipeline.`,confirmLabel:`Force Merge`,variant:`destructive`})&&f.mutate()},disabled:f.isPending,className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md text-sm bg-amber-600 text-white hover:bg-amber-700 transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,children:[f.isPending?(0,z.jsx)(ar,{className:`w-3.5 h-3.5 animate-spin`}):(0,z.jsx)(Gn,{className:`w-3.5 h-3.5`}),`Force Merge`]})]})]})}function Z5(e){let t=new Date(e).getTime();if(Number.isNaN(t))return e;let n=Math.max(0,Math.round((Date.now()-t)/1e3));if(n<60)return`${n}s ago`;let r=Math.round(n/60);if(r<60)return`${r}m ago`;let i=Math.round(r/60);return i<24?`${i}h ago`:`${Math.round(i/24)}d ago`}var Q5=null;function lCt(){Q5?.releaseTimer&&window.clearTimeout(Q5.releaseTimer),Q5?.unsubscribe(),Q5=null}var uCt=[`review.security`,`review.correctness`,`review.performance`,`review.requirements`],$5=[`typecheck`,`lint`,`test`];function dCt(e,t){return e.identifier.toLowerCase()===t.toLowerCase()||e.id.toLowerCase()===t.toLowerCase()}function fCt(e){let t=new Map;for(let n of e)n.issueId&&t.set(n.id.toLowerCase(),n.issueId.toLowerCase());return t}function pCt(e,t,n){let r=t.toLowerCase();return e.issueId?e.issueId.toLowerCase()===r:e.agentId?n.get(e.agentId.toLowerCase())===r:!1}function mCt(e){let t=`${e.source??``} ${e.category??``} ${e.triggeringEvent??``}`.toLowerCase();return e.level===`success`||t.includes(`done`)||t.includes(`merge`)?`done`:t.includes(`ship`)?`ship`:t.includes(`review`)||t.includes(`test`)?`review`:t.includes(`work`)||t.includes(`agent`)?`work`:`info`}function hCt(e,t){return e.id??`${e.timestamp??`activity`}-${t}`}function gCt(e){return e.replace(`review.`,``)}function _Ct(e,t){let n=t?.reviewSubStatuses?.[e];return n===`done`?`done`:n===`running`?`run`:n===`failed`||t?.reviewStatus===`failed`||t?.reviewStatus===`blocked`?`fail`:`idle`}function vCt(e){switch(e){case`run`:return`running`;case`done`:return`complete`;case`fail`:return`blocked`;default:return`waiting`}}function yCt(e,t){let n=t?.reviewSessionNames?.find(t=>t.includes(gCt(e)));return n?n.replace(/^agent-/,``):`—`}function bCt(e){return uCt.map(t=>{let n=_Ct(t,e);return{id:t,name:t,status:n,meta:vCt(n),duration:yCt(t,e)}})}function xCt(e){return e===`closed`?`done`:e===`in_progress`?`current`:`open`}function e7(e){if(!e)return null;let t=new Date(e).getTime();return Number.isNaN(t)?null:t}function SCt(e,t){let n=e7(e),r=e7(t);if(n===null||r===null||r<n)return`—`;let i=Math.max(1,Math.round((r-n)/6e4));if(i<60)return`${i}m`;let a=Math.round(i/60);return a<24?`${a}h`:`${Math.round(a/24)}d`}function CCt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function wCt(e,t){return(e.title??e.name??e.id??`Untitled bead`).replace(RegExp(`^${CCt(t)}:\\s*`,`i`),``)}function TCt(e){if(!e)return;let t=e;return t.beads??t.tasks}function ECt(e,t){return(e??[]).map(e=>{let n=xCt(e.status);return{id:e.id??e.title??`bead`,title:wCt(e,t),status:n,duration:SCt(e.startedAt??e.createdAt,e.closedAt??e.updatedAt)}})}function DCt(e){return e===`passed`||e===`failed`||e===`pending`||e===`running`||e===`skipped`?e:e===`testing`?`running`:e===`dispatch_failed`?`failed`:`pending`}function OCt(e){return(e?.match(/Verification FAILED at (typecheck|lint|test)\b/i))?.[1]?.toLowerCase()}function kCt(e,t){let n=DCt(t?.verificationStatus);if(n===`passed`||n===`skipped`||n===`running`||n===`pending`)return n;let r=OCt(t?.verificationNotes);return r?e===r?`failed`:$5.indexOf(e)<$5.indexOf(r)?`passed`:`pending`:`passed`}function ACt(e){switch(e){case`passed`:return`pass`;case`failed`:return`fail`;case`running`:return`running`;case`skipped`:return`skipped`;default:return`pending`}}function jCt(e){let t=$5.map(t=>{let n=kCt(t,e);return{id:t,label:t,status:n,detail:ACt(n)}}),n=DCt(e?.uatStatus);return[...t,{id:`uat`,label:`UAT`,status:n,detail:ACt(n)}]}function t7(e){let t=e7(e);if(t===null)return`—`;let n=new Date(t);return`${String(n.getUTCMonth()+1).padStart(2,`0`)}/${String(n.getUTCDate()).padStart(2,`0`)}`}function MCt(e,t){let n=t?.mergeStatus===`merged`||e?.state===`done`||e?.status?.toLowerCase()===`done`||!!e?.completedAt,r=!n&&(t?.mergeStatus===`queued`||t?.mergeStatus===`merging`||t?.mergeStatus===`verifying`||!!t?.readyForMerge),i=n||r||t?.reviewStatus===`passed`,a=!i&&t?.reviewStatus===`reviewing`,o=i||a||t?.verificationStatus===`passed`||t?.testStatus===`passed`,s=!o&&(t?.verificationStatus===`running`||t?.testStatus===`testing`||e?.state===`in_progress`||e?.status?.toLowerCase()===`in progress`),c=o||s||!!e?.planningComplete,l=!c&&!!e?.hasPlan,u=n?-1:r?4:a?3:s?2:+!!l,d=[!!e,c,o,i,n,n];return[{id:`triaged`,label:`Triaged`,when:t7(e?.createdAt),sub:`issue`},{id:`planned`,label:`Planned`,when:t7(e?.updatedAt),sub:`plan`},{id:`implemented`,label:`Implemented`,when:t7(t?.updatedAt),sub:`work`},{id:`reviewed`,label:`Reviewed`,when:t7(t?.reviewSpawnedAt??t?.updatedAt),sub:`review`},{id:`shipping`,label:`Shipping`,when:t7(t?.updatedAt),sub:`ship`},{id:`merged`,label:`Merged`,when:t7(e?.completedAt??(n?t?.updatedAt:void 0)),sub:`done`}].map((e,t)=>({...e,state:d[t]?`done`:t===u?`current`:`upcoming`}))}function n7(e){let t=e,n=sm(fm),r=sm(lm),i=sm(e=>e.recentActivity),a=sm(e=>e.detailedActivity),o=sm(um(t??``));return(0,R.useEffect)(()=>{if(t)return Q5?.issueId===t?(Q5.releaseTimer!==null&&(window.clearTimeout(Q5.releaseTimer),Q5.releaseTimer=null),Q5.refCount+=1):(Q5&&lCt(),Q5={issueId:t,refCount:1,unsubscribe:hj().subscribe(e=>e[Pp.subscribeIssueEvents]({issueId:t}),e=>sm.getState().applyEvent(e)),releaseTimer:null}),()=>{Q5?.issueId===t&&(--Q5.refCount,Q5.refCount===0&&(Q5.releaseTimer=window.setTimeout(lCt,1e3)))}},[t]),(0,R.useMemo)(()=>{if(!t)return{issue:null,agents:[],reviewStatus:void 0,beads:[],reviewSpecialists:[],verificationGates:[],phaseTimeline:[],activityRail:[],activityFull:[]};let e=n.find(e=>dCt(e,t))??null,s=r.filter(e=>e.issueId?.toLowerCase()===t.toLowerCase()),c=fCt(r),l=new Map;for(let e of[...i,...a])pCt(e,t,c)&&l.set(hCt(e,l.size),e);let u=Array.from(l.entries()).map(([e,t])=>{let n=t.timestamp??``,r=n?new Date(n).getTime():0;return{id:e,phase:mCt(t),message:t.message??`Activity update`,when:n,time:Number.isNaN(r)?0:r}}).sort((e,t)=>t.time-e.time),d=u.slice(0,100);return{issue:e,agents:s,reviewStatus:o,beads:ECt(TCt(e),t),reviewSpecialists:bCt(o),verificationGates:jCt(o),phaseTimeline:MCt(e,o),activityRail:d,activityFull:u}},[r,a,t,n,i,o])}function r7(){return n7(sm(e=>e.drawer.issueId))}function NCt(){let{issue:e,reviewStatus:t}=r7(),n=e?.identifier;return(0,z.jsxs)(`footer`,{"data-component":`drawer-action-bar`,"data-testid":`drawer-action-bar`,className:`flex items-center gap-[10px] border-t border-border bg-card/70 px-[22px] py-[12px]`,children:[n?(0,z.jsx)(Gj,{issueId:n,mode:`hybrid`,pinRight:[`viewPr`],className:`flex min-w-0 flex-1 items-center gap-1`}):(0,z.jsx)(`div`,{className:`flex-1`}),n?(0,z.jsx)(cH,{issueId:n,reviewStatus:t,variant:`inspector`,issueState:e?.state??e?.status}):null]})}function PCt(e){return!(e.status===`dead`||e.status===`failed`)}function FCt(e,t){let n=e.firstFailureInRunAt??e.lastFailureAt??e.lastActivity??e.startedAt;if(!n)return 0;let r=new Date(n).getTime();return Number.isNaN(r)?0:Math.max(0,Math.floor((t.getTime()-r)/36e5))}function ICt(e){return gh(e.status)||e.troubled?{variant:`STUCK · Nh`,hours:FCt(e,new Date),className:`text-[9px]`}:nM(e)?{variant:`INPUT`,className:`text-[9px]`}:e.status===`stopped`?{variant:`STOPPED`,className:`text-[9px]`}:e.role===`plan`?{variant:`PLANNING`,className:`text-[9px]`}:e.role===`review`||e.role===`test`?{variant:`REVIEW RUNNING`,className:`text-[9px]`}:e.role===`ship`?{variant:`SHIP RUNNING`,className:`text-[9px]`}:{variant:`WORK RUNNING`,className:`text-[9px]`}}var LCt={"verb-line":`text-signal-review-foreground`,ok:`text-success-foreground`,warn:`text-warning-foreground`,err:`text-destructive-foreground`,neutral:`text-foreground`};function RCt(e){return/^[✗❌]|\bERR\b|\bERROR\b|\bFAIL\b/i.test(e)?`err`:/^!|\bWARN\b|\bWARNING\b/i.test(e)?`warn`:/^✓|\bOK\b|\bPASS\b|\bdone\b/i.test(e)?`ok`:/^[→▸✱]/.test(e)?`verb-line`:`neutral`}function zCt(e){return e===void 0?`loading`:e>=100?`$${e.toFixed(0)}`:e>=10?`$${e.toFixed(1)}`:e>=1?`$${e.toFixed(2)}`:e>0?`$${e.toFixed(3)}`:`$0`}function BCt(){let{agents:e}=r7(),t=e.find(PCt)??null,n=sm(t?jhe(t.id):()=>[]),[r,i]=(0,R.useState)(!1);if(!t)return(0,z.jsxs)(`section`,{id:`active-agent`,"data-component":`drawer-active-agent`,"data-testid":`drawer-active-agent`,className:`rounded-[var(--radius)] border border-border bg-card p-[14px]`,children:[(0,z.jsx)(`div`,{className:`mb-[8px] text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground`,children:`Active Agent`}),(0,z.jsx)(`div`,{className:`rounded-[10px] border border-border bg-background/45 px-[12px] py-[14px] text-[12px] text-muted-foreground`,children:`No active agent.`})]});let a=n.slice(-8),o=`${vh(t.model)} · ${vp(t)} · spend ${zCt(t.costSoFar)}`,s=async e=>{if(r)return!1;i(!0);try{let n=t.status===`running`||t.status===`starting`?`/api/agents/${t.id}/tell`:`/api/agents/${t.id}/resume`;console.log(`[drawer/active-agent] send to ${t.id} status=${t.status} endpoint=${n} messageLength=${e.length}`);let r=await fetch(n,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({message:e})});if(!r.ok){let e=await r.text();return console.warn(`[drawer/active-agent] send ${r.status} ${n}: ${e.slice(0,300)}`),!1}let i=await r.json().catch(()=>({}));return console.log(`[drawer/active-agent] send 200 ${n}: messageDelivered=${i.messageDelivered}`),!0}catch(e){return console.error(`[drawer/active-agent] send error:`,e),!1}finally{i(!1)}},c=t.status===`running`||t.status===`starting`,l=async()=>{if(r)return!1;i(!0);try{console.log(`[drawer/active-agent] resume click for ${t.id} status=${t.status}`);let e=await fetch(`/api/agents/${t.id}/resume`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({message:`Resumed from drawer`})}),n=await e.json().catch(()=>({}));return e.ok?(console.log(`[drawer/active-agent] resume 200: messageDelivered=${n.messageDelivered}`),!0):(console.warn(`[drawer/active-agent] resume ${e.status}: ${n.error??`unknown error`}`),!1)}finally{i(!1)}};return(0,z.jsxs)(`section`,{id:`active-agent`,"data-component":`drawer-active-agent`,"data-testid":`drawer-active-agent`,className:`rounded-[var(--radius)] border border-border border-l-[3px] border-l-signal-review bg-card p-[14px]`,children:[(0,z.jsxs)(`div`,{className:`flex items-start justify-between gap-[12px]`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-[8px]`,children:[(0,z.jsx)(`h3`,{className:`truncate font-mono text-[13px] font-semibold leading-none text-foreground`,children:t.id}),(0,z.jsx)(qj,{...ICt(t)})]}),(0,z.jsx)(`div`,{className:`mt-[6px] text-[10px] uppercase tracking-[0.08em] text-muted-foreground`,children:t.status===`stopped`?`Stopped Agent — send a message to resume`:`Active Agent`})]}),(0,z.jsx)(`div`,{className:`shrink-0 text-right font-mono text-[10px] leading-none text-muted-foreground`,children:o})]}),(0,z.jsx)(`div`,{"data-testid":`drawer-active-agent-stream`,className:`mt-[12px] max-h-[180px] overflow-auto rounded-[10px] border border-border bg-[rgb(0_0_0_/_32%)] px-[12px] py-[10px] font-mono text-[11px] leading-[16px]`,children:a.length>0?a.map((e,t)=>(0,z.jsx)(`div`,{className:`truncate ${LCt[RCt(e)]}`,children:e},`${e}-${t}`)):(0,z.jsx)(`div`,{className:`italic text-muted-foreground`,children:`No recent stream output`})}),!c&&(0,z.jsx)(`button`,{type:`button`,"data-testid":`drawer-resume-button`,className:`mt-[10px] w-full rounded-[var(--radius-sm)] border border-primary/30 bg-primary/10 px-[12px] py-[8px] text-[12px] font-medium text-primary transition-colors hover:bg-primary/20 disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>void l(),disabled:r,title:`Send a continue message to wake the agent. The backend will auto-resume the saved session and deliver the message in one round trip.`,children:r?`Resuming…`:`▶ Resume agent`}),(0,z.jsx)(Aj,{className:`mt-[10px] flex gap-[8px]`,sending:r,onSend:s})]})}async function VCt(e){let t=await fetch(`/api/agents/${encodeURIComponent(e)}/git-info`);return t.ok?t.json():null}var HCt=new Set([`stopped`,`dead`,`failed`]);function i7(e){return HCt.has(e.status)}function UCt(e){let t=e.filter(e=>!i7(e));return t.find(e=>e.role===`work`)??e.find(e=>e.role===`work`)??t[0]??e[0]??null}function WCt(e){let t=i7(e);return{id:-1,name:e.id,tmuxSession:e.id,status:t?`ended`:`active`,cwd:e.workspace??``,issueId:e.issueId??null,createdAt:e.startedAt,endedAt:t?e.lastActivity??e.startedAt:null,lastAttachedAt:null,sessionAlive:!t,sessionFile:e.id,model:e.model,harness:e.harness??e.runtime??null}}function GCt(e){return`${e.role?`${e.role[0].toUpperCase()}${e.role.slice(1)}`:`Agent`} · ${e.id}`}function KCt({view:e,agents:t,agentId:n,onSelectAgent:r}){let i=`drawer-tab-panel-${e}`,a=(0,R.useMemo)(()=>t.find(e=>e.id===n)??null,[t,n]),o=(0,R.useMemo)(()=>a?WCt(a):null,[a]),{hideToolCalls:s,toggleHideToolCalls:c}=JY(a?.id??``),{data:l}=B({queryKey:[`agent-git-info`,a?.id],queryFn:()=>a?VCt(a.id):Promise.resolve(null),enabled:!!a,staleTime:3e4,refetchInterval:3e4});if(!a||!o)return(0,z.jsxs)(`div`,{"data-testid":i,className:`rounded-[var(--radius)] border border-dashed border-border bg-card/60 p-[18px]`,children:[(0,z.jsx)(`div`,{className:`mb-[8px] text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground`,children:e===`conversation`?`Conversation`:`Terminal`}),(0,z.jsxs)(`p`,{className:`text-[13px] leading-6 text-muted-foreground`,children:[`No agent session for this issue yet. The `,e===`conversation`?`transcript`:`live terminal`,` appears here once an agent starts.`]})]});let u=!!(l?.actualBranch||l?.workspaceMissing),d=!!l?.branchDrifted,f=!!l?.workspaceMissing;return(0,z.jsxs)(`div`,{"data-testid":i,className:`flex min-h-0 flex-1 flex-col gap-[10px]`,children:[(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-[8px]`,children:[t.length>1&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground`,children:`Agent`}),(0,z.jsx)(`select`,{value:a.id,onChange:e=>r(e.target.value),"aria-label":`Select agent session`,className:`rounded-[var(--radius-sm)] border border-border bg-card px-[8px] py-[4px] text-[12px] text-foreground`,children:t.map(e=>(0,z.jsx)(`option`,{value:e.id,children:GCt(e)},e.id))})]}),u&&(0,z.jsx)(`span`,{className:`${J.terminalBranchBar} ${f?J.terminalBranchBarMissing:d?J.terminalBranchBarDrift:``}`,title:f?`Workspace missing on disk: ${l?.workspacePath??`(unknown path)`}`:d?`Expected ${l?.expectedBranch??`(none)`}, on ${l?.actualBranch??`(none)`}`:`${l?.workspacePath??``}`,"data-testid":`drawer-agent-branch-chip`,children:f?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(an,{size:12}),(0,z.jsx)(`span`,{className:J.terminalBranchBarMode,children:`Worktree missing`})]}):(0,z.jsxs)(z.Fragment,{children:[d?(0,z.jsx)(Ir,{size:12}):(0,z.jsx)(Wn,{size:12}),(0,z.jsx)(`span`,{className:J.terminalBranchBarMode,children:d?`Drifted`:`Worktree`}),(0,z.jsx)(`span`,{className:J.terminalBranchBarText,children:l?.actualBranch})]})}),(0,z.jsxs)(`button`,{type:`button`,className:`ml-auto ${J.conversationAboutToggle} ${s?J.conversationAboutToggleActive:``}`,onClick:c,title:s?`Show tool calls`:`Hide tool calls`,"aria-label":s?`Show tool calls`:`Hide tool calls`,"aria-pressed":s,children:[(0,z.jsx)(Rr,{size:14}),(0,z.jsx)(`span`,{children:`Tools`})]})]}),(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden rounded-[var(--radius)] border border-border`,children:e===`conversation`?(0,z.jsx)(s5,{conversation:o,viewMode:`conversation`,embedded:!0,agentId:a.id,hideToolCalls:s,onToggleHideToolCalls:c},a.id):i7(a)?(0,z.jsx)(`div`,{className:`flex h-full items-center justify-center p-[18px] text-[13px] text-muted-foreground`,children:`Session ended — no live terminal to attach.`}):(0,z.jsx)(IS,{sessionName:a.id},a.id)})]})}var qCt={work:`bg-primary`,review:`bg-signal-review`,ship:`bg-warning`,done:`bg-success`,info:`bg-info`};function JCt(e){if(!e)return`just now`;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}function YCt(){let{activityRail:e}=r7(),t=(0,R.useRef)(null),n=e[0]?.id;return(0,R.useEffect)(()=>{t.current&&(t.current.scrollTop=0)},[n]),(0,z.jsx)(`aside`,{"data-component":`drawer-activity-rail`,"data-testid":`drawer-activity-rail`,className:`w-[320px] shrink-0 border-l border-border bg-card/70`,children:(0,z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,z.jsx)(`div`,{className:`border-b border-border px-[16px] py-[13px]`,children:(0,z.jsx)(`div`,{className:`text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground`,children:`Live Activity`})}),(0,z.jsx)(`div`,{ref:t,"data-testid":`drawer-activity-rail-scroll`,className:`min-h-0 flex-1 overflow-auto px-[16px] py-[14px]`,children:e.length===0?(0,z.jsx)(`div`,{className:`rounded-[12px] border border-dashed border-border px-[12px] py-[18px] text-center text-[12px] text-muted-foreground`,children:`No activity yet.`}):(0,z.jsx)(`div`,{className:`space-y-[12px]`,children:e.map(e=>(0,z.jsxs)(`div`,{className:`grid grid-cols-[14px_1fr] gap-[10px]`,"data-phase":e.phase,children:[(0,z.jsx)(`span`,{"data-testid":`drawer-activity-dot-${e.phase}`,className:vj(`mt-[4px] h-[8px] w-[8px] rounded-full`,qCt[e.phase])}),(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`div`,{className:`text-[12px] leading-[18px] text-foreground`,children:e.message}),(0,z.jsx)(`div`,{className:`mt-[2px] font-mono text-[10px] leading-none text-muted-foreground`,children:JCt(e.when)})]})]},e.id))})})]})})}function XCt({status:e}){return e===`done`?(0,z.jsx)(`span`,{"data-testid":`drawer-bead-status-done`,className:`flex h-[18px] w-[18px] items-center justify-center rounded-full bg-success text-[9px] font-bold leading-none text-white`,children:`✓`}):e===`current`?(0,z.jsxs)(`span`,{"data-testid":`drawer-bead-status-current`,className:`relative flex h-[18px] w-[18px] items-center justify-center`,children:[(0,z.jsx)(`span`,{className:`drawer-bead-current-ping absolute h-[18px] w-[18px] rounded-full border-[1.5px] border-info`}),(0,z.jsx)(`span`,{className:`h-[10px] w-[10px] rounded-full bg-info`})]}):(0,z.jsx)(`span`,{"data-testid":`drawer-bead-status-open`,className:`h-[18px] w-[18px] rounded-full border border-border bg-background/60`})}function ZCt({issueId:e}={}){let t=sm(e=>e.drawer.issueId),{beads:n}=n7(e??t);return(0,z.jsxs)(`section`,{"data-component":`drawer-beads-list`,"data-testid":`drawer-beads-list`,className:`overflow-hidden rounded-[var(--radius)] border border-border bg-card`,children:[(0,z.jsx)(`div`,{className:`border-b border-border px-[14px] py-[10px] text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground`,children:`Beads`}),n.length===0?(0,z.jsx)(`div`,{className:`px-[14px] py-[16px] text-[12px] text-muted-foreground`,children:`No beads yet.`}):(0,z.jsx)(`div`,{className:`divide-y divide-border/60`,children:n.map(e=>(0,z.jsxs)(`div`,{className:`grid grid-cols-[18px_1fr_auto_auto] items-center gap-[10px] px-[14px] py-[10px]`,children:[(0,z.jsx)(XCt,{status:e.status}),(0,z.jsx)(`span`,{className:vj(`min-w-0 truncate text-[12px] leading-[18px] text-foreground`,e.status===`done`&&`text-muted-foreground line-through decoration-[rgba(255,255,255,0.18)]`),children:e.title}),(0,z.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:e.id}),(0,z.jsx)(`span`,{className:`font-mono text-[10px] tabular-nums text-muted-foreground`,children:e.duration})]},e.id))})]})}var QCt={run:`bg-info`,idle:`bg-muted-foreground`,done:`bg-success`,fail:`bg-destructive`};function $Ct({issueId:e}={}){let t=sm(e=>e.drawer.issueId),{reviewSpecialists:n}=n7(e??t);return(0,z.jsxs)(`section`,{"data-component":`drawer-review-specialists`,"data-testid":`drawer-review-specialists`,className:`rounded-[var(--radius)] border border-border bg-card p-[14px]`,children:[(0,z.jsx)(`div`,{className:`mb-[10px] text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground`,children:`Review Specialists`}),(0,z.jsx)(`div`,{className:`space-y-[8px]`,children:n.map(e=>(0,z.jsxs)(`div`,{className:`grid grid-cols-[14px_1fr_auto_auto] items-center gap-[10px] rounded-[10px] bg-background/45 px-[10px] py-[8px]`,children:[(0,z.jsx)(`span`,{"data-testid":`drawer-review-specialist-dot-${e.status}`,className:vj(`h-[8px] w-[8px] rounded-full`,QCt[e.status])}),(0,z.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[11px] text-foreground`,children:e.name}),(0,z.jsx)(`span`,{className:`text-[10px] uppercase tracking-[0.06em] text-muted-foreground`,children:e.meta}),(0,z.jsx)(`span`,{className:`max-w-[120px] truncate font-mono text-[10px] text-muted-foreground`,title:e.duration,children:e.duration})]},e.id))})]})}var ewt=[{id:`overview`,label:`Overview`},{id:`plan`,label:`Plan`},{id:`beads`,label:`Beads`},{id:`conversation`,label:`Conversation`},{id:`terminal`,label:`Terminal`},{id:`activity`,label:`Activity`},{id:`files`,label:`Files`},{id:`artifacts`,label:`Artifacts`}];function twt(e){return e.length===0?`0/0`:`${e.filter(e=>e.status===`done`).length}/${e.length}`}function nwt(){let e=sm(e=>e.drawer.tab),t=sm(e=>e.setDrawerTab),{beads:n}=r7();return(0,z.jsx)(`nav`,{"data-component":`drawer-tabs`,"data-testid":`drawer-tabs`,className:`border-b border-border bg-background/95 px-[14px]`,role:`tablist`,"aria-label":`Issue drawer sections`,children:(0,z.jsx)(`div`,{className:`flex min-w-0 items-center overflow-x-auto`,children:ewt.map(r=>{let i=e===r.id;return(0,z.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":i,"data-testid":`drawer-tab-${r.id}`,className:vj(`relative flex shrink-0 items-center px-[14px] py-[10px] text-[13px] font-medium text-muted-foreground transition-colors hover:text-foreground`,i&&`text-foreground`),onClick:()=>t(r.id),children:[r.label,r.id===`beads`?(0,z.jsx)(`span`,{"data-testid":`drawer-tab-beads-count`,className:`ml-[6px] rounded-full bg-primary/15 px-[5px] py-[1px] font-mono text-[10px] leading-none text-primary`,children:twt(n)}):null,i?(0,z.jsx)(`span`,{"data-testid":`drawer-tab-active-underline`,className:`absolute bottom-0 left-[14px] right-[14px] h-[2px] bg-primary`}):null]},r.id)})})})}var rwt={passed:`drawer-gate-border-pass text-success-foreground`,failed:`drawer-gate-border-fail text-destructive-foreground`,running:`badge-border-info text-info-foreground`,skipped:`badge-border-muted text-muted-foreground`,pending:`badge-border-muted text-muted-foreground`};function iwt({issueId:e}={}){let t=sm(e=>e.drawer.issueId),{verificationGates:n}=n7(e??t);return(0,z.jsxs)(`section`,{"data-component":`drawer-verification-gates`,"data-testid":`drawer-verification-gates`,className:`rounded-[var(--radius)] border border-border bg-card p-[14px]`,children:[(0,z.jsx)(`div`,{className:`mb-[10px] text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground`,children:`Verification Gates`}),(0,z.jsx)(`div`,{className:`grid grid-cols-4 gap-[8px]`,children:n.map(e=>(0,z.jsxs)(`div`,{"data-testid":`drawer-verification-gate-${e.id}`,className:vj(`rounded-[10px] border bg-background/45 px-[12px] py-[10px]`,rwt[e.status]),children:[(0,z.jsx)(`div`,{className:`text-[14px] font-medium leading-none`,children:e.detail}),(0,z.jsx)(`div`,{className:`mt-[6px] font-mono text-[10px] uppercase leading-none text-muted-foreground`,children:e.label})]},e.id))})]})}var awt={done:`bg-success`,current:`bg-signal-review`,upcoming:`bg-transparent`};function owt({issueId:e}={}){let t=sm(e=>e.drawer.issueId),{phaseTimeline:n}=n7(e??t);return(0,z.jsx)(`section`,{"data-component":`drawer-phase-timeline`,"data-testid":`drawer-phase-timeline`,className:`grid grid-cols-6 overflow-hidden rounded-[var(--radius)] border border-border bg-card`,children:n.map(e=>(0,z.jsxs)(`div`,{"data-testid":`drawer-phase-${e.id}`,className:`min-w-0 border-r border-border/60 last:border-r-0`,children:[(0,z.jsx)(`div`,{"data-testid":`drawer-phase-accent-${e.state}`,className:vj(`h-[2px]`,awt[e.state])}),(0,z.jsxs)(`div`,{className:`min-w-0 px-[7px] py-[8px]`,children:[(0,z.jsx)(`div`,{className:`truncate text-[10px] font-semibold leading-none text-foreground/80`,title:e.label,children:e.label}),(0,z.jsx)(`div`,{className:vj(`mt-[7px] truncate font-mono text-[10px] leading-none`,e.state===`current`?`font-medium text-foreground`:`text-muted-foreground`),children:e.when}),(0,z.jsx)(`div`,{className:`mt-[6px] truncate text-[9px] leading-none text-muted-foreground`,children:e.sub})]})]},e.id))})}var swt={work:`bg-primary`,review:`bg-signal-review`,ship:`bg-warning`,done:`bg-success`,info:`bg-info`};function cwt(e){if(!e)return`just now`;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}function lwt(){let{activityFull:e}=r7();return(0,z.jsx)(`div`,{"data-testid":`drawer-tab-panel-activity`,children:e.length===0?(0,z.jsx)(`div`,{className:`rounded-[12px] border border-dashed border-border px-[12px] py-[18px] text-center text-[12px] text-muted-foreground`,children:`No activity yet.`}):(0,z.jsx)(`div`,{className:`space-y-[12px]`,children:e.map(e=>(0,z.jsxs)(`div`,{className:`grid grid-cols-[14px_1fr] gap-[10px]`,"data-phase":e.phase,children:[(0,z.jsx)(`span`,{"aria-hidden":`true`,className:vj(`mt-[4px] h-[8px] w-[8px] rounded-full`,swt[e.phase])}),(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`div`,{className:`text-[12px] leading-[18px] text-foreground`,children:e.message}),(0,z.jsx)(`div`,{className:`mt-[2px] font-mono text-[10px] leading-none text-muted-foreground`,children:cwt(e.when)})]})]},e.id))})})}function uwt({issueId:e}){let{data:t,isLoading:n,isError:r}=B({queryKey:[`drawer-vbrief-plan`,e],queryFn:async()=>{let t=await fetch(`/api/workspaces/${e}/plan`);return t.ok?t.json():null},retry:!1});return(0,z.jsx)(`div`,{"data-testid":`drawer-tab-panel-plan`,children:n?(0,z.jsx)(`div`,{className:`text-[12px] text-muted-foreground`,children:`Loading plan…`}):r?(0,z.jsx)(`div`,{className:`text-[12px] text-muted-foreground`,children:`Failed to load plan`}):(0,z.jsx)(ak,{doc:t??null})})}function dwt({issueId:e}){let{data:t}=B({queryKey:[`drawer-workspace`,e],queryFn:async()=>{let t=await fetch(`/api/workspaces/${e}`);return t.ok?t.json():null},retry:!1});return!t?.exists||!t.path?null:(0,z.jsxs)(`section`,{"data-testid":`drawer-workspace-section`,className:`rounded-[var(--radius)] border border-border bg-card p-[14px]`,children:[(0,z.jsx)(`div`,{className:`mb-[8px] text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground`,children:`Workspace`}),(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-[12px]`,children:[(0,z.jsx)(`div`,{className:`min-w-0 truncate font-mono text-[11px] leading-[18px] text-muted-foreground`,title:t.path,children:t.path}),(0,z.jsx)(`div`,{className:`shrink-0`,children:(0,z.jsx)(zj,{openInCwd:t.path})})]})]})}function fwt(e){return e.replace(/-/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function pwt({tab:e}){return(0,z.jsxs)(`div`,{"data-testid":`drawer-tab-panel-${e}`,className:`rounded-[var(--radius)] border border-dashed border-border bg-card/60 p-[18px]`,children:[(0,z.jsx)(`div`,{className:`mb-[8px] text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground`,children:fwt(e)}),(0,z.jsx)(`p`,{className:`text-[13px] leading-6 text-muted-foreground`,children:`This drawer section will appear here as data streams in.`})]})}function mwt(){let e=sm(e=>e.drawer),t=sm(e=>e.closeIssue),n=sm(e=>e.syncDrawerFromUrl),{issue:r,agents:i}=r7(),[a,o]=(0,R.useState)(null),s=(0,R.useMemo)(()=>a&&i.some(e=>e.id===a)?a:UCt(i)?.id??null,[a,i]);return(0,R.useEffect)(()=>{n()},[n]),(0,R.useEffect)(()=>{if(!e.issueId)return;let n=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[t,e.issueId]),(0,R.useEffect)(()=>{if(!e.issueId)return;let t=null,n=0,r=()=>{if(window.location.hash!==`#active-agent`)return;let e=document.getElementById(`active-agent`);if(e){e.scrollIntoView({block:`start`});return}n++,n<30&&(t=window.requestAnimationFrame(r))},i=()=>{t&&=(window.cancelAnimationFrame(t),null),n=0,r()};return i(),window.addEventListener(`hashchange`,i),()=>{window.removeEventListener(`hashchange`,i),t&&window.cancelAnimationFrame(t)}},[e.issueId]),e.issueId?(0,z.jsx)(`div`,{"data-component":`issue-drawer`,"data-testid":`issue-drawer-scrim`,className:`fixed inset-0 z-[100] flex justify-end bg-black/20 backdrop-blur-[2px]`,onClick:t,children:(0,z.jsxs)(`aside`,{role:`dialog`,"aria-modal":`true`,"aria-label":r?`Issue ${r.identifier}`:`Issue ${e.issueId}`,"data-testid":`issue-drawer`,className:`flex h-screen w-[min(980px,calc(100vw-48px))] max-w-[calc(100vw-48px)] origin-right scale-100 flex-col overflow-hidden border-l border-border bg-background opacity-100 shadow-[-24px_0_64px_rgb(0_0_0_/_40%)] animate-[issue-drawer-slide-in_200ms_ease-in-out]`,onClick:e=>e.stopPropagation(),children:[(0,z.jsxs)(`header`,{className:`flex h-[52px] items-center gap-[12px] border-b border-border px-[22px]`,children:[(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`div`,{className:`truncate font-mono text-[11px] uppercase tracking-[0.08em] text-muted-foreground`,children:e.issueId}),(0,z.jsx)(`h2`,{className:`truncate font-display text-[22px] font-semibold leading-none tracking-[-0.01em] text-foreground`,children:r?.title??`Issue details`})]}),(()=>{let t=dvt(e.issueId??``,r?.url);return t?(0,z.jsxs)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,title:`Open ${e.issueId} on its tracker`,className:`inline-flex items-center gap-[6px] rounded-[var(--radius-sm)] border border-border px-[10px] py-[6px] text-[13px] text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,children:[(0,z.jsx)(kn,{className:`h-[14px] w-[14px]`}),`Issue`]}):null})(),(0,z.jsx)(`button`,{type:`button`,"aria-label":`Close issue drawer`,className:`rounded-[var(--radius-sm)] border border-border px-[10px] py-[6px] text-[13px] text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,onClick:t,children:`×`})]}),(0,z.jsx)(hwt,{agents:i}),(0,z.jsx)(nwt,{}),(0,z.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-[minmax(0,1fr)_320px]`,children:[(0,z.jsx)(`div`,{className:vj(`flex min-w-0 flex-col`,e.tab===`conversation`||e.tab===`terminal`?`min-h-0 p-[14px]`:`overflow-auto px-[22px] py-[18px]`),children:e.tab===`overview`?(0,z.jsxs)(`div`,{"data-testid":`drawer-tab-panel-overview`,className:`space-y-[14px]`,children:[(0,z.jsx)(owt,{}),(0,z.jsx)(dwt,{issueId:e.issueId}),(0,z.jsx)(BCt,{}),(0,z.jsx)(iwt,{}),(0,z.jsx)(ZCt,{}),(0,z.jsx)($Ct,{})]}):e.tab===`beads`?(0,z.jsx)(`div`,{"data-testid":`drawer-tab-panel-beads`,children:(0,z.jsx)(ZCt,{})}):e.tab===`plan`&&e.issueId?(0,z.jsx)(uwt,{issueId:e.issueId}):e.tab===`activity`?(0,z.jsx)(lwt,{}):e.tab===`artifacts`?(0,z.jsx)(Hyt,{issueId:e.issueId}):e.tab===`conversation`?(0,z.jsx)(KCt,{view:`conversation`,agents:i,agentId:s,onSelectAgent:o}):e.tab===`terminal`?(0,z.jsx)(KCt,{view:`terminal`,agents:i,agentId:s,onSelectAgent:o}):(0,z.jsx)(pwt,{tab:e.tab})}),(0,z.jsx)(YCt,{})]}),(0,z.jsx)(NCt,{})]})}):null}function hwt({agents:e}){let t=e.filter(e=>e.paused===!0);if(t.length===0)return null;let n=async e=>{try{let t=await fetch(`/api/agents/${e}/unpause`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})}),n=await t.json().catch(()=>({}));if(!t.ok)throw Error(n.error||`Failed to unpause agent`);H.success(`${e} unpaused — deacon resumes it on the next patrol`)}catch(e){H.error(e instanceof Error?e.message:`Failed to unpause agent`)}};return(0,z.jsx)(`div`,{"data-testid":`drawer-paused-banner`,className:`space-y-[6px] border-b border-border px-[22px] py-[10px]`,children:t.map(e=>(0,z.jsxs)(`div`,{className:`flex items-center gap-[10px] rounded-[var(--radius-sm)] border px-[12px] py-[8px] badge-border-warning badge-bg-warning`,children:[(0,z.jsx)(`span`,{className:`text-[14px] leading-none text-warning-foreground`,children:`⏸`}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsxs)(`div`,{className:`text-[13px] font-medium text-warning-foreground`,children:[(0,z.jsx)(`span`,{className:`font-mono`,children:e.id}),` is paused`]}),e.pausedReason&&(0,z.jsx)(`div`,{className:`truncate text-[12px] text-warning-foreground/75`,title:e.pausedReason,children:e.pausedReason})]}),(0,z.jsx)(`button`,{type:`button`,"data-testid":`drawer-unpause-${e.id}`,onClick:()=>void n(e.id),className:`inline-flex shrink-0 items-center gap-[4px] rounded-[var(--radius-sm)] border px-[10px] py-[5px] text-[12px] font-medium badge-border-warning text-warning-foreground transition-colors hover:bg-warning/20`,children:`▶ Unpause`})]},e.id))})}function gwt(){let e=_t(),t=sm(Fhe);(0,R.useEffect)(()=>{t&&e.setQueryData([`resources`],t)},[t,e])}function _wt(e){return e>=85?`bg-destructive`:e>=60?`bg-warning`:`bg-success`}function a7({value:e,label:t,showValue:n=!0,className:r=``}){let i=Math.min(100,Math.max(0,e)),a=_wt(i);return(0,z.jsxs)(`div`,{className:`flex flex-col gap-0.5 ${r}`,children:[(t||n)&&(0,z.jsxs)(`div`,{className:`flex justify-between items-center`,children:[t&&(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t}),n&&(0,z.jsxs)(`span`,{className:`text-xs text-muted-foreground ml-auto`,children:[i.toFixed(1),`%`]})]}),(0,z.jsx)(`div`,{className:`h-1.5 bg-popover rounded-full overflow-hidden`,children:(0,z.jsx)(`div`,{className:`h-full rounded-full transition-all duration-500 ${a}`,style:{width:`${i}%`}})})]})}CF.register(_Je,bJe,wqe,TF,kGe,Zqe);function o7({data:e,color:t=`rgba(59,130,246,0.8)`,height:n=32,maxValue:r=100}){let i=(0,R.useRef)(null),a=(0,R.useRef)(null);return(0,R.useEffect)(()=>{let n=i.current;if(!n)return;let o={labels:e.map(()=>``),datasets:[{data:e,borderColor:t,borderWidth:1.5,fill:!0,backgroundColor:t.replace(/[\d.]+\)$/,`0.15)`),pointRadius:0,tension:.3}]},s={responsive:!1,animation:!1,plugins:{legend:{display:!1},tooltip:{enabled:!1}},scales:{x:{display:!1},y:{display:!1,min:0,max:r}}};return a.current?(a.current.data=o,a.current.update(`none`)):a.current=new CF(n,{type:`line`,data:o,options:s}),()=>{a.current?.destroy(),a.current=null}},[]),(0,R.useEffect)(()=>{a.current&&(a.current.data.labels=e.map(()=>``),a.current.data.datasets[0].data=e,a.current.update(`none`))},[e]),(0,z.jsx)(`canvas`,{ref:i,width:80,height:n,style:{display:`block`}})}function vwt(e){return e>=1024**3?`${(e/1024**3).toFixed(1)}GiB`:e>=1024**2?`${(e/1024**2).toFixed(0)}MiB`:e>=1024?`${(e/1024).toFixed(0)}KiB`:`${e}B`}var ywt={running:`bg-success`,stopped:`bg-destructive`,unhealthy:`bg-warning`,restarting:`bg-warning`},bwt={running:`running`,stopped:`stopped`,unhealthy:`unhealthy`,restarting:`restarting`},xwt={healthy:`bg-success`,warning:`bg-warning`,stuck:`bg-warning`,stalled:`bg-warning`,dead:`bg-destructive`,stopped:`bg-popover`,starting:`bg-signal-review`,running:`bg-primary`,failed:`bg-destructive`,error:`bg-destructive`,unknown:`bg-warning`};function Swt({container:e,history:t,onClick:n}){let r=e.cpuPercent>=85?`rgba(239,68,68,0.8)`:e.cpuPercent>=60?`rgba(234,179,8,0.8)`:`rgba(59,130,246,0.8)`;return(0,z.jsxs)(`button`,{onClick:()=>n(e),className:`w-full text-left bg-card border border-border rounded-lg p-3 hover:border-primary/50 hover:bg-popover transition-colors`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,z.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0 ${ywt[e.status]}`}),(0,z.jsx)(`span`,{className:`text-xs font-medium text-foreground truncate flex-1`,title:e.name,children:e.name}),(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground shrink-0`,children:bwt[e.status]})]}),(0,z.jsxs)(`div`,{className:`flex gap-2 items-end`,children:[(0,z.jsxs)(`div`,{className:`flex-1 space-y-1.5`,children:[(0,z.jsx)(a7,{value:e.cpuPercent,label:`CPU`}),(0,z.jsx)(a7,{value:e.memoryPercent,label:`MEM`}),e.memoryLimit>0&&(0,z.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[vwt(e.memoryUsage),` / `,vwt(e.memoryLimit)]})]}),t&&t.cpuPercent.length>1&&(0,z.jsx)(`div`,{className:`shrink-0`,children:(0,z.jsx)(o7,{data:t.cpuPercent,color:r,height:36})})]})]})}function Cwt({agent:e,onNavigate:t}){return(0,z.jsxs)(`button`,{onClick:()=>t(e.id),className:`w-full text-left bg-card border border-border rounded-lg p-3 hover:border-primary/50 hover:bg-popover transition-colors`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,z.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0 ${xwt[e.status]}`}),(0,z.jsx)(`span`,{className:`text-xs font-medium text-foreground truncate flex-1`,title:e.issueId??e.id,children:e.issueId??e.id}),(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground shrink-0`,children:e.status})]}),(0,z.jsxs)(`div`,{className:`text-xs text-muted-foreground space-y-0.5`,children:[(0,z.jsxs)(`div`,{className:`flex justify-between`,children:[(0,z.jsx)(`span`,{children:`Model`}),(0,z.jsx)(`span`,{className:`text-foreground`,children:e.model})]}),(0,z.jsxs)(`div`,{className:`flex justify-between`,children:[(0,z.jsx)(`span`,{children:`Runtime`}),(0,z.jsx)(`span`,{className:`text-foreground`,children:vp(e)})]}),e.consecutiveFailures>0&&(0,z.jsxs)(`div`,{className:`flex justify-between text-warning`,children:[(0,z.jsx)(`span`,{children:`Failures`}),(0,z.jsx)(`span`,{children:e.consecutiveFailures})]})]}),(0,z.jsx)(`div`,{className:`mt-1.5 text-xs text-primary`,children:`Click to view in Agents →`})]})}function s7(e){return e>=1024**3?`${(e/1024**3).toFixed(1)}GiB`:e>=1024**2?`${(e/1024**2).toFixed(0)}MiB`:e>=1024?`${(e/1024).toFixed(0)}KiB`:`${e}B`}async function wwt(e){let t=await fetch(`/api/resources/${e}/details`);if(!t.ok)throw Error(`Failed to fetch container details`);return t.json()}function Twt({container:e,history:t,onClose:n}){let[r,i]=(0,R.useState)(`overview`),{data:a}=B({queryKey:[`container-details`,e.id],queryFn:()=>wwt(e.id),refetchInterval:r===`logs`?5e3:3e4});return(0,R.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[n]),(0,z.jsxs)(`div`,{className:`fixed inset-0 z-50 flex justify-end`,children:[(0,z.jsx)(`div`,{className:`absolute inset-0 bg-black/40`,onClick:n}),(0,z.jsxs)(`div`,{className:`relative w-full max-w-lg bg-card border-l border-border flex flex-col shadow-2xl overflow-hidden`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-3 border-b border-border shrink-0`,children:[(0,z.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full shrink-0 ${e.status===`running`?`bg-success`:e.status===`unhealthy`||e.status===`restarting`?`bg-warning`:`bg-destructive`}`}),(0,z.jsx)(`h2`,{className:`font-semibold text-foreground text-sm flex-1 truncate`,title:e.name,children:e.name}),a?.image&&(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground truncate max-w-[160px]`,title:a.image,children:a.image}),(0,z.jsx)(`button`,{onClick:n,className:`p-1 rounded hover:bg-popover text-muted-foreground hover:text-foreground`,children:(0,z.jsx)(zr,{className:`w-4 h-4`})})]}),(0,z.jsx)(`div`,{className:`flex border-b border-border shrink-0`,children:[{id:`overview`,label:`Overview`},{id:`logs`,label:`Logs`},{id:`ports-env`,label:`Ports & Env`}].map(e=>(0,z.jsx)(`button`,{onClick:()=>i(e.id),className:`px-4 py-2 text-xs transition-colors ${r===e.id?`text-primary border-b-2 border-primary -mb-px`:`text-muted-foreground hover:text-foreground`}`,children:e.label},e.id))}),(0,z.jsxs)(`div`,{className:`flex-1 overflow-auto p-4`,children:[r===`overview`&&(0,z.jsxs)(`div`,{className:`space-y-4`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Current Usage`}),(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(a7,{value:e.cpuPercent,label:`CPU`}),(0,z.jsx)(a7,{value:e.memoryPercent,label:`Memory`}),e.memoryLimit>0&&(0,z.jsxs)(`div`,{className:`text-xs text-muted-foreground text-right`,children:[s7(e.memoryUsage),` / `,s7(e.memoryLimit)]})]})]}),t.cpuPercent.length>1&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`5-Min History`}),(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:`CPU %`}),(0,z.jsx)(`div`,{className:`w-full`,children:(0,z.jsx)(o7,{data:t.cpuPercent,color:`rgba(59,130,246,0.8)`,height:40})})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:`Memory %`}),(0,z.jsx)(`div`,{className:`w-full`,children:(0,z.jsx)(o7,{data:t.memoryPercent,color:`rgba(168,85,247,0.8)`,height:40})})]})]})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Network I/O`}),(0,z.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,z.jsxs)(`div`,{className:`bg-card p-2 rounded`,children:[(0,z.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`In`}),(0,z.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:s7(e.networkIn)})]}),(0,z.jsxs)(`div`,{className:`bg-card p-2 rounded`,children:[(0,z.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Out`}),(0,z.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:s7(e.networkOut)})]})]})]}),a&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Container Info`}),(0,z.jsxs)(`dl`,{className:`space-y-1 text-xs`,children:[a.uptime&&(0,z.jsxs)(`div`,{className:`flex justify-between`,children:[(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:`Uptime`}),(0,z.jsx)(`dd`,{className:`text-foreground`,children:a.uptime})]}),a.created&&(0,z.jsxs)(`div`,{className:`flex justify-between`,children:[(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:`Created`}),(0,z.jsx)(`dd`,{className:`text-foreground`,children:new Date(a.created).toLocaleString()})]}),(0,z.jsxs)(`div`,{className:`flex justify-between`,children:[(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:`Status`}),(0,z.jsx)(`dd`,{className:`text-foreground`,children:a.status})]})]})]})]}),r===`logs`&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Recent Logs (tail 100)`}),a?.logs?(0,z.jsx)(`pre`,{className:`text-xs text-foreground bg-card p-3 rounded overflow-auto max-h-[600px] font-mono whitespace-pre-wrap break-all`,children:a.logs}):(0,z.jsx)(`div`,{className:`text-xs text-muted-foreground text-center py-8`,children:`Loading logs…`})]}),r===`ports-env`&&(0,z.jsxs)(`div`,{className:`space-y-4`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Port Mappings`}),a?.ports?.length?(0,z.jsx)(`div`,{className:`space-y-1`,children:a.ports.map((e,t)=>(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,z.jsx)(`span`,{className:`text-foreground font-mono`,children:e.host}),(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`→`}),(0,z.jsxs)(`span`,{className:`text-foreground font-mono`,children:[e.container,`/`,e.protocol]})]},t))}):(0,z.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`No port mappings`})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Environment Variables`}),a?.env?.length?(0,z.jsx)(`div`,{className:`space-y-0.5 max-h-80 overflow-auto`,children:a.env.map((e,t)=>{let[n,...r]=e.split(`=`),i=r.join(`=`),a=/token|secret|key|pass|pwd|auth/i.test(n??``);return(0,z.jsxs)(`div`,{className:`text-xs font-mono flex gap-1 flex-wrap`,children:[(0,z.jsx)(`span`,{className:`text-primary`,children:n}),(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`=`}),(0,z.jsx)(`span`,{className:`text-foreground break-all`,children:a?`***`:i})]},t)})}):(0,z.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`No environment variables`})]})]})]})]})]})}async function Ewt(){let e=await fetch(`/api/resources`);if(!e.ok)throw Error(`Failed to fetch resources`);return e.json()}async function Dwt(e){let t=await fetch(`/api/resources/${e}/history`);if(!t.ok)throw Error(`Failed to fetch history`);return t.json()}function Owt(e,t,n){if(n===`issue`){let n=new Map;for(let t of e){let e=t.name.match(/(?:feature[_-])?([A-Z]+-\d+)/i),r=e?e[1].toUpperCase():`__ungrouped__`,i=e?e[1].toUpperCase():`Ungrouped`;n.has(r)||n.set(r,{key:r,label:i,containers:[],agents:[]}),n.get(r).containers.push(t)}for(let e of t){let t=e.issueId??`__ungrouped__`,r=e.issueId??`Ungrouped`;n.has(t)||n.set(t,{key:t,label:r,containers:[],agents:[]}),n.get(t).agents.push(e)}return Array.from(n.values()).sort((e,t)=>e.label.localeCompare(t.label))}if(n===`type`)return[{key:`containers`,label:`Containers`,containers:e,agents:[]},{key:`agents`,label:`Agents`,containers:[],agents:t}].filter(e=>e.containers.length+e.agents.length>0);let r=new Map;for(let t of e)r.has(t.status)||r.set(t.status,{key:t.status,label:t.status.charAt(0).toUpperCase()+t.status.slice(1),containers:[],agents:[]}),r.get(t.status).containers.push(t);for(let e of t)r.has(e.status)||r.set(e.status,{key:e.status,label:e.status.charAt(0).toUpperCase()+e.status.slice(1),containers:[],agents:[]}),r.get(e.status).agents.push(e);return Array.from(r.values())}function kwt({onNavigateToAgents:e}){let[t,n]=(0,R.useState)(`issue`),[r,i]=(0,R.useState)(`all`),[a,o]=(0,R.useState)(null);gwt();let{data:s,isLoading:c,error:l}=B({queryKey:[`resources`],queryFn:Ewt,refetchInterval:3e4}),{data:u}=B({queryKey:[`container-history`,a?.id],queryFn:()=>Dwt(a.id),enabled:!!a,refetchInterval:3e4});if(c)return(0,z.jsx)(`div`,{className:`p-6 text-muted-foreground text-sm`,children:`Loading resources…`});if(l)return(0,z.jsxs)(`div`,{className:`p-6 text-destructive text-sm`,children:[`Failed to load resources: `,l.message]});let d=s?.containers??[],f=s?.agents??[],p=r===`running`?d.filter(e=>e.status===`running`):d,m=Owt(p,f,t),h=p.length+f.length;return(0,z.jsxs)(`div`,{className:`h-full flex flex-col overflow-hidden`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-3 px-6 py-3 border-b border-border shrink-0`,children:[(0,z.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Resources`}),(0,z.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[h,` items`]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1 ml-4`,children:[(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground mr-1`,children:`Group by:`}),[`issue`,`type`,`status`].map(e=>(0,z.jsx)(`button`,{onClick:()=>n(e),className:`px-2 py-0.5 rounded text-xs transition-colors ${t===e?`bg-primary text-primary-foreground`:`text-muted-foreground hover:text-foreground hover:bg-popover`}`,children:e.charAt(0).toUpperCase()+e.slice(1)},e))]}),(0,z.jsx)(`div`,{className:`flex items-center gap-1`,children:[`all`,`running`].map(e=>(0,z.jsx)(`button`,{onClick:()=>i(e),className:`px-2 py-0.5 rounded text-xs transition-colors ${r===e?`bg-popover text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-popover`}`,children:e===`all`?`All`:`Running only`},e))}),s?.updatedAt&&(0,z.jsxs)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:[`Updated `,new Date(s.updatedAt).toLocaleTimeString()]})]}),(0,z.jsx)(`div`,{className:`flex-1 overflow-auto p-6`,children:h===0?(0,z.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-64 text-muted-foreground`,children:[(0,z.jsx)(`div`,{className:`text-4xl mb-3`,children:`📦`}),(0,z.jsx)(`div`,{className:`text-sm`,children:`No containers or agents found`}),(0,z.jsx)(`div`,{className:`text-xs mt-1`,children:`Docker may not be running or no workspaces are active`})]}):(0,z.jsx)(`div`,{className:`space-y-6`,children:m.map(t=>(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-3`,children:[t.label,(0,z.jsxs)(`span`,{className:`ml-2 font-normal text-muted-foreground/60`,children:[`(`,t.containers.length+t.agents.length,`)`]})]}),(0,z.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3`,children:[t.containers.map(e=>(0,z.jsx)(Swt,{container:e,history:(s?.containers,void 0),onClick:o},e.id)),t.agents.map(t=>(0,z.jsx)(Cwt,{agent:t,onNavigate:e},t.id))]})]},t.key))})}),a&&(0,z.jsx)(Twt,{container:a,history:u??{timestamps:[],cpuPercent:[],memoryPercent:[]},onClose:()=>o(null)})]})}var c7=ri(e=>({systemHealth:null,setSystemHealth:t=>e({systemHealth:t}),focusedAgentId:null,setFocusedAgentId:t=>e({focusedAgentId:t})})),Awt=e=>{let t=e.recentActivity;return[...Object.values(e.observationsByIssueId??{}).flat().filter(e=>e.actionStatus!==null).map(e=>({id:`memory-${e.id}`,agentId:e.workspaceId,issueId:e.issueId,timestamp:e.timestamp,source:`memory`,level:`success`,message:e.summary})),...t].sort((e,t)=>t.timestamp.localeCompare(e.timestamp))};function jwt(){let e=c7();(0,R.useEffect)(()=>{let t=null,n=async()=>{try{let t=await fetch(`/api/godview/system-health`);if(t.ok){let n=await t.json();e.setSystemHealth(n)}}catch{}};return n(),t=setInterval(n,1e4),()=>{t&&clearInterval(t)}},[])}function Mwt(){let[e,t]=(0,R.useState)(()=>new Date);return(0,R.useEffect)(()=>{let e=setInterval(()=>t(new Date),1e3);return()=>clearInterval(e)},[]),(0,z.jsx)(`span`,{className:`gv-mono text-sm`,style:{color:`var(--gv-blue)`},children:e.toLocaleTimeString(`en-US`,{hour12:!1})})}function Nwt({label:e,value:t,color:n}){return(0,z.jsxs)(`div`,{className:`flex flex-col items-center gap-0.5`,children:[(0,z.jsx)(`div`,{className:`flex items-end gap-0.5 h-6`,children:(0,z.jsx)(`div`,{className:`w-12 rounded-sm transition-all duration-500`,style:{height:`${Math.max(4,t/100*24)}px`,backgroundColor:n,opacity:.8}})}),(0,z.jsxs)(`span`,{className:`text-[10px]`,style:{color:`var(--gv-text-secondary)`},children:[e,` `,Math.round(t),`%`]})]})}function Pwt({agents:e}){let t=c7(e=>e.systemHealth),n=e.filter(e=>e.status!==`stopped`&&e.status!==`dead`).length;return(0,z.jsxs)(`div`,{className:`gv-glass flex items-center gap-4 px-4 py-2 shrink-0 mx-3 mt-3 rounded-xl`,style:{borderColor:`rgba(0, 212, 255, 0.2)`},children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,z.jsx)(Br,{className:`w-5 h-5`,style:{color:`var(--gv-blue)`,animation:`gv-logo-glow 3s ease-in-out infinite`}}),(0,z.jsx)(`span`,{className:`text-sm font-bold tracking-widest uppercase`,style:{color:`var(--gv-blue)`,fontFamily:`var(--gv-font-display)`},children:`God View`})]}),(0,z.jsx)(`div`,{className:`w-px h-5 shrink-0`,style:{backgroundColor:`var(--gv-border)`}}),(0,z.jsx)(Mwt,{}),(0,z.jsx)(`div`,{className:`w-px h-5 shrink-0`,style:{backgroundColor:`var(--gv-border)`}}),t&&(0,z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,z.jsx)(Nwt,{label:`CPU`,value:t.cpu,color:`var(--gv-blue)`}),(0,z.jsx)(Nwt,{label:`MEM`,value:t.memPercent,color:`var(--gv-purple)`})]}),(0,z.jsx)(`div`,{className:`flex-1`}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5 px-3 py-1 rounded-full`,style:{background:`rgba(57, 255, 20, 0.1)`,border:`1px solid rgba(57, 255, 20, 0.3)`,animation:n>0?`gv-pulse 2s ease-in-out infinite`:`none`},children:[(0,z.jsx)(`div`,{className:`w-1.5 h-1.5 rounded-full`,style:{backgroundColor:n>0?`var(--gv-green)`:`var(--gv-text-dim)`}}),(0,z.jsxs)(`span`,{className:`text-xs font-semibold gv-mono`,style:{color:n>0?`var(--gv-green)`:`var(--gv-text-secondary)`},children:[n,` active`]})]}),(0,z.jsxs)(`div`,{className:`text-xs`,style:{color:`var(--gv-text-secondary)`},children:[e.length,` total agents`]})]})}async function Fwt(){let e=await fetch(`/api/activity`);if(!e.ok)throw Error(`Failed to fetch activity`);return e.json()}var Iwt={success:(0,z.jsx)(sn,{className:`w-3 h-3 shrink-0`}),error:(0,z.jsx)(un,{className:`w-3 h-3 shrink-0`}),warn:(0,z.jsx)(Ir,{className:`w-3 h-3 shrink-0`}),info:(0,z.jsx)(Qn,{className:`w-3 h-3 shrink-0`})},Lwt={success:`var(--gv-green)`,info:`var(--gv-blue)`,error:`var(--gv-pink)`,warn:`var(--gv-amber)`};function Rwt(e,t){return e.issueId?e.issueId.toUpperCase()===t.toUpperCase():e.agentId?e.agentId.toLowerCase()===`agent-${t.toLowerCase()}`:!1}var zwt=e=>t=>Awt(t).filter(t=>Rwt(t,e));function Bwt({issueId:e}={}){let t=sm(e?zwt(e):Awt),{data:n=[]}=B({queryKey:[`god-view-activity`],queryFn:Fwt,refetchInterval:3e4,staleTime:5e3}),r=(0,R.useMemo)(()=>{let r=new Map;for(let e of t??[])r.set(e.id,e);for(let t of n)(!e||Rwt(t,e))&&r.set(t.id,t);return Array.from(r.values()).sort((e,t)=>new Date(t.timestamp).getTime()-new Date(e.timestamp).getTime())},[e,t,n]);return(0,z.jsxs)(`div`,{className:`flex flex-col gap-1 overflow-y-auto flex-1`,children:[(0,z.jsx)(`h3`,{className:`text-xs font-bold uppercase tracking-widest px-1 shrink-0`,style:{color:`var(--gv-text-secondary)`},children:`Activity`}),(0,z.jsx)(`div`,{className:`flex flex-col gap-1 overflow-y-auto`,children:r.length===0?(0,z.jsx)(`div`,{className:`text-xs text-center py-4`,style:{color:`var(--gv-text-dim)`},children:`Awaiting events...`}):(0,z.jsx)(GH,{initial:!1,children:r.map(e=>{let t=Lwt[e.level]||Lwt.info,n=Iwt[e.level]||Iwt.info;return(0,z.jsxs)(cJ.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},transition:{duration:.2},className:`flex items-start gap-1.5 px-1 py-1 rounded`,style:{background:`rgba(255,255,255,0.02)`},children:[(0,z.jsx)(`span`,{className:`mt-0.5 shrink-0`,style:{color:t},children:n}),(0,z.jsxs)(`div`,{className:`flex flex-col min-w-0 gap-0.5`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,z.jsx)(`span`,{className:`text-[10px] font-semibold gv-mono truncate`,style:{color:t},title:e.source,children:e.source}),(0,z.jsx)(`span`,{className:`text-[9px] shrink-0`,style:{color:`var(--gv-text-dim)`},children:oM(e.timestamp,new Date)})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1 min-w-0`,children:[e.issueId&&(0,z.jsx)(`span`,{className:`text-[9px] px-1 py-0.5 rounded shrink-0 gv-mono`,style:{color:`var(--gv-text-secondary)`,background:`rgba(255,255,255,0.04)`},children:e.issueId}),(0,z.jsx)(`span`,{className:`text-[10px] truncate leading-tight`,style:{color:`var(--gv-text-secondary)`},title:e.message,children:e.message})]})]})]},e.id)})})})]})}var Vwt=i(((e,t)=>{(function(){var e={}.hasOwnProperty;function n(){for(var e=``,t=0;t<arguments.length;t++){var n=arguments[t];n&&(e=i(e,r(n)))}return e}function r(t){if(typeof t==`string`||typeof t==`number`)return t;if(typeof t!=`object`)return``;if(Array.isArray(t))return n.apply(null,t);if(t.toString!==Object.prototype.toString&&!t.toString.toString().includes(`[native code]`))return t.toString();var r=``;for(var a in t)e.call(t,a)&&t[a]&&(r=i(r,a));return r}function i(e,t){return t?e?e+` `+t:e+t:e}t!==void 0&&t.exports?(n.default=n,t.exports=n):typeof define==`function`&&typeof define.amd==`object`&&define.amd?define(`classnames`,[],function(){return n}):window.classNames=n})()})),l7=n(yh()),Hwt=n(Vwt()),Uwt=[`top`,`left`,`transform`,`className`,`children`,`innerRef`];function u7(){return u7=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},u7.apply(this,arguments)}function Wwt(e,t){if(e==null)return{};var n={},r=Object.keys(e),i,a;for(a=0;a<r.length;a++)i=r[a],!(t.indexOf(i)>=0)&&(n[i]=e[i]);return n}function d7(e){var t=e.top,n=t===void 0?0:t,r=e.left,i=r===void 0?0:r,a=e.transform,o=e.className,s=e.children,c=e.innerRef,l=Wwt(e,Uwt);return R.createElement(`g`,u7({ref:c,className:(0,Hwt.default)(`visx-group`,o),transform:a||`translate(`+i+`, `+n+`)`},l),s)}d7.propTypes={top:l7.default.number,left:l7.default.number,transform:l7.default.string,className:l7.default.string,children:l7.default.node,innerRef:l7.default.oneOfType([l7.default.string,l7.default.func,l7.default.object])};var f7=Math.PI,p7=2*f7,m7=1e-6,Gwt=p7-m7;function h7(){this._x0=this._y0=this._x1=this._y1=null,this._=``}function g7(){return new h7}h7.prototype=g7.prototype={constructor:h7,moveTo:function(e,t){this._+=`M`+(this._x0=this._x1=+e)+`,`+(this._y0=this._y1=+t)},closePath:function(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._+=`Z`)},lineTo:function(e,t){this._+=`L`+(this._x1=+e)+`,`+(this._y1=+t)},quadraticCurveTo:function(e,t,n,r){this._+=`Q`+ +e+`,`+ +t+`,`+(this._x1=+n)+`,`+(this._y1=+r)},bezierCurveTo:function(e,t,n,r,i,a){this._+=`C`+ +e+`,`+ +t+`,`+ +n+`,`+ +r+`,`+(this._x1=+i)+`,`+(this._y1=+a)},arcTo:function(e,t,n,r,i){e=+e,t=+t,n=+n,r=+r,i=+i;var a=this._x1,o=this._y1,s=n-e,c=r-t,l=a-e,u=o-t,d=l*l+u*u;if(i<0)throw Error(`negative radius: `+i);if(this._x1===null)this._+=`M`+(this._x1=e)+`,`+(this._y1=t);else if(d>m7)if(!(Math.abs(u*s-c*l)>m7)||!i)this._+=`L`+(this._x1=e)+`,`+(this._y1=t);else{var f=n-a,p=r-o,m=s*s+c*c,h=f*f+p*p,g=Math.sqrt(m),_=Math.sqrt(d),v=i*Math.tan((f7-Math.acos((m+d-h)/(2*g*_)))/2),y=v/_,b=v/g;Math.abs(y-1)>m7&&(this._+=`L`+(e+y*l)+`,`+(t+y*u)),this._+=`A`+i+`,`+i+`,0,0,`+ +(u*f>l*p)+`,`+(this._x1=e+b*s)+`,`+(this._y1=t+b*c)}},arc:function(e,t,n,r,i,a){e=+e,t=+t,n=+n,a=!!a;var o=n*Math.cos(r),s=n*Math.sin(r),c=e+o,l=t+s,u=1^a,d=a?r-i:i-r;if(n<0)throw Error(`negative radius: `+n);this._x1===null?this._+=`M`+c+`,`+l:(Math.abs(this._x1-c)>m7||Math.abs(this._y1-l)>m7)&&(this._+=`L`+c+`,`+l),n&&(d<0&&(d=d%p7+p7),d>Gwt?this._+=`A`+n+`,`+n+`,0,1,`+u+`,`+(e-o)+`,`+(t-s)+`A`+n+`,`+n+`,0,1,`+u+`,`+(this._x1=c)+`,`+(this._y1=l):d>m7&&(this._+=`A`+n+`,`+n+`,0,`+ +(d>=f7)+`,`+u+`,`+(this._x1=e+n*Math.cos(i))+`,`+(this._y1=t+n*Math.sin(i))))},rect:function(e,t,n,r){this._+=`M`+(this._x0=this._x1=+e)+`,`+(this._y0=this._y1=+t)+`h`+ +n+`v`+ +r+`h`+-n+`Z`},toString:function(){return this._}};function _7(e){return function(){return e}}var Kwt=Math.abs,v7=Math.atan2,y7=Math.cos,qwt=Math.max,b7=Math.min,x7=Math.sin,S7=Math.sqrt,C7=Math.PI,w7=C7/2,Jwt=2*C7;function Ywt(e){return e>1?0:e<-1?C7:Math.acos(e)}function Xwt(e){return e>=1?w7:e<=-1?-w7:Math.asin(e)}function Zwt(e){return e.innerRadius}function Qwt(e){return e.outerRadius}function $wt(e){return e.startAngle}function eTt(e){return e.endAngle}function tTt(e){return e&&e.padAngle}function nTt(e,t,n,r,i,a,o,s){var c=n-e,l=r-t,u=o-i,d=s-a,f=d*c-u*l;if(!(f*f<1e-12))return f=(u*(t-a)-d*(e-i))/f,[e+f*c,t+f*l]}function T7(e,t,n,r,i,a,o){var s=e-n,c=t-r,l=(o?a:-a)/S7(s*s+c*c),u=l*c,d=-l*s,f=e+u,p=t+d,m=n+u,h=r+d,g=(f+m)/2,_=(p+h)/2,v=m-f,y=h-p,b=v*v+y*y,x=i-a,S=f*h-m*p,C=(y<0?-1:1)*S7(qwt(0,x*x*b-S*S)),w=(S*y-v*C)/b,T=(-S*v-y*C)/b,E=(S*y+v*C)/b,D=(-S*v+y*C)/b,O=w-g,k=T-_,A=E-g,j=D-_;return O*O+k*k>A*A+j*j&&(w=E,T=D),{cx:w,cy:T,x01:-u,y01:-d,x11:w*(i/x-1),y11:T*(i/x-1)}}function rTt(){var e=Zwt,t=Qwt,n=_7(0),r=null,i=$wt,a=eTt,o=tTt,s=null;function c(){var c,l,u=+e.apply(this,arguments),d=+t.apply(this,arguments),f=i.apply(this,arguments)-w7,p=a.apply(this,arguments)-w7,m=Kwt(p-f),h=p>f;if(s||=c=g7(),d<u&&(l=d,d=u,u=l),!(d>1e-12))s.moveTo(0,0);else if(m>Jwt-1e-12)s.moveTo(d*y7(f),d*x7(f)),s.arc(0,0,d,f,p,!h),u>1e-12&&(s.moveTo(u*y7(p),u*x7(p)),s.arc(0,0,u,p,f,h));else{var g=f,_=p,v=f,y=p,b=m,x=m,S=o.apply(this,arguments)/2,C=S>1e-12&&(r?+r.apply(this,arguments):S7(u*u+d*d)),w=b7(Kwt(d-u)/2,+n.apply(this,arguments)),T=w,E=w,D,O;if(C>1e-12){var k=Xwt(C/u*x7(S)),A=Xwt(C/d*x7(S));(b-=k*2)>1e-12?(k*=h?1:-1,v+=k,y-=k):(b=0,v=y=(f+p)/2),(x-=A*2)>1e-12?(A*=h?1:-1,g+=A,_-=A):(x=0,g=_=(f+p)/2)}var j=d*y7(g),M=d*x7(g),N=u*y7(y),P=u*x7(y);if(w>1e-12){var F=d*y7(_),I=d*x7(_),ee=u*y7(v),te=u*x7(v),ne;if(m<C7&&(ne=nTt(j,M,ee,te,F,I,N,P))){var L=j-ne[0],re=M-ne[1],ie=F-ne[0],ae=I-ne[1],oe=1/x7(Ywt((L*ie+re*ae)/(S7(L*L+re*re)*S7(ie*ie+ae*ae)))/2),se=S7(ne[0]*ne[0]+ne[1]*ne[1]);T=b7(w,(u-se)/(oe-1)),E=b7(w,(d-se)/(oe+1))}}x>1e-12?E>1e-12?(D=T7(ee,te,j,M,d,E,h),O=T7(F,I,N,P,d,E,h),s.moveTo(D.cx+D.x01,D.cy+D.y01),E<w?s.arc(D.cx,D.cy,E,v7(D.y01,D.x01),v7(O.y01,O.x01),!h):(s.arc(D.cx,D.cy,E,v7(D.y01,D.x01),v7(D.y11,D.x11),!h),s.arc(0,0,d,v7(D.cy+D.y11,D.cx+D.x11),v7(O.cy+O.y11,O.cx+O.x11),!h),s.arc(O.cx,O.cy,E,v7(O.y11,O.x11),v7(O.y01,O.x01),!h))):(s.moveTo(j,M),s.arc(0,0,d,g,_,!h)):s.moveTo(j,M),!(u>1e-12)||!(b>1e-12)?s.lineTo(N,P):T>1e-12?(D=T7(N,P,F,I,u,-T,h),O=T7(j,M,ee,te,u,-T,h),s.lineTo(D.cx+D.x01,D.cy+D.y01),T<w?s.arc(D.cx,D.cy,T,v7(D.y01,D.x01),v7(O.y01,O.x01),!h):(s.arc(D.cx,D.cy,T,v7(D.y01,D.x01),v7(D.y11,D.x11),!h),s.arc(0,0,u,v7(D.cy+D.y11,D.cx+D.x11),v7(O.cy+O.y11,O.cx+O.x11),h),s.arc(O.cx,O.cy,T,v7(O.y11,O.x11),v7(O.y01,O.x01),!h))):s.arc(0,0,u,y,v,h)}if(s.closePath(),c)return s=null,c+``||null}return c.centroid=function(){var n=(+e.apply(this,arguments)+ +t.apply(this,arguments))/2,r=(+i.apply(this,arguments)+ +a.apply(this,arguments))/2-C7/2;return[y7(r)*n,x7(r)*n]},c.innerRadius=function(t){return arguments.length?(e=typeof t==`function`?t:_7(+t),c):e},c.outerRadius=function(e){return arguments.length?(t=typeof e==`function`?e:_7(+e),c):t},c.cornerRadius=function(e){return arguments.length?(n=typeof e==`function`?e:_7(+e),c):n},c.padRadius=function(e){return arguments.length?(r=e==null?null:typeof e==`function`?e:_7(+e),c):r},c.startAngle=function(e){return arguments.length?(i=typeof e==`function`?e:_7(+e),c):i},c.endAngle=function(e){return arguments.length?(a=typeof e==`function`?e:_7(+e),c):a},c.padAngle=function(e){return arguments.length?(o=typeof e==`function`?e:_7(+e),c):o},c.context=function(e){return arguments.length?(s=e??null,c):s},c}function E7(e,t){e(t)}function iTt(e){var t=e===void 0?{}:e,n=t.innerRadius,r=t.outerRadius,i=t.cornerRadius,a=t.startAngle,o=t.endAngle,s=t.padAngle,c=t.padRadius,l=rTt();return n!=null&&E7(l.innerRadius,n),r!=null&&E7(l.outerRadius,r),i!=null&&E7(l.cornerRadius,i),a!=null&&E7(l.startAngle,a),o!=null&&E7(l.endAngle,o),s!=null&&E7(l.padAngle,s),c!=null&&E7(l.padRadius,c),l}var aTt=[`className`,`data`,`innerRadius`,`outerRadius`,`cornerRadius`,`startAngle`,`endAngle`,`padAngle`,`padRadius`,`children`,`innerRef`];function D7(){return D7=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},D7.apply(this,arguments)}function oTt(e,t){if(e==null)return{};var n={},r=Object.keys(e),i,a;for(a=0;a<r.length;a++)i=r[a],!(t.indexOf(i)>=0)&&(n[i]=e[i]);return n}function O7(e){var t=e.className,n=e.data,r=e.innerRadius,i=e.outerRadius,a=e.cornerRadius,o=e.startAngle,s=e.endAngle,c=e.padAngle,l=e.padRadius,u=e.children,d=e.innerRef,f=oTt(e,aTt),p=iTt({innerRadius:r,outerRadius:i,cornerRadius:a,startAngle:o,endAngle:s,padAngle:c,padRadius:l});return u?R.createElement(R.Fragment,null,u({path:p})):!n&&(o==null||s==null||r==null||i==null)?(console.warn(`[@visx/shape/Arc]: expected data because one of startAngle, endAngle, innerRadius, outerRadius is undefined. Bailing.`),null):R.createElement(`path`,D7({ref:d,className:(0,Hwt.default)(`visx-arc`,t),d:p(n)||``},f))}var sTt=class extends Map{constructor(e,t=dTt){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:t}}),e!=null)for(let[t,n]of e)this.set(t,n)}get(e){return super.get(cTt(this,e))}has(e){return super.has(cTt(this,e))}set(e,t){return super.set(lTt(this,e),t)}delete(e){return super.delete(uTt(this,e))}};function cTt({_intern:e,_key:t},n){let r=t(n);return e.has(r)?e.get(r):n}function lTt({_intern:e,_key:t},n){let r=t(n);return e.has(r)?e.get(r):(e.set(r,n),n)}function uTt({_intern:e,_key:t},n){let r=t(n);return e.has(r)&&(n=e.get(r),e.delete(r)),n}function dTt(e){return typeof e==`object`&&e?e.valueOf():e}function fTt(e,t){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(t).domain(e);break}return this}var pTt=Symbol(`implicit`);function k7(){var e=new sTt,t=[],n=[],r=pTt;function i(i){let a=e.get(i);if(a===void 0){if(r!==pTt)return r;e.set(i,a=t.push(i)-1)}return n[a%n.length]}return i.domain=function(n){if(!arguments.length)return t.slice();t=[],e=new sTt;for(let r of n)e.has(r)||e.set(r,t.push(r)-1);return i},i.range=function(e){return arguments.length?(n=Array.from(e),i):n.slice()},i.unknown=function(e){return arguments.length?(r=e,i):r},i.copy=function(){return k7(t,n).unknown(r)},fTt.apply(i,arguments),i}var A7=new Date,j7=new Date;function M7(e,t,n,r){function i(t){return e(t=arguments.length===0?new Date:new Date(+t)),t}return i.floor=t=>(e(t=new Date(+t)),t),i.ceil=n=>(e(n=new Date(n-1)),t(n,1),e(n),n),i.round=e=>{let t=i(e),n=i.ceil(e);return e-t<n-e?t:n},i.offset=(e,n)=>(t(e=new Date(+e),n==null?1:Math.floor(n)),e),i.range=(n,r,a)=>{let o=[];if(n=i.ceil(n),a=a==null?1:Math.floor(a),!(n<r)||!(a>0))return o;let s;do o.push(s=new Date(+n)),t(n,a),e(n);while(s<n&&n<r);return o},i.filter=n=>M7(t=>{if(t>=t)for(;e(t),!n(t);)t.setTime(t-1)},(e,r)=>{if(e>=e)if(r<0)for(;++r<=0;)for(;t(e,-1),!n(e););else for(;--r>=0;)for(;t(e,1),!n(e););}),n&&(i.count=(t,r)=>(A7.setTime(+t),j7.setTime(+r),e(A7),e(j7),Math.floor(n(A7,j7))),i.every=e=>(e=Math.floor(e),!isFinite(e)||!(e>0)?null:e>1?i.filter(r?t=>r(t)%e===0:t=>i.count(0,t)%e===0):i)),i}var N7=1e3,P7=N7*60,F7=P7*60,I7=F7*24,L7=I7*7,mTt=I7*30,hTt=I7*365,R7=M7(e=>{e.setTime(e-e.getMilliseconds())},(e,t)=>{e.setTime(+e+t*N7)},(e,t)=>(t-e)/N7,e=>e.getUTCSeconds());R7.range;var z7=M7(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*N7)},(e,t)=>{e.setTime(+e+t*P7)},(e,t)=>(t-e)/P7,e=>e.getMinutes());z7.range;var B7=M7(e=>{e.setUTCSeconds(0,0)},(e,t)=>{e.setTime(+e+t*P7)},(e,t)=>(t-e)/P7,e=>e.getUTCMinutes());B7.range;var V7=M7(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*N7-e.getMinutes()*P7)},(e,t)=>{e.setTime(+e+t*F7)},(e,t)=>(t-e)/F7,e=>e.getHours());V7.range;var H7=M7(e=>{e.setUTCMinutes(0,0,0)},(e,t)=>{e.setTime(+e+t*F7)},(e,t)=>(t-e)/F7,e=>e.getUTCHours());H7.range;var U7=M7(e=>e.setHours(0,0,0,0),(e,t)=>e.setDate(e.getDate()+t),(e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*P7)/I7,e=>e.getDate()-1);U7.range;var W7=M7(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/I7,e=>e.getUTCDate()-1);W7.range;var gTt=M7(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/I7,e=>Math.floor(e/I7));gTt.range;function G7(e){return M7(t=>{t.setDate(t.getDate()-(t.getDay()+7-e)%7),t.setHours(0,0,0,0)},(e,t)=>{e.setDate(e.getDate()+t*7)},(e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*P7)/L7)}var K7=G7(0),_Tt=G7(1),vTt=G7(2),yTt=G7(3),bTt=G7(4),xTt=G7(5),STt=G7(6);K7.range,_Tt.range,vTt.range,yTt.range,bTt.range,xTt.range,STt.range;function q7(e){return M7(t=>{t.setUTCDate(t.getUTCDate()-(t.getUTCDay()+7-e)%7),t.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t*7)},(e,t)=>(t-e)/L7)}var J7=q7(0),CTt=q7(1),wTt=q7(2),TTt=q7(3),ETt=q7(4),DTt=q7(5),OTt=q7(6);J7.range,CTt.range,wTt.range,TTt.range,ETt.range,DTt.range,OTt.range;var Y7=M7(e=>{e.setDate(1),e.setHours(0,0,0,0)},(e,t)=>{e.setMonth(e.getMonth()+t)},(e,t)=>t.getMonth()-e.getMonth()+(t.getFullYear()-e.getFullYear())*12,e=>e.getMonth());Y7.range;var X7=M7(e=>{e.setUTCDate(1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCMonth(e.getUTCMonth()+t)},(e,t)=>t.getUTCMonth()-e.getUTCMonth()+(t.getUTCFullYear()-e.getUTCFullYear())*12,e=>e.getUTCMonth());X7.range;var Z7=M7(e=>{e.setMonth(0,1),e.setHours(0,0,0,0)},(e,t)=>{e.setFullYear(e.getFullYear()+t)},(e,t)=>t.getFullYear()-e.getFullYear(),e=>e.getFullYear());Z7.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:M7(t=>{t.setFullYear(Math.floor(t.getFullYear()/e)*e),t.setMonth(0,1),t.setHours(0,0,0,0)},(t,n)=>{t.setFullYear(t.getFullYear()+n*e)}),Z7.range;var Q7=M7(e=>{e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCFullYear(e.getUTCFullYear()+t)},(e,t)=>t.getUTCFullYear()-e.getUTCFullYear(),e=>e.getUTCFullYear());Q7.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:M7(t=>{t.setUTCFullYear(Math.floor(t.getUTCFullYear()/e)*e),t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,n)=>{t.setUTCFullYear(t.getUTCFullYear()+n*e)}),Q7.range;function kTt(e,t){t.domain&&(`nice`in e||`quantiles`in e||`padding`in e,e.domain(t.domain))}function ATt(e,t){t.range&&(`padding`in e,e.range(t.range))}function jTt(e,t){`align`in e&&`align`in t&&t.align!==void 0&&e.align(t.align)}function MTt(e,t){`base`in e&&`base`in t&&t.base!==void 0&&e.base(t.base)}function NTt(e,t){`clamp`in e&&`clamp`in t&&t.clamp!==void 0&&e.clamp(t.clamp)}function PTt(e,t){`constant`in e&&`constant`in t&&t.constant!==void 0&&e.constant(t.constant)}function FTt(e,t){`exponent`in e&&`exponent`in t&&t.exponent!==void 0&&e.exponent(t.exponent)}var ITt={lab:xTe,hcl:CTe,"hcl-long":wTe,hsl:yTe,"hsl-long":bTe,cubehelix:ETe,"cubehelix-long":DTe,rgb:p};function LTt(e){switch(e){case`lab`:case`hcl`:case`hcl-long`:case`hsl`:case`hsl-long`:case`cubehelix`:case`cubehelix-long`:case`rgb`:return ITt[e];default:}var t=e.type,n=e.gamma,r=ITt[t];return n===void 0?r:r.gamma(n)}function RTt(e,t){if(`interpolate`in t&&`interpolate`in e&&t.interpolate!==void 0){var n=LTt(t.interpolate);e.interpolate(n)}}var zTt=new Date(Date.UTC(2020,1,2,3,4,5)),BTt=`%Y-%m-%d %H:%M`;function VTt(e){return e.tickFormat(1,BTt)(zTt)===`2020-02-02 03:04`}var HTt={day:U7,hour:V7,minute:z7,month:Y7,second:R7,week:K7,year:Z7},UTt={day:W7,hour:H7,minute:B7,month:X7,second:R7,week:J7,year:Q7};function WTt(e,t){if(`nice`in t&&t.nice!==void 0&&`nice`in e){var n=t.nice;if(typeof n==`boolean`)n&&e.nice();else if(typeof n==`number`)e.nice(n);else{var r=e,i=VTt(r);if(typeof n==`string`)r.nice(i?UTt[n]:HTt[n]);else{var a=n.interval,o=n.step,s=(i?UTt[a]:HTt[a]).every(o);s!=null&&r.nice(s)}}}}function GTt(e,t){`padding`in e&&`padding`in t&&t.padding!==void 0&&e.padding(t.padding),`paddingInner`in e&&`paddingInner`in t&&t.paddingInner!==void 0&&e.paddingInner(t.paddingInner),`paddingOuter`in e&&`paddingOuter`in t&&t.paddingOuter!==void 0&&e.paddingOuter(t.paddingOuter)}function KTt(e,t){if(t.reverse){var n=e.range().slice().reverse();`padding`in e,e.range(n)}}function qTt(e,t){`round`in t&&t.round!==void 0&&(t.round&&`interpolate`in t&&t.interpolate!==void 0?console.warn(`[visx/scale/applyRound] ignoring round: scale config contains round and interpolate. only applying interpolate. config:`,t):`round`in e?e.round(t.round):`interpolate`in e&&t.round&&e.interpolate(_Te))}function JTt(e,t){`unknown`in e&&`unknown`in t&&t.unknown!==void 0&&e.unknown(t.unknown)}function YTt(e,t){if(`zero`in t&&t.zero===!0){var n=e.domain(),r=n[0],i=n[1],a=i<r,o=a?[i,r]:[r,i],s=o[0],c=o[1],l=[Math.min(0,s),Math.max(0,c)];e.domain(a?l.reverse():l)}}var XTt=[`domain`,`nice`,`zero`,`interpolate`,`round`,`range`,`reverse`,`align`,`base`,`clamp`,`constant`,`exponent`,`padding`,`unknown`],ZTt={domain:kTt,nice:WTt,zero:YTt,interpolate:RTt,round:qTt,align:jTt,base:MTt,clamp:NTt,constant:PTt,exponent:FTt,padding:GTt,range:ATt,reverse:KTt,unknown:JTt};function QTt(){var e=new Set([...arguments]),t=XTt.filter(function(t){return e.has(t)});return function(e,n){return n!==void 0&&t.forEach(function(t){ZTt[t](e,n)}),e}}var $Tt=QTt(`domain`,`range`,`reverse`,`unknown`);function eEt(e){return $Tt(k7(),e)}function tEt({agents:e,width:t=120,height:n=120}){let r=e.filter(e=>e.status!==`stopped`&&e.status!==`dead`),i={};for(let e of r){let t=e.role||`other`;i[t]=(i[t]||0)+1}let a=Object.entries(i).map(([e,t])=>({label:e,value:t})),o=a.reduce((e,t)=>e+t.value,0),s=eEt({domain:a.map(e=>e.label),range:[`var(--gv-blue)`,`var(--gv-green)`,`var(--gv-amber)`,`var(--gv-pink)`,`var(--gv-purple)`]}),c=t/2,l=n/2,u=Math.min(c,l)-6,d=u*.6;if(o===0)return(0,z.jsx)(`div`,{className:`flex items-center justify-center rounded-full`,style:{width:t,height:n,border:`2px solid var(--gv-border)`},children:(0,z.jsx)(`span`,{className:`text-[10px]`,style:{color:`var(--gv-text-dim)`},children:`idle`})});let f=-Math.PI/2,p=a.map(e=>{let t=e.value/o*2*Math.PI,n={...e,startAngle:f,endAngle:f+t};return f+=t,n});return(0,z.jsxs)(`div`,{className:`flex flex-col items-center gap-2`,children:[(0,z.jsx)(`svg`,{width:t,height:n,children:(0,z.jsxs)(d7,{top:l,left:c,children:[p.map(e=>(0,z.jsx)(O7,{innerRadius:d,outerRadius:u,startAngle:e.startAngle,endAngle:e.endAngle,fill:s(e.label),stroke:`var(--gv-bg)`,strokeWidth:2,opacity:.85},e.label)),(0,z.jsx)(`text`,{textAnchor:`middle`,dy:`0.4em`,fontSize:18,fontWeight:`bold`,fill:`var(--gv-text-primary)`,fontFamily:`var(--gv-font-mono)`,children:o}),(0,z.jsx)(`text`,{textAnchor:`middle`,dy:`1.8em`,fontSize:10,fill:`var(--gv-text-secondary)`,fontFamily:`var(--gv-font-display)`,children:`agents`})]})}),(0,z.jsx)(`div`,{className:`flex flex-col gap-0.5 w-full`,children:p.map(e=>(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,z.jsx)(`div`,{className:`w-2 h-2 rounded-sm shrink-0`,style:{backgroundColor:s(e.label)}}),(0,z.jsx)(`span`,{className:`text-[10px] truncate`,style:{color:`var(--gv-text-secondary)`},children:e.label}),(0,z.jsx)(`span`,{className:`text-[10px] gv-mono ml-auto`,style:{color:`var(--gv-text-dim)`},children:e.value})]},e.label))})]})}function nEt({label:e,value:t,color:n,size:r=80}){let i=r/2,a=r/2,o=i-4,s=o-10,c=-Math.PI*.75,l=Math.PI*.75,u=c+t/100*(l-c);return(0,z.jsxs)(`div`,{className:`flex flex-col items-center gap-0.5`,children:[(0,z.jsx)(`svg`,{width:r,height:r*.7,overflow:`visible`,children:(0,z.jsxs)(d7,{top:a,left:i,children:[(0,z.jsx)(O7,{innerRadius:s,outerRadius:o,startAngle:c,endAngle:l,fill:`rgba(255,255,255,0.06)`}),(0,z.jsx)(O7,{innerRadius:s,outerRadius:o,startAngle:c,endAngle:u,fill:n,opacity:.85}),(0,z.jsxs)(`text`,{textAnchor:`middle`,dy:`0.35em`,fontSize:13,fontWeight:`bold`,fill:n,fontFamily:`var(--gv-font-mono)`,children:[Math.round(t),`%`]})]})}),(0,z.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wider`,style:{color:`var(--gv-text-secondary)`},children:e})]})}function rEt(e){if(e===0)return`0 B`;let t=e/1024**3;return t>=1?`${t.toFixed(1)} GB`:`${(e/1024**2).toFixed(0)} MB`}function iEt(){let e=c7(e=>e.systemHealth);return e?(0,z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,z.jsx)(`h3`,{className:`text-xs font-bold uppercase tracking-widest px-1`,style:{color:`var(--gv-text-secondary)`},children:`System`}),(0,z.jsxs)(`div`,{className:`flex justify-around gap-2`,children:[(0,z.jsx)(nEt,{label:`CPU`,value:e.cpu,color:`var(--gv-blue)`}),(0,z.jsx)(nEt,{label:`MEM`,value:e.memPercent,color:`var(--gv-purple)`})]}),(0,z.jsxs)(`div`,{className:`flex justify-between px-1`,children:[(0,z.jsxs)(`span`,{className:`text-[10px]`,style:{color:`var(--gv-text-dim)`},children:[`Used: `,rEt(e.memUsed)]}),(0,z.jsxs)(`span`,{className:`text-[10px]`,style:{color:`var(--gv-text-dim)`},children:[`Total: `,rEt(e.memTotal)]})]})]}):(0,z.jsx)(`div`,{className:`text-[10px] text-center py-2`,style:{color:`var(--gv-text-dim)`},children:`Loading system stats...`})}function aEt({agents:e}){return(0,z.jsxs)(`div`,{className:`gv-glass flex flex-col gap-3 p-3 overflow-hidden shrink-0`,style:{width:220,borderColor:`rgba(0, 212, 255, 0.1)`},children:[(0,z.jsx)(`div`,{className:`flex flex-col gap-2 flex-1 min-h-0 overflow-hidden`,children:(0,z.jsx)(Bwt,{})}),(0,z.jsx)(`div`,{className:`w-full h-px`,style:{backgroundColor:`var(--gv-border)`}}),(0,z.jsxs)(`div`,{className:`shrink-0`,children:[(0,z.jsx)(`h3`,{className:`text-xs font-bold uppercase tracking-widest px-1 mb-2`,style:{color:`var(--gv-text-secondary)`},children:`Agents`}),(0,z.jsx)(tEt,{agents:e,width:100,height:100})]}),(0,z.jsx)(`div`,{className:`w-full h-px`,style:{backgroundColor:`var(--gv-border)`}}),(0,z.jsx)(`div`,{className:`shrink-0`,children:(0,z.jsx)(iEt,{})})]})}function oEt(){jwt();let e=sm(lm);return(0,z.jsxs)(`div`,{className:`god-view flex flex-col h-full`,children:[(0,z.jsx)(Pwt,{agents:e}),(0,z.jsxs)(`div`,{className:`flex flex-1 gap-3 px-3 pb-3 pt-2 min-h-0 overflow-hidden`,children:[(0,z.jsx)(`div`,{className:`flex flex-1 min-w-0 min-h-0 items-center justify-center rounded-2xl border border-white/10 bg-black/20 text-sm text-white/50`,children:`Agent scan moved to the Agents fleet view.`}),(0,z.jsx)(aEt,{agents:e})]})]})}var sEt=[`deacon`,`pause`];function cEt(){return B({queryKey:sEt,queryFn:async()=>{let e=await fetch(`/api/deacon/pause`);if(!e.ok)throw Error(`GET /api/deacon/pause → ${e.status}`);return e.json()},staleTime:5e3,refetchInterval:3e4,refetchOnWindowFocus:!0})}function lEt(){let e=_t();return Nt({mutationFn:async e=>{let t=await fetch(`/api/deacon/pause`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({paused:e})});if(!t.ok){let e=await t.text().catch(()=>``);throw Error(e||`POST /api/deacon/pause → ${t.status}`)}return t.json()},onSuccess:t=>{e.setQueryData(sEt,t)}})}function uEt({compact:e=!1}){let{data:t}=cEt(),n=lEt(),r=t?.paused===!0,i=n.isPending,a=()=>{i||n.mutate(!r)},o=r?`Deacon is FROZEN — click to resume patrol`:`Freeze Deacon — stop all patrol cycles globally`;return e?(0,z.jsxs)(`button`,{onClick:a,disabled:i,className:`relative inline-flex items-center gap-1.5 transition-colors disabled:opacity-50 ${r?`rounded-full border border-warning/50 bg-warning/15 px-2.5 py-1 text-xs font-medium text-warning-foreground hover:bg-warning/25`:`rounded-md p-1.5 text-muted-foreground hover:bg-accent hover:text-foreground`}`,title:o,children:[(0,z.jsx)(Bee,{className:`h-3.5 w-3.5`}),r&&(0,z.jsx)(`span`,{children:`Deacon frozen`}),r&&(0,z.jsx)(`span`,{className:`absolute -right-1 -top-1 flex h-3.5 w-3.5 animate-pulse items-center justify-center rounded-full bg-amber-500 text-[9px] font-bold leading-none text-white ring-2 ring-background`,children:`!`})]}):(0,z.jsx)(`button`,{onClick:a,disabled:i,className:`inline-flex items-center gap-1.5 px-2 py-1 rounded-md text-xs font-semibold transition-colors disabled:opacity-50 ${r?`text-sky-200 bg-sky-900/70 hover:bg-sky-800/80 border border-sky-400/60`:`text-muted-foreground hover:text-foreground hover:bg-accent border border-transparent`}`,title:o,children:r?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(hr,{className:`w-3.5 h-3.5`}),`Resume Deacon`]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Bee,{className:`w-3.5 h-3.5`}),`Freeze Deacon`]})})}async function dEt(){let e=await fetch(`/api/deacon/status`);if(!e.ok)throw Error(`Failed to fetch deacon status`);return e.json()}async function fEt(){let e=await fetch(`/api/deacon/logs?limit=200`);if(!e.ok)throw Error(`Failed to fetch deacon logs`);return e.json()}function pEt(e){if(!e)return`never`;let t=Date.now()-new Date(e).getTime();if(t<0)return`just now`;let n=Math.floor(t/1e3);if(n<60)return`${n}s ago`;let r=Math.floor(n/60);if(r<60)return`${r}m ago`;let i=Math.floor(r/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function mEt(e){try{return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}catch{return``}}var hEt={info:{label:`INF`,cls:`text-muted-foreground bg-muted`},action:{label:`ACT`,cls:`text-primary bg-primary/10`},warn:{label:`WRN`,cls:`text-amber-500 bg-amber-500/10`},error:{label:`ERR`,cls:`text-destructive bg-destructive/10`}};function gEt(e){return e.consecutiveFailures>=3?`bg-destructive`:e.consecutiveFailures>0||e.lastForceKillTime&&Date.now()-new Date(e.lastForceKillTime).getTime()<300*1e3?`bg-amber-500`:`bg-emerald-500`}function _Et(e){let t=[];for(let n of e){let e=t[t.length-1];e&&e.cycle===n.cycle?e.entries.push(n):t.push({cycle:n.cycle,entries:[n]})}return t}function vEt(){let e=_t(),{data:t}=B({queryKey:[`deacon-status`],queryFn:dEt,refetchInterval:1e4}),{data:n}=B({queryKey:[`deacon-logs-full`],queryFn:fEt,refetchInterval:5e3}),r=Nt({mutationFn:async()=>{let e=await fetch(`/api/deacon/patrol`,{method:`POST`});if(!e.ok)throw Error(`Failed to trigger patrol`);return e.json()},onSuccess:()=>{e.invalidateQueries({queryKey:[`deacon-status`]}),e.invalidateQueries({queryKey:[`deacon-logs-full`]})}}),i=(0,R.useMemo)(()=>Object.values(t?.state.specialists||{}),[t]),a=(0,R.useMemo)(()=>_Et([...n?.logs||[]].reverse()),[n]),o=t?Math.round(t.config.patrolIntervalMs/1e3):null;return(0,z.jsx)(`div`,{className:`w-full h-full overflow-y-auto bg-background text-foreground`,children:(0,z.jsxs)(`div`,{className:`mx-auto max-w-4xl px-6 py-6`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-3 mb-6`,children:[(0,z.jsx)(kr,{className:`w-6 h-6 ${t?.isRunning?`text-emerald-500`:`text-muted-foreground`}`}),(0,z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,z.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Deacon`}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Cloister lifecycle watchdog — patrols, auto-resumes, and janitor actions`})]}),(0,z.jsx)(uEt,{}),(0,z.jsxs)(`button`,{onClick:()=>r.mutate(),disabled:r.isPending||!t?.isRunning,className:`inline-flex items-center gap-1.5 rounded-md border border-border bg-popover px-2.5 py-1.5 text-xs text-foreground hover:bg-card transition-colors disabled:opacity-50`,title:t?.isRunning?`Run a patrol cycle now`:`Deacon is stopped`,children:[(0,z.jsx)(_r,{className:`w-3.5 h-3.5 ${r.isPending?`animate-spin`:``}`}),`Run patrol`]})]}),(0,z.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-3 mb-6`,children:[(0,z.jsx)($7,{label:`Status`,value:t?t.isRunning?`Running`:`Stopped`:`—`,valueClass:t?.isRunning?`text-emerald-500`:`text-muted-foreground`}),(0,z.jsx)($7,{label:`Patrol cycle`,value:t?`#${t.state.patrolCycle}`:`—`}),(0,z.jsx)($7,{label:`Last patrol`,value:pEt(t?.state.lastPatrol)}),(0,z.jsx)($7,{label:`Interval`,value:o==null?`—`:`${o}s`})]}),t?.lastPatrol?.massDeathDetected&&(0,z.jsxs)(`div`,{className:`flex items-center gap-2 mb-6 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:[(0,z.jsx)(Ir,{className:`w-4 h-4 shrink-0`}),`Mass-death detected on the last patrol — auto-resume was held back as a safety brake.`]}),(0,z.jsx)(`h2`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground mb-2`,children:`Specialist health`}),(0,z.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 gap-2 mb-6`,children:i.length===0?(0,z.jsx)(`div`,{className:`col-span-full text-xs text-muted-foreground`,children:`No specialists tracked yet.`}):i.map(e=>(0,z.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border bg-card px-3 py-2`,children:[(0,z.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0 ${gEt(e)}`}),(0,z.jsx)(`span`,{className:`text-xs text-foreground truncate flex-1`,children:e.specialistName.replace(`-agent`,``)}),e.consecutiveFailures>0&&(0,z.jsxs)(`span`,{className:`text-[10px] text-amber-500`,title:`consecutive failures`,children:[e.consecutiveFailures,`×`]}),e.forceKillCount>0&&(0,z.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,title:`force-kills`,children:[`⊘`,e.forceKillCount]})]},e.specialistName))}),(0,z.jsxs)(`h2`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground mb-2 flex items-center gap-1.5`,children:[(0,z.jsx)(Lt,{className:`w-3.5 h-3.5`}),` Patrol activity`]}),(0,z.jsx)(`div`,{className:`rounded-md border border-border bg-card divide-y divide-border`,children:a.length===0?(0,z.jsx)(`div`,{className:`px-3 py-6 text-center text-xs text-muted-foreground`,children:`No patrol activity yet — waiting for the next cycle.`}):a.map((e,t)=>(0,z.jsxs)(`div`,{className:`px-3 py-2`,children:[(0,z.jsx)(`div`,{className:`mb-1.5 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e.cycle==null?`Uncycled`:`Cycle #${e.cycle}`}),(0,z.jsx)(`div`,{className:`space-y-1`,children:e.entries.map((e,t)=>{let n=hEt[e.level]??hEt.info;return(0,z.jsxs)(`div`,{className:`flex items-start gap-2 text-xs`,children:[(0,z.jsx)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums shrink-0 mt-0.5`,children:mEt(e.timestamp)}),(0,z.jsx)(`span`,{className:`text-[9px] font-semibold rounded px-1 py-0.5 shrink-0 mt-0.5 ${n.cls}`,children:n.label}),(0,z.jsx)(`span`,{className:`text-foreground break-words min-w-0`,children:e.message})]},t)})})]},t))})]})})}function $7({label:e,value:t,valueClass:n}){return(0,z.jsxs)(`div`,{className:`rounded-md border border-border bg-card px-3 py-2`,children:[(0,z.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:e}),(0,z.jsx)(`div`,{className:`text-sm font-medium ${n??`text-foreground`}`,children:t})]})}function yEt(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function bEt(e){if(Array.isArray(e))return e}function xEt(e,t,n){return(t=AEt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function SEt(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function CEt(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
667
|
+
`))if(i.startsWith(`diff --git `)){n&&t.set(n,r),r=[];let e=/\sb\/(.+)$/.exec(i);n=e?e[1]:``}else n&&r.push(i);return n&&t.set(n,r),t}function pbt(e){let t=[],n=0;for(let r of e)if(r.startsWith(`@@`)){let e=r.split(`@@`)[1]??``,i=/\+(\d+)/.exec(e);n=i?parseInt(i[1],10):n,t.push({kind:`hunk`,n:null,text:r})}else r.startsWith(`+`)&&!r.startsWith(`+++`)?t.push({kind:`add`,n:n++,text:r}):r.startsWith(`-`)&&!r.startsWith(`---`)?t.push({kind:`del`,n:null,text:r}):r.startsWith(`--- `)||r.startsWith(`+++ `)||r.startsWith(`index `)||r.startsWith(`new file`)||r.startsWith(`deleted file`)||r.startsWith(`rename `)||r.startsWith(`similarity `)||r.startsWith(`Binary `)||r.startsWith(`old mode`)||r.startsWith(`new mode`)||t.push({kind:`ctx`,n:n++,text:r});return t}function R5({add:e,del:t}){return(0,z.jsxs)(`span`,{className:L5.cnt,children:[e?(0,z.jsxs)(`span`,{className:L5.add,children:[`+`,e]}):null,e&&t?` `:null,t?(0,z.jsxs)(`span`,{className:L5.del,children:[`−`,t]}):null]})}function mbt({issueId:e}){let t=Dj(e),n=Oj(e),r=t.data?.pr?.files??[],[i,a]=(0,R.useState)(null),[o,s]=(0,R.useState)(new Set),c=i??r[0]?.path??null,l=(0,R.useMemo)(()=>{let e=new Map;for(let t of r){let n=ubt(t.path);e.has(n)||e.set(n,[]),e.get(n).push(t)}return[...e.entries()].sort((e,t)=>e[0].localeCompare(t[0]))},[r]),u=(0,R.useMemo)(()=>fbt(n.data?.diff),[n.data?.diff]),d=(0,R.useMemo)(()=>c?pbt(u.get(c)??[]):[],[u,c]),f=r.find(e=>e.path===c);if(t.isLoading)return(0,z.jsx)(`div`,{className:L5.wrap,children:(0,z.jsx)(`div`,{className:L5.loading,children:`Loading changed files…`})});if(!t.data?.pr)return(0,z.jsx)(`div`,{className:L5.wrap,children:(0,z.jsx)(`div`,{className:L5.empty,children:`No pull request for this issue yet.`})});let p=t.data.pr.additions??r.reduce((e,t)=>e+t.additions,0),m=t.data.pr.deletions??r.reduce((e,t)=>e+t.deletions,0);return(0,z.jsxs)(`div`,{className:L5.wrap,children:[(0,z.jsxs)(`div`,{className:L5.head,children:[(0,z.jsx)(`span`,{className:L5.title,children:`Changed files`}),(0,z.jsxs)(`span`,{className:L5.sum,children:[(0,z.jsx)(`b`,{children:r.length}),` `,(0,z.jsx)(`span`,{className:L5.files,children:`files`}),` · `,(0,z.jsxs)(`span`,{className:L5.add,children:[`+`,p]}),` `,(0,z.jsxs)(`span`,{className:L5.del,children:[`−`,m]})]}),(0,z.jsxs)(`span`,{className:L5.acts,children:[(0,z.jsx)(`button`,{type:`button`,className:L5.btn,onClick:()=>s(new Set(l.map(e=>e[0]).filter(Boolean))),children:`Collapse all`}),(0,z.jsx)(`button`,{type:`button`,className:L5.btn,onClick:()=>s(new Set),children:`Expand all`}),t.data.pr.url&&(0,z.jsx)(`a`,{className:L5.btn,href:t.data.pr.url,target:`_blank`,rel:`noreferrer`,children:`Open PR ↗`})]})]}),(0,z.jsxs)(`div`,{className:L5.grid,children:[(0,z.jsxs)(`div`,{className:L5.tree,children:[r.length===0&&(0,z.jsx)(`div`,{className:L5.empty,children:`No files changed.`}),l.map(([e,t])=>{let n=o.has(e),r=t.reduce((e,t)=>e+t.additions,0),i=t.reduce((e,t)=>e+t.deletions,0);return(0,z.jsxs)(`div`,{children:[e&&(0,z.jsxs)(`button`,{type:`button`,className:`${L5.row} ${L5.dirrow}`,onClick:()=>s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),children:[(0,z.jsx)(`span`,{className:L5.car,children:n?`▸`:`▾`}),(0,z.jsx)(`span`,{className:L5.ftype,children:`📁`}),(0,z.jsx)(`span`,{className:L5.nm,children:(0,z.jsx)(`span`,{className:L5.dirname,children:e})}),(0,z.jsx)(dbt,{add:r,del:i}),(0,z.jsx)(R5,{add:r,del:i})]}),!n&&t.map(t=>(0,z.jsxs)(`button`,{type:`button`,className:`${L5.row} ${e?L5.fileIndent:``} ${t.path===c?L5.sel:``}`,onClick:()=>a(t.path),title:t.path,children:[(0,z.jsx)(`span`,{className:L5.car}),(0,z.jsx)(`span`,{className:L5.ftype,children:cbt(t.path)}),(0,z.jsx)(`span`,{className:L5.nm,children:lbt(t.path)}),(0,z.jsx)(dbt,{add:t.additions,del:t.deletions}),(0,z.jsx)(R5,{add:t.additions,del:t.deletions})]},t.path))]},e||`__root`)})]}),(0,z.jsx)(`div`,{className:L5.diff,children:c?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:L5.dhead,children:[(0,z.jsx)(`span`,{className:L5.ftype,children:cbt(c)}),(0,z.jsx)(`span`,{className:L5.path,children:c}),f&&(0,z.jsx)(R5,{add:f.additions,del:f.deletions})]}),n.isLoading?(0,z.jsx)(`div`,{className:L5.loading,children:`Loading diff…`}):d.length===0?(0,z.jsxs)(`div`,{className:L5.empty,children:[`No text diff for this file`,(0,z.jsx)(`span`,{className:L5.sub,children:`(binary, renamed, or no line changes)`})]}):(0,z.jsx)(`div`,{className:L5.lines,children:d.map((e,t)=>{let n=e.kind===`hunk`?L5.hunk:e.kind===`add`?L5.add:e.kind===`del`?L5.del:``;return(0,z.jsxs)(`div`,{className:`${L5.dl} ${n}`,children:[(0,z.jsx)(`span`,{className:L5.ln,children:e.n??``}),(0,z.jsx)(`span`,{className:L5.tx,children:e.text})]},t)})})]}):(0,z.jsxs)(`div`,{className:L5.empty,children:[`Select a file to view its diff`,(0,z.jsx)(`span`,{className:L5.sub,children:`or “Open PR ↗” for the full review`})]})})]})]})}var hbt={info:`bg-info`,success:`bg-success`,warning:`bg-warning`,destructive:`bg-destructive`,review:`bg-signal-review`,cost:`bg-signal-cost`,muted:`bg-muted-foreground`};function z5({tone:e,title:t,right:n,children:r,className:i=``}){return(0,z.jsxs)(`div`,{className:`rounded-[18px] border border-border bg-card p-4 shadow-sm ${i}`,children:[(0,z.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`h-[7px] w-[7px] rounded-full ${hbt[e]}`}),(0,z.jsx)(`h3`,{className:`font-display text-[13px] font-semibold text-foreground`,children:t}),n!=null&&(0,z.jsx)(`div`,{className:`ml-auto flex items-center gap-2`,children:n})]}),r]})}var gbt={info:`text-info-foreground badge-bg-info badge-border-info`,success:`text-success-foreground badge-bg-success badge-border-success`,warning:`text-warning-foreground badge-bg-warning badge-border-warning`,destructive:`text-destructive-foreground badge-bg-destructive badge-border-destructive`,review:`text-signal-review-foreground badge-bg-signal-review badge-border-signal-review`,cost:`text-signal-cost-foreground badge-bg-signal-cost badge-border-signal-cost`,muted:`text-muted-foreground badge-bg-muted badge-border-muted`};function B5({tone:e,children:t,className:n=``}){let r=gbt[e];return(0,z.jsx)(`span`,{className:`inline-flex items-center gap-1 rounded-[var(--radius-sm)] border px-[7px] py-[2px] text-[10px] font-semibold uppercase tracking-[0.05em] ${r} ${n}`,children:t})}function V5(e){return[`passed`,`merged`,`done`,`completed`].includes(e)?`success`:[`blocked`,`failed`,`dispatch_failed`].includes(e)?`destructive`:[`reviewing`,`testing`,`merging`,`verifying`,`running`,`queued`].includes(e)?`info`:`muted`}var _bt={review:`review`,test:`warning`,merge:`success`,inspect:`info`,uat:`info`};function vbt(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString([],{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function ybt({issueId:e}){let t=wj(e),n=(0,R.useMemo)(()=>[...t.data?.history??[]].reverse(),[t.data?.history]);return n.length===0?(0,z.jsx)(`div`,{className:`px-1 py-4 text-[12px] text-muted-foreground`,children:t.isLoading?`Loading…`:`No status history yet.`}):(0,z.jsxs)(`div`,{className:`relative py-2 pl-4`,children:[(0,z.jsx)(`div`,{className:`absolute bottom-2 left-[6px] top-2 w-px bg-border`}),(0,z.jsx)(`div`,{className:`flex flex-col gap-3`,children:n.map((e,t)=>(0,z.jsxs)(`div`,{className:`relative`,children:[(0,z.jsx)(`span`,{className:`absolute -left-4 top-1 h-[9px] w-[9px] rounded-full border-2 border-background ${V5(e.status)===`success`?`bg-success`:V5(e.status)===`destructive`?`bg-destructive`:V5(e.status)===`info`?`bg-info`:`bg-muted-foreground`}`}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,z.jsx)(B5,{tone:_bt[e.type]??`muted`,children:e.type}),(0,z.jsx)(B5,{tone:V5(e.status),children:e.status}),(0,z.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:vbt(e.timestamp)})]}),e.notes&&(0,z.jsx)(`div`,{className:`mt-1 text-[12px] leading-snug text-foreground/85`,children:e.notes})]},`${e.type}-${e.timestamp}-${t}`))})]})}var H5={wrap:`_wrap_4ie0a_5`,scan:`_scan_4ie0a_9`,missionWrap:`_missionWrap_4ie0a_22`,headerTop:`_headerTop_4ie0a_35`,headerTitle:`_headerTitle_4ie0a_41`,headerMeta:`_headerMeta_4ie0a_45`,missionBody:`_missionBody_4ie0a_66`},bbt=[{id:`overview`,label:`Overview`},{id:`code`,label:`Code`},{id:`plan`,label:`PRD / Plan`},{id:`timeline`,label:`Timeline`},{id:`discussion`,label:`Discussion`},{id:`costs`,label:`Costs`},{id:`artifacts`,label:`Artifacts`},{id:`conversation`,label:`Conversation`},{id:`files`,label:`Files`},{id:`terminal`,label:`Terminal`}],xbt={planning:`Planning`,work:`Work`,review:`Review & Test`,agent:`Agent`,workspace:`Workspace`,artifacts:`Artifacts`,navigation:`Navigation`,danger:`Danger`,preserved:`Preserved`},Sbt=[`planning`,`work`,`review`,`agent`,`workspace`,`artifacts`,`navigation`,`danger`,`preserved`],Cbt={done:`bg-success`,active:`bg-info animate-pulse`,fail:`bg-destructive`,todo:`bg-muted-foreground/20`},wbt={done:`border-success/50 bg-success/15 text-success-foreground`,active:`border-info/50 bg-info/15 text-info-foreground`,fail:`border-destructive/50 bg-destructive/15 text-destructive-foreground`,todo:`border-border bg-muted/30 text-muted-foreground`},Tbt={ok:`bg-success`,bad:`bg-destructive`,run:`bg-info`,wait:`bg-muted-foreground`};function Ebt(e){let t=(e??``).toLowerCase();return[`passed`,`success`,`completed`,`merged`,`ready`].includes(t)?`success`:[`failed`,`blocked`,`dispatch_failed`,`timed_out`,`action_required`,`startup_failure`,`failure`].includes(t)?`destructive`:[`running`,`reviewing`,`testing`,`queued`,`merging`,`verifying`,`in_progress`].includes(t)?`info`:[`skipped`,`neutral`,`cancelled`].includes(t)?`muted`:`warning`}function Dbt(e){return e===`done`?`✓`:e===`fail`?`✕`:e===`active`?`◆`:`○`}function Obt(e){return e.status===`completed`?(e.conclusion??`unknown`).replace(/_/g,` `):e.status.replace(/_/g,` `)}function kbt(e){return e?e.mergeStatus===`merged`?`merged`:e.mergeStatus===`merging`||e.mergeStatus===`queued`||e.mergeStatus===`verifying`?e.mergeStatus:e.testStatus===`testing`?`testing`:e.reviewStatus===`reviewing`?`reviewing`:e.reviewStatus===`blocked`||e.reviewStatus===`failed`?e.reviewStatus:e.testStatus===`failed`||e.testStatus===`dispatch_failed`?e.testStatus:e.readyForMerge?`ready`:e.reviewStatus??`pending`:`pending`}function Abt(e){let{hasPlan:t,rs:n,ci:r,work:i}=e,a=n?.reviewStatus===`blocked`||n?.reviewStatus===`failed`?`fail`:n?.reviewStatus===`reviewing`?`active`:n?.reviewStatus===`passed`?`done`:`todo`,o=n?.testStatus===`failed`||n?.testStatus===`dispatch_failed`?`fail`:n?.testStatus===`testing`?`active`:n?.testStatus===`passed`||n?.testStatus===`skipped`?`done`:`todo`,s=r?.summary,c=s&&(s.failed||s.cancelled)?`fail`:s&&(s.running||s.pending)?`active`:s&&s.total?`done`:`todo`,l=n?.mergeStatus===`failed`?`fail`:n?.mergeStatus===`queued`||n?.mergeStatus===`merging`||n?.mergeStatus===`verifying`?`active`:n?.mergeStatus===`merged`?`done`:`todo`;return{plan:t?`done`:`todo`,work:i?.status===`running`?`active`:i?`done`:`todo`,review:a,test:o,ci:c,ship:l,merge:n?.mergeStatus===`merged`?`done`:n?.readyForMerge?`active`:`todo`}}function jbt(e){return e?e.mergeStatus===`merged`?`merged — close out`:e.readyForMerge?`merge to main`:e.reviewStatus===`blocked`||e.reviewStatus===`failed`?`work agent fixes → re-review`:e.reviewStatus===`reviewing`?`review in progress`:e.testStatus===`testing`?`test in progress`:e.testStatus===`failed`||e.testStatus===`dispatch_failed`?`fix tests → re-run`:e.reviewStatus===`passed`&&e.testStatus!==`passed`&&e.testStatus!==`skipped`?`dispatch test`:`awaiting pipeline`:`start work`}function Mbt(e){return e?e.mergeStatus===`merged`?`merged`:e.reviewStatus===`blocked`||e.reviewStatus===`failed`?`blocked by review`:e.testStatus===`failed`||e.testStatus===`dispatch_failed`?`test failed`:e.reviewStatus===`passed`?e.testStatus===`pending`||e.testStatus===`testing`?`test pending`:`not ready`:`review pending`:`status unknown`}function Nbt(e,t,n){let r=e?.reviewStatus===`blocked`||e?.reviewStatus===`failed`?{value:(e?.reviewStatus??``).toUpperCase(),tone:`bad`}:e?.reviewStatus===`reviewing`?{value:`reviewing`,tone:`run`}:e?.reviewStatus===`passed`?{value:`passed`,tone:`ok`}:{value:`pending`,tone:`wait`},i=e?.testStatus===`failed`||e?.testStatus===`dispatch_failed`?{value:`failed`,tone:`bad`}:e?.testStatus===`testing`?{value:`testing`,tone:`run`}:e?.testStatus===`passed`||e?.testStatus===`skipped`?{value:e.testStatus,tone:`ok`}:{value:`pending`,tone:`wait`},a=e?.verificationStatus===`passed`?{value:`passed`,tone:`ok`}:e?.verificationStatus===`failed`?{value:`failed`,tone:`bad`}:e?.verificationStatus===`running`?{value:`running`,tone:`run`}:{value:`pending`,tone:`wait`},o=t?.summary,s=!o||o.total===0?{value:`no checks`,tone:`wait`}:o.failed||o.cancelled?{value:`${o.passed}/${o.total}`,tone:`bad`}:o.running||o.pending?{value:`${o.passed}/${o.total}`,tone:`run`}:{value:`${o.passed}/${o.total} ✓`,tone:`ok`},c=(n?.mergeable??``).toUpperCase(),l=n?c===`MERGEABLE`||c===`CLEAN`?{value:`mergeable`,tone:`ok`}:c===`CONFLICTING`?{value:`conflicting`,tone:`bad`}:{value:`unknown`,tone:`wait`}:{value:`no PR`,tone:`wait`},u=e?.readyForMerge?{value:`yes`,tone:`ok`}:{value:`no`,tone:`bad`};return[{label:`Review`,...r},{label:`Test`,...i},{label:`Verification`,...a},{label:`CI`,...s},{label:`PR`,...l},{label:`Merge-ready`,...u}]}function U5({label:e,value:t}){return(0,z.jsxs)(`div`,{className:`flex flex-col gap-px text-right`,children:[(0,z.jsx)(`div`,{className:`text-[9px] uppercase tracking-[0.06em] text-muted-foreground`,children:e}),(0,z.jsx)(`div`,{className:`text-[11.5px] text-foreground`,children:t})]})}function Pbt({issueId:e,rs:t}){if(t?.mergeStatus===`merged`)return(0,z.jsx)(`span`,{className:`inline-flex items-center gap-1.5 rounded-[var(--radius-sm)] border badge-border-success badge-bg-success px-3 py-2 text-[12px] font-medium text-success-foreground`,children:`✓ Merged`});if(t?.readyForMerge)return(0,z.jsx)(cH,{issueId:e,reviewStatus:t,variant:`inspector`,tone:`primary`});let n=Mbt(t);return(0,z.jsxs)(`button`,{type:`button`,disabled:!0,title:`Merge gated: ${n}`,className:`inline-flex cursor-not-allowed items-center gap-1.5 rounded-[var(--radius-sm)] border border-border bg-muted/40 px-3 py-2 text-[12px] font-medium text-muted-foreground opacity-80`,children:[`⛔ Merge — `,n]})}function Fbt({issueId:e,onPhase:t}){let n=wj(e),r=Ej(e),i=Cj(e),a=Bj(e),o=i.data?.sections.find(e=>e.type===`work`),s=Abt({hasPlan:a.state.hasPlan,rs:n.data,ci:r.data,work:o}),c=r.data?.summary;return(0,z.jsx)(`div`,{className:`flex items-stretch gap-1.5`,"data-testid":`cockpit-pipeline-progress`,children:[{key:`plan`,label:`Plan`,sub:s.plan===`done`?`approved`:void 0,state:s.plan},{key:`work`,label:`Work`,sub:s.work===`done`?`done`:s.work===`active`?`running`:void 0,state:s.work},{key:`review`,label:`Review`,sub:n.data?.reviewStatus,state:s.review},{key:`test`,label:`Test`,sub:n.data?.testStatus,state:s.test},{key:`ci`,label:`CI/CD`,sub:c?.total?`${c.passed}/${c.total}`:void 0,state:s.ci},{key:`ship`,label:`Ship`,sub:n.data?.mergeStatus&&n.data.mergeStatus!==`pending`?n.data.mergeStatus:void 0,state:s.ship},{key:`merge`,label:`Merge`,sub:s.merge===`active`?`ready`:void 0,state:s.merge}].map(e=>(0,z.jsxs)(`button`,{type:`button`,onClick:()=>t(e.key),className:`flex min-w-0 flex-1 flex-col gap-1.5 rounded-[8px] p-1 text-left transition-colors hover:bg-accent`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,z.jsx)(`span`,{className:`grid h-[15px] w-[15px] shrink-0 place-items-center rounded-full border text-[9px] ${wbt[e.state]}`,children:Dbt(e.state)}),(0,z.jsxs)(`span`,{className:`min-w-0 truncate text-[10.5px] text-muted-foreground`,children:[(0,z.jsx)(`span`,{className:`font-medium text-foreground`,children:e.label}),e.sub?` ${e.sub}`:``]})]}),(0,z.jsx)(`div`,{className:`h-[5px] rounded-full ${Cbt[e.state]}`})]},e.key))})}function Ibt({issueId:e}){let t=wj(e),n=Ej(e),r=Dj(e);return(0,z.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,"data-testid":`cockpit-gates`,children:Nbt(t.data,n.data,r.data?.pr??null).map(e=>(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full border border-border bg-card px-2.5 py-1 text-[11px]`,children:[(0,z.jsx)(`span`,{className:`h-2 w-2 rounded-[2px] ${Tbt[e.tone]}`}),(0,z.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:e.label}),(0,z.jsx)(`span`,{className:`text-foreground`,children:e.value})]},e.label))})}function Lbt({issueId:e}){let[t,n]=(0,R.useState)(!1),r=Bj(e),i=(0,R.useMemo)(()=>new Map(r.all.map(e=>[e.action.key,e])),[r.all]);(0,R.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Escape`&&n(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let a=(0,R.useMemo)(()=>Sbt.map(e=>({group:e,views:Ck.filter(t=>t.group===e).map(e=>i.get(e.key)).filter(e=>!!e)})).filter(e=>e.views.length>0),[i]);return(0,z.jsxs)(`div`,{className:`relative`,children:[(0,z.jsx)(`button`,{type:`button`,"aria-expanded":t,"aria-label":`Issue actions`,className:`inline-flex items-center rounded-[var(--radius-sm)] border border-border bg-card px-3 py-2 text-[12px] font-semibold text-foreground transition-colors hover:bg-accent`,onClick:()=>n(e=>!e),children:`⌘ Actions ▾`}),t&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>n(!1)}),(0,z.jsx)(`div`,{className:`absolute right-0 top-full z-50 mt-2 grid w-[min(560px,calc(100vw-48px))] grid-cols-1 gap-x-5 gap-y-2 rounded-[18px] border border-border bg-popover p-3 shadow-xl md:grid-cols-2`,children:a.map(({group:e,views:t})=>(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`h4`,{className:`mb-1.5 px-1 text-[10px] font-semibold uppercase tracking-[0.08em] text-muted-foreground`,children:xbt[e]}),(0,z.jsx)(`div`,{className:`flex flex-col gap-1`,children:t.map(e=>(0,z.jsx)(`button`,{type:`button`,disabled:!e.enabled||e.isPending,title:e.disabledReason??e.action.label,onClick:()=>{e.invoke(),e.action.kind!==`dialog`&&n(!1)},className:`rounded-[8px] px-2 py-1.5 text-left text-[12px] transition-colors disabled:cursor-not-allowed disabled:opacity-45 ${e.action.kind===`destructive`||e.action.group===`danger`?`text-destructive-foreground hover:bg-destructive/10`:`text-foreground hover:bg-accent`}`,children:e.isPending?`${e.action.label}…`:e.action.label},e.action.key))})]},e))})]}),(0,z.jsx)(Wj,{issueId:e,actions:r})]})}function Rbt(e){let t=e.type===`reviewer`?`reviewer`:e.type===`review`?`review`:e.type===`test`?`test`:e.type===`ship`?`ship`:e.type===`merge`?`merge`:e.type===`planning`?`planning`:e.type===`legacy`?`legacy`:e.type===`strike`?`strike`:e.type===`work`?`work`:null;if(!t)return null;let n=e.status===`completed`?`stopped`:e.status===`running`||e.status===`starting`||e.status===`error`||e.status===`stopped`?e.status:e.status?.toLowerCase().includes(`fail`)?`error`:e.status?.toLowerCase().includes(`run`)?`running`:`stopped`;return{type:t,sessionId:e.sessionId||`${t}-session`,model:e.model||`unknown`,startedAt:e.startedAt||new Date(0).toISOString(),duration:e.duration??null,status:n,presence:n===`running`||n===`starting`?`active`:`ended`}}function zbt(e){return e?.mergeStatus===`merged`?`Done`:e?.readyForMerge?`In Review`:e?.testStatus===`testing`?`Testing`:e?.reviewStatus===`reviewing`||e?.reviewStatus===`passed`||e?.reviewStatus===`blocked`||e?.reviewStatus===`failed`?`In Review`:`In Progress`}async function Bbt(e,t){let n=t.toLowerCase(),r=await fetch(`/api/issues/resource-allocated`);if(!r.ok)return null;let i=(await r.json()).find(t=>t.issueId.toLowerCase()===n&&(!e||t.projectName===e))??null,a=e??i?.projectName;if(!a)return i;let o=await fetch(`/api/session-trees?projects=${encodeURIComponent(a)}`);if(!o.ok)return i;let s=((await o.json()).trees??[]).find(e=>e.projectKey===a)?.features.find(e=>e.issueId.toLowerCase()===n);return!i&&!s?null:i?{...i,sessions:s?.sessions??i.sessions}:{issueId:t,title:s?.title??t,projectName:a,branch:``,status:s?.sessions.some(e=>e.presence===`active`)?`running`:`has_state`,stateLabel:`In Progress`,agentStatus:s?.sessions.some(e=>e.presence===`active`)?`running`:null,hasPlanning:s?.sessions.some(e=>e.type===`planning`||e.type===`legacy`)??!1,hasPrd:!1,hasState:!1,isShadow:!1,sessions:s?.sessions??[]}}function Vbt({issueId:e,title:t,projectName:n,selectedSessionId:r,onSelectSession:i,onSessionsChange:a,onOpenVerification:o}){let s=wj(e),c=Cj(e),l=Bj(e),u=B({queryKey:[`cockpit-project-feature`,n,e],queryFn:()=>Bbt(n,e),enabled:!0,staleTime:1e4}),d=(0,R.useMemo)(()=>{let t=(c.data?.sections??[]).map(e=>Rbt(e)).filter(e=>!!e);return l.state.hasPlan&&!t.some(e=>e.type===`planning`||e.type===`legacy`)&&t.push({type:`legacy`,sessionId:`${e}-planning-state`,model:`planning`,startedAt:new Date(0).toISOString(),duration:null,status:`stopped`,presence:`ended`}),t},[l.state.hasPlan,c.data?.sections,e]),f=(0,R.useMemo)(()=>({issueId:e,title:t,projectName:n??`Project`,branch:``,status:d.some(e=>e.presence===`active`)?`running`:l.state.hasPlan?`has_state`:`idle`,stateLabel:zbt(s.data),agentStatus:d.some(e=>e.presence===`active`)?`running`:null,hasPlanning:l.state.hasPlan,hasPrd:l.state.hasPlan,hasState:l.state.hasPlan,isShadow:!1,readyForMerge:s.data?.readyForMerge,sessions:d,resourceSources:[...l.state.hasPlan?[`vbrief`]:[],...l.state.hasBeads?[`beads`]:[],`workspace`],resourceDetails:{hasWorkspace:!0,localBranchCount:0,remoteBranchCount:0,tmuxSessionCount:d.length,prs:[],hasVbrief:l.state.hasPlan,hasBeads:l.state.hasBeads,dockerContainerCount:0}}),[l.state.hasBeads,l.state.hasPlan,e,n,s.data,d,t]),p=u.data??f,m=(0,R.useMemo)(()=>p.sessions??[],[p.sessions]),h=(0,R.useMemo)(()=>m.filter(e=>e.type===`reviewer`),[m]);return(0,R.useEffect)(()=>{a(m)},[a,m]),(0,z.jsxs)(`aside`,{className:`min-w-0 rounded-[20px] border border-border bg-card/50 p-2`,"aria-label":`Issue tree`,children:[h.length>0?(0,z.jsxs)(`div`,{className:`mb-2 rounded-[var(--radius-sm)] border border-amber-500/40 bg-amber-500/10 px-2.5 py-2 text-[11px]`,role:`alert`,children:[(0,z.jsx)(`div`,{className:`font-semibold text-amber-600 dark:text-amber-400`,children:`⚠ Stale review state`}),(0,z.jsxs)(`div`,{className:`mt-0.5 text-muted-foreground`,children:[h.length,` leftover review agent`,h.length===1?``:`s`,` from a previous cycle (extended-review sub-reviewers). A fresh review can’t run cleanly until they’re cleared.`]}),(0,z.jsx)(`button`,{type:`button`,className:`mt-1.5 rounded-[var(--radius-sm)] border border-destructive/50 px-2 py-1 text-[11px] font-medium text-destructive hover:bg-destructive hover:text-destructive-foreground`,onClick:()=>l.all.find(e=>e.action.key===`purgeReview`)?.invoke(),children:`Complete review reset`})]}):null,(0,z.jsx)(tbt,{issueId:e,sessions:m,feature:p,branch:p.branch||`feature/${e.toLowerCase()}`,selectedSessionId:r,onSelectSession:i,onOpenVerification:o})]})}function Hbt({context:e,issueId:t,selectedSession:n,treeSessions:r,launcher:i,agentDock:a,actionDock:o,timeline:s,onBackToIssue:c,onTab:l,onOpenAgent:u}){let d={issue:{title:t,summary:`Issue overview from the tree. Workspace tabs stay visible above this pane.`}},f=n?(0,z.jsx)(S_t,{session:n,issueId:t,reviewers:r.filter(e=>e.type===`reviewer`)}):e===`issue`?(0,z.jsx)(ext,{issueId:t,onTab:l,onOpenAgent:u}):(0,z.jsx)(txt,{launcher:i,agentDock:a,actionDock:o,timeline:s}),p=n?n.role?`${n.role[0]?.toUpperCase()??``}${n.role.slice(1)} reviewer`:`${n.type[0]?.toUpperCase()??``}${n.type.slice(1)} session`:d[e].title,m=n?`${n.sessionId} · ${n.status}`:d[e].summary;return(0,z.jsxs)(`div`,{className:`space-y-3.5`,"data-testid":`issue-tree-context-panel`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3 rounded-[16px] border border-border bg-card px-4 py-3`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`h2`,{className:`truncate text-[16px] font-semibold text-foreground`,children:p}),(0,z.jsx)(`p`,{className:`mt-1 truncate text-[12px] text-muted-foreground`,children:m})]}),(0,z.jsx)(`button`,{type:`button`,onClick:c,className:`shrink-0 rounded-[var(--radius-sm)] border border-border px-2.5 py-1.5 text-[12px] font-semibold text-foreground hover:bg-accent`,children:`Issue overview`})]}),f]})}function Ubt({checkRuns:e,compact:t=!1}){return e.length===0?(0,z.jsx)(`div`,{className:`text-[12px] text-muted-foreground`,children:`No GitHub check runs reported.`}):(0,z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e.slice(0,t?5:void 0).map(e=>{let t=cY({status:e.status,conclusion:e.conclusion??void 0}),n=(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`grid h-[18px] w-[18px] shrink-0 place-items-center rounded-full text-[10px]`,style:{background:t.bg,color:t.fg},children:t.label===`pass`?`✓`:t.label===`fail`?`✕`:t.label===`skip`?`–`:`•`}),(0,z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[12px] font-medium text-foreground`,children:e.name}),(0,z.jsx)(`span`,{className:`shrink-0 text-[10px] uppercase text-muted-foreground`,children:Obt(e)})]});return e.htmlUrl||e.detailsUrl?(0,z.jsx)(`a`,{href:e.htmlUrl??e.detailsUrl??`#`,target:`_blank`,rel:`noreferrer`,className:`flex items-center gap-2 rounded-[10px] border border-border bg-background/40 px-2.5 py-2 hover:bg-accent`,children:n},e.id||e.name):(0,z.jsx)(`div`,{className:`flex items-center gap-2 rounded-[10px] border border-border bg-background/40 px-2.5 py-2`,children:n},e.id||e.name)}),t&&e.length>5&&(0,z.jsxs)(`div`,{className:`text-[11px] text-muted-foreground`,children:[`+`,e.length-5,` more checks in PR & CI`]})]})}function Wbt({issueId:e}){let t=Ej(e),n=t.data,r=n?.summary,i=r?.failed||r?.cancelled?`destructive`:r?.running||r?.pending?`info`:r?.total?`success`:`muted`;return(0,z.jsxs)(z5,{tone:i,title:`GitHub CI/CD`,right:r?(0,z.jsxs)(B5,{tone:i,children:[r.passed,`/`,r.total,` pass`]}):void 0,children:[t.isLoading?(0,z.jsx)(`div`,{className:`text-[12px] text-muted-foreground`,children:`Loading GitHub checks…`}):null,!t.isLoading&&!n?.pr?(0,z.jsx)(`div`,{className:`text-[12px] text-muted-foreground`,children:`No pull request found for this issue.`}):null,n?.pr&&(0,z.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2 text-[12px] text-muted-foreground`,children:[(0,z.jsxs)(`a`,{href:n.pr.url,target:`_blank`,rel:`noreferrer`,className:`font-semibold text-foreground hover:underline`,children:[`PR #`,n.pr.number]}),(0,z.jsx)(`span`,{children:`·`}),(0,z.jsx)(`span`,{children:n.pr.mergeable??`mergeability unknown`}),(0,z.jsx)(`span`,{children:`·`}),(0,z.jsx)(`code`,{className:`text-[11px]`,children:n.pr.headRefName})]}),n?.error&&(0,z.jsx)(`div`,{className:`mb-3 rounded-[10px] border border-destructive/40 bg-destructive/10 px-3 py-2 text-[12px] text-destructive-foreground`,children:n.error}),(0,z.jsx)(Ubt,{checkRuns:n?.checkRuns??[]}),r&&r.total>0&&(0,z.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2 text-[11px] text-muted-foreground`,children:[(0,z.jsxs)(`span`,{children:[r.failed,` failed`]}),(0,z.jsxs)(`span`,{children:[r.running,` running`]}),(0,z.jsxs)(`span`,{children:[r.pending,` pending`]}),(0,z.jsxs)(`span`,{children:[r.skipped,` skipped`]})]})]})}function Gbt({issueId:e,field:t}){let n=Sj(e,{enabled:!0});return(0,z.jsx)(GY,{body:n.data?.[t],isLoading:n.isLoading,emptyLabel:`No ${t.toUpperCase()} document.`})}function Kbt({issueId:e}){return(0,z.jsxs)(`div`,{className:`grid gap-3 xl:grid-cols-2`,children:[(0,z.jsx)(z5,{tone:`info`,title:`vBRIEF`,children:(0,z.jsx)(uY,{issueId:e})}),(0,z.jsx)(z5,{tone:`muted`,title:`PRD draft`,children:(0,z.jsx)(Gbt,{issueId:e,field:`prd`})}),(0,z.jsx)(z5,{tone:`muted`,title:`STATE`,children:(0,z.jsx)(Gbt,{issueId:e,field:`state`})})]})}function qbt({title:e,description:t,action:n,onOpen:r}){return(0,z.jsxs)(z5,{tone:`muted`,title:e,children:[(0,z.jsx)(`p`,{className:`text-[12px] text-muted-foreground`,children:t}),(0,z.jsx)(`button`,{type:`button`,className:`mt-3 rounded-[var(--radius-sm)] border border-border px-3 py-2 text-[12px] font-semibold hover:bg-accent`,onClick:r,children:n})]})}var Jbt={work:`Work`,strike:`Strike`,review:`Review`,reviewer:`Reviewer`,test:`Test`,ship:`Ship`,merge:`Ship`,planning:`Plan`,legacy:`Plan`},Ybt=new Set([``,`unknown`,`specialist`,`planning`,`idle`,`none`]);function Xbt(e){let t=(e??``).trim();return Ybt.has(t.toLowerCase())?``:t.replace(/^claude-/,``)}var Zbt={info:`bg-info`,success:`bg-success`,warning:`bg-warning`,destructive:`bg-destructive`,review:`bg-signal-review`,cost:`bg-signal-cost`,muted:`bg-muted-foreground`};function Qbt(e,t){let n=t?Jbt[t.type]??t.type:``,r=t?Xbt(t.model):``,i=t?r?`${n.toLowerCase()} · ${r}`:n.toLowerCase():void 0;if(e?.mergeStatus===`merged`)return{tone:`success`,text:`Merged — ready to close out`};if(e?.readyForMerge)return{tone:`success`,text:`Review & tests passed — ready to merge`};if(e?.reviewStatus===`blocked`||e?.reviewStatus===`failed`){let e=t?.type===`work`;return{tone:`destructive`,text:e?`Review blocked — work agent is fixing it`:`Review blocked — awaiting the work agent`,agentType:e?`work`:void 0,agentLabel:e?i:void 0}}return e?.testStatus===`testing`?{tone:`info`,text:`Tests running`}:e?.verificationStatus===`running`?{tone:`info`,text:`Verification running`}:t?{tone:`info`,text:`${n} agent is working`,agentType:t.type,agentLabel:i}:{tone:`muted`,text:`Idle — awaiting the pipeline`}}function $bt({issueId:e,onTab:t,onOpenAgent:n}){let r=wj(e),i=Dj(e),a=Cj(e),o=r.data,s=i.data?.pr,c=a.data?.sections??[],l=c.find(e=>e.status===`running`||e.status===`active`||e.status===`starting`),u=c.some(e=>e.type===`work`),d=Qbt(o,l),f=[...o?.history??[]].sort((e,t)=>new Date(t.timestamp).getTime()-new Date(e.timestamp).getTime()).slice(0,3),p=new Date,m=`rounded-[8px] border border-border px-2.5 py-1 text-[11.5px] text-muted-foreground transition-colors hover:bg-accent`;return(0,z.jsxs)(`div`,{className:`rounded-[16px] border border-border bg-card p-4`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5 text-[13px]`,children:[(0,z.jsx)(`span`,{className:`h-[9px] w-[9px] shrink-0 rounded-full ${Zbt[d.tone]}`}),(0,z.jsx)(`span`,{children:d.text}),d.agentLabel&&(0,z.jsx)(`button`,{type:`button`,onClick:()=>d.agentType&&n(d.agentType),className:`rounded-[6px] border border-info/40 bg-info/10 px-1.5 font-mono text-[11px] text-info-foreground`,children:d.agentLabel})]}),(0,z.jsxs)(`div`,{className:`mt-2.5 text-[12.5px]`,children:[(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`Next:`}),` `,jbt(o),s&&(0,z.jsxs)(z.Fragment,{children:[` · `,(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`diff`}),` `,(0,z.jsxs)(`span`,{className:`text-success-foreground`,children:[`+`,s.additions]}),` `,(0,z.jsxs)(`span`,{className:`text-destructive-foreground`,children:[`−`,s.deletions]}),` · `,s.changedFiles,` file`,s.changedFiles===1?``:`s`]})]}),(0,z.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[u&&(0,z.jsx)(`button`,{type:`button`,className:m,onClick:()=>n(`work`),children:`Open work agent ↗`}),s&&(0,z.jsx)(`button`,{type:`button`,className:m,onClick:()=>t(`code`),children:`Open diff →`}),s?.url&&(0,z.jsx)(`a`,{className:m,href:s.url,target:`_blank`,rel:`noreferrer`,children:`Open PR ↗`})]}),f.length>0&&(0,z.jsxs)(`div`,{className:`mt-3.5`,children:[(0,z.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between text-[10px] uppercase tracking-[0.06em] text-muted-foreground`,children:[(0,z.jsx)(`span`,{children:`Recent activity`}),(0,z.jsx)(`button`,{type:`button`,className:`text-[10px] normal-case tracking-normal text-muted-foreground hover:text-foreground`,onClick:()=>t(`timeline`),children:`→ Timeline`})]}),f.map((e,t)=>(0,z.jsxs)(`div`,{className:`flex items-baseline gap-2.5 py-1 text-[12.5px]`,children:[(0,z.jsx)(`span`,{className:`mt-1.5 h-[7px] w-[7px] shrink-0 rounded-full ${Zbt[Ebt(e.status)]}`}),(0,z.jsxs)(`span`,{className:`capitalize`,children:[e.type,` `,e.status]}),(0,z.jsx)(`span`,{className:`ml-auto text-[10.5px] text-muted-foreground`,children:oM(e.timestamp,p)})]},`${e.type}-${e.timestamp}-${t}`))]})]})}function ext({issueId:e,onTab:t,onOpenAgent:n}){return(0,z.jsxs)(`div`,{className:`space-y-3.5`,children:[(0,z.jsx)(Wyt,{issueId:e}),(0,z.jsx)($bt,{issueId:e,onTab:t,onOpenAgent:n})]})}function txt({launcher:e,agentDock:t,actionDock:n,timeline:r}){return(0,z.jsxs)(`div`,{className:`space-y-3.5`,children:[(0,z.jsx)(z5,{tone:`info`,title:`Launch`,children:e}),(0,z.jsxs)(`div`,{className:`grid gap-3.5 xl:grid-cols-2`,children:[(0,z.jsx)(z5,{tone:`success`,title:`Agents`,children:t}),(0,z.jsx)(z5,{tone:`muted`,title:`Quick tools`,children:n})]}),(0,z.jsx)(z5,{tone:`warning`,title:`Conversation timeline`,children:r})]})}function nxt(e,t){return e===`code`&&t?.summary.total?{label:t.summary.failed?`!`:t.summary.running||t.summary.pending?`…`:`✓`,tone:t.summary.failed?`destructive`:t.summary.running||t.summary.pending?`info`:`success`}:null}function rxt({issueId:e,title:t,branch:n,projectName:r,launcher:i,agentDock:a,actionDock:o,timeline:s,onOpenPane:c}){let[l,u]=(0,R.useState)(`overview`),[d,f]=(0,R.useState)(null),[p,m]=(0,R.useState)(null),[h,g]=(0,R.useState)([]),_=wj(e),v=Dj(e),y=Ej(e),b=Tj(e),x=kbt(_.data),S=b.data?.resolvedTotalCost??b.data?.totalCost??0,C=e=>{u(e),f(null),m(null)},w=()=>{f(`issue`),m(null),u(null)},T=e=>{m(e),f(null),u(null)},E=e=>{let t=h.find(t=>t.type===e);return t?(T(t),!0):!1},D=e=>{if(e===`work`){E(`work`)||C(`overview`);return}if(e===`review`){E(`review`)||C(`overview`);return}if(e===`test`){E(`test`)||C(`overview`);return}if(e===`plan`){C(`plan`);return}if(e===`ci`){C(`code`);return}C(`overview`)},O=(0,R.useCallback)(e=>{g(e),m(t=>t&&(e.find(e=>e.sessionId===t.sessionId)??t))},[]);return(0,z.jsxs)(`div`,{className:H5.missionWrap,children:[(0,z.jsxs)(`header`,{className:`rounded-[22px] border border-border bg-card p-4`,children:[(0,z.jsxs)(`div`,{className:H5.headerTop,children:[(0,z.jsxs)(`div`,{className:H5.headerTitle,children:[(0,z.jsxs)(`div`,{className:`text-[11px] text-muted-foreground/70`,children:[r?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:r}),` / `]}):null,`Issues`]}),(0,z.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`font-mono text-[13px] font-medium text-foreground`,children:e}),(0,z.jsx)(`h1`,{className:`min-w-0 max-w-full break-words text-[16px] font-medium leading-snug text-foreground`,children:t}),(0,z.jsx)(B5,{tone:Ebt(x),children:x})]})]}),(0,z.jsxs)(`div`,{className:H5.headerMeta,children:[(0,z.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,z.jsx)(U5,{label:`Branch`,value:(0,z.jsx)(`span`,{className:`font-mono`,children:n})}),(0,z.jsx)(U5,{label:`PR / CI`,value:v.data?.pr?`#${v.data.pr.number}${y.data?.summary.total?` · ${y.data.summary.passed}/${y.data.summary.total}`:``}`:`no PR`}),(0,z.jsx)(U5,{label:`Cost`,value:(0,z.jsx)(`span`,{className:`text-signal-cost-foreground tabular-nums`,children:S>0?`$${S.toFixed(2)}`:`—`})})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(Pbt,{issueId:e,rs:_.data}),(0,z.jsx)(Lbt,{issueId:e})]})]})]}),(0,z.jsx)(`div`,{className:`mt-4 border-t border-border pt-4`,children:(0,z.jsx)(Fbt,{issueId:e,onPhase:D})}),(0,z.jsx)(`div`,{className:`mt-3`,children:(0,z.jsx)(Ibt,{issueId:e})})]}),(0,z.jsxs)(`div`,{className:H5.missionBody,children:[(0,z.jsx)(Vbt,{issueId:e,title:t,projectName:r,selectedSessionId:p?.sessionId??null,onSelectSession:T,onSessionsChange:O,onOpenVerification:()=>C(`overview`)}),(0,z.jsxs)(`main`,{className:`min-w-0 rounded-[20px] border border-border bg-card/30`,children:[(0,z.jsx)(`nav`,{className:`flex flex-wrap gap-1 border-b border-border bg-card px-3 pt-2`,"aria-label":`Issue cockpit tabs`,children:bbt.map(e=>{let t=nxt(e.id,y.data);return(0,z.jsxs)(`button`,{type:`button`,"aria-selected":l===e.id,onClick:()=>C(e.id),className:`relative top-px flex shrink-0 items-center gap-1.5 rounded-t-[10px] border px-3 py-2 text-[12px] font-semibold transition-colors ${l===e.id?`border-border border-b-card bg-card text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`}`,children:[e.label,t&&(0,z.jsx)(B5,{tone:t.tone,className:`px-[5px] py-0 text-[9px]`,children:t.label})]},e.id)})}),(0,z.jsxs)(`div`,{className:`p-4`,children:[(d||p)&&(0,z.jsx)(Hbt,{context:d??`issue`,issueId:e,selectedSession:p,treeSessions:h,launcher:i,agentDock:a,actionDock:o,timeline:s,onBackToIssue:w,onTab:C,onOpenAgent:E}),l===`overview`&&(0,z.jsx)(ext,{issueId:e,onTab:C,onOpenAgent:E}),l===`code`&&(0,z.jsxs)(`div`,{className:`space-y-3.5`,children:[(0,z.jsx)(Wbt,{issueId:e}),(0,z.jsx)(mbt,{issueId:e})]}),l===`plan`&&(0,z.jsx)(Kbt,{issueId:e}),l===`timeline`&&(0,z.jsxs)(`div`,{className:`space-y-4`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{className:`mb-2 text-[11px] font-medium uppercase tracking-[0.06em] text-muted-foreground`,children:`Status history`}),(0,z.jsx)(ybt,{issueId:e})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{className:`mb-2 text-[11px] font-medium uppercase tracking-[0.06em] text-muted-foreground`,children:`Activity`}),(0,z.jsx)(Dyt,{issueId:e})]})]}),l===`discussion`&&(0,z.jsx)(Iyt,{issueId:e}),l===`costs`&&(0,z.jsx)(jyt,{issueId:e}),l===`artifacts`&&(0,z.jsx)(Hyt,{issueId:e}),l===`conversation`&&(0,z.jsx)(txt,{launcher:i,agentDock:a,actionDock:o,timeline:s}),l===`files`&&(0,z.jsx)(qbt,{title:`Files`,description:`Open the issue-scoped workspace file browser in a deck pane.`,action:`Open files pane`,onOpen:()=>c(`files`)}),l===`terminal`&&(0,z.jsx)(qbt,{title:`Terminal`,description:`Open the issue terminal drawer for the current workspace.`,action:`Open terminal`,onOpen:()=>c(`terminal`)}),l===`beads`&&(0,z.jsx)(dY,{issueId:e})]})]}),(0,z.jsx)(obt,{issueId:e,onOpenFull:()=>C(`beads`)})]})]})}function ixt({issueId:e,title:t,branch:n,projectName:r,agentId:i,conversations:a=[],onCreateConversation:o,api:s}){let c=(0,R.useMemo)(()=>a.filter(t=>(t.issueId??``).toUpperCase()===e.toUpperCase()),[a,e]),l=(0,R.useMemo)(()=>c.map(e=>({id:e.name,agentLabel:e.title??e.model??`Agent`,timestamp:e.lastAttachedAt??e.createdAt,preview:e.title??void 0})),[c]),u=async(t,n)=>{l5(e,t);let r=await o?.(t,n,`terminal`);r&&s.openOrFocusAgentPane(r,`Agent`)},d=()=>s.toggleTerminal(),f={files:`Files`,commits:`Commits`,plan:`Plan`,docs:`Docs`},p=t=>{if(t===`terminal`)return s.toggleTerminal();if(t===`browser`)return s.openPane({paneType:`browser`,label:`Web`});s.openPane({paneType:t,label:f[t]??`Pane`,issueId:e,agentId:i})},m=(0,z.jsx)(X_t,{lastUsedAgentId:K_t(e),onSelect:(t,n)=>cvt(t,n,{openAgent:(e,t)=>u(e.id,t),openTerminal:d,openWeb:(e,t)=>s.openPane({paneType:`browser`,label:`Web`,browserInitialUrl:t}),onAgentRun:t=>l5(e,t)})}),h=(0,z.jsx)(p5,{conversations:l,onOpen:e=>{let t=c.find(t=>t.name===e);s.openOrFocusAgentPane(e,t?.title??`Agent`)}});return(0,z.jsx)(rxt,{issueId:e,title:t,branch:n??`feature/${e.toLowerCase()}`,projectName:r,launcher:m,agentDock:(0,z.jsx)(u5,{onSelectAgent:u}),actionDock:(0,z.jsx)(d5,{onOpen:p}),timeline:h,onOpenPane:p})}function axt(e,t){let n=e instanceof Date?e:new Date(e),r=t.getTime()-n.getTime();if(r<=3e5)return`Just Now`;if(sxt(n,t))return cxt(n);let i=new Date(t);return i.setDate(t.getDate()-1),sxt(n,i)?`Yesterday ${lxt(n)} · ${cxt(n)}`:r>=0&&r<=10080*60*1e3?`${uxt(n)} ${lxt(n)}`:n.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,...n.getFullYear()===t.getFullYear()?{}:{year:`numeric`}})}function oxt(e,t){let n=[];for(let r of e){let e=t(r),i=n.at(-1);i?.label===e?i.items.push(r):n.push({label:e,items:[r]})}return n}function sxt(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function cxt(e){return e.toLocaleTimeString(`en-US`,{hour:`numeric`})}function lxt(e){return e.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`})}function uxt(e){return e.toLocaleDateString(`en-US`,{weekday:`long`})}function dxt({entry:e,onSelect:t,now:n=new Date}){let r=[e.workspaceId,e.issueId].filter(Boolean),i=r.length>0?r.join(` · `):e.summary;return(0,z.jsx)(`button`,{type:`button`,className:`w-full rounded-lg border border-border bg-card p-2.5 text-left text-xs transition-colors hover:bg-accent/40 focus:outline-none focus:ring-2 focus:ring-ring`,onClick:()=>t(e.id),title:e.headline,children:(0,z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,z.jsx)(`span`,{className:`mt-1.5 h-1.5 w-1.5 shrink-0 rounded-full bg-primary`}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`p`,{className:`break-words font-medium text-foreground`,children:e.headline}),(0,z.jsxs)(`div`,{className:`mt-1 flex min-w-0 items-center justify-between gap-2 text-[10px] text-muted-foreground`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[e.statusLabel?(0,z.jsx)(C5,{status:e.statusLabel}):null,(0,z.jsx)(`span`,{className:`truncate`,children:i}),(0,z.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:`·`}),(0,z.jsx)(`time`,{dateTime:e.timestamp,className:`shrink-0`,children:oM(e.timestamp,n)})]}),(0,z.jsx)(PM,{kind:e.activityClass??`operational`,className:`shrink-0`})]})]})]})})}var fxt={active:`bg-info`,waiting:`bg-warning`,idle:`bg-muted-foreground/60`},pxt={claude_code:`Claude Code`,pi:`Pi`,unknown:`Unknown`};function mxt({entry:e,onSelect:t,now:n=new Date}){let r=gxt(e),i=pxt[e.agent]??e.agent;return(0,z.jsx)(`button`,{type:`button`,className:`w-full rounded-lg border border-border bg-card p-2.5 text-left text-xs transition-colors hover:bg-accent/40 focus:outline-none focus:ring-2 focus:ring-ring`,onClick:()=>t(e.id),children:(0,z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,z.jsx)(`span`,{"data-testid":`conversation-feed-agent-icon`,className:`mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center`,children:(0,z.jsx)(hE,{harness:hxt(e.agent),className:`h-4 w-4`})}),(0,z.jsx)(`span`,{className:`mt-2 h-1.5 w-1.5 shrink-0 rounded-full ${fxt[r]}`}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`max-w-[120px] truncate font-medium text-foreground`,children:i}),(0,z.jsx)(`time`,{dateTime:e.lastMessageDate,className:`shrink-0 text-[10px] text-muted-foreground`,children:oM(e.lastMessageDate,n)})]}),(0,z.jsx)(`p`,{className:`mt-1 line-clamp-2 text-muted-foreground`,children:e.lastMessageSnippet}),(e.messageCount!==void 0||e.threadLabel&&e.threadIsPrimary===!1)&&(0,z.jsxs)(`div`,{className:`mt-2 flex items-center gap-2 text-[10px] text-muted-foreground`,children:[e.messageCount!==void 0&&(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,z.jsx)(sr,{className:`h-3 w-3`,"aria-hidden":`true`}),e.messageCount]}),e.threadLabel&&e.threadIsPrimary===!1&&(0,z.jsx)(`span`,{className:`rounded-full bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground`,children:e.threadLabel})]})]})]})})}function hxt(e){return e===`ohmypi`||e===`pi`?`ohmypi`:e===`codex`?`codex`:`claude-code`}function gxt(e){let t=e.agentState;return t===`active`||t===`waiting`||t===`idle`?t:`idle`}function _xt({entry:e,onSelect:t,now:n=new Date}){return(0,z.jsx)(`button`,{type:`button`,className:`w-full rounded-lg border border-border bg-card p-2.5 text-left text-xs transition-colors hover:bg-accent/40 focus:outline-none focus:ring-2 focus:ring-ring`,onClick:()=>t(e.id),children:(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,z.jsx)(vxt(e.source),{"data-testid":`git-feed-icon`,className:`h-4 w-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,z.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-foreground`,children:e.message}),e.issueId&&(0,z.jsx)(`span`,{className:`shrink-0 rounded-full bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground`,children:e.issueId}),(0,z.jsx)(`time`,{dateTime:e.timestamp,className:`shrink-0 text-[10px] text-muted-foreground`,children:oM(e.timestamp,n)})]})})}function vxt(e){return e.toLowerCase().includes(`branch`)?Hn:Un}function yxt({label:e,items:t,onSelect:n,now:r}){return(0,z.jsxs)(`section`,{className:`space-y-2`,children:[(0,z.jsx)(`h3`,{className:`px-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:e}),(0,z.jsx)(`div`,{className:`space-y-2`,children:t.map(e=>bxt(e,n,r))})]})}function bxt(e,t,n){let r=()=>t(e);switch(e.kind){case`conversation`:return(0,z.jsx)(mxt,{entry:e,onSelect:r,now:n},e.id);case`activity`:return(0,z.jsx)(dxt,{entry:e,onSelect:r,now:n},e.id);case`git`:return(0,z.jsx)(_xt,{entry:e,onSelect:r,now:n},e.id);case`file_change`:case`comment`:case`placeholder`:return null}}var xxt=new Set([`dashboard`,`supervisor`,`deploy-script`]);function Sxt(){let e,t;return n=>{let r=n.recentActivity;if(r===e&&t)return t;e=r,t=r.map(e=>{let t=typeof e.id==`string`?e.id:null,n=typeof e.timestamp==`string`?e.timestamp:null;if(!t||!n)return null;let r=typeof e.message==`string`?e.message:``,i=typeof e.source==`string`?e.source:`unknown`,a=typeof e.level==`string`?e.level:``,o=typeof e.details==`string`?e.details:void 0,s=typeof e.issueId==`string`?e.issueId:null,c=typeof e.link==`string`?e.link:void 0;return{kind:`activity`,activityClass:`operational`,id:t,timestamp:n,workspaceId:null,issueId:s,headline:r||i,summary:i,narrative:o,files:[],tags:a?[i,a]:[i],link:c,systemWide:xxt.has(i)}}).filter(e=>e!==null).sort((e,t)=>t.timestamp.localeCompare(e.timestamp));let i=new Set;return t=t.filter(e=>{if(e.issueId&&e.headline.startsWith(`Review role spawned`)){if(i.has(e.issueId))return!1;i.add(e.issueId)}return!0}).slice(0,500),t}}var Cxt=Sxt();function wxt(){return sm(Cxt)}async function Txt(){let e=await fJ(`/api/conversations`);if(!e.ok)throw Error(`Failed to fetch conversations`);return e.json()}function Ext(e){let t=e.lastActivityAt??e.lastAttachedAt??e.createdAt;return{kind:`conversation`,id:`conversation:${e.name}`,timestamp:t,workspaceId:e.cwd??null,issueId:e.issueId,conversationId:e.id,conversationName:e.name,agent:kxt(e.harness),lastMessageDate:t,lastMessageSnippet:e.title??`No messages yet`,...e.messageCount===void 0?{}:{messageCount:e.messageCount}}}function Dxt(e){return e.filter(e=>e.archivedAt==null).map(Ext)}function Oxt(){let e=B({queryKey:[`conversations`],queryFn:Txt,refetchInterval:3e4,staleTime:5e3}),t=e.data??[];return{entries:(0,R.useMemo)(()=>Dxt(t),[t]),isLoading:e.isLoading,error:e.error instanceof Error?e.error:null}}function kxt(e){return e===`claude-code`?`claude_code`:e===`ohmypi`?`pi`:e===`codex`?`codex`:`unknown`}async function Axt(){try{let e=await fetch(`/api/git-activity`);return e.ok?{entries:await e.json(),error:null}:{entries:[],error:Error(`Failed to fetch git activity`)}}catch(e){return{entries:[],error:e instanceof Error?e:Error(String(e))}}}function jxt(e){return{kind:`git`,id:e.id,timestamp:e.timestamp,workspaceId:null,issueId:e.issueId??null,source:e.source,level:e.level,message:e.message,details:e.details,category:e.category,triggeringEvent:e.triggeringEvent}}function Mxt(){let e=B({queryKey:[`session-feed-git`],queryFn:Axt,refetchInterval:15e3,staleTime:5e3}),t=e.data?.entries??[];return{entries:(0,R.useMemo)(()=>t.map(jxt),[t]),isLoading:e.isLoading,error:e.data?.error??(e.error instanceof Error?e.error:null)}}function Nxt(){let e,t;return n=>{let r=n.observationsByIssueId;return r===e&&t?t:(e=r,t=Object.values(r).flatMap(e=>e).filter(e=>e.actionStatus!==null).sort((e,t)=>t.timestamp.localeCompare(e.timestamp)).slice(0,500).map(e=>({kind:`activity`,activityClass:`memory`,id:e.id,timestamp:e.timestamp,workspaceId:e.workspaceId,issueId:e.issueId,headline:e.summary,statusLabel:e.actionStatus,summary:e.summary,narrative:e.narrative,files:e.files,tags:e.tags})),t)}}var Pxt=Nxt();function Fxt(){return sm(Pxt)}function Ixt(...e){let t=new Map;for(let n of e)for(let e of n)t.has(e.id)||t.set(e.id,e);return[...t.values()].sort((e,t)=>t.timestamp.localeCompare(e.timestamp))}function Lxt(e,t){switch(t){case`all`:return[...e];case`chats`:return e.filter(e=>e.kind===`conversation`);case`activity`:return e.filter(e=>e.kind===`activity`);case`git`:return e.filter(e=>e.kind===`git`);case`files`:case`comments`:return[]}}function Rxt(e){let t=Oxt(),n=Fxt(),r=wxt(),i=Mxt(),a=(0,R.useMemo)(()=>Ixt(t.entries,r,n,i.entries),[t.entries,r,n,i.entries]);return{entries:(0,R.useMemo)(()=>Lxt(a,e),[a,e]),allEntries:a,isLoading:t.isLoading||i.isLoading,error:t.error??i.error}}function zxt(e,t){if(e.has(t))return e;let n=new Set(e);return n.add(t),n}function Bxt(e,t){if(!e.has(t))return e;let n=new Set(e);return n.delete(t),n}function Vxt(e,t){let n=!1,r=new Set;for(let i of e)t.has(i)?r.add(i):n=!0;return n?r:e}var W5=ri(e=>({reopenId:null,reopenNonce:0,requestReopen:t=>e(e=>({reopenId:t,reopenNonce:e.reopenNonce+1})),answeredToolUseIds:new Set,dismissedSubjectIds:new Set,markAnswered:t=>e(e=>({answeredToolUseIds:zxt(e.answeredToolUseIds,t)})),unmarkAnswered:t=>e(e=>({answeredToolUseIds:Bxt(e.answeredToolUseIds,t)})),markDismissed:t=>e(e=>({dismissedSubjectIds:zxt(e.dismissedSubjectIds,t)})),undismiss:t=>e(e=>({dismissedSubjectIds:Bxt(e.dismissedSubjectIds,t)})),reconcileAnswered:t=>e(e=>({answeredToolUseIds:Vxt(e.answeredToolUseIds,t)})),reconcileDismissed:t=>e(e=>({dismissedSubjectIds:Vxt(e.dismissedSubjectIds,t)}))})),Hxt=`overdeck.ui.sessionFeedSidebarTab`,Uxt=`overdeck.ui.awarenessScope`,Wxt=[{id:`all`,label:`All`},{id:`chats`,label:`Chats`},{id:`files`,label:`Files`},{id:`git`,label:`Git`},{id:`comments`,label:`Comments`},{id:`activity`,label:`Activity`}],Gxt={all:`No session activity yet.`,chats:`No chats yet.`,files:`Files feed coming soon.`,git:`No git activity yet.`,comments:`Comments feed coming soon.`,activity:`No activity updates yet.`},Kxt=!1;function qxt({onClose:e,onSelect:t=tSt,now:n=new Date,issueIds:r,unscoped:i,heading:a=`Activity Feed`,embedded:o=!1,scopeSwitcher:s=!1,projectIssueIds:c}){let[l,u]=(0,R.useState)(Qxt),[d,f]=(0,R.useState)($xt);(0,R.useEffect)(()=>{typeof window>`u`||window.localStorage.setItem(Hxt,l)},[l]),(0,R.useEffect)(()=>{typeof window>`u`||window.localStorage.setItem(Uxt,d)},[d]);let p=sm(dm),m=s?p.length:0,h=s?d===`project`?c:void 0:r,g=s?!1:i,_=!s||d!==`needs`;return(0,z.jsxs)(`aside`,{className:`flex h-full min-h-0 flex-col bg-background ${o?`w-full`:`w-80 shrink-0 border-l border-border`}`,"aria-label":`Session activity feed`,children:[(0,z.jsxs)(`header`,{className:`flex items-center justify-between border-b border-border px-3 py-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-foreground`,children:[(0,z.jsx)(Xn,{className:`h-4 w-4`,"aria-hidden":`true`}),a]}),e&&(0,z.jsx)(`button`,{type:`button`,className:`rounded p-1 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus:outline-none focus:ring-2 focus:ring-ring`,"aria-label":`Close activity feed`,onClick:e,children:(0,z.jsx)(zr,{className:`h-4 w-4`,"aria-hidden":`true`})})]}),s&&(0,z.jsx)(`div`,{role:`tablist`,"aria-label":`Awareness scope`,className:`grid grid-cols-3 gap-1 border-b border-border p-2`,children:[{id:`needs`,label:`Needs you`,badge:m},{id:`project`,label:`Project`,badge:0},{id:`global`,label:`Global`,badge:0}].map(e=>(0,z.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":d===e.id,className:d===e.id?`flex items-center justify-center gap-1.5 rounded-md bg-accent px-2 py-1 text-xs font-medium text-foreground`:`flex items-center justify-center gap-1.5 rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-accent/60 hover:text-foreground`,onClick:()=>f(e.id),children:[e.label,e.badge>0&&(0,z.jsx)(`span`,{className:`rounded bg-amber-500/20 px-1 text-[10px] font-semibold text-amber-600 dark:text-amber-400`,children:e.badge})]},e.id))}),(0,z.jsx)(Jxt,{issueIds:h,unscoped:g,showEmpty:s&&d===`needs`}),_&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{role:`tablist`,"aria-label":`Session feed tabs`,className:`grid grid-cols-3 gap-1 border-b border-border p-2`,children:Wxt.map(e=>(0,z.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":l===e.id,className:l===e.id?`rounded-md bg-accent px-2 py-1 text-xs font-medium text-foreground`:`rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-accent/60 hover:text-foreground`,onClick:()=>u(e.id),children:e.label},e.id))}),(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-3`,children:Zxt(l)?(0,z.jsx)(Xxt,{tab:l}):(0,z.jsx)(Yxt,{tab:l,onSelect:t,now:n,issueIds:h,unscoped:g})})]})]})}function Jxt({issueIds:e,unscoped:t,showEmpty:n=!1}){let r=sm(dm),i=sm(fm),a=W5(e=>e.requestReopen),o=W5(e=>e.answeredToolUseIds),s=W5(e=>e.dismissedSubjectIds),c=(0,R.useMemo)(()=>{let e=new Map;for(let t of i)t?.id&&t.title&&e.set(t.id,t.title);return e},[i]),l=(0,R.useMemo)(()=>{if(t||!e||e.length===0)return r;let n=new Set(e.map(e=>e.toLowerCase()));return r.filter(e=>e.issueId&&n.has(e.issueId.toLowerCase()))},[r,e,t]),u=(0,R.useMemo)(()=>{let e=new Set,t=[];for(let n of l){let r=n.pendingAskUserQuestion?.toolUseId;if(r&&o.has(r)||s.has(n.agentId))continue;let i=n.pendingAskUserQuestion,a=i?.questions?.length??0,l=i?.questions?.[0]?.question??tM(n.kinds),u=n.issueId&&c.get(n.issueId)||n.issueId||n.agentId,d=r??`${n.issueId??n.agentId}::${u}::${l}`;e.has(d)||(e.add(d),t.push({key:d,agentId:n.agentId,label:u,detail:l,count:a,title:tM(n.kinds)}))}return t},[l,o,s,c]);return l.length===0?n?(0,z.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-6 text-center text-xs text-muted-foreground`,children:`Nothing needs you right now.`}):null:(0,z.jsxs)(`div`,{className:`border-b border-amber-500/30 bg-amber-500/5 px-2 py-2`,children:[(0,z.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 px-1 text-xs font-semibold uppercase tracking-wide text-amber-600 dark:text-amber-400`,children:[(0,z.jsx)(Ir,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),`Needs you`]}),(0,z.jsx)(`div`,{className:`flex flex-col gap-1`,children:(0,z.jsx)(GH,{initial:!1,children:u.map(e=>(0,z.jsxs)(cJ.button,{layout:!0,initial:{opacity:0,height:0,y:-4},animate:{opacity:1,height:`auto`,y:0},exit:{opacity:0,height:0,y:-4},transition:{duration:.18,ease:`easeOut`},type:`button`,onClick:()=>a(e.agentId),className:`flex w-full flex-col items-start gap-0.5 overflow-hidden rounded border border-amber-500/30 bg-background px-2 py-1.5 text-left transition-colors hover:border-amber-500/60 hover:bg-amber-500/10`,title:e.title,children:[(0,z.jsxs)(`span`,{className:`text-xs font-medium text-foreground`,children:[e.label,e.count>1?` · ${e.count} questions`:``]}),(0,z.jsx)(`span`,{className:`w-full truncate text-xs text-muted-foreground`,children:e.detail})]},e.key))})})]})}function Yxt({tab:e,onSelect:t,now:n,issueIds:r,unscoped:i}){let a=Rxt(e),o=(0,R.useMemo)(()=>r?new Set(r.map(e=>e.toLowerCase())):null,[r]),s=(0,R.useMemo)(()=>{let e=e=>e.kind===`activity`&&e.systemWide?!0:i?e.issueId==null:!o||!!e.issueId&&o.has(e.issueId.toLowerCase());return{entries:i||o?a.entries.filter(e):a.entries,allEntries:i||o?a.allEntries.filter(e):a.allEntries}},[a.entries,a.allEntries,o,i]),c=s.entries,l=s.allEntries,u=(0,R.useMemo)(()=>oxt(c,e=>axt(e.timestamp,n)),[c,n]),d=e===`all`?l.length===0:c.length===0;return a.error?(0,z.jsx)(`p`,{className:`text-xs text-destructive`,children:a.error.message}):a.isLoading?(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Loading activity…`}):d?(0,z.jsx)(`div`,{"data-testid":`session-feed-empty-${e}`,className:`rounded-lg border border-dashed border-border p-4 text-center text-xs text-muted-foreground`,children:Gxt[e]}):(0,z.jsx)(`div`,{className:`space-y-4`,children:u.map(e=>(0,z.jsx)(yxt,{label:e.label,items:e.items,onSelect:t,now:n},`${e.label}-${e.items[0]?.id??`empty`}`))})}function Xxt({tab:e}){let t=e===`files`?`Aggregate file changes are not wired into the session feed yet.`:`Issue comments are not cached for the session feed yet.`;return(0,z.jsxs)(`div`,{"data-testid":`session-feed-empty-${e}`,className:`rounded-lg border border-dashed border-border p-4 text-center text-xs text-muted-foreground`,children:[(0,z.jsx)(`p`,{className:`font-medium text-foreground`,children:Gxt[e]}),(0,z.jsx)(`p`,{className:`mt-1`,children:t})]})}function Zxt(e){return e===`files`||e===`comments`}function Qxt(){if(typeof window>`u`)return`all`;let e=window.localStorage.getItem(Hxt);return eSt(e)?e:`all`}function $xt(){if(typeof window>`u`)return`project`;let e=window.localStorage.getItem(Uxt);return e===`needs`||e===`project`||e===`global`?e:`project`}function eSt(e){return e===`all`||e===`chats`||e===`files`||e===`git`||e===`comments`||e===`activity`}function tSt(e){if(!(typeof window>`u`))switch(e.kind){case`conversation`:G5(`/conv/${encodeURIComponent(e.conversationName)}`);return;case`activity`:if(e.link){G5(e.link);return}e.issueId&&G5(`/command-deck?issue=${encodeURIComponent(e.issueId)}&tab=activity`);return;case`git`:Kxt||=(console.debug(`Session feed git entries do not have a destination yet.`),!0);return;case`file_change`:case`comment`:case`placeholder`:return}}function G5(e){window.history.pushState(null,``,e),window.dispatchEvent(new PopStateEvent(`popstate`))}var nSt=`__no-project__`,rSt=`No project`;function iSt(e,t){let n=e.cwd;return n?!t.some(e=>e.path&&(n===e.path||n.startsWith(e.path+`/`))):!0}function aSt(e){let t=new Map;for(let n of e){let e=t.get(n.projectName);if(e){e.features.push(n);continue}t.set(n.projectName,{name:n.projectName,path:n.projectName,features:[n]})}return[...t.values()].map(e=>({...e,features:[...e.features].sort((e,t)=>e.issueId.localeCompare(t.issueId))})).sort((e,t)=>e.name.localeCompare(t.name))}async function K5(){let[e,t]=await Promise.all([fetch(`/api/issues/resource-allocated`),fetch(`/api/registered-projects`)]);if(!e.ok)throw Error(`Failed to fetch resource-allocated issues`);if(!t.ok)throw Error(`Failed to fetch registered projects`);let n=await e.json(),r=await t.json(),i=new Map(aSt(n).map(e=>[e.name,e]));for(let e of r){let t=e.name??e.key;i.has(t)||i.set(t,{name:t,path:e.path,features:[]})}return[...i.values()].sort((e,t)=>e.name.localeCompare(t.name))}function oSt({issueId:e,isOpen:t,onClose:n}){let{data:r,isLoading:i,isFetching:a,error:o}=B({queryKey:[`beads`,e],queryFn:async()=>{let t=await fetch(`/api/issues/${e}/beads`);if(!t.ok)throw Error(`Failed to fetch tasks`);return t.json()},enabled:t,staleTime:0,refetchOnMount:`always`});if(!t)return null;let s=r?.tasks?.filter(e=>e.status!==`closed`)||[],c=r?.tasks?.filter(e=>e.status===`closed`)||[];return(0,z.jsxs)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center`,children:[(0,z.jsx)(`div`,{className:`absolute inset-0 bg-black/70 backdrop-blur-sm`,onClick:n}),(0,z.jsxs)(`div`,{className:`relative bg-card rounded-xl shadow-2xl w-full max-w-lg mx-4 max-h-[70vh] overflow-hidden flex flex-col`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b border-border`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(ir,{className:`w-5 h-5 text-success`}),(0,z.jsxs)(`h2`,{className:`font-semibold text-foreground`,children:[`Tasks: `,e]})]}),(0,z.jsx)(`button`,{onClick:n,className:`p-1 text-muted-foreground hover:text-foreground hover:bg-popover rounded transition-colors`,children:(0,z.jsx)(zr,{className:`w-5 h-5`})})]}),(0,z.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4`,children:[(i||a)&&!r?.tasks?.length&&(0,z.jsxs)(`div`,{className:`space-y-2`,children:[[1,2,3].map(e=>(0,z.jsxs)(`div`,{className:`flex items-start gap-3 p-3 rounded-lg border border-border bg-popover/30 animate-pulse`,children:[(0,z.jsx)(`div`,{className:`w-4 h-4 bg-card rounded-full mt-0.5`}),(0,z.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,z.jsx)(`div`,{className:`h-4 bg-card rounded w-3/4`}),(0,z.jsx)(`div`,{className:`h-3 bg-popover rounded w-1/4`})]})]},e)),(0,z.jsxs)(`div`,{className:`flex items-center justify-center py-2 text-muted-foreground text-sm`,children:[(0,z.jsx)(ar,{className:`w-4 h-4 animate-spin mr-2`}),`Loading tasks from workspace...`]})]}),o&&(0,z.jsx)(`div`,{className:`text-destructive text-center py-8`,children:`Failed to load tasks`}),r&&r.tasks?.length===0&&!a&&(0,z.jsxs)(`div`,{className:`text-muted-foreground text-center py-8`,children:[(0,z.jsx)(ir,{className:`w-8 h-8 mx-auto mb-2 opacity-50`}),(0,z.jsx)(`p`,{children:`No tasks created yet`}),(0,z.jsx)(`p`,{className:`text-xs mt-2`,children:`Tasks will appear here once created using beads.`})]}),r&&r.tasks?.length>0&&(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-4 text-xs text-muted-foreground mb-3 pb-3 border-b border-border`,children:[(0,z.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,z.jsx)(`div`,{className:`w-2 h-2 bg-primary rounded-full`}),s.length,` open`]}),(0,z.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,z.jsx)(on,{className:`w-3 h-3 text-success`}),c.length,` closed`]})]}),s.map(e=>(0,z.jsx)(sSt,{task:e},e.id)),c.length>0&&s.length>0&&(0,z.jsx)(`div`,{className:`text-xs text-muted-foreground mt-4 mb-2`,children:`Completed`}),c.map(e=>(0,z.jsx)(sSt,{task:e},e.id))]})]}),(0,z.jsxs)(`div`,{className:`px-4 py-3 border-t border-border text-xs text-muted-foreground flex items-center justify-between`,children:[(0,z.jsxs)(`span`,{children:[r?.count||0,` task`,r?.count===1?``:`s`]}),(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`Beads`})]})]})]})}function sSt({task:e}){let t={open:`bg-popover/50 border-border`,in_progress:`badge-bg-primary border-primary/40`,closed:`badge-bg-success border-success/30 opacity-60`},n={open:(0,z.jsx)(`div`,{className:`w-4 h-4 border-2 border-border rounded-full`}),in_progress:(0,z.jsx)(ar,{className:`w-4 h-4 text-primary animate-spin`}),closed:(0,z.jsx)(on,{className:`w-4 h-4 text-success`})};return(0,z.jsxs)(`div`,{className:`flex items-start gap-3 p-3 rounded-lg border ${t[e.status]}`,children:[(0,z.jsx)(`div`,{className:`mt-0.5`,children:n[e.status]}),(0,z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,z.jsx)(`div`,{className:`text-sm text-foreground`,children:e.title}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2 mt-1 flex-wrap`,children:[(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.id}),e.blockedBy.length>0&&(0,z.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-warning`,children:[(0,z.jsx)(hn,{className:`w-3 h-3`}),`Blocked`]}),e.labels.filter(e=>e.startsWith(`difficulty:`)).map(e=>(0,z.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded ${e.includes(`simple`)||e.includes(`trivial`)?`badge-bg-success text-success`:e.includes(`medium`)?`badge-bg-warning text-warning`:e.includes(`complex`)||e.includes(`hard`)?`badge-bg-destructive text-destructive`:`bg-popover text-foreground`}`,children:e.replace(`difficulty:`,``)},e))]})]})]})}var cSt={selectedSessionByIssue:{},draftTexts:{}},lSt=ri(e=>({...cSt,selectSession:(t,n)=>e(e=>({selectedSessionByIssue:{...e.selectedSessionByIssue,[t]:n}})),clearIssue:t=>e(e=>{if(!(t in e.selectedSessionByIssue))return e;let{[t]:n,...r}=e.selectedSessionByIssue;return{selectedSessionByIssue:r}}),clearAll:()=>e({selectedSessionByIssue:{}}),setDraft:(t,n)=>e(e=>({draftTexts:{...e.draftTexts,[t]:n}})),clearDraft:t=>e(e=>{if(!(t in e.draftTexts))return e;let{[t]:n,...r}=e.draftTexts;return{draftTexts:r}})})),uSt=new Set([`review`,`reviewer`]),dSt=new Set([`test`,`ship`,`merge`]);function fSt(e){if(!e.sessionType||e.sessionType===`work`)return null;if(uSt.has(e.sessionType)){if(!e.projectKey)throw Error(`Cannot find project for ${e.issueId}`);return{endpoint:`/api/specialists/${encodeURIComponent(e.projectKey)}/${encodeURIComponent(e.issueId)}/review/restart`,body:{...e.model?{model:e.model}:{},...e.harness?{harness:e.harness}:{}},successMessage:`Review restarted`,errorMessage:`Failed to restart review`}}if(dSt.has(e.sessionType)){let t=e.sessionType.charAt(0).toUpperCase()+e.sessionType.slice(1);return{endpoint:`/api/agents/${encodeURIComponent(e.sessionId)}/restart`,body:{...e.model?{model:e.model}:{},...e.harness?{harness:e.harness}:{},graceful:!1},successMessage:`${t} restarted`,errorMessage:`Failed to restart ${e.sessionType} agent`}}return null}async function pSt(){let e=await fJ(`/api/conversations`);if(!e.ok)throw Error(`Failed to fetch conversations`);return e.json()}async function mSt(){let e=await fetch(`/api/costs/by-issue`);if(!e.ok)throw Error(`Failed to fetch costs`);return e.json()}async function hSt(){let e=await fetch(`/api/version`);if(!e.ok)throw Error(`Failed to fetch version`);return e.json()}async function gSt(){let e=await fetch(`/api/registered-projects`);if(!e.ok)throw Error(`Failed to fetch registered projects`);let t=await e.json();return Array.isArray(t)?t:[]}async function _St(e){if(e.length===0)return[];let t=await fetch(`/api/session-trees?projects=${encodeURIComponent(e.join(`,`))}`);if(!t.ok)throw Error(`Failed to fetch session trees`);return(await t.json()).trees}function vSt(e,t){let n=t.issueId.toLowerCase(),r=e.features.findIndex(e=>e.issueId.toLowerCase()===n);if(r===-1)return e;let i=e.features[r];if(!i)return e;switch(t.kind){case`session_added`:return e;case`session_removed`:{let n=i.sessions.filter(e=>e.sessionId!==t.sessionId);if(n.length===i.sessions.length)return e;let a=[...e.features];return a[r]={...i,sessions:n},{...e,features:a}}case`presence_changed`:case`status_changed`:{let n=i.sessions.findIndex(e=>e.sessionId===t.sessionId);if(n===-1)return e;let a=[...i.sessions];a[n]={...i.sessions[n],...t.presence!==void 0&&{presence:t.presence},...t.status!==void 0&&{status:t.status}};let o=[...e.features];return o[r]={...i,sessions:a},{...e,features:o}}default:return e}}var ySt=`mc-convs-collapsed`,bSt=`mc-projects-collapsed`,xSt=`mc-section-split`;function SSt({issues:e=[],convId:t,pendingConversationTarget:n=null,onPendingConversationTargetConsumed:r,onConvIdChange:i,selectedProject:a=null,onSelectProject:o,onProjectPrefixChange:s,cockpitIssue:c=null,onCockpitChange:l}){let[u,d]=(0,R.useReducer)(e=>e+1,0),[f,p]=(0,R.useState)(null),[m,h]=(0,R.useState)(null),[g,_]=(0,R.useState)(()=>typeof window<`u`&&localStorage.getItem(`overdeck.ui.awarenessCollapsed`)===`true`),v=(0,R.useCallback)(e=>{_(e);try{localStorage.setItem(`overdeck.ui.awarenessCollapsed`,String(e))}catch{}},[]),[y,b]=(0,R.useState)(!1),[x,S]=(0,R.useState)(null),[C,w]=(0,R.useState)(()=>{try{return localStorage.getItem(ySt)===`true`}catch{return!1}}),[T,E]=(0,R.useState)(()=>{try{return localStorage.getItem(bSt)===`true`}catch{return!1}}),D=(0,R.useCallback)(()=>{w(e=>{let t=!e;try{localStorage.setItem(ySt,String(t))}catch{}return t})},[]),O=(0,R.useCallback)(()=>{E(e=>{let t=!e;try{localStorage.setItem(bSt,String(t))}catch{}return t})},[]),[k,A]=(0,R.useState)(()=>{try{let e=localStorage.getItem(xSt);return e?Math.max(20,Math.min(80,Number(e))):50}catch{return 50}}),j=(0,R.useRef)(!1),M=(0,R.useRef)(0),N=(0,R.useRef)(50),P=(0,R.useRef)(null),[F,I]=(0,R.useState)(`all`),[ee,te]=(0,R.useState)(Cat),[ne,L]=(0,R.useState)(wat),re=lSt(e=>e.selectSession),ie=lSt(e=>e.selectedSessionByIssue),ae=f?ie[f]??null:null,[oe,se]=(0,R.useState)(()=>{let e=localStorage.getItem(`mc-sidebar-width`);return e?Math.max(280,Number(e)):320}),ce=(0,R.useRef)(!1),le=(0,R.useRef)(0),ue=(0,R.useRef)(0),de=(0,R.useRef)(oe),fe=_t(),{data:pe=[],isLoading:me}=B({queryKey:[`command-deck-projects`,u],queryFn:K5,refetchInterval:3e4}),{data:he}=B({queryKey:[`costs-by-issue`],queryFn:mSt,refetchInterval:15e3}),{data:ge=[]}=B({queryKey:[`registered-projects`],queryFn:gSt,staleTime:6e4}),{data:_e}=B({queryKey:[`version`],queryFn:hSt,staleTime:1/0}),ve=(0,R.useMemo)(()=>pe.map(e=>e.name).join(`,`),[pe]),{data:ye=[]}=B({queryKey:[`session-trees`,ve],queryFn:()=>_St(pe.map(e=>e.name)),enabled:pe.length>0}),be=(0,R.useRef)({}),xe=(0,R.useMemo)(()=>{let e={},t=!1;for(let n of ye)e[n.projectKey]=n,be.current[n.projectKey]!==n&&(t=!0);return!t&&Object.keys(e).length===Object.keys(be.current).length?be.current:(be.current=e,e)},[ye]);(0,R.useEffect)(()=>{let e=hj(),t=[];for(let n of pe){let r=e.subscribe(e=>e[Pp.subscribeProjectSessionTree]({projectKey:n.name}),e=>{let t=[`session-trees`,ve],r=fe.getQueryData(t);if(!r)return;let i=r.find(e=>e.projectKey===n.name);if(!i)return;if(e.kind===`session_added`){fe.invalidateQueries({queryKey:t,exact:!0});return}let a=vSt(i,e);if(a===i)return;let o=r.map(e=>e.projectKey===n.name?a:e);fe.setQueryData(t,o)});t.push(r)}return()=>{for(let e of t)e()}},[ve,pe,fe]);let Se=(0,R.useMemo)(()=>pe.map(e=>{let t=xe[e.name];if(!t)return e;let n=new Map;for(let e of t.features)n.set(e.issueId.toLowerCase(),e.sessions);let r=!1,i=e.features.map(e=>{let t=n.get(e.issueId.toLowerCase());return!t&&!e.sessions||t===e.sessions?e:(r=!0,{...e,sessions:t??e.sessions})});return r?{...e,features:i}:e}),[pe,xe]);(0,R.useEffect)(()=>{if(a||!o)return;let e=Se.filter(e=>e.features.length>0);e.length===1&&o(e[0].name)},[o,Se,a]);let[Ce,we]=(0,R.useState)({});(0,R.useEffect)(()=>{if(!Se.some(e=>e.features.some(e=>(e.resourceDetails?.dockerContainerCount??0)>0)))return;let e=async()=>{try{let e=await fetch(`/api/resources`);if(!e.ok)return;let t=await e.json(),n={};for(let e of t.containers)n[e.name]=e;we(n)}catch{}};e();let t=setInterval(e,5e3);return()=>clearInterval(t)},[Se]);let Te=sm(lm),Ee=Hr(),{issueCosts:De,issueCostDetails:Oe}=(0,R.useMemo)(()=>{let e={},t={};for(let n of he?.issues||[]){e[n.issueId]=n.totalCost,e[n.issueId.toLowerCase()]=n.totalCost;let r={byModel:n.byModel??{},byStage:n.byStage??{}};t[n.issueId]=r,t[n.issueId.toLowerCase()]=r}return{issueCosts:e,issueCostDetails:t}},[he]),ke=(0,R.useMemo)(()=>{let t={};for(let n of e)n.identifier&&(t[n.identifier.toLowerCase()]=n.title,t[n.identifier]=n.title);return t},[e]),{data:Ae=[]}=B({queryKey:[`conversations`],queryFn:pSt,refetchInterval:1e4}),{projectConversations:je}=(0,R.useMemo)(()=>{let e={},t=new Set;if(!Array.isArray(ge)||ge.length===0)return{projectConversations:e,excludeConvIds:t};let n=new Map;for(let e of ge){if(!e.path)continue;let t=Array.from(new Set([e.key,e.name].filter(e=>!!e)));n.set(e.path.replace(/\/+$/,``),t)}for(let r of Ae){if(!r.cwd)continue;let i=r.cwd.replace(/\/+$/,``);for(let[a,o]of n)if(i===a||i.startsWith(a+`/`)){for(let t of o)e[t]||(e[t]=[]),e[t].push(r);t.add(r.id);break}}return{projectConversations:e,excludeConvIds:t}},[Ae,ge]),Me=(0,R.useRef)(null),Ne=(0,R.useRef)(null),Pe=(0,R.useCallback)(e=>{if(!e?.cwd)return null;let t=e.cwd,n=ge.find(e=>!!e.path&&(t===e.path||t.startsWith(e.path+`/`)));return n?n.name??n.key:null},[ge]),Fe=(0,R.useCallback)((e,t,n)=>{let r=FH.getState();r.ensureHome(e);let i=(r.panesByWorkspace[e]??[]).find(e=>e.paneType===`issue`&&e.issueId===t);i?r.setActivePane(e,i.paneId):r.addPane(e,{paneType:`issue`,label:n,issueId:t})},[]),Ie=(0,R.useCallback)((e,t,n,r,i)=>{let a=FH.getState();a.ensureHome(e);let o=(a.panesByWorkspace[e]??[]).find(e=>e.paneType===`agent`&&e.conversationId===t),s=o?o.paneId:a.addPane(e,{paneType:`agent`,label:n,conversationId:t,...i?{viewMode:i}:{}});a.setActivePane(e,s),r&&FH.getState().updatePane(e,s,{targetMessageId:r.messageId,targetMessageIndex:r.messageIndex,targetMessageNonce:r.nonce})},[]),Le=(0,R.useCallback)((e,t)=>{let n=FH.getState();n.ensureHome(e),n.addPane(e,{paneType:`terminal`,label:`Terminal`,terminalId:t})},[]),Re=(0,R.useCallback)((e,t,n,r)=>{let i=FH.getState();i.ensureHome(e);let a=(i.panesByWorkspace[e]??[]).find(e=>e.paneType===`agent`&&e.agentId===t);a?i.setActivePane(e,a.paneId):i.addPane(e,{paneType:`agent`,label:r,agentId:t,issueId:n})},[]);(0,R.useEffect)(()=>{if(!t||Ae.length===0||t===Me.current)return;let e=Ae.find(e=>String(e.id)===t||e.name===t);if(e){h(e.name),p(null);let i=Pe(e)??`__no-project__`,a=n?.conversationName===e.name?{messageId:n.messageId,messageIndex:n.messageIndex,nonce:n.nonce}:void 0;o?.(i,{updateUrl:!1}),Ie(i,e.name,n?.label??e.title??`Agent`,a),a&&r?.(),Me.current=t}},[t,Ae,Pe,o,Ie,n,r]);let ze=(0,R.useRef)(!1);(0,R.useEffect)(()=>{if(ze.current)return;let e=new URLSearchParams(window.location.search).has(`issue`);Ae.length===0||t||e||m!==null||f!==null||a!==null||(h(Ae[0].name),ze.current=!0)},[Ae,t,m,f,a]);let Be=(0,R.useRef)(null);(0,R.useEffect)(()=>{if(!i||m===Be.current)return;if(Be.current=m,!m){i(null);return}let e=Ae.find(e=>e.name===m);if(e){if(t===String(e.id)||t===e.name)return;i(String(e.id))}},[m,Ae,i,t]),(0,R.useEffect)(()=>{if(!c||ge.length===0)return;let e=`${c.project}/${c.issue}`;if(e===Ne.current)return;Ne.current=e;let t=c.project,n=t.includes(`/`)?t.split(`/`).pop():t,r=ge.find(e=>e.key===t||e.name===t||e.key===n||e.name===n),i=r?r.name??r.key:t;p(c.issue),h(null),o?.(i),Fe(i,c.issue,c.issue)},[c,o,Fe,ge]);let Ve=(0,R.useRef)(null);(0,R.useEffect)(()=>{l&&f!==Ve.current&&(Ve.current=f,f&&a&&l(a,f))},[f,a,l]);let He=(0,R.useCallback)(e=>{p(e),h(null),a&&Fe(a,e,e);let t=Se.flatMap(e=>e.features).find(t=>t.issueId===e)?.sessions?.find(e=>e.presence===`active`&&e.type===`work`);re(e,t?.sessionId??null)},[re,Se,a,Fe]),Ue=(0,R.useCallback)((e,t)=>{if(p(e),re(e,t),h(null),!a)return;let n=Se.flatMap(e=>e.features).flatMap(e=>e.sessions??[]).find(e=>e.sessionId===t),r=n?.role??n?.type??`Agent`;Re(a,t,e,r.charAt(0).toUpperCase()+r.slice(1))},[re,a,Se,Re]),We=(0,R.useCallback)(e=>Se.flatMap(e=>e.features).flatMap(e=>e.sessions??[]).find(t=>t.sessionId===e),[Se]),Ge=(0,R.useCallback)(async e=>{try{if(!(await fetch(`/api/agents/${e}`,{method:`DELETE`})).ok)throw Error(`Failed to stop session`);await _j(fe)}catch(e){H.error(e instanceof Error?e.message:`Failed to stop session`)}},[fe]),Ke=(0,R.useCallback)(async e=>{if(window.confirm(`Clean up orphaned resources for ${e}? This removes leftover local workspace state for a closed issue.`))try{if(!(await fetch(`/api/issues/${encodeURIComponent(e)}/cleanup-workspace`,{method:`POST`})).ok)throw Error(`Failed to clean up orphaned resources`);d(),await _j(fe)}catch(e){H.error(e instanceof Error?e.message:`Failed to clean up resources`)}},[fe]),qe=(0,R.useCallback)(e=>{for(let t of Se)for(let n of t.features)if(n.sessions?.some(t=>t.sessionId===e)){p(n.issueId),re(n.issueId,e),h(null),a&&Le(a,e);return}},[Se,re,a,Le]),Je=(0,R.useCallback)(async e=>{try{if(!(await fetch(`/api/agents/${e}/suspend`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:e})})).ok)throw Error(`Failed to pause session`);await _j(fe)}catch(e){H.error(e instanceof Error?e.message:`Failed to pause session`)}},[fe]),Ye=(0,R.useCallback)(async e=>{try{console.log(`[command-deck] handleResumeSession ${e}`);let t=await fetch(`/api/agents/${e}/resume`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({message:`Resumed from dashboard`})}),n=await t.json().catch(()=>({}));if(!t.ok)throw console.warn(`[command-deck] handleResumeSession ${e} failed: ${t.status} ${n.error??`no body`}`),Error(n.error||`Failed to resume session`);console.log(`[command-deck] handleResumeSession ${e} ok: messageDelivered=${n.messageDelivered}`),H.success(n.messageDelivered===!1?`Agent resumed; message queued in mail (PTY echo-confirm timed out)`:`Agent resumed`),await _j(fe)}catch(e){H.error(e instanceof Error?e.message:`Failed to resume session`)}},[fe]),Xe=(0,R.useCallback)(async e=>{try{let t=await fetch(`/api/agents/${e}/unpause`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})}),n=await t.json().catch(()=>({}));if(!t.ok)throw Error(n.error||`Failed to unpause agent`);H.success(`Agent unpaused — deacon will resume it on the next patrol`),await _j(fe)}catch(e){H.error(e instanceof Error?e.message:`Failed to unpause agent`)}},[fe]),Ze=(0,R.useCallback)(async(e,t,n,r,i,a)=>{try{let o=Se.find(e=>e.features.some(e=>e.issueId===t))?.name??Object.entries(xe).find(([,e])=>e.features.some(e=>e.issueId.toLowerCase()===t.toLowerCase()))?.[0],s=!n||n===`work`,c=s?Te.find(t=>t.id===e):void 0,l=c?.harness??void 0,u=c?.model??void 0,d=s&&a!==void 0&&a!==l&&l!==void 0,f=d||s&&i!==void 0&&i!==u&&u!==void 0&&!d,p=n===`review`||n===`reviewer`;if(f||p){let e=p?`Restart review with new harness/model`:`Restart work agent with new harness/model`,n=`This will delete the review agent's state for ${t} (sessions, activity, logs) and start a fresh review run with the chosen harness/model.\n\nThe workspace, vBRIEF, beads, and commit history are kept. The review will have to re-research the diff from scratch — this is a deliberate cost of switching harness/model or force-restarting the review.`,r=`This will delete the work agent's state for ${t} (sessions, activity, logs) and start a fresh ${a??l??``} + ${i??u??``} agent.\n\nThe workspace, vBRIEF, beads, and commit history are kept. The new agent will read .pan/continue.json and the branch to continue. The agent will have to re-research the diff from scratch — this is a deliberate cost of switching harness/model.`;if(!await Ee({title:e,message:p?n:r,confirmLabel:p?`Restart review`:`Restart work agent`,variant:`destructive`})){H.info(`Restart canceled`);return}}let m=fSt({projectKey:o,issueId:t,sessionId:e,sessionType:n,role:r,model:i,harness:a});if(m&&!f){let e=await fetch(m.endpoint,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(m.body)}),t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t.error||m.errorMessage);H.success(m.successMessage),await _j(fe);return}if(f){let t=await fetch(`/api/agents/${e}/restart-fresh`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({spawn:!0,...i?{model:i}:{},...a?{harness:a}:{}})}),n=await t.json().catch(()=>({}));if(!t.ok)throw Error(n.error||`Failed to restart agent with new harness/model`);H.success(`Agent restarted: ${n.spawnedHarness??a} + ${n.spawnedModel??i}`),await _j(fe);return}let h=await fetch(`/api/agents/${e}/resume`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...i?{model:i}:{},...a?{harness:a}:{}})}),g=await h.json().catch(()=>({}));if(h.ok){H.success(`Agent resumed`),await _j(fe);return}if(g.lifecycle?.isRunning){if(!(await fetch(`/api/agents/${e}`,{method:`DELETE`})).ok)throw Error(`Failed to stop agent before restart`);let t=await fetch(`/api/agents/${e}/resume`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...i?{model:i}:{},...a?{harness:a}:{}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||`Failed to restart agent`)}H.success(`Agent restarted`),await _j(fe);return}if(!(g.lifecycle?.canResumeSession===!1&&!g.lifecycle?.hasLiveTmuxSession))throw Error(g.error||`Failed to resume agent`);await fetch(`/api/agents/${e}`,{method:`DELETE`});let _={issueId:t};i&&(_.model=i),a&&(_.harness=a);let v=_,y=await fetch(`/api/agents`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(v)}),b=await y.json().catch(()=>({}));if(y.status===409&&b.requiresAcknowledgement){if(!window.confirm((b.guardrails?.warnings??[]).map(e=>`• ${e.message}`).join(`
|
|
668
|
+
`)))throw Error(`Agent start canceled`);v={..._,guardrailAcknowledged:!0},y=await fetch(`/api/agents`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(v)}),b=await y.json().catch(()=>({}))}if(!y.ok)throw SYe(y,b)?(vYe(v),Error(b.hint||b.error||`Codex authentication expired — re-authenticate to continue`)):Error(b.error||b.hint||`Failed to start agent`);b.guardrails?.warnings?.length&&H.success(`Agent started after acknowledging system health warnings.`,{duration:6e3}),await _j(fe)}catch(e){H.error(e instanceof Error?e.message:`Failed to restart session`)}},[fe,Se,xe,Ee,Te]),Qe=(0,R.useCallback)(async e=>{try{if(!(await fetch(`/api/issues/${encodeURIComponent(e)}/deep-wipe`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({deleteWorkspace:!0})})).ok)throw Error(`Failed to deep wipe`);await _j(fe),p(null),re(e,null)}catch(e){H.error(e instanceof Error?e.message:`Failed to deep wipe`)}},[fe,re]),$e=(0,R.useCallback)(e=>{let t=`~/.overdeck/agents/${e}/`;navigator.clipboard?.writeText(t).catch(()=>{})},[]),et=(0,R.useCallback)(t=>{S(e.find(e=>e.identifier.toLowerCase()===t.toLowerCase())??{id:t,identifier:t,title:t,status:`Todo`,priority:0,labels:[],url:``,createdAt:``,updatedAt:``})},[e]),tt=(0,R.useCallback)(e=>{for(let t of Se)for(let n of t.features)if(n.sessions?.some(t=>t.sessionId===e)){p(n.issueId),re(n.issueId,e),h(null),a&&Fe(a,n.issueId,n.issueId);return}},[Se,re,a,Fe]),nt=(0,R.useCallback)(e=>{o?.(e),p(null),h(null)},[o]),rt=(0,R.useCallback)(e=>{if(h(e),f&&re(f,null),e){p(null);let t=Ae.find(t=>t.name===e),n=Pe(t)??`__no-project__`;n!==a&&o?.(n,{updateUrl:!1}),Ie(n,e,t?.title??`Agent`)}},[re,f,Ae,Pe,a,o,Ie]),it=bJ(m,rt);(0,R.useEffect)(()=>{let e=e=>{let t=e.detail;t?.conversation&&it.openForkModal(t.conversation,{mode:t.mode,focus:t.focus})};return window.addEventListener(`overdeck:open-fork-modal`,e),()=>window.removeEventListener(`overdeck:open-fork-modal`,e)},[it]);let at=(0,R.useCallback)(async(e,t,n,r)=>{try{let o={model:ee,harness:t??ne};e&&(o.projectKey=e);let s=n?.trim();s&&(o.message=s);let c=await fetch(`/api/conversations`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(o)});if(!c.ok){let e=await c.json().catch(()=>({error:`Request failed`}));throw Error(e.error||`Failed to create conversation`)}let l=await c.json();h(l.name),C&&w(!1);let u=e??a;if(u&&Ie(u,l.name,l.title??`Agent`,void 0,r),i){let e=String(l.id);i(e),Me.current=e,Be.current=l.name}return fe.invalidateQueries({queryKey:[`conversations`]}),l.name}catch(e){console.error(`[CommandDeck] Failed to create conversation:`,e),H.error(e instanceof Error?e.message:`Failed to create conversation`);return}},[ee,ne,fe,i,C,a,Ie]),ot=(0,R.useCallback)(()=>{at(a&&a!==`__no-project__`?a:void 0)},[at,a]),st=(0,R.useCallback)(e=>{at(e)},[at]),ct=(0,R.useCallback)((e,t,n)=>at(a&&a!==`__no-project__`?a:void 0,e===`codex`?`codex`:e===`ohmypi`?`ohmypi`:`claude-code`,t,n),[at,a]),lt=(0,R.useCallback)(e=>{j.current=!0,M.current=e.clientY,N.current=k,document.body.style.cursor=`row-resize`,document.body.style.userSelect=`none`,e.preventDefault()},[k]);(0,R.useEffect)(()=>{let e=e=>{if(!j.current||!P.current)return;let t=P.current.getBoundingClientRect().height;if(t<=0)return;let n=(e.clientY-M.current)/t*100;A(Math.max(15,Math.min(85,N.current+n)))},t=()=>{j.current&&(j.current=!1,document.body.style.cursor=``,document.body.style.userSelect=``,A(e=>{try{localStorage.setItem(xSt,String(Math.round(e)))}catch{}return e}))};return document.addEventListener(`mousemove`,e),document.addEventListener(`mouseup`,t),()=>{document.removeEventListener(`mousemove`,e),document.removeEventListener(`mouseup`,t)}},[]);let ut=(0,R.useCallback)(e=>{ce.current=!0,le.current=e.clientX,ue.current=oe,document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`,e.preventDefault()},[oe]);(0,R.useEffect)(()=>{let e=e=>{if(!ce.current)return;let t=e.clientX-le.current,n=Math.max(280,Math.min(500,ue.current+t));se(n),de.current=n},t=()=>{ce.current&&localStorage.setItem(`mc-sidebar-width`,String(de.current)),ce.current=!1,document.body.style.cursor=``,document.body.style.userSelect=``};return document.addEventListener(`mousemove`,e),document.addEventListener(`mouseup`,t),()=>{document.removeEventListener(`mousemove`,e),document.removeEventListener(`mouseup`,t)}},[]),(0,R.useEffect)(()=>{let e=()=>{console.log(`[CommandDeck] transport reconnected — invalidating query caches`),fe.invalidateQueries()};return window.addEventListener(`overdeck:reconnected`,e),()=>window.removeEventListener(`overdeck:reconnected`,e)},[fe]);let dt=(0,R.useMemo)(()=>a?Se.find(e=>e.name===a)??null:null,[Se,a]),ft=a===nSt,pt=(0,R.useMemo)(()=>Ae.filter(e=>iSt(e,ge)),[Ae,ge]),mt=(0,R.useMemo)(()=>ft?pt:a?je[a]??[]:[],[ft,pt,a,je]),ht=(0,R.useMemo)(()=>new Set(mt.map(e=>e.id)),[mt]),gt=(0,R.useMemo)(()=>(dt?.features??[]).map(e=>e.issueId),[dt]),vt=(0,R.useMemo)(()=>{let e=new Set(gt.map(e=>e.split(`-`)[0]?.toUpperCase()).filter(Boolean));return e.size===1?[...e][0]:null},[gt]);(0,R.useEffect)(()=>{s?.(vt)},[vt,s]);let yt=(0,R.useCallback)(t=>{let n=t.toLowerCase();return{title:ke[n]||ke[t]||t,createdAt:e.find(e=>e.identifier===t)?.createdAt,branch:dt?.features.find(e=>e.issueId===t)?.branch,agentId:Te.find(e=>e.issueId?.toLowerCase()===n&&e.id.startsWith(`agent-`))?.id??Te.find(e=>e.issueId?.toLowerCase()===n)?.id}},[ke,e,dt,Te]);return(0,z.jsxs)(`div`,{className:J.commandDeck,children:[(0,z.jsxs)(`div`,{className:J.layout,children:[(0,z.jsxs)(`div`,{className:J.sidebar,style:{width:oe,minWidth:oe},children:[(0,z.jsx)(`div`,{className:J.sidebarHeader,children:(0,z.jsxs)(`div`,{className:J.sidebarHeaderRow,children:[(0,z.jsx)(`h2`,{className:J.sidebarTitle,children:`Command Deck`}),(0,z.jsxs)(`div`,{className:J.sidebarHeaderGroup,children:[(0,z.jsx)(l4,{value:ee,onChange:e=>{te(e),o4(e)},harness:ne,onHarnessChange:e=>{L(e),s4(e)}}),(0,z.jsx)(`button`,{className:J.conversationAddBtn,onClick:ot,title:`New conversation`,"aria-label":`New conversation`,children:(0,z.jsx)(gr,{size:13})})]})]})}),(0,z.jsxs)(`div`,{ref:P,style:{display:`flex`,flexDirection:`column`,flex:1,minHeight:0,overflow:`hidden`},children:[(0,z.jsxs)(`div`,{className:`${J.sidebarSection} ${C?J.sidebarSectionCollapsed:``}`,style:!C&&!T?{flex:`0 0 ${k}%`}:void 0,children:[(0,z.jsxs)(`div`,{className:J.sectionHeader,onClick:D,children:[C?(0,z.jsx)(nn,{size:14}):(0,z.jsx)(en,{size:14}),(0,z.jsx)(`span`,{className:J.sectionTitle,children:`Conversations`}),(0,z.jsx)(`span`,{className:J.segmentCount,children:mt.length})]}),!C&&(0,z.jsx)(`div`,{className:J.sectionBody,children:a?(0,z.jsx)(k7e,{selectedConversation:m,onSelectConversation:rt,includeIds:ht}):(0,z.jsx)(`div`,{className:J.emptyProject,children:`Select a project to see its conversations`})})]}),!C&&!T&&(0,z.jsx)(`div`,{className:J.sectionDivider,onMouseDown:lt}),(0,z.jsxs)(`div`,{className:`${J.sidebarSection} ${T?J.sidebarSectionCollapsed:``}`,style:!C&&!T?{flex:`0 0 ${100-k}%`}:void 0,children:[(0,z.jsxs)(`div`,{className:J.sectionHeader,onClick:O,children:[T?(0,z.jsx)(nn,{size:14}):(0,z.jsx)(en,{size:14}),(0,z.jsx)(`span`,{className:J.sectionTitle,children:`Issues`}),(0,z.jsx)(`span`,{className:J.segmentCount,children:dt?.features.length??0})]}),!T&&(0,z.jsxs)(`div`,{className:J.sectionBody,children:[(0,z.jsx)(`div`,{className:J.treeFilterRow,children:[`all`,`alive`,`failed`].map(e=>(0,z.jsx)(`button`,{onClick:()=>I(e),className:`${J.treeFilterButton} ${F===e?J.treeFilterButtonActive:``}`,children:e===`all`?`All`:e===`alive`?`Alive`:`Failed`},e))}),a?me&&!dt?(0,z.jsxs)(`div`,{className:J.skeletonList,children:[(0,z.jsx)(`div`,{className:J.skeletonItem,style:{width:`60%`}}),(0,z.jsx)(`div`,{className:J.skeletonItem,style:{width:`80%`}}),(0,z.jsx)(`div`,{className:J.skeletonItem,style:{width:`45%`}})]}):dt?(0,z.jsx)(L4e,{name:dt.name,features:dt.features,selectedFeature:f,onSelectFeature:He,onSelectProject:nt,selectedProject:a,selectedSessionId:ae,onSelectSession:Ue,issueTitles:ke,issueCosts:De,filter:F,onStopSession:Ge,onViewTerminal:qe,onPauseSession:Je,onResumeSession:Ye,onUnpauseSession:Xe,onRestartSession:Ze,onDeepWipe:Qe,onOpenStateDir:$e,onViewJsonl:tt,onCleanupOrphanedResources:Ke,onOpenPlanDialog:et,onNewConversation:st,containerStats:Ce},dt.path):(0,z.jsx)(`div`,{className:J.emptyProject,children:`No issues for this project`}):(0,z.jsx)(`div`,{className:J.emptyProject,children:`Select a project to see its issues`})]})]})]}),it.forkTarget&&(0,z.jsx)(uJ,{conversation:it.forkTarget,initialMode:it.forkTargetMode,initialFocus:it.forkTargetFocus,isPending:it.isForkPending,onClose:it.closeForkModal,onConfirm:(e,t,n,r,i,a,o,s,c,l,u,d,f)=>{it.submitFork(e,t,n,r,i,a,o,s,c,l,u,d,f)}}),_e&&(0,z.jsx)(`div`,{className:J.sidebarFooter,children:(0,z.jsxs)(`span`,{className:J.versionLabel,children:[`v`,_e.version]})})]}),(0,z.jsx)(`div`,{className:J.resizeHandle,onMouseDown:ut}),(0,z.jsx)(`div`,{className:J.content,children:a?(0,z.jsx)(j_t,{deckKey:a,conversations:Ae,resolveSession:We,onCreateConversation:ct,onActiveConversationChange:h,terminalCwd:ge.find(e=>(e.name??e.key)===a)?.path,renderHome:e=>(0,z.jsx)(gyt,{projectName:ft?rSt:a,projectKey:ge.find(e=>(e.name??e.key)===a)?.key,conversations:mt,onCreateConversation:ct,features:dt?.features,issueCosts:De,issueCostDetails:Oe,onSelectFeature:e=>He(e.issueId),api:e}),renderIssue:(e,t)=>{let n=yt(e);return(0,z.jsx)(ixt,{issueId:e,title:n.title,branch:n.branch,projectName:a??void 0,createdAt:n.createdAt,agentId:n.agentId,conversations:Ae,onCreateConversation:ct,api:t})}},a):(0,z.jsx)(`div`,{className:J.contentEmpty,children:(0,z.jsxs)(`div`,{style:{textAlign:`center`},children:[(0,z.jsx)(yn,{size:48,style:{marginBottom:`16px`,opacity:.3}}),(0,z.jsx)(`p`,{children:`Select a project to open its deck`})]})})}),a&&(g?(0,z.jsxs)(`button`,{type:`button`,className:J.activityColumnCollapsed,onClick:()=>v(!1),title:`Show Awareness`,"aria-label":`Show Awareness rail`,children:[(0,z.jsx)(tn,{size:16}),(0,z.jsx)(`span`,{className:J.activityCollapsedLabel,children:`Awareness`})]}):(0,z.jsx)(`div`,{className:J.activityColumn,children:(0,z.jsx)(qxt,{embedded:!0,heading:`Awareness`,scopeSwitcher:!0,projectIssueIds:ft?void 0:gt,onClose:()=>v(!0)})}))]}),y&&f&&(0,z.jsx)(oSt,{issueId:f,isOpen:y,onClose:()=>b(!1)}),x&&(0,z.jsx)(OE,{issue:x,isOpen:!0,onClose:()=>S(null),onComplete:async()=>{S(null),await _j(fe)}})]})}async function CSt(e,t){let n=await fetch(`/api/workspaces/${encodeURIComponent(e)}/auto-merge`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({autoMerge:t})});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error??n.statusText)}}function wSt(e,t){let n=sm.getState(),r=e.toUpperCase(),i=n.reviewStatusByIssueId[r]?r:e,a=n.reviewStatusByIssueId[i];a&&sm.setState(e=>({reviewStatusByIssueId:{...e.reviewStatusByIssueId,[i]:{...a,autoMerge:t}}}))}function TSt(){let{data:e}=B({queryKey:[`flywheel`,`config`,`require-uat`],queryFn:async()=>{let e=await fetch(`/api/flywheel/config`);return e.ok?!!(await e.json()).require_uat_before_merge:void 0},staleTime:3e4});return e}function q5({issueId:e,autoMerge:t,variant:n=`segmented`,compact:r=!1,className:i=``}){let[a,o]=(0,R.useState)(!1),s=TSt(),c=s===void 0?`the project default`:s?`hold for UAT`:`auto-merge`,l=async n=>{if(!(a||t===n)){o(!0);try{await CSt(e,n),wSt(e,n)}catch(e){H.error(e instanceof Error?e.message:`Failed to update auto-merge`)}finally{o(!1)}}},u=r?`w-3 h-3`:`w-3.5 h-3.5`;if(n===`badge`){let e=t===!0,n=!e,r=e?`auto`:t===!1?`hold`:`default`,o=e?`text-emerald-400 bg-emerald-500/10 border-emerald-500/40`:t===!1?`text-amber-400 bg-amber-500/10 border-amber-500/40`:`text-muted-foreground bg-transparent border-border`;return(0,z.jsxs)(`button`,{type:`button`,disabled:a,onClick:e=>{e.stopPropagation(),l(n)},title:e?`Auto-merge ON — click to hold for UAT`:t===!1?`Holding for UAT — click to auto-merge`:`Follows the global default (currently: ${c}) — click to set Auto`,className:`inline-flex items-center gap-1 rounded-md border px-2 py-0.5 text-xs font-semibold transition disabled:opacity-50 hover:brightness-110 ${o} ${i}`,children:[e?(0,z.jsx)(Br,{className:u}):(0,z.jsx)(or,{className:u}),r]})}let d=(e,t)=>`inline-flex items-center gap-1.5 ${r?`px-2 py-1`:`px-2.5 py-1.5`} text-xs font-semibold transition disabled:opacity-50 `+(e?t:`text-muted-foreground hover:text-foreground hover:bg-accent/40`);return(0,z.jsxs)(`div`,{role:`group`,"aria-label":`Auto-merge policy`,title:t===void 0?`Default follows the global setting (currently: ${c})`:void 0,className:`inline-flex overflow-hidden rounded-lg border border-border bg-background ${i}`,children:[(0,z.jsxs)(`button`,{type:`button`,disabled:a,"aria-pressed":t===!0,onClick:e=>{e.stopPropagation(),l(!0)},className:d(t===!0,`text-emerald-400 bg-emerald-500/10`),title:`Auto-merge — ride the train, ship when green`,children:[(0,z.jsx)(Br,{className:u}),` Auto`]}),(0,z.jsxs)(`button`,{type:`button`,disabled:a,"aria-pressed":t===!1,onClick:e=>{e.stopPropagation(),l(!1)},className:`border-l border-border ${d(t===!1,`text-amber-400 bg-amber-500/10`)}`,title:`Hold for UAT — wait for human batch review`,children:[(0,z.jsx)(or,{className:u}),` Hold`]})]})}var J5=[`ship`,`review`,`verifying`,`work`,`plan`,`ready`],ESt=[`all`,...J5],DSt={1:`urgent`,2:`high`,3:`medium`,4:`low`};function OSt(e){return Object.values(e).reduce((e,t)=>e+t.reduce((e,t)=>e+t.cost,0),0)}function kSt(e,t){return e[t.identifier]??e[t.identifier.toUpperCase()]}function ASt(e){return DSt[e]??`low`}function jSt(e){return[e.model,e.status].filter(Boolean).join(` · `)}function MSt(e){return 5-e}function NSt(e,t){let n=MSt(t.priority)-MSt(e.priority);return n===0?t.updatedAt.localeCompare(e.updatedAt):n}function PSt(){if(typeof window>`u`)return{phase:`all`,projects:[],blocked:!1,noPr:!1};let e=new URLSearchParams(window.location.search),t=e.get(`phase`);return{phase:J5.includes(t)?t:`all`,projects:e.get(`projects`)?.split(`,`).map(e=>e.trim()).filter(Boolean)??[],blocked:e.has(`blocked`),noPr:e.has(`noPr`)}}function FSt(e){if(typeof window>`u`)return;let t=new URL(window.location.href);e.phase===`all`?t.searchParams.delete(`phase`):t.searchParams.set(`phase`,e.phase),e.projects.length>0?t.searchParams.set(`projects`,e.projects.join(`,`)):t.searchParams.delete(`projects`),e.blocked?t.searchParams.set(`blocked`,`1`):t.searchParams.delete(`blocked`),e.noPr?t.searchParams.set(`noPr`,`1`):t.searchParams.delete(`noPr`),window.history.replaceState(null,``,`${t.pathname}${t.search}${t.hash}`)}function ISt(e){return e.project?{id:e.project.id||e.project.name,name:e.project.name}:null}function LSt(e){return!!(e&&(e.blockerReasons?.length??0)>0&&e.mergeStatus!==`merged`&&e.reviewStatus===`passed`&&(e.testStatus===`passed`||e.testStatus===`skipped`))}function RSt(e){return!!(e?.prUrl&&e.readyForMerge!==!0&&e.mergeStatus!==`merged`)}function zSt(e,t){return e.phase===`ship`?!(e.blocked&&!LSt(t)||e.noPr&&!RSt(t)):!0}function BSt(e){let t=e.state??e.status;return e.stateType===`completed`||e.stateType===`canceled`||t===`done`||t===`canceled`||t===`Canceled`||t===`Closed`||t===`Completed`}function VSt(e){return hh(e.status)}function HSt(e){return e>=100?`$${e.toFixed(0)}`:e>=10?`$${e.toFixed(1)}`:e>=1?`$${e.toFixed(2)}`:e>0?`$${e.toFixed(3)}`:`$0`}function USt(e){if(!Number.isFinite(e)||e<0)return`—`;let t=Math.max(0,e),n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4);return n>0?`${n}h ${r}m`:`${r}m`}function Y5({label:e}){return(0,z.jsx)(`span`,{"aria-hidden":`true`,children:e})}function WSt(e){return e===`ship`?(0,z.jsx)(qj,{variant:`READY TO MERGE`}):e===`review`?(0,z.jsx)(qj,{variant:`REVIEW RUNNING`}):e===`verifying`?(0,z.jsx)(qj,{variant:`MERGED`}):e===`work`?(0,z.jsx)(qj,{variant:`WORK RUNNING`}):e===`plan`?(0,z.jsx)(qj,{variant:`PLANNING`}):e===`ready`?(0,z.jsx)(qj,{variant:`READY`}):(0,z.jsx)(qj,{variant:`QUEUED FOR PLAN`})}function GSt({issue:e,phase:t,agent:n,costEvents:r,now:i,onOpen:a}){let[o,s]=(0,R.useState)(0),c=sm(t=>(t.reviewStatusByIssueId[e.identifier]??t.reviewStatusByIssueId[e.identifier.toUpperCase()])?.autoMerge),l=r?.reduce((e,t)=>e+t.cost,0)??0,u={runtime:n?.startedAt?USt(i.getTime()-new Date(n.startedAt).getTime()):void 0,cost:l>0?HSt(l):void 0};return(0,z.jsx)(xvt,{issueId:e.identifier,phase:t,priority:ASt(e.priority),title:e.title,project:e.project?{name:e.project.name}:void 0,labels:e.labels.slice(0,3),verbBadge:WSt(t),agent:n?{name:n.id,sub:jSt(n)}:void 0,ledger:u,assignee:e.assignee?{name:e.assignee.name}:void 0,onOpen:a,onContextMenu:()=>s(e=>e+1),actionMenu:(0,z.jsx)(Gj,{issueId:e.identifier,mode:`overflow-only`,className:`inline-flex`,openSignal:o}),trailingBadge:(0,z.jsx)(q5,{issueId:e.identifier,autoMerge:c,variant:`badge`,compact:!0})})}function KSt({onSearchOpen:e,onTabChange:t}={}){let n=sm(fm),r=sm(e=>e.reviewStatusByIssueId),i=sm(lm),a=sm(e=>e.openIssue),o=sm(e=>e.drawer.issueId),[s,c]=(0,R.useState)(PSt),{eventsByIssue:l}=eM({limit:500}),u=aM(3e4),d=(0,R.useRef)({ship:null,review:null,verifying:null,work:null,plan:null,ready:null,todo:null}),f=(0,R.useRef)(null),p=(0,R.useRef)(0);(0,R.useEffect)(()=>{if(o===null&&p.current>0){let e=f.current;e&&window.requestAnimationFrame(()=>{e.scrollTop=p.current})}},[o]),(0,R.useEffect)(()=>{let e=()=>c(PSt());return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[]);let m=(0,R.useMemo)(()=>{let e=new Map;for(let t of i){let n=t.issueId?.toLowerCase();n&&!e.has(n)&&e.set(n,t)}return e},[i]),h=(0,R.useMemo)(()=>{let e=new Map;for(let t of n){let n=ISt(t);n&&!e.has(n.id)&&e.set(n.id,n)}return Array.from(e.values()).sort((e,t)=>e.name.localeCompare(t.name))},[n]),g=(0,R.useMemo)(()=>{let e={ship:[],review:[],verifying:[],work:[],plan:[],ready:[],todo:[]};for(let t of n){if(BSt(t))continue;let n=ISt(t);if(s.projects.length>0&&(!n||!s.projects.includes(n.id)))continue;let i=m.get(t.identifier.toLowerCase())??null,a=kSt(r,t),o=_h(t,a,i);s.phase===`ship`&&(LSt(a)||RSt(a))&&(o=`ship`),!(s.phase!==`all`&&o!==s.phase)&&zSt(s,a)&&e[o].push(t)}for(let t of J5)e[t].sort(NSt);return e},[m,s,n,r]),_=(0,R.useMemo)(()=>{let e=n.filter(e=>{if(BSt(e))return!1;let t=m.get(e.identifier.toLowerCase())??null;return _h(e,kSt(r,e),t)!==`todo`}).length,t=i.filter(e=>e.role===`work`&&VSt(e)).length,a=new Set;for(let e of i)(e.role===`review`||e.role===`test`)&&VSt(e)&&e.issueId&&a.add(e.issueId);for(let e of Object.values(r))(e.reviewStatus===`reviewing`||e.testStatus===`testing`||e.verificationStatus===`running`)&&a.add(e.issueId);let o=Object.values(r).filter(e=>e.readyForMerge===!0&&e.mergeStatus!==`merged`).length,s=OSt(l);return[{id:`active`,eyebrow:`Active issues`,value:e,sub:`open pipeline`,icon:(0,z.jsx)(Y5,{label:`●`}),signal:`info`},{id:`work`,eyebrow:`Work running`,value:t,sub:`work agents`,icon:(0,z.jsx)(Y5,{label:`▶`}),signal:`info`},{id:`review`,eyebrow:`Review running`,value:a.size,sub:`review gates`,icon:(0,z.jsx)(Y5,{label:`◆`}),signal:`review`},{id:`ship`,eyebrow:`Ship`,value:o,sub:`ready to merge`,icon:(0,z.jsx)(Y5,{label:`↑`}),signal:`success`},{id:`spend`,eyebrow:`Spend`,value:HSt(s),sub:`24h spend`,icon:(0,z.jsx)(Y5,{label:`$`}),signal:`cost`}]},[i,m,l,n,r]),v=s.phase===`all`?J5:[s.phase];function y(e,t){c(e),FSt(e),t&&window.requestAnimationFrame(()=>d.current[t]?.scrollIntoView?.({block:`start`}))}function b(e){y({...s,phase:e},e===`all`?void 0:e)}function x(e){let t=s.projects.includes(e)?s.projects.filter(t=>t!==e):[...s.projects,e];y({...s,projects:t})}function S(e){y({...s,phase:`ship`,[e]:!s[e]},`ship`)}return(0,z.jsxs)(`section`,{className:`flex h-full w-full flex-col overflow-hidden bg-background`,"data-component":`pipeline-view`,children:[(0,z.jsx)(cM,{title:`Pipeline`,breadcrumb:`Unified operations`,search:e?(0,z.jsx)(`button`,{type:`button`,"data-component":`pipeline-search-trigger`,onClick:e,className:`flex h-[32px] w-full min-w-[280px] items-center gap-[8px] rounded-[var(--radius-lg)] border border-border bg-card px-[10px] text-[12px] text-muted-foreground hover:border-primary/40 hover:text-foreground`,children:`Search issues, agents, branches…`}):void 0,segmentedControl:t?(0,z.jsx)(`div`,{"data-component":`pipeline-segmented-control`,className:`flex items-center gap-[2px] rounded-[var(--radius-lg)] border border-border bg-card p-[2px]`,children:[`List`,`Board`,`Analytics`].map(e=>(0,z.jsx)(`button`,{type:`button`,"aria-pressed":e===`List`,onClick:()=>{e===`Board`?t(`kanban`):e===`Analytics`&&t(`metrics`)},className:vj(`rounded-[calc(var(--radius-lg)-2px)] px-[10px] py-[5px] text-[12px] font-medium leading-none text-muted-foreground transition-colors hover:text-foreground`,e===`List`&&`bg-accent text-foreground`),children:e},e))}):void 0,actions:e?(0,z.jsxs)(`button`,{type:`button`,"data-component":`pipeline-start-agent`,onClick:e,className:`flex h-[32px] items-center gap-[6px] rounded-[var(--radius-lg)] bg-primary px-[14px] text-[12px] font-medium text-primary-foreground hover:bg-primary/90`,children:[(0,z.jsx)(`span`,{"aria-hidden":`true`,children:`▶`}),`Start agent`]}):void 0}),(0,z.jsx)(sM,{columns:5,tiles:_}),(0,z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-[8px] border-b border-border bg-background px-[22px] py-[10px]`,"data-component":`pipeline-filter-row`,children:[(0,z.jsx)(`div`,{className:`flex items-center gap-[4px] rounded-[var(--radius-sm)] border border-border bg-card p-[2px]`,"aria-label":`Pipeline phase filter`,children:ESt.map(e=>(0,z.jsx)(`button`,{type:`button`,className:vj(`rounded-[calc(var(--radius-sm)-2px)] px-[9px] py-[5px] text-[11px] font-medium capitalize text-muted-foreground transition-colors hover:text-foreground`,s.phase===e&&`bg-accent text-foreground`),"aria-pressed":s.phase===e,onClick:()=>b(e),children:e},e))}),h.length>0&&(0,z.jsx)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-[6px]`,"aria-label":`Pipeline project filter`,children:h.map(e=>{let t=s.projects.includes(e.id);return(0,z.jsx)(`button`,{type:`button`,className:vj(`rounded-full border border-border px-[9px] py-[5px] text-[11px] font-medium text-muted-foreground transition-colors hover:text-foreground`,t&&`border-primary/50 bg-primary/10 text-foreground`),"aria-pressed":t,onClick:()=>x(e.id),children:e.name},e.id)})}),(0,z.jsxs)(`div`,{className:`ml-auto flex items-center gap-[6px]`,"aria-label":`Pipeline merge modifiers`,children:[(0,z.jsx)(`button`,{type:`button`,className:vj(`rounded-[var(--radius-sm)] border border-border px-[9px] py-[5px] text-[11px] font-medium text-muted-foreground transition-colors hover:text-foreground`,s.phase===`ship`&&s.blocked&&`border-warning/50 bg-warning/10 text-foreground`),"aria-pressed":s.phase===`ship`&&s.blocked,onClick:()=>S(`blocked`),children:`Blocked`}),(0,z.jsx)(`button`,{type:`button`,className:vj(`rounded-[var(--radius-sm)] border border-border px-[9px] py-[5px] text-[11px] font-medium text-muted-foreground transition-colors hover:text-foreground`,s.phase===`ship`&&s.noPr&&`border-info/50 bg-info/10 text-foreground`),"aria-pressed":s.phase===`ship`&&s.noPr,onClick:()=>S(`noPr`),children:`No PR`})]})]}),(0,z.jsxs)(`div`,{ref:f,className:`flex-1 overflow-auto`,children:[v.every(e=>g[e].length===0)?(0,z.jsx)(`div`,{"data-component":`pipeline-empty-state`,className:`mx-[22px] mt-[24px] rounded-[18px] border border-dashed border-border bg-card px-6 py-10 text-center text-sm text-muted-foreground`,children:`No issues match the selected filters.`}):v.map(e=>(0,z.jsxs)(`section`,{ref:t=>{d.current[e]=t},"data-component":`pipeline-phase`,"data-phase":e,children:[(0,z.jsx)(Dvt,{phase:e,count:g[e].length}),g[e].map(t=>(0,z.jsx)(GSt,{issue:t,phase:e,agent:m.get(t.identifier.toLowerCase()),costEvents:l[t.identifier],now:u,onOpen:e=>{p.current=f.current?.scrollTop??0,a(e)}},t.identifier))]},e)),(0,z.jsx)(`div`,{className:`h-[72px]`,"data-component":`pipeline-footer-empty`})]})]})}async function qSt(e){let t=await fetch(`/api/workspaces/${e}`);return t.ok?t.json():{}}async function JSt(e){let t=await fetch(`/api/workspaces/${e}/uat-context`);return t.ok?t.json():{}}async function YSt(e){let t=await fetch(`/api/workspaces/${e}/rebuild-stack`,{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||`Rebuild failed (${t.status})`)}}async function XSt(e){let t=await fetch(`/api/issues/${e}/forge-merge`,{method:`POST`,headers:{"Content-Type":`application/json`}});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||`Merge failed (${t.status})`)}return t.json()}async function ZSt(e){let t=await fetch(`/api/issues/${e}/forge-approve`,{method:`POST`,headers:{"Content-Type":`application/json`}});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||`Approve failed (${t.status})`)}return t.json()}function QSt(e){let t=(e?.state??e?.status??``).trim().toLowerCase().replace(/[-\s]+/g,`_`);return t===`verifying`||t===`verifying_on_main`}async function $St(e){let t=await fetch(`/api/issues/${e}/merge`,{method:`POST`,headers:{"Content-Type":`application/json`}});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||`Merge failed (${t.status})`)}return t.json()}function eCt(){let e=_t(),t=sm(Dhe),n=sm(fm),r=(0,R.useMemo)(()=>{let e=new Map;for(let t of n)t?.identifier&&e.set(t.identifier.toLowerCase(),t),t?.id&&e.set(String(t.id).toLowerCase(),t);return e},[n]),i=(0,R.useMemo)(()=>{let e=e=>{let t=e.toUpperCase().split(`-`)[0];return t===`PAN`?0:t===`KRUX`?1:2};return t.filter(e=>{let t=r.get(e.issueId.toLowerCase());return!(t?.state===`canceled`||QSt(t)||t?.state===`done`&&(e.mergeStatus===`failed`||t?.mergeStatus===`failed`||Array.isArray(t?.labels)&&t.labels.includes(`merged`))||(e.blockerReasons?.length??0)>0)}).sort((t,n)=>{let r=e(t.issueId),i=e(n.issueId);return r===i?(t.updatedAt??``).localeCompare(n.updatedAt??``):r-i})},[t,r]),a=sm(Ohe),o=sm(khe),s=(0,R.useMemo)(()=>o.filter(e=>!QSt(r.get(e.issueId.toLowerCase()))),[o,r]),c=jt({queries:i.map(e=>({queryKey:[`workspace`,e.issueId],queryFn:()=>qSt(e.issueId),staleTime:3e4}))});return(0,z.jsx)(`div`,{className:`flex-1 overflow-y-auto bg-background`,children:(0,z.jsxs)(`div`,{className:`max-w-5xl mx-auto p-6`,children:[(0,z.jsxs)(`header`,{className:`mb-6`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-3 mb-1`,children:[(0,z.jsx)(Gn,{className:`w-6 h-6 text-primary`}),(0,z.jsx)(`h1`,{className:`text-2xl font-semibold text-foreground`,children:`Awaiting Merge`}),(0,z.jsx)(`span`,{className:`ml-2 text-xs px-2 py-0.5 rounded-full bg-accent text-muted-foreground`,children:i.length})]}),(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Issues that have passed review and test and are waiting for a human UAT + merge click. Open the frontend link to verify, then merge.`})]}),i.length===0?(0,z.jsx)(tCt,{}):(0,z.jsx)(`ul`,{className:`space-y-3`,children:i.map((t,n)=>{let i=r.get(t.issueId.toLowerCase()),a=c[n]?.data;return(0,z.jsx)(iCt,{issueId:t.issueId,title:i?.title??t.issueId,description:i?.description,identifier:i?.identifier??t.issueId,trackerUrl:i?.url,frontendUrl:a?.frontendUrl,apiUrl:a?.apiUrl,stackHealthy:a?.stackHealth?.healthy,stackHealth:a?.stackHealth,stackReason:a?.stackHealth?.reasons?.[0],containers:a?.containers,pendingOperation:a?.pendingOperation,prUrl:t.prUrl??a?.mrUrl,updatedAt:t.updatedAt,mergeStatus:t.mergeStatus,mergeStep:t.mergeStep,mergeNotes:t.mergeNotes,autoMerge:t.autoMerge,uatNotes:t.uatNotes,onMerged:()=>{e.invalidateQueries({queryKey:[`workspace`,t.issueId]}),e.invalidateQueries({queryKey:[`review-status`,t.issueId]}),e.invalidateQueries({queryKey:[`command-deck-projects`]})}},t.issueId)})}),a.length>0&&(0,z.jsxs)(`div`,{className:`mt-10`,children:[(0,z.jsxs)(`header`,{className:`mb-4`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-3 mb-1`,children:[(0,z.jsx)(Dr,{className:`w-5 h-5 text-destructive`}),(0,z.jsx)(`h2`,{className:`text-lg font-semibold text-foreground`,children:`Blocked from Merge`}),(0,z.jsx)(`span`,{className:`ml-2 text-xs px-2 py-0.5 rounded-full bg-destructive/15 text-destructive`,children:a.length})]}),(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`These issues were ready to merge but GitHub is blocking them. Resolve the blocker on GitHub and the issue will re-enter the queue automatically.`})]}),(0,z.jsx)(`ul`,{className:`space-y-3`,children:a.map(e=>{let t=r.get(e.issueId.toLowerCase());return(0,z.jsx)(oCt,{issueId:e.issueId,title:t?.title??e.issueId,identifier:t?.identifier??e.issueId,trackerUrl:t?.url,blockerReasons:e.blockerReasons??[],updatedAt:e.updatedAt},e.issueId)})})]}),s.length>0&&(0,z.jsx)(sCt,{openMergeRequests:s,issuesById:r})]})})}function tCt(){return(0,z.jsxs)(`div`,{className:`border border-dashed border-border rounded-lg p-10 text-center`,children:[(0,z.jsx)(on,{className:`w-10 h-10 text-muted-foreground mx-auto mb-3`}),(0,z.jsx)(`p`,{className:`text-sm text-foreground mb-1`,children:`Nothing awaiting merge.`}),(0,z.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`The flywheel is idling — kick off more work or run `,(0,z.jsx)(`code`,{children:`/all-up`}),`.`]})]})}var nCt=[{key:`queued`,label:`Queued in merge queue`},{key:`validating-pr`,label:`Validating PR state`},{key:`rebasing`,label:`Rebasing onto main`},{key:`stripping-planning`,label:`Stripping .planning/ artifacts`},{key:`verifying`,label:`Post-rebase verification`},{key:`reporting-statuses`,label:`Reporting commit statuses`},{key:`squash-merging`,label:`Squash merge via forge`},{key:`post-merge-cleanup`,label:`Post-merge cleanup`}];function rCt({mergeStep:e,mergeStatus:t,mergeNotes:n}){if(!e&&t!==`merging`&&t!==`verifying`&&t!==`queued`)return null;let r=nCt.findIndex(t=>t.key===e),i=t===`failed`;return(0,z.jsxs)(`div`,{className:`mt-3 pl-1 border-l-2 border-primary/20 ml-1`,children:[(0,z.jsx)(`div`,{className:`space-y-1.5 pl-3`,children:nCt.map((e,n)=>{let a,o;return i&&n===r?(a=(0,z.jsx)(un,{className:`w-3.5 h-3.5 text-destructive shrink-0`}),o=`text-destructive`):n<r||t===`merged`&&r===-1?(a=(0,z.jsx)(on,{className:`w-3.5 h-3.5 text-success shrink-0`}),o=`text-muted-foreground`):n===r?(a=(0,z.jsx)(ar,{className:`w-3.5 h-3.5 text-primary animate-spin shrink-0`}),o=`text-foreground font-medium`):(a=(0,z.jsx)(dn,{className:`w-3.5 h-3.5 text-muted-foreground/40 shrink-0`}),o=`text-muted-foreground/60`),(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[a,(0,z.jsx)(`span`,{className:`text-[11px] ${o}`,children:e.label})]},e.key)})}),i&&n&&(0,z.jsx)(`p`,{className:`text-[11px] text-destructive mt-2 pl-3`,children:n})]})}function iCt({issueId:e,identifier:t,title:n,description:r,trackerUrl:i,frontendUrl:a,apiUrl:o,stackHealthy:s,stackHealth:c,stackReason:l,containers:u,pendingOperation:d,prUrl:f,updatedAt:p,mergeStatus:m,mergeStep:h,mergeNotes:g,autoMerge:_,uatContext:v,uatNotes:y,onMerged:b}){let x=_t(),S=Nt({mutationFn:()=>$St(e),onSuccess:()=>{H.success(`Merge started for ${t}`),b()},onError:e=>{H.error(`Merge failed for ${t}`,{description:e.message})}}),C=Nt({mutationFn:()=>YSt(e),onSuccess:()=>{x.invalidateQueries({queryKey:[`workspace`,e]}),H.success(`Rebuilding stack for ${t}`,{description:`UAT environment status is now shown in this row, the issue tree, and the issue slide-out.`})},onError:e=>{H.error(`Stack rebuild failed for ${t}`,{description:e.message})}}),w=m===`merging`||m===`queued`||m===`verifying`||S.isPending,T=m===`failed`,E=d?.type===`rebuild-stack`&&d.status===`failed`,D=C.isPending||d?.status===`running`&&(d.type===`containerize`||d.type===`start`||d.type===`rebuild-stack`),[O,k]=(0,R.useState)(!1),A=B({queryKey:[`uat-context`,e],queryFn:()=>JSt(e),enabled:O&&!v,staleTime:5*6e4,refetchInterval:!1,refetchOnWindowFocus:!1}),j=v??A.data,M=j?.acceptanceCriteria?.filter(e=>e.title.trim())??[],N=j?.deliverables?.filter(e=>e.title.trim())??[],P=j?.changedFiles??[],F=j?.changedFilesOmitted??Math.max(0,(j?.changedFilesTotal??0)-P.length),I=j?.proposal?.trim(),ee=r?.trim()||n,te=!!(A.isLoading&&!A.isError&&!v);return(0,z.jsxs)(`li`,{className:`border border-border rounded-lg bg-card p-4`,"data-testid":`merge-row-${t}`,children:[(0,z.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[i?(0,z.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,className:`text-xs font-mono px-1.5 py-0.5 rounded bg-accent text-foreground hover:underline`,children:t}):(0,z.jsx)(`span`,{className:`text-xs font-mono px-1.5 py-0.5 rounded bg-accent text-foreground`,children:t}),T&&(0,z.jsxs)(`span`,{className:`text-[10px] uppercase tracking-wider px-1.5 py-0.5 rounded bg-destructive/15 text-destructive flex items-center gap-1`,title:`A previous merge attempt failed`,children:[(0,z.jsx)(Ir,{className:`w-3 h-3`}),`Last merge failed`]}),w&&(0,z.jsxs)(`span`,{className:`text-[10px] uppercase tracking-wider px-1.5 py-0.5 rounded bg-primary/15 text-primary flex items-center gap-1`,children:[(0,z.jsx)(ar,{className:`w-3 h-3 animate-spin`}),`Merge in progress`]}),p&&!w&&(0,z.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[`ready `,Z5(p)]})]}),(0,z.jsx)(`p`,{className:`text-sm text-foreground truncate`,title:n,children:n}),f&&(0,z.jsx)(`a`,{href:f,target:`_blank`,rel:`noreferrer`,className:`text-[11px] text-muted-foreground hover:text-foreground hover:underline mt-1 inline-block`,"data-testid":`merge-pr-link-${t}`,children:`View PR ↗`})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[s===!1?(0,z.jsxs)(`button`,{type:`button`,onClick:()=>C.mutate(),disabled:C.isPending,title:l?`Workspace stack is down: ${l}`:`Workspace stack is down — rebuild it to UAT`,className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md text-sm border border-amber-500/30 text-amber-600 dark:text-amber-400 hover:bg-amber-500/10 transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,children:[C.isPending?(0,z.jsx)(ar,{className:`w-3.5 h-3.5 animate-spin`}):(0,z.jsx)(jee,{className:`w-3.5 h-3.5`}),C.isPending?`Rebuilding…`:`Rebuild to UAT`]}):a?(0,z.jsxs)(`a`,{href:a,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md text-sm border border-border text-foreground hover:bg-accent transition-colors`,title:`Open the workspace frontend for UAT`,children:[(0,z.jsx)(kn,{className:`w-3.5 h-3.5`}),`UAT`]}):(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md text-sm border border-border text-muted-foreground/60 cursor-not-allowed`,title:`No frontend URL — workspace info unavailable`,children:[(0,z.jsx)(kn,{className:`w-3.5 h-3.5`}),`UAT`]}),(0,z.jsx)(q5,{issueId:e,autoMerge:_,compact:!0}),(0,z.jsxs)(`button`,{onClick:()=>S.mutate(),disabled:w,className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md text-sm bg-primary text-primary-foreground hover:opacity-90 transition-opacity disabled:opacity-50 disabled:cursor-not-allowed`,"data-testid":`merge-btn-${t}`,children:[w?(0,z.jsx)(ar,{className:`w-3.5 h-3.5 animate-spin`}):(0,z.jsx)(Gn,{className:`w-3.5 h-3.5`}),w?`Merging��`:`Merge`]})]})]}),(D||s===!1||u)&&(0,z.jsxs)(`div`,{className:`mt-3`,"data-testid":`merge-uat-stack-${t}`,children:[(0,z.jsx)(sH,{containers:u,stackHealth:c,frontendUrl:a,apiUrl:o,pending:D,density:`compact`}),E&&d?.error?(0,z.jsxs)(`p`,{className:`mt-2 rounded-md border border-destructive/30 bg-destructive/10 px-2.5 py-2 text-[11px] text-destructive`,children:[`Rebuild failed: `,d.error]}):null]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>k(e=>!e),className:`mt-3 inline-flex items-center gap-1.5 text-[11px] font-medium text-muted-foreground hover:text-foreground transition-colors`,"data-testid":`merge-uat-toggle-${t}`,children:[O?(0,z.jsx)(rn,{className:`w-3.5 h-3.5`}):(0,z.jsx)(en,{className:`w-3.5 h-3.5`}),`What to test / Expected changes`]}),O&&(0,z.jsxs)(`div`,{className:`mt-3 rounded-md border border-border/70 bg-muted/20 p-3`,"data-testid":`merge-uat-context-${t}`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,z.jsx)(qee,{className:`w-3.5 h-3.5 text-primary`}),(0,z.jsx)(`h3`,{className:`text-xs font-semibold text-foreground`,children:`What to test (UAT)`})]}),te&&(0,z.jsx)(`p`,{className:`text-[11px] text-muted-foreground mb-2`,children:`Loading UAT context…`}),M.length>0?(0,z.jsx)(`ul`,{className:`space-y-1.5`,children:M.map(e=>(0,z.jsxs)(`li`,{className:`flex items-start gap-2 text-xs text-foreground`,children:[(0,z.jsx)(dn,{className:`w-3.5 h-3.5 text-muted-foreground mt-0.5 shrink-0`}),(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`span`,{children:e.title}),e.itemTitle&&(0,z.jsxs)(`span`,{className:`ml-1 text-[11px] text-muted-foreground`,children:[`(`,e.itemTitle,`)`]})]})]},e.id))}):(0,z.jsx)(`p`,{className:`text-xs text-foreground whitespace-pre-wrap`,children:ee}),(0,z.jsxs)(`div`,{className:`mt-4 border-t border-border/60 pt-3`,children:[(0,z.jsx)(`h3`,{className:`text-xs font-semibold text-foreground mb-2`,children:`Expected changes`}),N.length>0?(0,z.jsx)(`ul`,{className:`space-y-1.5 mb-3`,children:N.map(e=>(0,z.jsxs)(`li`,{className:`text-xs text-foreground`,children:[(0,z.jsx)(`span`,{className:`font-medium`,children:e.title}),e.action&&(0,z.jsx)(`span`,{className:`block text-[11px] text-muted-foreground mt-0.5`,children:e.action})]},e.id))}):I?(0,z.jsx)(`p`,{className:`text-xs text-foreground whitespace-pre-wrap mb-3`,children:I}):(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground mb-3`,children:`No deliverables available.`}),(0,z.jsx)(`div`,{className:`space-y-1.5`,children:P.length>0?(0,z.jsxs)(z.Fragment,{children:[P.map(e=>(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] text-muted-foreground`,children:[(0,z.jsx)(`span`,{className:`font-mono px-1 py-0.5 rounded bg-accent text-foreground`,children:e.status}),(0,z.jsx)(`span`,{className:`font-mono text-foreground truncate`,children:e.path}),(0,z.jsxs)(`span`,{className:`ml-auto font-mono text-success`,children:[`+`,e.additions]}),(0,z.jsxs)(`span`,{className:`font-mono text-destructive`,children:[`-`,e.deletions]})]},`${e.status}:${e.path}`)),F>0&&(0,z.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,children:[`+`,F,` more files`]})]}):(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No file changes available.`})})]}),y?.trim()&&(0,z.jsxs)(`div`,{className:`mt-3 rounded border border-primary/20 bg-primary/5 px-2.5 py-2`,children:[(0,z.jsx)(`p`,{className:`text-[10px] uppercase tracking-wider text-primary mb-1`,children:`Reviewer UAT notes`}),(0,z.jsx)(`p`,{className:`text-xs text-foreground whitespace-pre-wrap`,children:y.trim()})]})]}),(w||T)&&(0,z.jsx)(rCt,{mergeStep:h,mergeStatus:m,mergeNotes:g})]})}function aCt(e){switch(e){case`failing_checks`:return(0,z.jsx)(un,{className:`w-3 h-3`});case`merge_conflict`:return(0,z.jsx)(Kn,{className:`w-3 h-3`});case`unresolved_conversations`:return(0,z.jsx)(cr,{className:`w-3 h-3`});case`changes_requested`:return(0,z.jsx)(dee,{className:`w-3 h-3`});case`draft_pr`:return(0,z.jsx)(Dee,{className:`w-3 h-3`});case`not_mergeable`:return(0,z.jsx)(Ir,{className:`w-3 h-3`});default:return(0,z.jsx)(Dr,{className:`w-3 h-3`})}}function oCt({identifier:e,title:t,trackerUrl:n,blockerReasons:r,updatedAt:i}){let[a,o]=(0,R.useState)(!1);return(0,z.jsxs)(`li`,{className:`border border-destructive/30 rounded-lg bg-card p-4 opacity-80`,children:[(0,z.jsx)(`div`,{className:`flex items-start gap-4`,children:(0,z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[n?(0,z.jsx)(`a`,{href:n,target:`_blank`,rel:`noreferrer`,className:`text-xs font-mono px-1.5 py-0.5 rounded bg-accent text-foreground hover:underline`,children:e}):(0,z.jsx)(`span`,{className:`text-xs font-mono px-1.5 py-0.5 rounded bg-accent text-foreground`,children:e}),i&&(0,z.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[`ready `,Z5(i)]})]}),(0,z.jsx)(`p`,{className:`text-sm text-foreground truncate`,title:t,children:t}),(0,z.jsx)(`div`,{className:`flex flex-wrap gap-2 mt-2`,children:r.map(e=>(0,z.jsxs)(`span`,{className:`text-[10px] uppercase tracking-wider px-2 py-0.5 rounded bg-destructive/15 text-destructive flex items-center gap-1`,title:e.details??e.summary,children:[aCt(e.type),e.type,`: `,e.summary]},e.type))})]})}),r.some(e=>e.details)&&(0,z.jsxs)(`button`,{onClick:()=>o(!a),className:`mt-2 flex items-center gap-1 text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:[a?(0,z.jsx)(rn,{className:`w-3 h-3`}):(0,z.jsx)(en,{className:`w-3 h-3`}),a?`Hide details`:`Show details`]}),a&&(0,z.jsx)(`div`,{className:`mt-2 space-y-1`,children:r.filter(e=>e.details).map(e=>(0,z.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,children:[(0,z.jsxs)(`span`,{className:`font-medium text-foreground`,children:[e.type,`:`]}),` `,e.details]},e.type))})]})}function X5(e,t){return!t||t===`pending`?(0,z.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider px-1.5 py-0.5 rounded bg-accent text-muted-foreground`,children:e}):t===`running`?(0,z.jsxs)(`span`,{className:`text-[10px] uppercase tracking-wider px-1.5 py-0.5 rounded bg-primary/15 text-primary flex items-center gap-1`,children:[(0,z.jsx)(ar,{className:`w-3 h-3 animate-spin`}),e]}):t===`passed`||t===`skipped`?(0,z.jsxs)(`span`,{className:`text-[10px] uppercase tracking-wider px-1.5 py-0.5 rounded bg-success/15 text-success flex items-center gap-1`,children:[(0,z.jsx)(on,{className:`w-3 h-3`}),e]}):t===`failed`?(0,z.jsxs)(`span`,{className:`text-[10px] uppercase tracking-wider px-1.5 py-0.5 rounded bg-destructive/15 text-destructive flex items-center gap-1`,children:[(0,z.jsx)(un,{className:`w-3 h-3`}),e]}):(0,z.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider px-1.5 py-0.5 rounded bg-accent text-muted-foreground`,children:e})}function sCt({openMergeRequests:e,issuesById:t}){let[n,r]=(0,R.useState)(!1);return(0,z.jsxs)(`div`,{className:`mt-10`,children:[(0,z.jsx)(`button`,{onClick:()=>r(!n),className:`w-full text-left`,children:(0,z.jsxs)(`header`,{className:`mb-4`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-3 mb-1`,children:[(0,z.jsx)(Ir,{className:`w-5 h-5 text-amber-500`}),(0,z.jsx)(`h2`,{className:`text-lg font-semibold text-foreground`,children:`Pipeline Override`}),(0,z.jsx)(`span`,{className:`ml-2 text-xs px-2 py-0.5 rounded-full bg-amber-500/15 text-amber-600 dark:text-amber-400`,children:e.length}),(0,z.jsx)(`span`,{className:`ml-auto text-muted-foreground`,children:n?(0,z.jsx)(rn,{className:`w-4 h-4`}):(0,z.jsx)(en,{className:`w-4 h-4`})})]}),!n&&(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`PRs still going through the review/test pipeline. Click to expand override actions.`})]})}),n&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`rounded-md border border-amber-500/30 bg-amber-500/5 p-3 mb-4 text-[12px] text-amber-700 dark:text-amber-300`,children:`These issues have open PRs but haven't completed the review/test pipeline. Merging here bypasses Overdeck's rebase, verification, and cleanup steps.`}),(0,z.jsx)(`ul`,{className:`space-y-3`,children:e.map(e=>{let n=t.get(e.issueId.toLowerCase());return(0,z.jsx)(cCt,{issueId:e.issueId,identifier:n?.identifier??e.issueId,title:n?.title??e.issueId,trackerUrl:n?.url,prUrl:e.prUrl,reviewStatus:e.reviewStatus,testStatus:e.testStatus,verificationStatus:e.verificationStatus,updatedAt:e.updatedAt},e.issueId)})})]})]})}function cCt({issueId:e,identifier:t,title:n,trackerUrl:r,prUrl:i,reviewStatus:a,testStatus:o,verificationStatus:s,updatedAt:c}){let l=Hr(),u=i?.includes(`gitlab`)?`GitLab`:`GitHub`,d=Nt({mutationFn:()=>ZSt(e),onSuccess:()=>{H.success(`Approved ${t}`)},onError:e=>{H.error(`Approve failed for ${t}`,{description:e.message})}}),f=Nt({mutationFn:()=>XSt(e),onSuccess:()=>{H.success(`Force merge started for ${t}`)},onError:e=>{H.error(`Force merge failed for ${t}`,{description:e.message})}});return(0,z.jsxs)(`li`,{className:`border border-amber-500/20 rounded-lg bg-card p-4 flex items-start gap-4`,children:[(0,z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[r?(0,z.jsx)(`a`,{href:r,target:`_blank`,rel:`noreferrer`,className:`text-xs font-mono px-1.5 py-0.5 rounded bg-accent text-foreground hover:underline`,children:t}):(0,z.jsx)(`span`,{className:`text-xs font-mono px-1.5 py-0.5 rounded bg-accent text-foreground`,children:t}),c&&(0,z.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[`opened `,Z5(c)]})]}),(0,z.jsx)(`p`,{className:`text-sm text-foreground truncate`,title:n,children:n}),(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-1.5 mt-2`,children:[X5(`review`,a),X5(`test`,o),X5(`verify`,s)]})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[i&&(0,z.jsxs)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md text-sm border border-border text-foreground hover:bg-accent transition-colors`,children:[(0,z.jsx)(kn,{className:`w-3.5 h-3.5`}),`View PR`]}),(0,z.jsxs)(`button`,{onClick:async()=>{await l({title:`Force Approve ${t}`,message:`This bypasses Overdeck's review pipeline and submits an approving review directly on ${u}.\n\nThe automated review/test pipeline will continue running independently.`,confirmLabel:`Force Approve`})&&d.mutate()},disabled:d.isPending,className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md text-sm border border-amber-500/30 text-amber-600 dark:text-amber-400 hover:bg-amber-500/10 transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,children:[d.isPending?(0,z.jsx)(ar,{className:`w-3.5 h-3.5 animate-spin`}):(0,z.jsx)(qee,{className:`w-3.5 h-3.5`}),`Force Approve`]}),(0,z.jsxs)(`button`,{onClick:async()=>{await l({title:`Force Merge ${t} (Skip Pipeline)`,message:`This will squash-merge directly via ${u}, bypassing:\n\n• Rebasing onto main\n• Post-rebase verification (typecheck/lint/test)\n• Post-merge cleanup (labels, issue close, Docker teardown)\n\nYou'll need to handle cleanup manually. Use this only when the issue was handled outside the automated pipeline.`,confirmLabel:`Force Merge`,variant:`destructive`})&&f.mutate()},disabled:f.isPending,className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md text-sm bg-amber-600 text-white hover:bg-amber-700 transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,children:[f.isPending?(0,z.jsx)(ar,{className:`w-3.5 h-3.5 animate-spin`}):(0,z.jsx)(Gn,{className:`w-3.5 h-3.5`}),`Force Merge`]})]})]})}function Z5(e){let t=new Date(e).getTime();if(Number.isNaN(t))return e;let n=Math.max(0,Math.round((Date.now()-t)/1e3));if(n<60)return`${n}s ago`;let r=Math.round(n/60);if(r<60)return`${r}m ago`;let i=Math.round(r/60);return i<24?`${i}h ago`:`${Math.round(i/24)}d ago`}var Q5=null;function lCt(){Q5?.releaseTimer&&window.clearTimeout(Q5.releaseTimer),Q5?.unsubscribe(),Q5=null}var uCt=[`review.security`,`review.correctness`,`review.performance`,`review.requirements`],$5=[`typecheck`,`lint`,`test`];function dCt(e,t){return e.identifier.toLowerCase()===t.toLowerCase()||e.id.toLowerCase()===t.toLowerCase()}function fCt(e){let t=new Map;for(let n of e)n.issueId&&t.set(n.id.toLowerCase(),n.issueId.toLowerCase());return t}function pCt(e,t,n){let r=t.toLowerCase();return e.issueId?e.issueId.toLowerCase()===r:e.agentId?n.get(e.agentId.toLowerCase())===r:!1}function mCt(e){let t=`${e.source??``} ${e.category??``} ${e.triggeringEvent??``}`.toLowerCase();return e.level===`success`||t.includes(`done`)||t.includes(`merge`)?`done`:t.includes(`ship`)?`ship`:t.includes(`review`)||t.includes(`test`)?`review`:t.includes(`work`)||t.includes(`agent`)?`work`:`info`}function hCt(e,t){return e.id??`${e.timestamp??`activity`}-${t}`}function gCt(e){return e.replace(`review.`,``)}function _Ct(e,t){let n=t?.reviewSubStatuses?.[e];return n===`done`?`done`:n===`running`?`run`:n===`failed`||t?.reviewStatus===`failed`||t?.reviewStatus===`blocked`?`fail`:`idle`}function vCt(e){switch(e){case`run`:return`running`;case`done`:return`complete`;case`fail`:return`blocked`;default:return`waiting`}}function yCt(e,t){let n=t?.reviewSessionNames?.find(t=>t.includes(gCt(e)));return n?n.replace(/^agent-/,``):`—`}function bCt(e){return uCt.map(t=>{let n=_Ct(t,e);return{id:t,name:t,status:n,meta:vCt(n),duration:yCt(t,e)}})}function xCt(e){return e===`closed`?`done`:e===`in_progress`?`current`:`open`}function e7(e){if(!e)return null;let t=new Date(e).getTime();return Number.isNaN(t)?null:t}function SCt(e,t){let n=e7(e),r=e7(t);if(n===null||r===null||r<n)return`—`;let i=Math.max(1,Math.round((r-n)/6e4));if(i<60)return`${i}m`;let a=Math.round(i/60);return a<24?`${a}h`:`${Math.round(a/24)}d`}function CCt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function wCt(e,t){return(e.title??e.name??e.id??`Untitled bead`).replace(RegExp(`^${CCt(t)}:\\s*`,`i`),``)}function TCt(e){if(!e)return;let t=e;return t.beads??t.tasks}function ECt(e,t){return(e??[]).map(e=>{let n=xCt(e.status);return{id:e.id??e.title??`bead`,title:wCt(e,t),status:n,duration:SCt(e.startedAt??e.createdAt,e.closedAt??e.updatedAt)}})}function DCt(e){return e===`passed`||e===`failed`||e===`pending`||e===`running`||e===`skipped`?e:e===`testing`?`running`:e===`dispatch_failed`?`failed`:`pending`}function OCt(e){return(e?.match(/Verification FAILED at (typecheck|lint|test)\b/i))?.[1]?.toLowerCase()}function kCt(e,t){let n=DCt(t?.verificationStatus);if(n===`passed`||n===`skipped`||n===`running`||n===`pending`)return n;let r=OCt(t?.verificationNotes);return r?e===r?`failed`:$5.indexOf(e)<$5.indexOf(r)?`passed`:`pending`:`passed`}function ACt(e){switch(e){case`passed`:return`pass`;case`failed`:return`fail`;case`running`:return`running`;case`skipped`:return`skipped`;default:return`pending`}}function jCt(e){let t=$5.map(t=>{let n=kCt(t,e);return{id:t,label:t,status:n,detail:ACt(n)}}),n=DCt(e?.uatStatus);return[...t,{id:`uat`,label:`UAT`,status:n,detail:ACt(n)}]}function t7(e){let t=e7(e);if(t===null)return`—`;let n=new Date(t);return`${String(n.getUTCMonth()+1).padStart(2,`0`)}/${String(n.getUTCDate()).padStart(2,`0`)}`}function MCt(e,t){let n=t?.mergeStatus===`merged`||e?.state===`done`||e?.status?.toLowerCase()===`done`||!!e?.completedAt,r=!n&&(t?.mergeStatus===`queued`||t?.mergeStatus===`merging`||t?.mergeStatus===`verifying`||!!t?.readyForMerge),i=n||r||t?.reviewStatus===`passed`,a=!i&&t?.reviewStatus===`reviewing`,o=i||a||t?.verificationStatus===`passed`||t?.testStatus===`passed`,s=!o&&(t?.verificationStatus===`running`||t?.testStatus===`testing`||e?.state===`in_progress`||e?.status?.toLowerCase()===`in progress`),c=o||s||!!e?.planningComplete,l=!c&&!!e?.hasPlan,u=n?-1:r?4:a?3:s?2:+!!l,d=[!!e,c,o,i,n,n];return[{id:`triaged`,label:`Triaged`,when:t7(e?.createdAt),sub:`issue`},{id:`planned`,label:`Planned`,when:t7(e?.updatedAt),sub:`plan`},{id:`implemented`,label:`Implemented`,when:t7(t?.updatedAt),sub:`work`},{id:`reviewed`,label:`Reviewed`,when:t7(t?.reviewSpawnedAt??t?.updatedAt),sub:`review`},{id:`shipping`,label:`Shipping`,when:t7(t?.updatedAt),sub:`ship`},{id:`merged`,label:`Merged`,when:t7(e?.completedAt??(n?t?.updatedAt:void 0)),sub:`done`}].map((e,t)=>({...e,state:d[t]?`done`:t===u?`current`:`upcoming`}))}function n7(e){let t=e,n=sm(fm),r=sm(lm),i=sm(e=>e.recentActivity),a=sm(e=>e.detailedActivity),o=sm(um(t??``));return(0,R.useEffect)(()=>{if(t)return Q5?.issueId===t?(Q5.releaseTimer!==null&&(window.clearTimeout(Q5.releaseTimer),Q5.releaseTimer=null),Q5.refCount+=1):(Q5&&lCt(),Q5={issueId:t,refCount:1,unsubscribe:hj().subscribe(e=>e[Pp.subscribeIssueEvents]({issueId:t}),e=>sm.getState().applyEvent(e)),releaseTimer:null}),()=>{Q5?.issueId===t&&(--Q5.refCount,Q5.refCount===0&&(Q5.releaseTimer=window.setTimeout(lCt,1e3)))}},[t]),(0,R.useMemo)(()=>{if(!t)return{issue:null,agents:[],reviewStatus:void 0,beads:[],reviewSpecialists:[],verificationGates:[],phaseTimeline:[],activityRail:[],activityFull:[]};let e=n.find(e=>dCt(e,t))??null,s=r.filter(e=>e.issueId?.toLowerCase()===t.toLowerCase()),c=fCt(r),l=new Map;for(let e of[...i,...a])pCt(e,t,c)&&l.set(hCt(e,l.size),e);let u=Array.from(l.entries()).map(([e,t])=>{let n=t.timestamp??``,r=n?new Date(n).getTime():0;return{id:e,phase:mCt(t),message:t.message??`Activity update`,when:n,time:Number.isNaN(r)?0:r}}).sort((e,t)=>t.time-e.time),d=u.slice(0,100);return{issue:e,agents:s,reviewStatus:o,beads:ECt(TCt(e),t),reviewSpecialists:bCt(o),verificationGates:jCt(o),phaseTimeline:MCt(e,o),activityRail:d,activityFull:u}},[r,a,t,n,i,o])}function r7(){return n7(sm(e=>e.drawer.issueId))}function NCt(){let{issue:e,reviewStatus:t}=r7(),n=e?.identifier;return(0,z.jsxs)(`footer`,{"data-component":`drawer-action-bar`,"data-testid":`drawer-action-bar`,className:`flex items-center gap-[10px] border-t border-border bg-card/70 px-[22px] py-[12px]`,children:[n?(0,z.jsx)(Gj,{issueId:n,mode:`hybrid`,pinRight:[`viewPr`],className:`flex min-w-0 flex-1 items-center gap-1`}):(0,z.jsx)(`div`,{className:`flex-1`}),n?(0,z.jsx)(cH,{issueId:n,reviewStatus:t,variant:`inspector`,issueState:e?.state??e?.status}):null]})}function PCt(e){return!(e.status===`dead`||e.status===`failed`)}function FCt(e,t){let n=e.firstFailureInRunAt??e.lastFailureAt??e.lastActivity??e.startedAt;if(!n)return 0;let r=new Date(n).getTime();return Number.isNaN(r)?0:Math.max(0,Math.floor((t.getTime()-r)/36e5))}function ICt(e){return gh(e.status)||e.troubled?{variant:`STUCK · Nh`,hours:FCt(e,new Date),className:`text-[9px]`}:nM(e)?{variant:`INPUT`,className:`text-[9px]`}:e.status===`stopped`?{variant:`STOPPED`,className:`text-[9px]`}:e.role===`plan`?{variant:`PLANNING`,className:`text-[9px]`}:e.role===`review`||e.role===`test`?{variant:`REVIEW RUNNING`,className:`text-[9px]`}:e.role===`ship`?{variant:`SHIP RUNNING`,className:`text-[9px]`}:{variant:`WORK RUNNING`,className:`text-[9px]`}}var LCt={"verb-line":`text-signal-review-foreground`,ok:`text-success-foreground`,warn:`text-warning-foreground`,err:`text-destructive-foreground`,neutral:`text-foreground`};function RCt(e){return/^[✗❌]|\bERR\b|\bERROR\b|\bFAIL\b/i.test(e)?`err`:/^!|\bWARN\b|\bWARNING\b/i.test(e)?`warn`:/^✓|\bOK\b|\bPASS\b|\bdone\b/i.test(e)?`ok`:/^[→▸✱]/.test(e)?`verb-line`:`neutral`}function zCt(e){return e===void 0?`loading`:e>=100?`$${e.toFixed(0)}`:e>=10?`$${e.toFixed(1)}`:e>=1?`$${e.toFixed(2)}`:e>0?`$${e.toFixed(3)}`:`$0`}function BCt(){let{agents:e}=r7(),t=e.find(PCt)??null,n=sm(t?jhe(t.id):()=>[]),[r,i]=(0,R.useState)(!1);if(!t)return(0,z.jsxs)(`section`,{id:`active-agent`,"data-component":`drawer-active-agent`,"data-testid":`drawer-active-agent`,className:`rounded-[var(--radius)] border border-border bg-card p-[14px]`,children:[(0,z.jsx)(`div`,{className:`mb-[8px] text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground`,children:`Active Agent`}),(0,z.jsx)(`div`,{className:`rounded-[10px] border border-border bg-background/45 px-[12px] py-[14px] text-[12px] text-muted-foreground`,children:`No active agent.`})]});let a=n.slice(-8),o=`${vh(t.model)} · ${vp(t)} · spend ${zCt(t.costSoFar)}`,s=async e=>{if(r)return!1;i(!0);try{let n=t.status===`running`||t.status===`starting`?`/api/agents/${t.id}/tell`:`/api/agents/${t.id}/resume`;console.log(`[drawer/active-agent] send to ${t.id} status=${t.status} endpoint=${n} messageLength=${e.length}`);let r=await fetch(n,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({message:e})});if(!r.ok){let e=await r.text();return console.warn(`[drawer/active-agent] send ${r.status} ${n}: ${e.slice(0,300)}`),!1}let i=await r.json().catch(()=>({}));return console.log(`[drawer/active-agent] send 200 ${n}: messageDelivered=${i.messageDelivered}`),!0}catch(e){return console.error(`[drawer/active-agent] send error:`,e),!1}finally{i(!1)}},c=t.status===`running`||t.status===`starting`,l=async()=>{if(r)return!1;i(!0);try{console.log(`[drawer/active-agent] resume click for ${t.id} status=${t.status}`);let e=await fetch(`/api/agents/${t.id}/resume`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({message:`Resumed from drawer`})}),n=await e.json().catch(()=>({}));return e.ok?(console.log(`[drawer/active-agent] resume 200: messageDelivered=${n.messageDelivered}`),!0):(console.warn(`[drawer/active-agent] resume ${e.status}: ${n.error??`unknown error`}`),!1)}finally{i(!1)}};return(0,z.jsxs)(`section`,{id:`active-agent`,"data-component":`drawer-active-agent`,"data-testid":`drawer-active-agent`,className:`rounded-[var(--radius)] border border-border border-l-[3px] border-l-signal-review bg-card p-[14px]`,children:[(0,z.jsxs)(`div`,{className:`flex items-start justify-between gap-[12px]`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-[8px]`,children:[(0,z.jsx)(`h3`,{className:`truncate font-mono text-[13px] font-semibold leading-none text-foreground`,children:t.id}),(0,z.jsx)(qj,{...ICt(t)})]}),(0,z.jsx)(`div`,{className:`mt-[6px] text-[10px] uppercase tracking-[0.08em] text-muted-foreground`,children:t.status===`stopped`?`Stopped Agent — send a message to resume`:`Active Agent`})]}),(0,z.jsx)(`div`,{className:`shrink-0 text-right font-mono text-[10px] leading-none text-muted-foreground`,children:o})]}),(0,z.jsx)(`div`,{"data-testid":`drawer-active-agent-stream`,className:`mt-[12px] max-h-[180px] overflow-auto rounded-[10px] border border-border bg-[rgb(0_0_0_/_32%)] px-[12px] py-[10px] font-mono text-[11px] leading-[16px]`,children:a.length>0?a.map((e,t)=>(0,z.jsx)(`div`,{className:`truncate ${LCt[RCt(e)]}`,children:e},`${e}-${t}`)):(0,z.jsx)(`div`,{className:`italic text-muted-foreground`,children:`No recent stream output`})}),!c&&(0,z.jsx)(`button`,{type:`button`,"data-testid":`drawer-resume-button`,className:`mt-[10px] w-full rounded-[var(--radius-sm)] border border-primary/30 bg-primary/10 px-[12px] py-[8px] text-[12px] font-medium text-primary transition-colors hover:bg-primary/20 disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>void l(),disabled:r,title:`Send a continue message to wake the agent. The backend will auto-resume the saved session and deliver the message in one round trip.`,children:r?`Resuming…`:`▶ Resume agent`}),(0,z.jsx)(Aj,{className:`mt-[10px] flex gap-[8px]`,sending:r,onSend:s})]})}async function VCt(e){let t=await fetch(`/api/agents/${encodeURIComponent(e)}/git-info`);return t.ok?t.json():null}var HCt=new Set([`stopped`,`dead`,`failed`]);function i7(e){return HCt.has(e.status)}function UCt(e){let t=e.filter(e=>!i7(e));return t.find(e=>e.role===`work`)??e.find(e=>e.role===`work`)??t[0]??e[0]??null}function WCt(e){let t=i7(e);return{id:-1,name:e.id,tmuxSession:e.id,status:t?`ended`:`active`,cwd:e.workspace??``,issueId:e.issueId??null,createdAt:e.startedAt,endedAt:t?e.lastActivity??e.startedAt:null,lastAttachedAt:null,sessionAlive:!t,sessionFile:e.id,model:e.model,harness:e.harness??e.runtime??null}}function GCt(e){return`${e.role?`${e.role[0].toUpperCase()}${e.role.slice(1)}`:`Agent`} · ${e.id}`}function KCt({view:e,agents:t,agentId:n,onSelectAgent:r}){let i=`drawer-tab-panel-${e}`,a=(0,R.useMemo)(()=>t.find(e=>e.id===n)??null,[t,n]),o=(0,R.useMemo)(()=>a?WCt(a):null,[a]),{hideToolCalls:s,toggleHideToolCalls:c}=JY(a?.id??``),{data:l}=B({queryKey:[`agent-git-info`,a?.id],queryFn:()=>a?VCt(a.id):Promise.resolve(null),enabled:!!a,staleTime:3e4,refetchInterval:3e4});if(!a||!o)return(0,z.jsxs)(`div`,{"data-testid":i,className:`rounded-[var(--radius)] border border-dashed border-border bg-card/60 p-[18px]`,children:[(0,z.jsx)(`div`,{className:`mb-[8px] text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground`,children:e===`conversation`?`Conversation`:`Terminal`}),(0,z.jsxs)(`p`,{className:`text-[13px] leading-6 text-muted-foreground`,children:[`No agent session for this issue yet. The `,e===`conversation`?`transcript`:`live terminal`,` appears here once an agent starts.`]})]});let u=!!(l?.actualBranch||l?.workspaceMissing),d=!!l?.branchDrifted,f=!!l?.workspaceMissing;return(0,z.jsxs)(`div`,{"data-testid":i,className:`flex min-h-0 flex-1 flex-col gap-[10px]`,children:[(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-[8px]`,children:[t.length>1&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground`,children:`Agent`}),(0,z.jsx)(`select`,{value:a.id,onChange:e=>r(e.target.value),"aria-label":`Select agent session`,className:`rounded-[var(--radius-sm)] border border-border bg-card px-[8px] py-[4px] text-[12px] text-foreground`,children:t.map(e=>(0,z.jsx)(`option`,{value:e.id,children:GCt(e)},e.id))})]}),u&&(0,z.jsx)(`span`,{className:`${J.terminalBranchBar} ${f?J.terminalBranchBarMissing:d?J.terminalBranchBarDrift:``}`,title:f?`Workspace missing on disk: ${l?.workspacePath??`(unknown path)`}`:d?`Expected ${l?.expectedBranch??`(none)`}, on ${l?.actualBranch??`(none)`}`:`${l?.workspacePath??``}`,"data-testid":`drawer-agent-branch-chip`,children:f?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(an,{size:12}),(0,z.jsx)(`span`,{className:J.terminalBranchBarMode,children:`Worktree missing`})]}):(0,z.jsxs)(z.Fragment,{children:[d?(0,z.jsx)(Ir,{size:12}):(0,z.jsx)(Wn,{size:12}),(0,z.jsx)(`span`,{className:J.terminalBranchBarMode,children:d?`Drifted`:`Worktree`}),(0,z.jsx)(`span`,{className:J.terminalBranchBarText,children:l?.actualBranch})]})}),(0,z.jsxs)(`button`,{type:`button`,className:`ml-auto ${J.conversationAboutToggle} ${s?J.conversationAboutToggleActive:``}`,onClick:c,title:s?`Show tool calls`:`Hide tool calls`,"aria-label":s?`Show tool calls`:`Hide tool calls`,"aria-pressed":s,children:[(0,z.jsx)(Rr,{size:14}),(0,z.jsx)(`span`,{children:`Tools`})]})]}),(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden rounded-[var(--radius)] border border-border`,children:e===`conversation`?(0,z.jsx)(s5,{conversation:o,viewMode:`conversation`,embedded:!0,agentId:a.id,hideToolCalls:s,onToggleHideToolCalls:c},a.id):i7(a)?(0,z.jsx)(`div`,{className:`flex h-full items-center justify-center p-[18px] text-[13px] text-muted-foreground`,children:`Session ended — no live terminal to attach.`}):(0,z.jsx)(IS,{sessionName:a.id},a.id)})]})}var qCt={work:`bg-primary`,review:`bg-signal-review`,ship:`bg-warning`,done:`bg-success`,info:`bg-info`};function JCt(e){if(!e)return`just now`;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}function YCt(){let{activityRail:e}=r7(),t=(0,R.useRef)(null),n=e[0]?.id;return(0,R.useEffect)(()=>{t.current&&(t.current.scrollTop=0)},[n]),(0,z.jsx)(`aside`,{"data-component":`drawer-activity-rail`,"data-testid":`drawer-activity-rail`,className:`w-[320px] shrink-0 border-l border-border bg-card/70`,children:(0,z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,z.jsx)(`div`,{className:`border-b border-border px-[16px] py-[13px]`,children:(0,z.jsx)(`div`,{className:`text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground`,children:`Live Activity`})}),(0,z.jsx)(`div`,{ref:t,"data-testid":`drawer-activity-rail-scroll`,className:`min-h-0 flex-1 overflow-auto px-[16px] py-[14px]`,children:e.length===0?(0,z.jsx)(`div`,{className:`rounded-[12px] border border-dashed border-border px-[12px] py-[18px] text-center text-[12px] text-muted-foreground`,children:`No activity yet.`}):(0,z.jsx)(`div`,{className:`space-y-[12px]`,children:e.map(e=>(0,z.jsxs)(`div`,{className:`grid grid-cols-[14px_1fr] gap-[10px]`,"data-phase":e.phase,children:[(0,z.jsx)(`span`,{"data-testid":`drawer-activity-dot-${e.phase}`,className:vj(`mt-[4px] h-[8px] w-[8px] rounded-full`,qCt[e.phase])}),(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`div`,{className:`text-[12px] leading-[18px] text-foreground`,children:e.message}),(0,z.jsx)(`div`,{className:`mt-[2px] font-mono text-[10px] leading-none text-muted-foreground`,children:JCt(e.when)})]})]},e.id))})})]})})}function XCt({status:e}){return e===`done`?(0,z.jsx)(`span`,{"data-testid":`drawer-bead-status-done`,className:`flex h-[18px] w-[18px] items-center justify-center rounded-full bg-success text-[9px] font-bold leading-none text-white`,children:`✓`}):e===`current`?(0,z.jsxs)(`span`,{"data-testid":`drawer-bead-status-current`,className:`relative flex h-[18px] w-[18px] items-center justify-center`,children:[(0,z.jsx)(`span`,{className:`drawer-bead-current-ping absolute h-[18px] w-[18px] rounded-full border-[1.5px] border-info`}),(0,z.jsx)(`span`,{className:`h-[10px] w-[10px] rounded-full bg-info`})]}):(0,z.jsx)(`span`,{"data-testid":`drawer-bead-status-open`,className:`h-[18px] w-[18px] rounded-full border border-border bg-background/60`})}function ZCt({issueId:e}={}){let t=sm(e=>e.drawer.issueId),{beads:n}=n7(e??t);return(0,z.jsxs)(`section`,{"data-component":`drawer-beads-list`,"data-testid":`drawer-beads-list`,className:`overflow-hidden rounded-[var(--radius)] border border-border bg-card`,children:[(0,z.jsx)(`div`,{className:`border-b border-border px-[14px] py-[10px] text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground`,children:`Beads`}),n.length===0?(0,z.jsx)(`div`,{className:`px-[14px] py-[16px] text-[12px] text-muted-foreground`,children:`No beads yet.`}):(0,z.jsx)(`div`,{className:`divide-y divide-border/60`,children:n.map(e=>(0,z.jsxs)(`div`,{className:`grid grid-cols-[18px_1fr_auto_auto] items-center gap-[10px] px-[14px] py-[10px]`,children:[(0,z.jsx)(XCt,{status:e.status}),(0,z.jsx)(`span`,{className:vj(`min-w-0 truncate text-[12px] leading-[18px] text-foreground`,e.status===`done`&&`text-muted-foreground line-through decoration-[rgba(255,255,255,0.18)]`),children:e.title}),(0,z.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:e.id}),(0,z.jsx)(`span`,{className:`font-mono text-[10px] tabular-nums text-muted-foreground`,children:e.duration})]},e.id))})]})}var QCt={run:`bg-info`,idle:`bg-muted-foreground`,done:`bg-success`,fail:`bg-destructive`};function $Ct({issueId:e}={}){let t=sm(e=>e.drawer.issueId),{reviewSpecialists:n}=n7(e??t);return(0,z.jsxs)(`section`,{"data-component":`drawer-review-specialists`,"data-testid":`drawer-review-specialists`,className:`rounded-[var(--radius)] border border-border bg-card p-[14px]`,children:[(0,z.jsx)(`div`,{className:`mb-[10px] text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground`,children:`Review Specialists`}),(0,z.jsx)(`div`,{className:`space-y-[8px]`,children:n.map(e=>(0,z.jsxs)(`div`,{className:`grid grid-cols-[14px_1fr_auto_auto] items-center gap-[10px] rounded-[10px] bg-background/45 px-[10px] py-[8px]`,children:[(0,z.jsx)(`span`,{"data-testid":`drawer-review-specialist-dot-${e.status}`,className:vj(`h-[8px] w-[8px] rounded-full`,QCt[e.status])}),(0,z.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[11px] text-foreground`,children:e.name}),(0,z.jsx)(`span`,{className:`text-[10px] uppercase tracking-[0.06em] text-muted-foreground`,children:e.meta}),(0,z.jsx)(`span`,{className:`max-w-[120px] truncate font-mono text-[10px] text-muted-foreground`,title:e.duration,children:e.duration})]},e.id))})]})}var ewt=[{id:`overview`,label:`Overview`},{id:`plan`,label:`Plan`},{id:`beads`,label:`Beads`},{id:`conversation`,label:`Conversation`},{id:`terminal`,label:`Terminal`},{id:`activity`,label:`Activity`},{id:`files`,label:`Files`},{id:`artifacts`,label:`Artifacts`}];function twt(e){return e.length===0?`0/0`:`${e.filter(e=>e.status===`done`).length}/${e.length}`}function nwt(){let e=sm(e=>e.drawer.tab),t=sm(e=>e.setDrawerTab),{beads:n}=r7();return(0,z.jsx)(`nav`,{"data-component":`drawer-tabs`,"data-testid":`drawer-tabs`,className:`border-b border-border bg-background/95 px-[14px]`,role:`tablist`,"aria-label":`Issue drawer sections`,children:(0,z.jsx)(`div`,{className:`flex min-w-0 items-center overflow-x-auto`,children:ewt.map(r=>{let i=e===r.id;return(0,z.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":i,"data-testid":`drawer-tab-${r.id}`,className:vj(`relative flex shrink-0 items-center px-[14px] py-[10px] text-[13px] font-medium text-muted-foreground transition-colors hover:text-foreground`,i&&`text-foreground`),onClick:()=>t(r.id),children:[r.label,r.id===`beads`?(0,z.jsx)(`span`,{"data-testid":`drawer-tab-beads-count`,className:`ml-[6px] rounded-full bg-primary/15 px-[5px] py-[1px] font-mono text-[10px] leading-none text-primary`,children:twt(n)}):null,i?(0,z.jsx)(`span`,{"data-testid":`drawer-tab-active-underline`,className:`absolute bottom-0 left-[14px] right-[14px] h-[2px] bg-primary`}):null]},r.id)})})})}var rwt={passed:`drawer-gate-border-pass text-success-foreground`,failed:`drawer-gate-border-fail text-destructive-foreground`,running:`badge-border-info text-info-foreground`,skipped:`badge-border-muted text-muted-foreground`,pending:`badge-border-muted text-muted-foreground`};function iwt({issueId:e}={}){let t=sm(e=>e.drawer.issueId),{verificationGates:n}=n7(e??t);return(0,z.jsxs)(`section`,{"data-component":`drawer-verification-gates`,"data-testid":`drawer-verification-gates`,className:`rounded-[var(--radius)] border border-border bg-card p-[14px]`,children:[(0,z.jsx)(`div`,{className:`mb-[10px] text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground`,children:`Verification Gates`}),(0,z.jsx)(`div`,{className:`grid grid-cols-4 gap-[8px]`,children:n.map(e=>(0,z.jsxs)(`div`,{"data-testid":`drawer-verification-gate-${e.id}`,className:vj(`rounded-[10px] border bg-background/45 px-[12px] py-[10px]`,rwt[e.status]),children:[(0,z.jsx)(`div`,{className:`text-[14px] font-medium leading-none`,children:e.detail}),(0,z.jsx)(`div`,{className:`mt-[6px] font-mono text-[10px] uppercase leading-none text-muted-foreground`,children:e.label})]},e.id))})]})}var awt={done:`bg-success`,current:`bg-signal-review`,upcoming:`bg-transparent`};function owt({issueId:e}={}){let t=sm(e=>e.drawer.issueId),{phaseTimeline:n}=n7(e??t);return(0,z.jsx)(`section`,{"data-component":`drawer-phase-timeline`,"data-testid":`drawer-phase-timeline`,className:`grid grid-cols-6 overflow-hidden rounded-[var(--radius)] border border-border bg-card`,children:n.map(e=>(0,z.jsxs)(`div`,{"data-testid":`drawer-phase-${e.id}`,className:`min-w-0 border-r border-border/60 last:border-r-0`,children:[(0,z.jsx)(`div`,{"data-testid":`drawer-phase-accent-${e.state}`,className:vj(`h-[2px]`,awt[e.state])}),(0,z.jsxs)(`div`,{className:`min-w-0 px-[7px] py-[8px]`,children:[(0,z.jsx)(`div`,{className:`truncate text-[10px] font-semibold leading-none text-foreground/80`,title:e.label,children:e.label}),(0,z.jsx)(`div`,{className:vj(`mt-[7px] truncate font-mono text-[10px] leading-none`,e.state===`current`?`font-medium text-foreground`:`text-muted-foreground`),children:e.when}),(0,z.jsx)(`div`,{className:`mt-[6px] truncate text-[9px] leading-none text-muted-foreground`,children:e.sub})]})]},e.id))})}var swt={work:`bg-primary`,review:`bg-signal-review`,ship:`bg-warning`,done:`bg-success`,info:`bg-info`};function cwt(e){if(!e)return`just now`;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}function lwt(){let{activityFull:e}=r7();return(0,z.jsx)(`div`,{"data-testid":`drawer-tab-panel-activity`,children:e.length===0?(0,z.jsx)(`div`,{className:`rounded-[12px] border border-dashed border-border px-[12px] py-[18px] text-center text-[12px] text-muted-foreground`,children:`No activity yet.`}):(0,z.jsx)(`div`,{className:`space-y-[12px]`,children:e.map(e=>(0,z.jsxs)(`div`,{className:`grid grid-cols-[14px_1fr] gap-[10px]`,"data-phase":e.phase,children:[(0,z.jsx)(`span`,{"aria-hidden":`true`,className:vj(`mt-[4px] h-[8px] w-[8px] rounded-full`,swt[e.phase])}),(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`div`,{className:`text-[12px] leading-[18px] text-foreground`,children:e.message}),(0,z.jsx)(`div`,{className:`mt-[2px] font-mono text-[10px] leading-none text-muted-foreground`,children:cwt(e.when)})]})]},e.id))})})}function uwt({issueId:e}){let{data:t,isLoading:n,isError:r}=B({queryKey:[`drawer-vbrief-plan`,e],queryFn:async()=>{let t=await fetch(`/api/workspaces/${e}/plan`);return t.ok?t.json():null},retry:!1});return(0,z.jsx)(`div`,{"data-testid":`drawer-tab-panel-plan`,children:n?(0,z.jsx)(`div`,{className:`text-[12px] text-muted-foreground`,children:`Loading plan…`}):r?(0,z.jsx)(`div`,{className:`text-[12px] text-muted-foreground`,children:`Failed to load plan`}):(0,z.jsx)(ak,{doc:t??null})})}function dwt({issueId:e}){let{data:t}=B({queryKey:[`drawer-workspace`,e],queryFn:async()=>{let t=await fetch(`/api/workspaces/${e}`);return t.ok?t.json():null},retry:!1});return!t?.exists||!t.path?null:(0,z.jsxs)(`section`,{"data-testid":`drawer-workspace-section`,className:`rounded-[var(--radius)] border border-border bg-card p-[14px]`,children:[(0,z.jsx)(`div`,{className:`mb-[8px] text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground`,children:`Workspace`}),(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-[12px]`,children:[(0,z.jsx)(`div`,{className:`min-w-0 truncate font-mono text-[11px] leading-[18px] text-muted-foreground`,title:t.path,children:t.path}),(0,z.jsx)(`div`,{className:`shrink-0`,children:(0,z.jsx)(zj,{openInCwd:t.path})})]})]})}function fwt(e){return e.replace(/-/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function pwt({tab:e}){return(0,z.jsxs)(`div`,{"data-testid":`drawer-tab-panel-${e}`,className:`rounded-[var(--radius)] border border-dashed border-border bg-card/60 p-[18px]`,children:[(0,z.jsx)(`div`,{className:`mb-[8px] text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground`,children:fwt(e)}),(0,z.jsx)(`p`,{className:`text-[13px] leading-6 text-muted-foreground`,children:`This drawer section will appear here as data streams in.`})]})}function mwt(){let e=sm(e=>e.drawer),t=sm(e=>e.closeIssue),n=sm(e=>e.syncDrawerFromUrl),{issue:r,agents:i}=r7(),[a,o]=(0,R.useState)(null),s=(0,R.useMemo)(()=>a&&i.some(e=>e.id===a)?a:UCt(i)?.id??null,[a,i]);return(0,R.useEffect)(()=>{n()},[n]),(0,R.useEffect)(()=>{if(!e.issueId)return;let n=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[t,e.issueId]),(0,R.useEffect)(()=>{if(!e.issueId)return;let t=null,n=0,r=()=>{if(window.location.hash!==`#active-agent`)return;let e=document.getElementById(`active-agent`);if(e){e.scrollIntoView({block:`start`});return}n++,n<30&&(t=window.requestAnimationFrame(r))},i=()=>{t&&=(window.cancelAnimationFrame(t),null),n=0,r()};return i(),window.addEventListener(`hashchange`,i),()=>{window.removeEventListener(`hashchange`,i),t&&window.cancelAnimationFrame(t)}},[e.issueId]),e.issueId?(0,z.jsx)(`div`,{"data-component":`issue-drawer`,"data-testid":`issue-drawer-scrim`,className:`fixed inset-0 z-[100] flex justify-end bg-black/20 backdrop-blur-[2px]`,onClick:t,children:(0,z.jsxs)(`aside`,{role:`dialog`,"aria-modal":`true`,"aria-label":r?`Issue ${r.identifier}`:`Issue ${e.issueId}`,"data-testid":`issue-drawer`,className:`flex h-screen w-[min(980px,calc(100vw-48px))] max-w-[calc(100vw-48px)] origin-right scale-100 flex-col overflow-hidden border-l border-border bg-background opacity-100 shadow-[-24px_0_64px_rgb(0_0_0_/_40%)] animate-[issue-drawer-slide-in_200ms_ease-in-out]`,onClick:e=>e.stopPropagation(),children:[(0,z.jsxs)(`header`,{className:`flex h-[52px] items-center gap-[12px] border-b border-border px-[22px]`,children:[(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`div`,{className:`truncate font-mono text-[11px] uppercase tracking-[0.08em] text-muted-foreground`,children:e.issueId}),(0,z.jsx)(`h2`,{className:`truncate font-display text-[22px] font-semibold leading-none tracking-[-0.01em] text-foreground`,children:r?.title??`Issue details`})]}),(()=>{let t=dvt(e.issueId??``,r?.url);return t?(0,z.jsxs)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,title:`Open ${e.issueId} on its tracker`,className:`inline-flex items-center gap-[6px] rounded-[var(--radius-sm)] border border-border px-[10px] py-[6px] text-[13px] text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,children:[(0,z.jsx)(kn,{className:`h-[14px] w-[14px]`}),`Issue`]}):null})(),(0,z.jsx)(`button`,{type:`button`,"aria-label":`Close issue drawer`,className:`rounded-[var(--radius-sm)] border border-border px-[10px] py-[6px] text-[13px] text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,onClick:t,children:`×`})]}),(0,z.jsx)(hwt,{agents:i}),(0,z.jsx)(nwt,{}),(0,z.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-[minmax(0,1fr)_320px]`,children:[(0,z.jsx)(`div`,{className:vj(`flex min-w-0 flex-col`,e.tab===`conversation`||e.tab===`terminal`?`min-h-0 p-[14px]`:`overflow-auto px-[22px] py-[18px]`),children:e.tab===`overview`?(0,z.jsxs)(`div`,{"data-testid":`drawer-tab-panel-overview`,className:`space-y-[14px]`,children:[(0,z.jsx)(owt,{}),(0,z.jsx)(dwt,{issueId:e.issueId}),(0,z.jsx)(BCt,{}),(0,z.jsx)(iwt,{}),(0,z.jsx)(ZCt,{}),(0,z.jsx)($Ct,{})]}):e.tab===`beads`?(0,z.jsx)(`div`,{"data-testid":`drawer-tab-panel-beads`,children:(0,z.jsx)(ZCt,{})}):e.tab===`plan`&&e.issueId?(0,z.jsx)(uwt,{issueId:e.issueId}):e.tab===`activity`?(0,z.jsx)(lwt,{}):e.tab===`artifacts`?(0,z.jsx)(Hyt,{issueId:e.issueId}):e.tab===`conversation`?(0,z.jsx)(KCt,{view:`conversation`,agents:i,agentId:s,onSelectAgent:o}):e.tab===`terminal`?(0,z.jsx)(KCt,{view:`terminal`,agents:i,agentId:s,onSelectAgent:o}):(0,z.jsx)(pwt,{tab:e.tab})}),(0,z.jsx)(YCt,{})]}),(0,z.jsx)(NCt,{})]})}):null}function hwt({agents:e}){let t=e.filter(e=>e.paused===!0);if(t.length===0)return null;let n=async e=>{try{let t=await fetch(`/api/agents/${e}/unpause`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})}),n=await t.json().catch(()=>({}));if(!t.ok)throw Error(n.error||`Failed to unpause agent`);H.success(`${e} unpaused — deacon resumes it on the next patrol`)}catch(e){H.error(e instanceof Error?e.message:`Failed to unpause agent`)}};return(0,z.jsx)(`div`,{"data-testid":`drawer-paused-banner`,className:`space-y-[6px] border-b border-border px-[22px] py-[10px]`,children:t.map(e=>(0,z.jsxs)(`div`,{className:`flex items-center gap-[10px] rounded-[var(--radius-sm)] border px-[12px] py-[8px] badge-border-warning badge-bg-warning`,children:[(0,z.jsx)(`span`,{className:`text-[14px] leading-none text-warning-foreground`,children:`⏸`}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsxs)(`div`,{className:`text-[13px] font-medium text-warning-foreground`,children:[(0,z.jsx)(`span`,{className:`font-mono`,children:e.id}),` is paused`]}),e.pausedReason&&(0,z.jsx)(`div`,{className:`truncate text-[12px] text-warning-foreground/75`,title:e.pausedReason,children:e.pausedReason})]}),(0,z.jsx)(`button`,{type:`button`,"data-testid":`drawer-unpause-${e.id}`,onClick:()=>void n(e.id),className:`inline-flex shrink-0 items-center gap-[4px] rounded-[var(--radius-sm)] border px-[10px] py-[5px] text-[12px] font-medium badge-border-warning text-warning-foreground transition-colors hover:bg-warning/20`,children:`▶ Unpause`})]},e.id))})}function gwt(){let e=_t(),t=sm(Fhe);(0,R.useEffect)(()=>{t&&e.setQueryData([`resources`],t)},[t,e])}function _wt(e){return e>=85?`bg-destructive`:e>=60?`bg-warning`:`bg-success`}function a7({value:e,label:t,showValue:n=!0,className:r=``}){let i=Math.min(100,Math.max(0,e)),a=_wt(i);return(0,z.jsxs)(`div`,{className:`flex flex-col gap-0.5 ${r}`,children:[(t||n)&&(0,z.jsxs)(`div`,{className:`flex justify-between items-center`,children:[t&&(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t}),n&&(0,z.jsxs)(`span`,{className:`text-xs text-muted-foreground ml-auto`,children:[i.toFixed(1),`%`]})]}),(0,z.jsx)(`div`,{className:`h-1.5 bg-popover rounded-full overflow-hidden`,children:(0,z.jsx)(`div`,{className:`h-full rounded-full transition-all duration-500 ${a}`,style:{width:`${i}%`}})})]})}CF.register(_Je,bJe,wqe,TF,kGe,Zqe);function o7({data:e,color:t=`rgba(59,130,246,0.8)`,height:n=32,maxValue:r=100}){let i=(0,R.useRef)(null),a=(0,R.useRef)(null);return(0,R.useEffect)(()=>{let n=i.current;if(!n)return;let o={labels:e.map(()=>``),datasets:[{data:e,borderColor:t,borderWidth:1.5,fill:!0,backgroundColor:t.replace(/[\d.]+\)$/,`0.15)`),pointRadius:0,tension:.3}]},s={responsive:!1,animation:!1,plugins:{legend:{display:!1},tooltip:{enabled:!1}},scales:{x:{display:!1},y:{display:!1,min:0,max:r}}};return a.current?(a.current.data=o,a.current.update(`none`)):a.current=new CF(n,{type:`line`,data:o,options:s}),()=>{a.current?.destroy(),a.current=null}},[]),(0,R.useEffect)(()=>{a.current&&(a.current.data.labels=e.map(()=>``),a.current.data.datasets[0].data=e,a.current.update(`none`))},[e]),(0,z.jsx)(`canvas`,{ref:i,width:80,height:n,style:{display:`block`}})}function vwt(e){return e>=1024**3?`${(e/1024**3).toFixed(1)}GiB`:e>=1024**2?`${(e/1024**2).toFixed(0)}MiB`:e>=1024?`${(e/1024).toFixed(0)}KiB`:`${e}B`}var ywt={running:`bg-success`,stopped:`bg-destructive`,unhealthy:`bg-warning`,restarting:`bg-warning`},bwt={running:`running`,stopped:`stopped`,unhealthy:`unhealthy`,restarting:`restarting`},xwt={healthy:`bg-success`,warning:`bg-warning`,stuck:`bg-warning`,stalled:`bg-warning`,dead:`bg-destructive`,stopped:`bg-popover`,starting:`bg-signal-review`,running:`bg-primary`,failed:`bg-destructive`,error:`bg-destructive`,unknown:`bg-warning`};function Swt({container:e,history:t,onClick:n}){let r=e.cpuPercent>=85?`rgba(239,68,68,0.8)`:e.cpuPercent>=60?`rgba(234,179,8,0.8)`:`rgba(59,130,246,0.8)`;return(0,z.jsxs)(`button`,{onClick:()=>n(e),className:`w-full text-left bg-card border border-border rounded-lg p-3 hover:border-primary/50 hover:bg-popover transition-colors`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,z.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0 ${ywt[e.status]}`}),(0,z.jsx)(`span`,{className:`text-xs font-medium text-foreground truncate flex-1`,title:e.name,children:e.name}),(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground shrink-0`,children:bwt[e.status]})]}),(0,z.jsxs)(`div`,{className:`flex gap-2 items-end`,children:[(0,z.jsxs)(`div`,{className:`flex-1 space-y-1.5`,children:[(0,z.jsx)(a7,{value:e.cpuPercent,label:`CPU`}),(0,z.jsx)(a7,{value:e.memoryPercent,label:`MEM`}),e.memoryLimit>0&&(0,z.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[vwt(e.memoryUsage),` / `,vwt(e.memoryLimit)]})]}),t&&t.cpuPercent.length>1&&(0,z.jsx)(`div`,{className:`shrink-0`,children:(0,z.jsx)(o7,{data:t.cpuPercent,color:r,height:36})})]})]})}function Cwt({agent:e,onNavigate:t}){return(0,z.jsxs)(`button`,{onClick:()=>t(e.id),className:`w-full text-left bg-card border border-border rounded-lg p-3 hover:border-primary/50 hover:bg-popover transition-colors`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,z.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0 ${xwt[e.status]}`}),(0,z.jsx)(`span`,{className:`text-xs font-medium text-foreground truncate flex-1`,title:e.issueId??e.id,children:e.issueId??e.id}),(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground shrink-0`,children:e.status})]}),(0,z.jsxs)(`div`,{className:`text-xs text-muted-foreground space-y-0.5`,children:[(0,z.jsxs)(`div`,{className:`flex justify-between`,children:[(0,z.jsx)(`span`,{children:`Model`}),(0,z.jsx)(`span`,{className:`text-foreground`,children:e.model})]}),(0,z.jsxs)(`div`,{className:`flex justify-between`,children:[(0,z.jsx)(`span`,{children:`Runtime`}),(0,z.jsx)(`span`,{className:`text-foreground`,children:vp(e)})]}),e.consecutiveFailures>0&&(0,z.jsxs)(`div`,{className:`flex justify-between text-warning`,children:[(0,z.jsx)(`span`,{children:`Failures`}),(0,z.jsx)(`span`,{children:e.consecutiveFailures})]})]}),(0,z.jsx)(`div`,{className:`mt-1.5 text-xs text-primary`,children:`Click to view in Agents →`})]})}function s7(e){return e>=1024**3?`${(e/1024**3).toFixed(1)}GiB`:e>=1024**2?`${(e/1024**2).toFixed(0)}MiB`:e>=1024?`${(e/1024).toFixed(0)}KiB`:`${e}B`}async function wwt(e){let t=await fetch(`/api/resources/${e}/details`);if(!t.ok)throw Error(`Failed to fetch container details`);return t.json()}function Twt({container:e,history:t,onClose:n}){let[r,i]=(0,R.useState)(`overview`),{data:a}=B({queryKey:[`container-details`,e.id],queryFn:()=>wwt(e.id),refetchInterval:r===`logs`?5e3:3e4});return(0,R.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[n]),(0,z.jsxs)(`div`,{className:`fixed inset-0 z-50 flex justify-end`,children:[(0,z.jsx)(`div`,{className:`absolute inset-0 bg-black/40`,onClick:n}),(0,z.jsxs)(`div`,{className:`relative w-full max-w-lg bg-card border-l border-border flex flex-col shadow-2xl overflow-hidden`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-3 border-b border-border shrink-0`,children:[(0,z.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full shrink-0 ${e.status===`running`?`bg-success`:e.status===`unhealthy`||e.status===`restarting`?`bg-warning`:`bg-destructive`}`}),(0,z.jsx)(`h2`,{className:`font-semibold text-foreground text-sm flex-1 truncate`,title:e.name,children:e.name}),a?.image&&(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground truncate max-w-[160px]`,title:a.image,children:a.image}),(0,z.jsx)(`button`,{onClick:n,className:`p-1 rounded hover:bg-popover text-muted-foreground hover:text-foreground`,children:(0,z.jsx)(zr,{className:`w-4 h-4`})})]}),(0,z.jsx)(`div`,{className:`flex border-b border-border shrink-0`,children:[{id:`overview`,label:`Overview`},{id:`logs`,label:`Logs`},{id:`ports-env`,label:`Ports & Env`}].map(e=>(0,z.jsx)(`button`,{onClick:()=>i(e.id),className:`px-4 py-2 text-xs transition-colors ${r===e.id?`text-primary border-b-2 border-primary -mb-px`:`text-muted-foreground hover:text-foreground`}`,children:e.label},e.id))}),(0,z.jsxs)(`div`,{className:`flex-1 overflow-auto p-4`,children:[r===`overview`&&(0,z.jsxs)(`div`,{className:`space-y-4`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Current Usage`}),(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(a7,{value:e.cpuPercent,label:`CPU`}),(0,z.jsx)(a7,{value:e.memoryPercent,label:`Memory`}),e.memoryLimit>0&&(0,z.jsxs)(`div`,{className:`text-xs text-muted-foreground text-right`,children:[s7(e.memoryUsage),` / `,s7(e.memoryLimit)]})]})]}),t.cpuPercent.length>1&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`5-Min History`}),(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:`CPU %`}),(0,z.jsx)(`div`,{className:`w-full`,children:(0,z.jsx)(o7,{data:t.cpuPercent,color:`rgba(59,130,246,0.8)`,height:40})})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:`Memory %`}),(0,z.jsx)(`div`,{className:`w-full`,children:(0,z.jsx)(o7,{data:t.memoryPercent,color:`rgba(168,85,247,0.8)`,height:40})})]})]})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Network I/O`}),(0,z.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,z.jsxs)(`div`,{className:`bg-card p-2 rounded`,children:[(0,z.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`In`}),(0,z.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:s7(e.networkIn)})]}),(0,z.jsxs)(`div`,{className:`bg-card p-2 rounded`,children:[(0,z.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Out`}),(0,z.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:s7(e.networkOut)})]})]})]}),a&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Container Info`}),(0,z.jsxs)(`dl`,{className:`space-y-1 text-xs`,children:[a.uptime&&(0,z.jsxs)(`div`,{className:`flex justify-between`,children:[(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:`Uptime`}),(0,z.jsx)(`dd`,{className:`text-foreground`,children:a.uptime})]}),a.created&&(0,z.jsxs)(`div`,{className:`flex justify-between`,children:[(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:`Created`}),(0,z.jsx)(`dd`,{className:`text-foreground`,children:new Date(a.created).toLocaleString()})]}),(0,z.jsxs)(`div`,{className:`flex justify-between`,children:[(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:`Status`}),(0,z.jsx)(`dd`,{className:`text-foreground`,children:a.status})]})]})]})]}),r===`logs`&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Recent Logs (tail 100)`}),a?.logs?(0,z.jsx)(`pre`,{className:`text-xs text-foreground bg-card p-3 rounded overflow-auto max-h-[600px] font-mono whitespace-pre-wrap break-all`,children:a.logs}):(0,z.jsx)(`div`,{className:`text-xs text-muted-foreground text-center py-8`,children:`Loading logs…`})]}),r===`ports-env`&&(0,z.jsxs)(`div`,{className:`space-y-4`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Port Mappings`}),a?.ports?.length?(0,z.jsx)(`div`,{className:`space-y-1`,children:a.ports.map((e,t)=>(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,z.jsx)(`span`,{className:`text-foreground font-mono`,children:e.host}),(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`→`}),(0,z.jsxs)(`span`,{className:`text-foreground font-mono`,children:[e.container,`/`,e.protocol]})]},t))}):(0,z.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`No port mappings`})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:`Environment Variables`}),a?.env?.length?(0,z.jsx)(`div`,{className:`space-y-0.5 max-h-80 overflow-auto`,children:a.env.map((e,t)=>{let[n,...r]=e.split(`=`),i=r.join(`=`),a=/token|secret|key|pass|pwd|auth/i.test(n??``);return(0,z.jsxs)(`div`,{className:`text-xs font-mono flex gap-1 flex-wrap`,children:[(0,z.jsx)(`span`,{className:`text-primary`,children:n}),(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`=`}),(0,z.jsx)(`span`,{className:`text-foreground break-all`,children:a?`***`:i})]},t)})}):(0,z.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`No environment variables`})]})]})]})]})]})}async function Ewt(){let e=await fetch(`/api/resources`);if(!e.ok)throw Error(`Failed to fetch resources`);return e.json()}async function Dwt(e){let t=await fetch(`/api/resources/${e}/history`);if(!t.ok)throw Error(`Failed to fetch history`);return t.json()}function Owt(e,t,n){if(n===`issue`){let n=new Map;for(let t of e){let e=t.name.match(/(?:feature[_-])?([A-Z]+-\d+)/i),r=e?e[1].toUpperCase():`__ungrouped__`,i=e?e[1].toUpperCase():`Ungrouped`;n.has(r)||n.set(r,{key:r,label:i,containers:[],agents:[]}),n.get(r).containers.push(t)}for(let e of t){let t=e.issueId??`__ungrouped__`,r=e.issueId??`Ungrouped`;n.has(t)||n.set(t,{key:t,label:r,containers:[],agents:[]}),n.get(t).agents.push(e)}return Array.from(n.values()).sort((e,t)=>e.label.localeCompare(t.label))}if(n===`type`)return[{key:`containers`,label:`Containers`,containers:e,agents:[]},{key:`agents`,label:`Agents`,containers:[],agents:t}].filter(e=>e.containers.length+e.agents.length>0);let r=new Map;for(let t of e)r.has(t.status)||r.set(t.status,{key:t.status,label:t.status.charAt(0).toUpperCase()+t.status.slice(1),containers:[],agents:[]}),r.get(t.status).containers.push(t);for(let e of t)r.has(e.status)||r.set(e.status,{key:e.status,label:e.status.charAt(0).toUpperCase()+e.status.slice(1),containers:[],agents:[]}),r.get(e.status).agents.push(e);return Array.from(r.values())}function kwt({onNavigateToAgents:e}){let[t,n]=(0,R.useState)(`issue`),[r,i]=(0,R.useState)(`all`),[a,o]=(0,R.useState)(null);gwt();let{data:s,isLoading:c,error:l}=B({queryKey:[`resources`],queryFn:Ewt,refetchInterval:3e4}),{data:u}=B({queryKey:[`container-history`,a?.id],queryFn:()=>Dwt(a.id),enabled:!!a,refetchInterval:3e4});if(c)return(0,z.jsx)(`div`,{className:`p-6 text-muted-foreground text-sm`,children:`Loading resources…`});if(l)return(0,z.jsxs)(`div`,{className:`p-6 text-destructive text-sm`,children:[`Failed to load resources: `,l.message]});let d=s?.containers??[],f=s?.agents??[],p=r===`running`?d.filter(e=>e.status===`running`):d,m=Owt(p,f,t),h=p.length+f.length;return(0,z.jsxs)(`div`,{className:`h-full flex flex-col overflow-hidden`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-3 px-6 py-3 border-b border-border shrink-0`,children:[(0,z.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Resources`}),(0,z.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[h,` items`]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1 ml-4`,children:[(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground mr-1`,children:`Group by:`}),[`issue`,`type`,`status`].map(e=>(0,z.jsx)(`button`,{onClick:()=>n(e),className:`px-2 py-0.5 rounded text-xs transition-colors ${t===e?`bg-primary text-primary-foreground`:`text-muted-foreground hover:text-foreground hover:bg-popover`}`,children:e.charAt(0).toUpperCase()+e.slice(1)},e))]}),(0,z.jsx)(`div`,{className:`flex items-center gap-1`,children:[`all`,`running`].map(e=>(0,z.jsx)(`button`,{onClick:()=>i(e),className:`px-2 py-0.5 rounded text-xs transition-colors ${r===e?`bg-popover text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-popover`}`,children:e===`all`?`All`:`Running only`},e))}),s?.updatedAt&&(0,z.jsxs)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:[`Updated `,new Date(s.updatedAt).toLocaleTimeString()]})]}),(0,z.jsx)(`div`,{className:`flex-1 overflow-auto p-6`,children:h===0?(0,z.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-64 text-muted-foreground`,children:[(0,z.jsx)(`div`,{className:`text-4xl mb-3`,children:`📦`}),(0,z.jsx)(`div`,{className:`text-sm`,children:`No containers or agents found`}),(0,z.jsx)(`div`,{className:`text-xs mt-1`,children:`Docker may not be running or no workspaces are active`})]}):(0,z.jsx)(`div`,{className:`space-y-6`,children:m.map(t=>(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-3`,children:[t.label,(0,z.jsxs)(`span`,{className:`ml-2 font-normal text-muted-foreground/60`,children:[`(`,t.containers.length+t.agents.length,`)`]})]}),(0,z.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3`,children:[t.containers.map(e=>(0,z.jsx)(Swt,{container:e,history:(s?.containers,void 0),onClick:o},e.id)),t.agents.map(t=>(0,z.jsx)(Cwt,{agent:t,onNavigate:e},t.id))]})]},t.key))})}),a&&(0,z.jsx)(Twt,{container:a,history:u??{timestamps:[],cpuPercent:[],memoryPercent:[]},onClose:()=>o(null)})]})}var c7=ri(e=>({systemHealth:null,setSystemHealth:t=>e({systemHealth:t}),focusedAgentId:null,setFocusedAgentId:t=>e({focusedAgentId:t})})),Awt=e=>{let t=e.recentActivity;return[...Object.values(e.observationsByIssueId??{}).flat().filter(e=>e.actionStatus!==null).map(e=>({id:`memory-${e.id}`,agentId:e.workspaceId,issueId:e.issueId,timestamp:e.timestamp,source:`memory`,level:`success`,message:e.summary})),...t].sort((e,t)=>t.timestamp.localeCompare(e.timestamp))};function jwt(){let e=c7();(0,R.useEffect)(()=>{let t=null,n=async()=>{try{let t=await fetch(`/api/godview/system-health`);if(t.ok){let n=await t.json();e.setSystemHealth(n)}}catch{}};return n(),t=setInterval(n,1e4),()=>{t&&clearInterval(t)}},[])}function Mwt(){let[e,t]=(0,R.useState)(()=>new Date);return(0,R.useEffect)(()=>{let e=setInterval(()=>t(new Date),1e3);return()=>clearInterval(e)},[]),(0,z.jsx)(`span`,{className:`gv-mono text-sm`,style:{color:`var(--gv-blue)`},children:e.toLocaleTimeString(`en-US`,{hour12:!1})})}function Nwt({label:e,value:t,color:n}){return(0,z.jsxs)(`div`,{className:`flex flex-col items-center gap-0.5`,children:[(0,z.jsx)(`div`,{className:`flex items-end gap-0.5 h-6`,children:(0,z.jsx)(`div`,{className:`w-12 rounded-sm transition-all duration-500`,style:{height:`${Math.max(4,t/100*24)}px`,backgroundColor:n,opacity:.8}})}),(0,z.jsxs)(`span`,{className:`text-[10px]`,style:{color:`var(--gv-text-secondary)`},children:[e,` `,Math.round(t),`%`]})]})}function Pwt({agents:e}){let t=c7(e=>e.systemHealth),n=e.filter(e=>e.status!==`stopped`&&e.status!==`dead`).length;return(0,z.jsxs)(`div`,{className:`gv-glass flex items-center gap-4 px-4 py-2 shrink-0 mx-3 mt-3 rounded-xl`,style:{borderColor:`rgba(0, 212, 255, 0.2)`},children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,z.jsx)(Br,{className:`w-5 h-5`,style:{color:`var(--gv-blue)`,animation:`gv-logo-glow 3s ease-in-out infinite`}}),(0,z.jsx)(`span`,{className:`text-sm font-bold tracking-widest uppercase`,style:{color:`var(--gv-blue)`,fontFamily:`var(--gv-font-display)`},children:`God View`})]}),(0,z.jsx)(`div`,{className:`w-px h-5 shrink-0`,style:{backgroundColor:`var(--gv-border)`}}),(0,z.jsx)(Mwt,{}),(0,z.jsx)(`div`,{className:`w-px h-5 shrink-0`,style:{backgroundColor:`var(--gv-border)`}}),t&&(0,z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,z.jsx)(Nwt,{label:`CPU`,value:t.cpu,color:`var(--gv-blue)`}),(0,z.jsx)(Nwt,{label:`MEM`,value:t.memPercent,color:`var(--gv-purple)`})]}),(0,z.jsx)(`div`,{className:`flex-1`}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5 px-3 py-1 rounded-full`,style:{background:`rgba(57, 255, 20, 0.1)`,border:`1px solid rgba(57, 255, 20, 0.3)`,animation:n>0?`gv-pulse 2s ease-in-out infinite`:`none`},children:[(0,z.jsx)(`div`,{className:`w-1.5 h-1.5 rounded-full`,style:{backgroundColor:n>0?`var(--gv-green)`:`var(--gv-text-dim)`}}),(0,z.jsxs)(`span`,{className:`text-xs font-semibold gv-mono`,style:{color:n>0?`var(--gv-green)`:`var(--gv-text-secondary)`},children:[n,` active`]})]}),(0,z.jsxs)(`div`,{className:`text-xs`,style:{color:`var(--gv-text-secondary)`},children:[e.length,` total agents`]})]})}async function Fwt(){let e=await fetch(`/api/activity`);if(!e.ok)throw Error(`Failed to fetch activity`);return e.json()}var Iwt={success:(0,z.jsx)(sn,{className:`w-3 h-3 shrink-0`}),error:(0,z.jsx)(un,{className:`w-3 h-3 shrink-0`}),warn:(0,z.jsx)(Ir,{className:`w-3 h-3 shrink-0`}),info:(0,z.jsx)(Qn,{className:`w-3 h-3 shrink-0`})},Lwt={success:`var(--gv-green)`,info:`var(--gv-blue)`,error:`var(--gv-pink)`,warn:`var(--gv-amber)`};function Rwt(e,t){return e.issueId?e.issueId.toUpperCase()===t.toUpperCase():e.agentId?e.agentId.toLowerCase()===`agent-${t.toLowerCase()}`:!1}var zwt=e=>t=>Awt(t).filter(t=>Rwt(t,e));function Bwt({issueId:e}={}){let t=sm(e?zwt(e):Awt),{data:n=[]}=B({queryKey:[`god-view-activity`],queryFn:Fwt,refetchInterval:3e4,staleTime:5e3}),r=(0,R.useMemo)(()=>{let r=new Map;for(let e of t??[])r.set(e.id,e);for(let t of n)(!e||Rwt(t,e))&&r.set(t.id,t);return Array.from(r.values()).sort((e,t)=>new Date(t.timestamp).getTime()-new Date(e.timestamp).getTime())},[e,t,n]);return(0,z.jsxs)(`div`,{className:`flex flex-col gap-1 overflow-y-auto flex-1`,children:[(0,z.jsx)(`h3`,{className:`text-xs font-bold uppercase tracking-widest px-1 shrink-0`,style:{color:`var(--gv-text-secondary)`},children:`Activity`}),(0,z.jsx)(`div`,{className:`flex flex-col gap-1 overflow-y-auto`,children:r.length===0?(0,z.jsx)(`div`,{className:`text-xs text-center py-4`,style:{color:`var(--gv-text-dim)`},children:`Awaiting events...`}):(0,z.jsx)(GH,{initial:!1,children:r.map(e=>{let t=Lwt[e.level]||Lwt.info,n=Iwt[e.level]||Iwt.info;return(0,z.jsxs)(cJ.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},transition:{duration:.2},className:`flex items-start gap-1.5 px-1 py-1 rounded`,style:{background:`rgba(255,255,255,0.02)`},children:[(0,z.jsx)(`span`,{className:`mt-0.5 shrink-0`,style:{color:t},children:n}),(0,z.jsxs)(`div`,{className:`flex flex-col min-w-0 gap-0.5`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,z.jsx)(`span`,{className:`text-[10px] font-semibold gv-mono truncate`,style:{color:t},title:e.source,children:e.source}),(0,z.jsx)(`span`,{className:`text-[9px] shrink-0`,style:{color:`var(--gv-text-dim)`},children:oM(e.timestamp,new Date)})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1 min-w-0`,children:[e.issueId&&(0,z.jsx)(`span`,{className:`text-[9px] px-1 py-0.5 rounded shrink-0 gv-mono`,style:{color:`var(--gv-text-secondary)`,background:`rgba(255,255,255,0.04)`},children:e.issueId}),(0,z.jsx)(`span`,{className:`text-[10px] truncate leading-tight`,style:{color:`var(--gv-text-secondary)`},title:e.message,children:e.message})]})]})]},e.id)})})})]})}var Vwt=i(((e,t)=>{(function(){var e={}.hasOwnProperty;function n(){for(var e=``,t=0;t<arguments.length;t++){var n=arguments[t];n&&(e=i(e,r(n)))}return e}function r(t){if(typeof t==`string`||typeof t==`number`)return t;if(typeof t!=`object`)return``;if(Array.isArray(t))return n.apply(null,t);if(t.toString!==Object.prototype.toString&&!t.toString.toString().includes(`[native code]`))return t.toString();var r=``;for(var a in t)e.call(t,a)&&t[a]&&(r=i(r,a));return r}function i(e,t){return t?e?e+` `+t:e+t:e}t!==void 0&&t.exports?(n.default=n,t.exports=n):typeof define==`function`&&typeof define.amd==`object`&&define.amd?define(`classnames`,[],function(){return n}):window.classNames=n})()})),l7=n(yh()),Hwt=n(Vwt()),Uwt=[`top`,`left`,`transform`,`className`,`children`,`innerRef`];function u7(){return u7=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},u7.apply(this,arguments)}function Wwt(e,t){if(e==null)return{};var n={},r=Object.keys(e),i,a;for(a=0;a<r.length;a++)i=r[a],!(t.indexOf(i)>=0)&&(n[i]=e[i]);return n}function d7(e){var t=e.top,n=t===void 0?0:t,r=e.left,i=r===void 0?0:r,a=e.transform,o=e.className,s=e.children,c=e.innerRef,l=Wwt(e,Uwt);return R.createElement(`g`,u7({ref:c,className:(0,Hwt.default)(`visx-group`,o),transform:a||`translate(`+i+`, `+n+`)`},l),s)}d7.propTypes={top:l7.default.number,left:l7.default.number,transform:l7.default.string,className:l7.default.string,children:l7.default.node,innerRef:l7.default.oneOfType([l7.default.string,l7.default.func,l7.default.object])};var f7=Math.PI,p7=2*f7,m7=1e-6,Gwt=p7-m7;function h7(){this._x0=this._y0=this._x1=this._y1=null,this._=``}function g7(){return new h7}h7.prototype=g7.prototype={constructor:h7,moveTo:function(e,t){this._+=`M`+(this._x0=this._x1=+e)+`,`+(this._y0=this._y1=+t)},closePath:function(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._+=`Z`)},lineTo:function(e,t){this._+=`L`+(this._x1=+e)+`,`+(this._y1=+t)},quadraticCurveTo:function(e,t,n,r){this._+=`Q`+ +e+`,`+ +t+`,`+(this._x1=+n)+`,`+(this._y1=+r)},bezierCurveTo:function(e,t,n,r,i,a){this._+=`C`+ +e+`,`+ +t+`,`+ +n+`,`+ +r+`,`+(this._x1=+i)+`,`+(this._y1=+a)},arcTo:function(e,t,n,r,i){e=+e,t=+t,n=+n,r=+r,i=+i;var a=this._x1,o=this._y1,s=n-e,c=r-t,l=a-e,u=o-t,d=l*l+u*u;if(i<0)throw Error(`negative radius: `+i);if(this._x1===null)this._+=`M`+(this._x1=e)+`,`+(this._y1=t);else if(d>m7)if(!(Math.abs(u*s-c*l)>m7)||!i)this._+=`L`+(this._x1=e)+`,`+(this._y1=t);else{var f=n-a,p=r-o,m=s*s+c*c,h=f*f+p*p,g=Math.sqrt(m),_=Math.sqrt(d),v=i*Math.tan((f7-Math.acos((m+d-h)/(2*g*_)))/2),y=v/_,b=v/g;Math.abs(y-1)>m7&&(this._+=`L`+(e+y*l)+`,`+(t+y*u)),this._+=`A`+i+`,`+i+`,0,0,`+ +(u*f>l*p)+`,`+(this._x1=e+b*s)+`,`+(this._y1=t+b*c)}},arc:function(e,t,n,r,i,a){e=+e,t=+t,n=+n,a=!!a;var o=n*Math.cos(r),s=n*Math.sin(r),c=e+o,l=t+s,u=1^a,d=a?r-i:i-r;if(n<0)throw Error(`negative radius: `+n);this._x1===null?this._+=`M`+c+`,`+l:(Math.abs(this._x1-c)>m7||Math.abs(this._y1-l)>m7)&&(this._+=`L`+c+`,`+l),n&&(d<0&&(d=d%p7+p7),d>Gwt?this._+=`A`+n+`,`+n+`,0,1,`+u+`,`+(e-o)+`,`+(t-s)+`A`+n+`,`+n+`,0,1,`+u+`,`+(this._x1=c)+`,`+(this._y1=l):d>m7&&(this._+=`A`+n+`,`+n+`,0,`+ +(d>=f7)+`,`+u+`,`+(this._x1=e+n*Math.cos(i))+`,`+(this._y1=t+n*Math.sin(i))))},rect:function(e,t,n,r){this._+=`M`+(this._x0=this._x1=+e)+`,`+(this._y0=this._y1=+t)+`h`+ +n+`v`+ +r+`h`+-n+`Z`},toString:function(){return this._}};function _7(e){return function(){return e}}var Kwt=Math.abs,v7=Math.atan2,y7=Math.cos,qwt=Math.max,b7=Math.min,x7=Math.sin,S7=Math.sqrt,C7=Math.PI,w7=C7/2,Jwt=2*C7;function Ywt(e){return e>1?0:e<-1?C7:Math.acos(e)}function Xwt(e){return e>=1?w7:e<=-1?-w7:Math.asin(e)}function Zwt(e){return e.innerRadius}function Qwt(e){return e.outerRadius}function $wt(e){return e.startAngle}function eTt(e){return e.endAngle}function tTt(e){return e&&e.padAngle}function nTt(e,t,n,r,i,a,o,s){var c=n-e,l=r-t,u=o-i,d=s-a,f=d*c-u*l;if(!(f*f<1e-12))return f=(u*(t-a)-d*(e-i))/f,[e+f*c,t+f*l]}function T7(e,t,n,r,i,a,o){var s=e-n,c=t-r,l=(o?a:-a)/S7(s*s+c*c),u=l*c,d=-l*s,f=e+u,p=t+d,m=n+u,h=r+d,g=(f+m)/2,_=(p+h)/2,v=m-f,y=h-p,b=v*v+y*y,x=i-a,S=f*h-m*p,C=(y<0?-1:1)*S7(qwt(0,x*x*b-S*S)),w=(S*y-v*C)/b,T=(-S*v-y*C)/b,E=(S*y+v*C)/b,D=(-S*v+y*C)/b,O=w-g,k=T-_,A=E-g,j=D-_;return O*O+k*k>A*A+j*j&&(w=E,T=D),{cx:w,cy:T,x01:-u,y01:-d,x11:w*(i/x-1),y11:T*(i/x-1)}}function rTt(){var e=Zwt,t=Qwt,n=_7(0),r=null,i=$wt,a=eTt,o=tTt,s=null;function c(){var c,l,u=+e.apply(this,arguments),d=+t.apply(this,arguments),f=i.apply(this,arguments)-w7,p=a.apply(this,arguments)-w7,m=Kwt(p-f),h=p>f;if(s||=c=g7(),d<u&&(l=d,d=u,u=l),!(d>1e-12))s.moveTo(0,0);else if(m>Jwt-1e-12)s.moveTo(d*y7(f),d*x7(f)),s.arc(0,0,d,f,p,!h),u>1e-12&&(s.moveTo(u*y7(p),u*x7(p)),s.arc(0,0,u,p,f,h));else{var g=f,_=p,v=f,y=p,b=m,x=m,S=o.apply(this,arguments)/2,C=S>1e-12&&(r?+r.apply(this,arguments):S7(u*u+d*d)),w=b7(Kwt(d-u)/2,+n.apply(this,arguments)),T=w,E=w,D,O;if(C>1e-12){var k=Xwt(C/u*x7(S)),A=Xwt(C/d*x7(S));(b-=k*2)>1e-12?(k*=h?1:-1,v+=k,y-=k):(b=0,v=y=(f+p)/2),(x-=A*2)>1e-12?(A*=h?1:-1,g+=A,_-=A):(x=0,g=_=(f+p)/2)}var j=d*y7(g),M=d*x7(g),N=u*y7(y),P=u*x7(y);if(w>1e-12){var F=d*y7(_),I=d*x7(_),ee=u*y7(v),te=u*x7(v),ne;if(m<C7&&(ne=nTt(j,M,ee,te,F,I,N,P))){var L=j-ne[0],re=M-ne[1],ie=F-ne[0],ae=I-ne[1],oe=1/x7(Ywt((L*ie+re*ae)/(S7(L*L+re*re)*S7(ie*ie+ae*ae)))/2),se=S7(ne[0]*ne[0]+ne[1]*ne[1]);T=b7(w,(u-se)/(oe-1)),E=b7(w,(d-se)/(oe+1))}}x>1e-12?E>1e-12?(D=T7(ee,te,j,M,d,E,h),O=T7(F,I,N,P,d,E,h),s.moveTo(D.cx+D.x01,D.cy+D.y01),E<w?s.arc(D.cx,D.cy,E,v7(D.y01,D.x01),v7(O.y01,O.x01),!h):(s.arc(D.cx,D.cy,E,v7(D.y01,D.x01),v7(D.y11,D.x11),!h),s.arc(0,0,d,v7(D.cy+D.y11,D.cx+D.x11),v7(O.cy+O.y11,O.cx+O.x11),!h),s.arc(O.cx,O.cy,E,v7(O.y11,O.x11),v7(O.y01,O.x01),!h))):(s.moveTo(j,M),s.arc(0,0,d,g,_,!h)):s.moveTo(j,M),!(u>1e-12)||!(b>1e-12)?s.lineTo(N,P):T>1e-12?(D=T7(N,P,F,I,u,-T,h),O=T7(j,M,ee,te,u,-T,h),s.lineTo(D.cx+D.x01,D.cy+D.y01),T<w?s.arc(D.cx,D.cy,T,v7(D.y01,D.x01),v7(O.y01,O.x01),!h):(s.arc(D.cx,D.cy,T,v7(D.y01,D.x01),v7(D.y11,D.x11),!h),s.arc(0,0,u,v7(D.cy+D.y11,D.cx+D.x11),v7(O.cy+O.y11,O.cx+O.x11),h),s.arc(O.cx,O.cy,T,v7(O.y11,O.x11),v7(O.y01,O.x01),!h))):s.arc(0,0,u,y,v,h)}if(s.closePath(),c)return s=null,c+``||null}return c.centroid=function(){var n=(+e.apply(this,arguments)+ +t.apply(this,arguments))/2,r=(+i.apply(this,arguments)+ +a.apply(this,arguments))/2-C7/2;return[y7(r)*n,x7(r)*n]},c.innerRadius=function(t){return arguments.length?(e=typeof t==`function`?t:_7(+t),c):e},c.outerRadius=function(e){return arguments.length?(t=typeof e==`function`?e:_7(+e),c):t},c.cornerRadius=function(e){return arguments.length?(n=typeof e==`function`?e:_7(+e),c):n},c.padRadius=function(e){return arguments.length?(r=e==null?null:typeof e==`function`?e:_7(+e),c):r},c.startAngle=function(e){return arguments.length?(i=typeof e==`function`?e:_7(+e),c):i},c.endAngle=function(e){return arguments.length?(a=typeof e==`function`?e:_7(+e),c):a},c.padAngle=function(e){return arguments.length?(o=typeof e==`function`?e:_7(+e),c):o},c.context=function(e){return arguments.length?(s=e??null,c):s},c}function E7(e,t){e(t)}function iTt(e){var t=e===void 0?{}:e,n=t.innerRadius,r=t.outerRadius,i=t.cornerRadius,a=t.startAngle,o=t.endAngle,s=t.padAngle,c=t.padRadius,l=rTt();return n!=null&&E7(l.innerRadius,n),r!=null&&E7(l.outerRadius,r),i!=null&&E7(l.cornerRadius,i),a!=null&&E7(l.startAngle,a),o!=null&&E7(l.endAngle,o),s!=null&&E7(l.padAngle,s),c!=null&&E7(l.padRadius,c),l}var aTt=[`className`,`data`,`innerRadius`,`outerRadius`,`cornerRadius`,`startAngle`,`endAngle`,`padAngle`,`padRadius`,`children`,`innerRef`];function D7(){return D7=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},D7.apply(this,arguments)}function oTt(e,t){if(e==null)return{};var n={},r=Object.keys(e),i,a;for(a=0;a<r.length;a++)i=r[a],!(t.indexOf(i)>=0)&&(n[i]=e[i]);return n}function O7(e){var t=e.className,n=e.data,r=e.innerRadius,i=e.outerRadius,a=e.cornerRadius,o=e.startAngle,s=e.endAngle,c=e.padAngle,l=e.padRadius,u=e.children,d=e.innerRef,f=oTt(e,aTt),p=iTt({innerRadius:r,outerRadius:i,cornerRadius:a,startAngle:o,endAngle:s,padAngle:c,padRadius:l});return u?R.createElement(R.Fragment,null,u({path:p})):!n&&(o==null||s==null||r==null||i==null)?(console.warn(`[@visx/shape/Arc]: expected data because one of startAngle, endAngle, innerRadius, outerRadius is undefined. Bailing.`),null):R.createElement(`path`,D7({ref:d,className:(0,Hwt.default)(`visx-arc`,t),d:p(n)||``},f))}var sTt=class extends Map{constructor(e,t=dTt){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:t}}),e!=null)for(let[t,n]of e)this.set(t,n)}get(e){return super.get(cTt(this,e))}has(e){return super.has(cTt(this,e))}set(e,t){return super.set(lTt(this,e),t)}delete(e){return super.delete(uTt(this,e))}};function cTt({_intern:e,_key:t},n){let r=t(n);return e.has(r)?e.get(r):n}function lTt({_intern:e,_key:t},n){let r=t(n);return e.has(r)?e.get(r):(e.set(r,n),n)}function uTt({_intern:e,_key:t},n){let r=t(n);return e.has(r)&&(n=e.get(r),e.delete(r)),n}function dTt(e){return typeof e==`object`&&e?e.valueOf():e}function fTt(e,t){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(t).domain(e);break}return this}var pTt=Symbol(`implicit`);function k7(){var e=new sTt,t=[],n=[],r=pTt;function i(i){let a=e.get(i);if(a===void 0){if(r!==pTt)return r;e.set(i,a=t.push(i)-1)}return n[a%n.length]}return i.domain=function(n){if(!arguments.length)return t.slice();t=[],e=new sTt;for(let r of n)e.has(r)||e.set(r,t.push(r)-1);return i},i.range=function(e){return arguments.length?(n=Array.from(e),i):n.slice()},i.unknown=function(e){return arguments.length?(r=e,i):r},i.copy=function(){return k7(t,n).unknown(r)},fTt.apply(i,arguments),i}var A7=new Date,j7=new Date;function M7(e,t,n,r){function i(t){return e(t=arguments.length===0?new Date:new Date(+t)),t}return i.floor=t=>(e(t=new Date(+t)),t),i.ceil=n=>(e(n=new Date(n-1)),t(n,1),e(n),n),i.round=e=>{let t=i(e),n=i.ceil(e);return e-t<n-e?t:n},i.offset=(e,n)=>(t(e=new Date(+e),n==null?1:Math.floor(n)),e),i.range=(n,r,a)=>{let o=[];if(n=i.ceil(n),a=a==null?1:Math.floor(a),!(n<r)||!(a>0))return o;let s;do o.push(s=new Date(+n)),t(n,a),e(n);while(s<n&&n<r);return o},i.filter=n=>M7(t=>{if(t>=t)for(;e(t),!n(t);)t.setTime(t-1)},(e,r)=>{if(e>=e)if(r<0)for(;++r<=0;)for(;t(e,-1),!n(e););else for(;--r>=0;)for(;t(e,1),!n(e););}),n&&(i.count=(t,r)=>(A7.setTime(+t),j7.setTime(+r),e(A7),e(j7),Math.floor(n(A7,j7))),i.every=e=>(e=Math.floor(e),!isFinite(e)||!(e>0)?null:e>1?i.filter(r?t=>r(t)%e===0:t=>i.count(0,t)%e===0):i)),i}var N7=1e3,P7=N7*60,F7=P7*60,I7=F7*24,L7=I7*7,mTt=I7*30,hTt=I7*365,R7=M7(e=>{e.setTime(e-e.getMilliseconds())},(e,t)=>{e.setTime(+e+t*N7)},(e,t)=>(t-e)/N7,e=>e.getUTCSeconds());R7.range;var z7=M7(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*N7)},(e,t)=>{e.setTime(+e+t*P7)},(e,t)=>(t-e)/P7,e=>e.getMinutes());z7.range;var B7=M7(e=>{e.setUTCSeconds(0,0)},(e,t)=>{e.setTime(+e+t*P7)},(e,t)=>(t-e)/P7,e=>e.getUTCMinutes());B7.range;var V7=M7(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*N7-e.getMinutes()*P7)},(e,t)=>{e.setTime(+e+t*F7)},(e,t)=>(t-e)/F7,e=>e.getHours());V7.range;var H7=M7(e=>{e.setUTCMinutes(0,0,0)},(e,t)=>{e.setTime(+e+t*F7)},(e,t)=>(t-e)/F7,e=>e.getUTCHours());H7.range;var U7=M7(e=>e.setHours(0,0,0,0),(e,t)=>e.setDate(e.getDate()+t),(e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*P7)/I7,e=>e.getDate()-1);U7.range;var W7=M7(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/I7,e=>e.getUTCDate()-1);W7.range;var gTt=M7(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/I7,e=>Math.floor(e/I7));gTt.range;function G7(e){return M7(t=>{t.setDate(t.getDate()-(t.getDay()+7-e)%7),t.setHours(0,0,0,0)},(e,t)=>{e.setDate(e.getDate()+t*7)},(e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*P7)/L7)}var K7=G7(0),_Tt=G7(1),vTt=G7(2),yTt=G7(3),bTt=G7(4),xTt=G7(5),STt=G7(6);K7.range,_Tt.range,vTt.range,yTt.range,bTt.range,xTt.range,STt.range;function q7(e){return M7(t=>{t.setUTCDate(t.getUTCDate()-(t.getUTCDay()+7-e)%7),t.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t*7)},(e,t)=>(t-e)/L7)}var J7=q7(0),CTt=q7(1),wTt=q7(2),TTt=q7(3),ETt=q7(4),DTt=q7(5),OTt=q7(6);J7.range,CTt.range,wTt.range,TTt.range,ETt.range,DTt.range,OTt.range;var Y7=M7(e=>{e.setDate(1),e.setHours(0,0,0,0)},(e,t)=>{e.setMonth(e.getMonth()+t)},(e,t)=>t.getMonth()-e.getMonth()+(t.getFullYear()-e.getFullYear())*12,e=>e.getMonth());Y7.range;var X7=M7(e=>{e.setUTCDate(1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCMonth(e.getUTCMonth()+t)},(e,t)=>t.getUTCMonth()-e.getUTCMonth()+(t.getUTCFullYear()-e.getUTCFullYear())*12,e=>e.getUTCMonth());X7.range;var Z7=M7(e=>{e.setMonth(0,1),e.setHours(0,0,0,0)},(e,t)=>{e.setFullYear(e.getFullYear()+t)},(e,t)=>t.getFullYear()-e.getFullYear(),e=>e.getFullYear());Z7.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:M7(t=>{t.setFullYear(Math.floor(t.getFullYear()/e)*e),t.setMonth(0,1),t.setHours(0,0,0,0)},(t,n)=>{t.setFullYear(t.getFullYear()+n*e)}),Z7.range;var Q7=M7(e=>{e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCFullYear(e.getUTCFullYear()+t)},(e,t)=>t.getUTCFullYear()-e.getUTCFullYear(),e=>e.getUTCFullYear());Q7.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:M7(t=>{t.setUTCFullYear(Math.floor(t.getUTCFullYear()/e)*e),t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,n)=>{t.setUTCFullYear(t.getUTCFullYear()+n*e)}),Q7.range;function kTt(e,t){t.domain&&(`nice`in e||`quantiles`in e||`padding`in e,e.domain(t.domain))}function ATt(e,t){t.range&&(`padding`in e,e.range(t.range))}function jTt(e,t){`align`in e&&`align`in t&&t.align!==void 0&&e.align(t.align)}function MTt(e,t){`base`in e&&`base`in t&&t.base!==void 0&&e.base(t.base)}function NTt(e,t){`clamp`in e&&`clamp`in t&&t.clamp!==void 0&&e.clamp(t.clamp)}function PTt(e,t){`constant`in e&&`constant`in t&&t.constant!==void 0&&e.constant(t.constant)}function FTt(e,t){`exponent`in e&&`exponent`in t&&t.exponent!==void 0&&e.exponent(t.exponent)}var ITt={lab:xTe,hcl:CTe,"hcl-long":wTe,hsl:yTe,"hsl-long":bTe,cubehelix:ETe,"cubehelix-long":DTe,rgb:p};function LTt(e){switch(e){case`lab`:case`hcl`:case`hcl-long`:case`hsl`:case`hsl-long`:case`cubehelix`:case`cubehelix-long`:case`rgb`:return ITt[e];default:}var t=e.type,n=e.gamma,r=ITt[t];return n===void 0?r:r.gamma(n)}function RTt(e,t){if(`interpolate`in t&&`interpolate`in e&&t.interpolate!==void 0){var n=LTt(t.interpolate);e.interpolate(n)}}var zTt=new Date(Date.UTC(2020,1,2,3,4,5)),BTt=`%Y-%m-%d %H:%M`;function VTt(e){return e.tickFormat(1,BTt)(zTt)===`2020-02-02 03:04`}var HTt={day:U7,hour:V7,minute:z7,month:Y7,second:R7,week:K7,year:Z7},UTt={day:W7,hour:H7,minute:B7,month:X7,second:R7,week:J7,year:Q7};function WTt(e,t){if(`nice`in t&&t.nice!==void 0&&`nice`in e){var n=t.nice;if(typeof n==`boolean`)n&&e.nice();else if(typeof n==`number`)e.nice(n);else{var r=e,i=VTt(r);if(typeof n==`string`)r.nice(i?UTt[n]:HTt[n]);else{var a=n.interval,o=n.step,s=(i?UTt[a]:HTt[a]).every(o);s!=null&&r.nice(s)}}}}function GTt(e,t){`padding`in e&&`padding`in t&&t.padding!==void 0&&e.padding(t.padding),`paddingInner`in e&&`paddingInner`in t&&t.paddingInner!==void 0&&e.paddingInner(t.paddingInner),`paddingOuter`in e&&`paddingOuter`in t&&t.paddingOuter!==void 0&&e.paddingOuter(t.paddingOuter)}function KTt(e,t){if(t.reverse){var n=e.range().slice().reverse();`padding`in e,e.range(n)}}function qTt(e,t){`round`in t&&t.round!==void 0&&(t.round&&`interpolate`in t&&t.interpolate!==void 0?console.warn(`[visx/scale/applyRound] ignoring round: scale config contains round and interpolate. only applying interpolate. config:`,t):`round`in e?e.round(t.round):`interpolate`in e&&t.round&&e.interpolate(_Te))}function JTt(e,t){`unknown`in e&&`unknown`in t&&t.unknown!==void 0&&e.unknown(t.unknown)}function YTt(e,t){if(`zero`in t&&t.zero===!0){var n=e.domain(),r=n[0],i=n[1],a=i<r,o=a?[i,r]:[r,i],s=o[0],c=o[1],l=[Math.min(0,s),Math.max(0,c)];e.domain(a?l.reverse():l)}}var XTt=[`domain`,`nice`,`zero`,`interpolate`,`round`,`range`,`reverse`,`align`,`base`,`clamp`,`constant`,`exponent`,`padding`,`unknown`],ZTt={domain:kTt,nice:WTt,zero:YTt,interpolate:RTt,round:qTt,align:jTt,base:MTt,clamp:NTt,constant:PTt,exponent:FTt,padding:GTt,range:ATt,reverse:KTt,unknown:JTt};function QTt(){var e=new Set([...arguments]),t=XTt.filter(function(t){return e.has(t)});return function(e,n){return n!==void 0&&t.forEach(function(t){ZTt[t](e,n)}),e}}var $Tt=QTt(`domain`,`range`,`reverse`,`unknown`);function eEt(e){return $Tt(k7(),e)}function tEt({agents:e,width:t=120,height:n=120}){let r=e.filter(e=>e.status!==`stopped`&&e.status!==`dead`),i={};for(let e of r){let t=e.role||`other`;i[t]=(i[t]||0)+1}let a=Object.entries(i).map(([e,t])=>({label:e,value:t})),o=a.reduce((e,t)=>e+t.value,0),s=eEt({domain:a.map(e=>e.label),range:[`var(--gv-blue)`,`var(--gv-green)`,`var(--gv-amber)`,`var(--gv-pink)`,`var(--gv-purple)`]}),c=t/2,l=n/2,u=Math.min(c,l)-6,d=u*.6;if(o===0)return(0,z.jsx)(`div`,{className:`flex items-center justify-center rounded-full`,style:{width:t,height:n,border:`2px solid var(--gv-border)`},children:(0,z.jsx)(`span`,{className:`text-[10px]`,style:{color:`var(--gv-text-dim)`},children:`idle`})});let f=-Math.PI/2,p=a.map(e=>{let t=e.value/o*2*Math.PI,n={...e,startAngle:f,endAngle:f+t};return f+=t,n});return(0,z.jsxs)(`div`,{className:`flex flex-col items-center gap-2`,children:[(0,z.jsx)(`svg`,{width:t,height:n,children:(0,z.jsxs)(d7,{top:l,left:c,children:[p.map(e=>(0,z.jsx)(O7,{innerRadius:d,outerRadius:u,startAngle:e.startAngle,endAngle:e.endAngle,fill:s(e.label),stroke:`var(--gv-bg)`,strokeWidth:2,opacity:.85},e.label)),(0,z.jsx)(`text`,{textAnchor:`middle`,dy:`0.4em`,fontSize:18,fontWeight:`bold`,fill:`var(--gv-text-primary)`,fontFamily:`var(--gv-font-mono)`,children:o}),(0,z.jsx)(`text`,{textAnchor:`middle`,dy:`1.8em`,fontSize:10,fill:`var(--gv-text-secondary)`,fontFamily:`var(--gv-font-display)`,children:`agents`})]})}),(0,z.jsx)(`div`,{className:`flex flex-col gap-0.5 w-full`,children:p.map(e=>(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,z.jsx)(`div`,{className:`w-2 h-2 rounded-sm shrink-0`,style:{backgroundColor:s(e.label)}}),(0,z.jsx)(`span`,{className:`text-[10px] truncate`,style:{color:`var(--gv-text-secondary)`},children:e.label}),(0,z.jsx)(`span`,{className:`text-[10px] gv-mono ml-auto`,style:{color:`var(--gv-text-dim)`},children:e.value})]},e.label))})]})}function nEt({label:e,value:t,color:n,size:r=80}){let i=r/2,a=r/2,o=i-4,s=o-10,c=-Math.PI*.75,l=Math.PI*.75,u=c+t/100*(l-c);return(0,z.jsxs)(`div`,{className:`flex flex-col items-center gap-0.5`,children:[(0,z.jsx)(`svg`,{width:r,height:r*.7,overflow:`visible`,children:(0,z.jsxs)(d7,{top:a,left:i,children:[(0,z.jsx)(O7,{innerRadius:s,outerRadius:o,startAngle:c,endAngle:l,fill:`rgba(255,255,255,0.06)`}),(0,z.jsx)(O7,{innerRadius:s,outerRadius:o,startAngle:c,endAngle:u,fill:n,opacity:.85}),(0,z.jsxs)(`text`,{textAnchor:`middle`,dy:`0.35em`,fontSize:13,fontWeight:`bold`,fill:n,fontFamily:`var(--gv-font-mono)`,children:[Math.round(t),`%`]})]})}),(0,z.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wider`,style:{color:`var(--gv-text-secondary)`},children:e})]})}function rEt(e){if(e===0)return`0 B`;let t=e/1024**3;return t>=1?`${t.toFixed(1)} GB`:`${(e/1024**2).toFixed(0)} MB`}function iEt(){let e=c7(e=>e.systemHealth);return e?(0,z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,z.jsx)(`h3`,{className:`text-xs font-bold uppercase tracking-widest px-1`,style:{color:`var(--gv-text-secondary)`},children:`System`}),(0,z.jsxs)(`div`,{className:`flex justify-around gap-2`,children:[(0,z.jsx)(nEt,{label:`CPU`,value:e.cpu,color:`var(--gv-blue)`}),(0,z.jsx)(nEt,{label:`MEM`,value:e.memPercent,color:`var(--gv-purple)`})]}),(0,z.jsxs)(`div`,{className:`flex justify-between px-1`,children:[(0,z.jsxs)(`span`,{className:`text-[10px]`,style:{color:`var(--gv-text-dim)`},children:[`Used: `,rEt(e.memUsed)]}),(0,z.jsxs)(`span`,{className:`text-[10px]`,style:{color:`var(--gv-text-dim)`},children:[`Total: `,rEt(e.memTotal)]})]})]}):(0,z.jsx)(`div`,{className:`text-[10px] text-center py-2`,style:{color:`var(--gv-text-dim)`},children:`Loading system stats...`})}function aEt({agents:e}){return(0,z.jsxs)(`div`,{className:`gv-glass flex flex-col gap-3 p-3 overflow-hidden shrink-0`,style:{width:220,borderColor:`rgba(0, 212, 255, 0.1)`},children:[(0,z.jsx)(`div`,{className:`flex flex-col gap-2 flex-1 min-h-0 overflow-hidden`,children:(0,z.jsx)(Bwt,{})}),(0,z.jsx)(`div`,{className:`w-full h-px`,style:{backgroundColor:`var(--gv-border)`}}),(0,z.jsxs)(`div`,{className:`shrink-0`,children:[(0,z.jsx)(`h3`,{className:`text-xs font-bold uppercase tracking-widest px-1 mb-2`,style:{color:`var(--gv-text-secondary)`},children:`Agents`}),(0,z.jsx)(tEt,{agents:e,width:100,height:100})]}),(0,z.jsx)(`div`,{className:`w-full h-px`,style:{backgroundColor:`var(--gv-border)`}}),(0,z.jsx)(`div`,{className:`shrink-0`,children:(0,z.jsx)(iEt,{})})]})}function oEt(){jwt();let e=sm(lm);return(0,z.jsxs)(`div`,{className:`god-view flex flex-col h-full`,children:[(0,z.jsx)(Pwt,{agents:e}),(0,z.jsxs)(`div`,{className:`flex flex-1 gap-3 px-3 pb-3 pt-2 min-h-0 overflow-hidden`,children:[(0,z.jsx)(`div`,{className:`flex flex-1 min-w-0 min-h-0 items-center justify-center rounded-2xl border border-white/10 bg-black/20 text-sm text-white/50`,children:`Agent scan moved to the Agents fleet view.`}),(0,z.jsx)(aEt,{agents:e})]})]})}var sEt=[`deacon`,`pause`];function cEt(){return B({queryKey:sEt,queryFn:async()=>{let e=await fetch(`/api/deacon/pause`);if(!e.ok)throw Error(`GET /api/deacon/pause → ${e.status}`);return e.json()},staleTime:5e3,refetchInterval:3e4,refetchOnWindowFocus:!0})}function lEt(){let e=_t();return Nt({mutationFn:async e=>{let t=await fetch(`/api/deacon/pause`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({paused:e})});if(!t.ok){let e=await t.text().catch(()=>``);throw Error(e||`POST /api/deacon/pause → ${t.status}`)}return t.json()},onSuccess:t=>{e.setQueryData(sEt,t)}})}function uEt({compact:e=!1}){let{data:t}=cEt(),n=lEt(),r=t?.paused===!0,i=n.isPending,a=()=>{i||n.mutate(!r)},o=r?`Deacon is FROZEN — click to resume patrol`:`Freeze Deacon — stop all patrol cycles globally`;return e?(0,z.jsxs)(`button`,{onClick:a,disabled:i,className:`relative inline-flex items-center gap-1.5 transition-colors disabled:opacity-50 ${r?`rounded-full border border-warning/50 bg-warning/15 px-2.5 py-1 text-xs font-medium text-warning-foreground hover:bg-warning/25`:`rounded-md p-1.5 text-muted-foreground hover:bg-accent hover:text-foreground`}`,title:o,children:[(0,z.jsx)(Bee,{className:`h-3.5 w-3.5`}),r&&(0,z.jsx)(`span`,{children:`Deacon frozen`}),r&&(0,z.jsx)(`span`,{className:`absolute -right-1 -top-1 flex h-3.5 w-3.5 animate-pulse items-center justify-center rounded-full bg-amber-500 text-[9px] font-bold leading-none text-white ring-2 ring-background`,children:`!`})]}):(0,z.jsx)(`button`,{onClick:a,disabled:i,className:`inline-flex items-center gap-1.5 px-2 py-1 rounded-md text-xs font-semibold transition-colors disabled:opacity-50 ${r?`text-sky-200 bg-sky-900/70 hover:bg-sky-800/80 border border-sky-400/60`:`text-muted-foreground hover:text-foreground hover:bg-accent border border-transparent`}`,title:o,children:r?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(hr,{className:`w-3.5 h-3.5`}),`Resume Deacon`]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Bee,{className:`w-3.5 h-3.5`}),`Freeze Deacon`]})})}async function dEt(){let e=await fetch(`/api/deacon/status`);if(!e.ok)throw Error(`Failed to fetch deacon status`);return e.json()}async function fEt(){let e=await fetch(`/api/deacon/logs?limit=200`);if(!e.ok)throw Error(`Failed to fetch deacon logs`);return e.json()}function pEt(e){if(!e)return`never`;let t=Date.now()-new Date(e).getTime();if(t<0)return`just now`;let n=Math.floor(t/1e3);if(n<60)return`${n}s ago`;let r=Math.floor(n/60);if(r<60)return`${r}m ago`;let i=Math.floor(r/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function mEt(e){try{return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}catch{return``}}var hEt={info:{label:`INF`,cls:`text-muted-foreground bg-muted`},action:{label:`ACT`,cls:`text-primary bg-primary/10`},warn:{label:`WRN`,cls:`text-amber-500 bg-amber-500/10`},error:{label:`ERR`,cls:`text-destructive bg-destructive/10`}};function gEt(e){return e.consecutiveFailures>=3?`bg-destructive`:e.consecutiveFailures>0||e.lastForceKillTime&&Date.now()-new Date(e.lastForceKillTime).getTime()<300*1e3?`bg-amber-500`:`bg-emerald-500`}function _Et(e){let t=[];for(let n of e){let e=t[t.length-1];e&&e.cycle===n.cycle?e.entries.push(n):t.push({cycle:n.cycle,entries:[n]})}return t}function vEt(){let e=_t(),{data:t}=B({queryKey:[`deacon-status`],queryFn:dEt,refetchInterval:1e4}),{data:n}=B({queryKey:[`deacon-logs-full`],queryFn:fEt,refetchInterval:5e3}),r=Nt({mutationFn:async()=>{let e=await fetch(`/api/deacon/patrol`,{method:`POST`});if(!e.ok)throw Error(`Failed to trigger patrol`);return e.json()},onSuccess:()=>{e.invalidateQueries({queryKey:[`deacon-status`]}),e.invalidateQueries({queryKey:[`deacon-logs-full`]})}}),i=(0,R.useMemo)(()=>Object.values(t?.state.specialists||{}),[t]),a=(0,R.useMemo)(()=>_Et([...n?.logs||[]].reverse()),[n]),o=t?Math.round(t.config.patrolIntervalMs/1e3):null;return(0,z.jsx)(`div`,{className:`w-full h-full overflow-y-auto bg-background text-foreground`,children:(0,z.jsxs)(`div`,{className:`mx-auto max-w-4xl px-6 py-6`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-3 mb-6`,children:[(0,z.jsx)(kr,{className:`w-6 h-6 ${t?.isRunning?`text-emerald-500`:`text-muted-foreground`}`}),(0,z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,z.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Deacon`}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Cloister lifecycle watchdog — patrols, auto-resumes, and janitor actions`})]}),(0,z.jsx)(uEt,{}),(0,z.jsxs)(`button`,{onClick:()=>r.mutate(),disabled:r.isPending||!t?.isRunning,className:`inline-flex items-center gap-1.5 rounded-md border border-border bg-popover px-2.5 py-1.5 text-xs text-foreground hover:bg-card transition-colors disabled:opacity-50`,title:t?.isRunning?`Run a patrol cycle now`:`Deacon is stopped`,children:[(0,z.jsx)(_r,{className:`w-3.5 h-3.5 ${r.isPending?`animate-spin`:``}`}),`Run patrol`]})]}),(0,z.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-3 mb-6`,children:[(0,z.jsx)($7,{label:`Status`,value:t?t.isRunning?`Running`:`Stopped`:`—`,valueClass:t?.isRunning?`text-emerald-500`:`text-muted-foreground`}),(0,z.jsx)($7,{label:`Patrol cycle`,value:t?`#${t.state.patrolCycle}`:`—`}),(0,z.jsx)($7,{label:`Last patrol`,value:pEt(t?.state.lastPatrol)}),(0,z.jsx)($7,{label:`Interval`,value:o==null?`—`:`${o}s`})]}),t?.lastPatrol?.massDeathDetected&&(0,z.jsxs)(`div`,{className:`flex items-center gap-2 mb-6 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:[(0,z.jsx)(Ir,{className:`w-4 h-4 shrink-0`}),`Mass-death detected on the last patrol — auto-resume was held back as a safety brake.`]}),(0,z.jsx)(`h2`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground mb-2`,children:`Specialist health`}),(0,z.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 gap-2 mb-6`,children:i.length===0?(0,z.jsx)(`div`,{className:`col-span-full text-xs text-muted-foreground`,children:`No specialists tracked yet.`}):i.map(e=>(0,z.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border bg-card px-3 py-2`,children:[(0,z.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0 ${gEt(e)}`}),(0,z.jsx)(`span`,{className:`text-xs text-foreground truncate flex-1`,children:e.specialistName.replace(`-agent`,``)}),e.consecutiveFailures>0&&(0,z.jsxs)(`span`,{className:`text-[10px] text-amber-500`,title:`consecutive failures`,children:[e.consecutiveFailures,`×`]}),e.forceKillCount>0&&(0,z.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,title:`force-kills`,children:[`⊘`,e.forceKillCount]})]},e.specialistName))}),(0,z.jsxs)(`h2`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground mb-2 flex items-center gap-1.5`,children:[(0,z.jsx)(Lt,{className:`w-3.5 h-3.5`}),` Patrol activity`]}),(0,z.jsx)(`div`,{className:`rounded-md border border-border bg-card divide-y divide-border`,children:a.length===0?(0,z.jsx)(`div`,{className:`px-3 py-6 text-center text-xs text-muted-foreground`,children:`No patrol activity yet — waiting for the next cycle.`}):a.map((e,t)=>(0,z.jsxs)(`div`,{className:`px-3 py-2`,children:[(0,z.jsx)(`div`,{className:`mb-1.5 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e.cycle==null?`Uncycled`:`Cycle #${e.cycle}`}),(0,z.jsx)(`div`,{className:`space-y-1`,children:e.entries.map((e,t)=>{let n=hEt[e.level]??hEt.info;return(0,z.jsxs)(`div`,{className:`flex items-start gap-2 text-xs`,children:[(0,z.jsx)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums shrink-0 mt-0.5`,children:mEt(e.timestamp)}),(0,z.jsx)(`span`,{className:`text-[9px] font-semibold rounded px-1 py-0.5 shrink-0 mt-0.5 ${n.cls}`,children:n.label}),(0,z.jsx)(`span`,{className:`text-foreground break-words min-w-0`,children:e.message})]},t)})})]},t))})]})})}function $7({label:e,value:t,valueClass:n}){return(0,z.jsxs)(`div`,{className:`rounded-md border border-border bg-card px-3 py-2`,children:[(0,z.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:e}),(0,z.jsx)(`div`,{className:`text-sm font-medium ${n??`text-foreground`}`,children:t})]})}function yEt(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function bEt(e){if(Array.isArray(e))return e}function xEt(e,t,n){return(t=AEt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function SEt(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function CEt(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
669
669
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function wEt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function TEt(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?wEt(Object(n),!0).forEach(function(t){xEt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):wEt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function EEt(e,t){if(e==null)return{};var n,r,i=DEt(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function DEt(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function OEt(e,t){return bEt(e)||SEt(e,t)||jEt(e,t)||CEt()}function kEt(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function AEt(e){var t=kEt(e,`string`);return typeof t==`symbol`?t:t+``}function jEt(e,t){if(e){if(typeof e==`string`)return yEt(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?yEt(e,t):void 0}}function MEt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function NEt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function PEt(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?NEt(Object(n),!0).forEach(function(t){MEt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):NEt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function FEt(){var e=[...arguments];return function(t){return e.reduceRight(function(e,t){return t(e)},t)}}function e9(e){return function t(){var n=this,r=[...arguments];return r.length>=e.length?e.apply(this,r):function(){var e=[...arguments];return t.apply(n,[].concat(r,e))}}}function t9(e){return{}.toString.call(e).includes(`Object`)}function IEt(e){return!Object.keys(e).length}function n9(e){return typeof e==`function`}function LEt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function REt(e,t){return t9(t)||r9(`changeType`),Object.keys(t).some(function(t){return!LEt(e,t)})&&r9(`changeField`),t}function zEt(e){n9(e)||r9(`selectorType`)}function BEt(e){n9(e)||t9(e)||r9(`handlerType`),t9(e)&&Object.values(e).some(function(e){return!n9(e)})&&r9(`handlersType`)}function VEt(e){e||r9(`initialIsRequired`),t9(e)||r9(`initialType`),IEt(e)&&r9(`initialContent`)}function HEt(e,t){throw Error(e[t]||e.default)}var r9=e9(HEt)({initialIsRequired:`initial state is required`,initialType:`initial state should be an object`,initialContent:`initial state shouldn't be an empty object`,handlerType:`handler should be an object or a function`,handlersType:`all handlers should be a functions`,selectorType:`selector should be a function`,changeType:`provided value of changes should be an object`,changeField:`it seams you want to change a field in the state which is not specified in the "initial" state`,default:"an unknown error accured in `state-local` package"}),i9={changes:REt,selector:zEt,handler:BEt,initial:VEt};function UEt(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};i9.initial(e),i9.handler(t);var n={current:e},r=e9(KEt)(n,t),i=e9(GEt)(n),a=e9(i9.changes)(e),o=e9(WEt)(n);function s(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(e){return e};return i9.selector(e),e(n.current)}function c(e){FEt(r,i,a,o)(e)}return[s,c]}function WEt(e,t){return n9(t)?t(e.current):t}function GEt(e,t){return e.current=PEt(PEt({},e.current),t),t}function KEt(e,t,n){return n9(t)?t(e.current):Object.keys(n).forEach(function(n){return t[n]?.call(t,e.current[n])}),n}var qEt={create:UEt},JEt={paths:{vs:`https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs`}};function YEt(e){return function t(){var n=this,r=[...arguments];return r.length>=e.length?e.apply(this,r):function(){var e=[...arguments];return t.apply(n,[].concat(r,e))}}}function XEt(e){return{}.toString.call(e).includes(`Object`)}function ZEt(e){return e||tDt(`configIsRequired`),XEt(e)||tDt(`configType`),e.urls?(QEt(),{paths:{vs:e.urls.monacoBase}}):e}function QEt(){console.warn(eDt.deprecation)}function $Et(e,t){throw Error(e[t]||e.default)}var eDt={configIsRequired:`the configuration object is required`,configType:`the configuration object should be an object`,default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
|
|
670
670
|
You are using deprecated way of configuration.
|
|
671
671
|
|
|
@@ -675,7 +675,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
675
675
|
monaco.config({ paths: { vs: '...' } })
|
|
676
676
|
|
|
677
677
|
For more please check the link https://github.com/suren-atoyan/monaco-loader#config
|
|
678
|
-
`},tDt=YEt($Et)(eDt),nDt={config:ZEt},rDt=function(){var e=[...arguments];return function(t){return e.reduceRight(function(e,t){return t(e)},t)}};function iDt(e,t){return Object.keys(t).forEach(function(n){t[n]instanceof Object&&e[n]&&Object.assign(t[n],iDt(e[n],t[n]))}),TEt(TEt({},e),t)}var aDt={type:`cancelation`,msg:`operation is manually canceled`};function a9(e){var t=!1,n=new Promise(function(n,r){e.then(function(e){return t?r(aDt):n(e)}),e.catch(r)});return n.cancel=function(){return t=!0},n}var oDt=[`monaco`],sDt=OEt(qEt.create({config:JEt,isInitialized:!1,resolve:null,reject:null,monaco:null}),2),o9=sDt[0],s9=sDt[1];function cDt(e){var t=nDt.config(e),n=t.monaco,r=EEt(t,oDt);s9(function(e){return{config:iDt(e.config,r),monaco:n}})}function lDt(){var e=o9(function(e){return{monaco:e.monaco,isInitialized:e.isInitialized,resolve:e.resolve}});if(!e.isInitialized){if(s9({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),a9(c9);if(window.monaco&&window.monaco.editor)return mDt(window.monaco),e.resolve(window.monaco),a9(c9);rDt(uDt,fDt)(pDt)}return a9(c9)}function uDt(e){return document.body.appendChild(e)}function dDt(e){var t=document.createElement(`script`);return e&&(t.src=e),t}function fDt(e){var t=o9(function(e){return{config:e.config,reject:e.reject}}),n=dDt(`${t.config.paths.vs}/loader.js`);return n.onload=function(){return e()},n.onerror=t.reject,n}function pDt(){var e=o9(function(e){return{config:e.config,resolve:e.resolve,reject:e.reject}}),t=window.require;t.config(e.config),t([`vs/editor/editor.main`],function(t){var n=t.m||t;mDt(n),e.resolve(n)},function(t){e.reject(t)})}function mDt(e){o9().monaco||s9({monaco:e})}function hDt(){return o9(function(e){return e.monaco})}var c9=new Promise(function(e,t){return s9({resolve:e,reject:t})}),gDt={config:cDt,init:lDt,__getMonacoInstance:hDt},l9={wrapper:{display:`flex`,position:`relative`,textAlign:`initial`},fullWidth:{width:`100%`},hide:{display:`none`}},_Dt={container:{display:`flex`,height:`100%`,width:`100%`,justifyContent:`center`,alignItems:`center`}};function vDt({children:e}){return R.createElement(`div`,{style:_Dt.container},e)}var yDt=vDt;function bDt({width:e,height:t,isEditorReady:n,loading:r,_ref:i,className:a,wrapperProps:o}){return R.createElement(`section`,{style:{...l9.wrapper,width:e,height:t},...o},!n&&R.createElement(yDt,null,r),R.createElement(`div`,{ref:i,style:{...l9.fullWidth,...!n&&l9.hide},className:a}))}var xDt=(0,R.memo)(bDt);function SDt(e){(0,R.useEffect)(e,[])}var CDt=SDt;function wDt(e,t,n=!0){let r=(0,R.useRef)(!0);(0,R.useEffect)(r.current||!n?()=>{r.current=!1}:e,t)}var u9=wDt;function d9(){}function f9(e,t,n,r){return TDt(e,r)||EDt(e,t,n,r)}function TDt(e,t){return e.editor.getModel(DDt(e,t))}function EDt(e,t,n,r){return e.editor.createModel(t,n,r?DDt(e,r):void 0)}function DDt(e,t){return e.Uri.parse(t)}function ODt({original:e,modified:t,language:n,originalLanguage:r,modifiedLanguage:i,originalModelPath:a,modifiedModelPath:o,keepCurrentOriginalModel:s=!1,keepCurrentModifiedModel:c=!1,theme:l=`light`,loading:u=`Loading...`,options:d={},height:f=`100%`,width:p=`100%`,className:m,wrapperProps:h={},beforeMount:g=d9,onMount:_=d9}){let[v,y]=(0,R.useState)(!1),[b,x]=(0,R.useState)(!0),S=(0,R.useRef)(null),C=(0,R.useRef)(null),w=(0,R.useRef)(null),T=(0,R.useRef)(_),E=(0,R.useRef)(g),D=(0,R.useRef)(!1);CDt(()=>{let e=gDt.init();return e.then(e=>(C.current=e)&&x(!1)).catch(e=>e?.type!==`cancelation`&&console.error(`Monaco initialization: error:`,e)),()=>S.current?A():e.cancel()}),u9(()=>{if(S.current&&C.current){let t=S.current.getOriginalEditor(),i=f9(C.current,e||``,r||n||`text`,a||``);i!==t.getModel()&&t.setModel(i)}},[a],v),u9(()=>{if(S.current&&C.current){let e=S.current.getModifiedEditor(),r=f9(C.current,t||``,i||n||`text`,o||``);r!==e.getModel()&&e.setModel(r)}},[o],v),u9(()=>{let e=S.current.getModifiedEditor();e.getOption(C.current.editor.EditorOption.readOnly)?e.setValue(t||``):t!==e.getValue()&&(e.executeEdits(``,[{range:e.getModel().getFullModelRange(),text:t||``,forceMoveMarkers:!0}]),e.pushUndoStop())},[t],v),u9(()=>{S.current?.getModel()?.original.setValue(e||``)},[e],v),u9(()=>{let{original:e,modified:t}=S.current.getModel();C.current.editor.setModelLanguage(e,r||n||`text`),C.current.editor.setModelLanguage(t,i||n||`text`)},[n,r,i],v),u9(()=>{C.current?.editor.setTheme(l)},[l],v),u9(()=>{S.current?.updateOptions(d)},[d],v);let O=(0,R.useCallback)(()=>{if(!C.current)return;E.current(C.current);let s=f9(C.current,e||``,r||n||`text`,a||``),c=f9(C.current,t||``,i||n||`text`,o||``);S.current?.setModel({original:s,modified:c})},[n,t,i,e,r,a,o]),k=(0,R.useCallback)(()=>{!D.current&&w.current&&(S.current=C.current.editor.createDiffEditor(w.current,{automaticLayout:!0,...d}),O(),C.current?.editor.setTheme(l),y(!0),D.current=!0)},[d,l,O]);(0,R.useEffect)(()=>{v&&T.current(S.current,C.current)},[v]),(0,R.useEffect)(()=>{!b&&!v&&k()},[b,v,k]);function A(){let e=S.current?.getModel();s||e?.original?.dispose(),c||e?.modified?.dispose(),S.current?.dispose()}return R.createElement(xDt,{width:p,height:f,isEditorReady:v,loading:u,_ref:w,className:m,wrapperProps:h})}(0,R.memo)(ODt);function kDt(e){let t=(0,R.useRef)();return(0,R.useEffect)(()=>{t.current=e},[e]),t.current}var ADt=kDt,p9=new Map;function jDt({defaultValue:e,defaultLanguage:t,defaultPath:n,value:r,language:i,path:a,theme:o=`light`,line:s,loading:c=`Loading...`,options:l={},overrideServices:u={},saveViewState:d=!0,keepCurrentModel:f=!1,width:p=`100%`,height:m=`100%`,className:h,wrapperProps:g={},beforeMount:_=d9,onMount:v=d9,onChange:y,onValidate:b=d9}){let[x,S]=(0,R.useState)(!1),[C,w]=(0,R.useState)(!0),T=(0,R.useRef)(null),E=(0,R.useRef)(null),D=(0,R.useRef)(null),O=(0,R.useRef)(v),k=(0,R.useRef)(_),A=(0,R.useRef)(),j=(0,R.useRef)(r),M=ADt(a),N=(0,R.useRef)(!1),P=(0,R.useRef)(!1);CDt(()=>{let e=gDt.init();return e.then(e=>(T.current=e)&&w(!1)).catch(e=>e?.type!==`cancelation`&&console.error(`Monaco initialization: error:`,e)),()=>E.current?I():e.cancel()}),u9(()=>{let o=f9(T.current,e||r||``,t||i||``,a||n||``);o!==E.current?.getModel()&&(d&&p9.set(M,E.current?.saveViewState()),E.current?.setModel(o),d&&E.current?.restoreViewState(p9.get(a)))},[a],x),u9(()=>{E.current?.updateOptions(l)},[l],x),u9(()=>{!E.current||r===void 0||(E.current.getOption(T.current.editor.EditorOption.readOnly)?E.current.setValue(r):r!==E.current.getValue()&&(P.current=!0,E.current.executeEdits(``,[{range:E.current.getModel().getFullModelRange(),text:r,forceMoveMarkers:!0}]),E.current.pushUndoStop(),P.current=!1))},[r],x),u9(()=>{let e=E.current?.getModel();e&&i&&T.current?.editor.setModelLanguage(e,i)},[i],x),u9(()=>{s!==void 0&&E.current?.revealLine(s)},[s],x),u9(()=>{T.current?.editor.setTheme(o)},[o],x);let F=(0,R.useCallback)(()=>{if(!(!D.current||!T.current)&&!N.current){k.current(T.current);let c=a||n,f=f9(T.current,r||e||``,t||i||``,c||``);E.current=T.current?.editor.create(D.current,{model:f,automaticLayout:!0,...l},u),d&&E.current.restoreViewState(p9.get(c)),T.current.editor.setTheme(o),s!==void 0&&E.current.revealLine(s),S(!0),N.current=!0}},[e,t,n,r,i,a,l,u,d,o,s]);(0,R.useEffect)(()=>{x&&O.current(E.current,T.current)},[x]),(0,R.useEffect)(()=>{!C&&!x&&F()},[C,x,F]),j.current=r,(0,R.useEffect)(()=>{x&&y&&(A.current?.dispose(),A.current=E.current?.onDidChangeModelContent(e=>{P.current||y(E.current.getValue(),e)}))},[x,y]),(0,R.useEffect)(()=>{if(x){let e=T.current.editor.onDidChangeMarkers(e=>{let t=E.current.getModel()?.uri;if(t&&e.find(e=>e.path===t.path)){let e=T.current.editor.getModelMarkers({resource:t});b?.(e)}});return()=>{e?.dispose()}}return()=>{}},[x,b]);function I(){A.current?.dispose(),f?d&&p9.set(a,E.current.saveViewState()):E.current.getModel()?.dispose(),E.current.dispose()}return R.createElement(xDt,{width:p,height:m,isEditorReady:x,loading:c,_ref:D,className:h,wrapperProps:g})}var MDt=(0,R.memo)(jDt);function NDt({value:e,onChange:t,disabled:n=!1}){return(0,z.jsx)(MDt,{height:`100%`,language:`markdown`,theme:`vs-dark`,value:e,loading:(0,z.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`Loading editor…`}),options:{minimap:{enabled:!1},wordWrap:`on`,lineNumbers:`on`,readOnly:n,scrollBeyondLastLine:!1,fontSize:13,padding:{top:16,bottom:16},automaticLayout:!0},onChange:e=>t(e??``)})}var PDt=class extends Error{status;body;constructor(e,t,n){super(e),this.status=t,this.body=n,this.name=`ContextApiError`}},m9={layers:[`context`,`layers`]};async function FDt(e){let t=await e.text();if(!t)return null;try{return JSON.parse(t)}catch{return t}}function IDt(e,t){if(t&&typeof t==`object`){let e=t;if(typeof e.error==`string`)return e.error;if(typeof e.message==`string`)return e.message}return typeof t==`string`&&t.trim()?t:`Context API request failed with status ${e}`}async function h9(e,t){let n={Accept:`application/json`};t.body!==void 0&&(n[`Content-Type`]=`application/json`);let r=await fetch(e,{method:t.method,credentials:`include`,headers:n,body:t.body===void 0?void 0:JSON.stringify(t.body)}),i=await FDt(r);if(!r.ok)throw new PDt(IDt(r.status,i),r.status,i);return i}function LDt(){return h9(`/api/context/layers`,{method:`GET`})}function RDt(e){return h9(`/api/context/preview`,{method:`POST`,body:e})}function zDt(e){return h9(`/api/context/layers`,{method:`PUT`,body:e})}function BDt(e={operation:`sync`}){return h9(`/api/context/sync`,{method:`POST`,body:e})}function VDt(){return B({queryKey:m9.layers,queryFn:LDt})}function HDt(){return Nt({mutationFn:RDt})}function UDt(){let e=_t();return Nt({mutationFn:zDt,onSuccess:()=>{e.invalidateQueries({queryKey:m9.layers})}})}function WDt(){let e=_t();return Nt({mutationFn:BDt,onSuccess:()=>{e.invalidateQueries({queryKey:m9.layers})}})}function g9(e){switch(e.kind){case`global`:return`global`;case`project`:return`project:${e.projectKey}`;case`workspace`:return`workspace:${e.projectKey}:${e.workspacePath}`}}function GDt(e){switch(e.kind){case`global`:return{kind:`global`};case`project`:return{kind:`project`,projectKey:e.projectKey};case`workspace`:return{kind:`workspace`,projectKey:e.projectKey,workspacePath:e.workspacePath}}}function KDt(e){switch(e.kind){case`global`:return`~/.overdeck/context/global.md`;case`project`:return`.pan/context/project.md`;case`workspace`:return`.pan/context/workspace.md`}}function qDt(e){switch(e){case`global`:return`Global context`;case`project`:return`Project context`;case`workspace`:return`Workspace context`}}function _9(e){return e instanceof Error?e.message:String(e||`Unknown error`)}function JDt({error:e}){return(0,z.jsx)(`div`,{className:`h-full w-full p-6`,children:(0,z.jsxs)(`div`,{className:`rounded-lg border border-destructive/40 bg-destructive/10 p-4 text-sm text-destructive`,children:[`Failed to load context layers: `,_9(e)]})})}function YDt(e){let t=e.layer?g9(e.layer):`preview`;return`${e.level.toUpperCase()} · ${t}: ${e.message}`}function XDt(){let{data:e,isLoading:t,error:n,refetch:r}=VDt(),i=HDt(),a=UDt(),o=WDt(),s=i.mutateAsync,[c,l]=(0,R.useState)(`global`),[u,d]=(0,R.useState)(``),[f,p]=(0,R.useState)(``),[m,h]=(0,R.useState)({}),[g,_]=(0,R.useState)(`claude-code`),[v,y]=(0,R.useState)(null),[b,x]=(0,R.useState)(null),[S,C]=(0,R.useState)(null),w=(0,R.useMemo)(()=>e?.workspaces.filter(e=>e.projectKey===u)??[],[e?.workspaces,u]);(0,R.useEffect)(()=>{if(!e)return;let t=e.projects[0]?.projectKey??``;d(n=>e.projects.some(e=>e.projectKey===n)?n:t)},[e]),(0,R.useEffect)(()=>{e&&p(w.some(e=>e.path===f)?f:w[0]?.path??``)},[e,w,f]);let T=(0,R.useMemo)(()=>c===`global`?{kind:`global`}:u?c===`project`?{kind:`project`,projectKey:u}:f?{kind:`workspace`,projectKey:u,workspacePath:f}:null:null,[c,u,f]),E=(0,R.useMemo)(()=>{if(!e||!T)return null;let t=g9(T);return e.layers.find(e=>g9(GDt(e))===t)??null},[e,T]),D=(0,R.useMemo)(()=>e?e.layers.flatMap(e=>{let t=GDt(e),n=m[g9(t)];return n===void 0?[]:[{target:t,content:n}]}):[],[e,m]),O=T?g9(T):``,k=E?m[O]??E.content:``,A=e?.projects.find(e=>e.projectKey===u)??null,j=e?.workspaces.find(e=>e.path===f)??null,M=!!E&&m[O]!==void 0&&m[O]!==E.content,N=a.isPending||o.isPending,P=(0,R.useMemo)(()=>e?c===`global`?e.targets.filter(e=>e.layerKind===`global`):c===`project`?e.targets.filter(e=>e.layerKind===`project`&&e.projectKey===u):[]:[],[e,c,u]);(0,R.useEffect)(()=>{if(!T||!E){y(null);return}let e=!1;x(null);let t=window.setTimeout(()=>{s({operation:`preview`,selectedLayer:T,drafts:D}).then(t=>{e||y(t)}).catch(t=>{e||x(_9(t))})},300);return()=>{e=!0,window.clearTimeout(t)}},[D,s,E,T]);async function F(e){if(!(!T||!E)){C(null);try{await a.mutateAsync({operation:`save`,target:T,content:k}),e&&await o.mutateAsync({operation:`sync`}),await r(),h(e=>{let{[O]:t,...n}=e;return n}),H.success(e?`Context saved and synced`:`Context saved`)}catch(e){let t=_9(e);C(t),H.error(t)}}}if(t)return(0,z.jsx)(`div`,{className:`h-full w-full p-6 text-sm text-muted-foreground`,children:`Loading context layers…`});if(n)return(0,z.jsx)(JDt,{error:n});let I=v?.previews[g]??``,ee=v?.diagnostics??[];return(0,z.jsxs)(`div`,{className:`flex h-full w-full overflow-hidden bg-background text-foreground`,children:[(0,z.jsxs)(`aside`,{className:`w-80 shrink-0 overflow-y-auto border-r border-border bg-card/40 p-4`,children:[(0,z.jsxs)(`div`,{className:`mb-5`,children:[(0,z.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:`Context`}),(0,z.jsx)(`h1`,{className:`mt-1 text-lg font-semibold`,children:`Layer editor`}),(0,z.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-muted-foreground`,children:`Edit the context markdown Overdeck injects into coding-agent sessions.`})]}),(0,z.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,z.jsx)(`legend`,{className:`text-xs font-medium uppercase tracking-wide text-muted-foreground`,children:`Layer`}),[`global`,`project`,`workspace`].map(e=>(0,z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 rounded-md border border-border bg-background/60 px-3 py-2 text-sm`,children:[(0,z.jsx)(`input`,{type:`radio`,name:`context-layer-kind`,value:e,checked:c===e,onChange:()=>l(e)}),(0,z.jsx)(`span`,{children:qDt(e)})]},e))]}),(0,z.jsxs)(`div`,{className:`mt-5 space-y-4`,children:[(0,z.jsxs)(`label`,{className:`block space-y-1 text-xs text-muted-foreground`,children:[(0,z.jsx)(`span`,{children:`Project`}),(0,z.jsx)(`select`,{className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground`,value:u,onChange:e=>d(e.target.value),disabled:!e?.projects.length||c===`global`,children:e?.projects.length?e.projects.map(e=>(0,z.jsx)(`option`,{value:e.projectKey,children:e.name},e.projectKey)):(0,z.jsx)(`option`,{value:``,children:`No registered projects`})})]}),(0,z.jsxs)(`label`,{className:`block space-y-1 text-xs text-muted-foreground`,children:[(0,z.jsx)(`span`,{children:`Workspace`}),(0,z.jsx)(`select`,{className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground`,value:f,onChange:e=>p(e.target.value),disabled:c!==`workspace`||w.length===0,children:w.length?w.map(e=>(0,z.jsx)(`option`,{value:e.path,children:e.issueId??e.name},e.path)):(0,z.jsx)(`option`,{value:``,children:`No workspaces for this project`})})]})]}),(0,z.jsx)(`div`,{className:`mt-5 rounded-lg border border-border bg-background/70 p-3 text-xs text-muted-foreground`,children:E?(0,z.jsxs)(`dl`,{className:`space-y-2`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Layer file`}),(0,z.jsx)(`dd`,{className:`mt-1 font-mono`,children:KDt(E)})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Resolved path`}),(0,z.jsx)(`dd`,{className:`mt-1 break-all font-mono`,children:E.file})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Status`}),(0,z.jsx)(`dd`,{className:`mt-1`,children:E.exists?`File exists`:`File has not been created yet`})]})]}):(0,z.jsx)(`p`,{children:`Select a project or workspace to edit its context layer.`})}),(0,z.jsxs)(`div`,{className:`mt-4 rounded-lg border border-border bg-background/70 p-3 text-xs text-muted-foreground`,children:[(0,z.jsx)(`p`,{className:`font-medium text-foreground`,children:`Where this gets injected`}),(0,z.jsxs)(`p`,{className:`mt-1 leading-5`,children:[(0,z.jsx)(`code`,{className:`rounded bg-muted px-1`,children:`pan sync`}),` writes a managed region — between `,(0,z.jsx)(`code`,{className:`rounded bg-muted px-1`,children:`BEGIN/END OVERDECK CONTEXT`}),` markers — into the files below. Anything you wrote `,(0,z.jsx)(`span`,{className:`font-medium text-foreground`,children:`outside`}),` those markers is never modified. Edit the layer source here, not the region.`]}),P.length>0?(0,z.jsx)(`ul`,{className:`mt-2 space-y-2`,children:P.map(e=>(0,z.jsxs)(`li`,{children:[(0,z.jsx)(`div`,{className:`break-all font-mono text-foreground`,children:e.path}),(0,z.jsx)(`div`,{className:`mt-0.5`,children:e.exists?e.hasUserContent?`Has your own content — preserved outside the managed region.`:e.hasManagedRegion?`Managed by Overdeck (no other content).`:`Exists — a managed region is added on next sync.`:`Not created yet — created on next sync.`})]},e.path))}):c===`workspace`?(0,z.jsx)(`p`,{className:`mt-2`,children:`Workspace context is auto-assembled into the workspace and is not injected into any hand-authored file.`}):(0,z.jsx)(`p`,{className:`mt-2`,children:`No injection targets for this selection yet (the project has no project.md).`})]}),c===`workspace`?(0,z.jsxs)(`p`,{className:`mt-4 rounded-lg border border-info/30 bg-info/10 p-3 text-xs leading-5 text-info-foreground`,children:[(0,z.jsx)(`span`,{className:`font-semibold`,children:`Workspace context:`}),` .pan/context/workspace.md is auto-assembled for each workspace and may not exist until a workspace is created.`]}):null]}),(0,z.jsxs)(`section`,{className:`flex min-w-0 flex-1 overflow-hidden`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,z.jsx)(`header`,{className:`shrink-0 border-b border-border px-4 py-3`,children:(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`h2`,{className:`text-sm font-semibold`,children:qDt(c)}),(0,z.jsx)(`p`,{className:`mt-1 truncate text-xs text-muted-foreground`,children:c===`global`?`Applies to every registered project.`:c===`project`?A?.path??`No project selected`:j?.path??`No workspace selected`})]}),E?(0,z.jsx)(`span`,{className:`rounded-full border border-border px-2 py-1 text-xs text-muted-foreground`,children:M?`Edited`:`Loaded`}):null]})}),(0,z.jsx)(`div`,{className:`min-h-0 flex-1`,children:E?(0,z.jsx)(NDt,{value:k,disabled:N,onChange:e=>h(t=>({...t,[O]:e}))}):(0,z.jsx)(`div`,{className:`flex h-full items-center justify-center p-6 text-sm text-muted-foreground`,children:`No context layer is available for the current selection.`})}),(0,z.jsxs)(`footer`,{className:`flex shrink-0 items-center justify-between gap-3 border-t border-border px-4 py-3`,children:[(0,z.jsx)(`div`,{className:`min-w-0 text-xs text-muted-foreground`,children:S?(0,z.jsx)(`span`,{className:`text-destructive`,children:S}):M?`Unsaved changes`:`No unsaved changes`}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`button`,{type:`button`,className:`rounded-md border border-border px-3 py-1.5 text-sm text-foreground disabled:cursor-not-allowed disabled:opacity-50`,disabled:!M||N||!E,onClick:()=>void F(!1),children:a.isPending&&!o.isPending?`Saving…`:`Save`}),(0,z.jsx)(`button`,{type:`button`,className:`rounded-md bg-primary px-3 py-1.5 text-sm font-medium text-primary-foreground disabled:cursor-not-allowed disabled:opacity-50`,disabled:!M||N||!E,onClick:()=>void F(!0),children:N&&o.isPending?`Syncing…`:`Save & Sync`})]})]})]}),(0,z.jsxs)(`aside`,{className:`flex w-[28rem] shrink-0 flex-col overflow-hidden border-l border-border bg-card/30`,children:[(0,z.jsxs)(`div`,{className:`shrink-0 border-b border-border p-4`,children:[(0,z.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:`Preview`}),(0,z.jsx)(`div`,{className:`mt-3 grid grid-cols-3 gap-1 rounded-lg bg-muted p-1`,children:[[`claude-code`,`Claude Code output`],[`ohmypi`,`oh-my-pi output`],[`fullPrompt`,`Full injected prompt`]].map(([e,t])=>(0,z.jsx)(`button`,{type:`button`,className:`rounded-md px-2 py-1.5 text-xs transition-colors ${g===e?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`}`,onClick:()=>_(e),children:t},e))})]}),(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-4`,children:b?(0,z.jsx)(`div`,{className:`rounded-lg border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive`,children:b}):i.isPending&&!I?(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Rendering preview…`}):I?(0,z.jsx)(`pre`,{className:`whitespace-pre-wrap rounded-lg border border-border bg-background p-3 text-xs leading-5 text-foreground`,children:I}):(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Preview updates after the editor changes.`})}),(0,z.jsxs)(`div`,{className:`max-h-40 shrink-0 overflow-auto border-t border-border p-4`,children:[(0,z.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:`Validation`}),ee.length>0?(0,z.jsx)(`ul`,{className:`mt-2 space-y-2 text-xs`,children:ee.map((e,t)=>(0,z.jsx)(`li`,{className:e.level===`error`?`text-destructive`:`text-warning-foreground`,children:YDt(e)},`${e.message}-${t}`))}):(0,z.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:`No validation issues.`})]})]})]})]})}function ZDt({sessions:e,selectedId:t,onSelect:n}){return(0,z.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,z.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{className:`text-gray-500 border-b border-gray-800 sticky top-0 bg-gray-950 z-10`,children:[(0,z.jsx)(`th`,{className:`text-left px-3 py-2 font-medium w-8`}),(0,z.jsx)(`th`,{className:`text-left px-3 py-2 font-medium`,children:`Workspace`}),(0,z.jsx)(`th`,{className:`text-left px-3 py-2 font-medium w-32`,children:`Model`}),(0,z.jsx)(`th`,{className:`text-right px-3 py-2 font-medium w-12`,children:`Msgs`}),(0,z.jsx)(`th`,{className:`text-right px-3 py-2 font-medium w-20`,children:`Cost`}),(0,z.jsx)(`th`,{className:`text-left px-3 py-2 font-medium w-32`,children:`Last Active`})]})}),(0,z.jsx)(`tbody`,{children:e.map(e=>{let r=`${e.source}-${e.id}`,i=r===t,a=e.workspacePath??e.jsonlPath??`Unknown session path`,o=a.split(`/`).slice(-2).join(`/`);return(0,z.jsxs)(`tr`,{onClick:()=>n(i?null:r),className:`border-b border-gray-900 cursor-pointer transition-colors ${i?`bg-blue-950 border-blue-900`:`hover:bg-gray-900`}`,children:[(0,z.jsx)(`td`,{className:`px-3 py-1.5 text-center`,children:e.source===`managed-archived`?(0,z.jsx)(Rt,{className:`h-3 w-3 text-amber-400 inline`}):e.overdeckManaged?(0,z.jsx)(Mr,{className:`h-3 w-3 text-cyan-400 inline`}):e.enrichmentLevel>0?(0,z.jsx)(on,{className:`h-3 w-3 text-green-500 inline`}):(0,z.jsx)(dn,{className:`h-3 w-3 text-gray-700 inline`})}),(0,z.jsxs)(`td`,{className:`px-3 py-1.5 max-w-xs`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,z.jsx)(`div`,{className:`font-mono text-gray-200 truncate`,title:a,children:o}),e.source===`managed-archived`?(0,z.jsxs)(`span`,{className:`shrink-0 rounded-full border border-amber-700 bg-amber-950 px-1.5 py-0.5 text-[10px] font-medium text-amber-200`,children:[`Archived`,e.panIssueId?` · ${e.panIssueId}`:``]}):e.overdeckManaged&&(0,z.jsxs)(`span`,{className:`shrink-0 rounded-full border border-cyan-700 bg-cyan-950 px-1.5 py-0.5 text-[10px] font-medium text-cyan-200`,children:[`Managed`,e.panIssueId?` · ${e.panIssueId}`:``]})]}),e.summary&&(0,z.jsx)(`div`,{className:`text-gray-500 truncate mt-0.5`,title:e.summary,children:e.summary}),e.tags.length>0&&(0,z.jsx)(`div`,{className:`flex gap-1 mt-0.5 flex-wrap`,children:e.tags.slice(0,4).map(e=>(0,z.jsx)(`span`,{className:`px-1 py-0 bg-gray-800 text-gray-400 rounded text-[10px]`,children:e},e))})]}),(0,z.jsx)(`td`,{className:`px-3 py-1.5 text-gray-400 truncate max-w-[8rem]`,children:e.primaryModel?e.primaryModel.split(`-`).slice(-2).join(`-`):`—`}),(0,z.jsx)(`td`,{className:`px-3 py-1.5 text-right text-gray-400 font-mono`,children:e.messageCount}),(0,z.jsx)(`td`,{className:`px-3 py-1.5 text-right font-mono`,children:e.estimatedCost>0?(0,z.jsxs)(`span`,{className:`text-yellow-500`,children:[`$`,e.estimatedCost.toFixed(4)]}):(0,z.jsx)(`span`,{className:`text-gray-700`,children:`—`})}),(0,z.jsx)(`td`,{className:`px-3 py-1.5 text-gray-500`,children:e.lastTs?QDt(e.lastTs):`—`})]},r)})})]})})}function QDt(e){try{let t=new Date(e),n=Date.now()-t.getTime(),r=Math.floor(n/864e5);return r===0?`today`:r===1?`yesterday`:r<7?`${r}d ago`:r<30?`${Math.floor(r/7)}w ago`:t.toISOString().slice(0,10)}catch{return e}}async function $Dt(e,t){await hj().request(n=>n[Pp.enrichSessions]({ids:[e],level:t.tier,confirmed:t.confirmed,...t.model?{model:t.model}:{}}))}async function eOt(e){await hj().request(t=>t[Pp.embedSessions]({ids:[e]}))}async function tOt(e){if(!e)throw Error(`Archived conversation is missing its name`);let t=await fetch(`/api/conversations/${encodeURIComponent(e)}/unarchive`,{method:`POST`});if(!t.ok)throw Error(`Unarchive failed: ${t.status}`)}function nOt(e,t){let n=typeof e==`object`&&e&&`code`in e?String(e.code??``):``,r=/^COST_THRESHOLD:([^:]+):([^:]+):([^:]+)$/.exec(n);return r?{tier:t.tier,estimatedCost:Number(r[1]),threshold:Number(r[2]),sessionCount:Number(r[3]),model:t.model}:null}function rOt(e){return{id:e.id,jsonlPath:e.jsonlPath,workspacePath:e.workspacePath??null,primaryModel:e.primaryModel??null,messageCount:e.messageCount,firstTs:e.firstTs??null,lastTs:e.lastTs??null,estimatedCost:e.estimatedCost,tokenInput:e.tokenInput,tokenOutput:e.tokenOutput,toolsUsed:[...e.toolsUsed],filesTouched:[...e.filesTouched],tags:[...e.tags],summary:e.summary??null,summaryDetailed:e.summaryDetailed??null,enrichmentLevel:e.enrichmentLevel,enrichmentFailed:e.enrichmentFailed,overdeckManaged:e.overdeckManaged,panIssueId:e.panIssueId??null}}async function iOt(e){return rOt(await hj().request(t=>t[Pp.getDiscoveredSession]({id:e})))}function aOt({session:e,onClose:t}){let n=_t(),[r,i]=(0,R.useState)(null),[a,o]=(0,R.useState)(``),s=e.source===`managed-archived`,c=sm(t=>t.enrichProgressBySessionId[e.id]),{data:l}=B({queryKey:[`discovered-session`,e.id],queryFn:()=>iOt(e.id),staleTime:1/0,placeholderData:e,enabled:!s}),u=s?e:l??e,d=()=>{n.invalidateQueries({queryKey:[`discovered-session`,e.id]}),n.invalidateQueries({queryKey:[`discovered-sessions`]}),n.invalidateQueries({queryKey:[`discovered-sessions-search`]}),n.invalidateQueries({queryKey:[`discovered-sessions-stats`]})},f=Nt({mutationFn:t=>$Dt(e.id,t),onSuccess:()=>{i(null),d()},onError:(e,t)=>{i(nOt(e,t))}}),p=Nt({mutationFn:()=>eOt(e.id),onSuccess:d}),m=Nt({mutationFn:()=>tOt(u.conversationName),onSuccess:()=>{n.invalidateQueries({queryKey:[`archived-conversations`]}),n.invalidateQueries({queryKey:[`conversations`]})}}),h=(e,t)=>(0,z.jsxs)(`div`,{className:`flex gap-2 text-xs py-1 border-b border-gray-900`,children:[(0,z.jsx)(`span`,{className:`text-gray-500 w-28 shrink-0`,children:e}),(0,z.jsx)(`span`,{className:`text-gray-200 font-mono break-all`,children:t??`—`})]}),g=e=>{let t=a.trim();f.mutate({tier:e,...t?{model:t}:{}})};return(0,z.jsxs)(`div`,{className:`flex flex-col h-full border-l border-gray-800 bg-gray-950`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-gray-800 shrink-0`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsxs)(`span`,{className:`text-xs font-semibold text-gray-300`,children:[`Session #`,u.id]}),(0,z.jsx)(`span`,{className:u.overdeckManaged?`rounded border border-emerald-500/40 bg-emerald-950/60 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-emerald-300`:`rounded border border-amber-500/40 bg-amber-950/50 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-amber-300`,title:u.overdeckManaged?`Overdeck-managed session`:`Ad-hoc discovered session`,children:u.overdeckManaged?`Managed${u.panIssueId?` · ${u.panIssueId}`:``}`:`Ad-hoc`})]}),(0,z.jsx)(`button`,{onClick:t,className:`text-gray-600 hover:text-gray-300 transition-colors`,children:(0,z.jsx)(zr,{className:`h-4 w-4`})})]}),(0,z.jsxs)(`div`,{className:`flex-1 overflow-auto px-3 py-2 space-y-4`,children:[u.summary&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] font-semibold text-gray-500 uppercase tracking-wider mb-1`,children:`Summary`}),(0,z.jsx)(`p`,{className:`text-xs text-gray-300 leading-relaxed`,children:u.summary})]}),u.summaryDetailed&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] font-semibold text-gray-500 uppercase tracking-wider mb-1`,children:`Detailed`}),(0,z.jsx)(`p`,{className:`text-xs text-gray-400 leading-relaxed`,children:u.summaryDetailed})]}),u.tags.length>0&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] font-semibold text-gray-500 uppercase tracking-wider mb-1`,children:`Tags`}),(0,z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:u.tags.map(e=>(0,z.jsx)(`span`,{className:`px-1.5 py-0.5 bg-gray-800 text-cyan-400 rounded text-[10px]`,children:e},e))})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] font-semibold text-gray-500 uppercase tracking-wider mb-1`,children:`Metadata`}),h(`Workspace`,u.workspacePath),h(`Model`,u.primaryModel),h(`Messages`,u.messageCount),h(`Input tokens`,u.tokenInput.toLocaleString()),h(`Output tokens`,u.tokenOutput.toLocaleString()),h(`Est. cost`,u.estimatedCost>0?`$${u.estimatedCost.toFixed(6)}`:null),h(`First active`,u.firstTs?v9(u.firstTs):null),h(`Last active`,u.lastTs?v9(u.lastTs):null),s&&h(`Archived at`,u.archivedAt?v9(u.archivedAt):null),u.panIssueId&&h(`Issue`,u.panIssueId),h(`Enrichment`,u.enrichmentLevel===0?`None`:`L${u.enrichmentLevel}`)]}),u.toolsUsed.length>0&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] font-semibold text-gray-500 uppercase tracking-wider mb-1`,children:`Tools Used`}),(0,z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:u.toolsUsed.map(e=>(0,z.jsx)(`span`,{className:`px-1.5 py-0.5 bg-gray-900 text-gray-400 rounded text-[10px] font-mono`,children:e},e))})]}),u.filesTouched.length>0&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] font-semibold text-gray-500 uppercase tracking-wider mb-1`,children:`Files Touched`}),(0,z.jsx)(`div`,{className:`space-y-1 max-h-28 overflow-auto`,children:u.filesTouched.map(e=>(0,z.jsx)(`div`,{className:`text-[10px] text-gray-500 font-mono break-all`,children:e},e))})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] font-semibold text-gray-500 uppercase tracking-wider mb-1`,children:`File`}),(0,z.jsxs)(`div`,{className:`flex items-start gap-1`,children:[(0,z.jsx)(kn,{className:`h-3 w-3 text-gray-600 mt-0.5 shrink-0`}),(0,z.jsx)(`span`,{className:`text-[10px] text-gray-600 font-mono break-all`,children:u.jsonlPath??`No JSONL path available`})]})]})]}),(0,z.jsx)(`div`,{className:`px-3 py-2 border-t border-gray-800 shrink-0`,children:s?(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] text-gray-500 mb-1.5`,children:`Archived conversation`}),(0,z.jsx)(`div`,{className:`text-[10px] text-gray-600 mb-2`,children:`Restore this conversation to the active Command Deck list.`}),(0,z.jsx)(`button`,{onClick:()=>m.mutate(),disabled:m.isPending||m.isSuccess,className:`rounded bg-amber-700 px-2 py-1 text-xs text-amber-50 transition-colors hover:bg-amber-600 disabled:opacity-50`,children:m.isPending?`Unarchiving…`:`Unarchive`}),m.isSuccess&&(0,z.jsx)(`div`,{className:`text-[10px] text-green-400 mt-1`,children:`Conversation restored`}),m.isError&&(0,z.jsx)(`div`,{className:`text-[10px] text-red-400 mt-1`,children:m.error instanceof Error?m.error.message:`Unarchive failed`})]}):(0,z.jsxs)(z.Fragment,{children:[u.enrichmentLevel<3&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`text-[10px] text-gray-500 mb-1.5`,children:u.enrichmentFailed?`Enrichment failed — retry:`:`Enrich this session`}),(0,z.jsx)(`div`,{className:`text-[10px] text-amber-500/80 mb-1.5`,children:`Sends redacted conversation excerpts to the configured enrichment provider.`}),(0,z.jsxs)(`label`,{className:`mb-2 block text-[10px] text-gray-500`,children:[`Custom model`,(0,z.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),placeholder:`Use default provider model`,className:`mt-1 w-full rounded border border-gray-800 bg-gray-900 px-2 py-1 text-[10px] text-gray-200 placeholder-gray-600 focus:border-blue-500 focus:outline-none`})]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[u.enrichmentLevel<1&&(0,z.jsxs)(`button`,{onClick:()=>g(1),disabled:f.isPending,className:`flex items-center gap-1 px-2 py-1 bg-gray-800 hover:bg-gray-700 text-gray-300 rounded text-xs transition-colors disabled:opacity-50`,children:[(0,z.jsx)(Ar,{className:`h-3 w-3`}),`Quick (L1)`]}),u.enrichmentLevel<2&&(0,z.jsxs)(`button`,{onClick:()=>g(2),disabled:f.isPending,className:`flex items-center gap-1 px-2 py-1 bg-gray-800 hover:bg-gray-700 text-gray-300 rounded text-xs transition-colors disabled:opacity-50`,children:[(0,z.jsx)(Ar,{className:`h-3 w-3 text-yellow-400`}),`Detailed (L2)`]}),(0,z.jsxs)(`button`,{onClick:()=>g(3),disabled:f.isPending,className:`flex items-center gap-1 px-2 py-1 bg-gray-800 hover:bg-gray-700 text-gray-300 rounded text-xs transition-colors disabled:opacity-50`,children:[(0,z.jsx)(Ar,{className:`h-3 w-3 text-purple-400`}),`Deep (L3)`]})]})]}),f.isPending&&(0,z.jsx)(`div`,{className:`text-[10px] text-blue-400 mt-1`,children:`Enriching…`}),c&&(0,z.jsxs)(`div`,{className:c.success?`text-[10px] text-green-400 mt-1`:`text-[10px] text-red-400 mt-1`,children:[`L`,c.level,` `,c.success?`complete`:`failed: ${c.error??`unknown error`}`,` · `,c.model]}),r&&(0,z.jsxs)(`div`,{className:`mt-2 rounded border border-amber-700/60 bg-amber-950/30 p-2 text-[10px] text-amber-200`,children:[`Estimated cost $`,r.estimatedCost.toFixed(4),` exceeds threshold $`,r.threshold.toFixed(2),` for `,r.sessionCount,` session`,r.sessionCount===1?``:`s`,`.`,(0,z.jsx)(`button`,{onClick:()=>f.mutate({tier:r.tier,confirmed:!0,model:r.model}),disabled:f.isPending,className:`ml-2 rounded bg-amber-700 px-1.5 py-0.5 text-amber-50 disabled:opacity-50`,children:`Confirm`})]}),f.isError&&!r&&(0,z.jsx)(`div`,{className:`text-[10px] text-red-400 mt-1`,children:`Enrichment failed`}),(0,z.jsxs)(`div`,{className:`mt-3 flex items-center justify-between border-t border-gray-900 pt-2`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] text-gray-500`,children:`Semantic embedding`}),(0,z.jsx)(`div`,{className:`text-[10px] text-gray-600`,children:`Generate or refresh this session's vector index.`})]}),(0,z.jsx)(`button`,{onClick:()=>p.mutate(),disabled:p.isPending,className:`px-2 py-1 bg-gray-800 hover:bg-gray-700 text-gray-300 rounded text-xs transition-colors disabled:opacity-50`,children:`Embed`})]}),p.isPending&&(0,z.jsx)(`div`,{className:`text-[10px] text-blue-400 mt-1`,children:`Embedding…`}),p.isSuccess&&(0,z.jsx)(`div`,{className:`text-[10px] text-green-400 mt-1`,children:`Embedding complete`}),p.isError&&(0,z.jsx)(`div`,{className:`text-[10px] text-red-400 mt-1`,children:`Embedding failed`})]})})]})}function v9(e){try{return new Date(e).toISOString().replace(`T`,` `).slice(0,16)}catch{return e}}function oOt({isScanning:e,onScan:t,lastResult:n,progress:r}){let i=e||r?.active===!0;return(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[r?.active?(0,z.jsxs)(`span`,{className:`text-[10px] text-blue-300 font-mono`,children:[r.dirsProcessed,`/`,r.dirsTotal,` files · `,r.sessionsFound,` sessions · `,(r.elapsedMs/1e3).toFixed(1),`s`]}):n&&!i&&(0,z.jsxs)(`span`,{className:`text-[10px] text-gray-500`,children:[`+`,n.inserted,` ↑`,n.updated,` ·`,(n.durationMs/1e3).toFixed(1),`s`]}),(0,z.jsxs)(`button`,{onClick:t,disabled:i,className:`flex items-center gap-1.5 px-3 py-1.5 bg-blue-700 hover:bg-blue-600 disabled:opacity-50 text-white rounded text-xs transition-colors`,children:[(0,z.jsx)(_r,{className:`h-3.5 w-3.5 ${i?`animate-spin`:``}`}),i?`Scanning…`:`Scan`]})]})}var sOt=[{label:`All time`,value:``},{label:`Today`,value:`today`},{label:`Last 7 days`,value:`7d`},{label:`Last 30 days`,value:`30d`},{label:`Last 90 days`,value:`90d`}],cOt=[{label:`All`,value:`all`},{label:`Discovered`,value:`discovered`},{label:`Managed-archived`,value:`managed-archived`}];function lOt({filters:e,facets:t,onChange:n}){return(0,z.jsxs)(`div`,{className:`w-48 shrink-0 border-r border-gray-800 bg-gray-950 p-3 overflow-auto`,children:[(0,z.jsx)(`div`,{className:`text-[10px] font-semibold text-gray-500 uppercase tracking-wider mb-3`,children:`Filters`}),(0,z.jsxs)(`div`,{className:`mb-4`,children:[(0,z.jsx)(`label`,{className:`text-xs text-gray-400 block mb-1`,children:`Source`}),(0,z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:cOt.map(t=>(0,z.jsx)(`button`,{onClick:()=>n(`source`,t.value===`all`?void 0:t.value),className:`rounded px-1.5 py-0.5 text-[10px] transition-colors ${(e.source??`all`)===t.value?`bg-blue-900 text-blue-100`:`bg-gray-900 text-gray-400 hover:text-gray-200`}`,children:t.label},t.value))})]}),(0,z.jsxs)(`div`,{className:`mb-4`,children:[(0,z.jsx)(`label`,{className:`text-xs text-gray-400 block mb-1`,children:`Time range`}),(0,z.jsx)(`select`,{value:e.since??``,onChange:e=>n(`since`,e.target.value||void 0),className:`w-full bg-gray-900 border border-gray-700 rounded px-2 py-1 text-xs text-gray-200 focus:outline-none focus:border-blue-500`,children:sOt.map(e=>(0,z.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,z.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:t.timeRanges.map(t=>(0,z.jsxs)(`button`,{onClick:()=>n(`since`,e.since===t.value?void 0:t.value),className:`rounded px-1.5 py-0.5 text-[10px] transition-colors ${e.since===t.value?`bg-blue-900 text-blue-100`:`bg-gray-900 text-gray-400 hover:text-gray-200`}`,children:[t.label??t.value,`: `,t.count]},t.value))})]}),(0,z.jsxs)(`div`,{className:`mb-4`,children:[(0,z.jsx)(`label`,{className:`text-xs text-gray-400 block mb-1`,children:`Workspace path`}),(0,z.jsx)(`input`,{type:`text`,list:`conversation-workspaces`,value:e.workspace??``,onChange:e=>n(`workspace`,e.target.value||void 0),placeholder:`e.g. /Projects/myapp`,className:`w-full bg-gray-900 border border-gray-700 rounded px-2 py-1 text-xs text-gray-200 placeholder-gray-600 focus:outline-none focus:border-blue-500`}),(0,z.jsx)(`datalist`,{id:`conversation-workspaces`,children:t.workspaces.map(e=>(0,z.jsx)(`option`,{value:e.value},e.value))})]}),(0,z.jsxs)(`div`,{className:`mb-4`,children:[(0,z.jsx)(`label`,{className:`text-xs text-gray-400 block mb-1`,children:`Model`}),(0,z.jsxs)(`select`,{value:e.model??``,onChange:e=>n(`model`,e.target.value||void 0),className:`w-full bg-gray-900 border border-gray-700 rounded px-2 py-1 text-xs text-gray-200 focus:outline-none focus:border-blue-500`,children:[(0,z.jsx)(`option`,{value:``,children:`All models`}),t.models.map(e=>(0,z.jsxs)(`option`,{value:e.value,children:[e.value,` (`,e.count,`)`]},e.value))]}),(0,z.jsx)(`div`,{className:`mt-2 space-y-1 max-h-24 overflow-auto`,children:t.models.slice(0,8).map(t=>(0,z.jsxs)(`button`,{onClick:()=>n(`model`,e.model===t.value?void 0:t.value),className:`w-full truncate rounded px-1.5 py-0.5 text-left text-[10px] transition-colors ${e.model===t.value?`bg-blue-900 text-blue-100`:`bg-gray-900 text-gray-400 hover:text-gray-200`}`,title:t.value,children:[t.count,` · `,t.value]},t.value))})]}),(0,z.jsxs)(`div`,{className:`mb-4`,children:[(0,z.jsx)(`label`,{className:`text-xs text-gray-400 block mb-1`,children:`Tag`}),(0,z.jsx)(`input`,{type:`text`,list:`conversation-tags`,value:e.tag??``,onChange:e=>n(`tag`,e.target.value||void 0),placeholder:`e.g. bugfix`,className:`w-full bg-gray-900 border border-gray-700 rounded px-2 py-1 text-xs text-gray-200 placeholder-gray-600 focus:outline-none focus:border-blue-500`}),(0,z.jsx)(`datalist`,{id:`conversation-tags`,children:t.tags.map(e=>(0,z.jsx)(`option`,{value:e.value},e.value))}),(0,z.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1 max-h-20 overflow-auto`,children:t.tags.slice(0,12).map(t=>(0,z.jsxs)(`button`,{onClick:()=>n(`tag`,e.tag===t.value?void 0:t.value),className:`rounded px-1.5 py-0.5 text-[10px] transition-colors ${e.tag===t.value?`bg-blue-900 text-blue-100`:`bg-gray-900 text-gray-400 hover:text-gray-200`}`,title:t.value,children:[t.value,`: `,t.count]},t.value))})]}),(0,z.jsxs)(`div`,{className:`mb-4`,children:[(0,z.jsx)(`label`,{className:`text-xs text-gray-400 block mb-1`,children:`Tool`}),(0,z.jsx)(`input`,{type:`text`,list:`conversation-tools`,value:e.tool??``,onChange:e=>n(`tool`,e.target.value||void 0),placeholder:`e.g. Read`,className:`w-full bg-gray-900 border border-gray-700 rounded px-2 py-1 text-xs text-gray-200 placeholder-gray-600 focus:outline-none focus:border-blue-500`}),(0,z.jsx)(`datalist`,{id:`conversation-tools`,children:t.tools.map(e=>(0,z.jsx)(`option`,{value:e.value},e.value))}),(0,z.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1 max-h-20 overflow-auto`,children:t.tools.slice(0,12).map(t=>(0,z.jsxs)(`button`,{onClick:()=>n(`tool`,e.tool===t.value?void 0:t.value),className:`rounded px-1.5 py-0.5 text-[10px] transition-colors ${e.tool===t.value?`bg-blue-900 text-blue-100`:`bg-gray-900 text-gray-400 hover:text-gray-200`}`,title:t.value,children:[t.value,`: `,t.count]},t.value))})]}),(0,z.jsxs)(`div`,{className:`mb-4`,children:[(0,z.jsx)(`label`,{className:`text-xs text-gray-400 block mb-1`,children:`File touched`}),(0,z.jsx)(`input`,{type:`text`,list:`conversation-files`,value:e.file??``,onChange:e=>n(`file`,e.target.value||void 0),placeholder:`e.g. src/index.ts`,className:`w-full bg-gray-900 border border-gray-700 rounded px-2 py-1 text-xs text-gray-200 placeholder-gray-600 focus:outline-none focus:border-blue-500`}),(0,z.jsx)(`datalist`,{id:`conversation-files`,children:t.files.map(e=>(0,z.jsx)(`option`,{value:e.value},e.value))}),(0,z.jsx)(`div`,{className:`mt-2 space-y-1 max-h-24 overflow-auto`,children:t.files.slice(0,8).map(t=>(0,z.jsxs)(`button`,{onClick:()=>n(`file`,e.file===t.value?void 0:t.value),className:`w-full truncate rounded px-1.5 py-0.5 text-left text-[10px] transition-colors ${e.file===t.value?`bg-blue-900 text-blue-100`:`bg-gray-900 text-gray-400 hover:text-gray-200`}`,title:t.value,children:[t.count,` · `,t.value]},t.value))})]}),(0,z.jsxs)(`div`,{className:`mb-4`,children:[(0,z.jsx)(`div`,{className:`text-xs text-gray-400 block mb-1`,children:`Workspace cost`}),(0,z.jsx)(`div`,{className:`space-y-1 max-h-24 overflow-auto`,children:t.workspaces.slice(0,8).map(e=>(0,z.jsxs)(`button`,{onClick:()=>n(`workspace`,e.value),className:`w-full text-left text-[10px] text-gray-500 hover:text-gray-300 truncate`,title:e.value,children:[e.count,` · $`,(e.cost??0).toFixed(4),` · `,e.value]},e.value))})]}),(0,z.jsxs)(`div`,{className:`mb-4`,children:[(0,z.jsx)(`div`,{className:`text-xs text-gray-400 block mb-1`,children:`Cost ranges`}),(0,z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.costRanges.map(t=>(0,z.jsxs)(`button`,{onClick:()=>{let r=e.minCost===t.minCost&&e.maxCost===t.maxCost;n(`minCost`,r?void 0:t.minCost),n(`maxCost`,r?void 0:t.maxCost)},className:`rounded px-1.5 py-0.5 text-[10px] transition-colors ${e.minCost===t.minCost&&e.maxCost===t.maxCost?`bg-blue-900 text-blue-100`:`bg-gray-900 text-gray-400 hover:text-gray-200`}`,title:`Estimated total $${(t.cost??0).toFixed(4)}`,children:[t.label??t.value,`: `,t.count]},t.value))})]}),(0,z.jsxs)(`div`,{className:`mb-4`,children:[(0,z.jsx)(`div`,{className:`text-xs text-gray-400 block mb-1`,children:`Enrichment levels`}),(0,z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.enrichmentLevels.map(t=>(0,z.jsxs)(`button`,{onClick:()=>n(`enrichmentLevel`,e.enrichmentLevel===t.value?void 0:t.value),className:`rounded px-1.5 py-0.5 text-[10px] transition-colors ${e.enrichmentLevel===t.value?`bg-blue-900 text-blue-100`:`bg-gray-900 text-gray-400 hover:text-gray-200`}`,children:[`L`,t.value,`: `,t.count]},t.value))})]}),(0,z.jsxs)(`div`,{className:`mb-4 grid grid-cols-2 gap-2`,children:[(0,z.jsxs)(`label`,{className:`text-xs text-gray-400 block`,children:[`Min cost`,(0,z.jsx)(`input`,{type:`number`,step:`0.001`,value:e.minCost??``,onChange:e=>n(`minCost`,e.target.value||void 0),className:`mt-1 w-full bg-gray-900 border border-gray-700 rounded px-2 py-1 text-xs text-gray-200 focus:outline-none focus:border-blue-500`})]}),(0,z.jsxs)(`label`,{className:`text-xs text-gray-400 block`,children:[`Max cost`,(0,z.jsx)(`input`,{type:`number`,step:`0.001`,value:e.maxCost??``,onChange:e=>n(`maxCost`,e.target.value||void 0),className:`mt-1 w-full bg-gray-900 border border-gray-700 rounded px-2 py-1 text-xs text-gray-200 focus:outline-none focus:border-blue-500`})]})]}),(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:e.managed===!0,onChange:e=>n(`managed`,e.target.checked?!0:void 0),className:`rounded border-gray-600 bg-gray-800 text-blue-500 focus:ring-0`}),(0,z.jsx)(`span`,{className:`text-xs text-gray-400`,children:`Overdeck-managed`})]}),(0,z.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:e.enriched===!0,onChange:e=>n(`enriched`,e.target.checked?!0:void 0),className:`rounded border-gray-600 bg-gray-800 text-blue-500 focus:ring-0`}),(0,z.jsx)(`span`,{className:`text-xs text-gray-400`,children:`Enriched only`})]})]}),Object.values(e).some(Boolean)&&(0,z.jsx)(`button`,{onClick:()=>{n(`since`,void 0),n(`workspace`,void 0),n(`managed`,void 0),n(`enriched`,void 0),n(`model`,void 0),n(`tag`,void 0),n(`tool`,void 0),n(`file`,void 0),n(`minCost`,void 0),n(`maxCost`,void 0),n(`enrichmentLevel`,void 0)},className:`mt-4 text-[10px] text-gray-600 hover:text-gray-400 transition-colors`,children:`Clear filters`})]})}function y9(e,t){let n=new Map;return e.forEach((e,r)=>{if(!e)return;let i=n.get(e)??{value:e,count:0,cost:0};i.count+=1,i.cost=(i.cost??0)+(t?.[r]??0),n.set(e,i)}),[...n.values()].sort((e,t)=>t.count-e.count||e.value.localeCompare(t.value))}function uOt(e){let t=Date.now();return[{value:`today`,label:`Today`,days:1},{value:`7d`,label:`Last 7 days`,days:7},{value:`30d`,label:`Last 30 days`,days:30},{value:`90d`,label:`Last 90 days`,days:90}].map(n=>{let r=t-n.days*864e5,i=e.filter(e=>{let t=e.lastTs?Date.parse(e.lastTs):NaN;return Number.isFinite(t)&&t>=r}).length;return{value:n.value,label:n.label,count:i}})}function dOt(e){return`${e.source}-${e.id}`}function fOt(e,t){let n=e.lastTs?Date.parse(e.lastTs):0;return(t.lastTs?Date.parse(t.lastTs):0)-n}function pOt(e){return[{value:`free`,label:`$0`,minCost:void 0,maxCost:`0`},{value:`low`,label:`$0–$0.01`,minCost:`0`,maxCost:`0.01`},{value:`medium`,label:`$0.01–$0.05`,minCost:`0.01`,maxCost:`0.05`},{value:`high`,label:`$0.05+`,minCost:`0.05`,maxCost:void 0}].map(t=>{let n=t.minCost===void 0?void 0:Number(t.minCost),r=t.maxCost===void 0?void 0:Number(t.maxCost),i=e.filter(e=>{let t=e.estimatedCost;return(n===void 0||t>=n)&&(r===void 0||t<=r)});return{value:t.value,label:t.label,count:i.length,cost:i.reduce((e,t)=>e+t.estimatedCost,0),minCost:t.minCost,maxCost:t.maxCost}})}function mOt(e){let t=new URLSearchParams;return e.workspace&&t.set(`workspacePath`,e.workspace),e.since&&t.set(`since`,e.since),e.managed&&t.set(`managed`,`true`),e.enriched&&t.set(`enriched`,`true`),e.model&&t.set(`primaryModel`,e.model),e.tag&&t.set(`tag`,e.tag),e.tool&&t.set(`tool`,e.tool),e.file&&t.set(`file`,e.file),e.minCost&&t.set(`minCost`,e.minCost),e.maxCost&&t.set(`maxCost`,e.maxCost),e.enrichmentLevel&&t.set(`enrichmentLevel`,e.enrichmentLevel),t}function b9(e){let t={},n=e.get(`workspacePath`),r=e.get(`primaryModel`),i=e.get(`since`),a=e.get(`managed`),o=e.get(`enriched`),s=e.get(`tag`),c=e.get(`tool`),l=e.get(`file`),u=e.get(`minCost`),d=e.get(`maxCost`),f=e.get(`enrichmentLevel`);return n&&(t.workspacePath=n),r&&(t.primaryModel=r),i&&(t.since=i),a&&(t.managed=a===`true`),o&&(t.enriched=o===`true`),s&&(t.tags=[s]),c&&(t.tools=[c]),l&&(t.files=[l]),u&&Number.isFinite(Number(u))&&(t.minCost=Number(u)),d&&Number.isFinite(Number(d))&&(t.maxCost=Number(d)),f&&Number.isFinite(Number(f))&&(t.enrichmentLevel=Number(f)),t}function hOt(e){return{id:e.id,source:`discovered`,jsonlPath:e.jsonlPath,workspacePath:e.workspacePath??null,primaryModel:e.primaryModel??null,messageCount:e.messageCount,firstTs:e.firstTs??null,lastTs:e.lastTs??null,estimatedCost:e.estimatedCost,tokenInput:e.tokenInput,tokenOutput:e.tokenOutput,toolsUsed:[...e.toolsUsed],filesTouched:[...e.filesTouched],tags:[...e.tags],summary:e.summary??null,enrichmentLevel:e.enrichmentLevel,enrichmentFailed:e.enrichmentFailed,overdeckManaged:e.overdeckManaged,panIssueId:e.panIssueId??null}}async function gOt(e){let t=await hj().request(t=>t[Pp.listDiscoveredSessions]({...b9(e),limit:Number(e.get(`limit`)??50),offset:Number(e.get(`offset`)??0)}));return{...t,sessions:t.sessions.map(hOt)}}async function _Ot(e){let t=e.toString(),n=await fetch(`/api/conversations/archived${t?`?${t}`:``}`);if(!n.ok)throw Error(`Failed to load archived conversations: ${n.status}`);return await n.json()}async function vOt(e,t,n=50,r=0,i=!1){let a=await hj().request(a=>a[Pp.searchConversations]({...b9(t),query:e,semantic:i,limit:n,offset:r}));return{...a,sessions:a.sessions.map(hOt)}}async function yOt(){let e=await hj().request(e=>e[Pp.getConversationStats]({}));return{...e,embeddingModels:e.embeddingModels?.map(e=>({...e}))}}async function bOt(e){return hj().request(t=>t[Pp.getConversationCost](b9(e)))}async function xOt(e){return hj().request(t=>t[Pp.getConversationCostByWorkspace](b9(e)))}async function SOt(){return hj().request(e=>e[Pp.scanConversations]({mode:`system`}))}function COt(){let e=_t(),t=sm(Phe),[n,r]=(0,R.useState)(``),[i,a]=(0,R.useState)(null),[o,s]=(0,R.useState)(!1),[c,l]=(0,R.useState)(0),[u,d]=(0,R.useState)(!1),[f,p]=(0,R.useState)({}),m=f.source??`all`,h=n.trim(),[g,_]=(0,R.useState)(h),v=m!==`managed-archived`,y=v?u?g:h:``,b=mOt(f);(0,R.useEffect)(()=>{if(!u){_(h);return}let e=window.setTimeout(()=>_(h),350);return()=>window.clearTimeout(e)},[u,h]);let x=new URLSearchParams({limit:`50`}),S=new URLSearchParams({limit:`50`});for(let[e,t]of b)x.set(e,t),S.set(e,t);let{data:C,isLoading:w}=B({queryKey:[`discovered-sessions`,x.toString()],queryFn:()=>gOt(x),enabled:!y&&m!==`managed-archived`}),{data:T=[],isLoading:E}=B({queryKey:[`archived-conversations`,S.toString()],queryFn:()=>_Ot(S),enabled:!y&&m!==`discovered`}),{data:D,isLoading:O}=B({queryKey:[`discovered-sessions-search`,y,b.toString(),c,u],queryFn:()=>vOt(y,b,50,c,u),enabled:!!y}),{data:k}=B({queryKey:[`discovered-sessions-stats`],queryFn:yOt,staleTime:3e4}),{data:A}=B({queryKey:[`discovered-sessions-cost`,b.toString()],queryFn:()=>bOt(b),staleTime:3e4}),{data:j}=B({queryKey:[`discovered-sessions-cost-workspace`,b.toString()],queryFn:()=>xOt(b),staleTime:3e4}),M=Nt({mutationFn:SOt,onSuccess:()=>{e.invalidateQueries({queryKey:[`discovered-sessions`]}),e.invalidateQueries({queryKey:[`discovered-sessions-stats`]})}}),N=y?O:m===`all`?w||E:m===`managed-archived`?E:w,P=C?.sessions??[],F=y?D?.sessions??[]:m===`managed-archived`?T:m===`discovered`?P:[...P,...T].sort(fOt),I=i==null?null:F.find(e=>dOt(e)===i)??null,ee=j?.entries??[],te={models:y9(F.map(e=>e.primaryModel)),workspaces:ee.length>0?ee.map(e=>({value:e.key,count:e.sessionCount,cost:e.totalCost})):y9(F.map(e=>e.workspacePath),F.map(e=>e.estimatedCost)),tags:y9(F.flatMap(e=>e.tags)),tools:y9(F.flatMap(e=>e.toolsUsed)),files:y9(F.flatMap(e=>e.filesTouched)),timeRanges:uOt(F),costRanges:pOt(F),enrichmentLevels:y9(F.map(e=>String(e.enrichmentLevel)))},ne=[m===`all`?null:{key:`source`,label:`Source: ${m===`discovered`?`Discovered`:`Managed-archived`}`},f.workspace?{key:`workspace`,label:`Workspace: ${f.workspace}`}:null,f.model?{key:`model`,label:`Model: ${f.model}`}:null,f.tag?{key:`tag`,label:`Tag: ${f.tag}`}:null,f.tool?{key:`tool`,label:`Tool: ${f.tool}`}:null,f.file?{key:`file`,label:`File: ${f.file}`}:null,f.since?{key:`since`,label:`Since: ${f.since}`}:null,f.managed?{key:`managed`,label:`Managed`}:null,f.enriched?{key:`enriched`,label:`Enriched`}:null,f.minCost?{key:`minCost`,label:`Min cost: $${f.minCost}`}:null,f.maxCost?{key:`maxCost`,label:`Max cost: $${f.maxCost}`}:null,f.enrichmentLevel?{key:`enrichmentLevel`,label:`Enrichment: L${f.enrichmentLevel}`}:null].filter(e=>e!==null),L=(0,R.useCallback)(e=>{r(e),l(0)},[]),re=(0,R.useCallback)((e,t)=>{p(n=>({...n,[e]:t})),l(0)},[]);return(0,z.jsxs)(`div`,{className:`flex flex-col h-full bg-gray-950 text-gray-100`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3 border-b border-gray-800 shrink-0`,children:[(0,z.jsx)(`h1`,{className:`text-lg font-semibold text-white`,children:`Session History`}),k&&(0,z.jsxs)(`div`,{className:`flex items-center gap-4 text-xs text-gray-400 ml-2`,children:[(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`span`,{className:`text-white font-mono`,children:k.total}),` indexed`]}),(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`span`,{className:`text-green-400 font-mono`,children:k.enriched}),` enriched`]}),(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`span`,{className:`text-blue-400 font-mono`,children:k.managedCount}),` managed`]}),(0,z.jsxs)(`span`,{children:[(0,z.jsxs)(`span`,{className:`text-amber-300 font-mono`,children:[`$`,(A?.totalCost??0).toFixed(4)]}),` est. cost`]}),ee.length>0&&(0,z.jsxs)(`span`,{"data-testid":`workspace-cost-breakdown`,className:`text-gray-500`,children:[`Workspace costs:`,` `,ee.slice(0,3).map(e=>(0,z.jsxs)(`span`,{className:`mr-2`,children:[(0,z.jsx)(`span`,{className:`text-gray-300`,children:e.key}),` `,(0,z.jsxs)(`span`,{className:`text-amber-300 font-mono`,children:[`$`,e.totalCost.toFixed(4)]})]},e.key))]})]}),(0,z.jsx)(`div`,{className:`flex-1`}),v&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`relative w-72`,children:[(0,z.jsx)(wr,{className:`absolute left-2.5 top-2 h-3.5 w-3.5 text-gray-500`}),(0,z.jsx)(`input`,{type:`text`,placeholder:`Search sessions…`,value:n,onChange:e=>L(e.target.value),className:`w-full bg-gray-900 border border-gray-700 rounded pl-8 pr-3 py-1.5 text-sm text-gray-100 placeholder-gray-500 focus:outline-none focus:border-blue-500`})]}),(0,z.jsx)(`button`,{onClick:()=>{d(e=>!e),l(0)},className:`px-3 py-1.5 rounded text-xs border transition-colors ${u?`bg-purple-900 border-purple-600 text-purple-200`:`bg-gray-900 border-gray-700 text-gray-400 hover:border-gray-500`}`,children:u?`Semantic`:`Keyword`})]}),(0,z.jsxs)(`button`,{onClick:()=>s(e=>!e),className:`flex items-center gap-1.5 px-3 py-1.5 rounded text-xs border transition-colors ${o?`bg-blue-900 border-blue-600 text-blue-200`:`bg-gray-900 border-gray-700 text-gray-400 hover:border-gray-500`}`,children:[(0,z.jsx)(Nn,{className:`h-3.5 w-3.5`}),`Filters`]}),(0,z.jsx)(oOt,{isScanning:M.isPending,onScan:()=>M.mutate(),lastResult:M.data,progress:t})]}),ne.length>0&&(0,z.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-2 border-b border-gray-800 bg-gray-950 shrink-0 text-xs`,children:[(0,z.jsx)(`span`,{className:`text-gray-500`,children:`Active filters`}),ne.map(e=>(0,z.jsxs)(`button`,{onClick:()=>{re(e.key,void 0),e.key===`minCost`&&re(`maxCost`,void 0),e.key===`maxCost`&&re(`minCost`,void 0)},className:`px-2 py-1 rounded-full bg-blue-950 text-blue-200 border border-blue-800 hover:bg-blue-900 transition-colors`,children:[e.label,` `,(0,z.jsx)(`span`,{className:`text-blue-400`,children:`×`})]},e.key)),(0,z.jsx)(`button`,{onClick:()=>p({}),className:`text-gray-500 hover:text-gray-300 transition-colors`,children:`Clear all`})]}),(0,z.jsxs)(`div`,{className:`flex flex-1 min-h-0 overflow-hidden`,children:[o&&(0,z.jsx)(lOt,{filters:f,facets:te,onChange:re}),(0,z.jsxs)(`div`,{className:`flex flex-col flex-1 min-w-0 overflow-hidden ${I?`border-r border-gray-800`:``}`,children:[v&&D?.error&&(0,z.jsxs)(`div`,{className:`px-4 py-2 border-b border-amber-900 bg-amber-950/40 text-amber-200 text-xs`,children:[`Semantic search unavailable: `,D.error]}),N?(0,z.jsx)(`div`,{className:`flex items-center justify-center h-32 text-gray-500 text-sm`,children:`Loading sessions…`}):F.length===0?(0,z.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-32 text-gray-500 gap-2`,children:[(0,z.jsx)(`span`,{className:`text-sm`,children:`No sessions found`}),!k?.total&&(0,z.jsx)(`span`,{className:`text-xs`,children:`Run a scan to discover Claude Code sessions`})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(ZDt,{sessions:F,selectedId:i,onSelect:a}),y&&D&&D.total>50&&(0,z.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 border-t border-gray-800 shrink-0 text-xs text-gray-400`,children:[(0,z.jsxs)(`span`,{children:[c+1,`–`,c+F.length,` of `,D.total,` results`]}),(0,z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,z.jsx)(`button`,{disabled:c===0,onClick:()=>l(e=>Math.max(0,e-50)),className:`px-2 py-1 rounded bg-gray-800 hover:bg-gray-700 disabled:opacity-40 disabled:cursor-not-allowed transition-colors`,children:`Prev`}),(0,z.jsx)(`button`,{disabled:c+50>=D.total,onClick:()=>l(e=>e+50),className:`px-2 py-1 rounded bg-gray-800 hover:bg-gray-700 disabled:opacity-40 disabled:cursor-not-allowed transition-colors`,children:`Next`})]})]})]})]}),I&&(0,z.jsx)(`div`,{className:`w-96 shrink-0 overflow-auto`,children:(0,z.jsx)(aOt,{session:I,onClose:()=>a(null)})})]})]})}function wOt(e){return e===`warming`?(0,z.jsx)(ar,{className:`h-4 w-4 animate-spin text-primary`}):e===`ready`?(0,z.jsx)(sn,{className:`h-4 w-4 text-green-500`}):e===`failed`?(0,z.jsx)(an,{className:`h-4 w-4 text-destructive`}):(0,z.jsx)(dn,{className:`h-4 w-4 text-muted-foreground`})}function TOt({mode:e,warmupStatus:t,isListening:n,onStart:r,onBackToStaging:i,onReset:a,onToggleMic:o,voiceError:s}){return(0,z.jsxs)(`section`,{className:`rounded-xl border border-border bg-card p-4 shadow-sm`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:`AutoPreso`}),(0,z.jsx)(`h2`,{className:`mt-1 text-lg font-semibold`,children:`Voice whiteboard`})]}),(0,z.jsx)(`span`,{className:`rounded-full bg-muted px-2.5 py-1 text-xs font-medium capitalize text-muted-foreground`,children:e})]}),(0,z.jsxs)(`div`,{className:`mt-4 grid grid-cols-2 gap-2`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:o,className:`rounded-lg px-3 py-2 text-sm font-semibold transition-colors ${n?`bg-destructive text-destructive-foreground`:`bg-primary text-primary-foreground`}`,children:n?`Stop mic`:`Start mic`}),(0,z.jsx)(`button`,{type:`button`,onClick:e===`staging`?r:i,className:`rounded-lg border border-border bg-background px-3 py-2 text-sm font-semibold text-foreground hover:bg-accent`,children:e===`staging`?`Go live`:`Back to staging`})]}),(0,z.jsxs)(`div`,{className:`mt-4 rounded-lg bg-muted/40 p-3 text-sm`,children:[(0,z.jsxs)(`p`,{className:`flex items-center gap-2 font-medium text-foreground`,children:[wOt(t),`Warmup: `,(0,z.jsx)(`span`,{className:`capitalize`,children:t})]}),(0,z.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`The whiteboard agent uses the staged canvas as context before live transcription starts.`})]}),s&&(0,z.jsx)(`div`,{className:`mt-4 rounded-lg border border-destructive/30 bg-destructive/10 p-3 text-sm text-destructive`,children:s}),(0,z.jsx)(`button`,{type:`button`,onClick:a,className:`mt-3 w-full rounded-lg border border-border bg-background px-3 py-2 text-sm font-semibold text-muted-foreground hover:bg-accent hover:text-foreground`,children:`Reset session`})]})}function EOt({partialText:e,turns:t}){let n=(0,R.useRef)(null);return(0,R.useEffect)(()=>{n.current?.scrollIntoView({block:`end`})},[e,t]),(0,z.jsxs)(`section`,{className:`min-h-0 flex-1 rounded-xl border border-border bg-card p-4 shadow-sm`,children:[(0,z.jsx)(`h2`,{className:`text-sm font-semibold uppercase tracking-widest text-muted-foreground`,children:`Transcript`}),(0,z.jsxs)(`div`,{className:`mt-3 max-h-64 space-y-2 overflow-y-auto pr-1 text-sm`,children:[t.length===0&&!e&&(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:`Spoken turns will appear here while AutoPreso listens.`}),t.map((e,t)=>(0,z.jsxs)(`article`,{className:`rounded-lg bg-muted/40 p-2 text-foreground`,children:[(0,z.jsx)(`time`,{className:`mb-1 block text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:e.timestamp.toLocaleTimeString()}),(0,z.jsx)(`p`,{children:e.text})]},`${e.timestamp.toISOString()}-${t}`)),e&&(0,z.jsx)(`p`,{className:`rounded-lg border border-dashed border-border p-2 italic text-muted-foreground`,children:e}),(0,z.jsx)(`div`,{ref:n})]})]})}var DOt=25e4,OOt=6e3,kOt=200;function AOt(e){return`${window.location.protocol===`https:`?`wss:`:`ws:`}//${window.location.host}${e}`}function jOt(){let[e,t]=(0,R.useState)([]),[n,r]=(0,R.useState)(`staging`),[i,a]=(0,R.useState)(`idle`),[o,s]=(0,R.useState)(``),[c,l]=(0,R.useState)([]),[u,d]=(0,R.useState)(!1),[f,p]=(0,R.useState)(null),[m,h]=(0,R.useState)(null),g=(0,R.useRef)(null),_=(0,R.useRef)(null),v=(0,R.useRef)(null),y=(0,R.useRef)(0),b=(0,R.useRef)(!0),x=(0,R.useRef)(null),S=(0,R.useRef)(null),C=(0,R.useRef)(null),w=(0,R.useRef)(null),T=(0,R.useRef)(null),E=(0,R.useRef)(null),D=(0,R.useCallback)(()=>{g.current?.close();let e=new WebSocket(AOt(`/ws/autopreso`));g.current=e,e.onopen=()=>{y.current=0},e.onmessage=e=>{let n=JSON.parse(String(e.data));(n.type===`whiteboard:snapshot`||n.type===`whiteboard:update`)&&(n.elements&&t(n.elements),n.mode&&r(n.mode),n.warmupStatus&&a(n.warmupStatus))},e.onclose=()=>{if(!b.current||g.current!==e)return;let t=Math.min(1e3*2**y.current,1e4);y.current+=1,v.current=window.setTimeout(D,t)}},[]),O=(0,R.useCallback)(e=>{d(!1),e&&_.current?.close(),e&&(_.current=null),C.current?.disconnect(),w.current?.disconnect(),T.current?.disconnect(),S.current?.close(),x.current?.getTracks().forEach(e=>e.stop()),C.current=null,w.current=null,T.current=null,S.current=null,x.current=null,h(null)},[]),k=(0,R.useCallback)(async(e=!0)=>{let t=_.current;O(!1),e&&t?.readyState===WebSocket.OPEN&&(t.send(JSON.stringify({type:`stop`})),await new Promise(e=>{let t=window.setTimeout(e,OOt);E.current=()=>{window.clearTimeout(t),e()}}),E.current=null),O(!0)},[O]);return(0,R.useEffect)(()=>(b.current=!0,D(),()=>{b.current=!1,v.current&&window.clearTimeout(v.current),v.current=null;let e=g.current;g.current=null,e?.close(),k(!1)}),[D,k]),{elements:e,mode:n,warmupStatus:i,partialText:o,committedTurns:c,isListening:u,voiceError:f,startListening:(0,R.useCallback)(async()=>{if(u)return;p(null);let e=null,t=null,n=null,r=null,i=null,a=null;try{e=await navigator.mediaDevices.getUserMedia({audio:!0});let o=window.AudioContext;t=new o({sampleRate:24e3}),n=t.createMediaStreamSource(e),r=t.createAnalyser(),i=t.createScriptProcessor(4096,1,1),a=new WebSocket(AOt(`/ws/voice`)),a.binaryType=`arraybuffer`,a.onmessage=e=>{let t=JSON.parse(String(e.data));t.type===`transcript:partial`&&s(t.text),t.type===`transcript:committed`&&(s(``),l(e=>[...e,{text:t.text,timestamp:new Date}].slice(-kOt))),t.type===`transcript:finalized`&&E.current?.(),t.type===`error`&&p(t.error)},a.onclose=()=>{_.current===a&&k(!1)},i.onaudioprocess=e=>{if(a?.readyState!==WebSocket.OPEN||a.bufferedAmount>DOt)return;let t=e.inputBuffer.getChannelData(0),n=new Int16Array(t.length);for(let e=0;e<t.length;e+=1){let r=Math.max(-1,Math.min(1,t[e]??0));n[e]=r<0?r*32768:r*32767}a.send(n.buffer)},n.connect(r),r.connect(i),i.connect(t.destination),x.current=e,S.current=t,w.current=n,T.current=r,C.current=i,_.current=a,h(r),d(!0)}catch(o){a?.close(),i?.disconnect(),n?.disconnect(),r?.disconnect(),t?.close(),e?.getTracks().forEach(e=>e.stop()),p(o instanceof Error?o.message:`Unable to start voice input`)}},[u,k]),stopListening:k,analyserNode:m}}var MOt=(0,R.lazy)(async()=>({default:(await L(()=>import(`./prod-BtqEDkif.js`),__vite__mapDeps([109,2,3,110,111,112,6,113,114,5]))).Excalidraw}));function NOt(){let{elements:e,mode:t,warmupStatus:n,partialText:r,committedTurns:i,isListening:a,voiceError:o,startListening:s,stopListening:c}=jOt(),[l,u]=(0,R.useState)([]),d=(0,R.useRef)(null),f=t===`live`?e:l,p=(0,R.useMemo)(()=>({elements:f}),[f]),m=(0,R.useCallback)(async()=>{await fetch(`/api/autopreso/start`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({elements:l,screenshotBase64:null})})},[l]),h=(0,R.useCallback)(async()=>{await fetch(`/api/autopreso/back-to-staging`,{method:`POST`})},[]),g=(0,R.useCallback)(async()=>{await fetch(`/api/autopreso/session/reset`,{method:`POST`}),u([]),d.current?.updateScene?.({elements:[]})},[]),_=(0,R.useCallback)(()=>{a?c():s()},[a,s,c]),v=(0,R.useCallback)(e=>{t===`staging`&&u(e)},[t]),y=(0,R.useCallback)(e=>{d.current=e},[]);return(0,R.useEffect)(()=>{t===`live`&&d.current?.updateScene?.({elements:e})},[t,e]),(0,z.jsxs)(`div`,{className:`flex h-full w-full gap-4 overflow-hidden bg-background p-4 text-foreground`,children:[(0,z.jsx)(`div`,{className:`min-w-0 flex-1 overflow-hidden rounded-xl border border-border bg-card shadow-sm`,children:(0,z.jsx)(R.Suspense,{fallback:(0,z.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`Loading whiteboard…`}),children:(0,z.jsx)(MOt,{excalidrawAPI:y,initialData:p,onChange:v,viewModeEnabled:t===`live`},t)})}),(0,z.jsxs)(`aside`,{className:`flex w-96 shrink-0 flex-col gap-4 overflow-y-auto`,children:[(0,z.jsx)(TOt,{mode:t,warmupStatus:n,isListening:a,onStart:m,onBackToStaging:h,onReset:g,onToggleMic:_,voiceError:o}),(0,z.jsx)(EOt,{turns:i,partialText:r})]})]})}var x9=`flywheel-orchestrator`,POt={harness:`claude-code`,model:`claude-opus-4-8`,effort:`high`,maxAgents:8,scope:`pan-only`};async function S9(e){let t=await fetch(e);if(!t.ok)throw Error(`Request failed (${t.status})`);return t.json()}async function FOt(){let e=await fetch(`/api/flywheel/conversation`);if(!e.ok)throw Error(`Request failed (${e.status})`);return e.json()}async function C9(e,t){let n=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:t===void 0?void 0:JSON.stringify(t)}),r=await n.json().catch(()=>({}));if(!n.ok){let e=typeof r?.error==`string`?r.error:`Request failed (${n.status})`;throw Error(e)}return r}function IOt(e){return typeof e==`number`&&Number.isFinite(e)?`${Math.round(e)}%`:`—`}function LOt(e){return e===`pan-only`?`PAN only`:e===`all-tracked-projects`?`All tracked projects`:e}function ROt(e){return{...POt,...e?.roles?.flywheel??{}}}function zOt({onOpenSettings:e}){let[t,n]=(0,R.useState)(`conversation`),[r,i]=(0,R.useState)(!1),a=typeof window<`u`&&window.location.pathname===`/popout/flywheel-conversation`,o=_t(),s=B({queryKey:[`flywheel-runs`],queryFn:()=>S9(`/api/flywheel/runs?limit=10`),refetchInterval:5e3}),c=s.data?.[0]??null,l=B({queryKey:[`flywheel-run-detail`,c?.id],queryFn:()=>S9(`/api/flywheel/runs/${encodeURIComponent(c.id)}`),enabled:!!c?.id,refetchInterval:c?.status===`running`?5e3:!1}),u=B({queryKey:[`conversation`,x9],queryFn:FOt,refetchInterval:5e3}),d=B({queryKey:[`settings`],queryFn:()=>S9(`/api/settings`),staleTime:3e4}),f=l.data??null,p=f?.status===`running`?f:null,m=f?.status===`running`||f?.status===`paused`?f.latest:null,h=u.data??null,g=ROt(d.data),_=f?.status===`running`?`running`:f?.status===`paused`?`paused`:`none`,v=Hr(),y=async()=>{await Promise.all([o.invalidateQueries({queryKey:[`flywheel-runs`]}),o.invalidateQueries({queryKey:[`flywheel-run-detail`]}),o.invalidateQueries({queryKey:[`conversation`,x9]})])},b=Nt({mutationFn:()=>C9(`/api/flywheel/start`),onSuccess:async()=>{H.success(`Flywheel started`),await y()},onError:e=>H.error(`Failed to start Flywheel: ${e.message}`)}),x=Nt({mutationFn:()=>C9(`/api/flywheel/pause`),onSuccess:async()=>{H.success(`Flywheel paused`),await y()},onError:e=>H.error(`Failed to pause Flywheel: ${e.message}`)}),S=Nt({mutationFn:()=>C9(`/api/flywheel/resume`),onSuccess:async()=>{H.success(`Flywheel resumed`),await y()},onError:e=>H.error(`Failed to resume Flywheel: ${e.message}`)}),C=Nt({mutationFn:async()=>(_===`paused`&&await C9(`/api/flywheel/report`),C9(`/api/flywheel/start`)),onSuccess:async()=>{H.success(`Flywheel started`),await y()},onError:e=>H.error(`Failed to start Flywheel: ${e.message}`)}),w=Nt({mutationFn:()=>C9(`/api/flywheel/report/open`,{runId:f?.id}),onError:e=>H.error(`Failed to open run report: ${e.message}`)}),T=Nt({mutationFn:()=>C9(`/api/flywheel/report`),onSuccess:async()=>{H.success(`Flywheel run reported`),await y()},onError:e=>H.error(`Failed to report Flywheel run: ${e.message}`)}),E=Nt({mutationFn:()=>C9(`/api/flywheel/abort`),onSuccess:async()=>{H.success(`Flywheel run aborted`),await y()},onError:e=>H.error(`Failed to abort Flywheel: ${e.message}`)}),D=async()=>{await v({title:`Abort Flywheel Run`,message:`${f?.id??`The active run`} will be discarded without a report. Continue?`,confirmLabel:`Abort Run`,variant:`destructive`})&&E.mutate()},O=async()=>{await v({title:`Finalize Run Report`,message:`Write the report for ${f?.id??`the active run`} and close it out. The orchestrator session must be paused or stopped first; if it is alive, this will fail.`,confirmLabel:`Write Report`,variant:`default`})&&T.mutate()},k=async()=>{if(_===`paused`){if(!await v({title:`Start New Run`,message:`${f?.id??`The current run`} is paused. Reporting it will close the run and start a fresh one. Continue?`,confirmLabel:`Report & Start New`,variant:`destructive`}))return}else if(_===`running`&&!await v({title:`Start New Run`,message:`${f?.id??`The current run`} is RUNNING. Starting a new run will abort the active orchestrator session and discard its in-flight work. Continue?`,confirmLabel:`Abort & Start New`,variant:`destructive`}))return;C.mutate()},A=b.isPending||x.isPending||S.isPending||C.isPending||w.isPending||E.isPending||T.isPending,j=s.isLoading||l.isLoading;return(0,z.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col border-l border-border bg-background`,"aria-label":`Flywheel conversation pane`,children:[(0,z.jsx)(`header`,{className:`border-b border-border bg-card/60 px-4 py-3`,children:(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm font-semibold text-foreground`,children:[(0,z.jsx)(`span`,{children:p?.id??(f?`${f.id} (${f.status})`:`No active run`)}),j&&(0,z.jsx)(ar,{className:`h-3.5 w-3.5 animate-spin text-muted-foreground`})]}),(0,z.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-2 text-xs text-muted-foreground`,children:[(0,z.jsxs)(`span`,{children:[`Model: `,m?.orchestrator.model??g.model]}),(0,z.jsxs)(`span`,{children:[`Effort: `,m?.orchestrator.effort??g.effort]}),(0,z.jsxs)(`span`,{children:[`Context: `,IOt(m?.orchestrator.ctxPercent)]})]})]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,z.jsxs)(`div`,{className:J.viewToggle,role:`tablist`,"aria-label":`Flywheel pane view`,children:[(0,z.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":t===`conversation`,className:`${J.viewToggleBtn} ${t===`conversation`?J.viewToggleBtnActive:``}`,onClick:()=>n(`conversation`),children:`Conversation`}),(0,z.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":t===`terminal`,className:`${J.viewToggleBtn} ${t===`terminal`?J.viewToggleBtnActive:``}`,onClick:()=>n(`terminal`),title:h?`Attach to flywheel-orchestrator tmux session`:`No flywheel-orchestrator session yet`,disabled:!h,children:`Terminal`})]}),(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded-md border border-amber-500/40 bg-amber-500/10 px-2.5 py-1.5 text-xs font-semibold text-amber-500 hover:bg-amber-500/20 disabled:opacity-50`,onClick:()=>x.mutate(),disabled:A||_!==`running`,title:_===`running`?`Pause the orchestrator`:`No active run to pause`,children:[(0,z.jsx)(Eee,{className:`h-3.5 w-3.5`}),`Pause`]}),(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded-md border border-border bg-background px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-accent disabled:opacity-50`,onClick:()=>S.mutate(),disabled:A||_!==`paused`,title:_===`paused`?`Resume the orchestrator`:`Run is not paused`,children:[(0,z.jsx)(yr,{className:`h-3.5 w-3.5`}),`Resume`]}),(0,z.jsxs)(`div`,{className:`relative`,children:[(0,z.jsxs)(`button`,{type:`button`,"aria-haspopup":`menu`,"aria-expanded":r,className:`inline-flex items-center gap-1 rounded-md border border-border bg-background px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-accent`,onClick:()=>i(e=>!e),children:[(0,z.jsx)(On,{className:`h-3.5 w-3.5`}),`More`]}),r&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`fixed inset-0 z-40`,"aria-hidden":`true`,onClick:()=>i(!1)}),(0,z.jsxs)(`div`,{role:`menu`,"aria-label":`More flywheel actions`,className:`absolute right-0 top-full z-50 mt-1 w-48 rounded-lg border border-border bg-card p-1 shadow-lg`,children:[(0,z.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-md px-2.5 py-1.5 text-left text-xs font-medium text-foreground hover:bg-accent disabled:opacity-50`,onClick:()=>{i(!1),k()},disabled:A,title:_===`running`?`Abort the active run and start a new one`:_===`paused`?`Report the paused run and start a new one`:`Start a new Flywheel run`,children:[(0,z.jsx)(gr,{className:`h-3.5 w-3.5`}),`New Run`]}),(0,z.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-md px-2.5 py-1.5 text-left text-xs font-medium text-foreground hover:bg-accent disabled:opacity-50`,onClick:()=>{i(!1),O()},disabled:A||_===`none`,title:_===`none`?`No active run to report`:`Finalize the run report and close out (orchestrator must be paused/stopped)`,children:[(0,z.jsx)(Mn,{className:`h-3.5 w-3.5`}),`Write Report`]}),(0,z.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-md px-2.5 py-1.5 text-left text-xs font-medium text-foreground hover:bg-accent disabled:opacity-50`,onClick:()=>{i(!1),w.mutate()},disabled:A||!f?.paths.report,title:f?.paths.report??`No run report yet`,children:[(0,z.jsx)(kn,{className:`h-3.5 w-3.5`}),`Open Run Report`]}),!a&&(0,z.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-md px-2.5 py-1.5 text-left text-xs font-medium text-foreground hover:bg-accent`,onClick:()=>{i(!1),window.open(`/popout/flywheel-conversation`,`flywheel-conversation-popout`,`width=1100,height=750,menubar=no,toolbar=no,location=no,status=no`)},title:`Open this view in a separate window`,children:[(0,z.jsx)(_ee,{className:`h-3.5 w-3.5`}),`Pop out`]}),(0,z.jsxs)(`a`,{href:`/settings#roles`,className:`flex w-full items-center gap-2 rounded-md px-2.5 py-1.5 text-left text-xs font-medium text-foreground hover:bg-accent`,onClick:t=>{i(!1),e&&(t.preventDefault(),e())},children:[(0,z.jsx)(Tr,{className:`h-3.5 w-3.5`}),`Configure`]})]})]})]}),(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded-md border border-destructive/50 bg-destructive/5 px-2.5 py-1.5 text-xs font-semibold text-destructive hover:bg-destructive/15 disabled:opacity-50`,onClick:D,disabled:A||_===`none`,title:_===`none`?`No active run to abort`:`Discard this run without writing a report`,children:[(0,z.jsx)(ln,{className:`h-3.5 w-3.5`}),`Abort`]})]})]})}),(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:u.isLoading?(0,z.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,z.jsx)(ar,{className:`h-4 w-4 animate-spin`}),`Loading flywheel conversation…`]}):h?t===`terminal`?(0,z.jsx)(IS,{sessionName:x9}):(0,z.jsx)(s5,{conversation:h,embedded:!0,onEmbeddedResume:h.sessionAlive?void 0:()=>b.mutate(),embeddedResumeLabel:b.isPending?`Starting…`:`Start New Run`,onSendFailed:()=>void o.invalidateQueries({queryKey:[`conversation`,x9]})}):(0,z.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center p-8 text-center`,children:[(0,z.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`No flywheel-orchestrator session yet.`}),(0,z.jsx)(`p`,{className:`mt-1 max-w-sm text-xs text-muted-foreground`,children:`Start a run to create the singleton conversation. Once it exists, this pane reuses the standard conversation transcript and composer, and the Terminal toggle attaches to the orchestrator's tmux session.`})]})}),(0,z.jsx)(`footer`,{className:`border-t border-border bg-card/60 p-4 space-y-3`,children:(0,z.jsxs)(`button`,{type:`button`,className:`w-full rounded-lg border border-border bg-background p-3 text-left hover:bg-accent/60`,onClick:e,children:[(0,z.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,z.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:`Run config`}),(0,z.jsx)(`span`,{className:`text-xs font-medium text-primary`,children:`Settings → Roles → Flywheel`})]}),(0,z.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-4 gap-y-2 text-xs`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:`Harness`}),(0,z.jsx)(`dd`,{className:`font-medium text-foreground`,children:m?.orchestrator.harness??g.harness})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:`Model`}),(0,z.jsx)(`dd`,{className:`font-medium text-foreground`,children:g.model})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:`Effort`}),(0,z.jsx)(`dd`,{className:`font-medium text-foreground`,children:g.effort})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:`Max agents`}),(0,z.jsx)(`dd`,{className:`font-medium text-foreground`,children:g.maxAgents})]}),(0,z.jsxs)(`div`,{className:`col-span-2`,children:[(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:`Scope`}),(0,z.jsx)(`dd`,{className:`font-medium text-foreground`,children:LOt(g.scope)})]})]})]})})]})}var BOt=1e4;async function VOt(){let e=await fetch(`/api/flywheel/state`);if(!e.ok)throw Error(`Request failed (${e.status})`);return e.json()}function HOt(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?e:`${t.toLocaleDateString()} ${t.toLocaleTimeString()}`}function UOt(){let[e,t]=(0,R.useState)(null),[n,r]=(0,R.useState)(null),[i,a]=(0,R.useState)(!0);if((0,R.useEffect)(()=>{let e=!1,n=async()=>{try{let n=await VOt();if(e)return;t(n),r(null)}catch(t){if(e)return;r(t instanceof Error?t.message:String(t))}finally{e||a(!1)}};n();let i=window.setInterval(()=>{n()},BOt);return()=>{e=!0,window.clearInterval(i)}},[]),i&&!e)return(0,z.jsx)(`div`,{className:`flex min-h-[200px] items-center justify-center text-sm text-muted-foreground`,children:`Loading Flywheel state…`});if(n)return(0,z.jsxs)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 p-4 text-sm text-destructive`,children:[`Failed to load Flywheel state: `,n]});if(!e||!e.exists||!e.content)return(0,z.jsx)(`div`,{className:`flex min-h-[360px] items-center justify-center rounded-xl border border-dashed border-border bg-card/40 p-8 text-center`,children:(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`text-base font-medium text-foreground`,children:`No Flywheel state yet.`}),(0,z.jsxs)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:[(0,z.jsx)(`code`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono text-xs`,children:`docs/FLYWHEEL-STATE.md`}),` is created by the orchestrator the first time it records something worth remembering across runs.`]})]})});let o=HOt(e.lastModified);return(0,z.jsxs)(`div`,{className:`space-y-3`,children:[(0,z.jsxs)(`header`,{className:`flex flex-wrap items-baseline justify-between gap-2 border-b border-border pb-2 text-xs text-muted-foreground`,children:[(0,z.jsx)(`span`,{className:`font-mono`,children:e.path}),o&&(0,z.jsxs)(`span`,{children:[`Last modified `,o]})]}),(0,z.jsx)(`article`,{className:`prose prose-sm max-w-none dark:prose-invert`,children:(0,z.jsx)(lO,{remarkPlugins:[tk],children:e.content})})]})}var WOt=6e4,GOt=[`c1_bugRate`,`c2_p0Bugs`,`c3_passRate`,`c4_mttr`,`c5_intervention`,`c6_timeConsistency`,`c7_flake`],KOt={c1_bugRate:`Substrate bugs filed in the selected window divided by completed pipeline runs in the same window.`,c2_p0Bugs:`Count of P0 substrate bugs filed during the selected window.`,c3_passRate:`Pipeline pass success rate after counting only review or test failures tied to substrate bugs discovered on the same issue within 24 hours.`,c4_mttr:`Median and p95 time from substrate bug filing to fix merge for bugs filed in the selected window.`,c5_intervention:`Operator intervention events divided by completed pipeline runs in the selected window.`,c6_timeConsistency:`For simple, medium, and complex bead-count buckets, compares p95 completed-run duration to the median duration.`,c7_flake:`Substrate-attributable review or test failures that pass one cycle and fail the next with the same head SHA.`},qOt={green:`bg-success text-success`,yellow:`bg-warning text-warning`,red:`bg-destructive text-destructive`,insufficient_data:`bg-muted-foreground text-muted-foreground`,collecting:`bg-muted-foreground text-muted-foreground`},JOt={green:`Green`,yellow:`Yellow`,red:`Red`,insufficient_data:`Insufficient data`,collecting:`Collecting data`},YOt={up:`↗ Up`,down:`↘ Down`,flat:`→ Flat`};async function XOt(){let e=await fetch(`/api/flywheel/stats`);if(!e.ok)throw Error(`Request failed (${e.status})`);return e.json()}function ZOt(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toISOString().slice(0,10)}function QOt(e){let t=Math.abs(e);return t>=1440*60*1e3?`${(e/(1440*60*1e3)).toFixed(1)}d`:t>=3600*1e3?`${(e/(3600*1e3)).toFixed(1)}h`:t>=60*1e3?`${(e/(60*1e3)).toFixed(1)}m`:`${Math.round(e)}ms`}function $Ot(e){return Number.isFinite(e)?e>0&&Math.abs(e)<1?`${(e*100).toFixed(1)}%`:Number.isInteger(e)?String(e):e.toFixed(2):`—`}function ekt(e){return Object.entries(e).map(([e,t])=>typeof t==`number`&&e.toLowerCase().endsWith(`ms`)?`${e}: ${QOt(t)}`:typeof t==`number`?`${e}: ${$Ot(t)}`:typeof t==`string`||typeof t==`boolean`||t===null?`${e}: ${String(t)}`:`${e}: ${JSON.stringify(t)}`).join(` · `)}function tkt(e){return typeof e==`number`?$Ot(e):ekt(e)}function nkt(e){return e.dataSufficient?e.status:`collecting`}function rkt({criterion:e,criterionKey:t,generatedAt:n}){let r=nkt(e),i=e.dataSufficient?tkt(e.value):`collecting since ${ZOt(n)}`;return(0,z.jsxs)(`section`,{role:`region`,"aria-label":`${e.label} metric`,className:`rounded-lg border border-border bg-card/60 p-4`,title:KOt[t],children:[(0,z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,z.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:e.label}),(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 text-xs font-medium`,"aria-label":`Status: ${JOt[r]}`,children:[(0,z.jsx)(`span`,{className:vj(`h-2.5 w-2.5 rounded-full`,qOt[r].split(` `)[0]),"aria-hidden":`true`}),(0,z.jsx)(`span`,{className:qOt[r].split(` `)[1],children:JOt[r]})]})]}),(0,z.jsx)(`div`,{className:`mt-4 text-2xl font-semibold text-foreground`,children:i}),(0,z.jsxs)(`div`,{className:`mt-2 text-sm text-muted-foreground`,children:[`Target: `,tkt(e.target)]}),(0,z.jsxs)(`footer`,{className:`mt-4 flex flex-wrap items-center justify-between gap-2 border-t border-border/70 pt-3 text-xs text-muted-foreground`,children:[(0,z.jsxs)(`span`,{children:[`Sample size: `,e.sampleSize]}),e.trend&&(0,z.jsx)(`span`,{"aria-label":`Trend: ${YOt[e.trend]}`,children:YOt[e.trend]})]})]})}function ikt(){let[e,t]=(0,R.useState)(null),[n,r]=(0,R.useState)(null),[i,a]=(0,R.useState)(!0);return(0,R.useEffect)(()=>{let e=!1,n=async()=>{try{let n=await XOt();if(e)return;t(n),r(null)}catch(t){if(e)return;r(t instanceof Error?t.message:String(t))}finally{e||a(!1)}};n();let i=window.setInterval(()=>{n()},WOt);return()=>{e=!0,window.clearInterval(i)}},[]),i&&!e?(0,z.jsx)(`div`,{className:`flex min-h-[200px] items-center justify-center text-sm text-muted-foreground`,children:`Loading Flywheel stats…`}):e?(0,z.jsxs)(`div`,{className:`space-y-4`,"aria-label":`Flywheel stats`,children:[(0,z.jsxs)(`header`,{className:`flex flex-wrap items-baseline justify-between gap-2 border-b border-border pb-2 text-xs text-muted-foreground`,children:[(0,z.jsxs)(`span`,{children:[`Window: `,e.window]}),(0,z.jsxs)(`span`,{children:[`Generated: `,ZOt(e.generatedAt)]})]}),n&&(0,z.jsxs)(`div`,{className:`rounded-md border border-warning/40 bg-warning/10 p-3 text-sm text-warning`,role:`status`,children:[`Failed to refresh Flywheel stats: `,n,`. Showing last good data.`]}),(0,z.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:GOt.map(t=>(0,z.jsx)(rkt,{criterionKey:t,criterion:e.criteria[t],generatedAt:e.generatedAt},t))})]}):(0,z.jsxs)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 p-4 text-sm text-destructive`,children:[`Failed to load Flywheel stats: `,n??`unknown error`]})}var akt={planning:`bg-primary/15 text-primary border-primary/30`,working:`bg-info/15 text-info-foreground border-info/30`,reviewing:`bg-signal-review/15 text-signal-review-foreground border-signal-review/30`,testing:`bg-warning/15 text-warning-foreground border-warning/30`,shipping:`bg-success/15 text-success border-success/30`,merging:`bg-warning/15 text-warning-foreground border-warning/30`,blocked:`bg-destructive/15 text-destructive border-destructive/30`,parked:`bg-muted text-muted-foreground border-border`},okt={default:`text-foreground`,success:`text-success`,warning:`text-warning-foreground`,info:`text-info-foreground`};function skt({children:e}){return(0,z.jsx)(`div`,{className:`grid gap-3 md:grid-cols-4`,"aria-label":`Flywheel headline metrics`,children:e})}function w9({label:e,value:t,subtext:n,tone:r=`default`}){return(0,z.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/70 p-4`,children:[(0,z.jsx)(`div`,{className:`font-mono text-[10px] uppercase tracking-wider text-muted-foreground`,children:e}),(0,z.jsx)(`div`,{className:vj(`mt-1 text-3xl font-semibold tabular-nums tracking-tight`,okt[r]),children:t}),n&&(0,z.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:n})]})}function ckt({verb:e}){return(0,z.jsx)(`span`,{className:vj(`inline-flex rounded border px-2 py-0.5 font-mono text-[10px] font-semibold uppercase tracking-wide`,akt[e]),children:e})}function lkt({item:e}){return(0,z.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/60 p-4`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,z.jsx)(`span`,{className:`rounded border border-border bg-background px-2 py-0.5 font-mono text-xs text-primary`,children:e.issueId}),(0,z.jsx)(ckt,{verb:e.verb}),(0,z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-foreground`,children:e.title}),(0,z.jsx)(`span`,{className:`font-mono text-xs uppercase tracking-wide text-muted-foreground`,children:e.status})]}),typeof e.progressPercent==`number`&&Number.isFinite(e.progressPercent)&&(0,z.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,children:[(0,z.jsx)(`div`,{className:`h-1.5 flex-1 overflow-hidden rounded-full bg-muted`,children:(0,z.jsx)(`div`,{className:`h-full rounded-full bg-primary`,style:{width:`${Math.max(0,Math.min(100,e.progressPercent))}%`}})}),(0,z.jsxs)(`span`,{className:`w-10 text-right font-mono text-xs text-muted-foreground`,children:[Math.round(e.progressPercent),`%`]})]})]})}var ukt={fixed:`bg-success/15 text-success border-success/30`,filed:`bg-primary/15 text-primary border-primary/30`,workaround:`bg-warning/15 text-warning border-warning/30`},dkt={urgent:`bg-destructive/15 text-destructive border-destructive/30`,high:`bg-warning/15 text-warning border-warning/30`,medium:`bg-primary/15 text-primary border-primary/30`,low:`bg-muted text-muted-foreground border-border`},fkt={urgent:0,high:1,medium:2,low:3},pkt={starting:`starting`,running:`running`,waiting:`warning`,idle:`healthy`,stopped:`stopped`,error:`failed`},mkt=new Set([`plan`,`work`,`review`,`test`,`ship`,`flywheel`]);function T9(e){return Number.isFinite(e)?Math.abs(e)>=1024?`${(e/1024).toFixed(1)} GiB`:`${Math.round(e)} MiB`:`—`}function E9(e){return e.slice(0,7)}function hkt(e){if(!e)return null;try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`?t.toString():null}catch{return null}}function gkt(e){return e&&mkt.has(e)?e:void 0}function _kt(e,t){return{id:e.id,issueId:e.issueId??e.label,runtime:`claude-code`,model:e.model??`unknown`,status:pkt[e.status],startedAt:t,lastActivity:t,consecutiveFailures:+(e.status===`error`),killCount:0,role:gkt(e.role)}}function vkt({status:e}){return(0,z.jsx)(`span`,{className:vj(`inline-flex rounded-full border px-2 py-0.5 text-[11px] font-semibold uppercase tracking-wide`,ukt[e]),children:e})}function ykt({priority:e}){return(0,z.jsx)(`span`,{className:vj(`inline-flex rounded-full border px-2 py-0.5 text-[11px] font-semibold uppercase tracking-wide`,dkt[e]),children:e})}function bkt(e){return e.map((e,t)=>({suggestion:e,index:t})).sort((e,t)=>{let n=fkt[e.suggestion.priority]-fkt[t.suggestion.priority];return n===0?e.index-t.index:n}).map(({suggestion:e})=>e)}function D9({title:e,children:t}){return(0,z.jsxs)(`section`,{className:`rounded-lg border border-border bg-card/60 p-4`,children:[(0,z.jsx)(`h3`,{className:`mb-3 text-sm font-semibold text-foreground`,children:e}),t]})}function xkt({status:e,onNavigateAgent:t,onNavigateIssue:n}){let r=Math.max(e.system.ramTotalMb-e.system.ramUsedMb,0),i=Math.max(e.system.swapTotalMb-e.system.swapUsedMb,0),a=t??(()=>void 0),o=n??(()=>void 0),s=bkt(e.suggestions);return(0,z.jsxs)(`div`,{className:`space-y-4`,"aria-label":`Flywheel status details`,children:[(0,z.jsx)(D9,{title:`Suggestions`,children:s.length>0?(0,z.jsx)(`div`,{className:`space-y-3`,children:s.map((e,t)=>{let n=e.issueId;return(0,z.jsxs)(`div`,{"data-testid":`flywheel-suggestion`,className:`rounded-md border border-border bg-background p-3`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,z.jsx)(ykt,{priority:e.priority}),(0,z.jsx)(`span`,{className:`rounded-full bg-muted px-2 py-0.5 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground`,children:e.action}),n&&(0,z.jsx)(`button`,{type:`button`,className:`font-mono text-xs font-medium text-primary hover:underline`,onClick:()=>o(n),children:n})]}),(0,z.jsx)(`p`,{className:`mt-2 text-sm text-foreground`,children:e.rationale})]},`${e.priority}-${e.action}-${n??`system`}-${t}`)})}):(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No suggestions yet — orchestrator will emit on next tick.`})}),(0,z.jsxs)(skt,{children:[(0,z.jsx)(w9,{label:`Bugs Fixed`,value:e.headline.bugsFixed,tone:`success`}),(0,z.jsx)(w9,{label:`SWARM Items`,value:`${e.headline.swarmItemsMerged}/${e.headline.swarmItemsTotal}`,subtext:`merged`,tone:`info`}),(0,z.jsx)(w9,{label:`PRs Merged`,value:e.headline.prsMerged,tone:`success`}),(0,z.jsx)(w9,{label:`Awaiting UAT`,value:e.headline.awaitingUat,tone:e.headline.awaitingUat>0?`warning`:`default`})]}),(0,z.jsx)(D9,{title:`Active Pipeline`,children:e.activePipeline.length>0?(0,z.jsx)(`div`,{className:`space-y-3`,children:e.activePipeline.map(e=>(0,z.jsx)(lkt,{item:e},`${e.issueId}-${e.verb}`))}):(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No active pipeline items.`})}),(0,z.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-[minmax(0,1.25fr)_minmax(280px,0.75fr)]`,children:[(0,z.jsxs)(`div`,{className:`space-y-4`,children:[(0,z.jsx)(D9,{title:`Substrate Bugs Filed and Fixed`,children:e.substrateBugs.length>0?(0,z.jsx)(`div`,{className:`overflow-x-auto`,children:(0,z.jsxs)(`table`,{className:`w-full min-w-[520px] text-left text-sm`,children:[(0,z.jsx)(`thead`,{className:`text-xs uppercase tracking-wide text-muted-foreground`,children:(0,z.jsxs)(`tr`,{className:`border-b border-border`,children:[(0,z.jsx)(`th`,{className:`pb-2 pr-3 font-medium`,children:`Issue`}),(0,z.jsx)(`th`,{className:`pb-2 pr-3 font-medium`,children:`Title`}),(0,z.jsx)(`th`,{className:`pb-2 pr-3 font-medium`,children:`Status`}),(0,z.jsx)(`th`,{className:`pb-2 font-medium`,children:`Commit`})]})}),(0,z.jsx)(`tbody`,{children:e.substrateBugs.map(e=>{let t=hkt(e.url);return(0,z.jsxs)(`tr`,{className:`border-b border-border/60 last:border-0`,children:[(0,z.jsx)(`td`,{className:`py-2 pr-3 font-mono text-xs text-primary`,children:e.issueId}),(0,z.jsx)(`td`,{className:`py-2 pr-3 text-foreground`,children:e.title}),(0,z.jsx)(`td`,{className:`py-2 pr-3`,children:(0,z.jsx)(vkt,{status:e.status})}),(0,z.jsx)(`td`,{className:`py-2 font-mono text-xs`,children:e.commitSha?t?(0,z.jsx)(`a`,{className:`text-primary hover:underline`,href:t,target:`_blank`,rel:`noreferrer`,children:E9(e.commitSha)}):(0,z.jsx)(`span`,{className:`text-foreground`,children:E9(e.commitSha)}):(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})})]},`${e.issueId}-${e.title}`)})})]})}):(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No substrate bugs filed or fixed yet.`})}),(0,z.jsx)(D9,{title:`Currently Running Agents`,children:e.agents.length>0?(0,z.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:e.agents.map(t=>(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-xs`,children:[(0,z.jsx)(`span`,{className:`truncate font-medium text-foreground`,title:t.label,children:t.label}),typeof t.ctxPercent==`number`&&Number.isFinite(t.ctxPercent)&&(0,z.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[Math.round(t.ctxPercent),`% ctx`]})]}),(0,z.jsx)(Cwt,{agent:_kt(t,e.lastTickAt),onNavigate:a}),t.currentAction&&(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t.currentAction})]},t.id))}):(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No running Flywheel agents.`})})]}),(0,z.jsxs)(`div`,{className:`space-y-4`,children:[(0,z.jsx)(D9,{title:`System`,children:(0,z.jsxs)(`dl`,{className:`grid gap-3 text-sm`,children:[(0,z.jsxs)(`div`,{className:`rounded-md border border-border bg-background p-3`,children:[(0,z.jsx)(`dt`,{className:`text-xs uppercase tracking-wide text-muted-foreground`,children:`RAM`}),(0,z.jsxs)(`dd`,{className:`mt-1 font-medium text-foreground`,children:[T9(e.system.ramUsedMb),` used / `,T9(r),` available`]})]}),(0,z.jsxs)(`div`,{className:`rounded-md border border-border bg-background p-3`,children:[(0,z.jsx)(`dt`,{className:`text-xs uppercase tracking-wide text-muted-foreground`,children:`Swap`}),(0,z.jsxs)(`dd`,{className:`mt-1 font-medium text-foreground`,children:[T9(e.system.swapUsedMb),` used / `,T9(i),` available`]})]}),(0,z.jsxs)(`div`,{className:`rounded-md border border-border bg-background p-3`,children:[(0,z.jsx)(`dt`,{className:`text-xs uppercase tracking-wide text-muted-foreground`,children:`Agents`}),(0,z.jsxs)(`dd`,{className:`mt-1 font-medium text-foreground`,children:[e.system.agentsActive,` / `,e.system.agentsCap,` active`]})]}),(0,z.jsxs)(`div`,{className:`rounded-md border border-border bg-background p-3`,children:[(0,z.jsx)(`dt`,{className:`text-xs uppercase tracking-wide text-muted-foreground`,children:`Main HEAD`}),(0,z.jsx)(`dd`,{className:`mt-1 font-mono text-sm font-medium text-foreground`,children:E9(e.system.mainHead)})]})]})}),(0,z.jsx)(D9,{title:`Open Questions for the Next Tick`,children:e.openQuestions.length>0?(0,z.jsx)(`ul`,{className:`list-disc space-y-2 pl-5 text-sm text-foreground`,children:e.openQuestions.map(e=>(0,z.jsx)(`li`,{children:e},e))}):(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No open questions for the next tick.`})})]})]})]})}function Skt({icon:e,label:t,count:n,defaultCollapsed:r=!1,ariaLabel:i,children:a}){let[o,s]=(0,R.useState)(r);return(0,z.jsxs)(`section`,{className:`shrink-0 border-b border-border`,"aria-label":i??t,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:()=>s(e=>!e),"aria-expanded":!o,className:`flex w-full items-center justify-between gap-2 px-4 py-2.5 text-left hover:bg-accent/40`,children:[(0,z.jsxs)(`span`,{className:`flex items-center gap-2 text-[11px] font-semibold uppercase tracking-wide text-foreground`,children:[o?(0,z.jsx)(nn,{className:`h-3.5 w-3.5 text-muted-foreground`}):(0,z.jsx)(en,{className:`h-3.5 w-3.5 text-muted-foreground`}),e,t]}),n!=null&&(0,z.jsx)(`span`,{className:`text-[10px] font-semibold text-muted-foreground`,children:n})]}),!o&&(0,z.jsx)(`div`,{className:`px-3 pb-3`,children:a})]})}async function Ckt(e){let t=await fetch(e);if(!t.ok)throw Error(`${e} → ${t.status}`);return t.json()}async function O9(e,t){let n=await fetch(e,{method:`POST`,headers:await uj(),body:t===void 0?`{}`:JSON.stringify(t)}),r=await n.json().catch(()=>({}));if(!n.ok)throw Error(r.error??r.message??`${e} → ${n.status}`);return r}function wkt(e){return encodeURIComponent(e.replace(/^uat\//,``))}function k9(e){return e.replace(/^uat\//,``)}function Tkt({active:e,onNavigateIssue:t}){let n=_t(),r=Hr(),[i,a]=(0,R.useState)(!0),o=B({queryKey:[`flywheel-uat-generations`],queryFn:()=>Ckt(`/api/flywheel/uat-generations`),refetchInterval:e?15e3:!1}),s=B({queryKey:[`flywheel-merge-queue`],queryFn:()=>Ckt(`/api/flywheel/merge-queue`),refetchInterval:e?15e3:!1}),c=Array.isArray(o.data)?o.data:[],l=Array.isArray(s.data)?s.data:[],u=()=>{n.invalidateQueries({queryKey:[`flywheel-uat-generations`]}),n.invalidateQueries({queryKey:[`flywheel-merge-queue`]})},d=Nt({mutationFn:e=>O9(`/api/flywheel/uat-generations/${wkt(e)}/stack`),onSuccess:e=>{e.evicted.length>0&&H.info(`Stopped older UAT stack ${e.evicted.map(k9).join(`, `)} (max 2 run at once)`),window.open(e.frontendUrl,`_blank`,`noopener,noreferrer`),u()},onError:e=>H.error(e instanceof Error?e.message:`Could not start the UAT stack`)}),f=Nt({mutationFn:e=>O9(`/api/flywheel/uat-generations/${wkt(e)}/promote`),onSuccess:e=>{H.success(`Merged ${e.members.length} feature${e.members.length===1?``:`s`} to main (${e.members.join(`, `)})`),u()},onError:e=>{H.error(e instanceof Error?e.message:`Batch merge failed`),u()}}),p=Nt({mutationFn:()=>O9(`/api/flywheel/assemble-uat`),onSuccess:e=>{e.action===`assembled`?H.success(`Rebuilt the UAT batch`):H.info(`Rebuild: ${e.action}`),u()},onError:e=>H.error(e instanceof Error?e.message:`Rebuild failed`)}),m=Nt({mutationFn:()=>O9(`/api/flywheel/merge-next`,{n:1}),onSuccess:e=>{let t=e.outcomes[0];t?.result===`merged`?H.success(`Merged ${t.issueId} to main`):H.warning(`${t?.issueId??`Merge`} did not merge: ${t?.reason??`unknown`}`),u()},onError:e=>H.error(e instanceof Error?e.message:`Merge failed`)}),h=async e=>{let t=e.members.map((e,t)=>`${t+1}. ${e.issueId} (${e.branch}) — ${e.title}`).join(`
|
|
678
|
+
`},tDt=YEt($Et)(eDt),nDt={config:ZEt},rDt=function(){var e=[...arguments];return function(t){return e.reduceRight(function(e,t){return t(e)},t)}};function iDt(e,t){return Object.keys(t).forEach(function(n){t[n]instanceof Object&&e[n]&&Object.assign(t[n],iDt(e[n],t[n]))}),TEt(TEt({},e),t)}var aDt={type:`cancelation`,msg:`operation is manually canceled`};function a9(e){var t=!1,n=new Promise(function(n,r){e.then(function(e){return t?r(aDt):n(e)}),e.catch(r)});return n.cancel=function(){return t=!0},n}var oDt=[`monaco`],sDt=OEt(qEt.create({config:JEt,isInitialized:!1,resolve:null,reject:null,monaco:null}),2),o9=sDt[0],s9=sDt[1];function cDt(e){var t=nDt.config(e),n=t.monaco,r=EEt(t,oDt);s9(function(e){return{config:iDt(e.config,r),monaco:n}})}function lDt(){var e=o9(function(e){return{monaco:e.monaco,isInitialized:e.isInitialized,resolve:e.resolve}});if(!e.isInitialized){if(s9({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),a9(c9);if(window.monaco&&window.monaco.editor)return mDt(window.monaco),e.resolve(window.monaco),a9(c9);rDt(uDt,fDt)(pDt)}return a9(c9)}function uDt(e){return document.body.appendChild(e)}function dDt(e){var t=document.createElement(`script`);return e&&(t.src=e),t}function fDt(e){var t=o9(function(e){return{config:e.config,reject:e.reject}}),n=dDt(`${t.config.paths.vs}/loader.js`);return n.onload=function(){return e()},n.onerror=t.reject,n}function pDt(){var e=o9(function(e){return{config:e.config,resolve:e.resolve,reject:e.reject}}),t=window.require;t.config(e.config),t([`vs/editor/editor.main`],function(t){var n=t.m||t;mDt(n),e.resolve(n)},function(t){e.reject(t)})}function mDt(e){o9().monaco||s9({monaco:e})}function hDt(){return o9(function(e){return e.monaco})}var c9=new Promise(function(e,t){return s9({resolve:e,reject:t})}),gDt={config:cDt,init:lDt,__getMonacoInstance:hDt},l9={wrapper:{display:`flex`,position:`relative`,textAlign:`initial`},fullWidth:{width:`100%`},hide:{display:`none`}},_Dt={container:{display:`flex`,height:`100%`,width:`100%`,justifyContent:`center`,alignItems:`center`}};function vDt({children:e}){return R.createElement(`div`,{style:_Dt.container},e)}var yDt=vDt;function bDt({width:e,height:t,isEditorReady:n,loading:r,_ref:i,className:a,wrapperProps:o}){return R.createElement(`section`,{style:{...l9.wrapper,width:e,height:t},...o},!n&&R.createElement(yDt,null,r),R.createElement(`div`,{ref:i,style:{...l9.fullWidth,...!n&&l9.hide},className:a}))}var xDt=(0,R.memo)(bDt);function SDt(e){(0,R.useEffect)(e,[])}var CDt=SDt;function wDt(e,t,n=!0){let r=(0,R.useRef)(!0);(0,R.useEffect)(r.current||!n?()=>{r.current=!1}:e,t)}var u9=wDt;function d9(){}function f9(e,t,n,r){return TDt(e,r)||EDt(e,t,n,r)}function TDt(e,t){return e.editor.getModel(DDt(e,t))}function EDt(e,t,n,r){return e.editor.createModel(t,n,r?DDt(e,r):void 0)}function DDt(e,t){return e.Uri.parse(t)}function ODt({original:e,modified:t,language:n,originalLanguage:r,modifiedLanguage:i,originalModelPath:a,modifiedModelPath:o,keepCurrentOriginalModel:s=!1,keepCurrentModifiedModel:c=!1,theme:l=`light`,loading:u=`Loading...`,options:d={},height:f=`100%`,width:p=`100%`,className:m,wrapperProps:h={},beforeMount:g=d9,onMount:_=d9}){let[v,y]=(0,R.useState)(!1),[b,x]=(0,R.useState)(!0),S=(0,R.useRef)(null),C=(0,R.useRef)(null),w=(0,R.useRef)(null),T=(0,R.useRef)(_),E=(0,R.useRef)(g),D=(0,R.useRef)(!1);CDt(()=>{let e=gDt.init();return e.then(e=>(C.current=e)&&x(!1)).catch(e=>e?.type!==`cancelation`&&console.error(`Monaco initialization: error:`,e)),()=>S.current?A():e.cancel()}),u9(()=>{if(S.current&&C.current){let t=S.current.getOriginalEditor(),i=f9(C.current,e||``,r||n||`text`,a||``);i!==t.getModel()&&t.setModel(i)}},[a],v),u9(()=>{if(S.current&&C.current){let e=S.current.getModifiedEditor(),r=f9(C.current,t||``,i||n||`text`,o||``);r!==e.getModel()&&e.setModel(r)}},[o],v),u9(()=>{let e=S.current.getModifiedEditor();e.getOption(C.current.editor.EditorOption.readOnly)?e.setValue(t||``):t!==e.getValue()&&(e.executeEdits(``,[{range:e.getModel().getFullModelRange(),text:t||``,forceMoveMarkers:!0}]),e.pushUndoStop())},[t],v),u9(()=>{S.current?.getModel()?.original.setValue(e||``)},[e],v),u9(()=>{let{original:e,modified:t}=S.current.getModel();C.current.editor.setModelLanguage(e,r||n||`text`),C.current.editor.setModelLanguage(t,i||n||`text`)},[n,r,i],v),u9(()=>{C.current?.editor.setTheme(l)},[l],v),u9(()=>{S.current?.updateOptions(d)},[d],v);let O=(0,R.useCallback)(()=>{if(!C.current)return;E.current(C.current);let s=f9(C.current,e||``,r||n||`text`,a||``),c=f9(C.current,t||``,i||n||`text`,o||``);S.current?.setModel({original:s,modified:c})},[n,t,i,e,r,a,o]),k=(0,R.useCallback)(()=>{!D.current&&w.current&&(S.current=C.current.editor.createDiffEditor(w.current,{automaticLayout:!0,...d}),O(),C.current?.editor.setTheme(l),y(!0),D.current=!0)},[d,l,O]);(0,R.useEffect)(()=>{v&&T.current(S.current,C.current)},[v]),(0,R.useEffect)(()=>{!b&&!v&&k()},[b,v,k]);function A(){let e=S.current?.getModel();s||e?.original?.dispose(),c||e?.modified?.dispose(),S.current?.dispose()}return R.createElement(xDt,{width:p,height:f,isEditorReady:v,loading:u,_ref:w,className:m,wrapperProps:h})}(0,R.memo)(ODt);function kDt(e){let t=(0,R.useRef)();return(0,R.useEffect)(()=>{t.current=e},[e]),t.current}var ADt=kDt,p9=new Map;function jDt({defaultValue:e,defaultLanguage:t,defaultPath:n,value:r,language:i,path:a,theme:o=`light`,line:s,loading:c=`Loading...`,options:l={},overrideServices:u={},saveViewState:d=!0,keepCurrentModel:f=!1,width:p=`100%`,height:m=`100%`,className:h,wrapperProps:g={},beforeMount:_=d9,onMount:v=d9,onChange:y,onValidate:b=d9}){let[x,S]=(0,R.useState)(!1),[C,w]=(0,R.useState)(!0),T=(0,R.useRef)(null),E=(0,R.useRef)(null),D=(0,R.useRef)(null),O=(0,R.useRef)(v),k=(0,R.useRef)(_),A=(0,R.useRef)(),j=(0,R.useRef)(r),M=ADt(a),N=(0,R.useRef)(!1),P=(0,R.useRef)(!1);CDt(()=>{let e=gDt.init();return e.then(e=>(T.current=e)&&w(!1)).catch(e=>e?.type!==`cancelation`&&console.error(`Monaco initialization: error:`,e)),()=>E.current?I():e.cancel()}),u9(()=>{let o=f9(T.current,e||r||``,t||i||``,a||n||``);o!==E.current?.getModel()&&(d&&p9.set(M,E.current?.saveViewState()),E.current?.setModel(o),d&&E.current?.restoreViewState(p9.get(a)))},[a],x),u9(()=>{E.current?.updateOptions(l)},[l],x),u9(()=>{!E.current||r===void 0||(E.current.getOption(T.current.editor.EditorOption.readOnly)?E.current.setValue(r):r!==E.current.getValue()&&(P.current=!0,E.current.executeEdits(``,[{range:E.current.getModel().getFullModelRange(),text:r,forceMoveMarkers:!0}]),E.current.pushUndoStop(),P.current=!1))},[r],x),u9(()=>{let e=E.current?.getModel();e&&i&&T.current?.editor.setModelLanguage(e,i)},[i],x),u9(()=>{s!==void 0&&E.current?.revealLine(s)},[s],x),u9(()=>{T.current?.editor.setTheme(o)},[o],x);let F=(0,R.useCallback)(()=>{if(!(!D.current||!T.current)&&!N.current){k.current(T.current);let c=a||n,f=f9(T.current,r||e||``,t||i||``,c||``);E.current=T.current?.editor.create(D.current,{model:f,automaticLayout:!0,...l},u),d&&E.current.restoreViewState(p9.get(c)),T.current.editor.setTheme(o),s!==void 0&&E.current.revealLine(s),S(!0),N.current=!0}},[e,t,n,r,i,a,l,u,d,o,s]);(0,R.useEffect)(()=>{x&&O.current(E.current,T.current)},[x]),(0,R.useEffect)(()=>{!C&&!x&&F()},[C,x,F]),j.current=r,(0,R.useEffect)(()=>{x&&y&&(A.current?.dispose(),A.current=E.current?.onDidChangeModelContent(e=>{P.current||y(E.current.getValue(),e)}))},[x,y]),(0,R.useEffect)(()=>{if(x){let e=T.current.editor.onDidChangeMarkers(e=>{let t=E.current.getModel()?.uri;if(t&&e.find(e=>e.path===t.path)){let e=T.current.editor.getModelMarkers({resource:t});b?.(e)}});return()=>{e?.dispose()}}return()=>{}},[x,b]);function I(){A.current?.dispose(),f?d&&p9.set(a,E.current.saveViewState()):E.current.getModel()?.dispose(),E.current.dispose()}return R.createElement(xDt,{width:p,height:m,isEditorReady:x,loading:c,_ref:D,className:h,wrapperProps:g})}var MDt=(0,R.memo)(jDt);function NDt({value:e,onChange:t,disabled:n=!1}){return(0,z.jsx)(MDt,{height:`100%`,language:`markdown`,theme:`vs-dark`,value:e,loading:(0,z.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`Loading editor…`}),options:{minimap:{enabled:!1},wordWrap:`on`,lineNumbers:`on`,readOnly:n,scrollBeyondLastLine:!1,fontSize:13,padding:{top:16,bottom:16},automaticLayout:!0},onChange:e=>t(e??``)})}var PDt=class extends Error{status;body;constructor(e,t,n){super(e),this.status=t,this.body=n,this.name=`ContextApiError`}},m9={layers:[`context`,`layers`]};async function FDt(e){let t=await e.text();if(!t)return null;try{return JSON.parse(t)}catch{return t}}function IDt(e,t){if(t&&typeof t==`object`){let e=t;if(typeof e.error==`string`)return e.error;if(typeof e.message==`string`)return e.message}return typeof t==`string`&&t.trim()?t:`Context API request failed with status ${e}`}async function h9(e,t){let n={Accept:`application/json`};t.body!==void 0&&(n[`Content-Type`]=`application/json`);let r=await fetch(e,{method:t.method,credentials:`include`,headers:n,body:t.body===void 0?void 0:JSON.stringify(t.body)}),i=await FDt(r);if(!r.ok)throw new PDt(IDt(r.status,i),r.status,i);return i}function LDt(){return h9(`/api/context/layers`,{method:`GET`})}function RDt(e){return h9(`/api/context/preview`,{method:`POST`,body:e})}function zDt(e){return h9(`/api/context/layers`,{method:`PUT`,body:e})}function BDt(e={operation:`sync`}){return h9(`/api/context/sync`,{method:`POST`,body:e})}function VDt(){return B({queryKey:m9.layers,queryFn:LDt})}function HDt(){return Nt({mutationFn:RDt})}function UDt(){let e=_t();return Nt({mutationFn:zDt,onSuccess:()=>{e.invalidateQueries({queryKey:m9.layers})}})}function WDt(){let e=_t();return Nt({mutationFn:BDt,onSuccess:()=>{e.invalidateQueries({queryKey:m9.layers})}})}function g9(e){switch(e.kind){case`global`:return`global`;case`project`:return`project:${e.projectKey}`;case`workspace`:return`workspace:${e.projectKey}:${e.workspacePath}`}}function GDt(e){switch(e.kind){case`global`:return{kind:`global`};case`project`:return{kind:`project`,projectKey:e.projectKey};case`workspace`:return{kind:`workspace`,projectKey:e.projectKey,workspacePath:e.workspacePath}}}function KDt(e){switch(e.kind){case`global`:return`~/.overdeck/context/global.md`;case`project`:return`.pan/context/project.md`;case`workspace`:return`.pan/context/workspace.md`}}function qDt(e){switch(e){case`global`:return`Global context`;case`project`:return`Project context`;case`workspace`:return`Workspace context`}}function _9(e){return e instanceof Error?e.message:String(e||`Unknown error`)}function JDt({error:e}){return(0,z.jsx)(`div`,{className:`h-full w-full p-6`,children:(0,z.jsxs)(`div`,{className:`rounded-lg border border-destructive/40 bg-destructive/10 p-4 text-sm text-destructive`,children:[`Failed to load context layers: `,_9(e)]})})}function YDt(e){let t=e.layer?g9(e.layer):`preview`;return`${e.level.toUpperCase()} · ${t}: ${e.message}`}function XDt(){let{data:e,isLoading:t,error:n,refetch:r}=VDt(),i=HDt(),a=UDt(),o=WDt(),s=i.mutateAsync,[c,l]=(0,R.useState)(`global`),[u,d]=(0,R.useState)(``),[f,p]=(0,R.useState)(``),[m,h]=(0,R.useState)({}),[g,_]=(0,R.useState)(`claude-code`),[v,y]=(0,R.useState)(null),[b,x]=(0,R.useState)(null),[S,C]=(0,R.useState)(null),w=(0,R.useMemo)(()=>e?.workspaces.filter(e=>e.projectKey===u)??[],[e?.workspaces,u]);(0,R.useEffect)(()=>{if(!e)return;let t=e.projects[0]?.projectKey??``;d(n=>e.projects.some(e=>e.projectKey===n)?n:t)},[e]),(0,R.useEffect)(()=>{e&&p(w.some(e=>e.path===f)?f:w[0]?.path??``)},[e,w,f]);let T=(0,R.useMemo)(()=>c===`global`?{kind:`global`}:u?c===`project`?{kind:`project`,projectKey:u}:f?{kind:`workspace`,projectKey:u,workspacePath:f}:null:null,[c,u,f]),E=(0,R.useMemo)(()=>{if(!e||!T)return null;let t=g9(T);return e.layers.find(e=>g9(GDt(e))===t)??null},[e,T]),D=(0,R.useMemo)(()=>e?e.layers.flatMap(e=>{let t=GDt(e),n=m[g9(t)];return n===void 0?[]:[{target:t,content:n}]}):[],[e,m]),O=T?g9(T):``,k=E?m[O]??E.content:``,A=e?.projects.find(e=>e.projectKey===u)??null,j=e?.workspaces.find(e=>e.path===f)??null,M=!!E&&m[O]!==void 0&&m[O]!==E.content,N=a.isPending||o.isPending,P=(0,R.useMemo)(()=>e?c===`global`?e.targets.filter(e=>e.layerKind===`global`):c===`project`?e.targets.filter(e=>e.layerKind===`project`&&e.projectKey===u):[]:[],[e,c,u]);(0,R.useEffect)(()=>{if(!T||!E){y(null);return}let e=!1;x(null);let t=window.setTimeout(()=>{s({operation:`preview`,selectedLayer:T,drafts:D}).then(t=>{e||y(t)}).catch(t=>{e||x(_9(t))})},300);return()=>{e=!0,window.clearTimeout(t)}},[D,s,E,T]);async function F(e){if(!(!T||!E)){C(null);try{await a.mutateAsync({operation:`save`,target:T,content:k}),e&&await o.mutateAsync({operation:`sync`}),await r(),h(e=>{let{[O]:t,...n}=e;return n}),H.success(e?`Context saved and synced`:`Context saved`)}catch(e){let t=_9(e);C(t),H.error(t)}}}if(t)return(0,z.jsx)(`div`,{className:`h-full w-full p-6 text-sm text-muted-foreground`,children:`Loading context layers…`});if(n)return(0,z.jsx)(JDt,{error:n});let I=v?.previews[g]??``,ee=v?.diagnostics??[];return(0,z.jsxs)(`div`,{className:`flex h-full w-full overflow-hidden bg-background text-foreground`,children:[(0,z.jsxs)(`aside`,{className:`w-80 shrink-0 overflow-y-auto border-r border-border bg-card/40 p-4`,children:[(0,z.jsxs)(`div`,{className:`mb-5`,children:[(0,z.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:`Context`}),(0,z.jsx)(`h1`,{className:`mt-1 text-lg font-semibold`,children:`Layer editor`}),(0,z.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-muted-foreground`,children:`Edit the context markdown Overdeck injects into coding-agent sessions.`})]}),(0,z.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,z.jsx)(`legend`,{className:`text-xs font-medium uppercase tracking-wide text-muted-foreground`,children:`Layer`}),[`global`,`project`,`workspace`].map(e=>(0,z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 rounded-md border border-border bg-background/60 px-3 py-2 text-sm`,children:[(0,z.jsx)(`input`,{type:`radio`,name:`context-layer-kind`,value:e,checked:c===e,onChange:()=>l(e)}),(0,z.jsx)(`span`,{children:qDt(e)})]},e))]}),(0,z.jsxs)(`div`,{className:`mt-5 space-y-4`,children:[(0,z.jsxs)(`label`,{className:`block space-y-1 text-xs text-muted-foreground`,children:[(0,z.jsx)(`span`,{children:`Project`}),(0,z.jsx)(`select`,{className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground`,value:u,onChange:e=>d(e.target.value),disabled:!e?.projects.length||c===`global`,children:e?.projects.length?e.projects.map(e=>(0,z.jsx)(`option`,{value:e.projectKey,children:e.name},e.projectKey)):(0,z.jsx)(`option`,{value:``,children:`No registered projects`})})]}),(0,z.jsxs)(`label`,{className:`block space-y-1 text-xs text-muted-foreground`,children:[(0,z.jsx)(`span`,{children:`Workspace`}),(0,z.jsx)(`select`,{className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground`,value:f,onChange:e=>p(e.target.value),disabled:c!==`workspace`||w.length===0,children:w.length?w.map(e=>(0,z.jsx)(`option`,{value:e.path,children:e.issueId??e.name},e.path)):(0,z.jsx)(`option`,{value:``,children:`No workspaces for this project`})})]})]}),(0,z.jsx)(`div`,{className:`mt-5 rounded-lg border border-border bg-background/70 p-3 text-xs text-muted-foreground`,children:E?(0,z.jsxs)(`dl`,{className:`space-y-2`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Layer file`}),(0,z.jsx)(`dd`,{className:`mt-1 font-mono`,children:KDt(E)})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Resolved path`}),(0,z.jsx)(`dd`,{className:`mt-1 break-all font-mono`,children:E.file})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Status`}),(0,z.jsx)(`dd`,{className:`mt-1`,children:E.exists?`File exists`:`File has not been created yet`})]})]}):(0,z.jsx)(`p`,{children:`Select a project or workspace to edit its context layer.`})}),(0,z.jsxs)(`div`,{className:`mt-4 rounded-lg border border-border bg-background/70 p-3 text-xs text-muted-foreground`,children:[(0,z.jsx)(`p`,{className:`font-medium text-foreground`,children:`Where this gets injected`}),(0,z.jsxs)(`p`,{className:`mt-1 leading-5`,children:[(0,z.jsx)(`code`,{className:`rounded bg-muted px-1`,children:`pan sync`}),` writes a managed region — between `,(0,z.jsx)(`code`,{className:`rounded bg-muted px-1`,children:`BEGIN/END OVERDECK CONTEXT`}),` markers — into the files below. Anything you wrote `,(0,z.jsx)(`span`,{className:`font-medium text-foreground`,children:`outside`}),` those markers is never modified. Edit the layer source here, not the region.`]}),P.length>0?(0,z.jsx)(`ul`,{className:`mt-2 space-y-2`,children:P.map(e=>(0,z.jsxs)(`li`,{children:[(0,z.jsx)(`div`,{className:`break-all font-mono text-foreground`,children:e.path}),(0,z.jsx)(`div`,{className:`mt-0.5`,children:e.exists?e.hasUserContent?`Has your own content — preserved outside the managed region.`:e.hasManagedRegion?`Managed by Overdeck (no other content).`:`Exists — a managed region is added on next sync.`:`Not created yet — created on next sync.`})]},e.path))}):c===`workspace`?(0,z.jsx)(`p`,{className:`mt-2`,children:`Workspace context is auto-assembled into the workspace and is not injected into any hand-authored file.`}):(0,z.jsx)(`p`,{className:`mt-2`,children:`No injection targets for this selection yet (the project has no project.md).`})]}),c===`workspace`?(0,z.jsxs)(`p`,{className:`mt-4 rounded-lg border border-info/30 bg-info/10 p-3 text-xs leading-5 text-info-foreground`,children:[(0,z.jsx)(`span`,{className:`font-semibold`,children:`Workspace context:`}),` .pan/context/workspace.md is auto-assembled for each workspace and may not exist until a workspace is created.`]}):null]}),(0,z.jsxs)(`section`,{className:`flex min-w-0 flex-1 overflow-hidden`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,z.jsx)(`header`,{className:`shrink-0 border-b border-border px-4 py-3`,children:(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`h2`,{className:`text-sm font-semibold`,children:qDt(c)}),(0,z.jsx)(`p`,{className:`mt-1 truncate text-xs text-muted-foreground`,children:c===`global`?`Applies to every registered project.`:c===`project`?A?.path??`No project selected`:j?.path??`No workspace selected`})]}),E?(0,z.jsx)(`span`,{className:`rounded-full border border-border px-2 py-1 text-xs text-muted-foreground`,children:M?`Edited`:`Loaded`}):null]})}),(0,z.jsx)(`div`,{className:`min-h-0 flex-1`,children:E?(0,z.jsx)(NDt,{value:k,disabled:N,onChange:e=>h(t=>({...t,[O]:e}))}):(0,z.jsx)(`div`,{className:`flex h-full items-center justify-center p-6 text-sm text-muted-foreground`,children:`No context layer is available for the current selection.`})}),(0,z.jsxs)(`footer`,{className:`flex shrink-0 items-center justify-between gap-3 border-t border-border px-4 py-3`,children:[(0,z.jsx)(`div`,{className:`min-w-0 text-xs text-muted-foreground`,children:S?(0,z.jsx)(`span`,{className:`text-destructive`,children:S}):M?`Unsaved changes`:`No unsaved changes`}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`button`,{type:`button`,className:`rounded-md border border-border px-3 py-1.5 text-sm text-foreground disabled:cursor-not-allowed disabled:opacity-50`,disabled:!M||N||!E,onClick:()=>void F(!1),children:a.isPending&&!o.isPending?`Saving…`:`Save`}),(0,z.jsx)(`button`,{type:`button`,className:`rounded-md bg-primary px-3 py-1.5 text-sm font-medium text-primary-foreground disabled:cursor-not-allowed disabled:opacity-50`,disabled:!M||N||!E,onClick:()=>void F(!0),children:N&&o.isPending?`Syncing…`:`Save & Sync`})]})]})]}),(0,z.jsxs)(`aside`,{className:`flex w-[28rem] shrink-0 flex-col overflow-hidden border-l border-border bg-card/30`,children:[(0,z.jsxs)(`div`,{className:`shrink-0 border-b border-border p-4`,children:[(0,z.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:`Preview`}),(0,z.jsx)(`div`,{className:`mt-3 grid grid-cols-3 gap-1 rounded-lg bg-muted p-1`,children:[[`claude-code`,`Claude Code output`],[`ohmypi`,`oh-my-pi output`],[`fullPrompt`,`Full injected prompt`]].map(([e,t])=>(0,z.jsx)(`button`,{type:`button`,className:`rounded-md px-2 py-1.5 text-xs transition-colors ${g===e?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`}`,onClick:()=>_(e),children:t},e))})]}),(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-4`,children:b?(0,z.jsx)(`div`,{className:`rounded-lg border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive`,children:b}):i.isPending&&!I?(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Rendering preview…`}):I?(0,z.jsx)(`pre`,{className:`whitespace-pre-wrap rounded-lg border border-border bg-background p-3 text-xs leading-5 text-foreground`,children:I}):(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Preview updates after the editor changes.`})}),(0,z.jsxs)(`div`,{className:`max-h-40 shrink-0 overflow-auto border-t border-border p-4`,children:[(0,z.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:`Validation`}),ee.length>0?(0,z.jsx)(`ul`,{className:`mt-2 space-y-2 text-xs`,children:ee.map((e,t)=>(0,z.jsx)(`li`,{className:e.level===`error`?`text-destructive`:`text-warning-foreground`,children:YDt(e)},`${e.message}-${t}`))}):(0,z.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:`No validation issues.`})]})]})]})]})}function ZDt({sessions:e,selectedId:t,onSelect:n}){return(0,z.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,z.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{className:`text-gray-500 border-b border-gray-800 sticky top-0 bg-gray-950 z-10`,children:[(0,z.jsx)(`th`,{className:`text-left px-3 py-2 font-medium w-8`}),(0,z.jsx)(`th`,{className:`text-left px-3 py-2 font-medium`,children:`Workspace`}),(0,z.jsx)(`th`,{className:`text-left px-3 py-2 font-medium w-32`,children:`Model`}),(0,z.jsx)(`th`,{className:`text-right px-3 py-2 font-medium w-12`,children:`Msgs`}),(0,z.jsx)(`th`,{className:`text-right px-3 py-2 font-medium w-20`,children:`Cost`}),(0,z.jsx)(`th`,{className:`text-left px-3 py-2 font-medium w-32`,children:`Last Active`})]})}),(0,z.jsx)(`tbody`,{children:e.map(e=>{let r=`${e.source}-${e.id}`,i=r===t,a=e.workspacePath??e.jsonlPath??`Unknown session path`,o=a.split(`/`).slice(-2).join(`/`);return(0,z.jsxs)(`tr`,{onClick:()=>n(i?null:r),className:`border-b border-gray-900 cursor-pointer transition-colors ${i?`bg-blue-950 border-blue-900`:`hover:bg-gray-900`}`,children:[(0,z.jsx)(`td`,{className:`px-3 py-1.5 text-center`,children:e.source===`managed-archived`?(0,z.jsx)(Rt,{className:`h-3 w-3 text-amber-400 inline`}):e.overdeckManaged?(0,z.jsx)(Mr,{className:`h-3 w-3 text-cyan-400 inline`}):e.enrichmentLevel>0?(0,z.jsx)(on,{className:`h-3 w-3 text-green-500 inline`}):(0,z.jsx)(dn,{className:`h-3 w-3 text-gray-700 inline`})}),(0,z.jsxs)(`td`,{className:`px-3 py-1.5 max-w-xs`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,z.jsx)(`div`,{className:`font-mono text-gray-200 truncate`,title:a,children:o}),e.source===`managed-archived`?(0,z.jsxs)(`span`,{className:`shrink-0 rounded-full border border-amber-700 bg-amber-950 px-1.5 py-0.5 text-[10px] font-medium text-amber-200`,children:[`Archived`,e.panIssueId?` · ${e.panIssueId}`:``]}):e.overdeckManaged&&(0,z.jsxs)(`span`,{className:`shrink-0 rounded-full border border-cyan-700 bg-cyan-950 px-1.5 py-0.5 text-[10px] font-medium text-cyan-200`,children:[`Managed`,e.panIssueId?` · ${e.panIssueId}`:``]})]}),e.summary&&(0,z.jsx)(`div`,{className:`text-gray-500 truncate mt-0.5`,title:e.summary,children:e.summary}),e.tags.length>0&&(0,z.jsx)(`div`,{className:`flex gap-1 mt-0.5 flex-wrap`,children:e.tags.slice(0,4).map(e=>(0,z.jsx)(`span`,{className:`px-1 py-0 bg-gray-800 text-gray-400 rounded text-[10px]`,children:e},e))})]}),(0,z.jsx)(`td`,{className:`px-3 py-1.5 text-gray-400 truncate max-w-[8rem]`,children:e.primaryModel?e.primaryModel.split(`-`).slice(-2).join(`-`):`—`}),(0,z.jsx)(`td`,{className:`px-3 py-1.5 text-right text-gray-400 font-mono`,children:e.messageCount}),(0,z.jsx)(`td`,{className:`px-3 py-1.5 text-right font-mono`,children:e.estimatedCost>0?(0,z.jsxs)(`span`,{className:`text-yellow-500`,children:[`$`,e.estimatedCost.toFixed(4)]}):(0,z.jsx)(`span`,{className:`text-gray-700`,children:`—`})}),(0,z.jsx)(`td`,{className:`px-3 py-1.5 text-gray-500`,children:e.lastTs?QDt(e.lastTs):`—`})]},r)})})]})})}function QDt(e){try{let t=new Date(e),n=Date.now()-t.getTime(),r=Math.floor(n/864e5);return r===0?`today`:r===1?`yesterday`:r<7?`${r}d ago`:r<30?`${Math.floor(r/7)}w ago`:t.toISOString().slice(0,10)}catch{return e}}async function $Dt(e,t){await hj().request(n=>n[Pp.enrichSessions]({ids:[e],level:t.tier,confirmed:t.confirmed,...t.model?{model:t.model}:{}}))}async function eOt(e){await hj().request(t=>t[Pp.embedSessions]({ids:[e]}))}async function tOt(e){if(!e)throw Error(`Archived conversation is missing its name`);let t=await fetch(`/api/conversations/${encodeURIComponent(e)}/unarchive`,{method:`POST`});if(!t.ok)throw Error(`Unarchive failed: ${t.status}`)}function nOt(e,t){let n=typeof e==`object`&&e&&`code`in e?String(e.code??``):``,r=/^COST_THRESHOLD:([^:]+):([^:]+):([^:]+)$/.exec(n);return r?{tier:t.tier,estimatedCost:Number(r[1]),threshold:Number(r[2]),sessionCount:Number(r[3]),model:t.model}:null}function rOt(e){return{id:e.id,jsonlPath:e.jsonlPath,workspacePath:e.workspacePath??null,primaryModel:e.primaryModel??null,messageCount:e.messageCount,firstTs:e.firstTs??null,lastTs:e.lastTs??null,estimatedCost:e.estimatedCost,tokenInput:e.tokenInput,tokenOutput:e.tokenOutput,toolsUsed:[...e.toolsUsed],filesTouched:[...e.filesTouched],tags:[...e.tags],summary:e.summary??null,summaryDetailed:e.summaryDetailed??null,enrichmentLevel:e.enrichmentLevel,enrichmentFailed:e.enrichmentFailed,overdeckManaged:e.overdeckManaged,panIssueId:e.panIssueId??null}}async function iOt(e){return rOt(await hj().request(t=>t[Pp.getDiscoveredSession]({id:e})))}function aOt({session:e,onClose:t}){let n=_t(),[r,i]=(0,R.useState)(null),[a,o]=(0,R.useState)(``),s=e.source===`managed-archived`,c=sm(t=>t.enrichProgressBySessionId[e.id]),{data:l}=B({queryKey:[`discovered-session`,e.id],queryFn:()=>iOt(e.id),staleTime:1/0,placeholderData:e,enabled:!s}),u=s?e:l??e,d=()=>{n.invalidateQueries({queryKey:[`discovered-session`,e.id]}),n.invalidateQueries({queryKey:[`discovered-sessions`]}),n.invalidateQueries({queryKey:[`discovered-sessions-search`]}),n.invalidateQueries({queryKey:[`discovered-sessions-stats`]})},f=Nt({mutationFn:t=>$Dt(e.id,t),onSuccess:()=>{i(null),d()},onError:(e,t)=>{i(nOt(e,t))}}),p=Nt({mutationFn:()=>eOt(e.id),onSuccess:d}),m=Nt({mutationFn:()=>tOt(u.conversationName),onSuccess:()=>{n.invalidateQueries({queryKey:[`archived-conversations`]}),n.invalidateQueries({queryKey:[`conversations`]})}}),h=(e,t)=>(0,z.jsxs)(`div`,{className:`flex gap-2 text-xs py-1 border-b border-gray-900`,children:[(0,z.jsx)(`span`,{className:`text-gray-500 w-28 shrink-0`,children:e}),(0,z.jsx)(`span`,{className:`text-gray-200 font-mono break-all`,children:t??`—`})]}),g=e=>{let t=a.trim();f.mutate({tier:e,...t?{model:t}:{}})};return(0,z.jsxs)(`div`,{className:`flex flex-col h-full border-l border-gray-800 bg-gray-950`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-gray-800 shrink-0`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsxs)(`span`,{className:`text-xs font-semibold text-gray-300`,children:[`Session #`,u.id]}),(0,z.jsx)(`span`,{className:u.overdeckManaged?`rounded border border-emerald-500/40 bg-emerald-950/60 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-emerald-300`:`rounded border border-amber-500/40 bg-amber-950/50 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-amber-300`,title:u.overdeckManaged?`Overdeck-managed session`:`Ad-hoc discovered session`,children:u.overdeckManaged?`Managed${u.panIssueId?` · ${u.panIssueId}`:``}`:`Ad-hoc`})]}),(0,z.jsx)(`button`,{onClick:t,className:`text-gray-600 hover:text-gray-300 transition-colors`,children:(0,z.jsx)(zr,{className:`h-4 w-4`})})]}),(0,z.jsxs)(`div`,{className:`flex-1 overflow-auto px-3 py-2 space-y-4`,children:[u.summary&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] font-semibold text-gray-500 uppercase tracking-wider mb-1`,children:`Summary`}),(0,z.jsx)(`p`,{className:`text-xs text-gray-300 leading-relaxed`,children:u.summary})]}),u.summaryDetailed&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] font-semibold text-gray-500 uppercase tracking-wider mb-1`,children:`Detailed`}),(0,z.jsx)(`p`,{className:`text-xs text-gray-400 leading-relaxed`,children:u.summaryDetailed})]}),u.tags.length>0&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] font-semibold text-gray-500 uppercase tracking-wider mb-1`,children:`Tags`}),(0,z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:u.tags.map(e=>(0,z.jsx)(`span`,{className:`px-1.5 py-0.5 bg-gray-800 text-cyan-400 rounded text-[10px]`,children:e},e))})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] font-semibold text-gray-500 uppercase tracking-wider mb-1`,children:`Metadata`}),h(`Workspace`,u.workspacePath),h(`Model`,u.primaryModel),h(`Messages`,u.messageCount),h(`Input tokens`,u.tokenInput.toLocaleString()),h(`Output tokens`,u.tokenOutput.toLocaleString()),h(`Est. cost`,u.estimatedCost>0?`$${u.estimatedCost.toFixed(6)}`:null),h(`First active`,u.firstTs?v9(u.firstTs):null),h(`Last active`,u.lastTs?v9(u.lastTs):null),s&&h(`Archived at`,u.archivedAt?v9(u.archivedAt):null),u.panIssueId&&h(`Issue`,u.panIssueId),h(`Enrichment`,u.enrichmentLevel===0?`None`:`L${u.enrichmentLevel}`)]}),u.toolsUsed.length>0&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] font-semibold text-gray-500 uppercase tracking-wider mb-1`,children:`Tools Used`}),(0,z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:u.toolsUsed.map(e=>(0,z.jsx)(`span`,{className:`px-1.5 py-0.5 bg-gray-900 text-gray-400 rounded text-[10px] font-mono`,children:e},e))})]}),u.filesTouched.length>0&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] font-semibold text-gray-500 uppercase tracking-wider mb-1`,children:`Files Touched`}),(0,z.jsx)(`div`,{className:`space-y-1 max-h-28 overflow-auto`,children:u.filesTouched.map(e=>(0,z.jsx)(`div`,{className:`text-[10px] text-gray-500 font-mono break-all`,children:e},e))})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] font-semibold text-gray-500 uppercase tracking-wider mb-1`,children:`File`}),(0,z.jsxs)(`div`,{className:`flex items-start gap-1`,children:[(0,z.jsx)(kn,{className:`h-3 w-3 text-gray-600 mt-0.5 shrink-0`}),(0,z.jsx)(`span`,{className:`text-[10px] text-gray-600 font-mono break-all`,children:u.jsonlPath??`No JSONL path available`})]})]})]}),(0,z.jsx)(`div`,{className:`px-3 py-2 border-t border-gray-800 shrink-0`,children:s?(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] text-gray-500 mb-1.5`,children:`Archived conversation`}),(0,z.jsx)(`div`,{className:`text-[10px] text-gray-600 mb-2`,children:`Restore this conversation to the active Command Deck list.`}),(0,z.jsx)(`button`,{onClick:()=>m.mutate(),disabled:m.isPending||m.isSuccess,className:`rounded bg-amber-700 px-2 py-1 text-xs text-amber-50 transition-colors hover:bg-amber-600 disabled:opacity-50`,children:m.isPending?`Unarchiving…`:`Unarchive`}),m.isSuccess&&(0,z.jsx)(`div`,{className:`text-[10px] text-green-400 mt-1`,children:`Conversation restored`}),m.isError&&(0,z.jsx)(`div`,{className:`text-[10px] text-red-400 mt-1`,children:m.error instanceof Error?m.error.message:`Unarchive failed`})]}):(0,z.jsxs)(z.Fragment,{children:[u.enrichmentLevel<3&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`text-[10px] text-gray-500 mb-1.5`,children:u.enrichmentFailed?`Enrichment failed — retry:`:`Enrich this session`}),(0,z.jsx)(`div`,{className:`text-[10px] text-amber-500/80 mb-1.5`,children:`Sends redacted conversation excerpts to the configured enrichment provider.`}),(0,z.jsxs)(`label`,{className:`mb-2 block text-[10px] text-gray-500`,children:[`Custom model`,(0,z.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),placeholder:`Use default provider model`,className:`mt-1 w-full rounded border border-gray-800 bg-gray-900 px-2 py-1 text-[10px] text-gray-200 placeholder-gray-600 focus:border-blue-500 focus:outline-none`})]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[u.enrichmentLevel<1&&(0,z.jsxs)(`button`,{onClick:()=>g(1),disabled:f.isPending,className:`flex items-center gap-1 px-2 py-1 bg-gray-800 hover:bg-gray-700 text-gray-300 rounded text-xs transition-colors disabled:opacity-50`,children:[(0,z.jsx)(Ar,{className:`h-3 w-3`}),`Quick (L1)`]}),u.enrichmentLevel<2&&(0,z.jsxs)(`button`,{onClick:()=>g(2),disabled:f.isPending,className:`flex items-center gap-1 px-2 py-1 bg-gray-800 hover:bg-gray-700 text-gray-300 rounded text-xs transition-colors disabled:opacity-50`,children:[(0,z.jsx)(Ar,{className:`h-3 w-3 text-yellow-400`}),`Detailed (L2)`]}),(0,z.jsxs)(`button`,{onClick:()=>g(3),disabled:f.isPending,className:`flex items-center gap-1 px-2 py-1 bg-gray-800 hover:bg-gray-700 text-gray-300 rounded text-xs transition-colors disabled:opacity-50`,children:[(0,z.jsx)(Ar,{className:`h-3 w-3 text-purple-400`}),`Deep (L3)`]})]})]}),f.isPending&&(0,z.jsx)(`div`,{className:`text-[10px] text-blue-400 mt-1`,children:`Enriching…`}),c&&(0,z.jsxs)(`div`,{className:c.success?`text-[10px] text-green-400 mt-1`:`text-[10px] text-red-400 mt-1`,children:[`L`,c.level,` `,c.success?`complete`:`failed: ${c.error??`unknown error`}`,` · `,c.model]}),r&&(0,z.jsxs)(`div`,{className:`mt-2 rounded border border-amber-700/60 bg-amber-950/30 p-2 text-[10px] text-amber-200`,children:[`Estimated cost $`,r.estimatedCost.toFixed(4),` exceeds threshold $`,r.threshold.toFixed(2),` for `,r.sessionCount,` session`,r.sessionCount===1?``:`s`,`.`,(0,z.jsx)(`button`,{onClick:()=>f.mutate({tier:r.tier,confirmed:!0,model:r.model}),disabled:f.isPending,className:`ml-2 rounded bg-amber-700 px-1.5 py-0.5 text-amber-50 disabled:opacity-50`,children:`Confirm`})]}),f.isError&&!r&&(0,z.jsx)(`div`,{className:`text-[10px] text-red-400 mt-1`,children:`Enrichment failed`}),(0,z.jsxs)(`div`,{className:`mt-3 flex items-center justify-between border-t border-gray-900 pt-2`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] text-gray-500`,children:`Semantic embedding`}),(0,z.jsx)(`div`,{className:`text-[10px] text-gray-600`,children:`Generate or refresh this session's vector index.`})]}),(0,z.jsx)(`button`,{onClick:()=>p.mutate(),disabled:p.isPending,className:`px-2 py-1 bg-gray-800 hover:bg-gray-700 text-gray-300 rounded text-xs transition-colors disabled:opacity-50`,children:`Embed`})]}),p.isPending&&(0,z.jsx)(`div`,{className:`text-[10px] text-blue-400 mt-1`,children:`Embedding…`}),p.isSuccess&&(0,z.jsx)(`div`,{className:`text-[10px] text-green-400 mt-1`,children:`Embedding complete`}),p.isError&&(0,z.jsx)(`div`,{className:`text-[10px] text-red-400 mt-1`,children:`Embedding failed`})]})})]})}function v9(e){try{return new Date(e).toISOString().replace(`T`,` `).slice(0,16)}catch{return e}}function oOt({isScanning:e,onScan:t,lastResult:n,progress:r}){let i=e||r?.active===!0;return(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[r?.active?(0,z.jsxs)(`span`,{className:`text-[10px] text-blue-300 font-mono`,children:[r.dirsProcessed,`/`,r.dirsTotal,` files · `,r.sessionsFound,` sessions · `,(r.elapsedMs/1e3).toFixed(1),`s`]}):n&&!i&&(0,z.jsxs)(`span`,{className:`text-[10px] text-gray-500`,children:[`+`,n.inserted,` ↑`,n.updated,` ·`,(n.durationMs/1e3).toFixed(1),`s`]}),(0,z.jsxs)(`button`,{onClick:t,disabled:i,className:`flex items-center gap-1.5 px-3 py-1.5 bg-blue-700 hover:bg-blue-600 disabled:opacity-50 text-white rounded text-xs transition-colors`,children:[(0,z.jsx)(_r,{className:`h-3.5 w-3.5 ${i?`animate-spin`:``}`}),i?`Scanning…`:`Scan`]})]})}var sOt=[{label:`All time`,value:``},{label:`Today`,value:`today`},{label:`Last 7 days`,value:`7d`},{label:`Last 30 days`,value:`30d`},{label:`Last 90 days`,value:`90d`}],cOt=[{label:`All`,value:`all`},{label:`Discovered`,value:`discovered`},{label:`Managed-archived`,value:`managed-archived`}];function lOt({filters:e,facets:t,onChange:n}){return(0,z.jsxs)(`div`,{className:`w-48 shrink-0 border-r border-gray-800 bg-gray-950 p-3 overflow-auto`,children:[(0,z.jsx)(`div`,{className:`text-[10px] font-semibold text-gray-500 uppercase tracking-wider mb-3`,children:`Filters`}),(0,z.jsxs)(`div`,{className:`mb-4`,children:[(0,z.jsx)(`label`,{className:`text-xs text-gray-400 block mb-1`,children:`Source`}),(0,z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:cOt.map(t=>(0,z.jsx)(`button`,{onClick:()=>n(`source`,t.value===`all`?void 0:t.value),className:`rounded px-1.5 py-0.5 text-[10px] transition-colors ${(e.source??`all`)===t.value?`bg-blue-900 text-blue-100`:`bg-gray-900 text-gray-400 hover:text-gray-200`}`,children:t.label},t.value))})]}),(0,z.jsxs)(`div`,{className:`mb-4`,children:[(0,z.jsx)(`label`,{className:`text-xs text-gray-400 block mb-1`,children:`Time range`}),(0,z.jsx)(`select`,{value:e.since??``,onChange:e=>n(`since`,e.target.value||void 0),className:`w-full bg-gray-900 border border-gray-700 rounded px-2 py-1 text-xs text-gray-200 focus:outline-none focus:border-blue-500`,children:sOt.map(e=>(0,z.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,z.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:t.timeRanges.map(t=>(0,z.jsxs)(`button`,{onClick:()=>n(`since`,e.since===t.value?void 0:t.value),className:`rounded px-1.5 py-0.5 text-[10px] transition-colors ${e.since===t.value?`bg-blue-900 text-blue-100`:`bg-gray-900 text-gray-400 hover:text-gray-200`}`,children:[t.label??t.value,`: `,t.count]},t.value))})]}),(0,z.jsxs)(`div`,{className:`mb-4`,children:[(0,z.jsx)(`label`,{className:`text-xs text-gray-400 block mb-1`,children:`Workspace path`}),(0,z.jsx)(`input`,{type:`text`,list:`conversation-workspaces`,value:e.workspace??``,onChange:e=>n(`workspace`,e.target.value||void 0),placeholder:`e.g. /Projects/myapp`,className:`w-full bg-gray-900 border border-gray-700 rounded px-2 py-1 text-xs text-gray-200 placeholder-gray-600 focus:outline-none focus:border-blue-500`}),(0,z.jsx)(`datalist`,{id:`conversation-workspaces`,children:t.workspaces.map(e=>(0,z.jsx)(`option`,{value:e.value},e.value))})]}),(0,z.jsxs)(`div`,{className:`mb-4`,children:[(0,z.jsx)(`label`,{className:`text-xs text-gray-400 block mb-1`,children:`Model`}),(0,z.jsxs)(`select`,{value:e.model??``,onChange:e=>n(`model`,e.target.value||void 0),className:`w-full bg-gray-900 border border-gray-700 rounded px-2 py-1 text-xs text-gray-200 focus:outline-none focus:border-blue-500`,children:[(0,z.jsx)(`option`,{value:``,children:`All models`}),t.models.map(e=>(0,z.jsxs)(`option`,{value:e.value,children:[e.value,` (`,e.count,`)`]},e.value))]}),(0,z.jsx)(`div`,{className:`mt-2 space-y-1 max-h-24 overflow-auto`,children:t.models.slice(0,8).map(t=>(0,z.jsxs)(`button`,{onClick:()=>n(`model`,e.model===t.value?void 0:t.value),className:`w-full truncate rounded px-1.5 py-0.5 text-left text-[10px] transition-colors ${e.model===t.value?`bg-blue-900 text-blue-100`:`bg-gray-900 text-gray-400 hover:text-gray-200`}`,title:t.value,children:[t.count,` · `,t.value]},t.value))})]}),(0,z.jsxs)(`div`,{className:`mb-4`,children:[(0,z.jsx)(`label`,{className:`text-xs text-gray-400 block mb-1`,children:`Tag`}),(0,z.jsx)(`input`,{type:`text`,list:`conversation-tags`,value:e.tag??``,onChange:e=>n(`tag`,e.target.value||void 0),placeholder:`e.g. bugfix`,className:`w-full bg-gray-900 border border-gray-700 rounded px-2 py-1 text-xs text-gray-200 placeholder-gray-600 focus:outline-none focus:border-blue-500`}),(0,z.jsx)(`datalist`,{id:`conversation-tags`,children:t.tags.map(e=>(0,z.jsx)(`option`,{value:e.value},e.value))}),(0,z.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1 max-h-20 overflow-auto`,children:t.tags.slice(0,12).map(t=>(0,z.jsxs)(`button`,{onClick:()=>n(`tag`,e.tag===t.value?void 0:t.value),className:`rounded px-1.5 py-0.5 text-[10px] transition-colors ${e.tag===t.value?`bg-blue-900 text-blue-100`:`bg-gray-900 text-gray-400 hover:text-gray-200`}`,title:t.value,children:[t.value,`: `,t.count]},t.value))})]}),(0,z.jsxs)(`div`,{className:`mb-4`,children:[(0,z.jsx)(`label`,{className:`text-xs text-gray-400 block mb-1`,children:`Tool`}),(0,z.jsx)(`input`,{type:`text`,list:`conversation-tools`,value:e.tool??``,onChange:e=>n(`tool`,e.target.value||void 0),placeholder:`e.g. Read`,className:`w-full bg-gray-900 border border-gray-700 rounded px-2 py-1 text-xs text-gray-200 placeholder-gray-600 focus:outline-none focus:border-blue-500`}),(0,z.jsx)(`datalist`,{id:`conversation-tools`,children:t.tools.map(e=>(0,z.jsx)(`option`,{value:e.value},e.value))}),(0,z.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1 max-h-20 overflow-auto`,children:t.tools.slice(0,12).map(t=>(0,z.jsxs)(`button`,{onClick:()=>n(`tool`,e.tool===t.value?void 0:t.value),className:`rounded px-1.5 py-0.5 text-[10px] transition-colors ${e.tool===t.value?`bg-blue-900 text-blue-100`:`bg-gray-900 text-gray-400 hover:text-gray-200`}`,title:t.value,children:[t.value,`: `,t.count]},t.value))})]}),(0,z.jsxs)(`div`,{className:`mb-4`,children:[(0,z.jsx)(`label`,{className:`text-xs text-gray-400 block mb-1`,children:`File touched`}),(0,z.jsx)(`input`,{type:`text`,list:`conversation-files`,value:e.file??``,onChange:e=>n(`file`,e.target.value||void 0),placeholder:`e.g. src/index.ts`,className:`w-full bg-gray-900 border border-gray-700 rounded px-2 py-1 text-xs text-gray-200 placeholder-gray-600 focus:outline-none focus:border-blue-500`}),(0,z.jsx)(`datalist`,{id:`conversation-files`,children:t.files.map(e=>(0,z.jsx)(`option`,{value:e.value},e.value))}),(0,z.jsx)(`div`,{className:`mt-2 space-y-1 max-h-24 overflow-auto`,children:t.files.slice(0,8).map(t=>(0,z.jsxs)(`button`,{onClick:()=>n(`file`,e.file===t.value?void 0:t.value),className:`w-full truncate rounded px-1.5 py-0.5 text-left text-[10px] transition-colors ${e.file===t.value?`bg-blue-900 text-blue-100`:`bg-gray-900 text-gray-400 hover:text-gray-200`}`,title:t.value,children:[t.count,` · `,t.value]},t.value))})]}),(0,z.jsxs)(`div`,{className:`mb-4`,children:[(0,z.jsx)(`div`,{className:`text-xs text-gray-400 block mb-1`,children:`Workspace cost`}),(0,z.jsx)(`div`,{className:`space-y-1 max-h-24 overflow-auto`,children:t.workspaces.slice(0,8).map(e=>(0,z.jsxs)(`button`,{onClick:()=>n(`workspace`,e.value),className:`w-full text-left text-[10px] text-gray-500 hover:text-gray-300 truncate`,title:e.value,children:[e.count,` · $`,(e.cost??0).toFixed(4),` · `,e.value]},e.value))})]}),(0,z.jsxs)(`div`,{className:`mb-4`,children:[(0,z.jsx)(`div`,{className:`text-xs text-gray-400 block mb-1`,children:`Cost ranges`}),(0,z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.costRanges.map(t=>(0,z.jsxs)(`button`,{onClick:()=>{let r=e.minCost===t.minCost&&e.maxCost===t.maxCost;n(`minCost`,r?void 0:t.minCost),n(`maxCost`,r?void 0:t.maxCost)},className:`rounded px-1.5 py-0.5 text-[10px] transition-colors ${e.minCost===t.minCost&&e.maxCost===t.maxCost?`bg-blue-900 text-blue-100`:`bg-gray-900 text-gray-400 hover:text-gray-200`}`,title:`Estimated total $${(t.cost??0).toFixed(4)}`,children:[t.label??t.value,`: `,t.count]},t.value))})]}),(0,z.jsxs)(`div`,{className:`mb-4`,children:[(0,z.jsx)(`div`,{className:`text-xs text-gray-400 block mb-1`,children:`Enrichment levels`}),(0,z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.enrichmentLevels.map(t=>(0,z.jsxs)(`button`,{onClick:()=>n(`enrichmentLevel`,e.enrichmentLevel===t.value?void 0:t.value),className:`rounded px-1.5 py-0.5 text-[10px] transition-colors ${e.enrichmentLevel===t.value?`bg-blue-900 text-blue-100`:`bg-gray-900 text-gray-400 hover:text-gray-200`}`,children:[`L`,t.value,`: `,t.count]},t.value))})]}),(0,z.jsxs)(`div`,{className:`mb-4 grid grid-cols-2 gap-2`,children:[(0,z.jsxs)(`label`,{className:`text-xs text-gray-400 block`,children:[`Min cost`,(0,z.jsx)(`input`,{type:`number`,step:`0.001`,value:e.minCost??``,onChange:e=>n(`minCost`,e.target.value||void 0),className:`mt-1 w-full bg-gray-900 border border-gray-700 rounded px-2 py-1 text-xs text-gray-200 focus:outline-none focus:border-blue-500`})]}),(0,z.jsxs)(`label`,{className:`text-xs text-gray-400 block`,children:[`Max cost`,(0,z.jsx)(`input`,{type:`number`,step:`0.001`,value:e.maxCost??``,onChange:e=>n(`maxCost`,e.target.value||void 0),className:`mt-1 w-full bg-gray-900 border border-gray-700 rounded px-2 py-1 text-xs text-gray-200 focus:outline-none focus:border-blue-500`})]})]}),(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:e.managed===!0,onChange:e=>n(`managed`,e.target.checked?!0:void 0),className:`rounded border-gray-600 bg-gray-800 text-blue-500 focus:ring-0`}),(0,z.jsx)(`span`,{className:`text-xs text-gray-400`,children:`Overdeck-managed`})]}),(0,z.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:e.enriched===!0,onChange:e=>n(`enriched`,e.target.checked?!0:void 0),className:`rounded border-gray-600 bg-gray-800 text-blue-500 focus:ring-0`}),(0,z.jsx)(`span`,{className:`text-xs text-gray-400`,children:`Enriched only`})]})]}),Object.values(e).some(Boolean)&&(0,z.jsx)(`button`,{onClick:()=>{n(`since`,void 0),n(`workspace`,void 0),n(`managed`,void 0),n(`enriched`,void 0),n(`model`,void 0),n(`tag`,void 0),n(`tool`,void 0),n(`file`,void 0),n(`minCost`,void 0),n(`maxCost`,void 0),n(`enrichmentLevel`,void 0)},className:`mt-4 text-[10px] text-gray-600 hover:text-gray-400 transition-colors`,children:`Clear filters`})]})}function y9(e,t){let n=new Map;return e.forEach((e,r)=>{if(!e)return;let i=n.get(e)??{value:e,count:0,cost:0};i.count+=1,i.cost=(i.cost??0)+(t?.[r]??0),n.set(e,i)}),[...n.values()].sort((e,t)=>t.count-e.count||e.value.localeCompare(t.value))}function uOt(e){let t=Date.now();return[{value:`today`,label:`Today`,days:1},{value:`7d`,label:`Last 7 days`,days:7},{value:`30d`,label:`Last 30 days`,days:30},{value:`90d`,label:`Last 90 days`,days:90}].map(n=>{let r=t-n.days*864e5,i=e.filter(e=>{let t=e.lastTs?Date.parse(e.lastTs):NaN;return Number.isFinite(t)&&t>=r}).length;return{value:n.value,label:n.label,count:i}})}function dOt(e){return`${e.source}-${e.id}`}function fOt(e,t){let n=e.lastTs?Date.parse(e.lastTs):0;return(t.lastTs?Date.parse(t.lastTs):0)-n}function pOt(e){return[{value:`free`,label:`$0`,minCost:void 0,maxCost:`0`},{value:`low`,label:`$0–$0.01`,minCost:`0`,maxCost:`0.01`},{value:`medium`,label:`$0.01–$0.05`,minCost:`0.01`,maxCost:`0.05`},{value:`high`,label:`$0.05+`,minCost:`0.05`,maxCost:void 0}].map(t=>{let n=t.minCost===void 0?void 0:Number(t.minCost),r=t.maxCost===void 0?void 0:Number(t.maxCost),i=e.filter(e=>{let t=e.estimatedCost;return(n===void 0||t>=n)&&(r===void 0||t<=r)});return{value:t.value,label:t.label,count:i.length,cost:i.reduce((e,t)=>e+t.estimatedCost,0),minCost:t.minCost,maxCost:t.maxCost}})}function mOt(e){let t=new URLSearchParams;return e.workspace&&t.set(`workspacePath`,e.workspace),e.since&&t.set(`since`,e.since),e.managed&&t.set(`managed`,`true`),e.enriched&&t.set(`enriched`,`true`),e.model&&t.set(`primaryModel`,e.model),e.tag&&t.set(`tag`,e.tag),e.tool&&t.set(`tool`,e.tool),e.file&&t.set(`file`,e.file),e.minCost&&t.set(`minCost`,e.minCost),e.maxCost&&t.set(`maxCost`,e.maxCost),e.enrichmentLevel&&t.set(`enrichmentLevel`,e.enrichmentLevel),t}function b9(e){let t={},n=e.get(`workspacePath`),r=e.get(`primaryModel`),i=e.get(`since`),a=e.get(`managed`),o=e.get(`enriched`),s=e.get(`tag`),c=e.get(`tool`),l=e.get(`file`),u=e.get(`minCost`),d=e.get(`maxCost`),f=e.get(`enrichmentLevel`);return n&&(t.workspacePath=n),r&&(t.primaryModel=r),i&&(t.since=i),a&&(t.managed=a===`true`),o&&(t.enriched=o===`true`),s&&(t.tags=[s]),c&&(t.tools=[c]),l&&(t.files=[l]),u&&Number.isFinite(Number(u))&&(t.minCost=Number(u)),d&&Number.isFinite(Number(d))&&(t.maxCost=Number(d)),f&&Number.isFinite(Number(f))&&(t.enrichmentLevel=Number(f)),t}function hOt(e){return{id:e.id,source:`discovered`,jsonlPath:e.jsonlPath,workspacePath:e.workspacePath??null,primaryModel:e.primaryModel??null,messageCount:e.messageCount,firstTs:e.firstTs??null,lastTs:e.lastTs??null,estimatedCost:e.estimatedCost,tokenInput:e.tokenInput,tokenOutput:e.tokenOutput,toolsUsed:[...e.toolsUsed],filesTouched:[...e.filesTouched],tags:[...e.tags],summary:e.summary??null,enrichmentLevel:e.enrichmentLevel,enrichmentFailed:e.enrichmentFailed,overdeckManaged:e.overdeckManaged,panIssueId:e.panIssueId??null}}async function gOt(e){let t=await hj().request(t=>t[Pp.listDiscoveredSessions]({...b9(e),limit:Number(e.get(`limit`)??50),offset:Number(e.get(`offset`)??0)}));return{...t,sessions:t.sessions.map(hOt)}}async function _Ot(e){let t=e.toString(),n=await fetch(`/api/conversations/archived${t?`?${t}`:``}`);if(!n.ok)throw Error(`Failed to load archived conversations: ${n.status}`);return await n.json()}async function vOt(e,t,n=50,r=0,i=!1){let a=await hj().request(a=>a[Pp.searchConversations]({...b9(t),query:e,semantic:i,limit:n,offset:r}));return{...a,sessions:a.sessions.map(hOt)}}async function yOt(){let e=await hj().request(e=>e[Pp.getConversationStats]({}));return{...e,embeddingModels:e.embeddingModels?.map(e=>({...e}))}}async function bOt(e){return hj().request(t=>t[Pp.getConversationCost](b9(e)))}async function xOt(e){return hj().request(t=>t[Pp.getConversationCostByWorkspace](b9(e)))}async function SOt(){return hj().request(e=>e[Pp.scanConversations]({mode:`system`}))}function COt(){let e=_t(),t=sm(Phe),[n,r]=(0,R.useState)(``),[i,a]=(0,R.useState)(null),[o,s]=(0,R.useState)(!1),[c,l]=(0,R.useState)(0),[u,d]=(0,R.useState)(!1),[f,p]=(0,R.useState)({}),m=f.source??`all`,h=n.trim(),[g,_]=(0,R.useState)(h),v=m!==`managed-archived`,y=v?u?g:h:``,b=mOt(f);(0,R.useEffect)(()=>{if(!u){_(h);return}let e=window.setTimeout(()=>_(h),350);return()=>window.clearTimeout(e)},[u,h]);let x=new URLSearchParams({limit:`50`}),S=new URLSearchParams({limit:`50`});for(let[e,t]of b)x.set(e,t),S.set(e,t);let{data:C,isLoading:w}=B({queryKey:[`discovered-sessions`,x.toString()],queryFn:()=>gOt(x),enabled:!y&&m!==`managed-archived`}),{data:T=[],isLoading:E}=B({queryKey:[`archived-conversations`,S.toString()],queryFn:()=>_Ot(S),enabled:!y&&m!==`discovered`}),{data:D,isLoading:O}=B({queryKey:[`discovered-sessions-search`,y,b.toString(),c,u],queryFn:()=>vOt(y,b,50,c,u),enabled:!!y}),{data:k}=B({queryKey:[`discovered-sessions-stats`],queryFn:yOt,staleTime:3e4}),{data:A}=B({queryKey:[`discovered-sessions-cost`,b.toString()],queryFn:()=>bOt(b),staleTime:3e4}),{data:j}=B({queryKey:[`discovered-sessions-cost-workspace`,b.toString()],queryFn:()=>xOt(b),staleTime:3e4}),M=Nt({mutationFn:SOt,onSuccess:()=>{e.invalidateQueries({queryKey:[`discovered-sessions`]}),e.invalidateQueries({queryKey:[`discovered-sessions-stats`]})}}),N=y?O:m===`all`?w||E:m===`managed-archived`?E:w,P=C?.sessions??[],F=y?D?.sessions??[]:m===`managed-archived`?T:m===`discovered`?P:[...P,...T].sort(fOt),I=i==null?null:F.find(e=>dOt(e)===i)??null,ee=j?.entries??[],te={models:y9(F.map(e=>e.primaryModel)),workspaces:ee.length>0?ee.map(e=>({value:e.key,count:e.sessionCount,cost:e.totalCost})):y9(F.map(e=>e.workspacePath),F.map(e=>e.estimatedCost)),tags:y9(F.flatMap(e=>e.tags)),tools:y9(F.flatMap(e=>e.toolsUsed)),files:y9(F.flatMap(e=>e.filesTouched)),timeRanges:uOt(F),costRanges:pOt(F),enrichmentLevels:y9(F.map(e=>String(e.enrichmentLevel)))},ne=[m===`all`?null:{key:`source`,label:`Source: ${m===`discovered`?`Discovered`:`Managed-archived`}`},f.workspace?{key:`workspace`,label:`Workspace: ${f.workspace}`}:null,f.model?{key:`model`,label:`Model: ${f.model}`}:null,f.tag?{key:`tag`,label:`Tag: ${f.tag}`}:null,f.tool?{key:`tool`,label:`Tool: ${f.tool}`}:null,f.file?{key:`file`,label:`File: ${f.file}`}:null,f.since?{key:`since`,label:`Since: ${f.since}`}:null,f.managed?{key:`managed`,label:`Managed`}:null,f.enriched?{key:`enriched`,label:`Enriched`}:null,f.minCost?{key:`minCost`,label:`Min cost: $${f.minCost}`}:null,f.maxCost?{key:`maxCost`,label:`Max cost: $${f.maxCost}`}:null,f.enrichmentLevel?{key:`enrichmentLevel`,label:`Enrichment: L${f.enrichmentLevel}`}:null].filter(e=>e!==null),L=(0,R.useCallback)(e=>{r(e),l(0)},[]),re=(0,R.useCallback)((e,t)=>{p(n=>({...n,[e]:t})),l(0)},[]);return(0,z.jsxs)(`div`,{className:`flex flex-col h-full bg-gray-950 text-gray-100`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3 border-b border-gray-800 shrink-0`,children:[(0,z.jsx)(`h1`,{className:`text-lg font-semibold text-white`,children:`Session History`}),k&&(0,z.jsxs)(`div`,{className:`flex items-center gap-4 text-xs text-gray-400 ml-2`,children:[(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`span`,{className:`text-white font-mono`,children:k.total}),` indexed`]}),(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`span`,{className:`text-green-400 font-mono`,children:k.enriched}),` enriched`]}),(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`span`,{className:`text-blue-400 font-mono`,children:k.managedCount}),` managed`]}),(0,z.jsxs)(`span`,{children:[(0,z.jsxs)(`span`,{className:`text-amber-300 font-mono`,children:[`$`,(A?.totalCost??0).toFixed(4)]}),` est. cost`]}),ee.length>0&&(0,z.jsxs)(`span`,{"data-testid":`workspace-cost-breakdown`,className:`text-gray-500`,children:[`Workspace costs:`,` `,ee.slice(0,3).map(e=>(0,z.jsxs)(`span`,{className:`mr-2`,children:[(0,z.jsx)(`span`,{className:`text-gray-300`,children:e.key}),` `,(0,z.jsxs)(`span`,{className:`text-amber-300 font-mono`,children:[`$`,e.totalCost.toFixed(4)]})]},e.key))]})]}),(0,z.jsx)(`div`,{className:`flex-1`}),v&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`relative w-72`,children:[(0,z.jsx)(wr,{className:`absolute left-2.5 top-2 h-3.5 w-3.5 text-gray-500`}),(0,z.jsx)(`input`,{type:`text`,placeholder:`Search sessions…`,value:n,onChange:e=>L(e.target.value),className:`w-full bg-gray-900 border border-gray-700 rounded pl-8 pr-3 py-1.5 text-sm text-gray-100 placeholder-gray-500 focus:outline-none focus:border-blue-500`})]}),(0,z.jsx)(`button`,{onClick:()=>{d(e=>!e),l(0)},className:`px-3 py-1.5 rounded text-xs border transition-colors ${u?`bg-purple-900 border-purple-600 text-purple-200`:`bg-gray-900 border-gray-700 text-gray-400 hover:border-gray-500`}`,children:u?`Semantic`:`Keyword`})]}),(0,z.jsxs)(`button`,{onClick:()=>s(e=>!e),className:`flex items-center gap-1.5 px-3 py-1.5 rounded text-xs border transition-colors ${o?`bg-blue-900 border-blue-600 text-blue-200`:`bg-gray-900 border-gray-700 text-gray-400 hover:border-gray-500`}`,children:[(0,z.jsx)(Nn,{className:`h-3.5 w-3.5`}),`Filters`]}),(0,z.jsx)(oOt,{isScanning:M.isPending,onScan:()=>M.mutate(),lastResult:M.data,progress:t})]}),ne.length>0&&(0,z.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-2 border-b border-gray-800 bg-gray-950 shrink-0 text-xs`,children:[(0,z.jsx)(`span`,{className:`text-gray-500`,children:`Active filters`}),ne.map(e=>(0,z.jsxs)(`button`,{onClick:()=>{re(e.key,void 0),e.key===`minCost`&&re(`maxCost`,void 0),e.key===`maxCost`&&re(`minCost`,void 0)},className:`px-2 py-1 rounded-full bg-blue-950 text-blue-200 border border-blue-800 hover:bg-blue-900 transition-colors`,children:[e.label,` `,(0,z.jsx)(`span`,{className:`text-blue-400`,children:`×`})]},e.key)),(0,z.jsx)(`button`,{onClick:()=>p({}),className:`text-gray-500 hover:text-gray-300 transition-colors`,children:`Clear all`})]}),(0,z.jsxs)(`div`,{className:`flex flex-1 min-h-0 overflow-hidden`,children:[o&&(0,z.jsx)(lOt,{filters:f,facets:te,onChange:re}),(0,z.jsxs)(`div`,{className:`flex flex-col flex-1 min-w-0 overflow-hidden ${I?`border-r border-gray-800`:``}`,children:[v&&D?.error&&(0,z.jsxs)(`div`,{className:`px-4 py-2 border-b border-amber-900 bg-amber-950/40 text-amber-200 text-xs`,children:[`Semantic search unavailable: `,D.error]}),N?(0,z.jsx)(`div`,{className:`flex items-center justify-center h-32 text-gray-500 text-sm`,children:`Loading sessions…`}):F.length===0?(0,z.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-32 text-gray-500 gap-2`,children:[(0,z.jsx)(`span`,{className:`text-sm`,children:`No sessions found`}),!k?.total&&(0,z.jsx)(`span`,{className:`text-xs`,children:`Run a scan to discover Claude Code sessions`})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(ZDt,{sessions:F,selectedId:i,onSelect:a}),y&&D&&D.total>50&&(0,z.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 border-t border-gray-800 shrink-0 text-xs text-gray-400`,children:[(0,z.jsxs)(`span`,{children:[c+1,`–`,c+F.length,` of `,D.total,` results`]}),(0,z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,z.jsx)(`button`,{disabled:c===0,onClick:()=>l(e=>Math.max(0,e-50)),className:`px-2 py-1 rounded bg-gray-800 hover:bg-gray-700 disabled:opacity-40 disabled:cursor-not-allowed transition-colors`,children:`Prev`}),(0,z.jsx)(`button`,{disabled:c+50>=D.total,onClick:()=>l(e=>e+50),className:`px-2 py-1 rounded bg-gray-800 hover:bg-gray-700 disabled:opacity-40 disabled:cursor-not-allowed transition-colors`,children:`Next`})]})]})]})]}),I&&(0,z.jsx)(`div`,{className:`w-96 shrink-0 overflow-auto`,children:(0,z.jsx)(aOt,{session:I,onClose:()=>a(null)})})]})]})}function wOt(e){return e===`warming`?(0,z.jsx)(ar,{className:`h-4 w-4 animate-spin text-primary`}):e===`ready`?(0,z.jsx)(sn,{className:`h-4 w-4 text-green-500`}):e===`failed`?(0,z.jsx)(an,{className:`h-4 w-4 text-destructive`}):(0,z.jsx)(dn,{className:`h-4 w-4 text-muted-foreground`})}function TOt({mode:e,warmupStatus:t,isListening:n,onStart:r,onBackToStaging:i,onReset:a,onToggleMic:o,voiceError:s}){return(0,z.jsxs)(`section`,{className:`rounded-xl border border-border bg-card p-4 shadow-sm`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-widest text-muted-foreground`,children:`AutoPreso`}),(0,z.jsx)(`h2`,{className:`mt-1 text-lg font-semibold`,children:`Voice whiteboard`})]}),(0,z.jsx)(`span`,{className:`rounded-full bg-muted px-2.5 py-1 text-xs font-medium capitalize text-muted-foreground`,children:e})]}),(0,z.jsxs)(`div`,{className:`mt-4 grid grid-cols-2 gap-2`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:o,className:`rounded-lg px-3 py-2 text-sm font-semibold transition-colors ${n?`bg-destructive text-destructive-foreground`:`bg-primary text-primary-foreground`}`,children:n?`Stop mic`:`Start mic`}),(0,z.jsx)(`button`,{type:`button`,onClick:e===`staging`?r:i,className:`rounded-lg border border-border bg-background px-3 py-2 text-sm font-semibold text-foreground hover:bg-accent`,children:e===`staging`?`Go live`:`Back to staging`})]}),(0,z.jsxs)(`div`,{className:`mt-4 rounded-lg bg-muted/40 p-3 text-sm`,children:[(0,z.jsxs)(`p`,{className:`flex items-center gap-2 font-medium text-foreground`,children:[wOt(t),`Warmup: `,(0,z.jsx)(`span`,{className:`capitalize`,children:t})]}),(0,z.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`The whiteboard agent uses the staged canvas as context before live transcription starts.`})]}),s&&(0,z.jsx)(`div`,{className:`mt-4 rounded-lg border border-destructive/30 bg-destructive/10 p-3 text-sm text-destructive`,children:s}),(0,z.jsx)(`button`,{type:`button`,onClick:a,className:`mt-3 w-full rounded-lg border border-border bg-background px-3 py-2 text-sm font-semibold text-muted-foreground hover:bg-accent hover:text-foreground`,children:`Reset session`})]})}function EOt({partialText:e,turns:t}){let n=(0,R.useRef)(null);return(0,R.useEffect)(()=>{n.current?.scrollIntoView({block:`end`})},[e,t]),(0,z.jsxs)(`section`,{className:`min-h-0 flex-1 rounded-xl border border-border bg-card p-4 shadow-sm`,children:[(0,z.jsx)(`h2`,{className:`text-sm font-semibold uppercase tracking-widest text-muted-foreground`,children:`Transcript`}),(0,z.jsxs)(`div`,{className:`mt-3 max-h-64 space-y-2 overflow-y-auto pr-1 text-sm`,children:[t.length===0&&!e&&(0,z.jsx)(`p`,{className:`text-muted-foreground`,children:`Spoken turns will appear here while AutoPreso listens.`}),t.map((e,t)=>(0,z.jsxs)(`article`,{className:`rounded-lg bg-muted/40 p-2 text-foreground`,children:[(0,z.jsx)(`time`,{className:`mb-1 block text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:e.timestamp.toLocaleTimeString()}),(0,z.jsx)(`p`,{children:e.text})]},`${e.timestamp.toISOString()}-${t}`)),e&&(0,z.jsx)(`p`,{className:`rounded-lg border border-dashed border-border p-2 italic text-muted-foreground`,children:e}),(0,z.jsx)(`div`,{ref:n})]})]})}var DOt=25e4,OOt=6e3,kOt=200;function AOt(e){return`${window.location.protocol===`https:`?`wss:`:`ws:`}//${window.location.host}${e}`}function jOt(){let[e,t]=(0,R.useState)([]),[n,r]=(0,R.useState)(`staging`),[i,a]=(0,R.useState)(`idle`),[o,s]=(0,R.useState)(``),[c,l]=(0,R.useState)([]),[u,d]=(0,R.useState)(!1),[f,p]=(0,R.useState)(null),[m,h]=(0,R.useState)(null),g=(0,R.useRef)(null),_=(0,R.useRef)(null),v=(0,R.useRef)(null),y=(0,R.useRef)(0),b=(0,R.useRef)(!0),x=(0,R.useRef)(null),S=(0,R.useRef)(null),C=(0,R.useRef)(null),w=(0,R.useRef)(null),T=(0,R.useRef)(null),E=(0,R.useRef)(null),D=(0,R.useCallback)(()=>{g.current?.close();let e=new WebSocket(AOt(`/ws/autopreso`));g.current=e,e.onopen=()=>{y.current=0},e.onmessage=e=>{let n=JSON.parse(String(e.data));(n.type===`whiteboard:snapshot`||n.type===`whiteboard:update`)&&(n.elements&&t(n.elements),n.mode&&r(n.mode),n.warmupStatus&&a(n.warmupStatus))},e.onclose=()=>{if(!b.current||g.current!==e)return;let t=Math.min(1e3*2**y.current,1e4);y.current+=1,v.current=window.setTimeout(D,t)}},[]),O=(0,R.useCallback)(e=>{d(!1),e&&_.current?.close(),e&&(_.current=null),C.current?.disconnect(),w.current?.disconnect(),T.current?.disconnect(),S.current?.close(),x.current?.getTracks().forEach(e=>e.stop()),C.current=null,w.current=null,T.current=null,S.current=null,x.current=null,h(null)},[]),k=(0,R.useCallback)(async(e=!0)=>{let t=_.current;O(!1),e&&t?.readyState===WebSocket.OPEN&&(t.send(JSON.stringify({type:`stop`})),await new Promise(e=>{let t=window.setTimeout(e,OOt);E.current=()=>{window.clearTimeout(t),e()}}),E.current=null),O(!0)},[O]);return(0,R.useEffect)(()=>(b.current=!0,D(),()=>{b.current=!1,v.current&&window.clearTimeout(v.current),v.current=null;let e=g.current;g.current=null,e?.close(),k(!1)}),[D,k]),{elements:e,mode:n,warmupStatus:i,partialText:o,committedTurns:c,isListening:u,voiceError:f,startListening:(0,R.useCallback)(async()=>{if(u)return;p(null);let e=null,t=null,n=null,r=null,i=null,a=null;try{e=await navigator.mediaDevices.getUserMedia({audio:!0});let o=window.AudioContext;t=new o({sampleRate:24e3}),n=t.createMediaStreamSource(e),r=t.createAnalyser(),i=t.createScriptProcessor(4096,1,1),a=new WebSocket(AOt(`/ws/voice`)),a.binaryType=`arraybuffer`,a.onmessage=e=>{let t=JSON.parse(String(e.data));t.type===`transcript:partial`&&s(t.text),t.type===`transcript:committed`&&(s(``),l(e=>[...e,{text:t.text,timestamp:new Date}].slice(-kOt))),t.type===`transcript:finalized`&&E.current?.(),t.type===`error`&&p(t.error)},a.onclose=()=>{_.current===a&&k(!1)},i.onaudioprocess=e=>{if(a?.readyState!==WebSocket.OPEN||a.bufferedAmount>DOt)return;let t=e.inputBuffer.getChannelData(0),n=new Int16Array(t.length);for(let e=0;e<t.length;e+=1){let r=Math.max(-1,Math.min(1,t[e]??0));n[e]=r<0?r*32768:r*32767}a.send(n.buffer)},n.connect(r),r.connect(i),i.connect(t.destination),x.current=e,S.current=t,w.current=n,T.current=r,C.current=i,_.current=a,h(r),d(!0)}catch(o){a?.close(),i?.disconnect(),n?.disconnect(),r?.disconnect(),t?.close(),e?.getTracks().forEach(e=>e.stop()),p(o instanceof Error?o.message:`Unable to start voice input`)}},[u,k]),stopListening:k,analyserNode:m}}var MOt=(0,R.lazy)(async()=>({default:(await L(()=>import(`./prod-CnNbvojd.js`),__vite__mapDeps([109,2,3,110,111,112,6,113,114,5]))).Excalidraw}));function NOt(){let{elements:e,mode:t,warmupStatus:n,partialText:r,committedTurns:i,isListening:a,voiceError:o,startListening:s,stopListening:c}=jOt(),[l,u]=(0,R.useState)([]),d=(0,R.useRef)(null),f=t===`live`?e:l,p=(0,R.useMemo)(()=>({elements:f}),[f]),m=(0,R.useCallback)(async()=>{await fetch(`/api/autopreso/start`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({elements:l,screenshotBase64:null})})},[l]),h=(0,R.useCallback)(async()=>{await fetch(`/api/autopreso/back-to-staging`,{method:`POST`})},[]),g=(0,R.useCallback)(async()=>{await fetch(`/api/autopreso/session/reset`,{method:`POST`}),u([]),d.current?.updateScene?.({elements:[]})},[]),_=(0,R.useCallback)(()=>{a?c():s()},[a,s,c]),v=(0,R.useCallback)(e=>{t===`staging`&&u(e)},[t]),y=(0,R.useCallback)(e=>{d.current=e},[]);return(0,R.useEffect)(()=>{t===`live`&&d.current?.updateScene?.({elements:e})},[t,e]),(0,z.jsxs)(`div`,{className:`flex h-full w-full gap-4 overflow-hidden bg-background p-4 text-foreground`,children:[(0,z.jsx)(`div`,{className:`min-w-0 flex-1 overflow-hidden rounded-xl border border-border bg-card shadow-sm`,children:(0,z.jsx)(R.Suspense,{fallback:(0,z.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`Loading whiteboard…`}),children:(0,z.jsx)(MOt,{excalidrawAPI:y,initialData:p,onChange:v,viewModeEnabled:t===`live`},t)})}),(0,z.jsxs)(`aside`,{className:`flex w-96 shrink-0 flex-col gap-4 overflow-y-auto`,children:[(0,z.jsx)(TOt,{mode:t,warmupStatus:n,isListening:a,onStart:m,onBackToStaging:h,onReset:g,onToggleMic:_,voiceError:o}),(0,z.jsx)(EOt,{turns:i,partialText:r})]})]})}var x9=`flywheel-orchestrator`,POt={harness:`claude-code`,model:`claude-opus-4-8`,effort:`high`,maxAgents:8,scope:`pan-only`};async function S9(e){let t=await fetch(e);if(!t.ok)throw Error(`Request failed (${t.status})`);return t.json()}async function FOt(){let e=await fetch(`/api/flywheel/conversation`);if(!e.ok)throw Error(`Request failed (${e.status})`);return e.json()}async function C9(e,t){let n=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:t===void 0?void 0:JSON.stringify(t)}),r=await n.json().catch(()=>({}));if(!n.ok){let e=typeof r?.error==`string`?r.error:`Request failed (${n.status})`;throw Error(e)}return r}function IOt(e){return typeof e==`number`&&Number.isFinite(e)?`${Math.round(e)}%`:`—`}function LOt(e){return e===`pan-only`?`PAN only`:e===`all-tracked-projects`?`All tracked projects`:e}function ROt(e){return{...POt,...e?.roles?.flywheel??{}}}function zOt({onOpenSettings:e}){let[t,n]=(0,R.useState)(`conversation`),[r,i]=(0,R.useState)(!1),a=typeof window<`u`&&window.location.pathname===`/popout/flywheel-conversation`,o=_t(),s=B({queryKey:[`flywheel-runs`],queryFn:()=>S9(`/api/flywheel/runs?limit=10`),refetchInterval:5e3}),c=s.data?.[0]??null,l=B({queryKey:[`flywheel-run-detail`,c?.id],queryFn:()=>S9(`/api/flywheel/runs/${encodeURIComponent(c.id)}`),enabled:!!c?.id,refetchInterval:c?.status===`running`?5e3:!1}),u=B({queryKey:[`conversation`,x9],queryFn:FOt,refetchInterval:5e3}),d=B({queryKey:[`settings`],queryFn:()=>S9(`/api/settings`),staleTime:3e4}),f=l.data??null,p=f?.status===`running`?f:null,m=f?.status===`running`||f?.status===`paused`?f.latest:null,h=u.data??null,g=ROt(d.data),_=f?.status===`running`?`running`:f?.status===`paused`?`paused`:`none`,v=Hr(),y=async()=>{await Promise.all([o.invalidateQueries({queryKey:[`flywheel-runs`]}),o.invalidateQueries({queryKey:[`flywheel-run-detail`]}),o.invalidateQueries({queryKey:[`conversation`,x9]})])},b=Nt({mutationFn:()=>C9(`/api/flywheel/start`),onSuccess:async()=>{H.success(`Flywheel started`),await y()},onError:e=>H.error(`Failed to start Flywheel: ${e.message}`)}),x=Nt({mutationFn:()=>C9(`/api/flywheel/pause`),onSuccess:async()=>{H.success(`Flywheel paused`),await y()},onError:e=>H.error(`Failed to pause Flywheel: ${e.message}`)}),S=Nt({mutationFn:()=>C9(`/api/flywheel/resume`),onSuccess:async()=>{H.success(`Flywheel resumed`),await y()},onError:e=>H.error(`Failed to resume Flywheel: ${e.message}`)}),C=Nt({mutationFn:async()=>(_===`paused`&&await C9(`/api/flywheel/report`),C9(`/api/flywheel/start`)),onSuccess:async()=>{H.success(`Flywheel started`),await y()},onError:e=>H.error(`Failed to start Flywheel: ${e.message}`)}),w=Nt({mutationFn:()=>C9(`/api/flywheel/report/open`,{runId:f?.id}),onError:e=>H.error(`Failed to open run report: ${e.message}`)}),T=Nt({mutationFn:()=>C9(`/api/flywheel/report`),onSuccess:async()=>{H.success(`Flywheel run reported`),await y()},onError:e=>H.error(`Failed to report Flywheel run: ${e.message}`)}),E=Nt({mutationFn:()=>C9(`/api/flywheel/abort`),onSuccess:async()=>{H.success(`Flywheel run aborted`),await y()},onError:e=>H.error(`Failed to abort Flywheel: ${e.message}`)}),D=async()=>{await v({title:`Abort Flywheel Run`,message:`${f?.id??`The active run`} will be discarded without a report. Continue?`,confirmLabel:`Abort Run`,variant:`destructive`})&&E.mutate()},O=async()=>{await v({title:`Finalize Run Report`,message:`Write the report for ${f?.id??`the active run`} and close it out. The orchestrator session must be paused or stopped first; if it is alive, this will fail.`,confirmLabel:`Write Report`,variant:`default`})&&T.mutate()},k=async()=>{if(_===`paused`){if(!await v({title:`Start New Run`,message:`${f?.id??`The current run`} is paused. Reporting it will close the run and start a fresh one. Continue?`,confirmLabel:`Report & Start New`,variant:`destructive`}))return}else if(_===`running`&&!await v({title:`Start New Run`,message:`${f?.id??`The current run`} is RUNNING. Starting a new run will abort the active orchestrator session and discard its in-flight work. Continue?`,confirmLabel:`Abort & Start New`,variant:`destructive`}))return;C.mutate()},A=b.isPending||x.isPending||S.isPending||C.isPending||w.isPending||E.isPending||T.isPending,j=s.isLoading||l.isLoading;return(0,z.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col border-l border-border bg-background`,"aria-label":`Flywheel conversation pane`,children:[(0,z.jsx)(`header`,{className:`border-b border-border bg-card/60 px-4 py-3`,children:(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm font-semibold text-foreground`,children:[(0,z.jsx)(`span`,{children:p?.id??(f?`${f.id} (${f.status})`:`No active run`)}),j&&(0,z.jsx)(ar,{className:`h-3.5 w-3.5 animate-spin text-muted-foreground`})]}),(0,z.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-2 text-xs text-muted-foreground`,children:[(0,z.jsxs)(`span`,{children:[`Model: `,m?.orchestrator.model??g.model]}),(0,z.jsxs)(`span`,{children:[`Effort: `,m?.orchestrator.effort??g.effort]}),(0,z.jsxs)(`span`,{children:[`Context: `,IOt(m?.orchestrator.ctxPercent)]})]})]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,z.jsxs)(`div`,{className:J.viewToggle,role:`tablist`,"aria-label":`Flywheel pane view`,children:[(0,z.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":t===`conversation`,className:`${J.viewToggleBtn} ${t===`conversation`?J.viewToggleBtnActive:``}`,onClick:()=>n(`conversation`),children:`Conversation`}),(0,z.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":t===`terminal`,className:`${J.viewToggleBtn} ${t===`terminal`?J.viewToggleBtnActive:``}`,onClick:()=>n(`terminal`),title:h?`Attach to flywheel-orchestrator tmux session`:`No flywheel-orchestrator session yet`,disabled:!h,children:`Terminal`})]}),(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded-md border border-amber-500/40 bg-amber-500/10 px-2.5 py-1.5 text-xs font-semibold text-amber-500 hover:bg-amber-500/20 disabled:opacity-50`,onClick:()=>x.mutate(),disabled:A||_!==`running`,title:_===`running`?`Pause the orchestrator`:`No active run to pause`,children:[(0,z.jsx)(Eee,{className:`h-3.5 w-3.5`}),`Pause`]}),(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded-md border border-border bg-background px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-accent disabled:opacity-50`,onClick:()=>S.mutate(),disabled:A||_!==`paused`,title:_===`paused`?`Resume the orchestrator`:`Run is not paused`,children:[(0,z.jsx)(yr,{className:`h-3.5 w-3.5`}),`Resume`]}),(0,z.jsxs)(`div`,{className:`relative`,children:[(0,z.jsxs)(`button`,{type:`button`,"aria-haspopup":`menu`,"aria-expanded":r,className:`inline-flex items-center gap-1 rounded-md border border-border bg-background px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-accent`,onClick:()=>i(e=>!e),children:[(0,z.jsx)(On,{className:`h-3.5 w-3.5`}),`More`]}),r&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`fixed inset-0 z-40`,"aria-hidden":`true`,onClick:()=>i(!1)}),(0,z.jsxs)(`div`,{role:`menu`,"aria-label":`More flywheel actions`,className:`absolute right-0 top-full z-50 mt-1 w-48 rounded-lg border border-border bg-card p-1 shadow-lg`,children:[(0,z.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-md px-2.5 py-1.5 text-left text-xs font-medium text-foreground hover:bg-accent disabled:opacity-50`,onClick:()=>{i(!1),k()},disabled:A,title:_===`running`?`Abort the active run and start a new one`:_===`paused`?`Report the paused run and start a new one`:`Start a new Flywheel run`,children:[(0,z.jsx)(gr,{className:`h-3.5 w-3.5`}),`New Run`]}),(0,z.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-md px-2.5 py-1.5 text-left text-xs font-medium text-foreground hover:bg-accent disabled:opacity-50`,onClick:()=>{i(!1),O()},disabled:A||_===`none`,title:_===`none`?`No active run to report`:`Finalize the run report and close out (orchestrator must be paused/stopped)`,children:[(0,z.jsx)(Mn,{className:`h-3.5 w-3.5`}),`Write Report`]}),(0,z.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-md px-2.5 py-1.5 text-left text-xs font-medium text-foreground hover:bg-accent disabled:opacity-50`,onClick:()=>{i(!1),w.mutate()},disabled:A||!f?.paths.report,title:f?.paths.report??`No run report yet`,children:[(0,z.jsx)(kn,{className:`h-3.5 w-3.5`}),`Open Run Report`]}),!a&&(0,z.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-md px-2.5 py-1.5 text-left text-xs font-medium text-foreground hover:bg-accent`,onClick:()=>{i(!1),window.open(`/popout/flywheel-conversation`,`flywheel-conversation-popout`,`width=1100,height=750,menubar=no,toolbar=no,location=no,status=no`)},title:`Open this view in a separate window`,children:[(0,z.jsx)(_ee,{className:`h-3.5 w-3.5`}),`Pop out`]}),(0,z.jsxs)(`a`,{href:`/settings#roles`,className:`flex w-full items-center gap-2 rounded-md px-2.5 py-1.5 text-left text-xs font-medium text-foreground hover:bg-accent`,onClick:t=>{i(!1),e&&(t.preventDefault(),e())},children:[(0,z.jsx)(Tr,{className:`h-3.5 w-3.5`}),`Configure`]})]})]})]}),(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded-md border border-destructive/50 bg-destructive/5 px-2.5 py-1.5 text-xs font-semibold text-destructive hover:bg-destructive/15 disabled:opacity-50`,onClick:D,disabled:A||_===`none`,title:_===`none`?`No active run to abort`:`Discard this run without writing a report`,children:[(0,z.jsx)(ln,{className:`h-3.5 w-3.5`}),`Abort`]})]})]})}),(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:u.isLoading?(0,z.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,z.jsx)(ar,{className:`h-4 w-4 animate-spin`}),`Loading flywheel conversation…`]}):h?t===`terminal`?(0,z.jsx)(IS,{sessionName:x9}):(0,z.jsx)(s5,{conversation:h,embedded:!0,onEmbeddedResume:h.sessionAlive?void 0:()=>b.mutate(),embeddedResumeLabel:b.isPending?`Starting…`:`Start New Run`,onSendFailed:()=>void o.invalidateQueries({queryKey:[`conversation`,x9]})}):(0,z.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center p-8 text-center`,children:[(0,z.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`No flywheel-orchestrator session yet.`}),(0,z.jsx)(`p`,{className:`mt-1 max-w-sm text-xs text-muted-foreground`,children:`Start a run to create the singleton conversation. Once it exists, this pane reuses the standard conversation transcript and composer, and the Terminal toggle attaches to the orchestrator's tmux session.`})]})}),(0,z.jsx)(`footer`,{className:`border-t border-border bg-card/60 p-4 space-y-3`,children:(0,z.jsxs)(`button`,{type:`button`,className:`w-full rounded-lg border border-border bg-background p-3 text-left hover:bg-accent/60`,onClick:e,children:[(0,z.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,z.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:`Run config`}),(0,z.jsx)(`span`,{className:`text-xs font-medium text-primary`,children:`Settings → Roles → Flywheel`})]}),(0,z.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-4 gap-y-2 text-xs`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:`Harness`}),(0,z.jsx)(`dd`,{className:`font-medium text-foreground`,children:m?.orchestrator.harness??g.harness})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:`Model`}),(0,z.jsx)(`dd`,{className:`font-medium text-foreground`,children:g.model})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:`Effort`}),(0,z.jsx)(`dd`,{className:`font-medium text-foreground`,children:g.effort})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:`Max agents`}),(0,z.jsx)(`dd`,{className:`font-medium text-foreground`,children:g.maxAgents})]}),(0,z.jsxs)(`div`,{className:`col-span-2`,children:[(0,z.jsx)(`dt`,{className:`text-muted-foreground`,children:`Scope`}),(0,z.jsx)(`dd`,{className:`font-medium text-foreground`,children:LOt(g.scope)})]})]})]})})]})}var BOt=1e4;async function VOt(){let e=await fetch(`/api/flywheel/state`);if(!e.ok)throw Error(`Request failed (${e.status})`);return e.json()}function HOt(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?e:`${t.toLocaleDateString()} ${t.toLocaleTimeString()}`}function UOt(){let[e,t]=(0,R.useState)(null),[n,r]=(0,R.useState)(null),[i,a]=(0,R.useState)(!0);if((0,R.useEffect)(()=>{let e=!1,n=async()=>{try{let n=await VOt();if(e)return;t(n),r(null)}catch(t){if(e)return;r(t instanceof Error?t.message:String(t))}finally{e||a(!1)}};n();let i=window.setInterval(()=>{n()},BOt);return()=>{e=!0,window.clearInterval(i)}},[]),i&&!e)return(0,z.jsx)(`div`,{className:`flex min-h-[200px] items-center justify-center text-sm text-muted-foreground`,children:`Loading Flywheel state…`});if(n)return(0,z.jsxs)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 p-4 text-sm text-destructive`,children:[`Failed to load Flywheel state: `,n]});if(!e||!e.exists||!e.content)return(0,z.jsx)(`div`,{className:`flex min-h-[360px] items-center justify-center rounded-xl border border-dashed border-border bg-card/40 p-8 text-center`,children:(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`text-base font-medium text-foreground`,children:`No Flywheel state yet.`}),(0,z.jsxs)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:[(0,z.jsx)(`code`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono text-xs`,children:`docs/FLYWHEEL-STATE.md`}),` is created by the orchestrator the first time it records something worth remembering across runs.`]})]})});let o=HOt(e.lastModified);return(0,z.jsxs)(`div`,{className:`space-y-3`,children:[(0,z.jsxs)(`header`,{className:`flex flex-wrap items-baseline justify-between gap-2 border-b border-border pb-2 text-xs text-muted-foreground`,children:[(0,z.jsx)(`span`,{className:`font-mono`,children:e.path}),o&&(0,z.jsxs)(`span`,{children:[`Last modified `,o]})]}),(0,z.jsx)(`article`,{className:`prose prose-sm max-w-none dark:prose-invert`,children:(0,z.jsx)(lO,{remarkPlugins:[tk],children:e.content})})]})}var WOt=6e4,GOt=[`c1_bugRate`,`c2_p0Bugs`,`c3_passRate`,`c4_mttr`,`c5_intervention`,`c6_timeConsistency`,`c7_flake`],KOt={c1_bugRate:`Substrate bugs filed in the selected window divided by completed pipeline runs in the same window.`,c2_p0Bugs:`Count of P0 substrate bugs filed during the selected window.`,c3_passRate:`Pipeline pass success rate after counting only review or test failures tied to substrate bugs discovered on the same issue within 24 hours.`,c4_mttr:`Median and p95 time from substrate bug filing to fix merge for bugs filed in the selected window.`,c5_intervention:`Operator intervention events divided by completed pipeline runs in the selected window.`,c6_timeConsistency:`For simple, medium, and complex bead-count buckets, compares p95 completed-run duration to the median duration.`,c7_flake:`Substrate-attributable review or test failures that pass one cycle and fail the next with the same head SHA.`},qOt={green:`bg-success text-success`,yellow:`bg-warning text-warning`,red:`bg-destructive text-destructive`,insufficient_data:`bg-muted-foreground text-muted-foreground`,collecting:`bg-muted-foreground text-muted-foreground`},JOt={green:`Green`,yellow:`Yellow`,red:`Red`,insufficient_data:`Insufficient data`,collecting:`Collecting data`},YOt={up:`↗ Up`,down:`↘ Down`,flat:`→ Flat`};async function XOt(){let e=await fetch(`/api/flywheel/stats`);if(!e.ok)throw Error(`Request failed (${e.status})`);return e.json()}function ZOt(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toISOString().slice(0,10)}function QOt(e){let t=Math.abs(e);return t>=1440*60*1e3?`${(e/(1440*60*1e3)).toFixed(1)}d`:t>=3600*1e3?`${(e/(3600*1e3)).toFixed(1)}h`:t>=60*1e3?`${(e/(60*1e3)).toFixed(1)}m`:`${Math.round(e)}ms`}function $Ot(e){return Number.isFinite(e)?e>0&&Math.abs(e)<1?`${(e*100).toFixed(1)}%`:Number.isInteger(e)?String(e):e.toFixed(2):`—`}function ekt(e){return Object.entries(e).map(([e,t])=>typeof t==`number`&&e.toLowerCase().endsWith(`ms`)?`${e}: ${QOt(t)}`:typeof t==`number`?`${e}: ${$Ot(t)}`:typeof t==`string`||typeof t==`boolean`||t===null?`${e}: ${String(t)}`:`${e}: ${JSON.stringify(t)}`).join(` · `)}function tkt(e){return typeof e==`number`?$Ot(e):ekt(e)}function nkt(e){return e.dataSufficient?e.status:`collecting`}function rkt({criterion:e,criterionKey:t,generatedAt:n}){let r=nkt(e),i=e.dataSufficient?tkt(e.value):`collecting since ${ZOt(n)}`;return(0,z.jsxs)(`section`,{role:`region`,"aria-label":`${e.label} metric`,className:`rounded-lg border border-border bg-card/60 p-4`,title:KOt[t],children:[(0,z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,z.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:e.label}),(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 text-xs font-medium`,"aria-label":`Status: ${JOt[r]}`,children:[(0,z.jsx)(`span`,{className:vj(`h-2.5 w-2.5 rounded-full`,qOt[r].split(` `)[0]),"aria-hidden":`true`}),(0,z.jsx)(`span`,{className:qOt[r].split(` `)[1],children:JOt[r]})]})]}),(0,z.jsx)(`div`,{className:`mt-4 text-2xl font-semibold text-foreground`,children:i}),(0,z.jsxs)(`div`,{className:`mt-2 text-sm text-muted-foreground`,children:[`Target: `,tkt(e.target)]}),(0,z.jsxs)(`footer`,{className:`mt-4 flex flex-wrap items-center justify-between gap-2 border-t border-border/70 pt-3 text-xs text-muted-foreground`,children:[(0,z.jsxs)(`span`,{children:[`Sample size: `,e.sampleSize]}),e.trend&&(0,z.jsx)(`span`,{"aria-label":`Trend: ${YOt[e.trend]}`,children:YOt[e.trend]})]})]})}function ikt(){let[e,t]=(0,R.useState)(null),[n,r]=(0,R.useState)(null),[i,a]=(0,R.useState)(!0);return(0,R.useEffect)(()=>{let e=!1,n=async()=>{try{let n=await XOt();if(e)return;t(n),r(null)}catch(t){if(e)return;r(t instanceof Error?t.message:String(t))}finally{e||a(!1)}};n();let i=window.setInterval(()=>{n()},WOt);return()=>{e=!0,window.clearInterval(i)}},[]),i&&!e?(0,z.jsx)(`div`,{className:`flex min-h-[200px] items-center justify-center text-sm text-muted-foreground`,children:`Loading Flywheel stats…`}):e?(0,z.jsxs)(`div`,{className:`space-y-4`,"aria-label":`Flywheel stats`,children:[(0,z.jsxs)(`header`,{className:`flex flex-wrap items-baseline justify-between gap-2 border-b border-border pb-2 text-xs text-muted-foreground`,children:[(0,z.jsxs)(`span`,{children:[`Window: `,e.window]}),(0,z.jsxs)(`span`,{children:[`Generated: `,ZOt(e.generatedAt)]})]}),n&&(0,z.jsxs)(`div`,{className:`rounded-md border border-warning/40 bg-warning/10 p-3 text-sm text-warning`,role:`status`,children:[`Failed to refresh Flywheel stats: `,n,`. Showing last good data.`]}),(0,z.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:GOt.map(t=>(0,z.jsx)(rkt,{criterionKey:t,criterion:e.criteria[t],generatedAt:e.generatedAt},t))})]}):(0,z.jsxs)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 p-4 text-sm text-destructive`,children:[`Failed to load Flywheel stats: `,n??`unknown error`]})}var akt={planning:`bg-primary/15 text-primary border-primary/30`,working:`bg-info/15 text-info-foreground border-info/30`,reviewing:`bg-signal-review/15 text-signal-review-foreground border-signal-review/30`,testing:`bg-warning/15 text-warning-foreground border-warning/30`,shipping:`bg-success/15 text-success border-success/30`,merging:`bg-warning/15 text-warning-foreground border-warning/30`,blocked:`bg-destructive/15 text-destructive border-destructive/30`,parked:`bg-muted text-muted-foreground border-border`},okt={default:`text-foreground`,success:`text-success`,warning:`text-warning-foreground`,info:`text-info-foreground`};function skt({children:e}){return(0,z.jsx)(`div`,{className:`grid gap-3 md:grid-cols-4`,"aria-label":`Flywheel headline metrics`,children:e})}function w9({label:e,value:t,subtext:n,tone:r=`default`}){return(0,z.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/70 p-4`,children:[(0,z.jsx)(`div`,{className:`font-mono text-[10px] uppercase tracking-wider text-muted-foreground`,children:e}),(0,z.jsx)(`div`,{className:vj(`mt-1 text-3xl font-semibold tabular-nums tracking-tight`,okt[r]),children:t}),n&&(0,z.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:n})]})}function ckt({verb:e}){return(0,z.jsx)(`span`,{className:vj(`inline-flex rounded border px-2 py-0.5 font-mono text-[10px] font-semibold uppercase tracking-wide`,akt[e]),children:e})}function lkt({item:e}){return(0,z.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/60 p-4`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,z.jsx)(`span`,{className:`rounded border border-border bg-background px-2 py-0.5 font-mono text-xs text-primary`,children:e.issueId}),(0,z.jsx)(ckt,{verb:e.verb}),(0,z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-foreground`,children:e.title}),(0,z.jsx)(`span`,{className:`font-mono text-xs uppercase tracking-wide text-muted-foreground`,children:e.status})]}),typeof e.progressPercent==`number`&&Number.isFinite(e.progressPercent)&&(0,z.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,children:[(0,z.jsx)(`div`,{className:`h-1.5 flex-1 overflow-hidden rounded-full bg-muted`,children:(0,z.jsx)(`div`,{className:`h-full rounded-full bg-primary`,style:{width:`${Math.max(0,Math.min(100,e.progressPercent))}%`}})}),(0,z.jsxs)(`span`,{className:`w-10 text-right font-mono text-xs text-muted-foreground`,children:[Math.round(e.progressPercent),`%`]})]})]})}var ukt={fixed:`bg-success/15 text-success border-success/30`,filed:`bg-primary/15 text-primary border-primary/30`,workaround:`bg-warning/15 text-warning border-warning/30`},dkt={urgent:`bg-destructive/15 text-destructive border-destructive/30`,high:`bg-warning/15 text-warning border-warning/30`,medium:`bg-primary/15 text-primary border-primary/30`,low:`bg-muted text-muted-foreground border-border`},fkt={urgent:0,high:1,medium:2,low:3},pkt={starting:`starting`,running:`running`,waiting:`warning`,idle:`healthy`,stopped:`stopped`,error:`failed`},mkt=new Set([`plan`,`work`,`review`,`test`,`ship`,`flywheel`]);function T9(e){return Number.isFinite(e)?Math.abs(e)>=1024?`${(e/1024).toFixed(1)} GiB`:`${Math.round(e)} MiB`:`—`}function E9(e){return e.slice(0,7)}function hkt(e){if(!e)return null;try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`?t.toString():null}catch{return null}}function gkt(e){return e&&mkt.has(e)?e:void 0}function _kt(e,t){return{id:e.id,issueId:e.issueId??e.label,runtime:`claude-code`,model:e.model??`unknown`,status:pkt[e.status],startedAt:t,lastActivity:t,consecutiveFailures:+(e.status===`error`),killCount:0,role:gkt(e.role)}}function vkt({status:e}){return(0,z.jsx)(`span`,{className:vj(`inline-flex rounded-full border px-2 py-0.5 text-[11px] font-semibold uppercase tracking-wide`,ukt[e]),children:e})}function ykt({priority:e}){return(0,z.jsx)(`span`,{className:vj(`inline-flex rounded-full border px-2 py-0.5 text-[11px] font-semibold uppercase tracking-wide`,dkt[e]),children:e})}function bkt(e){return e.map((e,t)=>({suggestion:e,index:t})).sort((e,t)=>{let n=fkt[e.suggestion.priority]-fkt[t.suggestion.priority];return n===0?e.index-t.index:n}).map(({suggestion:e})=>e)}function D9({title:e,children:t}){return(0,z.jsxs)(`section`,{className:`rounded-lg border border-border bg-card/60 p-4`,children:[(0,z.jsx)(`h3`,{className:`mb-3 text-sm font-semibold text-foreground`,children:e}),t]})}function xkt({status:e,onNavigateAgent:t,onNavigateIssue:n}){let r=Math.max(e.system.ramTotalMb-e.system.ramUsedMb,0),i=Math.max(e.system.swapTotalMb-e.system.swapUsedMb,0),a=t??(()=>void 0),o=n??(()=>void 0),s=bkt(e.suggestions);return(0,z.jsxs)(`div`,{className:`space-y-4`,"aria-label":`Flywheel status details`,children:[(0,z.jsx)(D9,{title:`Suggestions`,children:s.length>0?(0,z.jsx)(`div`,{className:`space-y-3`,children:s.map((e,t)=>{let n=e.issueId;return(0,z.jsxs)(`div`,{"data-testid":`flywheel-suggestion`,className:`rounded-md border border-border bg-background p-3`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,z.jsx)(ykt,{priority:e.priority}),(0,z.jsx)(`span`,{className:`rounded-full bg-muted px-2 py-0.5 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground`,children:e.action}),n&&(0,z.jsx)(`button`,{type:`button`,className:`font-mono text-xs font-medium text-primary hover:underline`,onClick:()=>o(n),children:n})]}),(0,z.jsx)(`p`,{className:`mt-2 text-sm text-foreground`,children:e.rationale})]},`${e.priority}-${e.action}-${n??`system`}-${t}`)})}):(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No suggestions yet — orchestrator will emit on next tick.`})}),(0,z.jsxs)(skt,{children:[(0,z.jsx)(w9,{label:`Bugs Fixed`,value:e.headline.bugsFixed,tone:`success`}),(0,z.jsx)(w9,{label:`SWARM Items`,value:`${e.headline.swarmItemsMerged}/${e.headline.swarmItemsTotal}`,subtext:`merged`,tone:`info`}),(0,z.jsx)(w9,{label:`PRs Merged`,value:e.headline.prsMerged,tone:`success`}),(0,z.jsx)(w9,{label:`Awaiting UAT`,value:e.headline.awaitingUat,tone:e.headline.awaitingUat>0?`warning`:`default`})]}),(0,z.jsx)(D9,{title:`Active Pipeline`,children:e.activePipeline.length>0?(0,z.jsx)(`div`,{className:`space-y-3`,children:e.activePipeline.map(e=>(0,z.jsx)(lkt,{item:e},`${e.issueId}-${e.verb}`))}):(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No active pipeline items.`})}),(0,z.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-[minmax(0,1.25fr)_minmax(280px,0.75fr)]`,children:[(0,z.jsxs)(`div`,{className:`space-y-4`,children:[(0,z.jsx)(D9,{title:`Substrate Bugs Filed and Fixed`,children:e.substrateBugs.length>0?(0,z.jsx)(`div`,{className:`overflow-x-auto`,children:(0,z.jsxs)(`table`,{className:`w-full min-w-[520px] text-left text-sm`,children:[(0,z.jsx)(`thead`,{className:`text-xs uppercase tracking-wide text-muted-foreground`,children:(0,z.jsxs)(`tr`,{className:`border-b border-border`,children:[(0,z.jsx)(`th`,{className:`pb-2 pr-3 font-medium`,children:`Issue`}),(0,z.jsx)(`th`,{className:`pb-2 pr-3 font-medium`,children:`Title`}),(0,z.jsx)(`th`,{className:`pb-2 pr-3 font-medium`,children:`Status`}),(0,z.jsx)(`th`,{className:`pb-2 font-medium`,children:`Commit`})]})}),(0,z.jsx)(`tbody`,{children:e.substrateBugs.map(e=>{let t=hkt(e.url);return(0,z.jsxs)(`tr`,{className:`border-b border-border/60 last:border-0`,children:[(0,z.jsx)(`td`,{className:`py-2 pr-3 font-mono text-xs text-primary`,children:e.issueId}),(0,z.jsx)(`td`,{className:`py-2 pr-3 text-foreground`,children:e.title}),(0,z.jsx)(`td`,{className:`py-2 pr-3`,children:(0,z.jsx)(vkt,{status:e.status})}),(0,z.jsx)(`td`,{className:`py-2 font-mono text-xs`,children:e.commitSha?t?(0,z.jsx)(`a`,{className:`text-primary hover:underline`,href:t,target:`_blank`,rel:`noreferrer`,children:E9(e.commitSha)}):(0,z.jsx)(`span`,{className:`text-foreground`,children:E9(e.commitSha)}):(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})})]},`${e.issueId}-${e.title}`)})})]})}):(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No substrate bugs filed or fixed yet.`})}),(0,z.jsx)(D9,{title:`Currently Running Agents`,children:e.agents.length>0?(0,z.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:e.agents.map(t=>(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-xs`,children:[(0,z.jsx)(`span`,{className:`truncate font-medium text-foreground`,title:t.label,children:t.label}),typeof t.ctxPercent==`number`&&Number.isFinite(t.ctxPercent)&&(0,z.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[Math.round(t.ctxPercent),`% ctx`]})]}),(0,z.jsx)(Cwt,{agent:_kt(t,e.lastTickAt),onNavigate:a}),t.currentAction&&(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t.currentAction})]},t.id))}):(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No running Flywheel agents.`})})]}),(0,z.jsxs)(`div`,{className:`space-y-4`,children:[(0,z.jsx)(D9,{title:`System`,children:(0,z.jsxs)(`dl`,{className:`grid gap-3 text-sm`,children:[(0,z.jsxs)(`div`,{className:`rounded-md border border-border bg-background p-3`,children:[(0,z.jsx)(`dt`,{className:`text-xs uppercase tracking-wide text-muted-foreground`,children:`RAM`}),(0,z.jsxs)(`dd`,{className:`mt-1 font-medium text-foreground`,children:[T9(e.system.ramUsedMb),` used / `,T9(r),` available`]})]}),(0,z.jsxs)(`div`,{className:`rounded-md border border-border bg-background p-3`,children:[(0,z.jsx)(`dt`,{className:`text-xs uppercase tracking-wide text-muted-foreground`,children:`Swap`}),(0,z.jsxs)(`dd`,{className:`mt-1 font-medium text-foreground`,children:[T9(e.system.swapUsedMb),` used / `,T9(i),` available`]})]}),(0,z.jsxs)(`div`,{className:`rounded-md border border-border bg-background p-3`,children:[(0,z.jsx)(`dt`,{className:`text-xs uppercase tracking-wide text-muted-foreground`,children:`Agents`}),(0,z.jsxs)(`dd`,{className:`mt-1 font-medium text-foreground`,children:[e.system.agentsActive,` / `,e.system.agentsCap,` active`]})]}),(0,z.jsxs)(`div`,{className:`rounded-md border border-border bg-background p-3`,children:[(0,z.jsx)(`dt`,{className:`text-xs uppercase tracking-wide text-muted-foreground`,children:`Main HEAD`}),(0,z.jsx)(`dd`,{className:`mt-1 font-mono text-sm font-medium text-foreground`,children:E9(e.system.mainHead)})]})]})}),(0,z.jsx)(D9,{title:`Open Questions for the Next Tick`,children:e.openQuestions.length>0?(0,z.jsx)(`ul`,{className:`list-disc space-y-2 pl-5 text-sm text-foreground`,children:e.openQuestions.map(e=>(0,z.jsx)(`li`,{children:e},e))}):(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No open questions for the next tick.`})})]})]})]})}function Skt({icon:e,label:t,count:n,defaultCollapsed:r=!1,ariaLabel:i,children:a}){let[o,s]=(0,R.useState)(r);return(0,z.jsxs)(`section`,{className:`shrink-0 border-b border-border`,"aria-label":i??t,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:()=>s(e=>!e),"aria-expanded":!o,className:`flex w-full items-center justify-between gap-2 px-4 py-2.5 text-left hover:bg-accent/40`,children:[(0,z.jsxs)(`span`,{className:`flex items-center gap-2 text-[11px] font-semibold uppercase tracking-wide text-foreground`,children:[o?(0,z.jsx)(nn,{className:`h-3.5 w-3.5 text-muted-foreground`}):(0,z.jsx)(en,{className:`h-3.5 w-3.5 text-muted-foreground`}),e,t]}),n!=null&&(0,z.jsx)(`span`,{className:`text-[10px] font-semibold text-muted-foreground`,children:n})]}),!o&&(0,z.jsx)(`div`,{className:`px-3 pb-3`,children:a})]})}async function Ckt(e){let t=await fetch(e);if(!t.ok)throw Error(`${e} → ${t.status}`);return t.json()}async function O9(e,t){let n=await fetch(e,{method:`POST`,headers:await uj(),body:t===void 0?`{}`:JSON.stringify(t)}),r=await n.json().catch(()=>({}));if(!n.ok)throw Error(r.error??r.message??`${e} → ${n.status}`);return r}function wkt(e){return encodeURIComponent(e.replace(/^uat\//,``))}function k9(e){return e.replace(/^uat\//,``)}function Tkt({active:e,onNavigateIssue:t}){let n=_t(),r=Hr(),[i,a]=(0,R.useState)(!0),o=B({queryKey:[`flywheel-uat-generations`],queryFn:()=>Ckt(`/api/flywheel/uat-generations`),refetchInterval:e?15e3:!1}),s=B({queryKey:[`flywheel-merge-queue`],queryFn:()=>Ckt(`/api/flywheel/merge-queue`),refetchInterval:e?15e3:!1}),c=Array.isArray(o.data)?o.data:[],l=Array.isArray(s.data)?s.data:[],u=()=>{n.invalidateQueries({queryKey:[`flywheel-uat-generations`]}),n.invalidateQueries({queryKey:[`flywheel-merge-queue`]})},d=Nt({mutationFn:e=>O9(`/api/flywheel/uat-generations/${wkt(e)}/stack`),onSuccess:e=>{e.evicted.length>0&&H.info(`Stopped older UAT stack ${e.evicted.map(k9).join(`, `)} (max 2 run at once)`),window.open(e.frontendUrl,`_blank`,`noopener,noreferrer`),u()},onError:e=>H.error(e instanceof Error?e.message:`Could not start the UAT stack`)}),f=Nt({mutationFn:e=>O9(`/api/flywheel/uat-generations/${wkt(e)}/promote`),onSuccess:e=>{H.success(`Merged ${e.members.length} feature${e.members.length===1?``:`s`} to main (${e.members.join(`, `)})`),u()},onError:e=>{H.error(e instanceof Error?e.message:`Batch merge failed`),u()}}),p=Nt({mutationFn:()=>O9(`/api/flywheel/assemble-uat`),onSuccess:e=>{e.action===`assembled`?H.success(`Rebuilt the UAT batch`):H.info(`Rebuild: ${e.action}`),u()},onError:e=>H.error(e instanceof Error?e.message:`Rebuild failed`)}),m=Nt({mutationFn:()=>O9(`/api/flywheel/merge-next`,{n:1}),onSuccess:e=>{let t=e.outcomes[0];t?.result===`merged`?H.success(`Merged ${t.issueId} to main`):H.warning(`${t?.issueId??`Merge`} did not merge: ${t?.reason??`unknown`}`),u()},onError:e=>H.error(e instanceof Error?e.message:`Merge failed`)}),h=async e=>{let t=e.members.map((e,t)=>`${t+1}. ${e.issueId} (${e.branch}) — ${e.title}`).join(`
|
|
679
679
|
`),n=e.resolutions.length>0?`\n\nIncludes ${e.resolutions.length} conflict resolution${e.resolutions.length===1?``:`s`} you tested (${e.resolutions.map(e=>e.issueIds.join(` ↔ `)).join(`; `)}).`:``;await r({title:`Merge batch ${k9(e.name)} to main?`,message:`Lands exactly the tree you tested — one merge to main containing:\n${t}${n}\n\nThe ${e.members.length} issue${e.members.length===1?``:`s`} close out through the normal post-merge flow, and remaining ready features reassemble into a fresh batch.`,confirmLabel:`Merge batch (${e.members.length}) to main`})&&f.mutate(e.name)},g=async()=>{let e=l[0];e&&await r({title:`Merge ${e.issueId} to main on its own?`,message:`Merges only ${e.issueId} (${e.branchName}) to main with full checks.\n\nThis bypasses batch testing: the live UAT batches become stale and a new batch reassembles automatically. Prefer merging a tested batch.`,confirmLabel:`Merge ${e.issueId} to main`,variant:`destructive`})&&m.mutate()},_=c.filter(e=>e.status===`assembling`||e.status===`ready`||e.status===`superseded`),v=_.find(e=>e.status===`ready`)??_.find(e=>e.status===`superseded`),y=l.length,b=_.filter(e=>e.status!==`assembling`).length,x=({issueId:e})=>(0,z.jsx)(`button`,{type:`button`,onClick:()=>t?.(e),className:`font-mono text-[11px] font-semibold text-primary hover:underline`,children:e}),S=({children:e})=>(0,z.jsx)(`div`,{className:`mt-3 mb-1.5 flex items-center gap-2 text-[9.5px] font-bold uppercase tracking-wider text-muted-foreground after:h-px after:flex-1 after:bg-border`,children:e}),C=({gen:e,compact:t})=>{let n=d.isPending&&d.variables===e.name;return e.stack.status===`running`?(0,z.jsxs)(`a`,{href:e.stack.frontendUrl,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 rounded border border-emerald-500/40 px-2 py-0.5 text-[10.5px] font-semibold text-emerald-400 hover:bg-emerald-500/10`,children:[`▶ `,t?`Open`:`Open UAT frontend`]}):(0,z.jsx)(`button`,{type:`button`,disabled:n,onClick:()=>d.mutate(e.name),title:`Starts a live dashboard stack serving this exact batch (~1 min), then opens it`,className:`inline-flex items-center gap-1 rounded border border-emerald-500/40 px-2 py-0.5 text-[10.5px] font-semibold text-emerald-400 hover:bg-emerald-500/10 disabled:opacity-60`,children:n?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(ar,{className:`h-3 w-3 animate-spin`}),` Starting… ~1 min`]}):(0,z.jsxs)(z.Fragment,{children:[`▶ `,t?`Start & open`:`Start & open UAT frontend`]})})},w=_.length===0&&l.length===0;return(0,z.jsx)(Skt,{icon:(0,z.jsx)(Gn,{className:`h-3.5 w-3.5 text-emerald-400`}),label:`UAT batches`,ariaLabel:`UAT batches`,count:y>0?`${y} feature${y===1?``:`s`}${b>0?` · ${b} batch${b===1?``:`es`}`:``}`:void 0,children:w?(0,z.jsx)(`p`,{className:`px-1 py-1.5 text-xs text-muted-foreground`,children:`No features are ready to merge. When work passes review and tests, it lines up here and a test batch assembles automatically.`}):(0,z.jsxs)(`div`,{className:`space-y-1`,children:[(0,z.jsxs)(`p`,{className:`px-1 pb-1 text-[11px] leading-snug text-muted-foreground`,children:[(0,z.jsxs)(`span`,{className:`font-semibold text-foreground`,children:[y,` feature`,y===1?``:`s`]}),` passed review & tests.`,b>0?` They’re assembled into the test batches below — open a batch’s frontend, run its checklist, then merge that batch to main.`:` A test batch assembles automatically when the merge train is on.`]}),_.length>0&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(S,{children:`Batches — newest first`}),_.map(e=>{if(e.status===`assembling`){let t=e.members.length+e.heldOut.length;return(0,z.jsxs)(`div`,{className:`rounded-lg border border-violet-500/40 bg-violet-500/5 p-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`text-[10px] text-violet-400`,children:`◌`}),(0,z.jsx)(`span`,{className:`font-mono text-[11px] font-bold text-violet-400`,children:k9(e.name)}),(0,z.jsxs)(`span`,{className:`ml-auto inline-flex items-center gap-1 text-[10px] text-muted-foreground`,children:[(0,z.jsx)(ar,{className:`h-3 w-3 animate-spin text-violet-400`}),` assembling…`]})]}),(0,z.jsxs)(`div`,{className:`mt-1 pl-4 text-[10.5px] text-muted-foreground`,children:[t>0?`${e.members.length} merged${e.heldOut.length>0?`, ${e.heldOut.length} held out`:``} so far. `:``,`The current batch below stays testable until this one is ready.`]})]},e.name)}let t=e.status===`superseded`;return(0,z.jsxs)(`div`,{className:`rounded-lg border p-2 ${t?`border-border opacity-75`:`border-emerald-500/35 bg-emerald-500/[0.04]`}`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`text-[10px] ${t?`text-muted-foreground`:`text-emerald-400`}`,children:t?`○`:`●`}),(0,z.jsx)(`span`,{className:`font-mono text-[11px] font-bold ${t?`text-foreground`:`text-emerald-400`}`,children:k9(e.name)}),(0,z.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:t?`superseded · still testable`:`ready to test`})]}),(0,z.jsxs)(`div`,{className:`mt-0.5 pl-4 text-[10.5px] text-muted-foreground`,children:[e.members.map((e,t)=>(0,z.jsxs)(`span`,{children:[t>0&&` + `,(0,z.jsx)(x,{issueId:e.issueId})]},e.issueId)),e.resolutions.length>0&&(0,z.jsxs)(`span`,{children:[` · `,e.resolutions.length,` conflict`,e.resolutions.length===1?``:`s`,` resolved in batch`]})]}),e.heldOut.length>0&&(0,z.jsxs)(`div`,{className:`mt-0.5 pl-4 text-[10px] text-amber-400`,children:[`held out: `,e.heldOut.map(e=>`${e.issueId} (${e.reason})`).join(`; `)]}),(0,z.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-1.5 pl-4`,children:[(0,z.jsx)(C,{gen:e,compact:t}),(0,z.jsx)(`button`,{type:`button`,disabled:f.isPending,onClick:()=>void h(e),className:`rounded-md bg-emerald-500 px-2.5 py-0.5 text-[10.5px] font-bold text-emerald-950 hover:brightness-110 disabled:opacity-50`,children:f.isPending&&f.variables===e.name?`Merging…`:`Merge batch (${e.members.length}) to main`}),!t&&(0,z.jsx)(`button`,{type:`button`,disabled:p.isPending,onClick:()=>p.mutate(),title:`Re-merge the ready features onto a fresh branch off current main — use if you suspect this batch is stale`,className:`rounded border border-border px-1.5 py-0.5 text-[10.5px] text-muted-foreground hover:bg-accent disabled:opacity-50`,children:p.isPending?`…`:`↻`})]})]},e.name)}),(0,z.jsx)(`p`,{className:`px-1 text-[9.5px] leading-snug text-muted-foreground`,children:`Batches build automatically from the ready features. Nothing here merges to main until you say so.`})]}),v&&v.members.length>0&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(S,{children:(0,z.jsxs)(`button`,{type:`button`,className:`uppercase tracking-wider hover:text-foreground`,onClick:()=>a(e=>!e),children:[i?`▾`:`▸`,` What to UAT — `,k9(v.name)]})}),i&&(0,z.jsx)(`div`,{className:`rounded-lg border border-border p-2`,children:v.members.map(e=>{let t=v.resolutions.find(t=>t.issueIds[0]===e.issueId);return(0,z.jsxs)(`div`,{className:`mb-1.5 last:mb-0`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10.5px] font-bold`,children:[(0,z.jsx)(x,{issueId:e.issueId}),(0,z.jsx)(`span`,{className:`truncate text-foreground`,children:e.title})]}),(0,z.jsxs)(`ul`,{className:`mt-0.5 space-y-0.5 pl-1`,children:[e.acceptanceCriteria.length===0?(0,z.jsx)(`li`,{className:`text-[10.5px] italic text-muted-foreground`,children:`No UAT steps in plan — exercise the feature described above.`}):e.acceptanceCriteria.map((e,t)=>(0,z.jsxs)(`li`,{className:`flex gap-1.5 text-[10.5px] leading-snug text-foreground`,children:[(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`☐`}),(0,z.jsx)(`span`,{children:e.title})]},t)),t&&(0,z.jsxs)(`li`,{className:`flex gap-1.5 text-[10.5px] leading-snug text-amber-300`,children:[(0,z.jsx)(`span`,{children:`☐`}),(0,z.jsxs)(`span`,{children:[`Conflict with `,t.issueIds.filter(t=>t!==e.issueId).join(`, `),` was resolved in this batch (`,t.files.join(`, `),`) — verify both features still behave at that touchpoint.`]})]})]})]},e.issueId)})})]}),l.length>0&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(S,{children:`Ready features (merge order)`}),l.map(e=>{let t=_.find(e=>e.status!==`assembling`),n=t?.resolutions.some(t=>t.issueIds.includes(e.issueId)),r=t?.heldOut.find(t=>t.issueId===e.issueId);return(0,z.jsxs)(`div`,{className:`border-t border-border py-1 text-[11.5px] first:border-t-0`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`text-[10.5px] font-bold text-muted-foreground`,children:e.mergeOrder}),(0,z.jsx)(x,{issueId:e.issueId}),(0,z.jsx)(`span`,{className:`flex-1 truncate text-[11px] text-muted-foreground`,children:e.title}),n&&(0,z.jsx)(`span`,{className:`rounded bg-emerald-500/10 px-1.5 py-0.5 text-[9.5px] font-bold text-emerald-400`,title:`A file overlap with another feature was resolved inside the current batch`,children:`✓ resolved in batch`}),r&&(0,z.jsx)(`span`,{className:`rounded bg-amber-500/10 px-1.5 py-0.5 text-[9.5px] font-bold text-amber-400`,title:r.reason,children:`⚠ held out`})]}),(0,z.jsxs)(`div`,{className:`ml-6 mt-0.5 flex items-center gap-2.5`,children:[(0,z.jsx)(`span`,{className:`rounded bg-accent px-1.5 py-px font-mono text-[10px] text-muted-foreground`,children:e.branchName}),e.prUrl?(0,z.jsxs)(`a`,{href:e.prUrl,target:`_blank`,rel:`noreferrer`,className:`text-[10px] font-semibold text-primary hover:underline`,children:[`PR `,e.pr==null?``:`#${e.pr}`,` ↗`]}):e.pr==null?null:(0,z.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`#`,e.pr]})]})]},e.issueId)}),(0,z.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 border-t border-dashed border-border pt-2 text-[11px] text-muted-foreground`,children:[(0,z.jsx)(`span`,{children:`Escape hatch:`}),(0,z.jsx)(`button`,{type:`button`,disabled:m.isPending,onClick:()=>void g(),className:`rounded border border-border px-2 py-0.5 text-[10.5px] text-foreground hover:bg-accent disabled:opacity-50`,children:m.isPending?`Merging…`:`Merge one feature to main…`})]}),(0,z.jsx)(`p`,{className:`px-1 text-[9.5px] leading-snug text-muted-foreground`,children:`Merging a single feature invalidates the live batches — a fresh batch reassembles automatically. Prefer merging a tested batch.`})]})]})})}function Ekt(e){return e.mergeStatus===`merging`||e.mergeStatus===`queued`||e.mergeStatus===`verifying`?`merging`:e.readyForMerge?`ready to merge`:e.reviewStatus===`reviewing`?`in review`:e.testStatus===`testing`?`testing`:e.reviewStatus===`failed`||e.testStatus===`failed`?`failed`:e.reviewStatus===`passed`?`review passed`:`in progress`}function Dkt(e){return e.mergeStatus!==`merged`&&(e.readyForMerge===!0||!!e.mergeStatus||e.reviewStatus!==void 0&&e.reviewStatus!==`pending`||e.testStatus!==void 0&&e.testStatus!==`pending`)}function Okt({onNavigateIssue:e}){let t=sm(e=>e.reviewStatusByIssueId),n=sm(e=>e.issuesRaw),r=(0,R.useMemo)(()=>{let e=new Map;for(let t of n??[])t?.identifier&&t?.title&&e.set(t.identifier.toUpperCase(),t.title);return e},[n]),[i,a]=(0,R.useState)(!1),o=Object.values(t).filter(Dkt).sort((e,t)=>e.issueId.localeCompare(t.issueId));if(o.length===0)return null;let s=o.filter(e=>e.autoMerge===!0).length,c=o.filter(e=>e.autoMerge===!1).length;return(0,z.jsxs)(`section`,{className:`shrink-0 border-b border-border bg-background px-4 py-3`,"aria-label":`Merge policy`,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),className:`mb-2 flex w-full items-center justify-between text-left`,children:[(0,z.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-foreground`,children:[i?(0,z.jsx)(nn,{className:`h-4 w-4 text-muted-foreground`}):(0,z.jsx)(en,{className:`h-4 w-4 text-muted-foreground`}),(0,z.jsx)(Br,{className:`h-4 w-4 text-emerald-400`}),` Merge policy`]}),(0,z.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[(0,z.jsx)(`b`,{className:`text-emerald-400`,children:s}),` auto · `,(0,z.jsx)(`b`,{className:`text-amber-400`,children:c}),` hold · `,o.length,` active`]})]}),!i&&(0,z.jsx)(`ul`,{className:`max-h-56 space-y-1 overflow-y-auto`,children:o.map(t=>(0,z.jsxs)(`li`,{className:`flex items-center gap-2.5 rounded-md px-2 py-1 hover:bg-accent/40`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:()=>e?.(t.issueId),className:`w-20 shrink-0 text-left font-mono text-xs text-primary hover:underline`,children:t.issueId}),(0,z.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col leading-tight`,children:[(0,z.jsx)(`span`,{className:`truncate text-xs text-foreground`,title:r.get(t.issueId.toUpperCase()),children:r.get(t.issueId.toUpperCase())??Ekt(t)}),(0,z.jsx)(`span`,{className:`truncate text-[10px] text-muted-foreground`,children:Ekt(t)})]}),(0,z.jsx)(q5,{issueId:t.issueId,autoMerge:t.autoMerge,variant:`segmented`,compact:!0})]},t.issueId))})]})}var kkt=`overdeck.ui.flywheelSplitWidth`,A9=360,Akt=360,jkt=720,j9=[`flywheel`,`config`],Mkt=[`flywheel`,`auto-merge`,`pending`],Nkt=`Off: inventory is restricted to work in progress / in review / blocked / awaiting merge. On: also include READY backlog items bounded by maxAgents.`,Pkt=`On: UAT remains required before merge. Off: eligible merges may be scheduled through the server-managed cooldown.`,Fkt=`On: after a merge lands, automatically rebase every other ready branch onto the new main, re-verify the clean ones, and dispatch an agent to resolve conflicts. Off (default): siblings are left as-is. Mutates git — enable deliberately.`;function Ikt(){let e=localStorage.getItem(kkt);if(!e)return jkt;let t=Number(e);return Number.isFinite(t)&&t>=A9?t:jkt}async function Lkt(){let e=await fetch(`/api/flywheel/current`);if(!e.ok)throw Error(`Request failed (${e.status})`);return e.json()}async function Rkt(){let e=await fetch(`/api/flywheel/auto-merge/pending`);if(!e.ok)throw Error(`GET /api/flywheel/auto-merge/pending → ${e.status}`);return e.json()}function zkt(){return B({queryKey:j9,queryFn:async()=>{let e=await fetch(`/api/flywheel/config`);if(!e.ok)throw Error(`GET /api/flywheel/config → ${e.status}`);return e.json()},staleTime:5e3})}function Bkt(){return B({queryKey:Mkt,queryFn:Rkt,refetchInterval:5e3})}function Vkt(){let e=_t();return Nt({mutationFn:async e=>{let t=await fetch(`/api/flywheel/auto-merge/${encodeURIComponent(e)}`,{method:`DELETE`});if(!t.ok){let n=await t.text().catch(()=>``);throw Error(n||`DELETE /api/flywheel/auto-merge/${e} → ${t.status}`)}},onSuccess:async()=>{await e.invalidateQueries({queryKey:Mkt})}})}function Hkt(){let e=_t();return Nt({mutationFn:async e=>{let t=await fetch(`/api/flywheel/config`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok){let e=await t.text().catch(()=>``);throw Error(e||`POST /api/flywheel/config → ${t.status}`)}return t.json()},onMutate:async t=>{await e.cancelQueries({queryKey:j9});let n=e.getQueryData(j9);return e.setQueryData(j9,{auto_pickup_backlog:n?.auto_pickup_backlog??!1,require_uat_before_merge:n?.require_uat_before_merge??!0,merge_train_enabled:n?.merge_train_enabled??!1,...t}),{previous:n}},onError:(t,n,r)=>{e.setQueryData(j9,r?.previous)},onSuccess:t=>{e.setQueryData(j9,t)}})}function Ukt(e){if(!Number.isFinite(e)||e<0)return`—`;let t=Math.floor(e/1e3),n=Math.floor(t/3600),r=Math.floor(t%3600/60);return n>0?`${n}h ${r}m`:`${r}m`}function Wkt(e){let t=Math.max(0,Math.floor(e/1e3));return t<=90?`${t}s`:`${Math.max(1,Math.floor(t/60))}m`}function Gkt(e,t){let n=new Date(e).getTime(),r=Number.isFinite(n)?Math.max(0,t-n):1/0;return r<=6e4?{label:`live`,className:`border-success/30 bg-success/15 text-success`}:r<=12e5?{label:`last tick ${Wkt(r)} ago`,className:`border-warning/30 bg-warning/15 text-warning`}:{label:`stalled — last tick ${Wkt(r)} ago`,className:`border-destructive/30 bg-destructive/15 text-destructive`}}function Kkt(e){return e===`status`?`Flywheel status`:e===`state`?`Flywheel state`:`Flywheel stats`}function M9({label:e,checked:t,disabled:n,title:r,onChange:i}){return(0,z.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":t,"aria-label":e,disabled:n,title:r,onClick:()=>i(!t),className:`group flex items-center gap-1.5 text-[11px] font-medium text-muted-foreground disabled:opacity-50`,children:[(0,z.jsx)(`span`,{className:`relative h-4 w-7 rounded-full border transition-colors ${t?`border-primary/60 bg-primary/25`:`border-border bg-muted`}`,children:(0,z.jsx)(`span`,{className:`absolute top-0.5 h-2.5 w-2.5 rounded-full transition-all ${t?`left-[14px] bg-primary`:`left-0.5 bg-muted-foreground`}`})}),e]})}function qkt(e,t){let n=Date.parse(e)-t;if(!Number.isFinite(n)||n<=0)return`merging…`;let r=Math.ceil(n/1e3),i=Math.floor(r/60),a=r%60;return`auto-merging in ${i}:${String(a).padStart(2,`0`)}`}function Jkt(e){let t=e.match(/\/pull\/(\d+)(?:$|[/?#])/);return t?`PR #${t[1]}`:`PR`}function Ykt({onNavigateIssue:e}){let{data:t}=Bkt(),n=Vkt(),[r,i]=(0,R.useState)(()=>Date.now()),[a,o]=(0,R.useState)(null),s=Array.isArray(t)?t.filter(e=>e.status===`pending`):[];(0,R.useEffect)(()=>{if(s.length===0)return;let e=window.setInterval(()=>i(Date.now()),1e3);return()=>window.clearInterval(e)},[s.length]);let c=e=>{o(e),n.mutate(e,{onSettled:()=>o(null)})};return s.length===0?null:(0,z.jsx)(`section`,{className:`shrink-0 border-b border-warning/30 bg-warning/10 px-4 py-3`,"aria-label":`Pending auto-merges`,children:(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 text-sm`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h2`,{className:`font-semibold text-foreground`,children:`Pending auto-merges`}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Flywheel will merge eligible PRs when their cooldown expires.`})]}),(0,z.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:s.map(t=>{let i=Date.parse(t.scheduledMergeAt)-r,o=Number.isFinite(i)&&i<=0;return(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 rounded-lg border border-warning/30 bg-background px-3 py-2`,children:[(0,z.jsx)(`a`,{href:`#${t.issueId}`,onClick:n=>{n.preventDefault(),e?.(t.issueId)},className:`font-mono text-xs font-semibold text-primary hover:underline`,children:t.issueId}),(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:Jkt(t.prUrl)}),(0,z.jsx)(`span`,{className:`font-mono text-xs text-foreground`,children:qkt(t.scheduledMergeAt,r)}),(0,z.jsx)(`button`,{type:`button`,disabled:a!==null||n.isPending||t.status===`merging`||o,onClick:()=>c(t.issueId),className:`rounded-md border border-border px-2 py-1 text-xs font-medium text-foreground hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50`,children:`Cancel`})]},t.id)})})]})})}function Xkt({onOpenSettings:e,onNavigateAgent:t,onNavigateIssue:n}){let[r,i]=(0,R.useState)(null),[a,o]=(0,R.useState)(`status`),[s,c]=(0,R.useState)(Ikt),[l,u]=(0,R.useState)(()=>Date.now()),d=(0,R.useRef)(s),f=(0,R.useRef)(null),{data:p}=zkt(),m=Hkt(),h=p?.auto_pickup_backlog??!1,g=p?.require_uat_before_merge??!0,_=p?.merge_train_enabled??!1,v=m.isPending,y=m.error instanceof Error?m.error.message:null,{data:b}=B({queryKey:[`flywheel-latest-run-lifecycle`],queryFn:async()=>{let e=await fetch(`/api/flywheel/runs?limit=1`);if(!e.ok)return null;let t=await e.json();return Array.isArray(t)?t[0]??null:null},refetchInterval:5e3}),x=b?.status===`paused`,S=x?null:r,C=(0,R.useCallback)(e=>{let t=f.current?.getBoundingClientRect().width??window.innerWidth,n=Math.max(A9,t-Akt),r=Math.round(Math.min(n,Math.max(A9,e)));d.current=r,c(r),localStorage.setItem(kkt,String(r))},[]),w=(0,R.useCallback)(e=>{e.preventDefault();let t=e.clientX,n=d.current,r=e=>{C(n+(e.clientX-t))},i=()=>{document.removeEventListener(`pointermove`,r),document.removeEventListener(`pointerup`,i),document.body.style.cursor=``,document.body.style.userSelect=``};document.addEventListener(`pointermove`,r),document.addEventListener(`pointerup`,i),document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`},[C]);(0,R.useEffect)(()=>{let e=()=>C(d.current);return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[C]),(0,R.useEffect)(()=>{let e=window.setInterval(()=>u(Date.now()),5e3);return()=>window.clearInterval(e)},[]),(0,R.useEffect)(()=>{let e=!1,t=async()=>{try{let t=await Lkt();e||i(t)}catch{}};t();let n=window.setInterval(()=>{t()},5e3),r=sBe(e=>{i(e)});return()=>{e=!0,window.clearInterval(n),r()}},[]);let T=S?Gkt(S.lastTickAt,l):null;return(0,z.jsxs)(`div`,{ref:f,"aria-label":`Flywheel page`,className:`flex h-full w-full flex-col overflow-hidden bg-background`,children:[(0,z.jsxs)(`header`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2 border-b border-border bg-card/60 px-5 py-2.5`,children:[(0,z.jsx)(`h1`,{className:`font-display text-base font-semibold tracking-tight text-foreground`,children:`Fix-All Flywheel`}),(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full border border-border px-2 py-0.5 text-xs font-semibold text-muted-foreground`,children:[(0,z.jsx)(`span`,{className:S?`h-1.5 w-1.5 rounded-full bg-success`:`h-1.5 w-1.5 rounded-full bg-muted-foreground`}),S?`running · ${S.runId}`:x?`paused`:`idle`]}),(0,z.jsx)(`a`,{href:`https://github.com/eltmon/overdeck/blob/main/docs/FLYWHEEL.md`,target:`_blank`,rel:`noreferrer`,"aria-label":`Flywheel docs`,className:`text-xs font-medium text-primary hover:underline`,children:`docs`}),(0,z.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-x-4 gap-y-1 text-xs`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,z.jsx)(M9,{label:`Auto-pickup`,checked:h,disabled:v,title:Nkt,onChange:e=>m.mutate({auto_pickup_backlog:e})}),(0,z.jsx)(M9,{label:`Require UAT`,checked:g,disabled:v,title:Pkt,onChange:e=>m.mutate({require_uat_before_merge:e})}),(0,z.jsx)(M9,{label:`Merge train`,checked:_,disabled:v,title:Fkt,onChange:e=>m.mutate({merge_train_enabled:e})})]}),S&&(0,z.jsxs)(`div`,{className:`flex items-center gap-4 border-l border-border pl-4`,children:[(0,z.jsxs)(`span`,{className:`flex flex-col items-end leading-tight`,children:[(0,z.jsxs)(`b`,{className:`text-[13px] text-foreground`,children:[S.system.agentsActive,`/`,S.system.agentsCap]}),(0,z.jsx)(`span`,{className:`text-[9px] uppercase tracking-wide text-muted-foreground/70`,children:`agents`})]}),(0,z.jsxs)(`span`,{className:`flex flex-col items-end leading-tight`,children:[(0,z.jsx)(`b`,{className:`text-[13px] text-foreground`,children:S.activePipeline.length}),(0,z.jsx)(`span`,{className:`text-[9px] uppercase tracking-wide text-muted-foreground/70`,children:`in flight`})]}),(0,z.jsxs)(`span`,{className:`flex flex-col items-end leading-tight`,children:[(0,z.jsx)(`b`,{className:`text-[13px] text-foreground`,children:Ukt(S.elapsedMs)}),(0,z.jsxs)(`span`,{className:`text-[9px] uppercase tracking-wide text-muted-foreground/70`,children:[S.ticks,` ticks`]})]}),(0,z.jsx)(`span`,{className:`inline-flex rounded-full border px-2 py-0.5 font-semibold ${T?.className??``}`,children:T?.label??`—`})]})]})]}),y&&(0,z.jsx)(`div`,{className:`border-b border-border bg-destructive/5 px-5 py-1.5 text-xs text-destructive`,children:y}),(0,z.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:[(0,z.jsxs)(`section`,{className:`relative flex shrink-0 flex-col overflow-y-auto border-r border-border`,style:{width:`${s}px`,minWidth:`${A9}px`},"aria-label":`Flywheel control rail`,children:[(0,z.jsx)(Tkt,{active:!!S||x,onNavigateIssue:n}),(0,z.jsx)(Okt,{onNavigateIssue:n}),(0,z.jsx)(Ykt,{onNavigateIssue:n}),(0,z.jsxs)(Skt,{icon:(0,z.jsx)(Lt,{className:`h-3.5 w-3.5 text-primary`}),label:`Run status`,ariaLabel:`Flywheel run status`,children:[(0,z.jsx)(`div`,{className:`mb-3`,role:`tablist`,"aria-label":`Flywheel left-pane tabs`,children:(0,z.jsx)(`div`,{className:`inline-flex rounded-lg border border-border bg-background p-1 text-xs font-medium`,children:[`status`,`state`,`stats`].map(e=>(0,z.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":a===e,onClick:()=>o(e),className:a===e?`rounded-md bg-primary px-3 py-1.5 text-primary-foreground`:`rounded-md px-3 py-1.5 text-muted-foreground hover:text-foreground`,children:e.charAt(0).toUpperCase()+e.slice(1)},e))})}),(0,z.jsx)(`div`,{role:`tabpanel`,"aria-label":Kkt(a),children:a===`status`?S?(0,z.jsx)(xkt,{status:S,onNavigateAgent:t,onNavigateIssue:n}):x?(0,z.jsx)(`div`,{className:`flex min-h-[200px] items-center justify-center rounded-xl border border-dashed border-border bg-card/40 p-6 text-center`,children:(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`p`,{className:`text-sm font-medium text-foreground`,children:[`Run paused — `,(0,z.jsx)(`code`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono text-xs`,children:`pan flywheel resume`}),` to continue.`]}),(0,z.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:`The orchestrator is paused; its run state is preserved. The status pane will repopulate when it resumes.`})]})}):(0,z.jsx)(`div`,{className:`flex min-h-[200px] items-center justify-center rounded-xl border border-dashed border-border bg-card/40 p-6 text-center`,children:(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`p`,{className:`text-sm font-medium text-foreground`,children:[`No active run — `,(0,z.jsx)(`code`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono text-xs`,children:`pan flywheel start`}),` to begin.`]}),(0,z.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:`The status pane will update as soon as the orchestrator emits its first snapshot.`})]})}):a===`state`?(0,z.jsx)(UOt,{}):(0,z.jsx)(ikt,{})})]})]}),(0,z.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize flywheel panes`,className:`group relative z-30 flex w-1.5 shrink-0 cursor-col-resize items-center justify-center bg-border/40 hover:bg-primary/40 active:bg-primary`,onPointerDown:w,children:(0,z.jsx)(`div`,{className:`h-8 w-0.5 rounded-full bg-border/70 transition-colors group-hover:bg-primary/70 group-active:bg-primary`})}),(0,z.jsx)(`div`,{className:`min-w-0 flex-1 overflow-hidden`,"aria-label":`Flywheel conversation column`,children:(0,z.jsx)(zOt,{onOpenSettings:e})})]})]})}var Zkt={XS:{w:150,h:90},S:{w:168,h:90},M:{w:196,h:94},L:{w:216,h:94},XL:{w:236,h:98}};function Qkt(e){return Zkt[e]??Zkt.M}var $kt={critical:`crit`,high:`high`,medium:`med`,low:`low`};function eAt(e){return(e||`M`).toLowerCase()}function tAt(e,t){if(e.length>1&&t.length<e.length*.75){let t=Math.min(5,Math.ceil(Math.sqrt(e.length*1.4)));return e.map((e,n)=>{let r=n%t,i=Math.floor(n/t);return{...e,position:{x:r*265,y:i*120}}})}let n=new zT.graphlib.Graph;n.setGraph({rankdir:`TB`,nodesep:50,ranksep:80}),n.setDefaultEdgeLabel(()=>({}));for(let t of e){let e=Qkt(t.data.node.size);n.setNode(t.id,{width:e.w,height:e.h})}for(let e of t)n.setEdge(e.source,e.target);return zT.layout(n),e.map(e=>{let{x:t,y:r}=n.node(e.id),i=Qkt(e.data.node.size);return{...e,position:{x:t-i.w/2,y:r-i.h/2}}})}function nAt({data:e}){let{node:t,onSelect:n}=e,r=[`node`,eAt(t.size),$kt[t.importance]??`med`];t.inPipeline&&r.push(`pipe`),t.condition===`needs-refinement`&&r.push(`cond-refine`),t.condition===`stale`&&r.push(`cond-stale`),t.gate===`blocked`&&r.push(`gate-blocked`);let i=t.gate===`ready`&&!t.inPipeline;return i&&r.push(`gate-promoted`),(0,z.jsxs)(`div`,{className:r.join(` `),onClick:()=>n(t),children:[(0,z.jsxs)(`div`,{className:`row1`,children:[(0,z.jsxs)(`span`,{className:`rank`,children:[`#`,t.rank]}),(0,z.jsx)(`span`,{className:`iid`,children:t.issueId}),(0,z.jsx)(`span`,{className:`size-tag`,children:t.size})]}),(0,z.jsx)(`div`,{className:`title`,children:t.title||t.why}),(0,z.jsxs)(`div`,{className:`chips`,children:[i&&(0,z.jsx)(`span`,{className:`chip promoted`,children:`📌 PROMOTED`}),t.gate===`blocked`&&(0,z.jsx)(`span`,{className:`chip held`,children:`⛔ VETOED`}),t.inPipeline&&(0,z.jsxs)(`span`,{className:`chip verb work`,children:[(0,z.jsx)(`span`,{className:`pulsedot`}),`in pipeline`]}),t.condition===`needs-refinement`&&(0,z.jsx)(`span`,{className:`chip refine`,children:`⚠ REFINE`}),t.condition===`stale`&&(0,z.jsx)(`span`,{className:`chip stale`,children:`⊘ STALE`}),t.ready&&(0,z.jsx)(`span`,{className:`chip ready`,children:`✓ READY`}),t.hasPrd&&(0,z.jsx)(`span`,{className:`chip prd`,children:`PRD`}),(0,z.jsx)(`span`,{className:`score`,children:t.score})]})]})}var rAt={issueNode:nAt};function iAt(e,t,n){let r=e.map(e=>({id:e.issueId,type:`issueNode`,position:{x:0,y:0},data:{node:e,onSelect:n}})),i=t.map((e,t)=>{let n=e.type===`informs`,r=n?`color-mix(in srgb, var(--info) 60%, transparent)`:`color-mix(in srgb, var(--muted-foreground) 55%, transparent)`;return{id:`e-${t}-${e.from}-${e.to}`,source:e.from,target:e.to,type:`default`,markerEnd:{type:CC.ArrowClosed,width:14,height:14,color:r},style:{stroke:r,strokeWidth:1.5,strokeDasharray:n?`5 4`:void 0}}});return{nodes:tAt(r,i),edges:i}}var aAt={critical:`var(--destructive)`,high:`var(--warning)`,medium:`var(--color-neutral-400)`,low:`color-mix(in srgb, var(--muted-foreground) 55%, transparent)`},oAt={interactive:`Interactive: a human drives planning — a HARD gate. The Flywheel surfaces it as needs-you and never auto-runs it.`,skip:`Skip: no planning — pan start --auto straight to work (trivial/tiny/urgent).`,auto:`Auto: the AI plans it end-to-end (pan plan --auto).`},sAt={ready:`Promote: jump the queue ahead of rank (and auto-plan it if it has no spec yet).`,blocked:`Vetoed: an absolute NO — never auto-picked, planned, or struck, even to unblock the pipeline.`,auto:`Auto: normal eligibility (Ready · Planned · not parked · not vetoed).`};function cAt(e){let t=[];return e.inPipeline&&t.push({label:`in pipeline`,kind:`pipeline`}),e.condition===`needs-refinement`&&t.push({label:`⚠ needs refinement`,kind:`refine`}),e.condition===`stale`&&t.push({label:`⊘ likely stale · candidate to close`,kind:`stale`}),e.ready&&t.push({label:`✓ READY`,kind:`ready`}),e.hasPrd&&t.push({label:`PRD`,kind:`prd`}),t.length===0&&t.push({label:`not yet planned`,kind:`none`}),t}function lAt(e){let t={fontSize:10,fontWeight:500,letterSpacing:`0.04em`,padding:`1px 6px`,borderRadius:`var(--radius-sm, 4px)`,border:`1px solid`,lineHeight:`15px`,whiteSpace:`nowrap`};switch(e){case`ready`:return{...t,color:`var(--success-foreground)`,borderColor:`color-mix(in srgb, var(--success) 32%, transparent)`,background:`color-mix(in srgb, var(--success) 10%, transparent)`};case`refine`:return{...t,color:`var(--warning-foreground)`,borderColor:`color-mix(in srgb, var(--warning) 32%, transparent)`,background:`color-mix(in srgb, var(--warning) 10%, transparent)`};case`pipeline`:return{...t,color:`var(--info-foreground)`,borderColor:`color-mix(in srgb, var(--info) 32%, transparent)`,background:`color-mix(in srgb, var(--info) 10%, transparent)`};default:return{...t,color:`var(--muted-foreground)`,borderColor:`var(--border)`,background:`var(--accent)`}}}var uAt={display:`grid`,gridTemplateColumns:`auto 1fr`,gap:`7px 14px`,fontSize:12},N9={color:`var(--muted-foreground)`},P9={color:`var(--foreground)`,textAlign:`right`},F9={fontSize:10,textTransform:`uppercase`,letterSpacing:`0.1em`,color:`var(--muted-foreground)`,marginBottom:7},I9={fontSize:12,color:`var(--muted-foreground)`,marginTop:7,lineHeight:1.45};function dAt({value:e,options:t,onChange:n}){return(0,z.jsx)(`div`,{style:{display:`flex`,borderRadius:4,overflow:`hidden`,border:`1px solid var(--color-border)`},children:t.map(t=>{let r=e===t.value;return(0,z.jsx)(`button`,{onClick:()=>n(t.value),style:{flex:1,padding:`3px 6px`,fontSize:10,fontWeight:r?700:400,border:`none`,cursor:`pointer`,background:r?t.activeColor??`#3b82f6`:`var(--color-surface)`,color:r?`#fff`:`var(--color-fg-muted)`,transition:`all 0.15s`},children:t.label},t.value)})})}function L9({label:e,hint:t,on:n,color:r,onChange:i}){return(0,z.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,gap:12,margin:`9px 0`},children:[(0,z.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,z.jsx)(`div`,{style:{fontSize:12,fontWeight:500},children:e}),(0,z.jsx)(`div`,{style:{fontSize:10,color:`var(--muted-foreground)`,lineHeight:1.4,marginTop:2},children:t})]}),(0,z.jsx)(`button`,{onClick:()=>i(!n),"aria-pressed":n,style:{flexShrink:0,width:38,height:22,borderRadius:12,border:`none`,cursor:`pointer`,position:`relative`,background:n?`color-mix(in srgb, ${r} 60%, transparent)`:`var(--input)`,transition:`background 0.15s`},children:(0,z.jsx)(`span`,{style:{position:`absolute`,top:2,left:n?18:2,width:18,height:18,borderRadius:`50%`,background:`#fff`,transition:`left 0.15s`,boxShadow:`0 1px 2px rgba(0,0,0,0.4)`}})})]})}var R9={flex:1,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,gap:4,fontSize:10,textTransform:`uppercase`,letterSpacing:`0.06em`,fontWeight:500,padding:`5px 6px`,borderRadius:6,cursor:`pointer`,border:`1px solid var(--border)`,background:`var(--accent)`,color:`var(--foreground)`};function fAt({node:e,onClose:t,onGateChange:n,onPlanningChange:r,onIssueAction:i}){let[a,o]=(0,R.useState)(e.gate),[s,c]=(0,R.useState)(e.planning),[l,u]=(0,R.useState)(!1),[d,f]=(0,R.useState)(!!e.state?.ready),[p,m]=(0,R.useState)(!!e.state?.parked),[h,g]=(0,R.useState)(!!e.state?.blocksMain),[_,v]=(0,R.useState)(!!e.state?.released),[y,b]=(0,R.useState)(!!e.state?.objection),x=!!e.state?.planned;(0,R.useEffect)(()=>{o(e.gate),c(e.planning),f(!!e.state?.ready),m(!!e.state?.parked),g(!!e.state?.blocksMain),v(!!e.state?.released),b(!!e.state?.objection)},[e.issueId,e.gate,e.planning,e.state]);async function S(t){o(t),u(!0);try{await n(e.issueId,t)}finally{u(!1)}}async function C(t){c(t),u(!0);try{await r(e.issueId,t)}finally{u(!1)}}async function w(t,n){t===`ready`&&f(n),t===`parked`&&m(n),t===`blocksMain`&&g(n),t===`released`&&v(n),t===`objection`&&b(n),u(!0);try{await fetch(`/api/backlog/sequence/labels`,{method:`POST`,headers:await uj(),body:JSON.stringify({issueId:e.issueId,[t]:n})})}finally{u(!1)}}async function T(t){u(!0);try{await fetch(`/api/issues/${e.issueId}/start-planning`,{method:`POST`,headers:await uj(),body:JSON.stringify({auto:t===`auto`,autoStart:!1})}).catch(()=>{})}finally{u(!1)}}async function E(){await w(`objection`,!1),await w(`parked`,!0)}let D=cAt(e),O=Math.max(0,Math.min(100,e.score)),k={fontSize:11,fontWeight:500,padding:`5px 11px`,borderRadius:7,cursor:`pointer`,border:`1px solid var(--border)`,background:`var(--accent)`,color:`var(--foreground)`},A={...k,border:`none`,background:`var(--primary)`,color:`var(--primary-foreground)`},j={...k,border:`1px solid color-mix(in srgb, var(--destructive) 50%, transparent)`,background:`color-mix(in srgb, var(--destructive) 8%, transparent)`,color:`var(--destructive-foreground)`},M={fontSize:11,background:`none`,border:`none`,color:`var(--muted-foreground)`,textDecoration:`underline`,cursor:`pointer`,padding:2},N=e=>({fontSize:10,fontWeight:500,padding:`1px 7px`,borderRadius:5,border:`1px solid`,whiteSpace:`nowrap`,...e===`released`?{color:`var(--success-foreground)`,borderColor:`color-mix(in srgb, var(--success) 40%, transparent)`,background:`color-mix(in srgb, var(--success) 12%, transparent)`}:{color:`var(--info-foreground)`,borderColor:`color-mix(in srgb, var(--info) 34%, transparent)`,background:`color-mix(in srgb, var(--info) 9%, transparent)`}});return(0,z.jsxs)(`div`,{style:{width:320,flexShrink:0,background:`var(--card)`,borderLeft:`1px solid var(--border)`,padding:`16px`,overflowY:`auto`,display:`flex`,flexDirection:`column`,color:`var(--foreground)`},children:[(0,z.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,justifyContent:`space-between`,marginBottom:8},children:[(0,z.jsxs)(`span`,{style:{fontSize:10,textTransform:`uppercase`,letterSpacing:`0.12em`,color:`var(--muted-foreground)`},children:[`Why rank #`,e.rank]}),(0,z.jsx)(`button`,{onClick:t,style:{background:`none`,border:`none`,color:`var(--muted-foreground)`,cursor:`pointer`,fontSize:14,lineHeight:1,padding:`0 2px`},children:`×`})]}),(0,z.jsx)(`div`,{style:{fontFamily:`monospace`,fontSize:12,color:`var(--muted-foreground)`},children:e.issueId}),e.title&&(0,z.jsx)(`div`,{style:{fontSize:14,fontWeight:500,lineHeight:1.35,margin:`2px 0 10px`},children:e.title}),i&&(0,z.jsxs)(`div`,{style:{display:`flex`,gap:6,margin:`${e.title?0:10}px 0 14px`},children:[(0,z.jsx)(`button`,{style:R9,onClick:()=>i(e.issueId,`panel`),title:`Open the full issue cockpit (deep-linked tab)`,children:`⛶ Panel`}),(0,z.jsx)(`button`,{style:R9,onClick:()=>i(e.issueId,`modal`),title:`Open the issue overlay (quick peek, stays on this page)`,children:`▢ Overlay`}),(0,z.jsx)(`button`,{style:R9,onClick:()=>i(e.issueId,`browser`),title:`Open the issue on GitHub in a new tab`,children:`↗ GitHub`})]}),(0,z.jsxs)(`div`,{style:{...uAt,marginTop:e.title?0:12},children:[(0,z.jsx)(`span`,{style:N9,children:`Importance`}),(0,z.jsx)(`span`,{style:P9,children:(0,z.jsxs)(`span`,{style:{display:`inline-flex`,alignItems:`center`,gap:6},children:[(0,z.jsx)(`span`,{style:{width:10,height:10,borderRadius:3,background:aAt[e.importance]??`var(--muted-foreground)`}}),e.importance]})}),(0,z.jsx)(`span`,{style:N9,children:`Impact score`}),(0,z.jsxs)(`span`,{style:{...P9,fontFamily:`monospace`},children:[e.score,` / 100`]})]}),(0,z.jsx)(`div`,{style:{height:5,borderRadius:3,background:`var(--accent)`,overflow:`hidden`,marginTop:3,marginBottom:12},children:(0,z.jsx)(`div`,{style:{height:`100%`,width:`${O}%`,borderRadius:3,background:`linear-gradient(90deg, var(--warning), var(--destructive))`}})}),(0,z.jsxs)(`div`,{style:{...uAt,marginBottom:14},children:[(0,z.jsx)(`span`,{style:N9,children:`Est. size`}),(0,z.jsxs)(`span`,{style:P9,children:[e.size,` effort`]}),(0,z.jsx)(`span`,{style:N9,children:`Depends on`}),(0,z.jsx)(`span`,{style:{...P9,fontFamily:`monospace`},children:e.dependsOn.length?e.dependsOn.join(`, `):`— none`})]}),D.length>0&&(0,z.jsx)(`div`,{style:{display:`flex`,gap:6,flexWrap:`wrap`,marginBottom:14},children:D.map((e,t)=>(0,z.jsx)(`span`,{style:lAt(e.kind),children:e.label},t))}),e.state&&(0,z.jsxs)(`div`,{style:{borderTop:`1px solid var(--border)`,paddingTop:13,marginBottom:13},children:[(0,z.jsxs)(`div`,{style:F9,children:[`Plan → Release · operator (PAN-2059) `,l&&`…`]}),y?(0,z.jsxs)(`div`,{style:{border:`1px solid color-mix(in srgb, var(--destructive) 34%, transparent)`,background:`color-mix(in srgb, var(--destructive) 6%, transparent)`,borderRadius:9,padding:`10px 11px`},children:[(0,z.jsx)(`div`,{style:{fontSize:11.5,color:`var(--destructive-foreground)`,marginBottom:6},children:`🛑 Held for review — AI objection`}),(0,z.jsxs)(`div`,{style:{fontSize:11,color:`var(--muted-foreground)`,lineHeight:1.5,marginBottom:9},children:[`The planning agent objects to this work (doesn't make sense / would worsen the product / superseded).`,` `,i&&(0,z.jsx)(`button`,{style:{...M,padding:0},onClick:()=>i(e.issueId,`browser`),children:`View the write-up on the issue ↗`})]}),(0,z.jsxs)(`div`,{style:{display:`flex`,gap:8,flexWrap:`wrap`},children:[(0,z.jsx)(`button`,{style:j,onClick:()=>w(`objection`,!1),disabled:l,children:`Override → Plan anyway`}),(0,z.jsx)(`button`,{style:k,onClick:E,disabled:l,children:`Accept & park`})]})]}):x?_?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{style:{display:`flex`,gap:8,alignItems:`center`,flexWrap:`wrap`},children:[(0,z.jsx)(`span`,{style:N(`released`),children:`▶ released · pickable`}),(0,z.jsx)(`button`,{style:M,onClick:()=>w(`released`,!1),disabled:l,children:`Recall`})]}),(0,z.jsx)(`div`,{style:I9,children:`Released — eligible for pickup. Recall pulls it back to planned (held).`})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{style:{display:`flex`,gap:8,alignItems:`center`,flexWrap:`wrap`},children:[(0,z.jsx)(`span`,{style:N(`planned`),children:`✓ planned`}),(0,z.jsx)(`button`,{style:A,onClick:()=>w(`released`,!0),disabled:l,children:`Release ▶`}),(0,z.jsx)(`button`,{style:M,onClick:()=>T(`auto`),disabled:l,children:`Re-plan`})]}),(0,z.jsxs)(`div`,{style:I9,children:[`Plan ready — review it, then `,(0,z.jsx)(`b`,{children:`Release`}),` for pickup. `,(0,z.jsx)(`b`,{children:`Not pickable until released.`})]})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{style:{display:`flex`,gap:8,flexWrap:`wrap`},children:[(0,z.jsx)(`button`,{style:A,onClick:()=>T(`auto`),disabled:l,children:`Plan (Auto)`}),(0,z.jsx)(`button`,{style:k,onClick:()=>T(`interactive`),disabled:l,children:`⚑ Plan (Interactive)`})]}),(0,z.jsx)(`div`,{style:I9,children:`Generates the vBRIEF + beads. Auto runs end-to-end and stops before pickup; Interactive opens a Q&A session. The plan must be Released before an agent can pick it up.`})]})]}),e.state&&(0,z.jsxs)(`div`,{style:{borderTop:`1px solid var(--border)`,paddingTop:13,marginBottom:13},children:[(0,z.jsxs)(`div`,{style:F9,children:[`Pipeline state · operator controls `,l&&`…`]}),(0,z.jsx)(L9,{label:`Ready`,color:`var(--success)`,on:d,hint:`Definition of Ready — when off, the Flywheel won't auto-pick it (the entry gate).`,onChange:e=>w(`ready`,e)}),(0,z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,margin:`9px 0`},children:[(0,z.jsx)(`span`,{style:{fontSize:12,fontWeight:500},children:`Planned`}),(0,z.jsx)(`span`,{style:{fontSize:10,fontWeight:500,padding:`1px 6px`,borderRadius:5,border:`1px solid`,...x?{color:`var(--info-foreground)`,borderColor:`color-mix(in srgb, var(--info) 34%, transparent)`,background:`color-mix(in srgb, var(--info) 9%, transparent)`}:{color:`var(--warning-foreground)`,borderColor:`color-mix(in srgb, var(--warning) 34%, transparent)`,background:`color-mix(in srgb, var(--warning) 9%, transparent)`}},children:x?`✓ has spec + beads`:`✗ no spec`}),(0,z.jsx)(`span`,{style:{fontSize:10,color:`var(--muted-foreground)`},children:`derived`})]}),(0,z.jsx)(L9,{label:`Blocks main 🔴`,color:`var(--destructive)`,on:h,hint:`Flywheel prioritizes / strikes it even with auto-pickup off (never if vetoed).`,onChange:e=>w(`blocksMain`,e)}),(0,z.jsx)(L9,{label:`Park`,color:`var(--warning)`,on:p,hint:`Defer — needs human design/discussion; excluded from auto-pickup, reversible.`,onChange:e=>w(`parked`,e)})]}),(0,z.jsxs)(`div`,{style:{borderTop:`1px solid var(--border)`,paddingTop:13,marginBottom:13},children:[(0,z.jsx)(`div`,{style:F9,children:`Planning · AI-suggested, operator-overridable`}),(0,z.jsx)(dAt,{value:s,options:[{value:`skip`,label:`Skip`},{value:`auto`,label:`Auto`},{value:`interactive`,label:`⚑ Interactive`,activeColor:`#b45309`}],onChange:C}),(0,z.jsx)(`div`,{style:I9,children:oAt[s]??``})]}),(0,z.jsxs)(`div`,{style:{marginBottom:13},children:[(0,z.jsxs)(`div`,{style:F9,children:[`Pickup gate · operator `,l&&`…`]}),(0,z.jsx)(dAt,{value:a,options:[{value:`auto`,label:`Auto`},{value:`ready`,label:`📌 Promote`,activeColor:`#15803d`},{value:`blocked`,label:`⛔ Vetoed`,activeColor:`#b91c1c`}],onChange:S}),(0,z.jsx)(`div`,{style:I9,children:sAt[a]??``})]}),(0,z.jsxs)(`div`,{style:{fontSize:12,lineHeight:1.6,color:`color-mix(in srgb, var(--foreground) 88%, transparent)`,borderTop:`1px solid var(--border)`,paddingTop:13},children:[(0,z.jsx)(`div`,{style:{fontSize:10,textTransform:`uppercase`,letterSpacing:`0.1em`,color:`var(--muted-foreground)`,marginBottom:6},children:`AI rationale · from sequence.md`}),e.why,e.rationale&&(0,z.jsx)(`div`,{style:{marginTop:8},children:e.rationale})]})]})}function pAt({data:e,className:t,selectedNodeId:n,onSelectNode:r,onGateChange:i,onPlanningChange:a,onIssueAction:o}){let s=_t(),[c,l]=(0,R.useState)(null),u=r!==void 0,d=u?e.nodes.find(e=>e.issueId===n)??null:c,f=(0,R.useCallback)(e=>{u?r?.(n===e.issueId?null:e):l(t=>t?.issueId===e.issueId?null:e)},[u,r,n]),p=(0,R.useCallback)(()=>{u?r?.(null):l(null)},[u,r]),{nodes:m,edges:h}=(0,R.useMemo)(()=>iAt(e.nodes,e.edges,f),[e.nodes,e.edges,f]),[g,_,v]=Mw(m),[y,b,x]=Nw(h);(0,R.useEffect)(()=>{let{nodes:t,edges:n}=iAt(e.nodes,e.edges,f);if(_(t),b(n),!u&&c){let t=e.nodes.find(e=>e.issueId===c.issueId);t&&l(t)}},[e.nodes,e.edges,f,_,b,c,u]);let S=async(e,t)=>{await fetch(`/api/backlog/sequence/gate`,{method:`POST`,headers:await uj(),body:JSON.stringify({issueId:e,gate:t})}),s.invalidateQueries({queryKey:[`backlog-sequence`]})},C=async(e,t)=>{await fetch(`/api/backlog/sequence/planning`,{method:`POST`,headers:await uj(),body:JSON.stringify({issueId:e,planning:t})}),s.invalidateQueries({queryKey:[`backlog-sequence`]})},w=i??S,T=a??C;return(0,z.jsxs)(`div`,{className:`bk-dag-root${t?` ${t}`:``}`,style:{width:`100%`,height:`100%`,display:`flex`,background:`var(--background)`},children:[(0,z.jsx)(`style`,{children:`
|
|
680
680
|
/* ── Backlog DAG nodes — ported from docs/design/mockups/backlog-sequencer-scaled-opus.html, scoped to .bk-dag-root ── */
|
|
681
681
|
.bk-dag-root .react-flow { background: transparent; }
|
|
@@ -783,7 +783,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
783
783
|
.bkf-bi { font-family:ui-monospace,monospace; font-size:9.5px; color:var(--muted-foreground); }
|
|
784
784
|
.bkf-bt { font-size:10px; font-weight:500; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
|
|
785
785
|
.bkf-makespan { margin-top:10px; font-size:11px; color:var(--muted-foreground); }
|
|
786
|
-
`,bAt={ok:`border border-[color-mix(in_srgb,var(--success)_32%,transparent)] bg-[color-mix(in_srgb,var(--success)_10%,transparent)] text-[var(--success-foreground)]`,"needs-refinement":`border border-[color-mix(in_srgb,var(--warning)_36%,transparent)] bg-[color-mix(in_srgb,var(--warning)_12%,transparent)] text-[var(--warning-foreground)]`,stale:`border border-[var(--color-border)] bg-[var(--accent)] text-[var(--muted-foreground)] line-through opacity-70`},xAt={ready:`border border-[color-mix(in_srgb,var(--success)_32%,transparent)] bg-[color-mix(in_srgb,var(--success)_10%,transparent)] text-[var(--success-foreground)]`,blocked:`border border-[color-mix(in_srgb,var(--destructive)_32%,transparent)] bg-[color-mix(in_srgb,var(--destructive)_10%,transparent)] text-[var(--destructive-foreground)]`,auto:`border border-[var(--color-border)] bg-[var(--accent)] text-[var(--muted-foreground)]`},SAt={critical:`bg-[var(--destructive)]`,high:`bg-[var(--warning)]`,medium:`bg-[var(--color-neutral-400)]`,low:`bg-[var(--muted-foreground)] opacity-60`},B9=`inline-flex items-center gap-1.5 h-7 px-3 rounded-full border text-xs transition-colors`,V9=`border-[var(--color-border)] bg-[var(--color-surface)] text-[var(--color-fg-muted)] hover:border-[color-mix(in_srgb,var(--color-fg)_25%,transparent)]`,H9={info:`border-[color-mix(in_srgb,var(--info)_45%,transparent)] bg-[color-mix(in_srgb,var(--info)_12%,transparent)] text-[var(--info-foreground)]`,success:`border-[color-mix(in_srgb,var(--success)_45%,transparent)] bg-[color-mix(in_srgb,var(--success)_12%,transparent)] text-[var(--success-foreground)]`,warning:`border-[color-mix(in_srgb,var(--warning)_45%,transparent)] bg-[color-mix(in_srgb,var(--warning)_12%,transparent)] text-[var(--warning-foreground)]`,danger:`border-[color-mix(in_srgb,var(--destructive)_45%,transparent)] bg-[color-mix(in_srgb,var(--destructive)_12%,transparent)] text-[var(--destructive-foreground)]`,neutral:`border-[color-mix(in_srgb,var(--color-fg)_28%,transparent)] bg-[color-mix(in_srgb,var(--color-fg)_8%,transparent)] text-[var(--color-fg)]`},U9={info:`bg-[var(--info-foreground)]`,success:`bg-[var(--success-foreground)]`,warning:`bg-[var(--warning-foreground)]`,danger:`bg-[var(--destructive-foreground)]`,neutral:`bg-[var(--color-fg-muted)]`},CAt={now:`Now`,next:`Next`,later:`Later`,someday:`Someday`},wAt={now:`border border-[color-mix(in_srgb,var(--destructive)_34%,transparent)] bg-[color-mix(in_srgb,var(--destructive)_10%,transparent)] text-[var(--destructive-foreground)]`,next:`border border-[color-mix(in_srgb,var(--warning)_34%,transparent)] bg-[color-mix(in_srgb,var(--warning)_10%,transparent)] text-[var(--warning-foreground)]`,later:`border border-[color-mix(in_srgb,var(--info)_30%,transparent)] bg-[color-mix(in_srgb,var(--info)_9%,transparent)] text-[var(--info-foreground)]`,someday:`border border-[var(--color-border)] bg-[var(--accent)] text-[var(--muted-foreground)]`};function W9(e,t){return e<=Math.min(14,t)?`now`:e<=Math.min(52,t)?`next`:e<=Math.min(148,t)?`later`:`someday`}var TAt=150;function EAt({onIssueAction:e}={}){let t=_t(),[n,r]=(0,R.useState)(`dag`),[i,a]=(0,R.useState)(`all`),[o,s]=(0,R.useState)(`all`),[c,l]=(0,R.useState)(!1),[u,d]=(0,R.useState)(!1),[f,p]=(0,R.useState)(!1),[m,h]=(0,R.useState)(!0),[g,_]=(0,R.useState)(!1),[v,y]=(0,R.useState)(!1),[b,x]=(0,R.useState)(`incremental`),[S,C]=(0,R.useState)(!1),[w,T]=(0,R.useState)(null),[E,D]=(0,R.useState)(`now`),[O,k]=(0,R.useState)(``),[A,j]=(0,R.useState)(!1),[M,N]=(0,R.useState)(null),{data:P,isLoading:F,error:I,refetch:ee}=B({queryKey:[`backlog-sequence`],queryFn:async()=>{let e=await fetch(`/api/backlog/sequence`);if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()},refetchInterval:6e4}),{data:te}=B({queryKey:[`sequencer-status`],queryFn:async()=>{let e=await fetch(`/api/backlog/sequencer-status`);if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()},refetchInterval:3e3}),ne=te?.running??!1,L=(0,R.useRef)(!1);(0,R.useEffect)(()=>{L.current&&!ne&&ee(),L.current=ne},[ne,ee]);let[re,ie]=(0,R.useState)(()=>Date.now());(0,R.useEffect)(()=>{if(!ne)return;let e=setInterval(()=>ie(Date.now()),1e3);return()=>clearInterval(e)},[ne]);let ae=te?.startedAt?Math.max(0,Math.floor((re-new Date(te.startedAt).getTime())/1e3)):0,oe=P?.nodes??[],se=(0,R.useMemo)(()=>oe.filter(e=>e.condition===`stale`),[oe]),ce=(0,R.useMemo)(()=>oe.filter(e=>e.condition===`needs-refinement`),[oe]),le=(0,R.useMemo)(()=>{let e=oe.length,t={now:0,next:0,later:0,someday:0};return oe.forEach(n=>{let r=W9(n.rank,e);t[r]++}),t},[oe]),ue=(0,R.useMemo)(()=>oe.filter(e=>e.inPipeline).length,[oe]),de=(0,R.useMemo)(()=>oe.filter(e=>e.state?.ready??!1).length,[oe]),fe=(0,R.useMemo)(()=>oe.filter(e=>e.hasPrd).length,[oe]),pe=(0,R.useMemo)(()=>oe.filter(e=>{if(E&&W9(e.rank,oe.length)!==E||i!==`all`&&e.importance!==i||o!==`all`&&e.condition!==o||c&&!e.inPipeline||u&&!(e.state?.ready??!1)||A&&!e.hasPrd)return!1;if(O){let t=O.toLowerCase();if(!e.issueId.toLowerCase().includes(t)&&!e.why.toLowerCase().includes(t))return!1}return!0}),[oe,i,o,c,u,A,E,O]),me=(0,R.useMemo)(()=>{if(!P)return{nodes:[],edges:[]};let e=pe.length;if(e<=TAt){let e=new Set(pe.map(e=>e.issueId));return{nodes:pe,edges:P.edges.filter(t=>e.has(t.from)&&e.has(t.to))}}let t=Math.max(Math.floor(e*.1),20),n=new Set(pe.slice(0,t).map(e=>e.issueId));pe.filter(e=>e.inPipeline).forEach(e=>n.add(e.issueId));let r=new Set(n);for(let e of P.edges)n.has(e.from)&&r.add(e.to),n.has(e.to)&&r.add(e.from);return{nodes:pe.filter(e=>r.has(e.issueId)),edges:P.edges.filter(e=>r.has(e.from)&&r.has(e.to))}},[P,pe]),he=pe.length-me.nodes.length;async function ge(){if(!g){_(!0),T(null),C(!1);try{let e=await fetch(`/api/backlog/sequence/regenerate`,{method:`POST`,headers:await uj(),body:JSON.stringify({pass:b})});if(!e.ok){let t=`Request failed (HTTP ${e.status})`;try{let n=await e.json();n?.error&&(t=String(n.error))}catch{let n=await e.text().catch(()=>``);n&&(t=n.slice(0,300))}throw Error(t)}setTimeout(()=>ee(),2e3)}catch(e){T(e instanceof Error?e.message:String(e))}finally{_(!1)}}}async function _e(){if(!(v||g)&&window.confirm(`Delete the backlog sequencing? This removes the ranked sequence (sequence.md + cache) and any operator gate overrides. A re-sequence pass regenerates it.`)){y(!0),T(null);try{let e=await fetch(`/api/backlog/sequence/clear`,{method:`POST`,headers:await uj()});if(!e.ok){let t=`Request failed (HTTP ${e.status})`;try{let n=await e.json();n?.error&&(t=String(n.error))}catch{}throw Error(t)}setTimeout(()=>ee(),500)}catch(e){T(e instanceof Error?e.message:String(e))}finally{y(!1)}}}async function ve(e){await fetch(`/api/issues/${e}/start-planning`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})}).catch(()=>{})}async function ye(e){(await fetch(`/api/issues/${e}/close`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})}).catch(()=>null))?.ok&&t.invalidateQueries({queryKey:[`backlog-sequence`]})}async function be(e,n){await fetch(`/api/backlog/sequence/gate`,{method:`POST`,headers:await uj(),body:JSON.stringify({issueId:e,gate:n})}),t.invalidateQueries({queryKey:[`backlog-sequence`]})}async function xe(e,n){await fetch(`/api/backlog/sequence/planning`,{method:`POST`,headers:await uj(),body:JSON.stringify({issueId:e,planning:n})}),t.invalidateQueries({queryKey:[`backlog-sequence`]})}let Se=e=>bAt[e]??`border border-[var(--color-border)] bg-[var(--accent)] text-[var(--muted-foreground)]`,Ce=e=>xAt[e]??`border border-[var(--color-border)] bg-[var(--accent)] text-[var(--muted-foreground)]`;return(0,z.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden bg-[var(--color-bg)] text-[var(--color-fg)]`,children:[(0,z.jsxs)(`div`,{className:`flex items-start gap-4 px-6 py-4 border-b border-[var(--color-border)] shrink-0 flex-wrap bg-[var(--color-bg)]`,children:[(0,z.jsxs)(`div`,{className:`min-w-[280px] flex-1`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(nr,{className:`w-4 h-4 text-[var(--color-accent)]`}),(0,z.jsxs)(`h1`,{className:`font-display text-[22px] leading-tight font-medium tracking-normal text-[var(--color-fg)]`,children:[`Backlog Sequencer`,oe.length>0&&(0,z.jsxs)(`span`,{className:`ml-2 font-mono text-sm font-normal text-[var(--color-fg-muted)]`,children:[`· `,oe.length,` open`]})]})]}),(0,z.jsx)(`p`,{className:`mt-1 max-w-2xl text-[13px] leading-5 text-[var(--color-fg-muted)]`,children:`Ranked backlog flow with active-tier graphing, dependency context, and operator gates for pickup and planning.`})]}),(0,z.jsxs)(`div`,{className:`flex rounded-md overflow-hidden border border-[var(--color-border)] bg-[var(--color-surface)]`,children:[(0,z.jsxs)(`button`,{onClick:()=>r(`list`),className:`px-3 py-1.5 text-xs flex items-center gap-1 ${n===`list`?`bg-[var(--color-accent)] text-[var(--color-primary-foreground)]`:`text-[var(--color-fg-muted)] hover:bg-[var(--color-surface-hover)]`}`,children:[(0,z.jsx)(nr,{className:`w-3 h-3`}),`List`]}),(0,z.jsxs)(`button`,{onClick:()=>r(`dag`),className:`px-3 py-1.5 text-xs flex items-center gap-1 ${n===`dag`?`bg-[var(--color-accent)] text-[var(--color-primary-foreground)]`:`text-[var(--color-fg-muted)] hover:bg-[var(--color-surface-hover)]`}`,children:[(0,z.jsx)(Wn,{className:`w-3 h-3`}),`DAG`]}),(0,z.jsxs)(`button`,{onClick:()=>r(`forecast`),className:`px-3 py-1.5 text-xs flex items-center gap-1 ${n===`forecast`?`bg-[var(--color-accent)] text-[var(--color-primary-foreground)]`:`text-[var(--color-fg-muted)] hover:bg-[var(--color-surface-hover)]`}`,children:[(0,z.jsx)(hr,{className:`w-3 h-3`}),`Forecast`]})]}),(0,z.jsxs)(`button`,{onClick:()=>h(e=>!e),className:`px-3 py-1.5 text-xs flex items-center gap-1 rounded-md border ${m?`border-[var(--color-accent)] text-[var(--color-accent)] bg-[color-mix(in_srgb,var(--color-accent)_8%,transparent)]`:`border-[var(--color-border)] text-[var(--color-fg-muted)] hover:bg-[var(--color-surface-hover)]`}`,children:[(0,z.jsx)(Nn,{className:`w-3 h-3`}),`Filters `,pe.length!==oe.length&&`(${pe.length})`]}),se.length>0&&(0,z.jsxs)(`button`,{onClick:()=>p(e=>!e),className:`px-3 py-1.5 text-xs rounded-md border ${f?`border-[var(--warning)] text-[var(--warning-foreground)] bg-[color-mix(in_srgb,var(--warning)_10%,transparent)]`:`border-[var(--color-border)] text-[var(--color-fg-muted)] hover:bg-[var(--color-surface-hover)]`}`,children:[`⊘ `,se.length,` stale`]}),(0,z.jsxs)(`div`,{className:`relative ml-auto flex items-center gap-1`,children:[(0,z.jsxs)(`button`,{onClick:_e,disabled:v||g||ne,className:`px-2.5 py-1.5 text-xs flex items-center gap-1 rounded-md border border-[var(--color-border)] text-[var(--color-fg-muted)] hover:text-[var(--destructive)] hover:border-[color-mix(in_srgb,var(--destructive)_40%,transparent)] disabled:opacity-50`,title:`Delete the backlog sequencing (sequence.md + cache). Re-sequence regenerates it.`,children:[(0,z.jsx)(Fr,{className:`w-3 h-3`}),v?`Clearing…`:`Clear`]}),(0,z.jsxs)(`button`,{onClick:ge,disabled:g||ne,className:`px-3 py-1.5 text-xs flex items-center gap-1 rounded-md border border-[var(--color-accent)] text-[var(--color-accent)] hover:bg-[color-mix(in_srgb,var(--color-accent)_10%,transparent)] disabled:opacity-50`,title:`Run ${b} pass`,children:[(0,z.jsx)(hr,{className:`w-3 h-3`}),g||ne?`Sequencing…`:`Re-sequence`]}),(0,z.jsx)(`button`,{onClick:()=>C(e=>!e),className:`px-2 py-1.5 text-xs rounded-md border border-[var(--color-border)] text-[var(--color-fg-muted)] hover:bg-[var(--color-surface-hover)]`,title:`Select pass type`,children:`▾`}),S&&(0,z.jsx)(`div`,{className:`absolute right-0 top-full mt-1 z-20 bg-[var(--color-surface)] border border-[var(--color-border)] rounded shadow-lg text-xs`,children:[`auto`,`creation`,`incremental`,`review`].map(e=>(0,z.jsx)(`button`,{onClick:()=>{x(e),C(!1)},className:`block w-full text-left px-3 py-1.5 hover:bg-[var(--color-surface-hover)] ${b===e?`text-[var(--color-accent)]`:`text-[var(--color-fg)]`}`,children:e},e))})]}),(0,z.jsx)(`button`,{onClick:()=>ee(),className:`p-2 rounded-md hover:bg-[var(--color-surface-hover)] text-[var(--color-fg-muted)] hover:text-[var(--color-fg)]`,title:`Refresh`,children:(0,z.jsx)(_r,{className:`w-3.5 h-3.5`})})]}),ne&&(0,z.jsxs)(`div`,{className:`shrink-0 flex items-center gap-2 px-5 py-2 bg-[color-mix(in_srgb,var(--info)_10%,transparent)] border-b border-[color-mix(in_srgb,var(--info)_28%,transparent)] text-xs`,children:[(0,z.jsx)(_r,{className:`w-3.5 h-3.5 animate-spin text-[var(--info-foreground)]`}),(0,z.jsx)(`span`,{className:`text-[var(--info-foreground)] font-medium`,children:`Sequencing pass running`}),(0,z.jsxs)(`span`,{className:`text-[var(--color-fg)]`,children:[`ranked `,(0,z.jsx)(`b`,{className:`font-mono`,children:te?.processed??0}),` / `,(0,z.jsx)(`b`,{className:`font-mono`,children:te?.total??`…`}),` issues`]}),(0,z.jsxs)(`span`,{className:`text-[var(--color-fg-muted)] tabular-nums`,children:[`· `,Math.floor(ae/60),`m `,String(ae%60).padStart(2,`0`),`s`]}),(0,z.jsx)(`span`,{className:`ml-auto text-[var(--color-fg-muted)]`,children:`the new sequence appears automatically when it finishes`})]}),w&&(0,z.jsxs)(`div`,{className:`shrink-0 flex items-center gap-2 px-5 py-1.5 bg-[color-mix(in_srgb,var(--destructive)_10%,transparent)] border-b border-[color-mix(in_srgb,var(--destructive)_26%,transparent)] text-xs`,children:[(0,z.jsx)(`span`,{className:`text-[var(--destructive-foreground)] font-medium`,children:`Run pass failed`}),(0,z.jsx)(`span`,{className:`text-[var(--color-fg-muted)] truncate flex-1`,children:w}),(0,z.jsx)(`button`,{onClick:()=>T(null),className:`px-2 py-0.5 rounded border border-[color-mix(in_srgb,var(--destructive)_32%,transparent)] bg-[color-mix(in_srgb,var(--destructive)_16%,transparent)] text-[var(--destructive-foreground)] hover:bg-[color-mix(in_srgb,var(--destructive)_26%,transparent)] shrink-0`,children:`Dismiss`})]}),m&&(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-3 px-6 py-3 bg-[var(--color-surface)] border-b border-[var(--color-border)] text-xs shrink-0`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,z.jsx)(`span`,{className:`text-[var(--color-fg-muted)]`,children:`Importance:`}),[`all`,`critical`,`high`,`medium`,`low`].map(e=>(0,z.jsx)(`button`,{onClick:()=>a(e),className:`px-2 py-0.5 rounded-md border ${i===e?`border-[var(--color-accent)] bg-[var(--color-accent)] text-[var(--color-primary-foreground)]`:`border-[var(--color-border)] bg-[var(--color-bg)] text-[var(--color-fg-muted)] hover:bg-[var(--color-surface-hover)]`}`,children:e===`all`?`All`:e},e))]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,z.jsx)(`span`,{className:`text-[var(--color-fg-muted)]`,children:`Condition:`}),[`all`,`ok`,`needs-refinement`,`stale`].map(e=>(0,z.jsx)(`button`,{onClick:()=>s(e),className:`px-2 py-0.5 rounded-md border ${o===e?`border-[var(--color-accent)] bg-[var(--color-accent)] text-[var(--color-primary-foreground)]`:`border-[var(--color-border)] bg-[var(--color-bg)] text-[var(--color-fg-muted)] hover:bg-[var(--color-surface-hover)]`}`,children:e===`all`?`All`:e},e))]}),(0,z.jsxs)(`label`,{className:`flex items-center gap-1 cursor-pointer`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:c,onChange:e=>l(e.target.checked),className:`accent-[var(--color-accent)]`}),(0,z.jsx)(`span`,{className:`text-[var(--color-fg-muted)]`,children:`In pipeline`})]}),(0,z.jsxs)(`label`,{className:`flex items-center gap-1 cursor-pointer`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:u,onChange:e=>d(e.target.checked),className:`accent-[var(--color-accent)]`}),(0,z.jsx)(`span`,{className:`text-[var(--color-fg-muted)]`,children:`Ready only`})]}),(0,z.jsxs)(`label`,{className:`flex items-center gap-1 cursor-pointer`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:A,onChange:e=>j(e.target.checked),className:`accent-[var(--color-accent)]`}),(0,z.jsx)(`span`,{className:`text-[var(--color-fg-muted)]`,children:`Has PRD`})]}),(0,z.jsx)(`div`,{className:`ml-auto`,children:(0,z.jsx)(`input`,{type:`text`,value:O,onChange:e=>k(e.target.value),placeholder:`filter by id / title…`,className:`h-6 px-2 rounded border border-[var(--color-border)] bg-[var(--color-bg)] text-[var(--color-fg-muted)] text-xs placeholder:text-[var(--color-fg-muted)]/50 focus:outline-none focus:border-[var(--color-accent)] min-w-[180px]`})})]}),f&&se.length>0&&(0,z.jsxs)(`div`,{className:`shrink-0 border-b border-[var(--color-border)] bg-[var(--color-surface)] px-5 py-3`,children:[(0,z.jsxs)(`div`,{className:`text-xs font-medium text-[var(--color-fg-muted)] mb-2`,children:[`Candidates to close (`,se.length,`)`]}),(0,z.jsx)(`div`,{className:`flex flex-col gap-1.5 max-h-40 overflow-y-auto`,children:se.map(e=>(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,z.jsx)(`span`,{className:`font-mono text-[var(--color-accent)] w-24 shrink-0`,children:e.issueId}),(0,z.jsx)(`span`,{className:`text-[var(--color-fg-muted)] truncate flex-1`,children:e.why}),(0,z.jsx)(`button`,{onClick:()=>ye(e.issueId),className:`px-2 py-0.5 rounded text-[10px] border border-[color-mix(in_srgb,var(--destructive)_32%,transparent)] bg-[color-mix(in_srgb,var(--destructive)_14%,transparent)] text-[var(--destructive-foreground)] hover:bg-[color-mix(in_srgb,var(--destructive)_24%,transparent)] shrink-0`,children:`Close`})]},e.issueId))})]}),ce.length>0&&(0,z.jsxs)(`div`,{className:`shrink-0 flex items-center gap-2 px-5 py-1.5 bg-[color-mix(in_srgb,var(--warning)_10%,transparent)] border-b border-[color-mix(in_srgb,var(--warning)_26%,transparent)] text-xs`,children:[(0,z.jsxs)(`span`,{className:`text-[var(--warning-foreground)] font-medium`,children:[`⚠ `,ce.length,` need refinement`]}),(0,z.jsxs)(`span`,{className:`text-[var(--color-fg-muted)]`,children:[ce.slice(0,5).map(e=>e.issueId).join(`, `),ce.length>5?` +${ce.length-5}`:``]}),(0,z.jsx)(`button`,{onClick:()=>ve(ce[0].issueId),className:`ml-auto px-2 py-0.5 rounded border border-[color-mix(in_srgb,var(--warning)_32%,transparent)] bg-[color-mix(in_srgb,var(--warning)_16%,transparent)] text-[var(--warning-foreground)] hover:bg-[color-mix(in_srgb,var(--warning)_26%,transparent)] shrink-0`,children:`Draft PRD →`})]}),oe.length>0&&(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-2 px-6 py-2.5 border-b border-[var(--color-border)] shrink-0`,children:[(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 h-7 px-3 rounded-full border border-[var(--color-border)] bg-[var(--color-surface)] text-xs text-[var(--color-fg-muted)]`,children:[(0,z.jsx)(`b`,{className:`text-[var(--color-fg)] font-medium font-mono`,children:oe.length}),` open issues`]}),(0,z.jsxs)(`button`,{onClick:()=>l(e=>!e),className:`${B9} ${c?H9.info:V9}`,children:[(0,z.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0 ${U9.info}`}),`In pipeline `,(0,z.jsx)(`b`,{className:`font-mono font-medium text-[var(--color-fg)]`,children:ue})]}),(0,z.jsxs)(`button`,{onClick:()=>d(e=>!e),className:`${B9} ${u?H9.success:V9}`,children:[(0,z.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0 ${U9.success}`}),`Ready `,(0,z.jsx)(`b`,{className:`font-mono font-medium text-[var(--color-fg)]`,children:de})]}),(0,z.jsxs)(`button`,{onClick:()=>j(e=>!e),className:`${B9} ${A?H9.neutral:V9}`,children:[(0,z.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0 ${U9.neutral}`}),`Has PRD `,(0,z.jsx)(`b`,{className:`font-mono font-medium text-[var(--color-fg)]`,children:fe})]}),ce.length>0&&(0,z.jsxs)(`button`,{onClick:()=>s(e=>e===`needs-refinement`?`all`:`needs-refinement`),className:`${B9} ${o===`needs-refinement`?H9.warning:V9}`,children:[(0,z.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0 ${U9.warning}`}),`⚠ Needs refinement `,(0,z.jsx)(`b`,{className:`font-mono font-medium text-[var(--color-fg)]`,children:ce.length})]}),se.length>0&&(0,z.jsxs)(`button`,{onClick:()=>s(e=>e===`stale`?`all`:`stale`),className:`${B9} ${o===`stale`?H9.neutral:V9}`,children:[(0,z.jsx)(`span`,{className:`w-2 h-2 rounded-full opacity-60 shrink-0 ${U9.neutral}`}),`⊘ Stale candidates `,(0,z.jsx)(`b`,{className:`font-mono font-medium text-[var(--color-fg)]`,children:se.length})]}),(0,z.jsxs)(`button`,{onClick:()=>D(e=>e===`now`?null:`now`),className:`${B9} ${E===`now`?H9.danger:V9}`,children:[(0,z.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0 ${U9.danger}`}),`Tier 1 · Now `,(0,z.jsx)(`b`,{className:`font-mono font-medium text-[var(--color-fg)]`,children:le.now})]})]}),oe.length>0&&(0,z.jsx)(`div`,{className:`flex gap-2 px-6 py-3 border-b border-[var(--color-border)] shrink-0`,children:[{key:`now`,emoji:`🔴`,label:`Now`,count:le.now,sub:`act on these first`,accent:`border-l-[var(--destructive)]`,ring:`ring-[color-mix(in_srgb,var(--destructive)_50%,transparent)]`},{key:`next`,emoji:`🟠`,label:`Next`,count:le.next,sub:`queued behind Now`,accent:`border-l-[var(--warning)]`,ring:`ring-[color-mix(in_srgb,var(--warning)_50%,transparent)]`},{key:`later`,emoji:`🔵`,label:`Later`,count:le.later,sub:`planned horizon`,accent:`border-l-[var(--info)]`,ring:`ring-[color-mix(in_srgb,var(--info)_50%,transparent)]`},{key:`someday`,emoji:`⚪`,label:`Someday`,count:le.someday,sub:`long tail`,accent:`border-l-[color-mix(in_srgb,var(--color-fg)_30%,transparent)]`,ring:`ring-[color-mix(in_srgb,var(--color-fg)_30%,transparent)]`}].map(e=>(0,z.jsxs)(`button`,{onClick:()=>D(t=>t===e.key?null:e.key),className:`flex-1 min-w-[140px] flex flex-col gap-0.5 px-3.5 py-2.5 border border-l-4 ${e.accent} rounded-lg bg-[var(--color-surface)] text-left hover:bg-[var(--color-surface-hover)] transition-colors shadow-sm ${E===e.key?`ring-1 ${e.ring} border-[var(--color-border)]`:`border-[var(--color-border)]`}`,children:[(0,z.jsxs)(`span`,{className:`text-xs text-[var(--color-fg)]`,children:[e.emoji,` `,e.label]}),(0,z.jsx)(`span`,{className:`font-mono text-lg font-medium text-[var(--color-fg)] leading-tight`,children:e.count}),(0,z.jsx)(`span`,{className:`text-[10px] text-[var(--color-fg-muted)]`,children:e.sub})]},e.key))}),E&&oe.length>0&&(0,z.jsxs)(`div`,{className:`flex items-center gap-2 px-5 py-1.5 border-b border-[var(--color-border)] bg-[var(--color-surface)] shrink-0 text-xs text-[var(--color-fg-muted)]`,children:[(0,z.jsxs)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] font-medium uppercase tracking-widest bg-[var(--color-accent)] text-[var(--color-fg)]`,children:[`Showing `,CAt[E]]}),(0,z.jsxs)(`span`,{children:[pe.length,` of `,oe.length,` issues`,n===`dag`?` rendered as a graph`:``,` — click the tier again to show all`]})]}),(0,z.jsxs)(`div`,{className:`flex-1 overflow-hidden flex`,children:[(0,z.jsxs)(`div`,{className:`flex-1 min-w-0 overflow-hidden flex flex-col`,children:[F&&(0,z.jsx)(`div`,{className:`flex items-center justify-center h-32 text-[var(--color-fg-muted)] text-sm`,children:`Loading sequence…`}),I&&(0,z.jsx)(`div`,{className:`flex items-center justify-center h-32 text-[var(--destructive-foreground)] text-sm`,children:String(I)}),!F&&!I&&oe.length===0&&(0,z.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-48 gap-3 text-[var(--color-fg-muted)]`,children:[(0,z.jsx)(nr,{className:`w-8 h-8 opacity-40`}),(0,z.jsx)(`p`,{className:`text-sm`,children:`No backlog sequence yet.`}),(0,z.jsx)(`p`,{className:`text-xs`,children:`Run a creation pass to rank the open backlog.`}),(0,z.jsxs)(`button`,{onClick:()=>{x(`creation`),ge()},disabled:g,className:`px-3 py-1.5 text-xs rounded border border-[var(--color-accent)] text-[var(--color-accent)] hover:bg-[var(--color-accent)]/10 disabled:opacity-50 flex items-center gap-1`,children:[(0,z.jsx)(hr,{className:`w-3 h-3`}),g?`Spawning…`:`Run creation pass`]})]}),!F&&!I&&oe.length>0&&n===`list`&&(0,z.jsx)(`div`,{className:`overflow-y-auto flex-1`,children:(0,z.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,z.jsx)(`thead`,{className:`sticky top-0 bg-[var(--color-surface)] border-b border-[var(--color-border)]`,children:(0,z.jsxs)(`tr`,{className:`text-[var(--color-fg-muted)]`,children:[(0,z.jsx)(`th`,{className:`text-right px-3 py-2 font-medium w-8 cursor-help`,title:`Pickup rank — lower means the Flywheel works it sooner`,children:`#`}),(0,z.jsx)(`th`,{className:`text-left px-2 py-2 font-medium w-6 cursor-help`,title:`Importance — red = critical, orange = high, gray = medium, dim = low`,children:`●`}),(0,z.jsx)(`th`,{className:`text-left px-2 py-2 font-medium w-28 cursor-help`,title:`Issue ID. Markers: ▶ in pipeline · ⚠ needs refinement · P has PRD · ✓ planned (spec + beads)`,children:`Issue`}),(0,z.jsx)(`th`,{className:`text-center px-2 py-2 font-medium w-16 cursor-help`,title:`Tier band by rank: Now · Next · Later · Someday`,children:`Tier`}),(0,z.jsx)(`th`,{className:`text-left px-2 py-2 font-medium cursor-help`,title:`One-line rationale for this ranking (from the sequencer)`,children:`Why`}),(0,z.jsx)(`th`,{className:`text-center px-2 py-2 font-medium w-14 cursor-help`,title:`Estimated effort: XS / S / M / L / XL`,children:`Size`}),(0,z.jsx)(`th`,{className:`text-center px-2 py-2 font-medium w-24 cursor-help`,title:`AI condition: ok · needs-refinement (vague spec) · stale (likely close)`,children:`Condition`}),(0,z.jsx)(`th`,{className:`text-center px-2 py-2 font-medium w-20 cursor-help`,title:`Operator pickup gate: auto (normal) · promote (jump queue) · vetoed (never pick)`,children:`Gate`}),(0,z.jsx)(`th`,{className:`text-center px-2 py-2 font-medium w-14 cursor-help`,title:`Impact score (0–100) the sequencer assigned`,children:`Score`})]})}),(0,z.jsx)(`tbody`,{children:pe.map(e=>{let t=W9(e.rank,oe.length),n=e.condition===`stale`,r=e.condition===`needs-refinement`,i=M?.issueId===e.issueId;return(0,z.jsxs)(`tr`,{onClick:()=>N(t=>t?.issueId===e.issueId?null:e),className:`transition-colors cursor-pointer ${n?`opacity-50`:``} ${i?`bg-[color-mix(in_srgb,var(--color-accent)_14%,transparent)] ring-inset ring-1 ring-[var(--color-accent)]`:`even:bg-[color-mix(in_srgb,var(--color-fg)_3%,transparent)] hover:bg-[color-mix(in_srgb,var(--color-fg)_9%,transparent)]`}`,children:[(0,z.jsx)(`td`,{className:`text-right px-3 py-2 text-[var(--color-fg-muted)] tabular-nums border-l-2 ${e.inPipeline?`border-l-[var(--info)]`:`border-l-transparent`}`,children:e.rank}),(0,z.jsx)(`td`,{className:`px-2 py-2`,children:(0,z.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full ${SAt[e.importance]??`bg-[var(--color-fg-muted)]`}`,title:`Importance: ${e.importance}`})}),(0,z.jsxs)(`td`,{className:`px-2 py-2 font-mono text-[var(--color-accent)]`,children:[e.issueId,e.inPipeline&&(0,z.jsx)(`span`,{className:`ml-1 text-[9px] text-[var(--info-foreground)] align-top`,title:`In pipeline — active work / review / test`,children:`▶`}),r&&(0,z.jsx)(`span`,{className:`ml-1 text-[9px] text-[var(--warning-foreground)] align-top`,title:`Needs refinement — vague/underspecified`,children:`⚠`}),e.hasPrd&&(0,z.jsx)(`span`,{className:`ml-1 text-[9px] text-[var(--info-foreground)] align-top`,title:`Has PRD`,children:`P`}),e.ready&&(0,z.jsx)(`span`,{className:`ml-1 text-[9px] text-[var(--success-foreground)] align-top`,title:`Has spec — ready for work`,children:`✓`})]}),(0,z.jsx)(`td`,{className:`px-2 py-2 text-center`,children:(0,z.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] font-medium ${wAt[t]??`border border-[var(--color-border)] bg-[var(--accent)] text-[var(--muted-foreground)]`}`,children:CAt[t]})}),(0,z.jsx)(`td`,{className:`px-2 py-2 text-[var(--color-fg)] max-w-xs truncate ${n?`line-through`:``}`,children:e.why}),(0,z.jsx)(`td`,{className:`px-2 py-2 text-center text-[var(--color-fg-muted)]`,children:e.size}),(0,z.jsx)(`td`,{className:`px-2 py-2 text-center`,children:(0,z.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] font-medium ${Se(e.condition)}`,title:e.condition===`needs-refinement`?`Needs refinement — vague/underspecified`:e.condition===`stale`?`Stale — likely a candidate to close`:`OK — well-specified`,children:e.condition===`needs-refinement`?`⚠ refine`:e.condition===`stale`?`⊘ stale`:e.condition})}),(0,z.jsx)(`td`,{className:`px-2 py-2 text-center`,children:(0,z.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] font-medium ${Ce(e.gate)}`,title:e.gate===`ready`?e.inPipeline?`Auto (in-pipeline pin)`:`Promoted — jumps the queue`:e.gate===`blocked`?`Vetoed — never auto-picked`:`Auto — normal eligibility`,children:e.gate===`ready`?e.inPipeline?`auto`:`📌`:e.gate===`blocked`?`⛔`:e.gate})}),(0,z.jsx)(`td`,{className:`px-2 py-2 text-center text-[var(--color-fg-muted)] tabular-nums`,children:e.score})]},e.issueId)})})]})}),!F&&!I&&oe.length>0&&n===`dag`&&P&&(0,z.jsxs)(`div`,{className:`flex-1 flex flex-col min-h-0`,children:[he>0&&(0,z.jsxs)(`div`,{className:`shrink-0 text-xs text-center py-1 bg-[var(--color-surface)] border-b border-[var(--color-border)] text-[var(--color-fg-muted)]`,children:[`Showing `,me.nodes.length,` of `,pe.length,` issues (top tier + neighbors); `,he,` collapsed`]}),(0,z.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,z.jsx)(pAt,{data:me,className:`w-full h-full`,selectedNodeId:M?.issueId,onSelectNode:e=>N(e),onGateChange:be,onPlanningChange:xe,onIssueAction:e})})]}),!F&&!I&&oe.length>0&&n===`forecast`&&(0,z.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,z.jsx)(_At,{className:`w-full h-full`,onSelectIssue:e=>N(oe.find(t=>t.issueId===e)??null)})})]}),M&&(0,z.jsx)(fAt,{node:M,onClose:()=>N(null),onGateChange:be,onPlanningChange:xe,onIssueAction:e})]})]})}var DAt={exploring:{label:`Exploring`,color:`var(--primary)`,icon:wr},planning:{label:`Planning`,color:`var(--signal-review, var(--primary))`,icon:mn},building:{label:`Building`,color:`var(--success, #10b981)`,icon:Zt},verifying:{label:`Verifying`,color:`var(--warning, #f59e0b)`,icon:sn},cleaning:{label:`Cleaning`,color:`var(--muted-foreground)`,icon:Iee},shipping:{label:`Shipping`,color:`var(--primary)`,icon:vr}};function OAt(e){return e.filter(e=>e.actionStatus!==null).sort((e,t)=>t.timestamp.localeCompare(e.timestamp)).slice(0,3)}function kAt(e,t){if(!e)return!1;let n=Date.parse(e.timestamp);return!Number.isNaN(n)&&t.getTime()-n>3600*1e3}function G9({label:e,value:t,tone:n}){return(0,z.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,z.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:e}),(0,z.jsx)(`span`,{className:`text-xs font-semibold`,style:{color:n??`var(--foreground)`},children:t})]})}function AAt({issue:e,status:t,observations:n,stats:r,onOpenWorkspaceHome:i,now:a=new Date}){let o=t?.phase??`exploring`,s=DAt[o],c=s.icon,l=OAt(n),u=kAt(l[0],a),d=t?.headline||e.title,f=t?.summary||e.description||`No workspace status summary yet.`;return(0,z.jsxs)(`button`,{type:`button`,"data-testid":`workspace-status-card`,onClick:i,className:`w-full text-left bg-card border border-border rounded-lg p-3 hover:border-primary/50 hover:bg-popover transition-colors`,"aria-label":`Open ${e.identifier} workspace overview`,children:[(0,z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,z.jsx)(`div`,{"data-testid":`workspace-status-phase-icon`,"data-phase":o,className:`mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-full border`,style:{color:s.color,borderColor:s.color,background:`color-mix(in srgb, currentColor 10%, transparent)`},children:(0,z.jsx)(c,{className:`h-4 w-4`})}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`h3`,{className:`truncate text-sm font-semibold text-foreground`,title:d,children:d}),(0,z.jsx)(`span`,{"data-testid":`workspace-status-phase-label`,className:`shrink-0 rounded-full border px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide`,style:{color:s.color,borderColor:s.color},children:s.label}),u&&(0,z.jsxs)(`span`,{"data-testid":`workspace-status-stale`,className:`ml-auto flex shrink-0 items-center gap-1 text-[10px] font-semibold text-warning`,children:[(0,z.jsx)(Ir,{className:`h-3 w-3`}),`Stale`]})]}),(0,z.jsx)(`p`,{"data-testid":`workspace-status-summary`,className:`mt-1 text-xs text-muted-foreground`,style:{display:`-webkit-box`,WebkitLineClamp:3,WebkitBoxOrient:`vertical`,overflow:`hidden`},children:f})]})]}),(0,z.jsx)(`ul`,{"data-testid":`workspace-status-observations`,className:`mt-3 space-y-1 text-xs text-muted-foreground`,children:l.length===0?(0,z.jsx)(`li`,{className:`text-muted-foreground/70`,children:`No recent action status.`}):l.map(e=>(0,z.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full bg-primary`}),e.actionStatus?(0,z.jsx)(C5,{status:e.actionStatus}):null,(0,z.jsx)(`span`,{className:`min-w-0 truncate`,title:e.summary,children:e.summary})]},e.id))}),(0,z.jsxs)(`div`,{className:`mt-3 grid grid-cols-4 gap-3 border-t border-border pt-3`,children:[(0,z.jsx)(G9,{label:`Additions`,value:`+${r.additions}`,tone:`var(--success, #10b981)`}),(0,z.jsx)(G9,{label:`Deletions`,value:`-${r.deletions}`,tone:`var(--destructive)`}),(0,z.jsx)(G9,{label:`Commits`,value:r.commits}),(0,z.jsx)(G9,{label:`PRs`,value:r.prs})]})]})}var jAt={justNow:`Just Now`,earlierToday:`Earlier Today`,yesterday:`Yesterday`,thisWeek:`This Week`,thisMonth:`This Month`,older:`Older`},MAt=[`justNow`,`earlierToday`,`yesterday`,`thisWeek`,`thisMonth`,`older`];async function NAt(){let e=await fetch(`/api/registry/features`);if(!e.ok)throw Error(`Registry request failed (${e.status})`);let t=await e.json();return Array.isArray(t.entries)?t.entries:[]}async function PAt(){let e=await fetch(`/api/metrics/summary`);if(!e.ok)throw Error(`Metrics summary request failed (${e.status})`);return e.json()}function FAt({onOpenWorkspaceHome:e,onNewProject:t,onSelectProject:n,onOpenSettings:r,now:i}={}){let a=B({queryKey:[`feature-registry`],queryFn:NAt,staleTime:3e4,retry:!1}),o=B({queryKey:[`metrics-summary`],queryFn:PAt,staleTime:3e4,retry:!1}),s=B({queryKey:[`command-deck-projects`],queryFn:K5,staleTime:3e4,retry:!1}),c=s.data??[],l=sm(e=>e.issuesRaw),u=sm(e=>e.statusByIssueId),d=sm(e=>e.observationsByIssueId),f=sm(e=>e.agentsById),p=sm(e=>e.reviewStatusByIssueId),m=sm(Che),h=i??new Date,g=(0,R.useMemo)(()=>qAt({issuesRaw:l,statusByIssueId:u,observationsByIssueId:d,agentsById:f,reviewStatusByIssueId:p}),[f,l,d,p,u]),_=(0,R.useMemo)(()=>KAt(d),[d]),v=(0,R.useMemo)(()=>VAt(BAt({agentsById:f,reviewStatusByIssueId:p,dailyCost:o.data?.today?.totalCost,now:h})),[f,h,o.data?.today?.totalCost,p]);return(0,z.jsx)(`div`,{className:`h-full w-full overflow-y-auto bg-background`,children:(0,z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-7xl flex-col gap-6 p-6`,children:[(0,z.jsxs)(`header`,{className:`rounded-xl border border-border bg-card p-6 shadow-sm`,children:[(0,z.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.2em] text-muted-foreground`,children:`Overdeck Home`}),(0,z.jsx)(`h1`,{className:`mt-2 text-3xl font-semibold text-foreground`,children:`System briefing`}),(0,z.jsx)(`p`,{className:`mt-2 max-w-3xl text-sm text-muted-foreground`,children:`A live landing page for current workspace context, cross-workspace ownership, and memory-first guidance.`})]}),(0,z.jsx)(`section`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-5`,"aria-label":`Home summary`,children:v.map(e=>(0,z.jsxs)(`div`,{className:`rounded-xl border border-border bg-card p-4 shadow-sm`,children:[(0,z.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-muted-foreground`,children:e.label}),(0,z.jsx)(`p`,{className:`mt-2 text-2xl font-semibold tabular-nums ${e.tone??`text-foreground`}`,children:e.value}),(0,z.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:e.detail})]},e.label))}),(0,z.jsx)(IAt,{observations:_,failure:m,onOpenSettings:r,now:h}),(0,z.jsxs)(`section`,{className:`rounded-xl border border-border bg-card p-5 shadow-sm`,"aria-labelledby":`workspace-status-title`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h2`,{id:`workspace-status-title`,className:`text-lg font-semibold text-foreground`,children:`Workspaces`}),(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Live workspace status rollups from memory observations.`})]}),(0,z.jsx)(`div`,{className:`mt-4`,children:g.length>0?(0,z.jsx)(`div`,{className:`grid gap-3 lg:grid-cols-2`,children:g.map(t=>(0,z.jsx)(AAt,{issue:t.issue,status:t.status,observations:t.observations,stats:t.stats,onOpenWorkspaceHome:()=>e?.(t.issue.identifier),now:i},t.issue.identifier))}):(0,z.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border bg-muted/20 p-4 text-sm text-muted-foreground`,children:[(0,z.jsx)(`p`,{className:`font-medium text-foreground`,children:`No workspace status is available yet.`}),(0,z.jsx)(`p`,{className:`mt-1`,children:`Workspace cards will appear after memory status or observations are recorded for an issue.`})]})})]}),(0,z.jsxs)(`section`,{className:`rounded-xl border border-border bg-card p-5 shadow-sm`,"aria-labelledby":`knowledge-registry-title`,children:[(0,z.jsxs)(`div`,{className:`flex flex-col gap-1 sm:flex-row sm:items-start sm:justify-between`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h2`,{id:`knowledge-registry-title`,className:`text-lg font-semibold text-foreground`,children:`Knowledge Registry`}),(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Feature ownership across issues, workspaces, and agents.`})]}),a.isFetching&&(0,z.jsx)(`span`,{className:`mt-2 rounded-full border border-border px-2 py-1 text-xs text-muted-foreground sm:mt-0`,children:`Refreshing`})]}),(0,z.jsx)(`div`,{className:`mt-4`,children:a.isError?(0,z.jsx)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/10 p-4 text-sm text-destructive`,role:`alert`,children:`Knowledge Registry could not be loaded. The rest of Home is still available.`}):a.isLoading?(0,z.jsx)(`div`,{className:`rounded-lg border border-border bg-muted/30 p-4 text-sm text-muted-foreground`,children:`Loading registry entries…`}):a.data&&a.data.length>0?(0,z.jsx)($At,{entries:a.data}):(0,z.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border bg-muted/20 p-4 text-sm text-muted-foreground`,children:[(0,z.jsx)(`p`,{className:`font-medium text-foreground`,children:`No features are registered yet.`}),(0,z.jsxs)(`p`,{className:`mt-1`,children:[`Add one with `,(0,z.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 font-mono text-xs`,children:`pan registry tag <issueId> <feature>`}),`. Automatic classification will populate future entries as issue and workspace lifecycle wiring lands.`]})]})})]}),(0,z.jsxs)(`section`,{className:`rounded-xl border border-border bg-card p-5 shadow-sm`,"aria-labelledby":`home-projects-title`,"data-testid":`home-projects`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h2`,{id:`home-projects-title`,className:`text-lg font-semibold text-foreground`,children:`Projects`}),(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Your registered projects — click one to open its deck.`})]}),t&&(0,z.jsx)(`button`,{"data-testid":`home-new-project`,onClick:t,className:`rounded-lg border border-border bg-muted/20 px-3 py-1.5 text-sm font-medium text-foreground hover:bg-accent transition-colors`,children:`+ New project`})]}),(0,z.jsx)(`div`,{className:`mt-4`,children:s.isLoading?(0,z.jsx)(`div`,{className:`rounded-lg border border-border bg-muted/30 p-4 text-sm text-muted-foreground`,children:`Loading projects…`}):s.isError?(0,z.jsx)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/10 p-4 text-sm text-destructive`,role:`alert`,children:`Projects could not be loaded. The rest of Home is still available.`}):c.length>0?(0,z.jsx)(`ul`,{className:`divide-y divide-border rounded-lg border border-border`,children:c.map(e=>{let t=e.features.length>0;return(0,z.jsx)(`li`,{children:(0,z.jsxs)(`button`,{"data-testid":`home-project-${e.name}`,onClick:()=>n?.(e.name),title:e.path,className:`flex w-full items-center gap-3 px-4 py-3 text-left text-sm font-medium text-foreground transition-colors hover:bg-accent`,children:[(0,z.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${t?`bg-primary`:`bg-muted-foreground/30`}`,"aria-hidden":`true`}),(0,z.jsx)(`span`,{className:`truncate`,children:e.name}),t&&(0,z.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:e.features.length})]})},e.path)})}):(0,z.jsxs)(`div`,{"data-testid":`home-projects-empty`,className:`rounded-lg border border-dashed border-border bg-muted/20 p-4 text-sm text-muted-foreground`,children:[(0,z.jsx)(`p`,{className:`font-medium text-foreground`,children:`No projects yet.`}),(0,z.jsx)(`p`,{className:`mt-1`,children:`Create your first project to get started.`}),t&&(0,z.jsx)(`button`,{"data-testid":`home-new-project-empty`,onClick:t,className:`mt-3 rounded-lg border border-border bg-background px-3 py-1.5 text-sm font-medium text-foreground hover:bg-accent transition-colors`,children:`+ New project`})]})})]})]})})}function IAt({observations:e,failure:t,onOpenSettings:n,now:r}){let i=(0,R.useMemo)(()=>_yt(e,e=>e.timestamp,r),[e,r]);return(0,z.jsxs)(`section`,{className:`rounded-xl border border-border bg-card p-5 shadow-sm`,"aria-labelledby":`home-activity-title`,"data-testid":`home-activity-feed`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h2`,{id:`home-activity-title`,className:`text-lg font-semibold text-foreground`,children:`Activity Feed`}),(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Recent actionable memory observations across workspaces.`})]}),t&&(0,z.jsx)(LAt,{failure:t,onOpenSettings:n}),e.length===0?(0,z.jsxs)(`div`,{"data-testid":`home-activity-empty`,className:`mt-4 rounded-lg border border-dashed border-border bg-muted/20 p-4 text-sm text-muted-foreground`,children:[(0,z.jsx)(`p`,{className:`font-medium text-foreground`,children:`No actionable observations yet.`}),(0,z.jsx)(`p`,{className:`mt-1`,children:`Observations are extracted from running work agents — they appear here once an agent makes a change worth recording.`})]}):(0,z.jsx)(`div`,{className:`mt-4 space-y-5`,children:MAt.map(e=>{let t=i[e];return t.length===0?null:(0,z.jsxs)(`section`,{"data-testid":`home-activity-bucket-${e}`,children:[(0,z.jsx)(`h3`,{className:`mb-2 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:jAt[e]}),(0,z.jsx)(`ul`,{className:`space-y-2`,children:t.map(e=>(0,z.jsx)(zAt,{observation:e,now:r},e.id))})]},e)})})]})}function LAt({failure:e,onOpenSettings:t}){let n=RAt(e);return(0,z.jsx)(`div`,{"data-testid":`home-memory-failure`,className:`mt-4 rounded-lg border border-destructive/32 bg-destructive/8 p-4 text-sm text-foreground`,role:`alert`,children:(0,z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,z.jsx)(Ir,{className:`mt-0.5 h-4 w-4 shrink-0 text-destructive`,"aria-hidden":`true`}),(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`p`,{className:`font-medium text-destructive`,children:`Memory extraction is failing`}),(0,z.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:n}),e.detail?(0,z.jsx)(`p`,{className:`mt-2 break-words font-mono text-[11px] text-muted-foreground`,children:e.detail}):null,(0,z.jsx)(`p`,{className:`mt-2 text-[11px] text-muted-foreground`,children:`Memory observations and agent memory injection are disabled until this is fixed.`}),t?(0,z.jsx)(`button`,{onClick:t,className:`mt-3 rounded-sm border border-border bg-background px-2.5 py-1 text-xs font-medium text-foreground hover:bg-accent transition-colors`,children:`Open Settings › Memory`}):null]})]})})}function RAt(e){let t=(e.detail??``).toLowerCase();return t.includes(`could not resolve authentication`)||t.includes(`anthropic_api_key`)||t.includes(`x-api-key`)?`The Anthropic API provider has no API key. Switch the extraction provider to cliproxy (your ChatGPT subscription) in Settings › Memory.`:t.includes(`unknown provider for model`)||t.includes(`does not exist`)||t.includes(`unknown model`)?`The configured extraction model is not available on cliproxy. Pick a served model (e.g. gpt-5.4-mini) in Settings › Memory.`:t.includes(`401`)||t.includes(`unauthorized`)||t.includes(`expired`)?`The extraction provider rejected the credentials — the codex/ChatGPT subscription token used by cliproxy may have expired. Re-authenticate, then it will recover automatically.`:`Background memory-extraction calls are failing. Check the extraction provider and model in Settings › Memory.`}function zAt({observation:e,now:t}){return(0,z.jsxs)(`li`,{className:`rounded-lg border border-border bg-background p-3 text-xs`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(C5,{status:e.actionStatus}),(0,z.jsx)(`p`,{className:`font-semibold text-foreground`,children:e.summary})]}),(0,z.jsxs)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:[e.workspaceId,` · `,e.issueId,` · `,(0,z.jsx)(`time`,{dateTime:e.timestamp,children:oM(e.timestamp,t)})]}),e.narrative?(0,z.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-muted-foreground`,children:e.narrative}):null,e.files.length>0?(0,z.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1`,"aria-label":`Files`,children:e.files.map(e=>(0,z.jsx)(`code`,{className:`rounded border border-border bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground`,children:e},e))}):null,e.tags.length>0?(0,z.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1`,"aria-label":`Tags`,children:e.tags.map(e=>(0,z.jsx)(`span`,{className:`rounded-full border border-border px-1.5 py-0.5 text-[10px] text-muted-foreground`,children:e},e))}):null,(0,z.jsx)(`div`,{className:`mt-2 flex justify-end`,children:(0,z.jsx)(PM,{kind:`memory`})})]})}function BAt({agentsById:e={},reviewStatusByIssueId:t={},dailyCost:n,now:r}){let i=Object.values(e),a=Object.values(t);return{runningAgents:i.filter(HAt).length,gatedAgents:i.filter(UAt).length,recentMerges:a.filter(e=>WAt(e,r)).length,failedVerifications:a.filter(GAt).length,dailyCost:typeof n==`number`&&Number.isFinite(n)?n:null}}function VAt(e){return[{label:`Running agents`,value:String(e.runningAgents),detail:`Live or starting sessions`,tone:e.runningAgents>0?`text-primary`:void 0},{label:`Paused / troubled`,value:String(e.gatedAgents),detail:`Agents gated by pause or failures`,tone:e.gatedAgents>0?`text-warning`:void 0},{label:`Merged today`,value:String(e.recentMerges),detail:`Merges in the last 24 hours`,tone:e.recentMerges>0?`text-success`:void 0},{label:`Needs verification`,value:String(e.failedVerifications),detail:`Failed checks or merge blockers`,tone:e.failedVerifications>0?`text-destructive`:void 0},{label:`Cost today`,value:e.dailyCost===null?`Unavailable`:`$${e.dailyCost.toFixed(2)}`,detail:`UTC daily cost summary`,tone:e.dailyCost===null?`text-muted-foreground`:`text-success`}]}function HAt(e){return e.hasLiveTmuxSession===!0||e.status===`running`||e.status===`starting`}function UAt(e){return e.paused===!0||e.troubled===!0||(e.consecutiveFailures??0)>0}function WAt(e,t){if(e.mergeStatus!==`merged`||!e.updatedAt)return!1;let n=Date.parse(e.updatedAt);return!Number.isNaN(n)&&t.getTime()-n<=1440*60*1e3}function GAt(e){return e.verificationStatus===`failed`||e.testStatus===`failed`||e.uatStatus===`failed`||(e.blockerReasons?.length??0)>0}function KAt(e){return Object.values(e).flatMap(e=>e).filter(e=>e.actionStatus!==null).sort((e,t)=>t.timestamp.localeCompare(e.timestamp))}function qAt({issuesRaw:e,statusByIssueId:t={},observationsByIssueId:n={},agentsById:r={},reviewStatusByIssueId:i={}}){let a=new Map;for(let t of e){let e=ZAt(t);e&&a.set(e.identifier,e)}let o=new Set;for(let e of Object.keys(t))o.add(e);for(let[e,t]of Object.entries(n))t.length>0&&o.add(e);for(let e of Object.values(r))e.issueId&&JAt(e)&&o.add(e.issueId);return[...o].sort().map(e=>{let r=t[e],o=n[e]??[];return{issue:a.get(e)??{identifier:e,title:r?.headline||e,description:r?.summary},status:r,observations:o,stats:YAt(o,i[e])}})}function JAt(e){return e.hasLiveTmuxSession===!0||[`healthy`,`running`,`starting`,`stuck`,`warning`].includes(e.status)}function YAt(e,t){return{additions:0,deletions:0,commits:e.filter(XAt).length,prs:+!!t?.prUrl}}function XAt(e){return e.tags.some(e=>[`commit`,`commits`,`git.commit`].includes(e.toLowerCase()))}function ZAt(e){return!QAt(e)||typeof e.identifier!=`string`||typeof e.title!=`string`?null:{identifier:e.identifier,title:e.title,description:typeof e.description==`string`?e.description:void 0}}function QAt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function $At({entries:e}){return(0,z.jsx)(`div`,{className:`overflow-hidden rounded-lg border border-border`,children:(0,z.jsx)(`div`,{className:`overflow-x-auto`,children:(0,z.jsxs)(`table`,{className:`min-w-full divide-y divide-border text-sm`,children:[(0,z.jsx)(`thead`,{className:`bg-muted/40 text-left text-xs uppercase tracking-wide text-muted-foreground`,children:(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`th`,{scope:`col`,className:`px-4 py-3 font-semibold`,children:`Feature`}),(0,z.jsx)(`th`,{scope:`col`,className:`px-4 py-3 font-semibold`,children:`Issue`}),(0,z.jsx)(`th`,{scope:`col`,className:`px-4 py-3 font-semibold`,children:`Workspace`}),(0,z.jsx)(`th`,{scope:`col`,className:`px-4 py-3 font-semibold`,children:`Agent`}),(0,z.jsx)(`th`,{scope:`col`,className:`px-4 py-3 font-semibold`,children:`Status`}),(0,z.jsx)(`th`,{scope:`col`,className:`px-4 py-3 font-semibold`,children:`Updated`}),(0,z.jsx)(`th`,{scope:`col`,className:`px-4 py-3 font-semibold`,children:`Tags`})]})}),(0,z.jsx)(`tbody`,{className:`divide-y divide-border bg-card`,children:e.map(e=>(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`td`,{className:`px-4 py-3 font-medium text-foreground`,children:e.featureName}),(0,z.jsx)(`td`,{className:`px-4 py-3 font-mono text-xs text-muted-foreground`,children:e.owningIssueId??`—`}),(0,z.jsx)(`td`,{className:`px-4 py-3 font-mono text-xs text-muted-foreground`,children:e.owningWorkspaceId??`—`}),(0,z.jsx)(`td`,{className:`px-4 py-3 font-mono text-xs text-muted-foreground`,children:e.owningAgentId??`—`}),(0,z.jsx)(`td`,{className:`px-4 py-3`,children:(0,z.jsx)(`span`,{className:`rounded-full border border-border bg-muted/30 px-2 py-1 text-xs font-medium text-foreground`,children:e.status})}),(0,z.jsx)(`td`,{className:`px-4 py-3 text-xs text-muted-foreground`,children:ejt(e.updatedAt)}),(0,z.jsx)(`td`,{className:`px-4 py-3 text-xs text-muted-foreground`,children:e.tags.length>0?e.tags.join(`, `):`—`})]},e.featureId))})]})})})}function ejt(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}async function tjt(e){let t=await fJ(e?`/api/fs/list-dirs?path=${encodeURIComponent(e)}`:`/api/fs/list-dirs`,{credentials:`include`});if(!t.ok)throw Error(`list-dirs failed: ${t.status}`);return t.json()}function njt({onSelect:e,initialPath:t}){let[n,r]=(0,R.useState)(null),[i,a]=(0,R.useState)(!0),[o,s]=(0,R.useState)(null),c=(0,R.useCallback)(e=>{a(!0),s(null),tjt(e).then(e=>{r(e),a(!1)}).catch(e=>{s(e instanceof Error?e.message:String(e)),a(!1)})},[]);return(0,R.useEffect)(()=>{c(t)},[c,t]),(0,z.jsxs)(`div`,{"data-testid":`folder-picker`,style:{display:`flex`,flexDirection:`column`,gap:4,fontSize:13,color:`var(--foreground)`},children:[(0,z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:6,minHeight:24},children:[n?.parent!=null&&(0,z.jsx)(`button`,{"data-testid":`folder-picker-up`,onClick:()=>c(n.parent??void 0),style:{background:`none`,border:`none`,cursor:`pointer`,padding:`2px 6px`,borderRadius:4,color:`var(--muted-foreground)`,fontSize:13},children:`↑`}),(0,z.jsx)(`span`,{"data-testid":`folder-picker-path`,style:{color:`var(--muted-foreground)`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,flex:1},children:n?.path??``}),(0,z.jsx)(`button`,{"data-testid":`folder-picker-select`,disabled:!n,onClick:()=>{n&&e(n.path)},style:{padding:`2px 10px`,borderRadius:4,border:`1px solid var(--border)`,background:`var(--card)`,cursor:n?`pointer`:`default`,color:`var(--foreground)`,fontSize:12},children:`Select`})]}),i&&(0,z.jsx)(`span`,{"data-testid":`folder-picker-loading`,style:{color:`var(--muted-foreground)`,fontSize:12},children:`Loading…`}),o&&(0,z.jsx)(`span`,{"data-testid":`folder-picker-error`,style:{color:`var(--destructive)`,fontSize:12},children:o}),!i&&!o&&n&&(0,z.jsxs)(`div`,{"data-testid":`folder-picker-entries`,style:{display:`flex`,flexDirection:`column`,gap:1,maxHeight:240,overflowY:`auto`},children:[n.entries.length===0&&(0,z.jsx)(`span`,{style:{color:`var(--muted-foreground)`,fontSize:12,padding:`4px 0`},children:`No subdirectories`}),n.entries.map(e=>(0,z.jsxs)(`button`,{"data-testid":`folder-picker-entry`,"data-path":e.path,onClick:()=>c(e.path),style:{background:`none`,border:`none`,cursor:`pointer`,textAlign:`left`,padding:`3px 6px`,borderRadius:4,color:`var(--foreground)`,fontSize:13},children:[e.name,`/`]},e.path))]})]})}function rjt(e){return e.toLowerCase().replace(/[^a-z0-9-]/g,`-`)}function ijt({isOpen:e,onClose:t,onCreated:n}){let r=(0,R.useRef)(null),[i,a]=(0,R.useState)(`existing`),[o,s]=(0,R.useState)(``),[c,l]=(0,R.useState)(``),[u,d]=(0,R.useState)(``),[f,p]=(0,R.useState)(!1),[m,h]=(0,R.useState)(null);if((0,R.useEffect)(()=>{if(!e)return;let t=!1;return(async()=>{try{let e=await fJ(`/api/fs/list-dirs`,{credentials:`include`});if(t||!e?.ok)return;let n=await e.json();d(e=>e||`${n.path}/Projects`)}catch{}})(),()=>{t=!0}},[e]),!e)return null;let g=rjt(c.trim()),_=u&&c.trim()?`${u}/${g}`:``,v=!f&&(i===`existing`?!!o:!!c.trim()&&!!u);async function y(){h(null),p(!0);try{let e=i===`existing`?{mode:`existing`,path:o}:{mode:`new`,parentDir:u,name:c.trim()},r=await fJ(`/api/projects`,{method:`POST`,credentials:`include`,headers:await uj(),body:JSON.stringify(e)});if(!r.ok){h((await r.json().catch(()=>({}))).error??`HTTP ${r.status}`);return}n(await r.json()),t()}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(!1)}}function b(e){a(e),h(null)}return(0,z.jsx)(`div`,{ref:r,className:J.forkHelpOverlay,onClick:e=>{e.target===r.current&&t()},children:(0,z.jsxs)(`div`,{"data-testid":`new-project-modal`,className:J.forkHelpDialog,role:`dialog`,"aria-labelledby":`new-project-title`,children:[(0,z.jsxs)(`div`,{className:J.forkHeader,children:[(0,z.jsxs)(`div`,{className:J.forkHeaderLeft,children:[(0,z.jsx)(Ln,{size:16,className:J.forkHeaderIcon}),(0,z.jsx)(`h3`,{id:`new-project-title`,className:J.forkTitle,children:`Add project`})]}),(0,z.jsx)(`button`,{className:J.forkClose,onClick:t,"aria-label":`Close`,children:(0,z.jsx)(zr,{size:14})})]}),(0,z.jsx)(`div`,{style:{display:`flex`,borderBottom:`1px solid var(--border)`,padding:`0 16px`},children:[`existing`,`new`].map(e=>(0,z.jsx)(`button`,{"data-testid":`new-project-tab-${e}`,onClick:()=>b(e),style:{background:`none`,border:`none`,borderBottom:i===e?`2px solid var(--primary)`:`2px solid transparent`,cursor:`pointer`,padding:`8px 14px`,color:i===e?`var(--foreground)`:`var(--muted-foreground)`,fontSize:13,fontWeight:i===e?600:400},children:e===`existing`?`Add existing`:`New project`},e))}),(0,z.jsxs)(`div`,{className:J.forkHelpBody,children:[i===`existing`?(0,z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,z.jsx)(`p`,{className:J.forkDesc,children:`Browse to the project folder and click Select.`}),(0,z.jsx)(njt,{onSelect:e=>s(e)}),o&&(0,z.jsxs)(`div`,{"data-testid":`new-project-selected-path`,style:{fontSize:12,color:`var(--muted-foreground)`},children:[`Selected: `,(0,z.jsx)(`strong`,{children:o})]})]}):(0,z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,z.jsx)(`label`,{htmlFor:`new-project-name`,style:{fontSize:12,color:`var(--muted-foreground)`},children:`Project name`}),(0,z.jsx)(`input`,{id:`new-project-name`,"data-testid":`new-project-name-input`,type:`text`,value:c,onChange:e=>l(e.target.value),className:J.forkTitleInput,placeholder:`My App`,autoFocus:!0})]}),(0,z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,z.jsx)(`p`,{style:{fontSize:12,color:`var(--muted-foreground)`,margin:0},children:`Parent folder`}),(0,z.jsx)(njt,{onSelect:e=>d(e)})]}),_&&(0,z.jsx)(`div`,{"data-testid":`new-project-preview`,style:{fontSize:12,color:`var(--muted-foreground)`,fontFamily:`monospace`},children:_})]}),m&&(0,z.jsx)(`div`,{"data-testid":`new-project-error`,className:J.forkWarning,style:{marginTop:8},children:m})]}),(0,z.jsxs)(`div`,{className:J.forkFooter,children:[(0,z.jsx)(`button`,{className:J.forkCancelBtn,onClick:t,children:`Cancel`}),(0,z.jsxs)(`button`,{"data-testid":`new-project-start`,className:J.forkConfirmBtn,disabled:!v,onClick:y,children:[(0,z.jsx)(Ln,{size:13}),f?`Creating…`:`Start`]})]})]})})}function ajt(e){let t=Math.floor(e/1e3);if(t<10)return`Just now`;if(t<60)return`${t}s ago`;let n=Math.floor(t/60);return n<60?`${n}m ago`:`${Math.floor(n/60)}h ago`}function ojt(){let e=sm(e=>e.snapshotTimestamp),[,t]=(0,R.useState)(0),[n,r]=(0,R.useState)(!0);if((0,R.useEffect)(()=>{let e=setInterval(()=>t(e=>e+1),1e4);return()=>clearInterval(e)},[]),(0,R.useEffect)(()=>{if(e)if(Date.now()-new Date(e).getTime()<5e3){r(!0);let e=setTimeout(()=>r(!1),5e3);return()=>clearTimeout(e)}else r(!0)},[e]),!e)return null;let i=Date.now()-new Date(e).getTime(),a=ajt(i),o=i<5e3;return o&&!n?null:(0,z.jsx)(`span`,{className:`text-[11px] whitespace-nowrap transition-opacity duration-500`,style:{color:o?`#4ade80`:`#4a5c80`,opacity:+!!n},title:`Data timestamp: ${e}`,children:a})}var sjt=new Set([`agents`,`autopreso`,`resources`,`activity`,`sessions`,`metrics`,`costs`,`health`,`skills`,`god-view`]);async function cjt(){let e=await fetch(`/api/settings`);return e.ok?!!(await e.json()).experimental?.experimentalFeatures:!1}function K9(e){return sjt.has(e)}var ljt=[`todo`,`plan`,`work`,`review`,`ship`],ujt={ship:`Ship`,review:`Review`,work:`Work`,plan:`Plan`,todo:`Todo`},djt={ship:`bg-success`,review:`bg-warning`,work:`bg-info`,plan:`bg-signal-review`,todo:`bg-muted-foreground/30`};function fjt(e){let t=e.state??e.status;return e.stateType===`completed`||e.stateType===`canceled`||t===`done`||t===`canceled`||t===`Canceled`||t===`Closed`||t===`Completed`}function q9(){if(typeof window>`u`)return{phase:`all`,projects:[]};let e=new URLSearchParams(window.location.search),t=e.get(`phase`);return{phase:ljt.includes(t??``)?t:`all`,projects:e.get(`projects`)?.split(`,`).map(e=>e.trim()).filter(Boolean)??[]}}function J9(e,t){let n=new URL(window.location.href);t===null||t===``?n.searchParams.delete(e):n.searchParams.set(e,t),window.history.replaceState(null,``,`${n.pathname}${n.search}${n.hash}`),window.dispatchEvent(new PopStateEvent(`popstate`))}var pjt=`overdeck.ui.sidebarCollapsed`,mjt=[{id:`home`,label:`Home`,icon:Zn},{id:`flywheel`,label:`Flywheel`,icon:ar,badge:`flywheel-live`}],hjt=[{label:`Operations`,items:[{id:`backlog`,label:`Backlog`,icon:nr},{id:`command-deck`,label:`Command Deck`,icon:yn},{id:`kanban`,label:`Board`,icon:tr},{id:`pipeline`,label:`Pipeline`,icon:Hn},{id:`awaiting-merge`,label:`Awaiting Merge`,icon:Gn},{id:`agents`,label:`Agents`,icon:Yt},{id:`autopreso`,label:`AutoPreso`,icon:ur}]},{label:`Infrastructure`,items:[{id:`resources`,label:`Resources`,icon:Fee}]},{label:`Observability`,items:[{id:`activity`,label:`Activity`,icon:Pr},{id:`sessions`,label:`Sessions`,icon:Xn},{id:`metrics`,label:`Metrics`,icon:Ut},{id:`costs`,label:`Costs`,icon:wn},{id:`health`,label:`Health`,icon:hee},{id:`deacon`,label:`Deacon`,icon:kr}]},{label:`System`,items:[{id:`skills`,label:`Skills`,icon:Sn},{id:`context`,label:`Context`,icon:Mn},{id:`settings`,label:`Settings`,icon:Tr},{id:`god-view`,label:`God View`,icon:Br}]}],gjt=`overdeck.ui.sidebarMoreCollapsed`;function _jt({activeTab:e,onTabChange:t,onSearchOpen:n,selectedProject:r=null,onSelectProject:i,onNewProject:a}){let{theme:o,toggleTheme:s}=MS(),[c,l]=(0,R.useState)(()=>localStorage.getItem(pjt)===`true`),[u,d]=(0,R.useState)(()=>localStorage.getItem(gjt)===`true`),f=(0,R.useCallback)(()=>{d(e=>{let t=!e;try{localStorage.setItem(gjt,String(t))}catch{}return t})},[]),[p,m]=(0,R.useState)(!1),{data:h=[]}=B({queryKey:[`command-deck-projects`],queryFn:K5,refetchInterval:3e4}),{data:g=[]}=B({queryKey:[`conversations`],queryFn:gJ,refetchInterval:1e4}),{data:_=[]}=B({queryKey:[`registered-projects`],queryFn:async()=>{let e=await fetch(`/api/registered-projects`);if(!e.ok)return[];let t=await e.json();return Array.isArray(t)?t:[]},staleTime:6e4}),v=(0,R.useMemo)(()=>g.some(e=>iSt(e,_)),[g,_]),y=sm(fm),b=sm(lm),x=sm(e=>e.reviewStatusByIssueId),[S,C]=(0,R.useState)(q9);(0,R.useEffect)(()=>{let e=()=>C(q9());return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[]);let w=(0,R.useMemo)(()=>{if(e!==`pipeline`)return{phaseCounts:{},projects:[]};let t=new Map;for(let e of b){let n=e.issueId?.toLowerCase();n&&!t.has(n)&&t.set(n,e)}let n={ship:0,review:0,work:0,plan:0,todo:0},r=new Map;for(let e of y){if(fjt(e))continue;let i=t.get(e.identifier.toLowerCase())??null,a=_h(e,x[e.identifier]??x[e.identifier.toUpperCase()],i);if(n[a]=(n[a]??0)+1,e.project){let t=e.project.id||e.project.name;if(!r.has(t)){let n=e.identifier.includes(`-`)?e.identifier.split(`-`)[0].toUpperCase():``;r.set(t,{name:e.project.name,color:e.project.color??``,prefix:n})}}}return{phaseCounts:n,projects:Array.from(r.entries()).map(([e,t])=>({id:e,...t})).sort((e,t)=>e.name.localeCompare(t.name))}},[e,y,b,x]),{data:T}=B({queryKey:[`version`],queryFn:async()=>{let e=await fetch(`/api/version`);return e.ok?e.json():null},staleTime:1/0}),E=T?.isDev??!1,{data:D}=B({queryKey:[`flywheel-runs`],queryFn:async()=>{let e=await fetch(`/api/flywheel/runs?limit=10`);return e.ok?e.json():[]},refetchInterval:5e3}),O=(Array.isArray(D)?D:[]).some(e=>e.status===`running`),{data:k=!1}=B({queryKey:[`settings`,`experimental-features`],queryFn:cjt,staleTime:3e4}),A=(0,R.useMemo)(()=>hjt.map(e=>({...e,items:e.items.filter(e=>k||!K9(e.id))})).filter(e=>e.items.length>0),[k]),j=Nt({mutationFn:async()=>{let e=await fetch(`/api/dev/rebuild`,{method:`POST`}),t=await e.json();if(!e.ok)throw Error(t.error||`Build failed`);return t}}),M=(0,R.useCallback)(()=>{l(e=>{let t=!e;return localStorage.setItem(pjt,String(t)),t})},[]);(0,R.useEffect)(()=>{let e=e=>{e.key===`[`&&![`INPUT`,`TEXTAREA`].includes(e.target.tagName)&&M()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[M]);let N=({id:n,label:r,icon:i,badge:a,title:o})=>{let s=e===n,l=a===`flywheel-live`&&O;return(0,z.jsxs)(`button`,{onClick:()=>{t(n),m(!1)},title:o??(c?r:void 0),"data-testid":`sidebar-${n}`,className:`
|
|
786
|
+
`,bAt={ok:`border border-[color-mix(in_srgb,var(--success)_32%,transparent)] bg-[color-mix(in_srgb,var(--success)_10%,transparent)] text-[var(--success-foreground)]`,"needs-refinement":`border border-[color-mix(in_srgb,var(--warning)_36%,transparent)] bg-[color-mix(in_srgb,var(--warning)_12%,transparent)] text-[var(--warning-foreground)]`,stale:`border border-[var(--color-border)] bg-[var(--accent)] text-[var(--muted-foreground)] line-through opacity-70`},xAt={ready:`border border-[color-mix(in_srgb,var(--success)_32%,transparent)] bg-[color-mix(in_srgb,var(--success)_10%,transparent)] text-[var(--success-foreground)]`,blocked:`border border-[color-mix(in_srgb,var(--destructive)_32%,transparent)] bg-[color-mix(in_srgb,var(--destructive)_10%,transparent)] text-[var(--destructive-foreground)]`,auto:`border border-[var(--color-border)] bg-[var(--accent)] text-[var(--muted-foreground)]`},SAt={critical:`bg-[var(--destructive)]`,high:`bg-[var(--warning)]`,medium:`bg-[var(--color-neutral-400)]`,low:`bg-[var(--muted-foreground)] opacity-60`},B9=`inline-flex items-center gap-1.5 h-7 px-3 rounded-full border text-xs transition-colors`,V9=`border-[var(--color-border)] bg-[var(--color-surface)] text-[var(--color-fg-muted)] hover:border-[color-mix(in_srgb,var(--color-fg)_25%,transparent)]`,H9={info:`border-[color-mix(in_srgb,var(--info)_45%,transparent)] bg-[color-mix(in_srgb,var(--info)_12%,transparent)] text-[var(--info-foreground)]`,success:`border-[color-mix(in_srgb,var(--success)_45%,transparent)] bg-[color-mix(in_srgb,var(--success)_12%,transparent)] text-[var(--success-foreground)]`,warning:`border-[color-mix(in_srgb,var(--warning)_45%,transparent)] bg-[color-mix(in_srgb,var(--warning)_12%,transparent)] text-[var(--warning-foreground)]`,danger:`border-[color-mix(in_srgb,var(--destructive)_45%,transparent)] bg-[color-mix(in_srgb,var(--destructive)_12%,transparent)] text-[var(--destructive-foreground)]`,neutral:`border-[color-mix(in_srgb,var(--color-fg)_28%,transparent)] bg-[color-mix(in_srgb,var(--color-fg)_8%,transparent)] text-[var(--color-fg)]`},U9={info:`bg-[var(--info-foreground)]`,success:`bg-[var(--success-foreground)]`,warning:`bg-[var(--warning-foreground)]`,danger:`bg-[var(--destructive-foreground)]`,neutral:`bg-[var(--color-fg-muted)]`},CAt={now:`Now`,next:`Next`,later:`Later`,someday:`Someday`},wAt={now:`border border-[color-mix(in_srgb,var(--destructive)_34%,transparent)] bg-[color-mix(in_srgb,var(--destructive)_10%,transparent)] text-[var(--destructive-foreground)]`,next:`border border-[color-mix(in_srgb,var(--warning)_34%,transparent)] bg-[color-mix(in_srgb,var(--warning)_10%,transparent)] text-[var(--warning-foreground)]`,later:`border border-[color-mix(in_srgb,var(--info)_30%,transparent)] bg-[color-mix(in_srgb,var(--info)_9%,transparent)] text-[var(--info-foreground)]`,someday:`border border-[var(--color-border)] bg-[var(--accent)] text-[var(--muted-foreground)]`};function W9(e,t){return e<=Math.min(14,t)?`now`:e<=Math.min(52,t)?`next`:e<=Math.min(148,t)?`later`:`someday`}var TAt=150;function EAt({onIssueAction:e}={}){let t=_t(),[n,r]=(0,R.useState)(`dag`),[i,a]=(0,R.useState)(`all`),[o,s]=(0,R.useState)(`all`),[c,l]=(0,R.useState)(!1),[u,d]=(0,R.useState)(!1),[f,p]=(0,R.useState)(!1),[m,h]=(0,R.useState)(!0),[g,_]=(0,R.useState)(!1),[v,y]=(0,R.useState)(!1),[b,x]=(0,R.useState)(`incremental`),[S,C]=(0,R.useState)(!1),[w,T]=(0,R.useState)(null),[E,D]=(0,R.useState)(`now`),[O,k]=(0,R.useState)(``),[A,j]=(0,R.useState)(!1),[M,N]=(0,R.useState)(null),{data:P,isLoading:F,error:I,refetch:ee}=B({queryKey:[`backlog-sequence`],queryFn:async()=>{let e=await fetch(`/api/backlog/sequence`);if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()},refetchInterval:6e4}),{data:te}=B({queryKey:[`sequencer-status`],queryFn:async()=>{let e=await fetch(`/api/backlog/sequencer-status`);if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()},refetchInterval:3e3}),ne=te?.running??!1,L=(0,R.useRef)(!1);(0,R.useEffect)(()=>{L.current&&!ne&&ee(),L.current=ne},[ne,ee]);let[re,ie]=(0,R.useState)(()=>Date.now());(0,R.useEffect)(()=>{if(!ne)return;let e=setInterval(()=>ie(Date.now()),1e3);return()=>clearInterval(e)},[ne]);let ae=te?.startedAt?Math.max(0,Math.floor((re-new Date(te.startedAt).getTime())/1e3)):0,oe=P?.nodes??[],se=(0,R.useMemo)(()=>oe.filter(e=>e.condition===`stale`),[oe]),ce=(0,R.useMemo)(()=>oe.filter(e=>e.condition===`needs-refinement`),[oe]),le=(0,R.useMemo)(()=>{let e=oe.length,t={now:0,next:0,later:0,someday:0};return oe.forEach(n=>{let r=W9(n.rank,e);t[r]++}),t},[oe]),ue=(0,R.useMemo)(()=>oe.filter(e=>e.inPipeline).length,[oe]),de=(0,R.useMemo)(()=>oe.filter(e=>e.state?.ready??!1).length,[oe]),fe=(0,R.useMemo)(()=>oe.filter(e=>e.hasPrd).length,[oe]),pe=(0,R.useMemo)(()=>oe.filter(e=>{if(E&&W9(e.rank,oe.length)!==E||i!==`all`&&e.importance!==i||o!==`all`&&e.condition!==o||c&&!e.inPipeline||u&&!(e.state?.ready??!1)||A&&!e.hasPrd)return!1;if(O){let t=O.toLowerCase();if(!e.issueId.toLowerCase().includes(t)&&!e.why.toLowerCase().includes(t))return!1}return!0}),[oe,i,o,c,u,A,E,O]),me=(0,R.useMemo)(()=>{if(!P)return{nodes:[],edges:[]};let e=pe.length;if(e<=TAt){let e=new Set(pe.map(e=>e.issueId));return{nodes:pe,edges:P.edges.filter(t=>e.has(t.from)&&e.has(t.to))}}let t=Math.max(Math.floor(e*.1),20),n=new Set(pe.slice(0,t).map(e=>e.issueId));pe.filter(e=>e.inPipeline).forEach(e=>n.add(e.issueId));let r=new Set(n);for(let e of P.edges)n.has(e.from)&&r.add(e.to),n.has(e.to)&&r.add(e.from);return{nodes:pe.filter(e=>r.has(e.issueId)),edges:P.edges.filter(e=>r.has(e.from)&&r.has(e.to))}},[P,pe]),he=pe.length-me.nodes.length;async function ge(){if(!g){_(!0),T(null),C(!1);try{let e=await fetch(`/api/backlog/sequence/regenerate`,{method:`POST`,headers:await uj(),body:JSON.stringify({pass:b})});if(!e.ok){let t=`Request failed (HTTP ${e.status})`;try{let n=await e.json();n?.error&&(t=String(n.error))}catch{let n=await e.text().catch(()=>``);n&&(t=n.slice(0,300))}throw Error(t)}setTimeout(()=>ee(),2e3)}catch(e){T(e instanceof Error?e.message:String(e))}finally{_(!1)}}}async function _e(){if(!(v||g)&&window.confirm(`Delete the backlog sequencing? This removes the ranked sequence (sequence.md + cache) and any operator gate overrides. A re-sequence pass regenerates it.`)){y(!0),T(null);try{let e=await fetch(`/api/backlog/sequence/clear`,{method:`POST`,headers:await uj()});if(!e.ok){let t=`Request failed (HTTP ${e.status})`;try{let n=await e.json();n?.error&&(t=String(n.error))}catch{}throw Error(t)}setTimeout(()=>ee(),500)}catch(e){T(e instanceof Error?e.message:String(e))}finally{y(!1)}}}async function ve(e){await fetch(`/api/issues/${e}/start-planning`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})}).catch(()=>{})}async function ye(e){(await fetch(`/api/issues/${e}/close`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})}).catch(()=>null))?.ok&&t.invalidateQueries({queryKey:[`backlog-sequence`]})}async function be(e,n){await fetch(`/api/backlog/sequence/gate`,{method:`POST`,headers:await uj(),body:JSON.stringify({issueId:e,gate:n})}),t.invalidateQueries({queryKey:[`backlog-sequence`]})}async function xe(e,n){await fetch(`/api/backlog/sequence/planning`,{method:`POST`,headers:await uj(),body:JSON.stringify({issueId:e,planning:n})}),t.invalidateQueries({queryKey:[`backlog-sequence`]})}let Se=e=>bAt[e]??`border border-[var(--color-border)] bg-[var(--accent)] text-[var(--muted-foreground)]`,Ce=e=>xAt[e]??`border border-[var(--color-border)] bg-[var(--accent)] text-[var(--muted-foreground)]`;return(0,z.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden bg-[var(--color-bg)] text-[var(--color-fg)]`,children:[(0,z.jsxs)(`div`,{className:`flex items-start gap-4 px-6 py-4 border-b border-[var(--color-border)] shrink-0 flex-wrap bg-[var(--color-bg)]`,children:[(0,z.jsxs)(`div`,{className:`min-w-[280px] flex-1`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(nr,{className:`w-4 h-4 text-[var(--color-accent)]`}),(0,z.jsxs)(`h1`,{className:`font-display text-[22px] leading-tight font-medium tracking-normal text-[var(--color-fg)]`,children:[`Backlog Sequencer`,oe.length>0&&(0,z.jsxs)(`span`,{className:`ml-2 font-mono text-sm font-normal text-[var(--color-fg-muted)]`,children:[`· `,oe.length,` open`]})]})]}),(0,z.jsx)(`p`,{className:`mt-1 max-w-2xl text-[13px] leading-5 text-[var(--color-fg-muted)]`,children:`Ranked backlog flow with active-tier graphing, dependency context, and operator gates for pickup and planning.`})]}),(0,z.jsxs)(`div`,{className:`flex rounded-md overflow-hidden border border-[var(--color-border)] bg-[var(--color-surface)]`,children:[(0,z.jsxs)(`button`,{onClick:()=>r(`list`),className:`px-3 py-1.5 text-xs flex items-center gap-1 ${n===`list`?`bg-[var(--color-accent)] text-[var(--color-primary-foreground)]`:`text-[var(--color-fg-muted)] hover:bg-[var(--color-surface-hover)]`}`,children:[(0,z.jsx)(nr,{className:`w-3 h-3`}),`List`]}),(0,z.jsxs)(`button`,{onClick:()=>r(`dag`),className:`px-3 py-1.5 text-xs flex items-center gap-1 ${n===`dag`?`bg-[var(--color-accent)] text-[var(--color-primary-foreground)]`:`text-[var(--color-fg-muted)] hover:bg-[var(--color-surface-hover)]`}`,children:[(0,z.jsx)(Wn,{className:`w-3 h-3`}),`DAG`]}),(0,z.jsxs)(`button`,{onClick:()=>r(`forecast`),className:`px-3 py-1.5 text-xs flex items-center gap-1 ${n===`forecast`?`bg-[var(--color-accent)] text-[var(--color-primary-foreground)]`:`text-[var(--color-fg-muted)] hover:bg-[var(--color-surface-hover)]`}`,children:[(0,z.jsx)(hr,{className:`w-3 h-3`}),`Forecast`]})]}),(0,z.jsxs)(`button`,{onClick:()=>h(e=>!e),className:`px-3 py-1.5 text-xs flex items-center gap-1 rounded-md border ${m?`border-[var(--color-accent)] text-[var(--color-accent)] bg-[color-mix(in_srgb,var(--color-accent)_8%,transparent)]`:`border-[var(--color-border)] text-[var(--color-fg-muted)] hover:bg-[var(--color-surface-hover)]`}`,children:[(0,z.jsx)(Nn,{className:`w-3 h-3`}),`Filters `,pe.length!==oe.length&&`(${pe.length})`]}),se.length>0&&(0,z.jsxs)(`button`,{onClick:()=>p(e=>!e),className:`px-3 py-1.5 text-xs rounded-md border ${f?`border-[var(--warning)] text-[var(--warning-foreground)] bg-[color-mix(in_srgb,var(--warning)_10%,transparent)]`:`border-[var(--color-border)] text-[var(--color-fg-muted)] hover:bg-[var(--color-surface-hover)]`}`,children:[`⊘ `,se.length,` stale`]}),(0,z.jsxs)(`div`,{className:`relative ml-auto flex items-center gap-1`,children:[(0,z.jsxs)(`button`,{onClick:_e,disabled:v||g||ne,className:`px-2.5 py-1.5 text-xs flex items-center gap-1 rounded-md border border-[var(--color-border)] text-[var(--color-fg-muted)] hover:text-[var(--destructive)] hover:border-[color-mix(in_srgb,var(--destructive)_40%,transparent)] disabled:opacity-50`,title:`Delete the backlog sequencing (sequence.md + cache). Re-sequence regenerates it.`,children:[(0,z.jsx)(Fr,{className:`w-3 h-3`}),v?`Clearing…`:`Clear`]}),(0,z.jsxs)(`button`,{onClick:ge,disabled:g||ne,className:`px-3 py-1.5 text-xs flex items-center gap-1 rounded-md border border-[var(--color-accent)] text-[var(--color-accent)] hover:bg-[color-mix(in_srgb,var(--color-accent)_10%,transparent)] disabled:opacity-50`,title:`Run ${b} pass`,children:[(0,z.jsx)(hr,{className:`w-3 h-3`}),g||ne?`Sequencing…`:`Re-sequence`]}),(0,z.jsx)(`button`,{onClick:()=>C(e=>!e),className:`px-2 py-1.5 text-xs rounded-md border border-[var(--color-border)] text-[var(--color-fg-muted)] hover:bg-[var(--color-surface-hover)]`,title:`Select pass type`,children:`▾`}),S&&(0,z.jsx)(`div`,{className:`absolute right-0 top-full mt-1 z-20 bg-[var(--color-surface)] border border-[var(--color-border)] rounded shadow-lg text-xs`,children:[`auto`,`creation`,`incremental`,`review`].map(e=>(0,z.jsx)(`button`,{onClick:()=>{x(e),C(!1)},className:`block w-full text-left px-3 py-1.5 hover:bg-[var(--color-surface-hover)] ${b===e?`text-[var(--color-accent)]`:`text-[var(--color-fg)]`}`,children:e},e))})]}),(0,z.jsx)(`button`,{onClick:()=>ee(),className:`p-2 rounded-md hover:bg-[var(--color-surface-hover)] text-[var(--color-fg-muted)] hover:text-[var(--color-fg)]`,title:`Refresh`,children:(0,z.jsx)(_r,{className:`w-3.5 h-3.5`})})]}),ne&&(0,z.jsxs)(`div`,{className:`shrink-0 flex items-center gap-2 px-5 py-2 bg-[color-mix(in_srgb,var(--info)_10%,transparent)] border-b border-[color-mix(in_srgb,var(--info)_28%,transparent)] text-xs`,children:[(0,z.jsx)(_r,{className:`w-3.5 h-3.5 animate-spin text-[var(--info-foreground)]`}),(0,z.jsx)(`span`,{className:`text-[var(--info-foreground)] font-medium`,children:`Sequencing pass running`}),(0,z.jsxs)(`span`,{className:`text-[var(--color-fg)]`,children:[`ranked `,(0,z.jsx)(`b`,{className:`font-mono`,children:te?.processed??0}),` / `,(0,z.jsx)(`b`,{className:`font-mono`,children:te?.total??`…`}),` issues`]}),(0,z.jsxs)(`span`,{className:`text-[var(--color-fg-muted)] tabular-nums`,children:[`· `,Math.floor(ae/60),`m `,String(ae%60).padStart(2,`0`),`s`]}),(0,z.jsx)(`span`,{className:`ml-auto text-[var(--color-fg-muted)]`,children:`the new sequence appears automatically when it finishes`})]}),w&&(0,z.jsxs)(`div`,{className:`shrink-0 flex items-center gap-2 px-5 py-1.5 bg-[color-mix(in_srgb,var(--destructive)_10%,transparent)] border-b border-[color-mix(in_srgb,var(--destructive)_26%,transparent)] text-xs`,children:[(0,z.jsx)(`span`,{className:`text-[var(--destructive-foreground)] font-medium`,children:`Run pass failed`}),(0,z.jsx)(`span`,{className:`text-[var(--color-fg-muted)] truncate flex-1`,children:w}),(0,z.jsx)(`button`,{onClick:()=>T(null),className:`px-2 py-0.5 rounded border border-[color-mix(in_srgb,var(--destructive)_32%,transparent)] bg-[color-mix(in_srgb,var(--destructive)_16%,transparent)] text-[var(--destructive-foreground)] hover:bg-[color-mix(in_srgb,var(--destructive)_26%,transparent)] shrink-0`,children:`Dismiss`})]}),m&&(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-3 px-6 py-3 bg-[var(--color-surface)] border-b border-[var(--color-border)] text-xs shrink-0`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,z.jsx)(`span`,{className:`text-[var(--color-fg-muted)]`,children:`Importance:`}),[`all`,`critical`,`high`,`medium`,`low`].map(e=>(0,z.jsx)(`button`,{onClick:()=>a(e),className:`px-2 py-0.5 rounded-md border ${i===e?`border-[var(--color-accent)] bg-[var(--color-accent)] text-[var(--color-primary-foreground)]`:`border-[var(--color-border)] bg-[var(--color-bg)] text-[var(--color-fg-muted)] hover:bg-[var(--color-surface-hover)]`}`,children:e===`all`?`All`:e},e))]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,z.jsx)(`span`,{className:`text-[var(--color-fg-muted)]`,children:`Condition:`}),[`all`,`ok`,`needs-refinement`,`stale`].map(e=>(0,z.jsx)(`button`,{onClick:()=>s(e),className:`px-2 py-0.5 rounded-md border ${o===e?`border-[var(--color-accent)] bg-[var(--color-accent)] text-[var(--color-primary-foreground)]`:`border-[var(--color-border)] bg-[var(--color-bg)] text-[var(--color-fg-muted)] hover:bg-[var(--color-surface-hover)]`}`,children:e===`all`?`All`:e},e))]}),(0,z.jsxs)(`label`,{className:`flex items-center gap-1 cursor-pointer`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:c,onChange:e=>l(e.target.checked),className:`accent-[var(--color-accent)]`}),(0,z.jsx)(`span`,{className:`text-[var(--color-fg-muted)]`,children:`In pipeline`})]}),(0,z.jsxs)(`label`,{className:`flex items-center gap-1 cursor-pointer`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:u,onChange:e=>d(e.target.checked),className:`accent-[var(--color-accent)]`}),(0,z.jsx)(`span`,{className:`text-[var(--color-fg-muted)]`,children:`Ready only`})]}),(0,z.jsxs)(`label`,{className:`flex items-center gap-1 cursor-pointer`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:A,onChange:e=>j(e.target.checked),className:`accent-[var(--color-accent)]`}),(0,z.jsx)(`span`,{className:`text-[var(--color-fg-muted)]`,children:`Has PRD`})]}),(0,z.jsx)(`div`,{className:`ml-auto`,children:(0,z.jsx)(`input`,{type:`text`,value:O,onChange:e=>k(e.target.value),placeholder:`filter by id / title…`,className:`h-6 px-2 rounded border border-[var(--color-border)] bg-[var(--color-bg)] text-[var(--color-fg-muted)] text-xs placeholder:text-[var(--color-fg-muted)]/50 focus:outline-none focus:border-[var(--color-accent)] min-w-[180px]`})})]}),f&&se.length>0&&(0,z.jsxs)(`div`,{className:`shrink-0 border-b border-[var(--color-border)] bg-[var(--color-surface)] px-5 py-3`,children:[(0,z.jsxs)(`div`,{className:`text-xs font-medium text-[var(--color-fg-muted)] mb-2`,children:[`Candidates to close (`,se.length,`)`]}),(0,z.jsx)(`div`,{className:`flex flex-col gap-1.5 max-h-40 overflow-y-auto`,children:se.map(e=>(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,z.jsx)(`span`,{className:`font-mono text-[var(--color-accent)] w-24 shrink-0`,children:e.issueId}),(0,z.jsx)(`span`,{className:`text-[var(--color-fg-muted)] truncate flex-1`,children:e.why}),(0,z.jsx)(`button`,{onClick:()=>ye(e.issueId),className:`px-2 py-0.5 rounded text-[10px] border border-[color-mix(in_srgb,var(--destructive)_32%,transparent)] bg-[color-mix(in_srgb,var(--destructive)_14%,transparent)] text-[var(--destructive-foreground)] hover:bg-[color-mix(in_srgb,var(--destructive)_24%,transparent)] shrink-0`,children:`Close`})]},e.issueId))})]}),ce.length>0&&(0,z.jsxs)(`div`,{className:`shrink-0 flex items-center gap-2 px-5 py-1.5 bg-[color-mix(in_srgb,var(--warning)_10%,transparent)] border-b border-[color-mix(in_srgb,var(--warning)_26%,transparent)] text-xs`,children:[(0,z.jsxs)(`span`,{className:`text-[var(--warning-foreground)] font-medium`,children:[`⚠ `,ce.length,` need refinement`]}),(0,z.jsxs)(`span`,{className:`text-[var(--color-fg-muted)]`,children:[ce.slice(0,5).map(e=>e.issueId).join(`, `),ce.length>5?` +${ce.length-5}`:``]}),(0,z.jsx)(`button`,{onClick:()=>ve(ce[0].issueId),className:`ml-auto px-2 py-0.5 rounded border border-[color-mix(in_srgb,var(--warning)_32%,transparent)] bg-[color-mix(in_srgb,var(--warning)_16%,transparent)] text-[var(--warning-foreground)] hover:bg-[color-mix(in_srgb,var(--warning)_26%,transparent)] shrink-0`,children:`Draft PRD →`})]}),oe.length>0&&(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-2 px-6 py-2.5 border-b border-[var(--color-border)] shrink-0`,children:[(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 h-7 px-3 rounded-full border border-[var(--color-border)] bg-[var(--color-surface)] text-xs text-[var(--color-fg-muted)]`,children:[(0,z.jsx)(`b`,{className:`text-[var(--color-fg)] font-medium font-mono`,children:oe.length}),` open issues`]}),(0,z.jsxs)(`button`,{onClick:()=>l(e=>!e),className:`${B9} ${c?H9.info:V9}`,children:[(0,z.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0 ${U9.info}`}),`In pipeline `,(0,z.jsx)(`b`,{className:`font-mono font-medium text-[var(--color-fg)]`,children:ue})]}),(0,z.jsxs)(`button`,{onClick:()=>d(e=>!e),className:`${B9} ${u?H9.success:V9}`,children:[(0,z.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0 ${U9.success}`}),`Ready `,(0,z.jsx)(`b`,{className:`font-mono font-medium text-[var(--color-fg)]`,children:de})]}),(0,z.jsxs)(`button`,{onClick:()=>j(e=>!e),className:`${B9} ${A?H9.neutral:V9}`,children:[(0,z.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0 ${U9.neutral}`}),`Has PRD `,(0,z.jsx)(`b`,{className:`font-mono font-medium text-[var(--color-fg)]`,children:fe})]}),ce.length>0&&(0,z.jsxs)(`button`,{onClick:()=>s(e=>e===`needs-refinement`?`all`:`needs-refinement`),className:`${B9} ${o===`needs-refinement`?H9.warning:V9}`,children:[(0,z.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0 ${U9.warning}`}),`⚠ Needs refinement `,(0,z.jsx)(`b`,{className:`font-mono font-medium text-[var(--color-fg)]`,children:ce.length})]}),se.length>0&&(0,z.jsxs)(`button`,{onClick:()=>s(e=>e===`stale`?`all`:`stale`),className:`${B9} ${o===`stale`?H9.neutral:V9}`,children:[(0,z.jsx)(`span`,{className:`w-2 h-2 rounded-full opacity-60 shrink-0 ${U9.neutral}`}),`⊘ Stale candidates `,(0,z.jsx)(`b`,{className:`font-mono font-medium text-[var(--color-fg)]`,children:se.length})]}),(0,z.jsxs)(`button`,{onClick:()=>D(e=>e===`now`?null:`now`),className:`${B9} ${E===`now`?H9.danger:V9}`,children:[(0,z.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0 ${U9.danger}`}),`Tier 1 · Now `,(0,z.jsx)(`b`,{className:`font-mono font-medium text-[var(--color-fg)]`,children:le.now})]})]}),oe.length>0&&(0,z.jsx)(`div`,{className:`flex gap-2 px-6 py-3 border-b border-[var(--color-border)] shrink-0`,children:[{key:`now`,emoji:`🔴`,label:`Now`,count:le.now,sub:`act on these first`,accent:`border-l-[var(--destructive)]`,ring:`ring-[color-mix(in_srgb,var(--destructive)_50%,transparent)]`},{key:`next`,emoji:`🟠`,label:`Next`,count:le.next,sub:`queued behind Now`,accent:`border-l-[var(--warning)]`,ring:`ring-[color-mix(in_srgb,var(--warning)_50%,transparent)]`},{key:`later`,emoji:`🔵`,label:`Later`,count:le.later,sub:`planned horizon`,accent:`border-l-[var(--info)]`,ring:`ring-[color-mix(in_srgb,var(--info)_50%,transparent)]`},{key:`someday`,emoji:`⚪`,label:`Someday`,count:le.someday,sub:`long tail`,accent:`border-l-[color-mix(in_srgb,var(--color-fg)_30%,transparent)]`,ring:`ring-[color-mix(in_srgb,var(--color-fg)_30%,transparent)]`}].map(e=>(0,z.jsxs)(`button`,{onClick:()=>D(t=>t===e.key?null:e.key),className:`flex-1 min-w-[140px] flex flex-col gap-0.5 px-3.5 py-2.5 border border-l-4 ${e.accent} rounded-lg bg-[var(--color-surface)] text-left hover:bg-[var(--color-surface-hover)] transition-colors shadow-sm ${E===e.key?`ring-1 ${e.ring} border-[var(--color-border)]`:`border-[var(--color-border)]`}`,children:[(0,z.jsxs)(`span`,{className:`text-xs text-[var(--color-fg)]`,children:[e.emoji,` `,e.label]}),(0,z.jsx)(`span`,{className:`font-mono text-lg font-medium text-[var(--color-fg)] leading-tight`,children:e.count}),(0,z.jsx)(`span`,{className:`text-[10px] text-[var(--color-fg-muted)]`,children:e.sub})]},e.key))}),E&&oe.length>0&&(0,z.jsxs)(`div`,{className:`flex items-center gap-2 px-5 py-1.5 border-b border-[var(--color-border)] bg-[var(--color-surface)] shrink-0 text-xs text-[var(--color-fg-muted)]`,children:[(0,z.jsxs)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] font-medium uppercase tracking-widest bg-[var(--color-accent)] text-[var(--color-fg)]`,children:[`Showing `,CAt[E]]}),(0,z.jsxs)(`span`,{children:[pe.length,` of `,oe.length,` issues`,n===`dag`?` rendered as a graph`:``,` — click the tier again to show all`]})]}),(0,z.jsxs)(`div`,{className:`flex-1 overflow-hidden flex`,children:[(0,z.jsxs)(`div`,{className:`flex-1 min-w-0 overflow-hidden flex flex-col`,children:[F&&(0,z.jsx)(`div`,{className:`flex items-center justify-center h-32 text-[var(--color-fg-muted)] text-sm`,children:`Loading sequence…`}),I&&(0,z.jsx)(`div`,{className:`flex items-center justify-center h-32 text-[var(--destructive-foreground)] text-sm`,children:String(I)}),!F&&!I&&oe.length===0&&(0,z.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-48 gap-3 text-[var(--color-fg-muted)]`,children:[(0,z.jsx)(nr,{className:`w-8 h-8 opacity-40`}),(0,z.jsx)(`p`,{className:`text-sm`,children:`No backlog sequence yet.`}),(0,z.jsx)(`p`,{className:`text-xs`,children:`Run a creation pass to rank the open backlog.`}),(0,z.jsxs)(`button`,{onClick:()=>{x(`creation`),ge()},disabled:g,className:`px-3 py-1.5 text-xs rounded border border-[var(--color-accent)] text-[var(--color-accent)] hover:bg-[var(--color-accent)]/10 disabled:opacity-50 flex items-center gap-1`,children:[(0,z.jsx)(hr,{className:`w-3 h-3`}),g?`Spawning…`:`Run creation pass`]})]}),!F&&!I&&oe.length>0&&n===`list`&&(0,z.jsx)(`div`,{className:`overflow-y-auto flex-1`,children:(0,z.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,z.jsx)(`thead`,{className:`sticky top-0 bg-[var(--color-surface)] border-b border-[var(--color-border)]`,children:(0,z.jsxs)(`tr`,{className:`text-[var(--color-fg-muted)]`,children:[(0,z.jsx)(`th`,{className:`text-right px-3 py-2 font-medium w-8 cursor-help`,title:`Pickup rank — lower means the Flywheel works it sooner`,children:`#`}),(0,z.jsx)(`th`,{className:`text-left px-2 py-2 font-medium w-6 cursor-help`,title:`Importance — red = critical, orange = high, gray = medium, dim = low`,children:`●`}),(0,z.jsx)(`th`,{className:`text-left px-2 py-2 font-medium w-28 cursor-help`,title:`Issue ID. Markers: ▶ in pipeline · ⚠ needs refinement · P has PRD · ✓ planned (spec + beads)`,children:`Issue`}),(0,z.jsx)(`th`,{className:`text-center px-2 py-2 font-medium w-16 cursor-help`,title:`Tier band by rank: Now · Next · Later · Someday`,children:`Tier`}),(0,z.jsx)(`th`,{className:`text-left px-2 py-2 font-medium cursor-help`,title:`One-line rationale for this ranking (from the sequencer)`,children:`Why`}),(0,z.jsx)(`th`,{className:`text-center px-2 py-2 font-medium w-14 cursor-help`,title:`Estimated effort: XS / S / M / L / XL`,children:`Size`}),(0,z.jsx)(`th`,{className:`text-center px-2 py-2 font-medium w-24 cursor-help`,title:`AI condition: ok · needs-refinement (vague spec) · stale (likely close)`,children:`Condition`}),(0,z.jsx)(`th`,{className:`text-center px-2 py-2 font-medium w-20 cursor-help`,title:`Operator pickup gate: auto (normal) · promote (jump queue) · vetoed (never pick)`,children:`Gate`}),(0,z.jsx)(`th`,{className:`text-center px-2 py-2 font-medium w-14 cursor-help`,title:`Impact score (0–100) the sequencer assigned`,children:`Score`})]})}),(0,z.jsx)(`tbody`,{children:pe.map(e=>{let t=W9(e.rank,oe.length),n=e.condition===`stale`,r=e.condition===`needs-refinement`,i=M?.issueId===e.issueId;return(0,z.jsxs)(`tr`,{onClick:()=>N(t=>t?.issueId===e.issueId?null:e),className:`transition-colors cursor-pointer ${n?`opacity-50`:``} ${i?`bg-[color-mix(in_srgb,var(--color-accent)_14%,transparent)] ring-inset ring-1 ring-[var(--color-accent)]`:`even:bg-[color-mix(in_srgb,var(--color-fg)_3%,transparent)] hover:bg-[color-mix(in_srgb,var(--color-fg)_9%,transparent)]`}`,children:[(0,z.jsx)(`td`,{className:`text-right px-3 py-2 text-[var(--color-fg-muted)] tabular-nums border-l-2 ${e.inPipeline?`border-l-[var(--info)]`:`border-l-transparent`}`,children:e.rank}),(0,z.jsx)(`td`,{className:`px-2 py-2`,children:(0,z.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full ${SAt[e.importance]??`bg-[var(--color-fg-muted)]`}`,title:`Importance: ${e.importance}`})}),(0,z.jsxs)(`td`,{className:`px-2 py-2 font-mono text-[var(--color-accent)]`,children:[e.issueId,e.inPipeline&&(0,z.jsx)(`span`,{className:`ml-1 text-[9px] text-[var(--info-foreground)] align-top`,title:`In pipeline — active work / review / test`,children:`▶`}),r&&(0,z.jsx)(`span`,{className:`ml-1 text-[9px] text-[var(--warning-foreground)] align-top`,title:`Needs refinement — vague/underspecified`,children:`⚠`}),e.hasPrd&&(0,z.jsx)(`span`,{className:`ml-1 text-[9px] text-[var(--info-foreground)] align-top`,title:`Has PRD`,children:`P`}),e.ready&&(0,z.jsx)(`span`,{className:`ml-1 text-[9px] text-[var(--success-foreground)] align-top`,title:`Has spec — ready for work`,children:`✓`})]}),(0,z.jsx)(`td`,{className:`px-2 py-2 text-center`,children:(0,z.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] font-medium ${wAt[t]??`border border-[var(--color-border)] bg-[var(--accent)] text-[var(--muted-foreground)]`}`,children:CAt[t]})}),(0,z.jsx)(`td`,{className:`px-2 py-2 text-[var(--color-fg)] max-w-xs truncate ${n?`line-through`:``}`,children:e.why}),(0,z.jsx)(`td`,{className:`px-2 py-2 text-center text-[var(--color-fg-muted)]`,children:e.size}),(0,z.jsx)(`td`,{className:`px-2 py-2 text-center`,children:(0,z.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] font-medium ${Se(e.condition)}`,title:e.condition===`needs-refinement`?`Needs refinement — vague/underspecified`:e.condition===`stale`?`Stale — likely a candidate to close`:`OK — well-specified`,children:e.condition===`needs-refinement`?`⚠ refine`:e.condition===`stale`?`⊘ stale`:e.condition})}),(0,z.jsx)(`td`,{className:`px-2 py-2 text-center`,children:(0,z.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] font-medium ${Ce(e.gate)}`,title:e.gate===`ready`?e.inPipeline?`Auto (in-pipeline pin)`:`Promoted — jumps the queue`:e.gate===`blocked`?`Vetoed — never auto-picked`:`Auto — normal eligibility`,children:e.gate===`ready`?e.inPipeline?`auto`:`📌`:e.gate===`blocked`?`⛔`:e.gate})}),(0,z.jsx)(`td`,{className:`px-2 py-2 text-center text-[var(--color-fg-muted)] tabular-nums`,children:e.score})]},e.issueId)})})]})}),!F&&!I&&oe.length>0&&n===`dag`&&P&&(0,z.jsxs)(`div`,{className:`flex-1 flex flex-col min-h-0`,children:[he>0&&(0,z.jsxs)(`div`,{className:`shrink-0 text-xs text-center py-1 bg-[var(--color-surface)] border-b border-[var(--color-border)] text-[var(--color-fg-muted)]`,children:[`Showing `,me.nodes.length,` of `,pe.length,` issues (top tier + neighbors); `,he,` collapsed`]}),(0,z.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,z.jsx)(pAt,{data:me,className:`w-full h-full`,selectedNodeId:M?.issueId,onSelectNode:e=>N(e),onGateChange:be,onPlanningChange:xe,onIssueAction:e})})]}),!F&&!I&&oe.length>0&&n===`forecast`&&(0,z.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,z.jsx)(_At,{className:`w-full h-full`,onSelectIssue:e=>N(oe.find(t=>t.issueId===e)??null)})})]}),M&&(0,z.jsx)(fAt,{node:M,onClose:()=>N(null),onGateChange:be,onPlanningChange:xe,onIssueAction:e})]})]})}var DAt={exploring:{label:`Exploring`,color:`var(--primary)`,icon:wr},planning:{label:`Planning`,color:`var(--signal-review, var(--primary))`,icon:mn},building:{label:`Building`,color:`var(--success, #10b981)`,icon:Zt},verifying:{label:`Verifying`,color:`var(--warning, #f59e0b)`,icon:sn},cleaning:{label:`Cleaning`,color:`var(--muted-foreground)`,icon:Iee},shipping:{label:`Shipping`,color:`var(--primary)`,icon:vr}};function OAt(e){return e.filter(e=>e.actionStatus!==null).sort((e,t)=>t.timestamp.localeCompare(e.timestamp)).slice(0,3)}function kAt(e,t){if(!e)return!1;let n=Date.parse(e.timestamp);return!Number.isNaN(n)&&t.getTime()-n>3600*1e3}function G9({label:e,value:t,tone:n}){return(0,z.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,z.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground`,children:e}),(0,z.jsx)(`span`,{className:`text-xs font-semibold`,style:{color:n??`var(--foreground)`},children:t})]})}function AAt({issue:e,status:t,observations:n,stats:r,onOpenWorkspaceHome:i,now:a=new Date}){let o=t?.phase??`exploring`,s=DAt[o],c=s.icon,l=OAt(n),u=kAt(l[0],a),d=t?.headline||e.title,f=t?.summary||e.description||`No workspace status summary yet.`;return(0,z.jsxs)(`button`,{type:`button`,"data-testid":`workspace-status-card`,onClick:i,className:`w-full text-left bg-card border border-border rounded-lg p-3 hover:border-primary/50 hover:bg-popover transition-colors`,"aria-label":`Open ${e.identifier} workspace overview`,children:[(0,z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,z.jsx)(`div`,{"data-testid":`workspace-status-phase-icon`,"data-phase":o,className:`mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-full border`,style:{color:s.color,borderColor:s.color,background:`color-mix(in srgb, currentColor 10%, transparent)`},children:(0,z.jsx)(c,{className:`h-4 w-4`})}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`h3`,{className:`truncate text-sm font-semibold text-foreground`,title:d,children:d}),(0,z.jsx)(`span`,{"data-testid":`workspace-status-phase-label`,className:`shrink-0 rounded-full border px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide`,style:{color:s.color,borderColor:s.color},children:s.label}),u&&(0,z.jsxs)(`span`,{"data-testid":`workspace-status-stale`,className:`ml-auto flex shrink-0 items-center gap-1 text-[10px] font-semibold text-warning`,children:[(0,z.jsx)(Ir,{className:`h-3 w-3`}),`Stale`]})]}),(0,z.jsx)(`p`,{"data-testid":`workspace-status-summary`,className:`mt-1 text-xs text-muted-foreground`,style:{display:`-webkit-box`,WebkitLineClamp:3,WebkitBoxOrient:`vertical`,overflow:`hidden`},children:f})]})]}),(0,z.jsx)(`ul`,{"data-testid":`workspace-status-observations`,className:`mt-3 space-y-1 text-xs text-muted-foreground`,children:l.length===0?(0,z.jsx)(`li`,{className:`text-muted-foreground/70`,children:`No recent action status.`}):l.map(e=>(0,z.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full bg-primary`}),e.actionStatus?(0,z.jsx)(C5,{status:e.actionStatus}):null,(0,z.jsx)(`span`,{className:`min-w-0 truncate`,title:e.summary,children:e.summary})]},e.id))}),(0,z.jsxs)(`div`,{className:`mt-3 grid grid-cols-4 gap-3 border-t border-border pt-3`,children:[(0,z.jsx)(G9,{label:`Additions`,value:`+${r.additions}`,tone:`var(--success, #10b981)`}),(0,z.jsx)(G9,{label:`Deletions`,value:`-${r.deletions}`,tone:`var(--destructive)`}),(0,z.jsx)(G9,{label:`Commits`,value:r.commits}),(0,z.jsx)(G9,{label:`PRs`,value:r.prs})]})]})}var jAt={justNow:`Just Now`,earlierToday:`Earlier Today`,yesterday:`Yesterday`,thisWeek:`This Week`,thisMonth:`This Month`,older:`Older`},MAt=[`justNow`,`earlierToday`,`yesterday`,`thisWeek`,`thisMonth`,`older`];async function NAt(){let e=await fetch(`/api/registry/features`);if(!e.ok)throw Error(`Registry request failed (${e.status})`);let t=await e.json();return Array.isArray(t.entries)?t.entries:[]}async function PAt(){let e=await fetch(`/api/metrics/summary`);if(!e.ok)throw Error(`Metrics summary request failed (${e.status})`);return e.json()}function FAt({onOpenWorkspaceHome:e,onNewProject:t,onSelectProject:n,onOpenSettings:r,now:i}={}){let a=B({queryKey:[`feature-registry`],queryFn:NAt,staleTime:3e4,retry:!1}),o=B({queryKey:[`metrics-summary`],queryFn:PAt,staleTime:3e4,retry:!1}),s=B({queryKey:[`command-deck-projects`],queryFn:K5,staleTime:3e4,retry:!1}),c=s.data??[],l=sm(e=>e.issuesRaw),u=sm(e=>e.statusByIssueId),d=sm(e=>e.observationsByIssueId),f=sm(e=>e.agentsById),p=sm(e=>e.reviewStatusByIssueId),m=sm(Che),h=i??new Date,g=(0,R.useMemo)(()=>qAt({issuesRaw:l,statusByIssueId:u,observationsByIssueId:d,agentsById:f,reviewStatusByIssueId:p}),[f,l,d,p,u]),_=(0,R.useMemo)(()=>KAt(d),[d]),v=(0,R.useMemo)(()=>VAt(BAt({agentsById:f,reviewStatusByIssueId:p,dailyCost:o.data?.today?.totalCost,now:h})),[f,h,o.data?.today?.totalCost,p]);return(0,z.jsx)(`div`,{className:`h-full w-full overflow-y-auto bg-background`,children:(0,z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-7xl flex-col gap-6 p-6`,children:[(0,z.jsxs)(`header`,{className:`rounded-xl border border-border bg-card p-6 shadow-sm`,children:[(0,z.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.2em] text-muted-foreground`,children:`Overdeck Home`}),(0,z.jsx)(`h1`,{className:`mt-2 text-3xl font-semibold text-foreground`,children:`System briefing`}),(0,z.jsx)(`p`,{className:`mt-2 max-w-3xl text-sm text-muted-foreground`,children:`A live landing page for current workspace context, cross-workspace ownership, and memory-first guidance.`})]}),(0,z.jsx)(`section`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-5`,"aria-label":`Home summary`,children:v.map(e=>(0,z.jsxs)(`div`,{className:`rounded-xl border border-border bg-card p-4 shadow-sm`,children:[(0,z.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-muted-foreground`,children:e.label}),(0,z.jsx)(`p`,{className:`mt-2 text-2xl font-semibold tabular-nums ${e.tone??`text-foreground`}`,children:e.value}),(0,z.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:e.detail})]},e.label))}),(0,z.jsx)(IAt,{observations:_,failure:m,onOpenSettings:r,now:h}),(0,z.jsxs)(`section`,{className:`rounded-xl border border-border bg-card p-5 shadow-sm`,"aria-labelledby":`workspace-status-title`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h2`,{id:`workspace-status-title`,className:`text-lg font-semibold text-foreground`,children:`Workspaces`}),(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Live workspace status rollups from memory observations.`})]}),(0,z.jsx)(`div`,{className:`mt-4`,children:g.length>0?(0,z.jsx)(`div`,{className:`grid gap-3 lg:grid-cols-2`,children:g.map(t=>(0,z.jsx)(AAt,{issue:t.issue,status:t.status,observations:t.observations,stats:t.stats,onOpenWorkspaceHome:()=>e?.(t.issue.identifier),now:i},t.issue.identifier))}):(0,z.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border bg-muted/20 p-4 text-sm text-muted-foreground`,children:[(0,z.jsx)(`p`,{className:`font-medium text-foreground`,children:`No workspace status is available yet.`}),(0,z.jsx)(`p`,{className:`mt-1`,children:`Workspace cards will appear after memory status or observations are recorded for an issue.`})]})})]}),(0,z.jsxs)(`section`,{className:`rounded-xl border border-border bg-card p-5 shadow-sm`,"aria-labelledby":`knowledge-registry-title`,children:[(0,z.jsxs)(`div`,{className:`flex flex-col gap-1 sm:flex-row sm:items-start sm:justify-between`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h2`,{id:`knowledge-registry-title`,className:`text-lg font-semibold text-foreground`,children:`Knowledge Registry`}),(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Feature ownership across issues, workspaces, and agents.`})]}),a.isFetching&&(0,z.jsx)(`span`,{className:`mt-2 rounded-full border border-border px-2 py-1 text-xs text-muted-foreground sm:mt-0`,children:`Refreshing`})]}),(0,z.jsx)(`div`,{className:`mt-4`,children:a.isError?(0,z.jsx)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/10 p-4 text-sm text-destructive`,role:`alert`,children:`Knowledge Registry could not be loaded. The rest of Home is still available.`}):a.isLoading?(0,z.jsx)(`div`,{className:`rounded-lg border border-border bg-muted/30 p-4 text-sm text-muted-foreground`,children:`Loading registry entries…`}):a.data&&a.data.length>0?(0,z.jsx)($At,{entries:a.data}):(0,z.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border bg-muted/20 p-4 text-sm text-muted-foreground`,children:[(0,z.jsx)(`p`,{className:`font-medium text-foreground`,children:`No features are registered yet.`}),(0,z.jsxs)(`p`,{className:`mt-1`,children:[`Add one with `,(0,z.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 font-mono text-xs`,children:`pan registry tag <issueId> <feature>`}),`. Automatic classification will populate future entries as issue and workspace lifecycle wiring lands.`]})]})})]}),(0,z.jsxs)(`section`,{className:`rounded-xl border border-border bg-card p-5 shadow-sm`,"aria-labelledby":`home-projects-title`,"data-testid":`home-projects`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h2`,{id:`home-projects-title`,className:`text-lg font-semibold text-foreground`,children:`Projects`}),(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Your registered projects — click one to open its deck.`})]}),t&&(0,z.jsx)(`button`,{"data-testid":`home-new-project`,onClick:t,className:`rounded-lg border border-border bg-muted/20 px-3 py-1.5 text-sm font-medium text-foreground hover:bg-accent transition-colors`,children:`+ New project`})]}),(0,z.jsx)(`div`,{className:`mt-4`,children:s.isLoading?(0,z.jsx)(`div`,{className:`rounded-lg border border-border bg-muted/30 p-4 text-sm text-muted-foreground`,children:`Loading projects…`}):s.isError?(0,z.jsx)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/10 p-4 text-sm text-destructive`,role:`alert`,children:`Projects could not be loaded. The rest of Home is still available.`}):c.length>0?(0,z.jsx)(`ul`,{className:`divide-y divide-border rounded-lg border border-border`,children:c.map(e=>{let t=e.features.length>0;return(0,z.jsx)(`li`,{children:(0,z.jsxs)(`button`,{"data-testid":`home-project-${e.name}`,onClick:()=>n?.(e.name),title:e.path,className:`flex w-full items-center gap-3 px-4 py-3 text-left text-sm font-medium text-foreground transition-colors hover:bg-accent`,children:[(0,z.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${t?`bg-primary`:`bg-muted-foreground/30`}`,"aria-hidden":`true`}),(0,z.jsx)(`span`,{className:`truncate`,children:e.name}),t&&(0,z.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:e.features.length})]})},e.path)})}):(0,z.jsxs)(`div`,{"data-testid":`home-projects-empty`,className:`rounded-lg border border-dashed border-border bg-muted/20 p-4 text-sm text-muted-foreground`,children:[(0,z.jsx)(`p`,{className:`font-medium text-foreground`,children:`No projects yet.`}),(0,z.jsx)(`p`,{className:`mt-1`,children:`Create your first project to get started.`}),t&&(0,z.jsx)(`button`,{"data-testid":`home-new-project-empty`,onClick:t,className:`mt-3 rounded-lg border border-border bg-background px-3 py-1.5 text-sm font-medium text-foreground hover:bg-accent transition-colors`,children:`+ New project`})]})})]})]})})}function IAt({observations:e,failure:t,onOpenSettings:n,now:r}){let i=(0,R.useMemo)(()=>_yt(e,e=>e.timestamp,r),[e,r]);return(0,z.jsxs)(`section`,{className:`rounded-xl border border-border bg-card p-5 shadow-sm`,"aria-labelledby":`home-activity-title`,"data-testid":`home-activity-feed`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h2`,{id:`home-activity-title`,className:`text-lg font-semibold text-foreground`,children:`Activity Feed`}),(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Recent actionable memory observations across workspaces.`})]}),t&&(0,z.jsx)(LAt,{failure:t,onOpenSettings:n}),e.length===0?(0,z.jsxs)(`div`,{"data-testid":`home-activity-empty`,className:`mt-4 rounded-lg border border-dashed border-border bg-muted/20 p-4 text-sm text-muted-foreground`,children:[(0,z.jsx)(`p`,{className:`font-medium text-foreground`,children:`No actionable observations yet.`}),(0,z.jsx)(`p`,{className:`mt-1`,children:`Observations are extracted from running work agents — they appear here once an agent makes a change worth recording.`})]}):(0,z.jsx)(`div`,{className:`mt-4 space-y-5`,children:MAt.map(e=>{let t=i[e];return t.length===0?null:(0,z.jsxs)(`section`,{"data-testid":`home-activity-bucket-${e}`,children:[(0,z.jsx)(`h3`,{className:`mb-2 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:jAt[e]}),(0,z.jsx)(`ul`,{className:`space-y-2`,children:t.map(e=>(0,z.jsx)(zAt,{observation:e,now:r},e.id))})]},e)})})]})}function LAt({failure:e,onOpenSettings:t}){let n=RAt(e);return(0,z.jsx)(`div`,{"data-testid":`home-memory-failure`,className:`mt-4 rounded-lg border border-destructive/32 bg-destructive/8 p-4 text-sm text-foreground`,role:`alert`,children:(0,z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,z.jsx)(Ir,{className:`mt-0.5 h-4 w-4 shrink-0 text-destructive`,"aria-hidden":`true`}),(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`p`,{className:`font-medium text-destructive`,children:`Memory extraction is failing`}),(0,z.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:n}),e.detail?(0,z.jsx)(`p`,{className:`mt-2 break-words font-mono text-[11px] text-muted-foreground`,children:e.detail}):null,(0,z.jsx)(`p`,{className:`mt-2 text-[11px] text-muted-foreground`,children:`Memory observations and agent memory injection are disabled until this is fixed.`}),t?(0,z.jsx)(`button`,{onClick:t,className:`mt-3 rounded-sm border border-border bg-background px-2.5 py-1 text-xs font-medium text-foreground hover:bg-accent transition-colors`,children:`Open Settings › Memory`}):null]})]})})}function RAt(e){let t=(e.detail??``).toLowerCase();return t.includes(`could not resolve authentication`)||t.includes(`anthropic_api_key`)||t.includes(`x-api-key`)?`The Anthropic API provider has no API key. Switch the extraction provider to cliproxy (your ChatGPT subscription) in Settings › Memory.`:t.includes(`unknown provider for model`)||t.includes(`does not exist`)||t.includes(`unknown model`)?`The configured extraction model is not available on cliproxy. Pick a served model (e.g. gpt-5.4-mini) in Settings › Memory.`:t.includes(`401`)||t.includes(`unauthorized`)||t.includes(`expired`)?`The extraction provider rejected the credentials — the codex/ChatGPT subscription token used by cliproxy may have expired. Re-authenticate, then it will recover automatically.`:`Background memory-extraction calls are failing. Check the extraction provider and model in Settings › Memory.`}function zAt({observation:e,now:t}){return(0,z.jsxs)(`li`,{className:`rounded-lg border border-border bg-background p-3 text-xs`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(C5,{status:e.actionStatus}),(0,z.jsx)(`p`,{className:`font-semibold text-foreground`,children:e.summary})]}),(0,z.jsxs)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:[e.workspaceId,` · `,e.issueId,` · `,(0,z.jsx)(`time`,{dateTime:e.timestamp,children:oM(e.timestamp,t)})]}),e.narrative?(0,z.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-muted-foreground`,children:e.narrative}):null,e.files.length>0?(0,z.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1`,"aria-label":`Files`,children:e.files.map(e=>(0,z.jsx)(`code`,{className:`rounded border border-border bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground`,children:e},e))}):null,e.tags.length>0?(0,z.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1`,"aria-label":`Tags`,children:e.tags.map(e=>(0,z.jsx)(`span`,{className:`rounded-full border border-border px-1.5 py-0.5 text-[10px] text-muted-foreground`,children:e},e))}):null,(0,z.jsx)(`div`,{className:`mt-2 flex justify-end`,children:(0,z.jsx)(PM,{kind:`memory`})})]})}function BAt({agentsById:e={},reviewStatusByIssueId:t={},dailyCost:n,now:r}){let i=Object.values(e),a=Object.values(t);return{runningAgents:i.filter(HAt).length,gatedAgents:i.filter(UAt).length,recentMerges:a.filter(e=>WAt(e,r)).length,failedVerifications:a.filter(GAt).length,dailyCost:typeof n==`number`&&Number.isFinite(n)?n:null}}function VAt(e){return[{label:`Running agents`,value:String(e.runningAgents),detail:`Live or starting sessions`,tone:e.runningAgents>0?`text-primary`:void 0},{label:`Paused / troubled`,value:String(e.gatedAgents),detail:`Agents gated by pause or failures`,tone:e.gatedAgents>0?`text-warning`:void 0},{label:`Merged today`,value:String(e.recentMerges),detail:`Merges in the last 24 hours`,tone:e.recentMerges>0?`text-success`:void 0},{label:`Needs verification`,value:String(e.failedVerifications),detail:`Failed checks or merge blockers`,tone:e.failedVerifications>0?`text-destructive`:void 0},{label:`Cost today`,value:e.dailyCost===null?`Unavailable`:`$${e.dailyCost.toFixed(2)}`,detail:`UTC daily cost summary`,tone:e.dailyCost===null?`text-muted-foreground`:`text-success`}]}function HAt(e){return e.hasLiveTmuxSession===!0||e.status===`running`||e.status===`starting`}function UAt(e){return e.paused===!0||e.troubled===!0||e.status!==`stopped`&&(e.consecutiveFailures??0)>0}function WAt(e,t){if(e.mergeStatus!==`merged`||!e.updatedAt)return!1;let n=Date.parse(e.updatedAt);return!Number.isNaN(n)&&t.getTime()-n<=1440*60*1e3}function GAt(e){return e.verificationStatus===`failed`||e.testStatus===`failed`||e.uatStatus===`failed`||(e.blockerReasons?.length??0)>0}function KAt(e){return Object.values(e).flatMap(e=>e).filter(e=>e.actionStatus!==null).sort((e,t)=>t.timestamp.localeCompare(e.timestamp))}function qAt({issuesRaw:e,statusByIssueId:t={},observationsByIssueId:n={},agentsById:r={},reviewStatusByIssueId:i={}}){let a=new Map;for(let t of e){let e=ZAt(t);e&&a.set(e.identifier,e)}let o=new Set;for(let e of Object.keys(t))o.add(e);for(let[e,t]of Object.entries(n))t.length>0&&o.add(e);for(let e of Object.values(r))e.issueId&&JAt(e)&&o.add(e.issueId);return[...o].sort().map(e=>{let r=t[e],o=n[e]??[];return{issue:a.get(e)??{identifier:e,title:r?.headline||e,description:r?.summary},status:r,observations:o,stats:YAt(o,i[e])}})}function JAt(e){return e.hasLiveTmuxSession===!0||[`healthy`,`running`,`starting`,`stuck`,`warning`].includes(e.status)}function YAt(e,t){return{additions:0,deletions:0,commits:e.filter(XAt).length,prs:+!!t?.prUrl}}function XAt(e){return e.tags.some(e=>[`commit`,`commits`,`git.commit`].includes(e.toLowerCase()))}function ZAt(e){return!QAt(e)||typeof e.identifier!=`string`||typeof e.title!=`string`?null:{identifier:e.identifier,title:e.title,description:typeof e.description==`string`?e.description:void 0}}function QAt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function $At({entries:e}){return(0,z.jsx)(`div`,{className:`overflow-hidden rounded-lg border border-border`,children:(0,z.jsx)(`div`,{className:`overflow-x-auto`,children:(0,z.jsxs)(`table`,{className:`min-w-full divide-y divide-border text-sm`,children:[(0,z.jsx)(`thead`,{className:`bg-muted/40 text-left text-xs uppercase tracking-wide text-muted-foreground`,children:(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`th`,{scope:`col`,className:`px-4 py-3 font-semibold`,children:`Feature`}),(0,z.jsx)(`th`,{scope:`col`,className:`px-4 py-3 font-semibold`,children:`Issue`}),(0,z.jsx)(`th`,{scope:`col`,className:`px-4 py-3 font-semibold`,children:`Workspace`}),(0,z.jsx)(`th`,{scope:`col`,className:`px-4 py-3 font-semibold`,children:`Agent`}),(0,z.jsx)(`th`,{scope:`col`,className:`px-4 py-3 font-semibold`,children:`Status`}),(0,z.jsx)(`th`,{scope:`col`,className:`px-4 py-3 font-semibold`,children:`Updated`}),(0,z.jsx)(`th`,{scope:`col`,className:`px-4 py-3 font-semibold`,children:`Tags`})]})}),(0,z.jsx)(`tbody`,{className:`divide-y divide-border bg-card`,children:e.map(e=>(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`td`,{className:`px-4 py-3 font-medium text-foreground`,children:e.featureName}),(0,z.jsx)(`td`,{className:`px-4 py-3 font-mono text-xs text-muted-foreground`,children:e.owningIssueId??`—`}),(0,z.jsx)(`td`,{className:`px-4 py-3 font-mono text-xs text-muted-foreground`,children:e.owningWorkspaceId??`—`}),(0,z.jsx)(`td`,{className:`px-4 py-3 font-mono text-xs text-muted-foreground`,children:e.owningAgentId??`—`}),(0,z.jsx)(`td`,{className:`px-4 py-3`,children:(0,z.jsx)(`span`,{className:`rounded-full border border-border bg-muted/30 px-2 py-1 text-xs font-medium text-foreground`,children:e.status})}),(0,z.jsx)(`td`,{className:`px-4 py-3 text-xs text-muted-foreground`,children:ejt(e.updatedAt)}),(0,z.jsx)(`td`,{className:`px-4 py-3 text-xs text-muted-foreground`,children:e.tags.length>0?e.tags.join(`, `):`—`})]},e.featureId))})]})})})}function ejt(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}async function tjt(e){let t=await fJ(e?`/api/fs/list-dirs?path=${encodeURIComponent(e)}`:`/api/fs/list-dirs`,{credentials:`include`});if(!t.ok)throw Error(`list-dirs failed: ${t.status}`);return t.json()}function njt({onSelect:e,initialPath:t}){let[n,r]=(0,R.useState)(null),[i,a]=(0,R.useState)(!0),[o,s]=(0,R.useState)(null),c=(0,R.useCallback)(e=>{a(!0),s(null),tjt(e).then(e=>{r(e),a(!1)}).catch(e=>{s(e instanceof Error?e.message:String(e)),a(!1)})},[]);return(0,R.useEffect)(()=>{c(t)},[c,t]),(0,z.jsxs)(`div`,{"data-testid":`folder-picker`,style:{display:`flex`,flexDirection:`column`,gap:4,fontSize:13,color:`var(--foreground)`},children:[(0,z.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:6,minHeight:24},children:[n?.parent!=null&&(0,z.jsx)(`button`,{"data-testid":`folder-picker-up`,onClick:()=>c(n.parent??void 0),style:{background:`none`,border:`none`,cursor:`pointer`,padding:`2px 6px`,borderRadius:4,color:`var(--muted-foreground)`,fontSize:13},children:`↑`}),(0,z.jsx)(`span`,{"data-testid":`folder-picker-path`,style:{color:`var(--muted-foreground)`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,flex:1},children:n?.path??``}),(0,z.jsx)(`button`,{"data-testid":`folder-picker-select`,disabled:!n,onClick:()=>{n&&e(n.path)},style:{padding:`2px 10px`,borderRadius:4,border:`1px solid var(--border)`,background:`var(--card)`,cursor:n?`pointer`:`default`,color:`var(--foreground)`,fontSize:12},children:`Select`})]}),i&&(0,z.jsx)(`span`,{"data-testid":`folder-picker-loading`,style:{color:`var(--muted-foreground)`,fontSize:12},children:`Loading…`}),o&&(0,z.jsx)(`span`,{"data-testid":`folder-picker-error`,style:{color:`var(--destructive)`,fontSize:12},children:o}),!i&&!o&&n&&(0,z.jsxs)(`div`,{"data-testid":`folder-picker-entries`,style:{display:`flex`,flexDirection:`column`,gap:1,maxHeight:240,overflowY:`auto`},children:[n.entries.length===0&&(0,z.jsx)(`span`,{style:{color:`var(--muted-foreground)`,fontSize:12,padding:`4px 0`},children:`No subdirectories`}),n.entries.map(e=>(0,z.jsxs)(`button`,{"data-testid":`folder-picker-entry`,"data-path":e.path,onClick:()=>c(e.path),style:{background:`none`,border:`none`,cursor:`pointer`,textAlign:`left`,padding:`3px 6px`,borderRadius:4,color:`var(--foreground)`,fontSize:13},children:[e.name,`/`]},e.path))]})]})}function rjt(e){return e.toLowerCase().replace(/[^a-z0-9-]/g,`-`)}function ijt({isOpen:e,onClose:t,onCreated:n}){let r=(0,R.useRef)(null),[i,a]=(0,R.useState)(`existing`),[o,s]=(0,R.useState)(``),[c,l]=(0,R.useState)(``),[u,d]=(0,R.useState)(``),[f,p]=(0,R.useState)(!1),[m,h]=(0,R.useState)(null);if((0,R.useEffect)(()=>{if(!e)return;let t=!1;return(async()=>{try{let e=await fJ(`/api/fs/list-dirs`,{credentials:`include`});if(t||!e?.ok)return;let n=await e.json();d(e=>e||`${n.path}/Projects`)}catch{}})(),()=>{t=!0}},[e]),!e)return null;let g=rjt(c.trim()),_=u&&c.trim()?`${u}/${g}`:``,v=!f&&(i===`existing`?!!o:!!c.trim()&&!!u);async function y(){h(null),p(!0);try{let e=i===`existing`?{mode:`existing`,path:o}:{mode:`new`,parentDir:u,name:c.trim()},r=await fJ(`/api/projects`,{method:`POST`,credentials:`include`,headers:await uj(),body:JSON.stringify(e)});if(!r.ok){h((await r.json().catch(()=>({}))).error??`HTTP ${r.status}`);return}n(await r.json()),t()}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(!1)}}function b(e){a(e),h(null)}return(0,z.jsx)(`div`,{ref:r,className:J.forkHelpOverlay,onClick:e=>{e.target===r.current&&t()},children:(0,z.jsxs)(`div`,{"data-testid":`new-project-modal`,className:J.forkHelpDialog,role:`dialog`,"aria-labelledby":`new-project-title`,children:[(0,z.jsxs)(`div`,{className:J.forkHeader,children:[(0,z.jsxs)(`div`,{className:J.forkHeaderLeft,children:[(0,z.jsx)(Ln,{size:16,className:J.forkHeaderIcon}),(0,z.jsx)(`h3`,{id:`new-project-title`,className:J.forkTitle,children:`Add project`})]}),(0,z.jsx)(`button`,{className:J.forkClose,onClick:t,"aria-label":`Close`,children:(0,z.jsx)(zr,{size:14})})]}),(0,z.jsx)(`div`,{style:{display:`flex`,borderBottom:`1px solid var(--border)`,padding:`0 16px`},children:[`existing`,`new`].map(e=>(0,z.jsx)(`button`,{"data-testid":`new-project-tab-${e}`,onClick:()=>b(e),style:{background:`none`,border:`none`,borderBottom:i===e?`2px solid var(--primary)`:`2px solid transparent`,cursor:`pointer`,padding:`8px 14px`,color:i===e?`var(--foreground)`:`var(--muted-foreground)`,fontSize:13,fontWeight:i===e?600:400},children:e===`existing`?`Add existing`:`New project`},e))}),(0,z.jsxs)(`div`,{className:J.forkHelpBody,children:[i===`existing`?(0,z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,z.jsx)(`p`,{className:J.forkDesc,children:`Browse to the project folder and click Select.`}),(0,z.jsx)(njt,{onSelect:e=>s(e)}),o&&(0,z.jsxs)(`div`,{"data-testid":`new-project-selected-path`,style:{fontSize:12,color:`var(--muted-foreground)`},children:[`Selected: `,(0,z.jsx)(`strong`,{children:o})]})]}):(0,z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,z.jsx)(`label`,{htmlFor:`new-project-name`,style:{fontSize:12,color:`var(--muted-foreground)`},children:`Project name`}),(0,z.jsx)(`input`,{id:`new-project-name`,"data-testid":`new-project-name-input`,type:`text`,value:c,onChange:e=>l(e.target.value),className:J.forkTitleInput,placeholder:`My App`,autoFocus:!0})]}),(0,z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,z.jsx)(`p`,{style:{fontSize:12,color:`var(--muted-foreground)`,margin:0},children:`Parent folder`}),(0,z.jsx)(njt,{onSelect:e=>d(e)})]}),_&&(0,z.jsx)(`div`,{"data-testid":`new-project-preview`,style:{fontSize:12,color:`var(--muted-foreground)`,fontFamily:`monospace`},children:_})]}),m&&(0,z.jsx)(`div`,{"data-testid":`new-project-error`,className:J.forkWarning,style:{marginTop:8},children:m})]}),(0,z.jsxs)(`div`,{className:J.forkFooter,children:[(0,z.jsx)(`button`,{className:J.forkCancelBtn,onClick:t,children:`Cancel`}),(0,z.jsxs)(`button`,{"data-testid":`new-project-start`,className:J.forkConfirmBtn,disabled:!v,onClick:y,children:[(0,z.jsx)(Ln,{size:13}),f?`Creating…`:`Start`]})]})]})})}function ajt(e){let t=Math.floor(e/1e3);if(t<10)return`Just now`;if(t<60)return`${t}s ago`;let n=Math.floor(t/60);return n<60?`${n}m ago`:`${Math.floor(n/60)}h ago`}function ojt(){let e=sm(e=>e.snapshotTimestamp),[,t]=(0,R.useState)(0),[n,r]=(0,R.useState)(!0);if((0,R.useEffect)(()=>{let e=setInterval(()=>t(e=>e+1),1e4);return()=>clearInterval(e)},[]),(0,R.useEffect)(()=>{if(e)if(Date.now()-new Date(e).getTime()<5e3){r(!0);let e=setTimeout(()=>r(!1),5e3);return()=>clearTimeout(e)}else r(!0)},[e]),!e)return null;let i=Date.now()-new Date(e).getTime(),a=ajt(i),o=i<5e3;return o&&!n?null:(0,z.jsx)(`span`,{className:`text-[11px] whitespace-nowrap transition-opacity duration-500`,style:{color:o?`#4ade80`:`#4a5c80`,opacity:+!!n},title:`Data timestamp: ${e}`,children:a})}var sjt=new Set([`agents`,`autopreso`,`resources`,`activity`,`sessions`,`metrics`,`costs`,`health`,`skills`,`god-view`]);async function cjt(){let e=await fetch(`/api/settings`);return e.ok?!!(await e.json()).experimental?.experimentalFeatures:!1}function K9(e){return sjt.has(e)}var ljt=[`todo`,`plan`,`work`,`review`,`ship`],ujt={ship:`Ship`,review:`Review`,work:`Work`,plan:`Plan`,todo:`Todo`},djt={ship:`bg-success`,review:`bg-warning`,work:`bg-info`,plan:`bg-signal-review`,todo:`bg-muted-foreground/30`};function fjt(e){let t=e.state??e.status;return e.stateType===`completed`||e.stateType===`canceled`||t===`done`||t===`canceled`||t===`Canceled`||t===`Closed`||t===`Completed`}function q9(){if(typeof window>`u`)return{phase:`all`,projects:[]};let e=new URLSearchParams(window.location.search),t=e.get(`phase`);return{phase:ljt.includes(t??``)?t:`all`,projects:e.get(`projects`)?.split(`,`).map(e=>e.trim()).filter(Boolean)??[]}}function J9(e,t){let n=new URL(window.location.href);t===null||t===``?n.searchParams.delete(e):n.searchParams.set(e,t),window.history.replaceState(null,``,`${n.pathname}${n.search}${n.hash}`),window.dispatchEvent(new PopStateEvent(`popstate`))}var pjt=`overdeck.ui.sidebarCollapsed`,mjt=[{id:`home`,label:`Home`,icon:Zn},{id:`flywheel`,label:`Flywheel`,icon:ar,badge:`flywheel-live`}],hjt=[{label:`Operations`,items:[{id:`backlog`,label:`Backlog`,icon:nr},{id:`command-deck`,label:`Command Deck`,icon:yn},{id:`kanban`,label:`Board`,icon:tr},{id:`pipeline`,label:`Pipeline`,icon:Hn},{id:`awaiting-merge`,label:`Awaiting Merge`,icon:Gn},{id:`agents`,label:`Agents`,icon:Yt},{id:`autopreso`,label:`AutoPreso`,icon:ur}]},{label:`Infrastructure`,items:[{id:`resources`,label:`Resources`,icon:Fee}]},{label:`Observability`,items:[{id:`activity`,label:`Activity`,icon:Pr},{id:`sessions`,label:`Sessions`,icon:Xn},{id:`metrics`,label:`Metrics`,icon:Ut},{id:`costs`,label:`Costs`,icon:wn},{id:`health`,label:`Health`,icon:hee},{id:`deacon`,label:`Deacon`,icon:kr}]},{label:`System`,items:[{id:`skills`,label:`Skills`,icon:Sn},{id:`context`,label:`Context`,icon:Mn},{id:`settings`,label:`Settings`,icon:Tr},{id:`god-view`,label:`God View`,icon:Br}]}],gjt=`overdeck.ui.sidebarMoreCollapsed`;function _jt({activeTab:e,onTabChange:t,onSearchOpen:n,selectedProject:r=null,onSelectProject:i,onNewProject:a}){let{theme:o,toggleTheme:s}=MS(),[c,l]=(0,R.useState)(()=>localStorage.getItem(pjt)===`true`),[u,d]=(0,R.useState)(()=>localStorage.getItem(gjt)===`true`),f=(0,R.useCallback)(()=>{d(e=>{let t=!e;try{localStorage.setItem(gjt,String(t))}catch{}return t})},[]),[p,m]=(0,R.useState)(!1),{data:h=[]}=B({queryKey:[`command-deck-projects`],queryFn:K5,refetchInterval:3e4}),{data:g=[]}=B({queryKey:[`conversations`],queryFn:gJ,refetchInterval:1e4}),{data:_=[]}=B({queryKey:[`registered-projects`],queryFn:async()=>{let e=await fetch(`/api/registered-projects`);if(!e.ok)return[];let t=await e.json();return Array.isArray(t)?t:[]},staleTime:6e4}),v=(0,R.useMemo)(()=>g.some(e=>iSt(e,_)),[g,_]),y=sm(fm),b=sm(lm),x=sm(e=>e.reviewStatusByIssueId),[S,C]=(0,R.useState)(q9);(0,R.useEffect)(()=>{let e=()=>C(q9());return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[]);let w=(0,R.useMemo)(()=>{if(e!==`pipeline`)return{phaseCounts:{},projects:[]};let t=new Map;for(let e of b){let n=e.issueId?.toLowerCase();n&&!t.has(n)&&t.set(n,e)}let n={ship:0,review:0,work:0,plan:0,todo:0},r=new Map;for(let e of y){if(fjt(e))continue;let i=t.get(e.identifier.toLowerCase())??null,a=_h(e,x[e.identifier]??x[e.identifier.toUpperCase()],i);if(n[a]=(n[a]??0)+1,e.project){let t=e.project.id||e.project.name;if(!r.has(t)){let n=e.identifier.includes(`-`)?e.identifier.split(`-`)[0].toUpperCase():``;r.set(t,{name:e.project.name,color:e.project.color??``,prefix:n})}}}return{phaseCounts:n,projects:Array.from(r.entries()).map(([e,t])=>({id:e,...t})).sort((e,t)=>e.name.localeCompare(t.name))}},[e,y,b,x]),{data:T}=B({queryKey:[`version`],queryFn:async()=>{let e=await fetch(`/api/version`);return e.ok?e.json():null},staleTime:1/0}),E=T?.isDev??!1,{data:D}=B({queryKey:[`flywheel-runs`],queryFn:async()=>{let e=await fetch(`/api/flywheel/runs?limit=10`);return e.ok?e.json():[]},refetchInterval:5e3}),O=(Array.isArray(D)?D:[]).some(e=>e.status===`running`),{data:k=!1}=B({queryKey:[`settings`,`experimental-features`],queryFn:cjt,staleTime:3e4}),A=(0,R.useMemo)(()=>hjt.map(e=>({...e,items:e.items.filter(e=>k||!K9(e.id))})).filter(e=>e.items.length>0),[k]),j=Nt({mutationFn:async()=>{let e=await fetch(`/api/dev/rebuild`,{method:`POST`}),t=await e.json();if(!e.ok)throw Error(t.error||`Build failed`);return t}}),M=(0,R.useCallback)(()=>{l(e=>{let t=!e;return localStorage.setItem(pjt,String(t)),t})},[]);(0,R.useEffect)(()=>{let e=e=>{e.key===`[`&&![`INPUT`,`TEXTAREA`].includes(e.target.tagName)&&M()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[M]);let N=({id:n,label:r,icon:i,badge:a,title:o})=>{let s=e===n,l=a===`flywheel-live`&&O;return(0,z.jsxs)(`button`,{onClick:()=>{t(n),m(!1)},title:o??(c?r:void 0),"data-testid":`sidebar-${n}`,className:`
|
|
787
787
|
w-full flex items-center gap-3 transition-colors duration-150 text-sm font-medium
|
|
788
788
|
${c?`justify-center px-0 py-2.5`:`px-3 py-1.5`}
|
|
789
789
|
${s?`bg-accent text-foreground border-l-2 border-primary`:`text-muted-foreground hover:bg-accent hover:text-foreground border-l-2 border-transparent`}
|
|
@@ -800,6 +800,6 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
800
800
|
w-full flex items-center gap-3 px-3 py-1.5 transition-colors duration-150 text-sm font-medium border-l-2
|
|
801
801
|
${e===`command-deck`&&r===`__no-project__`?`bg-accent text-foreground border-primary`:`text-muted-foreground hover:bg-accent hover:text-foreground border-transparent`}
|
|
802
802
|
`,children:[(0,z.jsx)(`span`,{className:`h-2 w-2 rounded-full shrink-0 bg-muted-foreground/30`,"aria-hidden":`true`}),(0,z.jsx)(`span`,{className:`truncate italic`,children:`No project`})]})]}),c?A.map(e=>(0,z.jsxs)(`div`,{className:`mb-2`,children:[(0,z.jsx)(`div`,{className:`h-px mx-2 bg-border my-2`}),e.items.map(N)]},e.label)):(0,z.jsxs)(`div`,{className:`mb-1`,"data-testid":`sidebar-more`,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:f,"aria-expanded":!u,className:`w-full flex items-center gap-1.5 px-3 text-[10px] font-medium uppercase tracking-widest text-muted-foreground mt-4 mb-1 hover:text-foreground transition-colors`,children:[u?(0,z.jsx)(nn,{className:`w-3 h-3`}):(0,z.jsx)(en,{className:`w-3 h-3`}),(0,z.jsx)(On,{className:`w-3 h-3`}),`More`]}),!u&&A.map(e=>(0,z.jsxs)(`div`,{className:`mb-1`,children:[(0,z.jsx)(`p`,{className:`px-3 text-[10px] font-medium uppercase tracking-widest text-muted-foreground/70 mt-3 mb-1`,children:e.label}),e.items.map(N)]},e.label))]}),!c&&e===`pipeline`&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`mb-1`,"data-testid":`sidebar-pipeline-phases`,children:[(0,z.jsx)(`p`,{className:`px-3 text-[10px] font-medium uppercase tracking-widest text-muted-foreground mt-4 mb-1`,children:`Filter phase`}),(0,z.jsxs)(`button`,{type:`button`,"data-testid":`sidebar-phase-all`,onClick:()=>{J9(`phase`,null),C(q9)},className:`w-full flex items-center gap-3 px-3 py-1.5 transition-colors duration-150 text-sm font-medium border-l-2 ${S.phase===`all`?`bg-accent text-foreground border-primary`:`text-muted-foreground hover:bg-accent hover:text-foreground border-transparent`}`,children:[(0,z.jsx)(`span`,{className:`h-2 w-2 rounded-full bg-muted-foreground/30 shrink-0`}),(0,z.jsx)(`span`,{className:`truncate`,children:`All phases`}),(0,z.jsx)(`span`,{className:`ml-auto text-[11px] text-muted-foreground`,children:Object.values(w.phaseCounts).reduce((e,t)=>e+t,0)})]}),ljt.map(e=>(0,z.jsxs)(`button`,{type:`button`,"data-testid":`sidebar-phase-${e}`,onClick:()=>{J9(`phase`,e),C(q9)},className:`w-full flex items-center gap-3 px-3 py-1.5 transition-colors duration-150 text-sm font-medium border-l-2 ${S.phase===e?`bg-accent text-foreground border-primary`:`text-muted-foreground hover:bg-accent hover:text-foreground border-transparent`}`,children:[(0,z.jsx)(`span`,{className:`h-2 w-2 rounded-full shrink-0 ${djt[e]}`}),(0,z.jsx)(`span`,{className:`truncate`,children:ujt[e]}),(0,z.jsx)(`span`,{className:`ml-auto text-[11px] text-muted-foreground`,children:w.phaseCounts[e]??0})]},e))]}),w.projects.length>0&&(0,z.jsxs)(`div`,{className:`mb-1`,"data-testid":`sidebar-pipeline-projects`,children:[(0,z.jsx)(`p`,{className:`px-3 text-[10px] font-medium uppercase tracking-widest text-muted-foreground mt-4 mb-1`,children:`Projects`}),w.projects.map(e=>{let t=S.projects.includes(e.id);return(0,z.jsxs)(`button`,{type:`button`,"data-testid":`sidebar-project-${e.id}`,onClick:()=>{let n=t?S.projects.filter(t=>t!==e.id):[...S.projects,e.id];J9(`projects`,n.length>0?n.join(`,`):null),C(q9)},"aria-pressed":t,className:`w-full flex items-center gap-3 px-3 py-1.5 transition-colors duration-150 text-sm font-medium border-l-2 ${t?`bg-accent text-foreground border-primary`:`text-muted-foreground hover:bg-accent hover:text-foreground border-transparent`}`,children:[(0,z.jsx)(`span`,{className:`h-2 w-2 rounded-full shrink-0`,style:{background:e.color||`currentColor`}}),(0,z.jsx)(`span`,{className:`truncate`,children:e.name}),e.prefix&&(0,z.jsx)(`span`,{className:`ml-auto text-[11px] text-muted-foreground font-mono`,children:e.prefix})]},e.id)})]})]})]}),(0,z.jsxs)(`div`,{className:`shrink-0 border-t border-border`,children:[!c&&(0,z.jsxs)(`div`,{className:`px-3 py-2 space-y-1`,children:[(0,z.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,z.jsx)(`div`,{className:`ml-auto`,children:(0,z.jsx)(ojt,{})})}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsxs)(`button`,{onClick:n,className:`flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors`,title:`Search (press /)`,"data-testid":`sidebar-search`,children:[(0,z.jsx)(`span`,{children:`Search`}),(0,z.jsx)(`kbd`,{className:`text-[10px] px-1 py-0.5 rounded bg-muted text-muted-foreground`,children:`/`})]}),(0,z.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,z.jsx)(`button`,{onClick:()=>t(`settings`),className:`p-1.5 rounded-md transition-colors ${e===`settings`?`text-foreground bg-accent`:`text-muted-foreground hover:text-foreground hover:bg-accent`}`,title:`Settings`,"data-testid":`sidebar-settings-pinned`,children:(0,z.jsx)(Tr,{className:`w-4 h-4`})}),E&&(0,z.jsx)(`button`,{onClick:()=>j.mutate(),disabled:j.isPending,className:`p-1.5 rounded-md text-muted-foreground hover:text-foreground hover:bg-accent transition-colors disabled:opacity-50`,title:j.isPending?`Building...`:`Rebuild Overdeck (npm run build)`,"data-testid":`sidebar-rebuild`,children:j.isPending?(0,z.jsx)(ar,{className:`w-4 h-4 animate-spin`}):(0,z.jsx)(Yn,{className:`w-4 h-4`})}),(0,z.jsx)(`button`,{onClick:s,className:`p-1.5 rounded-md text-muted-foreground hover:text-foreground hover:bg-accent transition-colors`,title:`Switch to ${o===`dark`?`light`:`dark`} mode`,"data-testid":`sidebar-theme`,children:o===`dark`?(0,z.jsx)(Nr,{className:`w-4 h-4`}):(0,z.jsx)(fr,{className:`w-4 h-4`})})]})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,z.jsx)(`span`,{className:`text-[9px] font-semibold uppercase tracking-wider px-1.5 py-0.5 rounded ${E?`bg-amber-500/15 text-amber-500`:`bg-emerald-500/15 text-emerald-500`}`,children:E?`DEV`:`PROD`}),j.isSuccess&&(0,z.jsx)(`span`,{className:`text-[10px] text-emerald-500`,children:`Build complete`}),j.isError&&(0,z.jsx)(`span`,{className:`text-[10px] text-destructive`,title:j.error?.message,children:`Build failed`})]})]}),c&&(0,z.jsxs)(`div`,{className:`flex flex-col items-center gap-1 py-2`,children:[(0,z.jsx)(`span`,{className:`text-[8px] font-semibold uppercase tracking-wider px-1 py-0.5 rounded ${E?`bg-amber-500/15 text-amber-500`:`bg-emerald-500/15 text-emerald-500`}`,children:E?`DEV`:`PROD`}),(0,z.jsx)(`button`,{onClick:()=>t(`settings`),className:`p-1.5 rounded-md transition-colors ${e===`settings`?`text-foreground bg-accent`:`text-muted-foreground hover:text-foreground hover:bg-accent`}`,title:`Settings`,"data-testid":`sidebar-settings-pinned`,children:(0,z.jsx)(Tr,{className:`w-3.5 h-3.5`})}),E&&(0,z.jsx)(`button`,{onClick:()=>j.mutate(),disabled:j.isPending,className:`p-1.5 rounded-md text-muted-foreground hover:text-foreground hover:bg-accent transition-colors disabled:opacity-50`,title:j.isPending?`Building...`:`Rebuild`,"data-testid":`sidebar-rebuild`,children:j.isPending?(0,z.jsx)(ar,{className:`w-3.5 h-3.5 animate-spin`}):(0,z.jsx)(Yn,{className:`w-3.5 h-3.5`})}),(0,z.jsx)(`button`,{onClick:s,className:`p-1.5 rounded-md text-muted-foreground hover:text-foreground hover:bg-accent transition-colors`,title:`Switch to ${o===`dark`?`light`:`dark`} mode`,"data-testid":`sidebar-theme`,children:o===`dark`?(0,z.jsx)(Nr,{className:`w-3.5 h-3.5`}):(0,z.jsx)(fr,{className:`w-3.5 h-3.5`})}),(0,z.jsx)(`button`,{onClick:M,className:`p-1.5 rounded-md text-muted-foreground hover:text-foreground hover:bg-accent transition-colors`,title:`Expand sidebar ([)`,"data-testid":`sidebar-collapse`,children:(0,z.jsx)(ree,{className:`w-4 h-4`})})]})]})]})]})}function Y9({fallback:e,children:t}){return sm(Mhe)?(0,z.jsx)(z.Fragment,{children:t}):(0,z.jsx)(z.Fragment,{children:e})}function vjt(){return(0,z.jsx)(`div`,{className:`flex gap-4 overflow-x-auto pb-4`,children:[{title:`Todo`,color:`border-primary`},{title:`In Progress`,color:`border-yellow-500`},{title:`In Review`,color:`border-purple-500`},{title:`Done`,color:`border-success`}].map(e=>(0,z.jsxs)(`div`,{className:`border-t-4 ${e.color} bg-card rounded-lg min-w-[280px] flex-1`,children:[(0,z.jsx)(`div`,{className:`px-4 py-3 border-b border-border`,children:(0,z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,z.jsx)(`div`,{className:`h-4 w-24 animate-pulse bg-muted rounded`}),(0,z.jsx)(`div`,{className:`h-4 w-6 animate-pulse bg-muted rounded`})]})}),(0,z.jsx)(`div`,{className:`p-3 space-y-2`,children:Array.from({length:3}).map((e,t)=>(0,z.jsxs)(`div`,{className:`bg-card rounded-lg p-3 space-y-2`,children:[(0,z.jsx)(`div`,{className:`h-3 w-3/4 animate-pulse bg-muted rounded`}),(0,z.jsx)(`div`,{className:`h-3 w-1/2 animate-pulse bg-muted rounded`}),(0,z.jsxs)(`div`,{className:`flex gap-2 mt-2`,children:[(0,z.jsx)(`div`,{className:`h-5 w-16 animate-pulse bg-muted rounded`}),(0,z.jsx)(`div`,{className:`h-5 w-10 animate-pulse bg-muted rounded`})]})]},t))})]},e.title))})}function yjt(){return(0,z.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-6 p-6 w-full`,children:[(0,z.jsxs)(`div`,{className:`bg-card rounded-lg`,children:[(0,z.jsxs)(`div`,{className:`px-4 py-3 border-b border-border flex items-center justify-between`,children:[(0,z.jsx)(`div`,{className:`h-4 w-36 animate-pulse bg-muted rounded`}),(0,z.jsx)(`div`,{className:`h-6 w-20 animate-pulse bg-muted rounded`})]}),(0,z.jsx)(`div`,{className:`divide-y divide-divider`,children:Array.from({length:4}).map((e,t)=>(0,z.jsxs)(`div`,{className:`p-4 flex items-center justify-between`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,z.jsx)(`div`,{className:`h-8 w-8 animate-pulse bg-muted rounded-full`}),(0,z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,z.jsx)(`div`,{className:`h-3 w-32 animate-pulse bg-muted rounded`}),(0,z.jsx)(`div`,{className:`h-3 w-20 animate-pulse bg-muted rounded`})]})]}),(0,z.jsx)(`div`,{className:`h-5 w-16 animate-pulse bg-muted rounded`})]},t))})]}),(0,z.jsxs)(`div`,{className:`bg-card rounded-lg p-4`,children:[(0,z.jsx)(`div`,{className:`h-4 w-28 animate-pulse bg-muted rounded mb-4`}),(0,z.jsx)(`div`,{className:`space-y-2`,children:Array.from({length:6}).map((e,t)=>(0,z.jsx)(`div`,{className:`h-3 animate-pulse bg-muted rounded`,style:{width:`${60+t%3*15}%`}},t))})]})]})}function bjt(){return(0,z.jsxs)(`div`,{className:`flex h-full w-full flex-col overflow-hidden bg-background`,children:[(0,z.jsxs)(`div`,{className:`flex h-[52px] shrink-0 items-center gap-[12px] border-b border-border bg-background px-[22px]`,children:[(0,z.jsxs)(`div`,{className:`min-w-0 space-y-[4px]`,children:[(0,z.jsx)(`div`,{className:`h-[8px] w-[80px] animate-pulse rounded bg-muted`}),(0,z.jsx)(`div`,{className:`h-[14px] w-[100px] animate-pulse rounded bg-muted`})]}),(0,z.jsx)(`div`,{className:`flex-1 h-[32px] min-w-[280px] animate-pulse rounded-[var(--radius-lg)] bg-muted`}),(0,z.jsx)(`div`,{className:`h-[32px] w-[120px] animate-pulse rounded-[var(--radius-lg)] bg-muted`}),(0,z.jsx)(`div`,{className:`ml-auto h-[32px] w-[110px] animate-pulse rounded-[var(--radius-lg)] bg-muted`})]}),(0,z.jsx)(`div`,{className:`flex shrink-0 border-b border-border bg-background`,children:Array.from({length:5}).map((e,t)=>(0,z.jsxs)(`div`,{className:`flex-1 border-r border-border last:border-r-0 px-[18px] py-[12px] space-y-[6px]`,children:[(0,z.jsx)(`div`,{className:`h-[10px] w-[70px] animate-pulse rounded bg-muted`}),(0,z.jsx)(`div`,{className:`h-[20px] w-[40px] animate-pulse rounded bg-muted`}),(0,z.jsx)(`div`,{className:`h-[9px] w-[55px] animate-pulse rounded bg-muted`})]},t))}),(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-[8px] border-b border-border bg-background px-[22px] py-[10px]`,children:[Array.from({length:6}).map((e,t)=>(0,z.jsx)(`div`,{className:`h-[28px] animate-pulse rounded-[var(--radius-sm)] bg-muted ${t===0?`w-[40px]`:`w-[56px]`}`},t)),(0,z.jsxs)(`div`,{className:`ml-auto flex gap-[6px]`,children:[(0,z.jsx)(`div`,{className:`h-[28px] w-[70px] animate-pulse rounded-[var(--radius-sm)] bg-muted`}),(0,z.jsx)(`div`,{className:`h-[28px] w-[60px] animate-pulse rounded-[var(--radius-sm)] bg-muted`})]})]}),(0,z.jsx)(`div`,{className:`flex-1 overflow-auto`,children:[`Ship`,`Review`,`Work`,`Plan`].map(e=>(0,z.jsxs)(`section`,{children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-[10px] border-b border-border px-[22px] py-[12px]`,children:[(0,z.jsx)(`div`,{className:`h-[8px] w-[8px] animate-pulse rounded-full bg-muted`}),(0,z.jsx)(`div`,{className:`h-[14px] w-[60px] animate-pulse rounded bg-muted`}),(0,z.jsx)(`div`,{className:`h-[16px] w-[24px] animate-pulse rounded-[var(--radius-sm)] bg-muted`})]}),Array.from({length:3}).map((e,t)=>(0,z.jsxs)(`div`,{className:`flex items-center gap-[10px] border-b border-border px-[22px] py-[12px]`,children:[(0,z.jsx)(`div`,{className:`h-[10px] w-[10px] animate-pulse rounded bg-muted shrink-0`}),(0,z.jsx)(`div`,{className:`h-[12px] flex-1 animate-pulse rounded bg-muted`}),(0,z.jsx)(`div`,{className:`h-[18px] w-[90px] animate-pulse rounded bg-muted`}),(0,z.jsx)(`div`,{className:`h-[10px] w-[55px] animate-pulse rounded bg-muted`})]},t))]},e))})]})}function xjt(){return(0,z.jsxs)(`div`,{className:`god-view flex flex-col h-full`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 border-b border-border shrink-0`,children:[(0,z.jsx)(`div`,{className:`h-4 w-48 animate-pulse bg-muted rounded`}),(0,z.jsx)(`div`,{className:`h-4 w-24 animate-pulse bg-muted rounded`})]}),(0,z.jsxs)(`div`,{className:`flex flex-1 gap-3 px-3 pb-3 pt-2 min-h-0 overflow-hidden`,children:[(0,z.jsx)(`div`,{className:`flex-1 grid grid-cols-3 gap-3 content-start overflow-auto`,children:Array.from({length:6}).map((e,t)=>(0,z.jsxs)(`div`,{className:`bg-card rounded-lg p-3 space-y-2 min-h-[120px]`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`div`,{className:`h-6 w-6 animate-pulse bg-muted rounded-full`}),(0,z.jsx)(`div`,{className:`h-3 w-24 animate-pulse bg-muted rounded`})]}),(0,z.jsx)(`div`,{className:`h-3 w-3/4 animate-pulse bg-muted rounded`}),(0,z.jsx)(`div`,{className:`h-3 w-1/2 animate-pulse bg-muted rounded`}),(0,z.jsx)(`div`,{className:`h-16 animate-pulse bg-muted rounded mt-2`})]},t))}),(0,z.jsxs)(`div`,{className:`w-[220px] shrink-0 space-y-3`,children:[(0,z.jsxs)(`div`,{className:`bg-card rounded-lg p-3`,children:[(0,z.jsx)(`div`,{className:`h-3 w-20 animate-pulse bg-muted rounded mb-3`}),Array.from({length:4}).map((e,t)=>(0,z.jsxs)(`div`,{className:`flex items-center gap-2 py-1.5`,children:[(0,z.jsx)(`div`,{className:`h-2 w-2 animate-pulse bg-muted rounded-full`}),(0,z.jsx)(`div`,{className:`h-3 flex-1 animate-pulse bg-muted rounded`})]},t))]}),(0,z.jsxs)(`div`,{className:`bg-card rounded-lg p-3`,children:[(0,z.jsx)(`div`,{className:`h-3 w-24 animate-pulse bg-muted rounded mb-3`}),(0,z.jsx)(`div`,{className:`h-32 animate-pulse bg-muted rounded`})]})]})]})]})}function Sjt({sessionName:e,token:t}){let[n,r]=(0,R.useState)(!1),[i,a]=(0,R.useState)(e);(0,R.useEffect)(()=>{let e=new URLSearchParams(window.location.search).get(`title`);if(e){a(decodeURIComponent(e));return}document.title.trim()&&a(document.title)},[e]);function o(){let e=window.overdeckBridge;if(e?.isDesktopApp?.()){let t=!n;r(t),e.setAlwaysOnTop(t);return}window.focus()}let s=`#92a4c9`;return(0,z.jsxs)(`div`,{className:`flex h-full min-w-0 flex-col bg-[#0d1117]`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between border-b px-3 py-1.5 shrink-0`,style:{borderColor:`#232f48`,backgroundColor:`#161b26`},children:[(0,z.jsx)(`span`,{className:`text-xs font-medium`,style:{color:s},children:i}),(0,z.jsx)(`button`,{onClick:o,className:`rounded p-1 transition-colors hover:bg-white/10`,style:{color:n?`#58a6ff`:s},title:n?`Disable always on top`:`Enable always on top`,children:n?(0,z.jsx)(Oee,{className:`h-3.5 w-3.5`}):(0,z.jsx)(kee,{className:`h-3.5 w-3.5`})})]}),(0,z.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,z.jsx)(IS,{sessionName:e,token:t})})]})}var X9=[`no-resume-mode`];async function Cjt(){let e=await fetch(`/api/no-resume-mode`);if(!e.ok)throw Error(`GET /api/no-resume-mode → ${e.status}`);return e.json()}async function wjt(){let e=await fetch(`/api/resume-all`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error||`POST /api/resume-all → ${e.status}`)}return e.json()}function Tjt(e){if(!e)return`startup`;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function Ejt(){let e=_t(),t=Ur(),{data:n}=B({queryKey:X9,queryFn:Cjt,staleTime:5e3,refetchInterval:3e4,refetchOnWindowFocus:!0});(0,R.useEffect)(()=>{let t=()=>{e.invalidateQueries({queryKey:X9})};return window.addEventListener(`overdeck:reconnected`,t),()=>window.removeEventListener(`overdeck:reconnected`,t)},[e]);let r=Nt({mutationFn:wjt,onSuccess:({count:n})=>{e.invalidateQueries({queryKey:X9}),e.invalidateQueries({queryKey:[`agents`]}),t({message:n>0?`Resuming ${n} agent${n===1?``:`s`} — auto-resume is now on for this session.`:`Auto-resume is now on. No stopped agents needed resuming.`,variant:`success`})},onError:e=>{t({message:`Resume all failed: ${e.message}`,variant:`error`})}});if(n?.active!==!0)return null;let i=r.isPending;return(0,z.jsxs)(`div`,{className:`sticky top-0 z-40 bg-orange-950/70 border-b-2 border-orange-400/70 px-4 py-2 flex items-center gap-3 shrink-0`,"data-testid":`no-resume-banner`,children:[(0,z.jsx)(hr,{className:`w-5 h-5 text-orange-300 shrink-0`}),(0,z.jsxs)(`p`,{className:`text-orange-100 text-sm font-medium flex-1`,children:[`Agents are paused — Overdeck started without auto-resume (the standard, safe startup since `,Tjt(n.since),`). They will not pick up work until you start them. Click `,(0,z.jsx)(`span`,{className:`font-semibold`,children:`Resume all`}),` to put every stopped agent back to work, or use`,` `,(0,z.jsx)(`code`,{className:`font-mono text-xs bg-orange-500/20 px-1 rounded`,children:`pan start <id>`}),` `,`to spawn one individually.`]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>r.mutate(),disabled:i,"data-testid":`no-resume-resume-all`,className:`shrink-0 inline-flex items-center gap-1.5 h-[32px] rounded-[var(--radius-sm)] bg-orange-400 px-[14px] text-[12px] font-medium text-orange-950 transition-opacity hover:bg-orange-300 disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,z.jsx)(hr,{className:`w-3.5 h-3.5`}),i?`Resuming…`:`Resume all`]})]})}async function Djt(){let e=await fetch(`/api/settings`);if(!e.ok)throw Error(`settings fetch failed`);return e.json()}function Ojt({onOpenSettings:e}){let{data:t}=B({queryKey:[`settings`],queryFn:Djt,retry:!1});return t?.background_ai?.cheap_mode===!0?(0,z.jsxs)(`button`,{type:`button`,"data-testid":`low-cost-mode-pill`,onClick:()=>{aYe(`background-ai`),e?.()},title:`Background AI (titles, memory, enrichment, narration) is off to save cost. Memory in particular is one of Overdeck's most valuable features — click to choose what runs.`,className:`inline-flex items-center gap-1.5 rounded-full border border-border bg-muted/40 px-2.5 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:[(0,z.jsx)(zn,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),`Low-cost mode`,(0,z.jsx)(an,{className:`h-3.5 w-3.5 text-muted-foreground/70`,"aria-hidden":`true`})]}):null}async function kjt(){let e=await fetch(`/api/cloister/status`);if(!e.ok)throw Error(`Failed to fetch Cloister status`);return e.json()}async function Ajt(){if(!(await fetch(`/api/cloister/start`,{method:`POST`})).ok)throw Error(`Failed to start Cloister`)}async function jjt(){if(!(await fetch(`/api/cloister/stop`,{method:`POST`})).ok)throw Error(`Failed to stop Cloister`)}async function Mjt(){let e=await fetch(`/api/cloister/emergency-stop`,{method:`POST`});if(!e.ok)throw Error(`Failed to execute emergency stop`);return e.json()}async function Njt(){let e=await fJ(`/api/conversations`);return e.ok?e.json():[]}async function Pjt(){let e=await fetch(`/api/settings`);if(!e.ok)throw Error(`Failed to fetch settings`);return e.json()}async function Fjt(){let e=await fetch(`/api/tts/health`);if(!e.ok)throw Error(`Failed to fetch TTS health`);return e.json()}function Ijt(e,t){if(t)return`TTS: Health check failed`;if(!e)return`TTS: Checking daemon`;if(!e.ok)return e.error?`TTS: ${e.error}`:`TTS: Daemon offline`;let n=[e.model===void 0?void 0:`model: ${String(e.model)}`,e.queueDepth===void 0?e.queue===void 0?void 0:`queue: ${String(e.queue)}`:`queue: ${String(e.queueDepth)}`,typeof e.pid==`number`?`pid: ${e.pid}`:void 0,e.gpuMemoryUsedMb===void 0?void 0:`VRAM: ${e.gpuMemoryUsedMb}MB`].filter(Boolean);return n.length>0?`TTS: Running (${n.join(`, `)})`:`TTS: Running`}function Ljt({onOpenSettings:e}){let[t,n]=(0,R.useState)(!1),[r,i]=(0,R.useState)(!1),[a,o]=(0,R.useState)(!0),[s,c]=(0,R.useState)(!0),[l,u]=(0,R.useState)(!1),d=(0,R.useRef)(null),f=(0,R.useRef)(null),[p,m]=(0,R.useState)(null),h=_t(),{data:g,refetch:_}=B({queryKey:[`cloister-status`],queryFn:kjt,refetchInterval:1e4}),{data:v}=B({queryKey:[`specialists-raw`],queryFn:async()=>{let e=await fetch(`/api/specialists`);return e.ok?e.json():null},refetchInterval:3e4}),{data:y=[]}=B({queryKey:[`conversations`],queryFn:Njt,refetchInterval:1e4}),{data:b}=B({queryKey:[`settings`],queryFn:Pjt,retry:!1}),x=b?.tts?.enabled===!0,{data:S,isError:C}=B({queryKey:[`tts-health`],queryFn:Fjt,enabled:x,refetchInterval:1e4,retry:!1}),w=sm(lm).filter(e=>e.status===`running`).length,T=y.filter(e=>e.sessionAlive).length,E=(v?.projects??[]).filter(e=>e.isRunning),D=(0,R.useCallback)(()=>{if(f.current){let e=f.current.getBoundingClientRect();m({left:e.left,bottom:window.innerHeight-e.top+8})}i(!0)},[]);(0,R.useEffect)(()=>{if(!r)return;let e=e=>{d.current&&!d.current.contains(e.target)&&f.current&&!f.current.contains(e.target)&&i(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[r]);let O=Nt({mutationFn:async({convs:e,doAgents:t})=>{let n=[];e&&n.push(fetch(`/api/conversations/restart-all`,{method:`POST`})),t&&n.push(fetch(`/api/agents/restart-all`,{method:`POST`}));let r=await Promise.all(n);for(let e of r)if(!e.ok)throw Error(`Restart failed: ${e.statusText}`)},onSuccess:()=>{h.invalidateQueries({queryKey:[`conversations`]}),_(),i(!1)}}),k=async()=>{u(!0);try{g?.running?await jjt():await Ajt(),await _()}finally{u(!1)}},A=async()=>{await Mjt(),n(!1),_()},j=()=>{!a&&!s||O.mutate({convs:a,doAgents:s})};if(!g)return(0,z.jsx)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:(0,z.jsx)(`button`,{onClick:e,className:`p-1 rounded text-xs bg-popover text-foreground hover:bg-card transition-colors`,title:`Open Settings`,children:(0,z.jsx)(Tr,{className:`w-3.5 h-3.5`})})});let M=g.summary.warning>0||g.summary.stuck>0,N=g.agentsNeedingAttention.length,P=C?`bg-destructive`:S?.ok?`bg-success`:`bg-muted-foreground`;return(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,z.jsx)(`div`,{className:`flex items-center gap-1`,title:g.running?`Cloister: Running`:`Cloister: Stopped`,children:g.running?(0,z.jsx)(Kt,{className:`w-3.5 h-3.5 text-success`}):(0,z.jsx)(Gt,{className:`w-3.5 h-3.5 text-muted-foreground`})}),g.running&&g.summary.total>0&&(0,z.jsxs)(`div`,{className:`flex items-center gap-1 text-xs`,children:[g.summary.active>0&&(0,z.jsx)(`span`,{className:`text-success`,children:g.summary.active}),g.summary.warning>0&&(0,z.jsx)(`span`,{className:`text-warning`,children:g.summary.warning}),g.summary.stuck>0&&(0,z.jsx)(`span`,{className:`text-destructive`,children:g.summary.stuck})]}),E.length>0&&(0,z.jsxs)(`span`,{className:`flex items-center gap-0.5 text-xs text-success`,title:`Ephemeral: ${E.map(e=>`${e.projectKey.toUpperCase()} ${e.specialistType}`).join(`, `)}`,children:[(0,z.jsx)(Br,{className:`w-3 h-3`}),E.length]}),M&&(0,z.jsx)(`span`,{title:`${N} agent${N===1?``:`s`} need attention`,children:(0,z.jsx)(Ir,{className:`w-3.5 h-3.5 text-warning`})}),x&&(0,z.jsxs)(`span`,{"data-testid":`tts-health-badge`,className:`flex items-center gap-1 rounded bg-popover px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground`,title:Ijt(S,C),children:[(0,z.jsx)(`span`,{"data-testid":`tts-health-dot`,className:`h-1.5 w-1.5 rounded-full ${P}`}),`TTS`]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,z.jsx)(`button`,{onClick:k,disabled:l,className:`px-2 py-0.5 rounded text-xs transition-colors ${l?`bg-card text-muted-foreground cursor-wait`:g.running?`bg-popover text-foreground hover:bg-card`:`bg-primary text-primary-foreground hover:bg-primary/90`}`,children:l?`…`:g.running?`Stop Cloister`:`Start Cloister`}),(0,z.jsx)(`button`,{ref:f,onClick:()=>r?i(!1):D(),className:`p-1 rounded text-xs bg-popover text-foreground border border-border hover:bg-card transition-colors`,title:`Restart sessions`,children:(0,z.jsx)(_r,{className:`w-3.5 h-3.5 ${O.isPending?`animate-spin`:``}`})}),r&&p&&(0,Kr.createPortal)((0,z.jsxs)(`div`,{ref:d,style:{position:`fixed`,zIndex:9999,left:p.left,bottom:p.bottom,width:256,borderRadius:6,border:`1px solid var(--border, #333)`,boxShadow:`0 4px 12px rgba(0,0,0,0.4)`,backgroundColor:`var(--card, #0c1018)`},children:[(0,z.jsx)(`div`,{className:`px-3 py-2 text-xs font-semibold text-foreground border-b border-border`,children:`Restart Sessions`}),(0,z.jsxs)(`div`,{className:`p-2 space-y-1`,children:[(0,z.jsxs)(`label`,{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs text-foreground hover:bg-muted cursor-pointer`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:a,onChange:e=>o(e.target.checked),className:`accent-primary`}),(0,z.jsx)(`span`,{children:`Conversations`}),(0,z.jsxs)(`span`,{className:`ml-auto text-muted-foreground`,children:[`(`,T,` active)`]})]}),(0,z.jsxs)(`label`,{className:`flex items-center gap-2 px-2 py-1.5 rounded text-xs text-foreground hover:bg-muted cursor-pointer`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:s,onChange:e=>c(e.target.checked),className:`accent-primary`}),(0,z.jsx)(`span`,{children:`Workspace Agents`}),(0,z.jsxs)(`span`,{className:`ml-auto text-muted-foreground`,children:[`(`,w,` active)`]})]})]}),(0,z.jsxs)(`div`,{className:`flex justify-end gap-1.5 px-3 py-2 border-t border-border`,children:[(0,z.jsx)(`button`,{onClick:()=>i(!1),className:`px-2 py-1 rounded text-xs text-foreground bg-muted hover:bg-accent`,children:`Cancel`}),(0,z.jsx)(`button`,{onClick:j,disabled:O.isPending||!a&&!s,className:`px-2 py-1 rounded text-xs text-primary-foreground bg-primary hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed`,children:O.isPending?`Restarting...`:`Restart`})]}),O.isError&&(0,z.jsx)(`div`,{className:`px-3 py-1.5 text-xs text-destructive border-t border-border`,children:O.error.message})]}),document.body),t?(0,z.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-0.5 badge-bg-destructive rounded border badge-border-destructive`,children:[(0,z.jsx)(`span`,{className:`text-xs text-destructive`,children:`Kill all?`}),(0,z.jsx)(`button`,{onClick:A,className:`px-1.5 py-0.5 rounded text-xs bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:`Yes`}),(0,z.jsx)(`button`,{onClick:()=>n(!1),className:`px-1.5 py-0.5 rounded text-xs bg-popover text-foreground hover:bg-card`,children:`No`})]}):(0,z.jsx)(`button`,{onClick:()=>n(!0),className:`p-1 rounded text-xs badge-bg-destructive text-destructive border badge-border-destructive hover:bg-destructive/20 transition-colors`,title:`Emergency stop — kill all agents (hotkey: ${zM})`,children:(0,z.jsx)(ln,{className:`w-3.5 h-3.5`})}),(0,z.jsx)(`button`,{onClick:e,className:`p-1 rounded text-xs bg-popover text-foreground hover:bg-card transition-colors`,title:`Open Settings`,children:(0,z.jsx)(Tr,{className:`w-3.5 h-3.5`})})]})]})}function Rjt({onOpenSettings:e}){let[t,n]=(0,R.useState)(!1),r=(0,R.useRef)(null);return(0,R.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Escape`&&n(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[t]),(0,z.jsxs)(`div`,{className:`relative`,children:[(0,z.jsx)(`button`,{ref:r,type:`button`,"aria-label":`System controls`,"aria-expanded":t,title:`System controls — Cloister, restart, emergency stop, settings`,onClick:()=>n(e=>!e),className:`rounded-md p-1.5 transition-colors focus:outline-none focus:ring-2 focus:ring-ring ${t?`bg-accent text-foreground`:`text-muted-foreground hover:bg-accent hover:text-foreground`}`,children:(0,z.jsx)(zee,{className:`h-4 w-4`,"aria-hidden":`true`})}),t&&(0,z.jsx)(`div`,{role:`menu`,className:`absolute right-0 top-full z-50 mt-1 rounded-lg border border-border bg-popover p-2 shadow-lg`,children:(0,z.jsx)(Ljt,{onOpenSettings:e})})]})}var zjt=/^PAN-(AC|PI(-PROMPT)?|TEST|REVIEW|SHIP|SUB(REVIEW|SIGNAL)?)-?\d*$/;function Bjt(e){let t=e.lastActivity??e.startedAt;if(!t)return null;let n=Date.parse(t);return Number.isFinite(n)?n:null}function Vjt(e,t=Date.now()){if(e.hasLiveTmuxSession===!0||e.hasLiveTmuxSession===void 0&&(e.status===`running`||e.status===`starting`))return`active`;let n=Bjt(e);return zjt.test(e.issueId)&&n!==null&&t-n>6048e5?`orphan_test`:`stopped`}var Hjt=new Set([`plan`,`review`,`test`,`ship`]),Ujt=new Set([`in_review`,`verifying_on_main`,`done`,`canceled`,`merged`,`closed`]);function Wjt({variant:e=`banner`}={}){let t=sm(lm),n=sm(fm),r=new Map;for(let e of n){let t=typeof e.identifier==`string`?e.identifier.toUpperCase():null,n=typeof e.canonicalStatus==`string`?e.canonicalStatus:null;t&&n&&r.set(t,n)}let i=(0,R.useRef)(new Set);(0,R.useEffect)(()=>{let e=new Set(t.filter(e=>e.resolution===`api_error`).map(e=>e.id));for(let n of e)if(!i.current.has(n)){let e=t.find(e=>e.id===n)?.issueId||n;H.warning(`${e}: API error — auto-retry nudge sent`,{duration:8e3})}i.current=e},[t]);let a=new Set([`plan`,`work`,`review`,`test`,`ship`]),o=t.filter(e=>{if(!e.issueId||Vjt({issueId:e.issueId,status:e.status,hasLiveTmuxSession:e.hasLiveTmuxSession??e.lifecycle?.hasLiveTmuxSession,lastActivity:e.lastActivity,startedAt:e.startedAt})!==`stopped`||e.runtimeState===`completed`||e.resolution===`completed`||e.resolution===`done`||e.lifecycle?.isCompleted||!e.role||!a.has(e.role))return!1;if(Hjt.has(e.role)){let t=r.get(e.issueId.toUpperCase());if(t&&Ujt.has(t))return!1}let t=e.lastActivity?new Date(e.lastActivity).getTime():0,n=e.startedAt?new Date(e.startedAt).getTime():0,i=Math.max(t,n);return i>0&&Date.now()-i<6048e5}),s=new Map;for(let e of o){let t=e.issueId||e.id,n=s.get(t);if(!n){s.set(t,e);continue}let r=Math.max(n.lastActivity?new Date(n.lastActivity).getTime():0,n.startedAt?new Date(n.startedAt).getTime():0);Math.max(e.lastActivity?new Date(e.lastActivity).getTime():0,e.startedAt?new Date(e.startedAt).getTime():0)>r&&s.set(t,e)}let c=Array.from(s.values()),[l,u]=(0,R.useState)(!1),[d,f]=(0,R.useState)(!1),[p,m]=(0,R.useState)(null),[h,g]=(0,R.useState)(!1),_=(0,R.useRef)(null);(0,R.useEffect)(()=>{if(!h)return;let e=e=>{_.current?.contains(e.target)||g(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[h]);let v=(0,R.useCallback)(async()=>{if(d)return;f(!0),m(null);let e=[];for(let t of c)if(t.issueId)try{let n={issueId:t.issueId},r=n,i=await fetch(`/api/agents`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)}),a=await i.json().catch(()=>({}));if(i.status===409&&a.requiresAcknowledgement){if(!window.confirm((a.guardrails?.warnings??[]).map(e=>`• ${e.message}`).join(`
|
|
803
|
-
`))){e.push({issueId:t.issueId,success:!1,error:`Agent start canceled`});continue}r={...n,guardrailAcknowledged:!0},i=await fetch(`/api/agents`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)}),a=await i.json().catch(()=>({}))}if(i.ok)a.guardrails?.warnings?.length&&H.success(`${t.issueId}: started after acknowledging system health warnings`,{duration:8e3}),e.push({issueId:t.issueId,success:!0});else{if(SYe(i,a)){vYe(r),e.push({issueId:t.issueId,success:!1,error:a.hint||a.error||`Codex authentication expired — re-authenticate to continue`});continue}e.push({issueId:t.issueId,success:!1,error:a.error||a.hint||i.statusText})}}catch(n){e.push({issueId:t.issueId,success:!1,error:n instanceof Error?n.message:String(n)})}m(e),f(!1)},[d,c]),y=(0,R.useCallback)(()=>{u(!0)},[]),b=(0,R.useCallback)(()=>{m(null),u(!1)},[]),x=p?.filter(e=>e.success).length??0,S=p?.filter(e=>!e.success).length??0;if(e===`pill`)return c.length===0?null:(0,z.jsxs)(`div`,{className:`relative`,ref:_,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:()=>g(e=>!e),"aria-expanded":h,className:`inline-flex items-center gap-1.5 rounded-full border border-warning/40 bg-warning/10 px-2.5 py-1 text-xs font-medium text-warning-foreground transition-colors hover:bg-warning/20`,"data-testid":`stopped-agents-pill`,children:[(0,z.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-warning`}),c.length,` stopped`]}),h&&(0,z.jsxs)(`div`,{className:`absolute right-0 top-full z-50 mt-1.5 w-72 rounded-lg border border-border bg-card p-3 shadow-xl`,children:[(0,z.jsxs)(`div`,{className:`mb-2 flex items-center gap-1.5 text-xs font-semibold text-warning-foreground`,children:[(0,z.jsx)(Ir,{className:`h-3.5 w-3.5`}),c.length,` agent`,c.length>1?`s`:``,` stopped`]}),(0,z.jsx)(`div`,{className:`mb-3 max-h-40 overflow-y-auto`,children:c.map(e=>(0,z.jsxs)(`div`,{className:`flex items-center justify-between py-0.5 text-xs`,children:[(0,z.jsx)(`span`,{className:`font-mono text-foreground`,children:e.issueId||e.id}),e.role&&(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:e.role})]},e.id))}),p&&(0,z.jsxs)(`div`,{className:`mb-2 text-xs`,children:[x>0&&(0,z.jsxs)(`span`,{className:`text-success`,children:[`✓ `,x,` restarted`]}),S>0&&(0,z.jsxs)(`span`,{className:`ml-2 text-destructive`,children:[`✕ `,S,` failed`]})]}),(0,z.jsxs)(`button`,{onClick:v,disabled:d,className:`flex w-full items-center justify-center gap-1.5 rounded-md bg-primary px-2 py-1.5 text-xs font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50`,"data-testid":`pill-restart-all`,children:[d?(0,z.jsx)(ar,{className:`h-3 w-3 animate-spin`}):(0,z.jsx)(hr,{className:`h-3 w-3`}),d?`Restarting…`:`Restart all`]})]})]});if(l||c.length===0)return l&&c.length>0?(0,z.jsxs)(`div`,{className:`bg-card/40 border-b border-border px-4 py-1 flex items-center gap-2 shrink-0`,"data-testid":`stopped-agents-banner`,children:[(0,z.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[c.length,` agent`,c.length>1?`s`:``,` stopped`]}),(0,z.jsx)(`button`,{onClick:b,className:`text-xs text-primary hover:text-primary/80 underline`,children:`Show`})]}):null;let C=p?.filter(e=>e.success).length??0,w=p?.filter(e=>!e.success).length??0;return(0,z.jsxs)(`div`,{className:`bg-warning/10 border-b border-warning/30 px-3 py-1 flex items-center gap-2 shrink-0`,"data-testid":`stopped-agents-banner`,children:[(0,z.jsx)(Ir,{className:`w-3.5 h-3.5 text-warning-foreground shrink-0`}),(0,z.jsxs)(`span`,{className:`text-warning-foreground text-xs font-semibold`,children:[c.length,` stopped`]}),(0,z.jsxs)(`span`,{className:`text-warning-foreground/70 text-xs truncate`,children:[c.map(e=>e.issueId||e.id).join(`, `),c.some(e=>e.lastActivity)&&(0,z.jsxs)(`span`,{className:`ml-1`,children:[`(`,Math.max(...c.map(e=>e.lastActivity?Date.now()-new Date(e.lastActivity).getTime():0))/6e4|0,`m ago)`]})]}),p&&(0,z.jsxs)(`span`,{className:`text-xs ml-1`,children:[C>0&&(0,z.jsxs)(`span`,{className:`text-success inline-flex items-center gap-0.5`,children:[(0,z.jsx)(on,{className:`w-3 h-3`}),` `,C]}),w>0&&(0,z.jsxs)(`span`,{className:`text-destructive inline-flex items-center gap-0.5 ml-1`,children:[(0,z.jsx)(zr,{className:`w-3 h-3`}),` `,w]})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0 ml-auto`,children:[(0,z.jsxs)(`button`,{onClick:v,disabled:d,className:`flex items-center gap-1 px-2 py-0.5 text-xs font-medium rounded bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors`,"data-testid":`banner-restart-all`,children:[d?(0,z.jsx)(ar,{className:`w-3 h-3 animate-spin`}):(0,z.jsx)(hr,{className:`w-3 h-3`}),d?`Restarting...`:`Restart All`]}),(0,z.jsx)(`button`,{onClick:y,disabled:d,className:`text-warning-foreground/60 hover:text-warning-foreground shrink-0 disabled:opacity-50`,title:`Dismiss`,"data-testid":`banner-dismiss`,children:(0,z.jsx)(zr,{className:`w-3.5 h-3.5`})})]})]})}function Gjt(){let e=sm(lm),[t,n]=(0,R.useState)(!1),r=e.filter(e=>e.issueId?Vjt({issueId:e.issueId,status:e.status,hasLiveTmuxSession:e.hasLiveTmuxSession??e.lifecycle?.hasLiveTmuxSession,lastActivity:e.lastActivity,startedAt:e.startedAt})===`orphan_test`:!1);if(r.length===0)return null;let i=e=>{navigator.clipboard?.writeText(`pan wipe ${e}`)};return(0,z.jsxs)(`div`,{className:`bg-muted/35 border-b border-border px-3 py-1.5 shrink-0`,"data-testid":`orphan-test-agents-surface`,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:()=>n(e=>!e),className:`flex w-full items-center gap-2 text-xs text-muted-foreground hover:text-foreground transition-colors`,"data-testid":`orphan-test-toggle`,children:[t?(0,z.jsx)(en,{className:`w-3.5 h-3.5`}):(0,z.jsx)(nn,{className:`w-3.5 h-3.5`}),(0,z.jsxs)(`span`,{className:`font-medium`,children:[r.length,` residual test agent`,r.length===1?``:`s`]}),(0,z.jsx)(`span`,{className:`truncate`,children:`Residue from prior test runs; cleanup is manual via pan wipe.`})]}),t&&(0,z.jsx)(`div`,{className:`mt-1.5 grid gap-1 pl-5`,"data-testid":`orphan-test-agent-list`,children:r.map(e=>{let t=e.issueId??e.id;return(0,z.jsxs)(`div`,{className:`flex items-center gap-2 rounded border border-border/70 bg-background/60 px-2 py-1 text-xs`,children:[(0,z.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:t}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>i(t),className:`ml-auto inline-flex items-center gap-1 rounded border border-border px-2 py-0.5 text-muted-foreground hover:bg-muted hover:text-foreground`,children:[(0,z.jsx)(pn,{className:`w-3 h-3`}),"Copy `pan wipe ",t,"`"]})]},e.id)})})]})}function Kjt(){let{data:e}=JF(),[t,n]=(0,R.useState)(!1);return!e||e.status!==`expired`&&e.status!==`burned`?null:(0,z.jsxs)(`div`,{className:`bg-warning/10 border-b-2 border-warning/40 px-4 py-3 flex items-center gap-3 shrink-0`,children:[(0,z.jsx)(Ir,{className:`w-5 h-5 text-warning-foreground shrink-0`}),(0,z.jsxs)(`p`,{className:`text-warning-foreground text-sm font-semibold flex-1`,children:[`Codex authentication `,e.status,` — Codex-routed agents (gpt-5.x, o3, o4-mini) will fail.`,e.email&&(0,z.jsxs)(`span`,{className:`font-normal ml-1 opacity-80`,children:[`(`,(0,z.jsx)(eI,{value:e.email,className:`text-sm`}),`)`]})]}),(0,z.jsx)(`button`,{onClick:async()=>{n(!0);try{let e=await fetch(`/api/settings/codex-reauth`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error||`Failed to spawn re-auth session (${e.status})`)}let{sessionName:t,statusToken:n}=await e.json();yYe(t,n),H.success(`Re-authentication session started — opening terminal…`),window.location.href=`/terminal/${t}`}catch(e){H.error(e instanceof Error?e.message:`Failed to start re-authentication`)}finally{n(!1)}},disabled:t,className:`px-3 py-1.5 bg-warning/20 hover:bg-warning/30 text-warning-foreground text-sm font-semibold rounded-md transition-colors disabled:opacity-50 disabled:cursor-not-allowed shrink-0 flex items-center gap-1.5`,children:t?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(ar,{className:`w-3.5 h-3.5 animate-spin`}),`Starting…`]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(kn,{className:`w-3.5 h-3.5`}),`Re-authenticate`]})})]})}function Z9(){let{data:e}=JF(),t=_t(),n=(0,R.useRef)(null),r=(0,R.useRef)(!1);(0,R.useEffect)(()=>{if(r.current)return;let e=$F();if(!e?.reauthSessionName||!e.reauthStatusToken)return;let i=e.reauthSessionName,a=e.reauthStatusToken;return n.current&&clearInterval(n.current),n.current=setInterval(async()=>{if(!r.current)try{let e=await fetch(`/api/settings/codex-reauth/status`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({session:i,token:a})});if(!e.ok)return;let o=await e.json();if(o.completed){if(n.current&&=(clearInterval(n.current),null),o.success!==!0||o.authStatus?.status!==`valid`){xYe(),H.error(o.error||o.authStatus?.message||`Codex re-authentication did not produce valid auth`,{duration:8e3}),await _j(t);return}r.current=!0,t.setQueryData([`codex-auth-status`],o.authStatus);let e=$F();e?.requestBody?qjt(e.requestBody,t).finally(()=>{r.current=!1}):(bYe(),H.success(`Codex re-authentication completed`),await _j(t),r.current=!1)}}catch{}},3e3),()=>{n.current&&=(clearInterval(n.current),null)}},[e?.status,t]),(0,R.useEffect)(()=>{if(r.current)return;let n=$F();!n?.requestBody||n.reauthSessionName||e?.status===`valid`&&(r.current=!0,qjt(n.requestBody,t).finally(()=>{r.current=!1}))},[e?.status,t])}async function qjt(e,t){try{let n=await fetch(`/api/agents`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)}),r=await n.json().catch(()=>({}));if(!n.ok)throw Error(r.error||r.hint||`Failed to start agent (${n.status})`);bYe(),H.success(`Agent started automatically after Codex re-authentication`),await _j(t)}catch(e){xYe(),H.error(`Auto-retry failed: ${e instanceof Error?e.message:String(e)}`,{duration:8e3})}}function Jjt(e,t){let n=Hr(),r=_t(),i=Nt({mutationFn:async()=>{if(!e)throw Error(`No agent to kill`);let t=await fetch(`/api/agents/${e}`,{method:`DELETE`});if(!t.ok)throw Error(`Failed to kill agent`);return t.json()},onSuccess:async()=>{await _j(r),t?.onSuccess?.()}});return{killMutation:i,confirmAndKill:async()=>{if(!e)return!1;let t=await n({title:`Kill Agent`,message:`Kill agent ${e}?`,variant:`destructive`,confirmLabel:`Kill`});return t&&i.mutate(),t},isPending:i.isPending}}async function Yjt(){let e=await fetch(`/api/system/health`);if(!e.ok){let t=await e.text().catch(()=>``);throw Error(`Failed to fetch system health (${e.status}): ${t}`)}return e.json()}function Xjt(){return B({queryKey:[`system-health`],queryFn:Yjt,refetchInterval:15e3})}function Q9(e){let t=e/1024**3;return t>=1?`${t.toFixed(1)} GB`:`${(e/1024**2).toFixed(0)} MB`}function Zjt(e){return e===`critical`?`border-destructive/50 bg-destructive/10 text-destructive animate-pulse`:e===`warning`?`border-warning/40 bg-warning/10 text-warning-foreground`:`border-emerald-500/30 bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`}function Qjt(e){return e.issueId?`${e.label} · ${e.issueId}`:e.currentIssue?`${e.label} · ${e.currentIssue}`:e.label}function $jt({consumer:e,onSelectLeaked:t}){let n=Hr(),r=_t(),{confirmAndKill:i,isPending:a}=Jjt(e.killTarget?.kind===`agent`?e.killTarget.agentId:void 0,{onSuccess:()=>{e.leaked&&t()}}),o=Nt({mutationFn:async()=>{let t=e.killTarget;if(!t)throw Error(`No kill target available`);if(t.kind===`container`){if(!t.containerId)throw Error(`Missing container id`);let e=await fetch(`/api/resources/docker/container/${t.containerId}`,{method:`DELETE`});if(!e.ok)throw Error(`Failed to remove container`);return e.json()}if(t.kind===`specialist`){if(!t.projectKey||!t.issueId||!t.specialistType)throw Error(`Missing specialist target`);let e=await fetch(`/api/specialists/${t.projectKey}/${t.issueId}/${t.specialistType}/kill`,{method:`POST`});if(!e.ok)throw Error(`Failed to kill specialist`);return e.json()}throw Error(`Unsupported kill target`)},onSuccess:async()=>{await _j(r),await r.invalidateQueries({queryKey:[`system-health`]}),e.leaked&&t()}}),s=a||o.isPending,c=e.killTarget;if(!c)return null;let l=c.kind===`container`?`Remove container ${e.label}`:c.kind===`specialist`?`Kill specialist ${e.label}`:`Kill ${e.label}`,u=async()=>{if(c.kind===`agent`){await i();return}await n({title:c.kind===`container`?`Remove Container`:`Kill Specialist`,message:c.kind===`container`?`Remove Docker container ${e.label}?`:`Kill specialist ${e.label}?`,variant:`destructive`,confirmLabel:c.kind===`container`?`Remove`:`Kill`})&&o.mutate()};return(0,z.jsx)(`button`,{onClick:()=>void u(),disabled:s,className:`rounded border border-border px-2 py-1 text-[11px] text-muted-foreground hover:text-foreground hover:bg-accent disabled:opacity-50`,title:l,children:s?`Killing…`:c.kind===`container`?`Remove`:`Kill`})}function eMt({compact:e=!1}){let{data:t,isLoading:n,error:r}=Xjt(),[i,a]=(0,R.useState)(!1),[o,s]=(0,R.useState)(!1),c=(0,R.useRef)(null);(0,R.useEffect)(()=>{if(!t)return;let n=c.current;c.current=t.severity,!(e||n==null||n===t.severity||t.severity!==`critical`)&&H.error(`System health is critical`,{description:t.reasons[0]??`Open the health panel to inspect top consumers and leaked specialists.`,duration:1e4,action:{label:`Open`,onClick:()=>{s((t.leakedSpecialists?.length??0)>0),a(!0)}}})},[e,t]);let l=(0,R.useMemo)(()=>{let e=[...t?.topConsumers??[]].sort((e,t)=>Number(t.leaked??!1)-Number(e.leaked??!1));if(!o)return e;let n=e.filter(e=>e.leaked);return n.length>0?n:e},[t?.topConsumers,o]);return n?(0,z.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border px-2 py-1.5 text-xs text-muted-foreground ${e?`justify-center px-1.5`:``}`,children:[(0,z.jsx)(ar,{className:`h-3.5 w-3.5 animate-spin`}),!e&&(0,z.jsx)(`span`,{children:`Health`})]}):r||!t?(0,z.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-destructive/40 bg-destructive/10 px-2 py-1.5 text-xs text-destructive ${e?`justify-center px-1.5`:``}`,title:r?.message??`Failed to load system health`,children:[(0,z.jsx)(Ir,{className:`h-3.5 w-3.5`}),!e&&(0,z.jsx)(`span`,{children:`Health unavailable`})]}):(0,z.jsxs)(`div`,{className:`relative`,children:[(0,z.jsxs)(`button`,{onClick:()=>{s(!1),a(e=>!e)},className:`flex w-full items-center gap-2 rounded-md border px-2 py-1.5 text-xs transition-colors hover:bg-accent ${Zjt(t.severity)} ${e?`justify-center px-1.5`:`justify-between`}`,"data-testid":`system-health-pill`,children:[(0,z.jsxs)(`span`,{className:`flex items-center gap-2 min-w-0`,children:[t.severity===`critical`?(0,z.jsx)(Ree,{className:`h-3.5 w-3.5`}):(0,z.jsx)(Ir,{className:`h-3.5 w-3.5`}),!e&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`font-semibold uppercase tracking-wide`,children:t.severity}),(0,z.jsxs)(`span`,{className:`text-muted-foreground`,children:[Math.round(t.summary.memoryUsedPercent),`% mem`]})]})]}),!e&&(0,z.jsx)(en,{className:`h-3.5 w-3.5 transition-transform ${i?`rotate-180`:``}`})]}),i&&!e&&(0,z.jsxs)(`div`,{className:`absolute top-full right-0 z-[200] mt-2 w-[22rem] rounded-xl border border-border bg-popover p-3 text-sm shadow-lg`,children:[(0,z.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`font-semibold text-foreground`,children:`System health`}),(0,z.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Updated `,new Date(t.updatedAt).toLocaleTimeString()]})]}),(0,z.jsx)(`button`,{onClick:()=>{s(!1),a(!1)},className:`rounded p-1 text-muted-foreground hover:bg-accent hover:text-foreground`,title:`Close`,children:(0,z.jsx)(zr,{className:`h-4 w-4`})})]}),(0,z.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-xs mb-3`,children:[(0,z.jsxs)(`div`,{className:`rounded-lg border border-border p-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-1 text-muted-foreground`,children:[(0,z.jsx)(Sn,{className:`h-3.5 w-3.5`}),`CPU`]}),(0,z.jsxs)(`div`,{className:`mt-1 font-semibold text-foreground`,children:[t.summary.cpuPercent.toFixed(1),`%`]}),(0,z.jsxs)(`div`,{className:`text-muted-foreground`,children:[`Load/core `,t.summary.loadPerCore1m.toFixed(2)]})]}),(0,z.jsxs)(`div`,{className:`rounded-lg border border-border p-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-1 text-muted-foreground`,children:[(0,z.jsx)(vee,{className:`h-3.5 w-3.5`}),`Memory`]}),(0,z.jsxs)(`div`,{className:`mt-1 font-semibold text-foreground`,children:[Q9(t.summary.usedMemoryBytes),` / `,Q9(t.summary.totalMemoryBytes)]}),(0,z.jsxs)(`div`,{className:`text-muted-foreground`,children:[`Avail `,Q9(t.summary.availableMemoryBytes)]})]}),(0,z.jsxs)(`div`,{className:`rounded-lg border border-border p-2`,children:[(0,z.jsx)(`div`,{className:`text-muted-foreground`,children:`Overdeck`}),(0,z.jsx)(`div`,{className:`mt-1 font-semibold text-foreground`,children:Q9(t.summary.overdeckMemoryBytes)}),(0,z.jsxs)(`div`,{className:`text-muted-foreground`,children:[t.summary.overdeckMemoryPercent.toFixed(1),`% of host RAM`]})]}),(0,z.jsxs)(`div`,{className:`rounded-lg border border-border p-2`,children:[(0,z.jsx)(`div`,{className:`text-muted-foreground`,children:`Swap`}),(0,z.jsxs)(`div`,{className:`mt-1 font-semibold text-foreground`,children:[t.summary.swapUsedPercent.toFixed(1),`%`]}),(0,z.jsxs)(`div`,{className:`text-muted-foreground`,children:[`Overcommit `,t.summary.overcommitPercent.toFixed(1),`%`]})]}),(0,z.jsxs)(`div`,{className:`rounded-lg border border-border p-2`,children:[(0,z.jsx)(`div`,{className:`text-muted-foreground`,children:`Work agents`}),(0,z.jsx)(`div`,{className:`mt-1 font-semibold text-foreground`,children:t.summary.workAgentCount})]}),(0,z.jsxs)(`div`,{className:`rounded-lg border border-border p-2`,children:[(0,z.jsx)(`div`,{className:`text-muted-foreground`,children:`Containers`}),(0,z.jsx)(`div`,{className:`mt-1 font-semibold text-foreground`,children:t.summary.containerCount})]})]}),t.reasons.length>0&&(0,z.jsx)(`div`,{className:`mb-3 space-y-1 rounded-lg border border-border p-2 text-xs`,children:t.reasons.map(e=>(0,z.jsxs)(`div`,{className:`text-muted-foreground`,children:[`• `,e]},e))}),(0,z.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,z.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:`Top consumers`}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[o&&t.summary.leakedSpecialistCount>0&&(0,z.jsx)(`button`,{onClick:()=>s(!1),className:`rounded border border-border px-2 py-1 text-[11px] text-muted-foreground hover:bg-accent hover:text-foreground`,children:`Show all`}),(0,z.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Leaked specialists: `,t.summary.leakedSpecialistCount]})]})]}),(0,z.jsx)(`div`,{className:`space-y-2 max-h-72 overflow-auto pr-1`,children:l.map(e=>(0,z.jsx)(`div`,{className:`rounded-lg border p-2 ${e.leaked?`border-warning/40 bg-warning/10`:`border-border`}`,children:(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:Qjt(e)}),(0,z.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[e.type,` · `,e.memoryGb.toFixed(2),` GB`,e.cpuPercent==null?``:` · ${e.cpuPercent.toFixed(1)}% CPU`]})]}),(0,z.jsx)($jt,{consumer:e,onSelectLeaked:()=>s(!0)})]})},e.id))})]})]})}var tMt={home:`/`,pipeline:`/pipeline`,kanban:`/board`,"command-deck":`/command-deck`,agents:`/agents`,flywheel:`/flywheel`,backlog:`/backlog`,resources:`/resources`,autopreso:`/autopreso`,activity:`/activity`,metrics:`/metrics`,costs:`/costs`,skills:`/skills`,context:`/context`,health:`/health`,settings:`/settings`,"god-view":`/god-view`,deacon:`/deacon`,sessions:`/sessions`,"awaiting-merge":`/awaiting-merge`},nMt={...Object.fromEntries(Object.entries(tMt).map(([e,t])=>[t,e]))},rMt=`overdeck.ui.sessionFeedSidebarOpen`;function iMt(){let e=window.location.pathname;return e.startsWith(`/conv/`)||e.startsWith(`/command-deck/`)?`command-deck`:nMt[e]||`home`}function aMt(e=window.location.pathname){let t=e.match(/^\/command-deck\/([^/]+)\/([^/]+)$/);if(!t)return null;let n=e=>{try{return decodeURIComponent(e)}catch{return e}};return{project:n(t[1]??``),issue:n(t[2]??``)}}function oMt(e=window.location.pathname){let t=e.match(/^\/command-deck\/([^/]+)$/);if(!t)return null;try{return decodeURIComponent(t[1]??``)}catch{return t[1]??null}}function sMt(e=window.location.search){return new URLSearchParams(e).get(`view`)===`terminal`?`terminal`:`conversation`}function cMt(e=window.location.search){let t=new URLSearchParams(e).get(`views`);return t?t.split(`,`).map(e=>e.trim()).filter(Boolean).reduce((e,t)=>{let[n,r]=t.split(`:`);return n&&(e[n]=r===`terminal`?`terminal`:`conversation`),e},{}):{}}function lMt(e){return Object.entries(e).filter(([,e])=>e===`terminal`).sort(([e],[t])=>Number(e)-Number(t)).map(([e,t])=>`${e}:${t}`).join(`,`)}function uMt(){if(typeof window>`u`)return!0;let e=window.localStorage.getItem(rMt);return e===null?!0:e===`true`}function dMt(e=window.location.pathname){let t=e.match(/^\/conv\/([^/]+)$/);if(!t)return null;try{return decodeURIComponent(t[1]??``)}catch{return t[1]??null}}function $9(){let e=dMt(),t=cMt(),n=sMt(),r=e?n===`terminal`?`terminal`:t[e]??`conversation`:`conversation`;return e&&n===`terminal`&&(t[e]=`terminal`),{tab:iMt(),convId:e,viewMode:r,viewModes:t}}function fMt(e,t=`conversation`,n={}){if(!e)return`/command-deck`;let r={...n};t===`terminal`?r[e]=`terminal`:delete r[e];let i=new URLSearchParams;t===`terminal`&&i.set(`view`,`terminal`);let a=lMt(r);a&&i.set(`views`,a);let o=i.toString();return o?`/conv/${e}?${o}`:`/conv/${e}`}var pMt=null;async function mMt(){let e=await fetch(`/api/version`);if(!e.ok)throw Error(`Backend returned ${e.status}`);let t=await e.json();return t.supervisorUrl&&(pMt=t.supervisorUrl),t}async function hMt(e,t){let n=await fetch(`/api/conversations/${encodeURIComponent(e)}/message-locator?byteOffset=${t}`);if(!n.ok)throw Error(`Unable to locate matching message (${n.status})`);return n.json()}function gMt(e,t){let n=t instanceof Error?t.message:`Unable to open conversation hit`,r=[e.sourceLabel,e.conversationId===e.sessionId?`no dashboard conversation row`:null,e.projectId?`project ${e.projectId}`:null].filter(Boolean).join(` · `);return r?`${n}. ${r}`:n}async function _Mt(){let e=await fetch(`/api/tracker-status`);if(!e.ok)throw Error(`Failed to fetch tracker status`);return e.json()}async function vMt(){let e=await fetch(`/api/confirmations`);if(!e.ok)throw Error(`Failed to fetch confirmations`);return e.json()}async function yMt(e,t){if(!(await fetch(`/api/confirmations/${e}/respond`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({confirmed:t})})).ok)throw Error(`Failed to respond to confirmation`)}async function bMt(e,t,n){let r=await fetch(`/api/agents/${encodeURIComponent(e)}/permissions/${encodeURIComponent(t)}/respond`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({behavior:n})});if(r.ok)return;let i=`Failed to respond to permission request (${r.status})`;try{let e=await r.json();e?.error&&(i=e.error)}catch{}throw Error(i)}async function xMt(){let e=await fetch(`/api/cliproxy/status`);if(!e.ok)throw Error(`Failed to fetch CLIProxy status`);return e.json()}async function SMt(){if(!(await fetch(`/api/cliproxy/restart`,{method:`POST`})).ok)throw Error(`Failed to restart CLIProxy`)}function CMt({sessionName:e,token:t}){return Z9(),(0,z.jsxs)(`div`,{className:`h-screen overflow-hidden bg-[#0d1117]`,children:[(0,z.jsx)(XM,{}),(0,z.jsx)(Sjt,{sessionName:e,token:t})]})}function wMt(){return Z9(),(0,z.jsxs)(`div`,{className:`h-screen overflow-hidden bg-background`,children:[(0,z.jsx)(XM,{}),(0,z.jsx)(zOt,{})]})}function TMt({conversationId:e}){Z9();let t=Number(e),n=new URLSearchParams(window.location.search).get(`view`)===`terminal`?`terminal`:`conversation`,{data:r,isError:i,isLoading:a}=B({queryKey:[`popout-conversation`,t],queryFn:async()=>{let e=await fetch(`/api/conversations/${t}`);if(!e.ok)throw Error(`Failed to load conversation: ${e.status}`);return await e.json()},enabled:Number.isFinite(t)&&t>0,refetchInterval:5e3});return(0,z.jsxs)(`div`,{className:`h-screen overflow-hidden bg-background`,children:[(0,z.jsx)(XM,{}),!Number.isFinite(t)||t<=0?(0,z.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center text-sm text-muted-foreground`,children:`Invalid conversation id.`}):a&&r===void 0?(0,z.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center text-sm text-muted-foreground`,children:`Loading conversation…`}):i||r===void 0?(0,z.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center text-sm text-muted-foreground`,children:`Couldn’t load this conversation. It may have been archived or deleted.`}):(0,z.jsx)(s5,{conversation:r,viewMode:n,onArchived:()=>window.close()})]})}function EMt(){Z9();let e=new URLSearchParams(window.location.search),t=e.get(`prefix`)??``,n=e.get(`agentId`)??t,{data:r,isError:i}=B({queryKey:[`popout-diff-summaries`,t],queryFn:async()=>{let e=await fetch(t);if(!e.ok)throw Error(`Failed to load diff summaries: ${e.status}`);return await e.json()},enabled:t.length>0,refetchInterval:5e3});return(0,z.jsx)(`div`,{className:`h-screen overflow-hidden bg-background`,children:t.length===0||i&&r===void 0?(0,z.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center text-sm text-muted-foreground`,children:t.length===0?`Missing diff source.`:`Failed to load this diff — retrying…`}):r===void 0?(0,z.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center text-sm text-muted-foreground`,children:`Loading diff…`}):(0,z.jsx)(Vgt,{children:(0,z.jsx)(Rgt,{mode:`sheet`,agentId:n,turnDiffSummaries:r.summaries,diffUrlPrefix:t})})})}function DMt(){(0,R.useEffect)(()=>{},[]);let e=window.location.pathname,t=new URLSearchParams(window.location.search).get(`terminal`);if(e.startsWith(`/terminal/`)||t)return(0,z.jsx)(CMt,{sessionName:e.startsWith(`/terminal/`)?e.replace(`/terminal/`,``):t,token:new URLSearchParams(window.location.search).get(`token`)??void 0});if(e===`/popout/flywheel-conversation`)return(0,z.jsx)(wMt,{});let n=e.match(/^\/popout\/conversation\/([^/]+)$/);if(n)return(0,z.jsx)(TMt,{conversationId:n[1]});if(e===`/popout/diff`)return(0,z.jsx)(EMt,{});let[r,i]=(0,R.useState)(()=>$9().tab),[,a]=(0,R.useState)(()=>{let e=window.location.hash;return e.startsWith(`#agent=`)?decodeURIComponent(e.slice(7)):null}),o=(0,R.useCallback)(e=>{a(e),e?window.history.replaceState(null,``,`${window.location.pathname}#agent=${encodeURIComponent(e)}`):window.history.replaceState(null,``,window.location.pathname)},[]);Z9(),(0,R.useEffect)(()=>{let e=()=>{let e=window.location.hash;e.startsWith(`#agent=`)&&a(decodeURIComponent(e.slice(7)))};return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]);let s=$9(),c=aMt(),l=oMt(),[u,d]=(0,R.useState)(()=>s.convId),[f,p]=(0,R.useState)(()=>c?.project??l),[m,h]=(0,R.useState)(()=>s.viewMode),[g,_]=(0,R.useState)(()=>s.viewModes),[v,y]=(0,R.useState)(()=>c),b=(0,R.useCallback)((e,t=`conversation`)=>{d(e),h(e?t:`conversation`),_(n=>{let r={...n};return e&&t===`terminal`?r[e]=`terminal`:e&&delete r[e],window.history.replaceState(null,``,fMt(e,t,n)),r})},[]),x=(0,R.useCallback)(e=>{b(e,e?g[e]??`conversation`:`conversation`)},[g,b]),S=(0,R.useCallback)(e=>{b(u,e)},[u,b]),C=_t(),w=sm(e=>e.recentActivity??[]),[T,E]=(0,R.useState)(!1),D=(0,R.useCallback)(()=>E(!0),[]),O=(0,R.useCallback)(e=>{C.invalidateQueries({queryKey:[`command-deck-projects`]}),C.invalidateQueries({queryKey:[`registered-projects`]}),p(e.key),i(`command-deck`);let t=`/command-deck/${encodeURIComponent(e.key)}`;window.location.pathname!==t&&window.history.pushState({tab:`command-deck`,project:e.key},``,t),FH.getState().ensureHome(e.key)},[C]),k=(0,R.useRef)(new Set);(0,R.useEffect)(()=>{for(let e of w.slice(0,10)){let t=typeof e.id==`string`?e.id:null,n=typeof e.issueId==`string`?e.issueId:null,r=typeof e.message==`string`?e.message:``;!t||!n||k.current.has(t)||/^Rebuild stack for\b/.test(r)&&(k.current.add(t),C.invalidateQueries({queryKey:[`workspace`,n]}))}},[C,w]);let[A,j]=(0,R.useState)(null),[M,N]=(0,R.useState)(null),[P,F]=(0,R.useState)(!1),[I,ee]=(0,R.useState)(null),[te,ne]=(0,R.useState)(!1),[L,re]=(0,R.useState)(null),[ie,ae]=(0,R.useState)(uMt),[oe,se]=(0,R.useState)(!1),ce=sm(e=>e.drawer.issueId)!==null,le=sm(e=>e.openIssue),ue=sm(e=>e.syncDrawerFromUrl),de=sm(Nhe),{isError:fe,failureCount:pe}=B({queryKey:[`backend-health`],queryFn:mMt,refetchInterval:5e3,refetchIntervalInBackground:!0,retry:1,retryDelay:1e3,staleTime:0}),me=(0,R.useRef)(null),[he,ge]=(0,R.useState)(null);(0,R.useEffect)(()=>{fe?(me.current&&=(clearTimeout(me.current),null),pe>=2&&ge(`down`)):he===`down`&&(ge(`recovering`),me.current=setTimeout(()=>{ge(null),me.current=null},2500))},[fe,pe,he]),(0,R.useEffect)(()=>()=>{me.current&&clearTimeout(me.current)},[]);let _e=de.active,{data:ve}=B({queryKey:[`tracker-status`],queryFn:_Mt,refetchInterval:6e4,retry:!1}),ye=ve?.configured.filter(e=>!e.hasKey)||[],{data:be}=B({queryKey:[`cliproxy-status`],queryFn:xMt,refetchInterval:1e4,refetchIntervalInBackground:!0,retry:1,retryDelay:1e3,staleTime:0}),xe=be&&!be.running,{data:Se}=B({queryKey:[`settings`,`experimental-features`],queryFn:cjt,staleTime:3e4}),Ce=Se===!0||Se===!1,we=Nt({mutationFn:SMt,onSuccess:()=>{C.invalidateQueries({queryKey:[`cliproxy-status`]}),H.success(`CLIProxy restarted successfully`)},onError:e=>{H.error(`Failed to restart CLIProxy: `+e.message)}}),Te=Nt({mutationFn:async()=>{let e=window.overdeckBridge;if(e?.restartDashboard){await e.restartDashboard();return}try{if((await fetch(`/api/system/restart-dashboard`,{method:`POST`,signal:AbortSignal.timeout(3e3)})).ok)return}catch{}let t=pMt;if(!t)throw Error(`Dashboard is unreachable and supervisor URL is unknown — try restarting from the CLI.`);let n=await fetch(`${t}/restart-dashboard`,{method:`POST`,signal:AbortSignal.timeout(5e3)});if(!n.ok)throw Error(`Supervisor returned ${n.status}`)},onSuccess:()=>{H.success(`Restart requested — reconnecting…`)},onError:e=>{H.error(`Restart failed: `+e.message)}}),Ee=(0,R.useCallback)(e=>{let t=Ce&&!Se&&K9(e)?`home`:e;i(t);let n=tMt[t];window.location.pathname!==n&&window.history.pushState({tab:t},``,n)},[Se,Ce]);(0,R.useEffect)(()=>{Ce&&!Se&&K9(r)&&Ee(`home`)},[r,Se,Ce,Ee]);let De=(0,R.useCallback)((e,t)=>{if(e&&t){let n=`/command-deck/${encodeURIComponent(e)}/${encodeURIComponent(t)}`;window.location.pathname!==n&&window.history.replaceState({tab:`command-deck`},``,n)}else if(e){let t=`/command-deck/${encodeURIComponent(e)}`;window.location.pathname!==t&&window.history.replaceState({tab:`command-deck`,project:e},``,t)}else window.location.pathname.startsWith(`/command-deck/`)&&window.history.replaceState({tab:`command-deck`},``,`/command-deck`)},[]),Oe=(0,R.useCallback)(async e=>{let t=e.conversationId||e.sessionId,n=e.projectKey||`__no-project__`;try{let r=await hMt(t,e.byteOffset),i=Date.now();re({conversationName:t,messageId:r.messageId,messageIndex:r.messageIndex,nonce:i,label:e.label||`Agent`}),Ee(`command-deck`),p(n),b(t,`conversation`);let a=FH.getState();a.ensureHome(n);let o=a.addPane(n,{paneType:`agent`,label:e.label||`Agent`,conversationId:t,viewMode:`conversation`});FH.getState().updatePane(n,o,{viewMode:`conversation`,targetMessageId:r.messageId,targetMessageIndex:r.messageIndex,targetMessageNonce:i})}catch(t){H.error(gMt(e,t))}},[Ee,b]),ke=(0,R.useCallback)(e=>{ae(e),window.localStorage.setItem(rMt,String(e))},[]),Ae=(0,R.useCallback)(e=>{p(e),i(`command-deck`);let t=e?`/command-deck/${encodeURIComponent(e)}`:`/command-deck`;if(window.location.pathname!==t&&window.history.pushState({tab:`command-deck`,project:e},``,t),e){FH.getState().ensureHome(e);let t=FH.getState(),n=(t.panesByWorkspace[e]??[]).find(e=>e.paneType===`home`);n&&t.setActivePane(e,n.paneId)}},[]);(0,R.useEffect)(()=>{let e=()=>{let e=$9();i(e.tab),d(e.convId),h(e.viewMode),_(e.viewModes);let t=aMt();y(t);let n=t?.project??oMt();n?p(n):window.location.pathname===`/command-deck`&&p(null),ue()};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[ue]);let je=sm(lm),Me=(0,R.useMemo)(()=>je.filter(e=>[`running`,`active`,`starting`,`thinking`,`working`].includes(e.status)).length,[je]),Ne=sm(whe),Pe=sm(The),[Fe,Ie]=(0,R.useState)(new Set),Le=W5(e=>e.answeredToolUseIds),Re=W5(e=>e.dismissedSubjectIds),ze=W5(e=>e.markAnswered),Be=W5(e=>e.unmarkAnswered),Ve=W5(e=>e.markDismissed),He=W5(e=>e.undismiss),Ue=W5(e=>e.reconcileAnswered),We=W5(e=>e.reconcileDismissed),[Ge,Ke]=(0,R.useState)(null),qe=W5(e=>e.reopenId),Je=W5(e=>e.reopenNonce),Ye=W5(e=>e.requestReopen);(0,R.useEffect)(()=>{if(!qe)return;let e=sm.getState().agentsById[qe],t=e!=null,n=e?.pendingAskUserQuestion!=null;He(qe),Ke(qe),t&&!n&&H.info(`That question is no longer waiting`,{description:`The agent stopped or already received an answer.`})},[Je]);let Xe=sm(fm),Ze=Ne.filter(e=>!Fe.has(e.requestId))[0]??null,Qe=Ze?.issueId??je.find(e=>e.id===Ze?.agentId)?.issueId,{data:$e=[]}=B({queryKey:[`conv-ask-user-question`],queryFn:async({signal:e})=>{let t=await fJ(`/api/conversations/pending-input`,{signal:e});return t.ok?t.json():[]},refetchInterval:4e3,refetchIntervalInBackground:!0}),et=[...Pe.map(e=>({kind:`agent`,id:e.id,issueId:e.issueId??null,kindLabel:`Agent`,title:e.issueId?Xe.find(t=>t.id===e.issueId)?.title??null:null,pendingAskUserQuestion:e.pendingAskUserQuestion,askedAt:e.pendingAskUserQuestion?.askedAt??``})),...$e.map(e=>({kind:`conv`,id:e.name,issueId:e.issueId??null,kindLabel:`Conversation`,title:e.title??null,pendingAskUserQuestion:e.pendingAskUserQuestion,askedAt:e.pendingAskUserQuestion?.askedAt??``}))];et.sort((e,t)=>e.askedAt===t.askedAt?e.id.localeCompare(t.id):e.askedAt.localeCompare(t.askedAt));let tt=et.filter(e=>{let t=e.pendingAskUserQuestion?.toolUseId;return!(!t||Le.has(t)||Re.has(e.id))}),nt=(Ge?tt.find(e=>e.id===Ge):void 0)??tt[0]??null;(0,R.useEffect)(()=>{Ie(e=>{let t=new Set,n=new Set(Ne.map(e=>e.requestId));for(let r of e)n.has(r)&&t.add(r);return t.size===e.size&&Array.from(t).every(t=>e.has(t))?e:t})},[Ne]);let{data:rt=[]}=B({queryKey:[`confirmations`],queryFn:vMt,refetchInterval:1e4});(0,R.useEffect)(()=>{rt.length>0&&!M&&N(rt[0])},[rt,M]),(0,R.useEffect)(()=>{if(!(typeof window>`u`)&&`Notification`in window&&Notification.permission===`default`){let e=()=>{Notification.requestPermission().catch(()=>{}),window.removeEventListener(`pointerdown`,e)};return window.addEventListener(`pointerdown`,e,{once:!0}),()=>{window.removeEventListener(`pointerdown`,e)}}},[]);let it=(0,R.useRef)(new Set);(0,R.useEffect)(()=>{let e=(e,t,n,r)=>{let i=e;if(it.current.has(i))return;it.current.add(i);let a=()=>Ye(t);if(H.info(n,{description:r,duration:12e3,action:{label:`Answer`,onClick:a}}),typeof window<`u`&&`Notification`in window&&Notification.permission===`granted`)try{let e=new Notification(n,{body:r,tag:i});e.onclick=()=>{window.focus(),a(),e.close()}}catch{}};for(let t of Pe){let n=t.pendingAskUserQuestion?.toolUseId;if(!n)continue;let r=t.pendingAskUserQuestion?.questions?.[0]?.question??`AskUserQuestion is open.`,i=(t.issueId?Xe.find(e=>e.id===t.issueId)?.title:void 0)??t.issueId??t.id;e(`agent::${t.id}::${n}`,t.id,`${i} is waiting on you`,r)}for(let t of $e){let n=t.pendingAskUserQuestion?.toolUseId;if(!n)continue;let r=t.pendingAskUserQuestion?.questions?.[0]?.question??`AskUserQuestion is open.`,i=t.title??t.name;e(`conv::${t.name}::${n}`,t.name,`"${i}" is waiting on you`,r)}let t=new Set;for(let e of Pe){let n=e.pendingAskUserQuestion?.toolUseId;n&&t.add(`agent::${e.id}::${n}`)}for(let e of $e){let n=e.pendingAskUserQuestion?.toolUseId;n&&t.add(`conv::${e.name}::${n}`)}for(let e of it.current)t.has(e)||it.current.delete(e)},[Pe,$e]);let at=Nt({mutationFn:async({kind:e,id:t,answers:n,questions:r})=>{if(e===`agent`){let e=await fetch(`/api/agents/${encodeURIComponent(t)}/answer-question`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({answers:n})});if(!e.ok){let t=`Failed to deliver answer (${e.status})`;try{let n=await e.json();n?.error&&(t=n.error)}catch{}throw Error(t)}return e.json()}let i=[],a=r??[];for(let e=0;e<n.length&&e<a.length;e++){let t=a[e]?.question??`Question ${e+1}`;i.push(`Q: ${t}\nA: ${n[e]}`)}let o=`Operator answered the pending question${n.length>1?`s`:``}:\n\n${i.join(`
|
|
803
|
+
`))){e.push({issueId:t.issueId,success:!1,error:`Agent start canceled`});continue}r={...n,guardrailAcknowledged:!0},i=await fetch(`/api/agents`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)}),a=await i.json().catch(()=>({}))}if(i.ok)a.guardrails?.warnings?.length&&H.success(`${t.issueId}: started after acknowledging system health warnings`,{duration:8e3}),e.push({issueId:t.issueId,success:!0});else{if(SYe(i,a)){vYe(r),e.push({issueId:t.issueId,success:!1,error:a.hint||a.error||`Codex authentication expired — re-authenticate to continue`});continue}e.push({issueId:t.issueId,success:!1,error:a.error||a.hint||i.statusText})}}catch(n){e.push({issueId:t.issueId,success:!1,error:n instanceof Error?n.message:String(n)})}m(e),f(!1)},[d,c]),y=(0,R.useCallback)(()=>{u(!0)},[]),b=(0,R.useCallback)(()=>{m(null),u(!1)},[]),x=p?.filter(e=>e.success).length??0,S=p?.filter(e=>!e.success).length??0;if(e===`pill`)return c.length===0?null:(0,z.jsxs)(`div`,{className:`relative`,ref:_,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:()=>g(e=>!e),"aria-expanded":h,className:`inline-flex items-center gap-1.5 rounded-full border border-warning/40 bg-warning/10 px-2.5 py-1 text-xs font-medium text-warning-foreground transition-colors hover:bg-warning/20`,"data-testid":`stopped-agents-pill`,children:[(0,z.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-warning`}),c.length,` stopped`]}),h&&(0,z.jsxs)(`div`,{className:`absolute right-0 top-full z-50 mt-1.5 w-72 rounded-lg border border-border bg-card p-3 shadow-xl`,children:[(0,z.jsxs)(`div`,{className:`mb-2 flex items-center gap-1.5 text-xs font-semibold text-warning-foreground`,children:[(0,z.jsx)(Ir,{className:`h-3.5 w-3.5`}),c.length,` agent`,c.length>1?`s`:``,` stopped`]}),(0,z.jsx)(`div`,{className:`mb-3 max-h-40 overflow-y-auto`,children:c.map(e=>(0,z.jsxs)(`div`,{className:`flex items-center justify-between py-0.5 text-xs`,children:[(0,z.jsx)(`span`,{className:`font-mono text-foreground`,children:e.issueId||e.id}),e.role&&(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:e.role})]},e.id))}),p&&(0,z.jsxs)(`div`,{className:`mb-2 text-xs`,children:[x>0&&(0,z.jsxs)(`span`,{className:`text-success`,children:[`✓ `,x,` restarted`]}),S>0&&(0,z.jsxs)(`span`,{className:`ml-2 text-destructive`,children:[`✕ `,S,` failed`]})]}),(0,z.jsxs)(`button`,{onClick:v,disabled:d,className:`flex w-full items-center justify-center gap-1.5 rounded-md bg-primary px-2 py-1.5 text-xs font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-50`,"data-testid":`pill-restart-all`,children:[d?(0,z.jsx)(ar,{className:`h-3 w-3 animate-spin`}):(0,z.jsx)(hr,{className:`h-3 w-3`}),d?`Restarting…`:`Restart all`]})]})]});if(l||c.length===0)return l&&c.length>0?(0,z.jsxs)(`div`,{className:`bg-card/40 border-b border-border px-4 py-1 flex items-center gap-2 shrink-0`,"data-testid":`stopped-agents-banner`,children:[(0,z.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[c.length,` agent`,c.length>1?`s`:``,` stopped`]}),(0,z.jsx)(`button`,{onClick:b,className:`text-xs text-primary hover:text-primary/80 underline`,children:`Show`})]}):null;let C=p?.filter(e=>e.success).length??0,w=p?.filter(e=>!e.success).length??0;return(0,z.jsxs)(`div`,{className:`bg-warning/10 border-b border-warning/30 px-3 py-1 flex items-center gap-2 shrink-0`,"data-testid":`stopped-agents-banner`,children:[(0,z.jsx)(Ir,{className:`w-3.5 h-3.5 text-warning-foreground shrink-0`}),(0,z.jsxs)(`span`,{className:`text-warning-foreground text-xs font-semibold`,children:[c.length,` stopped`]}),(0,z.jsxs)(`span`,{className:`text-warning-foreground/70 text-xs truncate`,children:[c.map(e=>e.issueId||e.id).join(`, `),c.some(e=>e.lastActivity)&&(0,z.jsxs)(`span`,{className:`ml-1`,children:[`(`,Math.max(...c.map(e=>e.lastActivity?Date.now()-new Date(e.lastActivity).getTime():0))/6e4|0,`m ago)`]})]}),p&&(0,z.jsxs)(`span`,{className:`text-xs ml-1`,children:[C>0&&(0,z.jsxs)(`span`,{className:`text-success inline-flex items-center gap-0.5`,children:[(0,z.jsx)(on,{className:`w-3 h-3`}),` `,C]}),w>0&&(0,z.jsxs)(`span`,{className:`text-destructive inline-flex items-center gap-0.5 ml-1`,children:[(0,z.jsx)(zr,{className:`w-3 h-3`}),` `,w]})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0 ml-auto`,children:[(0,z.jsxs)(`button`,{onClick:v,disabled:d,className:`flex items-center gap-1 px-2 py-0.5 text-xs font-medium rounded bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors`,"data-testid":`banner-restart-all`,children:[d?(0,z.jsx)(ar,{className:`w-3 h-3 animate-spin`}):(0,z.jsx)(hr,{className:`w-3 h-3`}),d?`Restarting...`:`Restart All`]}),(0,z.jsx)(`button`,{onClick:y,disabled:d,className:`text-warning-foreground/60 hover:text-warning-foreground shrink-0 disabled:opacity-50`,title:`Dismiss`,"data-testid":`banner-dismiss`,children:(0,z.jsx)(zr,{className:`w-3.5 h-3.5`})})]})]})}function Gjt(){let e=sm(lm),[t,n]=(0,R.useState)(!1),r=e.filter(e=>e.issueId?Vjt({issueId:e.issueId,status:e.status,hasLiveTmuxSession:e.hasLiveTmuxSession??e.lifecycle?.hasLiveTmuxSession,lastActivity:e.lastActivity,startedAt:e.startedAt})===`orphan_test`:!1);if(r.length===0)return null;let i=e=>{navigator.clipboard?.writeText(`pan wipe ${e}`)};return(0,z.jsxs)(`div`,{className:`bg-muted/35 border-b border-border px-3 py-1.5 shrink-0`,"data-testid":`orphan-test-agents-surface`,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:()=>n(e=>!e),className:`flex w-full items-center gap-2 text-xs text-muted-foreground hover:text-foreground transition-colors`,"data-testid":`orphan-test-toggle`,children:[t?(0,z.jsx)(en,{className:`w-3.5 h-3.5`}):(0,z.jsx)(nn,{className:`w-3.5 h-3.5`}),(0,z.jsxs)(`span`,{className:`font-medium`,children:[r.length,` residual test agent`,r.length===1?``:`s`]}),(0,z.jsx)(`span`,{className:`truncate`,children:`Residue from prior test runs; cleanup is manual via pan wipe.`})]}),t&&(0,z.jsx)(`div`,{className:`mt-1.5 grid gap-1 pl-5`,"data-testid":`orphan-test-agent-list`,children:r.map(e=>{let t=e.issueId??e.id;return(0,z.jsxs)(`div`,{className:`flex items-center gap-2 rounded border border-border/70 bg-background/60 px-2 py-1 text-xs`,children:[(0,z.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:t}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>i(t),className:`ml-auto inline-flex items-center gap-1 rounded border border-border px-2 py-0.5 text-muted-foreground hover:bg-muted hover:text-foreground`,children:[(0,z.jsx)(pn,{className:`w-3 h-3`}),"Copy `pan wipe ",t,"`"]})]},e.id)})})]})}function Kjt(){let{data:e}=JF(),[t,n]=(0,R.useState)(!1);return!e||e.status!==`expired`&&e.status!==`burned`?null:(0,z.jsxs)(`div`,{className:`bg-warning/10 border-b-2 border-warning/40 px-4 py-3 flex items-center gap-3 shrink-0`,children:[(0,z.jsx)(Ir,{className:`w-5 h-5 text-warning-foreground shrink-0`}),(0,z.jsxs)(`p`,{className:`text-warning-foreground text-sm font-semibold flex-1`,children:[`Codex authentication `,e.status,` — Codex-routed agents (gpt-5.x, o3, o4-mini) will fail.`,e.email&&(0,z.jsxs)(`span`,{className:`font-normal ml-1 opacity-80`,children:[`(`,(0,z.jsx)(eI,{value:e.email,className:`text-sm`}),`)`]})]}),(0,z.jsx)(`button`,{onClick:async()=>{n(!0);try{let e=await fetch(`/api/settings/codex-reauth`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error||`Failed to spawn re-auth session (${e.status})`)}let{sessionName:t,statusToken:n}=await e.json();yYe(t,n),H.success(`Re-authentication session started — opening terminal…`),window.location.href=`/terminal/${t}`}catch(e){H.error(e instanceof Error?e.message:`Failed to start re-authentication`)}finally{n(!1)}},disabled:t,className:`px-3 py-1.5 bg-warning/20 hover:bg-warning/30 text-warning-foreground text-sm font-semibold rounded-md transition-colors disabled:opacity-50 disabled:cursor-not-allowed shrink-0 flex items-center gap-1.5`,children:t?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(ar,{className:`w-3.5 h-3.5 animate-spin`}),`Starting…`]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(kn,{className:`w-3.5 h-3.5`}),`Re-authenticate`]})})]})}function Z9(){let{data:e}=JF(),t=_t(),n=(0,R.useRef)(null),r=(0,R.useRef)(!1);(0,R.useEffect)(()=>{if(r.current)return;let e=$F();if(!e?.reauthSessionName||!e.reauthStatusToken)return;let i=e.reauthSessionName,a=e.reauthStatusToken;return n.current&&clearInterval(n.current),n.current=setInterval(async()=>{if(!r.current)try{let e=await fetch(`/api/settings/codex-reauth/status`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({session:i,token:a})});if(!e.ok)return;let o=await e.json();if(o.completed){if(n.current&&=(clearInterval(n.current),null),o.success!==!0||o.authStatus?.status!==`valid`){xYe(),H.error(o.error||o.authStatus?.message||`Codex re-authentication did not produce valid auth`,{duration:8e3}),await _j(t);return}r.current=!0,t.setQueryData([`codex-auth-status`],o.authStatus);let e=$F();e?.requestBody?qjt(e.requestBody,t).finally(()=>{r.current=!1}):(bYe(),H.success(`Codex re-authentication completed`),await _j(t),r.current=!1)}}catch{}},3e3),()=>{n.current&&=(clearInterval(n.current),null)}},[e?.status,t]),(0,R.useEffect)(()=>{if(r.current)return;let n=$F();!n?.requestBody||n.reauthSessionName||e?.status===`valid`&&(r.current=!0,qjt(n.requestBody,t).finally(()=>{r.current=!1}))},[e?.status,t])}async function qjt(e,t){try{let n=await fetch(`/api/agents`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)}),r=await n.json().catch(()=>({}));if(!n.ok)throw Error(r.error||r.hint||`Failed to start agent (${n.status})`);bYe(),H.success(`Agent started automatically after Codex re-authentication`),await _j(t)}catch(e){xYe(),H.error(`Auto-retry failed: ${e instanceof Error?e.message:String(e)}`,{duration:8e3})}}function Jjt(e,t){let n=Hr(),r=_t(),i=Nt({mutationFn:async()=>{if(!e)throw Error(`No agent to kill`);let t=await fetch(`/api/agents/${e}`,{method:`DELETE`});if(!t.ok)throw Error(`Failed to kill agent`);return t.json()},onSuccess:async()=>{await _j(r),t?.onSuccess?.()}});return{killMutation:i,confirmAndKill:async()=>{if(!e)return!1;let t=await n({title:`Kill Agent`,message:`Kill agent ${e}?`,variant:`destructive`,confirmLabel:`Kill`});return t&&i.mutate(),t},isPending:i.isPending}}async function Yjt(){let e=await fetch(`/api/system/health`);if(!e.ok){let t=await e.text().catch(()=>``);throw Error(`Failed to fetch system health (${e.status}): ${t}`)}return e.json()}function Xjt(){return B({queryKey:[`system-health`],queryFn:Yjt,refetchInterval:15e3})}function Q9(e){let t=e/1024**3;return t>=1?`${t.toFixed(1)} GB`:`${(e/1024**2).toFixed(0)} MB`}function Zjt(e){return e===`critical`?`border-destructive/50 bg-destructive/10 text-destructive animate-pulse`:e===`warning`?`border-warning/40 bg-warning/10 text-warning-foreground`:`border-emerald-500/30 bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`}function Qjt(e){return e.issueId?`${e.label} · ${e.issueId}`:e.currentIssue?`${e.label} · ${e.currentIssue}`:e.label}function $jt({consumer:e,onSelectLeaked:t}){let n=Hr(),r=_t(),{confirmAndKill:i,isPending:a}=Jjt(e.killTarget?.kind===`agent`?e.killTarget.agentId:void 0,{onSuccess:()=>{e.leaked&&t()}}),o=Nt({mutationFn:async()=>{let t=e.killTarget;if(!t)throw Error(`No kill target available`);if(t.kind===`container`){if(!t.containerId)throw Error(`Missing container id`);let e=await fetch(`/api/resources/docker/container/${t.containerId}`,{method:`DELETE`});if(!e.ok)throw Error(`Failed to remove container`);return e.json()}if(t.kind===`specialist`){if(!t.projectKey||!t.issueId||!t.specialistType)throw Error(`Missing specialist target`);let e=await fetch(`/api/specialists/${t.projectKey}/${t.issueId}/${t.specialistType}/kill`,{method:`POST`});if(!e.ok)throw Error(`Failed to kill specialist`);return e.json()}throw Error(`Unsupported kill target`)},onSuccess:async()=>{await _j(r),await r.invalidateQueries({queryKey:[`system-health`]}),e.leaked&&t()}}),s=a||o.isPending,c=e.killTarget;if(!c)return null;let l=c.kind===`container`?`Remove container ${e.label}`:c.kind===`specialist`?`Kill specialist ${e.label}`:`Kill ${e.label}`,u=async()=>{if(c.kind===`agent`){await i();return}await n({title:c.kind===`container`?`Remove Container`:`Kill Specialist`,message:c.kind===`container`?`Remove Docker container ${e.label}?`:`Kill specialist ${e.label}?`,variant:`destructive`,confirmLabel:c.kind===`container`?`Remove`:`Kill`})&&o.mutate()};return(0,z.jsx)(`button`,{onClick:()=>void u(),disabled:s,className:`rounded border border-border px-2 py-1 text-[11px] text-muted-foreground hover:text-foreground hover:bg-accent disabled:opacity-50`,title:l,children:s?`Killing…`:c.kind===`container`?`Remove`:`Kill`})}function eMt({compact:e=!1}){let{data:t,isLoading:n,error:r}=Xjt(),[i,a]=(0,R.useState)(!1),[o,s]=(0,R.useState)(!1),c=(0,R.useRef)(null);(0,R.useEffect)(()=>{if(!t)return;let n=c.current;c.current=t.severity,!(e||n==null||n===t.severity||t.severity!==`critical`)&&H.error(`System health is critical`,{description:t.reasons[0]??`Open the health panel to inspect top consumers and leaked specialists.`,duration:1e4,action:{label:`Open`,onClick:()=>{s((t.leakedSpecialists?.length??0)>0),a(!0)}}})},[e,t]);let l=(0,R.useMemo)(()=>{let e=[...t?.topConsumers??[]].sort((e,t)=>Number(t.leaked??!1)-Number(e.leaked??!1));if(!o)return e;let n=e.filter(e=>e.leaked);return n.length>0?n:e},[t?.topConsumers,o]);return n?(0,z.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border px-2 py-1.5 text-xs text-muted-foreground ${e?`justify-center px-1.5`:``}`,children:[(0,z.jsx)(ar,{className:`h-3.5 w-3.5 animate-spin`}),!e&&(0,z.jsx)(`span`,{children:`Health`})]}):r||!t?(0,z.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-destructive/40 bg-destructive/10 px-2 py-1.5 text-xs text-destructive ${e?`justify-center px-1.5`:``}`,title:r?.message??`Failed to load system health`,children:[(0,z.jsx)(Ir,{className:`h-3.5 w-3.5`}),!e&&(0,z.jsx)(`span`,{children:`Health unavailable`})]}):(0,z.jsxs)(`div`,{className:`relative`,children:[(0,z.jsxs)(`button`,{onClick:()=>{s(!1),a(e=>!e)},className:`flex w-full items-center gap-2 rounded-md border px-2 py-1.5 text-xs transition-colors hover:bg-accent ${Zjt(t.severity)} ${e?`justify-center px-1.5`:`justify-between`}`,"data-testid":`system-health-pill`,children:[(0,z.jsxs)(`span`,{className:`flex items-center gap-2 min-w-0`,children:[t.severity===`critical`?(0,z.jsx)(Ree,{className:`h-3.5 w-3.5`}):(0,z.jsx)(Ir,{className:`h-3.5 w-3.5`}),!e&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`font-semibold uppercase tracking-wide`,children:t.severity}),(0,z.jsxs)(`span`,{className:`text-muted-foreground`,children:[Math.round(t.summary.memoryUsedPercent),`% mem`]})]})]}),!e&&(0,z.jsx)(en,{className:`h-3.5 w-3.5 transition-transform ${i?`rotate-180`:``}`})]}),i&&!e&&(0,z.jsxs)(`div`,{className:`absolute top-full right-0 z-[200] mt-2 w-[22rem] rounded-xl border border-border bg-popover p-3 text-sm shadow-lg`,children:[(0,z.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`font-semibold text-foreground`,children:`System health`}),(0,z.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Updated `,new Date(t.updatedAt).toLocaleTimeString()]})]}),(0,z.jsx)(`button`,{onClick:()=>{s(!1),a(!1)},className:`rounded p-1 text-muted-foreground hover:bg-accent hover:text-foreground`,title:`Close`,children:(0,z.jsx)(zr,{className:`h-4 w-4`})})]}),(0,z.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-xs mb-3`,children:[(0,z.jsxs)(`div`,{className:`rounded-lg border border-border p-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-1 text-muted-foreground`,children:[(0,z.jsx)(Sn,{className:`h-3.5 w-3.5`}),`CPU`]}),(0,z.jsxs)(`div`,{className:`mt-1 font-semibold text-foreground`,children:[t.summary.cpuPercent.toFixed(1),`%`]}),(0,z.jsxs)(`div`,{className:`text-muted-foreground`,children:[`Load/core `,t.summary.loadPerCore1m.toFixed(2)]})]}),(0,z.jsxs)(`div`,{className:`rounded-lg border border-border p-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-1 text-muted-foreground`,children:[(0,z.jsx)(vee,{className:`h-3.5 w-3.5`}),`Memory`]}),(0,z.jsxs)(`div`,{className:`mt-1 font-semibold text-foreground`,children:[Q9(t.summary.usedMemoryBytes),` / `,Q9(t.summary.totalMemoryBytes)]}),(0,z.jsxs)(`div`,{className:`text-muted-foreground`,children:[`Avail `,Q9(t.summary.availableMemoryBytes)]})]}),(0,z.jsxs)(`div`,{className:`rounded-lg border border-border p-2`,children:[(0,z.jsx)(`div`,{className:`text-muted-foreground`,children:`Overdeck`}),(0,z.jsx)(`div`,{className:`mt-1 font-semibold text-foreground`,children:Q9(t.summary.overdeckMemoryBytes)}),(0,z.jsxs)(`div`,{className:`text-muted-foreground`,children:[t.summary.overdeckMemoryPercent.toFixed(1),`% of host RAM`]})]}),(0,z.jsxs)(`div`,{className:`rounded-lg border border-border p-2`,children:[(0,z.jsx)(`div`,{className:`text-muted-foreground`,children:`Swap`}),(0,z.jsxs)(`div`,{className:`mt-1 font-semibold text-foreground`,children:[t.summary.swapUsedPercent.toFixed(1),`%`]}),(0,z.jsxs)(`div`,{className:`text-muted-foreground`,children:[`Overcommit `,t.summary.overcommitPercent.toFixed(1),`%`]})]}),(0,z.jsxs)(`div`,{className:`rounded-lg border border-border p-2`,children:[(0,z.jsx)(`div`,{className:`text-muted-foreground`,children:`Work agents`}),(0,z.jsx)(`div`,{className:`mt-1 font-semibold text-foreground`,children:t.summary.workAgentCount})]}),(0,z.jsxs)(`div`,{className:`rounded-lg border border-border p-2`,children:[(0,z.jsx)(`div`,{className:`text-muted-foreground`,children:`Containers`}),(0,z.jsx)(`div`,{className:`mt-1 font-semibold text-foreground`,children:t.summary.containerCount})]})]}),t.reasons.length>0&&(0,z.jsx)(`div`,{className:`mb-3 space-y-1 rounded-lg border border-border p-2 text-xs`,children:t.reasons.map(e=>(0,z.jsxs)(`div`,{className:`text-muted-foreground`,children:[`• `,e]},e))}),(0,z.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,z.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:`Top consumers`}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[o&&t.summary.leakedSpecialistCount>0&&(0,z.jsx)(`button`,{onClick:()=>s(!1),className:`rounded border border-border px-2 py-1 text-[11px] text-muted-foreground hover:bg-accent hover:text-foreground`,children:`Show all`}),(0,z.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Leaked specialists: `,t.summary.leakedSpecialistCount]})]})]}),(0,z.jsx)(`div`,{className:`space-y-2 max-h-72 overflow-auto pr-1`,children:l.map(e=>(0,z.jsx)(`div`,{className:`rounded-lg border p-2 ${e.leaked?`border-warning/40 bg-warning/10`:`border-border`}`,children:(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:Qjt(e)}),(0,z.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[e.type,` · `,e.memoryGb.toFixed(2),` GB`,e.cpuPercent==null?``:` · ${e.cpuPercent.toFixed(1)}% CPU`]})]}),(0,z.jsx)($jt,{consumer:e,onSelectLeaked:()=>s(!0)})]})},e.id))})]})]})}var tMt={home:`/`,pipeline:`/pipeline`,kanban:`/board`,"command-deck":`/command-deck`,agents:`/agents`,flywheel:`/flywheel`,backlog:`/backlog`,resources:`/resources`,autopreso:`/autopreso`,activity:`/activity`,metrics:`/metrics`,costs:`/costs`,skills:`/skills`,context:`/context`,health:`/health`,settings:`/settings`,"god-view":`/god-view`,deacon:`/deacon`,sessions:`/sessions`,"awaiting-merge":`/awaiting-merge`},nMt={...Object.fromEntries(Object.entries(tMt).map(([e,t])=>[t,e]))},rMt=`overdeck.ui.sessionFeedSidebarOpen`;function iMt(){let e=window.location.pathname;return e.startsWith(`/conv/`)||e.startsWith(`/command-deck/`)?`command-deck`:nMt[e]||`home`}function aMt(e=window.location.pathname){let t=e.match(/^\/command-deck\/([^/]+)\/([^/]+)$/);if(!t)return null;let n=e=>{try{return decodeURIComponent(e)}catch{return e}};return{project:n(t[1]??``),issue:n(t[2]??``)}}function oMt(e=window.location.pathname){let t=e.match(/^\/command-deck\/([^/]+)$/);if(!t)return null;try{return decodeURIComponent(t[1]??``)}catch{return t[1]??null}}function sMt(e=window.location.search){return new URLSearchParams(e).get(`view`)===`terminal`?`terminal`:`conversation`}function cMt(e=window.location.search){let t=new URLSearchParams(e).get(`views`);return t?t.split(`,`).map(e=>e.trim()).filter(Boolean).reduce((e,t)=>{let[n,r]=t.split(`:`);return n&&(e[n]=r===`terminal`?`terminal`:`conversation`),e},{}):{}}function lMt(e){return Object.entries(e).filter(([,e])=>e===`terminal`).sort(([e],[t])=>Number(e)-Number(t)).map(([e,t])=>`${e}:${t}`).join(`,`)}function uMt(){if(typeof window>`u`)return!0;let e=window.localStorage.getItem(rMt);return e===null?!0:e===`true`}function dMt(e=window.location.pathname){let t=e.match(/^\/conv\/([^/]+)$/);if(!t)return null;try{return decodeURIComponent(t[1]??``)}catch{return t[1]??null}}function $9(){let e=dMt(),t=cMt(),n=sMt(),r=e?n===`terminal`?`terminal`:t[e]??`conversation`:`conversation`;return e&&n===`terminal`&&(t[e]=`terminal`),{tab:iMt(),convId:e,viewMode:r,viewModes:t}}function fMt(e,t=`conversation`,n={}){if(!e)return`/command-deck`;let r={...n};t===`terminal`?r[e]=`terminal`:delete r[e];let i=new URLSearchParams;t===`terminal`&&i.set(`view`,`terminal`);let a=lMt(r);a&&i.set(`views`,a);let o=i.toString();return o?`/conv/${e}?${o}`:`/conv/${e}`}var pMt=null;async function mMt(){let e=await fetch(`/api/version`);if(!e.ok)throw Error(`Backend returned ${e.status}`);let t=await e.json();return t.supervisorUrl&&(pMt=t.supervisorUrl),t}async function hMt(e,t){let n=await fetch(`/api/conversations/${encodeURIComponent(e)}/message-locator?byteOffset=${t}`);if(!n.ok)throw Error(`Unable to locate matching message (${n.status})`);return n.json()}function gMt(e,t){let n=t instanceof Error?t.message:`Unable to open conversation hit`,r=[e.sourceLabel,e.conversationId===e.sessionId?`no dashboard conversation row`:null,e.projectId?`project ${e.projectId}`:null].filter(Boolean).join(` · `);return r?`${n}. ${r}`:n}async function _Mt(){let e=await fetch(`/api/tracker-status`);if(!e.ok)throw Error(`Failed to fetch tracker status`);return e.json()}async function vMt(){let e=await fetch(`/api/confirmations`);if(!e.ok)throw Error(`Failed to fetch confirmations`);return e.json()}async function yMt(e,t){if(!(await fetch(`/api/confirmations/${e}/respond`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({confirmed:t})})).ok)throw Error(`Failed to respond to confirmation`)}async function bMt(e,t,n){let r=await fetch(`/api/agents/${encodeURIComponent(e)}/permissions/${encodeURIComponent(t)}/respond`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({behavior:n})});if(r.ok)return;let i=`Failed to respond to permission request (${r.status})`;try{let e=await r.json();e?.error&&(i=e.error)}catch{}throw Error(i)}async function xMt(){let e=await fetch(`/api/cliproxy/status`);if(!e.ok)throw Error(`Failed to fetch CLIProxy status`);return e.json()}async function SMt(){if(!(await fetch(`/api/cliproxy/restart`,{method:`POST`})).ok)throw Error(`Failed to restart CLIProxy`)}function CMt({sessionName:e,token:t}){return Z9(),(0,z.jsxs)(`div`,{className:`h-screen overflow-hidden bg-[#0d1117]`,children:[(0,z.jsx)(XM,{}),(0,z.jsx)(Sjt,{sessionName:e,token:t})]})}function wMt(){return Z9(),(0,z.jsxs)(`div`,{className:`h-screen overflow-hidden bg-background`,children:[(0,z.jsx)(XM,{}),(0,z.jsx)(zOt,{})]})}function TMt({conversationId:e}){Z9();let t=Number(e),n=new URLSearchParams(window.location.search).get(`view`)===`terminal`?`terminal`:`conversation`,{data:r,isError:i,isLoading:a}=B({queryKey:[`popout-conversation`,t],queryFn:async()=>{let e=await fetch(`/api/conversations/${t}`);if(!e.ok)throw Error(`Failed to load conversation: ${e.status}`);return await e.json()},enabled:Number.isFinite(t)&&t>0,refetchInterval:5e3});return(0,z.jsxs)(`div`,{className:`h-screen overflow-hidden bg-background`,children:[(0,z.jsx)(XM,{}),!Number.isFinite(t)||t<=0?(0,z.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center text-sm text-muted-foreground`,children:`Invalid conversation id.`}):a&&r===void 0?(0,z.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center text-sm text-muted-foreground`,children:`Loading conversation…`}):i||r===void 0?(0,z.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center text-sm text-muted-foreground`,children:`Couldn’t load this conversation. It may have been archived or deleted.`}):(0,z.jsx)(s5,{conversation:r,viewMode:n,onArchived:()=>window.close()})]})}function EMt(){Z9();let e=new URLSearchParams(window.location.search),t=e.get(`prefix`)??``,n=e.get(`agentId`)??t,{data:r,isError:i}=B({queryKey:[`popout-diff-summaries`,t],queryFn:async()=>{let e=await fetch(t);if(!e.ok)throw Error(`Failed to load diff summaries: ${e.status}`);return await e.json()},enabled:t.length>0,refetchInterval:5e3});return(0,z.jsx)(`div`,{className:`h-screen overflow-hidden bg-background`,children:t.length===0||i&&r===void 0?(0,z.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center text-sm text-muted-foreground`,children:t.length===0?`Missing diff source.`:`Failed to load this diff — retrying…`}):r===void 0?(0,z.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center text-sm text-muted-foreground`,children:`Loading diff…`}):(0,z.jsx)(Vgt,{children:(0,z.jsx)(Rgt,{mode:`sheet`,agentId:n,turnDiffSummaries:r.summaries,diffUrlPrefix:t})})})}function DMt(){(0,R.useEffect)(()=>{},[]);let e=window.location.pathname,t=new URLSearchParams(window.location.search).get(`terminal`);if(e.startsWith(`/terminal/`)||t)return(0,z.jsx)(CMt,{sessionName:e.startsWith(`/terminal/`)?e.replace(`/terminal/`,``):t,token:new URLSearchParams(window.location.search).get(`token`)??void 0});if(e===`/popout/flywheel-conversation`)return(0,z.jsx)(wMt,{});let n=e.match(/^\/popout\/conversation\/([^/]+)$/);if(n)return(0,z.jsx)(TMt,{conversationId:n[1]});if(e===`/popout/diff`)return(0,z.jsx)(EMt,{});let[r,i]=(0,R.useState)(()=>$9().tab),[,a]=(0,R.useState)(()=>{let e=window.location.hash;return e.startsWith(`#agent=`)?decodeURIComponent(e.slice(7)):null}),o=(0,R.useCallback)(e=>{a(e),e?window.history.replaceState(null,``,`${window.location.pathname}#agent=${encodeURIComponent(e)}`):window.history.replaceState(null,``,window.location.pathname)},[]);Z9(),(0,R.useEffect)(()=>{let e=()=>{let e=window.location.hash;e.startsWith(`#agent=`)&&a(decodeURIComponent(e.slice(7)))};return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]);let s=$9(),c=aMt(),l=oMt(),[u,d]=(0,R.useState)(()=>s.convId),[f,p]=(0,R.useState)(()=>c?.project??l),[m,h]=(0,R.useState)(()=>s.viewMode),[g,_]=(0,R.useState)(()=>s.viewModes),[v,y]=(0,R.useState)(()=>c),b=(0,R.useCallback)((e,t=`conversation`)=>{d(e),h(e?t:`conversation`),_(n=>{let r={...n};return e&&t===`terminal`?r[e]=`terminal`:e&&delete r[e],window.history.replaceState(null,``,fMt(e,t,n)),r})},[]),x=(0,R.useCallback)(e=>{b(e,e?g[e]??`conversation`:`conversation`)},[g,b]),S=(0,R.useCallback)(e=>{b(u,e)},[u,b]),C=_t(),w=sm(e=>e.recentActivity??[]),[T,E]=(0,R.useState)(!1),D=(0,R.useCallback)(()=>E(!0),[]),O=(0,R.useCallback)(e=>{C.invalidateQueries({queryKey:[`command-deck-projects`]}),C.invalidateQueries({queryKey:[`registered-projects`]}),p(e.key),i(`command-deck`);let t=`/command-deck/${encodeURIComponent(e.key)}`;window.location.pathname!==t&&window.history.pushState({tab:`command-deck`,project:e.key},``,t),FH.getState().ensureHome(e.key)},[C]),k=(0,R.useRef)(new Set);(0,R.useEffect)(()=>{for(let e of w.slice(0,10)){let t=typeof e.id==`string`?e.id:null,n=typeof e.issueId==`string`?e.issueId:null,r=typeof e.message==`string`?e.message:``;!t||!n||k.current.has(t)||/^Rebuild stack for\b/.test(r)&&(k.current.add(t),C.invalidateQueries({queryKey:[`workspace`,n]}))}},[C,w]);let[A,j]=(0,R.useState)(null),[M,N]=(0,R.useState)(null),[P,F]=(0,R.useState)(!1),[I,ee]=(0,R.useState)(null),[te,ne]=(0,R.useState)(!1),[L,re]=(0,R.useState)(null),[ie,ae]=(0,R.useState)(uMt),[oe,se]=(0,R.useState)(!1),ce=sm(e=>e.drawer.issueId)!==null,le=sm(e=>e.openIssue),ue=sm(e=>e.syncDrawerFromUrl),de=sm(Nhe),{isError:fe,failureCount:pe}=B({queryKey:[`backend-health`],queryFn:mMt,refetchInterval:5e3,refetchIntervalInBackground:!0,retry:1,retryDelay:1e3,staleTime:0}),me=(0,R.useRef)(null),[he,ge]=(0,R.useState)(null);(0,R.useEffect)(()=>{fe?(me.current&&=(clearTimeout(me.current),null),pe>=2&&ge(`down`)):he===`down`&&(ge(`recovering`),me.current=setTimeout(()=>{ge(null),me.current=null},2500))},[fe,pe,he]),(0,R.useEffect)(()=>()=>{me.current&&clearTimeout(me.current)},[]);let _e=de.active,{data:ve}=B({queryKey:[`tracker-status`],queryFn:_Mt,refetchInterval:6e4,retry:!1}),ye=ve?.configured.filter(e=>!e.hasKey)||[],{data:be}=B({queryKey:[`cliproxy-status`],queryFn:xMt,refetchInterval:1e4,refetchIntervalInBackground:!0,retry:1,retryDelay:1e3,staleTime:0}),xe=be&&!be.running,{data:Se}=B({queryKey:[`settings`,`experimental-features`],queryFn:cjt,staleTime:3e4}),Ce=Se===!0||Se===!1,we=Nt({mutationFn:SMt,onSuccess:()=>{C.invalidateQueries({queryKey:[`cliproxy-status`]}),H.success(`CLIProxy restarted successfully`)},onError:e=>{H.error(`Failed to restart CLIProxy: `+e.message)}}),Te=Nt({mutationFn:async()=>{let e=window.overdeckBridge;if(e?.restartDashboard){await e.restartDashboard();return}try{if((await fetch(`/api/system/restart-dashboard`,{method:`POST`,signal:AbortSignal.timeout(3e3)})).ok)return}catch{}let t=pMt;if(!t)throw Error(`Dashboard is unreachable and supervisor URL is unknown — try restarting from the CLI.`);let n=await fetch(`${t}/restart-dashboard`,{method:`POST`,signal:AbortSignal.timeout(5e3)});if(!n.ok)throw Error(`Supervisor returned ${n.status}`)},onSuccess:()=>{H.success(`Restart requested — reconnecting…`)},onError:e=>{H.error(`Restart failed: `+e.message)}}),Ee=(0,R.useCallback)(e=>{let t=Ce&&!Se&&K9(e)?`home`:e;i(t);let n=tMt[t];window.location.pathname!==n&&window.history.pushState({tab:t},``,n)},[Se,Ce]);(0,R.useEffect)(()=>{Ce&&!Se&&K9(r)&&Ee(`home`)},[r,Se,Ce,Ee]);let De=(0,R.useCallback)((e,t)=>{if(e&&t){let n=`/command-deck/${encodeURIComponent(e)}/${encodeURIComponent(t)}`;window.location.pathname!==n&&window.history.replaceState({tab:`command-deck`},``,n)}else if(e){let t=`/command-deck/${encodeURIComponent(e)}`;window.location.pathname!==t&&window.history.replaceState({tab:`command-deck`,project:e},``,t)}else window.location.pathname.startsWith(`/command-deck/`)&&window.history.replaceState({tab:`command-deck`},``,`/command-deck`)},[]),Oe=(0,R.useCallback)(async e=>{let t=e.conversationId||e.sessionId,n=e.projectKey||`__no-project__`;try{let r=await hMt(t,e.byteOffset),i=Date.now();re({conversationName:t,messageId:r.messageId,messageIndex:r.messageIndex,nonce:i,label:e.label||`Agent`}),Ee(`command-deck`),p(n),b(t,`conversation`);let a=FH.getState();a.ensureHome(n);let o=a.addPane(n,{paneType:`agent`,label:e.label||`Agent`,conversationId:t,viewMode:`conversation`});FH.getState().updatePane(n,o,{viewMode:`conversation`,targetMessageId:r.messageId,targetMessageIndex:r.messageIndex,targetMessageNonce:i})}catch(t){H.error(gMt(e,t))}},[Ee,b]),ke=(0,R.useCallback)(e=>{ae(e),window.localStorage.setItem(rMt,String(e))},[]),Ae=(0,R.useCallback)((e,t)=>{if(p(e),i(`command-deck`),t?.updateUrl!==!1){let t=e?`/command-deck/${encodeURIComponent(e)}`:`/command-deck`;window.location.pathname!==t&&window.history.pushState({tab:`command-deck`,project:e},``,t)}if(e){FH.getState().ensureHome(e);let t=FH.getState(),n=(t.panesByWorkspace[e]??[]).find(e=>e.paneType===`home`);n&&t.setActivePane(e,n.paneId)}},[]);(0,R.useEffect)(()=>{let e=()=>{let e=$9();i(e.tab),d(e.convId),h(e.viewMode),_(e.viewModes);let t=aMt();y(t);let n=t?.project??oMt();n?p(n):window.location.pathname===`/command-deck`&&p(null),ue()};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[ue]);let je=sm(lm),Me=(0,R.useMemo)(()=>je.filter(e=>[`running`,`active`,`starting`,`thinking`,`working`].includes(e.status)).length,[je]),Ne=sm(whe),Pe=sm(The),[Fe,Ie]=(0,R.useState)(new Set),Le=W5(e=>e.answeredToolUseIds),Re=W5(e=>e.dismissedSubjectIds),ze=W5(e=>e.markAnswered),Be=W5(e=>e.unmarkAnswered),Ve=W5(e=>e.markDismissed),He=W5(e=>e.undismiss),Ue=W5(e=>e.reconcileAnswered),We=W5(e=>e.reconcileDismissed),[Ge,Ke]=(0,R.useState)(null),qe=W5(e=>e.reopenId),Je=W5(e=>e.reopenNonce),Ye=W5(e=>e.requestReopen);(0,R.useEffect)(()=>{if(!qe)return;let e=sm.getState().agentsById[qe],t=e!=null,n=e?.pendingAskUserQuestion!=null;He(qe),Ke(qe),t&&!n&&H.info(`That question is no longer waiting`,{description:`The agent stopped or already received an answer.`})},[Je]);let Xe=sm(fm),Ze=Ne.filter(e=>!Fe.has(e.requestId))[0]??null,Qe=Ze?.issueId??je.find(e=>e.id===Ze?.agentId)?.issueId,{data:$e=[]}=B({queryKey:[`conv-ask-user-question`],queryFn:async({signal:e})=>{let t=await fJ(`/api/conversations/pending-input`,{signal:e});return t.ok?t.json():[]},refetchInterval:4e3,refetchIntervalInBackground:!0}),et=[...Pe.map(e=>({kind:`agent`,id:e.id,issueId:e.issueId??null,kindLabel:`Agent`,title:e.issueId?Xe.find(t=>t.id===e.issueId)?.title??null:null,pendingAskUserQuestion:e.pendingAskUserQuestion,askedAt:e.pendingAskUserQuestion?.askedAt??``})),...$e.map(e=>({kind:`conv`,id:e.name,issueId:e.issueId??null,kindLabel:`Conversation`,title:e.title??null,pendingAskUserQuestion:e.pendingAskUserQuestion,askedAt:e.pendingAskUserQuestion?.askedAt??``}))];et.sort((e,t)=>e.askedAt===t.askedAt?e.id.localeCompare(t.id):e.askedAt.localeCompare(t.askedAt));let tt=et.filter(e=>{let t=e.pendingAskUserQuestion?.toolUseId;return!(!t||Le.has(t)||Re.has(e.id))}),nt=(Ge?tt.find(e=>e.id===Ge):void 0)??tt[0]??null;(0,R.useEffect)(()=>{Ie(e=>{let t=new Set,n=new Set(Ne.map(e=>e.requestId));for(let r of e)n.has(r)&&t.add(r);return t.size===e.size&&Array.from(t).every(t=>e.has(t))?e:t})},[Ne]);let{data:rt=[]}=B({queryKey:[`confirmations`],queryFn:vMt,refetchInterval:1e4});(0,R.useEffect)(()=>{rt.length>0&&!M&&N(rt[0])},[rt,M]),(0,R.useEffect)(()=>{if(!(typeof window>`u`)&&`Notification`in window&&Notification.permission===`default`){let e=()=>{Notification.requestPermission().catch(()=>{}),window.removeEventListener(`pointerdown`,e)};return window.addEventListener(`pointerdown`,e,{once:!0}),()=>{window.removeEventListener(`pointerdown`,e)}}},[]);let it=(0,R.useRef)(new Set);(0,R.useEffect)(()=>{let e=(e,t,n,r)=>{let i=e;if(it.current.has(i))return;it.current.add(i);let a=()=>Ye(t);if(H.info(n,{description:r,duration:12e3,action:{label:`Answer`,onClick:a}}),typeof window<`u`&&`Notification`in window&&Notification.permission===`granted`)try{let e=new Notification(n,{body:r,tag:i});e.onclick=()=>{window.focus(),a(),e.close()}}catch{}};for(let t of Pe){let n=t.pendingAskUserQuestion?.toolUseId;if(!n)continue;let r=t.pendingAskUserQuestion?.questions?.[0]?.question??`AskUserQuestion is open.`,i=(t.issueId?Xe.find(e=>e.id===t.issueId)?.title:void 0)??t.issueId??t.id;e(`agent::${t.id}::${n}`,t.id,`${i} is waiting on you`,r)}for(let t of $e){let n=t.pendingAskUserQuestion?.toolUseId;if(!n)continue;let r=t.pendingAskUserQuestion?.questions?.[0]?.question??`AskUserQuestion is open.`,i=t.title??t.name;e(`conv::${t.name}::${n}`,t.name,`"${i}" is waiting on you`,r)}let t=new Set;for(let e of Pe){let n=e.pendingAskUserQuestion?.toolUseId;n&&t.add(`agent::${e.id}::${n}`)}for(let e of $e){let n=e.pendingAskUserQuestion?.toolUseId;n&&t.add(`conv::${e.name}::${n}`)}for(let e of it.current)t.has(e)||it.current.delete(e)},[Pe,$e]);let at=Nt({mutationFn:async({kind:e,id:t,answers:n,questions:r})=>{if(e===`agent`){let e=await fetch(`/api/agents/${encodeURIComponent(t)}/answer-question`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({answers:n})});if(!e.ok){let t=`Failed to deliver answer (${e.status})`;try{let n=await e.json();n?.error&&(t=n.error)}catch{}throw Error(t)}return e.json()}let i=[],a=r??[];for(let e=0;e<n.length&&e<a.length;e++){let t=a[e]?.question??`Question ${e+1}`;i.push(`Q: ${t}\nA: ${n[e]}`)}let o=`Operator answered the pending question${n.length>1?`s`:``}:\n\n${i.join(`
|
|
804
804
|
|
|
805
805
|
`)}`,s=await fetch(`/api/conversations/${encodeURIComponent(t)}/message`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({message:o})});if(!s.ok){let e=`Failed to deliver answer (${s.status})`;try{let t=await s.json();t?.error&&(e=t.error)}catch{}throw Error(e)}return s.json()},onMutate:e=>{let t=nt?.pendingAskUserQuestion?.toolUseId;return t&&ze(t),{subjectId:e.id,toolUseId:t}},onSuccess:(e,t)=>{H.success(`Answer delivered to ${t.label?.trim()||t.id}`)},onError:(e,t,n)=>{n?.toolUseId&&Be(n.toolUseId),H.error(`Failed to deliver answer: ${e.message}`)}}),ot=Nt({mutationFn:async({id:e,optionNumber:t})=>{let n=await fetch(`/api/conversations/${encodeURIComponent(e)}/codex-approval`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({optionNumber:t})});if(!n.ok){let e=`Failed to send approval (${n.status})`;try{let t=await n.json();t?.error&&(e=t.error)}catch{}throw Error(e)}return n.json()},onMutate:({toolUseId:e})=>(e&&ze(e),{toolUseId:e}),onSuccess:(e,t)=>{H.success(`Approval sent to ${t.label?.trim()||t.id}`)},onError:(e,t,n)=>{n?.toolUseId&&Be(n.toolUseId),H.error(`Failed to send approval: ${e.message}`)}}),st=(0,R.useCallback)(e=>{if(!nt)return;let t=nt,n=t.pendingAskUserQuestion?.toolUseId;if(n?.startsWith(`codex-approval:`)){let r=/^\s*(\d+)/.exec(e[0]??``),i=r?Number(r[1]):NaN;if(!Number.isInteger(i)){H.error(`Could not determine which option was selected`);return}ot.mutate({id:t.id,optionNumber:i,label:t.title?.trim()||t.id,toolUseId:n});return}at.mutate({kind:t.kind??`agent`,id:t.id,label:t.title?.trim()||t.id,answers:e,questions:t.pendingAskUserQuestion?.questions})},[at,ot,nt]),ct=(0,R.useCallback)(()=>{nt&&Ve(nt.id)},[nt,Ve]);(0,R.useEffect)(()=>{let e=Pe.map(e=>e.pendingAskUserQuestion?.toolUseId).filter(e=>typeof e==`string`),t=$e.map(e=>e.pendingAskUserQuestion?.toolUseId).filter(e=>typeof e==`string`);Ue(new Set([...e,...t]));let n=new Set([...Pe.map(e=>e.id),...$e.map(e=>e.name)]);We(n),Ke(e=>e&&n.has(e)?e:null)},[Pe,$e,Ue,We]);let lt=Nt({mutationFn:({agentId:e,requestId:t,behavior:n})=>bMt(e,t,n),onMutate:async e=>{Ie(t=>{let n=new Set(t);return n.add(e.requestId),n})},onSuccess:async(e,t)=>{await _j(C),H.success(t.behavior===`allow`?`Allowed ${t.agentId} to continue`:`Denied permission request for ${t.agentId}`)},onError:(e,t)=>{Ie(e=>{if(!e.has(t.requestId))return e;let n=new Set(e);return n.delete(t.requestId),n}),H.error(`Permission response failed: ${e.message}`)}}),ut=(0,R.useCallback)(async()=>{if(M)try{await yMt(M.id,!0),N(null)}catch(e){console.error(`Failed to confirm:`,e)}},[M]),dt=(0,R.useCallback)(async()=>{if(M)try{await yMt(M.id,!1),N(null)}catch(e){console.error(`Failed to deny:`,e)}},[M]),ft=(0,R.useCallback)(()=>{Ze&<.mutate({agentId:Ze.agentId,requestId:Ze.requestId,behavior:`allow`})},[lt,Ze]),pt=(0,R.useCallback)(()=>{Ze&<.mutate({agentId:Ze.agentId,requestId:Ze.requestId,behavior:`deny`})},[lt,Ze]),mt=(0,R.useCallback)(()=>{N(null)},[]);(0,R.useEffect)(()=>{let e=e=>{let t=navigator.platform.includes(`Mac`)?e.metaKey:e.ctrlKey,n=e.target,r=n.tagName===`INPUT`||n.tagName===`TEXTAREA`||n.isContentEditable;e.key===`/`&&!r?(e.preventDefault(),F(!0)):e.key===`k`&&t&&!e.shiftKey&&(e.preventDefault(),ne(e=>!e))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]),(0,R.useEffect)(()=>{let e=window.overdeckBridge;if(e)return e.onMenuAction(e=>{if(e===`open-settings`)Ee(`settings`);else if(e.startsWith(`open-workspace:`)){let t=e.slice(15);Ee(`kanban`),t&&le(t)}else if(e.startsWith(`auto-start-nag:`)){ne(!1);let t=e.split(`:`);ht(parseInt(t[1]??`0`,10),parseInt(t[2]??`5`,10))}})},[le,Ee]);function ht(e,t){let n=[`Auto-start means never missing an agent asking for help.`,`Your agents could be waiting for you right now.`,`Overdeck works best when it's always watching.`,`One click enables auto-start. You can disable it anytime.`];H(`Reminder ${e} of ${t} — ${n[(e-2)%n.length]??n[0]}`,{duration:8e3,action:{label:`Enable`,onClick:()=>{window.overdeckBridge?.updateDesktopSetting(`autoStart.enabled`,!0)}}})}let gt=(0,R.useCallback)(e=>{Ee(`kanban`),le(e)},[le,Ee]),{data:vt=[]}=B({queryKey:[`registered-projects`],queryFn:async()=>{let e=await fetch(`/api/registered-projects`);if(!e.ok)throw Error(`Failed to fetch registered projects`);return e.json()},staleTime:6e4}),yt=(0,R.useCallback)(e=>{let t=Xe.find(t=>t.identifier===e),n=t?.sourceRepo||t?.project?.name||``,r=n.includes(`/`)?n.split(`/`).pop():n,i=vt.find(e=>e.key===r||e.name===r||e.key===n||e.name===n);return i?i.name??i.key:f??null},[Xe,vt,f]),bt=(0,R.useCallback)((e,t)=>{let n=Xe.find(t=>t.identifier===e);if(t===`browser`){let t=e.replace(/^[A-Za-z]+-/,``),r=n?.project?.name,i=n?.url||(r&&r.includes(`/`)?`https://github.com/${r}/issues/${t}`:null);if(!i){le(e);return}window.open(i,`_blank`,`noopener,noreferrer`);return}if(t===`modal`){le(e);return}let r=yt(e);if(!r){le(e);return}Ee(`command-deck`),y({project:r,issue:e}),De(r,e)},[Xe,le,yt,Ee,De]),xt=(0,R.useCallback)(e=>{Ee(`kanban`),le(e)},[le,Ee]);return(0,z.jsxs)(`div`,{className:`h-screen flex flex-row overflow-hidden bg-background`,children:[(0,z.jsx)(XM,{}),(0,z.jsx)(ijt,{isOpen:T,onClose:()=>E(!1),onCreated:O}),(0,z.jsx)(Tje,{}),(0,z.jsx)(_jt,{activeTab:r,onTabChange:Ee,onSearchOpen:()=>F(!0),selectedProject:f,onSelectProject:Ae,onNewProject:D}),(0,z.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden min-w-0`,children:[(0,z.jsx)(Ejt,{}),(0,z.jsx)(Gjt,{}),(0,z.jsx)(Kjt,{}),_e&&(0,z.jsxs)(`div`,{className:`bg-primary/15 border-b-2 border-primary/40 px-4 py-3 flex items-center gap-3 shrink-0 overflow-hidden animate-slide-down-banner`,children:[(0,z.jsx)(_r,{className:`w-5 h-5 text-primary shrink-0 animate-spin`}),(0,z.jsxs)(`p`,{className:`text-primary text-sm font-semibold flex-1`,children:[`Dashboard is restarting`,de.issueId&&(0,z.jsxs)(z.Fragment,{children:[` — `,(0,z.jsx)(`span`,{className:`font-mono`,children:de.issueId})]}),de.reason&&(0,z.jsxs)(`span`,{className:`font-normal ml-1 text-primary/70`,children:[`(`,de.reason,`)`]})]}),(0,z.jsx)(`span`,{className:`text-primary/60 text-xs shrink-0 animate-pulse`,children:`● Restarting…`})]}),he===`down`&&!_e&&(0,z.jsxs)(`div`,{className:`bg-destructive/15 border-b-2 border-destructive/50 px-4 py-3 flex items-center gap-3 shrink-0 overflow-hidden animate-slide-down-banner`,children:[(0,z.jsx)(Ir,{className:`w-5 h-5 text-destructive shrink-0`}),(0,z.jsx)(`p`,{className:`text-destructive text-sm font-semibold flex-1`,children:`Backend is unreachable — waiting for it to come back.`}),(0,z.jsx)(`span`,{className:`text-destructive/60 text-xs shrink-0 animate-pulse`,children:`● Retrying…`}),(0,z.jsx)(`button`,{onClick:()=>Te.mutate(),disabled:Te.isPending,className:`px-4 py-1.5 bg-destructive/20 hover:bg-destructive/30 text-destructive text-sm font-bold rounded-md border border-destructive/40 transition-colors disabled:opacity-50 disabled:cursor-not-allowed shrink-0`,children:Te.isPending?`Restarting…`:`Force Restart`})]}),he===`recovering`&&!_e&&(0,z.jsxs)(`div`,{className:`bg-warning/15 border-b-2 border-warning/50 px-4 py-3 flex items-center gap-3 shrink-0 overflow-hidden animate-slide-down-banner`,children:[(0,z.jsx)(sn,{className:`w-5 h-5 text-warning-foreground shrink-0`}),(0,z.jsx)(`p`,{className:`text-warning-foreground text-sm font-semibold flex-1`,children:`Backend is back up.`})]}),ye.length>0&&!oe&&(0,z.jsxs)(`div`,{className:`bg-warning/10 border-b border-warning/30 px-4 py-2 flex items-center gap-3 shrink-0`,children:[(0,z.jsx)(Ir,{className:`w-4 h-4 text-warning-foreground shrink-0`}),(0,z.jsxs)(`p`,{className:`text-warning-foreground text-sm flex-1`,children:[(0,z.jsxs)(`span`,{className:`font-semibold`,children:[`Missing API key`,ye.length>1?`s`:``,`:`]}),` `,ye.map(e=>(0,z.jsxs)(`span`,{children:[e.name,` (`,(0,z.jsx)(`code`,{className:`font-mono text-xs bg-warning/20 px-1 rounded`,children:e.envVar}),`)`]},e.type)).reduce((e,t,n)=>n===0?[t]:[...e,`, `,t],[]),`.`,` `,(0,z.jsx)(`button`,{onClick:()=>Ee(`settings`),className:`underline hover:opacity-80 font-semibold`,children:`Configure in Settings`})]}),(0,z.jsx)(`button`,{onClick:()=>se(!0),className:`text-warning-foreground/60 hover:text-warning-foreground shrink-0`,title:`Dismiss`,children:`✕`})]}),xe&&(0,z.jsxs)(`div`,{className:`bg-warning/10 border-b-2 border-warning/40 px-4 py-3 flex items-center gap-3 shrink-0`,children:[(0,z.jsx)(Ir,{className:`w-5 h-5 text-warning-foreground shrink-0`}),(0,z.jsx)(`p`,{className:`text-warning-foreground text-sm font-semibold flex-1`,children:`CLIProxy is down — GPT subscription agents will fail.`}),(0,z.jsx)(`button`,{onClick:()=>we.mutate(),disabled:we.isPending,className:`px-3 py-1.5 bg-warning/20 hover:bg-warning/30 text-warning-foreground text-sm font-semibold rounded-md transition-colors disabled:opacity-50 disabled:cursor-not-allowed shrink-0`,children:we.isPending?`Restarting…`:`Restart CLIProxy`})]}),(0,z.jsxs)(`div`,{className:`relative flex h-12 shrink-0 items-center gap-3 border-b border-border bg-background px-3`,children:[(0,z.jsx)(`div`,{className:`flex shrink-0 items-center gap-2 text-sm font-semibold text-foreground`,children:f?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`h-3.5 w-3.5 rounded-[4px] bg-primary/40`,"aria-hidden":`true`}),f]}):(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`All projects`})}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>F(!0),className:`mx-auto flex w-full min-w-0 max-w-md items-center gap-2 rounded-lg border border-border px-3 py-1.5 text-sm text-muted-foreground transition-colors hover:bg-accent`,title:`Search`,children:[(0,z.jsx)(wr,{className:`h-4 w-4 shrink-0`,"aria-hidden":`true`}),(0,z.jsx)(`span`,{className:`truncate`,children:f?`Search ${f}…`:`Search issues, conversations, commands…`}),(0,z.jsx)(`kbd`,{className:`ml-auto rounded border border-border px-1.5 text-[11px]`,children:`/`})]}),(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,z.jsx)(uEt,{compact:!0}),Me>0&&(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full border border-emerald-500/30 bg-emerald-500/10 px-2.5 py-1 text-xs text-emerald-600 dark:text-emerald-400`,children:[(0,z.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-emerald-500`}),Me,` agent`,Me===1?``:`s`]}),Me>0&&(0,z.jsxs)(`button`,{type:`button`,onClick:xHe,title:`Emergency stop — kill all agents and freeze auto-resume (${zM})`,"aria-label":`Emergency stop all agents`,className:`inline-flex items-center gap-1.5 rounded-full border border-destructive/40 bg-destructive/10 px-2.5 py-1 text-xs font-medium text-destructive hover:bg-destructive/20 transition-colors`,children:[(0,z.jsx)(ln,{className:`h-3.5 w-3.5`}),` Stop all`]}),(0,z.jsx)(Wjt,{variant:`pill`}),(0,z.jsx)(Ojt,{onOpenSettings:()=>Ee(`settings`)}),(0,z.jsx)(eMt,{}),(0,z.jsx)(Rjt,{onOpenSettings:()=>Ee(`settings`)}),r!==`command-deck`&&(0,z.jsx)(`button`,{type:`button`,"aria-label":`Toggle activity feed`,"aria-pressed":ie,title:`Activity Feed`,className:`rounded-md p-1.5 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus:outline-none focus:ring-2 focus:ring-ring`,onClick:()=>ke(!ie),children:(0,z.jsx)(Xn,{className:`h-4 w-4`,"aria-hidden":`true`})})]})]}),(0,z.jsxs)(`div`,{className:`min-h-0 flex flex-1 overflow-hidden`,children:[(0,z.jsxs)(`main`,{"data-drawer-open":ce?`true`:void 0,className:`relative flex-1 flex overflow-hidden data-[drawer-open=true]:before:pointer-events-none data-[drawer-open=true]:before:absolute data-[drawer-open=true]:before:inset-0 data-[drawer-open=true]:before:z-[80] data-[drawer-open=true]:before:bg-primary/[0.04] data-[drawer-open=true]:before:backdrop-blur-[2px]`,children:[r===`home`&&(0,z.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:(0,z.jsx)(FAt,{onOpenWorkspaceHome:xt,onNewProject:D,onSelectProject:Ae,onOpenSettings:()=>Ee(`settings`)})}),r===`command-deck`&&(0,z.jsx)(`div`,{className:`w-full h-full`,children:(0,z.jsx)(SSt,{issues:Xe,convId:u,conversationViewMode:m,onConvIdChange:x,onConversationViewModeChange:S,pendingConversationTarget:L,onPendingConversationTargetConsumed:()=>re(null),selectedProject:f,onSelectProject:Ae,onProjectPrefixChange:ee,cockpitIssue:v,onCockpitChange:De})}),r===`pipeline`&&(0,z.jsx)(Y9,{fallback:(0,z.jsx)(bjt,{}),children:(0,z.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:(0,z.jsx)(KSt,{onSearchOpen:()=>F(!0),onTabChange:e=>Ee(e)})})}),r===`awaiting-merge`&&(0,z.jsx)(`div`,{className:`w-full h-full overflow-auto`,children:(0,z.jsx)(eCt,{})}),r===`kanban`&&(0,z.jsx)(Y9,{fallback:(0,z.jsx)(`div`,{className:`flex-1 overflow-auto p-6 w-full`,children:(0,z.jsx)(vjt,{})}),children:(0,z.jsx)(z.Fragment,{children:(0,z.jsxs)(`div`,{className:`flex-1 overflow-auto p-6 w-full`,children:[(0,z.jsx)(PHe,{}),(0,z.jsx)(sVe,{selectedIssue:null,onSelectIssue:e=>{e&&le(e)},onPlanDialogChange:j})]})})}),r===`agents`&&(0,z.jsx)(Y9,{fallback:(0,z.jsx)(yjt,{}),children:(0,z.jsx)(`div`,{className:`h-full w-full overflow-y-auto`,children:(0,z.jsx)(WVe,{onNavigateToIssues:()=>Ee(`kanban`)})})}),r===`resources`&&(0,z.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:(0,z.jsx)(kwt,{onNavigateToAgents:e=>{o(e),Ee(`agents`)}})}),r===`skills`&&(0,z.jsx)(`div`,{className:`p-6 w-full overflow-auto`,children:(0,z.jsx)(aHe,{})}),r===`context`&&(0,z.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:(0,z.jsx)(XDt,{})}),r===`health`&&(0,z.jsx)(`div`,{className:`p-6 w-full overflow-auto`,children:(0,z.jsx)(iHe,{})}),r===`activity`&&(0,z.jsx)(`div`,{className:`w-full h-full`,children:(0,z.jsx)(yHe,{onClose:()=>Ee(`kanban`)})}),r===`metrics`&&(0,z.jsx)(`div`,{className:`w-full overflow-auto`,children:(0,z.jsx)(LHe,{})}),r===`costs`&&(0,z.jsx)(`div`,{className:`w-full overflow-auto`,children:(0,z.jsx)(rYe,{})}),r===`autopreso`&&(0,z.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:(0,z.jsx)(NOt,{})}),r===`flywheel`&&(0,z.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:(0,z.jsx)(Xkt,{onOpenSettings:()=>Ee(`settings`),onNavigateAgent:e=>{o(e),Ee(`agents`)},onNavigateIssue:e=>le(e)})}),r===`backlog`&&(0,z.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:(0,z.jsx)(EAt,{onIssueAction:bt})}),r===`settings`&&(0,z.jsx)(`div`,{className:`p-6 w-full overflow-auto`,children:(0,z.jsx)(sZe,{})}),r===`sessions`&&(0,z.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:(0,z.jsx)(COt,{})}),r===`god-view`&&(0,z.jsx)(Y9,{fallback:(0,z.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:(0,z.jsx)(xjt,{})}),children:(0,z.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:(0,z.jsx)(oEt,{})})}),r===`deacon`&&(0,z.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:(0,z.jsx)(vEt,{})})]}),ie&&![`command-deck`,`backlog`].includes(r)&&(0,z.jsx)(qxt,{onClose:()=>ke(!1)})]})]}),(0,z.jsx)(mwt,{}),(0,z.jsx)(wHe,{request:Ze,issueId:Qe,isOpen:!!Ze,isSubmitting:lt.isPending,onAllow:ft,onDeny:pt}),(0,z.jsx)(THe,{subject:nt,isOpen:!!nt&&!Ze,isSubmitting:at.isPending||ot.isPending,onSubmit:st,onDismiss:ct}),(0,z.jsx)(bHe,{request:M,isOpen:!!M,onConfirm:ut,onDeny:dt,onClose:mt}),(0,z.jsx)(y$e,{isOpen:P,onClose:()=>F(!1),onSelectIssue:gt,cycleFilter:`current`,includeCompletedFilter:!1,projectPrefix:r===`command-deck`?I:null}),(0,z.jsx)(N$e,{isOpen:te,onClose:()=>ne(!1),onNavigate:(e,t)=>{Ee(e),t&&le(t)},onOpenConversationHit:Oe}),(0,z.jsx)(CHe,{}),(0,z.jsx)(kte,{})]})}DHe();function OMt(e){if(e instanceof TypeError){let t=e.message.toLowerCase();return t.includes(`failed to fetch`)||t.includes(`networkerror`)||t.includes(`network request failed`)}return!1}var kMt=new ht({defaultOptions:{queries:{refetchInterval:6e4,staleTime:3e4,refetchIntervalInBackground:!1,retry:(e,t)=>OMt(t)&&e<3},mutations:{retry:(e,t)=>OMt(t)&&e<3,retryDelay:e=>Math.min(1e3*2**e,8e3)}}});nte.createRoot(document.getElementById(`root`)).render((0,z.jsx)(R.StrictMode,{children:(0,z.jsx)(OHe,{children:(0,z.jsx)(vt,{client:kMt,children:(0,z.jsx)(ote,{children:(0,z.jsx)(DMt,{})})})})})),window.__panMounted=!0;export{ND as $,M7 as A,tB as B,I7 as C,N7 as D,mTt as E,pY as F,HL as G,aB as H,sB as I,eO as J,IL as K,iB as L,fTt as M,_7 as N,L7 as O,g7 as P,LD as Q,oB as R,R7 as S,P7 as T,eB as U,nB as V,qz as W,RD as X,HD as Y,UFe as Z,W7 as _,xTt as a,LE as at,z7 as b,K7 as c,_Te as ct,yTt as d,YPe as et,CTt as f,gTt as g,U7 as h,X7 as i,FE as it,k7 as j,hTt as k,bTt as l,ri as lt,ETt as m,Q7 as n,GE as nt,_Tt as o,Yje as ot,J7 as p,tk as q,Y7 as r,PE as rt,STt as s,CTe as st,Z7 as t,QE as tt,vTt as u,V7 as v,F7 as w,B7 as x,H7 as y,rB as z};
|