@openscout/scout 0.2.23 → 0.2.25
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/bin/scout.mjs +9 -0
- package/dist/client/assets/index-CJIMoIMu.css +1 -0
- package/dist/client/assets/{index-B0OEtbrj.js → index-EaWhXnAI.js} +4 -4
- package/dist/client/index.html +4 -8
- package/dist/control-plane-client/assets/{index-D70CFXZt.js → index-B9LKyxlo.js} +1 -1
- package/dist/control-plane-client/index.html +1 -1
- package/dist/main.mjs +1903 -1831
- package/dist/pair-supervisor.mjs +33378 -0
- package/dist/scout-control-plane-web.mjs +23 -35
- package/dist/scout-web-server.mjs +181 -171
- package/package.json +2 -2
- package/dist/client/apple-icon.png +0 -0
- package/dist/client/assets/index-B4RPFOPU.css +0 -1
- package/dist/client/dispatch-button.svg +0 -1
- package/dist/client/icon-dark-32x32.png +0 -0
- package/dist/client/icon-light-32x32.png +0 -0
- package/dist/client/icon.svg +0 -26
- package/dist/client/placeholder-logo.png +0 -0
- package/dist/client/placeholder-logo.svg +0 -1
- package/dist/client/placeholder-user.jpg +0 -0
- package/dist/client/placeholder.jpg +0 -0
- package/dist/client/placeholder.svg +0 -1
- package/dist/client/scout.icns +0 -0
- package/dist/client/scout.png +0 -0
|
@@ -83,8 +83,8 @@ For more information, see https://radix-ui.com/primitives/docs/components/${r.do
|
|
|
83
83
|
`))+1))}const d="#".repeat(o),f=a.enter("headingAtx"),p=a.enter("phrasing");u.move(d+" ");let h=a.containerPhrasing(e,{before:"# ",after:`
|
|
84
84
|
`,...u.current()});return/^[\t ]/.test(h)&&(h=Ao(h.charCodeAt(0))+h.slice(1)),h=h?d+" "+h:d,a.options.closeAtx&&(h+=" "+d),p(),f(),h}G0.peek=fR;function G0(e){return e.value||""}function fR(){return"<"}$0.peek=mR;function $0(e,r,a,i){const o=lh(a),u=o==='"'?"Quote":"Apostrophe",d=a.enter("image");let f=a.enter("label");const p=a.createTracker(i);let h=p.move("![");return h+=p.move(a.safe(e.alt,{before:h,after:"]",...p.current()})),h+=p.move("]("),f(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(f=a.enter("destinationLiteral"),h+=p.move("<"),h+=p.move(a.safe(e.url,{before:h,after:">",...p.current()})),h+=p.move(">")):(f=a.enter("destinationRaw"),h+=p.move(a.safe(e.url,{before:h,after:e.title?" ":")",...p.current()}))),f(),e.title&&(f=a.enter(`title${u}`),h+=p.move(" "+o),h+=p.move(a.safe(e.title,{before:h,after:o,...p.current()})),h+=p.move(o),f()),h+=p.move(")"),d(),h}function mR(){return"!"}Y0.peek=pR;function Y0(e,r,a,i){const o=e.referenceType,u=a.enter("imageReference");let d=a.enter("label");const f=a.createTracker(i);let p=f.move("![");const h=a.safe(e.alt,{before:p,after:"]",...f.current()});p+=f.move(h+"]["),d();const y=a.stack;a.stack=[],d=a.enter("reference");const b=a.safe(a.associationId(e),{before:p,after:"]",...f.current()});return d(),a.stack=y,u(),o==="full"||!h||h!==b?p+=f.move(b+"]"):o==="shortcut"?p=p.slice(0,-1):p+=f.move("]"),p}function pR(){return"!"}Q0.peek=hR;function Q0(e,r,a){let i=e.value||"",o="`",u=-1;for(;new RegExp("(^|[^`])"+o+"([^`]|$)").test(i);)o+="`";for(/[^ \r\n]/.test(i)&&(/^[ \r\n]/.test(i)&&/[ \r\n]$/.test(i)||/^`|`$/.test(i))&&(i=" "+i+" ");++u<a.unsafe.length;){const d=a.unsafe[u],f=a.compilePattern(d);let p;if(d.atBreak)for(;p=f.exec(i);){let h=p.index;i.charCodeAt(h)===10&&i.charCodeAt(h-1)===13&&h--,i=i.slice(0,h)+" "+i.slice(p.index+1)}}return o+i+o}function hR(){return"`"}function X0(e,r){const a=Qp(e);return!!(!r.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(a===e.url||"mailto:"+a===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}K0.peek=xR;function K0(e,r,a,i){const o=lh(a),u=o==='"'?"Quote":"Apostrophe",d=a.createTracker(i);let f,p;if(X0(e,a)){const y=a.stack;a.stack=[],f=a.enter("autolink");let b=d.move("<");return b+=d.move(a.containerPhrasing(e,{before:b,after:">",...d.current()})),b+=d.move(">"),f(),a.stack=y,b}f=a.enter("link"),p=a.enter("label");let h=d.move("[");return h+=d.move(a.containerPhrasing(e,{before:h,after:"](",...d.current()})),h+=d.move("]("),p(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(p=a.enter("destinationLiteral"),h+=d.move("<"),h+=d.move(a.safe(e.url,{before:h,after:">",...d.current()})),h+=d.move(">")):(p=a.enter("destinationRaw"),h+=d.move(a.safe(e.url,{before:h,after:e.title?" ":")",...d.current()}))),p(),e.title&&(p=a.enter(`title${u}`),h+=d.move(" "+o),h+=d.move(a.safe(e.title,{before:h,after:o,...d.current()})),h+=d.move(o),p()),h+=d.move(")"),f(),h}function xR(e,r,a){return X0(e,a)?"<":"["}Z0.peek=gR;function Z0(e,r,a,i){const o=e.referenceType,u=a.enter("linkReference");let d=a.enter("label");const f=a.createTracker(i);let p=f.move("[");const h=a.containerPhrasing(e,{before:p,after:"]",...f.current()});p+=f.move(h+"]["),d();const y=a.stack;a.stack=[],d=a.enter("reference");const b=a.safe(a.associationId(e),{before:p,after:"]",...f.current()});return d(),a.stack=y,u(),o==="full"||!h||h!==b?p+=f.move(b+"]"):o==="shortcut"?p=p.slice(0,-1):p+=f.move("]"),p}function gR(){return"["}function rh(e){const r=e.options.bullet||"*";if(r!=="*"&&r!=="+"&&r!=="-")throw new Error("Cannot serialize items with `"+r+"` for `options.bullet`, expected `*`, `+`, or `-`");return r}function bR(e){const r=rh(e),a=e.options.bulletOther;if(!a)return r==="*"?"-":"*";if(a!=="*"&&a!=="+"&&a!=="-")throw new Error("Cannot serialize items with `"+a+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(a===r)throw new Error("Expected `bullet` (`"+r+"`) and `bulletOther` (`"+a+"`) to be different");return a}function yR(e){const r=e.options.bulletOrdered||".";if(r!=="."&&r!==")")throw new Error("Cannot serialize items with `"+r+"` for `options.bulletOrdered`, expected `.` or `)`");return r}function W0(e){const r=e.options.rule||"*";if(r!=="*"&&r!=="-"&&r!=="_")throw new Error("Cannot serialize rules with `"+r+"` for `options.rule`, expected `*`, `-`, or `_`");return r}function vR(e,r,a,i){const o=a.enter("list"),u=a.bulletCurrent;let d=e.ordered?yR(a):rh(a);const f=e.ordered?d==="."?")":".":bR(a);let p=r&&a.bulletLastUsed?d===a.bulletLastUsed:!1;if(!e.ordered){const y=e.children?e.children[0]:void 0;if((d==="*"||d==="-")&&y&&(!y.children||!y.children[0])&&a.stack[a.stack.length-1]==="list"&&a.stack[a.stack.length-2]==="listItem"&&a.stack[a.stack.length-3]==="list"&&a.stack[a.stack.length-4]==="listItem"&&a.indexStack[a.indexStack.length-1]===0&&a.indexStack[a.indexStack.length-2]===0&&a.indexStack[a.indexStack.length-3]===0&&(p=!0),W0(a)===d&&y){let b=-1;for(;++b<e.children.length;){const v=e.children[b];if(v&&v.type==="listItem"&&v.children&&v.children[0]&&v.children[0].type==="thematicBreak"){p=!0;break}}}}p&&(d=f),a.bulletCurrent=d;const h=a.containerFlow(e,i);return a.bulletLastUsed=d,a.bulletCurrent=u,o(),h}function kR(e){const r=e.options.listItemIndent||"one";if(r!=="tab"&&r!=="one"&&r!=="mixed")throw new Error("Cannot serialize items with `"+r+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return r}function jR(e,r,a,i){const o=kR(a);let u=a.bulletCurrent||rh(a);r&&r.type==="list"&&r.ordered&&(u=(typeof r.start=="number"&&r.start>-1?r.start:1)+(a.options.incrementListMarker===!1?0:r.children.indexOf(e))+u);let d=u.length+1;(o==="tab"||o==="mixed"&&(r&&r.type==="list"&&r.spread||e.spread))&&(d=Math.ceil(d/4)*4);const f=a.createTracker(i);f.move(u+" ".repeat(d-u.length)),f.shift(d);const p=a.enter("listItem"),h=a.indentLines(a.containerFlow(e,f.current()),y);return p(),h;function y(b,v,j){return v?(j?"":" ".repeat(d))+b:(j?u:u+" ".repeat(d-u.length))+b}}function NR(e,r,a,i){const o=a.enter("paragraph"),u=a.enter("phrasing"),d=a.containerPhrasing(e,i);return u(),o(),d}const wR=Qu(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function SR(e,r,a,i){return(e.children.some(function(d){return wR(d)})?a.containerPhrasing:a.containerFlow).call(a,e,i)}function CR(e){const r=e.options.strong||"*";if(r!=="*"&&r!=="_")throw new Error("Cannot serialize strong with `"+r+"` for `options.strong`, expected `*`, or `_`");return r}J0.peek=TR;function J0(e,r,a,i){const o=CR(a),u=a.enter("strong"),d=a.createTracker(i),f=d.move(o+o);let p=d.move(a.containerPhrasing(e,{after:o,before:f,...d.current()}));const h=p.charCodeAt(0),y=Iu(i.before.charCodeAt(i.before.length-1),h,o);y.inside&&(p=Ao(h)+p.slice(1));const b=p.charCodeAt(p.length-1),v=Iu(i.after.charCodeAt(0),b,o);v.inside&&(p=p.slice(0,-1)+Ao(b));const j=d.move(o+o);return u(),a.attentionEncodeSurroundingInfo={after:v.outside,before:y.outside},f+p+j}function TR(e,r,a){return a.options.strong||"*"}function AR(e,r,a,i){return a.safe(e.value,i)}function ER(e){const r=e.options.ruleRepetition||3;if(r<3)throw new Error("Cannot serialize rules with repetition `"+r+"` for `options.ruleRepetition`, expected `3` or more");return r}function RR(e,r,a){const i=(W0(a)+(a.options.ruleSpaces?" ":"")).repeat(ER(a));return a.options.ruleSpaces?i.slice(0,-1):i}const ek={blockquote:JE,break:Vy,code:aR,definition:sR,emphasis:V0,hardBreak:Vy,heading:dR,html:G0,image:$0,imageReference:Y0,inlineCode:Q0,link:K0,linkReference:Z0,list:vR,listItem:jR,paragraph:NR,root:SR,strong:J0,text:AR,thematicBreak:RR};function MR(){return{enter:{table:zR,tableData:Gy,tableHeader:Gy,tableRow:LR},exit:{codeText:DR,table:OR,tableData:$m,tableHeader:$m,tableRow:$m}}}function zR(e){const r=e._align;this.enter({type:"table",align:r.map(function(a){return a==="none"?null:a}),children:[]},e),this.data.inTable=!0}function OR(e){this.exit(e),this.data.inTable=void 0}function LR(e){this.enter({type:"tableRow",children:[]},e)}function $m(e){this.exit(e)}function Gy(e){this.enter({type:"tableCell",children:[]},e)}function DR(e){let r=this.resume();this.data.inTable&&(r=r.replace(/\\([\\|])/g,_R));const a=this.stack[this.stack.length-1];a.type,a.value=r,this.exit(e)}function _R(e,r){return r==="|"?r:e}function BR(e){const r=e||{},a=r.tableCellPadding,i=r.tablePipeAlign,o=r.stringLength,u=a?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
85
85
|
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:v,table:d,tableCell:p,tableRow:f}};function d(j,C,E,w){return h(y(j,E,w),j.align)}function f(j,C,E,w){const M=b(j,E,w),D=h([M]);return D.slice(0,D.indexOf(`
|
|
86
|
-
`))}function p(j,C,E,w){const M=E.enter("tableCell"),D=E.enter("phrasing"),H=E.containerPhrasing(j,{...w,before:u,after:u});return D(),M(),H}function h(j,C){return ZE(j,{align:C,alignDelimiters:i,padding:a,stringLength:o})}function y(j,C,E){const w=j.children;let M=-1;const D=[],H=C.enter("table");for(;++M<w.length;)D[M]=b(w[M],C,E);return H(),D}function b(j,C,E){const w=j.children;let M=-1;const D=[],H=C.enter("tableRow");for(;++M<w.length;)D[M]=p(w[M],j,C,E);return H(),D}function v(j,C,E){let w=ek.inlineCode(j,C,E);return E.stack.includes("tableCell")&&(w=w.replace(/\|/g,"\\$&")),w}}function IR(){return{exit:{taskListCheckValueChecked:$y,taskListCheckValueUnchecked:$y,paragraph:UR}}}function PR(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:HR}}}function $y(e){const r=this.stack[this.stack.length-2];r.type,r.checked=e.type==="taskListCheckValueChecked"}function UR(e){const r=this.stack[this.stack.length-2];if(r&&r.type==="listItem"&&typeof r.checked=="boolean"){const a=this.stack[this.stack.length-1];a.type;const i=a.children[0];if(i&&i.type==="text"){const o=r.children;let u=-1,d;for(;++u<o.length;){const f=o[u];if(f.type==="paragraph"){d=f;break}}d===a&&(i.value=i.value.slice(1),i.value.length===0?a.children.shift():a.position&&i.position&&typeof i.position.start.offset=="number"&&(i.position.start.column++,i.position.start.offset++,a.position.start=Object.assign({},i.position.start)))}}this.exit(e)}function HR(e,r,a,i){const o=e.children[0],u=typeof e.checked=="boolean"&&o&&o.type==="paragraph",d="["+(e.checked?"x":" ")+"] ",f=a.createTracker(i);u&&f.move(d);let p=ek.listItem(e,r,a,{...i,...f.current()});return u&&(p=p.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,h)),p;function h(y){return y+d}}function FR(){return[vE(),HE(),GE(),MR(),IR()]}function qR(e){return{extensions:[kE(),FE(e),$E(),BR(e),PR()]}}const VR={tokenize:KR,partial:!0},tk={tokenize:ZR,partial:!0},nk={tokenize:WR,partial:!0},lk={tokenize:JR,partial:!0},GR={tokenize:eM,partial:!0},rk={name:"wwwAutolink",tokenize:QR,previous:ik},ak={name:"protocolAutolink",tokenize:XR,previous:sk},wr={name:"emailAutolink",tokenize:YR,previous:ok},Vl={};function $R(){return{text:Vl}}let qa=48;for(;qa<123;)Vl[qa]=wr,qa++,qa===58?qa=65:qa===91&&(qa=97);Vl[43]=wr;Vl[45]=wr;Vl[46]=wr;Vl[95]=wr;Vl[72]=[wr,ak];Vl[104]=[wr,ak];Vl[87]=[wr,rk];Vl[119]=[wr,rk];function YR(e,r,a){const i=this;let o,u;return d;function d(b){return!xp(b)||!ok.call(i,i.previous)||ah(i.events)?a(b):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),f(b))}function f(b){return xp(b)?(e.consume(b),f):b===64?(e.consume(b),p):a(b)}function p(b){return b===46?e.check(GR,y,h)(b):b===45||b===95||Ln(b)?(u=!0,e.consume(b),p):y(b)}function h(b){return e.consume(b),o=!0,p}function y(b){return u&&o&&Pn(i.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),r(b)):a(b)}}function QR(e,r,a){const i=this;return o;function o(d){return d!==87&&d!==119||!ik.call(i,i.previous)||ah(i.events)?a(d):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(VR,e.attempt(tk,e.attempt(nk,u),a),a)(d))}function u(d){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),r(d)}}function XR(e,r,a){const i=this;let o="",u=!1;return d;function d(b){return(b===72||b===104)&&sk.call(i,i.previous)&&!ah(i.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),o+=String.fromCodePoint(b),e.consume(b),f):a(b)}function f(b){if(Pn(b)&&o.length<5)return o+=String.fromCodePoint(b),e.consume(b),f;if(b===58){const v=o.toLowerCase();if(v==="http"||v==="https")return e.consume(b),p}return a(b)}function p(b){return b===47?(e.consume(b),u?h:(u=!0,p)):a(b)}function h(b){return b===null||Du(b)||It(b)||Qa(b)||Gu(b)?a(b):e.attempt(tk,e.attempt(nk,y),a)(b)}function y(b){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),r(b)}}function KR(e,r,a){let i=0;return o;function o(d){return(d===87||d===119)&&i<3?(i++,e.consume(d),o):d===46&&i===3?(e.consume(d),u):a(d)}function u(d){return d===null?a(d):r(d)}}function ZR(e,r,a){let i,o,u;return d;function d(h){return h===46||h===95?e.check(lk,p,f)(h):h===null||It(h)||Qa(h)||h!==45&&Gu(h)?p(h):(u=!0,e.consume(h),d)}function f(h){return h===95?i=!0:(o=i,i=void 0),e.consume(h),d}function p(h){return o||i||!u?a(h):r(h)}}function WR(e,r){let a=0,i=0;return o;function o(d){return d===40?(a++,e.consume(d),o):d===41&&i<a?u(d):d===33||d===34||d===38||d===39||d===41||d===42||d===44||d===46||d===58||d===59||d===60||d===63||d===93||d===95||d===126?e.check(lk,r,u)(d):d===null||It(d)||Qa(d)?r(d):(e.consume(d),o)}function u(d){return d===41&&i++,e.consume(d),o}}function JR(e,r,a){return i;function i(f){return f===33||f===34||f===39||f===41||f===42||f===44||f===46||f===58||f===59||f===63||f===95||f===126?(e.consume(f),i):f===38?(e.consume(f),u):f===93?(e.consume(f),o):f===60||f===null||It(f)||Qa(f)?r(f):a(f)}function o(f){return f===null||f===40||f===91||It(f)||Qa(f)?r(f):i(f)}function u(f){return Pn(f)?d(f):a(f)}function d(f){return f===59?(e.consume(f),i):Pn(f)?(e.consume(f),d):a(f)}}function eM(e,r,a){return i;function i(u){return e.consume(u),o}function o(u){return Ln(u)?a(u):r(u)}}function ik(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||It(e)}function sk(e){return!Pn(e)}function ok(e){return!(e===47||xp(e))}function xp(e){return e===43||e===45||e===46||e===95||Ln(e)}function ah(e){let r=e.length,a=!1;for(;r--;){const i=e[r][1];if((i.type==="labelLink"||i.type==="labelImage")&&!i._balanced){a=!0;break}if(i._gfmAutolinkLiteralWalkedInto){a=!1;break}}return e.length>0&&!a&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),a}const tM={tokenize:cM,partial:!0};function nM(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:iM,continuation:{tokenize:sM},exit:oM}},text:{91:{name:"gfmFootnoteCall",tokenize:aM},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:lM,resolveTo:rM}}}}function lM(e,r,a){const i=this;let o=i.events.length;const u=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let d;for(;o--;){const p=i.events[o][1];if(p.type==="labelImage"){d=p;break}if(p.type==="gfmFootnoteCall"||p.type==="labelLink"||p.type==="label"||p.type==="image"||p.type==="link")break}return f;function f(p){if(!d||!d._balanced)return a(p);const h=El(i.sliceSerialize({start:d.end,end:i.now()}));return h.codePointAt(0)!==94||!u.includes(h.slice(1))?a(p):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),r(p))}}function rM(e,r){let a=e.length;for(;a--;)if(e[a][1].type==="labelImage"&&e[a][0]==="enter"){e[a][1];break}e[a+1][1].type="data",e[a+3][1].type="gfmFootnoteCallLabelMarker";const i={type:"gfmFootnoteCall",start:Object.assign({},e[a+3][1].start),end:Object.assign({},e[e.length-1][1].end)},o={type:"gfmFootnoteCallMarker",start:Object.assign({},e[a+3][1].end),end:Object.assign({},e[a+3][1].end)};o.end.column++,o.end.offset++,o.end._bufferIndex++;const u={type:"gfmFootnoteCallString",start:Object.assign({},o.end),end:Object.assign({},e[e.length-1][1].start)},d={type:"chunkString",contentType:"string",start:Object.assign({},u.start),end:Object.assign({},u.end)},f=[e[a+1],e[a+2],["enter",i,r],e[a+3],e[a+4],["enter",o,r],["exit",o,r],["enter",u,r],["enter",d,r],["exit",d,r],["exit",u,r],e[e.length-2],e[e.length-1],["exit",i,r]];return e.splice(a,e.length-a+1,...f),e}function aM(e,r,a){const i=this,o=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let u=0,d;return f;function f(b){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(b),e.exit("gfmFootnoteCallLabelMarker"),p}function p(b){return b!==94?a(b):(e.enter("gfmFootnoteCallMarker"),e.consume(b),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",h)}function h(b){if(u>999||b===93&&!d||b===null||b===91||It(b))return a(b);if(b===93){e.exit("chunkString");const v=e.exit("gfmFootnoteCallString");return o.includes(El(i.sliceSerialize(v)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(b),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),r):a(b)}return It(b)||(d=!0),u++,e.consume(b),b===92?y:h}function y(b){return b===91||b===92||b===93?(e.consume(b),u++,h):h(b)}}function iM(e,r,a){const i=this,o=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let u,d=0,f;return p;function p(C){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(C),e.exit("gfmFootnoteDefinitionLabelMarker"),h}function h(C){return C===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(C),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",y):a(C)}function y(C){if(d>999||C===93&&!f||C===null||C===91||It(C))return a(C);if(C===93){e.exit("chunkString");const E=e.exit("gfmFootnoteDefinitionLabelString");return u=El(i.sliceSerialize(E)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(C),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),v}return It(C)||(f=!0),d++,e.consume(C),C===92?b:y}function b(C){return C===91||C===92||C===93?(e.consume(C),d++,y):y(C)}function v(C){return C===58?(e.enter("definitionMarker"),e.consume(C),e.exit("definitionMarker"),o.includes(u)||o.push(u),wt(e,j,"gfmFootnoteDefinitionWhitespace")):a(C)}function j(C){return r(C)}}function sM(e,r,a){return e.check(zo,r,e.attempt(tM,r,a))}function oM(e){e.exit("gfmFootnoteDefinition")}function cM(e,r,a){const i=this;return wt(e,o,"gfmFootnoteDefinitionIndent",5);function o(u){const d=i.events[i.events.length-1];return d&&d[1].type==="gfmFootnoteDefinitionIndent"&&d[2].sliceSerialize(d[1],!0).length===4?r(u):a(u)}}function uM(e){let a=(e||{}).singleTilde;const i={name:"strikethrough",tokenize:u,resolveAll:o};return a==null&&(a=!0),{text:{126:i},insideSpan:{null:[i]},attentionMarkers:{null:[126]}};function o(d,f){let p=-1;for(;++p<d.length;)if(d[p][0]==="enter"&&d[p][1].type==="strikethroughSequenceTemporary"&&d[p][1]._close){let h=p;for(;h--;)if(d[h][0]==="exit"&&d[h][1].type==="strikethroughSequenceTemporary"&&d[h][1]._open&&d[p][1].end.offset-d[p][1].start.offset===d[h][1].end.offset-d[h][1].start.offset){d[p][1].type="strikethroughSequence",d[h][1].type="strikethroughSequence";const y={type:"strikethrough",start:Object.assign({},d[h][1].start),end:Object.assign({},d[p][1].end)},b={type:"strikethroughText",start:Object.assign({},d[h][1].end),end:Object.assign({},d[p][1].start)},v=[["enter",y,f],["enter",d[h][1],f],["exit",d[h][1],f],["enter",b,f]],j=f.parser.constructs.insideSpan.null;j&&ul(v,v.length,0,$u(j,d.slice(h+1,p),f)),ul(v,v.length,0,[["exit",b,f],["enter",d[p][1],f],["exit",d[p][1],f],["exit",y,f]]),ul(d,h-1,p-h+3,v),p=h+v.length-2;break}}for(p=-1;++p<d.length;)d[p][1].type==="strikethroughSequenceTemporary"&&(d[p][1].type="data");return d}function u(d,f,p){const h=this.previous,y=this.events;let b=0;return v;function v(C){return h===126&&y[y.length-1][1].type!=="characterEscape"?p(C):(d.enter("strikethroughSequenceTemporary"),j(C))}function j(C){const E=Ji(h);if(C===126)return b>1?p(C):(d.consume(C),b++,j);if(b<2&&!a)return p(C);const w=d.exit("strikethroughSequenceTemporary"),M=Ji(C);return w._open=!M||M===2&&!!E,w._close=!E||E===2&&!!M,f(C)}}}class dM{constructor(){this.map=[]}add(r,a,i){fM(this,r,a,i)}consume(r){if(this.map.sort(function(u,d){return u[0]-d[0]}),this.map.length===0)return;let a=this.map.length;const i=[];for(;a>0;)a-=1,i.push(r.slice(this.map[a][0]+this.map[a][1]),this.map[a][2]),r.length=this.map[a][0];i.push(r.slice()),r.length=0;let o=i.pop();for(;o;){for(const u of o)r.push(u);o=i.pop()}this.map.length=0}}function fM(e,r,a,i){let o=0;if(!(a===0&&i.length===0)){for(;o<e.map.length;){if(e.map[o][0]===r){e.map[o][1]+=a,e.map[o][2].push(...i);return}o+=1}e.map.push([r,a,i])}}function mM(e,r){let a=!1;const i=[];for(;r<e.length;){const o=e[r];if(a){if(o[0]==="enter")o[1].type==="tableContent"&&i.push(e[r+1][1].type==="tableDelimiterMarker"?"left":"none");else if(o[1].type==="tableContent"){if(e[r-1][1].type==="tableDelimiterMarker"){const u=i.length-1;i[u]=i[u]==="left"?"center":"right"}}else if(o[1].type==="tableDelimiterRow")break}else o[0]==="enter"&&o[1].type==="tableDelimiterRow"&&(a=!0);r+=1}return i}function pM(){return{flow:{null:{name:"table",tokenize:hM,resolveAll:xM}}}}function hM(e,r,a){const i=this;let o=0,u=0,d;return f;function f(O){let P=i.events.length-1;for(;P>-1;){const J=i.events[P][1].type;if(J==="lineEnding"||J==="linePrefix")P--;else break}const Q=P>-1?i.events[P][1].type:null,oe=Q==="tableHead"||Q==="tableRow"?L:p;return oe===L&&i.parser.lazy[i.now().line]?a(O):oe(O)}function p(O){return e.enter("tableHead"),e.enter("tableRow"),h(O)}function h(O){return O===124||(d=!0,u+=1),y(O)}function y(O){return O===null?a(O):$e(O)?u>1?(u=0,i.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(O),e.exit("lineEnding"),j):a(O):gt(O)?wt(e,y,"whitespace")(O):(u+=1,d&&(d=!1,o+=1),O===124?(e.enter("tableCellDivider"),e.consume(O),e.exit("tableCellDivider"),d=!0,y):(e.enter("data"),b(O)))}function b(O){return O===null||O===124||It(O)?(e.exit("data"),y(O)):(e.consume(O),O===92?v:b)}function v(O){return O===92||O===124?(e.consume(O),b):b(O)}function j(O){return i.interrupt=!1,i.parser.lazy[i.now().line]?a(O):(e.enter("tableDelimiterRow"),d=!1,gt(O)?wt(e,C,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(O):C(O))}function C(O){return O===45||O===58?w(O):O===124?(d=!0,e.enter("tableCellDivider"),e.consume(O),e.exit("tableCellDivider"),E):q(O)}function E(O){return gt(O)?wt(e,w,"whitespace")(O):w(O)}function w(O){return O===58?(u+=1,d=!0,e.enter("tableDelimiterMarker"),e.consume(O),e.exit("tableDelimiterMarker"),M):O===45?(u+=1,M(O)):O===null||$e(O)?X(O):q(O)}function M(O){return O===45?(e.enter("tableDelimiterFiller"),D(O)):q(O)}function D(O){return O===45?(e.consume(O),D):O===58?(d=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(O),e.exit("tableDelimiterMarker"),H):(e.exit("tableDelimiterFiller"),H(O))}function H(O){return gt(O)?wt(e,X,"whitespace")(O):X(O)}function X(O){return O===124?C(O):O===null||$e(O)?!d||o!==u?q(O):(e.exit("tableDelimiterRow"),e.exit("tableHead"),r(O)):q(O)}function q(O){return a(O)}function L(O){return e.enter("tableRow"),B(O)}function B(O){return O===124?(e.enter("tableCellDivider"),e.consume(O),e.exit("tableCellDivider"),B):O===null||$e(O)?(e.exit("tableRow"),r(O)):gt(O)?wt(e,B,"whitespace")(O):(e.enter("data"),F(O))}function F(O){return O===null||O===124||It(O)?(e.exit("data"),B(O)):(e.consume(O),O===92?Z:F)}function Z(O){return O===92||O===124?(e.consume(O),F):F(O)}}function xM(e,r){let a=-1,i=!0,o=0,u=[0,0,0,0],d=[0,0,0,0],f=!1,p=0,h,y,b;const v=new dM;for(;++a<e.length;){const j=e[a],C=j[1];j[0]==="enter"?C.type==="tableHead"?(f=!1,p!==0&&(Yy(v,r,p,h,y),y=void 0,p=0),h={type:"table",start:Object.assign({},C.start),end:Object.assign({},C.end)},v.add(a,0,[["enter",h,r]])):C.type==="tableRow"||C.type==="tableDelimiterRow"?(i=!0,b=void 0,u=[0,0,0,0],d=[0,a+1,0,0],f&&(f=!1,y={type:"tableBody",start:Object.assign({},C.start),end:Object.assign({},C.end)},v.add(a,0,[["enter",y,r]])),o=C.type==="tableDelimiterRow"?2:y?3:1):o&&(C.type==="data"||C.type==="tableDelimiterMarker"||C.type==="tableDelimiterFiller")?(i=!1,d[2]===0&&(u[1]!==0&&(d[0]=d[1],b=hu(v,r,u,o,void 0,b),u=[0,0,0,0]),d[2]=a)):C.type==="tableCellDivider"&&(i?i=!1:(u[1]!==0&&(d[0]=d[1],b=hu(v,r,u,o,void 0,b)),u=d,d=[u[1],a,0,0])):C.type==="tableHead"?(f=!0,p=a):C.type==="tableRow"||C.type==="tableDelimiterRow"?(p=a,u[1]!==0?(d[0]=d[1],b=hu(v,r,u,o,a,b)):d[1]!==0&&(b=hu(v,r,d,o,a,b)),o=0):o&&(C.type==="data"||C.type==="tableDelimiterMarker"||C.type==="tableDelimiterFiller")&&(d[3]=a)}for(p!==0&&Yy(v,r,p,h,y),v.consume(r.events),a=-1;++a<r.events.length;){const j=r.events[a];j[0]==="enter"&&j[1].type==="table"&&(j[1]._align=mM(r.events,a))}return e}function hu(e,r,a,i,o,u){const d=i===1?"tableHeader":i===2?"tableDelimiter":"tableData",f="tableContent";a[0]!==0&&(u.end=Object.assign({},Gi(r.events,a[0])),e.add(a[0],0,[["exit",u,r]]));const p=Gi(r.events,a[1]);if(u={type:d,start:Object.assign({},p),end:Object.assign({},p)},e.add(a[1],0,[["enter",u,r]]),a[2]!==0){const h=Gi(r.events,a[2]),y=Gi(r.events,a[3]),b={type:f,start:Object.assign({},h),end:Object.assign({},y)};if(e.add(a[2],0,[["enter",b,r]]),i!==2){const v=r.events[a[2]],j=r.events[a[3]];if(v[1].end=Object.assign({},j[1].end),v[1].type="chunkText",v[1].contentType="text",a[3]>a[2]+1){const C=a[2]+1,E=a[3]-a[2]-1;e.add(C,E,[])}}e.add(a[3]+1,0,[["exit",b,r]])}return o!==void 0&&(u.end=Object.assign({},Gi(r.events,o)),e.add(o,0,[["exit",u,r]]),u=void 0),u}function Yy(e,r,a,i,o){const u=[],d=Gi(r.events,a);o&&(o.end=Object.assign({},d),u.push(["exit",o,r])),i.end=Object.assign({},d),u.push(["exit",i,r]),e.add(a+1,0,u)}function Gi(e,r){const a=e[r],i=a[0]==="enter"?"start":"end";return a[1][i]}const gM={name:"tasklistCheck",tokenize:yM};function bM(){return{text:{91:gM}}}function yM(e,r,a){const i=this;return o;function o(p){return i.previous!==null||!i._gfmTasklistFirstContentOfListItem?a(p):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(p),e.exit("taskListCheckMarker"),u)}function u(p){return It(p)?(e.enter("taskListCheckValueUnchecked"),e.consume(p),e.exit("taskListCheckValueUnchecked"),d):p===88||p===120?(e.enter("taskListCheckValueChecked"),e.consume(p),e.exit("taskListCheckValueChecked"),d):a(p)}function d(p){return p===93?(e.enter("taskListCheckMarker"),e.consume(p),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),f):a(p)}function f(p){return $e(p)?r(p):gt(p)?e.check({tokenize:vM},r,a)(p):a(p)}}function vM(e,r,a){return wt(e,i,"whitespace");function i(o){return o===null?a(o):r(o)}}function kM(e){return y0([$R(),nM(),uM(e),pM(),bM()])}const jM={};function NM(e){const r=this,a=e||jM,i=r.data(),o=i.micromarkExtensions||(i.micromarkExtensions=[]),u=i.fromMarkdownExtensions||(i.fromMarkdownExtensions=[]),d=i.toMarkdownExtensions||(i.toMarkdownExtensions=[]);o.push(kM(a)),u.push(FR()),d.push(qR(a))}function wM({thread:e}){return e.state==="available"?null:e.state==="working"?l.jsx("span",{className:"inline-flex items-center gap-1 shrink-0",style:{color:g.muted},children:l.jsx(Ku,{})}):l.jsxs("span",{className:"inline-flex items-center gap-1.5 text-[9px] font-mono tracking-wide shrink-0",style:{color:g.muted},children:[l.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${Ro(e.state)}`}),l.jsx("span",{children:e.statusLabel})]})}function Ku({className:e=""}){return l.jsxs("span",{className:`inline-flex items-center gap-1 ${e}`,"aria-hidden":"true",children:[l.jsx("span",{className:"os-thinking-dot"}),l.jsx("span",{className:"os-thinking-dot"}),l.jsx("span",{className:"os-thinking-dot"})]})}function ko({messages:e,showAnnotations:r,showStatusMessages:a,inkStyle:i,mutedStyle:o,tagStyle:u,annotStyle:d,agentLookup:f,directThreadLookup:p,onOpenAgentProfile:h,onOpenAgentChat:y,onNudgeMessage:b}){const[v,j]=A.useState(null),[C,E]=A.useState(null),[w,M]=A.useState(null),D=[];let H="",X=0;const q=A.useMemo(()=>a?e:e.filter(P=>P.messageClass!=="status"),[e,a]),L=A.useMemo(()=>new Map(q.map(P=>[P.id,P])),[q]),B=A.useMemo(()=>{let P=null;for(const Q of q)Q.isOperator&&Q.isDirectConversation&&Q.receipt&&(P=Q.id);return P},[q]);A.useEffect(()=>{if(!v)return;const P=window.setTimeout(()=>{j(Q=>Q===v?null:Q)},1400);return()=>window.clearTimeout(P)},[v]),A.useEffect(()=>{if(!C)return;const P=window.setTimeout(()=>{E(Q=>Q===C?null:Q)},1400);return()=>window.clearTimeout(P)},[C]),A.useEffect(()=>{if(!w)return;const P=window.setTimeout(()=>{M(Q=>Q===w?null:Q)},2200);return()=>window.clearTimeout(P)},[w]);const F=z.useCallback(async P=>{try{await uk(So(P)),j(P)}catch{j(null)}},[]),Z=z.useCallback(P=>{b?.(P),E(P.id)},[b]),O=z.useCallback(P=>{if(typeof document>"u")return;const Q=document.getElementById(km(P));Q&&(Q.scrollIntoView({block:"center",behavior:"smooth"}),M(P))},[]);for(;X<q.length;){const P=q[X],Q=FS(P.authorRole)?P.authorRole:null,oe=P.isOperator?null:f.get(P.authorId)??null,J=oe?p.get(oe.id)??null:null;if(P.dayLabel!==H&&(D.push(l.jsxs("div",{className:"flex items-center gap-3 mb-5 mt-2",children:[l.jsx("div",{className:"flex-1 h-px",style:{backgroundColor:g.border}}),l.jsx("div",{className:"px-2 font-mono text-[9px] tracking-widest uppercase shrink-0",style:o,children:P.dayLabel}),l.jsx("div",{className:"flex-1 h-px",style:{backgroundColor:g.border}})]},`day-${P.dayLabel}`)),H=P.dayLabel),P.isSystem||P.messageClass==="status"){D.push(l.jsxs("div",{className:"flex gap-3 mb-3 group rounded-lg px-2 py-2 -mx-2 bg-[var(--os-hover)]",children:[l.jsx("div",{className:"w-6 h-6 rounded-md flex items-center justify-center text-[9px] font-semibold shrink-0 mt-0.5",style:{backgroundColor:P.avatarColor,color:"white",opacity:.85},children:P.avatarLabel}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:"flex items-baseline justify-between mb-0.5",children:l.jsx("div",{className:"flex items-baseline gap-2",children:oe?l.jsx(Xy,{agent:oe,directThread:J,visibleRole:Q,timestampLabel:P.timestampLabel,inkStyle:i,mutedStyle:o,tagStyle:u,onOpenProfile:h,onOpenChat:y}):l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"font-semibold text-[12px]",style:i,children:P.authorName}),l.jsx("span",{className:"text-[9px] font-mono",style:o,children:P.timestampLabel})]})})}),l.jsxs("div",{id:km(P.id),className:"group/message relative text-[12px] leading-relaxed rounded-lg px-2 py-1.5 pr-12 -mx-2",style:w===P.id?Gb():i,children:[l.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 border rounded font-mono text-[10px] w-fit",style:u,children:[l.jsx(un,{className:"text-[10px]"}),l.jsxs("span",{children:[l.jsx("span",{style:o,children:"TASK //"})," ",P.body]}),l.jsx("span",{className:"ml-2 px-1 rounded",style:{backgroundColor:"rgba(99,102,241,0.12)",color:"var(--os-accent)"},children:"IN PROGRESS"})]}),l.jsx(Qy,{message:P,copied:v===P.id,nudged:C===P.id,canNudge:!!(b&&!P.isOperator),mutedStyle:o,onCopyRef:F,onNudge:()=>Z(P)})]})]})]},P.id)),X+=1;continue}const ee=[P];let N=X+1;for(;N<q.length&&q[N].authorId===P.authorId&&q[N].dayLabel===P.dayLabel&&!q[N].isSystem&&q[N].messageClass!=="status";)ee.push(q[N]),N+=1;const Y=!!oe;D.push(l.jsxs("div",{className:An("flex gap-3 mb-4 group rounded-lg px-2 py-2 -mx-2",Y&&"bg-[var(--os-hover)]"),children:[l.jsx("div",{className:"w-6 h-6 rounded-md flex items-center justify-center text-[9px] font-semibold shrink-0 mt-0.5",style:{backgroundColor:P.avatarColor,color:"white",opacity:.85},children:P.avatarLabel}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-baseline justify-between mb-1",children:[l.jsx("div",{className:"flex items-baseline gap-2",children:oe?l.jsx(Xy,{agent:oe,directThread:J,visibleRole:Q,timestampLabel:P.timestampLabel,inkStyle:i,mutedStyle:o,tagStyle:u,onOpenProfile:h,onOpenChat:y}):l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"font-semibold text-[12px]",style:i,children:P.authorName}),Q?l.jsx("span",{className:"text-[9px] font-mono border px-1 py-0.5 rounded",style:u,children:Q}):null,l.jsx("span",{className:"text-[9px] font-mono",style:o,children:P.timestampLabel})]})}),r&&(P.routingSummary||P.provenanceSummary)?l.jsxs("div",{className:"flex items-center gap-1",children:[P.routingSummary?l.jsx("span",{className:"text-[9px] font-mono border px-1 rounded",style:d,children:P.routingSummary}):null,P.provenanceSummary?l.jsx("span",{className:"text-[9px] font-mono border px-1 rounded",style:d,children:P.provenanceSummary}):null]}):null]}),l.jsx("div",{className:"flex flex-col gap-2 mt-0.5",children:ee.map($=>{const ye=$.replyToMessageId?L.get($.replyToMessageId)??null:null,T=!!($.receipt&&(!$.isOperator||!$.isDirectConversation||B===$.id)),_=T&&VS($.body);return l.jsxs("div",{id:km($.id),className:"group/message relative text-[12px] leading-relaxed rounded-lg px-2 py-1.5 pr-12 -mx-2",style:w===$.id?Gb():i,children:[$.replyToMessageId?ye?l.jsx(Ky,{messageId:$.replyToMessageId,preview:zu(ye.body,64),mutedStyle:o,onJump:()=>O($.replyToMessageId)}):l.jsx(Ky,{messageId:$.replyToMessageId,mutedStyle:o}):null,_&&$.receipt?l.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-1",children:[l.jsx("span",{className:"min-w-0 max-w-full whitespace-pre-wrap break-words",style:i,children:$.body}),l.jsx(Zy,{receipt:$.receipt,mutedStyle:o,inline:!0})]}):l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"flex flex-col gap-2",children:EM($.body,i,o,u)}),T&&$.receipt?l.jsx(Zy,{receipt:$.receipt,mutedStyle:o}):null]}),r&&($.routingSummary||$.provenanceSummary||$.provenanceDetail)?l.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mt-1.5",children:[$.routingSummary?l.jsx("span",{className:"text-[9px] font-mono border px-1 rounded",style:d,children:$.routingSummary}):null,$.provenanceSummary?l.jsx("span",{className:"text-[9px] font-mono border px-1 rounded",style:d,children:$.provenanceSummary}):null,$.provenanceDetail?l.jsx("span",{className:"text-[9px]",style:o,children:$.provenanceDetail}):null]}):null,l.jsx(Qy,{message:$,copied:v===$.id,nudged:C===$.id,canNudge:!!(b&&!$.isOperator),mutedStyle:o,onCopyRef:F,onNudge:()=>Z($)})]},$.id)})})]})]},P.id)),X=N}return l.jsx(l.Fragment,{children:D})}function Qy({message:e,copied:r,nudged:a,canNudge:i,mutedStyle:o,onCopyRef:u,onNudge:d}){return l.jsxs("div",{className:"absolute top-1.5 right-2 flex items-center gap-2 opacity-0 pointer-events-none transition-opacity group-hover/message:opacity-100 group-hover/message:pointer-events-auto group-focus-within/message:opacity-100 group-focus-within/message:pointer-events-auto",children:[i?l.jsx("button",{type:"button",onClick:d,className:"text-[9px] font-mono lowercase tracking-wide transition-colors hover:opacity-80",style:a?{color:g.accent}:o,title:`Follow up with ${e.authorName}`,children:a?"drafted":"nudge"}):null,l.jsx("button",{type:"button",onClick:()=>{u(e.id)},className:"text-[9px] font-mono lowercase tracking-wide transition-colors hover:opacity-80",style:r?{color:g.accent}:o,title:Nv(e.id),children:r?"copied":tC(e.id)})]})}function Xy({agent:e,directThread:r,visibleRole:a,timestampLabel:i,inkStyle:o,mutedStyle:u,tagStyle:d,onOpenProfile:f,onOpenChat:p}){const h=y=>{if(y.preventDefault(),y.stopPropagation(),y.metaKey||y.ctrlKey){p(e.id);return}f(e.id)};return l.jsxs("div",{className:"relative group/agent inline-flex items-baseline gap-2 min-w-0",children:[l.jsxs("button",{type:"button",onClick:h,className:"inline-flex items-baseline gap-2 min-w-0 text-left hover:opacity-90 transition-opacity",title:"Click for overview. Cmd-click to open direct chat.",children:[l.jsx("span",{className:"font-semibold text-[12px] truncate",style:o,children:e.title}),a?l.jsx("span",{className:"text-[9px] font-mono border px-1 py-0.5 rounded shrink-0",style:d,children:a}):null]}),l.jsx("span",{className:"text-[9px] font-mono shrink-0",style:u,children:i}),l.jsx(CM,{agent:e,directThread:r,mutedStyle:u,onOpenProfile:f,onOpenChat:p})]})}function SM({agent:e,directThread:r=null,variant:a="hero",mutedStyle:i={color:g.muted},borderColor:o=g.bg,actions:u=null}){const d=a==="hover",f=Fb(e.role),p=Fb(e.summary),h=r?.statusDetail??e.statusDetail??p??"Available as a local relay channel.";return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsxs("div",{className:"relative shrink-0",children:[l.jsx("div",{className:`${d?"w-8 h-8 text-[11px]":"w-10 h-10 text-[13px]"} rounded text-white flex items-center justify-center font-bold ${e.reachable?"":"opacity-40 grayscale"}`,style:{backgroundColor:cl(e.id)},children:e.title.charAt(0).toUpperCase()}),l.jsx("div",{className:`absolute -bottom-0.5 -right-0.5 w-2 h-2 rounded-full ${Ro(e.state)}`,style:{border:`1px solid ${o}`}})]}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[l.jsx("div",{className:d?"text-[12px] font-semibold truncate":"text-[15px] font-semibold tracking-tight",style:{color:g.ink},children:e.title}),l.jsx("span",{className:"text-[9px] font-mono uppercase px-1.5 py-0.5 rounded",style:{backgroundColor:g.tagBg,color:g.muted},children:mv(e.profileKind)})]}),d?l.jsx("div",{className:"text-[10px] mt-1",style:i,children:h}):l.jsxs(l.Fragment,{children:[f?l.jsx("div",{className:"text-[11px] mt-1",style:{color:g.ink},children:f}):null,p?l.jsx("div",{className:"text-[12px] leading-[1.55] mt-2",style:{color:g.muted},children:p}):null]}),l.jsx("div",{className:`text-[10px] ${d?"mt-2 flex flex-wrap gap-x-3 gap-y-1":"mt-3 flex items-center gap-2 flex-wrap"}`,style:i,children:d?l.jsxs(l.Fragment,{children:[l.jsx("span",{children:e.harness??"runtime"}),l.jsx("span",{children:Ka(e.projectRoot??e.cwd)??"no path"}),e.lastChatLabel?l.jsxs("span",{children:["last chat ",e.lastChatLabel]}):null]}):l.jsxs(l.Fragment,{children:[l.jsx("span",{children:e.lastChatLabel?`Last chat ${e.lastChatLabel}`:"No direct chat yet."}),e.lastSessionLabel?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"w-1 h-1 rounded-full",style:{backgroundColor:g.border}}),l.jsxs("span",{children:["Last session ",e.lastSessionLabel]})]}):null]})})]})]}),u?l.jsx("div",{className:"mt-3 flex items-center gap-2",children:u}):null]})}function ho({children:e,icon:r,tone:a="neutral",...i}){return l.jsxs(Nt,{type:"button",variant:"outline",size:"sm",className:"h-8 rounded-xl px-3 text-[10px] font-medium shadow-none",style:a==="primary"?{backgroundColor:g.accentBg,borderColor:g.accentBorder,color:g.accent}:{backgroundColor:g.surface,borderColor:g.border,color:g.ink},...i,children:[r,e]})}function CM({agent:e,directThread:r,mutedStyle:a,onOpenProfile:i,onOpenChat:o}){return l.jsx("div",{className:"absolute left-0 top-full z-30 mt-2 w-72 rounded-xl border p-3 shadow-lg opacity-0 pointer-events-none translate-y-1 transition-all duration-150 group-hover/agent:opacity-100 group-hover/agent:pointer-events-auto group-hover/agent:translate-y-0 group-focus-within/agent:opacity-100 group-focus-within/agent:pointer-events-auto group-focus-within/agent:translate-y-0",style:{borderColor:g.border,backgroundColor:g.surface},children:l.jsx(SM,{agent:e,directThread:r,variant:"hover",mutedStyle:a,borderColor:g.surface,actions:l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button",className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-1 rounded",style:{color:g.ink},onClick:u=>{u.preventDefault(),u.stopPropagation(),o(e.id)},children:"Message"}),l.jsx("button",{type:"button",className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-1 rounded",style:{color:g.ink},onClick:u=>{u.preventDefault(),u.stopPropagation(),i(e.id)},children:"Overview"}),l.jsx("span",{className:"ml-auto text-[9px] font-mono",style:a,children:"Cmd-click to DM"})]})})})}function Ky({messageId:e,preview:r,mutedStyle:a,onJump:i}){return l.jsxs("div",{className:"mb-1 flex items-center gap-1.5 text-[9px] leading-none min-w-0",style:{...a,opacity:.7},children:[l.jsx(_N,{size:9,className:"shrink-0"}),i?l.jsx("button",{type:"button",onClick:i,className:"hover:underline underline-offset-2 truncate min-w-0",title:Nv(e),children:r||So(e)}):l.jsx("span",{className:"font-mono shrink-0",children:So(e)})]})}function Zy({receipt:e,mutedStyle:r,inline:a=!1}){const i=qS(e.state);return l.jsxs("div",{className:`${a?"":"mt-1.5 "}inline-flex items-center gap-1.5 text-[10px] leading-none shrink-0`,style:{...r,color:i.color},title:e.detail??e.label,children:[l.jsx(TM,{state:e.state}),l.jsx("span",{className:"font-mono uppercase tracking-[0.14em]",children:e.label}),e.state==="replied"&&e.detail?l.jsx("span",{style:r,children:e.detail}):null]})}function TM({state:e}){switch(e){case"replied":return l.jsx(C2,{size:11});case"working":return l.jsx(Ku,{className:"text-[var(--os-accent)]"});case"seen":return l.jsx(Eu,{size:11});case"delivered":return l.jsx(Eu,{size:11});default:return l.jsx(Yi,{size:11})}}function Ki({size:e=16,strokeWidth:r=1.35,style:a}){return l.jsx(S1,{size:e,strokeWidth:r,className:"shrink-0",style:a,"aria-hidden":"true"})}function ck({id:e,active:r,size:a=12}){const i=r?{color:g.accent}:void 0;return e==="voice"?l.jsx(Km,{size:a,className:"os-row-icon shrink-0",style:i}):e==="system"?l.jsx($a,{size:a,className:"os-row-icon shrink-0",style:i}):e==="mentions"?l.jsx(Np,{size:a,className:"os-row-icon shrink-0",style:i}):e==="coordination"?l.jsx(Al,{size:a,className:"os-row-icon shrink-0",style:i}):e==="all-traffic"?l.jsx(j2,{size:a,className:"os-row-icon shrink-0",style:i}):l.jsx(e2,{size:a,className:"os-row-icon shrink-0",style:i})}function AM({relayState:e,appSettings:r,destinationKind:a,destinationId:i,body:o,replyToMessageId:u,clientMessageId:d}){const f=Date.now(),p=e?.operatorId??"operator",h=ZS(e,r),y=a==="direct"?Array.from(new Set([i,...Vb(o)])):Vb(o),b=a==="channel"?i:a==="direct"?null:"shared",v=a==="channel"&&i==="voice",j=a==="channel"&&i==="system";return{id:`pending-${d}`,clientMessageId:d,conversationId:eC(a,i),createdAt:f,replyToMessageId:u,authorId:p,authorName:h,authorRole:null,body:o,timestampLabel:QS(f),dayLabel:XS(f),normalizedChannel:b,recipients:y,isDirectConversation:a==="direct",isSystem:j,isVoice:v,messageClass:j?"system":"agent",routingSummary:y.length>0?`Targets ${y.join(", ")}`:null,provenanceSummary:"via electron · sending",provenanceDetail:null,isOperator:!0,avatarLabel:h.slice(0,1).toUpperCase()||"A",avatarColor:cl(p),receipt:{state:"sent",label:"Sending…",detail:null}}}function EM(e,r,a,i){const o={"--os-markdown-ink":String(r.color??g.ink),"--os-markdown-muted":String(a.color??g.muted),"--os-markdown-link":g.accent,"--os-markdown-border":g.border,"--os-markdown-surface":String(i.backgroundColor??g.tagBg),"--os-markdown-inline-border":String(i.borderColor??g.border),"--os-markdown-code-bg":g.termBg,"--os-markdown-code-fg":g.termFg};return l.jsx("div",{className:"os-markdown",style:o,children:l.jsx(uE,{remarkPlugins:[NM],components:{a:({href:u,children:d})=>l.jsx("a",{href:u,target:"_blank",rel:"noreferrer",children:d}),blockquote:({children:u})=>l.jsx("blockquote",{children:u}),code:({className:u,children:d,...f})=>{const p=/language-([\w-]+)/.exec(u??"")?.[1],h=String(d).replace(/\n$/,"");return!p&&!h.includes(`
|
|
87
|
-
`)?l.jsx("code",{className:"os-markdown-inline-code",...f,children:h}):l.jsxs("div",{className:"os-markdown-code-block",children:[l.jsx("div",{className:"os-markdown-code-header",children:l.jsx("span",{children:p??"code"})}),l.jsx("pre",{className:"os-markdown-pre",children:l.jsx("code",{className:u,...f,children:h})})]})},h1:({children:u})=>l.jsx("h1",{children:u}),h2:({children:u})=>l.jsx("h2",{children:u}),h3:({children:u})=>l.jsx("h3",{children:u}),hr:()=>l.jsx("hr",{}),pre:({children:u})=>l.jsx(l.Fragment,{children:u}),table:({children:u})=>l.jsx("div",{className:"os-markdown-table-wrap",children:l.jsx("table",{children:u})})},children:e})})}async function uk(e){if(typeof navigator<"u"&&navigator.clipboard?.writeText){await navigator.clipboard.writeText(e);return}if(typeof document<"u"){const r=document.createElement("textarea");r.value=e,r.setAttribute("readonly","true"),r.style.position="fixed",r.style.opacity="0",document.body.appendChild(r),r.select();const a=document.execCommand("copy");if(document.body.removeChild(r),a)return}throw new Error("Clipboard unavailable.")}function RM(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`client-${crypto.randomUUID()}`:`client-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function Wy({title:e,subtitle:r,layout:a,roster:i}){return a.isCollapsed?null:l.jsxs("div",{style:{width:a.sidebarWidth,...a.styles.sidebar},className:"relative flex flex-col h-full border-r shrink-0 z-10 overflow-hidden",children:[l.jsx("div",{className:"absolute right-[-3px] top-0 bottom-0 w-1.5 cursor-col-resize hover:bg-indigo-400 z-20 transition-colors",onMouseDown:a.onResizeStart}),l.jsxs("div",{className:"px-4 h-14 flex items-center justify-between border-b",style:{borderBottomColor:g.border},children:[l.jsxs("div",{children:[l.jsx("h1",{className:"text-[13px] font-semibold tracking-tight",style:a.styles.inkText,children:e}),l.jsx("div",{className:"text-[10px] font-mono mt-0.5",style:a.styles.mutedText,children:r})]}),l.jsx("button",{className:"p-1.5 rounded transition-opacity hover:opacity-70",style:a.styles.mutedText,onClick:i.onRefresh,children:l.jsx(xn,{size:14})})]}),l.jsx("div",{className:"flex-1 overflow-y-auto py-3",children:l.jsxs("div",{className:"mb-3 px-2",children:[l.jsx("div",{className:"font-mono text-[9px] tracking-widest uppercase mb-1.5 px-2",style:a.styles.mutedText,children:"Roster"}),l.jsxs("div",{className:"flex items-center justify-end gap-2 px-2 mb-2 relative",children:[l.jsxs("div",{className:"relative",children:[l.jsxs("button",{className:"os-toolbar-button flex items-center gap-1 text-[10px] px-2 py-1 rounded",style:{color:g.ink},onClick:()=>i.setAgentRosterMenu(o=>o==="filter"?null:"filter"),title:"Filter roster",children:[l.jsx($N,{size:11}),l.jsx("span",{style:a.styles.mutedText,children:IS(i.agentRosterFilter)})]}),i.agentRosterMenu==="filter"?l.jsx("div",{className:"absolute right-0 top-full mt-1 w-36 rounded-lg border shadow-sm z-20",style:{backgroundColor:g.surface,borderColor:g.border},children:[["all","All Agents"],["active","Active Only"]].map(([o,u])=>l.jsx("button",{className:"w-full text-left px-3 py-2 text-[11px] transition-opacity hover:opacity-80",style:o===i.agentRosterFilter?a.styles.activeItem:a.styles.inkText,onClick:()=>{i.setAgentRosterFilter(o),i.setAgentRosterMenu(null)},children:u},o))}):null]}),l.jsxs("div",{className:"relative",children:[l.jsxs("button",{className:"os-toolbar-button flex items-center gap-1 text-[10px] px-2 py-1 rounded",style:{color:g.ink},onClick:()=>i.setAgentRosterMenu(o=>o==="sort"?null:"sort"),title:"Sort roster",children:[l.jsx(bN,{size:11}),l.jsx("span",{style:a.styles.mutedText,children:PS(i.agentRosterSort)})]}),i.agentRosterMenu==="sort"?l.jsx("div",{className:"absolute right-0 top-full mt-1 w-36 rounded-lg border shadow-sm z-20",style:{backgroundColor:g.surface,borderColor:g.border},children:[["chat","Recent Chat"],["code","Code Changes"],["session","Dev Sessions"],["alpha","A-Z"]].map(([o,u])=>l.jsx("button",{className:"w-full text-left px-3 py-2 text-[11px] transition-opacity hover:opacity-80",style:o===i.agentRosterSort?a.styles.activeItem:a.styles.inkText,onClick:()=>{i.setAgentRosterSort(o),i.setAgentRosterMenu(null)},children:u},o))}):null]})]}),l.jsx("div",{className:"flex flex-col gap-px",children:i.rosterInterAgentAgents.length>0?i.rosterInterAgentAgents.map(o=>{const u=i.selectedInterAgentId===o.id;return l.jsxs("button",{onClick:()=>i.onSelectInterAgent(o.id),className:"flex items-center gap-2 px-2 py-2 rounded text-[12px] transition-opacity w-full text-left",style:u?a.styles.activeItem:a.styles.mutedText,children:[l.jsxs("div",{className:"relative shrink-0",children:[l.jsx("div",{className:`w-6 h-6 rounded text-white flex items-center justify-center text-[9px] font-bold ${o.reachable?"":"opacity-40 grayscale"}`,style:{backgroundColor:cl(o.id)},children:o.title.charAt(0).toUpperCase()}),l.jsx("div",{className:`absolute -bottom-0.5 -right-0.5 w-1.5 h-1.5 rounded-full ${Ro(o.state)}`,style:{border:`1px solid ${g.bg}`}})]}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"font-medium truncate",style:a.styles.inkText,children:[o.title,(i.rosterAgentTitleCounts.get(o.title)??0)>1&&o.branch?l.jsx("span",{className:"font-normal ml-1 text-[10px]",style:a.styles.mutedText,children:o.branch}):null]}),l.jsx("div",{className:"text-[10px] truncate",style:a.styles.mutedText,children:US(o,i.agentRosterSort)})]}),l.jsx("span",{className:"text-[9px] font-mono px-1.5 py-0.5 rounded",style:u?a.styles.activePill:a.styles.tagBadge,children:o.threadCount})]},o.id)}):l.jsx("div",{className:"px-3 py-8 text-[12px] text-center",style:a.styles.mutedText,children:"No agents match this view yet."})})]})})]})}function MM({activeView:e,layout:r,roster:a,agents:i,logs:o,interAgent:u,sessions:d}){if(e==="agents"){const f=a.rosterInterAgentAgents.length===a.interAgentAgents.length?`${a.interAgentAgents.length} agents`:`${a.rosterInterAgentAgents.length} visible · ${a.interAgentAgents.length} total`;return l.jsxs(l.Fragment,{children:[l.jsx(Wy,{title:"Agents",subtitle:f,layout:r,roster:a}),l.jsxs("div",{className:"flex-1 flex flex-col relative min-w-0",style:r.styles.surface,children:[l.jsx("div",{className:"border-b px-4 py-3 shrink-0",style:{...r.styles.surface,borderBottomColor:g.border},children:i.selectedInterAgent?l.jsxs("div",{className:"flex items-center justify-between gap-3",children:[l.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[l.jsxs("div",{className:"relative shrink-0",children:[l.jsx("div",{className:`w-9 h-9 rounded-xl text-[13px] text-white flex items-center justify-center font-bold ${i.selectedInterAgent.reachable?"":"opacity-40 grayscale"}`,style:{backgroundColor:cl(i.selectedInterAgent.id)},children:i.selectedInterAgent.title.charAt(0).toUpperCase()}),l.jsx("div",{className:`absolute -bottom-0.5 -right-0.5 w-2.5 h-2.5 rounded-full ${Ro(i.selectedInterAgent.state)}`,style:{border:`1px solid ${g.surface}`}})]}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("div",{className:"text-[15px] font-semibold tracking-tight truncate",style:r.styles.inkText,children:i.selectedInterAgent.title}),l.jsx("span",{className:"text-[9px] font-mono uppercase px-1.5 py-0.5 rounded",style:i.selectedInterAgent.state==="working"?r.styles.activePill:r.styles.tagBadge,children:i.selectedInterAgent.statusLabel})]}),l.jsx("div",{className:"text-[11px] mt-0.5 truncate max-w-2xl",style:r.styles.mutedText,children:i.selectedInterAgent.statusDetail??i.selectedInterAgent.summary??null})]})]}),l.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[l.jsx(ho,{icon:l.jsx(Al,{size:13}),tone:i.selectedInterAgentDirectThread?"primary":"neutral",onClick:()=>i.onOpenAgentThread(i.selectedInterAgent.id,{focusComposer:!0}),children:i.selectedInterAgentChatActionLabel}),l.jsx(ho,{icon:l.jsx(b1,{size:13}),onClick:i.onPeekAgentSession,children:"Peek"}),l.jsx(ho,{icon:l.jsx($a,{size:13}),onClick:()=>i.onOpenAgentSettings(i.selectedInterAgent.id,i.selectedInterAgent.profileKind==="project"),children:i.selectedInterAgent.profileKind==="project"?"Configure":"Settings"})]})]}):l.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[l.jsx($i,{size:14,style:r.styles.mutedText}),l.jsxs("div",{className:"min-w-0",children:[l.jsx("div",{className:"text-[13px] font-semibold tracking-tight truncate",style:r.styles.inkText,children:"Agents"}),l.jsx("div",{className:"text-[10px] truncate mt-0.5",style:r.styles.mutedText,children:"Select an agent to inspect its operational snapshot and recent threads."})]})]})}),l.jsx("div",{className:"flex-1 overflow-y-auto px-4 py-4",children:i.selectedInterAgent?l.jsxs("div",{className:"flex flex-col gap-4",children:[l.jsxs("section",{className:"border rounded-xl overflow-hidden",style:{...r.styles.surface,borderColor:g.border},children:[l.jsxs("div",{className:"px-4 py-3 border-b flex items-center justify-between gap-3",style:{backgroundColor:g.surface,borderBottomColor:g.border},children:[l.jsx("div",{className:"min-w-0",children:l.jsx("div",{className:"text-[10px] font-mono tracking-widest uppercase",style:{color:g.accent},children:"Live Session"})}),l.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[i.visibleAgentSession?.commandLabel?l.jsx(ho,{icon:l.jsx(Nr,{size:13}),onClick:i.onCopyAgentSessionCommand,children:i.agentSessionCopied?"Copied":"Copy"}):null,i.visibleAgentSession&&i.visibleAgentSession.mode!=="none"?l.jsx(ho,{icon:l.jsx(da,{size:13}),onClick:i.onOpenAgentSession,children:i.visibleAgentSession.mode==="tmux"?"Open TMUX":"Open Logs"}):null]})]}),l.jsx("div",{className:"px-4 py-4 max-h-[320px] overflow-y-auto",style:{backgroundColor:g.bg},children:i.selectedInterAgentActivityMessages.length>0?l.jsx(ko,{messages:i.selectedInterAgentActivityMessages.slice(-8),showAnnotations:!1,showStatusMessages:!1,inkStyle:r.styles.inkText,mutedStyle:r.styles.mutedText,tagStyle:r.styles.tagBadge,annotStyle:r.styles.annotBadge,agentLookup:i.interAgentAgentLookup,directThreadLookup:i.relayDirectLookup,onOpenAgentProfile:i.onOpenAgentProfile,onOpenAgentChat:(p,h)=>i.onOpenAgentThread(p,{draft:h,focusComposer:!0}),onNudgeMessage:i.onNudgeMessage}):l.jsx("div",{className:"text-[11px] leading-[1.6]",style:r.styles.mutedText,children:"No messages yet. Use the broker to send this agent a task."})}),l.jsxs(ju,{open:i.agentSessionLogsExpanded,onOpenChange:i.setAgentSessionLogsExpanded,children:[l.jsx(Nu,{asChild:!0,children:l.jsx("button",{className:"w-full px-4 py-2 border-t flex items-center justify-between gap-2 text-[10px] hover:opacity-90 transition-opacity text-left",style:{borderTopColor:g.border,backgroundColor:g.bg,color:g.muted},children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(ql,{size:10,className:"transition-transform duration-150",style:{transform:i.agentSessionLogsExpanded?"rotate(90deg)":void 0}}),l.jsx("span",{className:"font-mono uppercase tracking-wider",children:"Logs"}),l.jsx("span",{className:"text-[9px] font-mono uppercase px-1.5 py-0.5 rounded",style:i.visibleAgentSession?.mode==="tmux"?r.styles.activePill:r.styles.tagBadge,children:i.agentSessionPending?"Loading":i.visibleAgentSession?.mode==="tmux"?"TMUX":i.visibleAgentSession?.mode==="logs"?"Logs":"Unavailable"}),i.visibleAgentSession?.updatedAtLabel?l.jsxs("span",{children:["Updated ",i.visibleAgentSession.updatedAtLabel]}):null]})})}),l.jsxs(wu,{children:[l.jsx("div",{style:{backgroundColor:g.termBg},children:i.agentSessionLoading&&!i.visibleAgentSession?l.jsx("div",{className:"px-4 py-8 text-[11px] font-mono",style:{color:g.termFg},children:"Loading live session…"}):i.visibleAgentSession?.body?l.jsx("pre",{ref:p=>{i.agentSessionInlineViewportRef.current=p},onScroll:i.onInlineAgentSessionScroll,className:"px-4 py-4 text-[11px] leading-[1.6] overflow-x-auto whitespace-pre-wrap break-words max-h-[400px] overflow-y-auto",style:{color:g.termFg,fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace"},children:i.visibleAgentSession.body}):l.jsx("div",{className:"px-4 py-8 text-[11px] leading-[1.65] font-mono",style:{color:g.termFg},children:i.agentSessionPending?"Checking for a live tmux pane first, then falling back to canonical runtime logs.":i.visibleAgentSession?.subtitle??"No session output available yet."})}),l.jsxs("div",{className:"px-4 h-10 border-t flex items-center justify-between gap-3 text-[10px]",style:{borderTopColor:g.border,backgroundColor:g.bg,color:g.muted},children:[l.jsx("div",{className:"truncate min-w-0 font-mono",children:i.renderLocalPathValue(i.visibleAgentSession?.pathLabel??Ka(i.selectedInterAgent.cwd??i.selectedInterAgent.projectRoot)??"No stable session path yet.",{className:"text-left underline underline-offset-2 decoration-dotted hover:opacity-80 transition-opacity"})}),i.agentSessionFeedback?l.jsx("div",{className:"shrink-0",style:r.styles.inkText,children:i.agentSessionFeedback}):null]})]})]})]}),l.jsxs("section",{className:"border rounded-xl overflow-hidden",style:{...r.styles.surface,borderColor:g.border},children:[l.jsxs("div",{className:"px-4 py-3 border-b flex items-center justify-between gap-3",style:{borderBottomColor:g.border,backgroundColor:g.surface},children:[l.jsx("div",{className:"min-w-0",children:l.jsx("div",{className:"text-[10px] font-mono tracking-widest uppercase",style:{color:g.accent},children:"Recent Activity"})}),l.jsxs("div",{className:"flex items-center gap-2 shrink-0 flex-wrap justify-end",children:[l.jsxs("span",{className:"text-[9px] font-mono uppercase px-1.5 py-0.5 rounded",style:r.styles.tagBadge,children:[i.selectedInterAgentActivityMessages.length," events"]}),i.selectedInterAgentInboundTasks.length>0?l.jsxs("span",{className:"text-[9px] font-mono uppercase px-1.5 py-0.5 rounded",style:r.styles.activePill,children:[i.selectedInterAgentInboundTasks.length," asks"]}):null,i.selectedInterAgentOutboundFindings.length>0?l.jsxs("span",{className:"text-[9px] font-mono uppercase px-1.5 py-0.5 rounded",style:{backgroundColor:"rgba(248, 113, 113, 0.14)",color:"#b91c1c"},children:[i.selectedInterAgentOutboundFindings.length," waiting"]}):null]})]}),i.selectedInterAgentFindings.length>0?l.jsx("div",{className:"px-4 py-3 border-b flex flex-col gap-2",style:{borderBottomColor:g.border,backgroundColor:g.bg},children:i.selectedInterAgentFindings.slice(0,2).map(p=>l.jsxs("div",{className:"rounded-lg border px-3 py-2",style:{borderColor:p.severity==="error"?"rgba(248, 113, 113, 0.28)":"rgba(245, 158, 11, 0.28)",backgroundColor:p.severity==="error"?"rgba(248, 113, 113, 0.08)":"rgba(245, 158, 11, 0.08)"},children:[l.jsxs("div",{className:"flex items-center justify-between gap-3",children:[l.jsx("div",{className:"text-[11px] font-medium",style:r.styles.inkText,children:p.title}),l.jsx("span",{className:"text-[9px] font-mono uppercase",style:r.styles.mutedText,children:p.ageLabel??p.updatedAtLabel??"Open"})]}),l.jsx("div",{className:"text-[11px] mt-1",style:r.styles.mutedText,children:p.summary})]},p.id))}):null,l.jsxs("div",{className:"px-4 py-4 max-h-[280px] overflow-y-auto",style:{backgroundColor:g.bg},children:[i.selectedInterAgentActivityMessages.length>0?l.jsx(ko,{messages:i.agentActivityExpanded?i.selectedInterAgentActivityMessages:i.selectedInterAgentActivityMessages.slice(-5),showAnnotations:!0,showStatusMessages:!0,inkStyle:r.styles.inkText,mutedStyle:r.styles.mutedText,tagStyle:r.styles.tagBadge,annotStyle:r.styles.annotBadge,agentLookup:i.interAgentAgentLookup,directThreadLookup:i.relayDirectLookup,onOpenAgentProfile:i.onOpenAgentProfile,onOpenAgentChat:(p,h)=>i.onOpenAgentThread(p,{draft:h,focusComposer:!0}),onNudgeMessage:i.onNudgeMessage}):l.jsx("div",{className:"text-[11px] leading-[1.6]",style:r.styles.mutedText,children:"No broker-visible activity for this agent yet."}),i.selectedInterAgentActivityMessages.length>5&&!i.agentActivityExpanded?l.jsxs("button",{className:"w-full text-center py-2 text-[11px] font-medium hover:opacity-80 transition-opacity",style:{color:g.accent},onClick:()=>i.setAgentActivityExpanded(!0),children:["Show all ",i.selectedInterAgentActivityMessages.length," events"]}):null]})]}),l.jsx(ju,{open:i.agentThreadsExpanded,onOpenChange:i.setAgentThreadsExpanded,children:l.jsxs("section",{className:"border rounded-xl overflow-hidden",style:{...r.styles.surface,borderColor:g.border},children:[l.jsx(Nu,{asChild:!0,children:l.jsx("button",{className:"w-full px-4 py-3 flex items-center justify-between gap-3 hover:opacity-90 transition-opacity text-left",style:{backgroundColor:g.surface},children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(ql,{size:12,className:"transition-transform duration-150",style:{color:g.muted,transform:i.agentThreadsExpanded?"rotate(90deg)":void 0}}),l.jsx("div",{className:"text-[10px] font-mono tracking-widest uppercase",style:{color:g.accent},children:"Open Threads"}),l.jsx("span",{className:"text-[9px] font-mono px-1.5 py-0.5 rounded",style:r.styles.tagBadge,children:i.visibleInterAgentThreads.length+1})]})})}),l.jsx(wu,{children:l.jsxs("div",{className:"px-4 py-3 border-t flex flex-col gap-3",style:{borderTopColor:g.border},children:[l.jsxs("div",{className:"border rounded-lg px-3 py-3",style:{borderColor:g.border,backgroundColor:g.bg},children:[l.jsxs("div",{className:"flex items-start justify-between gap-3",children:[l.jsxs("div",{className:"min-w-0",children:[l.jsx("div",{className:"text-[13px] font-medium truncate",style:r.styles.inkText,children:"Direct Line"}),l.jsxs("div",{className:"text-[10px] truncate mt-1",style:r.styles.mutedText,children:["You and ",i.selectedInterAgent.title]})]}),l.jsx("span",{className:"text-[10px] font-mono shrink-0",style:r.styles.mutedText,children:i.selectedInterAgentDirectThread?.timestampLabel??i.selectedInterAgent.lastChatLabel??""})]}),l.jsx("div",{className:"text-[12px] leading-[1.55] mt-3",style:r.styles.mutedText,children:i.selectedAgentDirectLinePreview}),l.jsxs("div",{className:"flex items-center justify-between gap-3 mt-3",children:[l.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[l.jsx("span",{className:"text-[9px] font-mono uppercase px-1.5 py-0.5 rounded",style:r.styles.activePill,children:"Direct"}),l.jsx("span",{className:"text-[9px] font-mono uppercase px-1.5 py-0.5 rounded",style:r.styles.tagBadge,children:i.selectedInterAgent.statusLabel})]}),l.jsx("button",{className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded shrink-0",style:{color:g.ink},onClick:()=>i.onOpenAgentThread(i.selectedInterAgent.id,{focusComposer:!0}),children:i.selectedInterAgentChatActionLabel})]})]}),i.visibleInterAgentThreads.length>0?l.jsx("div",{className:"flex flex-col gap-3",children:i.visibleInterAgentThreads.map(p=>l.jsxs("div",{className:"border rounded-lg px-3 py-3",style:{borderColor:g.border,backgroundColor:i.selectedInterAgentThreadId===p.id?g.bg:g.surface},children:[l.jsxs("div",{className:"flex items-start justify-between gap-3",children:[l.jsxs("div",{className:"min-w-0",children:[l.jsx("div",{className:"text-[13px] font-medium truncate",style:r.styles.inkText,children:ep(p,i.selectedInterAgent.id)}),l.jsx("div",{className:"text-[10px] truncate mt-1",style:r.styles.mutedText,children:tp(p,i.selectedInterAgent.id)})]}),l.jsx("span",{className:"text-[10px] font-mono shrink-0",style:r.styles.mutedText,children:p.timestampLabel??""})]}),l.jsx("div",{className:"text-[12px] leading-[1.55] mt-3",style:r.styles.mutedText,children:p.preview??"No message preview yet."}),l.jsxs("div",{className:"flex items-center justify-between gap-3 mt-3",children:[l.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[l.jsx("span",{className:"text-[9px] font-mono uppercase px-1.5 py-0.5 rounded",style:p.sourceKind==="private"?r.styles.tagBadge:r.styles.activePill,children:p.sourceKind==="private"?"Private":"Targeted"}),l.jsxs("span",{className:"text-[9px] font-mono px-1.5 py-0.5 rounded",style:r.styles.tagBadge,children:[p.messageCount," msgs"]})]}),l.jsx("button",{className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded",style:{color:g.ink},onClick:()=>i.onOpenThreadInTrafficView(p.id),children:"Open"})]})]},p.id))}):l.jsx("div",{className:"flex flex-col items-start gap-3",children:l.jsx("div",{className:"text-[11px] leading-[1.5]",style:r.styles.mutedText,children:"No other active channels for this agent yet."})})]})})]})}),l.jsx(ju,{open:i.agentSnapshotExpanded,onOpenChange:i.setAgentSnapshotExpanded,children:l.jsxs("section",{className:"border rounded-xl overflow-hidden",style:{...r.styles.surface,borderColor:g.border},children:[l.jsx(Nu,{asChild:!0,children:l.jsxs("button",{className:"w-full px-4 py-3 flex items-center gap-2 hover:opacity-90 transition-opacity text-left",style:{backgroundColor:g.surface},children:[l.jsx(ql,{size:12,className:"transition-transform duration-150",style:{color:g.muted,transform:i.agentSnapshotExpanded?"rotate(90deg)":void 0}}),l.jsx("div",{className:"text-[10px] font-mono tracking-widest uppercase",style:{color:g.accent},children:"Operational Snapshot"})]})}),l.jsx(wu,{children:l.jsx("div",{className:"px-4 py-3 border-t",style:{borderTopColor:g.border},children:l.jsx("div",{className:"grid grid-cols-2 gap-x-4 gap-y-3",children:[["Harness",i.visibleAgentConfig?.runtime.harness??i.selectedInterAgent.harness??"Not reported"],["Session",i.visibleAgentConfig?.runtime.sessionId??i.selectedInterAgent.sessionId??"Not reported"],["Transport",i.visibleAgentConfig?.runtime.transport??i.selectedInterAgent.transport??"Not reported"],["Wake Policy",i.visibleAgentConfig?.runtime.wakePolicy||i.selectedInterAgent.wakePolicy||"Not reported"],["Last Chat",i.selectedInterAgent.lastChatLabel??"Not reported"],["Last Dev Session",i.selectedInterAgent.lastSessionLabel??"Not reported"],["Last Code Change",i.selectedInterAgent.lastCodeChangeLabel??"Not reported"]].map(([p,h])=>l.jsxs("div",{className:"min-w-0",children:[l.jsx("div",{className:"text-[9px] font-mono uppercase tracking-widest mb-1",style:r.styles.mutedText,children:p}),l.jsx("div",{className:"text-[11px] leading-[1.45] break-words",style:r.styles.inkText,children:h})]},p))})})})]})})]}):l.jsxs("div",{className:"flex flex-col items-center justify-center h-64 text-center",children:[l.jsx("div",{className:"w-16 h-16 rounded-full flex items-center justify-center mb-4",style:{backgroundColor:g.accentBg},children:l.jsx($i,{size:24,style:{color:g.accent}})}),l.jsx("h3",{className:"text-[15px] font-medium mb-1",style:r.styles.inkText,children:"No agent selected"}),l.jsx("p",{className:"text-[13px] max-w-sm",style:r.styles.mutedText,children:"Pick an agent from the left rail to inspect its profile, runtime binding, and recent communication."})]})})]})]})}if(e==="logs")return l.jsxs(l.Fragment,{children:[!r.isCollapsed&&l.jsxs("div",{style:{width:r.sidebarWidth,...r.styles.sidebar},className:"relative flex flex-col h-full border-r shrink-0 z-10 overflow-hidden",children:[l.jsx("div",{className:"absolute right-[-3px] top-0 bottom-0 w-1.5 cursor-col-resize hover:bg-indigo-400 z-20 transition-colors",onMouseDown:r.onResizeStart}),l.jsx("div",{className:"px-4 h-14 flex items-center border-b",style:{borderBottomColor:g.border},children:l.jsxs("div",{children:[l.jsx("h1",{className:"text-[13px] font-semibold tracking-tight",style:r.styles.inkText,children:"Logs"}),l.jsxs("div",{className:"text-[10px] font-mono mt-0.5",style:r.styles.mutedText,children:[o.logSources.length," sources"]})]})}),l.jsx("div",{className:"px-3 py-3 border-b",style:{borderBottomColor:g.border},children:l.jsx("input",{type:"text",value:o.logSourceQuery,onChange:f=>o.setLogSourceQuery(f.target.value),placeholder:"Filter sources…",className:"w-full rounded-lg border px-3 py-2 text-[11px] bg-transparent outline-none",style:{borderColor:g.border,color:g.ink}})}),l.jsx("div",{className:"flex-1 overflow-y-auto py-3",children:o.logSources.length===0?l.jsxs("div",{className:"px-4 py-6 text-center",children:[l.jsxs("div",{className:"flex justify-center gap-1 mb-2",children:[l.jsx("span",{className:"os-thinking-dot",style:{color:g.accent}}),l.jsx("span",{className:"os-thinking-dot",style:{color:g.accent}}),l.jsx("span",{className:"os-thinking-dot",style:{color:g.accent}})]}),l.jsx("div",{className:"text-[11px]",style:r.styles.mutedText,children:"Loading sources…"})]}):["runtime","app","agents"].map(f=>{const p=o.filteredLogSources.filter(y=>y.group===f);if(p.length===0)return null;const h=f==="runtime"?"Runtime":f==="app"?"App":"Agents";return l.jsxs("div",{className:"mb-3 px-2",children:[l.jsx("div",{className:"font-mono text-[9px] tracking-widest uppercase mb-1.5 px-2",style:r.styles.mutedText,children:h}),l.jsx("div",{className:"flex flex-col gap-px",children:p.map(y=>{const b=o.selectedLogSourceId===y.id;return l.jsxs("button",{onClick:()=>{o.setSelectedLogSourceId(y.id),o.setLogSearchQuery("")},className:"w-full text-left px-2 py-2 rounded transition-opacity hover:opacity-90",style:b?r.styles.activeItem:r.styles.mutedText,children:[l.jsx("div",{className:"text-[12px] font-medium truncate",style:r.styles.inkText,children:y.title}),l.jsx("div",{className:"text-[10px] truncate mt-0.5",style:r.styles.mutedText,children:y.subtitle})]},y.id)})})]},f)})})]}),l.jsxs("div",{className:"flex-1 flex flex-col relative min-w-0",style:r.styles.surface,children:[l.jsx("div",{className:"border-b flex items-center justify-between px-4 h-14 shrink-0 gap-4",style:{...r.styles.surface,borderBottomColor:g.border},children:l.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[l.jsx(No,{size:14,style:r.styles.mutedText}),l.jsxs("div",{className:"min-w-0",children:[l.jsx("div",{className:"text-[13px] font-semibold tracking-tight truncate",style:r.styles.inkText,children:o.selectedLogSource?.title??"Logs"}),l.jsx("div",{className:"text-[10px] truncate mt-0.5",style:r.styles.mutedText,children:o.logContent?.updatedAtLabel?`${o.selectedLogSource?.subtitle??"Log tail"} · Updated ${o.logContent.updatedAtLabel}`:o.selectedLogSource?.subtitle??"Relay runtime, app, and relay agent logs."})]})]})}),l.jsxs("div",{className:"border-b px-4 py-3 flex items-center gap-3",style:{borderBottomColor:g.border},children:[l.jsx("input",{type:"text",value:o.logSearchQuery,onChange:f=>o.setLogSearchQuery(f.target.value),placeholder:"Filter visible lines…",className:"flex-1 rounded-lg border px-3 py-2 text-[11px] bg-transparent outline-none",style:{borderColor:g.border,color:g.ink}}),l.jsx("div",{className:"text-[10px] font-mono shrink-0",style:r.styles.mutedText,children:o.logContent?o.logContent.truncated?`Tail ${o.logContent.lineCount} lines`:`${o.logContent.lineCount} lines`:"No file"})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto px-4 py-4",children:[o.selectedLogSource?l.jsx(U1,{title:o.selectedLogSource.title,pathLabel:o.logContent?.pathLabel??o.selectedLogSource.pathLabel,body:o.logContent?.body??null,truncated:o.logContent?.truncated,lineCount:o.logContent?.lineCount,missing:o.logContent?.missing,loading:o.logsLoading,searchQuery:o.logSearchQuery,updatedAtLabel:o.logContent?.updatedAtLabel,minHeight:360}):l.jsx("div",{className:"flex flex-col items-center justify-center h-64 text-center",children:o.logCatalog?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"w-16 h-16 rounded-full flex items-center justify-center mb-4",style:{backgroundColor:g.accentBg},children:l.jsx(No,{size:24,style:{color:g.accent}})}),l.jsx("h3",{className:"text-[15px] font-medium mb-1",style:r.styles.inkText,children:"No log selected"}),l.jsx("p",{className:"text-[13px] max-w-sm",style:r.styles.mutedText,children:"Pick a relay runtime, app, or relay agent source from the left rail."})]}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex justify-center gap-1 mb-3",children:[l.jsx("span",{className:"os-thinking-dot",style:{color:g.accent}}),l.jsx("span",{className:"os-thinking-dot",style:{color:g.accent}}),l.jsx("span",{className:"os-thinking-dot",style:{color:g.accent}})]}),l.jsx("p",{className:"text-[13px]",style:r.styles.mutedText,children:"Loading log sources…"})]})}),o.logsFeedback?l.jsx("div",{className:"text-[11px] leading-[1.5] mt-3",style:r.styles.inkText,children:o.logsFeedback}):null]}),l.jsx("div",{className:"h-7 border-t flex items-center justify-between px-4 shrink-0",style:{backgroundColor:g.bg,borderTopColor:g.border},children:l.jsx("span",{className:"text-[9px] font-mono",style:r.styles.mutedText,children:"Canonical relay runtime, app, and relay agent log tails"})})]})]});if(e==="inter-agent"){const f=a.rosterInterAgentAgents.length===a.interAgentAgents.length?a.interAgentStateSubtitle:`${a.rosterInterAgentAgents.length} visible · ${a.interAgentStateSubtitle}`;return l.jsxs(l.Fragment,{children:[l.jsx(Wy,{title:a.interAgentStateTitle,subtitle:f,layout:r,roster:a}),l.jsxs("div",{className:"w-[336px] border-r shrink-0 overflow-hidden flex flex-col",style:{...r.styles.surface,borderRightColor:g.border},children:[l.jsxs("div",{className:"px-4 h-14 border-b flex flex-col justify-center",style:{borderBottomColor:g.border},children:[l.jsx("div",{className:"text-[10px] font-mono tracking-widest uppercase",style:r.styles.mutedText,children:"Agent Threads"}),l.jsx("div",{className:"text-[12px] mt-1",style:r.styles.inkText,children:u.selectedInterAgent?`${u.selectedInterAgent.title} · ${u.visibleInterAgentThreads.length} thread${u.visibleInterAgentThreads.length===1?"":"s"}`:"Select an agent"})]}),l.jsx("div",{className:"flex-1 overflow-y-auto",children:u.selectedInterAgent&&u.visibleInterAgentThreads.length>0?l.jsx("div",{className:"divide-y",style:{borderColor:g.border},children:u.visibleInterAgentThreads.map(p=>{const h=u.selectedInterAgentThreadId===p.id;return l.jsxs("button",{onClick:()=>u.setSelectedInterAgentThreadId(p.id),className:"w-full text-left px-4 py-3.5 transition-opacity hover:opacity-90",style:h?{backgroundColor:g.bg}:void 0,children:[l.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1.5",children:[l.jsxs("div",{className:"min-w-0",children:[l.jsx("div",{className:"text-[12px] font-medium truncate",style:r.styles.inkText,children:ep(p,u.selectedInterAgent.id)}),l.jsx("div",{className:"mt-1",children:l.jsx("span",{className:"text-[9px] font-mono uppercase px-1.5 py-0.5 rounded",style:p.sourceKind==="private"?r.styles.tagBadge:r.styles.activePill,children:p.sourceKind==="private"?"Private":"Relay"})})]}),l.jsx("span",{className:"text-[10px] font-mono shrink-0",style:r.styles.mutedText,children:p.timestampLabel??""})]}),l.jsx("div",{className:"text-[10px] mb-1.5 truncate",style:r.styles.mutedText,children:tp(p,u.selectedInterAgent.id)}),l.jsx("div",{className:"text-[12px] leading-[1.45] line-clamp-2",style:r.styles.mutedText,children:p.preview??"No message preview yet."})]},p.id)})}):l.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:l.jsxs("div",{children:[l.jsx("div",{className:"w-14 h-14 rounded-full mx-auto mb-4 flex items-center justify-center",style:{backgroundColor:g.accentBg},children:l.jsx(Ki,{size:22,style:{color:g.accent}})}),l.jsx("div",{className:"text-[14px] font-medium mb-1",style:r.styles.inkText,children:"No agent threads"}),l.jsx("div",{className:"text-[12px]",style:r.styles.mutedText,children:u.selectedInterAgent?`No inter-agent traffic for ${u.selectedInterAgent.title} yet.`:"Pick an agent to inspect its thread network."})]})})})]}),l.jsxs("div",{className:"flex-1 flex flex-col relative min-w-0",style:r.styles.surface,children:[l.jsxs("div",{className:"border-b flex items-center justify-between px-4 h-14 shrink-0 gap-4",style:{...r.styles.surface,borderBottomColor:g.border},children:[l.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[l.jsx(Ki,{size:14,style:r.styles.mutedText}),l.jsxs("div",{className:"min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[l.jsx("h2",{className:"text-[13px] font-semibold tracking-tight truncate",style:r.styles.inkText,children:u.interAgentThreadTitle}),u.selectedInterAgentThread?l.jsx("span",{className:"text-[9px] font-mono uppercase px-1.5 py-0.5 rounded shrink-0",style:u.selectedInterAgentThread.sourceKind==="private"?r.styles.tagBadge:r.styles.activePill,children:u.selectedInterAgentThread.sourceKind==="private"?"Private":"Relay"}):null,u.selectedInterAgentThread?l.jsx("span",{className:"text-[9px] font-mono px-1.5 py-0.5 rounded shrink-0",style:r.styles.tagBadge,children:u.selectedInterAgentThread.messageCount}):null]}),l.jsx("div",{className:"text-[10px] truncate mt-0.5",style:r.styles.mutedText,children:u.selectedInterAgentThreadSubtitle})]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[u.selectedRelayDirectThread?l.jsxs("button",{className:"os-toolbar-button flex items-center gap-1.5 text-[10px] font-medium px-2 py-0.5 rounded",style:{color:g.ink},onClick:()=>u.onOpenAgentProfile(u.selectedRelayDirectThread.id),children:[l.jsx($i,{size:11}),l.jsx("span",{children:"Agent"})]}):null,l.jsxs("button",{onClick:()=>u.setShowAnnotations(!u.showAnnotations),className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded",style:u.showAnnotations?{backgroundColor:g.accentBg,color:g.accent}:{color:g.ink},children:["Annotations ",l.jsx("span",{className:"font-mono uppercase",children:u.showAnnotations?"On":"Off"})]}),u.interAgentMessageTarget?l.jsx("button",{className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded",style:{color:g.ink},onClick:()=>u.openAgentDirectMessage(u.interAgentMessageTarget.id),title:`Open direct chat with ${u.interAgentMessageTarget.title}`,children:"Message"}):null,u.interAgentConfigureTarget?l.jsx("button",{className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded",style:{color:g.ink},onClick:()=>u.onOpenAgentSettings(u.interAgentConfigureTarget.id,u.interAgentConfigureTarget.profileKind==="project"),title:u.interAgentConfigureTarget.profileKind==="project"?`Configure ${u.interAgentConfigureTarget.title}`:`Open ${u.interAgentConfigureTarget.title} profile`,children:u.interAgentConfigureLabel}):null]})]}),l.jsx("div",{className:"flex-1 overflow-y-auto px-4 py-3 pb-6",children:u.selectedInterAgent?u.selectedInterAgentThread?u.visibleInterAgentMessages.length===0?l.jsxs("div",{className:"flex flex-col items-center justify-center h-64 text-center",children:[l.jsx("div",{className:"w-16 h-16 rounded-full flex items-center justify-center mb-4",style:{backgroundColor:g.accentBg},children:l.jsx(Al,{size:24,style:{color:g.accent}})}),l.jsx("h3",{className:"text-[15px] font-medium mb-1",style:r.styles.inkText,children:"Thread is quiet"}),l.jsx("p",{className:"text-[13px] max-w-sm",style:r.styles.mutedText,children:"This agent thread exists, but there are no visible messages in it yet."})]}):l.jsx("div",{className:"flex flex-col gap-1",children:l.jsx(ko,{messages:u.visibleInterAgentMessages,showAnnotations:u.showAnnotations,showStatusMessages:!1,inkStyle:r.styles.inkText,mutedStyle:r.styles.mutedText,tagStyle:r.styles.tagBadge,annotStyle:r.styles.annotBadge,agentLookup:u.interAgentAgentLookup,directThreadLookup:u.relayDirectLookup,onOpenAgentProfile:u.onOpenAgentProfile,onOpenAgentChat:u.openAgentDirectMessage,onNudgeMessage:u.onNudgeMessage})}):l.jsxs("div",{className:"flex flex-col items-center justify-center h-64 text-center",children:[l.jsx("div",{className:"w-16 h-16 rounded-full flex items-center justify-center mb-4",style:{backgroundColor:g.accentBg},children:l.jsx(Al,{size:24,style:{color:g.accent}})}),l.jsx("h3",{className:"text-[15px] font-medium mb-1",style:r.styles.inkText,children:"No thread selected"}),l.jsxs("p",{className:"text-[13px] max-w-sm",style:r.styles.mutedText,children:["Pick one of ",u.selectedInterAgent.title,"'s agent threads to read it."]})]}):l.jsxs("div",{className:"flex flex-col items-center justify-center h-64 text-center",children:[l.jsx("div",{className:"w-16 h-16 rounded-full flex items-center justify-center mb-4",style:{backgroundColor:g.accentBg},children:l.jsx(Ki,{size:24,style:{color:g.accent}})}),l.jsx("h3",{className:"text-[15px] font-medium mb-1",style:r.styles.inkText,children:"No agent selected"}),l.jsx("p",{className:"text-[13px] max-w-sm",style:r.styles.mutedText,children:"Choose an agent from the left rail to inspect their traffic with other agents."})]})}),l.jsx("div",{className:"h-7 border-t flex items-center px-4 shrink-0",style:{backgroundColor:g.bg,borderTopColor:g.border},children:l.jsx("span",{className:"text-[9px] font-mono",style:r.styles.mutedText,children:"Read-only monitor over inter-agent traffic"})})]})]})}return e!=="sessions"?null:l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex-1 flex flex-col relative min-w-0",style:r.styles.surface,children:[l.jsxs("div",{className:"h-10 border-b flex items-center justify-between px-4 shrink-0",style:{...r.styles.surface,borderBottomColor:g.border},children:[l.jsxs("div",{className:"flex items-center gap-4 min-w-0 flex-1",children:[l.jsxs("div",{className:"min-w-0 shrink-0",children:[l.jsx("div",{className:"text-[13px] font-semibold tracking-tight",style:r.styles.inkText,children:"Sessions"}),l.jsx("div",{className:"text-[10px] font-mono mt-0.5",style:r.styles.mutedText,children:d.searchQuery?`${d.filteredSessions.length} results`:`${d.stats.totalSessions} total`})]}),l.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[l.jsx(wo,{size:14,style:r.styles.mutedText}),l.jsx("input",{type:"text",placeholder:"Search sessions by title, content, tags, or agent...",value:d.searchQuery,onChange:f=>d.setSearchQuery(f.target.value),className:"flex-1 bg-transparent border-none outline-none text-[12px]",style:{color:g.ink}}),d.searchQuery?l.jsx("button",{onClick:()=>d.setSearchQuery(""),className:"hover:opacity-70",style:r.styles.mutedText,children:l.jsx(kl,{size:14})}):null]})]}),l.jsx("div",{className:"flex items-center gap-2 shrink-0",children:l.jsx("button",{className:"p-1.5 rounded transition-opacity hover:opacity-70",style:r.styles.mutedText,onClick:d.onRefresh,children:l.jsx(xn,{size:14})})})]}),l.jsx("div",{className:"flex-1 overflow-y-auto",children:d.loadingSessions?l.jsx("div",{className:"flex items-center justify-center h-64",children:l.jsxs("div",{className:"flex flex-col items-center gap-3",children:[l.jsx(un,{className:"text-[28px]",style:{color:g.accent}}),l.jsx("span",{className:"text-[13px]",style:r.styles.mutedText,children:"Loading broker workspace…"})]})}):d.filteredSessions.length===0?l.jsxs("div",{className:"flex flex-col items-center justify-center h-64 text-center",children:[l.jsx("div",{className:"w-16 h-16 rounded-full flex items-center justify-center mb-4",style:{backgroundColor:g.accentBg},children:l.jsx(da,{size:24,style:{color:g.accent}})}),l.jsx("h3",{className:"text-[15px] font-medium mb-1",style:r.styles.inkText,children:"No sessions found"}),l.jsx("p",{className:"text-[13px] max-w-sm",style:r.styles.mutedText,children:d.searchQuery?"Try adjusting your search query":"No conversations are in the broker yet."})]}):l.jsx("div",{className:"divide-y",style:{borderColor:g.border},children:d.filteredSessions.map(f=>l.jsxs("button",{onClick:()=>d.setSelectedSession(f),draggable:!0,onDragStart:()=>{d.setDraggedSessionId(f.id),d.setDraggedPhoneSection(null)},onDragEnd:()=>{d.setDraggedSessionId(null),d.setDraggedPhoneSection(null)},className:"w-full text-left px-4 py-3 transition-opacity hover:opacity-90",style:d.selectedSession?.id===f.id?{backgroundColor:g.bg}:void 0,children:[l.jsxs("div",{className:"flex items-start justify-between mb-1",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("div",{className:"w-5 h-5 rounded text-white flex items-center justify-center text-[9px] font-bold",style:{backgroundColor:cl(f.agent)},children:f.agent.charAt(0)}),l.jsx("span",{className:"text-[13px] font-medium line-clamp-1",style:r.styles.inkText,children:f.title}),d.phonePreparationState.favorites.includes(f.id)?l.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full px-1.5 py-0.5 text-[9px] font-medium",style:{backgroundColor:g.accentBg,color:g.accent},children:[l.jsx(jb,{size:9}),"Fav"]}):null,!d.phonePreparationState.favorites.includes(f.id)&&d.phonePreparationState.quickHits.includes(f.id)?l.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full px-1.5 py-0.5 text-[9px] font-medium",style:{backgroundColor:g.tagBg,color:g.ink},children:[l.jsx(L2,{size:9}),"My List"]}):null]}),l.jsx("span",{className:"text-[10px] font-mono shrink-0 ml-2",style:r.styles.mutedText,children:d.formatDate(f.lastModified)})]}),l.jsxs("div",{className:"flex items-center gap-2 mb-1.5 pl-7",children:[l.jsx("span",{className:"text-[10px] font-mono",style:r.styles.mutedText,children:f.project}),l.jsx("span",{className:"w-px h-3",style:{backgroundColor:g.border}}),l.jsxs("span",{className:"text-[10px]",style:r.styles.mutedText,children:[f.messageCount," messages"]}),f.tokens?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"w-px h-3",style:{backgroundColor:g.border}}),l.jsxs("span",{className:"text-[10px]",style:r.styles.mutedText,children:[(f.tokens/1e3).toFixed(1),"k tokens"]})]}):null]}),l.jsx("p",{className:"text-[12px] line-clamp-1 pl-7",style:r.styles.mutedText,children:f.preview}),f.tags&&f.tags.length>0?l.jsxs("div",{className:"flex items-center gap-1.5 mt-2 pl-7",children:[f.tags.slice(0,3).map(p=>l.jsx("span",{className:"text-[9px] font-mono border px-1.5 py-0.5 rounded",style:r.styles.tagBadge,children:p},p)),f.tags.length>3?l.jsxs("span",{className:"text-[9px]",style:r.styles.mutedText,children:["+",f.tags.length-3]}):null]}):null]},f.id))})}),l.jsxs("div",{className:"h-7 border-t flex items-center justify-between px-4 shrink-0",style:{backgroundColor:g.bg,borderTopColor:g.border},children:[l.jsx("span",{className:"text-[9px] font-mono",style:r.styles.mutedText,children:"Drag sessions into My List or click one for quick actions."}),l.jsx("span",{className:"text-[9px] font-mono uppercase tracking-widest",style:r.styles.mutedText,children:"Index Ready"})]})]}),l.jsxs("div",{className:"w-80 border-l shrink-0 overflow-y-auto flex flex-col",style:{...r.styles.surface,borderLeftColor:g.border},children:[l.jsx("div",{className:"px-4 py-3 border-b",style:{borderBottomColor:g.border},children:l.jsxs("div",{className:"flex items-center justify-between gap-3",children:[l.jsxs("div",{className:"min-w-0",children:[l.jsx("div",{className:"text-[10px] font-mono tracking-widest uppercase mb-1",style:r.styles.mutedText,children:"My List"}),l.jsx("div",{className:"text-[12px] font-medium",style:r.styles.inkText,children:"My List first, then browse and search."})]}),l.jsx("button",{type:"button",onClick:d.onClearPhoneQuickHits,disabled:d.phonePreparationSaving||d.phonePreparationState.quickHits.length===0,className:"rounded px-2 py-1 text-[10px] font-medium transition-opacity hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-50",style:{backgroundColor:g.bg,color:g.ink,border:`1px solid ${g.border}`},children:"Clear"})]})}),l.jsx("div",{className:"p-4 flex-1 flex flex-col gap-4",children:d.phonePreparationLoading?l.jsxs("div",{className:"flex items-center gap-2 text-[12px]",style:r.styles.mutedText,children:[l.jsx(un,{className:"text-[12px]"}),"Loading list…"]}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"rounded-lg border p-3",style:{borderColor:g.border,backgroundColor:g.bg},onDragOver:f=>f.preventDefault(),onDrop:f=>{f.preventDefault(),d.onDropIntoFavorites()},children:[l.jsxs("div",{className:"flex items-center justify-between gap-2 mb-2",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(jb,{size:12,style:{color:g.accent}}),l.jsx("div",{className:"text-[11px] font-semibold",style:r.styles.inkText,children:"Favorites"})]}),l.jsx("div",{className:"text-[10px] font-mono",style:r.styles.mutedText,children:d.favoritePhoneSessions.length})]}),d.favoritePhoneSessions.length===0?l.jsx("div",{className:"rounded border border-dashed px-3 py-4 text-[11px]",style:{borderColor:g.border,color:g.muted},children:"Drop sessions here to keep them pinned in your list."}):l.jsx("div",{className:"flex flex-col gap-2",children:d.favoritePhoneSessions.map(f=>l.jsx("div",{draggable:!0,onDragStart:()=>{d.setDraggedSessionId(f.id),d.setDraggedPhoneSection("favorites")},onDragEnd:()=>{d.setDraggedSessionId(null),d.setDraggedPhoneSection(null)},className:"rounded border px-3 py-2",style:{borderColor:g.border,backgroundColor:g.surface},children:l.jsxs("div",{className:"flex items-start justify-between gap-2",children:[l.jsxs("div",{className:"min-w-0",children:[l.jsx("div",{className:"text-[12px] font-medium line-clamp-1",style:r.styles.inkText,children:f.title}),l.jsxs("div",{className:"text-[10px] mt-1",style:r.styles.mutedText,children:[f.project," · ",d.formatDate(f.lastModified)]})]}),l.jsx("button",{type:"button",onClick:()=>d.onRemoveSessionFromPhoneSection(f.id,"favorites"),className:"text-[10px] hover:opacity-70",style:r.styles.mutedText,children:l.jsx(kl,{size:12})})]})},`favorite-${f.id}`))})]}),l.jsxs("div",{className:"rounded-lg border p-3",style:{borderColor:g.border,backgroundColor:g.bg},onDragOver:f=>f.preventDefault(),onDrop:f=>{f.preventDefault(),d.onDropIntoQuickHits()},children:[l.jsxs("div",{className:"flex items-center justify-between gap-2 mb-2",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(j1,{size:12,style:{color:g.accent}}),l.jsx("div",{className:"text-[11px] font-semibold",style:r.styles.inkText,children:"My List"})]}),l.jsx("div",{className:"text-[10px] font-mono",style:r.styles.mutedText,children:d.quickHitPhoneSessions.length})]}),d.quickHitPhoneSessions.length===0?l.jsx("div",{className:"rounded border border-dashed px-3 py-4 text-[11px]",style:{borderColor:g.border,color:g.muted},children:"Drag sessions here and order them however you want."}):l.jsx("div",{className:"flex flex-col gap-2",children:d.quickHitPhoneSessions.map((f,p)=>l.jsx("div",{draggable:!0,onDragStart:()=>{d.setDraggedSessionId(f.id),d.setDraggedPhoneSection("quickHits")},onDragEnd:()=>{d.setDraggedSessionId(null),d.setDraggedPhoneSection(null)},onDragOver:h=>h.preventDefault(),onDrop:h=>{h.preventDefault(),d.onDropIntoQuickHits(p)},className:"rounded border px-3 py-2",style:{borderColor:g.border,backgroundColor:g.surface},children:l.jsxs("div",{className:"flex items-start justify-between gap-2",children:[l.jsxs("div",{className:"min-w-0",children:[l.jsxs("div",{className:"text-[11px] font-mono mb-1",style:r.styles.mutedText,children:["#",p+1]}),l.jsx("div",{className:"text-[12px] font-medium line-clamp-1",style:r.styles.inkText,children:f.title}),l.jsxs("div",{className:"text-[10px] mt-1",style:r.styles.mutedText,children:[f.project," · ",d.formatDate(f.lastModified)]})]}),l.jsx("button",{type:"button",onClick:()=>d.onRemoveSessionFromPhoneSection(f.id,"quickHits"),className:"text-[10px] hover:opacity-70",style:r.styles.mutedText,children:l.jsx(kl,{size:12})})]})},`quick-hit-${f.id}`))})]}),d.phonePreparationFeedback?l.jsx("div",{className:"rounded border px-3 py-2 text-[11px]",style:{borderColor:g.border,backgroundColor:g.surface,color:g.ink},children:d.phonePreparationFeedback}):null,l.jsxs("div",{className:"rounded-lg border p-3",style:{borderColor:g.border,backgroundColor:g.bg},children:[l.jsx("div",{className:"text-[10px] font-mono tracking-widest uppercase mb-2",style:r.styles.mutedText,children:"Selected Session"}),d.selectedSession?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[l.jsx("div",{className:"w-8 h-8 rounded text-white flex items-center justify-center text-[12px] font-bold",style:{backgroundColor:cl(d.selectedSession.agent)},children:d.selectedSession.agent.charAt(0)}),l.jsxs("div",{className:"min-w-0",children:[l.jsx("div",{className:"text-[12px] font-medium line-clamp-1",style:r.styles.inkText,children:d.selectedSession.title}),l.jsxs("div",{className:"text-[10px]",style:r.styles.mutedText,children:[d.selectedSession.project," · ",d.selectedSession.messageCount," messages"]})]})]}),l.jsx("p",{className:"text-[11px] leading-relaxed mb-3",style:r.styles.mutedText,children:d.selectedSession.preview}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("button",{type:"button",onClick:()=>d.onAddSessionToPhoneSection(d.selectedSession.id,"favorites"),disabled:d.phonePreparationSaving||d.phonePreparationState.favorites.includes(d.selectedSession.id),className:"flex-1 rounded px-3 py-2 text-[11px] font-medium transition-opacity hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-50",style:{backgroundColor:g.accentBg,color:g.accent},children:d.phonePreparationState.favorites.includes(d.selectedSession.id)?"Pinned":"Add to Favorites"}),l.jsx("button",{type:"button",onClick:()=>d.onAddSessionToPhoneSection(d.selectedSession.id,"quickHits"),disabled:d.phonePreparationSaving||d.phonePreparationState.quickHits.includes(d.selectedSession.id)||d.phonePreparationState.favorites.includes(d.selectedSession.id),className:"flex-1 rounded px-3 py-2 text-[11px] font-medium transition-opacity hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-50",style:{backgroundColor:g.surface,color:g.ink,border:`1px solid ${g.border}`},children:d.phonePreparationState.quickHits.includes(d.selectedSession.id)||d.phonePreparationState.favorites.includes(d.selectedSession.id)?"Already Added":"Add to My List"})]})]}):l.jsx("div",{className:"text-[11px]",style:r.styles.mutedText,children:"Select a session to pin it or add it to My List."})]})]})})]})]})}const xu=[{label:"Connecting relay service"},{label:"Loading agent availability"},{label:"Loading activity history"}];function zM(e){return e===0?420:195+Math.min(e,5)*12}const OM="11rem",Jy="w-[3.25rem]";function LM({color:e}){const r="0.2 0.2 0.4 0.8;0.2 0.2 0.4 0.8";return l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 14 32 4",preserveAspectRatio:"none",className:"h-[6px] w-[3.25rem] shrink-0 overflow-visible",style:{color:e},"aria-hidden":!0,children:[l.jsx("path",{opacity:.8,fill:"currentColor",d:"M2 14 V18 H6 V14z",children:l.jsx("animateTransform",{attributeName:"transform",type:"translate",values:"0 0; 24 0; 0 0",dur:"2s",begin:"0s",repeatCount:"indefinite",keySplines:r,calcMode:"spline"})}),l.jsx("path",{opacity:.5,fill:"currentColor",d:"M0 14 V18 H8 V14z",children:l.jsx("animateTransform",{attributeName:"transform",type:"translate",values:"0 0; 24 0; 0 0",dur:"2s",begin:"0.1s",repeatCount:"indefinite",keySplines:r,calcMode:"spline"})}),l.jsx("path",{opacity:.25,fill:"currentColor",d:"M0 14 V18 H8 V14z",children:l.jsx("animateTransform",{attributeName:"transform",type:"translate",values:"0 0; 24 0; 0 0",dur:"2s",begin:"0.2s",repeatCount:"indefinite",keySplines:r,calcMode:"spline"})})]})}function e1({dark:e,C:r,s:a}){const[i,o]=z.useState(0);z.useEffect(()=>{if(i>=xu.length)return;const y=zM(i),b=setTimeout(()=>o(v=>v+1),y);return()=>clearTimeout(b)},[i]);const u=i>=xu.length,d=e?"rgba(241,245,249,0.92)":"rgba(15,23,42,0.82)",f=e?"rgba(255,255,255,0.08)":"rgba(15,23,42,0.06)",p=e?"rgba(255,255,255,0.14)":"rgba(15,23,42,0.08)",h=e?"rgba(255,255,255,0.05)":"rgba(15,23,42,0.035)";return l.jsxs("div",{className:"w-full max-w-[440px] os-fade-up",children:[l.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[l.jsx("img",{src:"/scout-icon.png",alt:"Scout",className:"w-9 h-9 rounded-lg shrink-0",style:{boxShadow:`0 2px 8px ${e?"rgba(0,0,0,0.4)":"rgba(15,23,42,0.08)"}`}}),l.jsxs("div",{className:"min-w-0",children:[l.jsx("div",{className:"text-[15px] font-semibold tracking-tight",style:a.inkText,children:"Scout"}),l.jsx("div",{className:"text-[10px] font-mono uppercase tracking-[0.18em]",style:a.mutedText,children:"Initializing"})]})]}),l.jsx("div",{className:"rounded-lg border overflow-hidden font-mono text-[11px] leading-[1.7] flex flex-col",style:{borderColor:r.border,backgroundColor:r.termBg,color:r.termFg,minHeight:OM},children:l.jsx("div",{className:"flex flex-col flex-1 px-4 py-3 min-h-0",children:l.jsx("div",{className:"space-y-2 shrink-0",children:xu.map((y,b)=>{const v=b<i,j=b===i-1&&!u;return l.jsxs("div",{className:"os-boot-line flex items-center justify-between gap-3 min-h-[1.9em] rounded-md px-2",style:{backgroundColor:v?e?"rgba(255,255,255,0.04)":"rgba(15,23,42,0.035)":"transparent",opacity:v?1:.38},children:[l.jsx("div",{className:"min-w-0 flex items-center gap-3",children:l.jsx("span",{className:"os-boot-line-text min-w-0 truncate",style:{color:r.termFg,opacity:j?1:v?.72:.45},children:y.label})}),l.jsx("div",{className:"shrink-0 min-w-[1.25rem] flex justify-end",children:v?l.jsx("span",{className:"os-boot-prompt inline-flex h-5 min-w-5 items-center justify-center rounded-full border px-1.5 text-[12px] font-semibold leading-none",style:{color:j?r.accent:d,backgroundColor:j?h:f,borderColor:j?"transparent":p,opacity:j?1:.95},"aria-hidden":!0,children:j?"…":"✓"}):null})]},y.label)})})})}),l.jsxs("div",{className:"relative mt-5 h-5",children:[l.jsxs("div",{className:"os-boot-footer-track absolute inset-x-3 top-0 bottom-0 flex items-center gap-3 min-w-0",style:{opacity:u?0:1,transform:u?"translateY(2px)":"translateY(0)",pointerEvents:u?"none":"auto"},children:[l.jsx("div",{className:`${Jy} shrink-0`,"aria-hidden":!0}),l.jsxs("span",{className:"text-[10px] font-mono tabular-nums tracking-tight leading-none",style:a.mutedText,children:[i," of ",xu.length]})]}),l.jsxs("div",{className:"os-boot-footer-track absolute inset-x-3 top-0 bottom-0 flex items-center gap-3 min-w-0",style:{opacity:u?1:0,transform:u?"translateY(0)":"translateY(-2px)",pointerEvents:u?"auto":"none"},children:[l.jsxs("div",{className:`os-boot-footer-lead ${Jy} shrink-0 flex items-center justify-center`,"aria-hidden":!0,children:[l.jsx("div",{className:"os-boot-wait-wave-wrap",children:l.jsx(LM,{color:r.accent})}),l.jsx("div",{className:"os-boot-wait-static-row",children:[.8,.5,.25].map((y,b)=>l.jsx("span",{className:"w-[3px] h-1 rounded-[1px]",style:{backgroundColor:r.accent,opacity:y}},b))})]}),l.jsx("span",{className:"text-[10px] font-mono tracking-tight leading-none truncate",style:a.mutedText,children:"Finishing up"})]})]})]})}const rt={getAppInfo:"scout:get-app-info",getServicesState:"scout:get-services-state",getHomeState:"scout:get-home-state",getMessagesWorkspaceState:"scout:get-messages-workspace-state",getRelayShellPatch:"scout:get-relay-shell-patch",getShellState:"scout:get-shell-state",refreshRelayShellPatch:"scout:refresh-relay-shell-patch",refreshShellState:"scout:refresh-shell-state",getAppSettings:"scout:get-app-settings",refreshSettingsInventory:"scout:refresh-settings-inventory",updateAppSettings:"scout:update-app-settings",retireProject:"scout:retire-project",restoreProject:"scout:restore-project",runOnboardingCommand:"scout:run-onboarding-command",skipOnboarding:"scout:skip-onboarding",restartOnboarding:"scout:restart-onboarding",getAgentConfig:"scout:get-agent-config",updateAgentConfig:"scout:update-agent-config",createAgent:"scout:create-agent",pickDirectory:"scout:pick-directory",reloadApp:"scout:reload-app",quitApp:"scout:quit-app",revealPath:"scout:reveal-path",getPhonePreparation:"scout:get-phone-preparation",updatePhonePreparation:"scout:update-phone-preparation",getPairingState:"scout:get-pairing-state",refreshPairingState:"scout:refresh-pairing-state",controlPairingService:"scout:control-pairing-service",updatePairingConfig:"scout:update-pairing-config",decidePairingApproval:"scout:decide-pairing-approval",restartAgent:"scout:restart-agent",sendRelayMessage:"scout:send-relay-message",controlBroker:"scout:control-broker",getKeepAliveState:"scout:get-keep-alive-state",acquireKeepAliveLease:"scout:acquire-keep-alive-lease",releaseKeepAliveLease:"scout:release-keep-alive-lease",getAgentSession:"scout:get-agent-session",openAgentSession:"scout:open-agent-session",toggleVoiceCapture:"scout:toggle-voice-capture",setVoiceRepliesEnabled:"scout:set-voice-replies-enabled",getLogCatalog:"scout:get-log-catalog",getBrokerInspector:"scout:get-broker-inspector",getFeedbackBundle:"scout:get-feedback-bundle",submitFeedbackReport:"scout:submit-feedback-report",readLogSource:"scout:read-log-source"};function DM(e){return{isDesktop:!0,getAppInfo:()=>e(rt.getAppInfo),getServicesState:()=>e(rt.getServicesState),getHomeState:()=>e(rt.getHomeState),getMessagesWorkspaceState:()=>e(rt.getMessagesWorkspaceState),getRelayShellPatch:()=>e(rt.getRelayShellPatch),getShellState:()=>e(rt.getShellState),refreshRelayShellPatch:()=>e(rt.refreshRelayShellPatch),refreshShellState:()=>e(rt.refreshShellState),getAppSettings:()=>e(rt.getAppSettings),refreshSettingsInventory:()=>e(rt.refreshSettingsInventory),updateAppSettings:r=>e(rt.updateAppSettings,r),retireProject:r=>e(rt.retireProject,r),restoreProject:r=>e(rt.restoreProject,r),runOnboardingCommand:r=>e(rt.runOnboardingCommand,r),skipOnboarding:()=>e(rt.skipOnboarding),restartOnboarding:()=>e(rt.restartOnboarding),getAgentConfig:r=>e(rt.getAgentConfig,r),updateAgentConfig:r=>e(rt.updateAgentConfig,r),createAgent:r=>e(rt.createAgent,r),pickDirectory:()=>e(rt.pickDirectory),reloadApp:()=>e(rt.reloadApp),quitApp:()=>e(rt.quitApp),revealPath:r=>e(rt.revealPath,r),getPhonePreparation:()=>e(rt.getPhonePreparation),updatePhonePreparation:r=>e(rt.updatePhonePreparation,r),getPairingState:()=>e(rt.getPairingState),refreshPairingState:()=>e(rt.refreshPairingState),controlPairingService:r=>e(rt.controlPairingService,r),updatePairingConfig:r=>e(rt.updatePairingConfig,r),decidePairingApproval:r=>e(rt.decidePairingApproval,r),restartAgent:r=>e(rt.restartAgent,r),sendRelayMessage:r=>e(rt.sendRelayMessage,r),controlBroker:r=>e(rt.controlBroker,r),getKeepAliveState:()=>e(rt.getKeepAliveState),acquireKeepAliveLease:r=>e(rt.acquireKeepAliveLease,r),releaseKeepAliveLease:r=>e(rt.releaseKeepAliveLease,r),getAgentSession:r=>e(rt.getAgentSession,r),openAgentSession:r=>e(rt.openAgentSession,r),toggleVoiceCapture:()=>e(rt.toggleVoiceCapture),setVoiceRepliesEnabled:r=>e(rt.setVoiceRepliesEnabled,r),getLogCatalog:()=>e(rt.getLogCatalog),getBrokerInspector:()=>e(rt.getBrokerInspector),getFeedbackBundle:()=>e(rt.getFeedbackBundle),submitFeedbackReport:r=>e(rt.submitFeedbackReport,r),readLogSource:r=>e(rt.readLogSource,r)}}const _M={"scout:get-app-info":{method:"GET",path:"/api/app"},"scout:get-services-state":{method:"GET",path:"/api/services"},"scout:get-home-state":{method:"GET",path:"/api/home"},"scout:get-messages-workspace-state":{method:"GET",path:"/api/messages-workspace"},"scout:get-relay-shell-patch":{method:"GET",path:"/api/relay-shell-patch"},"scout:get-shell-state":{method:"GET",path:"/api/shell-state"},"scout:refresh-relay-shell-patch":{method:"GET",path:"/api/relay-shell-patch/refresh"},"scout:refresh-shell-state":{method:"GET",path:"/api/shell-state/refresh"},"scout:get-app-settings":{method:"GET",path:"/api/app-settings"},"scout:refresh-settings-inventory":{method:"GET",path:"/api/app-settings/refresh"},"scout:update-app-settings":{method:"POST",path:"/api/app-settings"},"scout:retire-project":{method:"POST",path:"/api/retire-project"},"scout:restore-project":{method:"POST",path:"/api/restore-project"},"scout:run-onboarding-command":{method:"POST",path:"/api/onboarding/run"},"scout:skip-onboarding":{method:"POST",path:"/api/onboarding/skip"},"scout:restart-onboarding":{method:"POST",path:"/api/onboarding/restart"},"scout:get-agent-config":{method:"GET",path:e=>`/api/agent-config/${e[0]}`},"scout:update-agent-config":{method:"POST",path:"/api/agent-config"},"scout:create-agent":{method:"POST",path:"/api/agent/create"},"scout:pick-directory":{method:"GET",path:"/api/pick-directory"},"scout:quit-app":{method:"POST",path:"/api/quit"},"scout:reveal-path":{method:"POST",path:"/api/reveal-path"},"scout:get-phone-preparation":{method:"GET",path:"/api/phone-preparation"},"scout:update-phone-preparation":{method:"POST",path:"/api/phone-preparation"},"scout:get-pairing-state":{method:"GET",path:"/api/pairing-state"},"scout:refresh-pairing-state":{method:"GET",path:"/api/pairing-state/refresh"},"scout:control-pairing-service":{method:"POST",path:"/api/pairing/control"},"scout:update-pairing-config":{method:"POST",path:"/api/pairing/config"},"scout:restart-agent":{method:"POST",path:"/api/agent/restart"},"scout:send-relay-message":{method:"POST",path:"/api/relay/send"},"scout:control-broker":{method:"POST",path:"/api/broker/control"},"scout:get-keep-alive-state":{method:"GET",path:"/api/keep-alive"},"scout:acquire-keep-alive-lease":{method:"POST",path:"/api/keep-alive/acquire"},"scout:release-keep-alive-lease":{method:"POST",path:"/api/keep-alive/release"},"scout:get-agent-session":{method:"GET",path:e=>`/api/agent-session/${e[0]}`},"scout:open-agent-session":{method:"POST",path:e=>`/api/agent-session/${e[0]}/open`},"scout:toggle-voice-capture":{method:"POST",path:"/api/voice/toggle-capture"},"scout:set-voice-replies-enabled":{method:"POST",path:"/api/voice/replies"},"scout:get-log-catalog":{method:"GET",path:"/api/log-catalog"},"scout:get-broker-inspector":{method:"GET",path:"/api/broker-inspector"},"scout:get-feedback-bundle":{method:"GET",path:"/api/feedback-bundle"},"scout:submit-feedback-report":{method:"POST",path:"/api/feedback-report"},"scout:read-log-source":{method:"POST",path:"/api/log-source"}};function BM(){return typeof window<"u"&&window.location.origin?window.location.origin:"http://localhost:3200"}async function t1(e,r){const a=await e.text();if(!e.ok){let i=a.trim()||`HTTP ${e.status}`;if(a.length>0)try{const o=JSON.parse(a);typeof o.error=="string"&&o.error.trim()&&(i=o.detail?`${o.error}: ${o.detail}`:o.error)}catch{}throw new Error(`${r} → ${i}`)}if(!a.length)return null;try{return JSON.parse(a)}catch{throw new Error(`${r} → response is not JSON`)}}async function IM(e,...r){if(e==="scout:reload-app")return typeof window<"u"&&window.location.reload(),!0;const a=_M[e];if(!a)return console.warn(`[web-bridge] unknown channel: ${e}`),null;const i=BM(),o=typeof a.path=="function"?a.path(r):a.path,u=`${i}${o}`;if(a.method==="GET"){const p=await fetch(u);return t1(p,u)}const d=r[0]!==void 0?r[0]:{},f=await fetch(u,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(d)});return t1(f,u)}function PM(){return{...DM(IM),isDesktop:!1}}let Ym=null;function UM(){return typeof window>"u"?null:window.scoutDesktop?window.scoutDesktop:(Ym||(Ym=PM()),Ym)}function HM({activeView:e,selectedMessagesThread:r,selectedRelayKind:a,selectedRelayId:i,selectedInterAgentId:o}){return e==="messages"?r?.kind==="relay"&&a==="direct"?i:null:e==="agents"?o:null}function n1(e){return{runtime:{cwd:e.runtime.cwd,harness:e.runtime.harness,sessionId:e.runtime.sessionId,transport:e.runtime.transport},systemPrompt:e.systemPrompt,toolUse:{launchArgsText:e.toolUse.launchArgsText},capabilitiesText:e.capabilitiesText}}function FM({activeView:e,scoutDesktop:r,surfaceCaps:a,interAgentState:i,interAgentAgents:o,interAgentThreads:u,relayState:d,selectedMessagesThread:f,selectedMessagesDetailAgentId:p,selectedRelayKind:h,selectedRelayId:y,agentableProjects:b,visibleAppSettings:v,isAppSettingsEditing:j,appSettingsDirty:C,setAppSettings:E,setAppSettingsDraft:w,setActiveView:M,setSettingsSection:D,setSettingsAgentId:H,setShellState:X,setShellError:q,setRelayFeedback:L}){const[B,F]=z.useState(null),[Z,O]=z.useState(null),[P,Q]=z.useState("all"),[oe,J]=z.useState("chat"),[ee,N]=z.useState(!1),[Y,$]=z.useState(!1),[ye,T]=z.useState(!1),[_,le]=z.useState(!1),[R,pe]=z.useState(null),[xe,ce]=z.useState(null),[Re,Te]=z.useState(null),[Ne,He]=z.useState(!1),[Le,Ue]=z.useState(!1),[it,tt]=z.useState(!1),[st,ot]=z.useState(null),[bt,Ye]=z.useState(null),[Ge,We]=z.useState(!1),[we,et]=z.useState(!1),[Se,Ze]=z.useState(()=>Em(b,v)),[mt,ae]=z.useState(!1),[ge,Ce]=z.useState(null),[_e,Xe]=z.useState(null),[Ae,ue]=z.useState(!1),[Ee,V]=z.useState(null),[me,je]=z.useState(!1),[Fe,Je]=z.useState(0),[qe,St]=z.useState(!1),Yt=z.useRef(null),Vt=z.useRef(null),Pt=z.useRef(null),yt=z.useRef(!0),Wt=z.useRef(!0),se=z.useMemo(()=>[...o.filter(Ke=>P==="all"?!0:Bb(Ke))].sort((Ke,zt)=>Pb(Ke,zt,oe)),[P,oe,o]),Me=z.useMemo(()=>{const ve=new Map;for(const Ke of se)ve.set(Ke.title,(ve.get(Ke.title)??0)+1);return ve},[se]),ze=z.useMemo(()=>o.find(ve=>ve.id===B)??null,[o,B]),nt=z.useMemo(()=>u.filter(ve=>ve.participants.some(Ke=>Ke.id===B)),[u,B]),Qt=z.useMemo(()=>nt.find(ve=>ve.id===Z)??null,[Z,nt]),gn=z.useMemo(()=>ze?d?.directs.find(ve=>ve.id===ze.id)??null:null,[d,ze]),ha=gn?.preview||gn?.timestampLabel?"Open Chat":"Start Chat",Gl=gn?.preview||gn?.timestampLabel?pv(gn):ze?`${ze.title} is ready for a direct message.`:"Direct line available.",xa=z.useMemo(()=>Em(b,v),[b,v]),bn=B&&(Re??xe)?.agentId===B?Re??xe:null,Wa=!!(xe?.editable&&bn),ga=z.useCallback(ve=>{Te(Ke=>Ke&&ve(Ke)),ot(null)},[]),Un=z.useMemo(()=>Ub(Re)!==Ub(xe),[Re,xe]),$t=z.useMemo(()=>{const ve=HS(bn?.capabilitiesText??"");return ve.length>0?ve:ze?.capabilities??[]},[ze?.capabilities,bn?.capabilitiesText]),dn=Ge&&Un?"Save + Restart":"Restart Agent",Ht=z.useMemo(()=>HM({activeView:e,selectedMessagesThread:f,selectedRelayKind:h,selectedRelayId:y,selectedInterAgentId:B}),[e,B,f,y,h]),$l=!!(B&&r?.getAgentConfig&&e==="settings"&&Ge),Ml=!!(Ht&&r?.getAgentSession&&(qe||_)),Yl=_e?.agentId===p||_e?.agentId===B?_e:null,ns=Ae&&!Yl;z.useEffect(()=>{if(!i)return;const ve=i.agents,Ke=ve.filter(_n=>P==="all"?!0:Bb(_n)).sort((_n,Tr)=>Pb(_n,Tr,oe)),zt=e==="agents"||e==="inter-agent"?Ke:ve;if(!zt.length){F(null),O(null);return}const yn=zt.find(_n=>_n.threadCount>0)?.id??zt[0]?.id??null,ti=zt.some(_n=>_n.id===B)?B:yn;ti!==B&&F(ti);const vn=i.threads.filter(_n=>_n.participants.some(Tr=>Tr.id===ti)),Cr=vn.some(_n=>_n.id===Z)?Z:vn[0]?.id??null;Cr!==Z&&O(Cr)},[e,P,oe,i,B,Z]),z.useEffect(()=>{if(!B){ce(null),Te(null),ot(null),He(!1),N(!1),$(!1),T(!1);return}if(!$l){He(!1);return}const ve=r;if(!ve?.getAgentConfig){He(!1);return}let Ke=!1;return(async()=>{He(!0);try{const yn=await ve.getAgentConfig(B);if(Ke)return;ce(yn),Te(yn),ot(null),(!bt||bt!==B)&&We(!1)}catch(yn){if(Ke)return;ce(null),Te(null),ot(lt(yn)),We(!1)}finally{Ke||He(!1)}})(),()=>{Ke=!0}},[bt,r,B,$l]),z.useEffect(()=>{if(!Ht){Xe(null),V(null),je(!1),ue(!1);return}if(!Ml){ue(!1);return}const ve=r;if(!ve?.getAgentSession){ue(!1);return}let Ke=!1;return(async()=>{ue(!0);try{const yn=await ve.getAgentSession(Ht);if(Ke)return;Xe(yn),V(null)}catch(yn){if(Ke)return;Xe(null),V(lt(yn))}finally{Ke||ue(!1)}})(),()=>{Ke=!0}},[Fe,Ht,r,Ml]),z.useEffect(()=>{V(null),je(!1)},[Ht]),z.useEffect(()=>{e!=="agents"&&e!=="messages"&&St(!1)},[e]),z.useEffect(()=>{if(!qe)return;const ve=Ke=>{Ke.key==="Escape"&&St(!1)};return window.addEventListener("keydown",ve),()=>window.removeEventListener("keydown",ve)},[qe]);const Wn=z.useCallback(ve=>ve?ve.scrollHeight-ve.scrollTop-ve.clientHeight<=48:!0,[]),zl=z.useCallback(ve=>{ve&&(ve.scrollTop=ve.scrollHeight)},[]);z.useEffect(()=>{yt.current=!0,Wt.current=!0},[qe,B]),z.useEffect(()=>{if(!Ht||!Ml)return;const ve=window.setInterval(()=>{Je(Ke=>Ke+1)},qe?1600:2500);return()=>{window.clearInterval(ve)}},[Ht,qe,Ml]),z.useEffect(()=>{if(!me)return;const ve=window.setTimeout(()=>{je(!1)},1500);return()=>{window.clearTimeout(ve)}},[me]),z.useEffect(()=>{if(e!=="settings"||!bt||B!==bt||Ne)return;const ve=Yt.current;if(!ve)return;const Ke=window.requestAnimationFrame(()=>{if(ve.scrollIntoView({block:"center",behavior:"smooth"}),ve.focus(),"value"in ve&&typeof ve.value=="string"){const zt=ve.value.length;ve.setSelectionRange?.(zt,zt)}Ye(zt=>zt===bt?null:zt)});return()=>{window.cancelAnimationFrame(Ke)}},[e,bt,B,Re,Ne]),z.useEffect(()=>{e!=="agents"||!Ge||(We(!1),Ye(null))},[e,Ge]),z.useEffect(()=>{if(!Yl?.body)return;const ve=window.requestAnimationFrame(()=>{yt.current&&zl(Vt.current),qe&&Wt.current&&zl(Pt.current)});return()=>window.cancelAnimationFrame(ve)},[qe,zl,Yl?.agentId,Yl?.body,Yl?.updatedAtLabel]);const dl=z.useCallback(ve=>{F(ve),O(BS(u,ve))},[u]),Ol=z.useCallback((ve,Ke=!1)=>{dl(ve),D("agents"),H(ve),M("settings"),We(Ke),Ye(Ke?ve:null)},[dl,M,H,D]),Sr=z.useCallback(()=>{We(!1),Ye(null)},[]),Ll=z.useCallback(()=>{F(null),O(null),We(!1),Ye(null),ot(null)},[]),Ft=z.useCallback(()=>{Ze(Em(b,v)),Ce(null),et(!0)},[b,v]),ba=z.useCallback(()=>{(async()=>{try{if(!a?.canPickDirectory||!r?.pickDirectory)return;const ve=await r.pickDirectory();if(!ve)return;Ze(Ke=>({...Ke,projectPath:ve})),Ce(null)}catch(ve){Ce(lt(ve))}})()},[r,a]),ya=z.useCallback(()=>{(async()=>{if(!r?.createAgent){Ce("Electron desktop bridge is unavailable.");return}const ve=Se.projectPath.trim();if(!ve){Ce("Choose a project path first.");return}ae(!0),Ce(null);try{const Ke=await r.createAgent({projectPath:ve,agentName:Se.agentName.trim()||null,harness:Se.harness});if(X(Ke.shellState),q(null),L(`Created ${Ke.agentId}.`),F(Ke.agentId),O(null),M("agents"),et(!1),r.refreshSettingsInventory)try{const zt=await r.refreshSettingsInventory();E(zt),(!j||!C)&&w(zt)}catch{}}catch(Ke){Ce(lt(Ke))}finally{ae(!1)}})()},[C,Se,j,r,M,E,w,L,q,X]),Dl=z.useCallback(()=>{M("settings"),D("agents"),B&&H(B),We(!0),B&&Ye(B)},[B,M,H,D]),Ql=z.useCallback(()=>{Te(xe),ot(null),We(!1)},[xe]),Lo=z.useCallback(async()=>{if(!(!B||!bn||!r?.updateAgentConfig)){Ue(!0);try{const ve=await r.updateAgentConfig({agentId:B,...n1(bn)});ce(ve),Te(ve),ot("Agent settings saved."),We(!1)}catch(ve){ot(lt(ve))}finally{Ue(!1)}}},[r,B,bn]),ls=z.useCallback(async()=>{if(!(!B||!bn||!r?.restartAgent)){tt(!0);try{let ve=bn;Un&&r.updateAgentConfig&&(Ue(!0),ve=await r.updateAgentConfig({agentId:B,...n1(bn)}),ce(ve),Te(ve),Ue(!1));const Ke=await r.restartAgent({agentId:B,previousSessionId:ze?.sessionId??xe?.runtime.sessionId??null});X(Ke),q(null),ot(`${ze?.title??"Agent"} restarted.`),We(!1)}catch(ve){ot(lt(ve))}finally{Ue(!1),tt(!1)}}},[xe,Un,r,ze,B,q,X,bn]),Ja=z.useCallback(async()=>{if(!(!a?.canOpenNativeSession||!Ht||!r?.openAgentSession))try{await r.openAgentSession(Ht),V(_e?.mode==="tmux"?"Opening tmux session in Terminal.":"Opening session logs.")}catch(ve){V(lt(ve))}},[_e?.mode,Ht,r,a]),rs=z.useCallback(async()=>{if(_e?.commandLabel)try{await uk(_e.commandLabel),je(!0),V("Attach command copied.")}catch(ve){V(lt(ve))}},[_e]),Xl=z.useCallback(()=>{Je(ve=>ve+1)},[]),_l=z.useCallback(()=>{V(null),St(!0),Xl()},[Xl]),Hn=z.useCallback(()=>{St(!1)},[]),Xt=z.useCallback(ve=>{yt.current=Wn(ve.currentTarget)},[Wn]),ei=z.useCallback(ve=>{Wt.current=Wn(ve.currentTarget)},[Wn]);return{selectedInterAgentId:B,selectedInterAgentThreadId:Z,setSelectedInterAgentThreadId:O,agentRosterFilter:P,setAgentRosterFilter:Q,agentRosterSort:oe,setAgentRosterSort:J,agentThreadsExpanded:ee,setAgentThreadsExpanded:N,agentSnapshotExpanded:Y,setAgentSnapshotExpanded:$,agentActivityExpanded:ye,setAgentActivityExpanded:T,agentSessionLogsExpanded:_,setAgentSessionLogsExpanded:le,agentRosterMenu:R,setAgentRosterMenu:pe,selectedInterAgent:ze,rosterInterAgentAgents:se,rosterAgentTitleCounts:Me,visibleInterAgentThreads:nt,selectedInterAgentDirectThread:gn,selectedInterAgentThread:Qt,selectedInterAgentChatActionLabel:ha,selectedAgentDirectLinePreview:Gl,isAgentConfigEditing:Ge,visibleAgentConfig:bn,hasEditableAgentConfig:Wa,agentConfigLoading:Ne,agentConfigSaving:Le,agentConfigRestarting:it,agentConfigFeedback:st,agentCapabilitiesPreview:$t,agentRuntimePathRef:Yt,updateAgentConfigDraft:ga,agentConfigDirty:Un,agentRestartActionLabel:dn,handleSelectInterAgent:dl,handleOpenAgentSettings:Ol,deactivateAgentConfigEdit:Sr,resetAgentInspector:Ll,handleStartAgentConfigEdit:Dl,handleCancelAgentConfigEdit:Ql,handleSaveAgentConfig:Lo,handleRestartAgent:ls,isCreateAgentDialogOpen:we,setIsCreateAgentDialogOpen:et,createAgentDraft:Se,setCreateAgentDraft:Ze,createAgentDefaults:xa,createAgentSubmitting:mt,createAgentFeedback:ge,setCreateAgentFeedback:Ce,handleOpenCreateAgentDialog:Ft,handleBrowseCreateAgentProject:ba,handleCreateAgent:ya,visibleAgentSession:Yl,agentSessionPending:ns,agentSessionLoading:Ae,agentSessionFeedback:Ee,agentSessionCopied:me,isAgentSessionPeekOpen:qe,closeAgentSessionPeek:Hn,agentSessionInlineViewportRef:Vt,handleInlineAgentSessionScroll:Xt,agentSessionPeekViewportRef:Pt,handlePeekAgentSessionScroll:ei,handleOpenAgentSession:Ja,handleCopyAgentSessionCommand:rs,handlePeekAgentSession:_l,refreshAgentSession:Xl}}async function qM(e){if(typeof navigator<"u"&&navigator.clipboard?.writeText){await navigator.clipboard.writeText(e);return}if(typeof document<"u"){const r=document.createElement("textarea");r.value=e,r.setAttribute("readonly","true"),r.style.position="fixed",r.style.opacity="0",document.body.appendChild(r),r.select();const a=document.execCommand("copy");if(document.body.removeChild(r),a)return}throw new Error("Clipboard unavailable.")}function VM({activeView:e,settingsSection:r,scoutDesktop:a,surfaceCaps:i,pendingBrokerInspectorFocus:o,setPendingBrokerInspectorFocus:u,relayServiceInspectorRef:d,loadShellState:f,setShellState:p,setShellError:h,applyRestartedOnboardingSettings:y,commitPairingState:b,pairingState:v,setAppSettingsFeedback:j,setRelayFeedback:C,setPairingError:E,setPairingConfigFeedback:w}){const[M,D]=z.useState(null),[H,X]=z.useState(null),[q,L]=z.useState(null),[B,F]=z.useState(null),[Z,O]=z.useState(!1),[P,Q]=z.useState(null),[oe,J]=z.useState(!1),[ee,N]=z.useState(null),[Y,$]=z.useState(!1),[ye,T]=z.useState(null),[_,le]=z.useState(""),[R,pe]=z.useState(null),[xe,ce]=z.useState(null),[Re,Te]=z.useState(null),[Ne,He]=z.useState(!1),[Le,Ue]=z.useState(null),[it,tt]=z.useState(""),[st,ot]=z.useState(""),[bt,Ye]=z.useState(0),Ge=M?.sources??[],We=z.useMemo(()=>{const ue=st.trim().toLowerCase();return ue?Ge.filter(Ee=>Ee.title.toLowerCase().includes(ue)||Ee.subtitle.toLowerCase().includes(ue)):Ge},[st,Ge]),we=Ge.find(ue=>ue.id===H)??null,et=z.useCallback(()=>{Ye(ue=>ue+1)},[]),Se=z.useCallback(()=>{J(!0),Te(null)},[]),Ze=z.useCallback(ue=>{J(ue),ue||Te(null)},[]),mt=z.useCallback(async()=>{if(!a?.getBrokerInspector)return F(null),null;try{const ue=await a.getBrokerInspector();return F(ue),ue}catch{return F(null),null}},[a]),ae=z.useCallback(async ue=>{if(!a?.getFeedbackBundle)return T("Feedback diagnostics are unavailable in this build."),null;ue?.showSpinner&&$(!0);try{const Ee=await a.getFeedbackBundle();return N(Ee),T(null),Ee}catch(Ee){return T(lt(Ee)),null}finally{ue?.showSpinner&&$(!1)}},[a]);z.useEffect(()=>{if(e!=="logs")return;if(!a?.getLogCatalog){D(null),Ue("Logs are unavailable in the current desktop bridge. Restart the app so the latest Electron preload is loaded.");return}let ue=!1;return(async()=>{try{const V=await a.getLogCatalog();if(ue)return;D(V),X(me=>me&&V.sources.some(je=>je.id===me)?me:V.defaultSourceId??V.sources[0]?.id??null),V.sources.length===0&&Ue("No log sources available.")}catch(V){ue||Ue(lt(V))}})(),()=>{ue=!0}},[e,a]),z.useEffect(()=>{if(e!=="logs"||!H)return;if(!a?.readLogSource){L(null);return}let ue=!1;return(!q||q.sourceId!==H)&&He(!0),Ue(null),(async()=>{try{const V=await a.readLogSource({sourceId:H,tailLines:500});if(ue)return;L(V),Ue(null)}catch(V){ue||(L(null),Ue(lt(V)))}finally{ue||He(!1)}})(),()=>{ue=!0}},[e,bt,a,H]),z.useEffect(()=>{e!=="settings"||r!=="communication"||mt()},[e,bt,mt,r]),z.useEffect(()=>{if(!o||e!=="settings"||r!=="communication")return;const ue=window.setTimeout(()=>{d.current?.scrollIntoView({behavior:"smooth",block:"start"}),u(!1)},40);return()=>{window.clearTimeout(ue)}},[e,o,d,r,B]),z.useEffect(()=>{if(e!=="logs")return;const ue=window.setInterval(()=>{Ye(Ee=>Ee+1)},2500);return()=>{window.clearInterval(ue)}},[e]),z.useEffect(()=>{oe&&ae({showSpinner:!0})},[oe,ae]);const ge=z.useCallback(async ue=>{if(!(!i?.canManageBroker||!a?.controlBroker)){O(!0),Q(null);try{const Ee=await a.controlBroker(ue);p(Ee),h(null),await mt(),Q(ue==="start"?"Relay started.":ue==="stop"?"Relay stopped.":"Relay restarted.")}catch(Ee){Q(lt(Ee))}finally{O(!1)}}},[mt,a,h,p,i]),Ce=z.useCallback(()=>{(async()=>{ce("refresh"),Te(null);try{await ae({showSpinner:!0}),Te("Support details refreshed.")}finally{ce(null)}})()},[ae]),_e=z.useCallback(()=>{(async()=>{if(!ee?.text){Te("Support bundle is still loading.");return}ce("copy"),Te(null);try{await qM(ee.text),Te("Support bundle copied.")}catch(ue){Te(lt(ue))}finally{ce(null)}})()},[ee?.text]),Xe=z.useCallback(()=>{(async()=>{if(!a?.submitFeedbackReport){Te("Feedback submission is unavailable in this build.");return}const ue=_.trim();if(!ue){Te("Add a short description before submitting.");return}ce("submit"),Te(null);try{const Ee=await a.submitFeedbackReport({message:ue});pe(Ee),le(""),Te(`Feedback submitted as ${Ee.key}.`)}catch(Ee){Te(lt(Ee))}finally{ce(null)}})()},[_,a]),Ae=z.useCallback(()=>{(async()=>{const ue=[];ce("repair"),Te(null);try{if(a?.restartOnboarding){const Ee=await a.restartOnboarding();y(Ee)}else ue.push("Onboarding reset unavailable.");if(j(null),C(null),E(null),w(null),Q(null),Ue(null),i?.canManageBroker&&a?.controlBroker)try{const Ee=await a.controlBroker(B?.installed?"restart":"start");p(Ee),h(null)}catch(Ee){ue.push(`Relay: ${lt(Ee)}`)}if(a?.controlPairingService)try{const Ee=await a.controlPairingService(v?.isRunning?"restart":"start");b(Ee)}catch(Ee){ue.push(`Pairing: ${lt(Ee)}`)}try{await mt()}catch(Ee){ue.push(`Broker diagnostics: ${lt(Ee)}`)}if(a?.refreshPairingState)try{const Ee=await a.refreshPairingState();b(Ee)}catch(Ee){ue.push(`Pairing refresh: ${lt(Ee)}`)}await f(!1),await ae(),Te(ue.length>0?`Repair finished with notes: ${ue.join(" · ")}`:"Setup repaired. Onboarding was reset and local services were refreshed.")}catch(Ee){Te(lt(Ee))}finally{ce(null)}})()},[y,B?.installed,b,ae,f,v?.isRunning,mt,a,j,w,E,C,h,p,i]);return{logCatalog:M,logSources:Ge,filteredLogSources:We,selectedLogSourceId:H,setSelectedLogSourceId:X,selectedLogSource:we,logContent:q,brokerInspector:B,brokerControlPending:Z,brokerControlFeedback:P,isFeedbackDialogOpen:oe,feedbackBundle:ee,feedbackBundleLoading:Y,feedbackBundleError:ye,feedbackDraft:_,setFeedbackDraft:le,feedbackSubmission:R,feedbackActionPending:xe,feedbackActionMessage:Re,logsLoading:Ne,logsFeedback:Le,logSearchQuery:it,setLogSearchQuery:tt,logSourceQuery:st,setLogSourceQuery:ot,refreshLogs:et,refreshBrokerInspector:mt,openFeedbackDialog:Se,handleFeedbackDialogOpenChange:Ze,handleBrokerControl:ge,handleRefreshFeedbackBundle:Ce,handleCopyFeedbackBundle:_e,handleSubmitFeedbackReport:Xe,handleRepairSetup:Ae}}function GM({pairingEnabled:e,scoutDesktop:r,setRelayFeedback:a}){const[i,o]=z.useState(null),[u,d]=z.useState(!1),[f,p]=z.useState(null),[h,y]=z.useState(!1),[b,v]=z.useState(!1),[j,C]=z.useState(null),[E,w]=z.useState(null),M=z.useRef(null),D=z.useRef(0);z.useEffect(()=>{M.current=i},[i]),z.useEffect(()=>{e||(o(null),d(!1),p(null),y(!1),v(!1),C(null),w(null))},[e]);const H=z.useCallback(Z=>{o(O=>AT(O,Z)?O:Z)},[]),X=z.useCallback(async(Z,O)=>{if(!e||!Z)return null;const P=++D.current;O?.showLoading&&d(!0);try{const Q=await Z();return D.current!==P||(H(Q),p(null)),Q}catch(Q){if(D.current===P&&p(lt(Q)),O?.throwOnError)throw Q;return null}finally{O?.showLoading&&D.current===P&&d(!1)}},[H,e]);z.useEffect(()=>{if(!e||!r?.getPairingState)return;X(()=>r.getPairingState(),{showLoading:M.current===null});const Z=window.setInterval(()=>{X(()=>r.getPairingState())},5e3);return()=>{window.clearInterval(Z)}},[e,r,X]);const q=z.useCallback(async()=>e?r?.refreshPairingState?X(()=>r.refreshPairingState(),{throwOnError:!0}):X(r?.getPairingState?()=>r.getPairingState():void 0,{throwOnError:!0}):null,[e,r,X]),L=z.useCallback(async Z=>{if(r?.controlPairingService){y(!0);try{const O=await r.controlPairingService(Z);H(O),p(null),a(Z==="start"?"Pairing started.":Z==="stop"?"Pairing stopped.":"Pairing restarted.")}catch(O){p(lt(O))}finally{y(!1)}}},[H,r,a]),B=z.useCallback(async Z=>{if(r?.updatePairingConfig){v(!0),w(null);try{const O=await r.updatePairingConfig(Z);H(O),p(null),w("Pairing settings saved.")}catch(O){const P=lt(O);throw w(P),O}finally{v(!1)}}},[H,r]),F=z.useCallback(async(Z,O)=>{if(!r?.decidePairingApproval)return;const P=`${Z.sessionId}:${Z.turnId}:${Z.blockId}:${O}`;C(P);try{const Q=await r.decidePairingApproval({sessionId:Z.sessionId,turnId:Z.turnId,blockId:Z.blockId,version:Z.version,decision:O});H(Q),p(null),a(O==="approve"?"Approval sent.":"Action denied.")}catch(Q){p(lt(Q))}finally{C(Q=>Q===P?null:Q)}},[H,r,a]);return{pairingState:i,pairingLoading:u,pairingError:f,setPairingError:p,pairingControlPending:h,pairingConfigPending:b,pairingApprovalPendingId:j,pairingConfigFeedback:E,setPairingConfigFeedback:w,pendingApprovals:i?.pendingApprovals??[],commitPairingState:H,refreshPairingState:q,handlePairingControl:L,handleUpdatePairingConfig:B,handleDecidePairingApproval:F}}const l1={favorites:[],quickHits:[],preparedAt:null};function $M({activeView:e,scoutDesktop:r,sessions:a}){const[i,o]=z.useState(null),[u,d]=z.useState(!1),[f,p]=z.useState(!1),[h,y]=z.useState(null),[b,v]=z.useState(null),[j,C]=z.useState(null),E=z.useRef(null),w=z.useRef(0);z.useEffect(()=>{E.current=i},[i]),z.useEffect(()=>{if(e!=="sessions"||!r?.getPhonePreparation)return;let J=!1;return(async()=>{d(!0);try{const N=await r.getPhonePreparation();if(J)return;o(N),y(null)}catch(N){if(J)return;o(null),y(lt(N))}finally{J||d(!1)}})(),()=>{J=!0}},[e,r]);const M=i??l1,D=z.useMemo(()=>new Map(a.map(J=>[J.id,J])),[a]),H=z.useMemo(()=>[...a].sort((J,ee)=>new Date(ee.lastModified).getTime()-new Date(J.lastModified).getTime()||ee.messageCount-J.messageCount||J.title.localeCompare(ee.title)),[a]),X=z.useMemo(()=>M.favorites.map(J=>D.get(J)).filter(J=>!!J),[M.favorites,D]),q=z.useMemo(()=>M.quickHits.filter(J=>!M.favorites.includes(J)).map(J=>D.get(J)).filter(J=>!!J),[M.favorites,M.quickHits,D]),L=z.useCallback(async(J,ee)=>{if(!r?.updatePhonePreparation){y("Phone preparation is unavailable in this build.");return}const N=++w.current,Y=E.current;o(J),p(!0);try{const $=await r.updatePhonePreparation(J);if(w.current!==N)return;o($),ee?y(ee):ee===null&&y(null)}catch($){if(w.current!==N)return;o(Y),y(lt($))}finally{w.current===N&&(p(!1),v(null),C(null))}},[r]),B=z.useCallback((J,ee)=>{const N=J(E.current??l1);L(N,ee)},[L]),F=z.useCallback(()=>{const J=M.favorites.filter(N=>D.has(N)),ee=H.map(N=>N.id).filter(N=>!J.includes(N)).slice(0,8);L({favorites:J,quickHits:ee,preparedAt:Date.now()},`Prepared ${J.length+ee.length} phone picks.`)},[L,M.favorites,H,D]),Z=z.useCallback(()=>{B(J=>({...J,quickHits:[],preparedAt:Date.now()}),"Cleared My List. Favorites stayed pinned.")},[B]),O=z.useCallback((J,ee)=>{B(N=>ee==="favorites"?{favorites:N.favorites.includes(J)?N.favorites:[...N.favorites,J],quickHits:N.quickHits.filter(Y=>Y!==J),preparedAt:Date.now()}:N.favorites.includes(J)||N.quickHits.includes(J)?{...N,preparedAt:Date.now()}:{...N,quickHits:[...N.quickHits,J],preparedAt:Date.now()},ee==="favorites"?"Pinned for phone.":"Added to My List.")},[B]),P=z.useCallback((J,ee)=>{B(N=>({favorites:ee==="favorites"?N.favorites.filter(Y=>Y!==J):N.favorites,quickHits:ee==="quickHits"?N.quickHits.filter(Y=>Y!==J):N.quickHits,preparedAt:Date.now()}),ee==="favorites"?"Removed from phone favorites.":"Removed from My List.")},[B]),Q=z.useCallback(()=>{b&&O(b,"favorites")},[b,O]),oe=z.useCallback(J=>{b&&B(ee=>{if(ee.favorites.includes(b))return{...ee,preparedAt:Date.now()};const N=ee.quickHits.filter($=>$!==b),Y=typeof J=="number"?Math.max(0,Math.min(J,N.length)):N.length;return N.splice(Y,0,b),{...ee,quickHits:N,preparedAt:Date.now()}},j==="quickHits"?"Reordered My List.":"Added to My List.")},[j,b,B]);return{phonePreparationState:M,phonePreparationLoading:u,phonePreparationSaving:f,phonePreparationFeedback:h,setDraggedSessionId:v,setDraggedPhoneSection:C,favoritePhoneSessions:X,quickHitPhoneSessions:q,handlePreparePhone:F,handleClearPhoneQuickHits:Z,handleDropIntoFavorites:Q,handleDropIntoQuickHits:oe,handleRemoveSessionFromPhoneSection:P,handleAddSessionToPhoneSection:O}}function YM({activeView:e,setActiveView:r,desktopFeatures:a,styles:i,colorTheme:o,sidebarWidth:u,messagesDetailWidth:d,isCollapsed:f,onResizeStart:p,onMessagesDetailResizeStart:h,stats:y,runtime:b,shellState:v,shellError:j,plansState:C,machinesState:E,messagesState:w,interAgentState:M,interAgentAgents:D,interAgentAgentLookup:H,relayDirectLookup:X,homeAgents:q,homeActivity:L,activityRecentMessages:B,activityTasks:F,activityLeadTask:Z,activityFindings:O,activityEndpoints:P,overviewSessions:Q,inboxAlertCount:oe,pendingApprovalsCount:J,inboxFailedTaskCount:ee,inboxAwaitingYouItems:N,availableAgentNames:Y,searchQuery:$,setSearchQuery:ye,filteredSessions:T,selectedSession:_,setSelectedSession:le,isLoadingMessagesWorkspace:R,isLoadingShell:pe,showAnnotations:xe,setShowAnnotations:ce,messagesDetailOpen:Re,setMessagesDetailOpen:Te,messagesDetailTab:Ne,setMessagesDetailTab:He,formatDate:Le,onRefreshShell:Ue,openAgentProfile:it,openSessionDetail:tt,handleSelectSearchSession:st,handleToggleVoiceCapture:ot,handleSetVoiceRepliesEnabled:bt,selectMessageThread:Ye,renderLocalPathValue:Ge,selectedInterAgentActivityMessages:We,selectedInterAgentInboundTasks:we,selectedInterAgentOutboundFindings:et,selectedInterAgentFindings:Se,interAgentThreadTitle:Ze,selectedInterAgentThreadSubtitle:mt,interAgentConfigureTarget:ae,interAgentConfigureLabel:ge,interAgentMessageTarget:Ce,visibleInterAgentMessages:_e,relayVoiceState:Xe,messagesController:Ae,agentController:ue,diagnosticsController:Ee,phonePreparationController:V,overviewBootLoader:me}){const je={sidebar:i.sidebar,surface:i.surface,inkText:i.inkText,mutedText:i.mutedText,tagBadge:i.tagBadge,activePill:i.activePill},Fe=w??{title:"Messages",subtitle:R||pe?"Loading relay workspace":j??"Broker unavailable",lastUpdatedLabel:b?.updatedAtLabel??null,threads:[]};return{overviewInboxActivityViewProps:{activeView:e,overviewViewProps:{C:o,s:i,bootLoader:me,homeAgents:q,activity:L,shellError:j,onRefresh:Ue,onOpenAgent:it,colorForIdentity:cl},inbox:{isCollapsed:f,sidebarWidth:u,onResizeStart:p,styles:je,inboxAlertCount:oe,pendingApprovalsCount:J,inboxFailedTaskCount:ee,inboxAwaitingYouItems:N},activity:{isCollapsed:f,sidebarWidth:u,onResizeStart:p,styles:je,plansState:C,machinesState:E,runtime:b,activityLeadTask:Z,activityTasks:F,activityFindings:O,activityEndpoints:P,activityRecentMessages:B,interAgentAgentLookup:H,overviewSessions:Q,formatDate:Le,onRefresh:Ue,onOpenPlans:()=>r("plans"),onOpenMessages:()=>r("messages"),onOpenAgentProfile:it,onOpenSessionDetail:tt}},opsViewsProps:{activeView:e,machinesViewProps:{machinesState:E??{title:"Machines",subtitle:"Broker unavailable",totalMachines:0,onlineCount:0,degradedCount:0,offlineCount:0,lastUpdatedLabel:null,machines:[]},C:o,s:i,isCollapsed:f,sidebarWidth:u,onResizeStart:p,onOpenRelayAgent:Ae.openDirectConversation,onRefresh:Ue,identityColor:cl},plansViewProps:{plansState:C??{title:"Plans",subtitle:"No broker snapshot yet",taskCount:0,runningTaskCount:0,failedTaskCount:0,completedTaskCount:0,findingCount:0,warningCount:0,errorCount:0,planCount:0,workspaceCount:0,lastUpdatedLabel:null,tasks:[],findings:[],plans:[]},C:o,s:i,isCollapsed:f,sidebarWidth:u,onResizeStart:p,onOpenRelayAgent:Ae.openDirectConversation,onRefresh:Ue,identityColor:cl},search:{isCollapsed:f,sidebarWidth:u,onResizeStart:p,styles:{sidebar:i.sidebar,surface:i.surface,inkText:i.inkText,mutedText:i.mutedText,tagBadge:i.tagBadge,activeItem:i.activeItem,kbd:i.kbd},availableAgentNames:Y,searchQuery:$,setSearchQuery:ye,filteredSessions:T,stats:{totalSessions:y.totalSessions,totalMessages:y.totalMessages},formatDate:Le,onOpenSession:st}},agentViewsProps:{activeView:e,layout:{isCollapsed:f,sidebarWidth:u,onResizeStart:p,styles:{sidebar:i.sidebar,surface:i.surface,inkText:i.inkText,mutedText:i.mutedText,tagBadge:i.tagBadge,activePill:i.activePill,activeItem:i.activeItem,annotBadge:i.annotBadge}},roster:{interAgentStateTitle:M?.title??"Inter-Agent",interAgentStateSubtitle:M?.subtitle??"Agent-to-agent traffic",rosterInterAgentAgents:ue.rosterInterAgentAgents,interAgentAgents:D,selectedInterAgentId:ue.selectedInterAgentId,onSelectInterAgent:ue.handleSelectInterAgent,agentRosterMenu:ue.agentRosterMenu,setAgentRosterMenu:ue.setAgentRosterMenu,agentRosterFilter:ue.agentRosterFilter,setAgentRosterFilter:ue.setAgentRosterFilter,agentRosterSort:ue.agentRosterSort,setAgentRosterSort:ue.setAgentRosterSort,rosterAgentTitleCounts:ue.rosterAgentTitleCounts,onRefresh:Ue},agents:{selectedInterAgent:ue.selectedInterAgent,selectedInterAgentDirectThread:ue.selectedInterAgentDirectThread,selectedInterAgentChatActionLabel:ue.selectedInterAgentChatActionLabel,onOpenAgentThread:Ae.openDirectConversation,onPeekAgentSession:ue.handlePeekAgentSession,onOpenAgentSettings:ue.handleOpenAgentSettings,visibleAgentSession:ue.visibleAgentSession,agentSessionPending:ue.agentSessionPending,agentSessionLoading:ue.agentSessionLoading,agentSessionFeedback:ue.agentSessionFeedback,agentSessionCopied:ue.agentSessionCopied,onCopyAgentSessionCommand:()=>{ue.handleCopyAgentSessionCommand()},onOpenAgentSession:()=>{ue.handleOpenAgentSession()},agentSessionLogsExpanded:ue.agentSessionLogsExpanded,setAgentSessionLogsExpanded:ue.setAgentSessionLogsExpanded,agentSessionInlineViewportRef:ue.agentSessionInlineViewportRef,onInlineAgentSessionScroll:ue.handleInlineAgentSessionScroll,renderLocalPathValue:Ge,selectedInterAgentActivityMessages:We,interAgentAgentLookup:H,relayDirectLookup:X,onOpenAgentProfile:it,onNudgeMessage:Ae.nudgeMessage,selectedInterAgentInboundTasks:we,selectedInterAgentOutboundFindings:et,selectedInterAgentFindings:Se,agentActivityExpanded:ue.agentActivityExpanded,setAgentActivityExpanded:ue.setAgentActivityExpanded,agentThreadsExpanded:ue.agentThreadsExpanded,setAgentThreadsExpanded:ue.setAgentThreadsExpanded,visibleInterAgentThreads:ue.visibleInterAgentThreads,selectedInterAgentThreadId:ue.selectedInterAgentThreadId,onOpenThreadInTrafficView:Je=>{ue.setSelectedInterAgentThreadId(Je),r("inter-agent")},selectedAgentDirectLinePreview:ue.selectedAgentDirectLinePreview,agentSnapshotExpanded:ue.agentSnapshotExpanded,setAgentSnapshotExpanded:ue.setAgentSnapshotExpanded,visibleAgentConfig:ue.visibleAgentConfig},logs:{logSources:Ee.logSources,filteredLogSources:Ee.filteredLogSources,selectedLogSourceId:Ee.selectedLogSourceId,setSelectedLogSourceId:Ee.setSelectedLogSourceId,selectedLogSource:Ee.selectedLogSource,logCatalog:Ee.logCatalog,logContent:Ee.logContent,logsLoading:Ee.logsLoading,logsFeedback:Ee.logsFeedback,logSearchQuery:Ee.logSearchQuery,setLogSearchQuery:Ee.setLogSearchQuery,logSourceQuery:Ee.logSourceQuery,setLogSourceQuery:Ee.setLogSourceQuery},interAgent:{selectedInterAgent:ue.selectedInterAgent,visibleInterAgentThreads:ue.visibleInterAgentThreads,selectedInterAgentThreadId:ue.selectedInterAgentThreadId,setSelectedInterAgentThreadId:ue.setSelectedInterAgentThreadId,interAgentThreadTitle:Ze,selectedInterAgentThread:ue.selectedInterAgentThread,selectedInterAgentThreadSubtitle:mt,selectedRelayDirectThread:Ae.selectedDirectConversation,showAnnotations:xe,setShowAnnotations:ce,interAgentMessageTarget:Ce,openAgentDirectMessage:Ae.openAgentDirectMessage,interAgentConfigureTarget:ae,onOpenAgentSettings:ue.handleOpenAgentSettings,interAgentConfigureLabel:ge,visibleInterAgentMessages:_e,interAgentAgentLookup:H,relayDirectLookup:X,onOpenAgentProfile:it,onNudgeMessage:Ae.nudgeMessage},sessions:{searchQuery:$,setSearchQuery:ye,filteredSessions:T,stats:{totalSessions:y.totalSessions},onRefresh:Ue,loadingSessions:pe&&!v,selectedSession:_,setSelectedSession:le,phonePreparationState:V.phonePreparationState,phonePreparationLoading:V.phonePreparationLoading,phonePreparationSaving:V.phonePreparationSaving,phonePreparationFeedback:V.phonePreparationFeedback,setDraggedSessionId:V.setDraggedSessionId,setDraggedPhoneSection:V.setDraggedPhoneSection,favoritePhoneSessions:V.favoritePhoneSessions,quickHitPhoneSessions:V.quickHitPhoneSessions,formatDate:Le,onClearPhoneQuickHits:V.handleClearPhoneQuickHits,onDropIntoFavorites:V.handleDropIntoFavorites,onDropIntoQuickHits:V.handleDropIntoQuickHits,onRemoveSessionFromPhoneSection:V.handleRemoveSessionFromPhoneSection,onAddSessionToPhoneSection:V.handleAddSessionToPhoneSection}},messagesRelayViewProps:{activeView:e,layout:{sidebarWidth:u,messagesDetailWidth:d,isCollapsed:f,onResizeStart:p,onMessagesDetailResizeStart:h,styles:{sidebar:i.sidebar,surface:i.surface,inkText:i.inkText,mutedText:i.mutedText,tagBadge:i.tagBadge,annotBadge:i.annotBadge,activeItem:i.activeItem,activePill:i.activePill,kbd:i.kbd}},threading:{messagesState:Fe,messageThreads:Ae.messageThreads,selectedMessagesThread:Ae.selectedMessagesThread,onSelectMessageThread:Ye,showAnnotations:xe,setShowAnnotations:ce,onRefresh:Ue,loadingWorkspace:(R||pe)&&!w,selectedMessagesInternalThread:Ae.selectedMessagesInternalThread,selectedMessagesInternalMessages:Ae.selectedMessagesInternalMessages,selectedMessagesInternalTarget:Ae.selectedMessagesInternalTarget,selectedMessagesDetailAgentId:Ae.selectedMessagesDetailAgentId,selectedMessagesDetailAgent:Ae.selectedMessagesDetailAgent,selectedMessagesSessions:Ae.selectedMessagesSessions,selectedSession:_,setSelectedSession:le,formatDate:Le,interAgentAgents:D,interAgentAgentLookup:H,relayDirectLookup:X,openAgentProfile:it,openAgentDirectMessage:Ae.openAgentDirectMessage,onNudgeMessage:Ae.nudgeMessage,messagesDetailOpen:Re,setMessagesDetailOpen:Te,messagesDetailTab:Ne,setMessagesDetailTab:He},composer:{selectedRelayKind:Ae.selectedConversationKind,selectedRelayId:Ae.selectedConversationId,relayThreadTitle:Ae.currentConversationTitle,relayThreadSubtitle:Ae.currentConversationSubtitle,relayThreadCount:Ae.currentConversationCount,selectedRelayDirectThread:Ae.selectedDirectConversation,relayVoiceState:Xe,visibleRelayMessages:Ae.visibleConversationMessages,relayTimelineViewportRef:Ae.timelineViewportRef,onRelayTimelineScroll:Ae.handleConversationTimelineScroll,relayReplyTarget:Ae.replyTarget,setRelayReplyTarget:Ae.setReplyTarget,relayContextReferences:Ae.contextReferences,relayContextMessageIds:Ae.contextMessageIds,setRelayContextMessageIds:Ae.setContextMessageIds,relayComposerRef:Ae.composerRef,relayDraft:Ae.composerDraft,setRelayDraft:Ae.setComposerDraft,relaySending:Ae.composerSending,relayFeedback:Ae.messagesFeedback,relayComposerSelectionStart:Ae.composerSelectionStart,setRelayComposerSelectionStart:Ae.setComposerSelectionStart,mergedRelayMessages:Ae.mergedConversationMessages,relayMentionMenuOpen:Ae.mentionMenuOpen,relayMentionSuggestions:Ae.mentionSuggestions,relayMentionSelectionIndex:Ae.mentionSelectionIndex,setRelayMentionSelectionIndex:Ae.setMentionSelectionIndex,relayMentionDuplicateTitleCounts:Ae.mentionDuplicateTitleCounts,applyRelayMentionSuggestion:Ae.applyMentionSuggestion,onRelaySend:()=>{Ae.sendMessage()},onToggleVoiceCapture:ot,onSetVoiceRepliesEnabled:Je=>{bt(Je)}},agentSession:{visibleAgentSession:ue.visibleAgentSession,agentSessionPending:ue.agentSessionPending,agentSessionFeedback:ue.agentSessionFeedback,agentSessionCopied:ue.agentSessionCopied,onCopyAgentSessionCommand:()=>{ue.handleCopyAgentSessionCommand()},onOpenAgentSession:()=>{ue.handleOpenAgentSession()},onPeekAgentSession:ue.handlePeekAgentSession,onOpenAgentSettings:ue.handleOpenAgentSettings,desktopVoiceEnabled:a.voice}}}}function QM({activeView:e,setActiveView:r,settingsSection:a,setSettingsSection:i,settingsAgentId:o,setSettingsAgentId:u,settingsSections:d,activeSettingsMeta:f,desktopFeatures:p,stats:h,runtime:y,relayState:b,relayRuntimeBooting:v,relayRuntimeHealthLabel:j,reachableRelayAgentCount:C,dark:E,setDark:w,showAnnotations:M,setShowAnnotations:D,isCollapsed:H,styles:X,scoutDesktop:q,surfaceCaps:L,interAgentAgents:B,openKnowledgeBase:F,openAgentProfile:Z,openDirectConversation:O,renderOnboardingCommandShell:P,renderLocalPathValue:Q,settingsOperatorNameRef:oe,relayServiceInspectorRef:J,handleSetVoiceRepliesEnabled:ee,settingsController:N,diagnosticsController:Y,agentController:$}){const[ye,T]=z.useState(null),[_,le]=z.useState(""),[R,pe]=z.useState("all"),[xe,ce]=z.useState("grid"),Re=z.useMemo(()=>N.agentableProjects.find(Se=>Se.id===ye)??null,[ye,N.agentableProjects]),Te=Re,Ne=z.useMemo(()=>Te?B.find(Se=>Se.id===Te.id||Se.id===Te.definitionId)??null:null,[B,Te]),He=z.useMemo(()=>N.agentableProjects.map(Se=>{const Ze=B.find(ge=>ge.id===Se.id||ge.id===Se.definitionId)??null,mt=!!Ze||Se.registrationKind==="configured",ae=Se.harnesses[0]?.harness??Se.defaultHarness;return{project:Se,linkedAgent:Ze,isBound:mt,primaryHarness:ae,pathLabel:Ka(Se.root)??Se.root,branchLabel:"local",activityLabel:Ze?.timestampLabel??"Workspace",statusLabel:mt?"Bound":Se.registrationKind==="configured"?"Ready":"Discovered"}}),[B,N.agentableProjects]),Le=z.useMemo(()=>{const Se=_.trim().toLowerCase();return He.filter(({project:Ze,isBound:mt,primaryHarness:ae})=>(R==="all"?!0:R==="bound"?mt:!mt)?Se?[Ze.title,Ze.projectName,Ze.root,Ze.relativePath,ae].some(Ce=>Ce.toLowerCase().includes(Se)):!0:!1)},[R,He,_]),Ue=z.useMemo(()=>He.filter(Se=>Se.isBound).length,[He]),it=z.useMemo(()=>He.filter(Se=>!Se.isBound).length,[He]),tt=z.useMemo(()=>o?B.find(Se=>Se.id===o)??null:null,[B,o]),st=$.selectedInterAgent?.id===o,ot=st?$.selectedInterAgent:tt,bt=z.useCallback(Se=>{i(Se),u(null)},[u,i]);z.useEffect(()=>{ye&&(N.agentableProjects.some(Se=>Se.id===ye)||T(null))},[ye,N.agentableProjects]);const Ye=z.useCallback(Se=>{T(Se.id),$.resetAgentInspector()},[$]),Ge=z.useCallback(Se=>{if(Se.registrationKind==="configured"){Z(Se.id);return}Ye(Se)},[Ye,Z]),We=z.useCallback(()=>{r("settings"),i("profile"),N.handleBeginGeneralEdit(),N.setAppSettingsFeedback("Add a scan folder below, then go back to Workspaces and refresh to discover workspaces.")},[r,i,N]),we=z.useCallback(Se=>{N.handleRetireProject(Se.root,Se.title).then(Ze=>{!Ze||Re?.root!==Se.root||(T(null),$.resetAgentInspector())})},[$,Re?.root,N]),et=a==="profile"?l.jsxs(l.Fragment,{children:[N.isAppSettingsEditing?l.jsxs(l.Fragment,{children:[l.jsx("button",{className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded disabled:opacity-50",style:{color:g.ink},onClick:()=>N.handleCancelAppSettingsEdit(),disabled:N.appSettingsSaving,children:"Cancel"}),l.jsx("button",{className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded disabled:opacity-50",style:{color:g.ink},onClick:()=>{N.handleSaveAppSettings()},disabled:!N.appSettingsDirty||N.appSettingsSaving||N.appSettingsLoading,children:N.appSettingsSaving?"Saving…":"Save General"})]}):l.jsx("button",{className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded disabled:opacity-50",style:{color:g.ink},onClick:()=>N.handleStartAppSettingsEdit(),disabled:N.appSettingsLoading||!N.visibleAppSettings,children:"Edit General"}),l.jsxs("button",{className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded disabled:opacity-50",style:{color:g.ink},onClick:N.handleRestartOnboarding,disabled:N.appSettingsLoading||!N.visibleAppSettings,children:[l.jsx(xn,{size:12}),"Restart onboarding"]})]}):a==="communication"?N.isAppSettingsEditing?l.jsxs(l.Fragment,{children:[l.jsx("button",{className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded disabled:opacity-50",style:{color:g.ink},onClick:()=>N.handleCancelAppSettingsEdit(),disabled:N.appSettingsSaving,children:"Cancel"}),l.jsx("button",{className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded disabled:opacity-50",style:{color:g.ink},onClick:()=>{N.handleSaveAppSettings()},disabled:!N.appSettingsDirty||N.appSettingsSaving||N.appSettingsLoading,children:N.appSettingsSaving?"Saving…":p.telegram?"Save Telegram":"Save Communication"})]}):l.jsx("button",{className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded disabled:opacity-50",style:{color:g.ink},onClick:()=>N.handleStartAppSettingsEdit(),disabled:N.appSettingsLoading||!N.visibleAppSettings,children:p.telegram?"Edit Telegram":"Edit Communication"}):a==="agents"?l.jsxs(l.Fragment,{children:[l.jsx("button",{className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded",style:{color:g.ink},onClick:()=>r("agents"),children:"Open Agents"}),ot&&st&&$.hasEditableAgentConfig?$.isAgentConfigEditing?l.jsxs(l.Fragment,{children:[l.jsx("button",{className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded disabled:opacity-50",style:{color:g.ink},onClick:()=>$.handleCancelAgentConfigEdit(),disabled:$.agentConfigSaving||$.agentConfigRestarting,children:"Cancel"}),l.jsx("button",{className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded disabled:opacity-50",style:{color:g.ink},onClick:()=>{$.handleSaveAgentConfig()},disabled:!$.agentConfigDirty||$.agentConfigLoading||$.agentConfigSaving||$.agentConfigRestarting,children:$.agentConfigSaving?"Saving…":"Save Changes"})]}):l.jsx("button",{className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded disabled:opacity-50",style:{color:g.ink},onClick:()=>$.handleStartAgentConfigEdit(),disabled:!o||$.agentConfigLoading||$.agentConfigRestarting,children:"Edit Agent"}):null,ot&&st&&$.hasEditableAgentConfig?l.jsx("button",{className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded disabled:opacity-50",style:{color:g.ink},onClick:()=>{$.handleRestartAgent()},disabled:$.agentConfigLoading||$.agentConfigRestarting||!$.visibleAgentConfig,children:$.agentConfigRestarting?"Restarting…":$.agentRestartActionLabel}):null]}):a==="database"?l.jsx("button",{className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded",style:{color:g.ink},onClick:()=>r("sessions"),children:"Browse Sessions"}):null;return{activeView:e,help:{styles:X,buildOnboardingCommandLine:N.buildOnboardingCommandLine,onboardingCopiedCommand:N.onboardingCopiedCommand,onboardingCommandPending:N.onboardingCommandPending,onCopyOnboardingCommand:N.handleCopyOnboardingCommand,onRunOnboardingCommand:N.handleRunOnboardingCommand,onOpenGeneralSettings:()=>{r("settings"),i("profile")}},settings:{styles:X,settingsSection:a,settingsSections:d,activeSettingsMeta:f,onSetSettingsSection:bt,onOpenFeedbackDialog:Y.openFeedbackDialog,headerActions:et,profile:{styles:X,visibleAppSettings:N.visibleAppSettings,appSettings:N.appSettings,isAppSettingsEditing:N.isAppSettingsEditing,appSettingsSaving:N.appSettingsSaving,appSettingsLoading:N.appSettingsLoading,appSettingsDirty:N.appSettingsDirty,appSettingsFeedback:N.appSettingsFeedback,settingsOperatorNameRef:oe,onboardingWizardStep:N.onboardingWizardStep,setOnboardingWizardStep:N.setOnboardingWizardStep,activeOnboardingStepIndex:N.onboardingWizardIndex,activeOnboardingStep:N.activeOnboardingStep,onboardingWizardSteps:N.onboardingWizardSteps,sourceRootPathSuggestions:N.SOURCE_ROOT_PATH_SUGGESTIONS,onboardingRuntimeMatch:N.onboardingRuntimeMatch,onboardingHasProjectConfig:N.onboardingHasProjectConfig,onboardingCopiedCommand:N.onboardingCopiedCommand,onboardingCommandPending:N.onboardingCommandPending,onboardingCommandResult:N.onboardingCommandResult,canGoToPreviousOnboardingStep:N.canGoToPreviousOnboardingStep,canGoToNextOnboardingStep:N.canGoToNextOnboardingStep,moveOnboardingWizard:N.moveOnboardingWizard,handleOnboardingContinue:N.handleOnboardingContinue,handleRestartOnboarding:N.handleRestartOnboarding,handleStartAppSettingsEdit:N.handleStartAppSettingsEdit,handleBeginGeneralEdit:N.handleBeginGeneralEdit,handleSetSourceRootAt:N.handleSetSourceRootAt,handleBrowseForSourceRoot:N.handleBrowseForSourceRoot,handleRemoveSourceRootRow:N.handleRemoveSourceRootRow,handleAddSourceRootRow:N.handleAddSourceRootRow,handleAddSourceRootSuggestion:N.handleAddSourceRootSuggestion,handleSetOnboardingContextRoot:N.handleSetOnboardingContextRoot,handleBrowseForOnboardingContextRoot:N.handleBrowseForOnboardingContextRoot,setAppSettingsDraft:N.setAppSettingsDraft,setAppSettingsFeedback:N.setAppSettingsFeedback,buildOnboardingCommandLine:N.buildOnboardingCommandLine,handleCopyOnboardingCommand:N.handleCopyOnboardingCommand,handleRunOnboardingCommand:N.handleRunOnboardingCommand,renderOnboardingCommandShell:P,renderLocalPathValue:Q,openKnowledgeBase:F},agentSettingsViewProps:{styles:X,selectedInterAgent:ot,availableAgents:$.rosterInterAgentAgents,isAgentConfigEditing:st?$.isAgentConfigEditing:!1,hasEditableAgentConfig:st?$.hasEditableAgentConfig:!1,agentConfigLoading:o?!st||$.agentConfigLoading:!1,agentConfigSaving:st?$.agentConfigSaving:!1,agentConfigRestarting:st?$.agentConfigRestarting:!1,visibleAgentConfig:st?$.visibleAgentConfig:null,agentConfigFeedback:st?$.agentConfigFeedback:null,agentCapabilitiesPreview:st?$.agentCapabilitiesPreview:[],agentRuntimePathRef:$.agentRuntimePathRef,onOpenAgents:()=>r("agents"),onOpenAgentProfile:Z,onOpenAgentThread:Se=>O(Se,{focusComposer:!0}),onUpdateAgentConfigDraft:$.updateAgentConfigDraft,renderLocalPathValue:Q,interAgentProfileKindLabel:mv,onSelectAgent:Se=>{u(Se),$.handleSelectInterAgent(Se)}},workspaceExplorerViewProps:{styles:X,selectedWorkspaceProject:Te,selectedWorkspaceAgent:Ne,workspaceExplorerQuery:_,setWorkspaceExplorerQuery:le,workspaceExplorerFilter:R,setWorkspaceExplorerFilter:pe,workspaceExplorerViewMode:xe,setWorkspaceExplorerViewMode:ce,workspaceExplorerItems:He,workspaceExplorerBoundCount:Ue,workspaceExplorerDiscoveredCount:it,filteredWorkspaceExplorerItems:Le,workspaceInventoryLoaded:N.workspaceInventoryLoaded,workspaceInventoryLoading:N.workspaceInventoryLoading,canRefreshWorkspaceInventory:N.canRefreshWorkspaceInventory,onboardingCommandPending:N.onboardingCommandPending,appSettingsLoading:N.appSettingsLoading,appSettingsSaving:N.appSettingsSaving,appSettingsDirty:N.appSettingsDirty,appSettingsFeedback:N.appSettingsFeedback,showDoctorOutput:N.showDoctorOutput,doctorOutput:P("doctor",N.buildOnboardingCommandLine("doctor"),N.onboardingCommandPending==="doctor"),projectRetirementPendingRoot:N.projectRetirementPendingRoot,onRefreshWorkspaceDiscovery:()=>{N.handleRunOnboardingCommand("doctor")},onLoadWorkspaceInventory:N.handleLoadWorkspaceInventory,onAddWorkspace:We,onInspectWorkspace:Ye,onOpenWorkspace:Ge,onRetireWorkspace:we,onOpenAgentProfile:Z,onOpenAgentSettings:Se=>$.handleOpenAgentSettings(Se,!0),renderLocalPathValue:Q},communicationSettingsViewProps:{styles:X,showTelegram:p.telegram,showVoice:p.voice,visibleAppSettings:N.visibleAppSettings,isAppSettingsEditing:N.isAppSettingsEditing,appSettingsSaving:N.appSettingsSaving,appSettingsFeedback:N.appSettingsFeedback,onUpdateAppSettingsDraft:N.updateAppSettingsDraft,brokerInspector:Y.brokerInspector,brokerControlPending:Y.brokerControlPending,brokerControlFeedback:Y.brokerControlFeedback,onBrokerControl:Se=>{Y.handleBrokerControl(Se)},relayServiceInspectorRef:J,relayRuntimeBooting:v,relayRuntimeHealthLabel:j,runtime:y,reachableRelayAgentCount:C,voiceCaptureTitle:b?.voice.captureTitle??"Not reported",voiceRepliesEnabled:b?.voice.repliesEnabled??!1,onSetVoiceRepliesEnabled:Se=>{ee(Se)},renderLocalPathValue:Q},database:{styles:X,stats:h,runtime:y,visibleAppSettings:N.visibleAppSettings,renderLocalPathValue:Q,onRevealPath:Se=>{L?.canRevealPath&&q?.revealPath?.(Se)}},appearance:{styles:X,dark:E,setDark:w,showAnnotations:M,setShowAnnotations:D,isCollapsed:H,activeSettingsLabel:f.label}}}}const XM=["~/dev","~/src","~/code"],xo=["welcome","source-roots","harness","confirm","setup","doctor","runtimes"];function KM({activeView:e,settingsSection:r,scoutDesktop:a,shellState:i,surfaceCaps:o,completeOnboardingIntoRelay:u,loadShellState:d}){const[f,p]=z.useState(null),[h,y]=z.useState(null),[b,v]=z.useState(!1),[j,C]=z.useState(!1),[E,w]=z.useState(!1),[M,D]=z.useState(null),[H,X]=z.useState(!1),[q,L]=z.useState(null),[B,F]=z.useState("welcome"),[Z,O]=z.useState(null),[P,Q]=z.useState(null),[oe,J]=z.useState({}),[ee,N]=z.useState(null),[Y,$]=z.useState("checking"),ye=H?h??f:f,T=ye?.projectInventory??[],_=ye?.hiddenProjects??[],le=z.useMemo(()=>Hb(h)!==Hb(f),[h,f]),R=!!ye?.workspaceInventoryLoaded,pe=!!(f&&a?.refreshSettingsInventory),xe=!!(Z==="doctor"||oe.doctor||P?.command==="doctor"),ce=ye?.onboardingContextRoot??ye?.workspaceRoots?.[0]??null,Re=!!ye?.currentProjectConfigPath,Te=(ye?.runtimeCatalog??[]).find(se=>se.name===ye?.defaultHarness)??null,Ne=z.useMemo(()=>new Map((ye?.onboarding.steps??[]).map(se=>[se.id,se.complete])),[ye?.onboarding.steps]),He=z.useMemo(()=>[{id:"welcome",number:"01",title:"Say hi",detail:"Tell Scout what to call you before the rest of setup begins.",complete:Ne.get("welcome")??!1},{id:"source-roots",number:"02",title:"Choose folders to scan",detail:"Pick the parent folders Scout should scan for repos, then choose where this Scout context should live.",complete:Ne.get("source-roots")??!1},{id:"harness",number:"03",title:"Choose a default harness",detail:"This is the assistant family Scout should prefer when a project does not pin one of its own.",complete:Ne.get("harness")??!1},{id:"confirm",number:"04",title:"Confirm this context",detail:"Review which folders Scout will scan and where it will save this context before moving into the command steps.",complete:Ne.get("confirm")??!1},{id:"setup",number:"05",title:"Run setup",detail:"See how Scout writes `.openscout/project.json` at your chosen context root and uses it as this context anchor.",complete:Ne.get("setup")??!1},{id:"doctor",number:"06",title:"Run doctor",detail:"See how Scout combines broker health, scanned folders, and context manifests into one inventory view.",complete:Ne.get("doctor")??!1},{id:"runtimes",number:"07",title:"Run runtimes",detail:"Check whether Claude or Codex is installed, signed in, and ready for broker-owned sessions.",complete:Ne.get("runtimes")??!1}],[Ne]),Le=Math.max(0,xo.indexOf(B)),Ue=He[Le]??He[0],it=Le>0,tt=Le<He.length-1,st=Y==="active"&&!!ye?.onboarding,ot=Y!=="done",bt=z.useCallback((se,Me)=>se?{...Me,operatorName:se.operatorName,onboardingContextRoot:se.onboardingContextRoot,workspaceRoots:se.workspaceRoots,includeCurrentRepo:se.includeCurrentRepo,defaultHarness:se.defaultHarness,defaultTransport:se.defaultTransport,defaultCapabilities:se.defaultCapabilities,sessionPrefix:se.sessionPrefix,telegram:se.telegram}:Me,[]),Ye=z.useCallback(se=>{p(se),y(se),se.workspaceInventoryLoaded&&C(!1)},[]),Ge=z.useCallback(se=>{p(se),y(Me=>H?Me:se),se.workspaceInventoryLoaded&&C(!1)},[H]),We=z.useCallback(se=>{p(se),y(Me=>H?bt(Me,se):se),se.workspaceInventoryLoaded&&C(!1)},[H,bt]),we=z.useCallback(se=>{Ye(se),F("welcome"),Q(null),N(null),X(!0),$("active")},[Ye]),et=z.useCallback(se=>{const Me=ce?` --context-root ${ce}`:"",ze=se==="setup"?(ye?.workspaceRoots??[]).map(nt=>` --source-root ${nt}`).join(""):"";return`scout ${se}${Me}${ze}`},[ce,ye?.workspaceRoots]),Se=z.useCallback(async se=>{if(!a?.getAppSettings)return null;const Me=se?.preferInventory&&a.refreshSettingsInventory?await a.refreshSettingsInventory():await a.getAppSettings();return Ge(Me),Me},[a,Ge]);z.useEffect(()=>{if(!(e==="settings"||e==="help"||Y==="active")||!a?.getAppSettings)return;let Me=!1;return(async()=>{v(!0);try{const nt=await a.getAppSettings();if(Me)return;Ye(nt),Y==="active"&&nt.onboarding.needed?(D(null),X(!0),F(Qt=>Qt||"welcome")):(D(null),X(!1)),Y==="active"&&!nt.onboarding.needed&&(u(i),$("done"))}catch(nt){if(Me)return;p(null),y(null),D(lt(nt)),X(!1),Y!=="done"&&$("done")}finally{Me||v(!1)}})(),()=>{Me=!0}},[e,u,Ye,a,i,Y]),z.useEffect(()=>{let se=!1;return a?.getAppSettings?((async()=>{try{const ze=await a.getAppSettings();if(se)return;p(nt=>nt??ze),y(nt=>nt??ze),ze.onboarding.needed?(D(null),X(!0),F("welcome"),$("active")):$("done")}catch{se||$("done")}})(),()=>{se=!0}):($("done"),()=>{se=!0})},[a]),z.useEffect(()=>{if(e!=="settings"||r!=="workspaces"||!a?.refreshSettingsInventory||!f||f.workspaceInventoryLoaded||j)return;let se=!1;return(async()=>{C(!0);try{const ze=await a.refreshSettingsInventory();se||We(ze)}catch(ze){se||D(lt(ze))}finally{se||C(!1)}})(),()=>{se=!0}},[e,f,We,a,r,j]);const Ze=z.useCallback(()=>{y(f),D(null),X(!0),f?.onboarding.needed&&F("welcome")},[f]),mt=z.useCallback(()=>{y(f),D(null),X(!1)},[f]),ae=z.useCallback(se=>{y(Me=>Me&&se(Me)),D(null)},[]),ge=z.useCallback(async()=>{if(!h||!a?.updateAppSettings)return!1;w(!0);try{const se=await a.updateAppSettings({operatorName:h.operatorName,onboardingContextRoot:h.onboardingContextRoot,workspaceRootsText:h.workspaceRoots.join(`
|
|
86
|
+
`))}function p(j,C,E,w){const M=E.enter("tableCell"),D=E.enter("phrasing"),H=E.containerPhrasing(j,{...w,before:u,after:u});return D(),M(),H}function h(j,C){return ZE(j,{align:C,alignDelimiters:i,padding:a,stringLength:o})}function y(j,C,E){const w=j.children;let M=-1;const D=[],H=C.enter("table");for(;++M<w.length;)D[M]=b(w[M],C,E);return H(),D}function b(j,C,E){const w=j.children;let M=-1;const D=[],H=C.enter("tableRow");for(;++M<w.length;)D[M]=p(w[M],j,C,E);return H(),D}function v(j,C,E){let w=ek.inlineCode(j,C,E);return E.stack.includes("tableCell")&&(w=w.replace(/\|/g,"\\$&")),w}}function IR(){return{exit:{taskListCheckValueChecked:$y,taskListCheckValueUnchecked:$y,paragraph:UR}}}function PR(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:HR}}}function $y(e){const r=this.stack[this.stack.length-2];r.type,r.checked=e.type==="taskListCheckValueChecked"}function UR(e){const r=this.stack[this.stack.length-2];if(r&&r.type==="listItem"&&typeof r.checked=="boolean"){const a=this.stack[this.stack.length-1];a.type;const i=a.children[0];if(i&&i.type==="text"){const o=r.children;let u=-1,d;for(;++u<o.length;){const f=o[u];if(f.type==="paragraph"){d=f;break}}d===a&&(i.value=i.value.slice(1),i.value.length===0?a.children.shift():a.position&&i.position&&typeof i.position.start.offset=="number"&&(i.position.start.column++,i.position.start.offset++,a.position.start=Object.assign({},i.position.start)))}}this.exit(e)}function HR(e,r,a,i){const o=e.children[0],u=typeof e.checked=="boolean"&&o&&o.type==="paragraph",d="["+(e.checked?"x":" ")+"] ",f=a.createTracker(i);u&&f.move(d);let p=ek.listItem(e,r,a,{...i,...f.current()});return u&&(p=p.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,h)),p;function h(y){return y+d}}function FR(){return[vE(),HE(),GE(),MR(),IR()]}function qR(e){return{extensions:[kE(),FE(e),$E(),BR(e),PR()]}}const VR={tokenize:KR,partial:!0},tk={tokenize:ZR,partial:!0},nk={tokenize:WR,partial:!0},lk={tokenize:JR,partial:!0},GR={tokenize:eM,partial:!0},rk={name:"wwwAutolink",tokenize:QR,previous:ik},ak={name:"protocolAutolink",tokenize:XR,previous:sk},wr={name:"emailAutolink",tokenize:YR,previous:ok},Vl={};function $R(){return{text:Vl}}let qa=48;for(;qa<123;)Vl[qa]=wr,qa++,qa===58?qa=65:qa===91&&(qa=97);Vl[43]=wr;Vl[45]=wr;Vl[46]=wr;Vl[95]=wr;Vl[72]=[wr,ak];Vl[104]=[wr,ak];Vl[87]=[wr,rk];Vl[119]=[wr,rk];function YR(e,r,a){const i=this;let o,u;return d;function d(b){return!xp(b)||!ok.call(i,i.previous)||ah(i.events)?a(b):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),f(b))}function f(b){return xp(b)?(e.consume(b),f):b===64?(e.consume(b),p):a(b)}function p(b){return b===46?e.check(GR,y,h)(b):b===45||b===95||Ln(b)?(u=!0,e.consume(b),p):y(b)}function h(b){return e.consume(b),o=!0,p}function y(b){return u&&o&&Pn(i.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),r(b)):a(b)}}function QR(e,r,a){const i=this;return o;function o(d){return d!==87&&d!==119||!ik.call(i,i.previous)||ah(i.events)?a(d):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(VR,e.attempt(tk,e.attempt(nk,u),a),a)(d))}function u(d){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),r(d)}}function XR(e,r,a){const i=this;let o="",u=!1;return d;function d(b){return(b===72||b===104)&&sk.call(i,i.previous)&&!ah(i.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),o+=String.fromCodePoint(b),e.consume(b),f):a(b)}function f(b){if(Pn(b)&&o.length<5)return o+=String.fromCodePoint(b),e.consume(b),f;if(b===58){const v=o.toLowerCase();if(v==="http"||v==="https")return e.consume(b),p}return a(b)}function p(b){return b===47?(e.consume(b),u?h:(u=!0,p)):a(b)}function h(b){return b===null||Du(b)||It(b)||Qa(b)||Gu(b)?a(b):e.attempt(tk,e.attempt(nk,y),a)(b)}function y(b){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),r(b)}}function KR(e,r,a){let i=0;return o;function o(d){return(d===87||d===119)&&i<3?(i++,e.consume(d),o):d===46&&i===3?(e.consume(d),u):a(d)}function u(d){return d===null?a(d):r(d)}}function ZR(e,r,a){let i,o,u;return d;function d(h){return h===46||h===95?e.check(lk,p,f)(h):h===null||It(h)||Qa(h)||h!==45&&Gu(h)?p(h):(u=!0,e.consume(h),d)}function f(h){return h===95?i=!0:(o=i,i=void 0),e.consume(h),d}function p(h){return o||i||!u?a(h):r(h)}}function WR(e,r){let a=0,i=0;return o;function o(d){return d===40?(a++,e.consume(d),o):d===41&&i<a?u(d):d===33||d===34||d===38||d===39||d===41||d===42||d===44||d===46||d===58||d===59||d===60||d===63||d===93||d===95||d===126?e.check(lk,r,u)(d):d===null||It(d)||Qa(d)?r(d):(e.consume(d),o)}function u(d){return d===41&&i++,e.consume(d),o}}function JR(e,r,a){return i;function i(f){return f===33||f===34||f===39||f===41||f===42||f===44||f===46||f===58||f===59||f===63||f===95||f===126?(e.consume(f),i):f===38?(e.consume(f),u):f===93?(e.consume(f),o):f===60||f===null||It(f)||Qa(f)?r(f):a(f)}function o(f){return f===null||f===40||f===91||It(f)||Qa(f)?r(f):i(f)}function u(f){return Pn(f)?d(f):a(f)}function d(f){return f===59?(e.consume(f),i):Pn(f)?(e.consume(f),d):a(f)}}function eM(e,r,a){return i;function i(u){return e.consume(u),o}function o(u){return Ln(u)?a(u):r(u)}}function ik(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||It(e)}function sk(e){return!Pn(e)}function ok(e){return!(e===47||xp(e))}function xp(e){return e===43||e===45||e===46||e===95||Ln(e)}function ah(e){let r=e.length,a=!1;for(;r--;){const i=e[r][1];if((i.type==="labelLink"||i.type==="labelImage")&&!i._balanced){a=!0;break}if(i._gfmAutolinkLiteralWalkedInto){a=!1;break}}return e.length>0&&!a&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),a}const tM={tokenize:cM,partial:!0};function nM(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:iM,continuation:{tokenize:sM},exit:oM}},text:{91:{name:"gfmFootnoteCall",tokenize:aM},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:lM,resolveTo:rM}}}}function lM(e,r,a){const i=this;let o=i.events.length;const u=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let d;for(;o--;){const p=i.events[o][1];if(p.type==="labelImage"){d=p;break}if(p.type==="gfmFootnoteCall"||p.type==="labelLink"||p.type==="label"||p.type==="image"||p.type==="link")break}return f;function f(p){if(!d||!d._balanced)return a(p);const h=El(i.sliceSerialize({start:d.end,end:i.now()}));return h.codePointAt(0)!==94||!u.includes(h.slice(1))?a(p):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),r(p))}}function rM(e,r){let a=e.length;for(;a--;)if(e[a][1].type==="labelImage"&&e[a][0]==="enter"){e[a][1];break}e[a+1][1].type="data",e[a+3][1].type="gfmFootnoteCallLabelMarker";const i={type:"gfmFootnoteCall",start:Object.assign({},e[a+3][1].start),end:Object.assign({},e[e.length-1][1].end)},o={type:"gfmFootnoteCallMarker",start:Object.assign({},e[a+3][1].end),end:Object.assign({},e[a+3][1].end)};o.end.column++,o.end.offset++,o.end._bufferIndex++;const u={type:"gfmFootnoteCallString",start:Object.assign({},o.end),end:Object.assign({},e[e.length-1][1].start)},d={type:"chunkString",contentType:"string",start:Object.assign({},u.start),end:Object.assign({},u.end)},f=[e[a+1],e[a+2],["enter",i,r],e[a+3],e[a+4],["enter",o,r],["exit",o,r],["enter",u,r],["enter",d,r],["exit",d,r],["exit",u,r],e[e.length-2],e[e.length-1],["exit",i,r]];return e.splice(a,e.length-a+1,...f),e}function aM(e,r,a){const i=this,o=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let u=0,d;return f;function f(b){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(b),e.exit("gfmFootnoteCallLabelMarker"),p}function p(b){return b!==94?a(b):(e.enter("gfmFootnoteCallMarker"),e.consume(b),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",h)}function h(b){if(u>999||b===93&&!d||b===null||b===91||It(b))return a(b);if(b===93){e.exit("chunkString");const v=e.exit("gfmFootnoteCallString");return o.includes(El(i.sliceSerialize(v)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(b),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),r):a(b)}return It(b)||(d=!0),u++,e.consume(b),b===92?y:h}function y(b){return b===91||b===92||b===93?(e.consume(b),u++,h):h(b)}}function iM(e,r,a){const i=this,o=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let u,d=0,f;return p;function p(C){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(C),e.exit("gfmFootnoteDefinitionLabelMarker"),h}function h(C){return C===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(C),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",y):a(C)}function y(C){if(d>999||C===93&&!f||C===null||C===91||It(C))return a(C);if(C===93){e.exit("chunkString");const E=e.exit("gfmFootnoteDefinitionLabelString");return u=El(i.sliceSerialize(E)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(C),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),v}return It(C)||(f=!0),d++,e.consume(C),C===92?b:y}function b(C){return C===91||C===92||C===93?(e.consume(C),d++,y):y(C)}function v(C){return C===58?(e.enter("definitionMarker"),e.consume(C),e.exit("definitionMarker"),o.includes(u)||o.push(u),wt(e,j,"gfmFootnoteDefinitionWhitespace")):a(C)}function j(C){return r(C)}}function sM(e,r,a){return e.check(zo,r,e.attempt(tM,r,a))}function oM(e){e.exit("gfmFootnoteDefinition")}function cM(e,r,a){const i=this;return wt(e,o,"gfmFootnoteDefinitionIndent",5);function o(u){const d=i.events[i.events.length-1];return d&&d[1].type==="gfmFootnoteDefinitionIndent"&&d[2].sliceSerialize(d[1],!0).length===4?r(u):a(u)}}function uM(e){let a=(e||{}).singleTilde;const i={name:"strikethrough",tokenize:u,resolveAll:o};return a==null&&(a=!0),{text:{126:i},insideSpan:{null:[i]},attentionMarkers:{null:[126]}};function o(d,f){let p=-1;for(;++p<d.length;)if(d[p][0]==="enter"&&d[p][1].type==="strikethroughSequenceTemporary"&&d[p][1]._close){let h=p;for(;h--;)if(d[h][0]==="exit"&&d[h][1].type==="strikethroughSequenceTemporary"&&d[h][1]._open&&d[p][1].end.offset-d[p][1].start.offset===d[h][1].end.offset-d[h][1].start.offset){d[p][1].type="strikethroughSequence",d[h][1].type="strikethroughSequence";const y={type:"strikethrough",start:Object.assign({},d[h][1].start),end:Object.assign({},d[p][1].end)},b={type:"strikethroughText",start:Object.assign({},d[h][1].end),end:Object.assign({},d[p][1].start)},v=[["enter",y,f],["enter",d[h][1],f],["exit",d[h][1],f],["enter",b,f]],j=f.parser.constructs.insideSpan.null;j&&ul(v,v.length,0,$u(j,d.slice(h+1,p),f)),ul(v,v.length,0,[["exit",b,f],["enter",d[p][1],f],["exit",d[p][1],f],["exit",y,f]]),ul(d,h-1,p-h+3,v),p=h+v.length-2;break}}for(p=-1;++p<d.length;)d[p][1].type==="strikethroughSequenceTemporary"&&(d[p][1].type="data");return d}function u(d,f,p){const h=this.previous,y=this.events;let b=0;return v;function v(C){return h===126&&y[y.length-1][1].type!=="characterEscape"?p(C):(d.enter("strikethroughSequenceTemporary"),j(C))}function j(C){const E=Ji(h);if(C===126)return b>1?p(C):(d.consume(C),b++,j);if(b<2&&!a)return p(C);const w=d.exit("strikethroughSequenceTemporary"),M=Ji(C);return w._open=!M||M===2&&!!E,w._close=!E||E===2&&!!M,f(C)}}}class dM{constructor(){this.map=[]}add(r,a,i){fM(this,r,a,i)}consume(r){if(this.map.sort(function(u,d){return u[0]-d[0]}),this.map.length===0)return;let a=this.map.length;const i=[];for(;a>0;)a-=1,i.push(r.slice(this.map[a][0]+this.map[a][1]),this.map[a][2]),r.length=this.map[a][0];i.push(r.slice()),r.length=0;let o=i.pop();for(;o;){for(const u of o)r.push(u);o=i.pop()}this.map.length=0}}function fM(e,r,a,i){let o=0;if(!(a===0&&i.length===0)){for(;o<e.map.length;){if(e.map[o][0]===r){e.map[o][1]+=a,e.map[o][2].push(...i);return}o+=1}e.map.push([r,a,i])}}function mM(e,r){let a=!1;const i=[];for(;r<e.length;){const o=e[r];if(a){if(o[0]==="enter")o[1].type==="tableContent"&&i.push(e[r+1][1].type==="tableDelimiterMarker"?"left":"none");else if(o[1].type==="tableContent"){if(e[r-1][1].type==="tableDelimiterMarker"){const u=i.length-1;i[u]=i[u]==="left"?"center":"right"}}else if(o[1].type==="tableDelimiterRow")break}else o[0]==="enter"&&o[1].type==="tableDelimiterRow"&&(a=!0);r+=1}return i}function pM(){return{flow:{null:{name:"table",tokenize:hM,resolveAll:xM}}}}function hM(e,r,a){const i=this;let o=0,u=0,d;return f;function f(O){let P=i.events.length-1;for(;P>-1;){const J=i.events[P][1].type;if(J==="lineEnding"||J==="linePrefix")P--;else break}const Q=P>-1?i.events[P][1].type:null,oe=Q==="tableHead"||Q==="tableRow"?L:p;return oe===L&&i.parser.lazy[i.now().line]?a(O):oe(O)}function p(O){return e.enter("tableHead"),e.enter("tableRow"),h(O)}function h(O){return O===124||(d=!0,u+=1),y(O)}function y(O){return O===null?a(O):$e(O)?u>1?(u=0,i.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(O),e.exit("lineEnding"),j):a(O):gt(O)?wt(e,y,"whitespace")(O):(u+=1,d&&(d=!1,o+=1),O===124?(e.enter("tableCellDivider"),e.consume(O),e.exit("tableCellDivider"),d=!0,y):(e.enter("data"),b(O)))}function b(O){return O===null||O===124||It(O)?(e.exit("data"),y(O)):(e.consume(O),O===92?v:b)}function v(O){return O===92||O===124?(e.consume(O),b):b(O)}function j(O){return i.interrupt=!1,i.parser.lazy[i.now().line]?a(O):(e.enter("tableDelimiterRow"),d=!1,gt(O)?wt(e,C,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(O):C(O))}function C(O){return O===45||O===58?w(O):O===124?(d=!0,e.enter("tableCellDivider"),e.consume(O),e.exit("tableCellDivider"),E):q(O)}function E(O){return gt(O)?wt(e,w,"whitespace")(O):w(O)}function w(O){return O===58?(u+=1,d=!0,e.enter("tableDelimiterMarker"),e.consume(O),e.exit("tableDelimiterMarker"),M):O===45?(u+=1,M(O)):O===null||$e(O)?X(O):q(O)}function M(O){return O===45?(e.enter("tableDelimiterFiller"),D(O)):q(O)}function D(O){return O===45?(e.consume(O),D):O===58?(d=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(O),e.exit("tableDelimiterMarker"),H):(e.exit("tableDelimiterFiller"),H(O))}function H(O){return gt(O)?wt(e,X,"whitespace")(O):X(O)}function X(O){return O===124?C(O):O===null||$e(O)?!d||o!==u?q(O):(e.exit("tableDelimiterRow"),e.exit("tableHead"),r(O)):q(O)}function q(O){return a(O)}function L(O){return e.enter("tableRow"),B(O)}function B(O){return O===124?(e.enter("tableCellDivider"),e.consume(O),e.exit("tableCellDivider"),B):O===null||$e(O)?(e.exit("tableRow"),r(O)):gt(O)?wt(e,B,"whitespace")(O):(e.enter("data"),F(O))}function F(O){return O===null||O===124||It(O)?(e.exit("data"),B(O)):(e.consume(O),O===92?Z:F)}function Z(O){return O===92||O===124?(e.consume(O),F):F(O)}}function xM(e,r){let a=-1,i=!0,o=0,u=[0,0,0,0],d=[0,0,0,0],f=!1,p=0,h,y,b;const v=new dM;for(;++a<e.length;){const j=e[a],C=j[1];j[0]==="enter"?C.type==="tableHead"?(f=!1,p!==0&&(Yy(v,r,p,h,y),y=void 0,p=0),h={type:"table",start:Object.assign({},C.start),end:Object.assign({},C.end)},v.add(a,0,[["enter",h,r]])):C.type==="tableRow"||C.type==="tableDelimiterRow"?(i=!0,b=void 0,u=[0,0,0,0],d=[0,a+1,0,0],f&&(f=!1,y={type:"tableBody",start:Object.assign({},C.start),end:Object.assign({},C.end)},v.add(a,0,[["enter",y,r]])),o=C.type==="tableDelimiterRow"?2:y?3:1):o&&(C.type==="data"||C.type==="tableDelimiterMarker"||C.type==="tableDelimiterFiller")?(i=!1,d[2]===0&&(u[1]!==0&&(d[0]=d[1],b=hu(v,r,u,o,void 0,b),u=[0,0,0,0]),d[2]=a)):C.type==="tableCellDivider"&&(i?i=!1:(u[1]!==0&&(d[0]=d[1],b=hu(v,r,u,o,void 0,b)),u=d,d=[u[1],a,0,0])):C.type==="tableHead"?(f=!0,p=a):C.type==="tableRow"||C.type==="tableDelimiterRow"?(p=a,u[1]!==0?(d[0]=d[1],b=hu(v,r,u,o,a,b)):d[1]!==0&&(b=hu(v,r,d,o,a,b)),o=0):o&&(C.type==="data"||C.type==="tableDelimiterMarker"||C.type==="tableDelimiterFiller")&&(d[3]=a)}for(p!==0&&Yy(v,r,p,h,y),v.consume(r.events),a=-1;++a<r.events.length;){const j=r.events[a];j[0]==="enter"&&j[1].type==="table"&&(j[1]._align=mM(r.events,a))}return e}function hu(e,r,a,i,o,u){const d=i===1?"tableHeader":i===2?"tableDelimiter":"tableData",f="tableContent";a[0]!==0&&(u.end=Object.assign({},Gi(r.events,a[0])),e.add(a[0],0,[["exit",u,r]]));const p=Gi(r.events,a[1]);if(u={type:d,start:Object.assign({},p),end:Object.assign({},p)},e.add(a[1],0,[["enter",u,r]]),a[2]!==0){const h=Gi(r.events,a[2]),y=Gi(r.events,a[3]),b={type:f,start:Object.assign({},h),end:Object.assign({},y)};if(e.add(a[2],0,[["enter",b,r]]),i!==2){const v=r.events[a[2]],j=r.events[a[3]];if(v[1].end=Object.assign({},j[1].end),v[1].type="chunkText",v[1].contentType="text",a[3]>a[2]+1){const C=a[2]+1,E=a[3]-a[2]-1;e.add(C,E,[])}}e.add(a[3]+1,0,[["exit",b,r]])}return o!==void 0&&(u.end=Object.assign({},Gi(r.events,o)),e.add(o,0,[["exit",u,r]]),u=void 0),u}function Yy(e,r,a,i,o){const u=[],d=Gi(r.events,a);o&&(o.end=Object.assign({},d),u.push(["exit",o,r])),i.end=Object.assign({},d),u.push(["exit",i,r]),e.add(a+1,0,u)}function Gi(e,r){const a=e[r],i=a[0]==="enter"?"start":"end";return a[1][i]}const gM={name:"tasklistCheck",tokenize:yM};function bM(){return{text:{91:gM}}}function yM(e,r,a){const i=this;return o;function o(p){return i.previous!==null||!i._gfmTasklistFirstContentOfListItem?a(p):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(p),e.exit("taskListCheckMarker"),u)}function u(p){return It(p)?(e.enter("taskListCheckValueUnchecked"),e.consume(p),e.exit("taskListCheckValueUnchecked"),d):p===88||p===120?(e.enter("taskListCheckValueChecked"),e.consume(p),e.exit("taskListCheckValueChecked"),d):a(p)}function d(p){return p===93?(e.enter("taskListCheckMarker"),e.consume(p),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),f):a(p)}function f(p){return $e(p)?r(p):gt(p)?e.check({tokenize:vM},r,a)(p):a(p)}}function vM(e,r,a){return wt(e,i,"whitespace");function i(o){return o===null?a(o):r(o)}}function kM(e){return y0([$R(),nM(),uM(e),pM(),bM()])}const jM={};function NM(e){const r=this,a=e||jM,i=r.data(),o=i.micromarkExtensions||(i.micromarkExtensions=[]),u=i.fromMarkdownExtensions||(i.fromMarkdownExtensions=[]),d=i.toMarkdownExtensions||(i.toMarkdownExtensions=[]);o.push(kM(a)),u.push(FR()),d.push(qR(a))}function wM({thread:e}){return e.state==="available"?null:e.state==="working"?l.jsx("span",{className:"inline-flex items-center gap-1 shrink-0",style:{color:g.muted},children:l.jsx(Ku,{})}):l.jsxs("span",{className:"inline-flex items-center gap-1.5 text-[9px] font-mono tracking-wide shrink-0",style:{color:g.muted},children:[l.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${Ro(e.state)}`}),l.jsx("span",{children:e.statusLabel})]})}function Ku({className:e=""}){return l.jsxs("span",{className:`inline-flex items-center gap-1 ${e}`,"aria-hidden":"true",children:[l.jsx("span",{className:"os-thinking-dot"}),l.jsx("span",{className:"os-thinking-dot"}),l.jsx("span",{className:"os-thinking-dot"})]})}function ko({messages:e,showAnnotations:r,showStatusMessages:a,inkStyle:i,mutedStyle:o,tagStyle:u,annotStyle:d,agentLookup:f,directThreadLookup:p,onOpenAgentProfile:h,onOpenAgentChat:y,onNudgeMessage:b}){const[v,j]=A.useState(null),[C,E]=A.useState(null),[w,M]=A.useState(null),D=[];let H="",X=0;const q=A.useMemo(()=>a?e:e.filter(P=>P.messageClass!=="status"),[e,a]),L=A.useMemo(()=>new Map(q.map(P=>[P.id,P])),[q]),B=A.useMemo(()=>{let P=null;for(const Q of q)Q.isOperator&&Q.isDirectConversation&&Q.receipt&&(P=Q.id);return P},[q]);A.useEffect(()=>{if(!v)return;const P=window.setTimeout(()=>{j(Q=>Q===v?null:Q)},1400);return()=>window.clearTimeout(P)},[v]),A.useEffect(()=>{if(!C)return;const P=window.setTimeout(()=>{E(Q=>Q===C?null:Q)},1400);return()=>window.clearTimeout(P)},[C]),A.useEffect(()=>{if(!w)return;const P=window.setTimeout(()=>{M(Q=>Q===w?null:Q)},2200);return()=>window.clearTimeout(P)},[w]);const F=z.useCallback(async P=>{try{await uk(So(P)),j(P)}catch{j(null)}},[]),Z=z.useCallback(P=>{b?.(P),E(P.id)},[b]),O=z.useCallback(P=>{if(typeof document>"u")return;const Q=document.getElementById(km(P));Q&&(Q.scrollIntoView({block:"center",behavior:"smooth"}),M(P))},[]);for(;X<q.length;){const P=q[X],Q=FS(P.authorRole)?P.authorRole:null,oe=P.isOperator?null:f.get(P.authorId)??null,J=oe?p.get(oe.id)??null:null;if(P.dayLabel!==H&&(D.push(l.jsxs("div",{className:"flex items-center gap-3 mb-5 mt-2",children:[l.jsx("div",{className:"flex-1 h-px",style:{backgroundColor:g.border}}),l.jsx("div",{className:"px-2 font-mono text-[9px] tracking-widest uppercase shrink-0",style:o,children:P.dayLabel}),l.jsx("div",{className:"flex-1 h-px",style:{backgroundColor:g.border}})]},`day-${P.dayLabel}`)),H=P.dayLabel),P.isSystem||P.messageClass==="status"){D.push(l.jsxs("div",{className:"flex gap-3 mb-3 group rounded-lg px-2 py-2 -mx-2 bg-[var(--os-hover)]",children:[l.jsx("div",{className:"w-6 h-6 rounded-md flex items-center justify-center text-[9px] font-semibold shrink-0 mt-0.5",style:{backgroundColor:P.avatarColor,color:"white",opacity:.85},children:P.avatarLabel}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:"flex items-baseline justify-between mb-0.5",children:l.jsx("div",{className:"flex items-baseline gap-2",children:oe?l.jsx(Xy,{agent:oe,directThread:J,visibleRole:Q,timestampLabel:P.timestampLabel,inkStyle:i,mutedStyle:o,tagStyle:u,onOpenProfile:h,onOpenChat:y}):l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"font-semibold text-[12px]",style:i,children:P.authorName}),l.jsx("span",{className:"text-[9px] font-mono",style:o,children:P.timestampLabel})]})})}),l.jsxs("div",{id:km(P.id),className:"group/message relative text-[12px] leading-relaxed rounded-lg px-2 py-1.5 pr-12 -mx-2",style:w===P.id?Gb():i,children:[l.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 border rounded font-mono text-[10px] w-fit",style:u,children:[l.jsx(un,{className:"text-[10px]"}),l.jsxs("span",{children:[l.jsx("span",{style:o,children:"TASK //"})," ",P.body]}),l.jsx("span",{className:"ml-2 px-1 rounded",style:{backgroundColor:"rgba(99,102,241,0.12)",color:"var(--os-accent)"},children:"IN PROGRESS"})]}),l.jsx(Qy,{message:P,copied:v===P.id,nudged:C===P.id,canNudge:!!(b&&!P.isOperator),mutedStyle:o,onCopyRef:F,onNudge:()=>Z(P)})]})]})]},P.id)),X+=1;continue}const ee=[P];let N=X+1;for(;N<q.length&&q[N].authorId===P.authorId&&q[N].dayLabel===P.dayLabel&&!q[N].isSystem&&q[N].messageClass!=="status";)ee.push(q[N]),N+=1;const Y=!!oe;D.push(l.jsxs("div",{className:An("flex gap-3 mb-4 group rounded-lg px-2 py-2 -mx-2",Y&&"bg-[var(--os-hover)]"),children:[l.jsx("div",{className:"w-6 h-6 rounded-md flex items-center justify-center text-[9px] font-semibold shrink-0 mt-0.5",style:{backgroundColor:P.avatarColor,color:"white",opacity:.85},children:P.avatarLabel}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-baseline justify-between mb-1",children:[l.jsx("div",{className:"flex items-baseline gap-2",children:oe?l.jsx(Xy,{agent:oe,directThread:J,visibleRole:Q,timestampLabel:P.timestampLabel,inkStyle:i,mutedStyle:o,tagStyle:u,onOpenProfile:h,onOpenChat:y}):l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"font-semibold text-[12px]",style:i,children:P.authorName}),Q?l.jsx("span",{className:"text-[9px] font-mono border px-1 py-0.5 rounded",style:u,children:Q}):null,l.jsx("span",{className:"text-[9px] font-mono",style:o,children:P.timestampLabel})]})}),r&&(P.routingSummary||P.provenanceSummary)?l.jsxs("div",{className:"flex items-center gap-1",children:[P.routingSummary?l.jsx("span",{className:"text-[9px] font-mono border px-1 rounded",style:d,children:P.routingSummary}):null,P.provenanceSummary?l.jsx("span",{className:"text-[9px] font-mono border px-1 rounded",style:d,children:P.provenanceSummary}):null]}):null]}),l.jsx("div",{className:"flex flex-col gap-2 mt-0.5",children:ee.map($=>{const ye=$.replyToMessageId?L.get($.replyToMessageId)??null:null,T=!!($.receipt&&(!$.isOperator||!$.isDirectConversation||B===$.id)),_=T&&VS($.body);return l.jsxs("div",{id:km($.id),className:"group/message relative text-[12px] leading-relaxed rounded-lg px-2 py-1.5 pr-12 -mx-2",style:w===$.id?Gb():i,children:[$.replyToMessageId?ye?l.jsx(Ky,{messageId:$.replyToMessageId,preview:zu(ye.body,64),mutedStyle:o,onJump:()=>O($.replyToMessageId)}):l.jsx(Ky,{messageId:$.replyToMessageId,mutedStyle:o}):null,_&&$.receipt?l.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-1",children:[l.jsx("span",{className:"min-w-0 max-w-full whitespace-pre-wrap break-words",style:i,children:$.body}),l.jsx(Zy,{receipt:$.receipt,mutedStyle:o,inline:!0})]}):l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"flex flex-col gap-2",children:EM($.body,i,o,u)}),T&&$.receipt?l.jsx(Zy,{receipt:$.receipt,mutedStyle:o}):null]}),r&&($.routingSummary||$.provenanceSummary||$.provenanceDetail)?l.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mt-1.5",children:[$.routingSummary?l.jsx("span",{className:"text-[9px] font-mono border px-1 rounded",style:d,children:$.routingSummary}):null,$.provenanceSummary?l.jsx("span",{className:"text-[9px] font-mono border px-1 rounded",style:d,children:$.provenanceSummary}):null,$.provenanceDetail?l.jsx("span",{className:"text-[9px]",style:o,children:$.provenanceDetail}):null]}):null,l.jsx(Qy,{message:$,copied:v===$.id,nudged:C===$.id,canNudge:!!(b&&!$.isOperator),mutedStyle:o,onCopyRef:F,onNudge:()=>Z($)})]},$.id)})})]})]},P.id)),X=N}return l.jsx(l.Fragment,{children:D})}function Qy({message:e,copied:r,nudged:a,canNudge:i,mutedStyle:o,onCopyRef:u,onNudge:d}){return l.jsxs("div",{className:"absolute top-1.5 right-2 flex items-center gap-2 opacity-0 pointer-events-none transition-opacity group-hover/message:opacity-100 group-hover/message:pointer-events-auto group-focus-within/message:opacity-100 group-focus-within/message:pointer-events-auto",children:[i?l.jsx("button",{type:"button",onClick:d,className:"text-[9px] font-mono lowercase tracking-wide transition-colors hover:opacity-80",style:a?{color:g.accent}:o,title:`Follow up with ${e.authorName}`,children:a?"drafted":"nudge"}):null,l.jsx("button",{type:"button",onClick:()=>{u(e.id)},className:"text-[9px] font-mono lowercase tracking-wide transition-colors hover:opacity-80",style:r?{color:g.accent}:o,title:Nv(e.id),children:r?"copied":tC(e.id)})]})}function Xy({agent:e,directThread:r,visibleRole:a,timestampLabel:i,inkStyle:o,mutedStyle:u,tagStyle:d,onOpenProfile:f,onOpenChat:p}){const h=y=>{if(y.preventDefault(),y.stopPropagation(),y.metaKey||y.ctrlKey){p(e.id);return}f(e.id)};return l.jsxs("div",{className:"relative group/agent inline-flex items-baseline gap-2 min-w-0",children:[l.jsxs("button",{type:"button",onClick:h,className:"inline-flex items-baseline gap-2 min-w-0 text-left hover:opacity-90 transition-opacity",title:"Click for overview. Cmd-click to open direct chat.",children:[l.jsx("span",{className:"font-semibold text-[12px] truncate",style:o,children:e.title}),a?l.jsx("span",{className:"text-[9px] font-mono border px-1 py-0.5 rounded shrink-0",style:d,children:a}):null]}),l.jsx("span",{className:"text-[9px] font-mono shrink-0",style:u,children:i}),l.jsx(CM,{agent:e,directThread:r,mutedStyle:u,onOpenProfile:f,onOpenChat:p})]})}function SM({agent:e,directThread:r=null,variant:a="hero",mutedStyle:i={color:g.muted},borderColor:o=g.bg,actions:u=null}){const d=a==="hover",f=Fb(e.role),p=Fb(e.summary),h=r?.statusDetail??e.statusDetail??p??"Available as a local relay channel.";return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsxs("div",{className:"relative shrink-0",children:[l.jsx("div",{className:`${d?"w-8 h-8 text-[11px]":"w-10 h-10 text-[13px]"} rounded text-white flex items-center justify-center font-bold ${e.reachable?"":"opacity-40 grayscale"}`,style:{backgroundColor:cl(e.id)},children:e.title.charAt(0).toUpperCase()}),l.jsx("div",{className:`absolute -bottom-0.5 -right-0.5 w-2 h-2 rounded-full ${Ro(e.state)}`,style:{border:`1px solid ${o}`}})]}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[l.jsx("div",{className:d?"text-[12px] font-semibold truncate":"text-[15px] font-semibold tracking-tight",style:{color:g.ink},children:e.title}),l.jsx("span",{className:"text-[9px] font-mono uppercase px-1.5 py-0.5 rounded",style:{backgroundColor:g.tagBg,color:g.muted},children:mv(e.profileKind)})]}),d?l.jsx("div",{className:"text-[10px] mt-1",style:i,children:h}):l.jsxs(l.Fragment,{children:[f?l.jsx("div",{className:"text-[11px] mt-1",style:{color:g.ink},children:f}):null,p?l.jsx("div",{className:"text-[12px] leading-[1.55] mt-2",style:{color:g.muted},children:p}):null]}),l.jsx("div",{className:`text-[10px] ${d?"mt-2 flex flex-wrap gap-x-3 gap-y-1":"mt-3 flex items-center gap-2 flex-wrap"}`,style:i,children:d?l.jsxs(l.Fragment,{children:[l.jsx("span",{children:e.harness??"runtime"}),l.jsx("span",{children:Ka(e.projectRoot??e.cwd)??"no path"}),e.lastChatLabel?l.jsxs("span",{children:["last chat ",e.lastChatLabel]}):null]}):l.jsxs(l.Fragment,{children:[l.jsx("span",{children:e.lastChatLabel?`Last chat ${e.lastChatLabel}`:"No direct chat yet."}),e.lastSessionLabel?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"w-1 h-1 rounded-full",style:{backgroundColor:g.border}}),l.jsxs("span",{children:["Last session ",e.lastSessionLabel]})]}):null]})})]})]}),u?l.jsx("div",{className:"mt-3 flex items-center gap-2",children:u}):null]})}function ho({children:e,icon:r,tone:a="neutral",...i}){return l.jsxs(Nt,{type:"button",variant:"outline",size:"sm",className:"h-8 rounded-xl px-3 text-[10px] font-medium shadow-none",style:a==="primary"?{backgroundColor:g.accentBg,borderColor:g.accentBorder,color:g.accent}:{backgroundColor:g.surface,borderColor:g.border,color:g.ink},...i,children:[r,e]})}function CM({agent:e,directThread:r,mutedStyle:a,onOpenProfile:i,onOpenChat:o}){return l.jsx("div",{className:"absolute left-0 top-full z-30 mt-2 w-72 rounded-xl border p-3 shadow-lg opacity-0 pointer-events-none translate-y-1 transition-all duration-150 group-hover/agent:opacity-100 group-hover/agent:pointer-events-auto group-hover/agent:translate-y-0 group-focus-within/agent:opacity-100 group-focus-within/agent:pointer-events-auto group-focus-within/agent:translate-y-0",style:{borderColor:g.border,backgroundColor:g.surface},children:l.jsx(SM,{agent:e,directThread:r,variant:"hover",mutedStyle:a,borderColor:g.surface,actions:l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button",className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-1 rounded",style:{color:g.ink},onClick:u=>{u.preventDefault(),u.stopPropagation(),o(e.id)},children:"Message"}),l.jsx("button",{type:"button",className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-1 rounded",style:{color:g.ink},onClick:u=>{u.preventDefault(),u.stopPropagation(),i(e.id)},children:"Overview"}),l.jsx("span",{className:"ml-auto text-[9px] font-mono",style:a,children:"Cmd-click to DM"})]})})})}function Ky({messageId:e,preview:r,mutedStyle:a,onJump:i}){return l.jsxs("div",{className:"mb-1 flex items-center gap-1.5 text-[9px] leading-none min-w-0",style:{...a,opacity:.7},children:[l.jsx(_N,{size:9,className:"shrink-0"}),i?l.jsx("button",{type:"button",onClick:i,className:"hover:underline underline-offset-2 truncate min-w-0",title:Nv(e),children:r||So(e)}):l.jsx("span",{className:"font-mono shrink-0",children:So(e)})]})}function Zy({receipt:e,mutedStyle:r,inline:a=!1}){const i=qS(e.state);return l.jsxs("div",{className:`${a?"":"mt-1.5 "}inline-flex items-center gap-1.5 text-[10px] leading-none shrink-0`,style:{...r,color:i.color},title:e.detail??e.label,children:[l.jsx(TM,{state:e.state}),l.jsx("span",{className:"font-mono uppercase tracking-[0.14em]",children:e.label}),e.state==="replied"&&e.detail?l.jsx("span",{style:r,children:e.detail}):null]})}function TM({state:e}){switch(e){case"replied":return l.jsx(C2,{size:11});case"working":return l.jsx(Ku,{className:"text-[var(--os-accent)]"});case"seen":return l.jsx(Eu,{size:11});case"delivered":return l.jsx(Eu,{size:11});default:return l.jsx(Yi,{size:11})}}function Ki({size:e=16,strokeWidth:r=1.35,style:a}){return l.jsx(S1,{size:e,strokeWidth:r,className:"shrink-0",style:a,"aria-hidden":"true"})}function ck({id:e,active:r,size:a=12}){const i=r?{color:g.accent}:void 0;return e==="voice"?l.jsx(Km,{size:a,className:"os-row-icon shrink-0",style:i}):e==="system"?l.jsx($a,{size:a,className:"os-row-icon shrink-0",style:i}):e==="mentions"?l.jsx(Np,{size:a,className:"os-row-icon shrink-0",style:i}):e==="coordination"?l.jsx(Al,{size:a,className:"os-row-icon shrink-0",style:i}):e==="all-traffic"?l.jsx(j2,{size:a,className:"os-row-icon shrink-0",style:i}):l.jsx(e2,{size:a,className:"os-row-icon shrink-0",style:i})}function AM({relayState:e,appSettings:r,destinationKind:a,destinationId:i,body:o,replyToMessageId:u,clientMessageId:d}){const f=Date.now(),p=e?.operatorId??"operator",h=ZS(e,r),y=a==="direct"?Array.from(new Set([i,...Vb(o)])):Vb(o),b=a==="channel"?i:a==="direct"?null:"shared",v=a==="channel"&&i==="voice",j=a==="channel"&&i==="system";return{id:`pending-${d}`,clientMessageId:d,conversationId:eC(a,i),createdAt:f,replyToMessageId:u,authorId:p,authorName:h,authorRole:null,body:o,timestampLabel:QS(f),dayLabel:XS(f),normalizedChannel:b,recipients:y,isDirectConversation:a==="direct",isSystem:j,isVoice:v,messageClass:j?"system":"agent",routingSummary:y.length>0?`Targets ${y.join(", ")}`:null,provenanceSummary:"via desktop · sending",provenanceDetail:null,isOperator:!0,avatarLabel:h.slice(0,1).toUpperCase()||"A",avatarColor:cl(p),receipt:{state:"sent",label:"Sending…",detail:null}}}function EM(e,r,a,i){const o={"--os-markdown-ink":String(r.color??g.ink),"--os-markdown-muted":String(a.color??g.muted),"--os-markdown-link":g.accent,"--os-markdown-border":g.border,"--os-markdown-surface":String(i.backgroundColor??g.tagBg),"--os-markdown-inline-border":String(i.borderColor??g.border),"--os-markdown-code-bg":g.termBg,"--os-markdown-code-fg":g.termFg};return l.jsx("div",{className:"os-markdown",style:o,children:l.jsx(uE,{remarkPlugins:[NM],components:{a:({href:u,children:d})=>l.jsx("a",{href:u,target:"_blank",rel:"noreferrer",children:d}),blockquote:({children:u})=>l.jsx("blockquote",{children:u}),code:({className:u,children:d,...f})=>{const p=/language-([\w-]+)/.exec(u??"")?.[1],h=String(d).replace(/\n$/,"");return!p&&!h.includes(`
|
|
87
|
+
`)?l.jsx("code",{className:"os-markdown-inline-code",...f,children:h}):l.jsxs("div",{className:"os-markdown-code-block",children:[l.jsx("div",{className:"os-markdown-code-header",children:l.jsx("span",{children:p??"code"})}),l.jsx("pre",{className:"os-markdown-pre",children:l.jsx("code",{className:u,...f,children:h})})]})},h1:({children:u})=>l.jsx("h1",{children:u}),h2:({children:u})=>l.jsx("h2",{children:u}),h3:({children:u})=>l.jsx("h3",{children:u}),hr:()=>l.jsx("hr",{}),pre:({children:u})=>l.jsx(l.Fragment,{children:u}),table:({children:u})=>l.jsx("div",{className:"os-markdown-table-wrap",children:l.jsx("table",{children:u})})},children:e})})}async function uk(e){if(typeof navigator<"u"&&navigator.clipboard?.writeText){await navigator.clipboard.writeText(e);return}if(typeof document<"u"){const r=document.createElement("textarea");r.value=e,r.setAttribute("readonly","true"),r.style.position="fixed",r.style.opacity="0",document.body.appendChild(r),r.select();const a=document.execCommand("copy");if(document.body.removeChild(r),a)return}throw new Error("Clipboard unavailable.")}function RM(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`client-${crypto.randomUUID()}`:`client-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function Wy({title:e,subtitle:r,layout:a,roster:i}){return a.isCollapsed?null:l.jsxs("div",{style:{width:a.sidebarWidth,...a.styles.sidebar},className:"relative flex flex-col h-full border-r shrink-0 z-10 overflow-hidden",children:[l.jsx("div",{className:"absolute right-[-3px] top-0 bottom-0 w-1.5 cursor-col-resize hover:bg-indigo-400 z-20 transition-colors",onMouseDown:a.onResizeStart}),l.jsxs("div",{className:"px-4 h-14 flex items-center justify-between border-b",style:{borderBottomColor:g.border},children:[l.jsxs("div",{children:[l.jsx("h1",{className:"text-[13px] font-semibold tracking-tight",style:a.styles.inkText,children:e}),l.jsx("div",{className:"text-[10px] font-mono mt-0.5",style:a.styles.mutedText,children:r})]}),l.jsx("button",{className:"p-1.5 rounded transition-opacity hover:opacity-70",style:a.styles.mutedText,onClick:i.onRefresh,children:l.jsx(xn,{size:14})})]}),l.jsx("div",{className:"flex-1 overflow-y-auto py-3",children:l.jsxs("div",{className:"mb-3 px-2",children:[l.jsx("div",{className:"font-mono text-[9px] tracking-widest uppercase mb-1.5 px-2",style:a.styles.mutedText,children:"Roster"}),l.jsxs("div",{className:"flex items-center justify-end gap-2 px-2 mb-2 relative",children:[l.jsxs("div",{className:"relative",children:[l.jsxs("button",{className:"os-toolbar-button flex items-center gap-1 text-[10px] px-2 py-1 rounded",style:{color:g.ink},onClick:()=>i.setAgentRosterMenu(o=>o==="filter"?null:"filter"),title:"Filter roster",children:[l.jsx($N,{size:11}),l.jsx("span",{style:a.styles.mutedText,children:IS(i.agentRosterFilter)})]}),i.agentRosterMenu==="filter"?l.jsx("div",{className:"absolute right-0 top-full mt-1 w-36 rounded-lg border shadow-sm z-20",style:{backgroundColor:g.surface,borderColor:g.border},children:[["all","All Agents"],["active","Active Only"]].map(([o,u])=>l.jsx("button",{className:"w-full text-left px-3 py-2 text-[11px] transition-opacity hover:opacity-80",style:o===i.agentRosterFilter?a.styles.activeItem:a.styles.inkText,onClick:()=>{i.setAgentRosterFilter(o),i.setAgentRosterMenu(null)},children:u},o))}):null]}),l.jsxs("div",{className:"relative",children:[l.jsxs("button",{className:"os-toolbar-button flex items-center gap-1 text-[10px] px-2 py-1 rounded",style:{color:g.ink},onClick:()=>i.setAgentRosterMenu(o=>o==="sort"?null:"sort"),title:"Sort roster",children:[l.jsx(bN,{size:11}),l.jsx("span",{style:a.styles.mutedText,children:PS(i.agentRosterSort)})]}),i.agentRosterMenu==="sort"?l.jsx("div",{className:"absolute right-0 top-full mt-1 w-36 rounded-lg border shadow-sm z-20",style:{backgroundColor:g.surface,borderColor:g.border},children:[["chat","Recent Chat"],["code","Code Changes"],["session","Dev Sessions"],["alpha","A-Z"]].map(([o,u])=>l.jsx("button",{className:"w-full text-left px-3 py-2 text-[11px] transition-opacity hover:opacity-80",style:o===i.agentRosterSort?a.styles.activeItem:a.styles.inkText,onClick:()=>{i.setAgentRosterSort(o),i.setAgentRosterMenu(null)},children:u},o))}):null]})]}),l.jsx("div",{className:"flex flex-col gap-px",children:i.rosterInterAgentAgents.length>0?i.rosterInterAgentAgents.map(o=>{const u=i.selectedInterAgentId===o.id;return l.jsxs("button",{onClick:()=>i.onSelectInterAgent(o.id),className:"flex items-center gap-2 px-2 py-2 rounded text-[12px] transition-opacity w-full text-left",style:u?a.styles.activeItem:a.styles.mutedText,children:[l.jsxs("div",{className:"relative shrink-0",children:[l.jsx("div",{className:`w-6 h-6 rounded text-white flex items-center justify-center text-[9px] font-bold ${o.reachable?"":"opacity-40 grayscale"}`,style:{backgroundColor:cl(o.id)},children:o.title.charAt(0).toUpperCase()}),l.jsx("div",{className:`absolute -bottom-0.5 -right-0.5 w-1.5 h-1.5 rounded-full ${Ro(o.state)}`,style:{border:`1px solid ${g.bg}`}})]}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"font-medium truncate",style:a.styles.inkText,children:[o.title,(i.rosterAgentTitleCounts.get(o.title)??0)>1&&o.branch?l.jsx("span",{className:"font-normal ml-1 text-[10px]",style:a.styles.mutedText,children:o.branch}):null]}),l.jsx("div",{className:"text-[10px] truncate",style:a.styles.mutedText,children:US(o,i.agentRosterSort)})]}),l.jsx("span",{className:"text-[9px] font-mono px-1.5 py-0.5 rounded",style:u?a.styles.activePill:a.styles.tagBadge,children:o.threadCount})]},o.id)}):l.jsx("div",{className:"px-3 py-8 text-[12px] text-center",style:a.styles.mutedText,children:"No agents match this view yet."})})]})})]})}function MM({activeView:e,layout:r,roster:a,agents:i,logs:o,interAgent:u,sessions:d}){if(e==="agents"){const f=a.rosterInterAgentAgents.length===a.interAgentAgents.length?`${a.interAgentAgents.length} agents`:`${a.rosterInterAgentAgents.length} visible · ${a.interAgentAgents.length} total`;return l.jsxs(l.Fragment,{children:[l.jsx(Wy,{title:"Agents",subtitle:f,layout:r,roster:a}),l.jsxs("div",{className:"flex-1 flex flex-col relative min-w-0",style:r.styles.surface,children:[l.jsx("div",{className:"border-b px-4 py-3 shrink-0",style:{...r.styles.surface,borderBottomColor:g.border},children:i.selectedInterAgent?l.jsxs("div",{className:"flex items-center justify-between gap-3",children:[l.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[l.jsxs("div",{className:"relative shrink-0",children:[l.jsx("div",{className:`w-9 h-9 rounded-xl text-[13px] text-white flex items-center justify-center font-bold ${i.selectedInterAgent.reachable?"":"opacity-40 grayscale"}`,style:{backgroundColor:cl(i.selectedInterAgent.id)},children:i.selectedInterAgent.title.charAt(0).toUpperCase()}),l.jsx("div",{className:`absolute -bottom-0.5 -right-0.5 w-2.5 h-2.5 rounded-full ${Ro(i.selectedInterAgent.state)}`,style:{border:`1px solid ${g.surface}`}})]}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("div",{className:"text-[15px] font-semibold tracking-tight truncate",style:r.styles.inkText,children:i.selectedInterAgent.title}),l.jsx("span",{className:"text-[9px] font-mono uppercase px-1.5 py-0.5 rounded",style:i.selectedInterAgent.state==="working"?r.styles.activePill:r.styles.tagBadge,children:i.selectedInterAgent.statusLabel})]}),l.jsx("div",{className:"text-[11px] mt-0.5 truncate max-w-2xl",style:r.styles.mutedText,children:i.selectedInterAgent.statusDetail??i.selectedInterAgent.summary??null})]})]}),l.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[l.jsx(ho,{icon:l.jsx(Al,{size:13}),tone:i.selectedInterAgentDirectThread?"primary":"neutral",onClick:()=>i.onOpenAgentThread(i.selectedInterAgent.id,{focusComposer:!0}),children:i.selectedInterAgentChatActionLabel}),l.jsx(ho,{icon:l.jsx(b1,{size:13}),onClick:i.onPeekAgentSession,children:"Peek"}),l.jsx(ho,{icon:l.jsx($a,{size:13}),onClick:()=>i.onOpenAgentSettings(i.selectedInterAgent.id,i.selectedInterAgent.profileKind==="project"),children:i.selectedInterAgent.profileKind==="project"?"Configure":"Settings"})]})]}):l.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[l.jsx($i,{size:14,style:r.styles.mutedText}),l.jsxs("div",{className:"min-w-0",children:[l.jsx("div",{className:"text-[13px] font-semibold tracking-tight truncate",style:r.styles.inkText,children:"Agents"}),l.jsx("div",{className:"text-[10px] truncate mt-0.5",style:r.styles.mutedText,children:"Select an agent to inspect its operational snapshot and recent threads."})]})]})}),l.jsx("div",{className:"flex-1 overflow-y-auto px-4 py-4",children:i.selectedInterAgent?l.jsxs("div",{className:"flex flex-col gap-4",children:[l.jsxs("section",{className:"border rounded-xl overflow-hidden",style:{...r.styles.surface,borderColor:g.border},children:[l.jsxs("div",{className:"px-4 py-3 border-b flex items-center justify-between gap-3",style:{backgroundColor:g.surface,borderBottomColor:g.border},children:[l.jsx("div",{className:"min-w-0",children:l.jsx("div",{className:"text-[10px] font-mono tracking-widest uppercase",style:{color:g.accent},children:"Live Session"})}),l.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[i.visibleAgentSession?.commandLabel?l.jsx(ho,{icon:l.jsx(Nr,{size:13}),onClick:i.onCopyAgentSessionCommand,children:i.agentSessionCopied?"Copied":"Copy"}):null,i.visibleAgentSession&&i.visibleAgentSession.mode!=="none"?l.jsx(ho,{icon:l.jsx(da,{size:13}),onClick:i.onOpenAgentSession,children:i.visibleAgentSession.mode==="tmux"?"Open TMUX":"Open Logs"}):null]})]}),l.jsx("div",{className:"px-4 py-4 max-h-[320px] overflow-y-auto",style:{backgroundColor:g.bg},children:i.selectedInterAgentActivityMessages.length>0?l.jsx(ko,{messages:i.selectedInterAgentActivityMessages.slice(-8),showAnnotations:!1,showStatusMessages:!1,inkStyle:r.styles.inkText,mutedStyle:r.styles.mutedText,tagStyle:r.styles.tagBadge,annotStyle:r.styles.annotBadge,agentLookup:i.interAgentAgentLookup,directThreadLookup:i.relayDirectLookup,onOpenAgentProfile:i.onOpenAgentProfile,onOpenAgentChat:(p,h)=>i.onOpenAgentThread(p,{draft:h,focusComposer:!0}),onNudgeMessage:i.onNudgeMessage}):l.jsx("div",{className:"text-[11px] leading-[1.6]",style:r.styles.mutedText,children:"No messages yet. Use the broker to send this agent a task."})}),l.jsxs(ju,{open:i.agentSessionLogsExpanded,onOpenChange:i.setAgentSessionLogsExpanded,children:[l.jsx(Nu,{asChild:!0,children:l.jsx("button",{className:"w-full px-4 py-2 border-t flex items-center justify-between gap-2 text-[10px] hover:opacity-90 transition-opacity text-left",style:{borderTopColor:g.border,backgroundColor:g.bg,color:g.muted},children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(ql,{size:10,className:"transition-transform duration-150",style:{transform:i.agentSessionLogsExpanded?"rotate(90deg)":void 0}}),l.jsx("span",{className:"font-mono uppercase tracking-wider",children:"Logs"}),l.jsx("span",{className:"text-[9px] font-mono uppercase px-1.5 py-0.5 rounded",style:i.visibleAgentSession?.mode==="tmux"?r.styles.activePill:r.styles.tagBadge,children:i.agentSessionPending?"Loading":i.visibleAgentSession?.mode==="tmux"?"TMUX":i.visibleAgentSession?.mode==="logs"?"Logs":"Unavailable"}),i.visibleAgentSession?.updatedAtLabel?l.jsxs("span",{children:["Updated ",i.visibleAgentSession.updatedAtLabel]}):null]})})}),l.jsxs(wu,{children:[l.jsx("div",{style:{backgroundColor:g.termBg},children:i.agentSessionLoading&&!i.visibleAgentSession?l.jsx("div",{className:"px-4 py-8 text-[11px] font-mono",style:{color:g.termFg},children:"Loading live session…"}):i.visibleAgentSession?.body?l.jsx("pre",{ref:p=>{i.agentSessionInlineViewportRef.current=p},onScroll:i.onInlineAgentSessionScroll,className:"px-4 py-4 text-[11px] leading-[1.6] overflow-x-auto whitespace-pre-wrap break-words max-h-[400px] overflow-y-auto",style:{color:g.termFg,fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace"},children:i.visibleAgentSession.body}):l.jsx("div",{className:"px-4 py-8 text-[11px] leading-[1.65] font-mono",style:{color:g.termFg},children:i.agentSessionPending?"Checking for a live tmux pane first, then falling back to canonical runtime logs.":i.visibleAgentSession?.subtitle??"No session output available yet."})}),l.jsxs("div",{className:"px-4 h-10 border-t flex items-center justify-between gap-3 text-[10px]",style:{borderTopColor:g.border,backgroundColor:g.bg,color:g.muted},children:[l.jsx("div",{className:"truncate min-w-0 font-mono",children:i.renderLocalPathValue(i.visibleAgentSession?.pathLabel??Ka(i.selectedInterAgent.cwd??i.selectedInterAgent.projectRoot)??"No stable session path yet.",{className:"text-left underline underline-offset-2 decoration-dotted hover:opacity-80 transition-opacity"})}),i.agentSessionFeedback?l.jsx("div",{className:"shrink-0",style:r.styles.inkText,children:i.agentSessionFeedback}):null]})]})]})]}),l.jsxs("section",{className:"border rounded-xl overflow-hidden",style:{...r.styles.surface,borderColor:g.border},children:[l.jsxs("div",{className:"px-4 py-3 border-b flex items-center justify-between gap-3",style:{borderBottomColor:g.border,backgroundColor:g.surface},children:[l.jsx("div",{className:"min-w-0",children:l.jsx("div",{className:"text-[10px] font-mono tracking-widest uppercase",style:{color:g.accent},children:"Recent Activity"})}),l.jsxs("div",{className:"flex items-center gap-2 shrink-0 flex-wrap justify-end",children:[l.jsxs("span",{className:"text-[9px] font-mono uppercase px-1.5 py-0.5 rounded",style:r.styles.tagBadge,children:[i.selectedInterAgentActivityMessages.length," events"]}),i.selectedInterAgentInboundTasks.length>0?l.jsxs("span",{className:"text-[9px] font-mono uppercase px-1.5 py-0.5 rounded",style:r.styles.activePill,children:[i.selectedInterAgentInboundTasks.length," asks"]}):null,i.selectedInterAgentOutboundFindings.length>0?l.jsxs("span",{className:"text-[9px] font-mono uppercase px-1.5 py-0.5 rounded",style:{backgroundColor:"rgba(248, 113, 113, 0.14)",color:"#b91c1c"},children:[i.selectedInterAgentOutboundFindings.length," waiting"]}):null]})]}),i.selectedInterAgentFindings.length>0?l.jsx("div",{className:"px-4 py-3 border-b flex flex-col gap-2",style:{borderBottomColor:g.border,backgroundColor:g.bg},children:i.selectedInterAgentFindings.slice(0,2).map(p=>l.jsxs("div",{className:"rounded-lg border px-3 py-2",style:{borderColor:p.severity==="error"?"rgba(248, 113, 113, 0.28)":"rgba(245, 158, 11, 0.28)",backgroundColor:p.severity==="error"?"rgba(248, 113, 113, 0.08)":"rgba(245, 158, 11, 0.08)"},children:[l.jsxs("div",{className:"flex items-center justify-between gap-3",children:[l.jsx("div",{className:"text-[11px] font-medium",style:r.styles.inkText,children:p.title}),l.jsx("span",{className:"text-[9px] font-mono uppercase",style:r.styles.mutedText,children:p.ageLabel??p.updatedAtLabel??"Open"})]}),l.jsx("div",{className:"text-[11px] mt-1",style:r.styles.mutedText,children:p.summary})]},p.id))}):null,l.jsxs("div",{className:"px-4 py-4 max-h-[280px] overflow-y-auto",style:{backgroundColor:g.bg},children:[i.selectedInterAgentActivityMessages.length>0?l.jsx(ko,{messages:i.agentActivityExpanded?i.selectedInterAgentActivityMessages:i.selectedInterAgentActivityMessages.slice(-5),showAnnotations:!0,showStatusMessages:!0,inkStyle:r.styles.inkText,mutedStyle:r.styles.mutedText,tagStyle:r.styles.tagBadge,annotStyle:r.styles.annotBadge,agentLookup:i.interAgentAgentLookup,directThreadLookup:i.relayDirectLookup,onOpenAgentProfile:i.onOpenAgentProfile,onOpenAgentChat:(p,h)=>i.onOpenAgentThread(p,{draft:h,focusComposer:!0}),onNudgeMessage:i.onNudgeMessage}):l.jsx("div",{className:"text-[11px] leading-[1.6]",style:r.styles.mutedText,children:"No broker-visible activity for this agent yet."}),i.selectedInterAgentActivityMessages.length>5&&!i.agentActivityExpanded?l.jsxs("button",{className:"w-full text-center py-2 text-[11px] font-medium hover:opacity-80 transition-opacity",style:{color:g.accent},onClick:()=>i.setAgentActivityExpanded(!0),children:["Show all ",i.selectedInterAgentActivityMessages.length," events"]}):null]})]}),l.jsx(ju,{open:i.agentThreadsExpanded,onOpenChange:i.setAgentThreadsExpanded,children:l.jsxs("section",{className:"border rounded-xl overflow-hidden",style:{...r.styles.surface,borderColor:g.border},children:[l.jsx(Nu,{asChild:!0,children:l.jsx("button",{className:"w-full px-4 py-3 flex items-center justify-between gap-3 hover:opacity-90 transition-opacity text-left",style:{backgroundColor:g.surface},children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(ql,{size:12,className:"transition-transform duration-150",style:{color:g.muted,transform:i.agentThreadsExpanded?"rotate(90deg)":void 0}}),l.jsx("div",{className:"text-[10px] font-mono tracking-widest uppercase",style:{color:g.accent},children:"Open Threads"}),l.jsx("span",{className:"text-[9px] font-mono px-1.5 py-0.5 rounded",style:r.styles.tagBadge,children:i.visibleInterAgentThreads.length+1})]})})}),l.jsx(wu,{children:l.jsxs("div",{className:"px-4 py-3 border-t flex flex-col gap-3",style:{borderTopColor:g.border},children:[l.jsxs("div",{className:"border rounded-lg px-3 py-3",style:{borderColor:g.border,backgroundColor:g.bg},children:[l.jsxs("div",{className:"flex items-start justify-between gap-3",children:[l.jsxs("div",{className:"min-w-0",children:[l.jsx("div",{className:"text-[13px] font-medium truncate",style:r.styles.inkText,children:"Direct Line"}),l.jsxs("div",{className:"text-[10px] truncate mt-1",style:r.styles.mutedText,children:["You and ",i.selectedInterAgent.title]})]}),l.jsx("span",{className:"text-[10px] font-mono shrink-0",style:r.styles.mutedText,children:i.selectedInterAgentDirectThread?.timestampLabel??i.selectedInterAgent.lastChatLabel??""})]}),l.jsx("div",{className:"text-[12px] leading-[1.55] mt-3",style:r.styles.mutedText,children:i.selectedAgentDirectLinePreview}),l.jsxs("div",{className:"flex items-center justify-between gap-3 mt-3",children:[l.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[l.jsx("span",{className:"text-[9px] font-mono uppercase px-1.5 py-0.5 rounded",style:r.styles.activePill,children:"Direct"}),l.jsx("span",{className:"text-[9px] font-mono uppercase px-1.5 py-0.5 rounded",style:r.styles.tagBadge,children:i.selectedInterAgent.statusLabel})]}),l.jsx("button",{className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded shrink-0",style:{color:g.ink},onClick:()=>i.onOpenAgentThread(i.selectedInterAgent.id,{focusComposer:!0}),children:i.selectedInterAgentChatActionLabel})]})]}),i.visibleInterAgentThreads.length>0?l.jsx("div",{className:"flex flex-col gap-3",children:i.visibleInterAgentThreads.map(p=>l.jsxs("div",{className:"border rounded-lg px-3 py-3",style:{borderColor:g.border,backgroundColor:i.selectedInterAgentThreadId===p.id?g.bg:g.surface},children:[l.jsxs("div",{className:"flex items-start justify-between gap-3",children:[l.jsxs("div",{className:"min-w-0",children:[l.jsx("div",{className:"text-[13px] font-medium truncate",style:r.styles.inkText,children:ep(p,i.selectedInterAgent.id)}),l.jsx("div",{className:"text-[10px] truncate mt-1",style:r.styles.mutedText,children:tp(p,i.selectedInterAgent.id)})]}),l.jsx("span",{className:"text-[10px] font-mono shrink-0",style:r.styles.mutedText,children:p.timestampLabel??""})]}),l.jsx("div",{className:"text-[12px] leading-[1.55] mt-3",style:r.styles.mutedText,children:p.preview??"No message preview yet."}),l.jsxs("div",{className:"flex items-center justify-between gap-3 mt-3",children:[l.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[l.jsx("span",{className:"text-[9px] font-mono uppercase px-1.5 py-0.5 rounded",style:p.sourceKind==="private"?r.styles.tagBadge:r.styles.activePill,children:p.sourceKind==="private"?"Private":"Targeted"}),l.jsxs("span",{className:"text-[9px] font-mono px-1.5 py-0.5 rounded",style:r.styles.tagBadge,children:[p.messageCount," msgs"]})]}),l.jsx("button",{className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded",style:{color:g.ink},onClick:()=>i.onOpenThreadInTrafficView(p.id),children:"Open"})]})]},p.id))}):l.jsx("div",{className:"flex flex-col items-start gap-3",children:l.jsx("div",{className:"text-[11px] leading-[1.5]",style:r.styles.mutedText,children:"No other active channels for this agent yet."})})]})})]})}),l.jsx(ju,{open:i.agentSnapshotExpanded,onOpenChange:i.setAgentSnapshotExpanded,children:l.jsxs("section",{className:"border rounded-xl overflow-hidden",style:{...r.styles.surface,borderColor:g.border},children:[l.jsx(Nu,{asChild:!0,children:l.jsxs("button",{className:"w-full px-4 py-3 flex items-center gap-2 hover:opacity-90 transition-opacity text-left",style:{backgroundColor:g.surface},children:[l.jsx(ql,{size:12,className:"transition-transform duration-150",style:{color:g.muted,transform:i.agentSnapshotExpanded?"rotate(90deg)":void 0}}),l.jsx("div",{className:"text-[10px] font-mono tracking-widest uppercase",style:{color:g.accent},children:"Operational Snapshot"})]})}),l.jsx(wu,{children:l.jsx("div",{className:"px-4 py-3 border-t",style:{borderTopColor:g.border},children:l.jsx("div",{className:"grid grid-cols-2 gap-x-4 gap-y-3",children:[["Harness",i.visibleAgentConfig?.runtime.harness??i.selectedInterAgent.harness??"Not reported"],["Session",i.visibleAgentConfig?.runtime.sessionId??i.selectedInterAgent.sessionId??"Not reported"],["Transport",i.visibleAgentConfig?.runtime.transport??i.selectedInterAgent.transport??"Not reported"],["Wake Policy",i.visibleAgentConfig?.runtime.wakePolicy||i.selectedInterAgent.wakePolicy||"Not reported"],["Last Chat",i.selectedInterAgent.lastChatLabel??"Not reported"],["Last Dev Session",i.selectedInterAgent.lastSessionLabel??"Not reported"],["Last Code Change",i.selectedInterAgent.lastCodeChangeLabel??"Not reported"]].map(([p,h])=>l.jsxs("div",{className:"min-w-0",children:[l.jsx("div",{className:"text-[9px] font-mono uppercase tracking-widest mb-1",style:r.styles.mutedText,children:p}),l.jsx("div",{className:"text-[11px] leading-[1.45] break-words",style:r.styles.inkText,children:h})]},p))})})})]})})]}):l.jsxs("div",{className:"flex flex-col items-center justify-center h-64 text-center",children:[l.jsx("div",{className:"w-16 h-16 rounded-full flex items-center justify-center mb-4",style:{backgroundColor:g.accentBg},children:l.jsx($i,{size:24,style:{color:g.accent}})}),l.jsx("h3",{className:"text-[15px] font-medium mb-1",style:r.styles.inkText,children:"No agent selected"}),l.jsx("p",{className:"text-[13px] max-w-sm",style:r.styles.mutedText,children:"Pick an agent from the left rail to inspect its profile, runtime binding, and recent communication."})]})})]})]})}if(e==="logs")return l.jsxs(l.Fragment,{children:[!r.isCollapsed&&l.jsxs("div",{style:{width:r.sidebarWidth,...r.styles.sidebar},className:"relative flex flex-col h-full border-r shrink-0 z-10 overflow-hidden",children:[l.jsx("div",{className:"absolute right-[-3px] top-0 bottom-0 w-1.5 cursor-col-resize hover:bg-indigo-400 z-20 transition-colors",onMouseDown:r.onResizeStart}),l.jsx("div",{className:"px-4 h-14 flex items-center border-b",style:{borderBottomColor:g.border},children:l.jsxs("div",{children:[l.jsx("h1",{className:"text-[13px] font-semibold tracking-tight",style:r.styles.inkText,children:"Logs"}),l.jsxs("div",{className:"text-[10px] font-mono mt-0.5",style:r.styles.mutedText,children:[o.logSources.length," sources"]})]})}),l.jsx("div",{className:"px-3 py-3 border-b",style:{borderBottomColor:g.border},children:l.jsx("input",{type:"text",value:o.logSourceQuery,onChange:f=>o.setLogSourceQuery(f.target.value),placeholder:"Filter sources…",className:"w-full rounded-lg border px-3 py-2 text-[11px] bg-transparent outline-none",style:{borderColor:g.border,color:g.ink}})}),l.jsx("div",{className:"flex-1 overflow-y-auto py-3",children:o.logSources.length===0?l.jsxs("div",{className:"px-4 py-6 text-center",children:[l.jsxs("div",{className:"flex justify-center gap-1 mb-2",children:[l.jsx("span",{className:"os-thinking-dot",style:{color:g.accent}}),l.jsx("span",{className:"os-thinking-dot",style:{color:g.accent}}),l.jsx("span",{className:"os-thinking-dot",style:{color:g.accent}})]}),l.jsx("div",{className:"text-[11px]",style:r.styles.mutedText,children:"Loading sources…"})]}):["runtime","app","agents"].map(f=>{const p=o.filteredLogSources.filter(y=>y.group===f);if(p.length===0)return null;const h=f==="runtime"?"Runtime":f==="app"?"App":"Agents";return l.jsxs("div",{className:"mb-3 px-2",children:[l.jsx("div",{className:"font-mono text-[9px] tracking-widest uppercase mb-1.5 px-2",style:r.styles.mutedText,children:h}),l.jsx("div",{className:"flex flex-col gap-px",children:p.map(y=>{const b=o.selectedLogSourceId===y.id;return l.jsxs("button",{onClick:()=>{o.setSelectedLogSourceId(y.id),o.setLogSearchQuery("")},className:"w-full text-left px-2 py-2 rounded transition-opacity hover:opacity-90",style:b?r.styles.activeItem:r.styles.mutedText,children:[l.jsx("div",{className:"text-[12px] font-medium truncate",style:r.styles.inkText,children:y.title}),l.jsx("div",{className:"text-[10px] truncate mt-0.5",style:r.styles.mutedText,children:y.subtitle})]},y.id)})})]},f)})})]}),l.jsxs("div",{className:"flex-1 flex flex-col relative min-w-0",style:r.styles.surface,children:[l.jsx("div",{className:"border-b flex items-center justify-between px-4 h-14 shrink-0 gap-4",style:{...r.styles.surface,borderBottomColor:g.border},children:l.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[l.jsx(No,{size:14,style:r.styles.mutedText}),l.jsxs("div",{className:"min-w-0",children:[l.jsx("div",{className:"text-[13px] font-semibold tracking-tight truncate",style:r.styles.inkText,children:o.selectedLogSource?.title??"Logs"}),l.jsx("div",{className:"text-[10px] truncate mt-0.5",style:r.styles.mutedText,children:o.logContent?.updatedAtLabel?`${o.selectedLogSource?.subtitle??"Log tail"} · Updated ${o.logContent.updatedAtLabel}`:o.selectedLogSource?.subtitle??"Relay runtime, app, and relay agent logs."})]})]})}),l.jsxs("div",{className:"border-b px-4 py-3 flex items-center gap-3",style:{borderBottomColor:g.border},children:[l.jsx("input",{type:"text",value:o.logSearchQuery,onChange:f=>o.setLogSearchQuery(f.target.value),placeholder:"Filter visible lines…",className:"flex-1 rounded-lg border px-3 py-2 text-[11px] bg-transparent outline-none",style:{borderColor:g.border,color:g.ink}}),l.jsx("div",{className:"text-[10px] font-mono shrink-0",style:r.styles.mutedText,children:o.logContent?o.logContent.truncated?`Tail ${o.logContent.lineCount} lines`:`${o.logContent.lineCount} lines`:"No file"})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto px-4 py-4",children:[o.selectedLogSource?l.jsx(U1,{title:o.selectedLogSource.title,pathLabel:o.logContent?.pathLabel??o.selectedLogSource.pathLabel,body:o.logContent?.body??null,truncated:o.logContent?.truncated,lineCount:o.logContent?.lineCount,missing:o.logContent?.missing,loading:o.logsLoading,searchQuery:o.logSearchQuery,updatedAtLabel:o.logContent?.updatedAtLabel,minHeight:360}):l.jsx("div",{className:"flex flex-col items-center justify-center h-64 text-center",children:o.logCatalog?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"w-16 h-16 rounded-full flex items-center justify-center mb-4",style:{backgroundColor:g.accentBg},children:l.jsx(No,{size:24,style:{color:g.accent}})}),l.jsx("h3",{className:"text-[15px] font-medium mb-1",style:r.styles.inkText,children:"No log selected"}),l.jsx("p",{className:"text-[13px] max-w-sm",style:r.styles.mutedText,children:"Pick a relay runtime, app, or relay agent source from the left rail."})]}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex justify-center gap-1 mb-3",children:[l.jsx("span",{className:"os-thinking-dot",style:{color:g.accent}}),l.jsx("span",{className:"os-thinking-dot",style:{color:g.accent}}),l.jsx("span",{className:"os-thinking-dot",style:{color:g.accent}})]}),l.jsx("p",{className:"text-[13px]",style:r.styles.mutedText,children:"Loading log sources…"})]})}),o.logsFeedback?l.jsx("div",{className:"text-[11px] leading-[1.5] mt-3",style:r.styles.inkText,children:o.logsFeedback}):null]}),l.jsx("div",{className:"h-7 border-t flex items-center justify-between px-4 shrink-0",style:{backgroundColor:g.bg,borderTopColor:g.border},children:l.jsx("span",{className:"text-[9px] font-mono",style:r.styles.mutedText,children:"Canonical relay runtime, app, and relay agent log tails"})})]})]});if(e==="inter-agent"){const f=a.rosterInterAgentAgents.length===a.interAgentAgents.length?a.interAgentStateSubtitle:`${a.rosterInterAgentAgents.length} visible · ${a.interAgentStateSubtitle}`;return l.jsxs(l.Fragment,{children:[l.jsx(Wy,{title:a.interAgentStateTitle,subtitle:f,layout:r,roster:a}),l.jsxs("div",{className:"w-[336px] border-r shrink-0 overflow-hidden flex flex-col",style:{...r.styles.surface,borderRightColor:g.border},children:[l.jsxs("div",{className:"px-4 h-14 border-b flex flex-col justify-center",style:{borderBottomColor:g.border},children:[l.jsx("div",{className:"text-[10px] font-mono tracking-widest uppercase",style:r.styles.mutedText,children:"Agent Threads"}),l.jsx("div",{className:"text-[12px] mt-1",style:r.styles.inkText,children:u.selectedInterAgent?`${u.selectedInterAgent.title} · ${u.visibleInterAgentThreads.length} thread${u.visibleInterAgentThreads.length===1?"":"s"}`:"Select an agent"})]}),l.jsx("div",{className:"flex-1 overflow-y-auto",children:u.selectedInterAgent&&u.visibleInterAgentThreads.length>0?l.jsx("div",{className:"divide-y",style:{borderColor:g.border},children:u.visibleInterAgentThreads.map(p=>{const h=u.selectedInterAgentThreadId===p.id;return l.jsxs("button",{onClick:()=>u.setSelectedInterAgentThreadId(p.id),className:"w-full text-left px-4 py-3.5 transition-opacity hover:opacity-90",style:h?{backgroundColor:g.bg}:void 0,children:[l.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1.5",children:[l.jsxs("div",{className:"min-w-0",children:[l.jsx("div",{className:"text-[12px] font-medium truncate",style:r.styles.inkText,children:ep(p,u.selectedInterAgent.id)}),l.jsx("div",{className:"mt-1",children:l.jsx("span",{className:"text-[9px] font-mono uppercase px-1.5 py-0.5 rounded",style:p.sourceKind==="private"?r.styles.tagBadge:r.styles.activePill,children:p.sourceKind==="private"?"Private":"Relay"})})]}),l.jsx("span",{className:"text-[10px] font-mono shrink-0",style:r.styles.mutedText,children:p.timestampLabel??""})]}),l.jsx("div",{className:"text-[10px] mb-1.5 truncate",style:r.styles.mutedText,children:tp(p,u.selectedInterAgent.id)}),l.jsx("div",{className:"text-[12px] leading-[1.45] line-clamp-2",style:r.styles.mutedText,children:p.preview??"No message preview yet."})]},p.id)})}):l.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:l.jsxs("div",{children:[l.jsx("div",{className:"w-14 h-14 rounded-full mx-auto mb-4 flex items-center justify-center",style:{backgroundColor:g.accentBg},children:l.jsx(Ki,{size:22,style:{color:g.accent}})}),l.jsx("div",{className:"text-[14px] font-medium mb-1",style:r.styles.inkText,children:"No agent threads"}),l.jsx("div",{className:"text-[12px]",style:r.styles.mutedText,children:u.selectedInterAgent?`No inter-agent traffic for ${u.selectedInterAgent.title} yet.`:"Pick an agent to inspect its thread network."})]})})})]}),l.jsxs("div",{className:"flex-1 flex flex-col relative min-w-0",style:r.styles.surface,children:[l.jsxs("div",{className:"border-b flex items-center justify-between px-4 h-14 shrink-0 gap-4",style:{...r.styles.surface,borderBottomColor:g.border},children:[l.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[l.jsx(Ki,{size:14,style:r.styles.mutedText}),l.jsxs("div",{className:"min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[l.jsx("h2",{className:"text-[13px] font-semibold tracking-tight truncate",style:r.styles.inkText,children:u.interAgentThreadTitle}),u.selectedInterAgentThread?l.jsx("span",{className:"text-[9px] font-mono uppercase px-1.5 py-0.5 rounded shrink-0",style:u.selectedInterAgentThread.sourceKind==="private"?r.styles.tagBadge:r.styles.activePill,children:u.selectedInterAgentThread.sourceKind==="private"?"Private":"Relay"}):null,u.selectedInterAgentThread?l.jsx("span",{className:"text-[9px] font-mono px-1.5 py-0.5 rounded shrink-0",style:r.styles.tagBadge,children:u.selectedInterAgentThread.messageCount}):null]}),l.jsx("div",{className:"text-[10px] truncate mt-0.5",style:r.styles.mutedText,children:u.selectedInterAgentThreadSubtitle})]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[u.selectedRelayDirectThread?l.jsxs("button",{className:"os-toolbar-button flex items-center gap-1.5 text-[10px] font-medium px-2 py-0.5 rounded",style:{color:g.ink},onClick:()=>u.onOpenAgentProfile(u.selectedRelayDirectThread.id),children:[l.jsx($i,{size:11}),l.jsx("span",{children:"Agent"})]}):null,l.jsxs("button",{onClick:()=>u.setShowAnnotations(!u.showAnnotations),className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded",style:u.showAnnotations?{backgroundColor:g.accentBg,color:g.accent}:{color:g.ink},children:["Annotations ",l.jsx("span",{className:"font-mono uppercase",children:u.showAnnotations?"On":"Off"})]}),u.interAgentMessageTarget?l.jsx("button",{className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded",style:{color:g.ink},onClick:()=>u.openAgentDirectMessage(u.interAgentMessageTarget.id),title:`Open direct chat with ${u.interAgentMessageTarget.title}`,children:"Message"}):null,u.interAgentConfigureTarget?l.jsx("button",{className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded",style:{color:g.ink},onClick:()=>u.onOpenAgentSettings(u.interAgentConfigureTarget.id,u.interAgentConfigureTarget.profileKind==="project"),title:u.interAgentConfigureTarget.profileKind==="project"?`Configure ${u.interAgentConfigureTarget.title}`:`Open ${u.interAgentConfigureTarget.title} profile`,children:u.interAgentConfigureLabel}):null]})]}),l.jsx("div",{className:"flex-1 overflow-y-auto px-4 py-3 pb-6",children:u.selectedInterAgent?u.selectedInterAgentThread?u.visibleInterAgentMessages.length===0?l.jsxs("div",{className:"flex flex-col items-center justify-center h-64 text-center",children:[l.jsx("div",{className:"w-16 h-16 rounded-full flex items-center justify-center mb-4",style:{backgroundColor:g.accentBg},children:l.jsx(Al,{size:24,style:{color:g.accent}})}),l.jsx("h3",{className:"text-[15px] font-medium mb-1",style:r.styles.inkText,children:"Thread is quiet"}),l.jsx("p",{className:"text-[13px] max-w-sm",style:r.styles.mutedText,children:"This agent thread exists, but there are no visible messages in it yet."})]}):l.jsx("div",{className:"flex flex-col gap-1",children:l.jsx(ko,{messages:u.visibleInterAgentMessages,showAnnotations:u.showAnnotations,showStatusMessages:!1,inkStyle:r.styles.inkText,mutedStyle:r.styles.mutedText,tagStyle:r.styles.tagBadge,annotStyle:r.styles.annotBadge,agentLookup:u.interAgentAgentLookup,directThreadLookup:u.relayDirectLookup,onOpenAgentProfile:u.onOpenAgentProfile,onOpenAgentChat:u.openAgentDirectMessage,onNudgeMessage:u.onNudgeMessage})}):l.jsxs("div",{className:"flex flex-col items-center justify-center h-64 text-center",children:[l.jsx("div",{className:"w-16 h-16 rounded-full flex items-center justify-center mb-4",style:{backgroundColor:g.accentBg},children:l.jsx(Al,{size:24,style:{color:g.accent}})}),l.jsx("h3",{className:"text-[15px] font-medium mb-1",style:r.styles.inkText,children:"No thread selected"}),l.jsxs("p",{className:"text-[13px] max-w-sm",style:r.styles.mutedText,children:["Pick one of ",u.selectedInterAgent.title,"'s agent threads to read it."]})]}):l.jsxs("div",{className:"flex flex-col items-center justify-center h-64 text-center",children:[l.jsx("div",{className:"w-16 h-16 rounded-full flex items-center justify-center mb-4",style:{backgroundColor:g.accentBg},children:l.jsx(Ki,{size:24,style:{color:g.accent}})}),l.jsx("h3",{className:"text-[15px] font-medium mb-1",style:r.styles.inkText,children:"No agent selected"}),l.jsx("p",{className:"text-[13px] max-w-sm",style:r.styles.mutedText,children:"Choose an agent from the left rail to inspect their traffic with other agents."})]})}),l.jsx("div",{className:"h-7 border-t flex items-center px-4 shrink-0",style:{backgroundColor:g.bg,borderTopColor:g.border},children:l.jsx("span",{className:"text-[9px] font-mono",style:r.styles.mutedText,children:"Read-only monitor over inter-agent traffic"})})]})]})}return e!=="sessions"?null:l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex-1 flex flex-col relative min-w-0",style:r.styles.surface,children:[l.jsxs("div",{className:"h-10 border-b flex items-center justify-between px-4 shrink-0",style:{...r.styles.surface,borderBottomColor:g.border},children:[l.jsxs("div",{className:"flex items-center gap-4 min-w-0 flex-1",children:[l.jsxs("div",{className:"min-w-0 shrink-0",children:[l.jsx("div",{className:"text-[13px] font-semibold tracking-tight",style:r.styles.inkText,children:"Sessions"}),l.jsx("div",{className:"text-[10px] font-mono mt-0.5",style:r.styles.mutedText,children:d.searchQuery?`${d.filteredSessions.length} results`:`${d.stats.totalSessions} total`})]}),l.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[l.jsx(wo,{size:14,style:r.styles.mutedText}),l.jsx("input",{type:"text",placeholder:"Search sessions by title, content, tags, or agent...",value:d.searchQuery,onChange:f=>d.setSearchQuery(f.target.value),className:"flex-1 bg-transparent border-none outline-none text-[12px]",style:{color:g.ink}}),d.searchQuery?l.jsx("button",{onClick:()=>d.setSearchQuery(""),className:"hover:opacity-70",style:r.styles.mutedText,children:l.jsx(kl,{size:14})}):null]})]}),l.jsx("div",{className:"flex items-center gap-2 shrink-0",children:l.jsx("button",{className:"p-1.5 rounded transition-opacity hover:opacity-70",style:r.styles.mutedText,onClick:d.onRefresh,children:l.jsx(xn,{size:14})})})]}),l.jsx("div",{className:"flex-1 overflow-y-auto",children:d.loadingSessions?l.jsx("div",{className:"flex items-center justify-center h-64",children:l.jsxs("div",{className:"flex flex-col items-center gap-3",children:[l.jsx(un,{className:"text-[28px]",style:{color:g.accent}}),l.jsx("span",{className:"text-[13px]",style:r.styles.mutedText,children:"Loading broker workspace…"})]})}):d.filteredSessions.length===0?l.jsxs("div",{className:"flex flex-col items-center justify-center h-64 text-center",children:[l.jsx("div",{className:"w-16 h-16 rounded-full flex items-center justify-center mb-4",style:{backgroundColor:g.accentBg},children:l.jsx(da,{size:24,style:{color:g.accent}})}),l.jsx("h3",{className:"text-[15px] font-medium mb-1",style:r.styles.inkText,children:"No sessions found"}),l.jsx("p",{className:"text-[13px] max-w-sm",style:r.styles.mutedText,children:d.searchQuery?"Try adjusting your search query":"No conversations are in the broker yet."})]}):l.jsx("div",{className:"divide-y",style:{borderColor:g.border},children:d.filteredSessions.map(f=>l.jsxs("button",{onClick:()=>d.setSelectedSession(f),draggable:!0,onDragStart:()=>{d.setDraggedSessionId(f.id),d.setDraggedPhoneSection(null)},onDragEnd:()=>{d.setDraggedSessionId(null),d.setDraggedPhoneSection(null)},className:"w-full text-left px-4 py-3 transition-opacity hover:opacity-90",style:d.selectedSession?.id===f.id?{backgroundColor:g.bg}:void 0,children:[l.jsxs("div",{className:"flex items-start justify-between mb-1",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("div",{className:"w-5 h-5 rounded text-white flex items-center justify-center text-[9px] font-bold",style:{backgroundColor:cl(f.agent)},children:f.agent.charAt(0)}),l.jsx("span",{className:"text-[13px] font-medium line-clamp-1",style:r.styles.inkText,children:f.title}),d.phonePreparationState.favorites.includes(f.id)?l.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full px-1.5 py-0.5 text-[9px] font-medium",style:{backgroundColor:g.accentBg,color:g.accent},children:[l.jsx(jb,{size:9}),"Fav"]}):null,!d.phonePreparationState.favorites.includes(f.id)&&d.phonePreparationState.quickHits.includes(f.id)?l.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full px-1.5 py-0.5 text-[9px] font-medium",style:{backgroundColor:g.tagBg,color:g.ink},children:[l.jsx(L2,{size:9}),"My List"]}):null]}),l.jsx("span",{className:"text-[10px] font-mono shrink-0 ml-2",style:r.styles.mutedText,children:d.formatDate(f.lastModified)})]}),l.jsxs("div",{className:"flex items-center gap-2 mb-1.5 pl-7",children:[l.jsx("span",{className:"text-[10px] font-mono",style:r.styles.mutedText,children:f.project}),l.jsx("span",{className:"w-px h-3",style:{backgroundColor:g.border}}),l.jsxs("span",{className:"text-[10px]",style:r.styles.mutedText,children:[f.messageCount," messages"]}),f.tokens?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"w-px h-3",style:{backgroundColor:g.border}}),l.jsxs("span",{className:"text-[10px]",style:r.styles.mutedText,children:[(f.tokens/1e3).toFixed(1),"k tokens"]})]}):null]}),l.jsx("p",{className:"text-[12px] line-clamp-1 pl-7",style:r.styles.mutedText,children:f.preview}),f.tags&&f.tags.length>0?l.jsxs("div",{className:"flex items-center gap-1.5 mt-2 pl-7",children:[f.tags.slice(0,3).map(p=>l.jsx("span",{className:"text-[9px] font-mono border px-1.5 py-0.5 rounded",style:r.styles.tagBadge,children:p},p)),f.tags.length>3?l.jsxs("span",{className:"text-[9px]",style:r.styles.mutedText,children:["+",f.tags.length-3]}):null]}):null]},f.id))})}),l.jsxs("div",{className:"h-7 border-t flex items-center justify-between px-4 shrink-0",style:{backgroundColor:g.bg,borderTopColor:g.border},children:[l.jsx("span",{className:"text-[9px] font-mono",style:r.styles.mutedText,children:"Drag sessions into My List or click one for quick actions."}),l.jsx("span",{className:"text-[9px] font-mono uppercase tracking-widest",style:r.styles.mutedText,children:"Index Ready"})]})]}),l.jsxs("div",{className:"w-80 border-l shrink-0 overflow-y-auto flex flex-col",style:{...r.styles.surface,borderLeftColor:g.border},children:[l.jsx("div",{className:"px-4 py-3 border-b",style:{borderBottomColor:g.border},children:l.jsxs("div",{className:"flex items-center justify-between gap-3",children:[l.jsxs("div",{className:"min-w-0",children:[l.jsx("div",{className:"text-[10px] font-mono tracking-widest uppercase mb-1",style:r.styles.mutedText,children:"My List"}),l.jsx("div",{className:"text-[12px] font-medium",style:r.styles.inkText,children:"My List first, then browse and search."})]}),l.jsx("button",{type:"button",onClick:d.onClearPhoneQuickHits,disabled:d.phonePreparationSaving||d.phonePreparationState.quickHits.length===0,className:"rounded px-2 py-1 text-[10px] font-medium transition-opacity hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-50",style:{backgroundColor:g.bg,color:g.ink,border:`1px solid ${g.border}`},children:"Clear"})]})}),l.jsx("div",{className:"p-4 flex-1 flex flex-col gap-4",children:d.phonePreparationLoading?l.jsxs("div",{className:"flex items-center gap-2 text-[12px]",style:r.styles.mutedText,children:[l.jsx(un,{className:"text-[12px]"}),"Loading list…"]}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"rounded-lg border p-3",style:{borderColor:g.border,backgroundColor:g.bg},onDragOver:f=>f.preventDefault(),onDrop:f=>{f.preventDefault(),d.onDropIntoFavorites()},children:[l.jsxs("div",{className:"flex items-center justify-between gap-2 mb-2",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(jb,{size:12,style:{color:g.accent}}),l.jsx("div",{className:"text-[11px] font-semibold",style:r.styles.inkText,children:"Favorites"})]}),l.jsx("div",{className:"text-[10px] font-mono",style:r.styles.mutedText,children:d.favoritePhoneSessions.length})]}),d.favoritePhoneSessions.length===0?l.jsx("div",{className:"rounded border border-dashed px-3 py-4 text-[11px]",style:{borderColor:g.border,color:g.muted},children:"Drop sessions here to keep them pinned in your list."}):l.jsx("div",{className:"flex flex-col gap-2",children:d.favoritePhoneSessions.map(f=>l.jsx("div",{draggable:!0,onDragStart:()=>{d.setDraggedSessionId(f.id),d.setDraggedPhoneSection("favorites")},onDragEnd:()=>{d.setDraggedSessionId(null),d.setDraggedPhoneSection(null)},className:"rounded border px-3 py-2",style:{borderColor:g.border,backgroundColor:g.surface},children:l.jsxs("div",{className:"flex items-start justify-between gap-2",children:[l.jsxs("div",{className:"min-w-0",children:[l.jsx("div",{className:"text-[12px] font-medium line-clamp-1",style:r.styles.inkText,children:f.title}),l.jsxs("div",{className:"text-[10px] mt-1",style:r.styles.mutedText,children:[f.project," · ",d.formatDate(f.lastModified)]})]}),l.jsx("button",{type:"button",onClick:()=>d.onRemoveSessionFromPhoneSection(f.id,"favorites"),className:"text-[10px] hover:opacity-70",style:r.styles.mutedText,children:l.jsx(kl,{size:12})})]})},`favorite-${f.id}`))})]}),l.jsxs("div",{className:"rounded-lg border p-3",style:{borderColor:g.border,backgroundColor:g.bg},onDragOver:f=>f.preventDefault(),onDrop:f=>{f.preventDefault(),d.onDropIntoQuickHits()},children:[l.jsxs("div",{className:"flex items-center justify-between gap-2 mb-2",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(j1,{size:12,style:{color:g.accent}}),l.jsx("div",{className:"text-[11px] font-semibold",style:r.styles.inkText,children:"My List"})]}),l.jsx("div",{className:"text-[10px] font-mono",style:r.styles.mutedText,children:d.quickHitPhoneSessions.length})]}),d.quickHitPhoneSessions.length===0?l.jsx("div",{className:"rounded border border-dashed px-3 py-4 text-[11px]",style:{borderColor:g.border,color:g.muted},children:"Drag sessions here and order them however you want."}):l.jsx("div",{className:"flex flex-col gap-2",children:d.quickHitPhoneSessions.map((f,p)=>l.jsx("div",{draggable:!0,onDragStart:()=>{d.setDraggedSessionId(f.id),d.setDraggedPhoneSection("quickHits")},onDragEnd:()=>{d.setDraggedSessionId(null),d.setDraggedPhoneSection(null)},onDragOver:h=>h.preventDefault(),onDrop:h=>{h.preventDefault(),d.onDropIntoQuickHits(p)},className:"rounded border px-3 py-2",style:{borderColor:g.border,backgroundColor:g.surface},children:l.jsxs("div",{className:"flex items-start justify-between gap-2",children:[l.jsxs("div",{className:"min-w-0",children:[l.jsxs("div",{className:"text-[11px] font-mono mb-1",style:r.styles.mutedText,children:["#",p+1]}),l.jsx("div",{className:"text-[12px] font-medium line-clamp-1",style:r.styles.inkText,children:f.title}),l.jsxs("div",{className:"text-[10px] mt-1",style:r.styles.mutedText,children:[f.project," · ",d.formatDate(f.lastModified)]})]}),l.jsx("button",{type:"button",onClick:()=>d.onRemoveSessionFromPhoneSection(f.id,"quickHits"),className:"text-[10px] hover:opacity-70",style:r.styles.mutedText,children:l.jsx(kl,{size:12})})]})},`quick-hit-${f.id}`))})]}),d.phonePreparationFeedback?l.jsx("div",{className:"rounded border px-3 py-2 text-[11px]",style:{borderColor:g.border,backgroundColor:g.surface,color:g.ink},children:d.phonePreparationFeedback}):null,l.jsxs("div",{className:"rounded-lg border p-3",style:{borderColor:g.border,backgroundColor:g.bg},children:[l.jsx("div",{className:"text-[10px] font-mono tracking-widest uppercase mb-2",style:r.styles.mutedText,children:"Selected Session"}),d.selectedSession?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[l.jsx("div",{className:"w-8 h-8 rounded text-white flex items-center justify-center text-[12px] font-bold",style:{backgroundColor:cl(d.selectedSession.agent)},children:d.selectedSession.agent.charAt(0)}),l.jsxs("div",{className:"min-w-0",children:[l.jsx("div",{className:"text-[12px] font-medium line-clamp-1",style:r.styles.inkText,children:d.selectedSession.title}),l.jsxs("div",{className:"text-[10px]",style:r.styles.mutedText,children:[d.selectedSession.project," · ",d.selectedSession.messageCount," messages"]})]})]}),l.jsx("p",{className:"text-[11px] leading-relaxed mb-3",style:r.styles.mutedText,children:d.selectedSession.preview}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("button",{type:"button",onClick:()=>d.onAddSessionToPhoneSection(d.selectedSession.id,"favorites"),disabled:d.phonePreparationSaving||d.phonePreparationState.favorites.includes(d.selectedSession.id),className:"flex-1 rounded px-3 py-2 text-[11px] font-medium transition-opacity hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-50",style:{backgroundColor:g.accentBg,color:g.accent},children:d.phonePreparationState.favorites.includes(d.selectedSession.id)?"Pinned":"Add to Favorites"}),l.jsx("button",{type:"button",onClick:()=>d.onAddSessionToPhoneSection(d.selectedSession.id,"quickHits"),disabled:d.phonePreparationSaving||d.phonePreparationState.quickHits.includes(d.selectedSession.id)||d.phonePreparationState.favorites.includes(d.selectedSession.id),className:"flex-1 rounded px-3 py-2 text-[11px] font-medium transition-opacity hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-50",style:{backgroundColor:g.surface,color:g.ink,border:`1px solid ${g.border}`},children:d.phonePreparationState.quickHits.includes(d.selectedSession.id)||d.phonePreparationState.favorites.includes(d.selectedSession.id)?"Already Added":"Add to My List"})]})]}):l.jsx("div",{className:"text-[11px]",style:r.styles.mutedText,children:"Select a session to pin it or add it to My List."})]})]})})]})]})}const xu=[{label:"Connecting relay service"},{label:"Loading agent availability"},{label:"Loading activity history"}];function zM(e){return e===0?420:195+Math.min(e,5)*12}const OM="11rem",Jy="w-[3.25rem]";function LM({color:e}){const r="0.2 0.2 0.4 0.8;0.2 0.2 0.4 0.8";return l.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 14 32 4",preserveAspectRatio:"none",className:"h-[6px] w-[3.25rem] shrink-0 overflow-visible",style:{color:e},"aria-hidden":!0,children:[l.jsx("path",{opacity:.8,fill:"currentColor",d:"M2 14 V18 H6 V14z",children:l.jsx("animateTransform",{attributeName:"transform",type:"translate",values:"0 0; 24 0; 0 0",dur:"2s",begin:"0s",repeatCount:"indefinite",keySplines:r,calcMode:"spline"})}),l.jsx("path",{opacity:.5,fill:"currentColor",d:"M0 14 V18 H8 V14z",children:l.jsx("animateTransform",{attributeName:"transform",type:"translate",values:"0 0; 24 0; 0 0",dur:"2s",begin:"0.1s",repeatCount:"indefinite",keySplines:r,calcMode:"spline"})}),l.jsx("path",{opacity:.25,fill:"currentColor",d:"M0 14 V18 H8 V14z",children:l.jsx("animateTransform",{attributeName:"transform",type:"translate",values:"0 0; 24 0; 0 0",dur:"2s",begin:"0.2s",repeatCount:"indefinite",keySplines:r,calcMode:"spline"})})]})}function e1({dark:e,C:r,s:a}){const[i,o]=z.useState(0);z.useEffect(()=>{if(i>=xu.length)return;const y=zM(i),b=setTimeout(()=>o(v=>v+1),y);return()=>clearTimeout(b)},[i]);const u=i>=xu.length,d=e?"rgba(241,245,249,0.92)":"rgba(15,23,42,0.82)",f=e?"rgba(255,255,255,0.08)":"rgba(15,23,42,0.06)",p=e?"rgba(255,255,255,0.14)":"rgba(15,23,42,0.08)",h=e?"rgba(255,255,255,0.05)":"rgba(15,23,42,0.035)";return l.jsxs("div",{className:"w-full max-w-[440px] os-fade-up",children:[l.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[l.jsx("img",{src:"/scout-icon.png",alt:"Scout",className:"w-9 h-9 rounded-lg shrink-0",style:{boxShadow:`0 2px 8px ${e?"rgba(0,0,0,0.4)":"rgba(15,23,42,0.08)"}`}}),l.jsxs("div",{className:"min-w-0",children:[l.jsx("div",{className:"text-[15px] font-semibold tracking-tight",style:a.inkText,children:"Scout"}),l.jsx("div",{className:"text-[10px] font-mono uppercase tracking-[0.18em]",style:a.mutedText,children:"Initializing"})]})]}),l.jsx("div",{className:"rounded-lg border overflow-hidden font-mono text-[11px] leading-[1.7] flex flex-col",style:{borderColor:r.border,backgroundColor:r.termBg,color:r.termFg,minHeight:OM},children:l.jsx("div",{className:"flex flex-col flex-1 px-4 py-3 min-h-0",children:l.jsx("div",{className:"space-y-2 shrink-0",children:xu.map((y,b)=>{const v=b<i,j=b===i-1&&!u;return l.jsxs("div",{className:"os-boot-line flex items-center justify-between gap-3 min-h-[1.9em] rounded-md px-2",style:{backgroundColor:v?e?"rgba(255,255,255,0.04)":"rgba(15,23,42,0.035)":"transparent",opacity:v?1:.38},children:[l.jsx("div",{className:"min-w-0 flex items-center gap-3",children:l.jsx("span",{className:"os-boot-line-text min-w-0 truncate",style:{color:r.termFg,opacity:j?1:v?.72:.45},children:y.label})}),l.jsx("div",{className:"shrink-0 min-w-[1.25rem] flex justify-end",children:v?l.jsx("span",{className:"os-boot-prompt inline-flex h-5 min-w-5 items-center justify-center rounded-full border px-1.5 text-[12px] font-semibold leading-none",style:{color:j?r.accent:d,backgroundColor:j?h:f,borderColor:j?"transparent":p,opacity:j?1:.95},"aria-hidden":!0,children:j?"…":"✓"}):null})]},y.label)})})})}),l.jsxs("div",{className:"relative mt-5 h-5",children:[l.jsxs("div",{className:"os-boot-footer-track absolute inset-x-3 top-0 bottom-0 flex items-center gap-3 min-w-0",style:{opacity:u?0:1,transform:u?"translateY(2px)":"translateY(0)",pointerEvents:u?"none":"auto"},children:[l.jsx("div",{className:`${Jy} shrink-0`,"aria-hidden":!0}),l.jsxs("span",{className:"text-[10px] font-mono tabular-nums tracking-tight leading-none",style:a.mutedText,children:[i," of ",xu.length]})]}),l.jsxs("div",{className:"os-boot-footer-track absolute inset-x-3 top-0 bottom-0 flex items-center gap-3 min-w-0",style:{opacity:u?1:0,transform:u?"translateY(0)":"translateY(-2px)",pointerEvents:u?"auto":"none"},children:[l.jsxs("div",{className:`os-boot-footer-lead ${Jy} shrink-0 flex items-center justify-center`,"aria-hidden":!0,children:[l.jsx("div",{className:"os-boot-wait-wave-wrap",children:l.jsx(LM,{color:r.accent})}),l.jsx("div",{className:"os-boot-wait-static-row",children:[.8,.5,.25].map((y,b)=>l.jsx("span",{className:"w-[3px] h-1 rounded-[1px]",style:{backgroundColor:r.accent,opacity:y}},b))})]}),l.jsx("span",{className:"text-[10px] font-mono tracking-tight leading-none truncate",style:a.mutedText,children:"Finishing up"})]})]})]})}const rt={getAppInfo:"scout:get-app-info",getServicesState:"scout:get-services-state",getHomeState:"scout:get-home-state",getMessagesWorkspaceState:"scout:get-messages-workspace-state",getRelayShellPatch:"scout:get-relay-shell-patch",getShellState:"scout:get-shell-state",refreshRelayShellPatch:"scout:refresh-relay-shell-patch",refreshShellState:"scout:refresh-shell-state",getAppSettings:"scout:get-app-settings",refreshSettingsInventory:"scout:refresh-settings-inventory",updateAppSettings:"scout:update-app-settings",retireProject:"scout:retire-project",restoreProject:"scout:restore-project",runOnboardingCommand:"scout:run-onboarding-command",skipOnboarding:"scout:skip-onboarding",restartOnboarding:"scout:restart-onboarding",getAgentConfig:"scout:get-agent-config",updateAgentConfig:"scout:update-agent-config",createAgent:"scout:create-agent",pickDirectory:"scout:pick-directory",reloadApp:"scout:reload-app",quitApp:"scout:quit-app",revealPath:"scout:reveal-path",getPhonePreparation:"scout:get-phone-preparation",updatePhonePreparation:"scout:update-phone-preparation",getPairingState:"scout:get-pairing-state",refreshPairingState:"scout:refresh-pairing-state",controlPairingService:"scout:control-pairing-service",updatePairingConfig:"scout:update-pairing-config",decidePairingApproval:"scout:decide-pairing-approval",restartAgent:"scout:restart-agent",sendRelayMessage:"scout:send-relay-message",controlBroker:"scout:control-broker",getKeepAliveState:"scout:get-keep-alive-state",acquireKeepAliveLease:"scout:acquire-keep-alive-lease",releaseKeepAliveLease:"scout:release-keep-alive-lease",getAgentSession:"scout:get-agent-session",openAgentSession:"scout:open-agent-session",toggleVoiceCapture:"scout:toggle-voice-capture",setVoiceRepliesEnabled:"scout:set-voice-replies-enabled",getLogCatalog:"scout:get-log-catalog",getBrokerInspector:"scout:get-broker-inspector",getFeedbackBundle:"scout:get-feedback-bundle",submitFeedbackReport:"scout:submit-feedback-report",readLogSource:"scout:read-log-source"};function DM(e){return{isDesktop:!0,getAppInfo:()=>e(rt.getAppInfo),getServicesState:()=>e(rt.getServicesState),getHomeState:()=>e(rt.getHomeState),getMessagesWorkspaceState:()=>e(rt.getMessagesWorkspaceState),getRelayShellPatch:()=>e(rt.getRelayShellPatch),getShellState:()=>e(rt.getShellState),refreshRelayShellPatch:()=>e(rt.refreshRelayShellPatch),refreshShellState:()=>e(rt.refreshShellState),getAppSettings:()=>e(rt.getAppSettings),refreshSettingsInventory:()=>e(rt.refreshSettingsInventory),updateAppSettings:r=>e(rt.updateAppSettings,r),retireProject:r=>e(rt.retireProject,r),restoreProject:r=>e(rt.restoreProject,r),runOnboardingCommand:r=>e(rt.runOnboardingCommand,r),skipOnboarding:()=>e(rt.skipOnboarding),restartOnboarding:()=>e(rt.restartOnboarding),getAgentConfig:r=>e(rt.getAgentConfig,r),updateAgentConfig:r=>e(rt.updateAgentConfig,r),createAgent:r=>e(rt.createAgent,r),pickDirectory:()=>e(rt.pickDirectory),reloadApp:()=>e(rt.reloadApp),quitApp:()=>e(rt.quitApp),revealPath:r=>e(rt.revealPath,r),getPhonePreparation:()=>e(rt.getPhonePreparation),updatePhonePreparation:r=>e(rt.updatePhonePreparation,r),getPairingState:()=>e(rt.getPairingState),refreshPairingState:()=>e(rt.refreshPairingState),controlPairingService:r=>e(rt.controlPairingService,r),updatePairingConfig:r=>e(rt.updatePairingConfig,r),decidePairingApproval:r=>e(rt.decidePairingApproval,r),restartAgent:r=>e(rt.restartAgent,r),sendRelayMessage:r=>e(rt.sendRelayMessage,r),controlBroker:r=>e(rt.controlBroker,r),getKeepAliveState:()=>e(rt.getKeepAliveState),acquireKeepAliveLease:r=>e(rt.acquireKeepAliveLease,r),releaseKeepAliveLease:r=>e(rt.releaseKeepAliveLease,r),getAgentSession:r=>e(rt.getAgentSession,r),openAgentSession:r=>e(rt.openAgentSession,r),toggleVoiceCapture:()=>e(rt.toggleVoiceCapture),setVoiceRepliesEnabled:r=>e(rt.setVoiceRepliesEnabled,r),getLogCatalog:()=>e(rt.getLogCatalog),getBrokerInspector:()=>e(rt.getBrokerInspector),getFeedbackBundle:()=>e(rt.getFeedbackBundle),submitFeedbackReport:r=>e(rt.submitFeedbackReport,r),readLogSource:r=>e(rt.readLogSource,r)}}const _M={"scout:get-app-info":{method:"GET",path:"/api/app"},"scout:get-services-state":{method:"GET",path:"/api/services"},"scout:get-home-state":{method:"GET",path:"/api/home"},"scout:get-messages-workspace-state":{method:"GET",path:"/api/messages-workspace"},"scout:get-relay-shell-patch":{method:"GET",path:"/api/relay-shell-patch"},"scout:get-shell-state":{method:"GET",path:"/api/shell-state"},"scout:refresh-relay-shell-patch":{method:"GET",path:"/api/relay-shell-patch/refresh"},"scout:refresh-shell-state":{method:"GET",path:"/api/shell-state/refresh"},"scout:get-app-settings":{method:"GET",path:"/api/app-settings"},"scout:refresh-settings-inventory":{method:"GET",path:"/api/app-settings/refresh"},"scout:update-app-settings":{method:"POST",path:"/api/app-settings"},"scout:retire-project":{method:"POST",path:"/api/retire-project"},"scout:restore-project":{method:"POST",path:"/api/restore-project"},"scout:run-onboarding-command":{method:"POST",path:"/api/onboarding/run"},"scout:skip-onboarding":{method:"POST",path:"/api/onboarding/skip"},"scout:restart-onboarding":{method:"POST",path:"/api/onboarding/restart"},"scout:get-agent-config":{method:"GET",path:e=>`/api/agent-config/${e[0]}`},"scout:update-agent-config":{method:"POST",path:"/api/agent-config"},"scout:create-agent":{method:"POST",path:"/api/agent/create"},"scout:pick-directory":{method:"GET",path:"/api/pick-directory"},"scout:quit-app":{method:"POST",path:"/api/quit"},"scout:reveal-path":{method:"POST",path:"/api/reveal-path"},"scout:get-phone-preparation":{method:"GET",path:"/api/phone-preparation"},"scout:update-phone-preparation":{method:"POST",path:"/api/phone-preparation"},"scout:get-pairing-state":{method:"GET",path:"/api/pairing-state"},"scout:refresh-pairing-state":{method:"GET",path:"/api/pairing-state/refresh"},"scout:control-pairing-service":{method:"POST",path:"/api/pairing/control"},"scout:update-pairing-config":{method:"POST",path:"/api/pairing/config"},"scout:restart-agent":{method:"POST",path:"/api/agent/restart"},"scout:send-relay-message":{method:"POST",path:"/api/relay/send"},"scout:control-broker":{method:"POST",path:"/api/broker/control"},"scout:get-keep-alive-state":{method:"GET",path:"/api/keep-alive"},"scout:acquire-keep-alive-lease":{method:"POST",path:"/api/keep-alive/acquire"},"scout:release-keep-alive-lease":{method:"POST",path:"/api/keep-alive/release"},"scout:get-agent-session":{method:"GET",path:e=>`/api/agent-session/${e[0]}`},"scout:open-agent-session":{method:"POST",path:e=>`/api/agent-session/${e[0]}/open`},"scout:toggle-voice-capture":{method:"POST",path:"/api/voice/toggle-capture"},"scout:set-voice-replies-enabled":{method:"POST",path:"/api/voice/replies"},"scout:get-log-catalog":{method:"GET",path:"/api/log-catalog"},"scout:get-broker-inspector":{method:"GET",path:"/api/broker-inspector"},"scout:get-feedback-bundle":{method:"GET",path:"/api/feedback-bundle"},"scout:submit-feedback-report":{method:"POST",path:"/api/feedback-report"},"scout:read-log-source":{method:"POST",path:"/api/log-source"}};function BM(){return typeof window<"u"&&window.location.origin?window.location.origin:"http://localhost:3200"}async function t1(e,r){const a=await e.text();if(!e.ok){let i=a.trim()||`HTTP ${e.status}`;if(a.length>0)try{const o=JSON.parse(a);typeof o.error=="string"&&o.error.trim()&&(i=o.detail?`${o.error}: ${o.detail}`:o.error)}catch{}throw new Error(`${r} → ${i}`)}if(!a.length)return null;try{return JSON.parse(a)}catch{throw new Error(`${r} → response is not JSON`)}}async function IM(e,...r){if(e==="scout:reload-app")return typeof window<"u"&&window.location.reload(),!0;const a=_M[e];if(!a)return console.warn(`[web-bridge] unknown channel: ${e}`),null;const i=BM(),o=typeof a.path=="function"?a.path(r):a.path,u=`${i}${o}`;if(a.method==="GET"){const p=await fetch(u);return t1(p,u)}const d=r[0]!==void 0?r[0]:{},f=await fetch(u,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(d)});return t1(f,u)}function PM(){return{...DM(IM),isDesktop:!1}}let Ym=null;function UM(){return typeof window>"u"?null:window.scoutDesktop?window.scoutDesktop:(Ym||(Ym=PM()),Ym)}function HM({activeView:e,selectedMessagesThread:r,selectedRelayKind:a,selectedRelayId:i,selectedInterAgentId:o}){return e==="messages"?r?.kind==="relay"&&a==="direct"?i:null:e==="agents"?o:null}function n1(e){return{runtime:{cwd:e.runtime.cwd,harness:e.runtime.harness,sessionId:e.runtime.sessionId,transport:e.runtime.transport},systemPrompt:e.systemPrompt,toolUse:{launchArgsText:e.toolUse.launchArgsText},capabilitiesText:e.capabilitiesText}}function FM({activeView:e,scoutDesktop:r,surfaceCaps:a,interAgentState:i,interAgentAgents:o,interAgentThreads:u,relayState:d,selectedMessagesThread:f,selectedMessagesDetailAgentId:p,selectedRelayKind:h,selectedRelayId:y,agentableProjects:b,visibleAppSettings:v,isAppSettingsEditing:j,appSettingsDirty:C,setAppSettings:E,setAppSettingsDraft:w,setActiveView:M,setSettingsSection:D,setSettingsAgentId:H,setShellState:X,setShellError:q,setRelayFeedback:L}){const[B,F]=z.useState(null),[Z,O]=z.useState(null),[P,Q]=z.useState("all"),[oe,J]=z.useState("chat"),[ee,N]=z.useState(!1),[Y,$]=z.useState(!1),[ye,T]=z.useState(!1),[_,le]=z.useState(!1),[R,pe]=z.useState(null),[xe,ce]=z.useState(null),[Re,Te]=z.useState(null),[Ne,He]=z.useState(!1),[Le,Ue]=z.useState(!1),[it,tt]=z.useState(!1),[st,ot]=z.useState(null),[bt,Ye]=z.useState(null),[Ge,We]=z.useState(!1),[we,et]=z.useState(!1),[Se,Ze]=z.useState(()=>Em(b,v)),[mt,ae]=z.useState(!1),[ge,Ce]=z.useState(null),[_e,Xe]=z.useState(null),[Ae,ue]=z.useState(!1),[Ee,V]=z.useState(null),[me,je]=z.useState(!1),[Fe,Je]=z.useState(0),[qe,St]=z.useState(!1),Yt=z.useRef(null),Vt=z.useRef(null),Pt=z.useRef(null),yt=z.useRef(!0),Wt=z.useRef(!0),se=z.useMemo(()=>[...o.filter(Ke=>P==="all"?!0:Bb(Ke))].sort((Ke,zt)=>Pb(Ke,zt,oe)),[P,oe,o]),Me=z.useMemo(()=>{const ve=new Map;for(const Ke of se)ve.set(Ke.title,(ve.get(Ke.title)??0)+1);return ve},[se]),ze=z.useMemo(()=>o.find(ve=>ve.id===B)??null,[o,B]),nt=z.useMemo(()=>u.filter(ve=>ve.participants.some(Ke=>Ke.id===B)),[u,B]),Qt=z.useMemo(()=>nt.find(ve=>ve.id===Z)??null,[Z,nt]),gn=z.useMemo(()=>ze?d?.directs.find(ve=>ve.id===ze.id)??null:null,[d,ze]),ha=gn?.preview||gn?.timestampLabel?"Open Chat":"Start Chat",Gl=gn?.preview||gn?.timestampLabel?pv(gn):ze?`${ze.title} is ready for a direct message.`:"Direct line available.",xa=z.useMemo(()=>Em(b,v),[b,v]),bn=B&&(Re??xe)?.agentId===B?Re??xe:null,Wa=!!(xe?.editable&&bn),ga=z.useCallback(ve=>{Te(Ke=>Ke&&ve(Ke)),ot(null)},[]),Un=z.useMemo(()=>Ub(Re)!==Ub(xe),[Re,xe]),$t=z.useMemo(()=>{const ve=HS(bn?.capabilitiesText??"");return ve.length>0?ve:ze?.capabilities??[]},[ze?.capabilities,bn?.capabilitiesText]),dn=Ge&&Un?"Save + Restart":"Restart Agent",Ht=z.useMemo(()=>HM({activeView:e,selectedMessagesThread:f,selectedRelayKind:h,selectedRelayId:y,selectedInterAgentId:B}),[e,B,f,y,h]),$l=!!(B&&r?.getAgentConfig&&e==="settings"&&Ge),Ml=!!(Ht&&r?.getAgentSession&&(qe||_)),Yl=_e?.agentId===p||_e?.agentId===B?_e:null,ns=Ae&&!Yl;z.useEffect(()=>{if(!i)return;const ve=i.agents,Ke=ve.filter(_n=>P==="all"?!0:Bb(_n)).sort((_n,Tr)=>Pb(_n,Tr,oe)),zt=e==="agents"||e==="inter-agent"?Ke:ve;if(!zt.length){F(null),O(null);return}const yn=zt.find(_n=>_n.threadCount>0)?.id??zt[0]?.id??null,ti=zt.some(_n=>_n.id===B)?B:yn;ti!==B&&F(ti);const vn=i.threads.filter(_n=>_n.participants.some(Tr=>Tr.id===ti)),Cr=vn.some(_n=>_n.id===Z)?Z:vn[0]?.id??null;Cr!==Z&&O(Cr)},[e,P,oe,i,B,Z]),z.useEffect(()=>{if(!B){ce(null),Te(null),ot(null),He(!1),N(!1),$(!1),T(!1);return}if(!$l){He(!1);return}const ve=r;if(!ve?.getAgentConfig){He(!1);return}let Ke=!1;return(async()=>{He(!0);try{const yn=await ve.getAgentConfig(B);if(Ke)return;ce(yn),Te(yn),ot(null),(!bt||bt!==B)&&We(!1)}catch(yn){if(Ke)return;ce(null),Te(null),ot(lt(yn)),We(!1)}finally{Ke||He(!1)}})(),()=>{Ke=!0}},[bt,r,B,$l]),z.useEffect(()=>{if(!Ht){Xe(null),V(null),je(!1),ue(!1);return}if(!Ml){ue(!1);return}const ve=r;if(!ve?.getAgentSession){ue(!1);return}let Ke=!1;return(async()=>{ue(!0);try{const yn=await ve.getAgentSession(Ht);if(Ke)return;Xe(yn),V(null)}catch(yn){if(Ke)return;Xe(null),V(lt(yn))}finally{Ke||ue(!1)}})(),()=>{Ke=!0}},[Fe,Ht,r,Ml]),z.useEffect(()=>{V(null),je(!1)},[Ht]),z.useEffect(()=>{e!=="agents"&&e!=="messages"&&St(!1)},[e]),z.useEffect(()=>{if(!qe)return;const ve=Ke=>{Ke.key==="Escape"&&St(!1)};return window.addEventListener("keydown",ve),()=>window.removeEventListener("keydown",ve)},[qe]);const Wn=z.useCallback(ve=>ve?ve.scrollHeight-ve.scrollTop-ve.clientHeight<=48:!0,[]),zl=z.useCallback(ve=>{ve&&(ve.scrollTop=ve.scrollHeight)},[]);z.useEffect(()=>{yt.current=!0,Wt.current=!0},[qe,B]),z.useEffect(()=>{if(!Ht||!Ml)return;const ve=window.setInterval(()=>{Je(Ke=>Ke+1)},qe?1600:2500);return()=>{window.clearInterval(ve)}},[Ht,qe,Ml]),z.useEffect(()=>{if(!me)return;const ve=window.setTimeout(()=>{je(!1)},1500);return()=>{window.clearTimeout(ve)}},[me]),z.useEffect(()=>{if(e!=="settings"||!bt||B!==bt||Ne)return;const ve=Yt.current;if(!ve)return;const Ke=window.requestAnimationFrame(()=>{if(ve.scrollIntoView({block:"center",behavior:"smooth"}),ve.focus(),"value"in ve&&typeof ve.value=="string"){const zt=ve.value.length;ve.setSelectionRange?.(zt,zt)}Ye(zt=>zt===bt?null:zt)});return()=>{window.cancelAnimationFrame(Ke)}},[e,bt,B,Re,Ne]),z.useEffect(()=>{e!=="agents"||!Ge||(We(!1),Ye(null))},[e,Ge]),z.useEffect(()=>{if(!Yl?.body)return;const ve=window.requestAnimationFrame(()=>{yt.current&&zl(Vt.current),qe&&Wt.current&&zl(Pt.current)});return()=>window.cancelAnimationFrame(ve)},[qe,zl,Yl?.agentId,Yl?.body,Yl?.updatedAtLabel]);const dl=z.useCallback(ve=>{F(ve),O(BS(u,ve))},[u]),Ol=z.useCallback((ve,Ke=!1)=>{dl(ve),D("agents"),H(ve),M("settings"),We(Ke),Ye(Ke?ve:null)},[dl,M,H,D]),Sr=z.useCallback(()=>{We(!1),Ye(null)},[]),Ll=z.useCallback(()=>{F(null),O(null),We(!1),Ye(null),ot(null)},[]),Ft=z.useCallback(()=>{Ze(Em(b,v)),Ce(null),et(!0)},[b,v]),ba=z.useCallback(()=>{(async()=>{try{if(!a?.canPickDirectory||!r?.pickDirectory)return;const ve=await r.pickDirectory();if(!ve)return;Ze(Ke=>({...Ke,projectPath:ve})),Ce(null)}catch(ve){Ce(lt(ve))}})()},[r,a]),ya=z.useCallback(()=>{(async()=>{if(!r?.createAgent){Ce("Desktop bridge is unavailable.");return}const ve=Se.projectPath.trim();if(!ve){Ce("Choose a project path first.");return}ae(!0),Ce(null);try{const Ke=await r.createAgent({projectPath:ve,agentName:Se.agentName.trim()||null,harness:Se.harness});if(X(Ke.shellState),q(null),L(`Created ${Ke.agentId}.`),F(Ke.agentId),O(null),M("agents"),et(!1),r.refreshSettingsInventory)try{const zt=await r.refreshSettingsInventory();E(zt),(!j||!C)&&w(zt)}catch{}}catch(Ke){Ce(lt(Ke))}finally{ae(!1)}})()},[C,Se,j,r,M,E,w,L,q,X]),Dl=z.useCallback(()=>{M("settings"),D("agents"),B&&H(B),We(!0),B&&Ye(B)},[B,M,H,D]),Ql=z.useCallback(()=>{Te(xe),ot(null),We(!1)},[xe]),Lo=z.useCallback(async()=>{if(!(!B||!bn||!r?.updateAgentConfig)){Ue(!0);try{const ve=await r.updateAgentConfig({agentId:B,...n1(bn)});ce(ve),Te(ve),ot("Agent settings saved."),We(!1)}catch(ve){ot(lt(ve))}finally{Ue(!1)}}},[r,B,bn]),ls=z.useCallback(async()=>{if(!(!B||!bn||!r?.restartAgent)){tt(!0);try{let ve=bn;Un&&r.updateAgentConfig&&(Ue(!0),ve=await r.updateAgentConfig({agentId:B,...n1(bn)}),ce(ve),Te(ve),Ue(!1));const Ke=await r.restartAgent({agentId:B,previousSessionId:ze?.sessionId??xe?.runtime.sessionId??null});X(Ke),q(null),ot(`${ze?.title??"Agent"} restarted.`),We(!1)}catch(ve){ot(lt(ve))}finally{Ue(!1),tt(!1)}}},[xe,Un,r,ze,B,q,X,bn]),Ja=z.useCallback(async()=>{if(!(!a?.canOpenNativeSession||!Ht||!r?.openAgentSession))try{await r.openAgentSession(Ht),V(_e?.mode==="tmux"?"Opening tmux session in Terminal.":"Opening session logs.")}catch(ve){V(lt(ve))}},[_e?.mode,Ht,r,a]),rs=z.useCallback(async()=>{if(_e?.commandLabel)try{await uk(_e.commandLabel),je(!0),V("Attach command copied.")}catch(ve){V(lt(ve))}},[_e]),Xl=z.useCallback(()=>{Je(ve=>ve+1)},[]),_l=z.useCallback(()=>{V(null),St(!0),Xl()},[Xl]),Hn=z.useCallback(()=>{St(!1)},[]),Xt=z.useCallback(ve=>{yt.current=Wn(ve.currentTarget)},[Wn]),ei=z.useCallback(ve=>{Wt.current=Wn(ve.currentTarget)},[Wn]);return{selectedInterAgentId:B,selectedInterAgentThreadId:Z,setSelectedInterAgentThreadId:O,agentRosterFilter:P,setAgentRosterFilter:Q,agentRosterSort:oe,setAgentRosterSort:J,agentThreadsExpanded:ee,setAgentThreadsExpanded:N,agentSnapshotExpanded:Y,setAgentSnapshotExpanded:$,agentActivityExpanded:ye,setAgentActivityExpanded:T,agentSessionLogsExpanded:_,setAgentSessionLogsExpanded:le,agentRosterMenu:R,setAgentRosterMenu:pe,selectedInterAgent:ze,rosterInterAgentAgents:se,rosterAgentTitleCounts:Me,visibleInterAgentThreads:nt,selectedInterAgentDirectThread:gn,selectedInterAgentThread:Qt,selectedInterAgentChatActionLabel:ha,selectedAgentDirectLinePreview:Gl,isAgentConfigEditing:Ge,visibleAgentConfig:bn,hasEditableAgentConfig:Wa,agentConfigLoading:Ne,agentConfigSaving:Le,agentConfigRestarting:it,agentConfigFeedback:st,agentCapabilitiesPreview:$t,agentRuntimePathRef:Yt,updateAgentConfigDraft:ga,agentConfigDirty:Un,agentRestartActionLabel:dn,handleSelectInterAgent:dl,handleOpenAgentSettings:Ol,deactivateAgentConfigEdit:Sr,resetAgentInspector:Ll,handleStartAgentConfigEdit:Dl,handleCancelAgentConfigEdit:Ql,handleSaveAgentConfig:Lo,handleRestartAgent:ls,isCreateAgentDialogOpen:we,setIsCreateAgentDialogOpen:et,createAgentDraft:Se,setCreateAgentDraft:Ze,createAgentDefaults:xa,createAgentSubmitting:mt,createAgentFeedback:ge,setCreateAgentFeedback:Ce,handleOpenCreateAgentDialog:Ft,handleBrowseCreateAgentProject:ba,handleCreateAgent:ya,visibleAgentSession:Yl,agentSessionPending:ns,agentSessionLoading:Ae,agentSessionFeedback:Ee,agentSessionCopied:me,isAgentSessionPeekOpen:qe,closeAgentSessionPeek:Hn,agentSessionInlineViewportRef:Vt,handleInlineAgentSessionScroll:Xt,agentSessionPeekViewportRef:Pt,handlePeekAgentSessionScroll:ei,handleOpenAgentSession:Ja,handleCopyAgentSessionCommand:rs,handlePeekAgentSession:_l,refreshAgentSession:Xl}}async function qM(e){if(typeof navigator<"u"&&navigator.clipboard?.writeText){await navigator.clipboard.writeText(e);return}if(typeof document<"u"){const r=document.createElement("textarea");r.value=e,r.setAttribute("readonly","true"),r.style.position="fixed",r.style.opacity="0",document.body.appendChild(r),r.select();const a=document.execCommand("copy");if(document.body.removeChild(r),a)return}throw new Error("Clipboard unavailable.")}function VM({activeView:e,settingsSection:r,scoutDesktop:a,surfaceCaps:i,pendingBrokerInspectorFocus:o,setPendingBrokerInspectorFocus:u,relayServiceInspectorRef:d,loadShellState:f,setShellState:p,setShellError:h,applyRestartedOnboardingSettings:y,commitPairingState:b,pairingState:v,setAppSettingsFeedback:j,setRelayFeedback:C,setPairingError:E,setPairingConfigFeedback:w}){const[M,D]=z.useState(null),[H,X]=z.useState(null),[q,L]=z.useState(null),[B,F]=z.useState(null),[Z,O]=z.useState(!1),[P,Q]=z.useState(null),[oe,J]=z.useState(!1),[ee,N]=z.useState(null),[Y,$]=z.useState(!1),[ye,T]=z.useState(null),[_,le]=z.useState(""),[R,pe]=z.useState(null),[xe,ce]=z.useState(null),[Re,Te]=z.useState(null),[Ne,He]=z.useState(!1),[Le,Ue]=z.useState(null),[it,tt]=z.useState(""),[st,ot]=z.useState(""),[bt,Ye]=z.useState(0),Ge=M?.sources??[],We=z.useMemo(()=>{const ue=st.trim().toLowerCase();return ue?Ge.filter(Ee=>Ee.title.toLowerCase().includes(ue)||Ee.subtitle.toLowerCase().includes(ue)):Ge},[st,Ge]),we=Ge.find(ue=>ue.id===H)??null,et=z.useCallback(()=>{Ye(ue=>ue+1)},[]),Se=z.useCallback(()=>{J(!0),Te(null)},[]),Ze=z.useCallback(ue=>{J(ue),ue||Te(null)},[]),mt=z.useCallback(async()=>{if(!a?.getBrokerInspector)return F(null),null;try{const ue=await a.getBrokerInspector();return F(ue),ue}catch{return F(null),null}},[a]),ae=z.useCallback(async ue=>{if(!a?.getFeedbackBundle)return T("Feedback diagnostics are unavailable in this build."),null;ue?.showSpinner&&$(!0);try{const Ee=await a.getFeedbackBundle();return N(Ee),T(null),Ee}catch(Ee){return T(lt(Ee)),null}finally{ue?.showSpinner&&$(!1)}},[a]);z.useEffect(()=>{if(e!=="logs")return;if(!a?.getLogCatalog){D(null),Ue("Logs are unavailable in the current desktop bridge. Restart the app so the latest desktop bridge is loaded.");return}let ue=!1;return(async()=>{try{const V=await a.getLogCatalog();if(ue)return;D(V),X(me=>me&&V.sources.some(je=>je.id===me)?me:V.defaultSourceId??V.sources[0]?.id??null),V.sources.length===0&&Ue("No log sources available.")}catch(V){ue||Ue(lt(V))}})(),()=>{ue=!0}},[e,a]),z.useEffect(()=>{if(e!=="logs"||!H)return;if(!a?.readLogSource){L(null);return}let ue=!1;return(!q||q.sourceId!==H)&&He(!0),Ue(null),(async()=>{try{const V=await a.readLogSource({sourceId:H,tailLines:500});if(ue)return;L(V),Ue(null)}catch(V){ue||(L(null),Ue(lt(V)))}finally{ue||He(!1)}})(),()=>{ue=!0}},[e,bt,a,H]),z.useEffect(()=>{e!=="settings"||r!=="communication"||mt()},[e,bt,mt,r]),z.useEffect(()=>{if(!o||e!=="settings"||r!=="communication")return;const ue=window.setTimeout(()=>{d.current?.scrollIntoView({behavior:"smooth",block:"start"}),u(!1)},40);return()=>{window.clearTimeout(ue)}},[e,o,d,r,B]),z.useEffect(()=>{if(e!=="logs")return;const ue=window.setInterval(()=>{Ye(Ee=>Ee+1)},2500);return()=>{window.clearInterval(ue)}},[e]),z.useEffect(()=>{oe&&ae({showSpinner:!0})},[oe,ae]);const ge=z.useCallback(async ue=>{if(!(!i?.canManageBroker||!a?.controlBroker)){O(!0),Q(null);try{const Ee=await a.controlBroker(ue);p(Ee),h(null),await mt(),Q(ue==="start"?"Relay started.":ue==="stop"?"Relay stopped.":"Relay restarted.")}catch(Ee){Q(lt(Ee))}finally{O(!1)}}},[mt,a,h,p,i]),Ce=z.useCallback(()=>{(async()=>{ce("refresh"),Te(null);try{await ae({showSpinner:!0}),Te("Support details refreshed.")}finally{ce(null)}})()},[ae]),_e=z.useCallback(()=>{(async()=>{if(!ee?.text){Te("Support bundle is still loading.");return}ce("copy"),Te(null);try{await qM(ee.text),Te("Support bundle copied.")}catch(ue){Te(lt(ue))}finally{ce(null)}})()},[ee?.text]),Xe=z.useCallback(()=>{(async()=>{if(!a?.submitFeedbackReport){Te("Feedback submission is unavailable in this build.");return}const ue=_.trim();if(!ue){Te("Add a short description before submitting.");return}ce("submit"),Te(null);try{const Ee=await a.submitFeedbackReport({message:ue});pe(Ee),le(""),Te(`Feedback submitted as ${Ee.key}.`)}catch(Ee){Te(lt(Ee))}finally{ce(null)}})()},[_,a]),Ae=z.useCallback(()=>{(async()=>{const ue=[];ce("repair"),Te(null);try{if(a?.restartOnboarding){const Ee=await a.restartOnboarding();y(Ee)}else ue.push("Onboarding reset unavailable.");if(j(null),C(null),E(null),w(null),Q(null),Ue(null),i?.canManageBroker&&a?.controlBroker)try{const Ee=await a.controlBroker(B?.installed?"restart":"start");p(Ee),h(null)}catch(Ee){ue.push(`Relay: ${lt(Ee)}`)}if(a?.controlPairingService)try{const Ee=await a.controlPairingService(v?.isRunning?"restart":"start");b(Ee)}catch(Ee){ue.push(`Pairing: ${lt(Ee)}`)}try{await mt()}catch(Ee){ue.push(`Broker diagnostics: ${lt(Ee)}`)}if(a?.refreshPairingState)try{const Ee=await a.refreshPairingState();b(Ee)}catch(Ee){ue.push(`Pairing refresh: ${lt(Ee)}`)}await f(!1),await ae(),Te(ue.length>0?`Repair finished with notes: ${ue.join(" · ")}`:"Setup repaired. Onboarding was reset and local services were refreshed.")}catch(Ee){Te(lt(Ee))}finally{ce(null)}})()},[y,B?.installed,b,ae,f,v?.isRunning,mt,a,j,w,E,C,h,p,i]);return{logCatalog:M,logSources:Ge,filteredLogSources:We,selectedLogSourceId:H,setSelectedLogSourceId:X,selectedLogSource:we,logContent:q,brokerInspector:B,brokerControlPending:Z,brokerControlFeedback:P,isFeedbackDialogOpen:oe,feedbackBundle:ee,feedbackBundleLoading:Y,feedbackBundleError:ye,feedbackDraft:_,setFeedbackDraft:le,feedbackSubmission:R,feedbackActionPending:xe,feedbackActionMessage:Re,logsLoading:Ne,logsFeedback:Le,logSearchQuery:it,setLogSearchQuery:tt,logSourceQuery:st,setLogSourceQuery:ot,refreshLogs:et,refreshBrokerInspector:mt,openFeedbackDialog:Se,handleFeedbackDialogOpenChange:Ze,handleBrokerControl:ge,handleRefreshFeedbackBundle:Ce,handleCopyFeedbackBundle:_e,handleSubmitFeedbackReport:Xe,handleRepairSetup:Ae}}function GM({pairingEnabled:e,scoutDesktop:r,setRelayFeedback:a}){const[i,o]=z.useState(null),[u,d]=z.useState(!1),[f,p]=z.useState(null),[h,y]=z.useState(!1),[b,v]=z.useState(!1),[j,C]=z.useState(null),[E,w]=z.useState(null),M=z.useRef(null),D=z.useRef(0);z.useEffect(()=>{M.current=i},[i]),z.useEffect(()=>{e||(o(null),d(!1),p(null),y(!1),v(!1),C(null),w(null))},[e]);const H=z.useCallback(Z=>{o(O=>AT(O,Z)?O:Z)},[]),X=z.useCallback(async(Z,O)=>{if(!e||!Z)return null;const P=++D.current;O?.showLoading&&d(!0);try{const Q=await Z();return D.current!==P||(H(Q),p(null)),Q}catch(Q){if(D.current===P&&p(lt(Q)),O?.throwOnError)throw Q;return null}finally{O?.showLoading&&D.current===P&&d(!1)}},[H,e]);z.useEffect(()=>{if(!e||!r?.getPairingState)return;X(()=>r.getPairingState(),{showLoading:M.current===null});const Z=window.setInterval(()=>{X(()=>r.getPairingState())},5e3);return()=>{window.clearInterval(Z)}},[e,r,X]);const q=z.useCallback(async()=>e?r?.refreshPairingState?X(()=>r.refreshPairingState(),{throwOnError:!0}):X(r?.getPairingState?()=>r.getPairingState():void 0,{throwOnError:!0}):null,[e,r,X]),L=z.useCallback(async Z=>{if(r?.controlPairingService){y(!0);try{const O=await r.controlPairingService(Z);H(O),p(null),a(Z==="start"?"Pairing started.":Z==="stop"?"Pairing stopped.":"Pairing restarted.")}catch(O){p(lt(O))}finally{y(!1)}}},[H,r,a]),B=z.useCallback(async Z=>{if(r?.updatePairingConfig){v(!0),w(null);try{const O=await r.updatePairingConfig(Z);H(O),p(null),w("Pairing settings saved.")}catch(O){const P=lt(O);throw w(P),O}finally{v(!1)}}},[H,r]),F=z.useCallback(async(Z,O)=>{if(!r?.decidePairingApproval)return;const P=`${Z.sessionId}:${Z.turnId}:${Z.blockId}:${O}`;C(P);try{const Q=await r.decidePairingApproval({sessionId:Z.sessionId,turnId:Z.turnId,blockId:Z.blockId,version:Z.version,decision:O});H(Q),p(null),a(O==="approve"?"Approval sent.":"Action denied.")}catch(Q){p(lt(Q))}finally{C(Q=>Q===P?null:Q)}},[H,r,a]);return{pairingState:i,pairingLoading:u,pairingError:f,setPairingError:p,pairingControlPending:h,pairingConfigPending:b,pairingApprovalPendingId:j,pairingConfigFeedback:E,setPairingConfigFeedback:w,pendingApprovals:i?.pendingApprovals??[],commitPairingState:H,refreshPairingState:q,handlePairingControl:L,handleUpdatePairingConfig:B,handleDecidePairingApproval:F}}const l1={favorites:[],quickHits:[],preparedAt:null};function $M({activeView:e,scoutDesktop:r,sessions:a}){const[i,o]=z.useState(null),[u,d]=z.useState(!1),[f,p]=z.useState(!1),[h,y]=z.useState(null),[b,v]=z.useState(null),[j,C]=z.useState(null),E=z.useRef(null),w=z.useRef(0);z.useEffect(()=>{E.current=i},[i]),z.useEffect(()=>{if(e!=="sessions"||!r?.getPhonePreparation)return;let J=!1;return(async()=>{d(!0);try{const N=await r.getPhonePreparation();if(J)return;o(N),y(null)}catch(N){if(J)return;o(null),y(lt(N))}finally{J||d(!1)}})(),()=>{J=!0}},[e,r]);const M=i??l1,D=z.useMemo(()=>new Map(a.map(J=>[J.id,J])),[a]),H=z.useMemo(()=>[...a].sort((J,ee)=>new Date(ee.lastModified).getTime()-new Date(J.lastModified).getTime()||ee.messageCount-J.messageCount||J.title.localeCompare(ee.title)),[a]),X=z.useMemo(()=>M.favorites.map(J=>D.get(J)).filter(J=>!!J),[M.favorites,D]),q=z.useMemo(()=>M.quickHits.filter(J=>!M.favorites.includes(J)).map(J=>D.get(J)).filter(J=>!!J),[M.favorites,M.quickHits,D]),L=z.useCallback(async(J,ee)=>{if(!r?.updatePhonePreparation){y("Phone preparation is unavailable in this build.");return}const N=++w.current,Y=E.current;o(J),p(!0);try{const $=await r.updatePhonePreparation(J);if(w.current!==N)return;o($),ee?y(ee):ee===null&&y(null)}catch($){if(w.current!==N)return;o(Y),y(lt($))}finally{w.current===N&&(p(!1),v(null),C(null))}},[r]),B=z.useCallback((J,ee)=>{const N=J(E.current??l1);L(N,ee)},[L]),F=z.useCallback(()=>{const J=M.favorites.filter(N=>D.has(N)),ee=H.map(N=>N.id).filter(N=>!J.includes(N)).slice(0,8);L({favorites:J,quickHits:ee,preparedAt:Date.now()},`Prepared ${J.length+ee.length} phone picks.`)},[L,M.favorites,H,D]),Z=z.useCallback(()=>{B(J=>({...J,quickHits:[],preparedAt:Date.now()}),"Cleared My List. Favorites stayed pinned.")},[B]),O=z.useCallback((J,ee)=>{B(N=>ee==="favorites"?{favorites:N.favorites.includes(J)?N.favorites:[...N.favorites,J],quickHits:N.quickHits.filter(Y=>Y!==J),preparedAt:Date.now()}:N.favorites.includes(J)||N.quickHits.includes(J)?{...N,preparedAt:Date.now()}:{...N,quickHits:[...N.quickHits,J],preparedAt:Date.now()},ee==="favorites"?"Pinned for phone.":"Added to My List.")},[B]),P=z.useCallback((J,ee)=>{B(N=>({favorites:ee==="favorites"?N.favorites.filter(Y=>Y!==J):N.favorites,quickHits:ee==="quickHits"?N.quickHits.filter(Y=>Y!==J):N.quickHits,preparedAt:Date.now()}),ee==="favorites"?"Removed from phone favorites.":"Removed from My List.")},[B]),Q=z.useCallback(()=>{b&&O(b,"favorites")},[b,O]),oe=z.useCallback(J=>{b&&B(ee=>{if(ee.favorites.includes(b))return{...ee,preparedAt:Date.now()};const N=ee.quickHits.filter($=>$!==b),Y=typeof J=="number"?Math.max(0,Math.min(J,N.length)):N.length;return N.splice(Y,0,b),{...ee,quickHits:N,preparedAt:Date.now()}},j==="quickHits"?"Reordered My List.":"Added to My List.")},[j,b,B]);return{phonePreparationState:M,phonePreparationLoading:u,phonePreparationSaving:f,phonePreparationFeedback:h,setDraggedSessionId:v,setDraggedPhoneSection:C,favoritePhoneSessions:X,quickHitPhoneSessions:q,handlePreparePhone:F,handleClearPhoneQuickHits:Z,handleDropIntoFavorites:Q,handleDropIntoQuickHits:oe,handleRemoveSessionFromPhoneSection:P,handleAddSessionToPhoneSection:O}}function YM({activeView:e,setActiveView:r,desktopFeatures:a,styles:i,colorTheme:o,sidebarWidth:u,messagesDetailWidth:d,isCollapsed:f,onResizeStart:p,onMessagesDetailResizeStart:h,stats:y,runtime:b,shellState:v,shellError:j,plansState:C,machinesState:E,messagesState:w,interAgentState:M,interAgentAgents:D,interAgentAgentLookup:H,relayDirectLookup:X,homeAgents:q,homeActivity:L,activityRecentMessages:B,activityTasks:F,activityLeadTask:Z,activityFindings:O,activityEndpoints:P,overviewSessions:Q,inboxAlertCount:oe,pendingApprovalsCount:J,inboxFailedTaskCount:ee,inboxAwaitingYouItems:N,availableAgentNames:Y,searchQuery:$,setSearchQuery:ye,filteredSessions:T,selectedSession:_,setSelectedSession:le,isLoadingMessagesWorkspace:R,isLoadingShell:pe,showAnnotations:xe,setShowAnnotations:ce,messagesDetailOpen:Re,setMessagesDetailOpen:Te,messagesDetailTab:Ne,setMessagesDetailTab:He,formatDate:Le,onRefreshShell:Ue,openAgentProfile:it,openSessionDetail:tt,handleSelectSearchSession:st,handleToggleVoiceCapture:ot,handleSetVoiceRepliesEnabled:bt,selectMessageThread:Ye,renderLocalPathValue:Ge,selectedInterAgentActivityMessages:We,selectedInterAgentInboundTasks:we,selectedInterAgentOutboundFindings:et,selectedInterAgentFindings:Se,interAgentThreadTitle:Ze,selectedInterAgentThreadSubtitle:mt,interAgentConfigureTarget:ae,interAgentConfigureLabel:ge,interAgentMessageTarget:Ce,visibleInterAgentMessages:_e,relayVoiceState:Xe,messagesController:Ae,agentController:ue,diagnosticsController:Ee,phonePreparationController:V,overviewBootLoader:me}){const je={sidebar:i.sidebar,surface:i.surface,inkText:i.inkText,mutedText:i.mutedText,tagBadge:i.tagBadge,activePill:i.activePill},Fe=w??{title:"Messages",subtitle:R||pe?"Loading relay workspace":j??"Broker unavailable",lastUpdatedLabel:b?.updatedAtLabel??null,threads:[]};return{overviewInboxActivityViewProps:{activeView:e,overviewViewProps:{C:o,s:i,bootLoader:me,homeAgents:q,activity:L,shellError:j,onRefresh:Ue,onOpenAgent:it,colorForIdentity:cl},inbox:{isCollapsed:f,sidebarWidth:u,onResizeStart:p,styles:je,inboxAlertCount:oe,pendingApprovalsCount:J,inboxFailedTaskCount:ee,inboxAwaitingYouItems:N},activity:{isCollapsed:f,sidebarWidth:u,onResizeStart:p,styles:je,plansState:C,machinesState:E,runtime:b,activityLeadTask:Z,activityTasks:F,activityFindings:O,activityEndpoints:P,activityRecentMessages:B,interAgentAgentLookup:H,overviewSessions:Q,formatDate:Le,onRefresh:Ue,onOpenPlans:()=>r("plans"),onOpenMessages:()=>r("messages"),onOpenAgentProfile:it,onOpenSessionDetail:tt}},opsViewsProps:{activeView:e,machinesViewProps:{machinesState:E??{title:"Machines",subtitle:"Broker unavailable",totalMachines:0,onlineCount:0,degradedCount:0,offlineCount:0,lastUpdatedLabel:null,machines:[]},C:o,s:i,isCollapsed:f,sidebarWidth:u,onResizeStart:p,onOpenRelayAgent:Ae.openDirectConversation,onRefresh:Ue,identityColor:cl},plansViewProps:{plansState:C??{title:"Plans",subtitle:"No broker snapshot yet",taskCount:0,runningTaskCount:0,failedTaskCount:0,completedTaskCount:0,findingCount:0,warningCount:0,errorCount:0,planCount:0,workspaceCount:0,lastUpdatedLabel:null,tasks:[],findings:[],plans:[]},C:o,s:i,isCollapsed:f,sidebarWidth:u,onResizeStart:p,onOpenRelayAgent:Ae.openDirectConversation,onRefresh:Ue,identityColor:cl},search:{isCollapsed:f,sidebarWidth:u,onResizeStart:p,styles:{sidebar:i.sidebar,surface:i.surface,inkText:i.inkText,mutedText:i.mutedText,tagBadge:i.tagBadge,activeItem:i.activeItem,kbd:i.kbd},availableAgentNames:Y,searchQuery:$,setSearchQuery:ye,filteredSessions:T,stats:{totalSessions:y.totalSessions,totalMessages:y.totalMessages},formatDate:Le,onOpenSession:st}},agentViewsProps:{activeView:e,layout:{isCollapsed:f,sidebarWidth:u,onResizeStart:p,styles:{sidebar:i.sidebar,surface:i.surface,inkText:i.inkText,mutedText:i.mutedText,tagBadge:i.tagBadge,activePill:i.activePill,activeItem:i.activeItem,annotBadge:i.annotBadge}},roster:{interAgentStateTitle:M?.title??"Inter-Agent",interAgentStateSubtitle:M?.subtitle??"Agent-to-agent traffic",rosterInterAgentAgents:ue.rosterInterAgentAgents,interAgentAgents:D,selectedInterAgentId:ue.selectedInterAgentId,onSelectInterAgent:ue.handleSelectInterAgent,agentRosterMenu:ue.agentRosterMenu,setAgentRosterMenu:ue.setAgentRosterMenu,agentRosterFilter:ue.agentRosterFilter,setAgentRosterFilter:ue.setAgentRosterFilter,agentRosterSort:ue.agentRosterSort,setAgentRosterSort:ue.setAgentRosterSort,rosterAgentTitleCounts:ue.rosterAgentTitleCounts,onRefresh:Ue},agents:{selectedInterAgent:ue.selectedInterAgent,selectedInterAgentDirectThread:ue.selectedInterAgentDirectThread,selectedInterAgentChatActionLabel:ue.selectedInterAgentChatActionLabel,onOpenAgentThread:Ae.openDirectConversation,onPeekAgentSession:ue.handlePeekAgentSession,onOpenAgentSettings:ue.handleOpenAgentSettings,visibleAgentSession:ue.visibleAgentSession,agentSessionPending:ue.agentSessionPending,agentSessionLoading:ue.agentSessionLoading,agentSessionFeedback:ue.agentSessionFeedback,agentSessionCopied:ue.agentSessionCopied,onCopyAgentSessionCommand:()=>{ue.handleCopyAgentSessionCommand()},onOpenAgentSession:()=>{ue.handleOpenAgentSession()},agentSessionLogsExpanded:ue.agentSessionLogsExpanded,setAgentSessionLogsExpanded:ue.setAgentSessionLogsExpanded,agentSessionInlineViewportRef:ue.agentSessionInlineViewportRef,onInlineAgentSessionScroll:ue.handleInlineAgentSessionScroll,renderLocalPathValue:Ge,selectedInterAgentActivityMessages:We,interAgentAgentLookup:H,relayDirectLookup:X,onOpenAgentProfile:it,onNudgeMessage:Ae.nudgeMessage,selectedInterAgentInboundTasks:we,selectedInterAgentOutboundFindings:et,selectedInterAgentFindings:Se,agentActivityExpanded:ue.agentActivityExpanded,setAgentActivityExpanded:ue.setAgentActivityExpanded,agentThreadsExpanded:ue.agentThreadsExpanded,setAgentThreadsExpanded:ue.setAgentThreadsExpanded,visibleInterAgentThreads:ue.visibleInterAgentThreads,selectedInterAgentThreadId:ue.selectedInterAgentThreadId,onOpenThreadInTrafficView:Je=>{ue.setSelectedInterAgentThreadId(Je),r("inter-agent")},selectedAgentDirectLinePreview:ue.selectedAgentDirectLinePreview,agentSnapshotExpanded:ue.agentSnapshotExpanded,setAgentSnapshotExpanded:ue.setAgentSnapshotExpanded,visibleAgentConfig:ue.visibleAgentConfig},logs:{logSources:Ee.logSources,filteredLogSources:Ee.filteredLogSources,selectedLogSourceId:Ee.selectedLogSourceId,setSelectedLogSourceId:Ee.setSelectedLogSourceId,selectedLogSource:Ee.selectedLogSource,logCatalog:Ee.logCatalog,logContent:Ee.logContent,logsLoading:Ee.logsLoading,logsFeedback:Ee.logsFeedback,logSearchQuery:Ee.logSearchQuery,setLogSearchQuery:Ee.setLogSearchQuery,logSourceQuery:Ee.logSourceQuery,setLogSourceQuery:Ee.setLogSourceQuery},interAgent:{selectedInterAgent:ue.selectedInterAgent,visibleInterAgentThreads:ue.visibleInterAgentThreads,selectedInterAgentThreadId:ue.selectedInterAgentThreadId,setSelectedInterAgentThreadId:ue.setSelectedInterAgentThreadId,interAgentThreadTitle:Ze,selectedInterAgentThread:ue.selectedInterAgentThread,selectedInterAgentThreadSubtitle:mt,selectedRelayDirectThread:Ae.selectedDirectConversation,showAnnotations:xe,setShowAnnotations:ce,interAgentMessageTarget:Ce,openAgentDirectMessage:Ae.openAgentDirectMessage,interAgentConfigureTarget:ae,onOpenAgentSettings:ue.handleOpenAgentSettings,interAgentConfigureLabel:ge,visibleInterAgentMessages:_e,interAgentAgentLookup:H,relayDirectLookup:X,onOpenAgentProfile:it,onNudgeMessage:Ae.nudgeMessage},sessions:{searchQuery:$,setSearchQuery:ye,filteredSessions:T,stats:{totalSessions:y.totalSessions},onRefresh:Ue,loadingSessions:pe&&!v,selectedSession:_,setSelectedSession:le,phonePreparationState:V.phonePreparationState,phonePreparationLoading:V.phonePreparationLoading,phonePreparationSaving:V.phonePreparationSaving,phonePreparationFeedback:V.phonePreparationFeedback,setDraggedSessionId:V.setDraggedSessionId,setDraggedPhoneSection:V.setDraggedPhoneSection,favoritePhoneSessions:V.favoritePhoneSessions,quickHitPhoneSessions:V.quickHitPhoneSessions,formatDate:Le,onClearPhoneQuickHits:V.handleClearPhoneQuickHits,onDropIntoFavorites:V.handleDropIntoFavorites,onDropIntoQuickHits:V.handleDropIntoQuickHits,onRemoveSessionFromPhoneSection:V.handleRemoveSessionFromPhoneSection,onAddSessionToPhoneSection:V.handleAddSessionToPhoneSection}},messagesRelayViewProps:{activeView:e,layout:{sidebarWidth:u,messagesDetailWidth:d,isCollapsed:f,onResizeStart:p,onMessagesDetailResizeStart:h,styles:{sidebar:i.sidebar,surface:i.surface,inkText:i.inkText,mutedText:i.mutedText,tagBadge:i.tagBadge,annotBadge:i.annotBadge,activeItem:i.activeItem,activePill:i.activePill,kbd:i.kbd}},threading:{messagesState:Fe,messageThreads:Ae.messageThreads,selectedMessagesThread:Ae.selectedMessagesThread,onSelectMessageThread:Ye,showAnnotations:xe,setShowAnnotations:ce,onRefresh:Ue,loadingWorkspace:(R||pe)&&!w,selectedMessagesInternalThread:Ae.selectedMessagesInternalThread,selectedMessagesInternalMessages:Ae.selectedMessagesInternalMessages,selectedMessagesInternalTarget:Ae.selectedMessagesInternalTarget,selectedMessagesDetailAgentId:Ae.selectedMessagesDetailAgentId,selectedMessagesDetailAgent:Ae.selectedMessagesDetailAgent,selectedMessagesSessions:Ae.selectedMessagesSessions,selectedSession:_,setSelectedSession:le,formatDate:Le,interAgentAgents:D,interAgentAgentLookup:H,relayDirectLookup:X,openAgentProfile:it,openAgentDirectMessage:Ae.openAgentDirectMessage,onNudgeMessage:Ae.nudgeMessage,messagesDetailOpen:Re,setMessagesDetailOpen:Te,messagesDetailTab:Ne,setMessagesDetailTab:He},composer:{selectedRelayKind:Ae.selectedConversationKind,selectedRelayId:Ae.selectedConversationId,relayThreadTitle:Ae.currentConversationTitle,relayThreadSubtitle:Ae.currentConversationSubtitle,relayThreadCount:Ae.currentConversationCount,selectedRelayDirectThread:Ae.selectedDirectConversation,relayVoiceState:Xe,visibleRelayMessages:Ae.visibleConversationMessages,relayTimelineViewportRef:Ae.timelineViewportRef,onRelayTimelineScroll:Ae.handleConversationTimelineScroll,relayReplyTarget:Ae.replyTarget,setRelayReplyTarget:Ae.setReplyTarget,relayContextReferences:Ae.contextReferences,relayContextMessageIds:Ae.contextMessageIds,setRelayContextMessageIds:Ae.setContextMessageIds,relayComposerRef:Ae.composerRef,relayDraft:Ae.composerDraft,setRelayDraft:Ae.setComposerDraft,relaySending:Ae.composerSending,relayFeedback:Ae.messagesFeedback,relayComposerSelectionStart:Ae.composerSelectionStart,setRelayComposerSelectionStart:Ae.setComposerSelectionStart,mergedRelayMessages:Ae.mergedConversationMessages,relayMentionMenuOpen:Ae.mentionMenuOpen,relayMentionSuggestions:Ae.mentionSuggestions,relayMentionSelectionIndex:Ae.mentionSelectionIndex,setRelayMentionSelectionIndex:Ae.setMentionSelectionIndex,relayMentionDuplicateTitleCounts:Ae.mentionDuplicateTitleCounts,applyRelayMentionSuggestion:Ae.applyMentionSuggestion,onRelaySend:()=>{Ae.sendMessage()},onToggleVoiceCapture:ot,onSetVoiceRepliesEnabled:Je=>{bt(Je)}},agentSession:{visibleAgentSession:ue.visibleAgentSession,agentSessionPending:ue.agentSessionPending,agentSessionFeedback:ue.agentSessionFeedback,agentSessionCopied:ue.agentSessionCopied,onCopyAgentSessionCommand:()=>{ue.handleCopyAgentSessionCommand()},onOpenAgentSession:()=>{ue.handleOpenAgentSession()},onPeekAgentSession:ue.handlePeekAgentSession,onOpenAgentSettings:ue.handleOpenAgentSettings,desktopVoiceEnabled:a.voice}}}}function QM({activeView:e,setActiveView:r,settingsSection:a,setSettingsSection:i,settingsAgentId:o,setSettingsAgentId:u,settingsSections:d,activeSettingsMeta:f,desktopFeatures:p,stats:h,runtime:y,relayState:b,relayRuntimeBooting:v,relayRuntimeHealthLabel:j,reachableRelayAgentCount:C,dark:E,setDark:w,showAnnotations:M,setShowAnnotations:D,isCollapsed:H,styles:X,scoutDesktop:q,surfaceCaps:L,interAgentAgents:B,openKnowledgeBase:F,openAgentProfile:Z,openDirectConversation:O,renderOnboardingCommandShell:P,renderLocalPathValue:Q,settingsOperatorNameRef:oe,relayServiceInspectorRef:J,handleSetVoiceRepliesEnabled:ee,settingsController:N,diagnosticsController:Y,agentController:$}){const[ye,T]=z.useState(null),[_,le]=z.useState(""),[R,pe]=z.useState("all"),[xe,ce]=z.useState("grid"),Re=z.useMemo(()=>N.agentableProjects.find(Se=>Se.id===ye)??null,[ye,N.agentableProjects]),Te=Re,Ne=z.useMemo(()=>Te?B.find(Se=>Se.id===Te.id||Se.id===Te.definitionId)??null:null,[B,Te]),He=z.useMemo(()=>N.agentableProjects.map(Se=>{const Ze=B.find(ge=>ge.id===Se.id||ge.id===Se.definitionId)??null,mt=!!Ze||Se.registrationKind==="configured",ae=Se.harnesses[0]?.harness??Se.defaultHarness;return{project:Se,linkedAgent:Ze,isBound:mt,primaryHarness:ae,pathLabel:Ka(Se.root)??Se.root,branchLabel:"local",activityLabel:Ze?.timestampLabel??"Workspace",statusLabel:mt?"Bound":Se.registrationKind==="configured"?"Ready":"Discovered"}}),[B,N.agentableProjects]),Le=z.useMemo(()=>{const Se=_.trim().toLowerCase();return He.filter(({project:Ze,isBound:mt,primaryHarness:ae})=>(R==="all"?!0:R==="bound"?mt:!mt)?Se?[Ze.title,Ze.projectName,Ze.root,Ze.relativePath,ae].some(Ce=>Ce.toLowerCase().includes(Se)):!0:!1)},[R,He,_]),Ue=z.useMemo(()=>He.filter(Se=>Se.isBound).length,[He]),it=z.useMemo(()=>He.filter(Se=>!Se.isBound).length,[He]),tt=z.useMemo(()=>o?B.find(Se=>Se.id===o)??null:null,[B,o]),st=$.selectedInterAgent?.id===o,ot=st?$.selectedInterAgent:tt,bt=z.useCallback(Se=>{i(Se),u(null)},[u,i]);z.useEffect(()=>{ye&&(N.agentableProjects.some(Se=>Se.id===ye)||T(null))},[ye,N.agentableProjects]);const Ye=z.useCallback(Se=>{T(Se.id),$.resetAgentInspector()},[$]),Ge=z.useCallback(Se=>{if(Se.registrationKind==="configured"){Z(Se.id);return}Ye(Se)},[Ye,Z]),We=z.useCallback(()=>{r("settings"),i("profile"),N.handleBeginGeneralEdit(),N.setAppSettingsFeedback("Add a scan folder below, then go back to Workspaces and refresh to discover workspaces.")},[r,i,N]),we=z.useCallback(Se=>{N.handleRetireProject(Se.root,Se.title).then(Ze=>{!Ze||Re?.root!==Se.root||(T(null),$.resetAgentInspector())})},[$,Re?.root,N]),et=a==="profile"?l.jsxs(l.Fragment,{children:[N.isAppSettingsEditing?l.jsxs(l.Fragment,{children:[l.jsx("button",{className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded disabled:opacity-50",style:{color:g.ink},onClick:()=>N.handleCancelAppSettingsEdit(),disabled:N.appSettingsSaving,children:"Cancel"}),l.jsx("button",{className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded disabled:opacity-50",style:{color:g.ink},onClick:()=>{N.handleSaveAppSettings()},disabled:!N.appSettingsDirty||N.appSettingsSaving||N.appSettingsLoading,children:N.appSettingsSaving?"Saving…":"Save General"})]}):l.jsx("button",{className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded disabled:opacity-50",style:{color:g.ink},onClick:()=>N.handleStartAppSettingsEdit(),disabled:N.appSettingsLoading||!N.visibleAppSettings,children:"Edit General"}),l.jsxs("button",{className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded disabled:opacity-50",style:{color:g.ink},onClick:N.handleRestartOnboarding,disabled:N.appSettingsLoading||!N.visibleAppSettings,children:[l.jsx(xn,{size:12}),"Restart onboarding"]})]}):a==="communication"?N.isAppSettingsEditing?l.jsxs(l.Fragment,{children:[l.jsx("button",{className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded disabled:opacity-50",style:{color:g.ink},onClick:()=>N.handleCancelAppSettingsEdit(),disabled:N.appSettingsSaving,children:"Cancel"}),l.jsx("button",{className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded disabled:opacity-50",style:{color:g.ink},onClick:()=>{N.handleSaveAppSettings()},disabled:!N.appSettingsDirty||N.appSettingsSaving||N.appSettingsLoading,children:N.appSettingsSaving?"Saving…":p.telegram?"Save Telegram":"Save Communication"})]}):l.jsx("button",{className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded disabled:opacity-50",style:{color:g.ink},onClick:()=>N.handleStartAppSettingsEdit(),disabled:N.appSettingsLoading||!N.visibleAppSettings,children:p.telegram?"Edit Telegram":"Edit Communication"}):a==="agents"?l.jsxs(l.Fragment,{children:[l.jsx("button",{className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded",style:{color:g.ink},onClick:()=>r("agents"),children:"Open Agents"}),ot&&st&&$.hasEditableAgentConfig?$.isAgentConfigEditing?l.jsxs(l.Fragment,{children:[l.jsx("button",{className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded disabled:opacity-50",style:{color:g.ink},onClick:()=>$.handleCancelAgentConfigEdit(),disabled:$.agentConfigSaving||$.agentConfigRestarting,children:"Cancel"}),l.jsx("button",{className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded disabled:opacity-50",style:{color:g.ink},onClick:()=>{$.handleSaveAgentConfig()},disabled:!$.agentConfigDirty||$.agentConfigLoading||$.agentConfigSaving||$.agentConfigRestarting,children:$.agentConfigSaving?"Saving…":"Save Changes"})]}):l.jsx("button",{className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded disabled:opacity-50",style:{color:g.ink},onClick:()=>$.handleStartAgentConfigEdit(),disabled:!o||$.agentConfigLoading||$.agentConfigRestarting,children:"Edit Agent"}):null,ot&&st&&$.hasEditableAgentConfig?l.jsx("button",{className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded disabled:opacity-50",style:{color:g.ink},onClick:()=>{$.handleRestartAgent()},disabled:$.agentConfigLoading||$.agentConfigRestarting||!$.visibleAgentConfig,children:$.agentConfigRestarting?"Restarting…":$.agentRestartActionLabel}):null]}):a==="database"?l.jsx("button",{className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded",style:{color:g.ink},onClick:()=>r("sessions"),children:"Browse Sessions"}):null;return{activeView:e,help:{styles:X,buildOnboardingCommandLine:N.buildOnboardingCommandLine,onboardingCopiedCommand:N.onboardingCopiedCommand,onboardingCommandPending:N.onboardingCommandPending,onCopyOnboardingCommand:N.handleCopyOnboardingCommand,onRunOnboardingCommand:N.handleRunOnboardingCommand,onOpenGeneralSettings:()=>{r("settings"),i("profile")}},settings:{styles:X,settingsSection:a,settingsSections:d,activeSettingsMeta:f,onSetSettingsSection:bt,onOpenFeedbackDialog:Y.openFeedbackDialog,headerActions:et,profile:{styles:X,visibleAppSettings:N.visibleAppSettings,appSettings:N.appSettings,isAppSettingsEditing:N.isAppSettingsEditing,appSettingsSaving:N.appSettingsSaving,appSettingsLoading:N.appSettingsLoading,appSettingsDirty:N.appSettingsDirty,appSettingsFeedback:N.appSettingsFeedback,settingsOperatorNameRef:oe,onboardingWizardStep:N.onboardingWizardStep,setOnboardingWizardStep:N.setOnboardingWizardStep,activeOnboardingStepIndex:N.onboardingWizardIndex,activeOnboardingStep:N.activeOnboardingStep,onboardingWizardSteps:N.onboardingWizardSteps,sourceRootPathSuggestions:N.SOURCE_ROOT_PATH_SUGGESTIONS,onboardingRuntimeMatch:N.onboardingRuntimeMatch,onboardingHasProjectConfig:N.onboardingHasProjectConfig,onboardingCopiedCommand:N.onboardingCopiedCommand,onboardingCommandPending:N.onboardingCommandPending,onboardingCommandResult:N.onboardingCommandResult,canGoToPreviousOnboardingStep:N.canGoToPreviousOnboardingStep,canGoToNextOnboardingStep:N.canGoToNextOnboardingStep,moveOnboardingWizard:N.moveOnboardingWizard,handleOnboardingContinue:N.handleOnboardingContinue,handleRestartOnboarding:N.handleRestartOnboarding,handleStartAppSettingsEdit:N.handleStartAppSettingsEdit,handleBeginGeneralEdit:N.handleBeginGeneralEdit,handleSetSourceRootAt:N.handleSetSourceRootAt,handleBrowseForSourceRoot:N.handleBrowseForSourceRoot,handleRemoveSourceRootRow:N.handleRemoveSourceRootRow,handleAddSourceRootRow:N.handleAddSourceRootRow,handleAddSourceRootSuggestion:N.handleAddSourceRootSuggestion,handleSetOnboardingContextRoot:N.handleSetOnboardingContextRoot,handleBrowseForOnboardingContextRoot:N.handleBrowseForOnboardingContextRoot,setAppSettingsDraft:N.setAppSettingsDraft,setAppSettingsFeedback:N.setAppSettingsFeedback,buildOnboardingCommandLine:N.buildOnboardingCommandLine,handleCopyOnboardingCommand:N.handleCopyOnboardingCommand,handleRunOnboardingCommand:N.handleRunOnboardingCommand,renderOnboardingCommandShell:P,renderLocalPathValue:Q,openKnowledgeBase:F},agentSettingsViewProps:{styles:X,selectedInterAgent:ot,availableAgents:$.rosterInterAgentAgents,isAgentConfigEditing:st?$.isAgentConfigEditing:!1,hasEditableAgentConfig:st?$.hasEditableAgentConfig:!1,agentConfigLoading:o?!st||$.agentConfigLoading:!1,agentConfigSaving:st?$.agentConfigSaving:!1,agentConfigRestarting:st?$.agentConfigRestarting:!1,visibleAgentConfig:st?$.visibleAgentConfig:null,agentConfigFeedback:st?$.agentConfigFeedback:null,agentCapabilitiesPreview:st?$.agentCapabilitiesPreview:[],agentRuntimePathRef:$.agentRuntimePathRef,onOpenAgents:()=>r("agents"),onOpenAgentProfile:Z,onOpenAgentThread:Se=>O(Se,{focusComposer:!0}),onUpdateAgentConfigDraft:$.updateAgentConfigDraft,renderLocalPathValue:Q,interAgentProfileKindLabel:mv,onSelectAgent:Se=>{u(Se),$.handleSelectInterAgent(Se)}},workspaceExplorerViewProps:{styles:X,selectedWorkspaceProject:Te,selectedWorkspaceAgent:Ne,workspaceExplorerQuery:_,setWorkspaceExplorerQuery:le,workspaceExplorerFilter:R,setWorkspaceExplorerFilter:pe,workspaceExplorerViewMode:xe,setWorkspaceExplorerViewMode:ce,workspaceExplorerItems:He,workspaceExplorerBoundCount:Ue,workspaceExplorerDiscoveredCount:it,filteredWorkspaceExplorerItems:Le,workspaceInventoryLoaded:N.workspaceInventoryLoaded,workspaceInventoryLoading:N.workspaceInventoryLoading,canRefreshWorkspaceInventory:N.canRefreshWorkspaceInventory,onboardingCommandPending:N.onboardingCommandPending,appSettingsLoading:N.appSettingsLoading,appSettingsSaving:N.appSettingsSaving,appSettingsDirty:N.appSettingsDirty,appSettingsFeedback:N.appSettingsFeedback,showDoctorOutput:N.showDoctorOutput,doctorOutput:P("doctor",N.buildOnboardingCommandLine("doctor"),N.onboardingCommandPending==="doctor"),projectRetirementPendingRoot:N.projectRetirementPendingRoot,onRefreshWorkspaceDiscovery:()=>{N.handleRunOnboardingCommand("doctor")},onLoadWorkspaceInventory:N.handleLoadWorkspaceInventory,onAddWorkspace:We,onInspectWorkspace:Ye,onOpenWorkspace:Ge,onRetireWorkspace:we,onOpenAgentProfile:Z,onOpenAgentSettings:Se=>$.handleOpenAgentSettings(Se,!0),renderLocalPathValue:Q},communicationSettingsViewProps:{styles:X,showTelegram:p.telegram,showVoice:p.voice,visibleAppSettings:N.visibleAppSettings,isAppSettingsEditing:N.isAppSettingsEditing,appSettingsSaving:N.appSettingsSaving,appSettingsFeedback:N.appSettingsFeedback,onUpdateAppSettingsDraft:N.updateAppSettingsDraft,brokerInspector:Y.brokerInspector,brokerControlPending:Y.brokerControlPending,brokerControlFeedback:Y.brokerControlFeedback,onBrokerControl:Se=>{Y.handleBrokerControl(Se)},relayServiceInspectorRef:J,relayRuntimeBooting:v,relayRuntimeHealthLabel:j,runtime:y,reachableRelayAgentCount:C,voiceCaptureTitle:b?.voice.captureTitle??"Not reported",voiceRepliesEnabled:b?.voice.repliesEnabled??!1,onSetVoiceRepliesEnabled:Se=>{ee(Se)},renderLocalPathValue:Q},database:{styles:X,stats:h,runtime:y,visibleAppSettings:N.visibleAppSettings,renderLocalPathValue:Q,onRevealPath:Se=>{L?.canRevealPath&&q?.revealPath?.(Se)}},appearance:{styles:X,dark:E,setDark:w,showAnnotations:M,setShowAnnotations:D,isCollapsed:H,activeSettingsLabel:f.label}}}}const XM=["~/dev","~/src","~/code"],xo=["welcome","source-roots","harness","confirm","setup","doctor","runtimes"];function KM({activeView:e,settingsSection:r,scoutDesktop:a,shellState:i,surfaceCaps:o,completeOnboardingIntoRelay:u,loadShellState:d}){const[f,p]=z.useState(null),[h,y]=z.useState(null),[b,v]=z.useState(!1),[j,C]=z.useState(!1),[E,w]=z.useState(!1),[M,D]=z.useState(null),[H,X]=z.useState(!1),[q,L]=z.useState(null),[B,F]=z.useState("welcome"),[Z,O]=z.useState(null),[P,Q]=z.useState(null),[oe,J]=z.useState({}),[ee,N]=z.useState(null),[Y,$]=z.useState("checking"),ye=H?h??f:f,T=ye?.projectInventory??[],_=ye?.hiddenProjects??[],le=z.useMemo(()=>Hb(h)!==Hb(f),[h,f]),R=!!ye?.workspaceInventoryLoaded,pe=!!(f&&a?.refreshSettingsInventory),xe=!!(Z==="doctor"||oe.doctor||P?.command==="doctor"),ce=ye?.onboardingContextRoot??ye?.workspaceRoots?.[0]??null,Re=!!ye?.currentProjectConfigPath,Te=(ye?.runtimeCatalog??[]).find(se=>se.name===ye?.defaultHarness)??null,Ne=z.useMemo(()=>new Map((ye?.onboarding.steps??[]).map(se=>[se.id,se.complete])),[ye?.onboarding.steps]),He=z.useMemo(()=>[{id:"welcome",number:"01",title:"Say hi",detail:"Tell Scout what to call you before the rest of setup begins.",complete:Ne.get("welcome")??!1},{id:"source-roots",number:"02",title:"Choose folders to scan",detail:"Pick the parent folders Scout should scan for repos, then choose where this Scout context should live.",complete:Ne.get("source-roots")??!1},{id:"harness",number:"03",title:"Choose a default harness",detail:"This is the assistant family Scout should prefer when a project does not pin one of its own.",complete:Ne.get("harness")??!1},{id:"confirm",number:"04",title:"Confirm this context",detail:"Review which folders Scout will scan and where it will save this context before moving into the command steps.",complete:Ne.get("confirm")??!1},{id:"setup",number:"05",title:"Run setup",detail:"See how Scout writes `.openscout/project.json` at your chosen context root and uses it as this context anchor.",complete:Ne.get("setup")??!1},{id:"doctor",number:"06",title:"Run doctor",detail:"See how Scout combines broker health, scanned folders, and context manifests into one inventory view.",complete:Ne.get("doctor")??!1},{id:"runtimes",number:"07",title:"Run runtimes",detail:"Check whether Claude or Codex is installed, signed in, and ready for broker-owned sessions.",complete:Ne.get("runtimes")??!1}],[Ne]),Le=Math.max(0,xo.indexOf(B)),Ue=He[Le]??He[0],it=Le>0,tt=Le<He.length-1,st=Y==="active"&&!!ye?.onboarding,ot=Y!=="done",bt=z.useCallback((se,Me)=>se?{...Me,operatorName:se.operatorName,onboardingContextRoot:se.onboardingContextRoot,workspaceRoots:se.workspaceRoots,includeCurrentRepo:se.includeCurrentRepo,defaultHarness:se.defaultHarness,defaultTransport:se.defaultTransport,defaultCapabilities:se.defaultCapabilities,sessionPrefix:se.sessionPrefix,telegram:se.telegram}:Me,[]),Ye=z.useCallback(se=>{p(se),y(se),se.workspaceInventoryLoaded&&C(!1)},[]),Ge=z.useCallback(se=>{p(se),y(Me=>H?Me:se),se.workspaceInventoryLoaded&&C(!1)},[H]),We=z.useCallback(se=>{p(se),y(Me=>H?bt(Me,se):se),se.workspaceInventoryLoaded&&C(!1)},[H,bt]),we=z.useCallback(se=>{Ye(se),F("welcome"),Q(null),N(null),X(!0),$("active")},[Ye]),et=z.useCallback(se=>{const Me=ce?` --context-root ${ce}`:"",ze=se==="setup"?(ye?.workspaceRoots??[]).map(nt=>` --source-root ${nt}`).join(""):"";return`scout ${se}${Me}${ze}`},[ce,ye?.workspaceRoots]),Se=z.useCallback(async se=>{if(!a?.getAppSettings)return null;const Me=se?.preferInventory&&a.refreshSettingsInventory?await a.refreshSettingsInventory():await a.getAppSettings();return Ge(Me),Me},[a,Ge]);z.useEffect(()=>{if(!(e==="settings"||e==="help"||Y==="active")||!a?.getAppSettings)return;let Me=!1;return(async()=>{v(!0);try{const nt=await a.getAppSettings();if(Me)return;Ye(nt),Y==="active"&&nt.onboarding.needed?(D(null),X(!0),F(Qt=>Qt||"welcome")):(D(null),X(!1)),Y==="active"&&!nt.onboarding.needed&&(u(i),$("done"))}catch(nt){if(Me)return;p(null),y(null),D(lt(nt)),X(!1),Y!=="done"&&$("done")}finally{Me||v(!1)}})(),()=>{Me=!0}},[e,u,Ye,a,i,Y]),z.useEffect(()=>{let se=!1;return a?.getAppSettings?((async()=>{try{const ze=await a.getAppSettings();if(se)return;p(nt=>nt??ze),y(nt=>nt??ze),ze.onboarding.needed?(D(null),X(!0),F("welcome"),$("active")):$("done")}catch{se||$("done")}})(),()=>{se=!0}):($("done"),()=>{se=!0})},[a]),z.useEffect(()=>{if(e!=="settings"||r!=="workspaces"||!a?.refreshSettingsInventory||!f||f.workspaceInventoryLoaded||j)return;let se=!1;return(async()=>{C(!0);try{const ze=await a.refreshSettingsInventory();se||We(ze)}catch(ze){se||D(lt(ze))}finally{se||C(!1)}})(),()=>{se=!0}},[e,f,We,a,r,j]);const Ze=z.useCallback(()=>{y(f),D(null),X(!0),f?.onboarding.needed&&F("welcome")},[f]),mt=z.useCallback(()=>{y(f),D(null),X(!1)},[f]),ae=z.useCallback(se=>{y(Me=>Me&&se(Me)),D(null)},[]),ge=z.useCallback(async()=>{if(!h||!a?.updateAppSettings)return!1;w(!0);try{const se=await a.updateAppSettings({operatorName:h.operatorName,onboardingContextRoot:h.onboardingContextRoot,workspaceRootsText:h.workspaceRoots.join(`
|
|
88
88
|
`),includeCurrentRepo:h.includeCurrentRepo,defaultHarness:h.defaultHarness,defaultCapabilitiesText:h.defaultCapabilities.join(`
|
|
89
|
-
`),sessionPrefix:h.sessionPrefix,telegram:{enabled:h.telegram.enabled,mode:h.telegram.mode,botToken:h.telegram.botToken,secretToken:h.telegram.secretToken,apiBaseUrl:h.telegram.apiBaseUrl,userName:h.telegram.userName,defaultConversationId:h.telegram.defaultConversationId,ownerNodeId:h.telegram.ownerNodeId}});return Ye(se),D("Settings saved."),X(se.onboarding.needed),$(Me=>Me==="active"?se.onboarding.needed?"active":"done":Me),await d(!1),!0}catch(se){return D(lt(se)),!1}finally{w(!1)}},[h,d,Ye,a]),Ce=z.useCallback(se=>{F(Me=>{const ze=xo.indexOf(Me);if(ze<0)return xo[0];const nt=Math.min(xo.length-1,Math.max(0,ze+se));return xo[nt]})},[]),_e=z.useCallback(async se=>{if(!o?.canProvisionRuntime||!a?.runOnboardingCommand)return D(o&&!o.canProvisionRuntime?"Setup and doctor commands must be run from the Scout CLI (`scout setup`, `scout doctor`) on this host.":null),null;O(se),D(null);try{const Me=(h??f)?.workspaceRoots??[],ze=await a.runOnboardingCommand({command:se,contextRoot:(h??f)?.onboardingContextRoot??Me[0],sourceRoots:se==="setup"?Me:void 0});if(Q(ze),J(nt=>({...nt,[se]:ze})),D(ze.exitCode!==0?`${se} exited with status ${ze.exitCode}. Review the output below before continuing.`:null),a.getAppSettings){const nt=(se==="doctor"||se==="setup")&&a.refreshSettingsInventory?await a.refreshSettingsInventory():await a.getAppSettings();Ye(nt),X(nt.onboarding.needed);const Qt=await d(!1);nt.onboarding.needed?se==="runtimes"&&ze.exitCode===0&&!Qt?.runtime?.brokerReachable?(F("doctor"),D("Relay is still offline. Run doctor again and make sure the broker is reachable before onboarding can finish.")):ze.exitCode===0&&setTimeout(()=>{Ce(1)},1800):u(Qt),$(gn=>gn==="active"?nt.onboarding.needed?"active":"done":gn)}return ze}catch(Me){return D(lt(Me)),null}finally{O(null)}},[f,h,u,d,Ce,a,o]),Xe=z.useCallback(async(se,Me)=>{if(!o?.canEditFilesystem)return D("Project retirement is not available in this host. Use the Scout CLI or desktop app."),!1;if(!a?.retireProject)return D("Project retirement is unavailable in this build."),!1;L(se);try{const ze=await a.retireProject(se);return We(ze),await d(!1),D(`Retired ${Me}. It is hidden from discovery until restored.`),!0}catch(ze){return D(lt(ze)),!1}finally{L(null)}},[We,d,a,o]),Ae=z.useCallback(async se=>{if(!o?.canEditFilesystem)return D("Project restore is not available in this host. Use the Scout CLI or desktop app."),!1;if(!a?.restoreProject)return D("Project restore is unavailable in this build."),!1;L(se.root);try{const Me=await a.restoreProject(se.root);return We(Me),await d(!1),D(`Restored ${se.title}. Scout will discover it again.`),!0}catch(Me){return D(lt(Me)),!1}finally{L(null)}},[We,d,a,o]),ue=z.useCallback(()=>{(async()=>{try{if(!a?.restartOnboarding)return;const se=await a.restartOnboarding();we(se),D("Onboarding restarted.")}catch(se){D(lt(se))}})()},[we,a]),Ee=z.useCallback(se=>{y(Me=>{const ze=Me??f;if(!ze)return Me;const nt=Array.from(new Set([...ze.workspaceRoots,se]));return{...ze,onboardingContextRoot:ze.onboardingContextRoot||se,workspaceRoots:nt}}),D("Project paths updated. Save General to persist the change."),X(!0)},[f]),V=z.useCallback(()=>{H||(y(f),D(null),X(!0))},[f,H]),me=z.useCallback((se,Me)=>{y(ze=>{const nt=ze??f;if(!nt)return ze;const Qt=[...nt.workspaceRoots];for(;Qt.length<=se;)Qt.push("");return Qt[se]=Me,{...nt,onboardingContextRoot:se===0&&(!nt.onboardingContextRoot||nt.onboardingContextRoot===nt.workspaceRoots[0])?Me:nt.onboardingContextRoot,workspaceRoots:Qt}}),D(null),X(!0)},[f]),je=z.useCallback(()=>{y(se=>{const Me=se??f;return Me?{...Me,workspaceRoots:[...Me.workspaceRoots,""]}:se}),D("Project paths updated. Save General to persist the change."),X(!0)},[f]),Fe=z.useCallback(se=>{y(Me=>{const ze=Me??f;if(!ze)return Me;const nt=ze.workspaceRoots[se]??"",Qt=ze.workspaceRoots.filter((ha,Gl)=>Gl!==se),gn=se===0&&(!ze.onboardingContextRoot||ze.onboardingContextRoot===nt)?Qt[0]??"":ze.onboardingContextRoot;return{...ze,onboardingContextRoot:gn,workspaceRoots:Qt}}),D("Project paths updated. Save General to persist the change."),X(!0)},[f]),Je=z.useCallback(se=>{(async()=>{try{if(!o?.canPickDirectory||!a?.pickDirectory)return;const Me=await a.pickDirectory();if(!Me)return;me(se,Me),D("Project paths updated. Save General to persist the change.")}catch(Me){D(lt(Me))}})()},[me,a,o]),qe=z.useCallback(se=>{y(Me=>{const ze=Me??f;return ze?{...ze,onboardingContextRoot:se}:Me}),D(null),X(!0)},[f]),St=z.useCallback(()=>{(async()=>{try{if(!o?.canPickDirectory||!a?.pickDirectory)return;const se=await a.pickDirectory();if(!se)return;qe(se)}catch(se){D(lt(se))}})()},[qe,a,o]),Yt=z.useCallback(()=>{(async()=>{try{if(a?.skipOnboarding){const se=await a.skipOnboarding();Ye(se)}$("done"),D(null),X(!1)}catch(se){D(lt(se))}})()},[Ye,a]),Vt=z.useCallback(()=>{(async()=>{if(Ue.id!=="confirm"){Ce(1);return}if(!le){Ce(1);return}await ge()&&Ce(1)})()},[Ue.id,le,ge,Ce]);z.useEffect(()=>{const se=Ue.id;if(se!=="setup"&&se!=="doctor"&&se!=="runtimes"||Z||oe[se]||!ye||b||se==="doctor"&&!Re)return;const Me=setTimeout(()=>{_e(se)},600);return()=>clearTimeout(Me)},[Ue.id,b,_e,oe,Z,Re,ye]);const Pt=z.useCallback(()=>{if(tt){Ce(1);return}Yt()},[tt,Yt,Ce]),yt=z.useCallback(async se=>{const Me=et(se);await navigator.clipboard.writeText(Me),N(se),window.setTimeout(()=>{N(ze=>ze===se?null:ze)},1500)},[et]),Wt=z.useCallback(()=>{a?.refreshSettingsInventory&&(C(!0),a.refreshSettingsInventory().then(se=>{We(se)}).catch(se=>{D(lt(se))}).finally(()=>{C(!1)}))},[We,a]);return{SOURCE_ROOT_PATH_SUGGESTIONS:XM,appSettings:f,setAppSettings:p,appSettingsDraft:h,appSettingsLoading:b,workspaceInventoryLoading:j,appSettingsSaving:E,appSettingsFeedback:M,setAppSettingsFeedback:D,setAppSettingsDraft:y,isAppSettingsEditing:H,onboardingWizardStep:B,setOnboardingWizardStep:F,onboardingCommandPending:Z,onboardingCommandResult:P,onboardingCommandHistory:oe,onboardingCopiedCommand:ee,startupOnboardingState:Y,setStartupOnboardingState:$,setIsAppSettingsEditing:X,setOnboardingCommandResult:Q,setOnboardingCopiedCommand:N,visibleAppSettings:ye,agentableProjects:T,hiddenProjects:_,appSettingsDirty:le,projectRetirementPendingRoot:q,workspaceInventoryLoaded:R,canRefreshWorkspaceInventory:pe,showDoctorOutput:xe,onboardingContextRoot:ce,onboardingHasProjectConfig:Re,onboardingRuntimeMatch:Te,onboardingWizardSteps:He,onboardingWizardIndex:Le,activeOnboardingStep:Ue,canGoToPreviousOnboardingStep:it,canGoToNextOnboardingStep:tt,startupOnboardingVisible:st,startupOnboardingBlocking:ot,buildOnboardingCommandLine:et,replaceAppSettings:Ye,syncRefreshedAppSettings:Ge,applyNextAppSettings:We,applyRestartedOnboardingSettings:we,refreshVisibleAppSettings:Se,handleStartAppSettingsEdit:Ze,handleCancelAppSettingsEdit:mt,updateAppSettingsDraft:ae,handleSaveAppSettings:ge,moveOnboardingWizard:Ce,handleRunOnboardingCommand:_e,handleRetireProject:Xe,handleRestoreProject:Ae,handleRestartOnboarding:ue,handleAddSourceRootSuggestion:Ee,handleBeginGeneralEdit:V,handleSetSourceRootAt:me,handleAddSourceRootRow:je,handleRemoveSourceRootRow:Fe,handleBrowseForSourceRoot:Je,handleSetOnboardingContextRoot:qe,handleBrowseForOnboardingContextRoot:St,dismissStartupOnboarding:Yt,handleOnboardingContinue:Vt,skipCurrentOnboardingStep:Pt,handleCopyOnboardingCommand:yt,handleLoadWorkspaceInventory:Wt}}function ZM({sidebarWidth:e,messagesDetailWidth:r,isCollapsed:a,onResizeStart:i,onMessagesDetailResizeStart:o,styles:u,messagesState:d,messageThreads:f,selectedMessagesThread:p,onSelectMessageThread:h,showAnnotations:y,setShowAnnotations:b,onRefresh:v,loadingWorkspace:j,selectedMessagesInternalThread:C,selectedMessagesInternalMessages:E,selectedMessagesInternalTarget:w,selectedMessagesDetailAgentId:M,selectedMessagesDetailAgent:D,selectedMessagesSessions:H,selectedSession:X,setSelectedSession:q,formatDate:L,interAgentAgents:B,interAgentAgentLookup:F,relayDirectLookup:Z,openAgentProfile:O,openAgentDirectMessage:P,onNudgeMessage:Q,messagesDetailOpen:oe,setMessagesDetailOpen:J,messagesDetailTab:ee,setMessagesDetailTab:N,selectedRelayKind:Y,selectedRelayId:$,relayThreadTitle:ye,relayThreadSubtitle:T,relayThreadCount:_,selectedRelayDirectThread:le,relayVoiceState:R,visibleRelayMessages:pe,relayTimelineViewportRef:xe,onRelayTimelineScroll:ce,relayReplyTarget:Re,setRelayReplyTarget:Te,relayContextReferences:Ne,relayContextMessageIds:He,setRelayContextMessageIds:Le,relayComposerRef:Ue,relayDraft:it,setRelayDraft:tt,relaySending:st,relayFeedback:ot,relayComposerSelectionStart:bt,setRelayComposerSelectionStart:Ye,mergedRelayMessages:Ge,relayMentionMenuOpen:We,relayMentionSuggestions:we,relayMentionSelectionIndex:et,setRelayMentionSelectionIndex:Se,relayMentionDuplicateTitleCounts:Ze,applyRelayMentionSuggestion:mt,onRelaySend:ae,onToggleVoiceCapture:ge,onSetVoiceRepliesEnabled:Ce,visibleAgentSession:_e,agentSessionPending:Xe,agentSessionFeedback:Ae,agentSessionCopied:ue,onCopyAgentSessionCommand:Ee,onOpenAgentSession:V,onPeekAgentSession:me,onOpenAgentSettings:je,desktopVoiceEnabled:Fe}){return l.jsxs(l.Fragment,{children:[a?null:l.jsx(WM,{sidebarWidth:e,styles:u,messagesState:d,messageThreads:f,selectedMessagesThread:p,onResizeStart:i,onSelectMessageThread:h}),l.jsx("div",{className:"flex-1 flex flex-col relative min-w-0",style:u.surface,children:p?.kind==="internal"?l.jsx(JM,{styles:u,selectedMessagesThread:p,selectedMessagesInternalThread:C,selectedMessagesInternalMessages:E,selectedMessagesInternalTarget:w,showAnnotations:y,setShowAnnotations:b,setMessagesDetailOpen:J,messagesDetailOpen:oe,onRefresh:v,interAgentAgentLookup:F,relayDirectLookup:Z,openAgentProfile:O,openAgentDirectMessage:P,onNudgeMessage:Q}):l.jsx(ez,{styles:u,selectedRelayKind:Y,selectedRelayId:$,relayThreadTitle:ye,relayThreadSubtitle:T,relayThreadCount:_,selectedRelayDirectThread:le,relayVoiceState:R,visibleRelayMessages:pe,relayTimelineViewportRef:xe,onRelayTimelineScroll:ce,relayReplyTarget:Re,setRelayReplyTarget:Te,relayContextReferences:Ne,relayContextMessageIds:He,setRelayContextMessageIds:Le,relayComposerRef:Ue,relayDraft:it,setRelayDraft:tt,relaySending:st,relayFeedback:ot,relayComposerSelectionStart:bt,setRelayComposerSelectionStart:Ye,mergedRelayMessages:Ge,relayMentionMenuOpen:We,relayMentionSuggestions:we,relayMentionSelectionIndex:et,setRelayMentionSelectionIndex:Se,relayMentionDuplicateTitleCounts:Ze,applyRelayMentionSuggestion:mt,showAnnotations:y,setShowAnnotations:b,setMessagesDetailOpen:J,messagesDetailOpen:oe,onRefresh:v,loadingWorkspace:j,onRelaySend:ae,onToggleVoiceCapture:ge,onSetVoiceRepliesEnabled:Ce,interAgentAgentLookup:F,relayDirectLookup:Z,openAgentProfile:O,openAgentDirectMessage:P,onNudgeMessage:Q,desktopVoiceEnabled:Fe})}),oe&&p?l.jsx(nz,{styles:u,messagesDetailWidth:r,selectedMessagesThread:p,selectedMessagesInternalThread:C,selectedMessagesDetailAgentId:M,selectedMessagesDetailAgent:D,selectedMessagesSessions:H,selectedSession:X,setSelectedSession:q,formatDate:L,interAgentAgents:B,messagesDetailTab:ee,setMessagesDetailTab:N,setMessagesDetailOpen:J,onResizeStart:o,openAgentProfile:O,openAgentDirectMessage:P,visibleAgentSession:_e,agentSessionPending:Xe,agentSessionFeedback:Ae,agentSessionCopied:ue,onCopyAgentSessionCommand:Ee,onOpenAgentSession:V,onPeekAgentSession:me,onOpenAgentSettings:je}):null]})}function WM({sidebarWidth:e,styles:r,messagesState:a,messageThreads:i,selectedMessagesThread:o,onResizeStart:u,onSelectMessageThread:d}){return l.jsxs("div",{style:{width:e,...r.sidebar},className:"relative flex flex-col h-full border-r shrink-0 z-10 overflow-hidden",children:[l.jsx("div",{className:"absolute right-[-3px] top-0 bottom-0 w-1.5 cursor-col-resize hover:bg-indigo-400 z-20 transition-colors",onMouseDown:u}),l.jsx("div",{className:"px-3 py-2.5 flex items-center justify-between",children:l.jsxs("div",{children:[l.jsx("h1",{className:"text-[13px] font-semibold tracking-tight",style:r.inkText,children:a?.title??"Messages"}),l.jsx("div",{className:"text-[10px] font-mono mt-0.5",style:r.mutedText,children:a?.subtitle??"Broker unavailable"})]})}),l.jsx("div",{className:"flex-1 overflow-y-auto py-2",children:[["inbox","Inbox"],["channels","Channels"],["agents","Agents"],["internal","Internal"]].map(([f,p])=>{const h=i.filter(y=>y.group===f);return h.length===0?null:l.jsxs("div",{className:"mb-3 px-1.5",children:[l.jsx("div",{className:"font-mono text-[9px] tracking-widest uppercase mb-1 px-1.5",style:r.mutedText,children:p}),l.jsx("div",{className:"flex flex-col gap-px",children:h.map(y=>{const b=o?.id===y.id,v=y.kind==="relay"&&y.relayDestinationKind==="direct";return l.jsxs("button",{className:`os-rail-row flex items-center gap-2 px-1.5 py-1 rounded cursor-pointer w-full text-left${b?" os-rail-row-active":""}`,style:b?r.activeItem:r.mutedText,onClick:()=>d(y),children:[y.kind==="internal"?l.jsx("div",{className:"w-4 h-4 shrink-0 flex items-center justify-center",children:l.jsx(Ki,{size:12,style:b?{color:g.accent}:r.mutedText})}):v?l.jsxs("div",{className:"relative shrink-0",children:[l.jsx("div",{className:`os-rail-avatar w-4 h-4 rounded text-white flex items-center justify-center font-bold text-[8px] ${y.reachable?"":"opacity-40 grayscale"}`,style:{backgroundColor:cl(y.relayDestinationId??y.id)},children:y.title.charAt(0).toUpperCase()}),y.state?l.jsx("div",{className:`absolute -bottom-0.5 -right-0.5 w-1.5 h-1.5 rounded-full ${Ro(y.state)}`,style:{border:`1px solid ${g.bg}`}}):null]}):l.jsx(ck,{id:y.relayDestinationId??y.id,active:b}),l.jsxs("div",{className:`flex-1 min-w-0 ${y.reachable?"":"opacity-50"}`,children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("div",{className:"font-medium text-[12px] truncate",children:Ip(y.title)}),y.state==="working"?l.jsx(Ku,{className:"text-[var(--os-accent)]"}):null]}),l.jsx("div",{className:"text-[10px] truncate",style:r.mutedText,children:y.preview??y.subtitle??""})]}),typeof y.count=="number"&&y.count>0?l.jsx("span",{className:"os-row-count text-[9px] font-mono px-1 rounded",style:b?r.activePill:r.tagBadge,children:y.count}):null]},y.id)})})]},f)})})]})}function JM({styles:e,selectedMessagesThread:r,selectedMessagesInternalThread:a,selectedMessagesInternalMessages:i,selectedMessagesInternalTarget:o,showAnnotations:u,setShowAnnotations:d,setMessagesDetailOpen:f,messagesDetailOpen:p,onRefresh:h,interAgentAgentLookup:y,relayDirectLookup:b,openAgentProfile:v,openAgentDirectMessage:j,onNudgeMessage:C}){return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"border-b flex items-center justify-between px-4 py-2 shrink-0 gap-4",style:{...e.surface,borderBottomColor:g.border},children:[l.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[l.jsx(Ki,{size:14,style:e.mutedText}),l.jsxs("div",{className:"min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[l.jsx("h2",{className:"text-[13px] font-semibold tracking-tight truncate",style:e.inkText,children:a?.title??r.title??"Internal"}),a?l.jsx("span",{className:"text-[9px] font-mono px-1.5 py-0.5 rounded shrink-0",style:e.tagBadge,children:a.messageCount}):null]}),l.jsx("div",{className:"text-[10px] truncate mt-0.5",style:e.mutedText,children:a?.subtitle??r.subtitle??"Agent-to-agent coordination"})]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[o?l.jsxs("button",{className:"os-toolbar-button flex items-center gap-1.5 text-[10px] font-medium px-2 py-0.5 rounded",style:{color:g.ink},onClick:()=>j(o.id),children:[l.jsx(Al,{size:11}),l.jsx("span",{children:"Message Agent"})]}):null,l.jsxs("button",{onClick:()=>d(!u),className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded",style:u?{backgroundColor:g.accentBg,color:g.accent}:{color:g.ink},children:["Annotations ",l.jsx("span",{className:"font-mono uppercase",children:u?"On":"Off"})]}),l.jsx("button",{className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded",style:{color:g.ink},onClick:()=>{h()},children:"Sync"}),l.jsx("button",{className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded",style:p?{backgroundColor:g.accentBg,color:g.accent}:{color:g.ink},onClick:()=>f(E=>!E),children:"Details"})]})]}),l.jsx("div",{className:"flex-1 overflow-y-auto px-4 py-3 pb-6",children:i.length===0?l.jsxs("div",{className:"flex flex-col items-center justify-center h-64 text-center",children:[l.jsx("div",{className:"w-16 h-16 rounded-full flex items-center justify-center mb-4",style:{backgroundColor:g.accentBg},children:l.jsx(Ki,{size:24,style:{color:g.accent}})}),l.jsx("h3",{className:"text-[15px] font-medium mb-1",style:e.inkText,children:"No internal traffic yet"}),l.jsx("p",{className:"text-[13px] max-w-sm",style:e.mutedText,children:"This thread exists, but no visible agent-to-agent messages have been captured yet."})]}):l.jsx("div",{className:"flex flex-col gap-1",children:l.jsx(ko,{messages:i,showAnnotations:u,showStatusMessages:!1,inkStyle:e.inkText,mutedStyle:e.mutedText,tagStyle:e.tagBadge,annotStyle:e.annotBadge,agentLookup:y,directThreadLookup:b,onOpenAgentProfile:v,onOpenAgentChat:j,onNudgeMessage:C})})}),l.jsx("div",{className:"px-4 py-3 shrink-0",style:e.surface,children:l.jsxs("div",{className:"rounded-lg border px-3 py-3",style:{borderColor:g.border,backgroundColor:g.bg},children:[l.jsx("div",{className:"text-[9px] font-mono uppercase tracking-widest",style:e.mutedText,children:"Internal Thread"}),l.jsx("div",{className:"text-[11px] mt-1 leading-[1.6]",style:e.mutedText,children:"Internal coordination is read-only here. Open a direct conversation with an agent if you want to intervene."}),o?l.jsxs("button",{type:"button",onClick:()=>j(o.id),className:"mt-3 os-toolbar-button flex items-center gap-1.5 text-[10px] font-medium px-2 py-1 rounded",style:{color:g.ink},children:[l.jsx(Np,{size:11}),"Open Direct Message"]}):null]})}),l.jsx("div",{className:"h-7 border-t flex items-center px-4 shrink-0",style:{backgroundColor:g.bg,borderTopColor:g.border},children:l.jsx("span",{className:"text-[9px] font-mono",style:e.mutedText,children:"Read-only internal coordination thread inside Messages"})})]})}function ez({styles:e,selectedRelayKind:r,selectedRelayId:a,relayThreadTitle:i,relayThreadSubtitle:o,relayThreadCount:u,selectedRelayDirectThread:d,relayVoiceState:f,visibleRelayMessages:p,relayTimelineViewportRef:h,onRelayTimelineScroll:y,relayReplyTarget:b,setRelayReplyTarget:v,relayContextReferences:j,relayContextMessageIds:C,setRelayContextMessageIds:E,relayComposerRef:w,relayDraft:M,setRelayDraft:D,relaySending:H,relayFeedback:X,relayComposerSelectionStart:q,setRelayComposerSelectionStart:L,mergedRelayMessages:B,relayMentionMenuOpen:F,relayMentionSuggestions:Z,relayMentionSelectionIndex:O,setRelayMentionSelectionIndex:P,relayMentionDuplicateTitleCounts:Q,applyRelayMentionSuggestion:oe,showAnnotations:J,setShowAnnotations:ee,setMessagesDetailOpen:N,messagesDetailOpen:Y,onRefresh:$,loadingWorkspace:ye,onRelaySend:T,onToggleVoiceCapture:_,onSetVoiceRepliesEnabled:le,interAgentAgentLookup:R,relayDirectLookup:pe,openAgentProfile:xe,openAgentDirectMessage:ce,onNudgeMessage:Re,desktopVoiceEnabled:Te}){const Ne=p.at(-1)?.createdAt??null,[He,Le]=z.useState(()=>Date.now());z.useEffect(()=>{if(d?.state!=="working")return;Le(Date.now());const Ge=window.setInterval(()=>{Le(Date.now())},15e3);return()=>window.clearInterval(Ge)},[Ne,d?.activeTask,d?.id,d?.state,d?.statusDetail]);const Ue=d?.state==="working"&&Ne?Math.max(0,He-Ne):0,it=Ue>0?lz(Ue):null,tt=Ue>=9e4,st=d?.activeTask??d?.statusDetail??o??"Agent is still working.",ot=!ye&&p.length===0&&r==="direct",bt=ye?"Loading relay workspace":ot?"Waiting for first relay message":"No relay traffic yet",Ye=ye?"Fetching threads, messages, and agent state for this workspace.":ot?d?.activeTask??d?.statusDetail??"This direct lane is open. Send a message or wait for the agent to speak first.":"Send a message into this lane to wake an agent or start a broker-backed conversation.";return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"border-b flex items-center justify-between px-4 py-2 shrink-0 gap-4",style:{...e.surface,borderBottomColor:g.border},children:[l.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[l.jsx("div",{className:"shrink-0",children:r==="direct"?l.jsx(Np,{size:14,style:e.mutedText}):l.jsx(ck,{id:a,active:!1,size:14})}),l.jsxs("div",{className:"min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[l.jsx("h2",{className:"text-[13px] font-semibold tracking-tight truncate",style:e.inkText,children:i}),u?l.jsx("span",{className:"text-[9px] font-mono px-1.5 py-0.5 rounded shrink-0",style:e.tagBadge,children:u}):null,d?l.jsx(wM,{thread:d}):null]}),o?l.jsx("div",{className:"text-[10px] truncate mt-0.5",style:e.mutedText,children:o}):null]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[d?l.jsxs("button",{className:"os-toolbar-button flex items-center gap-1.5 text-[10px] font-medium px-2 py-0.5 rounded",style:{color:g.ink},onClick:()=>xe(d.id),children:[l.jsx($i,{size:11}),l.jsx("span",{children:"Agent"})]}):null,l.jsxs("button",{onClick:()=>ee(!J),className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded",style:J?{backgroundColor:g.accentBg,color:g.accent}:{color:g.ink},children:["Annotations ",l.jsx("span",{className:"font-mono uppercase",children:J?"On":"Off"})]}),Te?l.jsxs(l.Fragment,{children:[l.jsxs("button",{className:"os-toolbar-button flex items-center gap-1.5 text-[10px] font-medium px-2 py-0.5 rounded",style:f?.isCapturing?{backgroundColor:g.accentBg,color:g.accent}:{color:g.ink},onClick:()=>{_()},title:f?.detail??void 0,children:[f?.captureTitle??"Capture"," ",l.jsx("span",{className:"font-mono uppercase",style:{color:g.accent},children:f?.captureState??"Off"})]}),l.jsxs("button",{className:"os-toolbar-button flex items-center gap-1.5 text-[10px] font-medium px-2 py-0.5 rounded",style:f?.repliesEnabled?{backgroundColor:g.accentBg,color:g.accent}:{color:g.ink},onClick:()=>{le(!(f?.repliesEnabled??!1))},title:f?.detail??void 0,children:["Playback ",l.jsx("span",{className:"font-mono uppercase",style:{color:g.accent},children:f?.speaking?"Speaking":f?.repliesEnabled?"On":"Off"})]})]}):null,l.jsx("button",{className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded",style:{color:g.ink},onClick:()=>{$()},children:"Sync"}),l.jsx("button",{className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded",style:Y?{backgroundColor:g.accentBg,color:g.accent}:{color:g.ink},onClick:()=>N(Ge=>!Ge),children:"Details"})]})]}),l.jsx("div",{ref:h,className:"flex-1 overflow-y-auto px-4 py-3 pb-6",onScroll:y,children:p.length===0?l.jsxs("div",{className:"flex flex-col items-center justify-center h-64 text-center",children:[l.jsx("div",{className:"w-16 h-16 rounded-full flex items-center justify-center mb-4",style:{backgroundColor:g.accentBg},children:ye||ot?l.jsx(un,{className:"text-[22px]",style:{color:g.accent}}):l.jsx(Al,{size:24,style:{color:g.accent}})}),l.jsx("h3",{className:"text-[15px] font-medium mb-1",style:e.inkText,children:bt}),l.jsx("p",{className:"text-[13px] max-w-sm",style:e.mutedText,children:Ye})]}):l.jsx("div",{className:"flex flex-col gap-1",children:l.jsx(ko,{messages:p,showAnnotations:J,showStatusMessages:r==="channel"&&a==="system",inkStyle:e.inkText,mutedStyle:e.mutedText,tagStyle:e.tagBadge,annotStyle:e.annotBadge,agentLookup:R,directThreadLookup:pe,onOpenAgentProfile:xe,onOpenAgentChat:ce,onNudgeMessage:Re})})}),d?.state==="working"?l.jsx("div",{className:"px-4 pb-1 shrink-0",style:e.surface,children:l.jsx("div",{className:"rounded-xl border px-3 py-2.5 flex items-start justify-between gap-3",style:{borderColor:tt?"rgba(245,158,11,0.32)":g.border,backgroundColor:tt?"rgba(245,158,11,0.08)":g.bg},children:l.jsxs("div",{className:"min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[l.jsx(Ku,{className:"text-[var(--os-accent)] shrink-0"}),l.jsx("span",{className:"text-[11px] font-medium truncate",style:e.inkText,children:tt?"Still working":"Working"}),it?l.jsx("span",{className:"text-[9px] font-mono px-1.5 py-0.5 rounded shrink-0",style:tt?{color:"#b45309",backgroundColor:"rgba(245,158,11,0.14)"}:e.tagBadge,children:tt?`No update for ${it}`:`${it} ago`}):null]}),l.jsx("div",{className:"text-[10px] mt-1 truncate",style:e.mutedText,children:st})]})})}):null,l.jsx(tz,{styles:e,selectedRelayKind:r,selectedRelayId:a,relayVoiceState:f,relayReplyTarget:b,setRelayReplyTarget:v,relayContextReferences:j,relayContextMessageIds:C,setRelayContextMessageIds:E,relayComposerRef:w,relayDraft:M,setRelayDraft:D,relaySending:H,relayComposerSelectionStart:q,setRelayComposerSelectionStart:L,mergedRelayMessages:B,relayMentionMenuOpen:F,relayMentionSuggestions:Z,relayMentionSelectionIndex:O,setRelayMentionSelectionIndex:P,relayMentionDuplicateTitleCounts:Q,applyRelayMentionSuggestion:oe,onRelaySend:T,desktopVoiceEnabled:Te}),l.jsxs("div",{className:"h-7 border-t flex items-center justify-between px-4 shrink-0",style:{backgroundColor:g.bg,borderTopColor:g.border},children:[l.jsxs("div",{className:"flex items-center gap-3 text-[9px] font-mono",style:e.mutedText,children:[l.jsxs("span",{className:"flex items-center gap-1",children:[l.jsx("span",{style:e.inkText,children:"@"})," mention agents"]}),F?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"w-px h-3",style:{backgroundColor:g.border}}),l.jsx("span",{children:"↑↓ select · ↵ or Tab insert"})]}):null,l.jsx("span",{className:"w-px h-3",style:{backgroundColor:g.border}}),l.jsxs("span",{className:"flex items-center gap-1",children:[l.jsx("kbd",{className:"font-sans px-1 py-0.5 rounded border text-[9px] font-medium leading-none shadow-sm",style:e.kbd,children:"Cmd+Enter"})," send"]}),X?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"w-px h-3",style:{backgroundColor:g.border}}),l.jsx("span",{children:X})]}):null]}),l.jsx("div",{className:"flex items-center gap-2 text-[9px] font-mono uppercase tracking-widest",style:e.mutedText,children:d?.state==="offline"?l.jsx("span",{children:d.statusLabel}):null})]})]})}function tz({styles:e,selectedRelayKind:r,selectedRelayId:a,relayVoiceState:i,relayReplyTarget:o,setRelayReplyTarget:u,relayContextReferences:d,relayContextMessageIds:f,setRelayContextMessageIds:p,relayComposerRef:h,relayDraft:y,setRelayDraft:b,relaySending:v,relayComposerSelectionStart:j,setRelayComposerSelectionStart:C,mergedRelayMessages:E,relayMentionMenuOpen:w,relayMentionSuggestions:M,relayMentionSelectionIndex:D,setRelayMentionSelectionIndex:H,relayMentionDuplicateTitleCounts:X,applyRelayMentionSuggestion:q,onRelaySend:L,desktopVoiceEnabled:B}){return l.jsxs("div",{className:"px-4 py-3 shrink-0",style:e.surface,children:[o?l.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3 rounded-lg border px-3 py-2",style:{borderColor:g.border,backgroundColor:g.bg},children:[l.jsxs("div",{className:"min-w-0",children:[l.jsxs("div",{className:"text-[9px] font-mono uppercase tracking-widest",style:e.mutedText,children:["Replying to ",o.authorName," · ",So(o.messageId)]}),l.jsx("div",{className:"text-[11px] truncate mt-1",style:e.mutedText,children:o.preview})]}),l.jsx("button",{type:"button",onClick:()=>u(null),className:"shrink-0 rounded p-1 transition-opacity hover:opacity-70",style:e.mutedText,title:"Clear reply context",children:l.jsx(kl,{size:12})})]}):null,d.length>0?l.jsx("div",{className:"mb-2 space-y-2",children:d.map(F=>l.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-lg border px-3 py-2",style:{borderColor:g.border,backgroundColor:g.bg},children:[l.jsxs("div",{className:"min-w-0",children:[l.jsxs("div",{className:"text-[9px] font-mono uppercase tracking-widest",style:e.mutedText,children:["Context · ",F.authorName," · ",So(F.messageId)]}),l.jsx("div",{className:"text-[11px] truncate mt-1",style:e.mutedText,children:F.preview})]}),l.jsx("button",{type:"button",onClick:()=>p(Z=>Z.filter(O=>O!==F.messageId)),className:"shrink-0 rounded p-1 transition-opacity hover:opacity-70",style:e.mutedText,title:"Clear referenced context",children:l.jsx(kl,{size:12})})]},F.messageId))}):null,l.jsxs("div",{className:"relative",children:[w?l.jsxs("div",{className:"absolute inset-x-0 bottom-full mb-2 rounded-xl border shadow-lg overflow-hidden z-20",style:{backgroundColor:g.surface,borderColor:g.border,boxShadow:g.shadowLg},children:[l.jsx("div",{className:"px-3 py-2 border-b text-[9px] font-mono uppercase tracking-widest",style:{...e.mutedText,borderColor:g.border},children:"Mention an agent"}),l.jsx("div",{className:"max-h-64 overflow-y-auto",children:M.map((F,Z)=>{const O=Z===D,P=az(F),Q=iz(F),oe=(X.get(F.title)??0)>1,J=oe||!!F.harness||!!Q,ee=!!(Q&&Q!==P);return l.jsxs("button",{type:"button",className:"w-full flex items-start justify-between gap-3 px-3 py-2.5 text-left transition-colors",style:{backgroundColor:O?g.bg:"transparent",color:g.ink},onMouseDown:N=>{N.preventDefault(),q(F)},children:[l.jsxs("div",{className:"min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-wrap",children:[l.jsx("span",{className:"text-[11px] font-medium truncate",children:F.title}),l.jsx("span",{className:"text-[9px] font-mono px-1.5 py-0.5 rounded",style:e.tagBadge,children:F.statusLabel}),J&&P?l.jsx("span",{className:"text-[9px] font-mono px-1.5 py-0.5 rounded",style:e.tagBadge,children:P}):null,F.harness?l.jsx("span",{className:"text-[9px] font-mono px-1.5 py-0.5 rounded",style:e.tagBadge,children:F.harness}):null,ee&&Q?l.jsx("span",{className:"text-[9px] font-mono px-1.5 py-0.5 rounded",style:e.tagBadge,children:Q}):null]}),l.jsxs("div",{className:"text-[10px] mt-1 truncate",style:e.mutedText,children:[F.mentionToken,oe&&F.subtitle?` · ${Ka(F.subtitle)??F.subtitle}`:""]})]}),l.jsx("span",{className:"text-[9px] font-mono shrink-0",style:e.mutedText,children:O?"↵":""})]},F.agentId)})})]}):null,l.jsxs("div",{className:"border rounded flex items-center px-2 py-1 transition-all focus-within:ring-1",style:{backgroundColor:g.bg,borderColor:g.border},children:[l.jsx("textarea",{ref:h,className:"flex-1 bg-transparent outline-none resize-none h-[20px] min-h-[20px] max-h-[80px] text-[12px] leading-tight py-0.5",style:{color:g.ink},placeholder:rz(r,a),rows:1,value:y,onChange:F=>{const Z=fz(F.currentTarget.value,E,f);b(Z.body),C(F.currentTarget.selectionStart??Z.body.length),Z.nextReferenceMessageIds!==f&&p(Z.nextReferenceMessageIds)},onClick:F=>C(F.currentTarget.selectionStart??y.length),onKeyUp:F=>C(F.currentTarget.selectionStart??y.length),onSelect:F=>C(F.currentTarget.selectionStart??y.length),onKeyDown:F=>{if(w){if(F.key==="ArrowDown"){F.preventDefault(),H(Z=>M.length===0?0:(Z+1)%M.length);return}if(F.key==="ArrowUp"){F.preventDefault(),H(Z=>M.length===0?0:(Z-1+M.length)%M.length);return}if(F.key==="Enter"&&!F.metaKey&&!F.ctrlKey&&!F.shiftKey||F.key==="Tab"){F.preventDefault();const Z=M[D]??M[0];Z&&q(Z);return}if(F.key==="Escape"){F.preventDefault(),C(y.length);return}}(F.metaKey||F.ctrlKey)&&F.key==="Enter"&&(F.preventDefault(),L())}}),l.jsxs("div",{className:"shrink-0 flex items-center gap-1 ml-2",children:[B?l.jsx("button",{className:"p-1 opacity-50 cursor-default transition-opacity",style:e.mutedText,title:i?.detail??"Voice unavailable in Electron",children:l.jsx(d2,{size:12})}):null,l.jsx("button",{type:"button",className:"shrink-0 flex h-[26px] w-[26px] items-center justify-center rounded-md border transition-opacity hover:opacity-85 disabled:opacity-30 disabled:cursor-not-allowed",style:{borderColor:g.border,backgroundColor:g.surface,color:g.ink},onClick:()=>{L()},disabled:v||!y.trim(),title:"Send","aria-label":"Send message",children:l.jsx(C1,{size:14})})]})]})]})]})}function nz({styles:e,messagesDetailWidth:r,selectedMessagesThread:a,selectedMessagesInternalThread:i,selectedMessagesDetailAgentId:o,selectedMessagesDetailAgent:u,selectedMessagesSessions:d,selectedSession:f,setSelectedSession:p,formatDate:h,interAgentAgents:y,messagesDetailTab:b,setMessagesDetailTab:v,setMessagesDetailOpen:j,onResizeStart:C,openAgentProfile:E,openAgentDirectMessage:w,visibleAgentSession:M,agentSessionPending:D,agentSessionFeedback:H,agentSessionCopied:X,onCopyAgentSessionCommand:q,onOpenAgentSession:L,onPeekAgentSession:B,onOpenAgentSettings:F}){return l.jsxs("div",{className:"relative border-l shrink-0 overflow-y-auto flex flex-col",style:{width:r,...e.surface,borderLeftColor:g.border},children:[l.jsx("div",{className:"absolute left-[-3px] top-0 bottom-0 w-1.5 cursor-col-resize hover:bg-indigo-400 z-20 transition-colors",onMouseDown:C}),l.jsxs("div",{className:"px-4 py-3 border-b",style:{borderBottomColor:g.border},children:[l.jsxs("div",{className:"flex items-start justify-between gap-3",children:[l.jsxs("div",{className:"min-w-0",children:[l.jsx("div",{className:"text-[10px] font-mono tracking-widest uppercase",style:e.mutedText,children:"Thread Details"}),l.jsx("div",{className:"text-[13px] font-semibold mt-1 truncate",style:e.inkText,children:a.kind==="internal"?i?.title??a.title:Ip(a.title)}),l.jsx("div",{className:"text-[10px] mt-1 line-clamp-2",style:e.mutedText,children:a.preview??a.subtitle??"Context for the selected thread."})]}),l.jsxs("button",{type:"button",onClick:()=>j(!1),className:"os-toolbar-button flex items-center gap-1.5 text-[10px] font-medium px-2 py-1 rounded shrink-0",style:{color:g.ink},title:"Hide details",children:[l.jsx(kl,{size:11}),l.jsx("span",{children:"Hide"})]})]}),l.jsx("div",{className:"flex items-center gap-1 mt-3",children:[["overview","Overview"],["live","Live"],["history","History"]].filter(([Z])=>Z!=="live"||!!o).map(([Z,O])=>l.jsx("button",{type:"button",className:"rounded-md px-2.5 py-1.5 text-[11px] font-medium transition-colors",style:b===Z?e.activeItem:e.mutedText,onClick:()=>v(Z),children:O},Z))})]}),l.jsxs("div",{className:"p-4 flex-1 space-y-4",children:[b==="overview"?l.jsxs(l.Fragment,{children:[u?l.jsxs("section",{className:"rounded-xl border p-3",style:{borderColor:g.border,backgroundColor:g.bg},children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"w-10 h-10 rounded-lg text-white flex items-center justify-center text-[13px] font-bold",style:{backgroundColor:cl(u.id)},children:u.title.charAt(0).toUpperCase()}),l.jsxs("div",{className:"min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("div",{className:"text-[13px] font-semibold truncate",style:e.inkText,children:u.title}),l.jsx("span",{className:"text-[9px] font-mono px-1.5 py-0.5 rounded",style:u.state==="working"?e.activePill:e.tagBadge,children:u.statusLabel})]}),l.jsx("div",{className:"text-[10px] mt-1 line-clamp-2",style:e.mutedText,children:u.summary??u.statusDetail??"No summary yet."})]})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-2 mt-3 text-[10px]",children:[l.jsxs("div",{children:[l.jsx("div",{style:e.mutedText,children:"Harness"}),l.jsx("div",{style:e.inkText,children:u.harness??"Unknown"})]}),l.jsxs("div",{children:[l.jsx("div",{style:e.mutedText,children:"Threads"}),l.jsx("div",{style:e.inkText,children:u.threadCount})]}),l.jsxs("div",{children:[l.jsx("div",{style:e.mutedText,children:"Workspace"}),l.jsx("div",{className:"truncate",style:e.inkText,children:u.projectRoot??u.cwd??"Unbound"})]}),l.jsxs("div",{children:[l.jsx("div",{style:e.mutedText,children:"Last Chat"}),l.jsx("div",{style:e.inkText,children:u.lastChatLabel??"No recent chat"})]})]}),l.jsxs("div",{className:"flex items-center gap-2 mt-3",children:[l.jsxs("button",{type:"button",onClick:()=>w(u.id),className:"os-toolbar-button flex items-center gap-1.5 text-[10px] font-medium px-2 py-1 rounded",style:{color:g.ink},children:[l.jsx(Al,{size:11}),"Message"]}),l.jsxs("button",{type:"button",onClick:()=>{v("live"),B()},className:"os-toolbar-button flex items-center gap-1.5 text-[10px] font-medium px-2 py-1 rounded",style:{color:g.ink},children:[l.jsx(b1,{size:11}),"Peek"]}),l.jsxs("button",{type:"button",onClick:()=>F(u.id,u.profileKind==="project"),className:"os-toolbar-button flex items-center gap-1.5 text-[10px] font-medium px-2 py-1 rounded",style:{color:g.ink},children:[l.jsx($a,{size:11}),"Settings"]})]})]}):null,a.kind==="internal"&&i?l.jsxs("section",{className:"rounded-xl border p-3",style:{borderColor:g.border,backgroundColor:g.bg},children:[l.jsx("div",{className:"text-[10px] font-mono tracking-widest uppercase",style:e.mutedText,children:"Participants"}),l.jsx("div",{className:"flex flex-col gap-2 mt-3",children:i.participants.map(Z=>l.jsxs("div",{className:"flex items-center justify-between gap-2",children:[l.jsxs("div",{className:"min-w-0",children:[l.jsx("div",{className:"text-[12px] font-medium truncate",style:e.inkText,children:Z.title}),l.jsx("div",{className:"text-[10px] truncate",style:e.mutedText,children:Z.role??Z.id})]}),y.some(O=>O.id===Z.id)?l.jsx("button",{type:"button",onClick:()=>E(Z.id),className:"text-[10px] font-medium hover:opacity-80",style:{color:g.accent},children:"Open"}):null]},Z.id))})]}):null]}):null,b==="live"?l.jsxs("section",{className:"rounded-xl border overflow-hidden",style:{borderColor:g.border,backgroundColor:g.bg},children:[l.jsxs("div",{className:"px-3 py-3 border-b flex items-center justify-between gap-2",style:{borderBottomColor:g.border},children:[l.jsxs("div",{children:[l.jsx("div",{className:"text-[10px] font-mono tracking-widest uppercase",style:e.mutedText,children:"Live Session"}),l.jsx("div",{className:"text-[11px] mt-1",style:e.mutedText,children:"Runtime, tmux, or log tail for the selected agent."})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[M?.commandLabel?l.jsxs("button",{type:"button",onClick:()=>{q()},className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-1 rounded",style:{color:g.ink},children:[l.jsx(Nr,{size:11}),X?"Copied":"Copy"]}):null,o?l.jsxs("button",{type:"button",onClick:()=>{L()},className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-1 rounded",style:{color:g.ink},children:[l.jsx(UN,{size:11}),"Open"]}):null]})]}),l.jsx("div",{className:"p-3",children:D?l.jsxs("div",{className:"flex items-center gap-2 text-[11px]",style:e.mutedText,children:[l.jsx(un,{className:"text-[12px]"}),"Loading live session…"]}):M?.body?l.jsx("pre",{className:"max-h-[280px] overflow-y-auto text-[11px] leading-[1.55] whitespace-pre-wrap break-words font-mono",style:{color:g.termFg,backgroundColor:g.termBg,padding:"12px",borderRadius:g.radiusMd},children:M.body}):l.jsx("div",{className:"text-[11px] leading-[1.6]",style:e.mutedText,children:H??"No live session output is available for this thread yet."})})]}):null,b==="history"?l.jsxs("section",{className:"rounded-xl border p-3",style:{borderColor:g.border,backgroundColor:g.bg},children:[l.jsxs("div",{className:"flex items-center justify-between gap-2",children:[l.jsxs("div",{children:[l.jsx("div",{className:"text-[10px] font-mono tracking-widest uppercase",style:e.mutedText,children:"Recent History"}),l.jsx("div",{className:"text-[11px] mt-1",style:e.mutedText,children:"Recent sessions tied to this thread or agent."})]}),f?l.jsx("span",{className:"text-[9px] font-mono px-1.5 py-0.5 rounded",style:e.tagBadge,children:"selected"}):null]}),l.jsx("div",{className:"mt-3 flex flex-col gap-2",children:d.length>0?d.slice(0,8).map(Z=>l.jsx("button",{type:"button",onClick:()=>p(Z),className:"w-full rounded-lg border px-3 py-3 text-left transition-opacity hover:opacity-90",style:{borderColor:g.border,backgroundColor:f?.id===Z.id?g.surface:g.bg},children:l.jsxs("div",{className:"flex items-start justify-between gap-3",children:[l.jsxs("div",{className:"min-w-0",children:[l.jsx("div",{className:"text-[12px] font-medium truncate",style:e.inkText,children:Z.title}),l.jsxs("div",{className:"text-[10px] mt-1",style:e.mutedText,children:[Z.project," · ",Z.messageCount," messages"]}),l.jsx("div",{className:"text-[10px] mt-2 line-clamp-2",style:e.mutedText,children:Z.preview})]}),l.jsx("span",{className:"text-[10px] font-mono shrink-0",style:e.mutedText,children:h(Z.lastModified)})]})},Z.id)):l.jsx("div",{className:"text-[11px] leading-[1.6]",style:e.mutedText,children:"No recent session history is linked to this thread yet."})})]}):null,f?l.jsxs("section",{className:"rounded-xl border p-3",style:{borderColor:g.border,backgroundColor:g.bg},children:[l.jsx("div",{className:"text-[10px] font-mono tracking-widest uppercase",style:e.mutedText,children:"Selected Session"}),l.jsx("div",{className:"text-[12px] font-medium mt-2",style:e.inkText,children:f.title}),l.jsxs("div",{className:"text-[10px] mt-1",style:e.mutedText,children:[f.project," · ",f.agent]}),l.jsx("div",{className:"text-[11px] mt-2 leading-[1.6]",style:e.mutedText,children:f.preview})]}):null]})]})}function lz(e){const r=Math.floor(e/6e4);return r>=1?`${r}m`:`${Math.max(1,Math.floor(e/1e3))}s`}function rz(e,r){return e==="direct"?"Message direct thread...":e==="filter"&&r==="coordination"?"Message #shared-channel or @agent...":e==="channel"&&r==="voice"?"Message #voice...":e==="channel"&&r==="system"?"Message #system...":"Message #shared-channel..."}function az(e){return sz(e.subtitle)??e.workspaceQualifier??null}function iz(e){const r=e.branch?.trim();return r&&r!=="HEAD"?r:e.workspaceQualifier?.trim()||null}function sz(e){if(!e)return null;const r=e.replace(/[\\/]+$/,"");return r?r.split(/[\\/]/).filter(Boolean).at(-1)??null:null}function dk(){return/\b(?:message:[a-zA-Z0-9._:-]+|m:[a-z0-9]{4,12})\b/gi}function oz(e){return e.replace(/[^a-zA-Z0-9]/g,"").toLowerCase()}function cz(e,r){const a=e.trim().toLowerCase();if(!a)return null;if(a.startsWith("message:")){const u=e.slice(e.indexOf(":")+1).trim();return r.find(d=>d.id===u)??null}if(!a.startsWith("m:"))return null;const i=a.slice(2);if(!i)return null;const o=r.filter(u=>oz(u.id).endsWith(i));return o.length===1?o[0]:null}function uz(e,r){if(r.length===0)return e;const a=new Set(r.map(o=>o.toLowerCase()));return e.replace(dk(),o=>a.has(o.toLowerCase())?" ":o).split(/\r?\n/g).map(o=>o.replace(/[ \t]{2,}/g," ").trim()).filter((o,u,d)=>o.length>0||u>0&&u<d.length-1).join(`
|
|
90
|
-
`).trim()}function dz(e,r){return e.length!==r.length?!1:e.every((a,i)=>a===r[i])}function fz(e,r,a){const i=e.match(dk())??[];if(i.length===0)return{body:e,nextReferenceMessageIds:a};const o=[...a],u=[];for(const f of i){const p=cz(f,r);p&&(u.push(f),o.includes(p.id)||o.push(p.id))}return{body:uz(e,u),nextReferenceMessageIds:dz(o,a)?a:o}}function mz({activeView:e,layout:r,threading:a,composer:i,agentSession:o}){return e!=="messages"&&e!=="relay"?null:l.jsx(ZM,{...r,...a,...i,...o})}function pz({activeView:e,scoutDesktop:r,voiceEnabled:a,relayState:i,messagesState:o,interAgentAgents:u,interAgentThreads:d,sessions:f,appSettings:p,setActiveView:h,applyRelayWorkspacePatch:y}){const[b,v]=z.useState("channel"),[j,C]=z.useState("shared"),[E,w]=z.useState(null),[M,D]=z.useState(""),[H,X]=z.useState(!1),[q,L]=z.useState(0),[B,F]=z.useState(0),[Z,O]=z.useState(null),[P,Q]=z.useState(!0),[oe,J]=z.useState(null),[ee,N]=z.useState([]),[Y,$]=z.useState([]),[ye,T]=z.useState(0),_=z.useRef(null),le=z.useRef(null),R=o?.threads??[],pe=z.useMemo(()=>R.find(V=>V.id===E)??null,[R,E]),xe=z.useMemo(()=>pe?.interAgentThreadId?d.find(V=>V.id===pe.interAgentThreadId)??null:null,[d,pe]),ce=z.useMemo(()=>{if(!xe)return null;const V=xe.participants.map(je=>je.id),me=i?.directs.find(je=>V.includes(je.id))?.id??null;return me?u.find(je=>je.id===me)??null:null},[u,i,xe]),Re=pe?.kind==="relay"&&b==="direct"?j:ce?.id??null;z.useEffect(()=>{if(!i)return;const V=qb(i),me=GS(i),je=[...V.map(Je=>`${Je.kind}:${Je.id}`),...me.map(Je=>`${Je.kind}:${Je.id}`),...i.directs.map(Je=>`${Je.kind}:${Je.id}`)],Fe=`${b}:${j}`;je.includes(Fe)||(v("channel"),C("shared"))},[i,j,b]),z.useEffect(()=>{const V=_.current;if(!V)return;const me=120;V.style.height="0px";const je=Math.min(V.scrollHeight,me);V.style.height=`${je}px`,V.style.overflowY=V.scrollHeight>me?"auto":"hidden"},[M]),z.useEffect(()=>{if(e!=="relay"&&e!=="messages"||ye===0)return;const V=_.current;if(!V)return;const me=window.requestAnimationFrame(()=>{V.focus();const je=V.value.length;V.setSelectionRange?.(je,je)});return()=>{window.cancelAnimationFrame(me)}},[e,ye]),z.useEffect(()=>{oe&&(b!=="direct"||j!==oe.authorId)&&J(null)},[oe,j,b]),z.useEffect(()=>{if(!i?.messages.length)return;const V=new Set(i.messages.map(me=>me.clientMessageId).filter(me=>!!me));V.size&&$(me=>me.filter(je=>!V.has(je.clientMessageId)))},[i]);const Te=z.useMemo(()=>qb(i).filter(V=>a||!(V.kind==="channel"&&V.id==="voice")),[i,a]),Ne=i&&b==="direct"?i.directs.find(V=>V.id===j)??null:null,He=i?$S(i,Te,b,j):null,Le=z.useMemo(()=>{const V=i?.messages??[];if(!Y.length)return V;const me=new Set(V.map(Fe=>Fe.clientMessageId).filter(Fe=>!!Fe)),je=Y.filter(Fe=>!me.has(Fe.clientMessageId)).map(Fe=>Fe.message);return je.length?[...V,...je].sort((Fe,Je)=>Fe.createdAt-Je.createdAt||Fe.id.localeCompare(Je.id)):V},[Y,i]),Ue=z.useMemo(()=>YS(Le,b,j),[Le,j,b]),it=z.useMemo(()=>new Map(Le.map(V=>[V.id,V])),[Le]),tt=z.useMemo(()=>ee.map(V=>it.get(V)).filter(V=>!!V).map(V=>({messageId:V.id,authorName:V.authorName,preview:zu(V.body,96)})),[ee,it]),st=Ip(He?.title??"# shared-channel"),ot=Ne?pv(Ne):He?.subtitle??null,bt=He&&"count"in He&&He.count>0?He.count:null,Ye=Ue.at(-1)??null,Ge=z.useMemo(()=>u.flatMap(V=>{const me=V.selector??V.defaultSelector;return me?[{agentId:V.id,title:V.title,subtitle:V.projectRoot??V.cwd??V.subtitle??null,mentionToken:me,definitionId:V.definitionId,workspaceQualifier:V.workspaceQualifier,branch:V.branch,harness:V.harness,state:V.state,statusLabel:V.statusLabel,searchText:[V.title,V.id,V.definitionId??"",me,V.selector??"",V.defaultSelector??"",V.workspaceQualifier??"",V.branch??"",V.harness??"",V.projectRoot??"",V.cwd??""].join(" ").toLowerCase()}]:[]}).sort((V,me)=>V.title.localeCompare(me.title)),[u]);z.useEffect(()=>{Q(!0);const V=le.current;V&&window.requestAnimationFrame(()=>{V.scrollTo({top:V.scrollHeight,behavior:"auto"})})},[j,b]),z.useEffect(()=>{if(!P)return;const V=le.current;V&&window.requestAnimationFrame(()=>{V.scrollTo({top:V.scrollHeight,behavior:"smooth"})})},[Ye?.body,Ye?.id,Ye?.receipt?.state,Ne?.activeTask,Ne?.state,P]);const We=z.useCallback(V=>{const me=V.currentTarget,je=me.scrollHeight-me.scrollTop-me.clientHeight;Q(je<=48)},[]),we=z.useMemo(()=>WS(M,q),[M,q]),et=z.useMemo(()=>{if(!we)return[];const V=b==="direct"?j:null;return Ge.map(me=>({candidate:me,score:JS(me,we.query,V)})).filter(({score:me})=>me>0).sort((me,je)=>je.score-me.score||me.candidate.title.localeCompare(je.candidate.title)).slice(0,8).map(({candidate:me})=>me)},[we,Ge,j,b]),Se=z.useMemo(()=>Ge.reduce((V,me)=>(V.set(me.title,(V.get(me.title)??0)+1),V),new Map),[Ge]),Ze=et.length>0;z.useEffect(()=>{if(!Ze){F(0);return}F(V=>Math.min(V,et.length-1))},[Ze,et.length]);const mt=z.useMemo(()=>{if(!xe)return[];const V=new Set(xe.messageIds);return Le.filter(me=>V.has(me.id))},[Le,xe]),ae=Re?u.find(V=>V.id===Re)??null:null,ge=z.useMemo(()=>{if(ae)return f.filter(V=>V.project===ae.id||V.agent===ae.title);if(xe){const V=new Set(xe.participants.map(je=>je.id)),me=new Set(xe.participants.map(je=>je.title));return f.filter(je=>V.has(je.project)||me.has(je.agent))}return pe?.relayDestinationKind==="channel"&&pe.relayDestinationId?f.filter(V=>V.tags?.includes(pe.relayDestinationId??"")??!1):f.slice(0,8)},[ae,xe,pe,f]),Ce=z.useCallback((V,me)=>{v(V),C(me),w(o?.threads.find(je=>je.relayDestinationKind===V&&je.relayDestinationId===me)?.id??null),h("messages")},[o,h]),_e=z.useCallback(V=>{if(!we)return;const me=M.slice(we.end),je=me.startsWith(" ")||me.length===0?"":" ",Fe=`${M.slice(0,we.start)}${V.mentionToken}${je}${me}`,Je=we.start+V.mentionToken.length+je.length;D(Fe),L(Je),F(0),window.requestAnimationFrame(()=>{const qe=_.current;qe&&(qe.focus(),qe.setSelectionRange(Je,Je))})},[we,M]),Xe=z.useCallback(async()=>{const V=M.trim();if(!V||H||!r?.sendRelayMessage)return;const me=M,je=oe,Fe=ee,Je=RM(),qe=oe?.messageId??ee[0]??null,St=AM({relayState:i,appSettings:p,destinationKind:b,destinationId:j,body:V,replyToMessageId:qe,clientMessageId:Je});X(!0),O("Sending…"),$(Yt=>[...Yt,{clientMessageId:Je,message:St}]),D(""),J(null),N([]);try{const Yt=await r.sendRelayMessage({destinationKind:b,destinationId:j,body:V,replyToMessageId:qe,referenceMessageIds:ee,clientMessageId:Je});y(Yt),$(Vt=>Vt.map(Pt=>Pt.clientMessageId===Je?{...Pt,message:{...Pt.message,receipt:Pt.message.receipt?{...Pt.message.receipt,label:"Sent",detail:null}:{state:"sent",label:"Sent",detail:null}}}:Pt)),O("Sent.")}catch(Yt){$(Vt=>Vt.filter(Pt=>Pt.clientMessageId!==Je)),D(me),J(je),N(Fe),O(lt(Yt))}finally{X(!1)}},[p,M,H,ee,i,oe,r,j,b,y]),Ae=z.useCallback((V,me)=>{Ce("direct",V),N([]),J(me?.replyToMessage?{messageId:me.replyToMessage.id,authorId:me.replyToMessage.authorId,authorName:me.replyToMessage.authorName,preview:zu(me.replyToMessage.body,96)}:null),typeof me?.draft=="string"&&D(me.draft),me?.focusComposer&&T(je=>je+1)},[Ce]),ue=z.useCallback(V=>{V.isOperator||(Ae(V.authorId,{replyToMessage:V,draft:"Following up on this.",focusComposer:!0}),O(`Drafting a follow-up to ${V.authorName}.`))},[Ae]),Ee=z.useCallback((V,me)=>{Ae(V,{draft:me??null,focusComposer:!0})},[Ae]);return{selectedConversationKind:b,setSelectedConversationKind:v,selectedConversationId:j,setSelectedConversationId:C,selectedMessageThreadId:E,setSelectedMessageThreadId:w,selectedMessagesThread:pe,selectedMessagesInternalThread:xe,selectedMessagesInternalTarget:ce,selectedMessagesDetailAgentId:Re,selectedMessagesDetailAgent:ae,selectedMessagesInternalMessages:mt,selectedMessagesSessions:ge,composerDraft:M,setComposerDraft:D,composerSending:H,composerSelectionStart:q,setComposerSelectionStart:L,mentionSelectionIndex:B,setMentionSelectionIndex:F,messagesFeedback:Z,setMessagesFeedback:O,replyTarget:oe,setReplyTarget:J,contextMessageIds:ee,setContextMessageIds:N,composerRef:_,timelineViewportRef:le,mergedConversationMessages:Le,visibleConversationMessages:Ue,currentConversationTitle:st,currentConversationSubtitle:ot,currentConversationCount:bt,selectedDirectConversation:Ne,contextReferences:tt,mentionMenuOpen:Ze,mentionSuggestions:et,mentionDuplicateTitleCounts:Se,handleConversationTimelineScroll:We,openConversation:Ce,applyMentionSuggestion:_e,sendMessage:Xe,openDirectConversation:Ae,nudgeMessage:ue,openAgentDirectMessage:Ee,messageThreads:R}}const hz=["profile","knowledge","agents","workspaces","communication","database","appearance"];function xz(e){return hz.includes(e)}function gz(e,r){const a=r?.agentId?.trim();return e==="agents"&&a?`/settings/agents/${encodeURIComponent(a)}`:`/settings/${e}`}function bz(e){if(e==="/settings"||e==="/settings/")return{section:"profile",agentId:null};if(!e.startsWith("/settings/"))return null;const r=e.slice(10).split("/").filter(Boolean),a=r[0]??"";if(!a)return{section:"profile",agentId:null};if(!xz(a))return null;if(a!=="agents")return r.length===1?{section:a,agentId:null}:null;if(r.length===1)return{section:"agents",agentId:null};if(r.length===2)try{return{section:"agents",agentId:decodeURIComponent(r[1]??"")||null}}catch{return null}return null}const yz=["overview","inbox","activity","machines","plans","sessions","search","messages","relay","inter-agent","agents","logs","settings","help"];function vz(e){return e!==null&&yz.includes(e)}function kz(e){if(e==="/")return"overview";const r=e.slice(1).split("/")[0]??"";return!r||r==="pairing"||r==="settings"?null:vz(r)?r:null}function jz(e,r,a,i){return e==="pairing"?"/pairing":r==="settings"?gz(a,{agentId:i}):r==="overview"?"/":`/${r}`}const Nz={enableAll:!1,overview:!0,inbox:!0,relay:!0,pairing:!0,interAgent:!0,agents:!0,settings:!0,logs:!0,activity:!1,machines:!1,plans:!1,sessions:!0,search:!0,phonePreparation:!1,telegram:!1,voice:!1,monitor:!1},r1=["claude","codex"],fk="scout.desktop.home-cache.v1";function wz(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(fk);return e?JSON.parse(e):null}catch{return null}}function Sz(e){if(!(typeof window>"u"))try{window.localStorage.setItem(fk,JSON.stringify({...e,savedAt:Date.now()}))}catch{}}function gu(e,r,a){const i={label:e,durationMs:Math.round(performance.now()-r),recordedAt:Date.now(),detail:a};return console.info(`[scout] ${e}`,{durationMs:i.durationMs,...a}),i}function bu(e,r){const a={...e};return r&&(a.Total=`${r.totalMs}ms`,r.steps.forEach(i=>{a[i.label]=`${i.durationMs}ms`})),Object.keys(a).length>0?a:void 0}function yu(e){return{runtime:e.runtime,messages:e.messages,sessions:e.sessions,relay:e.relay,interAgent:e.interAgent,performance:e.performance??null}}function Cz(e,r){return{...r,planCount:e.planCount,workspaceCount:e.workspaceCount,plans:e.plans,subtitle:`${r.taskCount} asks · ${r.findingCount} findings · ${e.planCount} plans · ${e.workspaceCount} workspaces`}}function Tz(){const e=UM(),[r,a]=A.useState(240),[i,o]=A.useState(340),[u,d]=A.useState(!1),[f,p]=A.useState("relay"),[h,y]=A.useState("overview"),[b,v]=A.useState(""),[j,C]=A.useState(null),[E,w]=A.useState(null),[M,D]=A.useState(!0),[H,X]=A.useState("overview"),[q,L]=A.useState(null),[B,F]=A.useState(null),[Z,O]=A.useState(null),[P,Q]=A.useState(null),[oe,J]=A.useState(null),[ee,N]=A.useState({services:null,home:null,workspace:null}),[Y,$]=A.useState(!1),[ye,T]=A.useState(!0),[_,le]=A.useState(!1),[R,pe]=A.useState(!1),[xe,ce]=A.useState(null),[Re,Te]=A.useState(!1),[Ne,He]=A.useState(!1),[Le,Ue]=A.useState("profile"),[it,tt]=A.useState(null),st=A.useRef(null),ot=A.useRef(null),bt=A.useRef(!1),Ye=eN(),Ge=d1();A.useLayoutEffect(()=>{if(!Ge.pathname.startsWith("/settings"))return;const I=bz(Ge.pathname);if(I){p("relay"),y("settings"),Ue(I.section),tt(I.agentId);return}Ye("/settings/profile",{replace:!0})},[Ge.pathname,Ye]),A.useLayoutEffect(()=>{if(Ge.pathname.startsWith("/settings"))return;if(Ge.pathname==="/pairing"){p("pairing"),y(W=>W==="settings"?"overview":W);return}const I=kz(Ge.pathname);if(I){p("relay"),y(I);return}Ye("/",{replace:!0})},[Ge.pathname,Ye]),A.useEffect(()=>{const I=jz(f,h,Le,it);Ge.pathname!==I&&Ye(I,{replace:!0})},[h,Ge.pathname,Ye,f,it,Le]);const We=z.useCallback(()=>{p("relay"),y("help"),Ht(null)},[]),[we,et]=A.useState(!1),[Se,Ze]=A.useState(!1),[mt,ae]=A.useState(!1),ge=A.useRef(null),Ce=A.useRef(null),_e=A.useRef(null),Xe=A.useRef(!1),Ae=A.useRef(!1),ue=A.useRef(!1),Ee=A.useRef(!1),V=f==="relay"&&(h==="messages"||h==="relay"),me=V?P?.sessions??oe?.sessions??[]:oe?.sessions??[],je=oe?.machines??null,Fe=oe?.plans??null,Je=V?P?.messages??oe?.messages??null:oe?.messages??null,qe=V?P?.runtime??oe?.runtime??null:oe?.runtime??null,St=V?P?.relay??oe?.relay??null:oe?.relay??null,Yt=V?P?.interAgent??oe?.interAgent??null:oe?.interAgent??null,Vt=Yt?.agents??[],Pt=Yt?.threads??[],yt=q?.features??oe?.appInfo.features??Nz,Wt=q?.capabilities??oe?.appInfo.capabilities;A.useEffect(()=>{st.current=B},[B]),A.useEffect(()=>{ot.current=Z},[Z]);const se=z.useCallback((I,W)=>{Sz({homeState:I,servicesState:W})},[]),Me=z.useCallback(async()=>{if(!e?.getServicesState||Ae.current)return null;const I=performance.now();$(!0),Ae.current=!0;try{const W=await e.getServicesState();return O(W),se(st.current,W),N(be=>({...be,services:gu("services-state",I,bu({serviceCount:W.services.length},W.performance))})),W}catch(W){return ce(lt(W)),null}finally{Ae.current=!1,$(!1)}},[se,e]),ze=z.useCallback(async(I=!1)=>{if(!e?.getHomeState)return ce("Electron desktop bridge is unavailable."),T(!1),null;if(Xe.current)return null;I&&T(!0);const W=performance.now();Xe.current=!0;try{const be=await e.getHomeState();return F(be),ce(null),se(be,ot.current),N(At=>({...At,home:gu("home-state",W,bu({agents:be.agents.length,activity:be.activity.length},be.performance))})),be}catch(be){return ce(lt(be)),null}finally{Xe.current=!1,T(!1)}},[se,e]),nt=z.useCallback(async(I=!1)=>{if(!e?.getMessagesWorkspaceState)return ce("Electron desktop bridge is unavailable."),le(!1),null;if(ue.current)return null;I&&le(!0),ue.current=!0;const W=performance.now();try{const be=await e.getMessagesWorkspaceState();return Q(be),ce(null),N(At=>({...At,workspace:gu("messages-workspace",W,bu({threads:be.messages.threads.length,messages:be.relay.messages.length,agents:be.interAgent.agents.length,sessions:be.sessions.length},be.performance))})),be}catch(be){return ce(lt(be)),null}finally{ue.current=!1,le(!1)}},[e]),Qt=z.useCallback(async(I=!1)=>{if(!e?.getShellState)return ce("Electron desktop bridge is unavailable."),pe(!1),null;if(Ee.current)return null;I&&pe(!0),Ee.current=!0;const W=performance.now();try{const be=await e.getShellState();return J(be),ce(null),N(At=>({...At,workspace:gu("relay-workspace",W,bu({messages:be.relay.messages.length,agents:be.interAgent.agents.length,sessions:be.sessions.length},be.performance))})),be}catch(be){return ce(lt(be)),null}finally{Ee.current=!1,pe(!1)}},[e]),gn=z.useCallback(I=>{J(W=>W&&{...W,...I,relay:{...I.relay,voice:W.relay.voice},plans:Cz(W.plans,I.plans)}),Q(W=>W&&{...W,...yu(I),relay:{...I.relay,voice:W.relay.voice}})},[]);A.useEffect(()=>{if(!e?.getAppInfo)return;let I=!1;return(async()=>{try{const be=await e.getAppInfo();I||L(be)}catch{I||L(null)}})(),()=>{I=!0}},[e]),A.useEffect(()=>{if(e?.onOpenKnowledgeBase)return e.onOpenKnowledgeBase(We)},[We,e]);const ha=z.useCallback(I=>{const W=I?.runtime?.brokerReachable??Z?.services.find(be=>be.id==="broker")?.reachable??!1;if(p("relay"),W){y("messages"),Jn("channel"),Wl("shared"),kn("Relay is running."),Ht(null);return}y("settings"),Ue("communication"),et(!0),Ht("Relay is not running yet. Finish onboarding by starting the broker from Communication.")},[Z]),Gl=KM({activeView:h,settingsSection:Le,scoutDesktop:e,shellState:oe,surfaceCaps:Wt,completeOnboardingIntoRelay:ha,loadShellState:Qt}),{SOURCE_ROOT_PATH_SUGGESTIONS:xa,appSettings:bn,setAppSettings:Wa,appSettingsLoading:ga,workspaceInventoryLoading:Un,appSettingsSaving:$t,appSettingsFeedback:dn,setAppSettingsFeedback:Ht,setAppSettingsDraft:$l,isAppSettingsEditing:Ml,onboardingWizardStep:Yl,setOnboardingWizardStep:ns,onboardingCommandPending:Wn,onboardingCommandResult:zl,onboardingCommandHistory:dl,onboardingCopiedCommand:Ol,startupOnboardingState:Sr,setIsAppSettingsEditing:Ll,visibleAppSettings:Ft,agentableProjects:ba,appSettingsDirty:ya,projectRetirementPendingRoot:Dl,workspaceInventoryLoaded:Ql,canRefreshWorkspaceInventory:Lo,showDoctorOutput:ls,onboardingContextRoot:Ja,onboardingHasProjectConfig:rs,onboardingRuntimeMatch:Xl,onboardingWizardSteps:_l,onboardingWizardIndex:Hn,activeOnboardingStep:Xt,canGoToPreviousOnboardingStep:ei,canGoToNextOnboardingStep:ve,startupOnboardingVisible:Ke,startupOnboardingBlocking:zt,buildOnboardingCommandLine:yn,applyNextAppSettings:ti,applyRestartedOnboardingSettings:vn,refreshVisibleAppSettings:Cr,handleStartAppSettingsEdit:_n,handleCancelAppSettingsEdit:Tr,updateAppSettingsDraft:va,handleSaveAppSettings:Zu,moveOnboardingWizard:Do,handleRunOnboardingCommand:Kl,handleRestoreProject:ih,handleRestartOnboarding:Wu,handleAddSourceRootSuggestion:_o,handleSetSourceRootAt:as,handleAddSourceRootRow:Ju,handleRemoveSourceRootRow:ed,handleBrowseForSourceRoot:ni,handleSetOnboardingContextRoot:Nl,handleBrowseForOnboardingContextRoot:is,dismissStartupOnboarding:ss,handleOnboardingContinue:Ar,skipCurrentOnboardingStep:Er,handleCopyOnboardingCommand:Bo,handleLoadWorkspaceInventory:Io}=Gl,os=pz({activeView:h,scoutDesktop:e,voiceEnabled:yt.voice,relayState:St,messagesState:Je,interAgentAgents:Vt,interAgentThreads:Pt,sessions:me,appSettings:bn,setActiveView:y,applyRelayWorkspacePatch:gn}),{selectedConversationKind:Zl,setSelectedConversationKind:Jn,selectedConversationId:ka,setSelectedConversationId:Wl,selectedMessageThreadId:En,setSelectedMessageThreadId:Jl,selectedMessagesThread:li,selectedMessagesDetailAgentId:Po,messagesFeedback:cs,setMessagesFeedback:kn,mergedConversationMessages:ja,openConversation:jn,openDirectConversation:er}=os,{pairingState:Rr,pairingLoading:Mr,pairingError:Uo,setPairingError:us,pairingControlPending:ds,pairingConfigPending:Na,pairingApprovalPendingId:ri,pairingConfigFeedback:Ho,setPairingConfigFeedback:td,pendingApprovals:ai,commitPairingState:nd,refreshPairingState:fs,handlePairingControl:ld,handleUpdatePairingConfig:rd,handleDecidePairingApproval:ms}=GM({pairingEnabled:yt.pairing,scoutDesktop:e,setRelayFeedback:kn}),ad=DS(Rr,Mr,Uo),id=$M({activeView:h,scoutDesktop:e,sessions:me}),ii=VM({activeView:h,settingsSection:Le,scoutDesktop:e,surfaceCaps:Wt,pendingBrokerInspectorFocus:we,setPendingBrokerInspectorFocus:et,relayServiceInspectorRef:_e,loadShellState:Qt,setShellState:J,setShellError:ce,applyRestartedOnboardingSettings:vn,commitPairingState:nd,pairingState:Rr,setAppSettingsFeedback:Ht,setRelayFeedback:kn,setPairingError:us,setPairingConfigFeedback:td}),{isFeedbackDialogOpen:sd,feedbackBundle:od,feedbackBundleLoading:cd,feedbackBundleError:ud,feedbackDraft:ps,setFeedbackDraft:dd,feedbackSubmission:fd,feedbackActionPending:md,feedbackActionMessage:Fo,refreshLogs:pd,refreshBrokerInspector:hd,openFeedbackDialog:qo,handleFeedbackDialogOpenChange:xd,handleRefreshFeedbackBundle:gd,handleCopyFeedbackBundle:bd,handleSubmitFeedbackReport:yd,handleRepairSetup:vd}=ii,hs=FM({activeView:h,scoutDesktop:e,surfaceCaps:Wt,interAgentState:Yt,interAgentAgents:Vt,interAgentThreads:Pt,relayState:St,selectedMessagesThread:li,selectedMessagesDetailAgentId:Po,selectedRelayKind:Zl,selectedRelayId:ka,agentableProjects:ba,visibleAppSettings:Ft,isAppSettingsEditing:Ml,appSettingsDirty:ya,setAppSettings:Wa,setAppSettingsDraft:$l,setActiveView:y,setSettingsSection:Ue,setSettingsAgentId:tt,setShellState:J,setShellError:ce,setRelayFeedback:kn}),{selectedInterAgentId:pn,selectedInterAgentThreadId:zr,setSelectedInterAgentThreadId:xs,selectedInterAgent:Fn,visibleInterAgentThreads:gs,selectedInterAgentThread:el,handleSelectInterAgent:tr,deactivateAgentConfigEdit:wa,isCreateAgentDialogOpen:Or,setIsCreateAgentDialogOpen:kd,createAgentDraft:jd,setCreateAgentDraft:Nd,createAgentDefaults:Vo,createAgentSubmitting:Go,createAgentFeedback:Sa,setCreateAgentFeedback:Ca,handleOpenCreateAgentDialog:sh,handleBrowseCreateAgentProject:si,handleCreateAgent:$o,visibleAgentSession:Yo,agentSessionPending:bs,agentSessionLoading:ys,agentSessionFeedback:Qo,agentSessionCopied:Xo,isAgentSessionPeekOpen:Ko,closeAgentSessionPeek:wd,agentSessionPeekViewportRef:Sd,handlePeekAgentSessionScroll:Cd,handleOpenAgentSession:Td,handleCopyAgentSessionCommand:Ad,handlePeekAgentSession:qn,refreshAgentSession:Ta}=hs;A.useEffect(()=>{if(!(h!=="settings"||Le!=="agents")){if(!it){wa();return}pn!==it&&tr(it)}},[h,wa,tr,pn,it,Le]);const Bl=f==="relay"&&(h==="inbox"||h==="activity"||h==="machines"||h==="plans"||h==="sessions"||h==="search"||h==="inter-agent"||h==="agents"||h==="logs"||h==="settings"&&(Le==="agents"||Le==="communication"||Le==="database")),Zo=f==="relay"&&(h==="inbox"||h==="activity"||h==="messages"||h==="relay"||h==="agents"||h==="inter-agent"||h==="sessions"||h==="search");A.useEffect(()=>{if(bt.current||!e)return;bt.current=!0;const I=wz();I?.servicesState&&O(I.servicesState),I?.homeState&&(F(I.homeState),T(!1)),Me(),ze(!I?.homeState)},[ze,Me,e]),A.useEffect(()=>{if(!(zt||!V||P)){if(oe){Q(yu(oe));return}nt(!0)}},[nt,V,P,oe,zt]),A.useEffect(()=>{zt||!Bl||oe||Qt(!0)},[Qt,Bl,oe,zt]),A.useEffect(()=>{const I=Je?.threads??[];if(I.length===0){En!==null&&Jl(null);return}if(En&&I.some(be=>be.id===En))return;const W=I.find(be=>be.relayDestinationKind===Zl&&be.relayDestinationId===ka)??I.find(be=>be.interAgentThreadId===zr)??I[0];W&&W.id!==En&&Jl(W.id)},[Je,ka,Zl,zr,En,Jl]),A.useEffect(()=>{En&&(D(!0),X("overview"))},[En]),A.useEffect(()=>{if(h!=="settings"||!Ml)return;const I=Ce.current;if(!I)return;const W=window.requestAnimationFrame(()=>{I.focus(),I.select()});return()=>{window.cancelAnimationFrame(W)}},[h,Ml]);const vs=A.useMemo(()=>{const I=new Map;return me.forEach(W=>{const be=I.get(W.project);!be||new Date(W.lastModified)>new Date(be.lastModified)?I.set(W.project,{count:(be?.count||0)+1,lastModified:W.lastModified}):be&&I.set(W.project,{...be,count:be.count+1})}),Array.from(I.entries()).map(([W,be])=>({name:W,...be}))},[me]),Wo=A.useMemo(()=>{let I=me;if(j&&(I=I.filter(W=>W.project===j)),b){const W=b.toLowerCase();I=I.filter(be=>be.title.toLowerCase().includes(W)||be.preview.toLowerCase().includes(W)||be.tags?.some(At=>At.toLowerCase().includes(W))||be.agent.toLowerCase().includes(W)||be.project.toLowerCase().includes(W))}return I.sort((W,be)=>new Date(be.lastModified).getTime()-new Date(W.lastModified).getTime())},[me,b,j]),oi=A.useMemo(()=>({totalSessions:me.length,totalMessages:me.reduce((I,W)=>I+W.messageCount,0),totalTokens:me.reduce((I,W)=>I+(W.tokens||0),0),projects:vs.length}),[me,vs]),Ed=A.useMemo(()=>Array.from(new Set(me.map(I=>I.agent))).sort(),[me]),Lr=A.useMemo(()=>new Map(Vt.map(I=>[I.id,I])),[Vt]),ks=A.useMemo(()=>new Map((St?.directs??[]).map(I=>[I.id,I])),[St]),Aa=A.useMemo(()=>{if(!St||!el)return[];const I=new Set(el.messageIds);return St.messages.filter(W=>I.has(W.id))},[St,el]),js=A.useMemo(()=>{if(!Fn)return[];const I=new Set(gs.filter(W=>W.sourceKind==="private").flatMap(W=>W.messageIds));return ja.filter(W=>I.has(W.id)||W.authorId===Fn.id).slice(-60)},[ja,Fn,gs]),Jo=A.useMemo(()=>Fe?.tasks.filter(I=>I.targetAgentId===pn)??[],[Fe,pn]),wl=A.useMemo(()=>Fe?.findings.filter(I=>I.targetAgentId===pn||I.requesterId===pn)??[],[Fe,pn]),Dr=A.useMemo(()=>wl.filter(I=>I.requesterId===pn),[wl,pn]),Ns=el?ep(el,pn):Fn?`${Fn.title}'s agent threads`:"Inter-Agent",ec=el?tp(el,pn):Fn?.statusDetail??"Select an agent to inspect private threads between agents.",fl=A.useMemo(()=>{if(el){const I=Bp(el,pn);if(I.length===1)return Vt.find(W=>W.id===I[0]?.id)??Fn}return Fn},[el,pn,Vt,Fn]),tc=fl?fl.profileKind==="project"?"Configure":"Profile":null,nc=fl??Fn,Ea=z.useCallback((I,W)=>{if(!I)return null;const be=W?.compact?Ka(I)??I:I;return be.includes("/")||be.startsWith("~/")||be.startsWith(".openscout")?l.jsx("button",{type:"button",className:W?.className??"text-left underline underline-offset-2 decoration-dotted hover:opacity-80 transition-opacity",style:W?.style??{color:g.ink},onClick:xi=>{xi.preventDefault(),!(!Wt?.canRevealPath||!e?.revealPath)&&e.revealPath(I).catch(sc=>{Ht(lt(sc))})},title:"Open in Finder",children:be}):l.jsx(l.Fragment,{children:be})},[e,Wt]),Rd=A.useMemo(()=>[...me].sort((I,W)=>new Date(W.lastModified).getTime()-new Date(I.lastModified).getTime()).slice(0,5),[me]);A.useEffect(()=>{qe&&O(I=>{if(!I)return I;const W={...I,updatedAtLabel:qe.updatedAtLabel??I.updatedAtLabel,services:I.services.map(be=>be.id==="broker"?{...be,status:qe.brokerReachable?qe.brokerHealthy?"running":"degraded":"offline",statusLabel:qe.brokerReachable?qe.brokerHealthy?"Running":"Degraded":"Offline",healthy:qe.brokerHealthy,reachable:qe.brokerReachable,detail:qe.brokerLabel,updatedAtLabel:qe.updatedAtLabel??be.updatedAtLabel,url:qe.brokerUrl,nodeId:qe.nodeId}:be.id==="helper"?{...be,status:qe.helperRunning?"running":"offline",statusLabel:qe.helperRunning?"Running":"Offline",healthy:qe.helperRunning,reachable:qe.helperRunning,detail:qe.helperDetail,updatedAtLabel:qe.updatedAtLabel??be.updatedAtLabel}:be)};return se(B,W),W})},[B,se,qe]),A.useEffect(()=>{if(!St)return;const I={title:"Home",subtitle:`${St.directs.length} agents · ${St.messages.filter(W=>!W.isVoice).length} recent updates`,updatedAtLabel:St.lastUpdatedLabel??qe?.updatedAtLabel??null,agents:St.directs.slice(0,24).map(W=>({id:W.id,title:W.title,role:null,summary:W.preview,projectRoot:null,state:W.state,reachable:W.reachable,statusLabel:W.statusLabel,statusDetail:W.statusDetail,activeTask:W.activeTask,timestampLabel:W.timestampLabel})),activity:St.messages.filter(W=>!W.isVoice).sort((W,be)=>be.createdAt-W.createdAt).slice(0,24).map(W=>({id:W.id,kind:W.isSystem?"system":"message",actorId:W.authorId,actorName:W.authorName,title:W.authorName,detail:W.body,conversationId:W.conversationId,channel:W.normalizedChannel,timestamp:W.createdAt,timestampLabel:W.timestampLabel})),recentSessions:[...me].sort((W,be)=>new Date(be.lastModified).getTime()-new Date(W.lastModified).getTime()).slice(0,6)};F(I),se(I,Z)},[se,St,qe?.updatedAtLabel,Z,me]);const ci=B?.agents??[],Md=B?.activity??[],ui=A.useMemo(()=>[...Fe?.tasks??[]].sort((I,W)=>W.createdAt-I.createdAt).slice(0,18),[Fe]),lc=A.useMemo(()=>[...Fe?.findings??[]].slice(0,10),[Fe]),ws=A.useMemo(()=>(je?.machines??[]).flatMap(I=>I.endpoints.map(W=>({machineId:I.id,machineTitle:I.title,machineStatus:I.status,endpoint:W}))).sort((I,W)=>{const be=At=>{switch(At){case"running":return 0;case"waiting":return 1;case"idle":return 2;default:return 3}};return be(I.endpoint.state)-be(W.endpoint.state)||I.endpoint.agentName.localeCompare(W.endpoint.agentName)}).slice(0,14),[je]),tl=A.useMemo(()=>[...ja].filter(I=>!I.isVoice).slice(-18).reverse(),[ja]),Ra=A.useMemo(()=>(Fe?.tasks??[]).filter(I=>I.status==="failed").length,[Fe]),Rn=ai.length+Ra,_r=ui.find(I=>I.status==="running")??ui[0]??null,Mn=Z?.services.find(I=>I.id==="broker")??null,di=ci.filter(I=>I.reachable).length,fi=ci.length>0?ci.length:qe?.agentCount??0,ml=!zt&&ye&&!Z&&!B&&!xe,nr=ml?"Syncing…":Mn?.statusLabel??(qe?.brokerReachable?"Running":"Offline"),rc=ml?"Checking relay health.":Mn?.detail?`Relay diagnostics · ${Mn.detail}`:Mn?.reachable||qe?.brokerReachable?"Open Relay diagnostics":"Relay is offline. Open diagnostics.",mi=ml?"bg-sky-500 animate-pulse":Mn?.status==="running"||qe?.brokerReachable?"bg-emerald-500":Mn?.status==="degraded"?"bg-amber-500":"bg-slate-400",Br=ml?"Syncing":Mn?.healthy||qe?.brokerHealthy?"Healthy":Mn?.reachable||qe?.brokerReachable?"Reachable":"Offline",Ss=A.useMemo(()=>xe||St?.voice.captureState==="error"?"error":ml?null:Mn&&(!Mn.reachable||!Mn.healthy)||qe&&(!qe.brokerReachable||!qe.brokerHealthy)?"warning":null,[Mn,ml,St?.voice.captureState,qe,xe]),Bn=Ss==="error"?"Logs · attention required":Ss==="warning"?"Logs · check runtime warnings":"Logs",Cs=KS(new Date),Jt=[];yt.overview&&Jt.push({id:"overview",icon:l.jsx(Cp,{size:16,strokeWidth:1.5}),title:"Overview"}),yt.inbox&&Jt.push({id:"inbox",icon:l.jsx(kN,{size:16,strokeWidth:1.5}),title:"Inbox",badgeCount:Rn>0?Rn:void 0}),yt.relay&&Jt.push({id:"messages",icon:l.jsx(Al,{size:16,strokeWidth:1.5}),title:"Messages"}),yt.activity&&Jt.push({id:"activity",icon:l.jsx(Km,{size:16,strokeWidth:1.5}),title:"Activity Monitor"}),yt.machines&&Jt.push({id:"machines",icon:l.jsx(S1,{size:16,strokeWidth:1.5}),title:"Machines"}),yt.plans&&Jt.push({id:"plans",icon:l.jsx(Sp,{size:16,strokeWidth:1.5}),title:"Plans"}),yt.search&&Jt.push({id:"search",icon:l.jsx(wo,{size:16,strokeWidth:1.5}),title:"Search"});const Ts=new Set(Jt.map(I=>I.id).filter(I=>I!=="overview"));yt.logs&&Ts.add("logs");const pl=[{id:"profile",label:"General",description:"Local Scout defaults, CLI setup commands, and workspace scanning roots.",icon:l.jsx(da,{size:15})},{id:"agents",label:"Agents",description:"Select an agent, then edit its runtime, capabilities, and restart controls.",icon:l.jsx($i,{size:15})},{id:"workspaces",label:"Workspaces",description:"Workspace discovery, repo bindings, and harness readiness.",icon:l.jsx(da,{size:15})},{id:"communication",label:"Communication",description:"Broker, relay delivery, and live runtime status.",icon:l.jsx(Km,{size:15})}];yt.sessions&&pl.push({id:"database",label:"Database",description:"Session indexing and storage.",icon:l.jsx(IN,{size:15})}),yt.enableAll&&pl.push({id:"appearance",label:"Appearance",description:"Visual preferences and display options.",icon:l.jsx(h2,{size:15})});const lr=pl.find(I=>I.id===Le)??pl[0];A.useEffect(()=>{if(f!=="relay")return;new Set([...Jt.map(W=>W.id),...yt.relay?["relay","inter-agent","agents"]:[],...yt.sessions?["sessions"]:[],...yt.settings?["settings"]:[],...yt.logs?["logs"]:[]]).has(h)||y(yt.relay?"messages":"overview")},[h,yt.logs,yt.relay,yt.sessions,yt.settings,Jt,f]),A.useEffect(()=>{pl.some(I=>I.id===Le)||Ue("profile")},[Le,pl]);const Ir=z.useCallback((I,W)=>{I.preventDefault(),ge.current=W,document.addEventListener("mousemove",Pr),document.addEventListener("mouseup",Nn)},[]),ac=z.useCallback(I=>{Ir(I,"left-sidebar")},[Ir]),As=z.useCallback(I=>{Ir(I,"right-sidebar")},[Ir]),Pr=z.useCallback(I=>{if(ge.current==="left-sidebar"){const W=I.clientX-48;W>160&&W<400&&a(W);return}if(ge.current==="right-sidebar"){const W=window.innerWidth-I.clientX;W>280&&W<520&&o(W)}},[]),Nn=z.useCallback(()=>{ge.current=null,document.removeEventListener("mousemove",Pr),document.removeEventListener("mouseup",Nn)},[Pr]);A.useEffect(()=>()=>{document.removeEventListener("mousemove",Pr),document.removeEventListener("mouseup",Nn)},[Pr,Nn]);const rr=async()=>{Te(!0),kn("Refreshing…");try{if(f==="pairing"&&yt.pairing&&(e?.refreshPairingState||e?.getPairingState)){await fs()&&kn("Pairing refreshed.");return}if(h==="overview")await Promise.all([Me(),ze(!B)]);else if(Zo&&e?.refreshRelayShellPatch){const I=await e.refreshRelayShellPatch();gn(I),ce(null)}else if(V)await nt(!0);else if(Bl&&e?.refreshShellState){const I=await e.refreshShellState();J(I),ce(null)}else Bl&&await Qt(!0);(h==="settings"||h==="help")&&await Cr({preferInventory:h==="settings"&&Le==="workspaces"}),h==="settings"&&Le==="communication"&&await hd(),h==="logs"&&pd(),h==="agents"&&pn&&Ta(),kn("Refreshed.")}catch(I){kn(lt(I))}finally{Te(!1)}},Ur=z.useCallback(()=>{if(!(typeof window>"u")){if(He(!0),e?.reloadApp){e.reloadApp();return}window.location.reload()}},[e]),pi=z.useCallback(()=>{p("relay"),y("settings"),Ue("communication"),et(!0)},[]),Hr=z.useCallback(()=>{(async()=>{try{if(!Wt?.canQuitHost)return;e?.quitApp&&await e.quitApp()}catch(I){Ht(lt(I))}})()},[e,Wt]),wn=z.useCallback(I=>{tr(I),wa(),D(!0),X("overview"),jn("direct",I)},[wa,tr,jn]),Vn=async()=>{if(!e?.toggleVoiceCapture){ce("Electron desktop bridge is unavailable.");return}try{const I=await e.toggleVoiceCapture();J(I),Q(W=>W&&yu(I)),ce(null),kn(I.relay.voice.isCapturing?"Voice capture started.":"Voice capture stopped.")}catch(I){kn(lt(I))}},Sl=async I=>{if(!e?.setVoiceRepliesEnabled){ce("Electron desktop bridge is unavailable.");return}try{const W=await e.setVoiceRepliesEnabled(I);J(W),Q(be=>be&&yu(W)),ce(null),kn(I?"Playback enabled.":"Playback disabled.")}catch(W){kn(lt(W))}},hl=I=>{w(I),D(!0),X("history");const W=Je?.threads.find(be=>be.relayDestinationKind==="direct"&&be.relayDestinationId===I.project)??null;W&&hi(W),C(null),y("messages")},nl=A.useMemo(()=>(Fe?.tasks??[]).filter(I=>I.status==="failed").slice(0,10).map(I=>({id:`task-failed:${I.id}`,kind:"task",tone:"critical",title:I.title,summary:`${I.targetAgentName} reported a failed ask.`,detail:I.statusDetail??I.replyPreview??I.body,meta:[I.project,I.updatedAtLabel,I.ageLabel].filter(Boolean).join(" · ")||I.createdAtLabel,actionLabel:"Open Agent",onAction:()=>wn(I.targetAgentId)})),[wn,Fe]),xl=A.useMemo(()=>ai.map(I=>({id:`approval:${I.sessionId}:${I.turnId}:${I.blockId}`,kind:"approval",tone:I.risk==="high"?"critical":I.risk==="medium"?"warning":"info",title:I.title,summary:I.description,detail:I.detail,meta:`${I.sessionName} · ${I.risk} risk`,actionLabel:"Open Pairing",onAction:()=>{p("pairing")},onSecondaryAction:()=>{ms(I,"approve")},secondaryActionLabel:"Approve"})),[ms,ai]),ic=A.useMemo(()=>[...xl,...nl].sort((I,W)=>{const be=At=>At==="critical"?0:At==="warning"?1:2;return be(I.tone)-be(W.tone)||I.title.localeCompare(W.title)}),[xl,nl]),hi=z.useCallback(I=>{if(Jl(I.id),I.kind==="relay"&&I.relayDestinationKind&&I.relayDestinationId){Jn(I.relayDestinationKind),Wl(I.relayDestinationId);return}if(!I.interAgentThreadId)return;xs(I.interAgentThreadId);const be=(Pt.find(At=>At.id===I.interAgentThreadId)??null)?.participants.find(At=>Vt.some(xi=>xi.id===At.id))?.id??null;be&&(tr(be),xs(I.interAgentThreadId))},[tr,Vt,Pt,Wl,Jn,xs,Jl]),Es=I=>{const W=new Date(I);return`${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][W.getUTCMonth()]} ${W.getUTCDate()}`},vt={root:{backgroundColor:g.bg,color:g.ink},surface:{backgroundColor:g.surface},border:{borderColor:g.border},topBar:{backgroundColor:g.surface,borderBottomColor:g.border},navBar:{backgroundColor:g.bg,borderRightColor:g.border},sidebar:{backgroundColor:g.bg,borderRightColor:g.border},sectionLabel:{color:g.muted},inkText:{color:g.ink},mutedText:{color:g.muted},tagBadge:{backgroundColor:g.tagBg,borderColor:g.border,color:g.muted},activePill:{backgroundColor:g.accentBg,color:g.accent},activeItem:{backgroundColor:g.surface,borderColor:g.border,color:g.ink},kbd:{backgroundColor:g.surface,borderColor:g.border,color:g.ink},hoverBg:"hover:bg-[var(--os-hover)]",annotBadge:{backgroundColor:g.tagBg,borderColor:g.border,color:g.muted}},nn=(I,W,be)=>{const At=dl[I]??(zl?.command===I?zl:null);return l.jsx(WT,{command:I,commandLine:W,running:be,commandResult:At,visibleAppSettings:Ft,onboardingCopiedCommand:Ol,onboardingCommandPending:Wn,onboardingContextRoot:Ja,onCopyOnboardingCommand:Bo,onRunOnboardingCommand:Kl})},_t=QM({activeView:h,setActiveView:y,settingsSection:Le,setSettingsSection:Ue,settingsAgentId:it,setSettingsAgentId:tt,settingsSections:pl,activeSettingsMeta:lr,desktopFeatures:yt,stats:oi,runtime:qe,relayState:St,relayRuntimeBooting:ml,relayRuntimeHealthLabel:Br,reachableRelayAgentCount:di,dark:mt,setDark:ae,showAnnotations:Se,setShowAnnotations:Ze,isCollapsed:u,styles:{surface:vt.surface,inkText:vt.inkText,mutedText:vt.mutedText,tagBadge:vt.tagBadge,activePill:vt.activePill},scoutDesktop:e,surfaceCaps:Wt,interAgentAgents:Vt,openKnowledgeBase:We,openAgentProfile:wn,openDirectConversation:er,renderOnboardingCommandShell:nn,renderLocalPathValue:Ea,settingsOperatorNameRef:Ce,relayServiceInspectorRef:_e,handleSetVoiceRepliesEnabled:Sl,settingsController:Gl,diagnosticsController:ii,agentController:hs}),ft=YM({activeView:h,setActiveView:y,desktopFeatures:yt,styles:{sidebar:vt.sidebar,surface:vt.surface,inkText:vt.inkText,mutedText:vt.mutedText,tagBadge:vt.tagBadge,activePill:vt.activePill,activeItem:vt.activeItem,annotBadge:vt.annotBadge,kbd:vt.kbd},colorTheme:g,sidebarWidth:r,messagesDetailWidth:i,isCollapsed:u,onResizeStart:ac,onMessagesDetailResizeStart:As,stats:oi,runtime:qe,shellState:oe,shellError:xe,plansState:Fe,machinesState:je,messagesState:Je,interAgentState:Yt,interAgentAgents:Vt,interAgentAgentLookup:Lr,relayDirectLookup:ks,homeAgents:ci,homeActivity:Md,activityRecentMessages:tl,activityTasks:ui,activityLeadTask:_r,activityFindings:lc,activityEndpoints:ws,overviewSessions:Rd,inboxAlertCount:Rn,pendingApprovalsCount:ai.length,inboxFailedTaskCount:Ra,inboxAwaitingYouItems:ic,availableAgentNames:Ed,searchQuery:b,setSearchQuery:v,filteredSessions:Wo,selectedSession:E,setSelectedSession:w,isLoadingMessagesWorkspace:_,isLoadingShell:R,showAnnotations:Se,setShowAnnotations:Ze,messagesDetailOpen:M,setMessagesDetailOpen:D,messagesDetailTab:H,setMessagesDetailTab:X,formatDate:Es,onRefreshShell:()=>{rr()},openAgentProfile:wn,openSessionDetail:hl,handleSelectSearchSession:I=>{w(I),y("sessions")},handleToggleVoiceCapture:()=>{Vn()},handleSetVoiceRepliesEnabled:I=>{Sl(I)},selectMessageThread:hi,renderLocalPathValue:Ea,selectedInterAgentActivityMessages:js,selectedInterAgentInboundTasks:Jo,selectedInterAgentOutboundFindings:Dr,selectedInterAgentFindings:wl,interAgentThreadTitle:Ns,selectedInterAgentThreadSubtitle:ec,interAgentConfigureTarget:fl,interAgentConfigureLabel:tc,interAgentMessageTarget:nc,visibleInterAgentMessages:Aa,relayVoiceState:St?.voice,messagesController:os,agentController:hs,diagnosticsController:ii,phonePreparationController:id,overviewBootLoader:!zt&&ye&&!B&&!xe?l.jsx(e1,{dark:mt,C:g,s:vt}):null});return zt?l.jsx("div",{className:`min-h-screen w-full font-sans${mt?" dark":""}`,style:{backgroundColor:g.bg,color:g.ink},children:l.jsxs("div",{className:"relative min-h-screen flex items-center justify-center px-6 py-10",children:[l.jsx("div",{className:"absolute top-6 left-6 z-10",children:l.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 rounded-full border px-3 py-1.5 text-[12px] transition-opacity hover:opacity-80",style:{borderColor:g.border,color:g.muted},onClick:Hr,children:[l.jsx(kl,{size:12}),"Quit"]})}),Ke&&Ft?l.jsx("div",{className:"w-full max-w-[820px] os-scale-in",children:l.jsxs("div",{className:"rounded-2xl border overflow-hidden",style:{borderColor:g.border,backgroundColor:g.surface,boxShadow:`0 24px 80px ${mt?"rgba(0,0,0,0.4)":"rgba(15,23,42,0.08)"}`},children:[l.jsxs("div",{className:"px-8 pt-8 pb-6 border-b cursor-grab active:cursor-grabbing",style:{borderBottomColor:g.border,WebkitAppRegion:"drag"},children:[l.jsxs("div",{className:"flex items-center justify-between gap-4",children:[l.jsx("div",{className:"text-[11px] font-mono uppercase tracking-[0.22em]",style:vt.mutedText,children:"Scout Setup"}),l.jsx("button",{className:"text-[12px] transition-opacity hover:opacity-70",style:{...vt.mutedText,WebkitAppRegion:"no-drag"},onClick:ss,children:"Skip onboarding"})]}),l.jsx("div",{className:"flex items-center gap-1.5 mt-6",children:_l.map((I,W)=>{const be=W<Hn,At=W===Hn;return l.jsx("div",{className:"h-1 flex-1 rounded-full transition-all duration-300",style:{backgroundColor:be||At?g.accent:mt?"rgba(255,255,255,0.06)":"rgba(15,23,42,0.06)",opacity:At?.6:1}},I.id)})}),l.jsxs("div",{className:"flex items-center gap-2 mt-4",children:[l.jsxs("span",{className:"text-[10px] font-mono px-2 py-0.5 rounded-full",style:{backgroundColor:g.accentBg,color:g.accent},children:[Xt.number,"/",_l.length]}),l.jsx("span",{className:"text-[12px] font-medium",style:vt.mutedText,children:Xt.title})]})]}),l.jsxs("div",{className:"px-8 py-8 os-fade-up",children:[l.jsx(JT,{activeOnboardingStep:Xt,visibleAppSettings:Ft,appSettingsSaving:$t,appSettingsLoading:ga,appSettingsDirty:ya,onboardingCommandPending:Wn,onboardingHasProjectConfig:rs,sourceRootPathSuggestions:xa,settingsOperatorNameRef:Ce,setAppSettingsDraft:$l,setAppSettingsFeedback:Ht,setIsAppSettingsEditing:Ll,handleAddSourceRootRow:Ju,handleSetSourceRootAt:as,handleBrowseForSourceRoot:ni,handleRemoveSourceRootRow:ed,handleSetOnboardingContextRoot:Nl,handleBrowseForOnboardingContextRoot:is,handleAddSourceRootSuggestion:_o,handleRunOnboardingCommand:Kl,buildOnboardingCommandLine:yn,renderOnboardingCommandShell:nn,renderLocalPathValue:Ea,styles:{inkText:vt.inkText,mutedText:vt.mutedText,activePill:vt.activePill,tagBadge:vt.tagBadge},availableHarnesses:r1}),dn?l.jsx("div",{className:"text-[13px] mt-6 leading-[1.6] os-fade-in",style:vt.inkText,children:dn}):null]},Xt.id),l.jsxs("div",{className:"px-8 py-5 border-t flex items-center justify-between gap-4",style:{borderTopColor:g.border,backgroundColor:g.bg},children:[l.jsx("button",{className:"os-btn flex items-center gap-1 text-[12px] font-medium px-4 py-2.5 rounded-lg border disabled:opacity-40 transition-all",style:{color:g.muted,borderColor:g.border,backgroundColor:"transparent"},onClick:()=>Do(-1),disabled:!ei,children:"Back"}),l.jsxs("div",{className:"text-[11px] font-mono text-center",style:vt.mutedText,children:[Xt.number," of ",_l.length]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("button",{className:"os-btn flex items-center gap-1 text-[12px] font-medium px-4 py-2.5 rounded-lg transition-all",style:{color:g.muted},onClick:Er,children:ve?"Skip step":"Finish later"}),l.jsxs("button",{className:"os-btn-primary flex items-center gap-1 text-[12px] font-semibold px-5 py-2.5 rounded-lg disabled:opacity-40 transition-all",style:{backgroundColor:g.accent,color:"#fff"},onClick:Ar,disabled:!ve||$t||ga,children:[Xt.id==="confirm"?$t?"Confirming…":"Confirm":"Continue",Xt.id==="confirm"?null:l.jsx(ql,{size:12})]})]})]})]})}):l.jsx(e1,{dark:mt,C:g,s:vt})]})}):l.jsxs(l.Fragment,{children:[l.jsx(zT,{dark:mt,setDark:ae,C:g,s:vt,productSurface:f,setProductSurface:p,activeView:h,setActiveView:y,desktopFeatures:yt,pairingSurfaceBadge:ad,openRelayDiagnostics:pi,relayStatusTitle:rc,relayRuntimeBooting:ml,relayStatusDotClassName:mi,relayStatusLabel:nr,runtime:qe,headerAgentCount:fi,appReloadPending:Ne,handleReloadApp:Ur,handleQuitApp:Hr,navViews:Jt,collapsibleViews:Ts,isCollapsed:u,setIsCollapsed:d,pairingSurfaceProps:{pairingControlPending:ds,pairingConfigFeedback:Ho,pairingConfigPending:Na,pairingError:Uo,pairingLoading:Mr,pairingState:Rr,onControlPairing:ld,onDecideApproval:ms,onOpenFullLogs:()=>{p("relay"),y("logs")},onOpenFeedback:qo,pairingApprovalPendingId:ri,onUpdateConfig:rd,onRefresh:()=>{rr()},onRevealPath:I=>{Wt?.canRevealPath&&e?.revealPath?.(I)}},isAgentSessionPeekOpen:Ko,selectedInterAgent:Fn,visibleAgentSession:Yo,agentSessionPending:bs,agentSessionLoading:ys,agentSessionFeedback:Qo,agentSessionCopied:Xo,agentSessionPeekViewportRef:Sd,handlePeekAgentSessionScroll:Cd,closeAgentSessionPeek:wd,handleCopyAgentSessionCommand:()=>{Ad()},handleOpenAgentSession:()=>{Td()},renderLocalPathValue:Ea,isCreateAgentDialogOpen:Or,setIsCreateAgentDialogOpen:kd,agentableProjects:ba,createAgentDraft:jd,setCreateAgentDraft:Nd,createAgentDefaults:Vo,createAgentSubmitting:Go,createAgentFeedback:Sa,setCreateAgentFeedback:Ca,handleBrowseCreateAgentProject:si,handleCreateAgent:$o,availableAgentHarnesses:r1,isFeedbackDialogOpen:sd,handleFeedbackDialogOpenChange:xd,feedbackDraft:ps,setFeedbackDraft:dd,feedbackSubmission:fd,feedbackActionPending:md,feedbackBundleLoading:cd,feedbackBundle:od,feedbackBundleError:ud,feedbackActionMessage:Fo,handleSubmitFeedbackReport:()=>{yd()},handleRefreshFeedbackBundle:()=>{gd()},handleRepairSetup:()=>{vd()},handleCopyFeedbackBundle:()=>{bd()},openFeedbackDialog:qo,openKnowledgeBase:We,logsAttentionLevel:Ss,logsButtonTitle:Bn,footerTimeLabel:Cs,children:f==="relay"?l.jsxs(l.Fragment,{children:[l.jsx(DT,{...ft.overviewInboxActivityViewProps}),l.jsx(qT,{...ft.opsViewsProps}),l.jsx(ZT,{..._t}),l.jsx(MM,{...ft.agentViewsProps}),l.jsx(mz,{...ft.messagesRelayViewProps})]}):null}),l.jsx("div",{className:"pointer-events-none fixed right-4 top-20 z-40",children:l.jsxs("div",{className:"w-[220px] rounded-2xl border px-4 py-3 shadow-[0_18px_48px_rgba(15,23,42,0.12)]",style:{backgroundColor:mt?"rgba(17, 24, 39, 0.9)":"rgba(255,255,255,0.92)",borderColor:g.border,backdropFilter:"blur(10px)"},children:[l.jsxs("div",{className:"flex items-center justify-between gap-3",children:[l.jsx("div",{className:"text-[10px] font-mono uppercase tracking-[0.16em]",style:vt.mutedText,children:"Dev Load Times"}),l.jsx("div",{className:"text-[10px]",style:vt.mutedText,children:"live"})]}),l.jsx("div",{className:"mt-3 space-y-2",children:[{key:"services",title:"Relay health",metric:ee.services,loading:Y,idleLabel:"—",idleDetail:"No measurement yet"},{key:"home",title:"Home data",metric:ee.home,loading:ye,idleLabel:"—",idleDetail:"No measurement yet"},{key:"workspace",title:"Workspace",metric:ee.workspace,loading:V?_:Bl&&R,idleLabel:V||Bl?"—":"deferred",idleDetail:V||Bl?"No measurement yet":"Loads only on workspace-heavy surfaces"}].map(I=>l.jsxs("div",{className:"rounded-xl border px-3 py-2",style:{borderColor:g.border,backgroundColor:mt?"rgba(255,255,255,0.03)":"rgba(15,23,42,0.025)"},children:[l.jsxs("div",{className:"flex items-center justify-between gap-3",children:[l.jsx("div",{className:"text-[11px] font-medium",style:vt.inkText,children:I.title}),l.jsx("div",{className:"text-[11px] font-mono",style:I.loading?{color:g.accent}:vt.inkText,children:I.loading?"loading…":I.metric?`${I.metric.durationMs}ms`:I.idleLabel})]}),l.jsx("div",{className:"mt-1 text-[10px] leading-[1.5]",style:vt.mutedText,children:I.metric?`${I.metric.label} · ${new Date(I.metric.recordedAt).toLocaleTimeString([],{hour:"numeric",minute:"2-digit",second:"2-digit"})}`:I.idleDetail}),I.metric?.detail?l.jsx("div",{className:"mt-2 space-y-1",children:Object.entries(I.metric.detail).slice(0,8).map(([W,be])=>l.jsxs("div",{className:"flex items-center justify-between gap-3 text-[10px]",style:vt.mutedText,children:[l.jsx("span",{className:"truncate",children:W}),l.jsx("span",{className:"font-mono shrink-0",style:vt.inkText,children:String(be)})]},W))}):null]},I.key))})]})})]})}const gp=document.getElementById("root");if(!gp)throw new Error("Root element was not found.");const a1=l.jsx(A.StrictMode,{children:l.jsx(uN,{children:l.jsx(Tz,{})})}),Az=typeof window<"u"&&Object.prototype.hasOwnProperty.call(window,"__INITIAL_STATE__");Az?fb.hydrateRoot(gp,a1):fb.createRoot(gp).render(a1);
|
|
89
|
+
`),sessionPrefix:h.sessionPrefix,telegram:{enabled:h.telegram.enabled,mode:h.telegram.mode,botToken:h.telegram.botToken,secretToken:h.telegram.secretToken,apiBaseUrl:h.telegram.apiBaseUrl,userName:h.telegram.userName,defaultConversationId:h.telegram.defaultConversationId,ownerNodeId:h.telegram.ownerNodeId}});return Ye(se),D("Settings saved."),X(se.onboarding.needed),$(Me=>Me==="active"?se.onboarding.needed?"active":"done":Me),await d(!1),!0}catch(se){return D(lt(se)),!1}finally{w(!1)}},[h,d,Ye,a]),Ce=z.useCallback(se=>{F(Me=>{const ze=xo.indexOf(Me);if(ze<0)return xo[0];const nt=Math.min(xo.length-1,Math.max(0,ze+se));return xo[nt]})},[]),_e=z.useCallback(async se=>{if(!o?.canProvisionRuntime||!a?.runOnboardingCommand)return D(o&&!o.canProvisionRuntime?"Setup and doctor commands must be run from the Scout CLI (`scout setup`, `scout doctor`) on this host.":null),null;O(se),D(null);try{const Me=(h??f)?.workspaceRoots??[],ze=await a.runOnboardingCommand({command:se,contextRoot:(h??f)?.onboardingContextRoot??Me[0],sourceRoots:se==="setup"?Me:void 0});if(Q(ze),J(nt=>({...nt,[se]:ze})),D(ze.exitCode!==0?`${se} exited with status ${ze.exitCode}. Review the output below before continuing.`:null),a.getAppSettings){const nt=(se==="doctor"||se==="setup")&&a.refreshSettingsInventory?await a.refreshSettingsInventory():await a.getAppSettings();Ye(nt),X(nt.onboarding.needed);const Qt=await d(!1);nt.onboarding.needed?se==="runtimes"&&ze.exitCode===0&&!Qt?.runtime?.brokerReachable?(F("doctor"),D("Relay is still offline. Run doctor again and make sure the broker is reachable before onboarding can finish.")):ze.exitCode===0&&setTimeout(()=>{Ce(1)},1800):u(Qt),$(gn=>gn==="active"?nt.onboarding.needed?"active":"done":gn)}return ze}catch(Me){return D(lt(Me)),null}finally{O(null)}},[f,h,u,d,Ce,a,o]),Xe=z.useCallback(async(se,Me)=>{if(!o?.canEditFilesystem)return D("Project retirement is not available in this host. Use the Scout CLI or desktop app."),!1;if(!a?.retireProject)return D("Project retirement is unavailable in this build."),!1;L(se);try{const ze=await a.retireProject(se);return We(ze),await d(!1),D(`Retired ${Me}. It is hidden from discovery until restored.`),!0}catch(ze){return D(lt(ze)),!1}finally{L(null)}},[We,d,a,o]),Ae=z.useCallback(async se=>{if(!o?.canEditFilesystem)return D("Project restore is not available in this host. Use the Scout CLI or desktop app."),!1;if(!a?.restoreProject)return D("Project restore is unavailable in this build."),!1;L(se.root);try{const Me=await a.restoreProject(se.root);return We(Me),await d(!1),D(`Restored ${se.title}. Scout will discover it again.`),!0}catch(Me){return D(lt(Me)),!1}finally{L(null)}},[We,d,a,o]),ue=z.useCallback(()=>{(async()=>{try{if(!a?.restartOnboarding)return;const se=await a.restartOnboarding();we(se),D("Onboarding restarted.")}catch(se){D(lt(se))}})()},[we,a]),Ee=z.useCallback(se=>{y(Me=>{const ze=Me??f;if(!ze)return Me;const nt=Array.from(new Set([...ze.workspaceRoots,se]));return{...ze,onboardingContextRoot:ze.onboardingContextRoot||se,workspaceRoots:nt}}),D("Project paths updated. Save General to persist the change."),X(!0)},[f]),V=z.useCallback(()=>{H||(y(f),D(null),X(!0))},[f,H]),me=z.useCallback((se,Me)=>{y(ze=>{const nt=ze??f;if(!nt)return ze;const Qt=[...nt.workspaceRoots];for(;Qt.length<=se;)Qt.push("");return Qt[se]=Me,{...nt,onboardingContextRoot:se===0&&(!nt.onboardingContextRoot||nt.onboardingContextRoot===nt.workspaceRoots[0])?Me:nt.onboardingContextRoot,workspaceRoots:Qt}}),D(null),X(!0)},[f]),je=z.useCallback(()=>{y(se=>{const Me=se??f;return Me?{...Me,workspaceRoots:[...Me.workspaceRoots,""]}:se}),D("Project paths updated. Save General to persist the change."),X(!0)},[f]),Fe=z.useCallback(se=>{y(Me=>{const ze=Me??f;if(!ze)return Me;const nt=ze.workspaceRoots[se]??"",Qt=ze.workspaceRoots.filter((ha,Gl)=>Gl!==se),gn=se===0&&(!ze.onboardingContextRoot||ze.onboardingContextRoot===nt)?Qt[0]??"":ze.onboardingContextRoot;return{...ze,onboardingContextRoot:gn,workspaceRoots:Qt}}),D("Project paths updated. Save General to persist the change."),X(!0)},[f]),Je=z.useCallback(se=>{(async()=>{try{if(!o?.canPickDirectory||!a?.pickDirectory)return;const Me=await a.pickDirectory();if(!Me)return;me(se,Me),D("Project paths updated. Save General to persist the change.")}catch(Me){D(lt(Me))}})()},[me,a,o]),qe=z.useCallback(se=>{y(Me=>{const ze=Me??f;return ze?{...ze,onboardingContextRoot:se}:Me}),D(null),X(!0)},[f]),St=z.useCallback(()=>{(async()=>{try{if(!o?.canPickDirectory||!a?.pickDirectory)return;const se=await a.pickDirectory();if(!se)return;qe(se)}catch(se){D(lt(se))}})()},[qe,a,o]),Yt=z.useCallback(()=>{(async()=>{try{if(a?.skipOnboarding){const se=await a.skipOnboarding();Ye(se)}$("done"),D(null),X(!1)}catch(se){D(lt(se))}})()},[Ye,a]),Vt=z.useCallback(()=>{(async()=>{if(Ue.id!=="confirm"){Ce(1);return}if(!le){Ce(1);return}await ge()&&Ce(1)})()},[Ue.id,le,ge,Ce]);z.useEffect(()=>{const se=Ue.id;if(se!=="setup"&&se!=="doctor"&&se!=="runtimes"||Z||oe[se]||!ye||b||se==="doctor"&&!Re)return;const Me=setTimeout(()=>{_e(se)},600);return()=>clearTimeout(Me)},[Ue.id,b,_e,oe,Z,Re,ye]);const Pt=z.useCallback(()=>{if(tt){Ce(1);return}Yt()},[tt,Yt,Ce]),yt=z.useCallback(async se=>{const Me=et(se);await navigator.clipboard.writeText(Me),N(se),window.setTimeout(()=>{N(ze=>ze===se?null:ze)},1500)},[et]),Wt=z.useCallback(()=>{a?.refreshSettingsInventory&&(C(!0),a.refreshSettingsInventory().then(se=>{We(se)}).catch(se=>{D(lt(se))}).finally(()=>{C(!1)}))},[We,a]);return{SOURCE_ROOT_PATH_SUGGESTIONS:XM,appSettings:f,setAppSettings:p,appSettingsDraft:h,appSettingsLoading:b,workspaceInventoryLoading:j,appSettingsSaving:E,appSettingsFeedback:M,setAppSettingsFeedback:D,setAppSettingsDraft:y,isAppSettingsEditing:H,onboardingWizardStep:B,setOnboardingWizardStep:F,onboardingCommandPending:Z,onboardingCommandResult:P,onboardingCommandHistory:oe,onboardingCopiedCommand:ee,startupOnboardingState:Y,setStartupOnboardingState:$,setIsAppSettingsEditing:X,setOnboardingCommandResult:Q,setOnboardingCopiedCommand:N,visibleAppSettings:ye,agentableProjects:T,hiddenProjects:_,appSettingsDirty:le,projectRetirementPendingRoot:q,workspaceInventoryLoaded:R,canRefreshWorkspaceInventory:pe,showDoctorOutput:xe,onboardingContextRoot:ce,onboardingHasProjectConfig:Re,onboardingRuntimeMatch:Te,onboardingWizardSteps:He,onboardingWizardIndex:Le,activeOnboardingStep:Ue,canGoToPreviousOnboardingStep:it,canGoToNextOnboardingStep:tt,startupOnboardingVisible:st,startupOnboardingBlocking:ot,buildOnboardingCommandLine:et,replaceAppSettings:Ye,syncRefreshedAppSettings:Ge,applyNextAppSettings:We,applyRestartedOnboardingSettings:we,refreshVisibleAppSettings:Se,handleStartAppSettingsEdit:Ze,handleCancelAppSettingsEdit:mt,updateAppSettingsDraft:ae,handleSaveAppSettings:ge,moveOnboardingWizard:Ce,handleRunOnboardingCommand:_e,handleRetireProject:Xe,handleRestoreProject:Ae,handleRestartOnboarding:ue,handleAddSourceRootSuggestion:Ee,handleBeginGeneralEdit:V,handleSetSourceRootAt:me,handleAddSourceRootRow:je,handleRemoveSourceRootRow:Fe,handleBrowseForSourceRoot:Je,handleSetOnboardingContextRoot:qe,handleBrowseForOnboardingContextRoot:St,dismissStartupOnboarding:Yt,handleOnboardingContinue:Vt,skipCurrentOnboardingStep:Pt,handleCopyOnboardingCommand:yt,handleLoadWorkspaceInventory:Wt}}function ZM({sidebarWidth:e,messagesDetailWidth:r,isCollapsed:a,onResizeStart:i,onMessagesDetailResizeStart:o,styles:u,messagesState:d,messageThreads:f,selectedMessagesThread:p,onSelectMessageThread:h,showAnnotations:y,setShowAnnotations:b,onRefresh:v,loadingWorkspace:j,selectedMessagesInternalThread:C,selectedMessagesInternalMessages:E,selectedMessagesInternalTarget:w,selectedMessagesDetailAgentId:M,selectedMessagesDetailAgent:D,selectedMessagesSessions:H,selectedSession:X,setSelectedSession:q,formatDate:L,interAgentAgents:B,interAgentAgentLookup:F,relayDirectLookup:Z,openAgentProfile:O,openAgentDirectMessage:P,onNudgeMessage:Q,messagesDetailOpen:oe,setMessagesDetailOpen:J,messagesDetailTab:ee,setMessagesDetailTab:N,selectedRelayKind:Y,selectedRelayId:$,relayThreadTitle:ye,relayThreadSubtitle:T,relayThreadCount:_,selectedRelayDirectThread:le,relayVoiceState:R,visibleRelayMessages:pe,relayTimelineViewportRef:xe,onRelayTimelineScroll:ce,relayReplyTarget:Re,setRelayReplyTarget:Te,relayContextReferences:Ne,relayContextMessageIds:He,setRelayContextMessageIds:Le,relayComposerRef:Ue,relayDraft:it,setRelayDraft:tt,relaySending:st,relayFeedback:ot,relayComposerSelectionStart:bt,setRelayComposerSelectionStart:Ye,mergedRelayMessages:Ge,relayMentionMenuOpen:We,relayMentionSuggestions:we,relayMentionSelectionIndex:et,setRelayMentionSelectionIndex:Se,relayMentionDuplicateTitleCounts:Ze,applyRelayMentionSuggestion:mt,onRelaySend:ae,onToggleVoiceCapture:ge,onSetVoiceRepliesEnabled:Ce,visibleAgentSession:_e,agentSessionPending:Xe,agentSessionFeedback:Ae,agentSessionCopied:ue,onCopyAgentSessionCommand:Ee,onOpenAgentSession:V,onPeekAgentSession:me,onOpenAgentSettings:je,desktopVoiceEnabled:Fe}){return l.jsxs(l.Fragment,{children:[a?null:l.jsx(WM,{sidebarWidth:e,styles:u,messagesState:d,messageThreads:f,selectedMessagesThread:p,onResizeStart:i,onSelectMessageThread:h}),l.jsx("div",{className:"flex-1 flex flex-col relative min-w-0",style:u.surface,children:p?.kind==="internal"?l.jsx(JM,{styles:u,selectedMessagesThread:p,selectedMessagesInternalThread:C,selectedMessagesInternalMessages:E,selectedMessagesInternalTarget:w,showAnnotations:y,setShowAnnotations:b,setMessagesDetailOpen:J,messagesDetailOpen:oe,onRefresh:v,interAgentAgentLookup:F,relayDirectLookup:Z,openAgentProfile:O,openAgentDirectMessage:P,onNudgeMessage:Q}):l.jsx(ez,{styles:u,selectedRelayKind:Y,selectedRelayId:$,relayThreadTitle:ye,relayThreadSubtitle:T,relayThreadCount:_,selectedRelayDirectThread:le,relayVoiceState:R,visibleRelayMessages:pe,relayTimelineViewportRef:xe,onRelayTimelineScroll:ce,relayReplyTarget:Re,setRelayReplyTarget:Te,relayContextReferences:Ne,relayContextMessageIds:He,setRelayContextMessageIds:Le,relayComposerRef:Ue,relayDraft:it,setRelayDraft:tt,relaySending:st,relayFeedback:ot,relayComposerSelectionStart:bt,setRelayComposerSelectionStart:Ye,mergedRelayMessages:Ge,relayMentionMenuOpen:We,relayMentionSuggestions:we,relayMentionSelectionIndex:et,setRelayMentionSelectionIndex:Se,relayMentionDuplicateTitleCounts:Ze,applyRelayMentionSuggestion:mt,showAnnotations:y,setShowAnnotations:b,setMessagesDetailOpen:J,messagesDetailOpen:oe,onRefresh:v,loadingWorkspace:j,onRelaySend:ae,onToggleVoiceCapture:ge,onSetVoiceRepliesEnabled:Ce,interAgentAgentLookup:F,relayDirectLookup:Z,openAgentProfile:O,openAgentDirectMessage:P,onNudgeMessage:Q,desktopVoiceEnabled:Fe})}),oe&&p?l.jsx(nz,{styles:u,messagesDetailWidth:r,selectedMessagesThread:p,selectedMessagesInternalThread:C,selectedMessagesDetailAgentId:M,selectedMessagesDetailAgent:D,selectedMessagesSessions:H,selectedSession:X,setSelectedSession:q,formatDate:L,interAgentAgents:B,messagesDetailTab:ee,setMessagesDetailTab:N,setMessagesDetailOpen:J,onResizeStart:o,openAgentProfile:O,openAgentDirectMessage:P,visibleAgentSession:_e,agentSessionPending:Xe,agentSessionFeedback:Ae,agentSessionCopied:ue,onCopyAgentSessionCommand:Ee,onOpenAgentSession:V,onPeekAgentSession:me,onOpenAgentSettings:je}):null]})}function WM({sidebarWidth:e,styles:r,messagesState:a,messageThreads:i,selectedMessagesThread:o,onResizeStart:u,onSelectMessageThread:d}){return l.jsxs("div",{style:{width:e,...r.sidebar},className:"relative flex flex-col h-full border-r shrink-0 z-10 overflow-hidden",children:[l.jsx("div",{className:"absolute right-[-3px] top-0 bottom-0 w-1.5 cursor-col-resize hover:bg-indigo-400 z-20 transition-colors",onMouseDown:u}),l.jsx("div",{className:"px-3 py-2.5 flex items-center justify-between",children:l.jsxs("div",{children:[l.jsx("h1",{className:"text-[13px] font-semibold tracking-tight",style:r.inkText,children:a?.title??"Messages"}),l.jsx("div",{className:"text-[10px] font-mono mt-0.5",style:r.mutedText,children:a?.subtitle??"Broker unavailable"})]})}),l.jsx("div",{className:"flex-1 overflow-y-auto py-2",children:[["inbox","Inbox"],["channels","Channels"],["agents","Agents"],["internal","Internal"]].map(([f,p])=>{const h=i.filter(y=>y.group===f);return h.length===0?null:l.jsxs("div",{className:"mb-3 px-1.5",children:[l.jsx("div",{className:"font-mono text-[9px] tracking-widest uppercase mb-1 px-1.5",style:r.mutedText,children:p}),l.jsx("div",{className:"flex flex-col gap-px",children:h.map(y=>{const b=o?.id===y.id,v=y.kind==="relay"&&y.relayDestinationKind==="direct";return l.jsxs("button",{className:`os-rail-row flex items-center gap-2 px-1.5 py-1 rounded cursor-pointer w-full text-left${b?" os-rail-row-active":""}`,style:b?r.activeItem:r.mutedText,onClick:()=>d(y),children:[y.kind==="internal"?l.jsx("div",{className:"w-4 h-4 shrink-0 flex items-center justify-center",children:l.jsx(Ki,{size:12,style:b?{color:g.accent}:r.mutedText})}):v?l.jsxs("div",{className:"relative shrink-0",children:[l.jsx("div",{className:`os-rail-avatar w-4 h-4 rounded text-white flex items-center justify-center font-bold text-[8px] ${y.reachable?"":"opacity-40 grayscale"}`,style:{backgroundColor:cl(y.relayDestinationId??y.id)},children:y.title.charAt(0).toUpperCase()}),y.state?l.jsx("div",{className:`absolute -bottom-0.5 -right-0.5 w-1.5 h-1.5 rounded-full ${Ro(y.state)}`,style:{border:`1px solid ${g.bg}`}}):null]}):l.jsx(ck,{id:y.relayDestinationId??y.id,active:b}),l.jsxs("div",{className:`flex-1 min-w-0 ${y.reachable?"":"opacity-50"}`,children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("div",{className:"font-medium text-[12px] truncate",children:Ip(y.title)}),y.state==="working"?l.jsx(Ku,{className:"text-[var(--os-accent)]"}):null]}),l.jsx("div",{className:"text-[10px] truncate",style:r.mutedText,children:y.preview??y.subtitle??""})]}),typeof y.count=="number"&&y.count>0?l.jsx("span",{className:"os-row-count text-[9px] font-mono px-1 rounded",style:b?r.activePill:r.tagBadge,children:y.count}):null]},y.id)})})]},f)})})]})}function JM({styles:e,selectedMessagesThread:r,selectedMessagesInternalThread:a,selectedMessagesInternalMessages:i,selectedMessagesInternalTarget:o,showAnnotations:u,setShowAnnotations:d,setMessagesDetailOpen:f,messagesDetailOpen:p,onRefresh:h,interAgentAgentLookup:y,relayDirectLookup:b,openAgentProfile:v,openAgentDirectMessage:j,onNudgeMessage:C}){return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"border-b flex items-center justify-between px-4 py-2 shrink-0 gap-4",style:{...e.surface,borderBottomColor:g.border},children:[l.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[l.jsx(Ki,{size:14,style:e.mutedText}),l.jsxs("div",{className:"min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[l.jsx("h2",{className:"text-[13px] font-semibold tracking-tight truncate",style:e.inkText,children:a?.title??r.title??"Internal"}),a?l.jsx("span",{className:"text-[9px] font-mono px-1.5 py-0.5 rounded shrink-0",style:e.tagBadge,children:a.messageCount}):null]}),l.jsx("div",{className:"text-[10px] truncate mt-0.5",style:e.mutedText,children:a?.subtitle??r.subtitle??"Agent-to-agent coordination"})]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[o?l.jsxs("button",{className:"os-toolbar-button flex items-center gap-1.5 text-[10px] font-medium px-2 py-0.5 rounded",style:{color:g.ink},onClick:()=>j(o.id),children:[l.jsx(Al,{size:11}),l.jsx("span",{children:"Message Agent"})]}):null,l.jsxs("button",{onClick:()=>d(!u),className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded",style:u?{backgroundColor:g.accentBg,color:g.accent}:{color:g.ink},children:["Annotations ",l.jsx("span",{className:"font-mono uppercase",children:u?"On":"Off"})]}),l.jsx("button",{className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded",style:{color:g.ink},onClick:()=>{h()},children:"Sync"}),l.jsx("button",{className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded",style:p?{backgroundColor:g.accentBg,color:g.accent}:{color:g.ink},onClick:()=>f(E=>!E),children:"Details"})]})]}),l.jsx("div",{className:"flex-1 overflow-y-auto px-4 py-3 pb-6",children:i.length===0?l.jsxs("div",{className:"flex flex-col items-center justify-center h-64 text-center",children:[l.jsx("div",{className:"w-16 h-16 rounded-full flex items-center justify-center mb-4",style:{backgroundColor:g.accentBg},children:l.jsx(Ki,{size:24,style:{color:g.accent}})}),l.jsx("h3",{className:"text-[15px] font-medium mb-1",style:e.inkText,children:"No internal traffic yet"}),l.jsx("p",{className:"text-[13px] max-w-sm",style:e.mutedText,children:"This thread exists, but no visible agent-to-agent messages have been captured yet."})]}):l.jsx("div",{className:"flex flex-col gap-1",children:l.jsx(ko,{messages:i,showAnnotations:u,showStatusMessages:!1,inkStyle:e.inkText,mutedStyle:e.mutedText,tagStyle:e.tagBadge,annotStyle:e.annotBadge,agentLookup:y,directThreadLookup:b,onOpenAgentProfile:v,onOpenAgentChat:j,onNudgeMessage:C})})}),l.jsx("div",{className:"px-4 py-3 shrink-0",style:e.surface,children:l.jsxs("div",{className:"rounded-lg border px-3 py-3",style:{borderColor:g.border,backgroundColor:g.bg},children:[l.jsx("div",{className:"text-[9px] font-mono uppercase tracking-widest",style:e.mutedText,children:"Internal Thread"}),l.jsx("div",{className:"text-[11px] mt-1 leading-[1.6]",style:e.mutedText,children:"Internal coordination is read-only here. Open a direct conversation with an agent if you want to intervene."}),o?l.jsxs("button",{type:"button",onClick:()=>j(o.id),className:"mt-3 os-toolbar-button flex items-center gap-1.5 text-[10px] font-medium px-2 py-1 rounded",style:{color:g.ink},children:[l.jsx(Np,{size:11}),"Open Direct Message"]}):null]})}),l.jsx("div",{className:"h-7 border-t flex items-center px-4 shrink-0",style:{backgroundColor:g.bg,borderTopColor:g.border},children:l.jsx("span",{className:"text-[9px] font-mono",style:e.mutedText,children:"Read-only internal coordination thread inside Messages"})})]})}function ez({styles:e,selectedRelayKind:r,selectedRelayId:a,relayThreadTitle:i,relayThreadSubtitle:o,relayThreadCount:u,selectedRelayDirectThread:d,relayVoiceState:f,visibleRelayMessages:p,relayTimelineViewportRef:h,onRelayTimelineScroll:y,relayReplyTarget:b,setRelayReplyTarget:v,relayContextReferences:j,relayContextMessageIds:C,setRelayContextMessageIds:E,relayComposerRef:w,relayDraft:M,setRelayDraft:D,relaySending:H,relayFeedback:X,relayComposerSelectionStart:q,setRelayComposerSelectionStart:L,mergedRelayMessages:B,relayMentionMenuOpen:F,relayMentionSuggestions:Z,relayMentionSelectionIndex:O,setRelayMentionSelectionIndex:P,relayMentionDuplicateTitleCounts:Q,applyRelayMentionSuggestion:oe,showAnnotations:J,setShowAnnotations:ee,setMessagesDetailOpen:N,messagesDetailOpen:Y,onRefresh:$,loadingWorkspace:ye,onRelaySend:T,onToggleVoiceCapture:_,onSetVoiceRepliesEnabled:le,interAgentAgentLookup:R,relayDirectLookup:pe,openAgentProfile:xe,openAgentDirectMessage:ce,onNudgeMessage:Re,desktopVoiceEnabled:Te}){const Ne=p.at(-1)?.createdAt??null,[He,Le]=z.useState(()=>Date.now());z.useEffect(()=>{if(d?.state!=="working")return;Le(Date.now());const Ge=window.setInterval(()=>{Le(Date.now())},15e3);return()=>window.clearInterval(Ge)},[Ne,d?.activeTask,d?.id,d?.state,d?.statusDetail]);const Ue=d?.state==="working"&&Ne?Math.max(0,He-Ne):0,it=Ue>0?lz(Ue):null,tt=Ue>=9e4,st=d?.activeTask??d?.statusDetail??o??"Agent is still working.",ot=!ye&&p.length===0&&r==="direct",bt=ye?"Loading relay workspace":ot?"Waiting for first relay message":"No relay traffic yet",Ye=ye?"Fetching threads, messages, and agent state for this workspace.":ot?d?.activeTask??d?.statusDetail??"This direct lane is open. Send a message or wait for the agent to speak first.":"Send a message into this lane to wake an agent or start a broker-backed conversation.";return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"border-b flex items-center justify-between px-4 py-2 shrink-0 gap-4",style:{...e.surface,borderBottomColor:g.border},children:[l.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[l.jsx("div",{className:"shrink-0",children:r==="direct"?l.jsx(Np,{size:14,style:e.mutedText}):l.jsx(ck,{id:a,active:!1,size:14})}),l.jsxs("div",{className:"min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[l.jsx("h2",{className:"text-[13px] font-semibold tracking-tight truncate",style:e.inkText,children:i}),u?l.jsx("span",{className:"text-[9px] font-mono px-1.5 py-0.5 rounded shrink-0",style:e.tagBadge,children:u}):null,d?l.jsx(wM,{thread:d}):null]}),o?l.jsx("div",{className:"text-[10px] truncate mt-0.5",style:e.mutedText,children:o}):null]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[d?l.jsxs("button",{className:"os-toolbar-button flex items-center gap-1.5 text-[10px] font-medium px-2 py-0.5 rounded",style:{color:g.ink},onClick:()=>xe(d.id),children:[l.jsx($i,{size:11}),l.jsx("span",{children:"Agent"})]}):null,l.jsxs("button",{onClick:()=>ee(!J),className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded",style:J?{backgroundColor:g.accentBg,color:g.accent}:{color:g.ink},children:["Annotations ",l.jsx("span",{className:"font-mono uppercase",children:J?"On":"Off"})]}),Te?l.jsxs(l.Fragment,{children:[l.jsxs("button",{className:"os-toolbar-button flex items-center gap-1.5 text-[10px] font-medium px-2 py-0.5 rounded",style:f?.isCapturing?{backgroundColor:g.accentBg,color:g.accent}:{color:g.ink},onClick:()=>{_()},title:f?.detail??void 0,children:[f?.captureTitle??"Capture"," ",l.jsx("span",{className:"font-mono uppercase",style:{color:g.accent},children:f?.captureState??"Off"})]}),l.jsxs("button",{className:"os-toolbar-button flex items-center gap-1.5 text-[10px] font-medium px-2 py-0.5 rounded",style:f?.repliesEnabled?{backgroundColor:g.accentBg,color:g.accent}:{color:g.ink},onClick:()=>{le(!(f?.repliesEnabled??!1))},title:f?.detail??void 0,children:["Playback ",l.jsx("span",{className:"font-mono uppercase",style:{color:g.accent},children:f?.speaking?"Speaking":f?.repliesEnabled?"On":"Off"})]})]}):null,l.jsx("button",{className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded",style:{color:g.ink},onClick:()=>{$()},children:"Sync"}),l.jsx("button",{className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded",style:Y?{backgroundColor:g.accentBg,color:g.accent}:{color:g.ink},onClick:()=>N(Ge=>!Ge),children:"Details"})]})]}),l.jsx("div",{ref:h,className:"flex-1 overflow-y-auto px-4 py-3 pb-6",onScroll:y,children:p.length===0?l.jsxs("div",{className:"flex flex-col items-center justify-center h-64 text-center",children:[l.jsx("div",{className:"w-16 h-16 rounded-full flex items-center justify-center mb-4",style:{backgroundColor:g.accentBg},children:ye||ot?l.jsx(un,{className:"text-[22px]",style:{color:g.accent}}):l.jsx(Al,{size:24,style:{color:g.accent}})}),l.jsx("h3",{className:"text-[15px] font-medium mb-1",style:e.inkText,children:bt}),l.jsx("p",{className:"text-[13px] max-w-sm",style:e.mutedText,children:Ye})]}):l.jsx("div",{className:"flex flex-col gap-1",children:l.jsx(ko,{messages:p,showAnnotations:J,showStatusMessages:r==="channel"&&a==="system",inkStyle:e.inkText,mutedStyle:e.mutedText,tagStyle:e.tagBadge,annotStyle:e.annotBadge,agentLookup:R,directThreadLookup:pe,onOpenAgentProfile:xe,onOpenAgentChat:ce,onNudgeMessage:Re})})}),d?.state==="working"?l.jsx("div",{className:"px-4 pb-1 shrink-0",style:e.surface,children:l.jsx("div",{className:"rounded-xl border px-3 py-2.5 flex items-start justify-between gap-3",style:{borderColor:tt?"rgba(245,158,11,0.32)":g.border,backgroundColor:tt?"rgba(245,158,11,0.08)":g.bg},children:l.jsxs("div",{className:"min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[l.jsx(Ku,{className:"text-[var(--os-accent)] shrink-0"}),l.jsx("span",{className:"text-[11px] font-medium truncate",style:e.inkText,children:tt?"Still working":"Working"}),it?l.jsx("span",{className:"text-[9px] font-mono px-1.5 py-0.5 rounded shrink-0",style:tt?{color:"#b45309",backgroundColor:"rgba(245,158,11,0.14)"}:e.tagBadge,children:tt?`No update for ${it}`:`${it} ago`}):null]}),l.jsx("div",{className:"text-[10px] mt-1 truncate",style:e.mutedText,children:st})]})})}):null,l.jsx(tz,{styles:e,selectedRelayKind:r,selectedRelayId:a,relayVoiceState:f,relayReplyTarget:b,setRelayReplyTarget:v,relayContextReferences:j,relayContextMessageIds:C,setRelayContextMessageIds:E,relayComposerRef:w,relayDraft:M,setRelayDraft:D,relaySending:H,relayComposerSelectionStart:q,setRelayComposerSelectionStart:L,mergedRelayMessages:B,relayMentionMenuOpen:F,relayMentionSuggestions:Z,relayMentionSelectionIndex:O,setRelayMentionSelectionIndex:P,relayMentionDuplicateTitleCounts:Q,applyRelayMentionSuggestion:oe,onRelaySend:T,desktopVoiceEnabled:Te}),l.jsxs("div",{className:"h-7 border-t flex items-center justify-between px-4 shrink-0",style:{backgroundColor:g.bg,borderTopColor:g.border},children:[l.jsxs("div",{className:"flex items-center gap-3 text-[9px] font-mono",style:e.mutedText,children:[l.jsxs("span",{className:"flex items-center gap-1",children:[l.jsx("span",{style:e.inkText,children:"@"})," mention agents"]}),F?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"w-px h-3",style:{backgroundColor:g.border}}),l.jsx("span",{children:"↑↓ select · ↵ or Tab insert"})]}):null,l.jsx("span",{className:"w-px h-3",style:{backgroundColor:g.border}}),l.jsxs("span",{className:"flex items-center gap-1",children:[l.jsx("kbd",{className:"font-sans px-1 py-0.5 rounded border text-[9px] font-medium leading-none shadow-sm",style:e.kbd,children:"Cmd+Enter"})," send"]}),X?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"w-px h-3",style:{backgroundColor:g.border}}),l.jsx("span",{children:X})]}):null]}),l.jsx("div",{className:"flex items-center gap-2 text-[9px] font-mono uppercase tracking-widest",style:e.mutedText,children:d?.state==="offline"?l.jsx("span",{children:d.statusLabel}):null})]})]})}function tz({styles:e,selectedRelayKind:r,selectedRelayId:a,relayVoiceState:i,relayReplyTarget:o,setRelayReplyTarget:u,relayContextReferences:d,relayContextMessageIds:f,setRelayContextMessageIds:p,relayComposerRef:h,relayDraft:y,setRelayDraft:b,relaySending:v,relayComposerSelectionStart:j,setRelayComposerSelectionStart:C,mergedRelayMessages:E,relayMentionMenuOpen:w,relayMentionSuggestions:M,relayMentionSelectionIndex:D,setRelayMentionSelectionIndex:H,relayMentionDuplicateTitleCounts:X,applyRelayMentionSuggestion:q,onRelaySend:L,desktopVoiceEnabled:B}){return l.jsxs("div",{className:"px-4 py-3 shrink-0",style:e.surface,children:[o?l.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3 rounded-lg border px-3 py-2",style:{borderColor:g.border,backgroundColor:g.bg},children:[l.jsxs("div",{className:"min-w-0",children:[l.jsxs("div",{className:"text-[9px] font-mono uppercase tracking-widest",style:e.mutedText,children:["Replying to ",o.authorName," · ",So(o.messageId)]}),l.jsx("div",{className:"text-[11px] truncate mt-1",style:e.mutedText,children:o.preview})]}),l.jsx("button",{type:"button",onClick:()=>u(null),className:"shrink-0 rounded p-1 transition-opacity hover:opacity-70",style:e.mutedText,title:"Clear reply context",children:l.jsx(kl,{size:12})})]}):null,d.length>0?l.jsx("div",{className:"mb-2 space-y-2",children:d.map(F=>l.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-lg border px-3 py-2",style:{borderColor:g.border,backgroundColor:g.bg},children:[l.jsxs("div",{className:"min-w-0",children:[l.jsxs("div",{className:"text-[9px] font-mono uppercase tracking-widest",style:e.mutedText,children:["Context · ",F.authorName," · ",So(F.messageId)]}),l.jsx("div",{className:"text-[11px] truncate mt-1",style:e.mutedText,children:F.preview})]}),l.jsx("button",{type:"button",onClick:()=>p(Z=>Z.filter(O=>O!==F.messageId)),className:"shrink-0 rounded p-1 transition-opacity hover:opacity-70",style:e.mutedText,title:"Clear referenced context",children:l.jsx(kl,{size:12})})]},F.messageId))}):null,l.jsxs("div",{className:"relative",children:[w?l.jsxs("div",{className:"absolute inset-x-0 bottom-full mb-2 rounded-xl border shadow-lg overflow-hidden z-20",style:{backgroundColor:g.surface,borderColor:g.border,boxShadow:g.shadowLg},children:[l.jsx("div",{className:"px-3 py-2 border-b text-[9px] font-mono uppercase tracking-widest",style:{...e.mutedText,borderColor:g.border},children:"Mention an agent"}),l.jsx("div",{className:"max-h-64 overflow-y-auto",children:M.map((F,Z)=>{const O=Z===D,P=az(F),Q=iz(F),oe=(X.get(F.title)??0)>1,J=oe||!!F.harness||!!Q,ee=!!(Q&&Q!==P);return l.jsxs("button",{type:"button",className:"w-full flex items-start justify-between gap-3 px-3 py-2.5 text-left transition-colors",style:{backgroundColor:O?g.bg:"transparent",color:g.ink},onMouseDown:N=>{N.preventDefault(),q(F)},children:[l.jsxs("div",{className:"min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-wrap",children:[l.jsx("span",{className:"text-[11px] font-medium truncate",children:F.title}),l.jsx("span",{className:"text-[9px] font-mono px-1.5 py-0.5 rounded",style:e.tagBadge,children:F.statusLabel}),J&&P?l.jsx("span",{className:"text-[9px] font-mono px-1.5 py-0.5 rounded",style:e.tagBadge,children:P}):null,F.harness?l.jsx("span",{className:"text-[9px] font-mono px-1.5 py-0.5 rounded",style:e.tagBadge,children:F.harness}):null,ee&&Q?l.jsx("span",{className:"text-[9px] font-mono px-1.5 py-0.5 rounded",style:e.tagBadge,children:Q}):null]}),l.jsxs("div",{className:"text-[10px] mt-1 truncate",style:e.mutedText,children:[F.mentionToken,oe&&F.subtitle?` · ${Ka(F.subtitle)??F.subtitle}`:""]})]}),l.jsx("span",{className:"text-[9px] font-mono shrink-0",style:e.mutedText,children:O?"↵":""})]},F.agentId)})})]}):null,l.jsxs("div",{className:"border rounded flex items-center px-2 py-1 transition-all focus-within:ring-1",style:{backgroundColor:g.bg,borderColor:g.border},children:[l.jsx("textarea",{ref:h,className:"flex-1 bg-transparent outline-none resize-none h-[20px] min-h-[20px] max-h-[80px] text-[12px] leading-tight py-0.5",style:{color:g.ink},placeholder:rz(r,a),rows:1,value:y,onChange:F=>{const Z=fz(F.currentTarget.value,E,f);b(Z.body),C(F.currentTarget.selectionStart??Z.body.length),Z.nextReferenceMessageIds!==f&&p(Z.nextReferenceMessageIds)},onClick:F=>C(F.currentTarget.selectionStart??y.length),onKeyUp:F=>C(F.currentTarget.selectionStart??y.length),onSelect:F=>C(F.currentTarget.selectionStart??y.length),onKeyDown:F=>{if(w){if(F.key==="ArrowDown"){F.preventDefault(),H(Z=>M.length===0?0:(Z+1)%M.length);return}if(F.key==="ArrowUp"){F.preventDefault(),H(Z=>M.length===0?0:(Z-1+M.length)%M.length);return}if(F.key==="Enter"&&!F.metaKey&&!F.ctrlKey&&!F.shiftKey||F.key==="Tab"){F.preventDefault();const Z=M[D]??M[0];Z&&q(Z);return}if(F.key==="Escape"){F.preventDefault(),C(y.length);return}}(F.metaKey||F.ctrlKey)&&F.key==="Enter"&&(F.preventDefault(),L())}}),l.jsxs("div",{className:"shrink-0 flex items-center gap-1 ml-2",children:[B?l.jsx("button",{className:"p-1 opacity-50 cursor-default transition-opacity",style:e.mutedText,title:i?.detail??"Voice unavailable on this desktop host",children:l.jsx(d2,{size:12})}):null,l.jsx("button",{type:"button",className:"shrink-0 flex h-[26px] w-[26px] items-center justify-center rounded-md border transition-opacity hover:opacity-85 disabled:opacity-30 disabled:cursor-not-allowed",style:{borderColor:g.border,backgroundColor:g.surface,color:g.ink},onClick:()=>{L()},disabled:v||!y.trim(),title:"Send","aria-label":"Send message",children:l.jsx(C1,{size:14})})]})]})]})]})}function nz({styles:e,messagesDetailWidth:r,selectedMessagesThread:a,selectedMessagesInternalThread:i,selectedMessagesDetailAgentId:o,selectedMessagesDetailAgent:u,selectedMessagesSessions:d,selectedSession:f,setSelectedSession:p,formatDate:h,interAgentAgents:y,messagesDetailTab:b,setMessagesDetailTab:v,setMessagesDetailOpen:j,onResizeStart:C,openAgentProfile:E,openAgentDirectMessage:w,visibleAgentSession:M,agentSessionPending:D,agentSessionFeedback:H,agentSessionCopied:X,onCopyAgentSessionCommand:q,onOpenAgentSession:L,onPeekAgentSession:B,onOpenAgentSettings:F}){return l.jsxs("div",{className:"relative border-l shrink-0 overflow-y-auto flex flex-col",style:{width:r,...e.surface,borderLeftColor:g.border},children:[l.jsx("div",{className:"absolute left-[-3px] top-0 bottom-0 w-1.5 cursor-col-resize hover:bg-indigo-400 z-20 transition-colors",onMouseDown:C}),l.jsxs("div",{className:"px-4 py-3 border-b",style:{borderBottomColor:g.border},children:[l.jsxs("div",{className:"flex items-start justify-between gap-3",children:[l.jsxs("div",{className:"min-w-0",children:[l.jsx("div",{className:"text-[10px] font-mono tracking-widest uppercase",style:e.mutedText,children:"Thread Details"}),l.jsx("div",{className:"text-[13px] font-semibold mt-1 truncate",style:e.inkText,children:a.kind==="internal"?i?.title??a.title:Ip(a.title)}),l.jsx("div",{className:"text-[10px] mt-1 line-clamp-2",style:e.mutedText,children:a.preview??a.subtitle??"Context for the selected thread."})]}),l.jsxs("button",{type:"button",onClick:()=>j(!1),className:"os-toolbar-button flex items-center gap-1.5 text-[10px] font-medium px-2 py-1 rounded shrink-0",style:{color:g.ink},title:"Hide details",children:[l.jsx(kl,{size:11}),l.jsx("span",{children:"Hide"})]})]}),l.jsx("div",{className:"flex items-center gap-1 mt-3",children:[["overview","Overview"],["live","Live"],["history","History"]].filter(([Z])=>Z!=="live"||!!o).map(([Z,O])=>l.jsx("button",{type:"button",className:"rounded-md px-2.5 py-1.5 text-[11px] font-medium transition-colors",style:b===Z?e.activeItem:e.mutedText,onClick:()=>v(Z),children:O},Z))})]}),l.jsxs("div",{className:"p-4 flex-1 space-y-4",children:[b==="overview"?l.jsxs(l.Fragment,{children:[u?l.jsxs("section",{className:"rounded-xl border p-3",style:{borderColor:g.border,backgroundColor:g.bg},children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"w-10 h-10 rounded-lg text-white flex items-center justify-center text-[13px] font-bold",style:{backgroundColor:cl(u.id)},children:u.title.charAt(0).toUpperCase()}),l.jsxs("div",{className:"min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("div",{className:"text-[13px] font-semibold truncate",style:e.inkText,children:u.title}),l.jsx("span",{className:"text-[9px] font-mono px-1.5 py-0.5 rounded",style:u.state==="working"?e.activePill:e.tagBadge,children:u.statusLabel})]}),l.jsx("div",{className:"text-[10px] mt-1 line-clamp-2",style:e.mutedText,children:u.summary??u.statusDetail??"No summary yet."})]})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-2 mt-3 text-[10px]",children:[l.jsxs("div",{children:[l.jsx("div",{style:e.mutedText,children:"Harness"}),l.jsx("div",{style:e.inkText,children:u.harness??"Unknown"})]}),l.jsxs("div",{children:[l.jsx("div",{style:e.mutedText,children:"Threads"}),l.jsx("div",{style:e.inkText,children:u.threadCount})]}),l.jsxs("div",{children:[l.jsx("div",{style:e.mutedText,children:"Workspace"}),l.jsx("div",{className:"truncate",style:e.inkText,children:u.projectRoot??u.cwd??"Unbound"})]}),l.jsxs("div",{children:[l.jsx("div",{style:e.mutedText,children:"Last Chat"}),l.jsx("div",{style:e.inkText,children:u.lastChatLabel??"No recent chat"})]})]}),l.jsxs("div",{className:"flex items-center gap-2 mt-3",children:[l.jsxs("button",{type:"button",onClick:()=>w(u.id),className:"os-toolbar-button flex items-center gap-1.5 text-[10px] font-medium px-2 py-1 rounded",style:{color:g.ink},children:[l.jsx(Al,{size:11}),"Message"]}),l.jsxs("button",{type:"button",onClick:()=>{v("live"),B()},className:"os-toolbar-button flex items-center gap-1.5 text-[10px] font-medium px-2 py-1 rounded",style:{color:g.ink},children:[l.jsx(b1,{size:11}),"Peek"]}),l.jsxs("button",{type:"button",onClick:()=>F(u.id,u.profileKind==="project"),className:"os-toolbar-button flex items-center gap-1.5 text-[10px] font-medium px-2 py-1 rounded",style:{color:g.ink},children:[l.jsx($a,{size:11}),"Settings"]})]})]}):null,a.kind==="internal"&&i?l.jsxs("section",{className:"rounded-xl border p-3",style:{borderColor:g.border,backgroundColor:g.bg},children:[l.jsx("div",{className:"text-[10px] font-mono tracking-widest uppercase",style:e.mutedText,children:"Participants"}),l.jsx("div",{className:"flex flex-col gap-2 mt-3",children:i.participants.map(Z=>l.jsxs("div",{className:"flex items-center justify-between gap-2",children:[l.jsxs("div",{className:"min-w-0",children:[l.jsx("div",{className:"text-[12px] font-medium truncate",style:e.inkText,children:Z.title}),l.jsx("div",{className:"text-[10px] truncate",style:e.mutedText,children:Z.role??Z.id})]}),y.some(O=>O.id===Z.id)?l.jsx("button",{type:"button",onClick:()=>E(Z.id),className:"text-[10px] font-medium hover:opacity-80",style:{color:g.accent},children:"Open"}):null]},Z.id))})]}):null]}):null,b==="live"?l.jsxs("section",{className:"rounded-xl border overflow-hidden",style:{borderColor:g.border,backgroundColor:g.bg},children:[l.jsxs("div",{className:"px-3 py-3 border-b flex items-center justify-between gap-2",style:{borderBottomColor:g.border},children:[l.jsxs("div",{children:[l.jsx("div",{className:"text-[10px] font-mono tracking-widest uppercase",style:e.mutedText,children:"Live Session"}),l.jsx("div",{className:"text-[11px] mt-1",style:e.mutedText,children:"Runtime, tmux, or log tail for the selected agent."})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[M?.commandLabel?l.jsxs("button",{type:"button",onClick:()=>{q()},className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-1 rounded",style:{color:g.ink},children:[l.jsx(Nr,{size:11}),X?"Copied":"Copy"]}):null,o?l.jsxs("button",{type:"button",onClick:()=>{L()},className:"os-toolbar-button flex items-center gap-1 text-[10px] font-medium px-2 py-1 rounded",style:{color:g.ink},children:[l.jsx(UN,{size:11}),"Open"]}):null]})]}),l.jsx("div",{className:"p-3",children:D?l.jsxs("div",{className:"flex items-center gap-2 text-[11px]",style:e.mutedText,children:[l.jsx(un,{className:"text-[12px]"}),"Loading live session…"]}):M?.body?l.jsx("pre",{className:"max-h-[280px] overflow-y-auto text-[11px] leading-[1.55] whitespace-pre-wrap break-words font-mono",style:{color:g.termFg,backgroundColor:g.termBg,padding:"12px",borderRadius:g.radiusMd},children:M.body}):l.jsx("div",{className:"text-[11px] leading-[1.6]",style:e.mutedText,children:H??"No live session output is available for this thread yet."})})]}):null,b==="history"?l.jsxs("section",{className:"rounded-xl border p-3",style:{borderColor:g.border,backgroundColor:g.bg},children:[l.jsxs("div",{className:"flex items-center justify-between gap-2",children:[l.jsxs("div",{children:[l.jsx("div",{className:"text-[10px] font-mono tracking-widest uppercase",style:e.mutedText,children:"Recent History"}),l.jsx("div",{className:"text-[11px] mt-1",style:e.mutedText,children:"Recent sessions tied to this thread or agent."})]}),f?l.jsx("span",{className:"text-[9px] font-mono px-1.5 py-0.5 rounded",style:e.tagBadge,children:"selected"}):null]}),l.jsx("div",{className:"mt-3 flex flex-col gap-2",children:d.length>0?d.slice(0,8).map(Z=>l.jsx("button",{type:"button",onClick:()=>p(Z),className:"w-full rounded-lg border px-3 py-3 text-left transition-opacity hover:opacity-90",style:{borderColor:g.border,backgroundColor:f?.id===Z.id?g.surface:g.bg},children:l.jsxs("div",{className:"flex items-start justify-between gap-3",children:[l.jsxs("div",{className:"min-w-0",children:[l.jsx("div",{className:"text-[12px] font-medium truncate",style:e.inkText,children:Z.title}),l.jsxs("div",{className:"text-[10px] mt-1",style:e.mutedText,children:[Z.project," · ",Z.messageCount," messages"]}),l.jsx("div",{className:"text-[10px] mt-2 line-clamp-2",style:e.mutedText,children:Z.preview})]}),l.jsx("span",{className:"text-[10px] font-mono shrink-0",style:e.mutedText,children:h(Z.lastModified)})]})},Z.id)):l.jsx("div",{className:"text-[11px] leading-[1.6]",style:e.mutedText,children:"No recent session history is linked to this thread yet."})})]}):null,f?l.jsxs("section",{className:"rounded-xl border p-3",style:{borderColor:g.border,backgroundColor:g.bg},children:[l.jsx("div",{className:"text-[10px] font-mono tracking-widest uppercase",style:e.mutedText,children:"Selected Session"}),l.jsx("div",{className:"text-[12px] font-medium mt-2",style:e.inkText,children:f.title}),l.jsxs("div",{className:"text-[10px] mt-1",style:e.mutedText,children:[f.project," · ",f.agent]}),l.jsx("div",{className:"text-[11px] mt-2 leading-[1.6]",style:e.mutedText,children:f.preview})]}):null]})]})}function lz(e){const r=Math.floor(e/6e4);return r>=1?`${r}m`:`${Math.max(1,Math.floor(e/1e3))}s`}function rz(e,r){return e==="direct"?"Message direct thread...":e==="filter"&&r==="coordination"?"Message #shared-channel or @agent...":e==="channel"&&r==="voice"?"Message #voice...":e==="channel"&&r==="system"?"Message #system...":"Message #shared-channel..."}function az(e){return sz(e.subtitle)??e.workspaceQualifier??null}function iz(e){const r=e.branch?.trim();return r&&r!=="HEAD"?r:e.workspaceQualifier?.trim()||null}function sz(e){if(!e)return null;const r=e.replace(/[\\/]+$/,"");return r?r.split(/[\\/]/).filter(Boolean).at(-1)??null:null}function dk(){return/\b(?:message:[a-zA-Z0-9._:-]+|m:[a-z0-9]{4,12})\b/gi}function oz(e){return e.replace(/[^a-zA-Z0-9]/g,"").toLowerCase()}function cz(e,r){const a=e.trim().toLowerCase();if(!a)return null;if(a.startsWith("message:")){const u=e.slice(e.indexOf(":")+1).trim();return r.find(d=>d.id===u)??null}if(!a.startsWith("m:"))return null;const i=a.slice(2);if(!i)return null;const o=r.filter(u=>oz(u.id).endsWith(i));return o.length===1?o[0]:null}function uz(e,r){if(r.length===0)return e;const a=new Set(r.map(o=>o.toLowerCase()));return e.replace(dk(),o=>a.has(o.toLowerCase())?" ":o).split(/\r?\n/g).map(o=>o.replace(/[ \t]{2,}/g," ").trim()).filter((o,u,d)=>o.length>0||u>0&&u<d.length-1).join(`
|
|
90
|
+
`).trim()}function dz(e,r){return e.length!==r.length?!1:e.every((a,i)=>a===r[i])}function fz(e,r,a){const i=e.match(dk())??[];if(i.length===0)return{body:e,nextReferenceMessageIds:a};const o=[...a],u=[];for(const f of i){const p=cz(f,r);p&&(u.push(f),o.includes(p.id)||o.push(p.id))}return{body:uz(e,u),nextReferenceMessageIds:dz(o,a)?a:o}}function mz({activeView:e,layout:r,threading:a,composer:i,agentSession:o}){return e!=="messages"&&e!=="relay"?null:l.jsx(ZM,{...r,...a,...i,...o})}function pz({activeView:e,scoutDesktop:r,voiceEnabled:a,relayState:i,messagesState:o,interAgentAgents:u,interAgentThreads:d,sessions:f,appSettings:p,setActiveView:h,applyRelayWorkspacePatch:y}){const[b,v]=z.useState("channel"),[j,C]=z.useState("shared"),[E,w]=z.useState(null),[M,D]=z.useState(""),[H,X]=z.useState(!1),[q,L]=z.useState(0),[B,F]=z.useState(0),[Z,O]=z.useState(null),[P,Q]=z.useState(!0),[oe,J]=z.useState(null),[ee,N]=z.useState([]),[Y,$]=z.useState([]),[ye,T]=z.useState(0),_=z.useRef(null),le=z.useRef(null),R=o?.threads??[],pe=z.useMemo(()=>R.find(V=>V.id===E)??null,[R,E]),xe=z.useMemo(()=>pe?.interAgentThreadId?d.find(V=>V.id===pe.interAgentThreadId)??null:null,[d,pe]),ce=z.useMemo(()=>{if(!xe)return null;const V=xe.participants.map(je=>je.id),me=i?.directs.find(je=>V.includes(je.id))?.id??null;return me?u.find(je=>je.id===me)??null:null},[u,i,xe]),Re=pe?.kind==="relay"&&b==="direct"?j:ce?.id??null;z.useEffect(()=>{if(!i)return;const V=qb(i),me=GS(i),je=[...V.map(Je=>`${Je.kind}:${Je.id}`),...me.map(Je=>`${Je.kind}:${Je.id}`),...i.directs.map(Je=>`${Je.kind}:${Je.id}`)],Fe=`${b}:${j}`;je.includes(Fe)||(v("channel"),C("shared"))},[i,j,b]),z.useEffect(()=>{const V=_.current;if(!V)return;const me=120;V.style.height="0px";const je=Math.min(V.scrollHeight,me);V.style.height=`${je}px`,V.style.overflowY=V.scrollHeight>me?"auto":"hidden"},[M]),z.useEffect(()=>{if(e!=="relay"&&e!=="messages"||ye===0)return;const V=_.current;if(!V)return;const me=window.requestAnimationFrame(()=>{V.focus();const je=V.value.length;V.setSelectionRange?.(je,je)});return()=>{window.cancelAnimationFrame(me)}},[e,ye]),z.useEffect(()=>{oe&&(b!=="direct"||j!==oe.authorId)&&J(null)},[oe,j,b]),z.useEffect(()=>{if(!i?.messages.length)return;const V=new Set(i.messages.map(me=>me.clientMessageId).filter(me=>!!me));V.size&&$(me=>me.filter(je=>!V.has(je.clientMessageId)))},[i]);const Te=z.useMemo(()=>qb(i).filter(V=>a||!(V.kind==="channel"&&V.id==="voice")),[i,a]),Ne=i&&b==="direct"?i.directs.find(V=>V.id===j)??null:null,He=i?$S(i,Te,b,j):null,Le=z.useMemo(()=>{const V=i?.messages??[];if(!Y.length)return V;const me=new Set(V.map(Fe=>Fe.clientMessageId).filter(Fe=>!!Fe)),je=Y.filter(Fe=>!me.has(Fe.clientMessageId)).map(Fe=>Fe.message);return je.length?[...V,...je].sort((Fe,Je)=>Fe.createdAt-Je.createdAt||Fe.id.localeCompare(Je.id)):V},[Y,i]),Ue=z.useMemo(()=>YS(Le,b,j),[Le,j,b]),it=z.useMemo(()=>new Map(Le.map(V=>[V.id,V])),[Le]),tt=z.useMemo(()=>ee.map(V=>it.get(V)).filter(V=>!!V).map(V=>({messageId:V.id,authorName:V.authorName,preview:zu(V.body,96)})),[ee,it]),st=Ip(He?.title??"# shared-channel"),ot=Ne?pv(Ne):He?.subtitle??null,bt=He&&"count"in He&&He.count>0?He.count:null,Ye=Ue.at(-1)??null,Ge=z.useMemo(()=>u.flatMap(V=>{const me=V.selector??V.defaultSelector;return me?[{agentId:V.id,title:V.title,subtitle:V.projectRoot??V.cwd??V.subtitle??null,mentionToken:me,definitionId:V.definitionId,workspaceQualifier:V.workspaceQualifier,branch:V.branch,harness:V.harness,state:V.state,statusLabel:V.statusLabel,searchText:[V.title,V.id,V.definitionId??"",me,V.selector??"",V.defaultSelector??"",V.workspaceQualifier??"",V.branch??"",V.harness??"",V.projectRoot??"",V.cwd??""].join(" ").toLowerCase()}]:[]}).sort((V,me)=>V.title.localeCompare(me.title)),[u]);z.useEffect(()=>{Q(!0);const V=le.current;V&&window.requestAnimationFrame(()=>{V.scrollTo({top:V.scrollHeight,behavior:"auto"})})},[j,b]),z.useEffect(()=>{if(!P)return;const V=le.current;V&&window.requestAnimationFrame(()=>{V.scrollTo({top:V.scrollHeight,behavior:"smooth"})})},[Ye?.body,Ye?.id,Ye?.receipt?.state,Ne?.activeTask,Ne?.state,P]);const We=z.useCallback(V=>{const me=V.currentTarget,je=me.scrollHeight-me.scrollTop-me.clientHeight;Q(je<=48)},[]),we=z.useMemo(()=>WS(M,q),[M,q]),et=z.useMemo(()=>{if(!we)return[];const V=b==="direct"?j:null;return Ge.map(me=>({candidate:me,score:JS(me,we.query,V)})).filter(({score:me})=>me>0).sort((me,je)=>je.score-me.score||me.candidate.title.localeCompare(je.candidate.title)).slice(0,8).map(({candidate:me})=>me)},[we,Ge,j,b]),Se=z.useMemo(()=>Ge.reduce((V,me)=>(V.set(me.title,(V.get(me.title)??0)+1),V),new Map),[Ge]),Ze=et.length>0;z.useEffect(()=>{if(!Ze){F(0);return}F(V=>Math.min(V,et.length-1))},[Ze,et.length]);const mt=z.useMemo(()=>{if(!xe)return[];const V=new Set(xe.messageIds);return Le.filter(me=>V.has(me.id))},[Le,xe]),ae=Re?u.find(V=>V.id===Re)??null:null,ge=z.useMemo(()=>{if(ae)return f.filter(V=>V.project===ae.id||V.agent===ae.title);if(xe){const V=new Set(xe.participants.map(je=>je.id)),me=new Set(xe.participants.map(je=>je.title));return f.filter(je=>V.has(je.project)||me.has(je.agent))}return pe?.relayDestinationKind==="channel"&&pe.relayDestinationId?f.filter(V=>V.tags?.includes(pe.relayDestinationId??"")??!1):f.slice(0,8)},[ae,xe,pe,f]),Ce=z.useCallback((V,me)=>{v(V),C(me),w(o?.threads.find(je=>je.relayDestinationKind===V&&je.relayDestinationId===me)?.id??null),h("messages")},[o,h]),_e=z.useCallback(V=>{if(!we)return;const me=M.slice(we.end),je=me.startsWith(" ")||me.length===0?"":" ",Fe=`${M.slice(0,we.start)}${V.mentionToken}${je}${me}`,Je=we.start+V.mentionToken.length+je.length;D(Fe),L(Je),F(0),window.requestAnimationFrame(()=>{const qe=_.current;qe&&(qe.focus(),qe.setSelectionRange(Je,Je))})},[we,M]),Xe=z.useCallback(async()=>{const V=M.trim();if(!V||H||!r?.sendRelayMessage)return;const me=M,je=oe,Fe=ee,Je=RM(),qe=oe?.messageId??ee[0]??null,St=AM({relayState:i,appSettings:p,destinationKind:b,destinationId:j,body:V,replyToMessageId:qe,clientMessageId:Je});X(!0),O("Sending…"),$(Yt=>[...Yt,{clientMessageId:Je,message:St}]),D(""),J(null),N([]);try{const Yt=await r.sendRelayMessage({destinationKind:b,destinationId:j,body:V,replyToMessageId:qe,referenceMessageIds:ee,clientMessageId:Je});y(Yt),$(Vt=>Vt.map(Pt=>Pt.clientMessageId===Je?{...Pt,message:{...Pt.message,receipt:Pt.message.receipt?{...Pt.message.receipt,label:"Sent",detail:null}:{state:"sent",label:"Sent",detail:null}}}:Pt)),O("Sent.")}catch(Yt){$(Vt=>Vt.filter(Pt=>Pt.clientMessageId!==Je)),D(me),J(je),N(Fe),O(lt(Yt))}finally{X(!1)}},[p,M,H,ee,i,oe,r,j,b,y]),Ae=z.useCallback((V,me)=>{Ce("direct",V),N([]),J(me?.replyToMessage?{messageId:me.replyToMessage.id,authorId:me.replyToMessage.authorId,authorName:me.replyToMessage.authorName,preview:zu(me.replyToMessage.body,96)}:null),typeof me?.draft=="string"&&D(me.draft),me?.focusComposer&&T(je=>je+1)},[Ce]),ue=z.useCallback(V=>{V.isOperator||(Ae(V.authorId,{replyToMessage:V,draft:"Following up on this.",focusComposer:!0}),O(`Drafting a follow-up to ${V.authorName}.`))},[Ae]),Ee=z.useCallback((V,me)=>{Ae(V,{draft:me??null,focusComposer:!0})},[Ae]);return{selectedConversationKind:b,setSelectedConversationKind:v,selectedConversationId:j,setSelectedConversationId:C,selectedMessageThreadId:E,setSelectedMessageThreadId:w,selectedMessagesThread:pe,selectedMessagesInternalThread:xe,selectedMessagesInternalTarget:ce,selectedMessagesDetailAgentId:Re,selectedMessagesDetailAgent:ae,selectedMessagesInternalMessages:mt,selectedMessagesSessions:ge,composerDraft:M,setComposerDraft:D,composerSending:H,composerSelectionStart:q,setComposerSelectionStart:L,mentionSelectionIndex:B,setMentionSelectionIndex:F,messagesFeedback:Z,setMessagesFeedback:O,replyTarget:oe,setReplyTarget:J,contextMessageIds:ee,setContextMessageIds:N,composerRef:_,timelineViewportRef:le,mergedConversationMessages:Le,visibleConversationMessages:Ue,currentConversationTitle:st,currentConversationSubtitle:ot,currentConversationCount:bt,selectedDirectConversation:Ne,contextReferences:tt,mentionMenuOpen:Ze,mentionSuggestions:et,mentionDuplicateTitleCounts:Se,handleConversationTimelineScroll:We,openConversation:Ce,applyMentionSuggestion:_e,sendMessage:Xe,openDirectConversation:Ae,nudgeMessage:ue,openAgentDirectMessage:Ee,messageThreads:R}}const hz=["profile","knowledge","agents","workspaces","communication","database","appearance"];function xz(e){return hz.includes(e)}function gz(e,r){const a=r?.agentId?.trim();return e==="agents"&&a?`/settings/agents/${encodeURIComponent(a)}`:`/settings/${e}`}function bz(e){if(e==="/settings"||e==="/settings/")return{section:"profile",agentId:null};if(!e.startsWith("/settings/"))return null;const r=e.slice(10).split("/").filter(Boolean),a=r[0]??"";if(!a)return{section:"profile",agentId:null};if(!xz(a))return null;if(a!=="agents")return r.length===1?{section:a,agentId:null}:null;if(r.length===1)return{section:"agents",agentId:null};if(r.length===2)try{return{section:"agents",agentId:decodeURIComponent(r[1]??"")||null}}catch{return null}return null}const yz=["overview","inbox","activity","machines","plans","sessions","search","messages","relay","inter-agent","agents","logs","settings","help"];function vz(e){return e!==null&&yz.includes(e)}function kz(e){if(e==="/")return"overview";const r=e.slice(1).split("/")[0]??"";return!r||r==="pairing"||r==="settings"?null:vz(r)?r:null}function jz(e,r,a,i){return e==="pairing"?"/pairing":r==="settings"?gz(a,{agentId:i}):r==="overview"?"/":`/${r}`}const Nz={enableAll:!1,overview:!0,inbox:!0,relay:!0,pairing:!0,interAgent:!0,agents:!0,settings:!0,logs:!0,activity:!1,machines:!1,plans:!1,sessions:!0,search:!0,phonePreparation:!1,telegram:!1,voice:!1,monitor:!1},r1=["claude","codex"],fk="scout.desktop.home-cache.v1";function wz(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(fk);return e?JSON.parse(e):null}catch{return null}}function Sz(e){if(!(typeof window>"u"))try{window.localStorage.setItem(fk,JSON.stringify({...e,savedAt:Date.now()}))}catch{}}function gu(e,r,a){const i={label:e,durationMs:Math.round(performance.now()-r),recordedAt:Date.now(),detail:a};return console.info(`[scout] ${e}`,{durationMs:i.durationMs,...a}),i}function bu(e,r){const a={...e};return r&&(a.Total=`${r.totalMs}ms`,r.steps.forEach(i=>{a[i.label]=`${i.durationMs}ms`})),Object.keys(a).length>0?a:void 0}function yu(e){return{runtime:e.runtime,messages:e.messages,sessions:e.sessions,relay:e.relay,interAgent:e.interAgent,performance:e.performance??null}}function Cz(e,r){return{...r,planCount:e.planCount,workspaceCount:e.workspaceCount,plans:e.plans,subtitle:`${r.taskCount} asks · ${r.findingCount} findings · ${e.planCount} plans · ${e.workspaceCount} workspaces`}}function Tz(){const e=UM(),[r,a]=A.useState(240),[i,o]=A.useState(340),[u,d]=A.useState(!1),[f,p]=A.useState("relay"),[h,y]=A.useState("overview"),[b,v]=A.useState(""),[j,C]=A.useState(null),[E,w]=A.useState(null),[M,D]=A.useState(!0),[H,X]=A.useState("overview"),[q,L]=A.useState(null),[B,F]=A.useState(null),[Z,O]=A.useState(null),[P,Q]=A.useState(null),[oe,J]=A.useState(null),[ee,N]=A.useState({services:null,home:null,workspace:null}),[Y,$]=A.useState(!1),[ye,T]=A.useState(!0),[_,le]=A.useState(!1),[R,pe]=A.useState(!1),[xe,ce]=A.useState(null),[Re,Te]=A.useState(!1),[Ne,He]=A.useState(!1),[Le,Ue]=A.useState("profile"),[it,tt]=A.useState(null),st=A.useRef(null),ot=A.useRef(null),bt=A.useRef(!1),Ye=eN(),Ge=d1();A.useLayoutEffect(()=>{if(!Ge.pathname.startsWith("/settings"))return;const I=bz(Ge.pathname);if(I){p("relay"),y("settings"),Ue(I.section),tt(I.agentId);return}Ye("/settings/profile",{replace:!0})},[Ge.pathname,Ye]),A.useLayoutEffect(()=>{if(Ge.pathname.startsWith("/settings"))return;if(Ge.pathname==="/pairing"){p("pairing"),y(W=>W==="settings"?"overview":W);return}const I=kz(Ge.pathname);if(I){p("relay"),y(I);return}Ye("/",{replace:!0})},[Ge.pathname,Ye]),A.useEffect(()=>{const I=jz(f,h,Le,it);Ge.pathname!==I&&Ye(I,{replace:!0})},[h,Ge.pathname,Ye,f,it,Le]);const We=z.useCallback(()=>{p("relay"),y("help"),Ht(null)},[]),[we,et]=A.useState(!1),[Se,Ze]=A.useState(!1),[mt,ae]=A.useState(!1),ge=A.useRef(null),Ce=A.useRef(null),_e=A.useRef(null),Xe=A.useRef(!1),Ae=A.useRef(!1),ue=A.useRef(!1),Ee=A.useRef(!1),V=f==="relay"&&(h==="messages"||h==="relay"),me=V?P?.sessions??oe?.sessions??[]:oe?.sessions??[],je=oe?.machines??null,Fe=oe?.plans??null,Je=V?P?.messages??oe?.messages??null:oe?.messages??null,qe=V?P?.runtime??oe?.runtime??null:oe?.runtime??null,St=V?P?.relay??oe?.relay??null:oe?.relay??null,Yt=V?P?.interAgent??oe?.interAgent??null:oe?.interAgent??null,Vt=Yt?.agents??[],Pt=Yt?.threads??[],yt=q?.features??oe?.appInfo.features??Nz,Wt=q?.capabilities??oe?.appInfo.capabilities;A.useEffect(()=>{st.current=B},[B]),A.useEffect(()=>{ot.current=Z},[Z]);const se=z.useCallback((I,W)=>{Sz({homeState:I,servicesState:W})},[]),Me=z.useCallback(async()=>{if(!e?.getServicesState||Ae.current)return null;const I=performance.now();$(!0),Ae.current=!0;try{const W=await e.getServicesState();return O(W),se(st.current,W),N(be=>({...be,services:gu("services-state",I,bu({serviceCount:W.services.length},W.performance))})),W}catch(W){return ce(lt(W)),null}finally{Ae.current=!1,$(!1)}},[se,e]),ze=z.useCallback(async(I=!1)=>{if(!e?.getHomeState)return ce("Desktop bridge is unavailable."),T(!1),null;if(Xe.current)return null;I&&T(!0);const W=performance.now();Xe.current=!0;try{const be=await e.getHomeState();return F(be),ce(null),se(be,ot.current),N(At=>({...At,home:gu("home-state",W,bu({agents:be.agents.length,activity:be.activity.length},be.performance))})),be}catch(be){return ce(lt(be)),null}finally{Xe.current=!1,T(!1)}},[se,e]),nt=z.useCallback(async(I=!1)=>{if(!e?.getMessagesWorkspaceState)return ce("Desktop bridge is unavailable."),le(!1),null;if(ue.current)return null;I&&le(!0),ue.current=!0;const W=performance.now();try{const be=await e.getMessagesWorkspaceState();return Q(be),ce(null),N(At=>({...At,workspace:gu("messages-workspace",W,bu({threads:be.messages.threads.length,messages:be.relay.messages.length,agents:be.interAgent.agents.length,sessions:be.sessions.length},be.performance))})),be}catch(be){return ce(lt(be)),null}finally{ue.current=!1,le(!1)}},[e]),Qt=z.useCallback(async(I=!1)=>{if(!e?.getShellState)return ce("Desktop bridge is unavailable."),pe(!1),null;if(Ee.current)return null;I&&pe(!0),Ee.current=!0;const W=performance.now();try{const be=await e.getShellState();return J(be),ce(null),N(At=>({...At,workspace:gu("relay-workspace",W,bu({messages:be.relay.messages.length,agents:be.interAgent.agents.length,sessions:be.sessions.length},be.performance))})),be}catch(be){return ce(lt(be)),null}finally{Ee.current=!1,pe(!1)}},[e]),gn=z.useCallback(I=>{J(W=>W&&{...W,...I,relay:{...I.relay,voice:W.relay.voice},plans:Cz(W.plans,I.plans)}),Q(W=>W&&{...W,...yu(I),relay:{...I.relay,voice:W.relay.voice}})},[]);A.useEffect(()=>{if(!e?.getAppInfo)return;let I=!1;return(async()=>{try{const be=await e.getAppInfo();I||L(be)}catch{I||L(null)}})(),()=>{I=!0}},[e]),A.useEffect(()=>{if(e?.onOpenKnowledgeBase)return e.onOpenKnowledgeBase(We)},[We,e]);const ha=z.useCallback(I=>{const W=I?.runtime?.brokerReachable??Z?.services.find(be=>be.id==="broker")?.reachable??!1;if(p("relay"),W){y("messages"),Jn("channel"),Wl("shared"),kn("Relay is running."),Ht(null);return}y("settings"),Ue("communication"),et(!0),Ht("Relay is not running yet. Finish onboarding by starting the broker from Communication.")},[Z]),Gl=KM({activeView:h,settingsSection:Le,scoutDesktop:e,shellState:oe,surfaceCaps:Wt,completeOnboardingIntoRelay:ha,loadShellState:Qt}),{SOURCE_ROOT_PATH_SUGGESTIONS:xa,appSettings:bn,setAppSettings:Wa,appSettingsLoading:ga,workspaceInventoryLoading:Un,appSettingsSaving:$t,appSettingsFeedback:dn,setAppSettingsFeedback:Ht,setAppSettingsDraft:$l,isAppSettingsEditing:Ml,onboardingWizardStep:Yl,setOnboardingWizardStep:ns,onboardingCommandPending:Wn,onboardingCommandResult:zl,onboardingCommandHistory:dl,onboardingCopiedCommand:Ol,startupOnboardingState:Sr,setIsAppSettingsEditing:Ll,visibleAppSettings:Ft,agentableProjects:ba,appSettingsDirty:ya,projectRetirementPendingRoot:Dl,workspaceInventoryLoaded:Ql,canRefreshWorkspaceInventory:Lo,showDoctorOutput:ls,onboardingContextRoot:Ja,onboardingHasProjectConfig:rs,onboardingRuntimeMatch:Xl,onboardingWizardSteps:_l,onboardingWizardIndex:Hn,activeOnboardingStep:Xt,canGoToPreviousOnboardingStep:ei,canGoToNextOnboardingStep:ve,startupOnboardingVisible:Ke,startupOnboardingBlocking:zt,buildOnboardingCommandLine:yn,applyNextAppSettings:ti,applyRestartedOnboardingSettings:vn,refreshVisibleAppSettings:Cr,handleStartAppSettingsEdit:_n,handleCancelAppSettingsEdit:Tr,updateAppSettingsDraft:va,handleSaveAppSettings:Zu,moveOnboardingWizard:Do,handleRunOnboardingCommand:Kl,handleRestoreProject:ih,handleRestartOnboarding:Wu,handleAddSourceRootSuggestion:_o,handleSetSourceRootAt:as,handleAddSourceRootRow:Ju,handleRemoveSourceRootRow:ed,handleBrowseForSourceRoot:ni,handleSetOnboardingContextRoot:Nl,handleBrowseForOnboardingContextRoot:is,dismissStartupOnboarding:ss,handleOnboardingContinue:Ar,skipCurrentOnboardingStep:Er,handleCopyOnboardingCommand:Bo,handleLoadWorkspaceInventory:Io}=Gl,os=pz({activeView:h,scoutDesktop:e,voiceEnabled:yt.voice,relayState:St,messagesState:Je,interAgentAgents:Vt,interAgentThreads:Pt,sessions:me,appSettings:bn,setActiveView:y,applyRelayWorkspacePatch:gn}),{selectedConversationKind:Zl,setSelectedConversationKind:Jn,selectedConversationId:ka,setSelectedConversationId:Wl,selectedMessageThreadId:En,setSelectedMessageThreadId:Jl,selectedMessagesThread:li,selectedMessagesDetailAgentId:Po,messagesFeedback:cs,setMessagesFeedback:kn,mergedConversationMessages:ja,openConversation:jn,openDirectConversation:er}=os,{pairingState:Rr,pairingLoading:Mr,pairingError:Uo,setPairingError:us,pairingControlPending:ds,pairingConfigPending:Na,pairingApprovalPendingId:ri,pairingConfigFeedback:Ho,setPairingConfigFeedback:td,pendingApprovals:ai,commitPairingState:nd,refreshPairingState:fs,handlePairingControl:ld,handleUpdatePairingConfig:rd,handleDecidePairingApproval:ms}=GM({pairingEnabled:yt.pairing,scoutDesktop:e,setRelayFeedback:kn}),ad=DS(Rr,Mr,Uo),id=$M({activeView:h,scoutDesktop:e,sessions:me}),ii=VM({activeView:h,settingsSection:Le,scoutDesktop:e,surfaceCaps:Wt,pendingBrokerInspectorFocus:we,setPendingBrokerInspectorFocus:et,relayServiceInspectorRef:_e,loadShellState:Qt,setShellState:J,setShellError:ce,applyRestartedOnboardingSettings:vn,commitPairingState:nd,pairingState:Rr,setAppSettingsFeedback:Ht,setRelayFeedback:kn,setPairingError:us,setPairingConfigFeedback:td}),{isFeedbackDialogOpen:sd,feedbackBundle:od,feedbackBundleLoading:cd,feedbackBundleError:ud,feedbackDraft:ps,setFeedbackDraft:dd,feedbackSubmission:fd,feedbackActionPending:md,feedbackActionMessage:Fo,refreshLogs:pd,refreshBrokerInspector:hd,openFeedbackDialog:qo,handleFeedbackDialogOpenChange:xd,handleRefreshFeedbackBundle:gd,handleCopyFeedbackBundle:bd,handleSubmitFeedbackReport:yd,handleRepairSetup:vd}=ii,hs=FM({activeView:h,scoutDesktop:e,surfaceCaps:Wt,interAgentState:Yt,interAgentAgents:Vt,interAgentThreads:Pt,relayState:St,selectedMessagesThread:li,selectedMessagesDetailAgentId:Po,selectedRelayKind:Zl,selectedRelayId:ka,agentableProjects:ba,visibleAppSettings:Ft,isAppSettingsEditing:Ml,appSettingsDirty:ya,setAppSettings:Wa,setAppSettingsDraft:$l,setActiveView:y,setSettingsSection:Ue,setSettingsAgentId:tt,setShellState:J,setShellError:ce,setRelayFeedback:kn}),{selectedInterAgentId:pn,selectedInterAgentThreadId:zr,setSelectedInterAgentThreadId:xs,selectedInterAgent:Fn,visibleInterAgentThreads:gs,selectedInterAgentThread:el,handleSelectInterAgent:tr,deactivateAgentConfigEdit:wa,isCreateAgentDialogOpen:Or,setIsCreateAgentDialogOpen:kd,createAgentDraft:jd,setCreateAgentDraft:Nd,createAgentDefaults:Vo,createAgentSubmitting:Go,createAgentFeedback:Sa,setCreateAgentFeedback:Ca,handleOpenCreateAgentDialog:sh,handleBrowseCreateAgentProject:si,handleCreateAgent:$o,visibleAgentSession:Yo,agentSessionPending:bs,agentSessionLoading:ys,agentSessionFeedback:Qo,agentSessionCopied:Xo,isAgentSessionPeekOpen:Ko,closeAgentSessionPeek:wd,agentSessionPeekViewportRef:Sd,handlePeekAgentSessionScroll:Cd,handleOpenAgentSession:Td,handleCopyAgentSessionCommand:Ad,handlePeekAgentSession:qn,refreshAgentSession:Ta}=hs;A.useEffect(()=>{if(!(h!=="settings"||Le!=="agents")){if(!it){wa();return}pn!==it&&tr(it)}},[h,wa,tr,pn,it,Le]);const Bl=f==="relay"&&(h==="inbox"||h==="activity"||h==="machines"||h==="plans"||h==="sessions"||h==="search"||h==="inter-agent"||h==="agents"||h==="logs"||h==="settings"&&(Le==="agents"||Le==="communication"||Le==="database")),Zo=f==="relay"&&(h==="inbox"||h==="activity"||h==="messages"||h==="relay"||h==="agents"||h==="inter-agent"||h==="sessions"||h==="search");A.useEffect(()=>{if(bt.current||!e)return;bt.current=!0;const I=wz();I?.servicesState&&O(I.servicesState),I?.homeState&&(F(I.homeState),T(!1)),Me(),ze(!I?.homeState)},[ze,Me,e]),A.useEffect(()=>{if(!(zt||!V||P)){if(oe){Q(yu(oe));return}nt(!0)}},[nt,V,P,oe,zt]),A.useEffect(()=>{zt||!Bl||oe||Qt(!0)},[Qt,Bl,oe,zt]),A.useEffect(()=>{const I=Je?.threads??[];if(I.length===0){En!==null&&Jl(null);return}if(En&&I.some(be=>be.id===En))return;const W=I.find(be=>be.relayDestinationKind===Zl&&be.relayDestinationId===ka)??I.find(be=>be.interAgentThreadId===zr)??I[0];W&&W.id!==En&&Jl(W.id)},[Je,ka,Zl,zr,En,Jl]),A.useEffect(()=>{En&&(D(!0),X("overview"))},[En]),A.useEffect(()=>{if(h!=="settings"||!Ml)return;const I=Ce.current;if(!I)return;const W=window.requestAnimationFrame(()=>{I.focus(),I.select()});return()=>{window.cancelAnimationFrame(W)}},[h,Ml]);const vs=A.useMemo(()=>{const I=new Map;return me.forEach(W=>{const be=I.get(W.project);!be||new Date(W.lastModified)>new Date(be.lastModified)?I.set(W.project,{count:(be?.count||0)+1,lastModified:W.lastModified}):be&&I.set(W.project,{...be,count:be.count+1})}),Array.from(I.entries()).map(([W,be])=>({name:W,...be}))},[me]),Wo=A.useMemo(()=>{let I=me;if(j&&(I=I.filter(W=>W.project===j)),b){const W=b.toLowerCase();I=I.filter(be=>be.title.toLowerCase().includes(W)||be.preview.toLowerCase().includes(W)||be.tags?.some(At=>At.toLowerCase().includes(W))||be.agent.toLowerCase().includes(W)||be.project.toLowerCase().includes(W))}return I.sort((W,be)=>new Date(be.lastModified).getTime()-new Date(W.lastModified).getTime())},[me,b,j]),oi=A.useMemo(()=>({totalSessions:me.length,totalMessages:me.reduce((I,W)=>I+W.messageCount,0),totalTokens:me.reduce((I,W)=>I+(W.tokens||0),0),projects:vs.length}),[me,vs]),Ed=A.useMemo(()=>Array.from(new Set(me.map(I=>I.agent))).sort(),[me]),Lr=A.useMemo(()=>new Map(Vt.map(I=>[I.id,I])),[Vt]),ks=A.useMemo(()=>new Map((St?.directs??[]).map(I=>[I.id,I])),[St]),Aa=A.useMemo(()=>{if(!St||!el)return[];const I=new Set(el.messageIds);return St.messages.filter(W=>I.has(W.id))},[St,el]),js=A.useMemo(()=>{if(!Fn)return[];const I=new Set(gs.filter(W=>W.sourceKind==="private").flatMap(W=>W.messageIds));return ja.filter(W=>I.has(W.id)||W.authorId===Fn.id).slice(-60)},[ja,Fn,gs]),Jo=A.useMemo(()=>Fe?.tasks.filter(I=>I.targetAgentId===pn)??[],[Fe,pn]),wl=A.useMemo(()=>Fe?.findings.filter(I=>I.targetAgentId===pn||I.requesterId===pn)??[],[Fe,pn]),Dr=A.useMemo(()=>wl.filter(I=>I.requesterId===pn),[wl,pn]),Ns=el?ep(el,pn):Fn?`${Fn.title}'s agent threads`:"Inter-Agent",ec=el?tp(el,pn):Fn?.statusDetail??"Select an agent to inspect private threads between agents.",fl=A.useMemo(()=>{if(el){const I=Bp(el,pn);if(I.length===1)return Vt.find(W=>W.id===I[0]?.id)??Fn}return Fn},[el,pn,Vt,Fn]),tc=fl?fl.profileKind==="project"?"Configure":"Profile":null,nc=fl??Fn,Ea=z.useCallback((I,W)=>{if(!I)return null;const be=W?.compact?Ka(I)??I:I;return be.includes("/")||be.startsWith("~/")||be.startsWith(".openscout")?l.jsx("button",{type:"button",className:W?.className??"text-left underline underline-offset-2 decoration-dotted hover:opacity-80 transition-opacity",style:W?.style??{color:g.ink},onClick:xi=>{xi.preventDefault(),!(!Wt?.canRevealPath||!e?.revealPath)&&e.revealPath(I).catch(sc=>{Ht(lt(sc))})},title:"Open in Finder",children:be}):l.jsx(l.Fragment,{children:be})},[e,Wt]),Rd=A.useMemo(()=>[...me].sort((I,W)=>new Date(W.lastModified).getTime()-new Date(I.lastModified).getTime()).slice(0,5),[me]);A.useEffect(()=>{qe&&O(I=>{if(!I)return I;const W={...I,updatedAtLabel:qe.updatedAtLabel??I.updatedAtLabel,services:I.services.map(be=>be.id==="broker"?{...be,status:qe.brokerReachable?qe.brokerHealthy?"running":"degraded":"offline",statusLabel:qe.brokerReachable?qe.brokerHealthy?"Running":"Degraded":"Offline",healthy:qe.brokerHealthy,reachable:qe.brokerReachable,detail:qe.brokerLabel,updatedAtLabel:qe.updatedAtLabel??be.updatedAtLabel,url:qe.brokerUrl,nodeId:qe.nodeId}:be.id==="helper"?{...be,status:qe.helperRunning?"running":"offline",statusLabel:qe.helperRunning?"Running":"Offline",healthy:qe.helperRunning,reachable:qe.helperRunning,detail:qe.helperDetail,updatedAtLabel:qe.updatedAtLabel??be.updatedAtLabel}:be)};return se(B,W),W})},[B,se,qe]),A.useEffect(()=>{if(!St)return;const I={title:"Home",subtitle:`${St.directs.length} agents · ${St.messages.filter(W=>!W.isVoice).length} recent updates`,updatedAtLabel:St.lastUpdatedLabel??qe?.updatedAtLabel??null,agents:St.directs.slice(0,24).map(W=>({id:W.id,title:W.title,role:null,summary:W.preview,projectRoot:null,state:W.state,reachable:W.reachable,statusLabel:W.statusLabel,statusDetail:W.statusDetail,activeTask:W.activeTask,timestampLabel:W.timestampLabel})),activity:St.messages.filter(W=>!W.isVoice).sort((W,be)=>be.createdAt-W.createdAt).slice(0,24).map(W=>({id:W.id,kind:W.isSystem?"system":"message",actorId:W.authorId,actorName:W.authorName,title:W.authorName,detail:W.body,conversationId:W.conversationId,channel:W.normalizedChannel,timestamp:W.createdAt,timestampLabel:W.timestampLabel})),recentSessions:[...me].sort((W,be)=>new Date(be.lastModified).getTime()-new Date(W.lastModified).getTime()).slice(0,6)};F(I),se(I,Z)},[se,St,qe?.updatedAtLabel,Z,me]);const ci=B?.agents??[],Md=B?.activity??[],ui=A.useMemo(()=>[...Fe?.tasks??[]].sort((I,W)=>W.createdAt-I.createdAt).slice(0,18),[Fe]),lc=A.useMemo(()=>[...Fe?.findings??[]].slice(0,10),[Fe]),ws=A.useMemo(()=>(je?.machines??[]).flatMap(I=>I.endpoints.map(W=>({machineId:I.id,machineTitle:I.title,machineStatus:I.status,endpoint:W}))).sort((I,W)=>{const be=At=>{switch(At){case"running":return 0;case"waiting":return 1;case"idle":return 2;default:return 3}};return be(I.endpoint.state)-be(W.endpoint.state)||I.endpoint.agentName.localeCompare(W.endpoint.agentName)}).slice(0,14),[je]),tl=A.useMemo(()=>[...ja].filter(I=>!I.isVoice).slice(-18).reverse(),[ja]),Ra=A.useMemo(()=>(Fe?.tasks??[]).filter(I=>I.status==="failed").length,[Fe]),Rn=ai.length+Ra,_r=ui.find(I=>I.status==="running")??ui[0]??null,Mn=Z?.services.find(I=>I.id==="broker")??null,di=ci.filter(I=>I.reachable).length,fi=ci.length>0?ci.length:qe?.agentCount??0,ml=!zt&&ye&&!Z&&!B&&!xe,nr=ml?"Syncing…":Mn?.statusLabel??(qe?.brokerReachable?"Running":"Offline"),rc=ml?"Checking relay health.":Mn?.detail?`Relay diagnostics · ${Mn.detail}`:Mn?.reachable||qe?.brokerReachable?"Open Relay diagnostics":"Relay is offline. Open diagnostics.",mi=ml?"bg-sky-500 animate-pulse":Mn?.status==="running"||qe?.brokerReachable?"bg-emerald-500":Mn?.status==="degraded"?"bg-amber-500":"bg-slate-400",Br=ml?"Syncing":Mn?.healthy||qe?.brokerHealthy?"Healthy":Mn?.reachable||qe?.brokerReachable?"Reachable":"Offline",Ss=A.useMemo(()=>xe||St?.voice.captureState==="error"?"error":ml?null:Mn&&(!Mn.reachable||!Mn.healthy)||qe&&(!qe.brokerReachable||!qe.brokerHealthy)?"warning":null,[Mn,ml,St?.voice.captureState,qe,xe]),Bn=Ss==="error"?"Logs · attention required":Ss==="warning"?"Logs · check runtime warnings":"Logs",Cs=KS(new Date),Jt=[];yt.overview&&Jt.push({id:"overview",icon:l.jsx(Cp,{size:16,strokeWidth:1.5}),title:"Overview"}),yt.inbox&&Jt.push({id:"inbox",icon:l.jsx(kN,{size:16,strokeWidth:1.5}),title:"Inbox",badgeCount:Rn>0?Rn:void 0}),yt.relay&&Jt.push({id:"messages",icon:l.jsx(Al,{size:16,strokeWidth:1.5}),title:"Messages"}),yt.activity&&Jt.push({id:"activity",icon:l.jsx(Km,{size:16,strokeWidth:1.5}),title:"Activity Monitor"}),yt.machines&&Jt.push({id:"machines",icon:l.jsx(S1,{size:16,strokeWidth:1.5}),title:"Machines"}),yt.plans&&Jt.push({id:"plans",icon:l.jsx(Sp,{size:16,strokeWidth:1.5}),title:"Plans"}),yt.search&&Jt.push({id:"search",icon:l.jsx(wo,{size:16,strokeWidth:1.5}),title:"Search"});const Ts=new Set(Jt.map(I=>I.id).filter(I=>I!=="overview"));yt.logs&&Ts.add("logs");const pl=[{id:"profile",label:"General",description:"Local Scout defaults, CLI setup commands, and workspace scanning roots.",icon:l.jsx(da,{size:15})},{id:"agents",label:"Agents",description:"Select an agent, then edit its runtime, capabilities, and restart controls.",icon:l.jsx($i,{size:15})},{id:"workspaces",label:"Workspaces",description:"Workspace discovery, repo bindings, and harness readiness.",icon:l.jsx(da,{size:15})},{id:"communication",label:"Communication",description:"Broker, relay delivery, and live runtime status.",icon:l.jsx(Km,{size:15})}];yt.sessions&&pl.push({id:"database",label:"Database",description:"Session indexing and storage.",icon:l.jsx(IN,{size:15})}),yt.enableAll&&pl.push({id:"appearance",label:"Appearance",description:"Visual preferences and display options.",icon:l.jsx(h2,{size:15})});const lr=pl.find(I=>I.id===Le)??pl[0];A.useEffect(()=>{if(f!=="relay")return;new Set([...Jt.map(W=>W.id),...yt.relay?["relay","inter-agent","agents"]:[],...yt.sessions?["sessions"]:[],...yt.settings?["settings"]:[],...yt.logs?["logs"]:[]]).has(h)||y(yt.relay?"messages":"overview")},[h,yt.logs,yt.relay,yt.sessions,yt.settings,Jt,f]),A.useEffect(()=>{pl.some(I=>I.id===Le)||Ue("profile")},[Le,pl]);const Ir=z.useCallback((I,W)=>{I.preventDefault(),ge.current=W,document.addEventListener("mousemove",Pr),document.addEventListener("mouseup",Nn)},[]),ac=z.useCallback(I=>{Ir(I,"left-sidebar")},[Ir]),As=z.useCallback(I=>{Ir(I,"right-sidebar")},[Ir]),Pr=z.useCallback(I=>{if(ge.current==="left-sidebar"){const W=I.clientX-48;W>160&&W<400&&a(W);return}if(ge.current==="right-sidebar"){const W=window.innerWidth-I.clientX;W>280&&W<520&&o(W)}},[]),Nn=z.useCallback(()=>{ge.current=null,document.removeEventListener("mousemove",Pr),document.removeEventListener("mouseup",Nn)},[Pr]);A.useEffect(()=>()=>{document.removeEventListener("mousemove",Pr),document.removeEventListener("mouseup",Nn)},[Pr,Nn]);const rr=async()=>{Te(!0),kn("Refreshing…");try{if(f==="pairing"&&yt.pairing&&(e?.refreshPairingState||e?.getPairingState)){await fs()&&kn("Pairing refreshed.");return}if(h==="overview")await Promise.all([Me(),ze(!B)]);else if(Zo&&e?.refreshRelayShellPatch){const I=await e.refreshRelayShellPatch();gn(I),ce(null)}else if(V)await nt(!0);else if(Bl&&e?.refreshShellState){const I=await e.refreshShellState();J(I),ce(null)}else Bl&&await Qt(!0);(h==="settings"||h==="help")&&await Cr({preferInventory:h==="settings"&&Le==="workspaces"}),h==="settings"&&Le==="communication"&&await hd(),h==="logs"&&pd(),h==="agents"&&pn&&Ta(),kn("Refreshed.")}catch(I){kn(lt(I))}finally{Te(!1)}},Ur=z.useCallback(()=>{if(!(typeof window>"u")){if(He(!0),e?.reloadApp){e.reloadApp();return}window.location.reload()}},[e]),pi=z.useCallback(()=>{p("relay"),y("settings"),Ue("communication"),et(!0)},[]),Hr=z.useCallback(()=>{(async()=>{try{if(!Wt?.canQuitHost)return;e?.quitApp&&await e.quitApp()}catch(I){Ht(lt(I))}})()},[e,Wt]),wn=z.useCallback(I=>{tr(I),wa(),D(!0),X("overview"),jn("direct",I)},[wa,tr,jn]),Vn=async()=>{if(!e?.toggleVoiceCapture){ce("Desktop bridge is unavailable.");return}try{const I=await e.toggleVoiceCapture();J(I),Q(W=>W&&yu(I)),ce(null),kn(I.relay.voice.isCapturing?"Voice capture started.":"Voice capture stopped.")}catch(I){kn(lt(I))}},Sl=async I=>{if(!e?.setVoiceRepliesEnabled){ce("Desktop bridge is unavailable.");return}try{const W=await e.setVoiceRepliesEnabled(I);J(W),Q(be=>be&&yu(W)),ce(null),kn(I?"Playback enabled.":"Playback disabled.")}catch(W){kn(lt(W))}},hl=I=>{w(I),D(!0),X("history");const W=Je?.threads.find(be=>be.relayDestinationKind==="direct"&&be.relayDestinationId===I.project)??null;W&&hi(W),C(null),y("messages")},nl=A.useMemo(()=>(Fe?.tasks??[]).filter(I=>I.status==="failed").slice(0,10).map(I=>({id:`task-failed:${I.id}`,kind:"task",tone:"critical",title:I.title,summary:`${I.targetAgentName} reported a failed ask.`,detail:I.statusDetail??I.replyPreview??I.body,meta:[I.project,I.updatedAtLabel,I.ageLabel].filter(Boolean).join(" · ")||I.createdAtLabel,actionLabel:"Open Agent",onAction:()=>wn(I.targetAgentId)})),[wn,Fe]),xl=A.useMemo(()=>ai.map(I=>({id:`approval:${I.sessionId}:${I.turnId}:${I.blockId}`,kind:"approval",tone:I.risk==="high"?"critical":I.risk==="medium"?"warning":"info",title:I.title,summary:I.description,detail:I.detail,meta:`${I.sessionName} · ${I.risk} risk`,actionLabel:"Open Pairing",onAction:()=>{p("pairing")},onSecondaryAction:()=>{ms(I,"approve")},secondaryActionLabel:"Approve"})),[ms,ai]),ic=A.useMemo(()=>[...xl,...nl].sort((I,W)=>{const be=At=>At==="critical"?0:At==="warning"?1:2;return be(I.tone)-be(W.tone)||I.title.localeCompare(W.title)}),[xl,nl]),hi=z.useCallback(I=>{if(Jl(I.id),I.kind==="relay"&&I.relayDestinationKind&&I.relayDestinationId){Jn(I.relayDestinationKind),Wl(I.relayDestinationId);return}if(!I.interAgentThreadId)return;xs(I.interAgentThreadId);const be=(Pt.find(At=>At.id===I.interAgentThreadId)??null)?.participants.find(At=>Vt.some(xi=>xi.id===At.id))?.id??null;be&&(tr(be),xs(I.interAgentThreadId))},[tr,Vt,Pt,Wl,Jn,xs,Jl]),Es=I=>{const W=new Date(I);return`${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][W.getUTCMonth()]} ${W.getUTCDate()}`},vt={root:{backgroundColor:g.bg,color:g.ink},surface:{backgroundColor:g.surface},border:{borderColor:g.border},topBar:{backgroundColor:g.surface,borderBottomColor:g.border},navBar:{backgroundColor:g.bg,borderRightColor:g.border},sidebar:{backgroundColor:g.bg,borderRightColor:g.border},sectionLabel:{color:g.muted},inkText:{color:g.ink},mutedText:{color:g.muted},tagBadge:{backgroundColor:g.tagBg,borderColor:g.border,color:g.muted},activePill:{backgroundColor:g.accentBg,color:g.accent},activeItem:{backgroundColor:g.surface,borderColor:g.border,color:g.ink},kbd:{backgroundColor:g.surface,borderColor:g.border,color:g.ink},hoverBg:"hover:bg-[var(--os-hover)]",annotBadge:{backgroundColor:g.tagBg,borderColor:g.border,color:g.muted}},nn=(I,W,be)=>{const At=dl[I]??(zl?.command===I?zl:null);return l.jsx(WT,{command:I,commandLine:W,running:be,commandResult:At,visibleAppSettings:Ft,onboardingCopiedCommand:Ol,onboardingCommandPending:Wn,onboardingContextRoot:Ja,onCopyOnboardingCommand:Bo,onRunOnboardingCommand:Kl})},_t=QM({activeView:h,setActiveView:y,settingsSection:Le,setSettingsSection:Ue,settingsAgentId:it,setSettingsAgentId:tt,settingsSections:pl,activeSettingsMeta:lr,desktopFeatures:yt,stats:oi,runtime:qe,relayState:St,relayRuntimeBooting:ml,relayRuntimeHealthLabel:Br,reachableRelayAgentCount:di,dark:mt,setDark:ae,showAnnotations:Se,setShowAnnotations:Ze,isCollapsed:u,styles:{surface:vt.surface,inkText:vt.inkText,mutedText:vt.mutedText,tagBadge:vt.tagBadge,activePill:vt.activePill},scoutDesktop:e,surfaceCaps:Wt,interAgentAgents:Vt,openKnowledgeBase:We,openAgentProfile:wn,openDirectConversation:er,renderOnboardingCommandShell:nn,renderLocalPathValue:Ea,settingsOperatorNameRef:Ce,relayServiceInspectorRef:_e,handleSetVoiceRepliesEnabled:Sl,settingsController:Gl,diagnosticsController:ii,agentController:hs}),ft=YM({activeView:h,setActiveView:y,desktopFeatures:yt,styles:{sidebar:vt.sidebar,surface:vt.surface,inkText:vt.inkText,mutedText:vt.mutedText,tagBadge:vt.tagBadge,activePill:vt.activePill,activeItem:vt.activeItem,annotBadge:vt.annotBadge,kbd:vt.kbd},colorTheme:g,sidebarWidth:r,messagesDetailWidth:i,isCollapsed:u,onResizeStart:ac,onMessagesDetailResizeStart:As,stats:oi,runtime:qe,shellState:oe,shellError:xe,plansState:Fe,machinesState:je,messagesState:Je,interAgentState:Yt,interAgentAgents:Vt,interAgentAgentLookup:Lr,relayDirectLookup:ks,homeAgents:ci,homeActivity:Md,activityRecentMessages:tl,activityTasks:ui,activityLeadTask:_r,activityFindings:lc,activityEndpoints:ws,overviewSessions:Rd,inboxAlertCount:Rn,pendingApprovalsCount:ai.length,inboxFailedTaskCount:Ra,inboxAwaitingYouItems:ic,availableAgentNames:Ed,searchQuery:b,setSearchQuery:v,filteredSessions:Wo,selectedSession:E,setSelectedSession:w,isLoadingMessagesWorkspace:_,isLoadingShell:R,showAnnotations:Se,setShowAnnotations:Ze,messagesDetailOpen:M,setMessagesDetailOpen:D,messagesDetailTab:H,setMessagesDetailTab:X,formatDate:Es,onRefreshShell:()=>{rr()},openAgentProfile:wn,openSessionDetail:hl,handleSelectSearchSession:I=>{w(I),y("sessions")},handleToggleVoiceCapture:()=>{Vn()},handleSetVoiceRepliesEnabled:I=>{Sl(I)},selectMessageThread:hi,renderLocalPathValue:Ea,selectedInterAgentActivityMessages:js,selectedInterAgentInboundTasks:Jo,selectedInterAgentOutboundFindings:Dr,selectedInterAgentFindings:wl,interAgentThreadTitle:Ns,selectedInterAgentThreadSubtitle:ec,interAgentConfigureTarget:fl,interAgentConfigureLabel:tc,interAgentMessageTarget:nc,visibleInterAgentMessages:Aa,relayVoiceState:St?.voice,messagesController:os,agentController:hs,diagnosticsController:ii,phonePreparationController:id,overviewBootLoader:!zt&&ye&&!B&&!xe?l.jsx(e1,{dark:mt,C:g,s:vt}):null});return zt?l.jsx("div",{className:`min-h-screen w-full font-sans${mt?" dark":""}`,style:{backgroundColor:g.bg,color:g.ink},children:l.jsxs("div",{className:"relative min-h-screen flex items-center justify-center px-6 py-10",children:[l.jsx("div",{className:"absolute top-6 left-6 z-10",children:l.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 rounded-full border px-3 py-1.5 text-[12px] transition-opacity hover:opacity-80",style:{borderColor:g.border,color:g.muted},onClick:Hr,children:[l.jsx(kl,{size:12}),"Quit"]})}),Ke&&Ft?l.jsx("div",{className:"w-full max-w-[820px] os-scale-in",children:l.jsxs("div",{className:"rounded-2xl border overflow-hidden",style:{borderColor:g.border,backgroundColor:g.surface,boxShadow:`0 24px 80px ${mt?"rgba(0,0,0,0.4)":"rgba(15,23,42,0.08)"}`},children:[l.jsxs("div",{className:"px-8 pt-8 pb-6 border-b cursor-grab active:cursor-grabbing",style:{borderBottomColor:g.border,WebkitAppRegion:"drag"},children:[l.jsxs("div",{className:"flex items-center justify-between gap-4",children:[l.jsx("div",{className:"text-[11px] font-mono uppercase tracking-[0.22em]",style:vt.mutedText,children:"Scout Setup"}),l.jsx("button",{className:"text-[12px] transition-opacity hover:opacity-70",style:{...vt.mutedText,WebkitAppRegion:"no-drag"},onClick:ss,children:"Skip onboarding"})]}),l.jsx("div",{className:"flex items-center gap-1.5 mt-6",children:_l.map((I,W)=>{const be=W<Hn,At=W===Hn;return l.jsx("div",{className:"h-1 flex-1 rounded-full transition-all duration-300",style:{backgroundColor:be||At?g.accent:mt?"rgba(255,255,255,0.06)":"rgba(15,23,42,0.06)",opacity:At?.6:1}},I.id)})}),l.jsxs("div",{className:"flex items-center gap-2 mt-4",children:[l.jsxs("span",{className:"text-[10px] font-mono px-2 py-0.5 rounded-full",style:{backgroundColor:g.accentBg,color:g.accent},children:[Xt.number,"/",_l.length]}),l.jsx("span",{className:"text-[12px] font-medium",style:vt.mutedText,children:Xt.title})]})]}),l.jsxs("div",{className:"px-8 py-8 os-fade-up",children:[l.jsx(JT,{activeOnboardingStep:Xt,visibleAppSettings:Ft,appSettingsSaving:$t,appSettingsLoading:ga,appSettingsDirty:ya,onboardingCommandPending:Wn,onboardingHasProjectConfig:rs,sourceRootPathSuggestions:xa,settingsOperatorNameRef:Ce,setAppSettingsDraft:$l,setAppSettingsFeedback:Ht,setIsAppSettingsEditing:Ll,handleAddSourceRootRow:Ju,handleSetSourceRootAt:as,handleBrowseForSourceRoot:ni,handleRemoveSourceRootRow:ed,handleSetOnboardingContextRoot:Nl,handleBrowseForOnboardingContextRoot:is,handleAddSourceRootSuggestion:_o,handleRunOnboardingCommand:Kl,buildOnboardingCommandLine:yn,renderOnboardingCommandShell:nn,renderLocalPathValue:Ea,styles:{inkText:vt.inkText,mutedText:vt.mutedText,activePill:vt.activePill,tagBadge:vt.tagBadge},availableHarnesses:r1}),dn?l.jsx("div",{className:"text-[13px] mt-6 leading-[1.6] os-fade-in",style:vt.inkText,children:dn}):null]},Xt.id),l.jsxs("div",{className:"px-8 py-5 border-t flex items-center justify-between gap-4",style:{borderTopColor:g.border,backgroundColor:g.bg},children:[l.jsx("button",{className:"os-btn flex items-center gap-1 text-[12px] font-medium px-4 py-2.5 rounded-lg border disabled:opacity-40 transition-all",style:{color:g.muted,borderColor:g.border,backgroundColor:"transparent"},onClick:()=>Do(-1),disabled:!ei,children:"Back"}),l.jsxs("div",{className:"text-[11px] font-mono text-center",style:vt.mutedText,children:[Xt.number," of ",_l.length]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("button",{className:"os-btn flex items-center gap-1 text-[12px] font-medium px-4 py-2.5 rounded-lg transition-all",style:{color:g.muted},onClick:Er,children:ve?"Skip step":"Finish later"}),l.jsxs("button",{className:"os-btn-primary flex items-center gap-1 text-[12px] font-semibold px-5 py-2.5 rounded-lg disabled:opacity-40 transition-all",style:{backgroundColor:g.accent,color:"#fff"},onClick:Ar,disabled:!ve||$t||ga,children:[Xt.id==="confirm"?$t?"Confirming…":"Confirm":"Continue",Xt.id==="confirm"?null:l.jsx(ql,{size:12})]})]})]})]})}):l.jsx(e1,{dark:mt,C:g,s:vt})]})}):l.jsxs(l.Fragment,{children:[l.jsx(zT,{dark:mt,setDark:ae,C:g,s:vt,productSurface:f,setProductSurface:p,activeView:h,setActiveView:y,desktopFeatures:yt,pairingSurfaceBadge:ad,openRelayDiagnostics:pi,relayStatusTitle:rc,relayRuntimeBooting:ml,relayStatusDotClassName:mi,relayStatusLabel:nr,runtime:qe,headerAgentCount:fi,appReloadPending:Ne,handleReloadApp:Ur,handleQuitApp:Hr,navViews:Jt,collapsibleViews:Ts,isCollapsed:u,setIsCollapsed:d,pairingSurfaceProps:{pairingControlPending:ds,pairingConfigFeedback:Ho,pairingConfigPending:Na,pairingError:Uo,pairingLoading:Mr,pairingState:Rr,onControlPairing:ld,onDecideApproval:ms,onOpenFullLogs:()=>{p("relay"),y("logs")},onOpenFeedback:qo,pairingApprovalPendingId:ri,onUpdateConfig:rd,onRefresh:()=>{rr()},onRevealPath:I=>{Wt?.canRevealPath&&e?.revealPath?.(I)}},isAgentSessionPeekOpen:Ko,selectedInterAgent:Fn,visibleAgentSession:Yo,agentSessionPending:bs,agentSessionLoading:ys,agentSessionFeedback:Qo,agentSessionCopied:Xo,agentSessionPeekViewportRef:Sd,handlePeekAgentSessionScroll:Cd,closeAgentSessionPeek:wd,handleCopyAgentSessionCommand:()=>{Ad()},handleOpenAgentSession:()=>{Td()},renderLocalPathValue:Ea,isCreateAgentDialogOpen:Or,setIsCreateAgentDialogOpen:kd,agentableProjects:ba,createAgentDraft:jd,setCreateAgentDraft:Nd,createAgentDefaults:Vo,createAgentSubmitting:Go,createAgentFeedback:Sa,setCreateAgentFeedback:Ca,handleBrowseCreateAgentProject:si,handleCreateAgent:$o,availableAgentHarnesses:r1,isFeedbackDialogOpen:sd,handleFeedbackDialogOpenChange:xd,feedbackDraft:ps,setFeedbackDraft:dd,feedbackSubmission:fd,feedbackActionPending:md,feedbackBundleLoading:cd,feedbackBundle:od,feedbackBundleError:ud,feedbackActionMessage:Fo,handleSubmitFeedbackReport:()=>{yd()},handleRefreshFeedbackBundle:()=>{gd()},handleRepairSetup:()=>{vd()},handleCopyFeedbackBundle:()=>{bd()},openFeedbackDialog:qo,openKnowledgeBase:We,logsAttentionLevel:Ss,logsButtonTitle:Bn,footerTimeLabel:Cs,children:f==="relay"?l.jsxs(l.Fragment,{children:[l.jsx(DT,{...ft.overviewInboxActivityViewProps}),l.jsx(qT,{...ft.opsViewsProps}),l.jsx(ZT,{..._t}),l.jsx(MM,{...ft.agentViewsProps}),l.jsx(mz,{...ft.messagesRelayViewProps})]}):null}),l.jsx("div",{className:"pointer-events-none fixed right-4 top-20 z-40",children:l.jsxs("div",{className:"w-[220px] rounded-2xl border px-4 py-3 shadow-[0_18px_48px_rgba(15,23,42,0.12)]",style:{backgroundColor:mt?"rgba(17, 24, 39, 0.9)":"rgba(255,255,255,0.92)",borderColor:g.border,backdropFilter:"blur(10px)"},children:[l.jsxs("div",{className:"flex items-center justify-between gap-3",children:[l.jsx("div",{className:"text-[10px] font-mono uppercase tracking-[0.16em]",style:vt.mutedText,children:"Dev Load Times"}),l.jsx("div",{className:"text-[10px]",style:vt.mutedText,children:"live"})]}),l.jsx("div",{className:"mt-3 space-y-2",children:[{key:"services",title:"Relay health",metric:ee.services,loading:Y,idleLabel:"—",idleDetail:"No measurement yet"},{key:"home",title:"Home data",metric:ee.home,loading:ye,idleLabel:"—",idleDetail:"No measurement yet"},{key:"workspace",title:"Workspace",metric:ee.workspace,loading:V?_:Bl&&R,idleLabel:V||Bl?"—":"deferred",idleDetail:V||Bl?"No measurement yet":"Loads only on workspace-heavy surfaces"}].map(I=>l.jsxs("div",{className:"rounded-xl border px-3 py-2",style:{borderColor:g.border,backgroundColor:mt?"rgba(255,255,255,0.03)":"rgba(15,23,42,0.025)"},children:[l.jsxs("div",{className:"flex items-center justify-between gap-3",children:[l.jsx("div",{className:"text-[11px] font-medium",style:vt.inkText,children:I.title}),l.jsx("div",{className:"text-[11px] font-mono",style:I.loading?{color:g.accent}:vt.inkText,children:I.loading?"loading…":I.metric?`${I.metric.durationMs}ms`:I.idleLabel})]}),l.jsx("div",{className:"mt-1 text-[10px] leading-[1.5]",style:vt.mutedText,children:I.metric?`${I.metric.label} · ${new Date(I.metric.recordedAt).toLocaleTimeString([],{hour:"numeric",minute:"2-digit",second:"2-digit"})}`:I.idleDetail}),I.metric?.detail?l.jsx("div",{className:"mt-2 space-y-1",children:Object.entries(I.metric.detail).slice(0,8).map(([W,be])=>l.jsxs("div",{className:"flex items-center justify-between gap-3 text-[10px]",style:vt.mutedText,children:[l.jsx("span",{className:"truncate",children:W}),l.jsx("span",{className:"font-mono shrink-0",style:vt.inkText,children:String(be)})]},W))}):null]},I.key))})]})})]})}const gp=document.getElementById("root");if(!gp)throw new Error("Root element was not found.");const a1=l.jsx(A.StrictMode,{children:l.jsx(uN,{children:l.jsx(Tz,{})})}),Az=typeof window<"u"&&Object.prototype.hasOwnProperty.call(window,"__INITIAL_STATE__");Az?fb.hydrateRoot(gp,a1):fb.createRoot(gp).render(a1);
|