@abstractframework/continuum 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/README.md +38 -17
  2. package/bin/cli.js +157 -32
  3. package/bin/hub_proxy.js +37 -17
  4. package/bin/settings.js +511 -0
  5. package/dist/assets/{abnfDiagram-VRR7QNED-DHZzhKO_.js → abnfDiagram-VRR7QNED-DkP5u0Ku.js} +2 -2
  6. package/dist/assets/{arc-9iPl5OLd.js → arc-vxPq5BjA.js} +2 -2
  7. package/dist/assets/{architectureDiagram-ZJ3FMSHR-BVRc0NRl.js → architectureDiagram-ZJ3FMSHR-ku0NT7zM.js} +2 -2
  8. package/dist/assets/{blockDiagram-677ZJIJ3-BTIe50OR.js → blockDiagram-677ZJIJ3-DXQQcNdo.js} +2 -2
  9. package/dist/assets/{c4Diagram-LMCZKHZV-D5P-4VLr.js → c4Diagram-LMCZKHZV-DuZ33cED.js} +2 -2
  10. package/dist/assets/channel-tvH0KUyT.js +2 -0
  11. package/dist/assets/{chunk-2Q5K7J3B-WcmxYPWP.js → chunk-2Q5K7J3B-BGWsS7uu.js} +2 -2
  12. package/dist/assets/{chunk-32BRIVSS-BPArWk_S.js → chunk-32BRIVSS-BgokockY.js} +2 -2
  13. package/dist/assets/{chunk-5VM5RSS4-DplW9bbf.js → chunk-5VM5RSS4-OLY5jTMg.js} +2 -2
  14. package/dist/assets/{chunk-EX3LRPZG-B8O0P99j.js → chunk-EX3LRPZG-BWHQVZSz.js} +2 -2
  15. package/dist/assets/{chunk-JWPE2WC7-DZoiE5m4.js → chunk-JWPE2WC7-CuM7Hcrw.js} +2 -2
  16. package/dist/assets/{chunk-MOJQB5TN-FqMZZAe1.js → chunk-MOJQB5TN-DI56DwNK.js} +2 -2
  17. package/dist/assets/{chunk-RYQCIY6F-D4I_kub_.js → chunk-RYQCIY6F-phvbPmeC.js} +2 -2
  18. package/dist/assets/{chunk-V7JOEXUC-CwJZa6s3.js → chunk-V7JOEXUC-Cv7eW1t4.js} +2 -2
  19. package/dist/assets/{chunk-VR4S4FIN-CdF7hCRc.js → chunk-VR4S4FIN-D8k2SzA3.js} +2 -2
  20. package/dist/assets/{chunk-XXDRQBXY-C2vm2DXm.js → chunk-XXDRQBXY-DZy8Plz8.js} +2 -2
  21. package/dist/assets/classDiagram-OUVF2IWQ-C0x6Ou39.js +2 -0
  22. package/dist/assets/classDiagram-v2-EOCWNBFH-C0x6Ou39.js +2 -0
  23. package/dist/assets/{cose-bilkent-JH36ORCC-BEoqSVoj.js → cose-bilkent-JH36ORCC-CiwWaVUb.js} +2 -2
  24. package/dist/assets/{cynefin-VYW2F7L2-DzsDaKjB.js → cynefin-VYW2F7L2-Cz79Fwdx.js} +2 -2
  25. package/dist/assets/{cynefinDiagram-TSTJHNR4-qVt2ETEm.js → cynefinDiagram-TSTJHNR4-DYlkii-x.js} +2 -2
  26. package/dist/assets/{dagre-VKFMJZFB-BszpuHqM.js → dagre-VKFMJZFB-Cumo7o1R.js} +2 -2
  27. package/dist/assets/{diagram-FQU43EPY-DkSwN897.js → diagram-FQU43EPY-Dorm69_e.js} +2 -2
  28. package/dist/assets/{diagram-G47NLZAW-DmmkniMR.js → diagram-G47NLZAW-Bhtzc4JU.js} +2 -2
  29. package/dist/assets/{diagram-NH7WQ7WH-PkbaZ3fb.js → diagram-NH7WQ7WH-DJF-iHCK.js} +2 -2
  30. package/dist/assets/{diagram-OA4YK3LP-D5O-VGkx.js → diagram-OA4YK3LP-8mQ4915-.js} +2 -2
  31. package/dist/assets/{diagram-WEI45ONY-CtS1f8zZ.js → diagram-WEI45ONY-C4Bv6dbm.js} +2 -2
  32. package/dist/assets/{ebnfDiagram-CCIWWBDH-2ydDo0Sq.js → ebnfDiagram-CCIWWBDH-DzagnQVX.js} +2 -2
  33. package/dist/assets/{erDiagram-Q63AITRT-Dc-2Dmcc.js → erDiagram-Q63AITRT-BbkYElA6.js} +2 -2
  34. package/dist/assets/{flowDiagram-23GEKE2U-DKKOHSrp.js → flowDiagram-23GEKE2U-OcR4vkjk.js} +2 -2
  35. package/dist/assets/{ganttDiagram-NO4QXBWP-B9Zi-Zd_.js → ganttDiagram-NO4QXBWP-DyAPiIdB.js} +2 -2
  36. package/dist/assets/{gitGraphDiagram-IHSO6WYX-lXzgHn-s.js → gitGraphDiagram-IHSO6WYX-pymEefZi.js} +2 -2
  37. package/dist/assets/index-D0YdqMpf.css +1 -0
  38. package/dist/assets/index-DTn9k-3t.js +123 -0
  39. package/dist/assets/{infoDiagram-FWYZ7A6U-BHV_H3bL.js → infoDiagram-FWYZ7A6U-Dh41Som-.js} +2 -2
  40. package/dist/assets/{ishikawaDiagram-FXEZZL3T-BX74rKth.js → ishikawaDiagram-FXEZZL3T-Xc9vuvPV.js} +2 -2
  41. package/dist/assets/{journeyDiagram-5HDEW3XC-BByysGFJ.js → journeyDiagram-5HDEW3XC-bJ0gK8bC.js} +2 -2
  42. package/dist/assets/{kanban-definition-HUTT4EX6-DatfLmCp.js → kanban-definition-HUTT4EX6-Cu1Zn3KW.js} +2 -2
  43. package/dist/assets/{linear-BgTPNh4i.js → linear-DrGsraGo.js} +2 -2
  44. package/dist/assets/{mermaid.core-CrABX5SH.js → mermaid.core-CkQqPHPZ.js} +5 -5
  45. package/dist/assets/{mindmap-definition-LN4V7U3C-Bz1XgdXA.js → mindmap-definition-LN4V7U3C-ZCEP6XWH.js} +2 -2
  46. package/dist/assets/{pegDiagram-2B236MQR-D5B8Egll.js → pegDiagram-2B236MQR-DjDrn07n.js} +2 -2
  47. package/dist/assets/{pieDiagram-ENE6RG2P-BaDg4f41.js → pieDiagram-ENE6RG2P-oD3ciEy7.js} +2 -2
  48. package/dist/assets/{quadrantDiagram-ABIIQ3AL-jr1V5VXJ.js → quadrantDiagram-ABIIQ3AL-CYbDYNM7.js} +2 -2
  49. package/dist/assets/{railroadDiagram-RFXS5EU6-F13Ho8ra.js → railroadDiagram-RFXS5EU6-DMcO7O0d.js} +2 -2
  50. package/dist/assets/{requirementDiagram-TGXJPOKE-DXb_w8Ww.js → requirementDiagram-TGXJPOKE-DeeSIVn-.js} +2 -2
  51. package/dist/assets/{sankeyDiagram-HTMAVEWB-BN42kL5b.js → sankeyDiagram-HTMAVEWB-C43xzNvP.js} +2 -2
  52. package/dist/assets/{sequenceDiagram-DBY2YBRQ-DI7-dEyi.js → sequenceDiagram-DBY2YBRQ-d3lj6z8y.js} +2 -2
  53. package/dist/assets/{sizeCapture-X5ZJPWSS-Dv-15ctr.js → sizeCapture-X5ZJPWSS-D4UyeLsX.js} +2 -2
  54. package/dist/assets/{stateDiagram-2N3HPSRC-De5ObM42.js → stateDiagram-2N3HPSRC-Cq4YMMP1.js} +2 -2
  55. package/dist/assets/stateDiagram-v2-6OUMAXLB-DMVYrQgX.js +2 -0
  56. package/dist/assets/{swimlanes-5IMT3BWC-DzZwgXNi.js → swimlanes-5IMT3BWC-CRbkVLoI.js} +3 -3
  57. package/dist/assets/swimlanesDiagram-G3AALYLV-Bzg2g7oq.js +9 -0
  58. package/dist/assets/{timeline-definition-FHXFAJF6-BO8KkL_w.js → timeline-definition-FHXFAJF6-BN8oLdvs.js} +2 -2
  59. package/dist/assets/{vennDiagram-L72KCM5P-D6LUv_CX.js → vennDiagram-L72KCM5P-BqAHS4HE.js} +2 -2
  60. package/dist/assets/{wardleyDiagram-EHGQE667-DWJp0Lmi.js → wardleyDiagram-EHGQE667-D2aA14yL.js} +2 -2
  61. package/dist/assets/{xychartDiagram-FW5EYKEG-B5IA4jNf.js → xychartDiagram-FW5EYKEG-BkrnnKWS.js} +2 -2
  62. package/dist/index.html +2 -2
  63. package/package.json +2 -2
  64. package/dist/assets/channel-CEGeSBNz.js +0 -2
  65. package/dist/assets/classDiagram-OUVF2IWQ-D11Ru5dS.js +0 -2
  66. package/dist/assets/classDiagram-v2-EOCWNBFH-D11Ru5dS.js +0 -2
  67. package/dist/assets/index-CCcufdYK.css +0 -1
  68. package/dist/assets/index-DmnZnFTc.js +0 -124
  69. package/dist/assets/stateDiagram-v2-6OUMAXLB-D9AwhP3S.js +0 -2
  70. package/dist/assets/swimlanesDiagram-G3AALYLV-DyzT80_E.js +0 -9
@@ -1,124 +0,0 @@
1
- var lp=Object.defineProperty;var op=(a,s,r)=>s in a?lp(a,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[s]=r;var kr=(a,s,r)=>op(a,typeof s!="symbol"?s+"":s,r);(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))l(c);new MutationObserver(c=>{for(const f of c)if(f.type==="childList")for(const m of f.addedNodes)m.tagName==="LINK"&&m.rel==="modulepreload"&&l(m)}).observe(document,{childList:!0,subtree:!0});function r(c){const f={};return c.integrity&&(f.integrity=c.integrity),c.referrerPolicy&&(f.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?f.credentials="include":c.crossOrigin==="anonymous"?f.credentials="omit":f.credentials="same-origin",f}function l(c){if(c.ep)return;c.ep=!0;const f=r(c);fetch(c.href,f)}})();function cp(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var fu={exports:{}},fl={},hu={exports:{}},mt={};/**
2
- * @license React
3
- * react.production.min.js
4
- *
5
- * Copyright (c) Facebook, Inc. and its affiliates.
6
- *
7
- * This source code is licensed under the MIT license found in the
8
- * LICENSE file in the root directory of this source tree.
9
- */var Fm;function up(){if(Fm)return mt;Fm=1;var a=Symbol.for("react.element"),s=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),l=Symbol.for("react.strict_mode"),c=Symbol.for("react.profiler"),f=Symbol.for("react.provider"),m=Symbol.for("react.context"),p=Symbol.for("react.forward_ref"),_=Symbol.for("react.suspense"),y=Symbol.for("react.memo"),w=Symbol.for("react.lazy"),x=Symbol.iterator;function N(S){return S===null||typeof S!="object"?null:(S=x&&S[x]||S["@@iterator"],typeof S=="function"?S:null)}var $={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},P=Object.assign,T={};function F(S,A,U){this.props=S,this.context=A,this.refs=T,this.updater=U||$}F.prototype.isReactComponent={},F.prototype.setState=function(S,A){if(typeof S!="object"&&typeof S!="function"&&S!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,S,A,"setState")},F.prototype.forceUpdate=function(S){this.updater.enqueueForceUpdate(this,S,"forceUpdate")};function D(){}D.prototype=F.prototype;function J(S,A,U){this.props=S,this.context=A,this.refs=T,this.updater=U||$}var B=J.prototype=new D;B.constructor=J,P(B,F.prototype),B.isPureReactComponent=!0;var ee=Array.isArray,C=Object.prototype.hasOwnProperty,Z={current:null},ae={key:!0,ref:!0,__self:!0,__source:!0};function fe(S,A,U){var ie,de={},L=null,ke=null;if(A!=null)for(ie in A.ref!==void 0&&(ke=A.ref),A.key!==void 0&&(L=""+A.key),A)C.call(A,ie)&&!ae.hasOwnProperty(ie)&&(de[ie]=A[ie]);var be=arguments.length-2;if(be===1)de.children=U;else if(1<be){for(var Ie=Array(be),Fe=0;Fe<be;Fe++)Ie[Fe]=arguments[Fe+2];de.children=Ie}if(S&&S.defaultProps)for(ie in be=S.defaultProps,be)de[ie]===void 0&&(de[ie]=be[ie]);return{$$typeof:a,type:S,key:L,ref:ke,props:de,_owner:Z.current}}function ge(S,A){return{$$typeof:a,type:S.type,key:A,ref:S.ref,props:S.props,_owner:S._owner}}function Te(S){return typeof S=="object"&&S!==null&&S.$$typeof===a}function Se(S){var A={"=":"=0",":":"=2"};return"$"+S.replace(/[=:]/g,function(U){return A[U]})}var K=/\/+/g;function te(S,A){return typeof S=="object"&&S!==null&&S.key!=null?Se(""+S.key):A.toString(36)}function z(S,A,U,ie,de){var L=typeof S;(L==="undefined"||L==="boolean")&&(S=null);var ke=!1;if(S===null)ke=!0;else switch(L){case"string":case"number":ke=!0;break;case"object":switch(S.$$typeof){case a:case s:ke=!0}}if(ke)return ke=S,de=de(ke),S=ie===""?"."+te(ke,0):ie,ee(de)?(U="",S!=null&&(U=S.replace(K,"$&/")+"/"),z(de,A,U,"",function(Fe){return Fe})):de!=null&&(Te(de)&&(de=ge(de,U+(!de.key||ke&&ke.key===de.key?"":(""+de.key).replace(K,"$&/")+"/")+S)),A.push(de)),1;if(ke=0,ie=ie===""?".":ie+":",ee(S))for(var be=0;be<S.length;be++){L=S[be];var Ie=ie+te(L,be);ke+=z(L,A,U,Ie,de)}else if(Ie=N(S),typeof Ie=="function")for(S=Ie.call(S),be=0;!(L=S.next()).done;)L=L.value,Ie=ie+te(L,be++),ke+=z(L,A,U,Ie,de);else if(L==="object")throw A=String(S),Error("Objects are not valid as a React child (found: "+(A==="[object Object]"?"object with keys {"+Object.keys(S).join(", ")+"}":A)+"). If you meant to render a collection of children, use an array instead.");return ke}function V(S,A,U){if(S==null)return S;var ie=[],de=0;return z(S,ie,"","",function(L){return A.call(U,L,de++)}),ie}function H(S){if(S._status===-1){var A=S._result;A=A(),A.then(function(U){(S._status===0||S._status===-1)&&(S._status=1,S._result=U)},function(U){(S._status===0||S._status===-1)&&(S._status=2,S._result=U)}),S._status===-1&&(S._status=0,S._result=A)}if(S._status===1)return S._result.default;throw S._result}var ce={current:null},I={transition:null},_e={ReactCurrentDispatcher:ce,ReactCurrentBatchConfig:I,ReactCurrentOwner:Z};function Y(){throw Error("act(...) is not supported in production builds of React.")}return mt.Children={map:V,forEach:function(S,A,U){V(S,function(){A.apply(this,arguments)},U)},count:function(S){var A=0;return V(S,function(){A++}),A},toArray:function(S){return V(S,function(A){return A})||[]},only:function(S){if(!Te(S))throw Error("React.Children.only expected to receive a single React element child.");return S}},mt.Component=F,mt.Fragment=r,mt.Profiler=c,mt.PureComponent=J,mt.StrictMode=l,mt.Suspense=_,mt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=_e,mt.act=Y,mt.cloneElement=function(S,A,U){if(S==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+S+".");var ie=P({},S.props),de=S.key,L=S.ref,ke=S._owner;if(A!=null){if(A.ref!==void 0&&(L=A.ref,ke=Z.current),A.key!==void 0&&(de=""+A.key),S.type&&S.type.defaultProps)var be=S.type.defaultProps;for(Ie in A)C.call(A,Ie)&&!ae.hasOwnProperty(Ie)&&(ie[Ie]=A[Ie]===void 0&&be!==void 0?be[Ie]:A[Ie])}var Ie=arguments.length-2;if(Ie===1)ie.children=U;else if(1<Ie){be=Array(Ie);for(var Fe=0;Fe<Ie;Fe++)be[Fe]=arguments[Fe+2];ie.children=be}return{$$typeof:a,type:S.type,key:de,ref:L,props:ie,_owner:ke}},mt.createContext=function(S){return S={$$typeof:m,_currentValue:S,_currentValue2:S,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},S.Provider={$$typeof:f,_context:S},S.Consumer=S},mt.createElement=fe,mt.createFactory=function(S){var A=fe.bind(null,S);return A.type=S,A},mt.createRef=function(){return{current:null}},mt.forwardRef=function(S){return{$$typeof:p,render:S}},mt.isValidElement=Te,mt.lazy=function(S){return{$$typeof:w,_payload:{_status:-1,_result:S},_init:H}},mt.memo=function(S,A){return{$$typeof:y,type:S,compare:A===void 0?null:A}},mt.startTransition=function(S){var A=I.transition;I.transition={};try{S()}finally{I.transition=A}},mt.unstable_act=Y,mt.useCallback=function(S,A){return ce.current.useCallback(S,A)},mt.useContext=function(S){return ce.current.useContext(S)},mt.useDebugValue=function(){},mt.useDeferredValue=function(S){return ce.current.useDeferredValue(S)},mt.useEffect=function(S,A){return ce.current.useEffect(S,A)},mt.useId=function(){return ce.current.useId()},mt.useImperativeHandle=function(S,A,U){return ce.current.useImperativeHandle(S,A,U)},mt.useInsertionEffect=function(S,A){return ce.current.useInsertionEffect(S,A)},mt.useLayoutEffect=function(S,A){return ce.current.useLayoutEffect(S,A)},mt.useMemo=function(S,A){return ce.current.useMemo(S,A)},mt.useReducer=function(S,A,U){return ce.current.useReducer(S,A,U)},mt.useRef=function(S){return ce.current.useRef(S)},mt.useState=function(S){return ce.current.useState(S)},mt.useSyncExternalStore=function(S,A,U){return ce.current.useSyncExternalStore(S,A,U)},mt.useTransition=function(){return ce.current.useTransition()},mt.version="18.3.1",mt}var qm;function td(){return qm||(qm=1,hu.exports=up()),hu.exports}/**
10
- * @license React
11
- * react-jsx-runtime.production.min.js
12
- *
13
- * Copyright (c) Facebook, Inc. and its affiliates.
14
- *
15
- * This source code is licensed under the MIT license found in the
16
- * LICENSE file in the root directory of this source tree.
17
- */var Bm;function dp(){if(Bm)return fl;Bm=1;var a=td(),s=Symbol.for("react.element"),r=Symbol.for("react.fragment"),l=Object.prototype.hasOwnProperty,c=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,f={key:!0,ref:!0,__self:!0,__source:!0};function m(p,_,y){var w,x={},N=null,$=null;y!==void 0&&(N=""+y),_.key!==void 0&&(N=""+_.key),_.ref!==void 0&&($=_.ref);for(w in _)l.call(_,w)&&!f.hasOwnProperty(w)&&(x[w]=_[w]);if(p&&p.defaultProps)for(w in _=p.defaultProps,_)x[w]===void 0&&(x[w]=_[w]);return{$$typeof:s,type:p,key:N,ref:$,props:x,_owner:c.current}}return fl.Fragment=r,fl.jsx=m,fl.jsxs=m,fl}var Um;function mp(){return Um||(Um=1,fu.exports=dp()),fu.exports}var e=mp(),h=td();const Gt=cp(h);var Do={},pu={exports:{}},Pn={},_u={exports:{}},gu={};/**
18
- * @license React
19
- * scheduler.production.min.js
20
- *
21
- * Copyright (c) Facebook, Inc. and its affiliates.
22
- *
23
- * This source code is licensed under the MIT license found in the
24
- * LICENSE file in the root directory of this source tree.
25
- */var Wm;function fp(){return Wm||(Wm=1,(function(a){function s(I,_e){var Y=I.length;I.push(_e);e:for(;0<Y;){var S=Y-1>>>1,A=I[S];if(0<c(A,_e))I[S]=_e,I[Y]=A,Y=S;else break e}}function r(I){return I.length===0?null:I[0]}function l(I){if(I.length===0)return null;var _e=I[0],Y=I.pop();if(Y!==_e){I[0]=Y;e:for(var S=0,A=I.length,U=A>>>1;S<U;){var ie=2*(S+1)-1,de=I[ie],L=ie+1,ke=I[L];if(0>c(de,Y))L<A&&0>c(ke,de)?(I[S]=ke,I[L]=Y,S=L):(I[S]=de,I[ie]=Y,S=ie);else if(L<A&&0>c(ke,Y))I[S]=ke,I[L]=Y,S=L;else break e}}return _e}function c(I,_e){var Y=I.sortIndex-_e.sortIndex;return Y!==0?Y:I.id-_e.id}if(typeof performance=="object"&&typeof performance.now=="function"){var f=performance;a.unstable_now=function(){return f.now()}}else{var m=Date,p=m.now();a.unstable_now=function(){return m.now()-p}}var _=[],y=[],w=1,x=null,N=3,$=!1,P=!1,T=!1,F=typeof setTimeout=="function"?setTimeout:null,D=typeof clearTimeout=="function"?clearTimeout:null,J=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function B(I){for(var _e=r(y);_e!==null;){if(_e.callback===null)l(y);else if(_e.startTime<=I)l(y),_e.sortIndex=_e.expirationTime,s(_,_e);else break;_e=r(y)}}function ee(I){if(T=!1,B(I),!P)if(r(_)!==null)P=!0,H(C);else{var _e=r(y);_e!==null&&ce(ee,_e.startTime-I)}}function C(I,_e){P=!1,T&&(T=!1,D(fe),fe=-1),$=!0;var Y=N;try{for(B(_e),x=r(_);x!==null&&(!(x.expirationTime>_e)||I&&!Se());){var S=x.callback;if(typeof S=="function"){x.callback=null,N=x.priorityLevel;var A=S(x.expirationTime<=_e);_e=a.unstable_now(),typeof A=="function"?x.callback=A:x===r(_)&&l(_),B(_e)}else l(_);x=r(_)}if(x!==null)var U=!0;else{var ie=r(y);ie!==null&&ce(ee,ie.startTime-_e),U=!1}return U}finally{x=null,N=Y,$=!1}}var Z=!1,ae=null,fe=-1,ge=5,Te=-1;function Se(){return!(a.unstable_now()-Te<ge)}function K(){if(ae!==null){var I=a.unstable_now();Te=I;var _e=!0;try{_e=ae(!0,I)}finally{_e?te():(Z=!1,ae=null)}}else Z=!1}var te;if(typeof J=="function")te=function(){J(K)};else if(typeof MessageChannel<"u"){var z=new MessageChannel,V=z.port2;z.port1.onmessage=K,te=function(){V.postMessage(null)}}else te=function(){F(K,0)};function H(I){ae=I,Z||(Z=!0,te())}function ce(I,_e){fe=F(function(){I(a.unstable_now())},_e)}a.unstable_IdlePriority=5,a.unstable_ImmediatePriority=1,a.unstable_LowPriority=4,a.unstable_NormalPriority=3,a.unstable_Profiling=null,a.unstable_UserBlockingPriority=2,a.unstable_cancelCallback=function(I){I.callback=null},a.unstable_continueExecution=function(){P||$||(P=!0,H(C))},a.unstable_forceFrameRate=function(I){0>I||125<I?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):ge=0<I?Math.floor(1e3/I):5},a.unstable_getCurrentPriorityLevel=function(){return N},a.unstable_getFirstCallbackNode=function(){return r(_)},a.unstable_next=function(I){switch(N){case 1:case 2:case 3:var _e=3;break;default:_e=N}var Y=N;N=_e;try{return I()}finally{N=Y}},a.unstable_pauseExecution=function(){},a.unstable_requestPaint=function(){},a.unstable_runWithPriority=function(I,_e){switch(I){case 1:case 2:case 3:case 4:case 5:break;default:I=3}var Y=N;N=I;try{return _e()}finally{N=Y}},a.unstable_scheduleCallback=function(I,_e,Y){var S=a.unstable_now();switch(typeof Y=="object"&&Y!==null?(Y=Y.delay,Y=typeof Y=="number"&&0<Y?S+Y:S):Y=S,I){case 1:var A=-1;break;case 2:A=250;break;case 5:A=1073741823;break;case 4:A=1e4;break;default:A=5e3}return A=Y+A,I={id:w++,callback:_e,priorityLevel:I,startTime:Y,expirationTime:A,sortIndex:-1},Y>S?(I.sortIndex=Y,s(y,I),r(_)===null&&I===r(y)&&(T?(D(fe),fe=-1):T=!0,ce(ee,Y-S))):(I.sortIndex=A,s(_,I),P||$||(P=!0,H(C))),I},a.unstable_shouldYield=Se,a.unstable_wrapCallback=function(I){var _e=N;return function(){var Y=N;N=_e;try{return I.apply(this,arguments)}finally{N=Y}}}})(gu)),gu}var Hm;function hp(){return Hm||(Hm=1,_u.exports=fp()),_u.exports}/**
26
- * @license React
27
- * react-dom.production.min.js
28
- *
29
- * Copyright (c) Facebook, Inc. and its affiliates.
30
- *
31
- * This source code is licensed under the MIT license found in the
32
- * LICENSE file in the root directory of this source tree.
33
- */var Vm;function pp(){if(Vm)return Pn;Vm=1;var a=td(),s=hp();function r(t){for(var n="https://reactjs.org/docs/error-decoder.html?invariant="+t,i=1;i<arguments.length;i++)n+="&args[]="+encodeURIComponent(arguments[i]);return"Minified React error #"+t+"; visit "+n+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var l=new Set,c={};function f(t,n){m(t,n),m(t+"Capture",n)}function m(t,n){for(c[t]=n,t=0;t<n.length;t++)l.add(n[t])}var p=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),_=Object.prototype.hasOwnProperty,y=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,w={},x={};function N(t){return _.call(x,t)?!0:_.call(w,t)?!1:y.test(t)?x[t]=!0:(w[t]=!0,!1)}function $(t,n,i,o){if(i!==null&&i.type===0)return!1;switch(typeof n){case"function":case"symbol":return!0;case"boolean":return o?!1:i!==null?!i.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function P(t,n,i,o){if(n===null||typeof n>"u"||$(t,n,i,o))return!0;if(o)return!1;if(i!==null)switch(i.type){case 3:return!n;case 4:return n===!1;case 5:return isNaN(n);case 6:return isNaN(n)||1>n}return!1}function T(t,n,i,o,d,g,j){this.acceptsBooleans=n===2||n===3||n===4,this.attributeName=o,this.attributeNamespace=d,this.mustUseProperty=i,this.propertyName=t,this.type=n,this.sanitizeURL=g,this.removeEmptyString=j}var F={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){F[t]=new T(t,0,!1,t,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var n=t[0];F[n]=new T(n,1,!1,t[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(t){F[t]=new T(t,2,!1,t.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){F[t]=new T(t,2,!1,t,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){F[t]=new T(t,3,!1,t.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(t){F[t]=new T(t,3,!0,t,null,!1,!1)}),["capture","download"].forEach(function(t){F[t]=new T(t,4,!1,t,null,!1,!1)}),["cols","rows","size","span"].forEach(function(t){F[t]=new T(t,6,!1,t,null,!1,!1)}),["rowSpan","start"].forEach(function(t){F[t]=new T(t,5,!1,t.toLowerCase(),null,!1,!1)});var D=/[\-:]([a-z])/g;function J(t){return t[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var n=t.replace(D,J);F[n]=new T(n,1,!1,t,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var n=t.replace(D,J);F[n]=new T(n,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(t){var n=t.replace(D,J);F[n]=new T(n,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(t){F[t]=new T(t,1,!1,t.toLowerCase(),null,!1,!1)}),F.xlinkHref=new T("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(t){F[t]=new T(t,1,!1,t.toLowerCase(),null,!0,!0)});function B(t,n,i,o){var d=F.hasOwnProperty(n)?F[n]:null;(d!==null?d.type!==0:o||!(2<n.length)||n[0]!=="o"&&n[0]!=="O"||n[1]!=="n"&&n[1]!=="N")&&(P(n,i,d,o)&&(i=null),o||d===null?N(n)&&(i===null?t.removeAttribute(n):t.setAttribute(n,""+i)):d.mustUseProperty?t[d.propertyName]=i===null?d.type===3?!1:"":i:(n=d.attributeName,o=d.attributeNamespace,i===null?t.removeAttribute(n):(d=d.type,i=d===3||d===4&&i===!0?"":""+i,o?t.setAttributeNS(o,n,i):t.setAttribute(n,i))))}var ee=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,C=Symbol.for("react.element"),Z=Symbol.for("react.portal"),ae=Symbol.for("react.fragment"),fe=Symbol.for("react.strict_mode"),ge=Symbol.for("react.profiler"),Te=Symbol.for("react.provider"),Se=Symbol.for("react.context"),K=Symbol.for("react.forward_ref"),te=Symbol.for("react.suspense"),z=Symbol.for("react.suspense_list"),V=Symbol.for("react.memo"),H=Symbol.for("react.lazy"),ce=Symbol.for("react.offscreen"),I=Symbol.iterator;function _e(t){return t===null||typeof t!="object"?null:(t=I&&t[I]||t["@@iterator"],typeof t=="function"?t:null)}var Y=Object.assign,S;function A(t){if(S===void 0)try{throw Error()}catch(i){var n=i.stack.trim().match(/\n( *(at )?)/);S=n&&n[1]||""}return`
34
- `+S+t}var U=!1;function ie(t,n){if(!t||U)return"";U=!0;var i=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(n)if(n=function(){throw Error()},Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(n,[])}catch(ue){var o=ue}Reflect.construct(t,[],n)}else{try{n.call()}catch(ue){o=ue}t.call(n.prototype)}else{try{throw Error()}catch(ue){o=ue}t()}}catch(ue){if(ue&&o&&typeof ue.stack=="string"){for(var d=ue.stack.split(`
35
- `),g=o.stack.split(`
36
- `),j=d.length-1,M=g.length-1;1<=j&&0<=M&&d[j]!==g[M];)M--;for(;1<=j&&0<=M;j--,M--)if(d[j]!==g[M]){if(j!==1||M!==1)do if(j--,M--,0>M||d[j]!==g[M]){var W=`
37
- `+d[j].replace(" at new "," at ");return t.displayName&&W.includes("<anonymous>")&&(W=W.replace("<anonymous>",t.displayName)),W}while(1<=j&&0<=M);break}}}finally{U=!1,Error.prepareStackTrace=i}return(t=t?t.displayName||t.name:"")?A(t):""}function de(t){switch(t.tag){case 5:return A(t.type);case 16:return A("Lazy");case 13:return A("Suspense");case 19:return A("SuspenseList");case 0:case 2:case 15:return t=ie(t.type,!1),t;case 11:return t=ie(t.type.render,!1),t;case 1:return t=ie(t.type,!0),t;default:return""}}function L(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case ae:return"Fragment";case Z:return"Portal";case ge:return"Profiler";case fe:return"StrictMode";case te:return"Suspense";case z:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case Se:return(t.displayName||"Context")+".Consumer";case Te:return(t._context.displayName||"Context")+".Provider";case K:var n=t.render;return t=t.displayName,t||(t=n.displayName||n.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case V:return n=t.displayName||null,n!==null?n:L(t.type)||"Memo";case H:n=t._payload,t=t._init;try{return L(t(n))}catch{}}return null}function ke(t){var n=t.type;switch(t.tag){case 24:return"Cache";case 9:return(n.displayName||"Context")+".Consumer";case 10:return(n._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=n.render,t=t.displayName||t.name||"",n.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return n;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return L(n);case 8:return n===fe?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n}return null}function be(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function Ie(t){var n=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function Fe(t){var n=Ie(t)?"checked":"value",i=Object.getOwnPropertyDescriptor(t.constructor.prototype,n),o=""+t[n];if(!t.hasOwnProperty(n)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var d=i.get,g=i.set;return Object.defineProperty(t,n,{configurable:!0,get:function(){return d.call(this)},set:function(j){o=""+j,g.call(this,j)}}),Object.defineProperty(t,n,{enumerable:i.enumerable}),{getValue:function(){return o},setValue:function(j){o=""+j},stopTracking:function(){t._valueTracker=null,delete t[n]}}}}function Ye(t){t._valueTracker||(t._valueTracker=Fe(t))}function he(t){if(!t)return!1;var n=t._valueTracker;if(!n)return!0;var i=n.getValue(),o="";return t&&(o=Ie(t)?t.checked?"true":"false":t.value),t=o,t!==i?(n.setValue(t),!0):!1}function Re(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function ze(t,n){var i=n.checked;return Y({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i??t._wrapperState.initialChecked})}function re(t,n){var i=n.defaultValue==null?"":n.defaultValue,o=n.checked!=null?n.checked:n.defaultChecked;i=be(n.value!=null?n.value:i),t._wrapperState={initialChecked:o,initialValue:i,controlled:n.type==="checkbox"||n.type==="radio"?n.checked!=null:n.value!=null}}function xe(t,n){n=n.checked,n!=null&&B(t,"checked",n,!1)}function O(t,n){xe(t,n);var i=be(n.value),o=n.type;if(i!=null)o==="number"?(i===0&&t.value===""||t.value!=i)&&(t.value=""+i):t.value!==""+i&&(t.value=""+i);else if(o==="submit"||o==="reset"){t.removeAttribute("value");return}n.hasOwnProperty("value")?De(t,n.type,i):n.hasOwnProperty("defaultValue")&&De(t,n.type,be(n.defaultValue)),n.checked==null&&n.defaultChecked!=null&&(t.defaultChecked=!!n.defaultChecked)}function me(t,n,i){if(n.hasOwnProperty("value")||n.hasOwnProperty("defaultValue")){var o=n.type;if(!(o!=="submit"&&o!=="reset"||n.value!==void 0&&n.value!==null))return;n=""+t._wrapperState.initialValue,i||n===t.value||(t.value=n),t.defaultValue=n}i=t.name,i!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,i!==""&&(t.name=i)}function De(t,n,i){(n!=="number"||Re(t.ownerDocument)!==t)&&(i==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+i&&(t.defaultValue=""+i))}var G=Array.isArray;function le(t,n,i,o){if(t=t.options,n){n={};for(var d=0;d<i.length;d++)n["$"+i[d]]=!0;for(i=0;i<t.length;i++)d=n.hasOwnProperty("$"+t[i].value),t[i].selected!==d&&(t[i].selected=d),d&&o&&(t[i].defaultSelected=!0)}else{for(i=""+be(i),n=null,d=0;d<t.length;d++){if(t[d].value===i){t[d].selected=!0,o&&(t[d].defaultSelected=!0);return}n!==null||t[d].disabled||(n=t[d])}n!==null&&(n.selected=!0)}}function ye(t,n){if(n.dangerouslySetInnerHTML!=null)throw Error(r(91));return Y({},n,{value:void 0,defaultValue:void 0,children:""+t._wrapperState.initialValue})}function Oe(t,n){var i=n.value;if(i==null){if(i=n.children,n=n.defaultValue,i!=null){if(n!=null)throw Error(r(92));if(G(i)){if(1<i.length)throw Error(r(93));i=i[0]}n=i}n==null&&(n=""),i=n}t._wrapperState={initialValue:be(i)}}function ot(t,n){var i=be(n.value),o=be(n.defaultValue);i!=null&&(i=""+i,i!==t.value&&(t.value=i),n.defaultValue==null&&t.defaultValue!==i&&(t.defaultValue=i)),o!=null&&(t.defaultValue=""+o)}function xt(t){var n=t.textContent;n===t._wrapperState.initialValue&&n!==""&&n!==null&&(t.value=n)}function pe(t){switch(t){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function R(t,n){return t==null||t==="http://www.w3.org/1999/xhtml"?pe(n):t==="http://www.w3.org/2000/svg"&&n==="foreignObject"?"http://www.w3.org/1999/xhtml":t}var X,$e=(function(t){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(n,i,o,d){MSApp.execUnsafeLocalFunction(function(){return t(n,i,o,d)})}:t})(function(t,n){if(t.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in t)t.innerHTML=n;else{for(X=X||document.createElement("div"),X.innerHTML="<svg>"+n.valueOf().toString()+"</svg>",n=X.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;n.firstChild;)t.appendChild(n.firstChild)}});function Ae(t,n){if(n){var i=t.firstChild;if(i&&i===t.lastChild&&i.nodeType===3){i.nodeValue=n;return}}t.textContent=n}var Ge={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},et=["Webkit","ms","Moz","O"];Object.keys(Ge).forEach(function(t){et.forEach(function(n){n=n+t.charAt(0).toUpperCase()+t.substring(1),Ge[n]=Ge[t]})});function ct(t,n,i){return n==null||typeof n=="boolean"||n===""?"":i||typeof n!="number"||n===0||Ge.hasOwnProperty(t)&&Ge[t]?(""+n).trim():n+"px"}function wt(t,n){t=t.style;for(var i in n)if(n.hasOwnProperty(i)){var o=i.indexOf("--")===0,d=ct(i,n[i],o);i==="float"&&(i="cssFloat"),o?t.setProperty(i,d):t[i]=d}}var pt=Y({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Ut(t,n){if(n){if(pt[t]&&(n.children!=null||n.dangerouslySetInnerHTML!=null))throw Error(r(137,t));if(n.dangerouslySetInnerHTML!=null){if(n.children!=null)throw Error(r(60));if(typeof n.dangerouslySetInnerHTML!="object"||!("__html"in n.dangerouslySetInnerHTML))throw Error(r(61))}if(n.style!=null&&typeof n.style!="object")throw Error(r(62))}}function Dt(t,n){if(t.indexOf("-")===-1)return typeof n.is=="string";switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Le=null;function rt(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var Ze=null,we=null,je=null;function Ke(t){if(t=fr(t)){if(typeof Ze!="function")throw Error(r(280));var n=t.stateNode;n&&(n=hr(n),Ze(t.stateNode,t.type,n))}}function it(t){we?je?je.push(t):je=[t]:we=t}function ht(){if(we){var t=we,n=je;if(je=we=null,Ke(t),n)for(t=0;t<n.length;t++)Ke(n[t])}}function Xe(t,n){return t(n)}function ws(){}var Jt=!1;function $t(t,n,i){if(Jt)return t(n,i);Jt=!0;try{return Xe(t,n,i)}finally{Jt=!1,(we!==null||je!==null)&&(ws(),ht())}}function Yt(t,n){var i=t.stateNode;if(i===null)return null;var o=hr(i);if(o===null)return null;i=o[n];e:switch(n){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(o=!o.disabled)||(t=t.type,o=!(t==="button"||t==="input"||t==="select"||t==="textarea")),t=!o;break e;default:t=!1}if(t)return null;if(i&&typeof i!="function")throw Error(r(231,n,typeof i));return i}var un=!1;if(p)try{var Ft={};Object.defineProperty(Ft,"passive",{get:function(){un=!0}}),window.addEventListener("test",Ft,Ft),window.removeEventListener("test",Ft,Ft)}catch{un=!1}function Ba(t,n,i,o,d,g,j,M,W){var ue=Array.prototype.slice.call(arguments,3);try{n.apply(i,ue)}catch(Ce){this.onError(Ce)}}var Kn=!1,Fn=null,ha=!1,Er=null,xi={onError:function(t){Kn=!0,Fn=t}};function ut(t,n,i,o,d,g,j,M,W){Kn=!1,Fn=null,Ba.apply(xi,arguments)}function Wt(t,n,i,o,d,g,j,M,W){if(ut.apply(this,arguments),Kn){if(Kn){var ue=Fn;Kn=!1,Fn=null}else throw Error(r(198));ha||(ha=!0,Er=ue)}}function Qn(t){var n=t,i=t;if(t.alternate)for(;n.return;)n=n.return;else{t=n;do n=t,(n.flags&4098)!==0&&(i=n.return),t=n.return;while(t)}return n.tag===3?i:null}function Tt(t){if(t.tag===13){var n=t.memoizedState;if(n===null&&(t=t.alternate,t!==null&&(n=t.memoizedState)),n!==null)return n.dehydrated}return null}function Ua(t){if(Qn(t)!==t)throw Error(r(188))}function Tl(t){var n=t.alternate;if(!n){if(n=Qn(t),n===null)throw Error(r(188));return n!==t?null:t}for(var i=t,o=n;;){var d=i.return;if(d===null)break;var g=d.alternate;if(g===null){if(o=d.return,o!==null){i=o;continue}break}if(d.child===g.child){for(g=d.child;g;){if(g===i)return Ua(d),t;if(g===o)return Ua(d),n;g=g.sibling}throw Error(r(188))}if(i.return!==o.return)i=d,o=g;else{for(var j=!1,M=d.child;M;){if(M===i){j=!0,i=d,o=g;break}if(M===o){j=!0,o=d,i=g;break}M=M.sibling}if(!j){for(M=g.child;M;){if(M===i){j=!0,i=g,o=d;break}if(M===o){j=!0,o=g,i=d;break}M=M.sibling}if(!j)throw Error(r(189))}}if(i.alternate!==o)throw Error(r(190))}if(i.tag!==3)throw Error(r(188));return i.stateNode.current===i?t:n}function wi(t){return t=Tl(t),t!==null?Tr(t):null}function Tr(t){if(t.tag===5||t.tag===6)return t;for(t=t.child;t!==null;){var n=Tr(t);if(n!==null)return n;t=t.sibling}return null}var bi=s.unstable_scheduleCallback,Wa=s.unstable_cancelCallback,Al=s.unstable_shouldYield,Ar=s.unstable_requestPaint,At=s.unstable_now,Rl=s.unstable_getCurrentPriorityLevel,Ha=s.unstable_ImmediatePriority,Fs=s.unstable_UserBlockingPriority,rs=s.unstable_NormalPriority,Rr=s.unstable_LowPriority,pa=s.unstable_IdlePriority,Va=null,dn=null;function Ll(t){if(dn&&typeof dn.onCommitFiberRoot=="function")try{dn.onCommitFiberRoot(Va,t,void 0,(t.current.flags&128)===128)}catch{}}var kn=Math.clz32?Math.clz32:qn,Zo=Math.log,ec=Math.LN2;function qn(t){return t>>>=0,t===0?32:31-(Zo(t)/ec|0)|0}var Jn=64,qs=4194304;function Yn(t){switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function Pt(t,n){var i=t.pendingLanes;if(i===0)return 0;var o=0,d=t.suspendedLanes,g=t.pingedLanes,j=i&268435455;if(j!==0){var M=j&~d;M!==0?o=Yn(M):(g&=j,g!==0&&(o=Yn(g)))}else j=i&~d,j!==0?o=Yn(j):g!==0&&(o=Yn(g));if(o===0)return 0;if(n!==0&&n!==o&&(n&d)===0&&(d=o&-o,g=n&-n,d>=g||d===16&&(g&4194240)!==0))return n;if((o&4)!==0&&(o|=i&16),n=t.entangledLanes,n!==0)for(t=t.entanglements,n&=o;0<n;)i=31-kn(n),d=1<<i,o|=t[i],n&=~d;return o}function nn(t,n){switch(t){case 1:case 2:case 4:return n+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return n+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Lr(t,n){for(var i=t.suspendedLanes,o=t.pingedLanes,d=t.expirationTimes,g=t.pendingLanes;0<g;){var j=31-kn(g),M=1<<j,W=d[j];W===-1?((M&i)===0||(M&o)!==0)&&(d[j]=nn(M,n)):W<=n&&(t.expiredLanes|=M),g&=~M}}function bs(t){return t=t.pendingLanes&-1073741825,t!==0?t:t&1073741824?1073741824:0}function Bs(){var t=Jn;return Jn<<=1,(Jn&4194240)===0&&(Jn=64),t}function Mr(t){for(var n=[],i=0;31>i;i++)n.push(t);return n}function Mt(t,n,i){t.pendingLanes|=n,n!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,n=31-kn(n),t[n]=i}function js(t,n){var i=t.pendingLanes&~n;t.pendingLanes=n,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=n,t.mutableReadLanes&=n,t.entangledLanes&=n,n=t.entanglements;var o=t.eventTimes;for(t=t.expirationTimes;0<i;){var d=31-kn(i),g=1<<d;n[d]=0,o[d]=-1,t[d]=-1,i&=~g}}function zr(t,n){var i=t.entangledLanes|=n;for(t=t.entanglements;i;){var o=31-kn(i),d=1<<o;d&n|t[o]&n&&(t[o]|=n),i&=~d}}var dt=0;function Pr(t){return t&=-t,1<t?4<t?(t&268435455)!==0?16:536870912:4:1}var ji,Ga,ki,Si,Ka,ks=!1,Us=[],Ht=null,mn=null,Ss=null,is=new Map,jt=new Map,Xt=[],Bn="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function Ir(t,n){switch(t){case"focusin":case"focusout":Ht=null;break;case"dragenter":case"dragleave":mn=null;break;case"mouseover":case"mouseout":Ss=null;break;case"pointerover":case"pointerout":is.delete(n.pointerId);break;case"gotpointercapture":case"lostpointercapture":jt.delete(n.pointerId)}}function Ws(t,n,i,o,d,g){return t===null||t.nativeEvent!==g?(t={blockedOn:n,domEventName:i,eventSystemFlags:o,nativeEvent:g,targetContainers:[d]},n!==null&&(n=fr(n),n!==null&&Ga(n)),t):(t.eventSystemFlags|=o,n=t.targetContainers,d!==null&&n.indexOf(d)===-1&&n.push(d),t)}function Ml(t,n,i,o,d){switch(n){case"focusin":return Ht=Ws(Ht,t,n,i,o,d),!0;case"dragenter":return mn=Ws(mn,t,n,i,o,d),!0;case"mouseover":return Ss=Ws(Ss,t,n,i,o,d),!0;case"pointerover":var g=d.pointerId;return is.set(g,Ws(is.get(g)||null,t,n,i,o,d)),!0;case"gotpointercapture":return g=d.pointerId,jt.set(g,Ws(jt.get(g)||null,t,n,i,o,d)),!0}return!1}function Un(t){var n=Ls(t.target);if(n!==null){var i=Qn(n);if(i!==null){if(n=i.tag,n===13){if(n=Tt(i),n!==null){t.blockedOn=n,Ka(t.priority,function(){ki(i)});return}}else if(n===3&&i.stateNode.current.memoizedState.isDehydrated){t.blockedOn=i.tag===3?i.stateNode.containerInfo:null;return}}}t.blockedOn=null}function Qa(t){if(t.blockedOn!==null)return!1;for(var n=t.targetContainers;0<n.length;){var i=_a(t.domEventName,t.eventSystemFlags,n[0],t.nativeEvent);if(i===null){i=t.nativeEvent;var o=new i.constructor(i.type,i);Le=o,i.target.dispatchEvent(o),Le=null}else return n=fr(i),n!==null&&Ga(n),t.blockedOn=i,!1;n.shift()}return!0}function Ja(t,n,i){Qa(t)&&i.delete(n)}function zl(){ks=!1,Ht!==null&&Qa(Ht)&&(Ht=null),mn!==null&&Qa(mn)&&(mn=null),Ss!==null&&Qa(Ss)&&(Ss=null),is.forEach(Ja),jt.forEach(Ja)}function Hs(t,n){t.blockedOn===n&&(t.blockedOn=null,ks||(ks=!0,s.unstable_scheduleCallback(s.unstable_NormalPriority,zl)))}function ls(t){function n(d){return Hs(d,t)}if(0<Us.length){Hs(Us[0],t);for(var i=1;i<Us.length;i++){var o=Us[i];o.blockedOn===t&&(o.blockedOn=null)}}for(Ht!==null&&Hs(Ht,t),mn!==null&&Hs(mn,t),Ss!==null&&Hs(Ss,t),is.forEach(n),jt.forEach(n),i=0;i<Xt.length;i++)o=Xt[i],o.blockedOn===t&&(o.blockedOn=null);for(;0<Xt.length&&(i=Xt[0],i.blockedOn===null);)Un(i),i.blockedOn===null&&Xt.shift()}var Vs=ee.ReactCurrentBatchConfig,Ya=!0;function Ni(t,n,i,o){var d=dt,g=Vs.transition;Vs.transition=null;try{dt=1,Gs(t,n,i,o)}finally{dt=d,Vs.transition=g}}function Pl(t,n,i,o){var d=dt,g=Vs.transition;Vs.transition=null;try{dt=4,Gs(t,n,i,o)}finally{dt=d,Vs.transition=g}}function Gs(t,n,i,o){if(Ya){var d=_a(t,n,i,o);if(d===null)Gi(t,n,o,Xn,i),Ir(t,o);else if(Ml(d,t,n,i,o))o.stopPropagation();else if(Ir(t,o),n&4&&-1<Bn.indexOf(t)){for(;d!==null;){var g=fr(d);if(g!==null&&ji(g),g=_a(t,n,i,o),g===null&&Gi(t,n,o,Xn,i),g===d)break;d=g}d!==null&&o.stopPropagation()}else Gi(t,n,o,null,i)}}var Xn=null;function _a(t,n,i,o){if(Xn=null,t=rt(o),t=Ls(t),t!==null)if(n=Qn(t),n===null)t=null;else if(i=n.tag,i===13){if(t=Tt(n),t!==null)return t;t=null}else if(i===3){if(n.stateNode.current.memoizedState.isDehydrated)return n.tag===3?n.stateNode.containerInfo:null;t=null}else n!==t&&(t=null);return Xn=t,null}function Or(t){switch(t){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(Rl()){case Ha:return 1;case Fs:return 4;case rs:case Rr:return 16;case pa:return 536870912;default:return 16}default:return 16}}var Zn=null,Xa=null,os=null;function ga(){if(os)return os;var t,n=Xa,i=n.length,o,d="value"in Zn?Zn.value:Zn.textContent,g=d.length;for(t=0;t<i&&n[t]===d[t];t++);var j=i-t;for(o=1;o<=j&&n[i-o]===d[g-o];o++);return os=d.slice(t,1<o?1-o:void 0)}function Dr(t){var n=t.keyCode;return"charCode"in t?(t=t.charCode,t===0&&n===13&&(t=13)):t=n,t===10&&(t=13),32<=t||t===13?t:0}function qt(){return!0}function Fr(){return!1}function fn(t){function n(i,o,d,g,j){this._reactName=i,this._targetInst=d,this.type=o,this.nativeEvent=g,this.target=j,this.currentTarget=null;for(var M in t)t.hasOwnProperty(M)&&(i=t[M],this[M]=i?i(g):g[M]);return this.isDefaultPrevented=(g.defaultPrevented!=null?g.defaultPrevented:g.returnValue===!1)?qt:Fr,this.isPropagationStopped=Fr,this}return Y(n.prototype,{preventDefault:function(){this.defaultPrevented=!0;var i=this.nativeEvent;i&&(i.preventDefault?i.preventDefault():typeof i.returnValue!="unknown"&&(i.returnValue=!1),this.isDefaultPrevented=qt)},stopPropagation:function(){var i=this.nativeEvent;i&&(i.stopPropagation?i.stopPropagation():typeof i.cancelBubble!="unknown"&&(i.cancelBubble=!0),this.isPropagationStopped=qt)},persist:function(){},isPersistent:qt}),n}var Ks={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Za=fn(Ks),Qs=Y({},Ks,{view:0,detail:0}),Ci=fn(Qs),qr,er,va,tr=Y({},Qs,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:us,button:0,buttons:0,relatedTarget:function(t){return t.relatedTarget===void 0?t.fromElement===t.srcElement?t.toElement:t.fromElement:t.relatedTarget},movementX:function(t){return"movementX"in t?t.movementX:(t!==va&&(va&&t.type==="mousemove"?(qr=t.screenX-va.screenX,er=t.screenY-va.screenY):er=qr=0,va=t),qr)},movementY:function(t){return"movementY"in t?t.movementY:er}}),Br=fn(tr),Il=Y({},tr,{dataTransfer:0}),$i=fn(Il),Ei=Y({},Qs,{relatedTarget:0}),Ur=fn(Ei),$n=Y({},Ks,{animationName:0,elapsedTime:0,pseudoElement:0}),Ns=fn($n),Cs=Y({},Ks,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),Ti=fn(Cs),Ai=Y({},Ks,{data:0}),Wr=fn(Ai),tc={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},ya={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},nr={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function cs(t){var n=this.nativeEvent;return n.getModifierState?n.getModifierState(t):(t=nr[t])?!!n[t]:!1}function us(){return cs}var Ol=Y({},Qs,{key:function(t){if(t.key){var n=tc[t.key]||t.key;if(n!=="Unidentified")return n}return t.type==="keypress"?(t=Dr(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?ya[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:us,charCode:function(t){return t.type==="keypress"?Dr(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?Dr(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),Dl=fn(Ol),Fl=Y({},tr,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),ql=fn(Fl),nc=Y({},Qs,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:us}),Ri=fn(nc),xa=Y({},Ks,{propertyName:0,elapsedTime:0,pseudoElement:0}),Li=fn(xa),Bl=Y({},tr,{deltaX:function(t){return"deltaX"in t?t.deltaX:"wheelDeltaX"in t?-t.wheelDeltaX:0},deltaY:function(t){return"deltaY"in t?t.deltaY:"wheelDeltaY"in t?-t.wheelDeltaY:"wheelDelta"in t?-t.wheelDelta:0},deltaZ:0,deltaMode:0}),Mi=fn(Bl),Ul=[9,13,27,32],$s=p&&"CompositionEvent"in window,Js=null;p&&"documentMode"in document&&(Js=document.documentMode);var sc=p&&"TextEvent"in window&&!Js,wa=p&&(!$s||Js&&8<Js&&11>=Js),Hr=" ",zi=!1;function Pi(t,n){switch(t){case"keyup":return Ul.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ii(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var ba=!1;function Ys(t,n){switch(t){case"compositionend":return Ii(n);case"keypress":return n.which!==32?null:(zi=!0,Hr);case"textInput":return t=n.data,t===Hr&&zi?null:t;default:return null}}function sr(t,n){if(ba)return t==="compositionend"||!$s&&Pi(t,n)?(t=ga(),os=Xa=Zn=null,ba=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1<n.char.length)return n.char;if(n.which)return String.fromCharCode(n.which)}return null;case"compositionend":return wa&&n.locale!=="ko"?null:n.data;default:return null}}var ac={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function ar(t){var n=t&&t.nodeName&&t.nodeName.toLowerCase();return n==="input"?!!ac[t.type]:n==="textarea"}function Vr(t,n,i,o){it(o),n=Sa(n,"onChange"),0<n.length&&(i=new Za("onChange","change",null,i,o),t.push({event:i,listeners:n}))}var rr=null,Es=null;function Gr(t){ei(t,0)}function Kr(t){var n=aa(t);if(he(n))return t}function rc(t,n){if(t==="change")return n}var Wl=!1;if(p){var Qr;if(p){var Oi="oninput"in document;if(!Oi){var Di=document.createElement("div");Di.setAttribute("oninput","return;"),Oi=typeof Di.oninput=="function"}Qr=Oi}else Qr=!1;Wl=Qr&&(!document.documentMode||9<document.documentMode)}function Hl(){rr&&(rr.detachEvent("onpropertychange",Vl),Es=rr=null)}function Vl(t){if(t.propertyName==="value"&&Kr(Es)){var n=[];Vr(n,Es,t,rt(t)),$t(Gr,n)}}function Fi(t,n,i){t==="focusin"?(Hl(),rr=n,Es=i,rr.attachEvent("onpropertychange",Vl)):t==="focusout"&&Hl()}function ic(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return Kr(Es)}function Gl(t,n){if(t==="click")return Kr(n)}function Kl(t,n){if(t==="input"||t==="change")return Kr(n)}function lc(t,n){return t===n&&(t!==0||1/t===1/n)||t!==t&&n!==n}var En=typeof Object.is=="function"?Object.is:lc;function Ts(t,n){if(En(t,n))return!0;if(typeof t!="object"||t===null||typeof n!="object"||n===null)return!1;var i=Object.keys(t),o=Object.keys(n);if(i.length!==o.length)return!1;for(o=0;o<i.length;o++){var d=i[o];if(!_.call(n,d)||!En(t[d],n[d]))return!1}return!0}function qi(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function ir(t,n){var i=qi(t);t=0;for(var o;i;){if(i.nodeType===3){if(o=t+i.textContent.length,t<=n&&o>=n)return{node:i,offset:n-t};t=o}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=qi(i)}}function Bi(t,n){return t&&n?t===n?!0:t&&t.nodeType===3?!1:n&&n.nodeType===3?Bi(t,n.parentNode):"contains"in t?t.contains(n):t.compareDocumentPosition?!!(t.compareDocumentPosition(n)&16):!1:!1}function Ql(){for(var t=window,n=Re();n instanceof t.HTMLIFrameElement;){try{var i=typeof n.contentWindow.location.href=="string"}catch{i=!1}if(i)t=n.contentWindow;else break;n=Re(t.document)}return n}function Ui(t){var n=t&&t.nodeName&&t.nodeName.toLowerCase();return n&&(n==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||n==="textarea"||t.contentEditable==="true")}function Jl(t){var n=Ql(),i=t.focusedElem,o=t.selectionRange;if(n!==i&&i&&i.ownerDocument&&Bi(i.ownerDocument.documentElement,i)){if(o!==null&&Ui(i)){if(n=o.start,t=o.end,t===void 0&&(t=n),"selectionStart"in i)i.selectionStart=n,i.selectionEnd=Math.min(t,i.value.length);else if(t=(n=i.ownerDocument||document)&&n.defaultView||window,t.getSelection){t=t.getSelection();var d=i.textContent.length,g=Math.min(o.start,d);o=o.end===void 0?g:Math.min(o.end,d),!t.extend&&g>o&&(d=o,o=g,g=d),d=ir(i,g);var j=ir(i,o);d&&j&&(t.rangeCount!==1||t.anchorNode!==d.node||t.anchorOffset!==d.offset||t.focusNode!==j.node||t.focusOffset!==j.offset)&&(n=n.createRange(),n.setStart(d.node,d.offset),t.removeAllRanges(),g>o?(t.addRange(n),t.extend(j.node,j.offset)):(n.setEnd(j.node,j.offset),t.addRange(n)))}}for(n=[],t=i;t=t.parentNode;)t.nodeType===1&&n.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof i.focus=="function"&&i.focus(),i=0;i<n.length;i++)t=n[i],t.element.scrollLeft=t.left,t.element.scrollTop=t.top}}var oc=p&&"documentMode"in document&&11>=document.documentMode,Xs=null,Wi=null,ja=null,Jr=!1;function Yl(t,n,i){var o=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;Jr||Xs==null||Xs!==Re(o)||(o=Xs,"selectionStart"in o&&Ui(o)?o={start:o.selectionStart,end:o.selectionEnd}:(o=(o.ownerDocument&&o.ownerDocument.defaultView||window).getSelection(),o={anchorNode:o.anchorNode,anchorOffset:o.anchorOffset,focusNode:o.focusNode,focusOffset:o.focusOffset}),ja&&Ts(ja,o)||(ja=o,o=Sa(Wi,"onSelect"),0<o.length&&(n=new Za("onSelect","select",null,n,i),t.push({event:n,listeners:o}),n.target=Xs)))}function Yr(t,n){var i={};return i[t.toLowerCase()]=n.toLowerCase(),i["Webkit"+t]="webkit"+n,i["Moz"+t]="moz"+n,i}var Zs={animationend:Yr("Animation","AnimationEnd"),animationiteration:Yr("Animation","AnimationIteration"),animationstart:Yr("Animation","AnimationStart"),transitionend:Yr("Transition","TransitionEnd")},Xr={},Xl={};p&&(Xl=document.createElement("div").style,"AnimationEvent"in window||(delete Zs.animationend.animation,delete Zs.animationiteration.animation,delete Zs.animationstart.animation),"TransitionEvent"in window||delete Zs.transitionend.transition);function hn(t){if(Xr[t])return Xr[t];if(!Zs[t])return t;var n=Zs[t],i;for(i in n)if(n.hasOwnProperty(i)&&i in Xl)return Xr[t]=n[i];return t}var kt=hn("animationend"),Kt=hn("animationiteration"),Zr=hn("animationstart"),Zl=hn("transitionend"),ds=new Map,ms="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function sn(t,n){ds.set(t,n),f(n,[t])}for(var As=0;As<ms.length;As++){var ea=ms[As],lr=ea.toLowerCase(),or=ea[0].toUpperCase()+ea.slice(1);sn(lr,"on"+or)}sn(kt,"onAnimationEnd"),sn(Kt,"onAnimationIteration"),sn(Zr,"onAnimationStart"),sn("dblclick","onDoubleClick"),sn("focusin","onFocus"),sn("focusout","onBlur"),sn(Zl,"onTransitionEnd"),m("onMouseEnter",["mouseout","mouseover"]),m("onMouseLeave",["mouseout","mouseover"]),m("onPointerEnter",["pointerout","pointerover"]),m("onPointerLeave",["pointerout","pointerover"]),f("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),f("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),f("onBeforeInput",["compositionend","keypress","textInput","paste"]),f("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),f("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),f("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var ta="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),eo=new Set("cancel close invalid load scroll toggle".split(" ").concat(ta));function Hi(t,n,i){var o=t.type||"unknown-event";t.currentTarget=i,Wt(o,n,void 0,t),t.currentTarget=null}function ei(t,n){n=(n&4)!==0;for(var i=0;i<t.length;i++){var o=t[i],d=o.event;o=o.listeners;e:{var g=void 0;if(n)for(var j=o.length-1;0<=j;j--){var M=o[j],W=M.instance,ue=M.currentTarget;if(M=M.listener,W!==g&&d.isPropagationStopped())break e;Hi(d,M,ue),g=W}else for(j=0;j<o.length;j++){if(M=o[j],W=M.instance,ue=M.currentTarget,M=M.listener,W!==g&&d.isPropagationStopped())break e;Hi(d,M,ue),g=W}}}if(ha)throw t=Er,ha=!1,Er=null,t}function Et(t,n){var i=n[Xi];i===void 0&&(i=n[Xi]=new Set);var o=t+"__bubble";i.has(o)||(na(n,t,2,!1),i.add(o))}function Vi(t,n,i){var o=0;n&&(o|=4),na(i,t,o,n)}var cr="_reactListening"+Math.random().toString(36).slice(2);function ka(t){if(!t[cr]){t[cr]=!0,l.forEach(function(i){i!=="selectionchange"&&(eo.has(i)||Vi(i,!1,t),Vi(i,!0,t))});var n=t.nodeType===9?t:t.ownerDocument;n===null||n[cr]||(n[cr]=!0,Vi("selectionchange",!1,n))}}function na(t,n,i,o){switch(Or(n)){case 1:var d=Ni;break;case 4:d=Pl;break;default:d=Gs}i=d.bind(null,n,i,t),d=void 0,!un||n!=="touchstart"&&n!=="touchmove"&&n!=="wheel"||(d=!0),o?d!==void 0?t.addEventListener(n,i,{capture:!0,passive:d}):t.addEventListener(n,i,!0):d!==void 0?t.addEventListener(n,i,{passive:d}):t.addEventListener(n,i,!1)}function Gi(t,n,i,o,d){var g=o;if((n&1)===0&&(n&2)===0&&o!==null)e:for(;;){if(o===null)return;var j=o.tag;if(j===3||j===4){var M=o.stateNode.containerInfo;if(M===d||M.nodeType===8&&M.parentNode===d)break;if(j===4)for(j=o.return;j!==null;){var W=j.tag;if((W===3||W===4)&&(W=j.stateNode.containerInfo,W===d||W.nodeType===8&&W.parentNode===d))return;j=j.return}for(;M!==null;){if(j=Ls(M),j===null)return;if(W=j.tag,W===5||W===6){o=g=j;continue e}M=M.parentNode}}o=o.return}$t(function(){var ue=g,Ce=rt(i),Ee=[];e:{var Ne=ds.get(t);if(Ne!==void 0){var We=Za,Ve=t;switch(t){case"keypress":if(Dr(i)===0)break e;case"keydown":case"keyup":We=Dl;break;case"focusin":Ve="focus",We=Ur;break;case"focusout":Ve="blur",We=Ur;break;case"beforeblur":case"afterblur":We=Ur;break;case"click":if(i.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":We=Br;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":We=$i;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":We=Ri;break;case kt:case Kt:case Zr:We=Ns;break;case Zl:We=Li;break;case"scroll":We=Ci;break;case"wheel":We=Mi;break;case"copy":case"cut":case"paste":We=Ti;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":We=ql}var Qe=(n&4)!==0,Vt=!Qe&&t==="scroll",se=Qe?Ne!==null?Ne+"Capture":null:Ne;Qe=[];for(var Q=ue,oe;Q!==null;){oe=Q;var Pe=oe.stateNode;if(oe.tag===5&&Pe!==null&&(oe=Pe,se!==null&&(Pe=Yt(Q,se),Pe!=null&&Qe.push(an(Q,Pe,oe)))),Vt)break;Q=Q.return}0<Qe.length&&(Ne=new We(Ne,Ve,null,i,Ce),Ee.push({event:Ne,listeners:Qe}))}}if((n&7)===0){e:{if(Ne=t==="mouseover"||t==="pointerover",We=t==="mouseout"||t==="pointerout",Ne&&i!==Le&&(Ve=i.relatedTarget||i.fromElement)&&(Ls(Ve)||Ve[hs]))break e;if((We||Ne)&&(Ne=Ce.window===Ce?Ce:(Ne=Ce.ownerDocument)?Ne.defaultView||Ne.parentWindow:window,We?(Ve=i.relatedTarget||i.toElement,We=ue,Ve=Ve?Ls(Ve):null,Ve!==null&&(Vt=Qn(Ve),Ve!==Vt||Ve.tag!==5&&Ve.tag!==6)&&(Ve=null)):(We=null,Ve=ue),We!==Ve)){if(Qe=Br,Pe="onMouseLeave",se="onMouseEnter",Q="mouse",(t==="pointerout"||t==="pointerover")&&(Qe=ql,Pe="onPointerLeave",se="onPointerEnter",Q="pointer"),Vt=We==null?Ne:aa(We),oe=Ve==null?Ne:aa(Ve),Ne=new Qe(Pe,Q+"leave",We,i,Ce),Ne.target=Vt,Ne.relatedTarget=oe,Pe=null,Ls(Ce)===ue&&(Qe=new Qe(se,Q+"enter",Ve,i,Ce),Qe.target=oe,Qe.relatedTarget=Vt,Pe=Qe),Vt=Pe,We&&Ve)t:{for(Qe=We,se=Ve,Q=0,oe=Qe;oe;oe=pn(oe))Q++;for(oe=0,Pe=se;Pe;Pe=pn(Pe))oe++;for(;0<Q-oe;)Qe=pn(Qe),Q--;for(;0<oe-Q;)se=pn(se),oe--;for(;Q--;){if(Qe===se||se!==null&&Qe===se.alternate)break t;Qe=pn(Qe),se=pn(se)}Qe=null}else Qe=null;We!==null&&ur(Ee,Ne,We,Qe,!1),Ve!==null&&Vt!==null&&ur(Ee,Vt,Ve,Qe,!0)}}e:{if(Ne=ue?aa(ue):window,We=Ne.nodeName&&Ne.nodeName.toLowerCase(),We==="select"||We==="input"&&Ne.type==="file")var Je=rc;else if(ar(Ne))if(Wl)Je=Kl;else{Je=ic;var tt=Fi}else(We=Ne.nodeName)&&We.toLowerCase()==="input"&&(Ne.type==="checkbox"||Ne.type==="radio")&&(Je=Gl);if(Je&&(Je=Je(t,ue))){Vr(Ee,Je,i,Ce);break e}tt&&tt(t,Ne,ue),t==="focusout"&&(tt=Ne._wrapperState)&&tt.controlled&&Ne.type==="number"&&De(Ne,"number",Ne.value)}switch(tt=ue?aa(ue):window,t){case"focusin":(ar(tt)||tt.contentEditable==="true")&&(Xs=tt,Wi=ue,ja=null);break;case"focusout":ja=Wi=Xs=null;break;case"mousedown":Jr=!0;break;case"contextmenu":case"mouseup":case"dragend":Jr=!1,Yl(Ee,i,Ce);break;case"selectionchange":if(oc)break;case"keydown":case"keyup":Yl(Ee,i,Ce)}var nt;if($s)e:{switch(t){case"compositionstart":var lt="onCompositionStart";break e;case"compositionend":lt="onCompositionEnd";break e;case"compositionupdate":lt="onCompositionUpdate";break e}lt=void 0}else ba?Pi(t,i)&&(lt="onCompositionEnd"):t==="keydown"&&i.keyCode===229&&(lt="onCompositionStart");lt&&(wa&&i.locale!=="ko"&&(ba||lt!=="onCompositionStart"?lt==="onCompositionEnd"&&ba&&(nt=ga()):(Zn=Ce,Xa="value"in Zn?Zn.value:Zn.textContent,ba=!0)),tt=Sa(ue,lt),0<tt.length&&(lt=new Wr(lt,t,null,i,Ce),Ee.push({event:lt,listeners:tt}),nt?lt.data=nt:(nt=Ii(i),nt!==null&&(lt.data=nt)))),(nt=sc?Ys(t,i):sr(t,i))&&(ue=Sa(ue,"onBeforeInput"),0<ue.length&&(Ce=new Wr("onBeforeInput","beforeinput",null,i,Ce),Ee.push({event:Ce,listeners:ue}),Ce.data=nt))}ei(Ee,n)})}function an(t,n,i){return{instance:t,listener:n,currentTarget:i}}function Sa(t,n){for(var i=n+"Capture",o=[];t!==null;){var d=t,g=d.stateNode;d.tag===5&&g!==null&&(d=g,g=Yt(t,i),g!=null&&o.unshift(an(t,g,d)),g=Yt(t,n),g!=null&&o.push(an(t,g,d))),t=t.return}return o}function pn(t){if(t===null)return null;do t=t.return;while(t&&t.tag!==5);return t||null}function ur(t,n,i,o,d){for(var g=n._reactName,j=[];i!==null&&i!==o;){var M=i,W=M.alternate,ue=M.stateNode;if(W!==null&&W===o)break;M.tag===5&&ue!==null&&(M=ue,d?(W=Yt(i,g),W!=null&&j.unshift(an(i,W,M))):d||(W=Yt(i,g),W!=null&&j.push(an(i,W,M)))),i=i.return}j.length!==0&&t.push({event:n,listeners:j})}var Ki=/\r\n?/g,fs=/\u0000|\uFFFD/g;function Wn(t){return(typeof t=="string"?t:""+t).replace(Ki,`
38
- `).replace(fs,"")}function sa(t,n,i){if(n=Wn(n),Wn(t)!==n&&i)throw Error(r(425))}function ti(){}var dr=null,Qi=null;function Ji(t,n){return t==="textarea"||t==="noscript"||typeof n.children=="string"||typeof n.children=="number"||typeof n.dangerouslySetInnerHTML=="object"&&n.dangerouslySetInnerHTML!==null&&n.dangerouslySetInnerHTML.__html!=null}var ni=typeof setTimeout=="function"?setTimeout:void 0,cc=typeof clearTimeout=="function"?clearTimeout:void 0,to=typeof Promise=="function"?Promise:void 0,no=typeof queueMicrotask=="function"?queueMicrotask:typeof to<"u"?function(t){return to.resolve(null).then(t).catch(uc)}:ni;function uc(t){setTimeout(function(){throw t})}function Yi(t,n){var i=n,o=0;do{var d=i.nextSibling;if(t.removeChild(i),d&&d.nodeType===8)if(i=d.data,i==="/$"){if(o===0){t.removeChild(d),ls(n);return}o--}else i!=="$"&&i!=="$?"&&i!=="$!"||o++;i=d}while(i);ls(n)}function Rs(t){for(;t!=null;t=t.nextSibling){var n=t.nodeType;if(n===1||n===3)break;if(n===8){if(n=t.data,n==="$"||n==="$!"||n==="$?")break;if(n==="/$")return null}}return t}function so(t){t=t.previousSibling;for(var n=0;t;){if(t.nodeType===8){var i=t.data;if(i==="$"||i==="$!"||i==="$?"){if(n===0)return t;n--}else i==="/$"&&n++}t=t.previousSibling}return null}var Na=Math.random().toString(36).slice(2),Tn="__reactFiber$"+Na,mr="__reactProps$"+Na,hs="__reactContainer$"+Na,Xi="__reactEvents$"+Na,dc="__reactListeners$"+Na,ao="__reactHandles$"+Na;function Ls(t){var n=t[Tn];if(n)return n;for(var i=t.parentNode;i;){if(n=i[hs]||i[Tn]){if(i=n.alternate,n.child!==null||i!==null&&i.child!==null)for(t=so(t);t!==null;){if(i=t[Tn])return i;t=so(t)}return n}t=i,i=t.parentNode}return null}function fr(t){return t=t[Tn]||t[hs],!t||t.tag!==5&&t.tag!==6&&t.tag!==13&&t.tag!==3?null:t}function aa(t){if(t.tag===5||t.tag===6)return t.stateNode;throw Error(r(33))}function hr(t){return t[mr]||null}var si=[],ra=-1;function ps(t){return{current:t}}function Nt(t){0>ra||(t.current=si[ra],si[ra]=null,ra--)}function u(t,n){ra++,si[ra]=t.current,t.current=n}var v={},k=ps(v),b=ps(!1),E=v;function ne(t,n){var i=t.type.contextTypes;if(!i)return v;var o=t.stateNode;if(o&&o.__reactInternalMemoizedUnmaskedChildContext===n)return o.__reactInternalMemoizedMaskedChildContext;var d={},g;for(g in i)d[g]=n[g];return o&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=n,t.__reactInternalMemoizedMaskedChildContext=d),d}function q(t){return t=t.childContextTypes,t!=null}function ve(){Nt(b),Nt(k)}function Me(t,n,i){if(k.current!==v)throw Error(r(168));u(k,n),u(b,i)}function qe(t,n,i){var o=t.stateNode;if(n=n.childContextTypes,typeof o.getChildContext!="function")return i;o=o.getChildContext();for(var d in o)if(!(d in n))throw Error(r(108,ke(t)||"Unknown",d));return Y({},i,o)}function Be(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||v,E=k.current,u(k,t),u(b,b.current),!0}function Rt(t,n,i){var o=t.stateNode;if(!o)throw Error(r(169));i?(t=qe(t,n,E),o.__reactInternalMemoizedMergedChildContext=t,Nt(b),Nt(k),u(k,t)):Nt(b),u(b,i)}var Ct=null,An=!1,gt=!1;function at(t){Ct===null?Ct=[t]:Ct.push(t)}function xn(t){An=!0,at(t)}function vt(){if(!gt&&Ct!==null){gt=!0;var t=0,n=dt;try{var i=Ct;for(dt=1;t<i.length;t++){var o=i[t];do o=o(!0);while(o!==null)}Ct=null,An=!1}catch(d){throw Ct!==null&&(Ct=Ct.slice(t+1)),bi(Ha,vt),d}finally{dt=n,gt=!1}}return null}var Ue=[],St=0,rn=null,Zt=0,bt=[],ft=0,Lt=null,Rn=1,ia="";function pr(t,n){Ue[St++]=Zt,Ue[St++]=rn,rn=t,Zt=n}function md(t,n,i){bt[ft++]=Rn,bt[ft++]=ia,bt[ft++]=Lt,Lt=t;var o=Rn;t=ia;var d=32-kn(o)-1;o&=~(1<<d),i+=1;var g=32-kn(n)+d;if(30<g){var j=d-d%5;g=(o&(1<<j)-1).toString(32),o>>=j,d-=j,Rn=1<<32-kn(n)+d|i<<d|o,ia=g+t}else Rn=1<<g|i<<d|o,ia=t}function mc(t){t.return!==null&&(pr(t,1),md(t,1,0))}function fc(t){for(;t===rn;)rn=Ue[--St],Ue[St]=null,Zt=Ue[--St],Ue[St]=null;for(;t===Lt;)Lt=bt[--ft],bt[ft]=null,ia=bt[--ft],bt[ft]=null,Rn=bt[--ft],bt[ft]=null}var Hn=null,Vn=null,zt=!1,_s=null;function fd(t,n){var i=ss(5,null,null,0);i.elementType="DELETED",i.stateNode=n,i.return=t,n=t.deletions,n===null?(t.deletions=[i],t.flags|=16):n.push(i)}function hd(t,n){switch(t.tag){case 5:var i=t.type;return n=n.nodeType!==1||i.toLowerCase()!==n.nodeName.toLowerCase()?null:n,n!==null?(t.stateNode=n,Hn=t,Vn=Rs(n.firstChild),!0):!1;case 6:return n=t.pendingProps===""||n.nodeType!==3?null:n,n!==null?(t.stateNode=n,Hn=t,Vn=null,!0):!1;case 13:return n=n.nodeType!==8?null:n,n!==null?(i=Lt!==null?{id:Rn,overflow:ia}:null,t.memoizedState={dehydrated:n,treeContext:i,retryLane:1073741824},i=ss(18,null,null,0),i.stateNode=n,i.return=t,t.child=i,Hn=t,Vn=null,!0):!1;default:return!1}}function hc(t){return(t.mode&1)!==0&&(t.flags&128)===0}function pc(t){if(zt){var n=Vn;if(n){var i=n;if(!hd(t,n)){if(hc(t))throw Error(r(418));n=Rs(i.nextSibling);var o=Hn;n&&hd(t,n)?fd(o,i):(t.flags=t.flags&-4097|2,zt=!1,Hn=t)}}else{if(hc(t))throw Error(r(418));t.flags=t.flags&-4097|2,zt=!1,Hn=t}}}function pd(t){for(t=t.return;t!==null&&t.tag!==5&&t.tag!==3&&t.tag!==13;)t=t.return;Hn=t}function ro(t){if(t!==Hn)return!1;if(!zt)return pd(t),zt=!0,!1;var n;if((n=t.tag!==3)&&!(n=t.tag!==5)&&(n=t.type,n=n!=="head"&&n!=="body"&&!Ji(t.type,t.memoizedProps)),n&&(n=Vn)){if(hc(t))throw _d(),Error(r(418));for(;n;)fd(t,n),n=Rs(n.nextSibling)}if(pd(t),t.tag===13){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(r(317));e:{for(t=t.nextSibling,n=0;t;){if(t.nodeType===8){var i=t.data;if(i==="/$"){if(n===0){Vn=Rs(t.nextSibling);break e}n--}else i!=="$"&&i!=="$!"&&i!=="$?"||n++}t=t.nextSibling}Vn=null}}else Vn=Hn?Rs(t.stateNode.nextSibling):null;return!0}function _d(){for(var t=Vn;t;)t=Rs(t.nextSibling)}function ai(){Vn=Hn=null,zt=!1}function _c(t){_s===null?_s=[t]:_s.push(t)}var Ch=ee.ReactCurrentBatchConfig;function Zi(t,n,i){if(t=i.ref,t!==null&&typeof t!="function"&&typeof t!="object"){if(i._owner){if(i=i._owner,i){if(i.tag!==1)throw Error(r(309));var o=i.stateNode}if(!o)throw Error(r(147,t));var d=o,g=""+t;return n!==null&&n.ref!==null&&typeof n.ref=="function"&&n.ref._stringRef===g?n.ref:(n=function(j){var M=d.refs;j===null?delete M[g]:M[g]=j},n._stringRef=g,n)}if(typeof t!="string")throw Error(r(284));if(!i._owner)throw Error(r(290,t))}return t}function io(t,n){throw t=Object.prototype.toString.call(n),Error(r(31,t==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":t))}function gd(t){var n=t._init;return n(t._payload)}function vd(t){function n(se,Q){if(t){var oe=se.deletions;oe===null?(se.deletions=[Q],se.flags|=16):oe.push(Q)}}function i(se,Q){if(!t)return null;for(;Q!==null;)n(se,Q),Q=Q.sibling;return null}function o(se,Q){for(se=new Map;Q!==null;)Q.key!==null?se.set(Q.key,Q):se.set(Q.index,Q),Q=Q.sibling;return se}function d(se,Q){return se=Ma(se,Q),se.index=0,se.sibling=null,se}function g(se,Q,oe){return se.index=oe,t?(oe=se.alternate,oe!==null?(oe=oe.index,oe<Q?(se.flags|=2,Q):oe):(se.flags|=2,Q)):(se.flags|=1048576,Q)}function j(se){return t&&se.alternate===null&&(se.flags|=2),se}function M(se,Q,oe,Pe){return Q===null||Q.tag!==6?(Q=lu(oe,se.mode,Pe),Q.return=se,Q):(Q=d(Q,oe),Q.return=se,Q)}function W(se,Q,oe,Pe){var Je=oe.type;return Je===ae?Ce(se,Q,oe.props.children,Pe,oe.key):Q!==null&&(Q.elementType===Je||typeof Je=="object"&&Je!==null&&Je.$$typeof===H&&gd(Je)===Q.type)?(Pe=d(Q,oe.props),Pe.ref=Zi(se,Q,oe),Pe.return=se,Pe):(Pe=Ao(oe.type,oe.key,oe.props,null,se.mode,Pe),Pe.ref=Zi(se,Q,oe),Pe.return=se,Pe)}function ue(se,Q,oe,Pe){return Q===null||Q.tag!==4||Q.stateNode.containerInfo!==oe.containerInfo||Q.stateNode.implementation!==oe.implementation?(Q=ou(oe,se.mode,Pe),Q.return=se,Q):(Q=d(Q,oe.children||[]),Q.return=se,Q)}function Ce(se,Q,oe,Pe,Je){return Q===null||Q.tag!==7?(Q=jr(oe,se.mode,Pe,Je),Q.return=se,Q):(Q=d(Q,oe),Q.return=se,Q)}function Ee(se,Q,oe){if(typeof Q=="string"&&Q!==""||typeof Q=="number")return Q=lu(""+Q,se.mode,oe),Q.return=se,Q;if(typeof Q=="object"&&Q!==null){switch(Q.$$typeof){case C:return oe=Ao(Q.type,Q.key,Q.props,null,se.mode,oe),oe.ref=Zi(se,null,Q),oe.return=se,oe;case Z:return Q=ou(Q,se.mode,oe),Q.return=se,Q;case H:var Pe=Q._init;return Ee(se,Pe(Q._payload),oe)}if(G(Q)||_e(Q))return Q=jr(Q,se.mode,oe,null),Q.return=se,Q;io(se,Q)}return null}function Ne(se,Q,oe,Pe){var Je=Q!==null?Q.key:null;if(typeof oe=="string"&&oe!==""||typeof oe=="number")return Je!==null?null:M(se,Q,""+oe,Pe);if(typeof oe=="object"&&oe!==null){switch(oe.$$typeof){case C:return oe.key===Je?W(se,Q,oe,Pe):null;case Z:return oe.key===Je?ue(se,Q,oe,Pe):null;case H:return Je=oe._init,Ne(se,Q,Je(oe._payload),Pe)}if(G(oe)||_e(oe))return Je!==null?null:Ce(se,Q,oe,Pe,null);io(se,oe)}return null}function We(se,Q,oe,Pe,Je){if(typeof Pe=="string"&&Pe!==""||typeof Pe=="number")return se=se.get(oe)||null,M(Q,se,""+Pe,Je);if(typeof Pe=="object"&&Pe!==null){switch(Pe.$$typeof){case C:return se=se.get(Pe.key===null?oe:Pe.key)||null,W(Q,se,Pe,Je);case Z:return se=se.get(Pe.key===null?oe:Pe.key)||null,ue(Q,se,Pe,Je);case H:var tt=Pe._init;return We(se,Q,oe,tt(Pe._payload),Je)}if(G(Pe)||_e(Pe))return se=se.get(oe)||null,Ce(Q,se,Pe,Je,null);io(Q,Pe)}return null}function Ve(se,Q,oe,Pe){for(var Je=null,tt=null,nt=Q,lt=Q=0,cn=null;nt!==null&&lt<oe.length;lt++){nt.index>lt?(cn=nt,nt=null):cn=nt.sibling;var yt=Ne(se,nt,oe[lt],Pe);if(yt===null){nt===null&&(nt=cn);break}t&&nt&&yt.alternate===null&&n(se,nt),Q=g(yt,Q,lt),tt===null?Je=yt:tt.sibling=yt,tt=yt,nt=cn}if(lt===oe.length)return i(se,nt),zt&&pr(se,lt),Je;if(nt===null){for(;lt<oe.length;lt++)nt=Ee(se,oe[lt],Pe),nt!==null&&(Q=g(nt,Q,lt),tt===null?Je=nt:tt.sibling=nt,tt=nt);return zt&&pr(se,lt),Je}for(nt=o(se,nt);lt<oe.length;lt++)cn=We(nt,se,lt,oe[lt],Pe),cn!==null&&(t&&cn.alternate!==null&&nt.delete(cn.key===null?lt:cn.key),Q=g(cn,Q,lt),tt===null?Je=cn:tt.sibling=cn,tt=cn);return t&&nt.forEach(function(za){return n(se,za)}),zt&&pr(se,lt),Je}function Qe(se,Q,oe,Pe){var Je=_e(oe);if(typeof Je!="function")throw Error(r(150));if(oe=Je.call(oe),oe==null)throw Error(r(151));for(var tt=Je=null,nt=Q,lt=Q=0,cn=null,yt=oe.next();nt!==null&&!yt.done;lt++,yt=oe.next()){nt.index>lt?(cn=nt,nt=null):cn=nt.sibling;var za=Ne(se,nt,yt.value,Pe);if(za===null){nt===null&&(nt=cn);break}t&&nt&&za.alternate===null&&n(se,nt),Q=g(za,Q,lt),tt===null?Je=za:tt.sibling=za,tt=za,nt=cn}if(yt.done)return i(se,nt),zt&&pr(se,lt),Je;if(nt===null){for(;!yt.done;lt++,yt=oe.next())yt=Ee(se,yt.value,Pe),yt!==null&&(Q=g(yt,Q,lt),tt===null?Je=yt:tt.sibling=yt,tt=yt);return zt&&pr(se,lt),Je}for(nt=o(se,nt);!yt.done;lt++,yt=oe.next())yt=We(nt,se,lt,yt.value,Pe),yt!==null&&(t&&yt.alternate!==null&&nt.delete(yt.key===null?lt:yt.key),Q=g(yt,Q,lt),tt===null?Je=yt:tt.sibling=yt,tt=yt);return t&&nt.forEach(function(ip){return n(se,ip)}),zt&&pr(se,lt),Je}function Vt(se,Q,oe,Pe){if(typeof oe=="object"&&oe!==null&&oe.type===ae&&oe.key===null&&(oe=oe.props.children),typeof oe=="object"&&oe!==null){switch(oe.$$typeof){case C:e:{for(var Je=oe.key,tt=Q;tt!==null;){if(tt.key===Je){if(Je=oe.type,Je===ae){if(tt.tag===7){i(se,tt.sibling),Q=d(tt,oe.props.children),Q.return=se,se=Q;break e}}else if(tt.elementType===Je||typeof Je=="object"&&Je!==null&&Je.$$typeof===H&&gd(Je)===tt.type){i(se,tt.sibling),Q=d(tt,oe.props),Q.ref=Zi(se,tt,oe),Q.return=se,se=Q;break e}i(se,tt);break}else n(se,tt);tt=tt.sibling}oe.type===ae?(Q=jr(oe.props.children,se.mode,Pe,oe.key),Q.return=se,se=Q):(Pe=Ao(oe.type,oe.key,oe.props,null,se.mode,Pe),Pe.ref=Zi(se,Q,oe),Pe.return=se,se=Pe)}return j(se);case Z:e:{for(tt=oe.key;Q!==null;){if(Q.key===tt)if(Q.tag===4&&Q.stateNode.containerInfo===oe.containerInfo&&Q.stateNode.implementation===oe.implementation){i(se,Q.sibling),Q=d(Q,oe.children||[]),Q.return=se,se=Q;break e}else{i(se,Q);break}else n(se,Q);Q=Q.sibling}Q=ou(oe,se.mode,Pe),Q.return=se,se=Q}return j(se);case H:return tt=oe._init,Vt(se,Q,tt(oe._payload),Pe)}if(G(oe))return Ve(se,Q,oe,Pe);if(_e(oe))return Qe(se,Q,oe,Pe);io(se,oe)}return typeof oe=="string"&&oe!==""||typeof oe=="number"?(oe=""+oe,Q!==null&&Q.tag===6?(i(se,Q.sibling),Q=d(Q,oe),Q.return=se,se=Q):(i(se,Q),Q=lu(oe,se.mode,Pe),Q.return=se,se=Q),j(se)):i(se,Q)}return Vt}var ri=vd(!0),yd=vd(!1),lo=ps(null),oo=null,ii=null,gc=null;function vc(){gc=ii=oo=null}function yc(t){var n=lo.current;Nt(lo),t._currentValue=n}function xc(t,n,i){for(;t!==null;){var o=t.alternate;if((t.childLanes&n)!==n?(t.childLanes|=n,o!==null&&(o.childLanes|=n)):o!==null&&(o.childLanes&n)!==n&&(o.childLanes|=n),t===i)break;t=t.return}}function li(t,n){oo=t,gc=ii=null,t=t.dependencies,t!==null&&t.firstContext!==null&&((t.lanes&n)!==0&&(Ln=!0),t.firstContext=null)}function es(t){var n=t._currentValue;if(gc!==t)if(t={context:t,memoizedValue:n,next:null},ii===null){if(oo===null)throw Error(r(308));ii=t,oo.dependencies={lanes:0,firstContext:t}}else ii=ii.next=t;return n}var _r=null;function wc(t){_r===null?_r=[t]:_r.push(t)}function xd(t,n,i,o){var d=n.interleaved;return d===null?(i.next=i,wc(n)):(i.next=d.next,d.next=i),n.interleaved=i,la(t,o)}function la(t,n){t.lanes|=n;var i=t.alternate;for(i!==null&&(i.lanes|=n),i=t,t=t.return;t!==null;)t.childLanes|=n,i=t.alternate,i!==null&&(i.childLanes|=n),i=t,t=t.return;return i.tag===3?i.stateNode:null}var Ca=!1;function bc(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function wd(t,n){t=t.updateQueue,n.updateQueue===t&&(n.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function oa(t,n){return{eventTime:t,lane:n,tag:0,payload:null,callback:null,next:null}}function $a(t,n,i){var o=t.updateQueue;if(o===null)return null;if(o=o.shared,(_t&2)!==0){var d=o.pending;return d===null?n.next=n:(n.next=d.next,d.next=n),o.pending=n,la(t,i)}return d=o.interleaved,d===null?(n.next=n,wc(o)):(n.next=d.next,d.next=n),o.interleaved=n,la(t,i)}function co(t,n,i){if(n=n.updateQueue,n!==null&&(n=n.shared,(i&4194240)!==0)){var o=n.lanes;o&=t.pendingLanes,i|=o,n.lanes=i,zr(t,i)}}function bd(t,n){var i=t.updateQueue,o=t.alternate;if(o!==null&&(o=o.updateQueue,i===o)){var d=null,g=null;if(i=i.firstBaseUpdate,i!==null){do{var j={eventTime:i.eventTime,lane:i.lane,tag:i.tag,payload:i.payload,callback:i.callback,next:null};g===null?d=g=j:g=g.next=j,i=i.next}while(i!==null);g===null?d=g=n:g=g.next=n}else d=g=n;i={baseState:o.baseState,firstBaseUpdate:d,lastBaseUpdate:g,shared:o.shared,effects:o.effects},t.updateQueue=i;return}t=i.lastBaseUpdate,t===null?i.firstBaseUpdate=n:t.next=n,i.lastBaseUpdate=n}function uo(t,n,i,o){var d=t.updateQueue;Ca=!1;var g=d.firstBaseUpdate,j=d.lastBaseUpdate,M=d.shared.pending;if(M!==null){d.shared.pending=null;var W=M,ue=W.next;W.next=null,j===null?g=ue:j.next=ue,j=W;var Ce=t.alternate;Ce!==null&&(Ce=Ce.updateQueue,M=Ce.lastBaseUpdate,M!==j&&(M===null?Ce.firstBaseUpdate=ue:M.next=ue,Ce.lastBaseUpdate=W))}if(g!==null){var Ee=d.baseState;j=0,Ce=ue=W=null,M=g;do{var Ne=M.lane,We=M.eventTime;if((o&Ne)===Ne){Ce!==null&&(Ce=Ce.next={eventTime:We,lane:0,tag:M.tag,payload:M.payload,callback:M.callback,next:null});e:{var Ve=t,Qe=M;switch(Ne=n,We=i,Qe.tag){case 1:if(Ve=Qe.payload,typeof Ve=="function"){Ee=Ve.call(We,Ee,Ne);break e}Ee=Ve;break e;case 3:Ve.flags=Ve.flags&-65537|128;case 0:if(Ve=Qe.payload,Ne=typeof Ve=="function"?Ve.call(We,Ee,Ne):Ve,Ne==null)break e;Ee=Y({},Ee,Ne);break e;case 2:Ca=!0}}M.callback!==null&&M.lane!==0&&(t.flags|=64,Ne=d.effects,Ne===null?d.effects=[M]:Ne.push(M))}else We={eventTime:We,lane:Ne,tag:M.tag,payload:M.payload,callback:M.callback,next:null},Ce===null?(ue=Ce=We,W=Ee):Ce=Ce.next=We,j|=Ne;if(M=M.next,M===null){if(M=d.shared.pending,M===null)break;Ne=M,M=Ne.next,Ne.next=null,d.lastBaseUpdate=Ne,d.shared.pending=null}}while(!0);if(Ce===null&&(W=Ee),d.baseState=W,d.firstBaseUpdate=ue,d.lastBaseUpdate=Ce,n=d.shared.interleaved,n!==null){d=n;do j|=d.lane,d=d.next;while(d!==n)}else g===null&&(d.shared.lanes=0);yr|=j,t.lanes=j,t.memoizedState=Ee}}function jd(t,n,i){if(t=n.effects,n.effects=null,t!==null)for(n=0;n<t.length;n++){var o=t[n],d=o.callback;if(d!==null){if(o.callback=null,o=i,typeof d!="function")throw Error(r(191,d));d.call(o)}}}var el={},Ms=ps(el),tl=ps(el),nl=ps(el);function gr(t){if(t===el)throw Error(r(174));return t}function jc(t,n){switch(u(nl,n),u(tl,t),u(Ms,el),t=n.nodeType,t){case 9:case 11:n=(n=n.documentElement)?n.namespaceURI:R(null,"");break;default:t=t===8?n.parentNode:n,n=t.namespaceURI||null,t=t.tagName,n=R(n,t)}Nt(Ms),u(Ms,n)}function oi(){Nt(Ms),Nt(tl),Nt(nl)}function kd(t){gr(nl.current);var n=gr(Ms.current),i=R(n,t.type);n!==i&&(u(tl,t),u(Ms,i))}function kc(t){tl.current===t&&(Nt(Ms),Nt(tl))}var It=ps(0);function mo(t){for(var n=t;n!==null;){if(n.tag===13){var i=n.memoizedState;if(i!==null&&(i=i.dehydrated,i===null||i.data==="$?"||i.data==="$!"))return n}else if(n.tag===19&&n.memoizedProps.revealOrder!==void 0){if((n.flags&128)!==0)return n}else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return null;n=n.return}n.sibling.return=n.return,n=n.sibling}return null}var Sc=[];function Nc(){for(var t=0;t<Sc.length;t++)Sc[t]._workInProgressVersionPrimary=null;Sc.length=0}var fo=ee.ReactCurrentDispatcher,Cc=ee.ReactCurrentBatchConfig,vr=0,Ot=null,en=null,ln=null,ho=!1,sl=!1,al=0,$h=0;function wn(){throw Error(r(321))}function $c(t,n){if(n===null)return!1;for(var i=0;i<n.length&&i<t.length;i++)if(!En(t[i],n[i]))return!1;return!0}function Ec(t,n,i,o,d,g){if(vr=g,Ot=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,fo.current=t===null||t.memoizedState===null?Rh:Lh,t=i(o,d),sl){g=0;do{if(sl=!1,al=0,25<=g)throw Error(r(301));g+=1,ln=en=null,n.updateQueue=null,fo.current=Mh,t=i(o,d)}while(sl)}if(fo.current=go,n=en!==null&&en.next!==null,vr=0,ln=en=Ot=null,ho=!1,n)throw Error(r(300));return t}function Tc(){var t=al!==0;return al=0,t}function zs(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return ln===null?Ot.memoizedState=ln=t:ln=ln.next=t,ln}function ts(){if(en===null){var t=Ot.alternate;t=t!==null?t.memoizedState:null}else t=en.next;var n=ln===null?Ot.memoizedState:ln.next;if(n!==null)ln=n,en=t;else{if(t===null)throw Error(r(310));en=t,t={memoizedState:en.memoizedState,baseState:en.baseState,baseQueue:en.baseQueue,queue:en.queue,next:null},ln===null?Ot.memoizedState=ln=t:ln=ln.next=t}return ln}function rl(t,n){return typeof n=="function"?n(t):n}function Ac(t){var n=ts(),i=n.queue;if(i===null)throw Error(r(311));i.lastRenderedReducer=t;var o=en,d=o.baseQueue,g=i.pending;if(g!==null){if(d!==null){var j=d.next;d.next=g.next,g.next=j}o.baseQueue=d=g,i.pending=null}if(d!==null){g=d.next,o=o.baseState;var M=j=null,W=null,ue=g;do{var Ce=ue.lane;if((vr&Ce)===Ce)W!==null&&(W=W.next={lane:0,action:ue.action,hasEagerState:ue.hasEagerState,eagerState:ue.eagerState,next:null}),o=ue.hasEagerState?ue.eagerState:t(o,ue.action);else{var Ee={lane:Ce,action:ue.action,hasEagerState:ue.hasEagerState,eagerState:ue.eagerState,next:null};W===null?(M=W=Ee,j=o):W=W.next=Ee,Ot.lanes|=Ce,yr|=Ce}ue=ue.next}while(ue!==null&&ue!==g);W===null?j=o:W.next=M,En(o,n.memoizedState)||(Ln=!0),n.memoizedState=o,n.baseState=j,n.baseQueue=W,i.lastRenderedState=o}if(t=i.interleaved,t!==null){d=t;do g=d.lane,Ot.lanes|=g,yr|=g,d=d.next;while(d!==t)}else d===null&&(i.lanes=0);return[n.memoizedState,i.dispatch]}function Rc(t){var n=ts(),i=n.queue;if(i===null)throw Error(r(311));i.lastRenderedReducer=t;var o=i.dispatch,d=i.pending,g=n.memoizedState;if(d!==null){i.pending=null;var j=d=d.next;do g=t(g,j.action),j=j.next;while(j!==d);En(g,n.memoizedState)||(Ln=!0),n.memoizedState=g,n.baseQueue===null&&(n.baseState=g),i.lastRenderedState=g}return[g,o]}function Sd(){}function Nd(t,n){var i=Ot,o=ts(),d=n(),g=!En(o.memoizedState,d);if(g&&(o.memoizedState=d,Ln=!0),o=o.queue,Lc(Ed.bind(null,i,o,t),[t]),o.getSnapshot!==n||g||ln!==null&&ln.memoizedState.tag&1){if(i.flags|=2048,il(9,$d.bind(null,i,o,d,n),void 0,null),on===null)throw Error(r(349));(vr&30)!==0||Cd(i,n,d)}return d}function Cd(t,n,i){t.flags|=16384,t={getSnapshot:n,value:i},n=Ot.updateQueue,n===null?(n={lastEffect:null,stores:null},Ot.updateQueue=n,n.stores=[t]):(i=n.stores,i===null?n.stores=[t]:i.push(t))}function $d(t,n,i,o){n.value=i,n.getSnapshot=o,Td(n)&&Ad(t)}function Ed(t,n,i){return i(function(){Td(n)&&Ad(t)})}function Td(t){var n=t.getSnapshot;t=t.value;try{var i=n();return!En(t,i)}catch{return!0}}function Ad(t){var n=la(t,1);n!==null&&xs(n,t,1,-1)}function Rd(t){var n=zs();return typeof t=="function"&&(t=t()),n.memoizedState=n.baseState=t,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:rl,lastRenderedState:t},n.queue=t,t=t.dispatch=Ah.bind(null,Ot,t),[n.memoizedState,t]}function il(t,n,i,o){return t={tag:t,create:n,destroy:i,deps:o,next:null},n=Ot.updateQueue,n===null?(n={lastEffect:null,stores:null},Ot.updateQueue=n,n.lastEffect=t.next=t):(i=n.lastEffect,i===null?n.lastEffect=t.next=t:(o=i.next,i.next=t,t.next=o,n.lastEffect=t)),t}function Ld(){return ts().memoizedState}function po(t,n,i,o){var d=zs();Ot.flags|=t,d.memoizedState=il(1|n,i,void 0,o===void 0?null:o)}function _o(t,n,i,o){var d=ts();o=o===void 0?null:o;var g=void 0;if(en!==null){var j=en.memoizedState;if(g=j.destroy,o!==null&&$c(o,j.deps)){d.memoizedState=il(n,i,g,o);return}}Ot.flags|=t,d.memoizedState=il(1|n,i,g,o)}function Md(t,n){return po(8390656,8,t,n)}function Lc(t,n){return _o(2048,8,t,n)}function zd(t,n){return _o(4,2,t,n)}function Pd(t,n){return _o(4,4,t,n)}function Id(t,n){if(typeof n=="function")return t=t(),n(t),function(){n(null)};if(n!=null)return t=t(),n.current=t,function(){n.current=null}}function Od(t,n,i){return i=i!=null?i.concat([t]):null,_o(4,4,Id.bind(null,n,t),i)}function Mc(){}function Dd(t,n){var i=ts();n=n===void 0?null:n;var o=i.memoizedState;return o!==null&&n!==null&&$c(n,o[1])?o[0]:(i.memoizedState=[t,n],t)}function Fd(t,n){var i=ts();n=n===void 0?null:n;var o=i.memoizedState;return o!==null&&n!==null&&$c(n,o[1])?o[0]:(t=t(),i.memoizedState=[t,n],t)}function qd(t,n,i){return(vr&21)===0?(t.baseState&&(t.baseState=!1,Ln=!0),t.memoizedState=i):(En(i,n)||(i=Bs(),Ot.lanes|=i,yr|=i,t.baseState=!0),n)}function Eh(t,n){var i=dt;dt=i!==0&&4>i?i:4,t(!0);var o=Cc.transition;Cc.transition={};try{t(!1),n()}finally{dt=i,Cc.transition=o}}function Bd(){return ts().memoizedState}function Th(t,n,i){var o=Ra(t);if(i={lane:o,action:i,hasEagerState:!1,eagerState:null,next:null},Ud(t))Wd(n,i);else if(i=xd(t,n,i,o),i!==null){var d=Nn();xs(i,t,o,d),Hd(i,n,o)}}function Ah(t,n,i){var o=Ra(t),d={lane:o,action:i,hasEagerState:!1,eagerState:null,next:null};if(Ud(t))Wd(n,d);else{var g=t.alternate;if(t.lanes===0&&(g===null||g.lanes===0)&&(g=n.lastRenderedReducer,g!==null))try{var j=n.lastRenderedState,M=g(j,i);if(d.hasEagerState=!0,d.eagerState=M,En(M,j)){var W=n.interleaved;W===null?(d.next=d,wc(n)):(d.next=W.next,W.next=d),n.interleaved=d;return}}catch{}finally{}i=xd(t,n,d,o),i!==null&&(d=Nn(),xs(i,t,o,d),Hd(i,n,o))}}function Ud(t){var n=t.alternate;return t===Ot||n!==null&&n===Ot}function Wd(t,n){sl=ho=!0;var i=t.pending;i===null?n.next=n:(n.next=i.next,i.next=n),t.pending=n}function Hd(t,n,i){if((i&4194240)!==0){var o=n.lanes;o&=t.pendingLanes,i|=o,n.lanes=i,zr(t,i)}}var go={readContext:es,useCallback:wn,useContext:wn,useEffect:wn,useImperativeHandle:wn,useInsertionEffect:wn,useLayoutEffect:wn,useMemo:wn,useReducer:wn,useRef:wn,useState:wn,useDebugValue:wn,useDeferredValue:wn,useTransition:wn,useMutableSource:wn,useSyncExternalStore:wn,useId:wn,unstable_isNewReconciler:!1},Rh={readContext:es,useCallback:function(t,n){return zs().memoizedState=[t,n===void 0?null:n],t},useContext:es,useEffect:Md,useImperativeHandle:function(t,n,i){return i=i!=null?i.concat([t]):null,po(4194308,4,Id.bind(null,n,t),i)},useLayoutEffect:function(t,n){return po(4194308,4,t,n)},useInsertionEffect:function(t,n){return po(4,2,t,n)},useMemo:function(t,n){var i=zs();return n=n===void 0?null:n,t=t(),i.memoizedState=[t,n],t},useReducer:function(t,n,i){var o=zs();return n=i!==void 0?i(n):n,o.memoizedState=o.baseState=n,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:n},o.queue=t,t=t.dispatch=Th.bind(null,Ot,t),[o.memoizedState,t]},useRef:function(t){var n=zs();return t={current:t},n.memoizedState=t},useState:Rd,useDebugValue:Mc,useDeferredValue:function(t){return zs().memoizedState=t},useTransition:function(){var t=Rd(!1),n=t[0];return t=Eh.bind(null,t[1]),zs().memoizedState=t,[n,t]},useMutableSource:function(){},useSyncExternalStore:function(t,n,i){var o=Ot,d=zs();if(zt){if(i===void 0)throw Error(r(407));i=i()}else{if(i=n(),on===null)throw Error(r(349));(vr&30)!==0||Cd(o,n,i)}d.memoizedState=i;var g={value:i,getSnapshot:n};return d.queue=g,Md(Ed.bind(null,o,g,t),[t]),o.flags|=2048,il(9,$d.bind(null,o,g,i,n),void 0,null),i},useId:function(){var t=zs(),n=on.identifierPrefix;if(zt){var i=ia,o=Rn;i=(o&~(1<<32-kn(o)-1)).toString(32)+i,n=":"+n+"R"+i,i=al++,0<i&&(n+="H"+i.toString(32)),n+=":"}else i=$h++,n=":"+n+"r"+i.toString(32)+":";return t.memoizedState=n},unstable_isNewReconciler:!1},Lh={readContext:es,useCallback:Dd,useContext:es,useEffect:Lc,useImperativeHandle:Od,useInsertionEffect:zd,useLayoutEffect:Pd,useMemo:Fd,useReducer:Ac,useRef:Ld,useState:function(){return Ac(rl)},useDebugValue:Mc,useDeferredValue:function(t){var n=ts();return qd(n,en.memoizedState,t)},useTransition:function(){var t=Ac(rl)[0],n=ts().memoizedState;return[t,n]},useMutableSource:Sd,useSyncExternalStore:Nd,useId:Bd,unstable_isNewReconciler:!1},Mh={readContext:es,useCallback:Dd,useContext:es,useEffect:Lc,useImperativeHandle:Od,useInsertionEffect:zd,useLayoutEffect:Pd,useMemo:Fd,useReducer:Rc,useRef:Ld,useState:function(){return Rc(rl)},useDebugValue:Mc,useDeferredValue:function(t){var n=ts();return en===null?n.memoizedState=t:qd(n,en.memoizedState,t)},useTransition:function(){var t=Rc(rl)[0],n=ts().memoizedState;return[t,n]},useMutableSource:Sd,useSyncExternalStore:Nd,useId:Bd,unstable_isNewReconciler:!1};function gs(t,n){if(t&&t.defaultProps){n=Y({},n),t=t.defaultProps;for(var i in t)n[i]===void 0&&(n[i]=t[i]);return n}return n}function zc(t,n,i,o){n=t.memoizedState,i=i(o,n),i=i==null?n:Y({},n,i),t.memoizedState=i,t.lanes===0&&(t.updateQueue.baseState=i)}var vo={isMounted:function(t){return(t=t._reactInternals)?Qn(t)===t:!1},enqueueSetState:function(t,n,i){t=t._reactInternals;var o=Nn(),d=Ra(t),g=oa(o,d);g.payload=n,i!=null&&(g.callback=i),n=$a(t,g,d),n!==null&&(xs(n,t,d,o),co(n,t,d))},enqueueReplaceState:function(t,n,i){t=t._reactInternals;var o=Nn(),d=Ra(t),g=oa(o,d);g.tag=1,g.payload=n,i!=null&&(g.callback=i),n=$a(t,g,d),n!==null&&(xs(n,t,d,o),co(n,t,d))},enqueueForceUpdate:function(t,n){t=t._reactInternals;var i=Nn(),o=Ra(t),d=oa(i,o);d.tag=2,n!=null&&(d.callback=n),n=$a(t,d,o),n!==null&&(xs(n,t,o,i),co(n,t,o))}};function Vd(t,n,i,o,d,g,j){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(o,g,j):n.prototype&&n.prototype.isPureReactComponent?!Ts(i,o)||!Ts(d,g):!0}function Gd(t,n,i){var o=!1,d=v,g=n.contextType;return typeof g=="object"&&g!==null?g=es(g):(d=q(n)?E:k.current,o=n.contextTypes,g=(o=o!=null)?ne(t,d):v),n=new n(i,g),t.memoizedState=n.state!==null&&n.state!==void 0?n.state:null,n.updater=vo,t.stateNode=n,n._reactInternals=t,o&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=d,t.__reactInternalMemoizedMaskedChildContext=g),n}function Kd(t,n,i,o){t=n.state,typeof n.componentWillReceiveProps=="function"&&n.componentWillReceiveProps(i,o),typeof n.UNSAFE_componentWillReceiveProps=="function"&&n.UNSAFE_componentWillReceiveProps(i,o),n.state!==t&&vo.enqueueReplaceState(n,n.state,null)}function Pc(t,n,i,o){var d=t.stateNode;d.props=i,d.state=t.memoizedState,d.refs={},bc(t);var g=n.contextType;typeof g=="object"&&g!==null?d.context=es(g):(g=q(n)?E:k.current,d.context=ne(t,g)),d.state=t.memoizedState,g=n.getDerivedStateFromProps,typeof g=="function"&&(zc(t,n,g,i),d.state=t.memoizedState),typeof n.getDerivedStateFromProps=="function"||typeof d.getSnapshotBeforeUpdate=="function"||typeof d.UNSAFE_componentWillMount!="function"&&typeof d.componentWillMount!="function"||(n=d.state,typeof d.componentWillMount=="function"&&d.componentWillMount(),typeof d.UNSAFE_componentWillMount=="function"&&d.UNSAFE_componentWillMount(),n!==d.state&&vo.enqueueReplaceState(d,d.state,null),uo(t,i,d,o),d.state=t.memoizedState),typeof d.componentDidMount=="function"&&(t.flags|=4194308)}function ci(t,n){try{var i="",o=n;do i+=de(o),o=o.return;while(o);var d=i}catch(g){d=`
39
- Error generating stack: `+g.message+`
40
- `+g.stack}return{value:t,source:n,stack:d,digest:null}}function Ic(t,n,i){return{value:t,source:null,stack:i??null,digest:n??null}}function Oc(t,n){try{console.error(n.value)}catch(i){setTimeout(function(){throw i})}}var zh=typeof WeakMap=="function"?WeakMap:Map;function Qd(t,n,i){i=oa(-1,i),i.tag=3,i.payload={element:null};var o=n.value;return i.callback=function(){So||(So=!0,Zc=o),Oc(t,n)},i}function Jd(t,n,i){i=oa(-1,i),i.tag=3;var o=t.type.getDerivedStateFromError;if(typeof o=="function"){var d=n.value;i.payload=function(){return o(d)},i.callback=function(){Oc(t,n)}}var g=t.stateNode;return g!==null&&typeof g.componentDidCatch=="function"&&(i.callback=function(){Oc(t,n),typeof o!="function"&&(Ta===null?Ta=new Set([this]):Ta.add(this));var j=n.stack;this.componentDidCatch(n.value,{componentStack:j!==null?j:""})}),i}function Yd(t,n,i){var o=t.pingCache;if(o===null){o=t.pingCache=new zh;var d=new Set;o.set(n,d)}else d=o.get(n),d===void 0&&(d=new Set,o.set(n,d));d.has(i)||(d.add(i),t=Qh.bind(null,t,n,i),n.then(t,t))}function Xd(t){do{var n;if((n=t.tag===13)&&(n=t.memoizedState,n=n!==null?n.dehydrated!==null:!0),n)return t;t=t.return}while(t!==null);return null}function Zd(t,n,i,o,d){return(t.mode&1)===0?(t===n?t.flags|=65536:(t.flags|=128,i.flags|=131072,i.flags&=-52805,i.tag===1&&(i.alternate===null?i.tag=17:(n=oa(-1,1),n.tag=2,$a(i,n,1))),i.lanes|=1),t):(t.flags|=65536,t.lanes=d,t)}var Ph=ee.ReactCurrentOwner,Ln=!1;function Sn(t,n,i,o){n.child=t===null?yd(n,null,i,o):ri(n,t.child,i,o)}function em(t,n,i,o,d){i=i.render;var g=n.ref;return li(n,d),o=Ec(t,n,i,o,g,d),i=Tc(),t!==null&&!Ln?(n.updateQueue=t.updateQueue,n.flags&=-2053,t.lanes&=~d,ca(t,n,d)):(zt&&i&&mc(n),n.flags|=1,Sn(t,n,o,d),n.child)}function tm(t,n,i,o,d){if(t===null){var g=i.type;return typeof g=="function"&&!iu(g)&&g.defaultProps===void 0&&i.compare===null&&i.defaultProps===void 0?(n.tag=15,n.type=g,nm(t,n,g,o,d)):(t=Ao(i.type,null,o,n,n.mode,d),t.ref=n.ref,t.return=n,n.child=t)}if(g=t.child,(t.lanes&d)===0){var j=g.memoizedProps;if(i=i.compare,i=i!==null?i:Ts,i(j,o)&&t.ref===n.ref)return ca(t,n,d)}return n.flags|=1,t=Ma(g,o),t.ref=n.ref,t.return=n,n.child=t}function nm(t,n,i,o,d){if(t!==null){var g=t.memoizedProps;if(Ts(g,o)&&t.ref===n.ref)if(Ln=!1,n.pendingProps=o=g,(t.lanes&d)!==0)(t.flags&131072)!==0&&(Ln=!0);else return n.lanes=t.lanes,ca(t,n,d)}return Dc(t,n,i,o,d)}function sm(t,n,i){var o=n.pendingProps,d=o.children,g=t!==null?t.memoizedState:null;if(o.mode==="hidden")if((n.mode&1)===0)n.memoizedState={baseLanes:0,cachePool:null,transitions:null},u(di,Gn),Gn|=i;else{if((i&1073741824)===0)return t=g!==null?g.baseLanes|i:i,n.lanes=n.childLanes=1073741824,n.memoizedState={baseLanes:t,cachePool:null,transitions:null},n.updateQueue=null,u(di,Gn),Gn|=t,null;n.memoizedState={baseLanes:0,cachePool:null,transitions:null},o=g!==null?g.baseLanes:i,u(di,Gn),Gn|=o}else g!==null?(o=g.baseLanes|i,n.memoizedState=null):o=i,u(di,Gn),Gn|=o;return Sn(t,n,d,i),n.child}function am(t,n){var i=n.ref;(t===null&&i!==null||t!==null&&t.ref!==i)&&(n.flags|=512,n.flags|=2097152)}function Dc(t,n,i,o,d){var g=q(i)?E:k.current;return g=ne(n,g),li(n,d),i=Ec(t,n,i,o,g,d),o=Tc(),t!==null&&!Ln?(n.updateQueue=t.updateQueue,n.flags&=-2053,t.lanes&=~d,ca(t,n,d)):(zt&&o&&mc(n),n.flags|=1,Sn(t,n,i,d),n.child)}function rm(t,n,i,o,d){if(q(i)){var g=!0;Be(n)}else g=!1;if(li(n,d),n.stateNode===null)xo(t,n),Gd(n,i,o),Pc(n,i,o,d),o=!0;else if(t===null){var j=n.stateNode,M=n.memoizedProps;j.props=M;var W=j.context,ue=i.contextType;typeof ue=="object"&&ue!==null?ue=es(ue):(ue=q(i)?E:k.current,ue=ne(n,ue));var Ce=i.getDerivedStateFromProps,Ee=typeof Ce=="function"||typeof j.getSnapshotBeforeUpdate=="function";Ee||typeof j.UNSAFE_componentWillReceiveProps!="function"&&typeof j.componentWillReceiveProps!="function"||(M!==o||W!==ue)&&Kd(n,j,o,ue),Ca=!1;var Ne=n.memoizedState;j.state=Ne,uo(n,o,j,d),W=n.memoizedState,M!==o||Ne!==W||b.current||Ca?(typeof Ce=="function"&&(zc(n,i,Ce,o),W=n.memoizedState),(M=Ca||Vd(n,i,M,o,Ne,W,ue))?(Ee||typeof j.UNSAFE_componentWillMount!="function"&&typeof j.componentWillMount!="function"||(typeof j.componentWillMount=="function"&&j.componentWillMount(),typeof j.UNSAFE_componentWillMount=="function"&&j.UNSAFE_componentWillMount()),typeof j.componentDidMount=="function"&&(n.flags|=4194308)):(typeof j.componentDidMount=="function"&&(n.flags|=4194308),n.memoizedProps=o,n.memoizedState=W),j.props=o,j.state=W,j.context=ue,o=M):(typeof j.componentDidMount=="function"&&(n.flags|=4194308),o=!1)}else{j=n.stateNode,wd(t,n),M=n.memoizedProps,ue=n.type===n.elementType?M:gs(n.type,M),j.props=ue,Ee=n.pendingProps,Ne=j.context,W=i.contextType,typeof W=="object"&&W!==null?W=es(W):(W=q(i)?E:k.current,W=ne(n,W));var We=i.getDerivedStateFromProps;(Ce=typeof We=="function"||typeof j.getSnapshotBeforeUpdate=="function")||typeof j.UNSAFE_componentWillReceiveProps!="function"&&typeof j.componentWillReceiveProps!="function"||(M!==Ee||Ne!==W)&&Kd(n,j,o,W),Ca=!1,Ne=n.memoizedState,j.state=Ne,uo(n,o,j,d);var Ve=n.memoizedState;M!==Ee||Ne!==Ve||b.current||Ca?(typeof We=="function"&&(zc(n,i,We,o),Ve=n.memoizedState),(ue=Ca||Vd(n,i,ue,o,Ne,Ve,W)||!1)?(Ce||typeof j.UNSAFE_componentWillUpdate!="function"&&typeof j.componentWillUpdate!="function"||(typeof j.componentWillUpdate=="function"&&j.componentWillUpdate(o,Ve,W),typeof j.UNSAFE_componentWillUpdate=="function"&&j.UNSAFE_componentWillUpdate(o,Ve,W)),typeof j.componentDidUpdate=="function"&&(n.flags|=4),typeof j.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof j.componentDidUpdate!="function"||M===t.memoizedProps&&Ne===t.memoizedState||(n.flags|=4),typeof j.getSnapshotBeforeUpdate!="function"||M===t.memoizedProps&&Ne===t.memoizedState||(n.flags|=1024),n.memoizedProps=o,n.memoizedState=Ve),j.props=o,j.state=Ve,j.context=W,o=ue):(typeof j.componentDidUpdate!="function"||M===t.memoizedProps&&Ne===t.memoizedState||(n.flags|=4),typeof j.getSnapshotBeforeUpdate!="function"||M===t.memoizedProps&&Ne===t.memoizedState||(n.flags|=1024),o=!1)}return Fc(t,n,i,o,g,d)}function Fc(t,n,i,o,d,g){am(t,n);var j=(n.flags&128)!==0;if(!o&&!j)return d&&Rt(n,i,!1),ca(t,n,g);o=n.stateNode,Ph.current=n;var M=j&&typeof i.getDerivedStateFromError!="function"?null:o.render();return n.flags|=1,t!==null&&j?(n.child=ri(n,t.child,null,g),n.child=ri(n,null,M,g)):Sn(t,n,M,g),n.memoizedState=o.state,d&&Rt(n,i,!0),n.child}function im(t){var n=t.stateNode;n.pendingContext?Me(t,n.pendingContext,n.pendingContext!==n.context):n.context&&Me(t,n.context,!1),jc(t,n.containerInfo)}function lm(t,n,i,o,d){return ai(),_c(d),n.flags|=256,Sn(t,n,i,o),n.child}var qc={dehydrated:null,treeContext:null,retryLane:0};function Bc(t){return{baseLanes:t,cachePool:null,transitions:null}}function om(t,n,i){var o=n.pendingProps,d=It.current,g=!1,j=(n.flags&128)!==0,M;if((M=j)||(M=t!==null&&t.memoizedState===null?!1:(d&2)!==0),M?(g=!0,n.flags&=-129):(t===null||t.memoizedState!==null)&&(d|=1),u(It,d&1),t===null)return pc(n),t=n.memoizedState,t!==null&&(t=t.dehydrated,t!==null)?((n.mode&1)===0?n.lanes=1:t.data==="$!"?n.lanes=8:n.lanes=1073741824,null):(j=o.children,t=o.fallback,g?(o=n.mode,g=n.child,j={mode:"hidden",children:j},(o&1)===0&&g!==null?(g.childLanes=0,g.pendingProps=j):g=Ro(j,o,0,null),t=jr(t,o,i,null),g.return=n,t.return=n,g.sibling=t,n.child=g,n.child.memoizedState=Bc(i),n.memoizedState=qc,t):Uc(n,j));if(d=t.memoizedState,d!==null&&(M=d.dehydrated,M!==null))return Ih(t,n,j,o,M,d,i);if(g){g=o.fallback,j=n.mode,d=t.child,M=d.sibling;var W={mode:"hidden",children:o.children};return(j&1)===0&&n.child!==d?(o=n.child,o.childLanes=0,o.pendingProps=W,n.deletions=null):(o=Ma(d,W),o.subtreeFlags=d.subtreeFlags&14680064),M!==null?g=Ma(M,g):(g=jr(g,j,i,null),g.flags|=2),g.return=n,o.return=n,o.sibling=g,n.child=o,o=g,g=n.child,j=t.child.memoizedState,j=j===null?Bc(i):{baseLanes:j.baseLanes|i,cachePool:null,transitions:j.transitions},g.memoizedState=j,g.childLanes=t.childLanes&~i,n.memoizedState=qc,o}return g=t.child,t=g.sibling,o=Ma(g,{mode:"visible",children:o.children}),(n.mode&1)===0&&(o.lanes=i),o.return=n,o.sibling=null,t!==null&&(i=n.deletions,i===null?(n.deletions=[t],n.flags|=16):i.push(t)),n.child=o,n.memoizedState=null,o}function Uc(t,n){return n=Ro({mode:"visible",children:n},t.mode,0,null),n.return=t,t.child=n}function yo(t,n,i,o){return o!==null&&_c(o),ri(n,t.child,null,i),t=Uc(n,n.pendingProps.children),t.flags|=2,n.memoizedState=null,t}function Ih(t,n,i,o,d,g,j){if(i)return n.flags&256?(n.flags&=-257,o=Ic(Error(r(422))),yo(t,n,j,o)):n.memoizedState!==null?(n.child=t.child,n.flags|=128,null):(g=o.fallback,d=n.mode,o=Ro({mode:"visible",children:o.children},d,0,null),g=jr(g,d,j,null),g.flags|=2,o.return=n,g.return=n,o.sibling=g,n.child=o,(n.mode&1)!==0&&ri(n,t.child,null,j),n.child.memoizedState=Bc(j),n.memoizedState=qc,g);if((n.mode&1)===0)return yo(t,n,j,null);if(d.data==="$!"){if(o=d.nextSibling&&d.nextSibling.dataset,o)var M=o.dgst;return o=M,g=Error(r(419)),o=Ic(g,o,void 0),yo(t,n,j,o)}if(M=(j&t.childLanes)!==0,Ln||M){if(o=on,o!==null){switch(j&-j){case 4:d=2;break;case 16:d=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:d=32;break;case 536870912:d=268435456;break;default:d=0}d=(d&(o.suspendedLanes|j))!==0?0:d,d!==0&&d!==g.retryLane&&(g.retryLane=d,la(t,d),xs(o,t,d,-1))}return ru(),o=Ic(Error(r(421))),yo(t,n,j,o)}return d.data==="$?"?(n.flags|=128,n.child=t.child,n=Jh.bind(null,t),d._reactRetry=n,null):(t=g.treeContext,Vn=Rs(d.nextSibling),Hn=n,zt=!0,_s=null,t!==null&&(bt[ft++]=Rn,bt[ft++]=ia,bt[ft++]=Lt,Rn=t.id,ia=t.overflow,Lt=n),n=Uc(n,o.children),n.flags|=4096,n)}function cm(t,n,i){t.lanes|=n;var o=t.alternate;o!==null&&(o.lanes|=n),xc(t.return,n,i)}function Wc(t,n,i,o,d){var g=t.memoizedState;g===null?t.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:o,tail:i,tailMode:d}:(g.isBackwards=n,g.rendering=null,g.renderingStartTime=0,g.last=o,g.tail=i,g.tailMode=d)}function um(t,n,i){var o=n.pendingProps,d=o.revealOrder,g=o.tail;if(Sn(t,n,o.children,i),o=It.current,(o&2)!==0)o=o&1|2,n.flags|=128;else{if(t!==null&&(t.flags&128)!==0)e:for(t=n.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&cm(t,i,n);else if(t.tag===19)cm(t,i,n);else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===n)break e;for(;t.sibling===null;){if(t.return===null||t.return===n)break e;t=t.return}t.sibling.return=t.return,t=t.sibling}o&=1}if(u(It,o),(n.mode&1)===0)n.memoizedState=null;else switch(d){case"forwards":for(i=n.child,d=null;i!==null;)t=i.alternate,t!==null&&mo(t)===null&&(d=i),i=i.sibling;i=d,i===null?(d=n.child,n.child=null):(d=i.sibling,i.sibling=null),Wc(n,!1,d,i,g);break;case"backwards":for(i=null,d=n.child,n.child=null;d!==null;){if(t=d.alternate,t!==null&&mo(t)===null){n.child=d;break}t=d.sibling,d.sibling=i,i=d,d=t}Wc(n,!0,i,null,g);break;case"together":Wc(n,!1,null,null,void 0);break;default:n.memoizedState=null}return n.child}function xo(t,n){(n.mode&1)===0&&t!==null&&(t.alternate=null,n.alternate=null,n.flags|=2)}function ca(t,n,i){if(t!==null&&(n.dependencies=t.dependencies),yr|=n.lanes,(i&n.childLanes)===0)return null;if(t!==null&&n.child!==t.child)throw Error(r(153));if(n.child!==null){for(t=n.child,i=Ma(t,t.pendingProps),n.child=i,i.return=n;t.sibling!==null;)t=t.sibling,i=i.sibling=Ma(t,t.pendingProps),i.return=n;i.sibling=null}return n.child}function Oh(t,n,i){switch(n.tag){case 3:im(n),ai();break;case 5:kd(n);break;case 1:q(n.type)&&Be(n);break;case 4:jc(n,n.stateNode.containerInfo);break;case 10:var o=n.type._context,d=n.memoizedProps.value;u(lo,o._currentValue),o._currentValue=d;break;case 13:if(o=n.memoizedState,o!==null)return o.dehydrated!==null?(u(It,It.current&1),n.flags|=128,null):(i&n.child.childLanes)!==0?om(t,n,i):(u(It,It.current&1),t=ca(t,n,i),t!==null?t.sibling:null);u(It,It.current&1);break;case 19:if(o=(i&n.childLanes)!==0,(t.flags&128)!==0){if(o)return um(t,n,i);n.flags|=128}if(d=n.memoizedState,d!==null&&(d.rendering=null,d.tail=null,d.lastEffect=null),u(It,It.current),o)break;return null;case 22:case 23:return n.lanes=0,sm(t,n,i)}return ca(t,n,i)}var dm,Hc,mm,fm;dm=function(t,n){for(var i=n.child;i!==null;){if(i.tag===5||i.tag===6)t.appendChild(i.stateNode);else if(i.tag!==4&&i.child!==null){i.child.return=i,i=i.child;continue}if(i===n)break;for(;i.sibling===null;){if(i.return===null||i.return===n)return;i=i.return}i.sibling.return=i.return,i=i.sibling}},Hc=function(){},mm=function(t,n,i,o){var d=t.memoizedProps;if(d!==o){t=n.stateNode,gr(Ms.current);var g=null;switch(i){case"input":d=ze(t,d),o=ze(t,o),g=[];break;case"select":d=Y({},d,{value:void 0}),o=Y({},o,{value:void 0}),g=[];break;case"textarea":d=ye(t,d),o=ye(t,o),g=[];break;default:typeof d.onClick!="function"&&typeof o.onClick=="function"&&(t.onclick=ti)}Ut(i,o);var j;i=null;for(ue in d)if(!o.hasOwnProperty(ue)&&d.hasOwnProperty(ue)&&d[ue]!=null)if(ue==="style"){var M=d[ue];for(j in M)M.hasOwnProperty(j)&&(i||(i={}),i[j]="")}else ue!=="dangerouslySetInnerHTML"&&ue!=="children"&&ue!=="suppressContentEditableWarning"&&ue!=="suppressHydrationWarning"&&ue!=="autoFocus"&&(c.hasOwnProperty(ue)?g||(g=[]):(g=g||[]).push(ue,null));for(ue in o){var W=o[ue];if(M=d!=null?d[ue]:void 0,o.hasOwnProperty(ue)&&W!==M&&(W!=null||M!=null))if(ue==="style")if(M){for(j in M)!M.hasOwnProperty(j)||W&&W.hasOwnProperty(j)||(i||(i={}),i[j]="");for(j in W)W.hasOwnProperty(j)&&M[j]!==W[j]&&(i||(i={}),i[j]=W[j])}else i||(g||(g=[]),g.push(ue,i)),i=W;else ue==="dangerouslySetInnerHTML"?(W=W?W.__html:void 0,M=M?M.__html:void 0,W!=null&&M!==W&&(g=g||[]).push(ue,W)):ue==="children"?typeof W!="string"&&typeof W!="number"||(g=g||[]).push(ue,""+W):ue!=="suppressContentEditableWarning"&&ue!=="suppressHydrationWarning"&&(c.hasOwnProperty(ue)?(W!=null&&ue==="onScroll"&&Et("scroll",t),g||M===W||(g=[])):(g=g||[]).push(ue,W))}i&&(g=g||[]).push("style",i);var ue=g;(n.updateQueue=ue)&&(n.flags|=4)}},fm=function(t,n,i,o){i!==o&&(n.flags|=4)};function ll(t,n){if(!zt)switch(t.tailMode){case"hidden":n=t.tail;for(var i=null;n!==null;)n.alternate!==null&&(i=n),n=n.sibling;i===null?t.tail=null:i.sibling=null;break;case"collapsed":i=t.tail;for(var o=null;i!==null;)i.alternate!==null&&(o=i),i=i.sibling;o===null?n||t.tail===null?t.tail=null:t.tail.sibling=null:o.sibling=null}}function bn(t){var n=t.alternate!==null&&t.alternate.child===t.child,i=0,o=0;if(n)for(var d=t.child;d!==null;)i|=d.lanes|d.childLanes,o|=d.subtreeFlags&14680064,o|=d.flags&14680064,d.return=t,d=d.sibling;else for(d=t.child;d!==null;)i|=d.lanes|d.childLanes,o|=d.subtreeFlags,o|=d.flags,d.return=t,d=d.sibling;return t.subtreeFlags|=o,t.childLanes=i,n}function Dh(t,n,i){var o=n.pendingProps;switch(fc(n),n.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return bn(n),null;case 1:return q(n.type)&&ve(),bn(n),null;case 3:return o=n.stateNode,oi(),Nt(b),Nt(k),Nc(),o.pendingContext&&(o.context=o.pendingContext,o.pendingContext=null),(t===null||t.child===null)&&(ro(n)?n.flags|=4:t===null||t.memoizedState.isDehydrated&&(n.flags&256)===0||(n.flags|=1024,_s!==null&&(nu(_s),_s=null))),Hc(t,n),bn(n),null;case 5:kc(n);var d=gr(nl.current);if(i=n.type,t!==null&&n.stateNode!=null)mm(t,n,i,o,d),t.ref!==n.ref&&(n.flags|=512,n.flags|=2097152);else{if(!o){if(n.stateNode===null)throw Error(r(166));return bn(n),null}if(t=gr(Ms.current),ro(n)){o=n.stateNode,i=n.type;var g=n.memoizedProps;switch(o[Tn]=n,o[mr]=g,t=(n.mode&1)!==0,i){case"dialog":Et("cancel",o),Et("close",o);break;case"iframe":case"object":case"embed":Et("load",o);break;case"video":case"audio":for(d=0;d<ta.length;d++)Et(ta[d],o);break;case"source":Et("error",o);break;case"img":case"image":case"link":Et("error",o),Et("load",o);break;case"details":Et("toggle",o);break;case"input":re(o,g),Et("invalid",o);break;case"select":o._wrapperState={wasMultiple:!!g.multiple},Et("invalid",o);break;case"textarea":Oe(o,g),Et("invalid",o)}Ut(i,g),d=null;for(var j in g)if(g.hasOwnProperty(j)){var M=g[j];j==="children"?typeof M=="string"?o.textContent!==M&&(g.suppressHydrationWarning!==!0&&sa(o.textContent,M,t),d=["children",M]):typeof M=="number"&&o.textContent!==""+M&&(g.suppressHydrationWarning!==!0&&sa(o.textContent,M,t),d=["children",""+M]):c.hasOwnProperty(j)&&M!=null&&j==="onScroll"&&Et("scroll",o)}switch(i){case"input":Ye(o),me(o,g,!0);break;case"textarea":Ye(o),xt(o);break;case"select":case"option":break;default:typeof g.onClick=="function"&&(o.onclick=ti)}o=d,n.updateQueue=o,o!==null&&(n.flags|=4)}else{j=d.nodeType===9?d:d.ownerDocument,t==="http://www.w3.org/1999/xhtml"&&(t=pe(i)),t==="http://www.w3.org/1999/xhtml"?i==="script"?(t=j.createElement("div"),t.innerHTML="<script><\/script>",t=t.removeChild(t.firstChild)):typeof o.is=="string"?t=j.createElement(i,{is:o.is}):(t=j.createElement(i),i==="select"&&(j=t,o.multiple?j.multiple=!0:o.size&&(j.size=o.size))):t=j.createElementNS(t,i),t[Tn]=n,t[mr]=o,dm(t,n,!1,!1),n.stateNode=t;e:{switch(j=Dt(i,o),i){case"dialog":Et("cancel",t),Et("close",t),d=o;break;case"iframe":case"object":case"embed":Et("load",t),d=o;break;case"video":case"audio":for(d=0;d<ta.length;d++)Et(ta[d],t);d=o;break;case"source":Et("error",t),d=o;break;case"img":case"image":case"link":Et("error",t),Et("load",t),d=o;break;case"details":Et("toggle",t),d=o;break;case"input":re(t,o),d=ze(t,o),Et("invalid",t);break;case"option":d=o;break;case"select":t._wrapperState={wasMultiple:!!o.multiple},d=Y({},o,{value:void 0}),Et("invalid",t);break;case"textarea":Oe(t,o),d=ye(t,o),Et("invalid",t);break;default:d=o}Ut(i,d),M=d;for(g in M)if(M.hasOwnProperty(g)){var W=M[g];g==="style"?wt(t,W):g==="dangerouslySetInnerHTML"?(W=W?W.__html:void 0,W!=null&&$e(t,W)):g==="children"?typeof W=="string"?(i!=="textarea"||W!=="")&&Ae(t,W):typeof W=="number"&&Ae(t,""+W):g!=="suppressContentEditableWarning"&&g!=="suppressHydrationWarning"&&g!=="autoFocus"&&(c.hasOwnProperty(g)?W!=null&&g==="onScroll"&&Et("scroll",t):W!=null&&B(t,g,W,j))}switch(i){case"input":Ye(t),me(t,o,!1);break;case"textarea":Ye(t),xt(t);break;case"option":o.value!=null&&t.setAttribute("value",""+be(o.value));break;case"select":t.multiple=!!o.multiple,g=o.value,g!=null?le(t,!!o.multiple,g,!1):o.defaultValue!=null&&le(t,!!o.multiple,o.defaultValue,!0);break;default:typeof d.onClick=="function"&&(t.onclick=ti)}switch(i){case"button":case"input":case"select":case"textarea":o=!!o.autoFocus;break e;case"img":o=!0;break e;default:o=!1}}o&&(n.flags|=4)}n.ref!==null&&(n.flags|=512,n.flags|=2097152)}return bn(n),null;case 6:if(t&&n.stateNode!=null)fm(t,n,t.memoizedProps,o);else{if(typeof o!="string"&&n.stateNode===null)throw Error(r(166));if(i=gr(nl.current),gr(Ms.current),ro(n)){if(o=n.stateNode,i=n.memoizedProps,o[Tn]=n,(g=o.nodeValue!==i)&&(t=Hn,t!==null))switch(t.tag){case 3:sa(o.nodeValue,i,(t.mode&1)!==0);break;case 5:t.memoizedProps.suppressHydrationWarning!==!0&&sa(o.nodeValue,i,(t.mode&1)!==0)}g&&(n.flags|=4)}else o=(i.nodeType===9?i:i.ownerDocument).createTextNode(o),o[Tn]=n,n.stateNode=o}return bn(n),null;case 13:if(Nt(It),o=n.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(zt&&Vn!==null&&(n.mode&1)!==0&&(n.flags&128)===0)_d(),ai(),n.flags|=98560,g=!1;else if(g=ro(n),o!==null&&o.dehydrated!==null){if(t===null){if(!g)throw Error(r(318));if(g=n.memoizedState,g=g!==null?g.dehydrated:null,!g)throw Error(r(317));g[Tn]=n}else ai(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;bn(n),g=!1}else _s!==null&&(nu(_s),_s=null),g=!0;if(!g)return n.flags&65536?n:null}return(n.flags&128)!==0?(n.lanes=i,n):(o=o!==null,o!==(t!==null&&t.memoizedState!==null)&&o&&(n.child.flags|=8192,(n.mode&1)!==0&&(t===null||(It.current&1)!==0?tn===0&&(tn=3):ru())),n.updateQueue!==null&&(n.flags|=4),bn(n),null);case 4:return oi(),Hc(t,n),t===null&&ka(n.stateNode.containerInfo),bn(n),null;case 10:return yc(n.type._context),bn(n),null;case 17:return q(n.type)&&ve(),bn(n),null;case 19:if(Nt(It),g=n.memoizedState,g===null)return bn(n),null;if(o=(n.flags&128)!==0,j=g.rendering,j===null)if(o)ll(g,!1);else{if(tn!==0||t!==null&&(t.flags&128)!==0)for(t=n.child;t!==null;){if(j=mo(t),j!==null){for(n.flags|=128,ll(g,!1),o=j.updateQueue,o!==null&&(n.updateQueue=o,n.flags|=4),n.subtreeFlags=0,o=i,i=n.child;i!==null;)g=i,t=o,g.flags&=14680066,j=g.alternate,j===null?(g.childLanes=0,g.lanes=t,g.child=null,g.subtreeFlags=0,g.memoizedProps=null,g.memoizedState=null,g.updateQueue=null,g.dependencies=null,g.stateNode=null):(g.childLanes=j.childLanes,g.lanes=j.lanes,g.child=j.child,g.subtreeFlags=0,g.deletions=null,g.memoizedProps=j.memoizedProps,g.memoizedState=j.memoizedState,g.updateQueue=j.updateQueue,g.type=j.type,t=j.dependencies,g.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),i=i.sibling;return u(It,It.current&1|2),n.child}t=t.sibling}g.tail!==null&&At()>mi&&(n.flags|=128,o=!0,ll(g,!1),n.lanes=4194304)}else{if(!o)if(t=mo(j),t!==null){if(n.flags|=128,o=!0,i=t.updateQueue,i!==null&&(n.updateQueue=i,n.flags|=4),ll(g,!0),g.tail===null&&g.tailMode==="hidden"&&!j.alternate&&!zt)return bn(n),null}else 2*At()-g.renderingStartTime>mi&&i!==1073741824&&(n.flags|=128,o=!0,ll(g,!1),n.lanes=4194304);g.isBackwards?(j.sibling=n.child,n.child=j):(i=g.last,i!==null?i.sibling=j:n.child=j,g.last=j)}return g.tail!==null?(n=g.tail,g.rendering=n,g.tail=n.sibling,g.renderingStartTime=At(),n.sibling=null,i=It.current,u(It,o?i&1|2:i&1),n):(bn(n),null);case 22:case 23:return au(),o=n.memoizedState!==null,t!==null&&t.memoizedState!==null!==o&&(n.flags|=8192),o&&(n.mode&1)!==0?(Gn&1073741824)!==0&&(bn(n),n.subtreeFlags&6&&(n.flags|=8192)):bn(n),null;case 24:return null;case 25:return null}throw Error(r(156,n.tag))}function Fh(t,n){switch(fc(n),n.tag){case 1:return q(n.type)&&ve(),t=n.flags,t&65536?(n.flags=t&-65537|128,n):null;case 3:return oi(),Nt(b),Nt(k),Nc(),t=n.flags,(t&65536)!==0&&(t&128)===0?(n.flags=t&-65537|128,n):null;case 5:return kc(n),null;case 13:if(Nt(It),t=n.memoizedState,t!==null&&t.dehydrated!==null){if(n.alternate===null)throw Error(r(340));ai()}return t=n.flags,t&65536?(n.flags=t&-65537|128,n):null;case 19:return Nt(It),null;case 4:return oi(),null;case 10:return yc(n.type._context),null;case 22:case 23:return au(),null;case 24:return null;default:return null}}var wo=!1,jn=!1,qh=typeof WeakSet=="function"?WeakSet:Set,He=null;function ui(t,n){var i=t.ref;if(i!==null)if(typeof i=="function")try{i(null)}catch(o){Bt(t,n,o)}else i.current=null}function Vc(t,n,i){try{i()}catch(o){Bt(t,n,o)}}var hm=!1;function Bh(t,n){if(dr=Ya,t=Ql(),Ui(t)){if("selectionStart"in t)var i={start:t.selectionStart,end:t.selectionEnd};else e:{i=(i=t.ownerDocument)&&i.defaultView||window;var o=i.getSelection&&i.getSelection();if(o&&o.rangeCount!==0){i=o.anchorNode;var d=o.anchorOffset,g=o.focusNode;o=o.focusOffset;try{i.nodeType,g.nodeType}catch{i=null;break e}var j=0,M=-1,W=-1,ue=0,Ce=0,Ee=t,Ne=null;t:for(;;){for(var We;Ee!==i||d!==0&&Ee.nodeType!==3||(M=j+d),Ee!==g||o!==0&&Ee.nodeType!==3||(W=j+o),Ee.nodeType===3&&(j+=Ee.nodeValue.length),(We=Ee.firstChild)!==null;)Ne=Ee,Ee=We;for(;;){if(Ee===t)break t;if(Ne===i&&++ue===d&&(M=j),Ne===g&&++Ce===o&&(W=j),(We=Ee.nextSibling)!==null)break;Ee=Ne,Ne=Ee.parentNode}Ee=We}i=M===-1||W===-1?null:{start:M,end:W}}else i=null}i=i||{start:0,end:0}}else i=null;for(Qi={focusedElem:t,selectionRange:i},Ya=!1,He=n;He!==null;)if(n=He,t=n.child,(n.subtreeFlags&1028)!==0&&t!==null)t.return=n,He=t;else for(;He!==null;){n=He;try{var Ve=n.alternate;if((n.flags&1024)!==0)switch(n.tag){case 0:case 11:case 15:break;case 1:if(Ve!==null){var Qe=Ve.memoizedProps,Vt=Ve.memoizedState,se=n.stateNode,Q=se.getSnapshotBeforeUpdate(n.elementType===n.type?Qe:gs(n.type,Qe),Vt);se.__reactInternalSnapshotBeforeUpdate=Q}break;case 3:var oe=n.stateNode.containerInfo;oe.nodeType===1?oe.textContent="":oe.nodeType===9&&oe.documentElement&&oe.removeChild(oe.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(r(163))}}catch(Pe){Bt(n,n.return,Pe)}if(t=n.sibling,t!==null){t.return=n.return,He=t;break}He=n.return}return Ve=hm,hm=!1,Ve}function ol(t,n,i){var o=n.updateQueue;if(o=o!==null?o.lastEffect:null,o!==null){var d=o=o.next;do{if((d.tag&t)===t){var g=d.destroy;d.destroy=void 0,g!==void 0&&Vc(n,i,g)}d=d.next}while(d!==o)}}function bo(t,n){if(n=n.updateQueue,n=n!==null?n.lastEffect:null,n!==null){var i=n=n.next;do{if((i.tag&t)===t){var o=i.create;i.destroy=o()}i=i.next}while(i!==n)}}function Gc(t){var n=t.ref;if(n!==null){var i=t.stateNode;switch(t.tag){case 5:t=i;break;default:t=i}typeof n=="function"?n(t):n.current=t}}function pm(t){var n=t.alternate;n!==null&&(t.alternate=null,pm(n)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(n=t.stateNode,n!==null&&(delete n[Tn],delete n[mr],delete n[Xi],delete n[dc],delete n[ao])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function _m(t){return t.tag===5||t.tag===3||t.tag===4}function gm(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||_m(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function Kc(t,n,i){var o=t.tag;if(o===5||o===6)t=t.stateNode,n?i.nodeType===8?i.parentNode.insertBefore(t,n):i.insertBefore(t,n):(i.nodeType===8?(n=i.parentNode,n.insertBefore(t,i)):(n=i,n.appendChild(t)),i=i._reactRootContainer,i!=null||n.onclick!==null||(n.onclick=ti));else if(o!==4&&(t=t.child,t!==null))for(Kc(t,n,i),t=t.sibling;t!==null;)Kc(t,n,i),t=t.sibling}function Qc(t,n,i){var o=t.tag;if(o===5||o===6)t=t.stateNode,n?i.insertBefore(t,n):i.appendChild(t);else if(o!==4&&(t=t.child,t!==null))for(Qc(t,n,i),t=t.sibling;t!==null;)Qc(t,n,i),t=t.sibling}var _n=null,vs=!1;function Ea(t,n,i){for(i=i.child;i!==null;)vm(t,n,i),i=i.sibling}function vm(t,n,i){if(dn&&typeof dn.onCommitFiberUnmount=="function")try{dn.onCommitFiberUnmount(Va,i)}catch{}switch(i.tag){case 5:jn||ui(i,n);case 6:var o=_n,d=vs;_n=null,Ea(t,n,i),_n=o,vs=d,_n!==null&&(vs?(t=_n,i=i.stateNode,t.nodeType===8?t.parentNode.removeChild(i):t.removeChild(i)):_n.removeChild(i.stateNode));break;case 18:_n!==null&&(vs?(t=_n,i=i.stateNode,t.nodeType===8?Yi(t.parentNode,i):t.nodeType===1&&Yi(t,i),ls(t)):Yi(_n,i.stateNode));break;case 4:o=_n,d=vs,_n=i.stateNode.containerInfo,vs=!0,Ea(t,n,i),_n=o,vs=d;break;case 0:case 11:case 14:case 15:if(!jn&&(o=i.updateQueue,o!==null&&(o=o.lastEffect,o!==null))){d=o=o.next;do{var g=d,j=g.destroy;g=g.tag,j!==void 0&&((g&2)!==0||(g&4)!==0)&&Vc(i,n,j),d=d.next}while(d!==o)}Ea(t,n,i);break;case 1:if(!jn&&(ui(i,n),o=i.stateNode,typeof o.componentWillUnmount=="function"))try{o.props=i.memoizedProps,o.state=i.memoizedState,o.componentWillUnmount()}catch(M){Bt(i,n,M)}Ea(t,n,i);break;case 21:Ea(t,n,i);break;case 22:i.mode&1?(jn=(o=jn)||i.memoizedState!==null,Ea(t,n,i),jn=o):Ea(t,n,i);break;default:Ea(t,n,i)}}function ym(t){var n=t.updateQueue;if(n!==null){t.updateQueue=null;var i=t.stateNode;i===null&&(i=t.stateNode=new qh),n.forEach(function(o){var d=Yh.bind(null,t,o);i.has(o)||(i.add(o),o.then(d,d))})}}function ys(t,n){var i=n.deletions;if(i!==null)for(var o=0;o<i.length;o++){var d=i[o];try{var g=t,j=n,M=j;e:for(;M!==null;){switch(M.tag){case 5:_n=M.stateNode,vs=!1;break e;case 3:_n=M.stateNode.containerInfo,vs=!0;break e;case 4:_n=M.stateNode.containerInfo,vs=!0;break e}M=M.return}if(_n===null)throw Error(r(160));vm(g,j,d),_n=null,vs=!1;var W=d.alternate;W!==null&&(W.return=null),d.return=null}catch(ue){Bt(d,n,ue)}}if(n.subtreeFlags&12854)for(n=n.child;n!==null;)xm(n,t),n=n.sibling}function xm(t,n){var i=t.alternate,o=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:if(ys(n,t),Ps(t),o&4){try{ol(3,t,t.return),bo(3,t)}catch(Qe){Bt(t,t.return,Qe)}try{ol(5,t,t.return)}catch(Qe){Bt(t,t.return,Qe)}}break;case 1:ys(n,t),Ps(t),o&512&&i!==null&&ui(i,i.return);break;case 5:if(ys(n,t),Ps(t),o&512&&i!==null&&ui(i,i.return),t.flags&32){var d=t.stateNode;try{Ae(d,"")}catch(Qe){Bt(t,t.return,Qe)}}if(o&4&&(d=t.stateNode,d!=null)){var g=t.memoizedProps,j=i!==null?i.memoizedProps:g,M=t.type,W=t.updateQueue;if(t.updateQueue=null,W!==null)try{M==="input"&&g.type==="radio"&&g.name!=null&&xe(d,g),Dt(M,j);var ue=Dt(M,g);for(j=0;j<W.length;j+=2){var Ce=W[j],Ee=W[j+1];Ce==="style"?wt(d,Ee):Ce==="dangerouslySetInnerHTML"?$e(d,Ee):Ce==="children"?Ae(d,Ee):B(d,Ce,Ee,ue)}switch(M){case"input":O(d,g);break;case"textarea":ot(d,g);break;case"select":var Ne=d._wrapperState.wasMultiple;d._wrapperState.wasMultiple=!!g.multiple;var We=g.value;We!=null?le(d,!!g.multiple,We,!1):Ne!==!!g.multiple&&(g.defaultValue!=null?le(d,!!g.multiple,g.defaultValue,!0):le(d,!!g.multiple,g.multiple?[]:"",!1))}d[mr]=g}catch(Qe){Bt(t,t.return,Qe)}}break;case 6:if(ys(n,t),Ps(t),o&4){if(t.stateNode===null)throw Error(r(162));d=t.stateNode,g=t.memoizedProps;try{d.nodeValue=g}catch(Qe){Bt(t,t.return,Qe)}}break;case 3:if(ys(n,t),Ps(t),o&4&&i!==null&&i.memoizedState.isDehydrated)try{ls(n.containerInfo)}catch(Qe){Bt(t,t.return,Qe)}break;case 4:ys(n,t),Ps(t);break;case 13:ys(n,t),Ps(t),d=t.child,d.flags&8192&&(g=d.memoizedState!==null,d.stateNode.isHidden=g,!g||d.alternate!==null&&d.alternate.memoizedState!==null||(Xc=At())),o&4&&ym(t);break;case 22:if(Ce=i!==null&&i.memoizedState!==null,t.mode&1?(jn=(ue=jn)||Ce,ys(n,t),jn=ue):ys(n,t),Ps(t),o&8192){if(ue=t.memoizedState!==null,(t.stateNode.isHidden=ue)&&!Ce&&(t.mode&1)!==0)for(He=t,Ce=t.child;Ce!==null;){for(Ee=He=Ce;He!==null;){switch(Ne=He,We=Ne.child,Ne.tag){case 0:case 11:case 14:case 15:ol(4,Ne,Ne.return);break;case 1:ui(Ne,Ne.return);var Ve=Ne.stateNode;if(typeof Ve.componentWillUnmount=="function"){o=Ne,i=Ne.return;try{n=o,Ve.props=n.memoizedProps,Ve.state=n.memoizedState,Ve.componentWillUnmount()}catch(Qe){Bt(o,i,Qe)}}break;case 5:ui(Ne,Ne.return);break;case 22:if(Ne.memoizedState!==null){jm(Ee);continue}}We!==null?(We.return=Ne,He=We):jm(Ee)}Ce=Ce.sibling}e:for(Ce=null,Ee=t;;){if(Ee.tag===5){if(Ce===null){Ce=Ee;try{d=Ee.stateNode,ue?(g=d.style,typeof g.setProperty=="function"?g.setProperty("display","none","important"):g.display="none"):(M=Ee.stateNode,W=Ee.memoizedProps.style,j=W!=null&&W.hasOwnProperty("display")?W.display:null,M.style.display=ct("display",j))}catch(Qe){Bt(t,t.return,Qe)}}}else if(Ee.tag===6){if(Ce===null)try{Ee.stateNode.nodeValue=ue?"":Ee.memoizedProps}catch(Qe){Bt(t,t.return,Qe)}}else if((Ee.tag!==22&&Ee.tag!==23||Ee.memoizedState===null||Ee===t)&&Ee.child!==null){Ee.child.return=Ee,Ee=Ee.child;continue}if(Ee===t)break e;for(;Ee.sibling===null;){if(Ee.return===null||Ee.return===t)break e;Ce===Ee&&(Ce=null),Ee=Ee.return}Ce===Ee&&(Ce=null),Ee.sibling.return=Ee.return,Ee=Ee.sibling}}break;case 19:ys(n,t),Ps(t),o&4&&ym(t);break;case 21:break;default:ys(n,t),Ps(t)}}function Ps(t){var n=t.flags;if(n&2){try{e:{for(var i=t.return;i!==null;){if(_m(i)){var o=i;break e}i=i.return}throw Error(r(160))}switch(o.tag){case 5:var d=o.stateNode;o.flags&32&&(Ae(d,""),o.flags&=-33);var g=gm(t);Qc(t,g,d);break;case 3:case 4:var j=o.stateNode.containerInfo,M=gm(t);Kc(t,M,j);break;default:throw Error(r(161))}}catch(W){Bt(t,t.return,W)}t.flags&=-3}n&4096&&(t.flags&=-4097)}function Uh(t,n,i){He=t,wm(t)}function wm(t,n,i){for(var o=(t.mode&1)!==0;He!==null;){var d=He,g=d.child;if(d.tag===22&&o){var j=d.memoizedState!==null||wo;if(!j){var M=d.alternate,W=M!==null&&M.memoizedState!==null||jn;M=wo;var ue=jn;if(wo=j,(jn=W)&&!ue)for(He=d;He!==null;)j=He,W=j.child,j.tag===22&&j.memoizedState!==null?km(d):W!==null?(W.return=j,He=W):km(d);for(;g!==null;)He=g,wm(g),g=g.sibling;He=d,wo=M,jn=ue}bm(t)}else(d.subtreeFlags&8772)!==0&&g!==null?(g.return=d,He=g):bm(t)}}function bm(t){for(;He!==null;){var n=He;if((n.flags&8772)!==0){var i=n.alternate;try{if((n.flags&8772)!==0)switch(n.tag){case 0:case 11:case 15:jn||bo(5,n);break;case 1:var o=n.stateNode;if(n.flags&4&&!jn)if(i===null)o.componentDidMount();else{var d=n.elementType===n.type?i.memoizedProps:gs(n.type,i.memoizedProps);o.componentDidUpdate(d,i.memoizedState,o.__reactInternalSnapshotBeforeUpdate)}var g=n.updateQueue;g!==null&&jd(n,g,o);break;case 3:var j=n.updateQueue;if(j!==null){if(i=null,n.child!==null)switch(n.child.tag){case 5:i=n.child.stateNode;break;case 1:i=n.child.stateNode}jd(n,j,i)}break;case 5:var M=n.stateNode;if(i===null&&n.flags&4){i=M;var W=n.memoizedProps;switch(n.type){case"button":case"input":case"select":case"textarea":W.autoFocus&&i.focus();break;case"img":W.src&&(i.src=W.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(n.memoizedState===null){var ue=n.alternate;if(ue!==null){var Ce=ue.memoizedState;if(Ce!==null){var Ee=Ce.dehydrated;Ee!==null&&ls(Ee)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(r(163))}jn||n.flags&512&&Gc(n)}catch(Ne){Bt(n,n.return,Ne)}}if(n===t){He=null;break}if(i=n.sibling,i!==null){i.return=n.return,He=i;break}He=n.return}}function jm(t){for(;He!==null;){var n=He;if(n===t){He=null;break}var i=n.sibling;if(i!==null){i.return=n.return,He=i;break}He=n.return}}function km(t){for(;He!==null;){var n=He;try{switch(n.tag){case 0:case 11:case 15:var i=n.return;try{bo(4,n)}catch(W){Bt(n,i,W)}break;case 1:var o=n.stateNode;if(typeof o.componentDidMount=="function"){var d=n.return;try{o.componentDidMount()}catch(W){Bt(n,d,W)}}var g=n.return;try{Gc(n)}catch(W){Bt(n,g,W)}break;case 5:var j=n.return;try{Gc(n)}catch(W){Bt(n,j,W)}}}catch(W){Bt(n,n.return,W)}if(n===t){He=null;break}var M=n.sibling;if(M!==null){M.return=n.return,He=M;break}He=n.return}}var Wh=Math.ceil,jo=ee.ReactCurrentDispatcher,Jc=ee.ReactCurrentOwner,ns=ee.ReactCurrentBatchConfig,_t=0,on=null,Qt=null,gn=0,Gn=0,di=ps(0),tn=0,cl=null,yr=0,ko=0,Yc=0,ul=null,Mn=null,Xc=0,mi=1/0,ua=null,So=!1,Zc=null,Ta=null,No=!1,Aa=null,Co=0,dl=0,eu=null,$o=-1,Eo=0;function Nn(){return(_t&6)!==0?At():$o!==-1?$o:$o=At()}function Ra(t){return(t.mode&1)===0?1:(_t&2)!==0&&gn!==0?gn&-gn:Ch.transition!==null?(Eo===0&&(Eo=Bs()),Eo):(t=dt,t!==0||(t=window.event,t=t===void 0?16:Or(t.type)),t)}function xs(t,n,i,o){if(50<dl)throw dl=0,eu=null,Error(r(185));Mt(t,i,o),((_t&2)===0||t!==on)&&(t===on&&((_t&2)===0&&(ko|=i),tn===4&&La(t,gn)),zn(t,o),i===1&&_t===0&&(n.mode&1)===0&&(mi=At()+500,An&&vt()))}function zn(t,n){var i=t.callbackNode;Lr(t,n);var o=Pt(t,t===on?gn:0);if(o===0)i!==null&&Wa(i),t.callbackNode=null,t.callbackPriority=0;else if(n=o&-o,t.callbackPriority!==n){if(i!=null&&Wa(i),n===1)t.tag===0?xn(Nm.bind(null,t)):at(Nm.bind(null,t)),no(function(){(_t&6)===0&&vt()}),i=null;else{switch(Pr(o)){case 1:i=Ha;break;case 4:i=Fs;break;case 16:i=rs;break;case 536870912:i=pa;break;default:i=rs}i=Mm(i,Sm.bind(null,t))}t.callbackPriority=n,t.callbackNode=i}}function Sm(t,n){if($o=-1,Eo=0,(_t&6)!==0)throw Error(r(327));var i=t.callbackNode;if(fi()&&t.callbackNode!==i)return null;var o=Pt(t,t===on?gn:0);if(o===0)return null;if((o&30)!==0||(o&t.expiredLanes)!==0||n)n=To(t,o);else{n=o;var d=_t;_t|=2;var g=$m();(on!==t||gn!==n)&&(ua=null,mi=At()+500,wr(t,n));do try{Gh();break}catch(M){Cm(t,M)}while(!0);vc(),jo.current=g,_t=d,Qt!==null?n=0:(on=null,gn=0,n=tn)}if(n!==0){if(n===2&&(d=bs(t),d!==0&&(o=d,n=tu(t,d))),n===1)throw i=cl,wr(t,0),La(t,o),zn(t,At()),i;if(n===6)La(t,o);else{if(d=t.current.alternate,(o&30)===0&&!Hh(d)&&(n=To(t,o),n===2&&(g=bs(t),g!==0&&(o=g,n=tu(t,g))),n===1))throw i=cl,wr(t,0),La(t,o),zn(t,At()),i;switch(t.finishedWork=d,t.finishedLanes=o,n){case 0:case 1:throw Error(r(345));case 2:br(t,Mn,ua);break;case 3:if(La(t,o),(o&130023424)===o&&(n=Xc+500-At(),10<n)){if(Pt(t,0)!==0)break;if(d=t.suspendedLanes,(d&o)!==o){Nn(),t.pingedLanes|=t.suspendedLanes&d;break}t.timeoutHandle=ni(br.bind(null,t,Mn,ua),n);break}br(t,Mn,ua);break;case 4:if(La(t,o),(o&4194240)===o)break;for(n=t.eventTimes,d=-1;0<o;){var j=31-kn(o);g=1<<j,j=n[j],j>d&&(d=j),o&=~g}if(o=d,o=At()-o,o=(120>o?120:480>o?480:1080>o?1080:1920>o?1920:3e3>o?3e3:4320>o?4320:1960*Wh(o/1960))-o,10<o){t.timeoutHandle=ni(br.bind(null,t,Mn,ua),o);break}br(t,Mn,ua);break;case 5:br(t,Mn,ua);break;default:throw Error(r(329))}}}return zn(t,At()),t.callbackNode===i?Sm.bind(null,t):null}function tu(t,n){var i=ul;return t.current.memoizedState.isDehydrated&&(wr(t,n).flags|=256),t=To(t,n),t!==2&&(n=Mn,Mn=i,n!==null&&nu(n)),t}function nu(t){Mn===null?Mn=t:Mn.push.apply(Mn,t)}function Hh(t){for(var n=t;;){if(n.flags&16384){var i=n.updateQueue;if(i!==null&&(i=i.stores,i!==null))for(var o=0;o<i.length;o++){var d=i[o],g=d.getSnapshot;d=d.value;try{if(!En(g(),d))return!1}catch{return!1}}}if(i=n.child,n.subtreeFlags&16384&&i!==null)i.return=n,n=i;else{if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return!0;n=n.return}n.sibling.return=n.return,n=n.sibling}}return!0}function La(t,n){for(n&=~Yc,n&=~ko,t.suspendedLanes|=n,t.pingedLanes&=~n,t=t.expirationTimes;0<n;){var i=31-kn(n),o=1<<i;t[i]=-1,n&=~o}}function Nm(t){if((_t&6)!==0)throw Error(r(327));fi();var n=Pt(t,0);if((n&1)===0)return zn(t,At()),null;var i=To(t,n);if(t.tag!==0&&i===2){var o=bs(t);o!==0&&(n=o,i=tu(t,o))}if(i===1)throw i=cl,wr(t,0),La(t,n),zn(t,At()),i;if(i===6)throw Error(r(345));return t.finishedWork=t.current.alternate,t.finishedLanes=n,br(t,Mn,ua),zn(t,At()),null}function su(t,n){var i=_t;_t|=1;try{return t(n)}finally{_t=i,_t===0&&(mi=At()+500,An&&vt())}}function xr(t){Aa!==null&&Aa.tag===0&&(_t&6)===0&&fi();var n=_t;_t|=1;var i=ns.transition,o=dt;try{if(ns.transition=null,dt=1,t)return t()}finally{dt=o,ns.transition=i,_t=n,(_t&6)===0&&vt()}}function au(){Gn=di.current,Nt(di)}function wr(t,n){t.finishedWork=null,t.finishedLanes=0;var i=t.timeoutHandle;if(i!==-1&&(t.timeoutHandle=-1,cc(i)),Qt!==null)for(i=Qt.return;i!==null;){var o=i;switch(fc(o),o.tag){case 1:o=o.type.childContextTypes,o!=null&&ve();break;case 3:oi(),Nt(b),Nt(k),Nc();break;case 5:kc(o);break;case 4:oi();break;case 13:Nt(It);break;case 19:Nt(It);break;case 10:yc(o.type._context);break;case 22:case 23:au()}i=i.return}if(on=t,Qt=t=Ma(t.current,null),gn=Gn=n,tn=0,cl=null,Yc=ko=yr=0,Mn=ul=null,_r!==null){for(n=0;n<_r.length;n++)if(i=_r[n],o=i.interleaved,o!==null){i.interleaved=null;var d=o.next,g=i.pending;if(g!==null){var j=g.next;g.next=d,o.next=j}i.pending=o}_r=null}return t}function Cm(t,n){do{var i=Qt;try{if(vc(),fo.current=go,ho){for(var o=Ot.memoizedState;o!==null;){var d=o.queue;d!==null&&(d.pending=null),o=o.next}ho=!1}if(vr=0,ln=en=Ot=null,sl=!1,al=0,Jc.current=null,i===null||i.return===null){tn=1,cl=n,Qt=null;break}e:{var g=t,j=i.return,M=i,W=n;if(n=gn,M.flags|=32768,W!==null&&typeof W=="object"&&typeof W.then=="function"){var ue=W,Ce=M,Ee=Ce.tag;if((Ce.mode&1)===0&&(Ee===0||Ee===11||Ee===15)){var Ne=Ce.alternate;Ne?(Ce.updateQueue=Ne.updateQueue,Ce.memoizedState=Ne.memoizedState,Ce.lanes=Ne.lanes):(Ce.updateQueue=null,Ce.memoizedState=null)}var We=Xd(j);if(We!==null){We.flags&=-257,Zd(We,j,M,g,n),We.mode&1&&Yd(g,ue,n),n=We,W=ue;var Ve=n.updateQueue;if(Ve===null){var Qe=new Set;Qe.add(W),n.updateQueue=Qe}else Ve.add(W);break e}else{if((n&1)===0){Yd(g,ue,n),ru();break e}W=Error(r(426))}}else if(zt&&M.mode&1){var Vt=Xd(j);if(Vt!==null){(Vt.flags&65536)===0&&(Vt.flags|=256),Zd(Vt,j,M,g,n),_c(ci(W,M));break e}}g=W=ci(W,M),tn!==4&&(tn=2),ul===null?ul=[g]:ul.push(g),g=j;do{switch(g.tag){case 3:g.flags|=65536,n&=-n,g.lanes|=n;var se=Qd(g,W,n);bd(g,se);break e;case 1:M=W;var Q=g.type,oe=g.stateNode;if((g.flags&128)===0&&(typeof Q.getDerivedStateFromError=="function"||oe!==null&&typeof oe.componentDidCatch=="function"&&(Ta===null||!Ta.has(oe)))){g.flags|=65536,n&=-n,g.lanes|=n;var Pe=Jd(g,M,n);bd(g,Pe);break e}}g=g.return}while(g!==null)}Tm(i)}catch(Je){n=Je,Qt===i&&i!==null&&(Qt=i=i.return);continue}break}while(!0)}function $m(){var t=jo.current;return jo.current=go,t===null?go:t}function ru(){(tn===0||tn===3||tn===2)&&(tn=4),on===null||(yr&268435455)===0&&(ko&268435455)===0||La(on,gn)}function To(t,n){var i=_t;_t|=2;var o=$m();(on!==t||gn!==n)&&(ua=null,wr(t,n));do try{Vh();break}catch(d){Cm(t,d)}while(!0);if(vc(),_t=i,jo.current=o,Qt!==null)throw Error(r(261));return on=null,gn=0,tn}function Vh(){for(;Qt!==null;)Em(Qt)}function Gh(){for(;Qt!==null&&!Al();)Em(Qt)}function Em(t){var n=Lm(t.alternate,t,Gn);t.memoizedProps=t.pendingProps,n===null?Tm(t):Qt=n,Jc.current=null}function Tm(t){var n=t;do{var i=n.alternate;if(t=n.return,(n.flags&32768)===0){if(i=Dh(i,n,Gn),i!==null){Qt=i;return}}else{if(i=Fh(i,n),i!==null){i.flags&=32767,Qt=i;return}if(t!==null)t.flags|=32768,t.subtreeFlags=0,t.deletions=null;else{tn=6,Qt=null;return}}if(n=n.sibling,n!==null){Qt=n;return}Qt=n=t}while(n!==null);tn===0&&(tn=5)}function br(t,n,i){var o=dt,d=ns.transition;try{ns.transition=null,dt=1,Kh(t,n,i,o)}finally{ns.transition=d,dt=o}return null}function Kh(t,n,i,o){do fi();while(Aa!==null);if((_t&6)!==0)throw Error(r(327));i=t.finishedWork;var d=t.finishedLanes;if(i===null)return null;if(t.finishedWork=null,t.finishedLanes=0,i===t.current)throw Error(r(177));t.callbackNode=null,t.callbackPriority=0;var g=i.lanes|i.childLanes;if(js(t,g),t===on&&(Qt=on=null,gn=0),(i.subtreeFlags&2064)===0&&(i.flags&2064)===0||No||(No=!0,Mm(rs,function(){return fi(),null})),g=(i.flags&15990)!==0,(i.subtreeFlags&15990)!==0||g){g=ns.transition,ns.transition=null;var j=dt;dt=1;var M=_t;_t|=4,Jc.current=null,Bh(t,i),xm(i,t),Jl(Qi),Ya=!!dr,Qi=dr=null,t.current=i,Uh(i),Ar(),_t=M,dt=j,ns.transition=g}else t.current=i;if(No&&(No=!1,Aa=t,Co=d),g=t.pendingLanes,g===0&&(Ta=null),Ll(i.stateNode),zn(t,At()),n!==null)for(o=t.onRecoverableError,i=0;i<n.length;i++)d=n[i],o(d.value,{componentStack:d.stack,digest:d.digest});if(So)throw So=!1,t=Zc,Zc=null,t;return(Co&1)!==0&&t.tag!==0&&fi(),g=t.pendingLanes,(g&1)!==0?t===eu?dl++:(dl=0,eu=t):dl=0,vt(),null}function fi(){if(Aa!==null){var t=Pr(Co),n=ns.transition,i=dt;try{if(ns.transition=null,dt=16>t?16:t,Aa===null)var o=!1;else{if(t=Aa,Aa=null,Co=0,(_t&6)!==0)throw Error(r(331));var d=_t;for(_t|=4,He=t.current;He!==null;){var g=He,j=g.child;if((He.flags&16)!==0){var M=g.deletions;if(M!==null){for(var W=0;W<M.length;W++){var ue=M[W];for(He=ue;He!==null;){var Ce=He;switch(Ce.tag){case 0:case 11:case 15:ol(8,Ce,g)}var Ee=Ce.child;if(Ee!==null)Ee.return=Ce,He=Ee;else for(;He!==null;){Ce=He;var Ne=Ce.sibling,We=Ce.return;if(pm(Ce),Ce===ue){He=null;break}if(Ne!==null){Ne.return=We,He=Ne;break}He=We}}}var Ve=g.alternate;if(Ve!==null){var Qe=Ve.child;if(Qe!==null){Ve.child=null;do{var Vt=Qe.sibling;Qe.sibling=null,Qe=Vt}while(Qe!==null)}}He=g}}if((g.subtreeFlags&2064)!==0&&j!==null)j.return=g,He=j;else e:for(;He!==null;){if(g=He,(g.flags&2048)!==0)switch(g.tag){case 0:case 11:case 15:ol(9,g,g.return)}var se=g.sibling;if(se!==null){se.return=g.return,He=se;break e}He=g.return}}var Q=t.current;for(He=Q;He!==null;){j=He;var oe=j.child;if((j.subtreeFlags&2064)!==0&&oe!==null)oe.return=j,He=oe;else e:for(j=Q;He!==null;){if(M=He,(M.flags&2048)!==0)try{switch(M.tag){case 0:case 11:case 15:bo(9,M)}}catch(Je){Bt(M,M.return,Je)}if(M===j){He=null;break e}var Pe=M.sibling;if(Pe!==null){Pe.return=M.return,He=Pe;break e}He=M.return}}if(_t=d,vt(),dn&&typeof dn.onPostCommitFiberRoot=="function")try{dn.onPostCommitFiberRoot(Va,t)}catch{}o=!0}return o}finally{dt=i,ns.transition=n}}return!1}function Am(t,n,i){n=ci(i,n),n=Qd(t,n,1),t=$a(t,n,1),n=Nn(),t!==null&&(Mt(t,1,n),zn(t,n))}function Bt(t,n,i){if(t.tag===3)Am(t,t,i);else for(;n!==null;){if(n.tag===3){Am(n,t,i);break}else if(n.tag===1){var o=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof o.componentDidCatch=="function"&&(Ta===null||!Ta.has(o))){t=ci(i,t),t=Jd(n,t,1),n=$a(n,t,1),t=Nn(),n!==null&&(Mt(n,1,t),zn(n,t));break}}n=n.return}}function Qh(t,n,i){var o=t.pingCache;o!==null&&o.delete(n),n=Nn(),t.pingedLanes|=t.suspendedLanes&i,on===t&&(gn&i)===i&&(tn===4||tn===3&&(gn&130023424)===gn&&500>At()-Xc?wr(t,0):Yc|=i),zn(t,n)}function Rm(t,n){n===0&&((t.mode&1)===0?n=1:(n=qs,qs<<=1,(qs&130023424)===0&&(qs=4194304)));var i=Nn();t=la(t,n),t!==null&&(Mt(t,n,i),zn(t,i))}function Jh(t){var n=t.memoizedState,i=0;n!==null&&(i=n.retryLane),Rm(t,i)}function Yh(t,n){var i=0;switch(t.tag){case 13:var o=t.stateNode,d=t.memoizedState;d!==null&&(i=d.retryLane);break;case 19:o=t.stateNode;break;default:throw Error(r(314))}o!==null&&o.delete(n),Rm(t,i)}var Lm;Lm=function(t,n,i){if(t!==null)if(t.memoizedProps!==n.pendingProps||b.current)Ln=!0;else{if((t.lanes&i)===0&&(n.flags&128)===0)return Ln=!1,Oh(t,n,i);Ln=(t.flags&131072)!==0}else Ln=!1,zt&&(n.flags&1048576)!==0&&md(n,Zt,n.index);switch(n.lanes=0,n.tag){case 2:var o=n.type;xo(t,n),t=n.pendingProps;var d=ne(n,k.current);li(n,i),d=Ec(null,n,o,t,d,i);var g=Tc();return n.flags|=1,typeof d=="object"&&d!==null&&typeof d.render=="function"&&d.$$typeof===void 0?(n.tag=1,n.memoizedState=null,n.updateQueue=null,q(o)?(g=!0,Be(n)):g=!1,n.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,bc(n),d.updater=vo,n.stateNode=d,d._reactInternals=n,Pc(n,o,t,i),n=Fc(null,n,o,!0,g,i)):(n.tag=0,zt&&g&&mc(n),Sn(null,n,d,i),n=n.child),n;case 16:o=n.elementType;e:{switch(xo(t,n),t=n.pendingProps,d=o._init,o=d(o._payload),n.type=o,d=n.tag=Zh(o),t=gs(o,t),d){case 0:n=Dc(null,n,o,t,i);break e;case 1:n=rm(null,n,o,t,i);break e;case 11:n=em(null,n,o,t,i);break e;case 14:n=tm(null,n,o,gs(o.type,t),i);break e}throw Error(r(306,o,""))}return n;case 0:return o=n.type,d=n.pendingProps,d=n.elementType===o?d:gs(o,d),Dc(t,n,o,d,i);case 1:return o=n.type,d=n.pendingProps,d=n.elementType===o?d:gs(o,d),rm(t,n,o,d,i);case 3:e:{if(im(n),t===null)throw Error(r(387));o=n.pendingProps,g=n.memoizedState,d=g.element,wd(t,n),uo(n,o,null,i);var j=n.memoizedState;if(o=j.element,g.isDehydrated)if(g={element:o,isDehydrated:!1,cache:j.cache,pendingSuspenseBoundaries:j.pendingSuspenseBoundaries,transitions:j.transitions},n.updateQueue.baseState=g,n.memoizedState=g,n.flags&256){d=ci(Error(r(423)),n),n=lm(t,n,o,i,d);break e}else if(o!==d){d=ci(Error(r(424)),n),n=lm(t,n,o,i,d);break e}else for(Vn=Rs(n.stateNode.containerInfo.firstChild),Hn=n,zt=!0,_s=null,i=yd(n,null,o,i),n.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if(ai(),o===d){n=ca(t,n,i);break e}Sn(t,n,o,i)}n=n.child}return n;case 5:return kd(n),t===null&&pc(n),o=n.type,d=n.pendingProps,g=t!==null?t.memoizedProps:null,j=d.children,Ji(o,d)?j=null:g!==null&&Ji(o,g)&&(n.flags|=32),am(t,n),Sn(t,n,j,i),n.child;case 6:return t===null&&pc(n),null;case 13:return om(t,n,i);case 4:return jc(n,n.stateNode.containerInfo),o=n.pendingProps,t===null?n.child=ri(n,null,o,i):Sn(t,n,o,i),n.child;case 11:return o=n.type,d=n.pendingProps,d=n.elementType===o?d:gs(o,d),em(t,n,o,d,i);case 7:return Sn(t,n,n.pendingProps,i),n.child;case 8:return Sn(t,n,n.pendingProps.children,i),n.child;case 12:return Sn(t,n,n.pendingProps.children,i),n.child;case 10:e:{if(o=n.type._context,d=n.pendingProps,g=n.memoizedProps,j=d.value,u(lo,o._currentValue),o._currentValue=j,g!==null)if(En(g.value,j)){if(g.children===d.children&&!b.current){n=ca(t,n,i);break e}}else for(g=n.child,g!==null&&(g.return=n);g!==null;){var M=g.dependencies;if(M!==null){j=g.child;for(var W=M.firstContext;W!==null;){if(W.context===o){if(g.tag===1){W=oa(-1,i&-i),W.tag=2;var ue=g.updateQueue;if(ue!==null){ue=ue.shared;var Ce=ue.pending;Ce===null?W.next=W:(W.next=Ce.next,Ce.next=W),ue.pending=W}}g.lanes|=i,W=g.alternate,W!==null&&(W.lanes|=i),xc(g.return,i,n),M.lanes|=i;break}W=W.next}}else if(g.tag===10)j=g.type===n.type?null:g.child;else if(g.tag===18){if(j=g.return,j===null)throw Error(r(341));j.lanes|=i,M=j.alternate,M!==null&&(M.lanes|=i),xc(j,i,n),j=g.sibling}else j=g.child;if(j!==null)j.return=g;else for(j=g;j!==null;){if(j===n){j=null;break}if(g=j.sibling,g!==null){g.return=j.return,j=g;break}j=j.return}g=j}Sn(t,n,d.children,i),n=n.child}return n;case 9:return d=n.type,o=n.pendingProps.children,li(n,i),d=es(d),o=o(d),n.flags|=1,Sn(t,n,o,i),n.child;case 14:return o=n.type,d=gs(o,n.pendingProps),d=gs(o.type,d),tm(t,n,o,d,i);case 15:return nm(t,n,n.type,n.pendingProps,i);case 17:return o=n.type,d=n.pendingProps,d=n.elementType===o?d:gs(o,d),xo(t,n),n.tag=1,q(o)?(t=!0,Be(n)):t=!1,li(n,i),Gd(n,o,d),Pc(n,o,d,i),Fc(null,n,o,!0,t,i);case 19:return um(t,n,i);case 22:return sm(t,n,i)}throw Error(r(156,n.tag))};function Mm(t,n){return bi(t,n)}function Xh(t,n,i,o){this.tag=t,this.key=i,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=o,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ss(t,n,i,o){return new Xh(t,n,i,o)}function iu(t){return t=t.prototype,!(!t||!t.isReactComponent)}function Zh(t){if(typeof t=="function")return iu(t)?1:0;if(t!=null){if(t=t.$$typeof,t===K)return 11;if(t===V)return 14}return 2}function Ma(t,n){var i=t.alternate;return i===null?(i=ss(t.tag,n,t.key,t.mode),i.elementType=t.elementType,i.type=t.type,i.stateNode=t.stateNode,i.alternate=t,t.alternate=i):(i.pendingProps=n,i.type=t.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=t.flags&14680064,i.childLanes=t.childLanes,i.lanes=t.lanes,i.child=t.child,i.memoizedProps=t.memoizedProps,i.memoizedState=t.memoizedState,i.updateQueue=t.updateQueue,n=t.dependencies,i.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},i.sibling=t.sibling,i.index=t.index,i.ref=t.ref,i}function Ao(t,n,i,o,d,g){var j=2;if(o=t,typeof t=="function")iu(t)&&(j=1);else if(typeof t=="string")j=5;else e:switch(t){case ae:return jr(i.children,d,g,n);case fe:j=8,d|=8;break;case ge:return t=ss(12,i,n,d|2),t.elementType=ge,t.lanes=g,t;case te:return t=ss(13,i,n,d),t.elementType=te,t.lanes=g,t;case z:return t=ss(19,i,n,d),t.elementType=z,t.lanes=g,t;case ce:return Ro(i,d,g,n);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case Te:j=10;break e;case Se:j=9;break e;case K:j=11;break e;case V:j=14;break e;case H:j=16,o=null;break e}throw Error(r(130,t==null?t:typeof t,""))}return n=ss(j,i,n,d),n.elementType=t,n.type=o,n.lanes=g,n}function jr(t,n,i,o){return t=ss(7,t,o,n),t.lanes=i,t}function Ro(t,n,i,o){return t=ss(22,t,o,n),t.elementType=ce,t.lanes=i,t.stateNode={isHidden:!1},t}function lu(t,n,i){return t=ss(6,t,null,n),t.lanes=i,t}function ou(t,n,i){return n=ss(4,t.children!==null?t.children:[],t.key,n),n.lanes=i,n.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},n}function ep(t,n,i,o,d){this.tag=n,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Mr(0),this.expirationTimes=Mr(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Mr(0),this.identifierPrefix=o,this.onRecoverableError=d,this.mutableSourceEagerHydrationData=null}function cu(t,n,i,o,d,g,j,M,W){return t=new ep(t,n,i,M,W),n===1?(n=1,g===!0&&(n|=8)):n=0,g=ss(3,null,null,n),t.current=g,g.stateNode=t,g.memoizedState={element:o,isDehydrated:i,cache:null,transitions:null,pendingSuspenseBoundaries:null},bc(g),t}function tp(t,n,i){var o=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Z,key:o==null?null:""+o,children:t,containerInfo:n,implementation:i}}function zm(t){if(!t)return v;t=t._reactInternals;e:{if(Qn(t)!==t||t.tag!==1)throw Error(r(170));var n=t;do{switch(n.tag){case 3:n=n.stateNode.context;break e;case 1:if(q(n.type)){n=n.stateNode.__reactInternalMemoizedMergedChildContext;break e}}n=n.return}while(n!==null);throw Error(r(171))}if(t.tag===1){var i=t.type;if(q(i))return qe(t,i,n)}return n}function Pm(t,n,i,o,d,g,j,M,W){return t=cu(i,o,!0,t,d,g,j,M,W),t.context=zm(null),i=t.current,o=Nn(),d=Ra(i),g=oa(o,d),g.callback=n??null,$a(i,g,d),t.current.lanes=d,Mt(t,d,o),zn(t,o),t}function Lo(t,n,i,o){var d=n.current,g=Nn(),j=Ra(d);return i=zm(i),n.context===null?n.context=i:n.pendingContext=i,n=oa(g,j),n.payload={element:t},o=o===void 0?null:o,o!==null&&(n.callback=o),t=$a(d,n,j),t!==null&&(xs(t,d,j,g),co(t,d,j)),j}function Mo(t){if(t=t.current,!t.child)return null;switch(t.child.tag){case 5:return t.child.stateNode;default:return t.child.stateNode}}function Im(t,n){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var i=t.retryLane;t.retryLane=i!==0&&i<n?i:n}}function uu(t,n){Im(t,n),(t=t.alternate)&&Im(t,n)}function np(){return null}var Om=typeof reportError=="function"?reportError:function(t){console.error(t)};function du(t){this._internalRoot=t}zo.prototype.render=du.prototype.render=function(t){var n=this._internalRoot;if(n===null)throw Error(r(409));Lo(t,n,null,null)},zo.prototype.unmount=du.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var n=t.containerInfo;xr(function(){Lo(null,t,null,null)}),n[hs]=null}};function zo(t){this._internalRoot=t}zo.prototype.unstable_scheduleHydration=function(t){if(t){var n=Si();t={blockedOn:null,target:t,priority:n};for(var i=0;i<Xt.length&&n!==0&&n<Xt[i].priority;i++);Xt.splice(i,0,t),i===0&&Un(t)}};function mu(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function Po(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11&&(t.nodeType!==8||t.nodeValue!==" react-mount-point-unstable "))}function Dm(){}function sp(t,n,i,o,d){if(d){if(typeof o=="function"){var g=o;o=function(){var ue=Mo(j);g.call(ue)}}var j=Pm(n,o,t,0,null,!1,!1,"",Dm);return t._reactRootContainer=j,t[hs]=j.current,ka(t.nodeType===8?t.parentNode:t),xr(),j}for(;d=t.lastChild;)t.removeChild(d);if(typeof o=="function"){var M=o;o=function(){var ue=Mo(W);M.call(ue)}}var W=cu(t,0,!1,null,null,!1,!1,"",Dm);return t._reactRootContainer=W,t[hs]=W.current,ka(t.nodeType===8?t.parentNode:t),xr(function(){Lo(n,W,i,o)}),W}function Io(t,n,i,o,d){var g=i._reactRootContainer;if(g){var j=g;if(typeof d=="function"){var M=d;d=function(){var W=Mo(j);M.call(W)}}Lo(n,j,t,d)}else j=sp(i,n,t,d,o);return Mo(j)}ji=function(t){switch(t.tag){case 3:var n=t.stateNode;if(n.current.memoizedState.isDehydrated){var i=Yn(n.pendingLanes);i!==0&&(zr(n,i|1),zn(n,At()),(_t&6)===0&&(mi=At()+500,vt()))}break;case 13:xr(function(){var o=la(t,1);if(o!==null){var d=Nn();xs(o,t,1,d)}}),uu(t,1)}},Ga=function(t){if(t.tag===13){var n=la(t,134217728);if(n!==null){var i=Nn();xs(n,t,134217728,i)}uu(t,134217728)}},ki=function(t){if(t.tag===13){var n=Ra(t),i=la(t,n);if(i!==null){var o=Nn();xs(i,t,n,o)}uu(t,n)}},Si=function(){return dt},Ka=function(t,n){var i=dt;try{return dt=t,n()}finally{dt=i}},Ze=function(t,n,i){switch(n){case"input":if(O(t,i),n=i.name,i.type==="radio"&&n!=null){for(i=t;i.parentNode;)i=i.parentNode;for(i=i.querySelectorAll("input[name="+JSON.stringify(""+n)+'][type="radio"]'),n=0;n<i.length;n++){var o=i[n];if(o!==t&&o.form===t.form){var d=hr(o);if(!d)throw Error(r(90));he(o),O(o,d)}}}break;case"textarea":ot(t,i);break;case"select":n=i.value,n!=null&&le(t,!!i.multiple,n,!1)}},Xe=su,ws=xr;var ap={usingClientEntryPoint:!1,Events:[fr,aa,hr,it,ht,su]},ml={findFiberByHostInstance:Ls,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},rp={bundleType:ml.bundleType,version:ml.version,rendererPackageName:ml.rendererPackageName,rendererConfig:ml.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:ee.ReactCurrentDispatcher,findHostInstanceByFiber:function(t){return t=wi(t),t===null?null:t.stateNode},findFiberByHostInstance:ml.findFiberByHostInstance||np,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Oo=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Oo.isDisabled&&Oo.supportsFiber)try{Va=Oo.inject(rp),dn=Oo}catch{}}return Pn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=ap,Pn.createPortal=function(t,n){var i=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!mu(n))throw Error(r(200));return tp(t,n,null,i)},Pn.createRoot=function(t,n){if(!mu(t))throw Error(r(299));var i=!1,o="",d=Om;return n!=null&&(n.unstable_strictMode===!0&&(i=!0),n.identifierPrefix!==void 0&&(o=n.identifierPrefix),n.onRecoverableError!==void 0&&(d=n.onRecoverableError)),n=cu(t,1,!1,null,null,i,!1,o,d),t[hs]=n.current,ka(t.nodeType===8?t.parentNode:t),new du(n)},Pn.findDOMNode=function(t){if(t==null)return null;if(t.nodeType===1)return t;var n=t._reactInternals;if(n===void 0)throw typeof t.render=="function"?Error(r(188)):(t=Object.keys(t).join(","),Error(r(268,t)));return t=wi(n),t=t===null?null:t.stateNode,t},Pn.flushSync=function(t){return xr(t)},Pn.hydrate=function(t,n,i){if(!Po(n))throw Error(r(200));return Io(null,t,n,!0,i)},Pn.hydrateRoot=function(t,n,i){if(!mu(t))throw Error(r(405));var o=i!=null&&i.hydratedSources||null,d=!1,g="",j=Om;if(i!=null&&(i.unstable_strictMode===!0&&(d=!0),i.identifierPrefix!==void 0&&(g=i.identifierPrefix),i.onRecoverableError!==void 0&&(j=i.onRecoverableError)),n=Pm(n,null,t,1,i??null,d,!1,g,j),t[hs]=n.current,ka(t),o)for(t=0;t<o.length;t++)i=o[t],d=i._getVersion,d=d(i._source),n.mutableSourceEagerHydrationData==null?n.mutableSourceEagerHydrationData=[i,d]:n.mutableSourceEagerHydrationData.push(i,d);return new zo(n)},Pn.render=function(t,n,i){if(!Po(n))throw Error(r(200));return Io(null,t,n,!1,i)},Pn.unmountComponentAtNode=function(t){if(!Po(t))throw Error(r(40));return t._reactRootContainer?(xr(function(){Io(null,null,t,!1,function(){t._reactRootContainer=null,t[hs]=null})}),!0):!1},Pn.unstable_batchedUpdates=su,Pn.unstable_renderSubtreeIntoContainer=function(t,n,i,o){if(!Po(i))throw Error(r(200));if(t==null||t._reactInternals===void 0)throw Error(r(38));return Io(t,n,i,!1,o)},Pn.version="18.3.1-next-f1338f8080-20240426",Pn}var Gm;function Ff(){if(Gm)return pu.exports;Gm=1;function a(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(a)}catch(s){console.error(s)}}return a(),pu.exports=pp(),pu.exports}var Km;function _p(){if(Km)return Do;Km=1;var a=Ff();return Do.createRoot=a.createRoot,Do.hydrateRoot=a.hydrateRoot,Do}var gp=_p();const qf=[{id:"dark",label:"Dark (Abstract)",group:"dark",swatches:["#1a1a2e","#16213e","#0f3460","#e94560","#60a5fa","#27ae60"]},{id:"observer-night",label:"Observer Night",group:"dark",swatches:["#0b0f14","#10161e","#161e28","#e8a54a","#6ea8d8","#7bc98c"]},{id:"catppuccin-mocha",label:"Catppuccin Mocha",group:"dark",swatches:["#1e1e2e","#181825","#313244","#cba6f7","#89b4fa","#a6e3a1"]},{id:"catppuccin-macchiato",label:"Catppuccin Macchiato",group:"dark",swatches:["#24273a","#1e2030","#363a4f","#c6a0f6","#8aadf4","#a6da95"]},{id:"catppuccin-frappe",label:"Catppuccin Frappe",group:"dark",swatches:["#303446","#292c3c","#414559","#ca9ee6","#8caaee","#a6d189"]},{id:"rose-pine",label:"Rose Pine",group:"dark",swatches:["#191724","#1f1d2e","#26233a","#c4a7e7","#31748f","#9ccfd8"]},{id:"rose-pine-moon",label:"Rose Pine Moon",group:"dark",swatches:["#232136","#2a273f","#393552","#c4a7e7","#3e8fb0","#9ccfd8"]},{id:"tokyo-night",label:"Tokyo Night",group:"dark",swatches:["#1a1b26","#24283b","#414868","#7aa2f7","#2ac3de","#9ece6a"]},{id:"nord",label:"Nord",group:"dark",swatches:["#2e3440","#3b4252","#434c5e","#88c0d0","#5e81ac","#a3be8c"]},{id:"one-dark",label:"One Dark",group:"dark",swatches:["#282c34","#21252b","#3a3f4b","#61afef","#c678dd","#98c379"]},{id:"dracula",label:"Dracula",group:"dark",swatches:["#282a36","#343746","#44475a","#ff79c6","#8be9fd","#50fa7b"]},{id:"monokai",label:"Monokai",group:"dark",swatches:["#272822","#2d2e27","#3e3d32","#66d9ef","#a1efe4","#a6e22e"]},{id:"gruvbox",label:"Gruvbox",group:"dark",swatches:["#282828","#3c3836","#504945","#fe8019","#83a598","#b8bb26"]},{id:"solarized-dark",label:"Solarized Dark",group:"dark",swatches:["#002b36","#073642","#0b4b5a","#268bd2","#2aa198","#859900"]},{id:"everforest-dark",label:"Everforest Dark",group:"dark",swatches:["#2b3339","#323c41","#3a464c","#a7c080","#7fbbb3","#a7c080"]},{id:"catppuccin-latte",label:"Catppuccin Latte",group:"light",swatches:["#eff1f5","#e6e9ef","#ccd0da","#8839ef","#1e66f5","#40a02b"]},{id:"rose-pine-dawn",label:"Rose Pine Dawn",group:"light",swatches:["#faf4ed","#fffaf3","#f2e9e1","#907aa9","#56949f","#286983"]},{id:"one-light",label:"One Light",group:"light",swatches:["#fafafa","#ffffff","#e5e5e6","#4078f2","#a626a4","#50a14f"]},{id:"everforest-light",label:"Everforest Light",group:"light",swatches:["#fdf6e3","#fffbef","#e8e0cc","#4f8f5a","#3a94c5","#4f8f5a"]},{id:"solarized-light",label:"Solarized Light",group:"light",swatches:["#fdf6e3","#eee8d5","#e3ddc9","#268bd2","#2aa198","#859900"]},{id:"light",label:"Light",group:"light",swatches:["#f7f7fb","#ffffff","#e6e8f0","#e94560","#2563eb","#16a34a"]}];qf.map(a=>({id:a.id,label:a.label}));function vp(a){return`theme-${String(a||"").trim()||"dark"}`}function Qm(a){try{const s=document.documentElement,r=Array.from(s.classList).filter(l=>l.startsWith("theme-"));for(const l of r)s.classList.remove(l);s.classList.add(vp(a))}catch{}}const Ou=[{id:"sm",label:"Small",scale:.9},{id:"md",label:"Medium",scale:1},{id:"lg",label:"Large",scale:1.1},{id:"xl",label:"Extra Large",scale:1.2}],Du=[{id:"compact",label:"Compact",density:.85},{id:"standard",label:"Standard",density:1},{id:"spacious",label:"Spacious",density:1.2}];function yp(a){const s=String(a).trim();return Ou.find(r=>r.id===s)||Ou[1]}function xp(a){const s=String(a).trim();return Du.find(r=>r.id===s)||Du[1]}function Jm(a){try{const s=document.documentElement,r=yp(a.font_scale||"md"),l=xp(a.header_density||"standard");s.style.setProperty("--font-scale",String(r.scale)),s.style.setProperty("--header-density",String(l.density))}catch{}}var Bf=Ff();function hi(...a){return a.filter(Boolean).join(" ")}function $r({value:a,options:s,placeholder:r="Select…",disabled:l=!1,loading:c=!1,searchable:f=!0,searchPlaceholder:m="Search…",allowCustom:p=!1,clearable:_=!1,minPopoverWidth:y=240,variant:w="panel",className:x,triggerClassName:N,ariaLabel:$,id:P,includeValueOption:T=!1,onOpen:F,customOptionLabel:D,validateCustomValue:J,onChange:B,renderOption:ee,renderValue:C}){const Z=h.useRef(null),ae=h.useRef(null),fe=h.useRef(null),ge=h.useRef(F),Te=h.useId(),Se=P||`af-select-${Te.replace(/[^a-zA-Z0-9_-]/g,"")}`,K=`${Se}-listbox`,[te,z]=h.useState(!1),[V,H]=h.useState(""),[ce,I]=h.useState(0),[_e,Y]=h.useState("bottom"),[S,A]=h.useState({left:0,top:0,width:0});h.useEffect(()=>{ge.current=F},[F]);const U=h.useMemo(()=>{if(!T)return s;const G=String(a??"").trim();return!G||s.some(le=>le.value===G)?s:[...s,{value:G,label:G}]},[T,s,a]),ie=h.useMemo(()=>{const G=String(a??"");return U.find(le=>le.value===G)||null},[U,a]),de=h.useMemo(()=>(ie==null?void 0:ie.label)||String(a||"").trim()||"",[ie,a]),L=h.useMemo(()=>{const G=V.trim().toLowerCase();return G?U.filter(le=>le.label.toLowerCase().includes(G)||le.value.toLowerCase().includes(G)):U},[U,V]),ke=h.useMemo(()=>{if(!p)return null;const G=V.trim();if(!G||U.some(Oe=>Oe.value===G))return null;const ye=(J==null?void 0:J(G,{options:U}))||"";return{value:G,label:D?D(G):`Use "${G}"`,disabled:!!ye,reason:ye}},[p,D,U,V,J]),be=h.useMemo(()=>{const G=ke?[ke,...L]:L;if(G.length>0)return G;const le=String(a??"").trim();return c&&le?[{value:le,label:de||le}]:G},[ke,L,c,de,a]),Ie=h.useCallback(()=>{const G=Z.current;if(!G)return;const le=G.getBoundingClientRect(),ye=Math.max(le.width,y),Oe=Math.max(8,Math.min(le.left,window.innerWidth-ye-8)),ot=window.innerHeight-le.bottom,xt=le.top,pe=ot>=220||ot>=xt?"bottom":"top";Y(pe);const R=pe==="bottom"?le.bottom+6:le.top-6;A({left:Oe,top:R,width:ye})},[y]),Fe=h.useCallback(()=>{z(!1),H("")},[]);h.useEffect(()=>{var G;te&&((G=ge.current)==null||G.call(ge))},[te]),h.useEffect(()=>{if(!te)return;Ie();const G=()=>Ie();return window.addEventListener("resize",G),window.addEventListener("scroll",G,!0),()=>{window.removeEventListener("resize",G),window.removeEventListener("scroll",G,!0)}},[te,Ie]),h.useEffect(()=>{if(!te)return;const G=le=>{var Oe,ot;const ye=le.target;ye&&((Oe=Z.current)!=null&&Oe.contains(ye)||(ot=ae.current)!=null&&ot.contains(ye)||Fe())};return document.addEventListener("mousedown",G,!0),()=>document.removeEventListener("mousedown",G,!0)},[te,Fe]),h.useEffect(()=>{if(!te)return;const G=Math.max(0,be.findIndex(le=>le.value===a));I(G===-1?0:G),f&&setTimeout(()=>{var le;return(le=fe.current)==null?void 0:le.focus()},0)},[te,f,a,be]);const Ye=G=>{var ye;const le=be.find(Oe=>Oe.value===G);le!=null&&le.disabled||(B(G),Fe(),(ye=Z.current)==null||ye.focus())},he=G=>{var le,ye;if(G.key==="Escape")return G.preventDefault(),Fe(),(le=Z.current)==null||le.focus(),!0;if(G.key==="Tab")return Fe(),(ye=Z.current)==null||ye.focus(),!1;if(G.key==="ArrowDown")return G.preventDefault(),I(Oe=>Math.min(Oe+1,Math.max(0,be.length-1))),!0;if(G.key==="ArrowUp")return G.preventDefault(),I(Oe=>Math.max(Oe-1,0)),!0;if(G.key==="Home")return G.preventDefault(),I(0),!0;if(G.key==="End")return G.preventDefault(),I(Math.max(0,be.length-1)),!0;if(G.key==="Enter"){G.preventDefault();const Oe=be[ce];return Oe&&Ye(Oe.value),!0}return!1},Re=G=>{if(!l){if(te){if(he(G))return;if(G.key===" "&&!f){G.preventDefault();const le=be[ce];le&&Ye(le.value)}return}(G.key==="Enter"||G.key===" "||G.key==="ArrowDown"||G.key==="ArrowUp")&&(G.preventDefault(),z(!0))}},ze=!!String(a||"").trim(),re=ze?de:r,xe=ke!=null&&ke.disabled?ke.reason||"Unavailable":"",O=te&&be.length>0?`${Se}-opt-${ce}`:void 0,me=e.jsx("span",{className:hi("af-select-value",!ze&&"af-select-value--placeholder"),children:c&&!ze?"Loading…":re}),De=C?C(ie,String(a||"")):me;return e.jsxs("span",{className:hi("af-select",w==="pin"?"af-select--pin":"af-select--panel",x),children:[e.jsxs("button",{ref:Z,id:Se,type:"button",className:hi("af-select-trigger",_&&ze&&"af-select-trigger--clearable",N),disabled:l,onMouseDown:G=>G.stopPropagation(),onClick:G=>{G.stopPropagation(),!l&&z(le=>!le)},onKeyDown:Re,role:f?void 0:"combobox","aria-haspopup":"listbox","aria-expanded":te,"aria-controls":te?K:void 0,"aria-activedescendant":f?void 0:O,"aria-label":$,children:[De,e.jsx("span",{className:hi("af-select-caret",te&&"af-select-caret--open"),children:"▾"})]}),_&&ze?e.jsx("button",{type:"button",className:"af-select-clear-btn","aria-label":"Clear selection",disabled:l,onMouseDown:G=>{G.preventDefault(),G.stopPropagation()},onClick:G=>{var le;G.preventDefault(),G.stopPropagation(),B(""),Fe(),(le=Z.current)==null||le.focus()},title:"Clear",children:"×"}):null,te?Bf.createPortal(e.jsxs("div",{ref:ae,className:hi("af-select-popover",_e==="top"&&"af-select-popover--top"),style:{position:"fixed",left:`${S.left}px`,top:`${S.top}px`,width:`${S.width}px`},onMouseDown:G=>G.stopPropagation(),onClick:G=>G.stopPropagation(),onWheel:G=>G.stopPropagation(),onKeyDown:he,tabIndex:-1,children:[f?e.jsxs("div",{className:"af-select-search",children:[e.jsx("input",{ref:fe,className:"af-select-search-input",value:V,onChange:G=>H(G.target.value),placeholder:m,onKeyDown:he,role:"combobox","aria-expanded":!0,"aria-controls":K,"aria-activedescendant":O,"aria-invalid":!!xe,"aria-describedby":xe?`${Se}-custom-error`:void 0}),xe?e.jsx("div",{id:`${Se}-custom-error`,className:"af-select-custom-error",role:"alert",children:xe}):null]}):null,e.jsx("div",{className:"af-select-options",role:"listbox",id:K,"aria-label":$,children:c&&be.length===0?e.jsx("div",{className:"af-select-empty",children:"Loading…"}):be.length===0?e.jsx("div",{className:"af-select-empty",children:"No results"}):be.map((G,le)=>{var R;const ye=G.value===a,Oe=le===ce,ot=String(G.group||"").trim(),xt=le>0?String(((R=be[le-1])==null?void 0:R.group)||"").trim():"",pe=!!ot&&ot!==xt;return e.jsxs(Gt.Fragment,{children:[pe?e.jsx("div",{className:"af-select-group",role:"presentation",children:ot}):null,e.jsx("div",{id:`${Se}-opt-${le}`,role:"option","aria-selected":ye,className:hi("af-select-option",ye&&"af-select-option--selected",Oe&&"af-select-option--highlighted",G.disabled&&"af-select-option--disabled"),title:G.disabled?G.reason||"Unavailable":void 0,onMouseEnter:()=>I(le),onMouseDown:X=>{X.preventDefault(),X.stopPropagation()},onClick:()=>Ye(G.value),"aria-disabled":G.disabled?!0:void 0,children:ee?ee(G,{selected:ye,highlighted:Oe}):e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"af-select-option-label",children:[e.jsx("span",{children:G.label}),G.reason?e.jsx("small",{className:"af-select-option-reason",children:G.reason}):null]}),ye?e.jsx("span",{className:"af-select-check",children:"✓"}):null]})})]},G.value)})})]}),document.body):null]})}function wp(a){const s=new Set,r=[];for(const l of a||[]){if(!l||typeof l!="object")continue;const c=String(l.name||"").trim();!c||s.has(c)||(s.add(c),r.push({name:c,display_name:typeof l.display_name=="string"?l.display_name:void 0}))}return r.sort((l,c)=>l.name.localeCompare(c.name)),r}function bp(a){const s=new Set,r=[];for(const l of a||[]){const c=String(l||"").trim();!c||s.has(c)||(s.add(c),r.push(c))}return r.sort(),r}function jp(a){const s=a.disabled===!0,r=a.layout||"stack",l=a.allowGatewayDefault!==!1,c=String(a.gatewayDefaultLabel||"(gateway default)"),f=String(a.providerLabel||"Provider"),m=String(a.modelLabel||"Model"),p=String(a.providerPlaceholder||"(select)"),_=String(a.modelPlaceholder||"(select)"),y=String(a.provider||"").trim(),w=String(a.model||"").trim(),x=wp(a.providers),N=bp(a.models),$=s||!!a.loadingProviders,P=s||!!a.loadingModels,T=[...l?[{value:"",label:c}]:[],...x.map(D=>({value:D.name,label:D.display_name?`${D.display_name} (${D.name})`:D.name}))],F=[...l?[{value:"",label:c}]:[],...N.map(D=>({value:D,label:D}))];return e.jsxs("div",{className:a.className,style:r==="row"?{display:"flex",gap:"10px",flexWrap:"wrap",alignItems:"flex-start"}:{display:"flex",flexDirection:"column",gap:"10px"},children:[e.jsxs("div",{style:r==="row"?{flex:"1 1 260px",minWidth:240}:void 0,children:[e.jsx("label",{children:f}),e.jsx($r,{value:y,options:T,placeholder:l?c:p,disabled:$,loading:!!a.loadingProviders,searchable:!0,allowCustom:a.allowCustomProvider===!0,clearable:l,variant:"panel",triggerClassName:a.selectClassName,ariaLabel:f,onChange:D=>a.onChange({provider:String(D||"").trim(),model:""})}),a.loadingProviders?e.jsx("div",{className:"mono muted",style:{fontSize:"12px",marginTop:"6px"},children:"Loading providers…"}):null,a.providerError?e.jsx("div",{className:"mono",style:{color:"var(--error)",fontSize:"12px",marginTop:"6px"},children:a.providerError}):null]}),e.jsxs("div",{style:r==="row"?{flex:"1 1 260px",minWidth:240}:void 0,children:[e.jsx("label",{children:m}),e.jsx($r,{value:w,options:F,placeholder:l?c:_,disabled:P,loading:!!a.loadingModels,searchable:!0,allowCustom:a.allowCustomModel===!0,clearable:l,variant:"panel",triggerClassName:a.selectClassName,ariaLabel:m,onChange:D=>a.onChange({provider:y,model:String(D||"").trim()})}),a.loadingModels?e.jsx("div",{className:"mono muted",style:{fontSize:"12px",marginTop:"6px"},children:"Loading models…"}):null,a.modelError?e.jsx("div",{className:"mono",style:{color:"var(--error)",fontSize:"12px",marginTop:"6px"},children:a.modelError}):null]})]})}function kp(a){if(a===!1||a&&typeof a=="object"&&a.mode==="off")return!1;if(!a||typeof a!="object")return;const s=a;if(!(s.mode!=="native_mtp"||!Number.isInteger(s.num_draft_tokens)||Number(s.num_draft_tokens)<1))return{mode:"native_mtp",num_draft_tokens:Number(s.num_draft_tokens),require_acceleration:!0}}function Sp(a){var r;const s=(r=a==null?void 0:a.execution)==null?void 0:r.speculation;return!s||typeof s.supported!="boolean"?null:{supported:s.supported,ready:typeof s.ready=="boolean"?s.ready:null,reason:typeof s.reason=="string"?s.reason:null,supported_depths:s.supported&&Array.isArray(s.supported_depths)?[...new Set(s.supported_depths.filter(l=>typeof l=="number"&&Number.isInteger(l)&&l>0))]:[],default:Object.prototype.hasOwnProperty.call(s,"effective_default")?s.effective_default:s.default,requires_reload:typeof s.requires_reload=="boolean"?s.requires_reload:null}}function Ym(a){const s=kp(a);return s===!1?"off":s?String(s.num_draft_tokens):""}function Np(a){if(a==="off")return!1;if(!(!/^\d+$/.test(a)||Number(a)<1))return{mode:"native_mtp",num_draft_tokens:Number(a),require_acceleration:!0}}function Cp(a){const s=Sp(a.capabilities),r=Ym(a.value),l=(s==null?void 0:s.supported_depths.map(String))||[],c=Ym(s==null?void 0:s.default),f=a.inheritLabel||"Workflow / Gateway default",m=c?`${f} (${c==="off"?"Off":`depth ${c}`})`:f,p=a.error||(a.loading?"Checking MTP capability…":s?s.reason||(s.requires_reload?"Model reload required before MTP can run.":s.ready===!1?"MTP is supported but not ready on this instance.":s.ready===null&&s.supported?"MTP support verified; loaded-instance readiness is unknown.":s.supported?"":"MTP is not supported on this model/backend."):"MTP capability unknown; no depth is assumed.");return e.jsxs("div",{className:"af-pmp__speculation",children:[e.jsx("label",{children:"MTP depth"}),e.jsx($r,{ariaLabel:"MTP depth",value:r,placeholder:m,disabled:a.disabled||a.loading,options:[{value:"",label:m},{value:"off",label:"Off"},...l.map(_=>({value:_,label:`Depth ${_}`})),...r&&r!=="off"&&!l.includes(r)?[{value:r,label:`Depth ${r} (saved; not available)`}]:[]],onChange:_=>a.onChange(Np(_))}),p?e.jsx("div",{role:"status",className:"af-pmp__hint",children:p}):null]})}function $p(a){var I,_e;const s=a.disabled===!0,r=a.value||{provider:"",model:""},l=!String(r.provider||"").trim()&&!String(r.model||"").trim(),[c,f]=h.useState(!l),m=l&&!c,p=h.useRef(l);h.useEffect(()=>{l&&!p.current&&f(!1),p.current=l},[l]);const[_,y]=h.useState([]),[w,x]=h.useState(!1),[N,$]=h.useState(""),[P,T]=h.useState([]),[F,D]=h.useState(!1),[J,B]=h.useState(""),ee=h.useRef(a);ee.current=a,h.useEffect(()=>{if(m||s)return;let Y=!0;return x(!0),(async()=>{try{const S=await ee.current.fetchProviders();if(!Y)return;y(Array.isArray(S)?S:[]),$("")}catch(S){if(!Y)return;y([]),$(`#FALLBACK provider discovery failed: ${String((S==null?void 0:S.message)||S)}`)}finally{Y&&x(!1)}})(),()=>{Y=!1}},[m,s]);const C=String(r.provider||"").trim();h.useEffect(()=>{if(!C||s){T([]),B(""),D(!1);return}let Y=!0;return T([]),D(!0),B(""),(async()=>{try{const S=await ee.current.fetchModels(C);if(!Y)return;T(Array.isArray(S)?S:[])}catch(S){if(!Y)return;T([]),B(`#FALLBACK model discovery failed: ${String((S==null?void 0:S.message)||S)}`)}finally{Y&&D(!1)}})(),()=>{Y=!1}},[C,s]);const Z=h.useMemo(()=>{const Y=[..._];return C&&!Y.some(S=>S.name===C)&&Y.unshift({name:C}),Y},[_,C]),ae=String(r.model||"").trim(),fe=h.useMemo(()=>{const Y=[...P];return ae&&!Y.includes(ae)&&Y.unshift(ae),Y},[P,ae]),ge=a.defaultModeLabel||"Gateway default",Te=a.customModeLabel||"Custom",Se=C||((I=a.effectiveDefault)==null?void 0:I.provider)||"",K=ae||(C?"":(_e=a.effectiveDefault)==null?void 0:_e.model)||"",[te,z]=h.useState({levels:[],error:"",loading:!1}),V=!!a.fetchModelCapabilities,[H,ce]=h.useState();return h.useEffect(()=>{let Y=!0;if(ce(void 0),z({levels:[],error:"",loading:V&&!!K}),!(!V||!K||s))return ee.current.fetchModelCapabilities(K,Se).then(S=>{var de;if(!Y)return;if(S!=null&&S.error)throw new Error(String(S.error));ce(S);const A=(S==null?void 0:S.capabilities)||S||{},U=A.reasoning_levels||A.thinking_levels,ie=Array.isArray(U)?[...new Set(U.filter(L=>typeof L=="string"&&!!L.trim()))]:[];!ie.length&&A.thinking_support===!0&&((de=A.thinking_control)!=null&&de.prompt_disable_token)&&ie.push("off","auto"),z({levels:ie,error:"",loading:!1})}).catch(S=>{Y&&z({levels:[],error:`Reasoning options unavailable: ${String((S==null?void 0:S.message)||S)}`,loading:!1})}),()=>{Y=!1}},[Se,K,V,s]),e.jsxs("div",{className:`af-pmp${a.className?` ${a.className}`:""}`,children:[e.jsxs("div",{className:"af-pmp__seg",role:"tablist","aria-label":"Provider mode",children:[e.jsx("button",{type:"button",role:"tab","aria-selected":m,className:`af-pmp__seg-btn${m?" is-active":""}`,onClick:()=>{f(!1),a.onChange({...r,provider:"",model:"",...V?{reasoning:""}:{}})},disabled:s,children:ge}),e.jsx("button",{type:"button",role:"tab","aria-selected":!m,className:`af-pmp__seg-btn${m?"":" is-active"}`,onClick:()=>{f(!0)},disabled:s,children:Te})]}),m?e.jsx("div",{className:"af-pmp__hint",children:a.defaultHint||"The gateway picks its configured default provider and model for this task."}):e.jsx(jp,{provider:C,model:ae,providers:Z,models:fe,disabled:s,loadingProviders:w,loadingModels:F,providerError:N||void 0,modelError:J||void 0,providerLabel:a.providerLabel,modelLabel:a.modelLabel,allowGatewayDefault:!1,allowCustomProvider:a.allowCustom!==!1,allowCustomModel:a.allowCustom!==!1,onChange:Y=>a.onChange({...r,provider:Y.provider,model:Y.model,...V?{reasoning:""}:{}})}),V&&(te.levels.length>0||r.reasoning)?e.jsxs("div",{className:"af-pmp__reasoning",children:[e.jsx("label",{children:a.reasoningLabel||"Reasoning effort"}),e.jsx($r,{ariaLabel:a.reasoningLabel||"Reasoning effort",placeholder:"Workflow / Gateway default",value:r.reasoning||"",options:[{value:"",label:"Workflow / Gateway default"},...te.levels.map(Y=>({value:Y,label:Y})),...r.reasoning&&!te.levels.includes(r.reasoning)?[{value:r.reasoning,label:`${r.reasoning} (saved; not advertised)`}]:[]],disabled:s||te.loading,onChange:Y=>a.onChange({...r,reasoning:Y})})]}):null,te.error?e.jsx("div",{role:"status",className:"af-pmp__hint",children:te.error}):null,a.enableSpeculation?e.jsx(Cp,{value:r.speculation,onChange:Y=>a.onChange({...r,speculation:Y}),capabilities:H,disabled:s,loading:te.loading,error:te.error?te.error.replace("Reasoning options","MTP options"):void 0}):null]})}function Xm(...a){return a.filter(Boolean).join(" ")}function Ep({kicker:a="AbstractGateway connection",title:s="Connect to AbstractGateway",description:r="Sign in with the Gateway user token assigned by the Gateway admin.",statusLabel:l="Gateway token missing",statusTone:c="warn",tokenSourceLabel:f="token: missing",showGatewayUrl:m=!1,gatewayUrl:p="",gatewayUrlPlaceholder:_="http://127.0.0.1:8080",onGatewayUrlChange:y,userId:w,userPlaceholder:x="admin",onUserIdChange:N,token:$,tokenPlaceholder:P="Paste Gateway user token",showToken:T=!1,onTokenChange:F,onShowTokenChange:D,remember:J=!1,rememberLabel:B="Remember this browser",onRememberChange:ee,loading:C=!1,submitting:Z=!1,submitDisabled:ae=!1,submitLabel:fe="Sign in",submittingLabel:ge="Signing in...",closeLabel:Te="Close",signOutLabel:Se="Sign out",showClose:K=!1,showSignOut:te=!1,error:z,message:V,className:H,onSubmit:ce,onClose:I,onSignOut:_e}){const Y=C||Z,S=Y||ae||!String(w||"").trim()||!String($||"").trim(),A=U=>{U.preventDefault(),!S&&ce()};return e.jsxs("form",{className:Xm("af-gateway-signin",H),onSubmit:A,children:[e.jsxs("div",{className:"af-gateway-signin__hero",children:[e.jsxs("div",{children:[e.jsx("div",{className:"af-gateway-signin__kicker",children:a}),e.jsx("h2",{children:s}),r?e.jsx("p",{children:r}):null]}),e.jsx("div",{className:"af-gateway-signin__mark","aria-hidden":"true",children:"↔"})]}),e.jsxs("div",{className:"af-gateway-signin__status-row",children:[e.jsx("span",{className:Xm("af-gateway-signin__status",`af-gateway-signin__status--${c}`),children:l}),f?e.jsx("span",{className:"af-gateway-signin__source",children:f}):null]}),e.jsxs("div",{className:"af-gateway-signin__form",children:[m?e.jsxs(e.Fragment,{children:[e.jsx("label",{className:"af-gateway-signin__label",htmlFor:"gateway-session-url",children:"Gateway URL"}),e.jsx("input",{id:"gateway-session-url",value:p,onChange:U=>y==null?void 0:y(U.target.value),placeholder:_,autoComplete:"url",disabled:Y})]}):null,e.jsx("label",{className:"af-gateway-signin__label",htmlFor:"gateway-session-user",children:"Gateway user"}),e.jsx("input",{id:"gateway-session-user",value:w,onChange:U=>N(U.target.value),placeholder:x,autoComplete:"username",disabled:Y}),e.jsx("label",{className:"af-gateway-signin__label",htmlFor:"gateway-session-token",children:"Gateway token"}),e.jsxs("div",{className:"af-gateway-signin__token-input",children:[e.jsx("input",{id:"gateway-session-token",type:T?"text":"password",value:$,onChange:U=>F(U.target.value),placeholder:P,autoComplete:"current-password",disabled:Y}),e.jsx("button",{className:"af-gateway-signin__secondary",type:"button",onClick:()=>D==null?void 0:D(!T),disabled:Y,children:T?"Hide":"Show"})]}),e.jsx("label",{className:"af-gateway-signin__label",children:"Browser session"}),e.jsxs("label",{className:"af-gateway-signin__checkbox",children:[e.jsx("input",{type:"checkbox",checked:!!J,onChange:U=>ee==null?void 0:ee(U.target.checked),disabled:Y}),B]})]}),z?e.jsx("div",{className:"af-gateway-signin__message af-gateway-signin__message--error",children:z}):null,!z&&V?e.jsx("div",{className:"af-gateway-signin__message af-gateway-signin__message--ok",children:V}):null,e.jsxs("div",{className:"af-gateway-signin__actions",children:[K?e.jsx("button",{className:"af-gateway-signin__secondary",type:"button",onClick:I,disabled:Y,children:Te}):null,te?e.jsx("button",{className:"af-gateway-signin__secondary",type:"button",onClick:()=>void(_e==null?void 0:_e()),disabled:Y,children:Se}):null,e.jsx("button",{className:"af-gateway-signin__primary",type:"submit",disabled:S,children:Z?ge:fe})]})]})}function Tp(a){return a==="light"?"Light":"Dark"}function Ap(a){const s=a.themes&&a.themes.length?a.themes:qf,r=a.showSwatches!==!1,l=a.variant||"panel",c=h.useMemo(()=>{const m={};for(const p of s)m[p.id]=p;return m},[s]),f=h.useMemo(()=>s.map(m=>({value:m.id,label:m.label,group:Tp(m.group)})),[s]);return e.jsx($r,{value:a.value,options:f,placeholder:a.placeholder||"Select theme…",disabled:a.disabled===!0,searchable:!0,allowCustom:!1,clearable:!1,variant:l,className:a.className,triggerClassName:a.triggerClassName,onChange:m=>a.onChange(String(m||"").trim()),renderValue:(m,p)=>{const _=String(p||"").trim(),y=c[_],w=(y==null?void 0:y.label)||_||a.placeholder||"Select theme…",x=(y==null?void 0:y.swatches)||null,N=!_;return e.jsxs("span",{className:"af-theme-value",children:[e.jsx("span",{className:`af-theme-label ${N?"af-theme-label--placeholder":""}`.trim(),children:w}),r&&x?e.jsx("span",{className:"af-theme-swatches","aria-hidden":"true",children:x.map(($,P)=>e.jsx("span",{className:"af-theme-swatch",style:{background:$}},`${_}:${P}`))}):null]})},renderOption:(m,p)=>{const _=String(m.value||"").trim(),y=c[_],w=(y==null?void 0:y.swatches)||null;return e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"af-theme-option-label",children:m.label}),e.jsxs("span",{className:"af-theme-option-right",children:[r&&w?e.jsx("span",{className:"af-theme-swatches","aria-hidden":"true",children:w.map((x,N)=>e.jsx("span",{className:"af-theme-swatch",style:{background:x}},`${_}:${N}`))}):null,p.selected?e.jsx("span",{className:"af-select-check",children:"✓"}):null]})]})}})}function Rp(a){const s=a.scales&&a.scales.length?a.scales:Ou,r=a.variant||"panel",l=h.useMemo(()=>s.map(c=>({value:c.id,label:c.label})),[s]);return e.jsx($r,{value:a.value,options:l,placeholder:a.placeholder||"Font size…",disabled:a.disabled===!0,searchable:!1,allowCustom:!1,clearable:!1,variant:r,className:a.className,triggerClassName:a.triggerClassName,onChange:c=>a.onChange(String(c||"").trim())})}function Lp(a){const s=a.densities&&a.densities.length?a.densities:Du,r=a.variant||"panel",l=h.useMemo(()=>s.map(c=>({value:c.id,label:c.label})),[s]);return e.jsx($r,{value:a.value,options:l,placeholder:a.placeholder||"Header size…",disabled:a.disabled===!0,searchable:!1,allowCustom:!1,clearable:!1,variant:r,className:a.className,triggerClassName:a.triggerClassName,onChange:c=>a.onChange(String(c||"").trim())})}const Mp=new Set(["board","inbox","server","agent","playCircle","list","gear"]);function zp(a){switch(a){case"chat":return e.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H8l-5 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"});case"plus":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M12 5v14"}),e.jsx("path",{d:"M5 12h14"})]});case"history":return e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"12",cy:"12",r:"9"}),e.jsx("path",{d:"M12 7v5l3 3"})]});case"refresh":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M21 12a9 9 0 0 0-15.5-6.4L3 8"}),e.jsx("path",{d:"M3 3v5h5"}),e.jsx("path",{d:"M3 12a9 9 0 0 0 15.5 6.4L21 16"}),e.jsx("path",{d:"M21 21v-5h-5"})]});case"settings":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M4 6h16"}),e.jsx("circle",{cx:"8",cy:"6",r:"2"}),e.jsx("path",{d:"M4 12h16"}),e.jsx("circle",{cx:"16",cy:"12",r:"2"}),e.jsx("path",{d:"M4 18h16"}),e.jsx("circle",{cx:"10",cy:"18",r:"2"})]});case"user":return e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"12",cy:"8",r:"4"}),e.jsx("path",{d:"M4 21a8 8 0 0 1 16 0"})]});case"bot":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M12 2v3"}),e.jsx("rect",{x:"5",y:"6",width:"14",height:"14",rx:"3"}),e.jsx("circle",{cx:"9",cy:"13",r:"1",fill:"currentColor",stroke:"none"}),e.jsx("circle",{cx:"15",cy:"13",r:"1",fill:"currentColor",stroke:"none"}),e.jsx("path",{d:"M9 17h6"})]});case"paperclip":return e.jsx("path",{d:"M21.44 11.05l-9.19 9.19a5.5 5.5 0 0 1-7.78-7.78l9.19-9.19a3.5 3.5 0 0 1 4.95 4.95l-9.2 9.19a1.5 1.5 0 0 1-2.12-2.12l8.49-8.48"});case"mic":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M12 14a3 3 0 0 0 3-3V5a3 3 0 0 0-6 0v6a3 3 0 0 0 3 3z"}),e.jsx("path",{d:"M19 11a7 7 0 0 1-14 0"}),e.jsx("path",{d:"M12 18v4"}),e.jsx("path",{d:"M8 22h8"})]});case"speaker":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M11 5L6 9H2v6h4l5 4V5z"}),e.jsx("path",{d:"M15.5 8.5a5 5 0 0 1 0 7"}),e.jsx("path",{d:"M18 6a9 9 0 0 1 0 12"})]});case"pause":return e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",fill:"currentColor",stroke:"none"}),e.jsx("rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",fill:"currentColor",stroke:"none"})]});case"terminal":return e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2",ry:"2"}),e.jsx("path",{d:"M7 9l3 3-3 3"}),e.jsx("path",{d:"M12 15h5"})]});case"edit":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M12 20h9"}),e.jsx("path",{d:"M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4 12.5-12.5z"})]});case"download":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("path",{d:"M7 10l5 5 5-5"}),e.jsx("path",{d:"M12 15V3"})]});case"loader":return e.jsx("path",{d:"M21 12a9 9 0 1 1-3.3-6.9"});case"info":return e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M12 16v-4"}),e.jsx("circle",{cx:"12",cy:"8",r:"0.75",fill:"currentColor",stroke:"none"})]});case"warning":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M12 3l10 18H2L12 3z"}),e.jsx("path",{d:"M12 9v4"}),e.jsx("circle",{cx:"12",cy:"17",r:"0.75",fill:"currentColor",stroke:"none"})]});case"error":return e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M15 9l-6 6"}),e.jsx("path",{d:"M9 9l6 6"})]});case"copy":return e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),e.jsx("path",{d:"M5 15V5a2 2 0 0 1 2-2h10"})]});case"check":return e.jsx("path",{d:"M20 6L9 17l-5-5"});case"x":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M18 6L6 18"}),e.jsx("path",{d:"M6 6l12 12"})]});case"chevronDown":return e.jsx("path",{d:"M6 9l6 6 6-6"});case"chevronRight":return e.jsx("path",{d:"M9 18l6-6-6-6"});case"trash":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M3 6h18"}),e.jsx("path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),e.jsx("path",{d:"M6 6l1 16h10l1-16"}),e.jsx("path",{d:"M10 11v6"}),e.jsx("path",{d:"M14 11v6"})]});case"send":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M22 2L11 13"}),e.jsx("path",{d:"M22 2L15 22l-4-9-9-4 20-7z"})]});case"thumbsUp":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M7 10v11"}),e.jsx("path",{d:"M7 10l4.5-8a2 2 0 0 1 3.6 1.5L14 8h5.2a2 2 0 0 1 2 2.4l-1.6 8a2 2 0 0 1-2 1.6H7"})]});case"thumbsDown":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M17 14V3"}),e.jsx("path",{d:"M17 14l-4.5 8a2 2 0 0 1-3.6-1.5L10 16H4.8a2 2 0 0 1-2-2.4l1.6-8a2 2 0 0 1 2-1.6H17"})]});case"thumbsUpFilled":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M7 10v11"}),e.jsx("path",{d:"M7 10l4.5-8a2 2 0 0 1 3.6 1.5L14 8h5.2a2 2 0 0 1 2 2.4l-1.6 8a2 2 0 0 1-2 1.6H7z",fill:"currentColor",stroke:"none"})]});case"thumbsDownFilled":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M17 14V3"}),e.jsx("path",{d:"M17 14l-4.5 8a2 2 0 0 1-3.6-1.5L10 16H4.8a2 2 0 0 1-2-2.4l1.6-8a2 2 0 0 1 2-1.6H17z",fill:"currentColor",stroke:"none"})]});case"board":return e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"1.5",y:"2",width:"3.6",height:"12",rx:"1"}),e.jsx("rect",{x:"6.2",y:"2",width:"3.6",height:"8.5",rx:"1"}),e.jsx("rect",{x:"10.9",y:"2",width:"3.6",height:"5.5",rx:"1"})]});case"inbox":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M2 9.5 L4 3.5 h8 l2 6"}),e.jsx("path",{d:"M2 9.5 v3 h12 v-3"}),e.jsx("path",{d:"M2 9.5 h3.4 l1 1.6 h3.2 l1-1.6 H14"})]});case"server":return e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"2",y:"2.5",width:"12",height:"4.6",rx:"1.2"}),e.jsx("rect",{x:"2",y:"8.9",width:"12",height:"4.6",rx:"1.2"}),e.jsx("circle",{cx:"4.6",cy:"4.8",r:"0.8",fill:"currentColor",stroke:"none"}),e.jsx("circle",{cx:"4.6",cy:"11.2",r:"0.8",fill:"currentColor",stroke:"none"})]});case"agent":return e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"3",y:"4.5",width:"10",height:"8",rx:"2"}),e.jsx("path",{d:"M8 4.5V2.2"}),e.jsx("circle",{cx:"8",cy:"1.8",r:"0.9",fill:"currentColor",stroke:"none"}),e.jsx("circle",{cx:"5.8",cy:"8.4",r:"0.9",fill:"currentColor",stroke:"none"}),e.jsx("circle",{cx:"10.2",cy:"8.4",r:"0.9",fill:"currentColor",stroke:"none"})]});case"playCircle":return e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"8",cy:"8",r:"6.2"}),e.jsx("path",{d:"M6.5 5.6 L11 8 L6.5 10.4 Z",fill:"currentColor",stroke:"none"})]});case"list":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M2.5 4h11"}),e.jsx("path",{d:"M2.5 8h11"}),e.jsx("path",{d:"M2.5 12h7"})]});case"gear":return e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"8",cy:"8",r:"2.2"}),e.jsx("path",{d:"M8 1.6v2"}),e.jsx("path",{d:"M8 12.4v2"}),e.jsx("path",{d:"M1.6 8h2"}),e.jsx("path",{d:"M12.4 8h2"}),e.jsx("path",{d:"M3.5 3.5l1.4 1.4"}),e.jsx("path",{d:"M11.1 11.1l1.4 1.4"}),e.jsx("path",{d:"M12.5 3.5l-1.4 1.4"}),e.jsx("path",{d:"M4.9 11.1l-1.4 1.4"})]});case"sparkle":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M12 3l1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9z"}),e.jsx("path",{d:"M18.5 15.5l.8 2.2 2.2.8-2.2.8-.8 2.2-.8-2.2-2.2-.8 2.2-.8z"})]});case"contrast":return e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"12",cy:"12",r:"9"}),e.jsx("path",{d:"M12 3a9 9 0 0 1 0 18z",fill:"currentColor",stroke:"none"})]});case"logout":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),e.jsx("path",{d:"M16 17l5-5-5-5"}),e.jsx("path",{d:"M21 12H9"})]});default:return null}}function st({name:a,size:s=16,className:r,title:l,...c}){const f=l?void 0:!0,m=Mp.has(a);return e.jsxs("svg",{width:s,height:s,viewBox:m?"0 0 16 16":"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:m?1.4:2,strokeLinecap:"round",strokeLinejoin:"round",className:r,"aria-hidden":f,role:l?"img":"presentation",...c,children:[l?e.jsx("title",{children:l}):null,zp(a)]})}const vu=1;function Oa(a){return typeof a=="object"&&a!==null&&!Array.isArray(a)}const Pp=["granted","denied","structurally_unavailable","trust_gated"],Ip=["attachable","requires_review","blocked"],Op=["default","operator","structural"],Dp=["grant","deny","clear"],Fp=new Set(["__proto__","constructor","prototype"]);function qp(a,s){if(!Oa(a))return{ok:!1,reason:`${s}: cell is not an object`};const r=String(a.availability||"");if(!Pp.includes(r))return{ok:!1,reason:`${s}: unknown availability "${r}"`};const l=String(a.provenance||"");if(!Op.includes(l))return{ok:!1,reason:`${s}: unknown provenance "${l}"`};let c;if(r==="trust_gated"){const f=String(a.trust_state||"");if(!Ip.includes(f))return{ok:!1,reason:`${s}: trust_gated cell without a valid trust_state ("${f}")`};c=f}for(const f of["assigned","resolved_value","executable"]){const m=a[f];if(m!==void 0&&typeof m!="boolean")return{ok:!1,reason:`${s}: "${f}" is present but not a boolean`}}return{ok:!0,cell:{assigned:a.assigned===!0,resolved_value:a.resolved_value===!0,provenance:l,availability:r,executable:a.executable!==!1,reason:typeof a.reason=="string"?a.reason:void 0,trust_state:c}}}function Uf(a){if(!Oa(a))return{ok:!1,reason:"payload is not an object"};const s=a.schema_version;if(typeof s!="number"||!Number.isFinite(s))return{ok:!1,reason:"payload has no numeric schema_version"};if(Math.floor(s)!==vu)return{ok:!1,reason:`unsupported schema_version ${s} (this build understands ${vu}); refusing to render grant state from an unknown schema`};if(!Array.isArray(a.phases)||a.phases.length===0)return{ok:!1,reason:"payload has no phases"};if(!Array.isArray(a.sections))return{ok:!1,reason:"payload has no sections"};const r=[],l=new Set;for(const m of a.phases){if(!Oa(m)||typeof m.id!="string"||!m.id.trim())return{ok:!1,reason:"phase without a string id"};const p=m.id.trim();if(Fp.has(p))return{ok:!1,reason:`reserved phase id "${p}"`};if(l.has(p))return{ok:!1,reason:`duplicate phase id "${p}"`};l.add(p),r.push({id:p,label:typeof m.label=="string"?m.label:void 0,hint:typeof m.hint=="string"?m.hint:void 0})}const c=[],f=new Set;for(const m of a.sections){if(!Oa(m)||typeof m.id!="string"||!m.id.trim())return{ok:!1,reason:"section without a string id"};const p=m.id.trim();if(f.has(p))return{ok:!1,reason:`duplicate section id "${p}"`};if(f.add(p),!Array.isArray(m.items))return{ok:!1,reason:`section "${p}" has no items array`};const _=[],y=new Set;for(const w of m.items){if(!Oa(w)||typeof w.id!="string"||!w.id.trim())return{ok:!1,reason:`section "${p}": item without a string id`};const x=w.id.trim();if(y.has(x))return{ok:!1,reason:`section "${p}": duplicate item id "${x}"`};if(y.add(x),w.cells!==void 0&&!Oa(w.cells))return{ok:!1,reason:`section "${p}" item "${x}": cells is not an object`};const N=Object.create(null),$=Oa(w.cells)?w.cells:{};for(const[P,T]of Object.entries($)){if(!l.has(P))return{ok:!1,reason:`section "${p}" item "${x}": cell for undeclared phase "${P}"`};const F=qp(T,`section "${p}" item "${x}" phase "${P}"`);if(!F.ok)return F;N[P]=F.cell}_.push({id:x,label:typeof w.label=="string"?w.label:void 0,description:typeof w.description=="string"?w.description:void 0,cells:N})}c.push({id:p,label:typeof m.label=="string"?m.label:void 0,items:_})}return{ok:!0,payload:{schema_version:vu,phases:r,sections:c}}}function Bp(a,s,r,l){for(const c of a)if(c.section===s&&c.item===r&&c.phase===l)return c.op;return null}function nd(a,s,r,l,c){const f=a.sections.find(P=>P.id===r),m=f==null?void 0:f.items.find(P=>P.id===l),p=m&&m.cells[c]||null,_=Bp(s,r,l,c);if(!p)return{cell:null,pending:null,effective_value:!1,interactive:!1,approval_required:!1,standing_config:!1,reason:"not declared by the server for this phase",control:{kind:"absent"}};const y=p.availability==="structurally_unavailable"||p.availability==="trust_gated"&&p.trust_state==="blocked";let w=p.resolved_value;_==="grant"?w=!0:_==="deny"?w=!1:_==="clear"&&(w=p.provenance==="operator"?null:p.resolved_value);const x=p.availability==="trust_gated"&&p.trust_state==="requires_review",N=y?!1:w;let $;return y?$={kind:"blocked",blocked_kind:p.availability==="trust_gated"?"trust":"structural"}:x&&N!==!0?$={kind:"approval"}:$={kind:"tristate",options:["grant","clear","deny"],active_op:_!==null?_:p.assigned?p.resolved_value?"grant":"deny":"clear"},{cell:p,pending:_,effective_value:N,interactive:!y,approval_required:x,standing_config:!y&&p.executable===!1,reason:p.reason||(y?p.availability:null),control:$}}function Up(a,s,r){const l=nd(a,s,r.section,r.item,r.phase);if(!l.cell||!l.interactive)return s;const c=s.filter(p=>!(p.section===r.section&&p.item===r.item&&p.phase===r.phase)),f=l.cell;return r.op==="clear"?f.assigned?[...c,r]:c:f.assigned&&f.provenance==="operator"&&f.resolved_value===(r.op==="grant")?c:[...c,r]}function Wp(a,s){const r=new Set,l=[];for(const c of s){if(!Oa(c)||!Dp.includes(c.op))continue;const f=`${c.section}\0${c.item}\0${c.phase}`;if(r.has(f))continue;r.add(f);const m=nd(a,[],c.section,c.item,c.phase);!m.cell||!m.interactive||l.push(c)}return l}function Hp(a){return a==="grant"?"Grant":a==="deny"?"Deny":"Default"}function Vp(a){const{view:s,disabled:r}=a,l=s.control;if(l.kind==="absent")return e.jsx("div",{className:"af-matrix__cell is-absent",title:s.reason||void 0,children:e.jsx("span",{className:"af-matrix__cell-mark",children:"—"})});if(l.kind==="blocked")return e.jsxs("div",{className:`af-matrix__cell is-unavailable is-${l.blocked_kind}`,children:[e.jsx("span",{className:"af-matrix__cell-mark",children:"✕"}),e.jsx("span",{className:"af-matrix__cell-note",children:l.blocked_kind==="trust"?"blocked":"structural"}),s.reason?e.jsx("span",{className:"af-matrix__cell-reason",children:s.reason}):null]});if(l.kind==="approval")return e.jsxs("div",{className:"af-matrix__cell is-review",children:[e.jsx("span",{className:"af-matrix__cell-note",children:"needs review"}),e.jsx("button",{type:"button",className:"af-matrix__approve-btn",disabled:r,onClick:()=>a.onAct("grant"),"aria-label":`Approve and enable: ${a.cellLabel}`,children:"Approve & enable"}),s.reason?e.jsx("span",{className:"af-matrix__cell-reason",children:s.reason}):null]});const c=s.cell,f=s.effective_value===null?"server default (unknown until saved)":s.effective_value?"on":"off";return e.jsxs("div",{className:`af-matrix__cell ${s.effective_value===null?"is-indeterminate":s.effective_value?"is-on":"is-off"} ${s.pending?"is-pending":""}`.trim(),title:s.reason||void 0,children:[e.jsx("div",{className:"af-matrix__tristate",role:"group","aria-label":a.cellLabel,children:l.options.map(m=>e.jsx("button",{type:"button","aria-pressed":l.active_op===m,className:`af-matrix__tri-btn is-${m} ${l.active_op===m?"is-active":""}`.trim(),disabled:r,onClick:()=>a.onAct(m),children:Hp(m)},m))}),e.jsxs("div",{className:"af-matrix__cell-meta",children:[e.jsx("span",{className:`af-matrix__prov is-${c.provenance}`,children:s.pending?"pending":c.provenance}),e.jsx("span",{className:"af-matrix__value-mark",children:f}),s.standing_config?e.jsx("span",{className:"af-matrix__standing",title:s.reason||"grant is stored; no executor consumes it yet",children:"standing config"}):null]})]})}function Gp(a){const s=a.disabled===!0,r=h.useMemo(()=>Uf(a.payload),[a.payload]),l=h.useMemo(()=>r.ok?Wp(r.payload,a.patches):a.patches,[r,a.patches]);if(!r.ok)return e.jsxs("div",{className:`af-matrix af-matrix--refused ${a.className||""}`.trim(),children:[e.jsx("div",{className:"af-matrix__title",children:a.title||"Phase capabilities"}),e.jsxs("div",{className:"af-matrix__refusal",children:["Cannot render capability state: ",r.reason]})]});const c=r.payload,f=(m,p,_,y)=>{if(s)return;const w=Up(c,l,{section:m,item:p,phase:_,op:y});a.onPatchesChange(w)};return e.jsxs("div",{className:`af-matrix ${a.className||""}`.trim(),children:[e.jsxs("div",{className:"af-matrix__header",children:[e.jsx("div",{className:"af-matrix__title",children:a.title||"Phase capabilities"}),a.subtitle?e.jsx("div",{className:"af-matrix__subtitle",children:a.subtitle}):null,l.length>0?e.jsxs("div",{className:"af-matrix__pending-note",children:[l.length," unsaved change",l.length===1?"":"s"," (cell-scoped; untouched cells are never written)"]}):null]}),e.jsx("div",{className:"af-matrix__scroll",children:e.jsxs("table",{className:"af-matrix__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:"af-matrix__corner"}),c.phases.map(m=>e.jsxs("th",{className:"af-matrix__phase",title:m.hint||void 0,children:[e.jsx("span",{className:"af-matrix__phase-label",children:m.label||m.id}),m.hint?e.jsx("span",{className:"af-matrix__phase-hint",children:m.hint}):null]},m.id))]})}),c.sections.map(m=>e.jsxs("tbody",{className:"af-matrix__section",children:[e.jsx("tr",{className:"af-matrix__section-row",children:e.jsx("th",{className:"af-matrix__section-label",colSpan:c.phases.length+1,children:m.label||m.id})}),m.items.map(p=>e.jsxs("tr",{className:"af-matrix__item-row",children:[e.jsx("th",{className:"af-matrix__item",title:p.description||void 0,children:e.jsx("span",{className:"af-matrix__item-name",children:p.label||p.id})}),c.phases.map(_=>{const y=nd(c,l,m.id,p.id,_.id);return e.jsx("td",{className:"af-matrix__cell-td",children:e.jsx(Vp,{view:y,cellLabel:`${p.label||p.id} — ${_.label||_.id}`,disabled:s,onAct:w=>f(m.id,p.id,_.id,w)})},_.id)})]},p.id)),m.items.length===0?e.jsx("tr",{children:e.jsx("td",{className:"af-matrix__empty",colSpan:c.phases.length+1,children:"No entries in this section."})}):null]},m.id))]})})]})}async function Fu(a="/api/connection/gateway"){const s=await fetch(a),r=await s.json().catch(()=>null);if(!s.ok){const l=r&&typeof r=="object"&&r.detail?String(r.detail):`HTTP ${s.status}`;throw new Error(l)}return r}async function Kp(a,s="/api/connection/gateway"){const r=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),l=await r.json().catch(()=>null);if(!r.ok){const c=l&&typeof l=="object"&&l.detail?String(l.detail):`HTTP ${r.status}`;throw new Error(c)}return l}async function Wf(a="/api/connection/gateway"){const s=await fetch(a,{method:"DELETE"});if(!s.ok){const r=await s.json().catch(()=>({})),l=r&&typeof r=="object"&&r.detail?String(r.detail):`HTTP ${s.status}`;throw new Error(l)}}function yu(a){let s=String(a||"").trim();for(let r=0;r<2&&s;r+=1){try{const f=JSON.parse(s);if(typeof f=="string"&&f!==s){s=f.trim();continue}}catch{}const l=s[0],c=s[s.length-1];if(l==='"'&&c==='"'||l==="'"&&c==="'"){s=s.slice(1,-1).trim();continue}break}return s.replace(/\/+$/,"")}function Qp(a){var f,m;if(!a)return{label:"Signed out",tone:"warn"};if(!a.has_session)return{label:"Signed out",tone:"warn"};const s=a.gateway||{},r=(f=s.principal)==null?void 0:f.user_id,l=(m=s.principal)==null?void 0:m.runtime_id;if(s.ok&&r)return{label:`Signed in as ${r}${l?` · runtime ${l}`:""}`,tone:"ok"};if(s.ok)return{label:"Signed in",tone:"ok"};const c=s.error||s.detail;return typeof c=="string"&&c.trim()?{label:"Session rejected — sign in again",tone:"err"}:{label:"Sign in required",tone:"err"}}function Jp(a){const s=a.connectionPath||"/api/connection/gateway",[r,l]=h.useState(!1),[c,f]=h.useState(!1),[m,p]=h.useState(null),[_,y]=h.useState(!1);h.useEffect(()=>{a.isOpen||y(!1)},[a.isOpen]);const[w,x]=h.useState(a.defaultGatewayUrl||"http://127.0.0.1:8080"),[N,$]=h.useState("admin"),[P,T]=h.useState(""),[F,D]=h.useState(!1),[J,B]=h.useState(!0),[ee,C]=h.useState(""),[Z,ae]=h.useState(""),fe=h.useMemo(()=>Qp(m),[m]),ge=te=>{var z;p(te),(z=a.onStatusChange)==null||z.call(a,te)},Te=h.useRef(!1);if(h.useEffect(()=>{var z;if(!a.isOpen)return;const te=!Te.current;if(Te.current=!0,te&&a.initialStatus!==void 0&&a.initialStatus!==null){const V=a.initialStatus;ge(V),typeof V.gateway_url=="string"&&V.gateway_url.trim()&&x(yu(V.gateway_url));const H=(z=V.gateway)==null?void 0:z.principal;H!=null&&H.user_id&&$(H.user_id);return}l(!0),C(""),Fu(s).then(V=>{var ce;ge(V),typeof V.gateway_url=="string"&&V.gateway_url.trim()&&x(yu(V.gateway_url));const H=(ce=V.gateway)==null?void 0:ce.principal;H!=null&&H.user_id&&$(H.user_id)}).catch(V=>C(`Failed to load connection status: ${String((V==null?void 0:V.message)||V)}`)).finally(()=>l(!1))},[a.isOpen]),h.useEffect(()=>{if(!a.isOpen)return;const te=z=>{z.key==="Escape"&&!z.defaultPrevented&&!a.blocking&&(z.preventDefault(),a.onClose())};return window.addEventListener("keydown",te),()=>window.removeEventListener("keydown",te)},[a.isOpen,a.blocking,a.onClose]),!a.isOpen||_)return null;const Se=async()=>{f(!0),C(""),ae("");try{const te=yu(w);x(te);const z=await Kp({gateway_url:te,gateway_user_id:N,gateway_token:P,persist:J},s);ge(z),T(""),y(!0),a.onClose()}catch(te){C(String((te==null?void 0:te.message)||te))}finally{f(!1)}},K=async()=>{f(!0),C(""),ae("");try{await Wf(s),T("");const te=await Fu(s).catch(()=>null);ge(te),ae("Signed out. This browser no longer holds a gateway session.")}catch(te){C(String((te==null?void 0:te.message)||te))}finally{f(!1)}};return e.jsx("div",{className:"af-connect-overlay",role:"presentation",onMouseDown:te=>{!a.blocking&&te.target===te.currentTarget&&a.onClose()},children:e.jsx("div",{className:"af-connect-modal",role:"dialog","aria-modal":"true","aria-label":"Gateway connection",children:e.jsx(Ep,{kicker:`${a.appName||"AbstractFramework"} connection`,title:"Connect this browser to AbstractGateway",description:"Sign in with a Gateway user token. The app exchanges it for an HTTP-only browser session and never stores the raw token.",statusLabel:fe.label,statusTone:fe.tone,tokenSourceLabel:m!=null&&m.has_session?"token: browser session":"token: missing",showGatewayUrl:!0,gatewayUrl:w,onGatewayUrlChange:te=>x(te),userId:N,onUserIdChange:$,token:P,tokenPlaceholder:m!=null&&m.has_session?"(browser session already signed in)":"Paste Gateway user token",showToken:F,onTokenChange:T,onShowTokenChange:D,remember:J,rememberLabel:"Keep this browser signed in",onRememberChange:B,loading:r,submitting:c,submittingLabel:"Signing in...",showClose:!a.blocking,onClose:a.onClose,showSignOut:!a.blocking&&!!(m!=null&&m.has_session),onSignOut:K,error:ee,message:Z,onSubmit:Se})})})}function Yp(a){return!!(a&&a.ok===!0&&a.has_session===!0)}function Xp(a){const s=a||{},r=s.connectionPath||"/api/connection/gateway",l=s.variant||"dismissable",c=h.useRef(s.onStatusChange);c.current=s.onStatusChange;const f=h.useRef(l);f.current=l;const m=h.useRef(!!s.autoOpenMidSession);m.current=!!s.autoOpenMidSession;const[p,_]=h.useState(null),[y,w]=h.useState("loading"),[x,N]=h.useState(!1),$=h.useRef(!1),P=h.useRef(!1),T=h.useRef("loading"),F=h.useRef("none"),D=h.useRef(!1),J=h.useRef(0),B=h.useCallback(z=>{var H;J.current+=1,_(z),(H=c.current)==null||H.call(c,z);const V=Yp(z);if(V)w("connected"),T.current="connected",$.current=!1,F.current="none",P.current||N(!1);else if(z!==null){const ce=T.current;w("disconnected"),T.current="disconnected",ce!=="disconnected"&&(F.current=D.current?"signout":ce==="connected"?"mid":"boot");const I=f.current==="blocking"||F.current!=="mid"||m.current;!$.current&&I&&N(!0)}z!==null&&(P.current=V)},[]),ee=h.useCallback(async()=>{const z=J.current;try{const V=await Fu(r);if(J.current!==z)return;B(V)}catch{if(J.current!==z)return;B(null)}},[r,B]),[C,Z]=h.useState(!1),[ae,fe]=h.useState(null),ge=h.useCallback(async()=>{Z(!0),fe(null),J.current+=1;let z=null;try{await Wf(r)}catch(V){z=String((V==null?void 0:V.message)||V||"Sign-out request failed")}D.current=!0;try{await ee()}finally{D.current=!1}fe(z),Z(!1)},[r,ee]),Te=h.useRef(!1);h.useEffect(()=>{Te.current||(Te.current=!0,ee())},[ee]);const Se=h.useCallback(()=>{N(!0)},[]),K=h.useCallback(()=>{const z=T.current;l==="blocking"&&z==="disconnected"||(z==="disconnected"&&($.current=!0),N(!1))},[l]),te=h.useMemo(()=>({isOpen:x,onClose:K,blocking:l==="blocking"&&y!=="connected",appName:s.appName,connectionPath:r,defaultGatewayUrl:s.defaultGatewayUrl,initialStatus:p,onStatusChange:B}),[x,K,l,y,s.appName,r,s.defaultGatewayUrl,p,B]);return{status:p,phase:y,connected:y==="connected",modalOpen:x,signingOut:C,signOutError:ae,openModal:Se,refresh:ee,signOut:ge,modalProps:te}}const xu={neutral:"var(--text-secondary)",muted:"var(--text-muted)",accent:"var(--accent)",info:"var(--info)",success:"var(--success)",warning:"var(--warning)",error:"var(--error)"},Zp=/^var\(--[a-z0-9-]+\)$/i;function e_(a,s){const r=a||"neutral";if(r==="custom"){const l=String(s||"").trim();return Zp.test(l)?l:xu.neutral}return xu[r]||xu.neutral}function t_(a,s,r){return[a,`${a}--${s.tone||"neutral"}`,s.size==="sm"?`${a}--sm`:"",r||"",s.className||""].filter(Boolean).join(" ")}function n_(a){return{"--af-chip-hue":e_(a.tone,a.hue)}}function In(a){return e.jsxs("span",{className:t_("af-chip",a,a.onRemove?"af-chip--removable":""),style:n_(a),title:a.title,children:[e.jsx("span",{className:"af-chip__label",children:a.children}),a.onRemove?e.jsx("button",{type:"button",className:"af-chip__remove","aria-label":a.removeLabel||"Remove",onClick:s=>{var r;s.stopPropagation(),(r=a.onRemove)==null||r.call(a)},children:e.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.6",strokeLinecap:"round",children:[e.jsx("path",{d:"M18 6L6 18"}),e.jsx("path",{d:"M6 6l12 12"})]})}):null]})}function s_(a){const s=a.closeOnEscape!==!1,r=h.useRef(null);return h.useEffect(()=>{if(!a.open||!s)return;const l=c=>{c.key!=="Escape"||c.defaultPrevented||(c.preventDefault(),a.onClose())};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[a.open,s,a.onClose]),h.useEffect(()=>{const l=r.current;l&&(a.open?l.removeAttribute("inert"):l.setAttribute("inert",""))},[a.open]),e.jsxs("div",{ref:r,className:`af-drawer${a.open?" af-drawer--open":""}${a.className?` ${a.className}`:""}`,style:{width:a.width||420,top:a.topOffset||0,display:a.open?void 0:"none"},role:"complementary","aria-label":a.label,"aria-hidden":a.open?void 0:!0,children:[a.title!==void 0?e.jsxs("div",{className:"af-drawer__header",children:[e.jsx("div",{className:"af-drawer__title",children:a.title}),e.jsxs("div",{className:"af-drawer__header-actions",children:[a.headerActions,e.jsx("button",{type:"button",className:"af-drawer__close","aria-label":"Close panel",onClick:a.onClose,children:"×"})]})]}):null,e.jsx("div",{className:"af-drawer__body",children:a.children})]})}function a_(a){const{connection:s}=a,r=s.phase,l=s.signingOut===!0,c=l?"Signing out…":r==="connected"?"Disconnect":r==="loading"?"Connecting…":"Connect",f=r==="connected"?"Disconnect from gateway":r==="loading"?"Checking gateway session…":"Connect to gateway";return e.jsxs("div",{className:`af-topbar${a.className?` ${a.className}`:""}`,role:"group","aria-label":"App actions",children:[a.assistant?e.jsx("button",{type:"button",className:`af-topbar__btn${a.assistant.open?" is-active":""}`,"aria-pressed":a.assistant.open,"aria-label":a.assistant.label||"Open assistant",title:a.assistant.label||"Assistant",onClick:a.assistant.onToggle,children:e.jsx(st,{name:"sparkle",size:16})}):null,a.appearance?e.jsx("button",{type:"button",className:"af-topbar__btn","aria-label":a.appearance.label||"Appearance (theme and typography)",title:a.appearance.label||"Appearance",onClick:a.appearance.onOpen,children:e.jsx(st,{name:"contrast",size:16})}):null,a.extraActions,e.jsxs("button",{type:"button",className:`af-topbar__pill af-topbar__pill--${r}`,onClick:r==="connected"?s.onDisconnect:s.onConnect,disabled:l,title:f,"aria-label":f,children:[e.jsx("span",{className:`af-topbar__dot af-topbar__dot--${r}`,"aria-hidden":"true"}),e.jsx("span",{className:"af-topbar__pill-label",children:c})]})]})}const Ko={theme:"dark",font_scale:"md",header_density:"standard"};function r_(a){const s=a&&typeof a=="object"?a:{};return{theme:typeof s.theme=="string"&&s.theme?s.theme:Ko.theme,font_scale:typeof s.font_scale=="string"&&s.font_scale?s.font_scale:Ko.font_scale,header_density:typeof s.header_density=="string"&&s.header_density?s.header_density:Ko.header_density}}function i_(a){return`af_appearance_${a}_v1`}function l_(a,s){const r=i_(a),l=h.useMemo(()=>({...Ko}),[JSON.stringify({})]),[c,f]=h.useState(()=>{let m=l;try{const p=localStorage.getItem(r)??(s!=null&&s.legacyKey?localStorage.getItem(s.legacyKey):null);p&&(m=r_({...l,...JSON.parse(p)}))}catch{}try{Qm(m.theme),Jm({font_scale:m.font_scale,header_density:m.header_density})}catch{}return m});return h.useEffect(()=>{Qm(c.theme),Jm({font_scale:c.font_scale,header_density:c.header_density});try{localStorage.setItem(r,JSON.stringify(c))}catch{}},[r,c]),[c,f]}function o_(a){return h.useEffect(()=>{if(!a.open)return;const s=r=>{r.key!=="Escape"||r.defaultPrevented||(r.preventDefault(),a.onClose())};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[a.open,a.onClose]),a.open?e.jsx("div",{className:"af-appearance-overlay",onClick:a.onClose,role:"presentation",children:e.jsxs("div",{className:"af-appearance",role:"dialog","aria-modal":"true","aria-label":a.title||"Appearance",onClick:s=>s.stopPropagation(),children:[e.jsx("div",{className:"af-appearance__title",children:a.title||"Appearance"}),e.jsx("div",{className:"af-appearance__note",children:a.note||"Stored locally in this browser, per app."}),e.jsxs("div",{className:"af-appearance__grid",children:[e.jsx("label",{className:"af-appearance__label",children:"Theme"}),e.jsx(Ap,{value:a.value.theme,onChange:s=>a.onChange({...a.value,theme:s})}),e.jsx("label",{className:"af-appearance__label",children:"Font size"}),e.jsx(Rp,{value:a.value.font_scale,onChange:s=>a.onChange({...a.value,font_scale:s})}),e.jsx("label",{className:"af-appearance__label",children:"Header size"}),e.jsx(Lp,{value:a.value.header_density,onChange:s=>a.onChange({...a.value,header_density:s})})]}),e.jsx("div",{className:"af-appearance__actions",children:e.jsx("button",{type:"button",className:"af-appearance__close",onClick:a.onClose,children:"Close"})})]})}):null}async function*c_(a){const s=new AbortController;try{const r=await fetch(a.path,{method:"POST",headers:{"Content-Type":"application/json",...a.csrfToken?{"x-abstract-csrf":a.csrfToken}:{},...a.headers||{}},body:JSON.stringify(a.body),signal:s.signal});if(!r.ok){const m=await r.json().catch(()=>null),p=m&&typeof m=="object"&&m.detail?String(m.detail):`HTTP ${r.status}`;throw new Error(p)}if(!r.body)throw new Error("TTS stream has no body");const l=r.body.getReader(),c=new TextDecoder;let f="";for(;;){const{done:m,value:p}=await l.read();if(m)break;f+=c.decode(p,{stream:!0});let _;for(;(_=f.indexOf(`
41
- `))>=0;){const y=f.slice(0,_).trim();if(f=f.slice(_+1),!y)continue;let w=null;try{w=JSON.parse(y)}catch{continue}if(w&&w.type==="error")throw new Error(String(w.error||"TTS stream error"));const x=w&&typeof w.audio_b64=="string"?w.audio_b64:"";if(x){const N=atob(x),$=new Uint8Array(N.length);for(let P=0;P<N.length;P+=1)$[P]=N.charCodeAt(P);yield $.buffer}if(w&&(w.type==="done"||w.type==="cancelled"))return}}}finally{s.abort()}}function u_(){var s;if(typeof window>"u")return!1;const a=navigator;return!!((s=a==null?void 0:a.mediaDevices)!=null&&s.getUserMedia)&&typeof window.MediaRecorder=="function"}function d_(){if(typeof window>"u")return!1;const a=window;return!!(a!=null&&a.AudioContext||a!=null&&a.webkitAudioContext)}function m_(){const a=window.MediaRecorder,s=l=>{var c;try{return!!((c=a==null?void 0:a.isTypeSupported)!=null&&c.call(a,l))}catch{return!1}},r=["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/ogg;codecs=opus","audio/ogg"];for(const l of r)if(s(l))return l;return""}async function wu(a,s){var c;const r=s.slice(0),l=(c=a.decodeAudioData)==null?void 0:c.bind(a);if(typeof l!="function")throw new Error("decodeAudioData not available");try{const f=l(r);if(f&&typeof f.then=="function")return await f}catch{}return await new Promise((f,m)=>{try{l(r,f,m)}catch(p){m(p)}})}function f_(a){const s=new Uint8Array(a);if(s.length<44)return null;const r=f=>String.fromCharCode(s[f],s[f+1],s[f+2],s[f+3]);if(r(0)!=="RIFF"||r(8)!=="WAVE")return null;const l=new DataView(a);let c=12;for(;c+8<=s.length;){const f=r(c),m=l.getUint32(c+4,!0);if(f==="data")return s.slice(0,c+8);c+=8+m+m%2}return null}function h_(a,s){const r=new Uint8Array(s),l=new Uint8Array(a.length+r.length);l.set(a,0),l.set(r,a.length);const c=new DataView(l.buffer);return c.setUint32(4,l.length-8,!0),c.setUint32(a.length-4,r.length,!0),l.buffer}function Hf(a){const s=h.useRef(a);s.current=a;const r=he=>{var Re,ze;return(ze=(Re=s.current).on_error)==null?void 0:ze.call(Re,he)},l=h.useMemo(()=>d_()&&(typeof a.tts=="function"||typeof a.tts_stream=="function"),[a.tts,a.tts_stream]),c=h.useMemo(()=>u_()&&typeof a.transcribe=="function",[a.transcribe]),[f,m]=h.useState({key:"",status:"idle"}),p=h.useRef(f),_=h.useCallback(he=>{p.current=he,m(Re=>Re.key===he.key&&Re.status===he.status?Re:he)},[]),y=h.useRef(""),w=h.useRef(""),x=h.useRef(null),N=h.useRef(null),$=h.useRef(null),P=h.useRef(null),T=h.useRef(0),F=h.useRef(0),D=h.useRef(0),J=h.useRef([]),B=h.useRef(0),ee=h.useRef(!0),C=h.useRef(!1),Z=()=>{try{const he=globalThis,Re=(he==null?void 0:he.AudioContext)||(he==null?void 0:he.webkitAudioContext);if(!Re)return null;if(!x.current){const xe=new Re,O=xe.createGain();O.gain.value=1,O.connect(xe.destination),x.current=xe,N.current=O}const ze=x.current,re=N.current;if(!ze||!re)return null;try{ze.state==="suspended"&&ze.resume()}catch{}return{ctx:ze,gain:re}}catch{return null}},ae=h.useCallback(()=>{const he=$.current;if($.current=null,!!he){try{he.onended=null}catch{}try{he.stop()}catch{}try{he.disconnect()}catch{}}},[]),fe=h.useCallback(()=>{ae(),D.current+=1,J.current=[],B.current=0,ee.current=!0,C.current=!1,w.current="",y.current="",P.current=null,T.current=0,F.current=0,_({key:"",status:"idle"})},[ae,_]);h.useEffect(()=>()=>{var he,Re;fe();try{(he=N.current)==null||he.disconnect()}catch{}try{(Re=x.current)==null||Re.close()}catch{}x.current=null,N.current=null,P.current=null},[]);const ge=async(he,Re,ze)=>{const re=D.current,xe=Z();if(!xe)throw new Error("TTS playback is not supported in this browser");const{ctx:O,gain:me}=xe;try{O.state==="suspended"&&await O.resume()}catch{}if(re!==D.current)return;ae();const De=O.createBufferSource();De.buffer=Re,De.connect(me);const G=Number.isFinite(Number(Re.duration))?Number(Re.duration):0,le=Math.max(0,Math.min(Number(ze||0),G>0?Math.max(0,G-.01):0));F.current=O.currentTime-le,T.current=le,$.current=De,y.current=he,De.onended=()=>{$.current===De&&($.current=null,T.current=0,F.current=0,y.current="",_({key:"",status:"idle"}))},De.start(0,le),_({key:he,status:"playing"})},Te=(he,Re)=>{if(Re!==D.current)return;const ze=Z();if(!ze)return;const re=J.current,xe=B.current;if(xe>=re.length){ee.current&&(y.current="",T.current=0,F.current=0,_({key:"",status:"idle"}));return}const O=re[xe],{ctx:me,gain:De}=ze;ae();const G=me.createBufferSource();G.buffer=O,G.connect(De);const le=Number.isFinite(Number(O.duration))?Number(O.duration):0,ye=Math.max(0,Math.min(Number(T.current||0),le>0?Math.max(0,le-.01):0));F.current=me.currentTime-ye,$.current=G,y.current=he,G.onended=()=>{Re===D.current&&$.current===G&&($.current=null,B.current=xe+1,T.current=0,Te(he,Re))};try{me.state==="suspended"&&me.resume()}catch{}G.start(0,ye),_({key:he,status:"playing"})},Se=async(he,Re,ze)=>{const re=Z();if(!re){r==null||r("TTS playback is not supported in this browser.");return}ae();const xe=++D.current;J.current=[],B.current=0,ee.current=!1,C.current=!1,P.current=null,T.current=0,F.current=0,y.current=he,w.current=he,_({key:he,status:"loading"}),r==null||r("");let O=null;try{for await(const me of ze(Re)){if(xe!==D.current)return;let De;try{De=await wu(re.ctx,me),O||(O=f_(me))}catch{if(!O)continue;try{De=await wu(re.ctx,h_(O,me))}catch{continue}}if(xe!==D.current)return;J.current.push(De),!$.current&&!C.current&&(w.current="",Te(he,xe))}if(xe!==D.current)return;if(ee.current=!0,J.current.length===0){r==null||r("TTS stream produced no audio."),fe();return}!$.current&&!C.current&&Te(he,xe)}catch(me){if(xe!==D.current)return;r==null||r(String((me==null?void 0:me.message)||me||"TTS stream failed")),fe()}},K=h.useCallback(async(he,Re)=>{const ze=String(he||"").trim(),re=String(Re||"").trim();if(!ze||!re)return;const xe=s.current.tts,O=s.current.tts_stream;if(typeof xe!="function"&&typeof O!="function"){r==null||r("TTS is not available.");return}const me=Z();if(!me){r==null||r("TTS playback is not supported in this browser.");return}const De=p.current,G=De.key===ze;if(G&&De.status==="playing"){if($.current){const ye=Math.max(0,me.ctx.currentTime-Number(F.current||0));T.current=ye}else T.current=0;C.current=!0,ae(),_({key:ze,status:"paused"});return}if(G&&De.status==="paused"){if(J.current.length>0){r==null||r(""),C.current=!1,_({key:ze,status:"playing"}),Te(ze,D.current);return}const ye=P.current;if(ye){r==null||r(""),C.current=!1;try{await ge(ze,ye,T.current)}catch(Oe){r==null||r(String((Oe==null?void 0:Oe.message)||Oe||"TTS play failed")),_({key:"",status:"idle"})}return}}if(G&&De.status==="loading")return;if(typeof O=="function"){await Se(ze,re,O);return}ae(),D.current+=1;const le=D.current;J.current=[],B.current=0,ee.current=!0,C.current=!1,P.current=null,T.current=0,F.current=0,y.current=ze,w.current=ze,_({key:ze,status:"loading"}),r==null||r("");try{const ye=await xe(re);if(w.current!==ze||D.current!==le)return;const Oe=await wu(me.ctx,ye);if(w.current!==ze||D.current!==le)return;P.current=Oe,T.current=0,await ge(ze,Oe,0)}catch(ye){if(D.current!==le)return;w.current===ze&&(w.current="",y.current="",_({key:"",status:"idle"})),r==null||r(String((ye==null?void 0:ye.message)||ye||"TTS failed"))}},[]),[te,z]=h.useState(!1),[V,H]=h.useState(!1),ce=h.useRef(!1),I=h.useRef(c);I.current=c;const _e=h.useCallback(he=>{ce.current=he,z(Re=>Re===he?Re:he)},[]),Y=h.useRef(!1),S=h.useRef(null),A=h.useRef(null),U=h.useRef([]),ie=h.useRef(""),de=h.useRef(0),L=h.useRef(!1);function ke(){var he,Re;try{(Re=(he=S.current)==null?void 0:he.getTracks)==null||Re.call(he).forEach(ze=>{try{ze.stop()}catch{}})}catch{}S.current=null}const be=h.useCallback(()=>{de.current+=1,L.current=!1;const he=A.current;if(he){he.onstop=null,he.ondataavailable=null,he.onerror=null;try{he.stop()}catch{}}A.current=null,ke(),_e(!1),Y.current=!1,H(!1),U.current=[]},[_e]);h.useEffect(()=>()=>be(),[be]);async function Ie(he,Re){var xe,O;if(r==null||r(""),!he||!he.size||Y.current)return;const ze=s.current.transcribe;if(typeof ze!="function"){r==null||r("Transcription is not available.");return}Y.current=!0;const re=de.current;H(!0);try{const me=String(await ze(he,Re)||"").trim();re===de.current&&me&&((O=(xe=s.current).on_transcript)==null||O.call(xe,me))}catch(me){re===de.current&&(r==null||r(String((me==null?void 0:me.message)||me||"Transcription failed")))}finally{re===de.current&&(Y.current=!1,H(!1))}}const Fe=h.useCallback(async()=>{if(r==null||r(""),!I.current){r==null||r("Voice recording is not supported in this browser (MediaRecorder/getUserMedia unavailable).");return}if(Y.current||L.current||ce.current||A.current)return;U.current=[];const he=de.current;L.current=!0;try{const Re=await navigator.mediaDevices.getUserMedia({audio:!0});if(he!==de.current){Re.getTracks().forEach(xe=>xe.stop());return}S.current=Re;const ze=m_();ie.current=ze;const re=ze?new MediaRecorder(Re,{mimeType:ze}):new MediaRecorder(Re);A.current=re,re.ondataavailable=xe=>{if(he===de.current)try{xe!=null&&xe.data&&U.current.push(xe.data)}catch{}},re.onerror=()=>{he===de.current&&(r==null||r("Recording failed."))},re.onstop=()=>{if(he===de.current){_e(!1),ke(),A.current=null;try{const xe=new Blob(U.current,{type:ie.current||""});Ie(xe,ie.current)}catch(xe){r==null||r(String((xe==null?void 0:xe.message)||xe||"Failed to build recording"))}}},re.start(),_e(!0)}catch(Re){if(he!==de.current)return;ke(),A.current=null,_e(!1);const ze=String((Re==null?void 0:Re.message)||Re||"Failed to access microphone");r==null||r(ze.toLowerCase().includes("permission")?`Microphone permission denied: ${ze}`:ze)}finally{he===de.current&&(L.current=!1)}},[]),Ye=h.useCallback(()=>{const he=A.current;if(!(!ce.current||!he)){_e(!1);try{he.stop()}catch(Re){r==null||r(String((Re==null?void 0:Re.message)||Re||"Failed to stop recording"))}}},[]);return h.useEffect(()=>{if(!te)return;const he=()=>Ye();return window.addEventListener("pointerup",he),window.addEventListener("pointercancel",he),()=>{window.removeEventListener("pointerup",he),window.removeEventListener("pointercancel",he)}},[te]),{tts_supported:l,tts_playback:f,toggle_tts:K,stop_tts:fe,voice_ptt_supported:c,voice_ptt_recording:te,voice_ptt_busy:V,start_voice_ptt_recording:Fe,stop_voice_ptt_recording:Ye,cancel_voice_ptt_recording:be}}function p_(a){const s=String(a??"").trim();if(!s||!(s.startsWith("{")&&s.endsWith("}")||s.startsWith("[")&&s.endsWith("]")))return null;try{return JSON.parse(s)}catch{return null}}async function yn(a){const s=String(a||"");if(!s)return!1;try{return await navigator.clipboard.writeText(s),!0}catch{try{const r=document.createElement("textarea");return r.value=s,r.style.position="fixed",r.style.left="-9999px",document.body.appendChild(r),r.select(),document.execCommand("copy"),document.body.removeChild(r),!0}catch{return!1}}}const __=3,g_=Number.MAX_SAFE_INTEGER;function Vf(a){return!!a&&typeof a=="object"&&!Array.isArray(a)}function Gf(a){return Array.isArray(a)}function v_(a){if(a==null)return"";if(typeof a=="string")return a;try{return JSON.stringify(a,null,2)}catch{return String(a)}}function gi({kind:a,children:s}){return e.jsx("span",{className:`pc-json-token ${a}`,children:s})}function y_(a){const s=JSON.stringify(a.value),r=s.length>96||s.includes("\\n")||s.includes("\\r")||s.includes("\\t"),[l,c]=h.useState(!r||a.expansionMode==="unfolded");return h.useEffect(()=>{r&&c(a.expansionMode==="unfolded")},[r,a.expansionMode,a.expansionVersion]),r?e.jsxs("span",{className:`pc-json-string ${l?"open":"collapsed"}`,children:[e.jsx("button",{type:"button",className:"pc-json-string__toggle",onClick:()=>c(f=>!f),"aria-label":l?"Collapse string value":"Expand string value","aria-expanded":l,children:l?"▾":"▸"}),l?e.jsx("span",{className:"pc-json-token string pc-json-string__value",children:s}):e.jsxs("button",{type:"button",className:"pc-json-string__preview",onClick:()=>c(!0),"aria-label":"Expand string value",children:[e.jsx("span",{className:"pc-json-token string pc-json-string__preview_text",children:s}),e.jsx("span",{className:"pc-json-string__suffix",children:"(...)"})]})]}):e.jsx(gi,{kind:"string",children:s})}function x_(a,s,r){return a===null?e.jsx(gi,{kind:"null",children:"null"}):typeof a=="string"?e.jsx(y_,{value:a,expansionMode:s,expansionVersion:r}):typeof a=="number"?e.jsx(gi,{kind:"number",children:String(a)}):typeof a=="boolean"?e.jsx(gi,{kind:"boolean",children:a?"true":"false"}):e.jsx(gi,{kind:"string",children:JSON.stringify(String(a))})}function w_(a){return Gf(a)?a.length===1?"1 item":`${a.length} items`:Vf(a)?Object.keys(a).length===1?"1 key":`${Object.keys(a).length} keys`:""}function Kf(a){const{label:s,value:r,depth:l,collapseAfterDepth:c,expansionMode:f,expansionVersion:m,trailingComma:p}=a,_=l*14,y=Vf(r),w=Gf(r),x=y||w,N=l<c,[$,P]=h.useState(N);h.useEffect(()=>{P(N)},[N,m]);const T=s?e.jsxs(e.Fragment,{children:[e.jsx(gi,{kind:"key",children:JSON.stringify(s)}),": "]}):null;if(!x)return e.jsxs("div",{className:"pc-json-viewer__line",style:{paddingLeft:_},children:[T,x_(r,f,m),p?",":""]});const F=w?"[":"{",D=w?"]":"}",J=w_(r),B=$?`${F}`:`${F}…${D}${J?` (${J})`:""}`,ee=w?r.map((C,Z)=>({key:String(Z),label:void 0,value:C})):Object.entries(r).map(([C,Z])=>({key:C,label:C,value:Z}));return e.jsxs("details",{className:"pc-json-viewer__details",open:$,onToggle:C=>P(C.currentTarget.open),children:[e.jsxs("summary",{className:"pc-json-viewer__summary",style:{paddingLeft:_},children:[T,e.jsx("span",{className:"pc-json-viewer__caret","aria-hidden":"true",children:$?"▾":"▸"}),e.jsx("span",{className:"pc-json-viewer__punct",children:B}),!$&&p?e.jsx("span",{className:"pc-json-viewer__punct",children:","}):null]}),$?e.jsx("div",{className:"pc-json-viewer__children",children:ee.length===0?e.jsxs("div",{className:"pc-json-viewer__line",style:{paddingLeft:_},children:[e.jsx("span",{className:"pc-json-viewer__punct",children:D}),p?",":""]}):e.jsxs(e.Fragment,{children:[ee.map((C,Z)=>{const ae=Z===ee.length-1;return e.jsx(Kf,{label:C.label,value:C.value,depth:l+1,collapseAfterDepth:c,expansionMode:f,expansionVersion:m,trailingComma:!ae},`${l}:${s||"root"}:${C.key}`)}),e.jsxs("div",{className:"pc-json-viewer__line",style:{paddingLeft:_},children:[e.jsx("span",{className:"pc-json-viewer__punct",children:D}),p?",":""]})]})}):null]})}function b_(a){const s=a.trim();if(!s)return a;if(s.startsWith("{")&&s.endsWith("}")||s.startsWith("[")&&s.endsWith("]"))try{return JSON.parse(s)}catch{return a}return a}function Qo(a){const{value:s,className:r,showCopy:l=!0}=a,[c,f]=h.useState({mode:"folded",version:0}),m=typeof a.collapseAfterDepth=="number"&&(Number.isFinite(a.collapseAfterDepth)||a.collapseAfterDepth===1/0)&&a.collapseAfterDepth>=0?a.collapseAfterDepth===1/0?Number.MAX_SAFE_INTEGER:Math.trunc(a.collapseAfterDepth):__,p=c.mode==="unfolded"?g_:m,_=h.useMemo(()=>typeof s=="string"?b_(s):s,[s]),y=h.useMemo(()=>v_(s),[s]),w=["pc-json-viewer",r].filter(Boolean).join(" ");h.useEffect(()=>{f(N=>({mode:"folded",version:N.version+1}))},[_]);const x=()=>{f(N=>({mode:N.mode==="unfolded"?"folded":"unfolded",version:N.version+1}))};return e.jsxs("div",{className:w,children:[e.jsxs("div",{className:"pc-json-viewer__toolbar",children:[e.jsx("button",{type:"button",className:"pc-btn pc-json-viewer__toggle-all",onClick:x,"aria-expanded":c.mode==="unfolded",children:c.mode==="unfolded"?"Fold all":"Unfold all"}),l?e.jsx("button",{type:"button",className:"pc-btn pc-json-viewer__copy",onClick:()=>void yn(y),children:"Copy JSON"}):null]}),e.jsx("div",{className:"pc-json-viewer__tree",role:"tree","aria-label":"JSON viewer",children:e.jsx(Kf,{value:_,depth:0,collapseAfterDepth:p,expansionMode:c.mode,expansionVersion:c.version,trailingComma:!1})})]})}function hl(a,s){const r=String(a??"");if(!s||!s.needles.length)return[r];const l=[],c=r.toLowerCase();let f=0;for(;f<r.length;){let m=-1,p="";for(let w=0;w<s.needlesLower.length;w++){const x=s.needlesLower[w];if(!x)continue;const N=c.indexOf(x,f);if(N===-1)continue;const $=s.needles[w]||"";$&&(m===-1||N<m||N===m&&$.length>p.length)&&(m=N,p=$)}if(m===-1||!p){l.push(r.slice(f));break}m>f&&l.push(r.slice(f,m));const _=s.hits===0&&s.id?s.id:void 0,y=r.slice(m,m+p.length);l.push(e.jsx("span",{id:_,className:s.className,children:y},`hl:${s.hits}`)),s.hits+=1,f=m+p.length}return l}function qu(a){const s=String(a||"").trim();if(s&&/^(https?:|mailto:|tel:|#|\/)/i.test(s))return s}function Da(a,s){const r=[],l=String(a??"");let c=0,f="";const m=()=>{if(f){for(const p of hl(f,s))r.push(p);f=""}};for(;c<l.length;){const p=l[c];if(p==="!"&&l[c+1]==="["){const _=l.indexOf("]",c+2);if(_!==-1&&l[_+1]==="("){const y=l.indexOf(")",_+2);if(y!==-1){const w=l.slice(c+2,_),x=qu(l.slice(_+2,y));if(x){m(),r.push(e.jsxs("span",{className:"pc-md_image_inline",children:[e.jsx("img",{className:"pc-md_img",src:x,alt:w,loading:"lazy"}),w?e.jsx("span",{className:"pc-md_img_caption",children:s?hl(w,s):w}):null]},`img:${c}`)),c=y+1;continue}}}}if(p==="["){const _=l.indexOf("]",c+1);if(_!==-1&&l[_+1]==="("){const y=l.indexOf(")",_+2);if(y!==-1){const w=l.slice(c+1,_),x=qu(l.slice(_+2,y));if(x){m(),r.push(e.jsx("a",{className:"pc-md_link",href:x,target:x.startsWith("#")?void 0:"_blank",rel:"noreferrer",children:Da(w,s)},`link:${c}`)),c=y+1;continue}}}}if(p==="`"){const _=l.indexOf("`",c+1);if(_!==-1){m();const y=l.slice(c+1,_);r.push(e.jsx("code",{children:s?hl(y,s):y},`code:${c}`)),c=_+1;continue}}if(p==="*"&&l[c+1]==="*"){const _=l.indexOf("**",c+2);if(_!==-1){m();const y=l.slice(c+2,_);r.push(e.jsx("strong",{children:s?hl(y,s):y},`bold:${c}`)),c=_+2;continue}}if(p==="*"&&l[c+1]!=="*"){const _=l.indexOf("*",c+1);if(_!==-1){m();const y=l.slice(c+1,_);r.push(e.jsx("em",{children:s?hl(y,s):y},`em:${c}`)),c=_+1;continue}}f+=p,c+=1}return m(),r}function j_(a){return String(a??"").replace(/\r\n/g,`
42
- `).replace(/\r/g,`
43
- `).split(`
44
- `)}function Jo(a){const r=String(a??"").match(/^([ \t]*)(?:([-*+])|(\d{1,9})[.)])\s+(.*)$/);return r?{indent:r[1].replace(/\t/g," ").length,ordered:!!r[3],start:r[3]?Math.max(1,parseInt(r[3],10)||1):1,content:r[4]??""}:null}function k_(a){const s=[];for(const c of a){const f=Jo(c);f?s.push(f):s.length>0&&c.trim()&&(s[s.length-1].content+=` ${c.trim()}`)}const r=[],l=[];for(const c of s){for(;l.length>0&&c.indent<l[l.length-1].indent;)l.pop();let f=l.length>0?l[l.length-1]:null;if(f&&c.indent>f.indent){const m=f.node.items,p=m[m.length-1];if(p){const _={ordered:c.ordered,start:c.start,items:[]};p.children.push(_),l.push({indent:c.indent,node:_}),f=l[l.length-1]}}else if(f&&f.node.ordered!==c.ordered){l.pop();const m=l.length>0?l[l.length-1]:null,p={ordered:c.ordered,start:c.start,items:[]};if(m){const _=m.node.items,y=_[_.length-1];y?y.children.push(p):m.node.items.push({content:"",children:[p]})}else r.push(p);l.push({indent:c.indent,node:p}),f=l[l.length-1]}if(!f){const m={ordered:c.ordered,start:c.start,items:[]};r.push(m),l.push({indent:c.indent,node:m}),f=l[l.length-1]}f.node.items.push({content:c.content,children:[]})}return r}function Qf(a,s,r){const l=a.items.map((c,f)=>e.jsxs("li",{children:[Da(c.content,s),c.children.map((m,p)=>Qf(m,s,`${r}:${f}:${p}`))]},`${r}:li:${f}`));return a.ordered?e.jsx("ol",{className:"pc-md_ol",start:a.start!==1?a.start:void 0,children:l},r):e.jsx("ul",{className:"pc-md_ul",children:l},r)}function S_(a,s,r){return k_(a).map((l,c)=>Qf(l,s,`${r}:${c}`))}function Zm(a){let s=String(a??"").trim();return s?(s.startsWith("|")&&(s=s.slice(1)),s.endsWith("|")&&(s=s.slice(0,-1)),s.split("|").map(r=>String(r??"").trim())):[]}function ef(a){let s=String(a??"").trim();if(!s)return!1;s.startsWith("|")&&(s=s.slice(1)),s.endsWith("|")&&(s=s.slice(0,-1));const r=s.split("|").map(l=>String(l??"").trim());return r.length<2?!1:r.every(l=>/^:?-{3,}:?$/.test(l))}function as({text:a,className:s,highlight:r,highlights:l,highlightClassName:c,highlightId:f}){const m=j_(a),p=[],_=[];Array.isArray(l)&&_.push(...l),typeof r=="string"&&r.trim()&&_.push(r);const y=Array.from(new Set(_.map($=>String($??"").trim()).filter(Boolean))).filter($=>$.length>=4),w=y.length?{needles:y,needlesLower:y.map($=>$.toLowerCase()),className:c||"pc-md_hl",id:f,hits:0}:null;let x=0;for(;x<m.length;){const $=String(m[x]??"");if(!$.trim()){x+=1;continue}const P=$.trim();if(/^([-_*])(\s*\1){2,}$/.test(P)){p.push(e.jsx("hr",{className:"pc-md_hr"},`hr:${x}`)),x+=1;continue}const T=$.match(/^\s*!\[([^\]]*)\]\(([^)]+)\)\s*$/);if(T){const J=qu(T[2]||"");if(J){const B=T[1]||"";p.push(e.jsxs("figure",{className:"pc-md_figure",children:[e.jsx("img",{className:"pc-md_img",src:J,alt:B,loading:"lazy"}),B?e.jsx("figcaption",{children:Da(B,w)}):null]},`figure:${x}`)),x+=1;continue}}if($.trim().startsWith("```")){const B=$.trim().replace(/```/g,"").trim(),ee=[];for(x+=1;x<m.length&&!String(m[x]??"").trim().startsWith("```");)ee.push(String(m[x]??"")),x+=1;x<m.length&&(x+=1);const C=ee.join(`
45
- `);p.push(e.jsx("pre",{className:"pc-md_pre",children:e.jsx("code",{className:B?`language-${B}`:void 0,children:C})},`pre:${x}`));continue}const F=$.match(/^(#{1,5})\s+(.*)$/);if(F){const J=F[1].length,B=F[2]||"",ee=Da(B,w);J===1?p.push(e.jsx("h1",{children:ee},`h1:${x}`)):J===2?p.push(e.jsx("h2",{children:ee},`h2:${x}`)):J===3?p.push(e.jsx("h3",{children:ee},`h3:${x}`)):J===4?p.push(e.jsx("h4",{children:ee},`h4:${x}`)):p.push(e.jsx("h5",{children:ee},`h5:${x}`)),x+=1;continue}if($.trimStart().startsWith(">")){const J=[];for(;x<m.length&&String(m[x]??"").trimStart().startsWith(">");){const ee=String(m[x]??"").trimStart();J.push(ee.replace(/^>\s?/,"")),x+=1}p.push(e.jsx("blockquote",{className:"pc-md_quote",children:J.map((B,ee)=>e.jsxs(Gt.Fragment,{children:[Da(B,w),ee<J.length-1?e.jsx("br",{}):null]},`q:${x}:${ee}`))},`quote:${x}`));continue}if($.includes("|")&&x+1<m.length&&ef(String(m[x+1]??""))){const J=Zm($),B=Math.max(1,J.length),ee=[];for(x+=2;x<m.length;){const C=String(m[x]??"");if(!C.trim()||!C.includes("|"))break;const Z=Zm(C),ae=[];for(let fe=0;fe<B;fe++)ae.push(Z[fe]??"");ee.push(ae),x+=1}p.push(e.jsx("div",{className:"pc-md_table_wrap",children:e.jsxs("table",{className:"pc-md_table",children:[e.jsx("thead",{children:e.jsx("tr",{children:J.slice(0,B).map((C,Z)=>e.jsx("th",{children:Da(C,w)},`th:${x}:${Z}`))})}),e.jsx("tbody",{children:ee.map((C,Z)=>e.jsx("tr",{children:C.map((ae,fe)=>e.jsx("td",{children:Da(ae,w)},`td:${x}:${Z}:${fe}`))},`tr:${x}:${Z}`))})]})},`table:${x}`));continue}if(Jo($)){const J=[];for(;x<m.length;){const B=String(m[x]??"");if(!B.trim()||B.trimStart().startsWith("```"))break;if(Jo(B)||/^\s{2,}\S/.test(B)){J.push(B),x+=1;continue}break}p.push(e.jsx(Gt.Fragment,{children:S_(J,w,`list:${x}`)},`list:${x}`));continue}const D=[];for(;x<m.length&&String(m[x]??"").trim()&&!(D.length>0&&Jo(String(m[x]??"")));){const J=String(m[x]??"");if(D.length>0&&J.includes("|")&&x+1<m.length&&ef(String(m[x+1]??"")))break;D.push(J),x+=1}p.push(e.jsx("p",{className:"pc-md_p",children:D.map((J,B)=>e.jsxs(Gt.Fragment,{children:[Da(J,w),B<D.length-1?e.jsx("br",{}):null]},`pl:${x}:${B}`))},`p:${x}`))}const N=["pc-md",s].filter(Boolean).join(" ");return e.jsx("div",{className:N,children:p})}function N_(a){const s=String(a.text??""),r=h.useMemo(()=>p_(s),[s]),l=["pc-chat-content",a.className].filter(Boolean).join(" ");return r!==null?e.jsx("div",{className:l,children:e.jsx(Qo,{value:r,collapseAfterDepth:a.jsonCollapseAfterDepth})}):a.renderMarkdown?e.jsx("div",{className:l,children:a.renderMarkdown(s)}):e.jsx("div",{className:l,children:e.jsx(as,{text:s})})}function Jf(a){if(typeof a!="string")return a;try{return JSON.parse(a)}catch{return a}}function C_(a){const s=Jf(a);if(!s||typeof s!="object"||Array.isArray(s))return{label:"input",value:s==null?"":String(s)};const r=Object.entries(s),c=["command","query","url","file_path","path","pattern","name"].map(f=>r.find(([m])=>m===f)).find(Boolean)||r[0];return c?{label:c[0].replace(/_/g," "),value:typeof c[1]=="string"?c[1]:JSON.stringify(c[1])??""}:{label:"",value:""}}function Yf({tool:a,showCopy:s=!0}){const[r,l]=h.useState(!1),c=Jf(a.arguments),f=C_(a.arguments),m=["file path","path"].includes(f.label)&&f.value.length>60?`${f.value.split(/[\\/]/).pop()} · ${f.value.slice(0,24)}…`:f.value,p=a.error&&/^File ['"].+['"] does not exist\.?$/.test(a.error)?"File not found. Expand for the exact path.":a.error&&a.error.length>180?`${a.error.slice(0,100)}…${a.error.slice(-70)}`:a.error,_={running:"Running",waiting:"Approval needed",completed:"Done",failed:"Failed"},y=a.startedAt&&a.endedAt?Date.parse(a.endedAt)-Date.parse(a.startedAt):NaN,w=c&&typeof c=="object"&&!Array.isArray(c)?Object.entries(c):null;return e.jsxs("details",{className:`pc-tool-activity pc-tool-activity--${a.status}`,children:[e.jsxs("summary",{className:"pc-tool-activity__summary",children:[e.jsx("span",{className:"pc-tool-activity__state-icon","aria-hidden":"true",children:e.jsx(st,{name:a.status==="completed"?"check":a.status==="failed"?"x":a.status==="waiting"?"warning":"loader",size:15})}),e.jsx("strong",{children:a.name}),e.jsx("span",{className:"pc-tool-activity__preview",title:f.value,children:f.value?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"pc-tool-activity__key",children:f.label}),m]}):"No parameters"}),e.jsx("span",{className:"pc-tool-activity__status",children:_[a.status]}),Number.isFinite(y)&&y>=0?e.jsxs("span",{className:"pc-tool-activity__duration",children:[(y/1e3).toFixed(1),"s"]}):null,e.jsx("span",{className:"pc-tool-activity__chevron","aria-hidden":"true",children:e.jsx(st,{name:"chevronRight",size:13})}),a.error?e.jsx("span",{className:"pc-tool-activity__error",title:a.error,children:p}):null]}),e.jsxs("div",{className:"pc-tool-activity__detail",children:[a.error?e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"Error"}),e.jsx("pre",{className:"pc-tool-activity__output",children:a.error})]}):null,e.jsxs("div",{className:"pc-tool-activity__detail-heading",children:[e.jsx("h4",{children:"Parameters"}),s?e.jsxs("button",{type:"button",onClick:async()=>l(await yn(JSON.stringify(a,null,2))),children:[e.jsx(st,{name:"copy",size:13}),r?"Copied":"Copy details"]}):null]}),w?e.jsx("dl",{className:"pc-tool-activity__parameters",children:w.map(([x,N])=>e.jsxs(Gt.Fragment,{children:[e.jsx("dt",{children:x}),e.jsx("dd",{children:N&&typeof N=="object"?e.jsx(Qo,{value:N}):e.jsx("code",{children:typeof N=="string"?N:JSON.stringify(N)})})]},x))}):a.arguments===void 0?e.jsx("p",{children:"Arguments are unavailable in this ledger."}):e.jsx(Qo,{value:c}),a.output!==void 0?e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"Result"}),typeof a.output=="string"?e.jsx("pre",{className:"pc-tool-activity__output",children:a.output}):e.jsx("div",{className:"pc-tool-activity__output",children:e.jsx(Qo,{value:a.output})})]}):null]})]})}function $_({tools:a,showCopy:s}){const r=l=>a.filter(c=>c.status===l).length;return e.jsxs("section",{className:"pc-tool-group","aria-label":"Tool activity",children:[e.jsxs("div",{className:"pc-tool-group__heading",children:[e.jsx(st,{name:"terminal",size:14}),e.jsx("strong",{children:"Tools"}),e.jsxs("span",{children:[a.length," ",a.length===1?"call":"calls"]}),e.jsx("div",{}),r("running")?e.jsxs("span",{className:"pc-tool-group__running",children:[r("running")," running"]}):null,r("waiting")?e.jsxs("span",{className:"pc-tool-group__waiting",children:[r("waiting")," need approval"]}):null,r("failed")?e.jsxs("span",{className:"pc-tool-group__failed",children:[r("failed")," failed"]}):null,r("completed")?e.jsxs("span",{className:"pc-tool-group__completed",children:[r("completed")," done"]}):null]}),a.map(l=>e.jsx(Yf,{tool:l,showCopy:s},l.id))]})}const vn="not reported",Cn=a=>a===void 0?vn:Math.round(a).toLocaleString(),Dn=a=>{if(a===void 0)return vn;if(a<6e4)return`${(a/1e3).toFixed(1)}s`;const s=Math.round(a/1e3);return`${Math.floor(s/60)}m ${String(s%60).padStart(2,"0")}s`},Xf=a=>a===void 0?vn:`${Math.round(a).toLocaleString()} tok/s`,E_=(a,s)=>s>0?`${Math.round(a/s*100)}%`:"",Cr=(a,s,r=`${s}s`)=>`${a.toLocaleString()} ${a===1?s:r}`,T_=a=>{const s=a.split("#")[0].replace(/\/+$/,"");return s.slice(s.lastIndexOf("/")+1)||a};function A_(a){const s=new Map;for(const r of a)r&&s.set(r,(s.get(r)||0)+1);return[...s].map(([r,l])=>l>1?`${r} ×${l}`:r).join(" · ")}function Yo(a){const s=[],r=(a.models||[]).map(T_),l=a.providers||[];return(r.length||l.length)&&s.push([r.join(", ")||"model not reported",l.join(", ")].filter(Boolean).join(" · ")),s.push("From the run ledger; summed across this turn and its child runs."),s}function R_(a){const s=a.modelCalls||[],r=[],l=[{label:"Input",value:Cn(a.inputTokens)},{label:"Output",value:Cn(a.outputTokens)}];if(a.reasoningTokens!==void 0&&l.push({label:"Reasoning",value:Cn(a.reasoningTokens),hint:"part of output"}),l.push({label:"Total",value:Cn(a.totalTokens)}),r.push({heading:`Usage · ${Cr(a.llmCalls,"model call")}`,rows:l}),a.measuredCacheCalls){const f=a.cachedTokens||0,m=a.fedTokens||0,p=[{label:"Reused from cache",value:`${Cn(f)}${f+m?` (${E_(f,f+m)})`:""}`},{label:"Newly processed",value:Cn(a.fedTokens)},{label:"Outcome",value:A_(s.map(_=>_.cacheOutcome))||(a.cacheOutcomes||[]).join(" · ")||vn},{label:"Backend",value:(a.cacheBackends||[]).join(", ")||vn}];a.measuredCacheCalls!==a.llmCalls&&p.push({label:"Measured on",value:`${a.measuredCacheCalls} of ${a.llmCalls} calls`}),r.push({heading:"Prompt cache",rows:p})}else a.llmCalls&&r.push({heading:"Prompt cache",rows:[{label:"Cache reuse",value:vn}]});const c=s.filter(f=>f.inputTokens!==void 0);return c.length===1&&s.length===1?r.push({heading:"Context",rows:[{label:"Prompt size",value:`${Cn(c[0].inputTokens)} tokens`}]}):c.length>1&&r.push({heading:"Context",rows:[{label:"First → last call",value:`${Cn(c[0].inputTokens)} → ${Cn(c[c.length-1].inputTokens)} tokens`}],note:"Each call re-sends the conversation, so the input total counts the context once per call."}),s.length>1&&r.push({heading:"Per call",table:{columns:["#","Input","Cached","New","Output","Cache"],rows:s.map((f,m)=>[String(m+1),Cn(f.inputTokens),f.cachedTokens===void 0?"—":Cn(f.cachedTokens),f.fedTokens===void 0?"—":Cn(f.fedTokens),Cn(f.outputTokens),f.cacheOutcome||"—"])}}),{kind:"tokens",title:"Tokens",headline:a.totalTokens===void 0?vn:`${a.totalTokens.toLocaleString()} total`,sections:r,footer:Yo(a)}}function Fo(a,s,r,l){if(a===void 0)return vn;const c=[Dn(a)];return s!==void 0&&c.push(`${s.toLocaleString()} ${l}${r!==void 0?` at ${Xf(r)}`:""}`),c.join(" · ")}function L_(a){var y,w,x;const s=a.modelCalls||[],r=[],l=a.durationMs,c=[{label:"Wall clock",value:Dn(l)}];if(c.push({label:"Model",value:a.genTimeMs===void 0?vn:`${Dn(a.genTimeMs)} · ${Cr(a.timedCalls||0,"call")}${a.timedCalls!==a.llmCalls?` (of ${a.llmCalls})`:""}`}),c.push({label:"Tools",value:a.toolTimeMs!==void 0?`${Dn(a.toolTimeMs)} · ${Cr(a.toolBatches||0,"batch","batches")}`:a.toolCalls?vn:"none",hint:a.toolTimeIncludesApproval?"includes approval wait":void 0}),l!==void 0&&a.genTimeMs!==void 0){const N=l-a.genTimeMs-(a.toolTimeMs||0);c.push({label:"Orchestration",value:N>=0?Dn(N):"overlaps (parallel runs)",hint:"wall − model − tools: routing, hand-offs, model load"})}r.push({heading:"Turn",rows:c});const f=[],m=a.ttftCalls||0,p=a.promptPhaseCalls||0;a.promptPhaseMs!==void 0?f.push({label:m&&m===p?"Prefill (TTFT)":"Prefill",value:Fo(a.promptPhaseMs,a.promptPhaseNewTokens,a.promptPhaseTokensPerSecond,"new tok"),hint:m===p?"measured time to first token":m?`TTFT measured on ${m} of ${p}; rest from provider rate`:"derived: prompt ÷ provider rate"}):a.prefillMs!==void 0&&a.prefillNewTokensPerSecond!==void 0?f.push({label:"Prefill",value:Fo(a.prefillMs,a.prefillNewTokens,a.prefillNewTokensPerSecond,"new tok"),hint:"derived: prompt ÷ provider rate"}):a.prefillMs!==void 0?f.push({label:"Prefill",value:`${Dn(a.prefillMs)}${a.promptTokensPerSecond!==void 0?` at ${Xf(a.promptTokensPerSecond)}`:""}`,hint:"provider rate over all prompt tokens, restored included"}):f.push({label:"Prefill",value:vn}),a.cachedTokens&&(a.promptPhaseMs??a.prefillMs)!==void 0&&f.push({label:"Restored",value:`${a.cachedTokens.toLocaleString()} tok from cache`,hint:"not recomputed"}),f.push({label:"Generation",value:a.generationPhaseMs!==void 0?Fo(a.generationPhaseMs,a.generationPhaseTokens,a.generationPhaseTokensPerSecond,"tok"):Fo(a.decodeMs,a.outputTokens,a.generationTokensPerSecond,"tok")}),a.measuredSpeedCalls&&a.measuredSpeedCalls!==a.llmCalls&&f.push({label:"Speeds from",value:`${a.measuredSpeedCalls} of ${a.llmCalls} calls`}),r.push({heading:"Model",rows:f});const _=a.speculation;if(_){const N=(_.draftKinds||[]).map(P=>P.toUpperCase()).join(", "),$=[{label:"Mode",value:`${_.used?"on":"off"}${N?` · ${N}`:""}${(y=_.modes)!=null&&y.length?` (${_.modes.join(", ")})`:""}`,hint:_.calls!==a.llmCalls||_.used!==_.calls?`used on ${_.used} of ${a.llmCalls} calls`:void 0},{label:"Acceptance",value:_.acceptanceRate===void 0?vn:`${Math.round(_.acceptanceRate*100)}% · ${Cn(_.acceptedTokens)} of ${Cn(_.draftedTokens)} drafted`}];((w=_.draftLengths)!=null&&w.length||_.rounds!==void 0)&&$.push({label:"Draft length",value:`${(x=_.draftLengths)!=null&&x.length?`${_.draftLengths.join("/")} tok/round`:vn}${_.rounds!==void 0?` · ${_.rounds.toLocaleString()} rounds`:""}`}),r.push({heading:"Speculation",rows:$})}return a.slowestToolBatch&&r.push({heading:"Tools",rows:[{label:"Total",value:`${Dn(a.toolTimeMs)} · ${Cr(a.toolBatches||0,"batch","batches")}`},{label:"Slowest",value:`${Dn(a.slowestToolBatch.ms)} · ${Zf(a.slowestToolBatch)}`}],note:a.toolTimeIncludesApproval?"Gated calls are timed from request to result, so this includes waiting for your approval.":void 0}),s.length>1&&r.push({heading:"Per call",table:{columns:["#","Prefill","New tok/s","Gen","Gen tok/s","Cache"],rows:s.map((N,$)=>[String($+1),N.promptMs===void 0?"—":`${Dn(N.promptMs)}${N.promptSource==="rate"?"*":""}`,N.promptNewTokensPerSecond===void 0?"—":Math.round(N.promptNewTokensPerSecond).toLocaleString(),N.generationMs===void 0?"—":Dn(N.generationMs),N.generationTokensPerSecond===void 0?"—":Math.round(N.generationTokensPerSecond).toLocaleString(),N.cacheOutcome||"—"])},note:s.some(N=>N.promptSource==="rate")?"* derived from the provider's prompt rate (no TTFT event).":void 0}),{kind:"time",title:"Time",headline:l===void 0?vn:`${Dn(l)} wall clock`,sections:r,footer:Yo(a)}}function Zf(a){return a.tools.length===1?`${a.tools[0]} ×${a.calls}`:`${Cr(a.calls,"call")} (${a.tools.join(", ")})`}function M_(a){const s=[],r=(a.toolsWaiting||0)+(a.toolsRunning||0);if(!a.toolCalls&&!r)return s.push({heading:"Outcome",rows:[{label:"Tools called",value:"none"}]}),{kind:"tools",title:"Tools",headline:"none",sections:s,footer:Yo(a)};const l=[{label:"Succeeded",value:(a.toolCalls-(a.toolsFailed||0)).toLocaleString()},{label:"Failed",value:(a.toolsFailed||0).toLocaleString()}];a.toolsRunning&&l.push({label:"Running",value:a.toolsRunning.toLocaleString()}),a.toolsWaiting&&l.push({label:"Awaiting approval",value:a.toolsWaiting.toLocaleString(),hint:"not run yet — not a failure"}),s.push({heading:"Outcome",rows:l});const c=Object.entries(a.toolBreakdown||{}).sort((p,_)=>_[1].calls-p[1].calls||p[0].localeCompare(_[0]));c.length&&s.push({heading:"By tool",table:{columns:["Tool","Calls","Failed","Time"],rows:c.map(([p,_])=>[p,_.calls.toLocaleString(),_.failed.toLocaleString(),_.ms!==void 0?`${Dn(_.ms)}${_.sharedBatches?" +shared":""}`:_.sharedBatches?"shared":vn])},note:c.some(([,p])=>p.sharedBatches)?"A batch that mixed tools ran them together; its time is not split between them.":void 0});const f=c.filter(([,p])=>p.errors&&Object.keys(p.errors).length);f.length&&s.push({heading:"Failures",rows:f.map(([p,_])=>({label:p,value:Object.entries(_.errors).sort((y,w)=>w[1]-y[1]).map(([y,w])=>w>1?`${y} ×${w}`:y).join(" · ")}))});const m=[{label:"Tool time",value:a.toolTimeMs===void 0?vn:`${Dn(a.toolTimeMs)} · ${Cr(a.toolBatches||0,"batch","batches")}`}];return a.slowestToolBatch&&m.push({label:"Slowest batch",value:`${Dn(a.slowestToolBatch.ms)} · ${Zf(a.slowestToolBatch)}`}),s.push({heading:"Timing",rows:m,note:a.toolTimeIncludesApproval?"Gated calls are timed from request to result, so this includes waiting for your approval.":void 0}),{kind:"tools",title:"Tools",headline:`${Cr(a.toolCalls,"call")}${a.toolsFailed?` · ${a.toolsFailed} failed`:""}`,sections:s,footer:Yo(a)}}function bu(a,s){return a==="tokens"?R_(s):a==="time"?L_(s):M_(s)}function z_(a){const s=a.detail;return e.jsxs("div",{ref:a.panelRef,id:a.id,role:"tooltip",className:`pc-stat-detail pc-stat-detail--${s.kind}`,style:a.style,onMouseEnter:a.onMouseEnter,onMouseLeave:a.onMouseLeave,children:[e.jsxs("div",{className:"pc-stat-detail-head",children:[e.jsx("span",{className:"pc-stat-detail-title",children:s.title}),e.jsx("span",{className:"pc-stat-detail-headline",children:s.headline})]}),s.sections.map(r=>{var l;return e.jsxs("div",{className:"pc-stat-detail-section",children:[e.jsx("div",{className:"pc-stat-detail-heading",children:r.heading}),(l=r.rows)!=null&&l.length?e.jsx("dl",{className:"pc-stat-detail-rows",children:r.rows.map(c=>e.jsxs(Gt.Fragment,{children:[e.jsx("dt",{children:c.label}),e.jsxs("dd",{children:[e.jsx("span",{className:c.value===vn?"pc-stat-detail-value pc-stat-detail-value--absent":"pc-stat-detail-value",children:c.value}),c.hint?e.jsx("span",{className:"pc-stat-detail-hint",children:c.hint}):null]})]},c.label))}):null,r.table?e.jsxs("table",{className:"pc-stat-detail-table",children:[e.jsx("thead",{children:e.jsx("tr",{children:r.table.columns.map(c=>e.jsx("th",{scope:"col",children:c},c))})}),e.jsx("tbody",{children:r.table.rows.map((c,f)=>e.jsx("tr",{children:c.map((m,p)=>e.jsx("td",{children:m},p))},f))})]}):null,r.note?e.jsx("p",{className:"pc-stat-detail-note",children:r.note}):null]},r.heading)}),e.jsx("div",{className:"pc-stat-detail-foot",children:s.footer.map(r=>e.jsx("div",{children:r},r))})]})}const da=8;function P_(a){const[s,r]=h.useState(!!a.defaultOpen),[l,c]=h.useState(null),f=h.useRef(null),m=h.useRef(null),p=h.useRef(null),_=`pc-stat-${h.useId().replace(/[^a-zA-Z0-9_-]/g,"")}`,y=h.useCallback(()=>{p.current!==null&&window.clearTimeout(p.current),p.current=null},[]),w=h.useCallback(()=>{y(),r(!0)},[y]),x=h.useCallback(()=>{y(),p.current=window.setTimeout(()=>r(!1),120)},[y]);h.useEffect(()=>y,[y]),h.useLayoutEffect(()=>{if(!s){c(null);return}const T=()=>{const F=f.current,D=m.current;if(!F||!D)return;const J=F.getBoundingClientRect(),B=D.offsetWidth,ee=D.offsetHeight,C=window.innerWidth,Z=window.innerHeight,ae=J.top-da-ee,fe=J.bottom+da,ge=ae>=da?ae:fe+ee<=Z-da?fe:Math.max(da,Z-da-ee),Te=Math.min(Math.max(da,J.left),Math.max(da,C-da-B));c({top:ge,left:Te})};return T(),window.addEventListener("resize",T),window.addEventListener("scroll",T,!0),()=>{window.removeEventListener("resize",T),window.removeEventListener("scroll",T,!0)}},[s]),h.useEffect(()=>{if(!s)return;const T=F=>{F.key==="Escape"&&r(!1)};return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[s]);const N=typeof a.onClick=="function",$=N?"button":"span",P=s?e.jsx(z_,{detail:a.detail,id:_,panelRef:m,onMouseEnter:y,onMouseLeave:x,style:{position:"fixed",top:(l==null?void 0:l.top)??0,left:(l==null?void 0:l.left)??0,visibility:l?"visible":"hidden"}}):null;return e.jsxs(e.Fragment,{children:[e.jsxs($,{ref:f,...N?{type:"button"}:{tabIndex:0},className:["pc-chat-stat","pc-chat-stat--detail",N?"pc-chat-stat--clickable":"",a.className].filter(Boolean).join(" "),"aria-label":`${a.label} — ${a.detail.title.toLowerCase()} details`,"aria-describedby":s?_:void 0,"data-stat-kind":a.detail.kind,onMouseEnter:w,onMouseLeave:x,onFocus:w,onBlur:()=>r(!1),onKeyDown:T=>{T.key==="Escape"&&r(!1)},onClick:N?()=>{var T;return(T=a.onClick)==null?void 0:T.call(a)}:void 0,children:[a.icon?e.jsx("span",{className:"pc-chat-stat-icon","aria-hidden":"true",children:a.icon}):null,e.jsx("span",{className:"pc-chat-stat-label",children:a.label})]}),P&&typeof document<"u"?Bf.createPortal(P,document.body):P]})}function I_(a){const s=a.totalTokens!==void 0?bu("tokens",a):null,r=bu("tools",a),l=a.durationMs!==void 0?bu("time",a):null;return[...s?[{label:`${a.totalTokens.toLocaleString()} tokens`,detail:s}]:[],{label:`${a.toolCalls} ${a.toolCalls===1?"tool":"tools"}`,detail:r},...a.changedFiles.length?[{label:`${a.changedFiles.length} ${a.changedFiles.length===1?"file":"files"} changed`,title:a.changedFiles.join(`
46
- `)}]:[],...l?[{label:`${(a.durationMs/1e3).toFixed(a.durationMs<1e4?1:0)}s`,detail:l}]:[]]}function O_(a){const s=String(a.role||"").trim().toLowerCase()||"system",r=String(a.kind||"").trim().toLowerCase(),l=String(a.level||"").trim().toLowerCase();return s==="system"&&r==="report_bug"?{label:String(a.title||"").trim()||"Bug report",icon:"warning",variant:"report_bug"}:s==="system"&&r==="report_feature"?{label:String(a.title||"").trim()||"Feature request",icon:"check",variant:"report_feature"}:s==="user"?{label:String(a.title||"").trim()||"You",icon:"user",variant:"user"}:s==="assistant"?{label:String(a.title||"").trim()||"Agent",icon:"bot",variant:"assistant"}:{label:String(a.title||"").trim()||(l==="error"?"Error":l==="warn"?"Warning":"System"),icon:l==="error"?"error":l==="warn"?"warning":"info",variant:l==="error"?"error":l==="warn"?"warn":"status"}}function D_(a){var F;const s=a.message,r=h.useMemo(()=>O_(s),[s.kind,s.level,s.role,s.title]),l=String(s.ts||"").trim(),c=h.useMemo(()=>{if(!l)return"";const D=new Date(l);return Number.isFinite(D.getTime())?D.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):""},[l]),[f,m]=h.useState("idle"),p=h.useRef(null);h.useEffect(()=>()=>{p.current!==null&&window.clearTimeout(p.current)},[]);const _=typeof a.onSpeakToggle=="function"&&r.variant==="assistant"&&!!String(s.content||"").trim(),y=_&&((F=a.getSpeakState)==null?void 0:F.call(a,s))||"idle",w=y==="loading"?"loader":y==="playing"?"pause":"speaker",x=y==="loading"?"Generating audio…":y==="playing"?"Pause":y==="paused"?"Resume":"Speak (TTS)",N=a.showCopy!==!1,$=Array.isArray(a.attachments)?a.attachments:[],P=s.statistics,T=h.useMemo(()=>Array.isArray(a.stats)?a.stats:P?I_(P):[],[a.stats,P]);return s.toolActivity?e.jsx(Yf,{tool:s.toolActivity,showCopy:a.showCopy}):e.jsxs("div",{className:["pc-chat-item",`pc-chat-item--${r.variant}`,a.className].filter(Boolean).join(" "),children:[e.jsxs("div",{className:"pc-chat-header",children:[e.jsx("div",{className:"pc-chat-avatar","aria-hidden":"true",children:e.jsx(st,{name:r.icon,size:14})}),e.jsx("span",{className:"pc-chat-role",children:r.label}),e.jsx("span",{className:"pc-chat-header-spacer"}),c?e.jsx("span",{className:"pc-chat-time",children:c}):null,e.jsxs("div",{className:"pc-chat-header-actions",children:[_?e.jsx("button",{className:"pc-chat-icon-btn",type:"button","aria-label":x,title:x,onClick:()=>{var D;return(D=a.onSpeakToggle)==null?void 0:D.call(a,s)},children:e.jsx(st,{name:w,size:22})}):null,N?e.jsx("button",{className:`pc-chat-icon-btn ${f!=="idle"?`pc-chat-icon-btn--${f}`:""}`.trim(),type:"button","aria-label":"Copy message",title:f==="idle"?"Copy":f==="copied"?"Copied":"Copy failed",onClick:async()=>{const D=await yn(String(s.content||""));m(D?"copied":"failed"),p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>m("idle"),900)},children:e.jsx(st,{name:"copy",size:22})}):null]})]}),e.jsx("div",{className:"pc-chat-body",children:e.jsx(N_,{text:String(s.content||""),renderMarkdown:a.renderMarkdown,jsonCollapseAfterDepth:a.jsonCollapseAfterDepth})}),$.length?e.jsx("div",{className:"pc-chat-attachments","aria-label":"Attachments",children:$.slice(0,24).map((D,J)=>{const B=String(D.label||"").trim()||"attachment",ee=String(D.target||"").trim(),C=String(D.title||"").trim(),Z=!!D.disabled||typeof D.onClick!="function";return e.jsxs("button",{type:"button",className:"pc-chat-attachment-chip",title:C||B,onClick:Z?void 0:D.onClick,disabled:Z,children:[e.jsx(st,{name:"paperclip",size:14}),ee?e.jsx("span",{className:`pc-chat-attachment-target pc-chat-attachment-target--${ee}`,children:ee}):null,e.jsx("span",{className:"pc-chat-attachment-name",children:B})]},D.id||`${B}:${J}`)})}):null,T.length?e.jsx("div",{className:"pc-chat-stats","aria-label":"Stats",children:T.slice(0,12).map((D,J)=>{const B=String(D.label||"").trim();if(!B)return null;if(D.detail)return e.jsx(P_,{label:B,detail:D.detail,icon:D.icon,onClick:D.onClick},D.id||`${B}:${J}`);const ee=String(D.title||"").trim(),C=typeof D.onClick=="function",Z=C?"button":"span";return e.jsxs(Z,{...C?{type:"button"}:{},className:["pc-chat-stat",C?"pc-chat-stat--clickable":""].filter(Boolean).join(" "),title:ee||void 0,onClick:C?()=>{var ae;return(ae=D.onClick)==null?void 0:ae.call(D)}:void 0,children:[D.icon?e.jsx("span",{className:"pc-chat-stat-icon","aria-hidden":"true",children:D.icon}):null,e.jsx("span",{className:"pc-chat-stat-label",children:B})]},D.id||`${B}:${J}`)})}):null]})}function F_(a,s){const r=Math.max(0,Math.trunc(s));return a.scrollHeight-a.scrollTop-a.clientHeight<=r}function sd(a){const s=typeof a.autoScrollThresholdPx=="number"&&Number.isFinite(a.autoScrollThresholdPx)?a.autoScrollThresholdPx:120,r=a.autoScroll!==!1,l=h.useRef(null),c=h.useRef(null),[f,m]=h.useState(!0),p=h.useMemo(()=>Array.isArray(a.messages)?a.messages:[],[a.messages]),_=h.useMemo(()=>{var x;const w=[];for(const N of p){const $=w[w.length-1];N.toolActivity&&((x=$==null?void 0:$[0])!=null&&x.toolActivity)&&$[0].runId===N.runId?$.push(N):w.push([N])}return w},[p]);h.useEffect(()=>{if(!r)return;const w=l.current;if(!w)return;const x=()=>{m(F_(w,s))};return w.addEventListener("scroll",x,{passive:!0}),x(),()=>w.removeEventListener("scroll",x)},[r,s]);const y=h.useMemo(()=>{let w=0;for(const x of p)w+=String(x.content??"").length;return`${p.length}:${w}:${String(a.afterKey??"")}`},[p,a.afterKey]);return h.useEffect(()=>{if(!r||!f)return;const w=l.current;w&&(w.scrollTop=w.scrollHeight)},[r,f,y]),e.jsxs("div",{ref:l,className:["pc-chat-thread",a.className].filter(Boolean).join(" "),children:[p.length?null:a.empty||null,_.map((w,x)=>{var P;const N=w[0],$=String(N.id||"")||String(N.ts||"")+":"+String(N.role||"")+":"+x;return N.toolActivity?e.jsx($_,{tools:w.map(T=>T.toolActivity),showCopy:(P=a.messageProps)==null?void 0:P.showCopy},$):e.jsx(D_,{message:N,...a.messageProps||{}},$)}),a.after,e.jsx("div",{ref:c})]})}const Xo=Gt.forwardRef(function(s,r){const l=typeof s.rows=="number"&&Number.isFinite(s.rows)?Math.max(1,Math.trunc(s.rows)):3,c=!!s.disabled,f=!!s.busy,m=!c&&!f&&!!String(s.value||"").trim();return e.jsxs("div",{className:["pc-composer",s.className].filter(Boolean).join(" "),children:[s.leading,e.jsx("textarea",{ref:r,className:["pc-composer__textarea",s.textareaClassName].filter(Boolean).join(" "),value:s.value,onChange:p=>s.onChange(p.target.value),rows:l,spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",autoComplete:"off",placeholder:s.placeholder||"","aria-label":s.ariaLabel||s.placeholder||"Message",disabled:c,autoFocus:!!s.autoFocus,onPaste:s.onPaste,onKeyDown:p=>{p.key!=="Enter"||p.shiftKey||p.nativeEvent.isComposing||p.keyCode===229||(p.preventDefault(),m&&s.onSubmit())}}),e.jsxs("div",{className:"pc-composer__row",children:[e.jsx("div",{className:"pc-composer__actions",children:s.actions}),e.jsx("button",{type:"button",className:s.sendButtonClassName||"pc-btn",disabled:!m,onClick:()=>s.onSubmit(),children:f?s.busyLabel||"Thinking…":s.sendLabel||"Send"})]}),s.overlay]})});function q_(a){return!!(a&&typeof a[Symbol.asyncIterator]=="function")}function B_(a){const[s,r]=h.useState([]),l=a.messages??s,c=T=>{a.onMessagesChange&&a.onMessagesChange(T),a.messages===void 0&&r(T)},f=h.useRef(l);f.current=l;const[m,p]=h.useState(""),[_,y]=h.useState(!1),w=h.useRef(null),x=a.assistantName||"Assistant",N=!!a.blockedNotice,$=async T=>{const F=String(T||"").trim();if(!F||_||N)return;p("");const D=f.current,J=[...D,{role:"user",content:F,ts:new Date().toISOString()}];c(J),y(!0);const B=new AbortController;w.current=B;try{const ee=a.ask(F,{signal:B.signal,history:D});if(q_(ee)){let C="";const Z=[...J,{role:"assistant",title:x,content:"",ts:new Date().toISOString()}];c(Z);for await(const ae of ee){if(B.signal.aborted)break;C+=String(ae??""),c([...J,{role:"assistant",title:x,content:C,ts:new Date().toISOString()}])}!C.trim()&&!B.signal.aborted&&c([...J,{role:"assistant",title:x,content:"#FALLBACK the assistant returned no answer.",level:"warn",ts:new Date().toISOString()}])}else{const C=String(await ee??"").trim();c([...J,C?{role:"assistant",title:x,content:C,ts:new Date().toISOString()}:{role:"assistant",title:x,content:"#FALLBACK the assistant returned no answer.",level:"warn",ts:new Date().toISOString()}])}}catch(ee){B.signal.aborted||c([...f.current,{role:"assistant",title:x,content:`#FALLBACK assistant request failed: ${String((ee==null?void 0:ee.message)||ee||"unknown error")}`,level:"error",ts:new Date().toISOString()}])}finally{w.current===B&&(w.current=null),y(!1)}},P=h.useMemo(()=>l.length>0?null:e.jsxs("div",{className:"pc-assistant__empty",children:[e.jsx("div",{className:"pc-assistant__empty-text",children:a.emptyState||"Ask about this app — answers are grounded in its documentation."}),a.suggestions&&a.suggestions.length>0?e.jsx("div",{className:"pc-assistant__suggestions",children:a.suggestions.map(T=>e.jsx("button",{type:"button",className:"pc-assistant__suggestion",onClick:()=>void $(T),disabled:_||N,children:T},T))}):null]}),[l.length,a.emptyState,a.suggestions,_,N]);return e.jsxs("div",{className:`pc-assistant${a.className?` ${a.className}`:""}`,children:[e.jsxs("div",{className:"pc-assistant__thread",children:[P,e.jsx(sd,{messages:l,autoScroll:!0}),N?e.jsx("div",{className:"pc-assistant__blocked",children:a.blockedNotice}):null]}),e.jsx("div",{className:"pc-assistant__composer",children:e.jsx(Xo,{value:m,onChange:p,onSubmit:()=>void $(m),placeholder:a.placeholder||"Ask about this app…",disabled:N,busy:_,rows:2,actions:_?e.jsx("button",{type:"button",className:"pc-btn",onClick:()=>{var T;(T=w.current)==null||T.abort()},children:"Stop"}):null})})]})}function pi(a){return a?a.value!==void 0&&a.value!==null?!!a.value:a.enabled!==void 0?!!a.enabled:a.configured!==void 0?!!a.configured:a.path!==void 0?!!a.path:null:null}function qo(a){if(!a)return"";const s=a.value!==void 0&&a.value!==null?a.value:a.id??a.path??"";return typeof s=="string"?s.trim():""}const tf="abstractcontinuum_gateway_csrf",U_="x-abstractcontinuum-csrf",W_="x-abstract-csrf";function nf(a,s){const r=(a||"").trim().replace(/\/+$/,"");return r?`${r}${s}`:s}function sf(a){var l;const s=(a||"").trim(),r={};s&&(r.Authorization=`Bearer ${s}`);try{const c=(l=document.cookie.split(";").map(f=>f.trim()).find(f=>f.startsWith(`${tf}=`)))==null?void 0:l.slice(`${tf}=`.length);if(c){const f=decodeURIComponent(c);r[U_]=f,r[W_]=f}}catch{}return r}function af(a){const s={},r=(l,c)=>{const f=String(c||"").trim();f&&(s[l]=f)};return r("provider",a==null?void 0:a.provider),r("model",a==null?void 0:a.model),r("profile",a==null?void 0:a.profile),r("voice",a==null?void 0:a.voice),r("quality_preset",a==null?void 0:a.quality_preset),s}async function H_(a){try{const s=await a.text();return s!=null&&s.trim()?s.trim():`${a.status}`}catch{return`${a.status}`}}class V_ extends Error{constructor(r,l,c){super(r);kr(this,"status");kr(this,"body");this.name="GatewayRequestError",this.status=l,this.body=c}}const ju=[15,30,60,120];class G_{constructor(s){kr(this,"_cfg");kr(this,"_backoff_until",0);kr(this,"_backoff_step",0);this._cfg={...s,base_url:(s.base_url||"").trim()}}is_backing_off(){return Date.now()<this._backoff_until}backoff_until(){return this.is_backing_off()?this._backoff_until:0}async _fetch(s,r,l){const c=await fetch(nf(this._cfg.base_url,r),{...l,headers:{...l==null?void 0:l.headers,...sf(this._cfg.auth_token)}});if(c.ok)return this._backoff_step=0,this._backoff_until=0,c;const f=await H_(c);let m=null;try{m=JSON.parse(f)}catch{}let p=f;if(m&&typeof m=="object"&&m.detail!==void 0&&(p=typeof m.detail=="string"?m.detail:JSON.stringify(m.detail)),c.status===429||/too many requests|auth lockout|locked/i.test(p)){const y=ju[Math.min(this._backoff_step,ju.length-1)];this._backoff_until=Date.now()+y*1e3,this._backoff_step<ju.length-1&&(this._backoff_step+=1)}throw new V_(`${s} failed: ${p}`,c.status,m)}async _get_json(s,r){return await(await this._fetch(s,r)).json()}async _post_json(s,r,l){return await(await this._fetch(s,r,{method:"POST",headers:l===void 0?void 0:{"Content-Type":"application/json"},body:l===void 0?void 0:JSON.stringify(l)})).json()}async _post_form(s,r,l){return await(await this._fetch(s,r,{method:"POST",body:l})).json()}async list_runs(s){const r=new URLSearchParams;r.set("limit",String(typeof(s==null?void 0:s.limit)=="number"?s.limit:50));const l=String((s==null?void 0:s.status)||"").trim();l&&r.set("status",l);const c=String((s==null?void 0:s.session_id)||"").trim();return c&&r.set("session_id",c),(s==null?void 0:s.root_only)===!0&&r.set("root_only","true"),await this._get_json("list_runs",`/api/gateway/runs?${r.toString()}`)}async download_run_artifact_content(s,r,l){const c=String(s||"").trim(),f=String(r||"").trim();if(!c)throw new Error("download_run_artifact_content: run_id is required");if(!f)throw new Error("download_run_artifact_content: artifact_id is required");const m=String((l==null?void 0:l.access)||"").trim(),p=m?`?access=${encodeURIComponent(m)}`:"";return await(await this._fetch("download_run_artifact_content",`/api/gateway/runs/${encodeURIComponent(c)}/artifacts/${encodeURIComponent(f)}/content${p}`)).blob()}async attachments_upload(s,r,l){const c=String(s||"").trim();if(!c)throw new Error("attachments_upload: session_id is required");if(!r)throw new Error("attachments_upload: file is required");const f=String((l==null?void 0:l.filename)||"").trim()||String((r==null?void 0:r.name)||"").trim()||"upload.bin",m=String((l==null?void 0:l.content_type)||"").trim()||String((r==null?void 0:r.type)||"").trim(),p=new FormData;p.append("session_id",c),p.append("file",r,f),p.append("filename",f),m&&p.append("content_type",m);const _=await this._post_form("attachments_upload","/api/gateway/attachments/upload",p),y=_==null?void 0:_.attachment;if(!y||typeof y!="object")throw new Error("attachments_upload: missing attachment");if(!String(y.$artifact||"").trim())throw new Error("attachments_upload: missing attachment.$artifact");return y}async audio_transcribe(s,r){const l=String(s||"").trim();if(!l)throw new Error("audio_transcribe: run_id is required");const c=r==null?void 0:r.audio_artifact;if(!c||typeof c!="object")throw new Error("audio_transcribe: audio_artifact is required");if(!String(c.$artifact||"").trim())throw new Error("audio_transcribe: audio_artifact.$artifact is required");const m={audio_artifact:c},p=String((r==null?void 0:r.language)||"").trim();p&&(m.language=p);const _=String((r==null?void 0:r.request_id)||"").trim();_&&(m.request_id=_);const y=await this._post_json("audio_transcribe",`/api/gateway/runs/${encodeURIComponent(l)}/audio/transcribe`,m);return{ok:!!(y!=null&&y.ok),run_id:String((y==null?void 0:y.run_id)||""),request_id:String((y==null?void 0:y.request_id)||""),text:String((y==null?void 0:y.text)||""),transcript_artifact:y==null?void 0:y.transcript_artifact}}async voice_tts(s,r){const l=String(s||"").trim();if(!l)throw new Error("voice_tts: run_id is required");const c=String((r==null?void 0:r.text)||"").trim();if(!c)throw new Error("voice_tts: text is required");const f={text:c,...af(r)},m=String((r==null?void 0:r.format)||"").trim();m&&(f.format=m),typeof(r==null?void 0:r.timeout_s)=="number"&&r.timeout_s>0&&(f.timeout_s=r.timeout_s);const p=String((r==null?void 0:r.request_id)||"").trim();p&&(f.request_id=p);const _=await this._post_json("voice_tts",`/api/gateway/runs/${encodeURIComponent(l)}/voice/tts`,f);return{ok:!!(_!=null&&_.ok),run_id:String((_==null?void 0:_.run_id)||""),request_id:String((_==null?void 0:_.request_id)||""),audio_artifact:_==null?void 0:_.audio_artifact}}async capability_defaults(){return await this._get_json("capability_defaults","/api/gateway/config/capability-defaults")}async voice_voices(s){const r=new URLSearchParams({compact:"true"}),l=String((s==null?void 0:s.provider)||"").trim(),c=String((s==null?void 0:s.model)||"").trim();return l&&r.set("provider",l),c&&r.set("model",c),s!=null&&s.providers_only&&r.set("providers_only","true"),await this._get_json("voice_voices",`/api/gateway/voice/voices?${r.toString()}`)}voice_stream_transport(s,r){const l=String(s||"").trim();if(!l)throw new Error("voice_stream_transport: run_id is required");return{path:nf(this._cfg.base_url,`/api/gateway/runs/${encodeURIComponent(l)}/voice/tts/stream`),body:{text:String((r==null?void 0:r.text)||""),format:"wav",...af(r)},headers:sf(this._cfg.auth_token)}}async list_bug_reports(){return await this._get_json("list_bug_reports","/api/gateway/reports/bugs")}async list_feature_requests(){return await this._get_json("list_feature_requests","/api/gateway/reports/features")}async get_bug_report_content(s){const r=String(s||"").trim();if(!r)throw new Error("get_bug_report_content: filename is required");return await this._get_json("get_bug_report_content",`/api/gateway/reports/bugs/${encodeURIComponent(r)}/content`)}async get_feature_request_content(s){const r=String(s||"").trim();if(!r)throw new Error("get_feature_request_content: filename is required");return await this._get_json("get_feature_request_content",`/api/gateway/reports/features/${encodeURIComponent(r)}/content`)}async bug_report_create(s){return await this._post_json("bug_report_create","/api/gateway/bugs/report",rf(s,"bug_report_create"))}async feature_report_create(s){return await this._post_json("feature_report_create","/api/gateway/features/report",rf(s,"feature_report_create"))}async email_list_accounts(){return await this._get_json("email_list_accounts","/api/gateway/email/accounts")}async email_list_messages(s){const r=new URLSearchParams,l=String((s==null?void 0:s.account)||"").trim();l&&r.set("account",l);const c=String((s==null?void 0:s.mailbox)||"").trim();c&&r.set("mailbox",c);const f=String((s==null?void 0:s.since)||"").trim();f&&r.set("since",f);const m=String((s==null?void 0:s.status)||"").trim();return m&&r.set("status",m),r.set("limit",String(typeof(s==null?void 0:s.limit)=="number"&&Number.isFinite(s.limit)?Number(s.limit):20)),await this._get_json("email_list_messages",`/api/gateway/email/messages?${r.toString()}`)}async email_read_message(s,r){const l=String(s||"").trim();if(!l)throw new Error("email_read_message: uid is required");const c=new URLSearchParams,f=String((r==null?void 0:r.account)||"").trim();f&&c.set("account",f);const m=String((r==null?void 0:r.mailbox)||"").trim();m&&c.set("mailbox",m);const p=typeof(r==null?void 0:r.max_body_chars)=="number"&&Number.isFinite(r.max_body_chars)?Number(r.max_body_chars):2e4;return c.set("max_body_chars",String(p)),await this._get_json("email_read_message",`/api/gateway/email/messages/${encodeURIComponent(l)}?${c.toString()}`)}async email_send(s){if(!String((s==null?void 0:s.subject)||"").trim())throw new Error("email_send: subject is required");return await this._post_json("email_send","/api/gateway/email/send",s||{})}async triage_run(s){const r={};return typeof(s==null?void 0:s.write_drafts)=="boolean"&&(r.write_drafts=!!s.write_drafts),typeof(s==null?void 0:s.enable_llm)=="boolean"&&(r.enable_llm=!!s.enable_llm),await this._post_json("triage_run","/api/gateway/triage/run",r)}async list_triage_decisions(s){const r=new URLSearchParams,l=String((s==null?void 0:s.status)||"").trim();return l&&r.set("status",l),r.set("limit",String(typeof(s==null?void 0:s.limit)=="number"&&Number.isFinite(s.limit)?Number(s.limit):200)),await this._get_json("list_triage_decisions",`/api/gateway/triage/decisions?${r.toString()}`)}async apply_triage_decision(s,r){const l=String(s||"").trim();if(!l)throw new Error("apply_triage_decision: decision_id is required");const c=String((r==null?void 0:r.action)||"").trim();if(!c)throw new Error("apply_triage_decision: action is required");const f={action:c};if(c==="defer"){const m=r==null?void 0:r.defer_days;typeof m=="number"&&Number.isFinite(m)&&m>0&&(f.defer_days=Number(m))}return await this._post_json("apply_triage_decision",`/api/gateway/triage/decisions/${encodeURIComponent(l)}/apply`,f)}async backlog_list(s){const r=String(s||"").trim();if(!r)throw new Error("backlog_list: kind is required");return await this._get_json("backlog_list",`/api/gateway/backlog/${encodeURIComponent(r)}`)}async backlog_content(s,r){const l=String(s||"").trim(),c=String(r||"").trim();if(!l)throw new Error("backlog_content: kind is required");if(!c)throw new Error("backlog_content: filename is required");return await this._get_json("backlog_content",`/api/gateway/backlog/${encodeURIComponent(l)}/${encodeURIComponent(c)}/content`)}async backlog_template(){return await this._get_json("backlog_template","/api/gateway/backlog/template")}async backlog_move(s){const r=String((s==null?void 0:s.from_kind)||"").trim(),l=String((s==null?void 0:s.to_kind)||"").trim(),c=String((s==null?void 0:s.filename)||"").trim();if(!r)throw new Error("backlog_move: from_kind is required");if(!l)throw new Error("backlog_move: to_kind is required");if(!c)throw new Error("backlog_move: filename is required");return await this._post_json("backlog_move","/api/gateway/backlog/move",{from_kind:r,to_kind:l,filename:c})}async backlog_update(s){const r=String((s==null?void 0:s.kind)||"").trim(),l=String((s==null?void 0:s.filename)||"").trim();if(!r)throw new Error("backlog_update: kind is required");if(!l)throw new Error("backlog_update: filename is required");const c={content:String((s==null?void 0:s.content)??"")},f=String((s==null?void 0:s.expected_sha256)||"").trim();return f&&(c.expected_sha256=f),await this._post_json("backlog_update",`/api/gateway/backlog/${encodeURIComponent(r)}/${encodeURIComponent(l)}/update`,c)}async backlog_create(s){const r=String((s==null?void 0:s.kind)||"").trim(),l=String((s==null?void 0:s.package)||"").trim(),c=String((s==null?void 0:s.title)||"").trim();if(!r)throw new Error("backlog_create: kind is required");if(!l)throw new Error("backlog_create: package is required");if(!c)throw new Error("backlog_create: title is required");const f={kind:r,package:l,title:c},m=String((s==null?void 0:s.task_type)||"").trim();m&&(f.task_type=m);const p=String((s==null?void 0:s.summary)||"").trim();p&&(f.summary=p);const _=(s==null?void 0:s.content)==null?"":String((s==null?void 0:s.content)??"");return _.trim()&&(f.content=_),await this._post_json("backlog_create","/api/gateway/backlog/create",f)}async backlog_merge(s){const r=String((s==null?void 0:s.kind)||"").trim(),l=String((s==null?void 0:s.package)||"").trim(),c=String((s==null?void 0:s.title)||"").trim(),f=Array.isArray(s==null?void 0:s.items)?s.items:[];if(!r)throw new Error("backlog_merge: kind is required");if(!l)throw new Error("backlog_merge: package is required");if(!c)throw new Error("backlog_merge: title is required");if(f.length<2)throw new Error("backlog_merge: at least 2 items are required");const m={kind:r,package:l,title:c,items:f.map(y=>({kind:String((y==null?void 0:y.kind)||"").trim(),filename:String((y==null?void 0:y.filename)||"").trim()}))},p=String((s==null?void 0:s.task_type)||"").trim();p&&(m.task_type=p);const _=String((s==null?void 0:s.summary)||"").trim();return _&&(m.summary=_),await this._post_json("backlog_merge","/api/gateway/backlog/merge",m)}async backlog_upload_attachment(s){const r=String((s==null?void 0:s.kind)||"").trim(),l=String((s==null?void 0:s.filename)||"").trim(),c=s==null?void 0:s.file;if(!r)throw new Error("backlog_upload_attachment: kind is required");if(!l)throw new Error("backlog_upload_attachment: filename is required");if(!c)throw new Error("backlog_upload_attachment: file is required");const f=new FormData;return f.set("overwrite",(s==null?void 0:s.overwrite)===!0?"true":"false"),f.set("file",c,c.name||"attachment"),await this._post_form("backlog_upload_attachment",`/api/gateway/backlog/${encodeURIComponent(r)}/${encodeURIComponent(l)}/attachments/upload`,f)}async backlog_assist(s){const r=String((s==null?void 0:s.kind)||"").trim(),l=String((s==null?void 0:s.package)||"").trim(),c=String((s==null?void 0:s.title)||"").trim();if(!r)throw new Error("backlog_assist: kind is required");if(!l)throw new Error("backlog_assist: package is required");if(!c)throw new Error("backlog_assist: title is required");const f={kind:r,package:l,title:c,messages:Array.isArray(s==null?void 0:s.messages)?s.messages:[]},m=String((s==null?void 0:s.summary)||"").trim();m&&(f.summary=m);const p=(s==null?void 0:s.draft_markdown)==null?"":String(s.draft_markdown??"");p.trim()&&(f.draft_markdown=p);const _=String((s==null?void 0:s.provider)||"").trim();_&&(f.provider=_);const y=String((s==null?void 0:s.model)||"").trim();y&&(f.model=y);const w=String((s==null?void 0:s.thinking)||"").trim();return w&&(f.thinking=w),await this._post_json("backlog_assist","/api/gateway/backlog/assist",f)}async backlog_maintain(s){const r=String((s==null?void 0:s.kind)||"").trim(),l=String((s==null?void 0:s.filename)||"").trim(),c=String((s==null?void 0:s.package)||"").trim(),f=String((s==null?void 0:s.title)||"").trim();if(!r)throw new Error("backlog_maintain: kind is required");if(!l)throw new Error("backlog_maintain: filename is required");if(!c)throw new Error("backlog_maintain: package is required");if(!f)throw new Error("backlog_maintain: title is required");const m={kind:r,filename:l,package:c,title:f,messages:Array.isArray(s==null?void 0:s.messages)?s.messages:[]},p=String((s==null?void 0:s.summary)||"").trim();p&&(m.summary=p);const _=(s==null?void 0:s.draft_markdown)==null?"":String(s.draft_markdown??"");_.trim()&&(m.draft_markdown=_);const y=String((s==null?void 0:s.provider)||"").trim();y&&(m.provider=y);const w=String((s==null?void 0:s.model)||"").trim();return w&&(m.model=w),await this._post_json("backlog_maintain","/api/gateway/backlog/maintain",m)}async backlog_advisor(s){const r={messages:Array.isArray(s==null?void 0:s.messages)?s.messages:[]},l=String((s==null?void 0:s.provider)||"").trim();l&&(r.provider=l);const c=String((s==null?void 0:s.model)||"").trim();c&&(r.model=c);const f=String((s==null?void 0:s.thinking)||"").trim();f&&(r.thinking=f);const m=String((s==null?void 0:s.agent)||"").trim();m&&(r.agent=m),(s==null?void 0:s.include_trace)===!0&&(r.include_trace=!0);const p=String((s==null?void 0:s.focus_kind)||"").trim();p&&(r.focus_kind=p);const _=String((s==null?void 0:s.focus_type)||"").trim();return _&&(r.focus_type=_),await this._post_json("backlog_advisor","/api/gateway/backlog/advisor",r)}async backlog_execute(s){const r=String((s==null?void 0:s.kind)||"").trim(),l=String((s==null?void 0:s.filename)||"").trim();if(!r)throw new Error("backlog_execute: kind is required");if(!l)throw new Error("backlog_execute: filename is required");const c=new URLSearchParams,f=String((s==null?void 0:s.execution_mode)||"").trim();f&&c.set("execution_mode",f);const m=String((s==null?void 0:s.executor)||"").trim();m&&c.set("executor",m);const p=String((s==null?void 0:s.target_model)||"").trim();p&&c.set("target_model",p);const _=String((s==null?void 0:s.target_reasoning_effort)||"").trim();return _&&c.set("target_reasoning_effort",_),(s==null?void 0:s.dor)==="check"&&c.set("dor","check"),(s==null?void 0:s.override)===!0&&c.set("override","true"),await(await this._fetch("backlog_execute",`/api/gateway/backlog/${encodeURIComponent(r)}/${encodeURIComponent(l)}/execute${c.toString()?`?${c.toString()}`:""}`,{method:"POST"})).json()}async backlog_execute_batch(s){const r=Array.isArray(s==null?void 0:s.items)?s.items:[];if(!r.length)throw new Error("backlog_execute_batch: items are required");const l={items:r.map(_=>({kind:String((_==null?void 0:_.kind)||"").trim(),filename:String((_==null?void 0:_.filename)||"").trim()}))},c=String((s==null?void 0:s.execution_mode)||"").trim();c&&(l.execution_mode=c);const f=String((s==null?void 0:s.executor)||"").trim();f&&(l.executor=f);const m=String((s==null?void 0:s.target_model)||"").trim();m&&(l.target_model=m);const p=String((s==null?void 0:s.target_reasoning_effort)||"").trim();return p&&(l.target_reasoning_effort=p),(s==null?void 0:s.dor)==="check"&&(l.dor="check"),(s==null?void 0:s.override)===!0&&(l.override=!0),await this._post_json("backlog_execute_batch","/api/gateway/backlog/execute_batch",l)}async backlog_exec_config(){return await this._get_json("backlog_exec_config","/api/gateway/backlog/exec/config")}async backlog_exec_requests(s){const r=new URLSearchParams,l=String((s==null?void 0:s.status)||"").trim();return l&&r.set("status",l),r.set("limit",String(typeof(s==null?void 0:s.limit)=="number"&&Number.isFinite(s.limit)?Number(s.limit):200)),await this._get_json("backlog_exec_requests",`/api/gateway/backlog/exec/requests?${r.toString()}`)}async backlog_exec_request(s,r){const l=String(s||"").trim();if(!l)throw new Error("backlog_exec_request: request_id is required");const c=new URLSearchParams;return(r==null?void 0:r.include_prompt)===!0&&c.set("include_prompt","true"),await this._get_json("backlog_exec_request",`/api/gateway/backlog/exec/requests/${encodeURIComponent(l)}?${c.toString()}`)}async backlog_exec_feedback(s){const r=String((s==null?void 0:s.request_id)||"").trim();if(!r)throw new Error("backlog_exec_feedback: request_id is required");const l=String((s==null?void 0:s.feedback)??"");if(!l.trim())throw new Error("backlog_exec_feedback: feedback is required");return await this._post_json("backlog_exec_feedback",`/api/gateway/backlog/exec/requests/${encodeURIComponent(r)}/feedback`,{feedback:l})}async backlog_exec_promote(s){const r=String((s==null?void 0:s.request_id)||"").trim();if(!r)throw new Error("backlog_exec_promote: request_id is required");const l={};return(s==null?void 0:s.redeploy)===!0&&(l.redeploy=!0),await this._post_json("backlog_exec_promote",`/api/gateway/backlog/exec/requests/${encodeURIComponent(r)}/promote`,l)}async backlog_exec_deploy_uat(s){const r=String((s==null?void 0:s.request_id)||"").trim();if(!r)throw new Error("backlog_exec_deploy_uat: request_id is required");return await this._post_json("backlog_exec_deploy_uat",`/api/gateway/backlog/exec/requests/${encodeURIComponent(r)}/uat/deploy`,{})}async backlog_exec_log_tail(s){const r=String((s==null?void 0:s.request_id)||"").trim();if(!r)throw new Error("backlog_exec_log_tail: request_id is required");const l=new URLSearchParams,c=String((s==null?void 0:s.name)||"").trim();c&&l.set("name",c);const f=typeof(s==null?void 0:s.max_bytes)=="number"&&Number.isFinite(s.max_bytes)?Number(s.max_bytes):0;f>0&&l.set("max_bytes",String(Math.floor(f)));const m=typeof(s==null?void 0:s.after_bytes)=="number"&&Number.isFinite(s.after_bytes)?Math.max(0,Math.floor(s.after_bytes)):null;return m!==null&&l.set("after_bytes",String(m)),await this._get_json("backlog_exec_log_tail",`/api/gateway/backlog/exec/requests/${encodeURIComponent(r)}/logs/tail?${l.toString()}`)}async backlog_exec_active_items(s){const r=new URLSearchParams,l=String((s==null?void 0:s.status)||"").trim();return l&&r.set("status",l),r.set("limit",String(typeof(s==null?void 0:s.limit)=="number"&&Number.isFinite(s.limit)?Number(s.limit):600)),await this._get_json("backlog_exec_active_items",`/api/gateway/backlog/exec/active_items?${r.toString()}`)}async discovery_providers(){return await(await this._fetch("discovery_providers","/api/gateway/discovery/providers")).json()}async discovery_model_capabilities(s){const r=String(s||"").trim();if(!r)throw new Error("discovery_model_capabilities: model_name is required");return await(await this._fetch("discovery_model_capabilities",`/api/gateway/discovery/models/capabilities?model_name=${encodeURIComponent(r)}`)).json()}async discovery_provider_models(s){const r=String(s||"").trim();if(!r)throw new Error("discovery_provider_models: provider is required");return await(await this._fetch("discovery_provider_models",`/api/gateway/discovery/providers/${encodeURIComponent(r)}/models`)).json()}async list_entities(){return await(await this._fetch("list_entities","/api/gateway/entities")).json()}async admin_runtime_config(){return await(await this._fetch("admin_runtime_config","/api/gateway/admin/runtime-config")).json()}async admin_executors(){return await(await this._fetch("admin_executors","/api/gateway/admin/executors")).json()}async admin_runtime_config_update(s){return await(await this._fetch("admin_runtime_config_update","/api/gateway/admin/runtime-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s||{})})).json()}async entity_state(s,r){return await(await this._fetch("entity_state",`/api/gateway/entities/${encodeURIComponent(s)}/state`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})).json()}async entity_skills(s){return await(await this._fetch("entity_skills",`/api/gateway/entities/${encodeURIComponent(s)}/skills`)).json()}async put_entity_skills(s,r){return await(await this._fetch("put_entity_skills",`/api/gateway/entities/${encodeURIComponent(s)}/skills`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({skills:r})})).json()}async list_bundles(){return await(await this._fetch("list_bundles","/api/gateway/bundles")).json()}async admin_data_homes(){return await(await this._fetch("admin_data_homes","/api/gateway/admin/data-homes")).json()}async list_processes(){return await this._get_json("list_processes","/api/gateway/processes")}async list_process_env_vars(){return await this._get_json("list_process_env_vars","/api/gateway/processes/env")}async update_process_env_vars(s){const r={},l=s!=null&&s.set&&typeof s.set=="object"?s.set:{},c=Array.isArray(s==null?void 0:s.unset)?s==null?void 0:s.unset:[];return l&&Object.keys(l).length&&(r.set=l),c&&c.length&&(r.unset=c),await this._post_json("update_process_env_vars","/api/gateway/processes/env",r)}async start_process(s){const r=String(s||"").trim();return await this._post_json("start_process",`/api/gateway/processes/${encodeURIComponent(r)}/start`)}async stop_process(s){const r=String(s||"").trim();return await this._post_json("stop_process",`/api/gateway/processes/${encodeURIComponent(r)}/stop`)}async restart_process(s){const r=String(s||"").trim();return await this._post_json("restart_process",`/api/gateway/processes/${encodeURIComponent(r)}/restart`)}async redeploy_process(s){const r=String(s||"").trim();return await this._post_json("redeploy_process",`/api/gateway/processes/${encodeURIComponent(r)}/redeploy`)}async process_log_tail(s,r){const l=String(s||"").trim(),c=typeof(r==null?void 0:r.max_bytes)=="number"?Math.max(1024,Math.min(4e5,Math.floor(r.max_bytes))):8e4;return await this._get_json("process_log_tail",`/api/gateway/processes/${encodeURIComponent(l)}/logs/tail?max_bytes=${encodeURIComponent(String(c))}`)}}function rf(a,s){const r=String((a==null?void 0:a.session_id)||"").trim();if(!r)throw new Error(`${s}: session_id is required`);const l=String((a==null?void 0:a.description)||"").trim();if(!l)throw new Error(`${s}: description is required`);const c={session_id:r,description:l};for(const m of["active_run_id","workflow_id","client","client_version","user_agent","url","provider","model","template"]){const p=String((a==null?void 0:a[m])||"").trim();p&&(c[m]=p)}const f=a==null?void 0:a.context;return f&&typeof f=="object"&&(c.context=f),c}const K_=/^[a-zA-Z0-9_-]+$/;function lf(a){return K_.test(String(a||"").trim())}async function Q_(a){const s=String(a||""),r=new TextEncoder().encode(s),l=globalThis.crypto;if(!l||!l.subtle||typeof l.subtle.digest!="function")return"";const c=await l.subtle.digest("SHA-256",r);return Array.from(new Uint8Array(c)).map(f=>f.toString(16).padStart(2,"0")).join("")}async function ad(a){const s=String(a||"").trim();if(!s)throw new Error("session_id is required");if(lf(s)){const l=`session_memory_${s}`;if(lf(l))return l}return`session_memory_sha_${(await Q_(s)).slice(0,32)}`}const Fa=["bug","feature","improvement","task"];function Nl(a){return String(a||"").trim().toLowerCase()}function eh(a){return Fa.includes(Nl(a))}function th(a){const s=Nl(a);return eh(s)?s:"task"}function nh(a){return a.toUpperCase()}function sh(a){return a==="bug"?"danger":a==="feature"?"ok":a==="improvement"?"info":a==="task"?"task":"muted"}function ah(a){return eh(a)?void 0:`"${a}" is not in the ruled type vocabulary (${Fa.join(" / ")})`}function rh(a){const s=String(a||"").trim();return s.replace(/^\[(bug|feature|improvement|task)\]\s*/i,"").trim()||s}function fa(a,s){const r=String(a||"");return r.length<=s?r:`${r.slice(0,Math.max(0,s-1))}…`}function Bu(a=new Date){const s=p=>String(p).padStart(2,"0"),r=-a.getTimezoneOffset(),l=r>=0?"+":"-",c=Math.abs(r),f=s(Math.floor(c/60)),m=s(c%60);return`${a.getFullYear()}-${s(a.getMonth()+1)}-${s(a.getDate())} ${s(a.getHours())}:${s(a.getMinutes())}:${s(a.getSeconds())} ${l}${f}${m}`}function J_(a){try{return JSON.parse(a)}catch{return null}}function of(a,s){return a.scrollHeight-a.scrollTop-a.clientHeight<=s}function ku(a){const s=typeof a=="string"?a.trim():"";if(!s)return null;const r=s.replace(/(\.\d{3})\d+/,"$1"),l=Date.parse(r);return Number.isFinite(l)?l:null}function Os(a){if(!Number.isFinite(a))return"";const s=Math.max(0,Math.floor(a/1e3)),r=s%60,l=Math.floor(s/60),c=l%60,f=Math.floor(l/60),m=f%24,p=Math.floor(f/24);return p>0?`${p}d ${m}h`:f>0?`${f}h ${c}m`:l>0?`${l}m ${r}s`:`${s}s`}async function Uu(a){const s=String(a||""),r=new TextEncoder().encode(s),l=globalThis.crypto;if(!l||!l.subtle||typeof l.subtle.digest!="function")return"";const c=await l.subtle.digest("SHA-256",r);return Array.from(new Uint8Array(c)).map(f=>f.toString(16).padStart(2,"0")).join("")}function kl(a){const s=String(a||"").trim().toLowerCase();return s==="completed"||s==="promoted"?"ok":s==="failed"?"danger":s==="running"?"info":s==="queued"||s==="awaiting_qa"?"warn":"muted"}function Y_(a,s){return a==="processing"?"queued,running,awaiting_qa":a==="failed"?"failed":a==="completed"&&s==="runs"?"completed,promoted":""}function pl(a,s){const r=a&&typeof a=="object"?a:{},l=r.backlog&&typeof r.backlog=="object"?r.backlog:{},c=r.result&&typeof r.result=="object"?r.result:{},f=r.executor&&typeof r.executor=="object"?r.executor:{},m=String(c.last_message||"").trim(),p=String(r.target_model||f.model||"").trim(),_=String(r.target_reasoning_effort||f.reasoning_effort||"").trim();return{request_id:s,status:String(r.status||"unknown"),created_at:r.created_at??null,started_at:r.started_at??null,finished_at:r.finished_at??null,backlog_relpath:l.relpath??null,backlog_kind:l.kind??null,backlog_filename:l.filename??null,target_agent:r.target_agent??null,target_model:p||null,target_reasoning_effort:_||null,executor_type:f.type??null,ok:typeof c.ok=="boolean"?c.ok:null,exit_code:typeof c.exit_code=="number"?c.exit_code:c.exit_code??null,error:typeof c.error=="string"?c.error:c.error??null,run_dir_relpath:r.run_dir_relpath??null,last_message:X_(m)}}const Su=1200;function X_(a){const s=String(a||"");return s?s.length<=Su?s:`${s.slice(0,Su)}
47
- … [#TRUNCATION: ${Su} of ${s.length} chars; the full last_message is in the run directory]`:null}function Z_(a){const s=String(a||""),r=s.split(/\r?\n/).filter(f=>String(f||"").trim().length>0),l=[];let c=0;for(let f=0;f<r.length;f+=1){const m=String(r[f]||"").trim(),p=J_(m);if(!p||typeof p!="object"){c+=1,l.push({idx:f,type:"raw",payload:null,raw:m});continue}const _=String(p.type||p.event||"event");l.push({idx:f,type:_,payload:p,raw:m})}return{total:r.length,bad:c,events:l,raw:s}}function eg(a){if(!a)return null;let s=0,r=0,l=0,c=0,f=0;for(const p of a.events){const _=p.payload,y=_&&typeof _.usage=="object"?_.usage:null;y&&(Number.isFinite(Number(y.input_tokens))&&(s+=Number(y.input_tokens)),Number.isFinite(Number(y.cached_input_tokens))&&(r+=Number(y.cached_input_tokens)),Number.isFinite(Number(y.output_tokens))&&(l+=Number(y.output_tokens)));const w=_&&typeof _.item=="object"?_.item:null;w&&String(w.type||"").trim()==="command_execution"&&(c+=1,String(w.status||"").trim().toLowerCase()==="failed"&&(f+=1))}return{has_tokens:s>0||l>0||r>0,input_tokens:s,cached_input_tokens:r,output_tokens:l,total_tokens:s+l,command_count:c,command_fail_count:f}}function Cl(a,s=Date.now()){const r=ku(a==null?void 0:a.created_at),l=ku(a==null?void 0:a.started_at),c=ku(a==null?void 0:a.finished_at),f=String((a==null?void 0:a.status)||"").trim().toLowerCase(),m=c??(f==="running"?s:null),p=c!=null,_=r!=null&&l!=null?Math.max(0,l-r):null,y=l!=null&&m!=null?Math.max(0,m-l):null,w=r!=null&&m!=null?Math.max(0,m-r):null,x=!p&&r!=null?Math.max(0,s-r):null;return{is_done:p,queue_delay_ms:_,run_ms:y,total_ms:w,age_ms:x}}function tg(a,s){const r=String(s.package_name).trim()||"{Package}",l=rh(String(s.title||"").trim()||"{Title}"),c=String(s.summary||"").trim(),f=th(s.task_type),m=`# {ID}-${r}: [${nh(f)}] ${l}`.trim();let p=String(a||"");p=p.split("{Package}").join(r).split("{Title}").join(l);const _=p.split(/\r?\n/);let y=!1;for(let P=0;P<_.length;P+=1){const T=String(_[P]||"");if(T.trim().startsWith("# ")){_[P]=m,y=!0;break}if(T.trim())break}y||(_.unshift("",m),_.shift());const w=`> Created: ${String(s.created_at||"").trim()}`.trim();let x=!1;for(let P=0;P<Math.min(_.length,40);P+=1)if(String(_[P]||"").trim().toLowerCase().startsWith("> created:")){_[P]=w,x=!0;break}if(!x){const P=_.length>1&&!String(_[1]||"").trim()?2:1;_.splice(P,0,w,"")}const N=`> Type: ${f}`.trim();let $=!1;for(let P=0;P<Math.min(_.length,60);P+=1)if(String(_[P]||"").trim().toLowerCase().startsWith("> type:")){_[P]=N,$=!0;break}if(!$){let P=-1;for(let T=0;T<Math.min(_.length,60);T+=1)if(String(_[T]||"").trim().toLowerCase().startsWith("> created:")){P=T;break}if(P>=0){const T=P+1;T<_.length&&!String(_[T]||"").trim()?_.splice(T,0,N):_.splice(T,0,N,"")}else{const T=_.length>1&&!String(_[1]||"").trim()?2:1;_.splice(T,0,N,"")}}if(c){for(let P=0;P<_.length;P+=1)if(String(_[P]||"").trim().toLowerCase()==="## summary"){let T=P+1;for(;T<_.length&&!String(_[T]||"").trim();)T+=1;(T<_.length?String(_[T]||""):"").trim().toLowerCase().startsWith("one paragraph describing")?_[T]=c:_.splice(P+1,0,c,"");break}}return p=_.join(`
48
- `),p.endsWith(`
49
- `)||(p+=`
50
- `),p}function Pa(a){return String(a||"").split(/\r?\n/).map(s=>s.trim()).filter(Boolean)}function ng(a){const s=String(a.package_name||"").trim()||"{Package}",r=rh(String(a.title||"").trim()||"{Title}"),l=th(a.task_type),c=String(a.created_at||"").trim()||Bu(),f=String(a.diagram||"").trim(),m=String(a.context||"").trim(),p=[];return p.push(`# {ID}-${s}: [${nh(l)}] ${r}`),p.push(""),p.push(`> Created: ${c}`),p.push(`> Type: ${l}`),p.push(""),p.push("## Summary"),p.push(a.summary.trim()||"One paragraph describing what this task accomplishes (user value + outcome)."),p.push(""),p.push("## Diagram"),p.push("```"),p.push(f||`ASCII diagram of the system change.
51
- Show inputs/outputs and where code lives.`),p.push("```"),p.push(""),p.push("## Context"),p.push(m||"(why is this needed? link to evidence: bug/feature report paths, discussions, etc.)"),p.push(""),p.push("## Scope"),p.push("### Included"),a.included.length?p.push(...a.included.map(_=>`- ${_}`)):p.push("- "),p.push(""),p.push("### Excluded"),a.excluded.length?p.push(...a.excluded.map(_=>`- ${_}`)):p.push("- "),p.push(""),p.push("## Implementation Plan"),a.plan.length?p.push(...a.plan.map((_,y)=>`${y+1}. ${_}`)):p.push("1. "),p.push(""),p.push("## Dependencies"),a.dependencies.length?p.push(...a.dependencies.map(_=>`- ${_}`)):p.push("- Related backlog items / ADRs"),p.push(""),p.push("## Acceptance Criteria"),a.acceptance.length?p.push(...a.acceptance.map(_=>`- [ ] ${_}`)):p.push("- [ ] Criterion 1 (clear, testable)"),p.push(""),p.push("## Testing (ADR-0019)"),p.push("- Level A:"),a.tests_a.length?p.push(...a.tests_a.map(_=>` - \`${_}\``)):p.push(" - `...`"),p.push("- Level B:"),a.tests_b.length?p.push(...a.tests_b.map(_=>` - \`${_}\``)):p.push(" - `...`"),p.push("- Level C (optional / opt-in):"),a.tests_c.length?p.push(...a.tests_c.map(_=>` - \`${_}\``)):p.push(" - n/a"),p.push(""),p.push("## Related"),p.push("- ADRs:"),p.push("- Code:"),p.push("- Reports:"),a.attachments.length&&(p.push("- Attachments:"),p.push(...a.attachments.map(_=>` - ${_}`))),p.push(""),p.push("---"),p.push("## Report (added when completed)"),p.push(""),p.push("> Completed: YYYY-MM-DD"),p.push(""),p.push("### What changed"),p.push("- "),p.push(""),p.push("### Security / hardening"),p.push("- "),p.push(""),p.push("### Testing (ADR-0019)"),p.push("Levels executed:"),p.push("- A:"),p.push("- B:"),p.push("- C (if any):"),p.push(""),p.push("Commands run:"),p.push("- `...`"),p.push(""),p.push("### Follow-ups"),p.push("- "),p.push(""),p.join(`
52
- `)}function sg(a,s){const r=s.map(_=>String(_||"").trim()).filter(Boolean);if(!r.length)return a;const l=String(a||"").split(/\r?\n/),c=l.map(_=>_.toLowerCase()),f=c.findIndex(_=>_.trim()==="## related");if(f<0)return`${String(a||"").trimEnd()}
53
-
54
- ## Related
55
- - Attachments:
56
- ${r.map(y=>` - ${y}`).join(`
57
- `)}
58
- `;let m=-1;for(let _=f+1;_<l.length;_+=1){const y=c[_].trim();if(y.startsWith("## ")||y.startsWith("---"))break;if(y.startsWith("- attachments:")){m=_;break}}const p=["- Attachments:",...r.map(_=>` - ${_}`)];if(m>=0){let _=m+1;for(;_<l.length&&/^\s+-\s/.test(l[_]);)_+=1;l.splice(_,0,...r.map(y=>` - ${y}`))}else{let _=f+1;for(let y=f+1;y<l.length;y+=1){const w=c[y].trim();if(w.startsWith("## ")||w.startsWith("---")){_=y;break}_=y+1}l.splice(_,0,...p,"")}return l.join(`
59
- `)}function ag(a,s){const r=Uf(a);if(!r.ok)return null;const l=r.payload.phases.map(m=>m.id),c=new Map;for(const m of s)c.set(`${m.section}\0${m.item}\0${m.phase}`,m.op);const f=[];for(const m of r.payload.sections)for(const p of m.items){const _=[];for(const y of l){const w=p.cells[y];if(!w)continue;const x=c.get(`${m.id}\0${p.id}\0${y}`);(x?x==="grant":!!w.assigned)&&_.push(y)}_.length&&(_.length===l.length?f.push({name:p.id}):f.push({name:p.id,phases:_}))}return f}function rg(a){var C,Z;const{gateway:s,entity_name:r}=a,[l,c]=h.useState(null),[f,m]=h.useState(""),[p,_]=h.useState(!1),[y,w]=h.useState([]),[x,N]=h.useState(!1),[$,P]=h.useState(""),[T,F]=h.useState(""),D=h.useCallback(async()=>{_(!0),m("");try{c(await s.entity_skills(r))}catch(ae){c(null),m(String((ae==null?void 0:ae.message)||ae))}finally{_(!1)}},[s,r]);h.useEffect(()=>{w([]),F(""),P(""),D()},[D]);async function J(){if(!(l!=null&&l.matrix))return;const ae=ag(l.matrix,y);if(ae===null){P("Cannot serialize the selection: the matrix payload failed validation — refresh and retry.");return}N(!0),P("");try{const fe=await s.put_entity_skills(r,ae);c(fe),w([]),F("Selection saved — recorded as a host marker on the entity's stream."),setTimeout(()=>F(""),5e3)}catch(fe){P(String((fe==null?void 0:fe.message)||fe))}finally{N(!1)}}const B=Array.isArray((C=l==null?void 0:l.selection)==null?void 0:C.warnings)?l.selection.warnings.map(String):[],ee=Array.isArray((Z=l==null?void 0:l.resolved)==null?void 0:Z.skills)?l.resolved.skills:[];return e.jsxs("div",{className:"entity_skills_panel",children:[e.jsxs("div",{className:"entity_skills_head",children:[e.jsxs("span",{className:"pane_title",children:["Skills — ",r]}),e.jsx("span",{className:"muted",style:{fontSize:"var(--font-size-xs)"},children:"what this mind is taught, per phase; the trust gate resolves server-side"}),e.jsxs("span",{style:{marginLeft:"auto",display:"inline-flex",gap:6},children:[e.jsx("button",{className:"btn",onClick:()=>void D(),disabled:p||x,title:"Reload the resolved view (discards pending edits)",children:p?"Loading…":"Refresh"}),e.jsx("button",{className:"btn",onClick:a.on_close,children:"Close"})]})]}),f?e.jsxs("div",{className:"page_error",children:["Skills unavailable: ",f]}):null,B.length?e.jsx("div",{className:"detail_warn",style:{marginTop:4},children:B.join(" · ")}):null,ee.length?e.jsx("div",{className:"entity_skills_resolved",children:ee.map(ae=>{const fe=String((ae==null?void 0:ae.name)||""),ge=!!(ae!=null&&ae.active),Te=!!(ae!=null&&ae.blocked),Se=!!(ae!=null&&ae.requires_review),K=ae==null?void 0:ae.requires_unmet,te=Array.isArray(K)?K.map(String):K&&typeof K=="object"?Object.entries(K).map(([ce,I])=>`${ce}: ${String(I)}`):[],z=ge?"ok":Te?"danger":te.length||Se?"warn":"muted",V=ge?"active":Te?"blocked":te.length?"requires unmet":Se?"requires review":"inactive",H=[...Array.isArray(ae==null?void 0:ae.reasons)?ae.reasons.map(String):[],...te].join("; ");return e.jsxs("span",{className:`chip mono ${z}`,title:H||void 0,children:[fe," · ",V]},fe)})}):null,e.jsx(Gp,{payload:l==null?void 0:l.matrix,patches:y,onPatchesChange:w,disabled:x||p,title:"Phase capabilities",subtitle:"Grant/Deny per phase; Default clears the operator word (unselected). Save replaces the whole selection."}),e.jsxs("div",{className:"entity_skills_actions",children:[e.jsx("button",{className:"btn primary",onClick:()=>void J(),disabled:x||!y.length,title:y.length?`Save ${y.length} pending change(s)`:"No pending changes",children:x?"Saving…":y.length?`Save ${y.length} change${y.length>1?"s":""}`:"Save"}),y.length?e.jsx("button",{className:"btn",onClick:()=>w([]),disabled:x,children:"Discard edits"}):null,$?e.jsx("span",{className:"page_error",style:{margin:0},children:$}):null,T?e.jsx("span",{className:"chip mono ok",children:T}):null]})]})}function ig(a){const s=new Map;for(const r of a){const l=String(r.target_agent||(r.target_model?`${String(r.executor_type||"agent").trim()||"agent"}:${r.target_model}`:"")||"(unattributed)").trim();let c=s.get(l);c||(c={agent:l,model:String(r.target_model||"").trim(),runs:0,active:0,promoted:0,completed:0,failed:0,awaiting_qa:0,total_run_ms:0,timed_runs:0,last_active:""},s.set(l,c)),c.runs+=1;const f=String(r.status||"").toLowerCase();f==="queued"||f==="running"?c.active+=1:f==="promoted"?c.promoted+=1:f==="completed"?c.completed+=1:f==="failed"?c.failed+=1:f==="awaiting_qa"&&(c.awaiting_qa+=1);const m=Cl(r);m.run_ms!=null&&(c.total_run_ms+=m.run_ms,c.timed_runs+=1);const p=String(r.finished_at||r.started_at||r.created_at||"");p>c.last_active&&(c.last_active=p)}return[...s.values()].sort((r,l)=>l.runs-r.runs)}function lg(a){const{gateway:s,gateway_connected:r}=a,l=String(a.backlog_advisor_agent||"").trim()||"basic-agent",[c,f]=h.useState(null),[m,p]=h.useState([]),[_,y]=h.useState([]),[w,x]=h.useState(""),[N,$]=h.useState(null),[P,T]=h.useState(!1),[F,D]=h.useState(""),[J,B]=h.useState(!1),[ee,C]=h.useState(""),[Z,ae]=h.useState(null),fe=h.useRef(0);async function ge(){if(!r||P)return;const S=++fe.current;T(!0),D("");try{const[A,U,ie]=await Promise.all([s.backlog_exec_config(),s.backlog_exec_requests({status:"queued,running,awaiting_qa",limit:200}),s.backlog_exec_requests({status:"promoted,completed,failed",limit:200})]);if(S!==fe.current)return;f(A),p([...Array.isArray(U==null?void 0:U.requests)?U.requests:[],...Array.isArray(ie==null?void 0:ie.requests)?ie.requests:[]])}catch(A){S===fe.current&&D(String((A==null?void 0:A.message)||A||"Failed to load agents"))}finally{fe.current,T(!1)}try{const A=await s.list_entities();if(S!==fe.current)return;y(Array.isArray(A==null?void 0:A.entities)?A.entities:[]),x("")}catch(A){if(S!==fe.current)return;y([]),x(`#FALLBACK entity registry unavailable: ${String((A==null?void 0:A.message)||A)}`)}try{const A=await s.admin_executors();if(S!==fe.current)return;const U=Array.isArray(A)?A:Array.isArray(A==null?void 0:A.executors)?A.executors:[];$(U)}catch{S===fe.current&&$(A=>A===null?null:A)}try{const A=await s.admin_runtime_config();S===fe.current&&B((A==null?void 0:A.writable)===!0)}catch{S===fe.current&&B(!1)}}async function Te(){fe.current+=1;try{const S=await s.list_entities();y(Array.isArray(S==null?void 0:S.entities)?S.entities:[]),x("")}catch(S){x(`#FALLBACK entity registry unavailable: ${String((S==null?void 0:S.message)||S)}`)}}async function Se(){fe.current+=1;try{const S=await s.admin_executors(),A=Array.isArray(S)?S:Array.isArray(S==null?void 0:S.executors)?S.executors:[];$(A)}catch{}try{f(await s.backlog_exec_config())}catch{}}async function K(S){if(ee)return;const A=`executor:${S}`;C(A),ae(null);try{await s.admin_runtime_config_update({executor:S}),await Se()}catch(U){ae({key:A,text:String((U==null?void 0:U.message)||U||"Executor change refused")})}finally{C("")}}const[te,z]=h.useState(null);async function V(S,A){if(ee)return;const U=String(S.slug||S.name||"").trim();if(!U)return;const ie=`entity:${U}`;C(ie),ae(null);try{await s.entity_state(U,{state:A,reason:"by the operator via Continuum (Agents & Entities)"}),await Te()}catch(de){ae({key:ie,text:String((de==null?void 0:de.message)||de||"State change refused")})}finally{C("")}}h.useEffect(()=>{ge()},[r]);const H=h.useMemo(()=>ig(m),[m]),ce=!!(c!=null&&c.runner_alive),I=String((c==null?void 0:c.executor)||"").trim(),_e=!I||I==="none",Y=_e?"No execution agent":I;return e.jsx("div",{className:"page page_scroll",children:e.jsxs("div",{className:"page_inner page_pad constrained",children:[e.jsxs("div",{className:"page_toolbar",children:[e.jsx("span",{className:"page_hint",children:"The workforce behind the pipeline — the executor is a pluggable seam; this console renders whatever the gateway reports."}),F?e.jsx("span",{className:"page_error mono",children:F}):null,e.jsx("div",{className:"page_toolbar_spacer"}),e.jsx("button",{className:`btn btn_icon ${P?"is_loading":""}`,onClick:()=>void ge(),disabled:!r||P,title:"Refresh","aria-label":"Refresh",children:e.jsx(st,{name:"refresh",size:16})})]}),e.jsxs("div",{className:"agents_grid",children:[N!==null&&N.length?N.map(S=>e.jsxs("div",{className:"entity_card",children:[e.jsxs("div",{className:"entity_card_head",children:[e.jsx("span",{className:"agent_avatar","aria-hidden":"true",children:e.jsx(st,{name:"terminal",size:16})}),e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{className:"entity_card_title",children:S.display||S.id}),e.jsxs("div",{className:"entity_card_sub",children:["execution agent",S.default?" · gateway default":""]})]}),e.jsx("span",{className:`chip mono ${S.available?"ok":"danger"}`,style:{marginLeft:"auto"},children:S.available?"available":"unavailable"})]}),e.jsx("div",{className:"agent_facts",children:Array.isArray(S.models)&&S.models.length?e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"models:"})," ",S.models.slice(0,4).join(", "),S.models.length>4?` +${S.models.length-4}`:""]}):null}),e.jsx("div",{className:"entity_card_actions",children:S.default?e.jsx("span",{className:"chip mono ok",title:"New executions run under this agent unless the request overrides it.",children:"gateway default"}):J?e.jsx("button",{className:"btn",disabled:!!ee||S.available===!1,title:S.available===!1?"Unavailable on the gateway host — the binary is not on its PATH":ee&&ee!==`executor:${S.id}`?"Another action is in flight":"Make this the gateway's default executor (admin, persisted gateway-side)",onClick:()=>void K(S.id),children:ee===`executor:${S.id}`?"Setting…":"Set as default"}):e.jsx("span",{className:"chip mono muted",title:"Changing the default executor is admin-only — the gateway authorizes it (Settings → Gateway administration).",children:"admin only"})}),(Z==null?void 0:Z.key)===`executor:${S.id}`?e.jsx("div",{className:"detail_warn",children:Z.text}):null]},S.id)):c?e.jsxs("div",{className:"entity_card",children:[e.jsxs("div",{className:"entity_card_head",children:[e.jsx("span",{className:"agent_avatar","aria-hidden":"true",children:e.jsx(st,{name:"terminal",size:16})}),e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{className:"entity_card_title",children:Y}),e.jsx("div",{className:"entity_card_sub",children:_e?"enable one from Settings → Gateway administration":"execution agent (gateway-configured)"})]}),e.jsx("span",{className:`chip mono ${ce?"ok":_e?"warn":"danger"}`,style:{marginLeft:"auto"},children:ce?"available":_e?"not configured":"offline"})]}),e.jsxs("div",{className:"agent_facts",children:[c.codex_model?e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"model:"})," ",c.codex_model]}):null,c.codex_reasoning_effort?e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"reasoning:"})," ",c.codex_reasoning_effort]}):null,e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"can execute:"})," ",c.can_execute?"yes":"no"]}),c.runner_error?e.jsx("div",{className:"page_error",children:c.runner_error}):null]})]}):null,e.jsxs("div",{className:"entity_card",children:[e.jsxs("div",{className:"entity_card_head",children:[e.jsx("span",{className:"agent_avatar","aria-hidden":"true",children:e.jsx(st,{name:"edit",size:16})}),e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{className:"entity_card_title",children:l}),e.jsx("div",{className:"entity_card_sub",children:"backlog advisor (read-only chat agent)"})]}),e.jsx("span",{className:"chip mono muted",style:{marginLeft:"auto"},children:"advisory"})]}),e.jsxs("div",{className:"agent_facts",children:[e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"surface:"})," assistant drawer + Backlog advisor"]}),e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"writes:"})," none (advice only)"]})]}),e.jsx("div",{className:"entity_card_actions",children:e.jsx("button",{className:"btn",onClick:()=>{var S;return(S=a.on_open_assistant)==null?void 0:S.call(a)},disabled:!a.on_open_assistant,title:"Open the assistant drawer and ask this advisor a question",children:"Ask the advisor"})})]})]}),e.jsxs("div",{className:"pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Summoned entities"}),e.jsxs("span",{className:"pane_count",children:[_.length," on this gateway"]}),e.jsx("span",{className:"pane_header_actions muted",style:{fontSize:"var(--font-size-xs)"},children:"persistent minds with full package history — recruitable for development alongside agents"})]}),e.jsxs("div",{className:"pane_body",children:[w?e.jsx("div",{className:"page_error",style:{fontSize:"var(--font-size-sm)"},children:w}):null,!w&&!_.length?e.jsx("div",{className:"empty_note",children:"No summoned entities on this gateway yet. Entities are created and summoned through the gateway (its CLI/console); once they exist they appear here as recruitable developers."}):null,_.length?e.jsx("div",{className:"agents_grid",style:{marginTop:0},children:_.map(S=>{var L,ke,be,Ie,Fe,Ye;if(S.error)return e.jsxs("div",{className:"entity_card",style:{borderColor:"var(--danger, rgb(248,113,113))"},children:[e.jsxs("div",{className:"entity_card_head",children:[e.jsx("span",{className:"agent_avatar","aria-hidden":"true",children:e.jsx(st,{name:"warning",size:16})}),e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{className:"entity_card_title",children:S.name||S.slug||"(unreadable home)"}),e.jsx("div",{className:"entity_card_sub mono",children:S.entity_id||S.slug})]}),e.jsx("span",{className:"chip mono danger",style:{marginLeft:"auto"},children:"error"})]}),e.jsx("div",{className:"detail_warn",style:{marginTop:0},children:S.error})]},S.entity_id||S.slug||S.name);const A=String(((L=S.state)==null?void 0:L.state)||"unknown").toLowerCase(),U=A==="awake"?"ok":A==="asleep"?"info":A==="paused"?"warn":"muted",de=String(S.liveness||((ke=S.state)==null?void 0:ke.liveness)||"").toLowerCase()==="stopped";return e.jsxs("div",{className:"entity_card",children:[e.jsxs("div",{className:"entity_card_head",children:[e.jsx("span",{className:"agent_avatar","aria-hidden":"true",children:e.jsx(st,{name:"agent",size:16})}),e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{className:"entity_card_title",children:S.name||S.slug}),e.jsx("div",{className:"entity_card_sub mono",children:S.entity_id})]}),de?e.jsx("span",{className:"chip mono danger",style:{marginLeft:"auto"},title:`The kill switch: served liveness=stopped (state: ${A}). Restore lives on the gateway console.`,children:"STOPPED"}):e.jsx("span",{className:`chip mono ${U}`,style:{marginLeft:"auto"},children:A})]}),e.jsxs("div",{className:"agent_facts",children:[S.created_at?e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"born:"})," ",new Date(S.created_at).toLocaleDateString()]}):null,(be=S.state)!=null&&be.reason?e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"state reason:"})," ",S.state.reason]}):null,e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"home:"})," spark ",(Ie=S.files)!=null&&Ie.spark?"✓":"—"," · memory ",(Fe=S.files)!=null&&Fe.memory?"✓":"—"," · book ",(Ye=S.files)!=null&&Ye.book?"✓":"—"]})]}),e.jsxs("div",{className:"entity_card_actions",children:[!de&&(A==="asleep"||A==="paused")?e.jsx("button",{className:"btn",disabled:!!ee,title:ee&&ee!==`entity:${S.slug||S.name}`?"Another action is in flight":"Wake this entity (operator act, recorded as a host marker; the gateway authorizes or refuses)",onClick:()=>void V(S,"awake"),children:ee===`entity:${S.slug||S.name}`?"Waking…":"Wake"}):null,!de&&A==="awake"?e.jsx("button",{className:"btn",disabled:!!ee,title:ee&&ee!==`entity:${S.slug||S.name}`?"Another action is in flight":"Graceful sleep (in-flight work finishes; reflection runs). The gateway refuses if a visit is live.",onClick:()=>void V(S,"asleep"),children:ee===`entity:${S.slug||S.name}`?"Sending…":"Sleep"}):null,de?e.jsx("span",{className:"chip mono warn",title:"Restore lives on the gateway console — the kill switch keeps one management surface.",children:"restore via gateway console"}):null,e.jsx("button",{className:"btn",onClick:()=>z(he=>he===(S.name||S.slug)?null:S.name||S.slug||null),title:"What this mind is taught, per phase (selection persists in the entity's home; changes record as host markers)",children:te===(S.name||S.slug)?"Hide skills":"Skills"})]}),(Z==null?void 0:Z.key)===`entity:${S.slug||S.name}`?e.jsx("div",{className:"detail_warn",children:Z.text}):null]},S.entity_id||S.slug)})}):null,te?e.jsx(rg,{gateway:s,entity_name:te,on_close:()=>z(null)}):null]})]}),e.jsxs("div",{className:"pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Capabilities"}),e.jsx("span",{className:"pane_subtitle",children:"live features link to their surface; pending ones name their owner"})]}),e.jsx("div",{className:"pane_body",children:e.jsxs("div",{className:"cap_rows",children:[e.jsxs("div",{className:"cap_row",children:[e.jsxs("div",{className:"cap_row_head",children:[e.jsx("span",{className:"cap_row_name",children:"Executor choice per task"}),e.jsx("span",{className:"chip mono ok",children:"live"}),a.on_open_executions?e.jsx("button",{className:"btn cap_row_action",onClick:a.on_open_executions,title:"Watch runs execute under their chosen agent",children:"Open Executions"}):null]}),e.jsx("div",{className:"cap_row_detail",children:"Every Execute dialog (Board and Backlog) carries an Execution agent dropdown — codex, claude, cursor-agent, abstractcode, probed live by the gateway. The default is set on the executor cards above; runs attribute canonically in the track record."})]}),e.jsxs("div",{className:"cap_row",children:[e.jsxs("div",{className:"cap_row_head",children:[e.jsx("span",{className:"cap_row_name",children:"Skills per run and per member"}),e.jsx("span",{className:"chip mono warn",children:"partial"}),a.on_open_executions?e.jsx("button",{className:"btn cap_row_action",onClick:a.on_open_executions,title:"Run detail → Skills section shows which teachings rode each run",children:"View on a run"}):null]}),e.jsx("div",{className:"cap_row_detail",children:"Which skills rode each run renders in the run detail today (requested vs active, held verdicts verbatim). Per-MEMBER skill grants (trust levels, review badges) land when the gateway serves the abstractskill union contract over HTTP (c1778) — the cards above grow a Skills action that day."})]}),e.jsxs("div",{className:"cap_row",children:[e.jsxs("div",{className:"cap_row_head",children:[e.jsx("span",{className:"cap_row_name",children:"MCP access grants"}),e.jsx("span",{className:"chip mono muted",children:"pending contract"})]}),e.jsx("div",{className:"cap_row_detail",children:"Per-member MCP grants — the ruled home is the gateway's phases config family, endpoint mirroring tool-policy (c1554). No continuum surface until the gateway serves it; this row turns live then."})]}),e.jsxs("div",{className:"cap_row",children:[e.jsxs("div",{className:"cap_row_head",children:[e.jsx("span",{className:"cap_row_name",children:"Agora charters and recruitment"}),e.jsx("span",{className:"chip mono info",children:"read live"}),a.on_open_team?e.jsx("button",{className:"btn cap_row_action",onClick:a.on_open_team,title:"Team page → ⓘ About shows each channel's charter, purpose, SLA, and members",children:"Open Team"}):null]}),e.jsx("div",{className:"cap_row_detail",children:"Per-channel charters, purpose, SLA, and members render on the Team page (ⓘ About on any channel). Charter WRITES and recruitment criteria are the next hub-proxy slice — writes are governance acts and get their own confirmation surface."})]})]})})]}),e.jsxs("div",{className:"pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Track record"}),e.jsxs("span",{className:"pane_count",children:[H.length," agent",H.length===1?"":"s"]}),e.jsx("span",{className:"pane_header_actions muted",style:{fontSize:"var(--font-size-xs)"},children:"all live + last 200 finished — counts, not quality"})]}),e.jsx("div",{className:"pane_body",style:{padding:0},children:H.length?e.jsx("div",{className:"table_scroll",children:e.jsxs("table",{className:"data_table track_table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"agent"}),e.jsx("th",{children:"runs"}),e.jsx("th",{className:"col_aux",children:"active"}),e.jsx("th",{className:"col_aux",children:"promoted"}),e.jsx("th",{className:"col_aux",children:"completed"}),e.jsx("th",{className:"col_aux",children:"in review"}),e.jsx("th",{children:"failed"}),e.jsx("th",{className:"col_aux2",children:"avg run"}),e.jsx("th",{className:"col_aux2",children:"last active"})]})}),e.jsx("tbody",{children:H.map(S=>e.jsxs("tr",{children:[e.jsx("td",{className:"td_agent mono",children:S.agent}),e.jsx("td",{children:S.runs}),e.jsx("td",{className:"col_aux",children:S.active||""}),e.jsx("td",{className:"col_aux",children:S.promoted||""}),e.jsx("td",{className:"col_aux",children:S.completed||""}),e.jsx("td",{className:"col_aux",children:S.awaiting_qa||""}),e.jsx("td",{className:S.failed?"page_error":"",children:S.failed||""}),e.jsx("td",{className:"col_aux2 td_time",children:S.timed_runs?Os(S.total_run_ms/S.timed_runs):""}),e.jsx("td",{className:"col_aux2 td_time",children:S.last_active?new Date(S.last_active).toLocaleString():""})]},S.agent))})]})}):e.jsx("div",{className:"muted",style:{fontSize:"var(--font-size-sm)",padding:"12px"},children:"No execution history yet."})})]})]})})}function Ds(a){const s=String(a||"").trim(),r=s.lastIndexOf("-");if(r<=0||r===s.length-1)return null;const l=s.slice(0,r),c=s.slice(r+1);return!/^[0-9]+$/.test(c)||!/^[a-z0-9][a-z0-9_.-]*$/.test(l)?null:{package:l,num:c}}function cf(a,s){const r=String(s||"").match(/^(\d{1,4})[-_]/);return!r||!a?null:`${a.toLowerCase()}-${r[1].padStart(4,"0")}`}function og(a){return String(a||"").replace(/\\/g,"/").split("/").filter(Boolean).pop()||""}function cg(a){const r=String(a||"").replace(/\\/g,"/").match(/(?:^|\/)(proposed|planned|completed|deprecated|recurrent)\/([^/]+\.md)$/i);return r?{kind:r[1].toLowerCase(),filename:r[2]}:null}const ug=/\b([a-z][a-z0-9_.-]{3,60}-\d{4})\b/g,dg=6;function mg(a){const s=[];for(const r of String(a||"").matchAll(ug)){const l=r[1];if(Ds(l)&&(s.includes(l)||s.push(l),s.length>=dg))break}return s}function ih(a,s,r=24){const l=a.started_at;if(l==null||l==="")return null;let c;if(typeof l=="number")c=l>1e12?l:l*1e3;else{const p=Date.parse(String(l));if(Number.isNaN(p))return null;c=p}const f=Math.max(0,(s-c)/36e5);return{label:f<1?`claimed ${Math.max(1,Math.round(f*60))}m`:f<48?`claimed ${Math.round(f)}h`:`claimed ${Math.round(f/24)}d`,stale:f>=r}}const $l=["P0","P1","P2","P3"],lh={P0:"P0 · critical",P1:"P1 · high",P2:"P2 · normal",P3:"P3 · low"},oh=/^>\s*priority:\s*(p[0-3])\b/i,ch=/^>\s*labels:\s*(.+)$/i;function rd(a){return String(a||"").split(",").map(s=>s.trim().toLowerCase().replace(/\s+/g,"-")).filter(s=>!!s&&s.length<=40).slice(0,12)}function Nu(a,s){const r=[];let l=!1;for(const c of a){const f=c.trim();if(/^#{1,6}\s/.test(f)){l=s.test(f);continue}l&&r.push(c)}return r}const fg=["one paragraph describing","criterion 1 (clear, testable)"];function uf(a){const s=a.trim().toLowerCase();return s?fg.some(r=>s.startsWith(r)):!0}function yi(a){const s=String(a||"").split(/\r?\n/);let r=null,l=[];for(const _ of s.slice(0,60)){const y=_.trim();if(/^##+\s/.test(y))break;const w=oh.exec(y);w&&!r&&(r=w[1].toUpperCase());const x=ch.exec(y);x&&!l.length&&(l=rd(x[1]))}const c=[];for(const _ of Nu(s,/acceptance criteria/i)){const y=/^\s*[-*]\s*\[( |x|X)\]\s*(.+)$/.exec(_);if(!y)continue;const w=y[2].trim();uf(w)||c.push({text:w,checked:y[1].toLowerCase()==="x"})}const f=[];for(const _ of Nu(s,/testing/i))for(const y of _.matchAll(/`([^`]+)`/g)){const w=y[1].trim();!w||w==="..."||w.toLowerCase()==="n/a"||f.push(w)}const m=Nu(s,/^#{1,6}\s*summary\b/i).map(_=>_.trim()).filter(Boolean),p=m.length>0&&!m.every(uf);return{priority:r,labels:l,acceptance:c,test_commands:f,has_summary:p}}function id(a,s){const r=String(a.task_type||"").trim().toLowerCase(),l=[{id:"type",label:`Work type is set (${Fa.join(" / ")})`,ok:Fa.includes(r),evidence:r?`type: ${r}`:"no type"},{id:"summary",label:"Summary describes the outcome (not the template placeholder)",ok:s.has_summary,evidence:s.has_summary?"summary present":"empty or template placeholder"},{id:"acceptance",label:"At least one acceptance criterion",ok:s.acceptance.length>0,evidence:s.acceptance.length?`found ${s.acceptance.length}: "${df(s.acceptance[0].text,60)}"${s.acceptance.length>1?", …":""}`:"none found under ## Acceptance Criteria"},{id:"tests",label:"At least one concrete test command (Testing A/B)",ok:s.test_commands.length>0,evidence:s.test_commands.length?`found ${s.test_commands.length}: \`${df(s.test_commands[0],60)}\``:"none found under ## Testing"}];return{ok:l.every(c=>c.ok),checks:l}}function df(a,s){const r=String(a||"");return r.length<=s?r:`${r.slice(0,Math.max(0,s-1))}…`}function Wu(a){const s=a;if(!s||s.status!==409)return null;const r=s.body,l=r&&typeof r=="object"&&r.detail&&typeof r.detail=="object"?r.detail:r;if(!l||l.error!=="definition_of_ready_failed")return null;const f=(Array.isArray(l.checks)?l.checks:Array.isArray(l.members)?l.members.flatMap(m=>(Array.isArray(m==null?void 0:m.checks)?m.checks:[]).map(p=>({...p,label:m!=null&&m.relpath?`${m.relpath}: ${String((p==null?void 0:p.label)||"")}`:p==null?void 0:p.label}))):[]).map(m=>({id:String((m==null?void 0:m.id)||""),label:String((m==null?void 0:m.label)||""),ok:(m==null?void 0:m.ok)===!0,evidence:m!=null&&m.evidence?String(m.evidence):void 0}));return f.length?{ok:f.every(m=>m.ok),checks:f}:null}function Hu(a,s){const l=[...String(a||"").split(/\r?\n/)];function c(f,m){const p=[];for(let y=0;y<Math.min(l.length,60);y+=1){const w=l[y].trim();if(/^##+\s/.test(w))break;f.test(w)&&p.push(y)}if(p.length){for(let y=p.length-1;y>=1;y-=1)l.splice(p[y],1);m?l[p[0]]=m:l.splice(p[0],1);return}if(!m)return;let _=-1;for(let y=0;y<Math.min(l.length,60);y+=1){const w=l[y].trim();if(w.startsWith("> ")&&(_=y),/^##\s/.test(w))break}if(_<0){const y=l.findIndex(w=>w.trim().startsWith("# "));if(y>=0)_=y;else{l.unshift(m);return}}l.splice(_+1,0,m)}return c(oh,s.priority?`> Priority: ${s.priority}`:null),c(ch,s.labels.length?`> Labels: ${s.labels.join(", ")}`:null),l.join(`
60
- `)}const mf=[{id:"triage",label:"Triage",hint:"Proposed — needs a decision (merge/advisor tooling lives on the Backlog page)"},{id:"ready",label:"Ready",hint:"Planned — executable. A ⚠ badge counts recent failed attempts."},{id:"in_progress",label:"In Progress",hint:"Queued/running executions + seat-claimed items (live hub pointer claims — the ⛏ chip names the owner)"},{id:"in_review",label:"In Review",hint:"Awaiting QA decision (receipts-posted seat work joins when the /work index is live)"},{id:"done",label:"Done",hint:"Recent promotions/completions (attempts). The full archive lives in Backlog → Completed."},{id:"failed",label:"Failed",hint:"Recent failed attempts (history) — the item itself stays executable in Ready"}];function Vu(a){const s=String(a||"").trim().toUpperCase();return $l.includes(s)?s:null}function Gu(a){return a.priority!==void 0||a.labels!==void 0}const hg="decision-gate";function pg(a){return Array.isArray(a)&&a.some(s=>String(s||"").trim().toLowerCase()===hg)}function uh(a,s){return pg(a.labels!==void 0?a.labels:s==null?void 0:s.labels)}function dh(a){return a.priority!==void 0||a.labels!==void 0}function Ku(a,s){return a.priority!==void 0?a.priority:(s==null?void 0:s.priority)??null}function Qu(a,s){return a.labels!==void 0?a.labels:(s==null?void 0:s.labels)??[]}const _g=new Set(["queued","running"]);function gg(a){const s=String(a||"").split("/").filter(Boolean);return s.length?s[s.length-1]:""}const vg=/^batch\((\d+)\)$/i;function ff(a){const s=vg.exec(String(a||"").trim());return s?Number(s[1]):null}function yg(a){const s=a.recent_limit??12,r=[],l=new Set;for(const w of a.active_items){const x=String(w.filename||"").trim();x&&l.add(x)}const c=(w,x,N)=>{const $=String(w.backlog_filename||"").trim()||gg(String(w.backlog_relpath||"")),P=ff($),T=P!==null?"":$;return T&&N&&l.add(T),{key:T&&N?`file:${T}`:`req:${w.request_id}`,column:x,title:P!==null?`Batch execution (${P} items)`:T||`Execution ${w.request_id.slice(0,8)}…`,filename:T||void 0,request_id:w.request_id,exec_status:String(w.status||"").trim().toLowerCase(),created_at:w.created_at??null,started_at:w.started_at??null,finished_at:w.finished_at??null,target_agent:w.target_agent??(w.target_model?`${String(w.executor_type||"agent").trim()||"agent"}:${w.target_model}`:null),batch_size:P!==null?P:void 0}};for(const w of a.active_requests){const x=String(w.status||"").trim().toLowerCase();_g.has(x)?r.push(c(w,"in_progress",!0)):x==="awaiting_qa"&&r.push(c(w,"in_review",!0))}const f=[...a.terminal_requests].sort((w,x)=>{const N=String(w.finished_at||w.started_at||w.created_at||"");return String(x.finished_at||x.started_at||x.created_at||"").localeCompare(N)}),m=new Map;let p=0,_=0;for(const w of f){const x=String(w.status||"").trim().toLowerCase();if(x==="failed"){const N=String(w.backlog_filename||"").trim();N&&ff(N)===null&&m.set(N,(m.get(N)||0)+1),_<s&&(r.push(c(w,"failed",!1)),_+=1)}else(x==="promoted"||x==="completed")&&p<s&&(r.push(c(w,"done",!1)),p+=1)}for(const w of a.planned){const x=String(w.filename||"").trim();!x||l.has(x)||r.push({key:`file:${x}`,column:"ready",title:w.title||x,kind:"planned",filename:x,item_id:w.item_id,package:w.package,task_type:w.task_type,summary:w.summary,recent_failures:m.get(x)||void 0,priority:Gu(w)?Vu(w.priority):void 0,labels:Array.isArray(w.labels)?w.labels:void 0})}for(const w of a.proposed){const x=String(w.filename||"").trim();!x||l.has(x)||r.push({key:`file:${x}`,column:"triage",title:w.title||x,kind:"proposed",filename:x,item_id:w.item_id,package:w.package,task_type:w.task_type,summary:w.summary,priority:Gu(w)?Vu(w.priority):void 0,labels:Array.isArray(w.labels)?w.labels:void 0})}const y=new Map;for(const w of[...a.planned,...a.proposed])y.set(String(w.filename||"").trim(),w);for(const w of r){if(!w.filename||w.kind)continue;const x=y.get(w.filename);x&&(w.title=x.title||w.title,w.item_id=x.item_id,w.package=x.package,w.task_type=x.task_type,w.summary=x.summary)}return r}const xg=200;function wg(a,s){var w;const{live:r,done:l}=s,c=s.work||new Map;if(!r.size&&!l.length&&!c.size)return a;const f=new Set,m=new Set;for(const x of a){if(!x.filename||!x.package)continue;const N=cf(x.package,x.filename);N&&m.add(N)}const p=a.map(x=>{if(x.column!=="ready"||x.kind!=="planned"||!x.filename||!x.package)return x;const N=cf(x.package,x.filename);if(!N)return x;const $=r.get(N);return!$||!$.owner?x:(f.add(N),{...x,column:"in_progress",work_id:N,claim_owner:$.owner,claim_started_at:$.started_at})}),_=new Map;p.forEach((x,N)=>{x.filename&&_.set(x.filename,N)});for(const[x,N]of c){const $=N.card?_.get(og(N.card)):void 0;if(m.has(x)||$!==void 0){if($!==void 0){const F=p[$],D={...F,work_id:F.work_id||x,card_path:F.card_path||N.card},J=r.get(x);J!=null&&J.owner&&(f.add(x),D.claim_owner||(D.claim_owner=J.owner,D.claim_started_at=J.started_at)),p[$]=D}continue}if(N.status==="deprecated")continue;const P=r.get(x),T=N.status==="completed"?"done":N.status==="planned"?P!=null&&P.owner?"in_progress":"ready":"triage";P!=null&&P.owner&&f.add(x),p.push({key:`work:${x}`,column:T,title:N.title||x,work_id:x,package:(w=Ds(x))==null?void 0:w.package,summary:N.receipt,card_path:N.card,claim_owner:(P==null?void 0:P.owner)||(N.status==="completed"?N.owner:void 0),claim_started_at:P==null?void 0:P.started_at})}for(const[x,N]of r){if(f.has(x)||!N.owner)continue;const $=Ds(x);p.push({key:`claim:${x}`,column:"in_progress",title:typeof N.task=="string"&&N.task?N.task:x,work_id:$?x:void 0,package:$==null?void 0:$.package,claim_owner:N.owner,claim_started_at:N.started_at})}const y=new Set(p.filter(x=>x.column==="done").map(x=>x.work_id).filter(Boolean));for(const x of l.slice(0,xg)){if(y.has(x.item))continue;const N=Ds(x.item);p.push({key:`claim-done:${x.item}`,column:"done",title:x.item,work_id:N?x.item:void 0,package:N==null?void 0:N.package,claim_owner:x.owner,summary:x.receipt})}return p}function El(a){const s=String((a==null?void 0:a.message)??a??"");return/backlog browsing not configured/i.test(s)}function ld(a){return e.jsxs("div",{className:"pane setup_callout",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Backlog browsing is not configured on this gateway"}),e.jsx("span",{className:"chip mono warn",children:"setup required"})]}),e.jsxs("div",{className:"pane_body",children:[e.jsxs("div",{style:{fontSize:"var(--font-size-md)"},children:["The gateway is reachable and you are signed in — but it is serving without a backlog root, so ",a.surface," has no data source. On the ",e.jsx("span",{className:"mono",children:"gateway host"}),", set:"]}),e.jsx("pre",{className:"mono setup_callout_pre",children:`ABSTRACTGATEWAY_TRIAGE_REPO_ROOT=/path/to/AbstractFramework # checkout root holding docs/backlog
61
- ABSTRACTGATEWAY_BACKLOG_EXEC_RUNNER=1 # optional: enables the exec worker`}),e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"…then restart the gateway. If it worked earlier today, the last gateway restart most likely dropped the env (launchers must export it). Details: docs/getting-started.md."})]})]})}function bg(a){return a.kind?[a.kind]:["completed","planned","proposed"]}function mh(a){const{gateway:s,can_use_gateway:r,target:l,on_close:c,on_mutated:f,on_open_executions:m}=a,p=!!l,[_,y]=h.useState("spec"),[w,x]=h.useState(""),[N,$]=h.useState(""),[P,T]=h.useState(null),[F,D]=h.useState(!1),[J,B]=h.useState(""),[ee,C]=h.useState(!1),[Z,ae]=h.useState(""),[fe,ge]=h.useState(!1),[Te,Se]=h.useState(""),[K,te]=h.useState(""),[z,V]=h.useState(!1),[H,ce]=h.useState([]),[I,_e]=h.useState(!1),[Y,S]=h.useState(null),[A,U]=h.useState(null),[ie,de]=h.useState(""),[L,ke]=h.useState(!1),[be,Ie]=h.useState(""),[Fe,Ye]=h.useState({}),he=h.useMemo(()=>yi(w),[w]);h.useEffect(()=>{!p||!l||(y(l.initial_tab||"spec"),C(!1),B(""),Ie(""),de(""),Ye({}),me(!1),S(null),U(null),T(null),Re(l),ze(l))},[p,l==null?void 0:l.filename,l==null?void 0:l.kind,l==null?void 0:l.request_id]);async function Re(le){if(!le.filename){x(""),$("");return}D(!0);try{let ye=null,Oe=null;for(const xt of bg(le))try{const pe=await s.backlog_content(xt,le.filename);ye={kind:xt,text:String((pe==null?void 0:pe.content)||"")};break}catch(pe){Oe=pe}if(!ye)throw Oe||new Error("Spec not found in any backlog kind");T(ye.kind),x(ye.text),$(await Uu(ye.text));const ot=yi(ye.text);Se(ot.priority||""),te(ot.labels.join(", "))}catch(ye){B(String((ye==null?void 0:ye.message)||ye||"Failed to load the spec"))}finally{D(!1)}}async function ze(le){_e(!0);try{const[ye,Oe]=await Promise.all([s.backlog_exec_requests({status:"queued,running,awaiting_qa",limit:200}),s.backlog_exec_requests({status:"promoted,completed,failed",limit:200})]),xt=[...Array.isArray(ye==null?void 0:ye.requests)?ye.requests:[],...Array.isArray(Oe==null?void 0:Oe.requests)?Oe.requests:[]].filter(R=>le.filename&&String(R.backlog_filename||"").trim()===le.filename||R.request_id===le.request_id);xt.sort((R,X)=>String(X.created_at||"").localeCompare(String(R.created_at||""))),ce(xt);const pe=xt.find(R=>String(R.status||"").toLowerCase()==="awaiting_qa")||null;if(S(pe),pe)try{const R=await s.backlog_exec_request(pe.request_id);U((R==null?void 0:R.payload)??null)}catch{U(null)}}catch{ce([])}finally{_e(!1)}}async function re(){if(!l||fe)return;const le=P||l.kind;if(le){ge(!0),B("");try{const ye=await s.backlog_update({kind:le,filename:l.filename,content:Z,expected_sha256:N||null}),Oe=Z.endsWith(`
62
- `)?Z:`${Z}
63
- `;x(Oe),$(String((ye==null?void 0:ye.sha256)||"")),C(!1),await f()}catch(ye){B(String((ye==null?void 0:ye.message)||ye||"Save failed"))}finally{ge(!1)}}}async function xe(){if(!l||z)return;const le=P||l.kind;if(le){V(!0),B("");try{const ye=Hu(w,{priority:Te||null,labels:rd(K)}),Oe=await s.backlog_update({kind:le,filename:l.filename,content:ye,expected_sha256:N||null});x(ye.endsWith(`
64
- `)?ye:`${ye}
65
- `),$(String((Oe==null?void 0:Oe.sha256)||"")),await f()}catch(ye){B(String((ye==null?void 0:ye.message)||ye||"Metadata save failed"))}finally{V(!1)}}}const[O,me]=h.useState(!1);async function De(le){if(!(!Y||L)){if(le==="feedback"&&!ie.trim()){Ie("Feedback is required.");return}ke(!0),Ie("");try{le==="feedback"?await s.backlog_exec_feedback({request_id:Y.request_id,feedback:ie}):le==="promote"?await s.backlog_exec_promote({request_id:Y.request_id,redeploy:!0}):await s.backlog_exec_deploy_uat({request_id:Y.request_id}),de(""),me(!1),l&&await ze(l),await f()}catch(ye){Ie(String((ye==null?void 0:ye.message)||ye||"QA action failed"));try{const Oe=await s.backlog_exec_request(Y.request_id);U((Oe==null?void 0:Oe.payload)??null)}catch{}}finally{ke(!1)}}}if(!p||!l)return null;const G=he.acceptance.filter((le,ye)=>!Fe[`${ye}:${le.text}`]).length;return e.jsx("div",{className:"drawer_backdrop",onMouseDown:le=>{le.target===le.currentTarget&&c()},children:e.jsxs("div",{className:"drawer_panel work_drawer",children:[e.jsxs("div",{className:"drawer_header",children:[e.jsxs("div",{className:"col",style:{gap:2,minWidth:0},children:[e.jsx("div",{className:"drawer_title",title:l.filename,children:l.title}),e.jsxs("div",{className:"mono muted",style:{fontSize:"var(--font-size-xs)"},children:[P||l.kind||"locating…",l.filename?` • ${l.filename}`:""]})]}),e.jsxs("div",{className:"row",style:{gap:8,justifyContent:"flex-end"},children:[l.filename?e.jsx("button",{className:"btn",onClick:()=>yn(`docs/backlog/${P||l.kind||"planned"}/${l.filename}`),title:"Copy repo path",children:"Copy path"}):null,e.jsx("button",{className:"btn",onClick:c,children:"Close"})]})]}),e.jsxs("div",{className:"tab_bar work_drawer_tabs",children:[e.jsx("button",{className:`tab ${_==="spec"?"active":""}`,onClick:()=>y("spec"),children:"Spec"}),e.jsxs("button",{className:`tab ${_==="runs"?"active":""}`,onClick:()=>y("runs"),children:["Runs ",H.length?`(${H.length})`:""]}),e.jsxs("button",{className:`tab ${_==="review"?"active":""}`,onClick:()=>y("review"),children:["Review",Y?" ●":""]})]}),e.jsxs("div",{className:"drawer_body work_drawer_body",children:[J?e.jsx("div",{className:"mono board_error",children:J}):null,_==="spec"?e.jsxs(e.Fragment,{children:[l.has_live_request?e.jsx("div",{className:"mono",style:{color:"rgb(250, 204, 21)",fontSize:"var(--font-size-sm)",marginBottom:"8px"},children:"An execution holds a queue-time snapshot of this spec — edits here will NOT reach the running agent; they apply to the next run (and QA iterations re-run from the snapshot plus your feedback)."}):null,l.filename?e.jsxs("div",{className:"work_meta_editor",children:[e.jsxs("select",{value:Te,onChange:le=>Se(le.target.value),disabled:z,title:"Priority",children:[e.jsx("option",{value:"",children:"priority: unset"}),$l.map(le=>e.jsx("option",{value:le,children:lh[le]},le))]}),e.jsx("input",{value:K,onChange:le=>te(le.target.value),placeholder:"labels (comma-separated; sprints: sprint-29)",disabled:z}),e.jsx("button",{className:"btn",onClick:()=>void xe(),disabled:z||!r||F,children:z?"Saving…":"Save metadata"}),ee?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:()=>C(!1),disabled:fe,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:()=>void re(),disabled:fe,children:fe?"Saving…":"Save spec"})]}):e.jsx("button",{className:"btn",onClick:()=>{ae(w),C(!0)},disabled:F,children:"Edit spec"})]}):null,F?e.jsx("div",{className:"mono muted",children:"Loading…"}):ee?e.jsx("textarea",{className:"mono work_spec_editor",value:Z,onChange:le=>ae(le.target.value),rows:24}):w?e.jsxs(e.Fragment,{children:[e.jsx(as,{className:"md_doc",text:w}),e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-xs)",marginTop:"10px"},children:"Deep tooling (maintenance AI chat, attachments, advisor) lives on the Backlog page."})]}):e.jsx("div",{className:"mono muted",children:"No spec file for this card (batch execution). See Runs."})]}):null,_==="runs"?e.jsxs(e.Fragment,{children:[I?e.jsx("div",{className:"mono muted",children:"Loading…"}):null,!I&&!H.length?e.jsx("div",{className:"mono muted",children:"No executions for this item in recent history (window: live + last 200 finished)."}):null,H.map(le=>{const ye=String(le.status||"").toLowerCase(),Oe=Cl(le);return e.jsxs("div",{className:"work_run_row",children:[e.jsx("span",{className:`chip mono ${kl(ye)}`,children:ye}),e.jsx("span",{className:"mono muted",children:fa(le.request_id,18)}),e.jsx("span",{className:"mono muted",children:le.created_at?new Date(le.created_at).toLocaleString():""}),e.jsx("span",{className:"mono muted",children:Oe.run_ms!=null?`ran ${Os(Oe.run_ms)}`:""}),le.target_agent?e.jsx("span",{className:"chip mono muted",children:le.target_agent}):null,ye==="running"||ye==="queued"||ye==="awaiting_qa"?e.jsx("button",{className:"btn",onClick:()=>m(le.request_id),children:ye==="awaiting_qa"?"View logs":"Follow live"}):null]},le.request_id)})]}):null,_==="review"?Y?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"section_title",style:{marginTop:0},children:"Definition of Done — acceptance criteria"}),e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-xs)",marginBottom:"6px"},children:"Criteria come from the current spec file; if the agent refined them inside the candidate, review against the candidate patch too. Ticks live in this drawer session only."}),he.acceptance.length?e.jsx("div",{className:"work_dod_list",children:he.acceptance.map((le,ye)=>e.jsxs("label",{className:"work_dod_item",children:[e.jsx("input",{type:"checkbox",checked:!!Fe[`${ye}:${le.text}`],onChange:Oe=>Ye(ot=>({...ot,[`${ye}:${le.text}`]:Oe.target.checked}))}),e.jsx("span",{children:le.text})]},`dod:${ye}:${le.text}`))}):e.jsx("div",{className:"mono muted",children:"This spec declares no acceptance criteria — review against the diff and logs."}),(()=>{const le=String((A==null?void 0:A.execution_mode)||"uat").toLowerCase(),ye=String((A==null?void 0:A.candidate_relpath)||"").trim(),Oe=A==null?void 0:A.promotion_report,ot=!!(Oe!=null&&Oe.blocked);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"row",style:{alignItems:"center",gap:"10px",flexWrap:"wrap",marginTop:"8px"},children:[e.jsxs("span",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:["mode: ",le,ye?` • candidate: ${ye}`:""]}),e.jsx("button",{className:"btn",onClick:()=>m(Y.request_id),title:"Open this run's logs and events in Executions",children:"View run logs"})]}),ot?e.jsxs("div",{className:"mono board_error",style:{marginTop:"6px"},children:["Promotion blocked: ",String((Oe==null?void 0:Oe.reason)||"conflicts")," — iterate on top of current prod or resolve manually."]}):null]})})(),he.acceptance.length&&G>0?e.jsxs("div",{className:"mono",style:{color:"rgb(250, 204, 21)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:[G," acceptance criteri",G===1?"on":"a"," unconfirmed — promoting anyway is an override."]}):null,e.jsx("textarea",{value:ie,onChange:le=>de(le.target.value),rows:3,placeholder:"QA feedback (what to change / fix)…",style:{width:"100%",marginTop:"10px"},disabled:L}),be?e.jsx("div",{className:"mono board_error",children:be}):null,e.jsxs("div",{className:"row",style:{gap:8,marginTop:"10px",flexWrap:"wrap",alignItems:"center"},children:[e.jsx("button",{className:"btn",onClick:()=>void De("deploy_uat"),disabled:L,children:"Restart UAT"}),O?e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"btn danger",onClick:()=>void De("promote"),disabled:L,children:["Confirm: promote to prod",G>0?` (${G} unconfirmed)`:""," + redeploy"]}),e.jsx("button",{className:"btn",onClick:()=>me(!1),disabled:L,children:"Cancel"})]}):e.jsx("button",{className:"btn primary",onClick:()=>me(!0),disabled:L,children:he.acceptance.length&&G>0?"Promote (override)…":"Approve → promote…"}),e.jsx("button",{className:"btn",onClick:()=>void De("feedback"),disabled:L,children:"Iterate (send feedback)"})]})]}):e.jsx("div",{className:"mono muted",children:"Nothing awaiting review for this item."}):null]})]})})}function Nr(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`id_${Date.now()}_${Math.random().toString(16).slice(2)}`}function jg(a){const{gateway:s,can_use_gateway:r,is_compact_layout:l,maint_provider:c,maint_model:f,maint_reasoning:m,advisor_agent:p,focus_kind:_,focus_type:y}=a,[w,x]=h.useState(!1),[N,$]=h.useState([]),[P,T]=h.useState(""),[F,D]=h.useState(!1),[J,B]=h.useState(""),[ee,C]=h.useState(!1),[Z,ae]=h.useState([]),fe=h.useRef(null),ge=h.useRef(null),Te=String(a.voice_session_id||"").trim()||"abstractcontinuum_backlog_advisor",[Se,K]=h.useState(""),[te,z]=h.useState("");h.useEffect(()=>{(async()=>{try{const A=await ad(Te);K(A)}catch{K("")}})()},[Te]);const V=h.useMemo(()=>{if(!r)return{};const A=String(Se||"").trim(),U=Te;return{tts:async ie=>{if(!A)throw new Error("Voice store not available (missing run_id).");const de=await s.voice_tts(A,{text:ie,request_id:Nr()}),L=de==null?void 0:de.audio_artifact,ke=L&&typeof L=="object"&&!Array.isArray(L)?String(L.$artifact||"").trim():"";if(!ke)throw new Error("TTS failed: missing audio artifact");return await(await s.download_run_artifact_content(A,ke)).arrayBuffer()},transcribe:async(ie,de)=>{if(!A)throw new Error("Voice input unavailable (missing run_id).");const L=String(de||ie.type||"").toLowerCase(),ke=L.includes("mp4")?"m4a":L.includes("ogg")?"ogg":L.includes("wav")?"wav":"webm",be=new File([ie],`recording.${ke}`,{type:L||"audio/webm"}),Ie=await s.attachments_upload(U,be,{filename:be.name,content_type:be.type}),Fe=await s.audio_transcribe(A,{audio_artifact:Ie,request_id:Nr()});return String((Fe==null?void 0:Fe.text)||"").trim()}}},[r,s,Se,Te]),H=Hf({...V,on_error:z,on_transcript:A=>{const U=String(A||"").trim();U&&(T(ie=>{const de=String(ie||"");return de.trim()?`${de.trimEnd()}
66
- ${U}`:U}),window.setTimeout(()=>{var ie;return(ie=fe.current)==null?void 0:ie.focus()},0))}});h.useEffect(()=>{if(!w)return;const A=U=>{U.key==="Escape"&&(S(),x(!1))};return window.addEventListener("keydown",A),setTimeout(()=>{var U;return(U=fe.current)==null?void 0:U.focus()},0),()=>window.removeEventListener("keydown",A)},[w]);async function ce(){if(F||!r)return;if(H.voice_ptt_busy){z("Wait for transcription to finish.");return}B(""),z("");const A=P.trim();if(!A)return;const U={id:Nr(),role:"user",content:A,ts:new Date().toISOString()},ie=[...N,U];$(ie),T(""),D(!0);try{const de=await s.backlog_advisor({messages:ie.map(Ie=>({role:Ie.role,content:Ie.content})),provider:c||null,model:f||null,thinking:m||null,agent:p||null,include_trace:ee,focus_kind:_,focus_type:y}),L=ee&&Array.isArray(de==null?void 0:de.tool_trace)?de.tool_trace:[],ke=String((de==null?void 0:de.run_id)||"").trim(),be=String((de==null?void 0:de.reply)||"").trim();if(ee&&L.length){const Ie={id:Nr(),role:"system",title:"Tool execution",level:"info",ts:new Date().toISOString(),content:JSON.stringify({run_id:ke||null,tool_trace:L},null,2)};$(Fe=>[...Fe,Ie])}be&&$(Ie=>[...Ie,{id:Nr(),role:"assistant",content:be,ts:new Date().toISOString()}])}catch(de){B(String((de==null?void 0:de.message)||de||"Backlog advisor failed"))}finally{D(!1)}}async function I(A){var be;const U=Array.from(A||[]);if(!U.length)return;const ie=[],de=[],L=6,ke=2e4;for(const Ie of U.slice(0,L)){const Fe=String((Ie==null?void 0:Ie.name)||"").trim()||"attachment";de.push(Fe);try{const Ye=await Ie.text(),he=Ye.length>ke?`${Ye.slice(0,ke)}
67
- …(truncated)…
68
- `:Ye;ie.push(`[attached file: ${Fe}]
69
-
70
- \`\`\`
71
- ${he}
72
- \`\`\``)}catch{ie.push(`[attached file: ${Fe}] (unreadable in browser)`)}}ae(Ie=>[...de,...Ie].slice(0,12)),T(Ie=>{const Fe=String(Ie||"").trim(),Ye=ie.join(`
73
-
74
- `);return Fe?`${Fe}
75
-
76
- ${Ye}`:Ye});try{(be=fe.current)==null||be.focus()}catch{}}function _e(A){const U=String(A.id||A.ts||"").trim(),ie=String(A.content||"").trim();!U||!ie||(z(""),H.toggle_tts(U,ie))}function Y(A){const U=String(A.id||A.ts||"").trim(),ie=H.tts_playback;return!U||!ie.key||ie.key!==U?"idle":ie.status}function S(){H.stop_voice_ptt_recording(),H.stop_tts()}return e.jsxs(e.Fragment,{children:[e.jsx("button",{className:`advisor_toggle ${w?"open":""}`,onClick:()=>{x(A=>{const U=!A;return U||S(),U})},title:"Open backlog advisor (read-only)","aria-label":"Open backlog advisor",children:e.jsx("span",{className:"advisor_toggle_label",children:"Advisor"})}),w?e.jsx("div",{className:"drawer_backdrop",onMouseDown:A=>{A.target===A.currentTarget&&(S(),x(!1))},children:e.jsxs("div",{className:"drawer_panel",children:[e.jsxs("div",{className:"drawer_header",children:[e.jsxs("div",{className:"col",style:{gap:2},children:[e.jsx("div",{className:"drawer_title",children:"Backlog advisor"}),e.jsxs("div",{className:"mono muted",style:{fontSize:"var(--font-size-xs)"},children:["Read-only. Agent: ",p||"basic-agent"," • Using: ",c||"(gateway default)"," / ",f||"(gateway default)"]})]}),e.jsxs("div",{className:"row",style:{gap:8,justifyContent:"flex-end"},children:[e.jsxs("button",{className:`btn btn_icon ${ee?"primary":""}`,onClick:()=>C(A=>!A),disabled:F,title:ee?"Hide tool execution":"Show tool execution","aria-label":ee?"Hide tool execution":"Show tool execution",children:[e.jsx(st,{name:"terminal",size:16}),l?null:ee?"Tools on":"Tools"]}),e.jsx("button",{className:"btn",onClick:()=>$([]),disabled:F||!N.length,children:"Clear"}),e.jsx("button",{className:"btn",onClick:()=>{S(),x(!1)},children:"Close"})]})]}),e.jsxs("div",{className:"drawer_body",children:[e.jsx(sd,{messages:N,className:"drawer_chat_thread",messageProps:H.tts_supported&&r&&Se.trim()?{onSpeakToggle:_e,getSpeakState:Y,jsonCollapseAfterDepth:4}:{jsonCollapseAfterDepth:4},empty:e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Ask about the backlog, e.g. “What are the top 5 planned items to focus on next and why?”"})}),e.jsxs("div",{className:"drawer_footer",children:[e.jsx("input",{ref:ge,type:"file",multiple:!0,style:{display:"none"},onChange:A=>{const U=Array.from(A.currentTarget.files||[]);A.currentTarget.value="",U.length&&I(U)}}),e.jsx(Xo,{ref:fe,value:P,onChange:T,onSubmit:()=>void ce(),placeholder:"Message to backlog advisor…",disabled:!r,busy:F||H.voice_ptt_busy,rows:3,sendButtonClassName:"btn primary",busyLabel:H.voice_ptt_busy?"Transcribing…":"Thinking…",actions:e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:`btn btn_icon voice_btn${H.voice_ptt_recording?" danger":""}`,type:"button",disabled:!r||!Se.trim()||F||H.voice_ptt_busy||!H.voice_ptt_supported,title:H.voice_ptt_supported?H.voice_ptt_busy?"Transcribing…":H.voice_ptt_recording?"Recording… release to transcribe":"Hold to talk (record + transcribe)":"Voice recording is not supported in this browser","aria-label":"Voice input",onPointerDown:A=>{var U,ie;if(!(!r||!Se.trim()||F||H.voice_ptt_busy||!H.voice_ptt_supported)){A.preventDefault();try{(ie=(U=A.currentTarget)==null?void 0:U.setPointerCapture)==null||ie.call(U,A.pointerId)}catch{}H.start_voice_ptt_recording()}},onPointerUp:A=>{A.preventDefault(),H.stop_voice_ptt_recording()},onPointerCancel:A=>{A.preventDefault(),H.stop_voice_ptt_recording()},children:[e.jsx(st,{name:H.voice_ptt_recording?"x":"mic",size:16}),l?null:H.voice_ptt_busy?"Transcribing…":H.voice_ptt_recording?"Recording…":"Voice"]}),e.jsxs("button",{className:"btn btn_icon",type:"button",onClick:()=>{var A;return(A=ge.current)==null?void 0:A.click()},disabled:F,title:"Attach a local file to your message","aria-label":"Attach file",children:[e.jsx(st,{name:"paperclip",size:16}),l?null:"Attach"]})]})}),Z.length?e.jsxs("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"6px"},children:["Last attached: ",Z[0]]}):null,J?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:J}):null,te?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:te}):null,r?null:e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:"Connect the gateway in Settings to use the advisor."})]})]})]})}):null]})}function qa({open:a,title:s,children:r,actions:l,variant:c="default",onClose:f}){if(h.useEffect(()=>{if(!a)return;const p=_=>{_.key==="Escape"&&f()};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[a,f]),!a)return null;const m=c==="fullscreen";return e.jsx("div",{className:`modal_backdrop${m?" fullscreen":""}`,onMouseDown:p=>{p.target===p.currentTarget&&f()},children:e.jsxs("div",{className:`modal_panel${m?" fullscreen":""}`,children:[e.jsxs("div",{className:"modal_header",children:[e.jsx("div",{className:"modal_title",children:s}),e.jsx("button",{className:"btn",onClick:f,children:"Close"})]}),e.jsx("div",{className:"modal_body",children:r}),l?e.jsx("div",{className:"modal_footer",children:l}):null]})})}function kg(a){const{readiness:s,server_refused:r,on_open_spec:l}=a;return s?e.jsxs("div",{style:{marginTop:"10px"},children:[e.jsxs("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginBottom:"6px"},children:["Definition of Ready"," ",e.jsx("span",{style:{opacity:.7},children:r?"(the gateway refused this execute — server-evaluated checks below)":"(advisory — parsed from the spec)"})]}),s.checks.map(c=>e.jsxs("div",{className:"mono",style:{fontSize:"var(--font-size-sm)",color:c.ok?"rgb(74, 222, 128)":"rgb(250, 204, 21)"},children:[c.ok?"✓":"○"," ",c.label,c.evidence?e.jsxs("span",{style:{opacity:.75},children:[" — ",c.evidence]}):null]},c.id)),s.ok?null:e.jsxs("div",{className:"row",style:{alignItems:"center",gap:"10px",marginTop:"6px",flexWrap:"wrap"},children:[e.jsx("span",{className:"mono",style:{color:"rgb(250, 204, 21)",fontSize:"var(--font-size-sm)"},children:"This spec is not ready — executing anyway is an override."}),l?e.jsx("button",{className:"btn",type:"button",onClick:l,children:"Open spec to fix"}):null]})]}):e.jsx("div",{style:{marginTop:"10px"},children:e.jsx("div",{className:"mono",style:{color:"rgb(250, 204, 21)",fontSize:"var(--font-size-sm)"},children:"Definition of Ready: NOT EVALUATED — the spec could not be scanned. The server gate still checks on execute."})})}function fh(a){const{exec_cfg:s,with_setup:r}=a,l=["ABSTRACTGATEWAY_BACKLOG_EXEC_RUNNER=1 # or: Settings → Gateway administration → Enable","ABSTRACTGATEWAY_BACKLOG_EXECUTOR=codex # canonical: codex | claude | cursor-agent | abstractcode"];return e.jsxs("div",{style:{marginTop:"10px"},children:[e.jsx("div",{className:"detail_warn",style:{marginTop:0},children:(s==null?void 0:s.runner_enabled)!==!0?"Backlog exec runner is disabled on this gateway — admins can enable it live from Settings → Gateway administration.":(s==null?void 0:s.runner_alive)===!1?"Backlog exec runner is not running on this gateway.":(s==null?void 0:s.codex_available)===!1?`The configured executor is not available on the gateway host (${String((s==null?void 0:s.codex_bin)||(s==null?void 0:s.executor)||"binary")} not found).`:"Backlog exec is not available on this gateway."}),s!=null&&s.runner_error?e.jsx("div",{className:"detail_hint",children:s.runner_error}):null,r?e.jsxs("details",{style:{marginTop:"8px"},children:[e.jsx("summary",{className:"muted",style:{fontSize:"var(--font-size-sm)",cursor:"pointer"},children:"Setup without the admin surface (env + restart)"}),e.jsxs("div",{style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:[e.jsx("pre",{className:"mono setup_callout_pre",style:{marginTop:0},children:l.join(`
77
- `)}),e.jsx("button",{className:"btn",style:{marginTop:"4px"},onClick:()=>yn(l.join(`
78
- `)),children:"Copy setup"})]})]}):null]})}function hh(a){const{value:s,onChange:r,disabled:l,inplace_warning:c,uat_note:f}=a;return e.jsxs("div",{style:{marginTop:"10px"},children:[e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginBottom:"6px"},children:"Execution mode"}),e.jsxs("select",{className:"input",value:s,onChange:m=>r(m.target.value),disabled:l,style:{width:"100%"},children:[e.jsx("option",{value:"uat",children:"UAT (staged, safe)"}),e.jsx("option",{value:"inplace",children:"Inplace (dangerous, edits prod)"})]}),s==="inplace"?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:c}):e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:f})]})}const Sg=["minimal","low","medium","high"];function ph(a){const{executors:s,value:r,onChange:l,disabled:c}=a;if(!s||!s.length)return null;const f=s.find(m=>m.default);return e.jsxs("div",{style:{marginTop:"10px"},children:[e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginBottom:"6px"},children:"Execution agent"}),e.jsxs("select",{className:"input",value:r,onChange:m=>l(m.target.value),disabled:c,style:{width:"100%"},children:[e.jsxs("option",{value:"",children:["gateway default",f?` (${f.display||f.id})`:""]}),s.map(m=>e.jsxs("option",{value:m.id,disabled:m.available===!1,children:[m.display||m.id,m.available===!1?" (unavailable on the gateway host)":""]},m.id))]})]})}function Ng(a){const{exec_cfg:s,model:r,set_model:l,effort:c,set_effort:f,disabled:m}=a;return e.jsxs("details",{style:{marginTop:"8px"},open:!!(r||c),children:[e.jsx("summary",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",cursor:"pointer"},children:"Assign a different agent (operator override)"}),e.jsxs("div",{className:"row",style:{gap:"10px",flexWrap:"wrap",marginTop:"8px"},children:[e.jsx("div",{className:"col",style:{minWidth:200},children:e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Model"}),e.jsx("input",{value:r,onChange:p=>l(p.target.value),placeholder:String((s==null?void 0:s.codex_model)||"gateway default"),disabled:m})]})}),e.jsx("div",{className:"col",style:{minWidth:160},children:e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Reasoning effort"}),e.jsxs("select",{value:c,onChange:p=>f(p.target.value),disabled:m,children:[e.jsx("option",{value:"",children:"gateway default"}),Sg.map(p=>e.jsx("option",{value:p,children:p},p))]})]})})]}),e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"4px"},children:"Overrides validate against the gateway's model allowlist; a refusal is shown verbatim below."})]})}function _h(a){const{open:s,target:r,execute_mode:l,set_execute_mode:c,action_loading:f,action_error:m,exec_cfg:p,exec_cfg_loading:_,exec_cfg_error:y,on_confirm:w,on_close:x}=a,N=a.readiness??null,$=a.show_readiness===!0,[P,T]=Gt.useState(""),[F,D]=Gt.useState(""),[J,B]=Gt.useState(""),ee=(r==null?void 0:r.filename)||"";Gt.useEffect(()=>{T(""),D(""),B("")},[ee]);const C=P.trim()||F||J?{executor:J||void 0,target_model:P.trim()||void 0,target_reasoning_effort:F||void 0}:void 0;return e.jsxs(qa,{open:s,title:"Execute backlog item?",onClose:x,actions:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:x,disabled:f,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:()=>w(C),disabled:f||_||!r||(p==null?void 0:p.can_execute)!==!0,children:f?"Executing…":$&&!N?"Execute (readiness unknown)":N&&!N.ok?"Execute anyway (override)":"Execute"})]}),children:[e.jsxs("div",{className:"mono",style:{fontSize:"var(--font-size-sm)"},children:["Target:"," ",e.jsx("span",{className:"mono",style:{fontWeight:700},children:r?r.title:"(unknown)"})]}),p?e.jsxs("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"6px"},children:["Agent: ",String(p.executor||"executor"),p.codex_model?` · ${p.codex_model}`:"",p.codex_reasoning_effort?` (reasoning ${p.codex_reasoning_effort})`:""]}):null,e.jsx(ph,{executors:a.executors??null,value:J,onChange:B,disabled:f}),e.jsx(Ng,{exec_cfg:p,model:P,set_model:T,effort:F,set_effort:D,disabled:f}),$?e.jsx(kg,{readiness:N,server_refused:a.server_refused,on_open_spec:a.on_open_spec}):null,e.jsx(hh,{value:l,onChange:c,disabled:f,inplace_warning:"Warning: inplace runs directly in the prod workspace. Use only when you understand the risk.",uat_note:"The run will execute in a candidate workspace. When it reaches “awaiting QA”, click “Restart UAT” to deploy it to the shared UAT stack. After you promote or iterate, UAT services are stopped automatically."}),_?e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"10px"},children:"Checking worker…"}):null,!_&&(p==null?void 0:p.can_execute)!==!0?e.jsx(fh,{exec_cfg:p,with_setup:!0}):null,y?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"10px"},children:y}):null,m?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"10px"},children:m}):null]})}function Cg(a){const{open:s,batch_selected_items:r,batch_execute_mode:l,set_batch_execute_mode:c,batch_execute_loading:f,batch_execute_error:m,exec_cfg:p,exec_cfg_loading:_,exec_cfg_error:y,on_confirm:w,on_close:x}=a,[N,$]=Gt.useState("");return Gt.useEffect(()=>{s||$("")},[s]),e.jsxs(qa,{open:s,title:"Execute batch (single context)?",onClose:x,actions:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:x,disabled:f,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:()=>w(N||void 0),disabled:f||_||r.length<2||(p==null?void 0:p.can_execute)!==!0,children:f?"Executing…":"Execute batch"})]}),children:[e.jsxs("div",{className:"mono",style:{fontSize:"var(--font-size-sm)"},children:["Items:"," ",e.jsx("span",{className:"mono",style:{fontWeight:700},children:r.length})]}),e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:"This queues a single exec request whose prompt includes all selected backlog items (in order), so the agent keeps a shared growing context."}),e.jsx(ph,{executors:a.executors??null,value:N,onChange:$,disabled:f}),e.jsx(hh,{value:l,onChange:c,disabled:f,inplace_warning:"Warning: inplace runs directly in the prod workspace (for the entire batch). Use only when you understand the risk.",uat_note:"The batch will execute in a candidate workspace. When it reaches “awaiting QA”, click “Restart UAT” to deploy it to the shared UAT stack. After you promote or iterate, UAT services are stopped automatically."}),r.length?e.jsx("div",{className:"mono",style:{fontSize:"var(--font-size-sm)",marginTop:"10px"},children:r.map(P=>e.jsxs("div",{children:["- docs/backlog/planned/",P.filename]},`batchitem:${P.filename}`))}):null,_?e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"10px"},children:"Checking worker…"}):null,!_&&(p==null?void 0:p.can_execute)!==!0?e.jsx(fh,{exec_cfg:p}):null,y?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"10px"},children:y}):null,m?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"10px"},children:m}):null]})}function $g(a){const{open:s,batch_selected_items:r,merge_package:l,set_merge_package:c,merge_task_type:f,set_merge_task_type:m,merge_title:p,set_merge_title:_,merge_summary:y,set_merge_summary:w,merge_loading:x,merge_error:N,on_confirm:$,on_close:P}=a;return e.jsxs(qa,{open:s,title:"Merge planned items into master backlog?",onClose:P,actions:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:P,disabled:x,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:$,disabled:x||r.length<2||!p.trim()||!l.trim(),children:x?"Merging…":"Create master"})]}),children:[e.jsxs("div",{className:"row",style:{gap:"10px",flexWrap:"wrap"},children:[e.jsx("div",{className:"col",style:{minWidth:220},children:e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Package"}),e.jsx("input",{value:l,onChange:T=>c(T.target.value),placeholder:"framework"})]})}),e.jsx("div",{className:"col",style:{minWidth:220},children:e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Type"}),e.jsx("select",{value:f,onChange:T=>m(T.target.value),children:Fa.map(T=>e.jsx("option",{value:T,children:T},T))})]})})]}),e.jsxs("div",{className:"field",style:{marginTop:"10px"},children:[e.jsx("label",{children:"Title"}),e.jsx("input",{value:p,onChange:T=>_(T.target.value),placeholder:"Master backlog"})]}),e.jsxs("div",{className:"field",style:{marginTop:"10px"},children:[e.jsx("label",{children:"Summary (optional)"}),e.jsx("textarea",{value:y,onChange:T=>w(T.target.value),rows:3})]}),r.length?e.jsxs("div",{style:{marginTop:"10px"},children:[e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Referenced backlog items:"}),e.jsx("div",{className:"mono",style:{fontSize:"var(--font-size-sm)",marginTop:"6px"},children:r.map(T=>e.jsxs("div",{children:["- docs/backlog/planned/",T.filename]},`mergeitem:${T.filename}`))})]}):null,N?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"10px"},children:N}):null]})}function od(a){const s=()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(a).matches,[r,l]=h.useState(s);return h.useEffect(()=>{var m;if(typeof window>"u"||typeof window.matchMedia!="function")return;const c=window.matchMedia(a),f=()=>l(c.matches);return f(),typeof c.addEventListener=="function"?c.addEventListener("change",f):(m=c.addListener)==null||m.call(c,f),()=>{var p;typeof c.removeEventListener=="function"?c.removeEventListener("change",f):(p=c.removeListener)==null||p.call(c,f)}},[a]),r}function gh(a,s){const[r,l]=h.useState(null);return h.useEffect(()=>{if(!s){l(null);return}let c=!1;return(async()=>{try{const f=await a.admin_executors(),m=Array.isArray(f)?f:Array.isArray(f==null?void 0:f.executors)?f.executors:[];c||l(m)}catch{c||l(null)}})(),()=>{c=!0}},[s]),r}function cd(a){const{gateway:s,can_use_gateway:r,kind:l,completed_view:c,is_exec_view:f,is_compact_layout:m,set_compact_pane:p,on_status_transfer:_}=a,[y,w]=h.useState(null),[x,N]=h.useState(!1),[$,P]=h.useState(""),[T,F]=h.useState([]),[D,J]=h.useState(!1),[B,ee]=h.useState(""),[C,Z]=h.useState(null),[ae,fe]=h.useState(null),[ge,Te]=h.useState(!1),[Se,K]=h.useState(""),[te,z]=h.useState(""),[V,H]=h.useState(!1),[ce,I]=h.useState(""),[_e,Y]=h.useState("events"),[S,A]=h.useState(""),[U,ie]=h.useState(!1),[de,L]=h.useState(""),[ke,be]=h.useState(!1),[Ie,Fe]=h.useState(!0),Ye=h.useRef(null),he=h.useRef(!0),Re=h.useRef(null),ze=h.useRef(!1),re=h.useRef(!1),xe=1e6,O=h.useMemo(()=>_e!=="events"?null:Z_(S),[S,_e]),me=h.useMemo(()=>eg(O),[O]),De=Cl(C);function G(){Z(null),fe(null),K(""),A(""),L(""),be(!1),Re.current=null}async function le(){if(!r)return null;if(x)return y;P(""),N(!0);try{const X=await s.backlog_exec_config();return w(X),X}catch(X){const $e=String((X==null?void 0:X.message)||X||"Failed to load backlog exec config");return P($e),w(null),null}finally{N(!1)}}async function ye(X,$e,Ae){if(re.current)return T;re.current=!0,Ae!=null&&Ae.background||J(!0);const Ge=X||l;try{const et=Y_(Ge,$e||c),ct=await s.backlog_exec_requests({status:et,limit:200}),wt=Array.isArray(ct==null?void 0:ct.requests)?ct.requests:[];ee(""),F(wt);const pt=String((C==null?void 0:C.status)||"").trim().toLowerCase(),Ut=pt==="failed"||pt==="completed"||pt==="promoted";if(Ge==="processing"&&(C!=null&&C.request_id)&&!Ut&&!wt.some(Dt=>Dt.request_id===C.request_id))try{const Dt=await s.backlog_exec_request(C.request_id),Le=Dt==null?void 0:Dt.payload,rt=String((Le==null?void 0:Le.status)||"").trim().toLowerCase();(rt==="failed"||rt==="completed"||rt==="promoted")&&(_(rt),fe(Le),Z(pl(Le,C.request_id)))}catch{}if(C!=null&&C.request_id){const Dt=wt.find(Le=>Le.request_id===C.request_id)||null;Dt&&Z(Dt)}return wt}catch(et){return ee(String((et==null?void 0:et.message)||et||"Failed to load backlog exec requests")),[]}finally{re.current=!1,Ae!=null&&Ae.background||J(!1)}}async function Oe(X){if(r){Z(X),m&&p("detail"),fe(null),K(""),Te(!0),I(""),z(""),A(""),L(""),be(!1),Re.current=null;try{const $e=await s.backlog_exec_request(X.request_id);fe(($e==null?void 0:$e.payload)??null)}catch($e){K(String(($e==null?void 0:$e.message)||$e||"Failed to load request"))}finally{Te(!1)}}}async function ot(X){if(!r)return;const $e=String((C==null?void 0:C.request_id)||"").trim();if(!$e||V)return;const Ae=String(te||"");if(!Ae.trim()){I("Feedback is required.");return}I(""),H(!0);try{const Ge=await s.backlog_exec_feedback({request_id:$e,feedback:Ae}),et=(Ge==null?void 0:Ge.payload)??null;fe(et),et&&Z(pl(et,$e)),z(""),await X()}catch(Ge){I(String((Ge==null?void 0:Ge.message)||Ge||"Failed to send feedback"))}finally{H(!1)}}async function xt(X){if(!r)return;const $e=String((C==null?void 0:C.request_id)||"").trim();if($e&&!V){I(""),H(!0);try{const Ae=await s.backlog_exec_promote({request_id:$e,redeploy:!0}),Ge=(Ae==null?void 0:Ae.payload)??null;fe(Ge),Ge&&Z(pl(Ge,$e)),z(""),await X()}catch(Ae){I(String((Ae==null?void 0:Ae.message)||Ae||"Failed to promote to prod"));try{const Ge=await s.backlog_exec_request($e),et=(Ge==null?void 0:Ge.payload)??null;fe(et),et&&Z(pl(et,$e))}catch{}}finally{H(!1)}}}async function pe(X){if(!r)return;const $e=String((C==null?void 0:C.request_id)||"").trim();if($e&&!V){I(""),H(!0);try{const Ae=await s.backlog_exec_deploy_uat({request_id:$e}),Ge=(Ae==null?void 0:Ae.payload)??null;fe(Ge),Ge&&Z(pl(Ge,$e)),await X()}catch(Ae){I(String((Ae==null?void 0:Ae.message)||Ae||"Failed to deploy to UAT"))}finally{H(!1)}}}async function R(X){if(!r)return;const $e=String((X==null?void 0:X.request_id)||(C==null?void 0:C.request_id)||"").trim();if(!$e)return;const Ae=(X==null?void 0:X.name)||_e,Ge=typeof(X==null?void 0:X.max_bytes)=="number"&&Number.isFinite(X.max_bytes)?Number(X.max_bytes):16e4;if(!ze.current){ze.current=!0,L(""),ie(!0);try{const et=`${$e}::${String(Ae)}`,ct=Re.current,wt=ct!==null&&ct.key===et,pt=await s.backlog_exec_log_tail({request_id:$e,name:String(Ae),max_bytes:Ge,...wt?{after_bytes:ct.offset}:{}}),Ut=typeof(pt==null?void 0:pt.next_offset)=="number"&&Number.isFinite(pt.next_offset),Dt=String((pt==null?void 0:pt.content)||"");wt&&Ut&&(pt==null?void 0:pt.reset)!==!0?(Dt&&A(Le=>{let rt=Le+Dt;if(rt.length>xe){const Ze=rt.length-xe,we=rt.indexOf(`
79
- `,Ze);rt=we>=0?rt.slice(we+1):rt.slice(Ze),be(!0)}return rt}),Re.current={key:et,offset:Number(pt.next_offset)}):(A(Dt),be(!!(pt!=null&&pt.truncated)),Re.current=Ut?{key:et,offset:Number(pt.next_offset)}:null)}catch(et){L(String((et==null?void 0:et.message)||et||"Failed to load logs"))}finally{ze.current=!1,ie(!1)}}}return h.useEffect(()=>{r&&f&&le()},[f,r]),h.useEffect(()=>{if(!r||!f)return;const $e=setInterval(()=>{s.is_backing_off()||ye(l,void 0,{background:!0})},l==="processing"?2e3:5e3);return()=>clearInterval($e)},[l,c,r,f,C==null?void 0:C.request_id]),h.useEffect(()=>{r&&f&&C!=null&&C.request_id&&R({request_id:C.request_id,name:_e})},[C==null?void 0:C.request_id,_e,f,r]),h.useEffect(()=>{he.current=!0},[C==null?void 0:C.request_id,_e]),h.useEffect(()=>{if(!Ye.current||!he.current)return;const $e=window.requestAnimationFrame(()=>{const Ae=Ye.current;Ae&&(Ae.scrollTop=Ae.scrollHeight)});return()=>window.cancelAnimationFrame($e)},[S,_e,C==null?void 0:C.request_id]),h.useEffect(()=>{if(!r||!f||!(C!=null&&C.request_id))return;const X=String(C.status||"").trim().toLowerCase();if(X==="completed"||X==="promoted"||X==="failed"||X!=="running"&&Ie!==!0)return;const Ae=setInterval(()=>{s.is_backing_off()||R({request_id:C.request_id,name:_e})},X==="running"?1500:2500);return()=>clearInterval(Ae)},[C==null?void 0:C.request_id,C==null?void 0:C.status,_e,f,r,Ie]),{exec_cfg:y,exec_cfg_loading:x,exec_cfg_error:$,exec_requests:T,exec_loading:D,exec_error:B,exec_selected:C,set_exec_selected:Z,exec_detail:ae,set_exec_detail:fe,exec_detail_loading:ge,exec_detail_error:Se,set_exec_detail_error:K,exec_qa_feedback:te,set_exec_qa_feedback:z,exec_qa_loading:V,exec_qa_error:ce,exec_log_name:_e,set_exec_log_name:Y,exec_log_text:S,exec_log_loading:U,exec_log_error:de,exec_log_truncated:ke,exec_log_auto:Ie,set_exec_log_auto:Fe,exec_log_scroll_el_ref:Ye,exec_log_follow_ref:he,parsed_exec_events:O,event_stats:me,time_stats:De,clear_exec_selection:G,load_exec_config:le,refresh_exec_list:ye,load_exec_request:Oe,exec_send_feedback:ot,exec_promote_to_prod:xt,exec_deploy_uat_now:pe,load_exec_log_tail:R}}const hf=[{id:"planned",label:"Planned"},{id:"proposed",label:"Proposed"},{id:"recurrent",label:"Recurrent"},{id:"completed",label:"Completed"},{id:"deprecated",label:"Deprecated"},{id:"trash",label:"Trash"}];function Eg(a){var Ze;const s=a.gateway,r=a.gateway_connected,l=String(a.maintenance_ai_provider||"").trim(),c=String(a.maintenance_ai_model||"").trim(),f=String(a.maintenance_ai_reasoning||"").trim(),m=String(a.backlog_advisor_agent||"").trim()||"basic-agent",p=a.default_execution_mode==="inplace"?"inplace":"uat",_=od("(max-width: 900px)"),[y,w]=h.useState("planned"),[x,N]=h.useState([]),[$,P]=h.useState(!1),[T,F]=h.useState(""),[D,J]=h.useState(""),[B,ee]=h.useState("all"),[C,Z]=h.useState(""),[ae,fe]=h.useState(new Set),ge=h.useRef(0),[Te,Se]=h.useState(null),[K,te]=h.useState([]),[z,V]=h.useState(null),[H,ce]=h.useState(p),[I,_e]=h.useState(!1),Y=gh(s,r),[S,A]=h.useState(""),[U,ie]=h.useState(!1),[de,L]=h.useState(p),[ke,be]=h.useState(!1),[Ie,Fe]=h.useState(""),[Ye,he]=h.useState(!1),[Re,ze]=h.useState(!1),[re,xe]=h.useState("framework"),[O,me]=h.useState("task"),[De,G]=h.useState(""),[le,ye]=h.useState(""),[Oe,ot]=h.useState(!1),[xt,pe]=h.useState(""),R=cd({gateway:s,can_use_gateway:r,kind:"planned",completed_view:"tasks",is_exec_view:!1,is_compact_layout:_,set_compact_pane:()=>{},on_status_transfer:()=>{}});async function X(){if(!r)return;const we=++ge.current;P(!0),F("");try{const je=await s.backlog_list(y);if(we!==ge.current)return;N(Array.isArray(je==null?void 0:je.items)?je.items:[])}catch(je){if(we!==ge.current)return;N([]),F(String((je==null?void 0:je.message)||je||"Failed to load backlog"))}finally{we===ge.current&&P(!1)}if(y==="planned")try{const je=await s.backlog_exec_active_items();if(we!==ge.current)return;const Ke=new Set;for(const it of Array.isArray(je==null?void 0:je.items)?je.items:[]){const ht=String((it==null?void 0:it.filename)||"").trim();ht&&Ke.add(ht)}fe(Ke)}catch{we===ge.current&&fe(new Set)}else fe(new Set)}h.useEffect(()=>{te([]),Z(""),X()},[y,r]),h.useEffect(()=>{te(we=>{const je=new Set(x.map(it=>String(it.filename||"").trim())),Ke=we.filter(it=>je.has(it));return Ke.length===we.length?we:Ke})},[x]);const $e=h.useMemo(()=>{const we=D.trim().toLowerCase(),je=B.trim().toLowerCase();return x.filter(Ke=>{if(je&&je!=="all"&&Nl(Ke.task_type)!==je)return!1;if(!we)return!0;const it=Array.isArray(Ke.labels)?Ke.labels.join(" "):"";return`${Ke.item_id||""} ${Ke.package||""} ${Ke.title||""} ${Ke.task_type||""} ${Ke.summary||""} ${Ke.filename||""} ${it} ${Ke.priority||""}`.toLowerCase().includes(we)})},[x,D,B]),Ae=h.useMemo(()=>x.filter(we=>K.includes(String(we.filename||"").trim())),[x,K]),Ge=El(T);function et(we){Se({filename:String(we.filename||""),kind:y,title:we.title||we.filename,initial_tab:"spec"})}async function ct(we,je){Z("");try{await s.backlog_move({from_kind:y,to_kind:je,filename:String(we.filename||"")}),await X()}catch(Ke){Z(String((Ke==null?void 0:Ke.message)||Ke||"Move failed"))}}async function wt(we){const je=String(we.filename||"").trim();if(!je)return;let Ke=null;try{const it=await s.backlog_content("planned",je);Ke=id({task_type:we.task_type},yi(String((it==null?void 0:it.content)||"")))}catch{Ke=null}A(""),ce(p),V({filename:je,title:we.title||je,readiness:Ke}),R.load_exec_config()}async function pt(we){if(!(!z||I)){_e(!0),A("");try{const je=R.exec_cfg||await R.load_exec_config();if(!je||je.can_execute!==!0){A((je==null?void 0:je.runner_error)||"Backlog exec is not available on this gateway.");return}const Ke=!!(z.readiness&&!z.readiness.ok);await s.backlog_execute({kind:"planned",filename:z.filename,execution_mode:H,executor:we==null?void 0:we.executor,target_model:we==null?void 0:we.target_model,target_reasoning_effort:we==null?void 0:we.target_reasoning_effort,dor:"check",override:Ke}),V(null),await X()}catch(je){const Ke=Wu(je);Ke?(V(it=>it&&{...it,readiness:Ke,server_refused:!0}),A("")):A(String((je==null?void 0:je.message)||je||"Execute failed"))}finally{_e(!1)}}}async function Ut(we){if(!(ke||Ae.length<2)){Fe(""),be(!0);try{const je=R.exec_cfg||await R.load_exec_config();if(!je||je.can_execute!==!0){Fe((je==null?void 0:je.runner_error)||"Backlog exec is not available on this gateway.");return}await s.backlog_execute_batch({items:Ae.map(Ke=>({kind:"planned",filename:String(Ke.filename||"")})),execution_mode:de,executor:we,dor:"check",override:Ye}),ie(!1),te([]),he(!1),await X()}catch(je){const Ke=Wu(je);if(Ke){const it=Ke.checks.filter(ht=>!ht.ok);he(!0),Fe(`Definition of Ready refused by the gateway:
80
- ${it.map(ht=>`○ ${ht.label}${ht.evidence?` — ${ht.evidence}`:""}`).join(`
81
- `)}
82
- Execute batch again to override (recorded as dor_overridden).`)}else Fe(String((je==null?void 0:je.message)||je||"Execute batch failed"))}finally{be(!1)}}}async function Dt(){if(Oe||Ae.length<2)return;const we=De.trim();if(!we){pe("Title is required.");return}pe(""),ot(!0);try{await s.backlog_merge({kind:"planned",items:Ae.map(je=>({kind:"planned",filename:String(je.filename||"")})),package:re.trim()||"framework",task_type:O,title:we,summary:le.trim()||void 0}),ze(!1),te([]),await X()}catch(je){pe(String((je==null?void 0:je.message)||je||"Merge failed"))}finally{ot(!1)}}function Le(we){const je=String(we||"").trim();te(Ke=>Ke.includes(je)?Ke.filter(it=>it!==je):[...Ke,je])}function rt(we){if(y==="planned"){const je=ae.has(String(we.filename||"").trim());return e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:()=>void wt(we),disabled:!r||je,title:je?"A live execution request already exists for this item":void 0,children:je?"Processing…":"Execute"}),e.jsx("button",{className:"btn",title:"Move back to Triage (proposed)",onClick:()=>void ct(we,"proposed"),disabled:!r,children:"→ Triage"}),e.jsx("button",{className:"btn",title:"Move to trash",onClick:()=>void ct(we,"trash"),disabled:!r,children:"Trash"})]})}return y==="proposed"?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",title:"Promote to Ready (planned)",onClick:()=>void ct(we,"planned"),disabled:!r,children:"→ Ready"}),e.jsx("button",{className:"btn",title:"Deprecate",onClick:()=>void ct(we,"deprecated"),disabled:!r,children:"Deprecate"}),e.jsx("button",{className:"btn",title:"Move to trash",onClick:()=>void ct(we,"trash"),disabled:!r,children:"Trash"})]}):y==="recurrent"?e.jsx("button",{className:"btn",title:"Move to trash",onClick:()=>void ct(we,"trash"),disabled:!r,children:"Trash"}):y==="deprecated"||y==="trash"?e.jsx("button",{className:"btn",title:"Restore to Triage (proposed)",onClick:()=>void ct(we,"proposed"),disabled:!r,children:"Restore"}):null}return e.jsxs("div",{className:"page page_pad backlog_page",children:[e.jsxs("div",{className:"page_toolbar",children:[e.jsx("div",{className:"seg seg_scroll",role:"group","aria-label":"Backlog kinds",children:hf.map(we=>e.jsx("button",{"aria-pressed":y===we.id,className:`seg_btn ${y===we.id?"active":""}`,onClick:()=>w(we.id),children:we.label},we.id))}),r?null:e.jsx("span",{className:"page_hint mono",children:"Not connected — use the connection control (top right)."}),e.jsx("div",{className:"page_toolbar_spacer"}),e.jsxs("button",{className:`btn btn_icon ${$?"is_loading":""}`,onClick:()=>void X(),disabled:!r||$,title:"Refresh","aria-label":"Refresh",children:[e.jsx(st,{name:"refresh",size:16}),$?"Refreshing":"Refresh"]})]}),Ge?e.jsx(ld,{surface:"the backlog archive"}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"page_toolbar",children:[e.jsx("input",{className:"board_search",value:D,onChange:we=>J(we.target.value),placeholder:"Search backlog (id/title/package/filename…)"}),e.jsxs("select",{value:B,onChange:we=>ee(we.target.value),title:"Filter by type",children:[e.jsx("option",{value:"all",children:"all types"}),Fa.map(we=>e.jsx("option",{value:we,children:we},we))]}),e.jsx("div",{className:"page_toolbar_spacer"}),y==="planned"&&K.length?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"chip mono info",children:[K.length," selected"]}),e.jsx("button",{className:"btn primary",disabled:K.length<2,onClick:()=>{Fe(""),L(p),he(!1),ie(!0),R.load_exec_config()},children:"Execute batch"}),e.jsx("button",{className:"btn",disabled:K.length<2,onClick:()=>{const we=Ae.map(je=>String(je.package||"").trim()).filter(Boolean);xe(we.length&&we.every(je=>je===we[0])?we[0]:"framework"),me("task"),G(`Master backlog (${Ae.length} items)`),ye(""),pe(""),ze(!0)},children:"Merge → master"})]}):null,e.jsxs("span",{className:"mono muted backlog_count",style:{fontSize:"var(--font-size-sm)"},children:[$e.length,"/",x.length]})]}),T&&!Ge?e.jsx("div",{className:"page_error mono",children:T}):null,C?e.jsx("div",{className:"page_error mono",children:C}):null,e.jsxs("div",{className:"pane backlog_table_pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:(Ze=hf.find(we=>we.id===y))==null?void 0:Ze.label}),e.jsxs("span",{className:"pane_count",children:[$e.length," item",$e.length===1?"":"s"]})]}),e.jsx("div",{className:"pane_body",style:{padding:0},children:$e.length?e.jsxs("table",{className:"data_table backlog_table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[y==="planned"?e.jsx("th",{className:"backlog_table_sel col_sel"}):null,e.jsx("th",{className:"col_id",children:"#"}),e.jsx("th",{className:"col_type",children:"type"}),e.jsx("th",{className:"col_package",children:"package"}),e.jsx("th",{children:"title"}),e.jsx("th",{className:"col_priority",children:"priority"}),e.jsx("th",{className:"col_labels",children:"labels"}),y!=="completed"?e.jsx("th",{className:"backlog_table_actions col_actions",children:"actions"}):null]})}),e.jsx("tbody",{children:$e.map(we=>{const je=String(we.filename||"").trim(),Ke=Nl(we.task_type),it=Gu(we)?Vu(we.priority):null,ht=Array.isArray(we.labels)?we.labels:[];return e.jsxs("tr",{className:"backlog_row",onClick:()=>et(we),children:[y==="planned"?e.jsx("td",{className:"backlog_table_sel col_sel",onClick:Xe=>Xe.stopPropagation(),children:e.jsx("input",{type:"checkbox",checked:K.includes(je),onChange:()=>Le(je),"aria-label":`Select ${je}`})}):null,e.jsx("td",{className:"mono muted col_id",children:we.item_id||""}),e.jsx("td",{className:"col_type",children:Ke?e.jsx("span",{className:`chip mono ${sh(Ke)}`,title:ah(Ke),children:Ke}):null}),e.jsx("td",{className:"mono muted col_package",title:we.package||"",children:we.package||""}),e.jsx("td",{className:"backlog_table_title",title:je,children:we.title||je}),e.jsx("td",{className:"col_priority",children:it?e.jsx("span",{className:`chip mono board_prio_${it.toLowerCase()}`,children:it}):null}),e.jsxs("td",{className:"col_labels",title:ht.join(", "),children:[ht.slice(0,2).map(Xe=>e.jsx("span",{className:"chip mono info",style:{marginRight:4},children:Xe},Xe)),ht.length>2?e.jsxs("span",{className:"chip mono muted",children:["+",ht.length-2]}):null]}),y!=="completed"?e.jsx("td",{className:"backlog_table_actions col_actions",onClick:Xe=>Xe.stopPropagation(),children:e.jsx("div",{className:"entity_card_actions",children:rt(we)})}):null]},`${y}:${je}`)})})]}):e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",padding:"12px"},children:$?"Loading…":"No items."})})]})]}),e.jsx(_h,{open:!!z,target:z?{kind:"planned",filename:z.filename,title:z.title}:null,execute_mode:H,set_execute_mode:ce,action_loading:I,action_error:S,exec_cfg:R.exec_cfg,exec_cfg_loading:R.exec_cfg_loading,exec_cfg_error:R.exec_cfg_error,executors:Y,readiness:(z==null?void 0:z.readiness)??null,server_refused:(z==null?void 0:z.server_refused)===!0,show_readiness:!0,on_open_spec:z?()=>{const we=z;V(null),Se({filename:we.filename,kind:"planned",title:we.title,initial_tab:"spec"})}:void 0,on_confirm:we=>void pt(we),on_close:()=>V(null)}),e.jsx(Cg,{open:U,batch_selected_items:Ae,batch_execute_mode:de,set_batch_execute_mode:L,batch_execute_loading:ke,batch_execute_error:Ie,executors:Y,exec_cfg:R.exec_cfg,exec_cfg_loading:R.exec_cfg_loading,exec_cfg_error:R.exec_cfg_error,on_confirm:we=>void Ut(we),on_close:()=>{ie(!1),Fe(""),he(!1)}}),e.jsx($g,{open:Re,batch_selected_items:Ae,merge_package:re,set_merge_package:xe,merge_task_type:O,set_merge_task_type:me,merge_title:De,set_merge_title:G,merge_summary:le,set_merge_summary:ye,merge_loading:Oe,merge_error:xt,on_confirm:()=>void Dt(),on_close:()=>{ze(!1),pe("")}}),e.jsx(mh,{gateway:s,can_use_gateway:r,target:Te,on_close:()=>Se(null),on_mutated:async()=>{await X()},on_open_executions:we=>{var je;return(je=a.on_open_executions)==null?void 0:je.call(a,we)}}),e.jsx(jg,{gateway:s,can_use_gateway:r,is_compact_layout:_,maint_provider:l,maint_model:c,maint_reasoning:f,advisor_agent:m,focus_kind:y,focus_type:B,voice_session_id:a.voice_session_id})]})}function Tg(a){const{open:s,gateway:r,can_use_gateway:l,maint_provider:c,maint_model:f,maint_reasoning:m,on_close:p,on_created:_}=a,[y,w]=h.useState(""),[x,N]=h.useState(!1),[$,P]=h.useState(""),[T,F]=h.useState("proposed"),[D,J]=h.useState("feature"),[B,ee]=h.useState("framework"),[C,Z]=h.useState(""),[ae,fe]=h.useState(""),[ge,Te]=h.useState(""),[Se,K]=h.useState(""),[te,z]=h.useState(""),[V,H]=h.useState(""),[ce,I]=h.useState(!1),[_e,Y]=h.useState(""),[S,A]=h.useState(""),[U,ie]=h.useState(""),[de,L]=h.useState(""),[ke,be]=h.useState(""),[Ie,Fe]=h.useState(""),[Ye,he]=h.useState(""),[Re,ze]=h.useState(""),[re,xe]=h.useState(""),[O,me]=h.useState(""),[De,G]=h.useState([]),[le,ye]=h.useState(!1),[Oe,ot]=h.useState(""),[xt,pe]=h.useState([]),[R,X]=h.useState(""),[$e,Ae]=h.useState(!1);function Ge(){F("proposed"),J("feature"),ee("framework"),Z(""),fe(""),Te(""),K(""),z(""),H(""),I(!1),Y(""),A(""),ie(""),L(""),be(""),Fe(""),he(""),ze(""),xe(""),me(""),G([]),ye(!1),ot(""),pe([]),X(""),Ae(!1)}function et(){p(),Ge()}async function ct(){const Le=String(y||"").trim();if(Le)return Le;if(x)return"";P(""),N(!0);try{const rt=await r.backlog_template(),Ze=String((rt==null?void 0:rt.content)||"");return w(Ze),Ze}catch(rt){return P(String((rt==null?void 0:rt.message)||rt||"Failed to load backlog template")),""}finally{N(!1)}}async function wt(Le){if(!l)return;const rt=(Le==null?void 0:Le.force)===!0;if(!rt&&te.trim())return;const Ze=await ct();if(!Ze.trim())return;const we=String(B||"").trim().toLowerCase()||"{Package}",je=Bu(),Ke=tg(Ze,{package_name:we,title:C,task_type:D,summary:ae,created_at:je});z(it=>rt||!String(it||"").trim()?Ke:it)}h.useEffect(()=>{s&&l&&wt()},[s,l]);function pt(Le){if(te.trim()&&!globalThis.confirm("Overwrite the current draft markdown with a guided draft?"))return;const rt=String(B||"").trim().toLowerCase()||"{Package}",Ze=Bu(),we=ng({package_name:rt,title:C,task_type:D,summary:ae,diagram:_e,context:S,included:Pa(U),excluded:Pa(de),plan:Pa(ke),dependencies:Pa(Ie),acceptance:Pa(Ye),tests_a:Pa(Re),tests_b:Pa(re),tests_c:Pa(O),created_at:Ze,attachments:[]});z(we)}async function Ut(){var rt;if(ce)return;H(""),I(!0),ot("");let Le="";try{const Ze=String(B||"").trim().toLowerCase(),we=rd(Se),je=!!(ge||we.length);let Ke=te||"";je&&Ke.trim()&&(Ke=Hu(Ke,{priority:ge||null,labels:we}));const it=await r.backlog_create({kind:T,package:Ze,title:C,task_type:D,summary:ae||null,content:Ke||null}),ht=String((it==null?void 0:it.kind)||"").trim(),Xe=String((it==null?void 0:it.filename)||"").trim();if(je&&!Ke.trim()&&ht&&Xe)try{const Jt=await r.backlog_content(ht,Xe),$t=String((Jt==null?void 0:Jt.content)||""),Yt=await Uu($t),un=Hu($t,{priority:ge||null,labels:we});await r.backlog_update({kind:ht,filename:Xe,content:un,expected_sha256:Yt||null})}catch(Jt){Le=[Le,`metadata lines not written: ${String((Jt==null?void 0:Jt.message)||Jt)}`].filter(Boolean).join("; ")}const ws=[...De||[]];if(ht&&Xe&&ws.length){ye(!0);const Jt=[];try{for(const $t of ws){const Yt=await r.backlog_upload_attachment({kind:ht,filename:Xe,file:$t,overwrite:!1}),un=String(((rt=Yt==null?void 0:Yt.stored)==null?void 0:rt.relpath)||"").trim();un&&Jt.push(un)}}catch($t){Le=[Le,String(($t==null?void 0:$t.message)||$t||"Attachment upload failed")].filter(Boolean).join("; "),ot(Le)}finally{if(Jt.length)try{const $t=await r.backlog_content(ht,Xe),Yt=String(($t==null?void 0:$t.content)||""),un=await Uu(Yt),Ft=sg(Yt,Jt);await r.backlog_update({kind:ht,filename:Xe,content:Ft,expected_sha256:un||null})}catch($t){Le=[Le,`uploaded files not linked: ${String(($t==null?void 0:$t.message)||$t)}`].filter(Boolean).join("; ")}ye(!1)}}p(),Ge();try{await _(ht,Xe,Le)}catch{}}catch(Ze){H(String((Ze==null?void 0:Ze.message)||Ze||"Create failed"))}finally{I(!1)}}async function Dt(){if($e)return;H("");const Le=R.trim();if(!Le)return;if(!C.trim()){H("Title is required before using AI assist.");return}const rt=String(B||"").trim().toLowerCase();if(!rt){H("Package is required before using AI assist.");return}const Ze={id:Nr(),role:"user",content:Le,ts:new Date().toISOString()},we=[...xt,Ze];pe(we),X(""),Ae(!0);try{const je=await r.backlog_assist({kind:T,package:rt,title:C,summary:ae||null,draft_markdown:te||null,messages:we.map(ht=>({role:ht.role,content:ht.content})),provider:c||null,model:f||null,thinking:m||null}),Ke=String((je==null?void 0:je.reply)||"").trim(),it=String((je==null?void 0:je.draft_markdown)||"").trim();Ke&&pe(ht=>[...ht,{id:Nr(),role:"assistant",content:Ke,ts:new Date().toISOString()}]),it&&z(it)}catch(je){H(String((je==null?void 0:je.message)||je||"AI assist failed"))}finally{Ae(!1)}}return e.jsxs(qa,{open:s,title:"New backlog task",onClose:et,actions:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:et,disabled:ce||$e,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:()=>void Ut(),disabled:ce||!C.trim()||!B.trim(),children:ce?"Creating…":"Create"})]}),children:[e.jsxs("div",{className:"row",children:[e.jsx("div",{className:"col",style:{minWidth:220},children:e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Kind (proposed → board Triage · planned → board Ready · recurrent → Backlog page)"}),e.jsxs("select",{value:T,onChange:Le=>F(Le.target.value),children:[e.jsx("option",{value:"proposed",children:"proposed"}),e.jsx("option",{value:"planned",children:"planned"}),e.jsx("option",{value:"recurrent",children:"recurrent"})]})]})}),e.jsx("div",{className:"col",style:{minWidth:220},children:e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Type"}),e.jsx("select",{value:D,onChange:Le=>J(Le.target.value),children:Fa.map(Le=>e.jsx("option",{value:Le,children:Le},Le))})]})}),e.jsx("div",{className:"col",style:{minWidth:220},children:e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Package"}),e.jsx("input",{value:B,onChange:Le=>ee(Le.target.value),placeholder:"framework"})]})})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Title"}),e.jsx("input",{value:C,onChange:Le=>Z(Le.target.value),placeholder:"Short descriptive title"})]}),e.jsxs("div",{className:"row",children:[e.jsx("div",{className:"col",style:{minWidth:220},children:e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Priority"}),e.jsxs("select",{value:ge,onChange:Le=>Te(Le.target.value),children:[e.jsx("option",{value:"",children:"unset"}),$l.map(Le=>e.jsx("option",{value:Le,children:lh[Le]},Le))]})]})}),e.jsx("div",{className:"col",style:{minWidth:320},children:e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Labels (comma-separated; sprints: sprint-29)"}),e.jsx("input",{value:Se,onChange:Le=>K(Le.target.value),placeholder:"ui, security, sprint-29",className:"mono"})]})})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Summary (optional)"}),e.jsx("textarea",{value:ae,onChange:Le=>fe(Le.target.value),rows:3,placeholder:"One paragraph summary"})]}),e.jsx("div",{className:"section_divider"}),e.jsx("div",{className:"section_title",children:"Guided fields (optional)"}),e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Use this to generate a structured draft without editing markdown directly. One item per line for list fields."}),e.jsx("div",{style:{marginTop:"8px"},children:e.jsxs("details",{children:[e.jsx("summary",{className:"mono",style:{cursor:"pointer"},children:"Show guided fields"}),e.jsxs("div",{className:"field",style:{marginTop:"10px"},children:[e.jsx("label",{children:"Diagram (ASCII)"}),e.jsx("textarea",{value:_e,onChange:Le=>Y(Le.target.value),rows:4,className:"mono",placeholder:"(optional) ascii diagram"})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Context"}),e.jsx("textarea",{value:S,onChange:Le=>A(Le.target.value),rows:4,placeholder:"Why is this needed? Link to evidence (reports, discussions, etc.)."})]}),e.jsxs("div",{className:"row",children:[e.jsx("div",{className:"col",style:{minWidth:260},children:e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Scope: Included (1 per line)"}),e.jsx("textarea",{value:U,onChange:Le=>ie(Le.target.value),rows:4,className:"mono",placeholder:"..."})]})}),e.jsx("div",{className:"col",style:{minWidth:260},children:e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Scope: Excluded (1 per line)"}),e.jsx("textarea",{value:de,onChange:Le=>L(Le.target.value),rows:4,className:"mono",placeholder:"..."})]})})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Implementation Plan (1 per line)"}),e.jsx("textarea",{value:ke,onChange:Le=>be(Le.target.value),rows:4,className:"mono",placeholder:"..."})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Dependencies (1 per line)"}),e.jsx("textarea",{value:Ie,onChange:Le=>Fe(Le.target.value),rows:3,className:"mono",placeholder:"Related backlog items / ADRs / external libs…"})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Acceptance Criteria (1 per line)"}),e.jsx("textarea",{value:Ye,onChange:Le=>he(Le.target.value),rows:4,className:"mono",placeholder:"..."})]}),e.jsxs("div",{className:"row",children:[e.jsx("div",{className:"col",style:{minWidth:260},children:e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Testing Level A (1 per line)"}),e.jsx("textarea",{value:Re,onChange:Le=>ze(Le.target.value),rows:3,className:"mono",placeholder:"cd pkg && pytest -q ..."})]})}),e.jsx("div",{className:"col",style:{minWidth:260},children:e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Testing Level B (1 per line)"}),e.jsx("textarea",{value:re,onChange:Le=>xe(Le.target.value),rows:3,className:"mono",placeholder:"run local gateway + manual verification..."})]})})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Testing Level C (1 per line)"}),e.jsx("textarea",{value:O,onChange:Le=>me(Le.target.value),rows:2,className:"mono",placeholder:"(optional / opt-in)"})]}),e.jsx("div",{className:"row",style:{marginTop:"10px",justifyContent:"flex-end"},children:e.jsx("button",{className:"btn",onClick:()=>pt(),disabled:ce||$e,children:"Generate draft from guided fields"})})]})}),e.jsx("div",{className:"section_divider"}),e.jsx("div",{className:"section_title",children:"Attachments (optional)"}),e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Upload screenshots/diagrams to `docs/backlog/assets/<id>/` and link them under `## Related` after the task is created."}),e.jsx("div",{className:"field",style:{marginTop:"8px"},children:e.jsx("input",{type:"file",multiple:!0,onChange:Le=>{const rt=Array.from(Le.target.files||[]);rt.length&&(G(Ze=>[...Ze,...rt]),Le.currentTarget.value="")}})}),De.length?e.jsx("div",{className:"mono",style:{fontSize:"var(--font-size-sm)",marginTop:"6px"},children:De.map((Le,rt)=>e.jsxs("div",{className:"row",style:{alignItems:"center",justifyContent:"space-between",marginTop:"4px"},children:[e.jsxs("span",{className:"mono muted",style:{paddingRight:"10px"},children:[Le.name," (",Math.round(Le.size/1024)," KB)"]}),e.jsx("button",{className:"btn",onClick:()=>G(Ze=>Ze.filter((we,je)=>je!==rt)),disabled:ce||le,children:"Remove"})]},`${Le.name}_${Le.size}_${rt}`))}):null,le?e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:"Uploading attachments…"}):null,Oe?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:Oe}):null,e.jsx("div",{className:"section_divider"}),e.jsx("div",{className:"section_title",children:"Draft (Markdown)"}),e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Prefilled from `docs/backlog/template.md` (editable). AI assist can also refine the draft."}),x?e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:"Loading template…"}):null,$?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:$}):null,e.jsx("div",{className:"row",style:{marginTop:"10px",justifyContent:"flex-end",gap:"8px"},children:e.jsx("button",{className:"btn",onClick:()=>{te.trim()&&!globalThis.confirm("Reset the draft markdown to the backlog template?")||wt({force:!0})},disabled:ce||$e||x||!l,children:"Reset from template"})}),e.jsx("div",{className:"field",children:e.jsx("textarea",{value:te,onChange:Le=>z(Le.target.value),rows:10,className:"mono",placeholder:"(optional) full markdown draft"})}),e.jsx("div",{className:"section_divider"}),e.jsx("div",{className:"section_title",children:"AI Assist (chat)"}),e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Use this to iteratively refine a backlog draft; assistant replies can also update the draft markdown."}),e.jsx(sd,{messages:xt,className:"backlog_chat_thread_small",empty:e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"No messages yet."})}),e.jsx("div",{style:{marginTop:"10px"},children:e.jsx(Xo,{value:R,onChange:X,onSubmit:()=>void Dt(),placeholder:"Message to AI (e.g. refine acceptance criteria…)",disabled:!l||!C.trim(),busy:$e,rows:3,sendButtonClassName:"btn primary"})}),V?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:V}):null]})}class vh extends Gt.Component{constructor(){super(...arguments);kr(this,"state",{error:null})}static getDerivedStateFromError(r){return{error:r}}static getDerivedStateFromProps(r,l){return l.error&&l.for_key!==void 0&&r.resetKey!==l.for_key?{error:null,for_key:r.resetKey}:l.for_key!==r.resetKey&&!l.error?{for_key:r.resetKey}:null}componentDidCatch(r,l){var c,f;try{(f=(c=this.props).onError)==null||f.call(c,r,l)}catch{}}render(){const{error:r}=this.state;if(r){const{fallback:l}=this.props;return typeof l=="function"?l(r):l}return this.props.children}}class ud{async _fetch(s,r,l){const c=await fetch(`/api/hub${r}`,{...l,signal:(l==null?void 0:l.signal)??AbortSignal.timeout(2e4),headers:{...l!=null&&l.body?{"Content-Type":"application/json"}:{}}}),f=await c.text();let m=null;try{m=JSON.parse(f)}catch{}if(!c.ok){const p=m&&typeof m=="object"&&(m.detail||m.error)||f,_=new Error(`${s} failed: ${p}`);throw _.status=c.status,_}return m}async meta(){return await this._fetch("hub_meta","/meta")}async healthz(){return await this._fetch("hub_healthz","/healthz")}async ledger(s){return await this._fetch("hub_ledger",`/channels/${encodeURIComponent(s)}/ledger`)}async channel_info(s){return await this._fetch("hub_channel_info",`/channels/${encodeURIComponent(s)}/info`)}async digest(s){return await this._fetch("hub_digest",`/channels/${encodeURIComponent(s)}/digest`)}async fs_list(s,r=""){const l=r?`?prefix=${encodeURIComponent(r)}`:"",c=await this._fetch("hub_fs_list",`/channels/${encodeURIComponent(s)}/fs${l}`);return Array.isArray(c)?c:[]}async fs_read(s,r){const l=r.split("/").map(encodeURIComponent).join("/");return await this._fetch("hub_fs_read",`/channels/${encodeURIComponent(s)}/fs/${l}`)}async inbox(){const s=await this._fetch("hub_inbox","/inbox");return Array.isArray(s)?s:[]}async channels(){const s=await this._fetch("hub_channels","/channels");return Array.isArray(s)?s:[]}async messages(s,r){const l=new URLSearchParams;(r==null?void 0:r.since)!==void 0&&l.set("since",String(r.since)),r!=null&&r.limit&&l.set("limit",String(r.limit)),r!=null&&r.sort&&l.set("sort",r.sort);const c=await this._fetch("hub_messages",`/channels/${encodeURIComponent(s)}/messages?${l.toString()}`);return Array.isArray(c)?c:[]}async search(s){const r=new URLSearchParams;r.set("q",s.q);for(const l of s.channel??[])r.append("channel",l);return s.sender&&r.set("sender",s.sender),s.kind&&r.set("kind",s.kind),s.since!==void 0&&r.set("since",String(s.since)),s.until!==void 0&&r.set("until",String(s.until)),s.ref&&r.set("ref",s.ref),s.rated&&r.set("rated",s.rated),s.min_votes&&r.set("min_votes",String(s.min_votes)),s.sort&&r.set("sort",s.sort),s.limit&&r.set("limit",String(s.limit)),s.cursor&&r.set("cursor",s.cursor),await this._fetch("hub_search",`/search?${r.toString()}`)}async read_message(s,r){const l=await this._fetch("hub_read_message",`/channels/${encodeURIComponent(s)}/messages/${encodeURIComponent(r)}`);return(Array.isArray(l)?l[0]:l)??null}async post_message(s,r){return await this._fetch("hub_post",`/channels/${encodeURIComponent(s)}/messages`,{method:"POST",body:JSON.stringify(r)})}async upload_attachment(s,r){const l=`/api/hub/channels/${encodeURIComponent(s)}/attachments?filename=${encodeURIComponent(r.name)}`,c=await fetch(l,{method:"POST",headers:{"Content-Type":r.type||"application/octet-stream"},body:r,signal:AbortSignal.timeout(6e4)}),f=await c.text();let m=null;try{m=JSON.parse(f)}catch{}if(!c.ok){const p=m&&typeof m=="object"&&(m.detail||m.error)||f,_=new Error(`upload failed: ${p}`);throw _.status=c.status,_}if(!m||typeof m!="object"||!m.id)throw new Error("upload returned no attachment id (unexpected hub response shape)");return m}attachment_url(s,r){return`/api/hub/channels/${encodeURIComponent(s)}/attachments/${encodeURIComponent(r)}`}async ack(s,r){return await this._fetch("hub_ack","/inbox/ack",{method:"POST",body:JSON.stringify({cursors:{[s]:r}})})}async members(s){const r=await this._fetch("hub_members",`/channels/${encodeURIComponent(s)}/members`);return Array.isArray(r)?r:[]}async create_channel(s,r){return await this._fetch("hub_create_channel","/channels",{method:"POST",body:JSON.stringify({name:s,private:r})})}async put_channel_meta(s,r,l){const c={value:r};return typeof l=="number"&&(c.expect_version=l),await this._fetch("hub_channel_meta_put",`/channels/${encodeURIComponent(s)}/store/${encodeURIComponent("channel:meta")}`,{method:"PUT",body:JSON.stringify(c)})}async channel_meta(s){return await this._fetch("hub_channel_meta",`/channels/${encodeURIComponent(s)}/store/${encodeURIComponent("channel:meta")}`)}async block(s,r,l){return await this._fetch("hub_block",`/channels/${encodeURIComponent(s)}/blocks`,{method:"POST",body:JSON.stringify({agent:r,seconds:l==null?void 0:l.seconds,reason:l==null?void 0:l.reason})})}async unblock(s,r){return await this._fetch("hub_unblock",`/channels/${encodeURIComponent(s)}/blocks/${encodeURIComponent(r)}`,{method:"DELETE"})}async hub_block(s,r){return await this._fetch("hub_hub_block","/hub/blocks",{method:"POST",body:JSON.stringify({agent:s,seconds:r==null?void 0:r.seconds,reason:r==null?void 0:r.reason})})}async hub_unblock(s){return await this._fetch("hub_hub_unblock",`/hub/blocks/${encodeURIComponent(s)}`,{method:"DELETE"})}async leave(s){return await this._fetch("hub_leave",`/channels/${encodeURIComponent(s)}/leave`,{method:"POST"})}async archive(s){return await this._fetch("hub_archive",`/channels/${encodeURIComponent(s)}/archive`,{method:"POST"})}async unarchive(s){return await this._fetch("hub_unarchive",`/channels/${encodeURIComponent(s)}/archive`,{method:"DELETE"})}async retire_agent(s,r){return await this._fetch("hub_retire",`/agents/${encodeURIComponent(s)}/retire`,{method:"POST",body:JSON.stringify(r?{reason:r}:{})})}async unretire_agent(s){return await this._fetch("hub_unretire",`/agents/${encodeURIComponent(s)}/retire`,{method:"DELETE"})}async retired_agents(){const s=await this._fetch("hub_retired","/agents/retired");return Array.isArray(s)?s:[]}async delete_agent(s){return await this._fetch("hub_delete_agent",`/agents/${encodeURIComponent(s)}`,{method:"DELETE"})}async list_blocks(s){const r=s?`?scope=${encodeURIComponent(s)}`:"",l=await this._fetch("hub_blocks",`/blocks${r}`);return Array.isArray(l)?l:[]}async send_dm(s,r){return await this._fetch("hub_send_dm",`/dms/${encodeURIComponent(s)}/messages`,{method:"POST",body:JSON.stringify({body:r.body,title:r.title||void 0,status:r.status||"open"})})}async store_keys(s){const r=await this._fetch("hub_store_keys",`/channels/${encodeURIComponent(s)}/store`);return Array.isArray(r)?r:[]}async store_get(s,r){return await this._fetch("hub_store_get",`/channels/${encodeURIComponent(s)}/store/${encodeURIComponent(r)}`)}async delegations(){const s=await this._fetch("hub_delegations","/delegations");return Array.isArray(s)?s:[]}async set_delegation(s,r,l){return await this._fetch("hub_set_delegation","/admin/delegation",{method:"PUT",body:JSON.stringify({agent_id:s,powers:r,ttl_seconds:(l==null?void 0:l.ttl_seconds)??null,note:(l==null?void 0:l.note)??""})})}async revoke_delegation(s){return await this._fetch("hub_revoke_delegation",`/admin/delegation/${encodeURIComponent(s)}`,{method:"DELETE"})}async retract_message(s,r){return await this._fetch("hub_retract",`/channels/${encodeURIComponent(s)}/messages/${encodeURIComponent(r)}/retract`,{method:"POST",body:JSON.stringify({})})}async desk(){const s=await this._fetch("hub_desk","/desk");return Array.isArray(s)?{rows:s,satisfied:[]}:{...s,rows:Array.isArray(s==null?void 0:s.rows)?s.rows:[],satisfied:Array.isArray(s==null?void 0:s.satisfied)?s.satisfied:[]}}async owed(){const s=await this._fetch("hub_owed","/owed"),r=s&&typeof s=="object"?s:{};return{...r,to_answer:Array.isArray(r.to_answer)?r.to_answer:[],to_consume:Array.isArray(r.to_consume)?r.to_consume:[],waiting_on:Array.isArray(r.waiting_on)?r.waiting_on:[]}}async create_group(s){return await this._fetch("hub_create_group","/groups",{method:"POST",body:JSON.stringify({name:s.name,members:s.members,purpose:s.purpose,opening_post:s.opening_post||s.purpose,private:s.private!==!1})})}async work_rows(s){const r=await this._fetch("hub_work_rows",`/channels/${encodeURIComponent(s)}/work`);return Array.isArray(r)?r:[]}async work(s){return await this._fetch("hub_work",`/work/${encodeURIComponent(s)}`)}async create_invite(s,r){const l=await this._fetch("hub_create_invite",`/channels/${encodeURIComponent(s)}/invites`,{method:"POST",body:JSON.stringify({agent_id:r})}),c=l&&typeof l=="object"?String(l.invite_token||""):"";if(!c)throw new Error("invite mint returned no token (unexpected hub response shape)");return c}async presence(){const s=await this._fetch("hub_presence","/presence");return Array.isArray(s)?s:[]}async reputation(s){return await this._fetch("hub_reputation",`/channels/${encodeURIComponent(s)}/reputation`)}async reputation_hub(){return await this._fetch("hub_reputation_hub","/reputation")}async reputation_votes(s,r){const l=await this._fetch("hub_reputation_votes",`/channels/${encodeURIComponent(s)}/reputation/${encodeURIComponent(r)}/votes`);return Array.isArray(l)?l:[]}async rate_message(s,r,l,c=""){const f={value:l,note:c};return await this._fetch("hub_rate_message",`/channels/${encodeURIComponent(s)}/messages/${encodeURIComponent(r)}/rating`,{method:"PUT",body:JSON.stringify(f)})}async unrate_message(s,r){return await this._fetch("hub_unrate_message",`/channels/${encodeURIComponent(s)}/messages/${encodeURIComponent(r)}/rating`,{method:"DELETE"})}async rate(s,r,l,c,f=""){return await this._fetch("hub_rate",`/channels/${encodeURIComponent(s)}/reputation/${encodeURIComponent(r)}`,{method:"PUT",body:JSON.stringify({axis:l,value:c,note:f})})}async _delete_reputation(s,r,l){return await this._fetch("hub_unrate",`/channels/${encodeURIComponent(s)}/reputation/${encodeURIComponent(r)}?axis=${encodeURIComponent(l)}`,{method:"DELETE"})}ws_url(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/hub/ws`}}const Ag=["commons"],Rg=3e4,Lg=5*6e4,pf={live:new Map,done:[],work:new Map},_f=new Set(["proposed","planned","completed","deprecated"]);function Mg(a,s){const r=s&&typeof s=="object"?String(s.item||""):"";if(r&&Ds(r))return r;const l=a.startsWith("claim:")?a.slice(6):"";return l&&Ds(l)?l:null}function zg(a){const[s,r]=h.useState(pf),l=h.useRef(new ud),c=h.useRef(new Map),f=h.useRef(0),m=h.useRef(!1);return h.useEffect(()=>{let p=!0;const _=async()=>{if(!(m.current||Date.now()<f.current)){m.current=!0;try{const w=new Map,x=[],N=new Map;for(const $ of Ag){let P=!1;try{const F=await l.current.work_rows($);for(const D of F){const J=String(D.id||D.item||""),B=String(D.status||"").toLowerCase();!Ds(J)||!_f.has(B)||N.set(J,{item:J,title:typeof D.title=="string"?D.title:void 0,status:B,owner:typeof D.owner=="string"?D.owner:void 0,receipt:typeof D.receipt=="string"?D.receipt:void 0,card:typeof D.card=="string"?D.card:void 0,updated_at:D.updated_at})}P=!0}catch{}const T=await l.current.store_keys($);for(const F of T){const D=String(F.key||"");if(D.startsWith("work:")){if(P)continue;const fe=D.slice(5);if(!Ds(fe))continue;const ge=Number(F.version||0),Te=`${$}\0${D}`,Se=c.current.get(Te);let K;if(Se&&Se.version===ge)K=Se.value;else{const z=await l.current.store_get($,D);K=z==null?void 0:z.value,c.current.set(Te,{version:ge,value:K})}const te=K&&typeof K=="object"?String(K.status||"").toLowerCase():"";if(!_f.has(te))continue;N.set(fe,{item:fe,title:typeof K.title=="string"?K.title:void 0,status:te,owner:typeof K.owner=="string"?K.owner:void 0,receipt:typeof K.receipt=="string"?K.receipt:void 0,card:typeof K.card=="string"?K.card:void 0,updated_at:F.updated_at});continue}if(!D.startsWith("claim:"))continue;const J=Number(F.version||0),B=`${$}\0${D}`,ee=c.current.get(B);let C;if(ee&&ee.version===J)C=ee.value;else{const fe=await l.current.store_get($,D);C=fe==null?void 0:fe.value,c.current.set(B,{version:J,value:C})}if(!C||typeof C!="object"||typeof C.owner!="string"||!C.owner)continue;const Z=Mg(D,C)||D.slice(6);if(!Z)continue;!!C.done||String(C.status||"").toLowerCase()==="done"?x.push({item:Z,owner:C.owner,receipt:typeof C.receipt=="string"?C.receipt:void 0,updated_at:F.updated_at}):w.has(Z)||w.set(Z,C)}}x.sort(($,P)=>(P.updated_at||0)-($.updated_at||0)),p&&r($=>$.live.size===w.size&&[...w.keys()].every(T=>JSON.stringify($.live.get(T))===JSON.stringify(w.get(T)))&&JSON.stringify($.done)===JSON.stringify(x)&&$.work.size===N.size&&[...N.keys()].every(T=>JSON.stringify($.work.get(T))===JSON.stringify(N.get(T)))?$:{live:w,done:x,work:N})}catch{f.current=Date.now()+Lg,p&&r(w=>w.live.size||w.done.length||w.work.size?pf:w)}finally{m.current=!1}}};_();const y=setInterval(()=>void _(),Rg);return()=>{p=!1,clearInterval(y)}},[a]),s}const Pg=40,Ig=4;function Og(a){const{gateway:s,can_use_gateway:r,data_nonce:l}=a,[c,f]=h.useState([]),[m,p]=h.useState(!1),[_,y]=h.useState(""),[w,x]=h.useState(""),[N,$]=h.useState(!1),[P,T]=h.useState({}),F=h.useRef({}),D=h.useRef(!1),J=h.useCallback(async C=>{if(r&&!D.current){D.current=!0,C!=null&&C.background||p(!0);try{const[Z,ae,fe,ge,Te]=await Promise.allSettled([s.backlog_list("proposed"),s.backlog_list("planned"),s.backlog_exec_requests({status:"queued,running,awaiting_qa",limit:200}),s.backlog_exec_requests({status:"promoted,completed,failed",limit:60}),s.backlog_exec_active_items({status:"queued,running,awaiting_qa",limit:1200})]),Se=[],K=[],te=(ie,de)=>ie.status==="fulfilled"?ie.value:(Se.push(de),K.push(ie.reason),null),z=te(Z,"proposed list"),V=te(ae,"planned list"),H=te(fe,"live requests"),ce=te(ge,"recent history"),I=te(Te,"busy set");if($(K.some(ie=>El(ie))),!z&&!V&&!H&&!ce){y("Failed to load the board (all sources failed)");return}y("");const _e=Array.isArray(H==null?void 0:H.requests)?H.requests:[];let Y=Array.isArray(I==null?void 0:I.items)?I.items:[];I||(Y=_e.map(ie=>({request_id:String(ie.request_id||""),status:String(ie.status||""),kind:"planned",filename:String(ie.backlog_filename||"").trim(),relpath:String(ie.backlog_relpath||"").trim()})).filter(ie=>ie.filename&&!/^batch\(\d+\)$/i.test(ie.filename)));const S=Array.isArray(z==null?void 0:z.items)?z.items:[],A=Array.isArray(V==null?void 0:V.items)?V.items:[],U=yg({proposed:S,planned:A,active_requests:_e,terminal_requests:Array.isArray(ce==null?void 0:ce.requests)?ce.requests:[],active_items:Y});f(U),x(Se.length?`#FALLBACK partial board — failed: ${Se.join(", ")}`:""),B(U,S,A)}finally{D.current=!1,C!=null&&C.background||p(!1)}}},[s,r]);async function B(C,Z,ae){const fe=new Map;for(const K of Z)fe.set(String(K.filename||"").trim(),"proposed");for(const K of ae)fe.set(String(K.filename||"").trim(),"planned");const ge=C.filter(K=>K.filename&&!F.current[K.filename]&&fe.has(K.filename)).filter(K=>!dh(K)||K.column==="ready").slice(0,Pg).map(K=>({filename:K.filename,kind:fe.get(K.filename)}));if(!ge.length)return;const Te=[...ge],Se=Array.from({length:Math.min(Ig,Te.length)},async()=>{for(;;){const K=Te.shift();if(!K)return;try{const te=await s.backlog_content(K.kind,K.filename),z=yi(String((te==null?void 0:te.content)||""));F.current={...F.current,[K.filename]:z}}catch{}}});await Promise.all(Se),T(F.current)}const ee=h.useCallback(async(C,Z)=>{try{const ae=await s.backlog_content(C,Z),fe=yi(String((ae==null?void 0:ae.content)||""));F.current={...F.current,[Z]:fe},T(F.current)}catch{}},[s]);return h.useEffect(()=>{J()},[J,l]),h.useEffect(()=>{if(!r)return;const C=setInterval(()=>{s.is_backing_off()||J({background:!0})},1e4);return()=>clearInterval(C)},[r,J,s]),{cards:c,loading:m,error:_,degraded:w,unconfigured:N,metadata:P,refresh:J,refresh_item_metadata:ee}}function gf(a,s){return a.length<=s?a:`${a.slice(0,s-1).trimEnd()}…`}const Dg=new ud;function Fg(a){if(!a)return"";const s=Math.max(0,Date.now()/1e3-a);return s<3600?`${Math.max(1,Math.round(s/60))}m`:s<172800?`${Math.round(s/3600)}h`:`${Math.round(s/86400)}d`}function qg(a){const{card:s}=a,r=s.work_id||"",l=!!(r&&Ds(r)),[c,f]=h.useState({loading:l,error:"",claims:[],decisions:[],messages:[]});h.useEffect(()=>{let _=!0;if(l)return f(y=>({...y,loading:!0,error:""})),Dg.work(r).then(y=>{_&&f({loading:!1,error:"",claims:Array.isArray(y==null?void 0:y.claims)?y.claims:[],decisions:Array.isArray(y==null?void 0:y.decisions)?y.decisions:[],messages:(Array.isArray(y==null?void 0:y.messages)?y.messages:[]).slice().sort((w,x)=>(x.created_at||0)-(w.created_at||0))})}).catch(y=>{_&&f({loading:!1,error:String((y==null?void 0:y.message)||y||"activity unavailable"),claims:[],decisions:[],messages:[]})}),()=>{_=!1}},[r,l]);const m=c.messages[0],p=s.claim_started_at!==void 0&&s.claim_owner?ih({owner:s.claim_owner,started_at:s.claim_started_at},Date.now()):null;return e.jsx("div",{className:"modal_backdrop",onClick:a.on_close,children:e.jsxs("div",{className:"modal_panel board_claim_panel board_activity_panel",onClick:_=>_.stopPropagation(),children:[e.jsxs("div",{className:"modal_head",children:[e.jsx("span",{className:"modal_title",children:s.title}),e.jsx("button",{className:"btn",onClick:a.on_close,children:"Close"})]}),e.jsxs("div",{className:"board_claim_facts",children:[r?e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"work id:"})," ",e.jsx("span",{className:"mono",children:r})]}):null,s.claim_owner?e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:s.column==="done"?"completed by:":"held by:"})," ",s.claim_owner,p?e.jsxs("span",{className:"muted",children:[" · ",p.label]}):null]}):null,s.summary?e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"receipt:"})," ",s.summary]}):null,s.card_path?e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"item file:"})," ",e.jsx("span",{className:"mono",children:s.card_path}),e.jsxs("span",{className:"muted",children:[" (in ",s.package||"its own","'s repository)"]})]}):null]}),e.jsxs("div",{className:"board_activity_section",children:[e.jsxs("div",{className:"muted team_note",style:{marginBottom:4},children:["Discussion & receipts ",c.loading?"· loading…":c.messages.length?`· ${c.messages.length} citing message(s)`:""]}),c.error?e.jsxs("div",{className:"muted team_note",children:["#FALLBACK hub activity unavailable (",c.error.slice(0,80),") — the Team thread button below still works."]}):null,!c.loading&&!c.error&&l&&!c.messages.length?e.jsx("div",{className:"muted team_note",children:"No citing messages on the hub yet."}):null,l?null:e.jsx("div",{className:"muted team_note",children:"This claim has no ruled work id — discussion lives in the coordination channel."}),c.messages.slice(0,8).map(_=>e.jsxs("div",{className:"board_activity_msg",children:[e.jsxs("div",{className:"board_activity_msg_head mono",children:[e.jsx("span",{children:_.sender}),e.jsxs("span",{className:"muted",children:[_.channel," #",_.seq," · ",Fg(_.created_at)]}),a.on_open_team?e.jsx("button",{className:"team_row_expand",onClick:()=>a.on_open_team({channel:String(_.channel||""),message_id:String(_.id||""),seq:Number(_.seq)}),title:"Open this message in its Team channel",children:"open ↗"}):null]}),_.title?e.jsx("div",{className:"board_activity_msg_title",children:gf(String(_.title),140)}):null,_.body?e.jsx("div",{className:"board_activity_msg_body muted",children:gf(String(_.body),220)}):null]},_.id||_.seq))]}),e.jsx("div",{className:"entity_skills_actions",children:a.on_open_team?e.jsx("button",{className:"btn primary",onClick:()=>a.on_open_team(m?{channel:String(m.channel||"commons"),message_id:String(m.id||""),seq:Number(m.seq)}:{channel:"commons"}),title:m?"Open the most recent citing message in its channel":"Open the coordination channel",children:"Open discussion in Team"}):null})]})})}function Bg(a){const{gateway:s,gateway_connected:r,data_nonce:l,on_mutated:c,on_open_executions:f}=a,m=a.default_execution_mode==="inplace"?"inplace":"uat",p=od("(max-width: 900px)"),_=gh(s,r),y=Og({gateway:s,can_use_gateway:r,data_nonce:l}),w=zg(!0),x=h.useMemo(()=>wg(y.cards,w),[y.cards,w]),N=cd({gateway:s,can_use_gateway:r,kind:"planned",completed_view:"tasks",is_exec_view:!1,is_compact_layout:p,set_compact_pane:()=>{},on_status_transfer:()=>{}}),[$,P]=h.useState("");h.useEffect(()=>{var me;if(!a.query_preset)return;const O=Ds(a.query_preset);P(O?O.num.padStart(4,"0"):a.query_preset),(me=a.on_query_preset_consumed)==null||me.call(a)},[a.query_preset]);const[T,F]=h.useState("all"),[D,J]=h.useState("all"),[B,ee]=h.useState(""),[C,Z]=h.useState(!1),[ae,fe]=h.useState(null),[ge,Te]=h.useState(null),[Se,K]=h.useState(null),[te,z]=h.useState("uat"),[V,H]=h.useState(!1),[ce,I]=h.useState(""),[_e,Y]=h.useState(""),[S,A]=h.useState(null),U=h.useRef(null),ie=x.some(O=>O.column==="in_progress"),[,de]=h.useState(0);h.useEffect(()=>{if(!ie)return;const O=setInterval(()=>de(me=>(me+1)%3600),1e3);return()=>clearInterval(O)},[ie]);const L=h.useMemo(()=>{const O=new Set;for(const me of x)me.package&&O.add(me.package);return[...O].sort()},[x]),ke=h.useMemo(()=>x.filter(O=>O.filename&&O.kind).length,[x]),be=h.useMemo(()=>x.filter(O=>O.filename&&O.kind&&(dh(O)||y.metadata[O.filename])).length,[x,y.metadata]),Ie=h.useMemo(()=>{const O=new Map;for(const me of x)if(me.filename)for(const De of Qu(me,y.metadata[me.filename]))O.set(De,(O.get(De)||0)+1);return[...O.entries()].sort((me,De)=>De[1]-me[1]).slice(0,12)},[x,y.metadata]),Fe=h.useMemo(()=>{const O=$.trim().toLowerCase();return x.filter(me=>{if(T!=="all"&&(me.package||"")!==T||D!=="all"&&String(me.task_type||"").toLowerCase()!==D)return!1;const De=me.filename?y.metadata[me.filename]:void 0,G=Qu(me,De);return B&&!G.includes(B)||C&&!G.some(ye=>{const Oe=ye.toLowerCase();return Oe==="decision-gate"||Oe.startsWith("wave-")||Oe.startsWith("seat-")})?!1:O?`${me.item_id||""} ${me.title} ${me.filename||""} ${me.package||""} ${me.summary||""} ${me.exec_status||""} ${G.join(" ")} ${Ku(me,De)||""}`.toLowerCase().includes(O):!0})},[x,y.metadata,$,T,D,B,C]),Ye=h.useMemo(()=>{var De;const O=new Map;for(const G of mf)O.set(G.id,[]);for(const G of Fe)(De=O.get(G.column))==null||De.push(G);const me=G=>{const le=G.filename?Ku(G,y.metadata[G.filename]):null;return le?$l.indexOf(le):$l.length};for(const[G,le]of O)(G==="triage"||G==="ready")&&le.sort((ye,Oe)=>me(ye)-me(Oe)||(Oe.item_id||0)-(ye.item_id||0));return O},[Fe,y.metadata]);async function he(O,me){if(!(!O.filename||!O.kind||O.kind==="completed")&&O.kind!==me){Y("");try{await s.backlog_move({from_kind:O.kind,to_kind:me,filename:O.filename}),await y.refresh(),c()}catch(De){Y(String((De==null?void 0:De.message)||De||"Move failed"))}}}async function Re(O){if(!O.filename)return;let me=y.metadata[O.filename];if(!me)try{const G=await s.backlog_content("planned",O.filename);me=yi(String((G==null?void 0:G.content)||""))}catch{me=void 0}const De=me?id({task_type:O.task_type},me):null;I(""),z(m),K({filename:O.filename,title:O.title,readiness:De}),N.load_exec_config()}async function ze(O){if(!(!Se||V)){H(!0),I("");try{const me=N.exec_cfg||await N.load_exec_config();if(!me||me.can_execute!==!0){I((me==null?void 0:me.runner_error)||"Backlog exec is not available on this gateway.");return}const De=!!(Se.readiness&&!Se.readiness.ok);await s.backlog_execute({kind:"planned",filename:Se.filename,execution_mode:te,executor:O==null?void 0:O.executor,target_model:O==null?void 0:O.target_model,target_reasoning_effort:O==null?void 0:O.target_reasoning_effort,dor:"check",override:De}),K(null),await y.refresh(),c()}catch(me){const De=Wu(me);De?(K(G=>G&&{...G,readiness:De,server_refused:!0}),I("")):I(String((me==null?void 0:me.message)||me||"Execute failed"))}finally{H(!1)}}}function re(O){if(!O.filename&&!O.request_id){const me=cg(O.card_path);if(me&&r){s.backlog_content(me.kind,me.filename).then(()=>{fe({filename:me.filename,kind:me.kind,title:O.title,work_id:O.work_id,has_live_request:!1,initial_tab:"spec"})}).catch(()=>Te(O));return}Te(O);return}fe({filename:O.filename||"",kind:O.kind||null,request_id:O.request_id,title:O.title,work_id:O.work_id,has_live_request:O.column==="in_progress"||O.column==="in_review",initial_tab:O.column==="in_review"?"review":O.column==="in_progress"?"runs":"spec"})}const xe={ready:"planned",triage:"proposed"};return e.jsxs("div",{className:"page board_page_root",children:[e.jsxs("div",{className:"board_toolbar",children:[e.jsx("input",{className:"board_search",value:$,onChange:O=>P(O.target.value),placeholder:"Search the board…"}),e.jsxs("select",{value:T,onChange:O=>F(O.target.value),title:"Package",children:[e.jsx("option",{value:"all",children:"all packages"}),L.map(O=>e.jsx("option",{value:O,children:O},O))]}),e.jsxs("select",{value:D,onChange:O=>J(O.target.value),title:"Type",children:[e.jsx("option",{value:"all",children:"all types"}),Fa.map(O=>e.jsx("option",{value:O,children:O},O))]}),e.jsx("button",{className:`chip mono board_facet ${C?"active":"muted"}`,onClick:()=>Z(O=>!O),"aria-pressed":C,title:"Room supervision: only operator decision gates + wave items (labels decision-gate / wave-* / seat-*)",children:"Supervision"}),e.jsx("div",{className:"board_toolbar_spacer"}),y.degraded&&!y.unconfigured?e.jsx("span",{className:"mono board_warn",title:y.degraded,children:"partial board"}):null,y.error&&!y.unconfigured?e.jsx("span",{className:"mono board_error",children:y.error}):null,_e?e.jsx("span",{className:"mono board_error",children:_e}):null,e.jsx("button",{className:`btn btn_icon ${y.loading?"is_loading":""}`,onClick:()=>void y.refresh(),disabled:!r||y.loading,children:y.loading?"Refreshing…":"Refresh"})]}),y.unconfigured?e.jsx(ld,{surface:"the board"}):null,!y.unconfigured&&(Ie.length||ke)?e.jsxs("div",{className:"board_facets",children:[e.jsx("span",{className:"mono muted board_facets_caption",children:"labels:"}),Ie.map(([O,me])=>e.jsxs("button",{className:`chip mono board_facet ${B===O?"active":"info"}`,onClick:()=>ee(De=>De===O?"":O),title:`${me} scanned card(s) carry ${O} — click to filter (sprints are labels: sprint-N)`,children:[O," ",e.jsx("span",{className:"muted",children:me})]},O)),B?e.jsx("button",{className:"chip mono warn board_facet",onClick:()=>ee(""),children:"clear ✕"}):null,be<ke?e.jsxs("span",{className:"chip mono warn",title:"Label chips/filters cover only scanned cards — this gateway does not serve list-level metadata yet (#FALLBACK content scan; exact on gateways ≥ c1090)",children:["scanned ",be,"/",ke]}):null]}):null,e.jsx("div",{className:"board_columns",style:y.unconfigured?{display:"none"}:void 0,children:mf.map(O=>{const me=Ye.get(O.id)||[],De=xe[O.id];return e.jsxs("div",{className:`board_column board_column_${O.id} ${S===O.id?"drag_over":""}`,onDragOver:G=>{!De||!U.current||(G.preventDefault(),A(O.id))},onDragLeave:()=>A(G=>G===O.id?null:G),onDrop:G=>{G.preventDefault(),A(null);const le=U.current;U.current=null,le&&De&&he(le,De)},children:[e.jsxs("div",{className:"board_column_header",title:O.hint,children:[e.jsx("span",{className:"board_column_title",children:O.label}),e.jsx("span",{className:"board_column_count mono",children:me.length})]}),e.jsxs("div",{className:"board_column_body",children:[me.map(G=>{const le=uh(G,G.filename?y.metadata[G.filename]:void 0);return e.jsx(Ug,{card:G,metadata:G.filename?y.metadata[G.filename]:void 0,draggable:!le&&!!(G.kind&&G.filename&&(G.column==="triage"||G.column==="ready")),on_drag_start:()=>{U.current=G},on_drag_end:()=>{U.current=null,A(null)},on_open:()=>re(G),on_promote:!le&&O.id==="triage"?()=>void he(G,"planned"):void 0,on_demote:!le&&O.id==="ready"?()=>void he(G,"proposed"):void 0,on_execute:!le&&O.id==="ready"?()=>void Re(G):void 0,on_follow:G.exec_status==="running"||G.exec_status==="queued"?()=>f(G.request_id):void 0},G.key)}),me.length?null:e.jsx("div",{className:"board_column_empty mono muted",children:"—"})]})]},O.id)})}),e.jsx(_h,{open:!!Se,target:Se?{kind:"planned",filename:Se.filename,title:Se.title}:null,execute_mode:te,set_execute_mode:z,action_loading:V,action_error:ce,exec_cfg:N.exec_cfg,exec_cfg_loading:N.exec_cfg_loading,exec_cfg_error:N.exec_cfg_error,executors:_,readiness:(Se==null?void 0:Se.readiness)??null,server_refused:(Se==null?void 0:Se.server_refused)===!0,show_readiness:!0,on_open_spec:Se?()=>{const O=Se;K(null),fe({filename:O.filename,kind:"planned",title:O.title,initial_tab:"spec"})}:void 0,on_confirm:O=>void ze(O),on_close:()=>K(null)}),e.jsx(mh,{gateway:s,can_use_gateway:r,target:ae,on_close:()=>fe(null),on_mutated:async()=>{ae!=null&&ae.filename&&(ae.kind==="proposed"||ae.kind==="planned")&&await y.refresh_item_metadata(ae.kind,ae.filename),await y.refresh(),c()},on_open_executions:f}),ge?e.jsx(qg,{card:ge,on_close:()=>Te(null),on_open_team:a.on_open_team}):null]})}function Ug(a){const{card:s,metadata:r,draggable:l,on_drag_start:c,on_drag_end:f,on_open:m,on_promote:p,on_demote:_,on_execute:y,on_follow:w}=a,x=Ku(s,r),N=uh(s,r),$=!N&&r?id({task_type:s.task_type},r):null,P=Nl(s.task_type),T=s.exec_status==="running"&&s.started_at?Math.max(0,Date.now()-Date.parse(s.started_at)):null;return e.jsxs("div",{className:`board_card ${l?"draggable":""} ${N?"gate":""}`,onClick:m,role:"button",tabIndex:0,onKeyDown:F=>{(F.key==="Enter"||F.key===" ")&&(F.preventDefault(),m())},draggable:l,onDragStart:l?c:void 0,onDragEnd:l?f:void 0,children:[e.jsxs("div",{className:"board_card_title",children:[$?e.jsx("span",{className:`board_ready_dot ${$.ok?"ok":"warn"}`,title:$.ok?"Definition of Ready: satisfied":`Not ready: ${$.checks.filter(F=>!F.ok).map(F=>F.label).join("; ")}`}):null,e.jsx("span",{className:"board_card_title_text",children:s.title})]}),e.jsxs("div",{className:"board_card_chips",children:[N?e.jsx("span",{className:"chip mono warn",title:"Operator decision gate — resolved by the operator's ruling, never assignable or executable (c1631)",children:"⛬ operator gate"}):null,s.item_id?e.jsxs("span",{className:"chip mono muted",children:["#",s.item_id]}):null,P&&!N?e.jsx("span",{className:`chip mono ${sh(P)}`,title:ah(P),children:P}):null,x?e.jsx("span",{className:`chip mono board_prio_${x.toLowerCase()}`,children:x}):null,s.package?e.jsx("span",{className:"chip mono muted",children:s.package}):null,s.batch_size?e.jsxs("span",{className:"chip mono info",children:[s.batch_size," items"]}):null,Qu(s,r).filter(F=>!N||F.toLowerCase()!=="decision-gate").slice(0,3).map(F=>e.jsx("span",{className:"chip mono info",children:F},F)),s.exec_status?e.jsx("span",{className:`chip mono ${s.exec_status==="failed"?"danger":s.exec_status==="awaiting_qa"?"warn":"info"}`,children:s.exec_status}):null,T!==null?e.jsx("span",{className:"chip mono info",children:Os(T)}):null,s.recent_failures?e.jsxs("span",{className:"chip mono danger",title:`${s.recent_failures} recent failed attempt(s) — see the Failed lane`,children:["⚠ ",s.recent_failures]}):null,s.target_agent?e.jsx("span",{className:"chip mono muted",children:s.target_agent}):null,s.claim_owner?(()=>{const F=ih({owner:s.claim_owner,started_at:s.claim_started_at},Date.now());return e.jsxs("span",{className:`chip mono ${F!=null&&F.stale?"warn":"info"}`,title:`Live hub claim${s.work_id?` (claim:${s.work_id})`:""}${F!=null&&F.stale?" — stale: claimed long ago with no receipt yet; open to re-claim on the record per the ruled process":""}`,children:["⛏ ",s.claim_owner,F?` · ${F.label.replace("claimed ","")}`:""]})})():null]}),p||_||y||w?e.jsxs("div",{className:"board_card_actions",onClick:F=>F.stopPropagation(),children:[p?e.jsx("button",{className:"btn",onClick:p,title:"Move to Ready (planned)",children:"→ Ready"}):null,y?e.jsx("button",{className:"btn primary",onClick:y,children:"Execute"}):null,_?e.jsx("button",{className:"btn",onClick:_,title:"Move back to Triage (proposed)",children:"→ Triage"}):null,w?e.jsx("button",{className:"btn",onClick:w,children:"Follow live"}):null]}):null]})}function Cu(a,s){const r=String(a||"").replace(/\r/g,"").trim();if(!r)return"";const c=(r.split(`
83
- `,1)[0]||"").trim();return c.length<=s?c:`${c.slice(0,Math.max(0,s-1))}…`}function Wg(a){const s=String(a||"").trim();if(s.length<2)return s;const r=s[0],l=s[s.length-1];return r==="'"&&l==="'"||r==='"'&&l==='"'?s.slice(1,-1):s}function yh(a){const s=String(a||"").trim();if(!s)return"";const r=s.match(/^(?:\/bin\/)?(?:zsh|bash)\s+-lc\s+([\s\S]+)$/);return r?Wg(String(r[1]||"").trim()):s}function Hg(a,s){const r=String(a||"").trim().toLowerCase();if(r==="error"||r==="turn.failed")return"error";if(r==="turn.completed"||r==="turn.succeeded"||r==="turn.success")return"ok";const l=s&&typeof s=="object"?s:null,c=l&&typeof l.item=="object"?l.item:null;if(c&&String(c.type||"").trim()==="command_execution"){const f=String(c.status||"").trim().toLowerCase();if(f==="failed")return"error";const m=c.exit_code,p=typeof m=="number"?m:Number.isFinite(Number(m))?Number(m):null;if(p!=null)return p===0?"ok":"error";if(f==="completed")return"ok"}return"info"}function Vg(a,s){var y;const r=s&&typeof s=="object"?s:{},l=r.item&&typeof r.item=="object"?r.item:null,c=l?String(l.type||"").trim():"",f=l?String(l.text||"").trim():"",m=l?String(l.command||"").trim():"",p=l&&Array.isArray(l.items)?l.items:[],_=String((r==null?void 0:r.message)||((y=r==null?void 0:r.error)==null?void 0:y.message)||"").trim();if(c==="command_execution"&&m)return yh(m)||m;if(c==="todo_list"&&p.length>0){const w=p.length,x=p.filter(D=>(D&&D.completed)===!0).length,N=p.find(D=>(D&&D.completed)!==!0),$=String((N==null?void 0:N.text)||"").trim(),P=w>1?` (+${w-1})`:"",T=w>0?` (${x}/${w})`:"",F=$?`todo: ${$}${P}`:`todo list (${w})`;return Cu(`${F}${T}`,96)}return f?Cu(f,96)||f:_?Cu(_,96)||_:c||String(a||"").trim()||"event"}function vf(a){const s=new Date(a),r=l=>String(l).padStart(2,"0");return`${r(s.getHours())}:${r(s.getMinutes())}`}function Gg(a){var l,c,f;const s=a&&typeof a=="object"?a:{},r=[s.at,s.created_at,s.timestamp,s.time,s.ts,s.datetime,(l=s.item)==null?void 0:l.at,(c=s.item)==null?void 0:c.created_at,(f=s.item)==null?void 0:f.timestamp];for(const m of r)if(m!=null){if(typeof m=="number"&&Number.isFinite(m)){const p=m>1e11?m:m*1e3;return vf(p)}if(typeof m=="string"){const p=m.trim();if(!p)continue;const _=Date.parse(p.replace(/(\.\d{3})\d+/,"$1"));if(Number.isFinite(_))return vf(_)}}return null}function Kg(a){var F;const{exec_selected:s,exec_detail:r,is_compact_layout:l,exec_log_name:c,set_exec_log_name:f,exec_log_text:m,exec_log_loading:p,exec_log_error:_,exec_log_truncated:y,exec_log_auto:w,set_exec_log_auto:x,exec_log_scroll_el_ref:N,exec_log_follow_ref:$,parsed_exec_events:P,load_exec_log_tail:T}=a;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"row",style:{alignItems:"center",justifyContent:"space-between",gap:"8px",marginTop:"8px"},children:[e.jsx("div",{className:"section_title",style:{marginTop:0},children:"Live logs"}),e.jsxs("div",{style:{display:"flex",gap:"6px",alignItems:"center",justifyContent:"flex-end",flexWrap:"wrap"},children:[e.jsxs("select",{value:c,onChange:D=>f(D.target.value),children:[e.jsx("option",{value:"events",children:"events"}),e.jsx("option",{value:"stderr",children:"stderr"}),e.jsx("option",{value:"last_message",children:"last message"})]}),e.jsx("button",{className:`btn ${w?"primary":""}`,onClick:()=>x(D=>!D),disabled:!(s!=null&&s.request_id),children:w?"Auto on":"Auto off"}),e.jsxs("button",{className:`btn btn_icon ${p?"is_loading":""}`,onClick:()=>T(),disabled:p||!(s!=null&&s.request_id),"aria-label":"Refresh logs",title:"Refresh logs",children:[e.jsx(st,{name:"refresh",size:16}),l?null:p?"Loading…":"Refresh"]})]})]}),_?e.jsx("div",{className:"detail_warn",children:_}):null,!_&&y?e.jsx("div",{className:"detail_hint",children:"#TRUNCATION: log tail truncated"}):null,c==="events"&&P?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"exec_log_scroll",ref:N,onScroll:D=>{$.current=of(D.currentTarget,12)},children:P.events.length===0?e.jsx("div",{className:"empty_note",children:"No events yet."}):P.events.map(D=>{var _e;const J=D.payload,B=J&&typeof J.item=="object"?J.item:null,ee=B?String(B.type||"").trim():"",C=B?String(B.id||"").trim():"",Z=J?String(J.thread_id||"").trim():"",ae=Hg(D.type,J),fe=ae==="error"?"danger":ae==="ok"?"ok":"info",ge=Gg(J),Te=Vg(D.type,J),Se=String((J==null?void 0:J.message)||((_e=J==null?void 0:J.error)==null?void 0:_e.message)||"").trim(),K=B?String(B.text||"").trim():"",te=B?String(B.command||"").trim():"",z=B?String(B.status||"").trim():"",V=B&&B.exit_code!=null?String(B.exit_code):"",H=B?String(B.aggregated_output||"").trim():"",ce=B&&Array.isArray(B.items)?B.items:[],I=te?yh(te)||te:"";return e.jsxs("details",{className:`exec_event ${ae}`,children:[e.jsxs("summary",{className:"exec_event_summary",children:[ge?e.jsx("span",{className:"exec_event_when mono muted",children:ge}):null,ge?e.jsx("span",{className:"exec_event_sep mono muted",children:"|"}):null,e.jsx("span",{className:"exec_event_main mono",title:Te,children:Te}),e.jsx("span",{className:`chip mono ${fe}`,children:ee||D.type}),V?e.jsxs("span",{className:"mono muted exec_event_right",children:["exit=",V]}):null]}),e.jsxs("div",{className:"exec_event_body",children:[e.jsxs("div",{className:"row exec_event_meta",children:[e.jsx("span",{className:"mono muted",style:{fontSize:"var(--font-size-xs)"},children:D.type}),C?e.jsx("span",{className:"mono muted",style:{fontSize:"var(--font-size-xs)"},children:C}):null,Z?e.jsxs("span",{className:"mono muted",style:{fontSize:"var(--font-size-xs)"},children:["thread ",fa(Z,18)]}):null]}),Se?e.jsx("pre",{className:"mono",style:{whiteSpace:"pre-wrap",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:Se}):null,ce&&ce.length>0?e.jsx("div",{className:"mono",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:ce.map((Y,S)=>e.jsxs("div",{children:[(Y&&Y.completed)===!0?"✓":"○"," ",String((Y==null?void 0:Y.text)||"").trim()]},`${D.idx}-todo-${S}`))}):null,te?e.jsxs("div",{style:{marginTop:"8px"},children:[e.jsxs("div",{className:"mono muted",style:{fontSize:"var(--font-size-xs)"},children:["command_execution ",z?`(${z})`:""," ",V?`exit=${V}`:""]}),e.jsx("pre",{className:"mono",style:{whiteSpace:"pre-wrap",fontSize:"var(--font-size-sm)",marginTop:"6px"},children:I})]}):null,H?e.jsxs("details",{style:{marginTop:"8px"},children:[e.jsxs("summary",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",cursor:"pointer"},children:["output (",H.length.toLocaleString()," chars)"]}),e.jsx("pre",{className:"mono",style:{whiteSpace:"pre-wrap",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:H})]}):null,K?e.jsx("div",{style:{marginTop:"8px"},children:e.jsx(as,{className:"md_doc",text:K})}):null]})]},`${D.idx}-${C}-${D.type}`)})}),e.jsxs("details",{style:{marginTop:"8px"},children:[e.jsxs("summary",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",cursor:"pointer"},children:["Raw JSONL",P.bad?` (${P.bad} unparsable line(s))`:""]}),e.jsx("pre",{className:"mono",style:{whiteSpace:"pre-wrap",fontSize:"var(--font-size-sm)",marginTop:"8px",maxHeight:"240px",overflow:"auto"},children:P.raw||""})]})]}):e.jsx("div",{className:"exec_log_scroll",ref:N,onScroll:D=>{$.current=of(D.currentTarget,12)},children:e.jsx("pre",{className:"mono",style:{whiteSpace:"pre-wrap",fontSize:"var(--font-size-sm)"},children:(()=>{var J;if(String(m||"").trim())return m;if(c==="last_message"){const B=String(((J=r==null?void 0:r.result)==null?void 0:J.last_message)||s.last_message||"").trim();if(B)return B;const ee=String(s.status||"").trim().toLowerCase();return ee==="queued"||ee==="running"?"(last message is written when the run finishes — use events for live output)":"(no last message yet)"}return c==="stderr"?"(no stderr yet)":"(no logs yet)"})()})}),(F=r==null?void 0:r.result)!=null&&F.logs?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"section_divider"}),e.jsx("div",{className:"section_title",children:"Logs"}),e.jsxs("div",{className:"fact_grid",children:[r.result.logs.events_relpath?e.jsxs("div",{className:"fact fact_wide",children:[e.jsx("span",{className:"fact_label",children:"events"}),e.jsx("span",{className:"fact_value mono",children:r.result.logs.events_relpath})]}):null,r.result.logs.stderr_relpath?e.jsxs("div",{className:"fact fact_wide",children:[e.jsx("span",{className:"fact_label",children:"stderr"}),e.jsx("span",{className:"fact_value mono",children:r.result.logs.stderr_relpath})]}):null,r.result.logs.last_message_relpath?e.jsxs("div",{className:"fact fact_wide",children:[e.jsx("span",{className:"fact_label",children:"last message"}),e.jsx("span",{className:"fact_value mono",children:r.result.logs.last_message_relpath})]}):null]})]}):null]})}function Qg(a){const{pipeline:s,is_compact_layout:r,on_back_to_list:l,on_send_feedback:c,on_promote:f,on_deploy_uat:m}=a,p=s.exec_selected;if(!p)return e.jsx("div",{className:"empty_note",children:"Select an exec request."});const{exec_detail:_,exec_detail_loading:y,exec_detail_error:w,exec_qa_feedback:x,set_exec_qa_feedback:N,exec_qa_loading:$,exec_qa_error:P,event_stats:T,time_stats:F,exec_log_name:D}=s;return e.jsxs("div",{className:"inbox_detail",children:[e.jsxs("div",{className:"inbox_detail_header",children:[e.jsxs("div",{className:"inbox_detail_title",children:[e.jsx("span",{style:{fontWeight:650,fontSize:"var(--font-size-md)"},children:p.backlog_filename||p.backlog_relpath||p.request_id}),(()=>{const J=String(p.status||"").trim().toLowerCase();return e.jsx("span",{className:`chip mono ${kl(J)}`,children:J||"unknown"})})(),e.jsx("span",{className:"chip mono muted",children:fa(p.request_id,16)})]}),e.jsxs("div",{className:"inbox_detail_actions",children:[r?e.jsx("button",{className:"btn",onClick:l,disabled:y,children:"Back"}):null,e.jsxs("button",{className:"btn btn_icon",onClick:()=>yn(p.request_id),disabled:y,"aria-label":"Copy request id",title:"Copy request id",children:[e.jsx(st,{name:"copy",size:16}),r?null:"Copy request id"]}),p.backlog_relpath?e.jsxs("button",{className:"btn btn_icon",onClick:()=>yn(p.backlog_relpath||""),disabled:y,"aria-label":"Copy backlog path",title:"Copy backlog path",children:[e.jsx(st,{name:"copy",size:16}),r?null:"Copy backlog path"]}):null,(()=>{var ee;const B=(Array.isArray((ee=_==null?void 0:_.backlog_queue)==null?void 0:ee.items)?_.backlog_queue.items:[]).map(C=>String((C==null?void 0:C.relpath)||"").trim()).filter(Boolean);return B.length?e.jsxs("button",{className:"btn btn_icon",onClick:()=>yn(B.join(`
84
- `)),disabled:y,"aria-label":"Copy backlog paths",title:"Copy backlog paths",children:[e.jsx(st,{name:"copy",size:16}),r?null:"Copy backlog paths"]}):null})(),p.run_dir_relpath?e.jsxs("button",{className:"btn btn_icon",onClick:()=>yn(p.run_dir_relpath||""),disabled:y,"aria-label":"Copy run dir",title:"Copy run dir",children:[e.jsx(st,{name:"copy",size:16}),r?null:"Copy run dir"]}):null]})]}),e.jsxs("div",{className:"detail_hint",style:{marginTop:0},children:[p.created_at?`created ${new Date(p.created_at).toLocaleString()}`:"",p.started_at?` • started ${new Date(p.started_at).toLocaleString()}`:"",p.finished_at?` • finished ${new Date(p.finished_at).toLocaleString()}`:""]}),p.error?e.jsx("div",{className:"detail_warn",children:p.error}):null,w?e.jsx("div",{className:"detail_warn",children:w}):null,e.jsx("div",{style:{marginTop:"12px"},children:y?e.jsx("div",{className:"empty_note",children:"Loading…"}):e.jsxs(e.Fragment,{children:[e.jsx(Jg,{exec_selected:p,exec_detail:_,exec_qa_feedback:x,set_exec_qa_feedback:N,exec_qa_loading:$,exec_qa_error:P,on_send_feedback:c,on_promote:f,on_deploy_uat:m}),e.jsx(Yg,{exec_selected:p,exec_detail:_}),e.jsx("div",{className:"section_title",children:"Execution"}),e.jsxs("div",{className:"fact_grid",children:[e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"status"}),e.jsx("span",{className:"fact_value",children:p.status||"unknown"})]}),p.executor_type?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"executor"}),e.jsx("span",{className:"fact_value",children:p.executor_type})]}):null,p.target_agent?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"target agent"}),e.jsx("span",{className:"fact_value",children:p.target_agent})]}):null,p.target_model?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"model"}),e.jsxs("span",{className:"fact_value",children:[p.target_model,p.target_reasoning_effort?` (reasoning ${p.target_reasoning_effort})`:""]})]}):null,p.exit_code!=null?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"exit code"}),e.jsx("span",{className:"fact_value",children:String(p.exit_code)})]}):null,F.age_ms!=null?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"age"}),e.jsx("span",{className:"fact_value",children:Os(F.age_ms)})]}):null,F.queue_delay_ms!=null?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"queue delay"}),e.jsx("span",{className:"fact_value",children:Os(F.queue_delay_ms)})]}):null,F.run_ms!=null?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"run time"}),e.jsx("span",{className:"fact_value",children:Os(F.run_ms)})]}):null,F.total_ms!=null&&F.is_done?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"total time"}),e.jsx("span",{className:"fact_value",children:Os(F.total_ms)})]}):null,T?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"commands"}),e.jsxs("span",{className:"fact_value",children:[T.command_count.toLocaleString(),T.command_fail_count?` (${T.command_fail_count.toLocaleString()} failed)`:""]})]}):null,e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"tokens"}),e.jsx("span",{className:"fact_value",children:T!=null&&T.has_tokens?e.jsxs(e.Fragment,{children:["in ",T.input_tokens.toLocaleString(),T.cached_input_tokens?` (cached ${T.cached_input_tokens.toLocaleString()})`:"",", out ",T.output_tokens.toLocaleString(),", total ",T.total_tokens.toLocaleString()]}):e.jsx("span",{className:"muted",children:D==="events"?"n/a":'select "events"'})})]}),p.run_dir_relpath?e.jsxs("div",{className:"fact fact_wide",children:[e.jsx("span",{className:"fact_label",children:"run dir"}),e.jsx("span",{className:"fact_value mono",children:p.run_dir_relpath})]}):null]}),e.jsx(ev,{exec_detail:_}),e.jsx(Xg,{exec_detail:_,exec_qa_loading:$,status:String(p.status||"")}),e.jsx(Zg,{exec_detail:_}),e.jsx(tv,{exec_selected:p,exec_detail:_}),e.jsx("div",{className:"section_divider"}),e.jsx(Kg,{exec_selected:p,exec_detail:_,is_compact_layout:r,exec_log_name:s.exec_log_name,set_exec_log_name:s.set_exec_log_name,exec_log_text:s.exec_log_text,exec_log_loading:s.exec_log_loading,exec_log_error:s.exec_log_error,exec_log_truncated:s.exec_log_truncated,exec_log_auto:s.exec_log_auto,set_exec_log_auto:J=>s.set_exec_log_auto(J),exec_log_scroll_el_ref:s.exec_log_scroll_el_ref,exec_log_follow_ref:s.exec_log_follow_ref,parsed_exec_events:s.parsed_exec_events,load_exec_log_tail:()=>void s.load_exec_log_tail()})]})})]})}function Jg(a){const{exec_selected:s,exec_detail:r,exec_qa_feedback:l,set_exec_qa_feedback:c,exec_qa_loading:f,exec_qa_error:m,on_send_feedback:p,on_promote:_,on_deploy_uat:y}=a;if(String(s.status||"").trim().toLowerCase()!=="awaiting_qa")return null;const x=String((r==null?void 0:r.execution_mode)||"").trim().toLowerCase()||"uat",N=String((r==null?void 0:r.candidate_relpath)||"").trim(),$=String((r==null?void 0:r.candidate_patch_relpath)||"").trim(),P=String((r==null?void 0:r.candidate_manifest_relpath)||"").trim(),T=String((r==null?void 0:r.uat_current_relpath)||"").trim(),F=String((r==null?void 0:r.uat_lock_owner_request_id)||"").trim(),D=!!(r!=null&&r.uat_lock_acquired),J=!!(r!=null&&r.uat_pending),B=(r==null?void 0:r.uat_deploy)??null,ee=String((r==null?void 0:r.uat_deploy_error)||"").trim(),C=r==null?void 0:r.attempt,Z=(r==null?void 0:r.promotion_report)??null,ae=!!(Z!=null&&Z.blocked),fe=String((Z==null?void 0:Z.reason)||"").trim(),ge=Array.isArray(Z==null?void 0:Z.conflicts)?(Z==null?void 0:Z.conflicts).slice(0,8):[],Te=typeof(Z==null?void 0:Z.conflicts_total)=="number"?Number(Z.conflicts_total):ge.length;let Se="",K="";const te=[];try{const z=B==null?void 0:B.processes;if(z&&typeof z=="object"&&!Array.isArray(z)){typeof z.status=="string"&&(Se=String(z.status||"").trim()),typeof z.reason=="string"&&(K=String(z.reason||"").trim());for(const[V,H]of Object.entries(z)){if(!H||typeof H!="object"||Array.isArray(H))continue;const ce=H.probe;!ce||typeof ce!="object"||ce.ok===!1&&te.push(String(V))}}}catch{}return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"section_title",children:"QA decision"}),e.jsxs("div",{className:"fact_grid",children:[e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"mode"}),e.jsx("span",{className:"fact_value",children:x})]}),typeof C=="number"?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"attempt"}),e.jsx("span",{className:"fact_value",children:C})]}):null,x==="uat"&&F?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"uat lock"}),e.jsxs("span",{className:"fact_value",children:[fa(F,18),D?" (owned)":J?" (pending)":""]})]}):null,N?e.jsxs("div",{className:"fact fact_wide",children:[e.jsx("span",{className:"fact_label",children:"candidate"}),e.jsx("span",{className:"fact_value mono",children:N})]}):null,P?e.jsxs("div",{className:"fact fact_wide",children:[e.jsx("span",{className:"fact_label",children:"manifest"}),e.jsx("span",{className:"fact_value mono",children:P})]}):null,$?e.jsxs("div",{className:"fact fact_wide",children:[e.jsx("span",{className:"fact_label",children:"patch"}),e.jsx("span",{className:"fact_value mono",children:$})]}):null,T?e.jsxs("div",{className:"fact fact_wide",children:[e.jsx("span",{className:"fact_label",children:"uat current"}),e.jsx("span",{className:"fact_value mono",children:T})]}):null]}),x==="inplace"?e.jsx("div",{className:"detail_warn",children:"Inplace mode: prod may already be mutated. Approving only finalizes the request status."}):x==="uat"&&J&&F&&!D?e.jsxs("div",{className:"detail_warn",children:["UAT currently points to ",fa(F,16),". Click “Restart UAT” to switch the shared UAT stack to this request."]}):x==="uat"&&D?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"detail_hint",children:["UAT URLs: gateway ",e.jsx("code",{children:"http://localhost:6081"}),", observer ",e.jsx("code",{children:"http://localhost:6082"}),", code ",e.jsx("code",{children:"http://localhost:6083"}),", flow"," ",e.jsx("code",{children:"http://localhost:6084"})]}),e.jsx("div",{className:"detail_hint",children:"UAT is intentionally short-lived: promoting or iterating will stop the shared UAT services."}),te.length?e.jsxs("div",{className:"detail_warn",children:["UAT may be unreachable: URL probe failed for ",te.slice(0,4).join(", "),te.length>4?"…":"",". Click “Restart UAT” and check process logs."]}):null]}):null,x==="uat"&&Se==="skipped"&&K==="process_manager_disabled"?e.jsxs("div",{className:"detail_warn",children:["UAT services were not started: process manager is disabled. Restart the gateway with ",e.jsx("code",{children:"ABSTRACTGATEWAY_ENABLE_PROCESS_MANAGER=1"}),"."]}):null,ee?e.jsxs("div",{className:"detail_warn",children:["UAT deploy failed: ",ee]}):null,ae&&fe==="conflicts"?e.jsxs("div",{className:"detail_warn",children:["Promotion blocked: prod diverged from the candidate base (",Te," conflict",Te===1?"":"s","). Use “Iterate” to re-run the request on top of current prod, or resolve conflicts manually.",ge.length?e.jsx("ul",{style:{marginTop:"8px",paddingLeft:"18px"},children:ge.map((z,V)=>e.jsxs("li",{children:[String((z==null?void 0:z.repo)||""),"/",String((z==null?void 0:z.path)||"")," (",String((z==null?void 0:z.reason)||"conflict"),")"]},`c:${V}`))}):null]}):null,e.jsxs("div",{className:"row",style:{flexWrap:"wrap",gap:"6px",marginTop:"8px"},children:[$?e.jsxs("button",{className:"btn btn_icon",onClick:()=>yn($),disabled:f,children:[e.jsx(st,{name:"copy",size:16}),"Copy patch path"]}):null,P?e.jsxs("button",{className:"btn btn_icon",onClick:()=>yn(P),disabled:f,children:[e.jsx(st,{name:"copy",size:16}),"Copy manifest path"]}):null,N?e.jsxs("button",{className:"btn btn_icon",onClick:()=>yn(N),disabled:f,children:[e.jsx(st,{name:"copy",size:16}),"Copy candidate path"]}):null]}),e.jsx("div",{style:{marginTop:"10px"},children:e.jsx("textarea",{value:l,onChange:z=>c(z.target.value),rows:3,placeholder:"QA feedback (what to change / fix)…",style:{width:"100%",resize:"vertical",minHeight:"72px"},disabled:f})}),m?e.jsx("div",{className:"detail_warn",children:m}):null,e.jsxs("div",{className:"row",style:{flexWrap:"wrap",gap:"8px",marginTop:"10px"},children:[x==="uat"?e.jsx("button",{className:"btn",onClick:y,disabled:f,children:"Restart UAT"}):null,e.jsx("button",{className:"btn primary",onClick:_,disabled:f,children:x==="inplace"?"Approve (finalize)":"Approve → promote to prod"}),e.jsx("button",{className:"btn",onClick:p,disabled:f,children:"Iterate (send feedback)"})]}),e.jsx("div",{className:"section_divider"})]})}function Yg(a){const{exec_selected:s,exec_detail:r}=a;if(String(s.status||"").trim().toLowerCase()!=="promoted")return null;const c=String((r==null?void 0:r.promoted_at)||"").trim(),f=(r==null?void 0:r.promotion)??null,m=(r==null?void 0:r.promotion_report)??null,p=typeof(f==null?void 0:f.copied)=="number"?Number(f==null?void 0:f.copied):null,_=typeof(f==null?void 0:f.deleted)=="number"?Number(f==null?void 0:f.deleted):null,y=String((f==null?void 0:f.manifest_sha256)||"").trim(),w=String((f==null?void 0:f.mode)||"").trim(),x=(m==null?void 0:m.redeploy)??null,N=String((x==null?void 0:x.status)||"").trim(),$=String((x==null?void 0:x.reason)||"").trim(),P=String((m==null?void 0:m.redeploy_error)||"").trim();return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"section_title",children:"Promotion"}),e.jsxs("div",{className:"fact_grid",children:[c?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"promoted at"}),e.jsx("span",{className:"fact_value",children:new Date(c).toLocaleString()})]}):null,w?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"mode"}),e.jsx("span",{className:"fact_value",children:w})]}):null,y?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"manifest sha256"}),e.jsxs("span",{className:"fact_value",children:[y.slice(0,16),"…"]})]}):null,p!=null?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"copied"}),e.jsxs("span",{className:"fact_value",children:[p," files"]})]}):null,_!=null?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"deleted"}),e.jsxs("span",{className:"fact_value",children:[_," files"]})]}):null,N?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"redeploy"}),e.jsxs("span",{className:"fact_value",children:[N,$?` (${$})`:""]})]}):null,P?e.jsxs("div",{className:"fact fact_wide",children:[e.jsx("span",{className:"fact_label",children:"redeploy error"}),e.jsx("span",{className:"fact_value",style:{color:"var(--danger, rgb(248, 113, 113))"},children:P})]}):null]}),e.jsx("div",{className:"section_divider"})]})}function Xg(a){const{exec_detail:s,exec_qa_loading:r}=a;if(String(a.status||"").trim().toLowerCase()==="promoted")return null;const l=s&&typeof s.promotion=="object"?s.promotion:null;if(!l)return null;const c=s&&typeof s.promotion_report=="object"?s.promotion_report:null,f=String((l==null?void 0:l.mode)||"").trim(),m=(l==null?void 0:l.copied)!=null?String(l.copied):"",p=(l==null?void 0:l.deleted)!=null?String(l.deleted):"",_=String((l==null?void 0:l.manifest_sha256)||"").trim(),y=c&&typeof c.redeploy=="object"?c.redeploy:null,w=y?String(y.status||"").trim():"";return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"section_divider"}),e.jsx("div",{className:"section_title",children:"Promotion"}),e.jsxs("div",{className:"fact_grid",children:[f?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"mode"}),e.jsx("span",{className:"fact_value",children:f})]}):null,m?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"copied"}),e.jsxs("span",{className:"fact_value",children:[m," files"]})]}):null,p?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"deleted"}),e.jsxs("span",{className:"fact_value",children:[p," files"]})]}):null,_?e.jsxs("div",{className:"fact fact_wide",children:[e.jsxs("span",{className:"fact_label",children:["manifest sha256"," ",e.jsx("button",{className:"chip_icon_btn",onClick:()=>yn(_),disabled:r,title:"Copy the full sha","aria-label":"Copy manifest sha256",children:e.jsx(st,{name:"copy",size:12})})]}),e.jsxs("span",{className:"fact_value mono",children:[_.slice(0,16),"…"]})]}):null,w?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"redeploy"}),e.jsx("span",{className:"fact_value",children:w})]}):null]})]})}function Zg(a){var l,c;const r=(Array.isArray((c=(l=a.exec_detail)==null?void 0:l.backlog_queue)==null?void 0:c.items)?a.exec_detail.backlog_queue.items:[]).map(f=>String((f==null?void 0:f.relpath)||"").trim()).filter(Boolean);return r.length?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"section_divider"}),e.jsx("div",{className:"section_title",children:"Backlog queue"}),e.jsx("div",{className:"path_list mono",children:r.map(f=>e.jsx("div",{children:f},`bq:${f}`))})]}):null}function ev(a){var _,y,w;const s=((_=a.exec_detail)==null?void 0:_.skills)||((w=(y=a.exec_detail)==null?void 0:y.payload)==null?void 0:w.skills);if(!s||typeof s!="object")return null;const r=Array.isArray(s.requested)?s.requested:[],l=Array.isArray(s.active)?s.active:[],c=s.resolved_tree_hashes&&typeof s.resolved_tree_hashes=="object"?s.resolved_tree_hashes:{},f=Array.isArray(s.verdicts)?s.verdicts:[];if(!r.length&&!l.length&&!f.length)return null;const m=new Set(l.map(x=>String(x))),p=f.filter(x=>{const N=String((x==null?void 0:x.status)||(x==null?void 0:x.state)||"").toLowerCase();return N&&N!=="active"});return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"section_divider"}),e.jsx("div",{className:"section_title",children:"Skills"}),s.source?e.jsx("div",{className:"fact_grid",children:e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"source"}),e.jsx("span",{className:"fact_value",children:String(s.source)})]})}):null,e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,marginTop:4},children:r.map(x=>{const N=m.has(String(x)),$=c[String(x)];return e.jsxs("span",{className:`chip mono ${N?"ok":"warn"}`,title:N?$?`active · ${String($).slice(0,12)}`:"active":"requested but not active — see verdict below",children:[x,N?"":" (held)"]},`skill:${x}`)})}),p.map((x,N)=>{const $=String((x==null?void 0:x.name)||(x==null?void 0:x.skill)||"skill"),P=String((x==null?void 0:x.reason)||(x==null?void 0:x.detail)||(x==null?void 0:x.status)||"held");return e.jsxs("div",{className:"detail_warn",children:[$,": ",P]},`verdict:${N}:${$}`)})]})}function tv(a){var r,l;const s=String(((l=(r=a.exec_detail)==null?void 0:r.result)==null?void 0:l.last_message)||a.exec_selected.last_message||"").trim();return s?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"section_divider"}),e.jsx("div",{className:"section_title",children:"Last message"}),e.jsx("div",{className:"detail_prose",children:e.jsx(as,{className:"md_doc",text:s})})]}):null}const nv=10;function sv(a){const{gateway:s,gateway_connected:r}=a,l=od("(max-width: 900px)"),[c,f]=h.useState("list"),[m,p]=h.useState(null);async function _(){try{const K=await s.admin_executors(),te=Array.isArray(K)?K:Array.isArray(K==null?void 0:K.executors)?K.executors:[];p(te)}catch{p(null)}}h.useEffect(()=>{if(!r){p(null);return}_()},[s,r]);const y=cd({gateway:s,can_use_gateway:r,kind:"processing",completed_view:"tasks",is_exec_view:!0,is_compact_layout:l,set_compact_pane:f,on_status_transfer:()=>{P()}}),[w,x]=h.useState([]),[N,$]=h.useState("");async function P(){if(r)try{const K=await s.backlog_exec_requests({status:"completed,promoted,failed",limit:50}),te=Array.isArray(K==null?void 0:K.requests)?K.requests:[];te.sort((z,V)=>{const H=String(z.finished_at||z.started_at||z.created_at||"");return String(V.finished_at||V.started_at||V.created_at||"").localeCompare(H)}),x(te.slice(0,nv)),$("")}catch(K){$(String((K==null?void 0:K.message)||K||"Failed to load recent executions"))}}h.useEffect(()=>{if(!r)return;(async()=>{var V;const te=await y.refresh_exec_list("processing");await P();const z=String(a.focus_request_id||"").trim();if(z){const H=te.find(ce=>ce.request_id===z);if(H)await y.load_exec_request(H);else try{const ce=await s.backlog_exec_request(z);ce!=null&&ce.payload&&await y.load_exec_request({request_id:z,status:String(ce.payload.status||"unknown")})}catch{}(V=a.on_focus_consumed)==null||V.call(a)}})();const K=setInterval(()=>{s.is_backing_off()||P()},15e3);return()=>clearInterval(K)},[r,a.focus_request_id]);const T=y.exec_requests.some(K=>String(K.status||"").toLowerCase()==="running"),[,F]=h.useState(0);h.useEffect(()=>{if(!T)return;const K=setInterval(()=>F(te=>(te+1)%3600),1e3);return()=>clearInterval(K)},[T]);const D=y.exec_requests,J=h.useMemo(()=>{let K=0,te=0,z=0;for(const V of D){const H=String(V.status||"").trim().toLowerCase();H==="queued"?K+=1:H==="running"?te+=1:H==="awaiting_qa"&&(z+=1)}return{queued:K,running:te,awaiting:z}},[D]),B=y.exec_cfg,ee=!!(B!=null&&B.runner_alive),C=String((B==null?void 0:B.executor)||"").trim(),Z=!C||C==="none",ae=Z?"execution agent":C,fe=!!(B!=null&&B.can_execute),ge=El(y.exec_error)||El(N),Te=!l||c==="list",Se=!l||c==="detail";return e.jsxs("div",{className:"page page_pad exec_page",children:[e.jsxs("div",{className:"page_toolbar",children:[r&&B?e.jsxs("span",{className:`chip mono ${fe?"ok":"warn"}`,title:B.codex_model?`${ae}: ${B.codex_model}${B.codex_reasoning_effort?` (reasoning ${B.codex_reasoning_effort})`:""}`:void 0,children:[Z?"no execution agent":`${ae} worker ${ee?"on":"off"}`,!l&&B.codex_model?` · ${B.codex_model}`:""]}):null,r?null:e.jsx("span",{className:"page_hint",children:"Not connected — use the connection control (top right)."}),!ge&&y.exec_error?e.jsx("span",{className:"page_error mono",children:y.exec_error}):null,e.jsx("div",{className:"page_toolbar_spacer"}),e.jsx("button",{className:`btn btn_icon ${y.exec_loading?"is_loading":""}`,onClick:()=>{y.refresh_exec_list("processing"),P(),y.load_exec_config(),_()},disabled:!r||y.exec_loading,title:"Refresh runs, worker config, and the executor registry","aria-label":"Refresh",children:e.jsx(st,{name:"refresh",size:16})})]}),r&&B&&!fe&&!ge?e.jsxs("div",{className:"callout callout_warn",children:[e.jsx("div",{className:"callout_icon","aria-hidden":"true",children:e.jsx(st,{name:"warning",size:18})}),e.jsxs("div",{className:"callout_main",children:[e.jsxs("div",{className:"callout_title",children:[Z?m!=null&&m.length?"No default executor selected":"No execution agent on this gateway":ee?"The pipeline cannot execute":"The exec worker is not running",e.jsx("span",{className:"chip mono warn",children:Z?"setup required":ee?"cannot execute":"queued until it returns"})]}),e.jsx("p",{className:"callout_text",children:(()=>{if(!Z)return B.runner_error?`The worker reports: ${B.runner_error} — new executions queue until it comes back.`:ee?"The worker is alive but the gateway reports it cannot execute — check the executor configuration below.":"New executions will queue until the worker comes back.";if(!(m!=null&&m.length))return"The gateway serves the pipeline but has no executor configured — nothing can run until one is enabled on the gateway host.";const K=m.map(V=>V.display||V.id),te=K.slice(0,4).join(", ")+(K.length>4?` +${K.length-4} more`:"");return m.some(V=>V.available!==!1)?`The gateway's registry serves ${m.length} executor${m.length===1?"":"s"} (${te}), but no default is selected — pick one in Settings → Gateway administration (gateway admin).`:`The gateway's registry serves ${m.length} executor${m.length===1?"":"s"} (${te}), but none is currently available — install an executor binary on the gateway host (PATH), then pick it in Settings.`})()}),(!(m!=null&&m.length)||!m.some(K=>K.available!==!1))&&(Z||!ee)?e.jsx("pre",{className:"mono setup_callout_pre",children:`ABSTRACTGATEWAY_BACKLOG_EXEC_RUNNER=1 # enables the exec worker
85
- ABSTRACTGATEWAY_BACKLOG_EXECUTOR=codex # canonical ids: codex | claude | cursor-agent | abstractcode
86
- # the agent binary must be on the gateway host PATH (abstractcode: importable)`}):null,e.jsx("div",{className:"callout_actions",children:a.on_open_settings?e.jsx("button",{className:"btn primary",onClick:a.on_open_settings,title:"Settings → Gateway administration (admin-gated; the gateway authorizes every change)",children:"Open Settings"}):null}),e.jsx("p",{className:"callout_text muted",children:"The gateway is the gatekeeper: admins enable the worker and pick the executor from Settings → Gateway administration — changes apply live, no gateway restart (the worker reconciles in-process). Env + restart remains the fallback on gateways without the admin surface."})]})]}):null,ge?e.jsx(ld,{surface:"the execution pipeline"}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"stat_strip",children:[e.jsxs("div",{className:`stat_card ${J.running?"tone_info":""}`,children:[e.jsx("span",{className:"stat_value",children:J.running}),e.jsx("span",{className:"stat_label",children:"running"})]}),e.jsxs("div",{className:`stat_card ${J.awaiting?"tone_warn":""}`,children:[e.jsx("span",{className:"stat_value",children:J.awaiting}),e.jsx("span",{className:"stat_label",children:"awaiting QA"})]}),e.jsxs("div",{className:"stat_card",children:[e.jsx("span",{className:"stat_value",children:J.queued}),e.jsx("span",{className:"stat_label",children:"queued"})]}),e.jsxs("div",{className:`stat_card ${fe?"tone_ok":"tone_danger"}`,children:[e.jsx("span",{className:"stat_value",children:fe?"on":Z?"none":"off"}),e.jsxs("span",{className:"stat_label",children:[ae,Z?"":" worker"]})]})]}),e.jsxs("div",{className:"inbox_layout exec_layout",children:[Te?e.jsxs("div",{className:"exec_side",children:[e.jsxs("div",{className:"pane exec_pane_active",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Active"}),e.jsx("span",{className:"pane_count",children:D.length})]}),e.jsx("div",{className:"pane_body pane_body_list",children:D.length?D.map(K=>{var _e;const te=String(K.status||"").trim().toLowerCase(),z=Cl(K),V=((_e=y.exec_selected)==null?void 0:_e.request_id)===K.request_id,H=te==="running"&&K.started_at?Math.max(0,Date.now()-Date.parse(K.started_at)):null,ce=String(K.backlog_filename||K.backlog_relpath||"").trim(),I=K.target_agent||(K.target_model?`${String(K.executor_type||"agent").trim()||"agent"}:${K.target_model}`:"");return e.jsxs("button",{className:`run_card ${V?"selected":""} ${te==="running"?"is_running":""}`,onClick:()=>void y.load_exec_request(K),children:[e.jsxs("div",{className:"run_card_head",children:[e.jsx("span",{className:"run_card_title",title:ce,children:ce||`request ${fa(K.request_id,12)}`}),e.jsx("span",{className:`chip mono ${kl(te)}`,children:te||"unknown"})]}),e.jsxs("div",{className:"run_card_meta",children:[e.jsx("span",{className:"run_card_time",children:H!==null?`running ${Os(H)}`:z.queue_delay_ms!=null?`queued ${Os(z.queue_delay_ms)}`:" "}),I?e.jsx("span",{className:"chip mono muted",children:I}):null,e.jsx("span",{className:"run_card_id mono",children:fa(K.request_id,14)})]})]},K.request_id)}):e.jsx("div",{className:"empty_note",children:"Nothing is executing right now. Execute a Ready item from the Board (or Backlog)."})})]}),e.jsxs("div",{className:"pane exec_pane_recent",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Recently finished"}),e.jsx("span",{className:"pane_count",children:w.length})]}),e.jsxs("div",{className:"pane_body",style:{padding:0},children:[N&&!ge?e.jsx("div",{className:"page_error mono",style:{padding:"10px 12px"},children:N}):null,!N&&!w.length?e.jsx("div",{className:"empty_note",style:{padding:"10px 12px"},children:"No finished executions yet."}):null,w.length?e.jsx("div",{className:"recent_list",children:w.map(K=>{var ce;const te=String(K.status||"").trim().toLowerCase(),z=Cl(K),V=((ce=y.exec_selected)==null?void 0:ce.request_id)===K.request_id,H=fa(K.backlog_filename||K.backlog_relpath||"request",44);return e.jsxs("button",{className:`recent_row ${V?"selected":""}`,onClick:()=>void y.load_exec_request(K),title:String(K.backlog_filename||K.backlog_relpath||K.request_id),children:[e.jsx("span",{className:`chip mono ${kl(te)}`,children:te||"?"}),e.jsx("span",{className:"recent_row_name",children:H}),e.jsx("span",{className:"recent_row_time mono",children:z.run_ms!=null?Os(z.run_ms):""})]},`recent:${K.request_id}`)})}):null]})]})]}):null,Se?e.jsxs("div",{className:"pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Run detail"}),y.exec_selected?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:`chip mono ${kl(String(y.exec_selected.status||"").toLowerCase())}`,children:String(y.exec_selected.status||"?").toLowerCase()}),e.jsx("span",{className:"pane_count mono",children:fa(y.exec_selected.request_id,20)})]}):e.jsx("span",{className:"pane_count",children:"select a run"})]}),e.jsx("div",{className:"pane_body",children:e.jsx(Qg,{pipeline:y,is_compact_layout:l,on_back_to_list:()=>f("list"),on_send_feedback:()=>void y.exec_send_feedback(async()=>{await y.refresh_exec_list("processing")}),on_promote:()=>void y.exec_promote_to_prod(async()=>{await y.refresh_exec_list("processing"),await P()}),on_deploy_uat:()=>void y.exec_deploy_uat_now(async()=>{await y.refresh_exec_list("processing")})})})]}):null]})]})]})}function $u(a,s){const r=String(a||"");return r.length<=s?r:`${r.slice(0,Math.max(0,s-1))}…`}function av(a){const s=String(a||"").trim().toLowerCase();return s==="running"?{cls:"ok",label:"running"}:s==="stopped"?{cls:"muted",label:"stopped"}:s.includes("restart")?{cls:"warn",label:s}:s.includes("error")||s.includes("failed")?{cls:"danger",label:s||"error"}:{cls:"warn",label:s||"unknown"}}function yf(a){const s=r=>{const l=String((r==null?void 0:r.id)||"").trim(),c=l.endsWith("_uat")?l.slice(0,-4):l;return c==="gateway"?0:c==="build"?1:c==="abstractobserver"?2:c==="abstractcode_web"?3:c==="abstractflow_backend"?4:c==="abstractflow_frontend"?5:10};return[...a||[]].sort((r,l)=>{const c=s(r),f=s(l);if(c!==f)return c-f;const m=String((r==null?void 0:r.label)||(r==null?void 0:r.id)||"").toLowerCase(),p=String((l==null?void 0:l.label)||(l==null?void 0:l.id)||"").toLowerCase();return m<p?-1:m>p?1:0})}function rv(a){const s=String(a||"").trim().toLowerCase();return s==="override"?{cls:"ok",label:"override"}:s.startsWith("inherited")?{cls:"info",label:s}:s==="unset"?{cls:"warn",label:"unset"}:!s||s==="missing"?{cls:"muted",label:"missing"}:{cls:"muted",label:s}}function iv({gateway:a,gateway_connected:s}){const[r,l]=h.useState("prod"),[c,f]=h.useState(null),[m,p]=h.useState([]),[_,y]=h.useState(!1),[w,x]=h.useState(""),[N,$]=h.useState(!1),[P,T]=h.useState(null),[F,D]=h.useState([]),[J,B]=h.useState(!1),[ee,C]=h.useState(""),[Z,ae]=h.useState({}),[fe,ge]=h.useState(!1),[Te,Se]=h.useState(null),[K,te]=h.useState(""),[z,V]=h.useState(""),[H,ce]=h.useState(!1),I=h.useRef(null),_e=h.useMemo(()=>yf(m.filter(re=>!String((re==null?void 0:re.id)||"").trim().endsWith("_uat"))),[m]),Y=h.useMemo(()=>yf(m.filter(re=>String((re==null?void 0:re.id)||"").trim().endsWith("_uat"))),[m]),S=r==="uat"?Y:_e,A=h.useCallback(async()=>{if(s){y(!0),x("");try{const re=await a.list_processes();f(!!(re!=null&&re.enabled));const xe=Array.isArray(re==null?void 0:re.processes)?re.processes:[];p(xe)}catch(re){x(String((re==null?void 0:re.message)||re||"Failed to list processes"))}finally{y(!1)}}},[a,s]),U=h.useCallback(async()=>{if(s){B(!0),C("");try{const re=await a.list_process_env_vars();T(!!(re!=null&&re.enabled));const xe=Array.isArray(re==null?void 0:re.vars)?re.vars:[];D(xe);const O=String((re==null?void 0:re.error)||"").trim();O&&C(O)}catch(re){C(String((re==null?void 0:re.message)||re||"Failed to list env vars"))}finally{B(!1)}}},[a,s]),ie=h.useCallback(async()=>{if(!s)return;const re=Te;if(re){ce(!0);try{const xe=await a.process_log_tail(String(re.id||""),{max_bytes:16e4}),O=String((xe==null?void 0:xe.content)||""),me=typeof(xe==null?void 0:xe.bytes)=="number"?Number(xe.bytes):0,De=!!(xe!=null&&xe.truncated),G=String((xe==null?void 0:xe.log_relpath)||"");te(O),V(`${me.toLocaleString()} bytes${De?" (tail)":""}${G?` • ${G}`:""}`)}catch(xe){te(""),V(String((xe==null?void 0:xe.message)||xe||"Failed to read logs"))}finally{ce(!1)}}},[a,s,Te]),de=h.useCallback(async re=>{Se(re),ge(!0)},[]),L=h.useCallback(()=>{ge(!1),Se(null),te(""),V("")},[]);h.useEffect(()=>{s&&A()},[s,A]),h.useEffect(()=>{if(!s||r==="env"||!N)return;const re=window.setInterval(()=>{a.is_backing_off()||A()},2e3);return()=>window.clearInterval(re)},[s,r,N,A,a]),h.useEffect(()=>{s&&r==="env"&&U()},[s,r,U]),h.useEffect(()=>{if(s&&fe)return ie(),I.current&&window.clearInterval(I.current),I.current=window.setInterval(()=>{a.is_backing_off()||ie()},1500),()=>{I.current&&window.clearInterval(I.current),I.current=null}},[s,fe,ie]);const ke=h.useRef(!1),[be,Ie]=h.useState(!1);async function Fe(re,xe){if(!ke.current){ke.current=!0,Ie(!0),x("");try{xe==="start"?await a.start_process(re.id):xe==="stop"?await a.stop_process(re.id):xe==="restart"?await a.restart_process(re.id):xe==="redeploy"&&await a.redeploy_process(re.id),await A()}catch(O){x(String((O==null?void 0:O.message)||O||`Failed to ${xe}`))}finally{ke.current=!1,Ie(!1)}}}async function Ye(re){const xe=String(re||"").trim();if(xe){C("");try{const O=String((Z==null?void 0:Z[xe])??""),me=await a.update_process_env_vars({set:{[xe]:O}});T(!!(me!=null&&me.enabled)),D(Array.isArray(me==null?void 0:me.vars)?me.vars:[]),ae(G=>({...G||{},[xe]:""}));const De=String((me==null?void 0:me.error)||"").trim();De&&C(De)}catch(O){C(String((O==null?void 0:O.message)||O||"Failed to set env var"))}}}async function he(re){const xe=String(re||"").trim();if(xe){C("");try{const O=await a.update_process_env_vars({unset:[xe]});T(!!(O!=null&&O.enabled)),D(Array.isArray(O==null?void 0:O.vars)?O.vars:[]),ae(De=>({...De||{},[xe]:""}));const me=String((O==null?void 0:O.error)||"").trim();me&&C(me)}catch(O){C(String((O==null?void 0:O.message)||O||"Failed to unset env var"))}}}const Re=c===null?"…":c?"enabled":"disabled",ze=P===null?"…":P?"enabled":"disabled";return e.jsx("div",{className:"page page_scroll",children:e.jsxs("div",{className:"page_inner page_pad constrained",children:[e.jsxs("div",{className:"page_toolbar",children:[e.jsxs("div",{className:"seg",role:"group","aria-label":"Service views",children:[e.jsx("button",{"aria-pressed":r==="prod",className:`seg_btn ${r==="prod"?"active":""}`,onClick:()=>l("prod"),children:"Production"}),e.jsx("button",{"aria-pressed":r==="uat",className:`seg_btn ${r==="uat"?"active":""}`,onClick:()=>l("uat"),children:"UAT"}),e.jsx("button",{"aria-pressed":r==="env",className:`seg_btn ${r==="env"?"active":""}`,onClick:()=>l("env"),children:"ENV"})]}),s?null:e.jsx("span",{className:"page_hint mono",children:"Not connected — use the connection badge in the sidebar."}),s&&r!=="env"?e.jsxs("span",{className:`chip mono ${c===!1?"warn":"muted"}`,children:["manager ",Re]}):null,s&&r==="env"?e.jsxs("span",{className:`chip mono ${P===!1?"warn":"muted"}`,children:["env ",ze]}):null,e.jsx("div",{className:"page_toolbar_spacer"}),r!=="env"?e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"btn btn_icon",style:{display:"inline-flex",alignItems:"center",gap:"8px"},children:[e.jsx("input",{type:"checkbox",checked:N,onChange:re=>$(!!re.target.checked)}),"auto"]}),e.jsxs("button",{className:`btn btn_icon ${_?"is_loading":""}`,onClick:()=>void A(),disabled:!s||_,children:[e.jsx(st,{name:"refresh",size:16}),_?"Refreshing…":"Refresh"]})]}):e.jsxs("button",{className:`btn btn_icon ${J?"is_loading":""}`,onClick:()=>void U(),disabled:!s||J,children:[e.jsx(st,{name:"refresh",size:16}),J?"Refreshing…":"Refresh"]})]}),s&&r!=="env"&&c===!1?e.jsxs("div",{className:"page_hint mono",children:["To manage processes, set ",e.jsx("span",{className:"mono",children:"ABSTRACTGATEWAY_ENABLE_PROCESS_MANAGER=1"})," and"," ",e.jsx("span",{className:"mono",children:"ABSTRACTGATEWAY_TRIAGE_REPO_ROOT"})," (your AbstractFramework checkout root) on the gateway host."]}):null,s&&r==="env"&&P===!1?e.jsxs("div",{className:"page_hint mono",children:["Set ",e.jsx("span",{className:"mono",children:"ABSTRACTGATEWAY_ENABLE_PROCESS_MANAGER=1"})," on the gateway host."]}):null,r!=="env"&&w?e.jsx("div",{className:"page_error mono",children:w}):null,r==="env"&&ee?e.jsx("div",{className:"page_error mono",children:ee}):null,s&&r!=="env"?e.jsxs("div",{className:"pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:r==="uat"?"UAT services":"Production services"}),e.jsx("span",{className:"pane_count",children:S.length})]}),e.jsxs("div",{className:"pane_body pane_body_list",children:[S.length?null:e.jsxs("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",padding:"6px 4px"},children:["No ",r==="uat"?"UAT":"production"," processes reported."]}),S.map(re=>{const xe=String(re.id||"").trim(),O=String(re.label||xe).trim()||xe,me=av(String(re.status||"")),G=String(re.status||"").trim().toLowerCase()==="running",le=Array.isArray(re==null?void 0:re.actions)?re.actions.map(wt=>String(wt||"").trim()):[],ye=le.includes("start"),Oe=le.includes("stop"),ot=le.includes("restart"),xt=le.includes("redeploy"),pe=le.includes("logs"),R=typeof(re==null?void 0:re.pid)=="number"?Number(re.pid):null,X=String((re==null?void 0:re.url)||"").trim(),$e=String((re==null?void 0:re.description)||"").trim(),Ae=String((re==null?void 0:re.last_error)||"").trim(),Ge=typeof(re==null?void 0:re.exit_code)=="number"?Number(re.exit_code):null,et=[];R&&et.push(`pid ${R}`),Ge!==null&&et.push(`exit ${Ge}`);const ct=et.join(" • ");return e.jsxs("div",{className:"entity_card",children:[e.jsxs("div",{className:"entity_card_head",children:[e.jsx("span",{className:"entity_card_title",children:O}),e.jsx("span",{className:`chip mono ${me.cls}`,children:me.label}),e.jsx("span",{className:"chip mono muted",children:xe}),ct?e.jsx("span",{className:"entity_card_sub mono",children:ct}):null]}),$e?e.jsx("div",{className:"entity_card_sub mono",children:$u($e,220)}):null,X?e.jsx("div",{className:"entity_card_sub mono",children:G?e.jsx("a",{href:X,target:"_blank",rel:"noreferrer",className:"mono",style:{opacity:.95},children:X}):e.jsx("span",{className:"mono",children:X})}):null,Ae?e.jsx("div",{className:"page_error mono",children:$u(Ae,360)}):null,e.jsxs("div",{className:"entity_card_actions",children:[ye?e.jsx("button",{className:"btn primary",onClick:()=>void Fe(re,"start"),disabled:_||be,children:"Start"}):null,Oe?e.jsx("button",{className:"btn danger",onClick:()=>void Fe(re,"stop"),disabled:_||be,children:"Stop"}):null,ot?e.jsx("button",{className:"btn",onClick:()=>void Fe(re,"restart"),disabled:_||be,children:"Restart"}):null,xt?e.jsx("button",{className:"btn",onClick:()=>void Fe(re,"redeploy"),disabled:_||be,children:"Redeploy"}):null,pe?e.jsx("button",{className:"btn",onClick:()=>void de(re),disabled:_,children:"Logs"}):null]})]},xe)})]})]}):null,s&&r==="env"?e.jsxs("div",{className:"pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Environment variables"}),e.jsx("span",{className:"pane_count",children:F.length}),e.jsx("span",{className:"pane_header_actions mono muted",style:{fontSize:"var(--font-size-xs)"},children:"write-only: the gateway will never return env var values to the browser"})]}),e.jsxs("div",{className:"pane_body pane_body_list",children:[F.map(re=>{const xe=String((re==null?void 0:re.key)||"").trim();if(!xe)return null;const O=String((re==null?void 0:re.label)||xe).trim()||xe,me=String((re==null?void 0:re.description)||"").trim(),De=String((re==null?void 0:re.source)||"").trim(),G=!!(re!=null&&re.secret),le=String((re==null?void 0:re.updated_at)||"").trim(),ye=rv(De),Oe=String((Z==null?void 0:Z[xe])??"");return e.jsxs("div",{className:"entity_card",children:[e.jsxs("div",{className:"entity_card_head",children:[e.jsx("span",{className:"entity_card_title",children:O}),e.jsx("span",{className:`chip mono ${ye.cls}`,children:ye.label}),e.jsx("span",{className:"chip mono muted",children:xe})]}),me?e.jsx("div",{className:"entity_card_sub mono",children:$u(me,280)}):null,le?e.jsxs("div",{className:"entity_card_sub mono",children:["updated ",le]}):null,e.jsxs("div",{className:"entity_card_actions",children:[e.jsx("input",{className:"input",value:Oe,onChange:ot=>ae(xt=>({...xt||{},[xe]:String(ot.target.value||"")})),placeholder:G?"••••••••":"value",type:G?"password":"text",style:{flex:"1 1 320px",minWidth:"220px"},autoComplete:"off",spellCheck:!1}),e.jsx("button",{className:"btn primary",onClick:()=>void Ye(xe),disabled:J,children:"Set"}),e.jsx("button",{className:"btn",onClick:()=>void he(xe),disabled:J,children:"Unset"})]})]},`env:${xe}`)}),F.length?null:e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",padding:"6px 4px"},children:"No env vars available (process manager must be enabled)."})]})]}):null,fe&&Te?e.jsxs(qa,{open:fe,title:`${String(Te.label||Te.id||"logs").trim()||"Logs"}`,onClose:L,children:[e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:z}),e.jsxs("div",{className:"actions",style:{marginTop:"10px"},children:[e.jsxs("button",{className:`btn btn_icon ${H?"is_loading":""}`,onClick:()=>void ie(),disabled:H,children:[e.jsx(st,{name:"refresh",size:16}),H?"Refreshing…":"Refresh"]}),e.jsxs("button",{className:"btn btn_icon",onClick:()=>{try{navigator.clipboard.writeText(K||"")}catch{}},disabled:!K,children:[e.jsx(st,{name:"copy",size:16}),"Copy"]})]}),e.jsx("pre",{className:"mono",style:{marginTop:"10px",padding:"10px",borderRadius:"10px",border:"1px solid rgba(255,255,255,0.12)",background:"rgba(0,0,0,0.22)",overflowX:"auto",maxHeight:"55vh",whiteSpace:"pre-wrap"},children:K||"(no logs yet)"})]}):null]})})}function xf(a){const s=String(a||"").trim();if(!s)return"";const r=Date.parse(s);return Number.isFinite(r)?new Date(r).toLocaleString():s}function _l(a,s){const r=String(a||"");return r.length<=s?r:`${r.slice(0,Math.max(0,s-1))}…`}function Eu(a){const s=String(a||"").split(/[,\n]/g).map(r=>r.trim()).filter(Boolean);return s.length<=1?s[0]||"":s}function lv(a){const s=a.gateway,[r,l]=h.useState([]),[c,f]=h.useState(""),[m,p]=h.useState(""),[_,y]=h.useState(""),[w,x]=h.useState("7d"),[N,$]=h.useState("unread"),[P,T]=h.useState(25),[F,D]=h.useState(!1),[J,B]=h.useState(!1),[ee,C]=h.useState(!1),[Z,ae]=h.useState(!1),[fe,ge]=h.useState(""),[Te,Se]=h.useState(""),[K,te]=h.useState(""),[z,V]=h.useState([]),[H,ce]=h.useState(""),[I,_e]=h.useState(null),[Y,S]=h.useState(!1),[A,U]=h.useState(""),[ie,de]=h.useState(""),[L,ke]=h.useState(""),[be,Ie]=h.useState(""),[Fe,Ye]=h.useState(""),he=a.enabled,Re=h.useMemo(()=>(Array.isArray(r)?r:[]).map(X=>({account:String((X==null?void 0:X.account)||"").trim(),can_read:(X==null?void 0:X.can_read)!==!1,can_send:(X==null?void 0:X.can_send)!==!1,label:""})).filter(X=>!!X.account),[r]),ze=h.useMemo(()=>{const R=String(m||"").trim();return R&&Re.find(X=>X.account===R)||null},[Re,m]),re=!!(ze!=null&&ze.can_read),xe=!!(ze!=null&&ze.can_send),O=h.useMemo(()=>Re.map(R=>{const X=R.can_read?R.can_send?"":" (read-only)":" (send-only)";return{...R,label:`${R.account}${X}`}}),[Re]);async function me(){if(he){ge(""),D(!0);try{const R=await s.email_list_accounts();l(Array.isArray(R==null?void 0:R.accounts)?R.accounts:[]),f(String((R==null?void 0:R.default_account)||"").trim())}catch(R){ge(String((R==null?void 0:R.message)||R||"Failed to list email accounts")),l([]),f("")}finally{D(!1)}}}h.useEffect(()=>{me()},[he]),h.useEffect(()=>{if(!he)return;const R=String(m||"").trim();if(R&&Re.some($e=>$e.account===R))return;const X=String(localStorage.getItem("abstractcontinuum_email_account")||"").trim();if(X&&Re.some($e=>$e.account===X)){p(X);return}if(c&&Re.some($e=>$e.account===c)){p(c);return}Re.length&&p(Re[0].account)},[he,m,c,Re]),h.useEffect(()=>{const R=String(m||"").trim();R&&localStorage.setItem("abstractcontinuum_email_account",R)},[m]);async function De(){if(!he)return;const R=String(m||"").trim();if(R){if(!re){ge("Selected account is not allowed to read email."),V([]),ce(""),_e(null);return}ge(""),B(!0);try{const X=await s.email_list_messages({account:R,mailbox:String(_||"").trim()||void 0,since:String(w||"").trim()||void 0,status:N,limit:P}),$e=Array.isArray(X==null?void 0:X.messages)?X.messages:[];V($e);const Ae=String(H||"").trim();Ae&&!$e.some(Ge=>String((Ge==null?void 0:Ge.uid)||"").trim()===Ae)&&(ce(""),_e(null))}catch(X){ge(String((X==null?void 0:X.message)||X||"Failed to list emails")),V([]),ce(""),_e(null)}finally{B(!1)}}}h.useEffect(()=>{he&&String(m||"").trim()&&De()},[he,m]);async function G(R){if(!he)return;const X=String(m||"").trim(),$e=String(R||"").trim();if(!(!X||!$e)&&re){ce($e),_e(null),Se(""),C(!0);try{const Ae=await s.email_read_message($e,{account:X,mailbox:String(_||"").trim()||void 0,max_body_chars:2e4});_e(Ae)}catch(Ae){Se(String((Ae==null?void 0:Ae.message)||Ae||"Failed to read email"))}finally{C(!1)}}}function le(R){te(""),U(String((R==null?void 0:R.to)||"").trim()),de(""),ke(""),Ie(String((R==null?void 0:R.subject)||"").trim()),Ye(String((R==null?void 0:R.body)||"")),S(!0)}function ye(){if(!I)return;const R=String((I==null?void 0:I.from)||"").trim(),X=String((I==null?void 0:I.subject)||"").trim(),$e=X.toLowerCase().startsWith("re:")?X:`Re: ${X||"(no subject)"}`,Ae=String((I==null?void 0:I.body_text)||"").trim(),Ge=`
87
-
88
- ---
89
- On ${xf((I==null?void 0:I.date)||"")}, ${R} wrote:
90
-
91
- ${Ae}`;le({to:R,subject:$e,body:Ge})}async function Oe(){if(!he||Z)return;const R=String(m||"").trim();if(R){if(!xe){te("Selected account is not allowed to send email.");return}te(""),ae(!0);try{const X=Eu(A);if(!X)throw new Error("to is required");const $e=String(be||"").trim();if(!$e)throw new Error("subject is required");const Ae=String(Fe||"").trim();if(!Ae)throw new Error("body is required");await s.email_send({account:R,to:X,subject:$e,body_text:Ae,cc:Eu(ie),bcc:Eu(L)}),S(!1),U(""),de(""),ke(""),Ie(""),Ye(""),await De()}catch(X){te(String((X==null?void 0:X.message)||X||"Failed to send email"))}finally{ae(!1)}}}const ot=h.useMemo(()=>{const R=String(H||"").trim();return R&&z.find(X=>String((X==null?void 0:X.uid)||"").trim()===R)||null},[z,H]),xt=String((I==null?void 0:I.body_text)||"").trim()||String((I==null?void 0:I.body_html)||"").trim(),pe=String((I==null?void 0:I.body_text)||"").trim()?"Body (text)":String((I==null?void 0:I.body_html)||"").trim()?"Body (html, raw)":"Body";return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"inbox_layout exec_layout",children:[e.jsxs("div",{className:"pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Email"}),e.jsx("span",{className:"pane_count",children:z.length})]}),e.jsxs("div",{className:"pane_body",style:{display:"flex",flexDirection:"column",gap:"10px"},children:[e.jsxs("div",{className:"row",style:{alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{className:"row",style:{gap:"8px",alignItems:"center"},children:[e.jsx("select",{value:m,onChange:R=>p(String(R.target.value||"")),disabled:!he||F,children:O.length?O.map(R=>e.jsx("option",{value:R.account,children:R.label},R.account)):e.jsx("option",{value:"",children:"(no accounts)"})}),e.jsx("button",{className:"btn",onClick:()=>void me(),disabled:!he||F,children:F?"Loading…":"Accounts"})]}),e.jsxs("div",{className:"row",style:{gap:"8px",justifyContent:"flex-end"},children:[e.jsx("button",{className:"btn",onClick:()=>void De(),disabled:!he||J||!String(m||"").trim()||!re,children:J?"Refreshing…":"Refresh"}),e.jsx("button",{className:"btn primary",onClick:()=>le(),disabled:!he||!String(m||"").trim()||!xe,children:"Compose"})]})]}),e.jsxs("div",{className:"row",style:{gap:"8px",alignItems:"center",flexWrap:"wrap"},children:[e.jsxs("div",{className:"field",style:{margin:0,minWidth:120,flex:"1 1 120px"},children:[e.jsx("label",{children:"Since"}),e.jsx("input",{value:w,onChange:R=>x(String(R.target.value||"")),placeholder:"7d"})]}),e.jsxs("div",{className:"field",style:{margin:0,minWidth:120,flex:"0 0 120px"},children:[e.jsx("label",{children:"Status"}),e.jsxs("select",{value:N,onChange:R=>$(String(R.target.value||"all")),children:[e.jsx("option",{value:"all",children:"all"}),e.jsx("option",{value:"unread",children:"unread"}),e.jsx("option",{value:"read",children:"read"})]})]}),e.jsxs("div",{className:"field",style:{margin:0,minWidth:120,flex:"0 0 120px"},children:[e.jsx("label",{children:"Limit"}),e.jsx("input",{value:String(P),onChange:R=>T(Number(R.target.value||"0")||25),inputMode:"numeric",placeholder:"25"})]}),e.jsxs("div",{className:"field",style:{margin:0,minWidth:160,flex:"1 1 160px"},children:[e.jsx("label",{children:"Mailbox"}),e.jsx("input",{value:_,onChange:R=>y(String(R.target.value||"")),placeholder:"INBOX"})]}),e.jsx("div",{className:"row",style:{gap:"8px",alignItems:"center",marginTop:"18px"},children:e.jsx("button",{className:"btn",onClick:()=>void De(),disabled:!he||J||!String(m||"").trim()||!re,children:"Apply"})})]}),fe?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)"},children:fe}):null,e.jsx("div",{className:"inbox_list",children:z.length?z.map((R,X)=>{const $e=String((R==null?void 0:R.uid)||"").trim(),Ae=!!$e&&$e===String(H||"").trim(),Ge=String((R==null?void 0:R.subject)||"").trim()||"(no subject)",et=String((R==null?void 0:R.from)||"").trim(),ct=String((R==null?void 0:R.date)||"").trim(),wt=!!(R!=null&&R.seen);return e.jsxs("button",{className:`inbox_item ${Ae?"active":""}`,onClick:()=>void G($e),children:[e.jsxs("div",{className:"inbox_item_title",children:[e.jsx("span",{className:`pill ${wt?"approved":"pending"}`,children:wt?"read":"unread"}),e.jsx("span",{className:"item_title_text",children:_l(Ge,52)})]}),e.jsx("div",{className:"inbox_item_meta mono muted",children:_l(et,60)||"(from?)"}),e.jsxs("div",{className:"inbox_item_meta mono muted",children:[_l(ct,36)||"(date?)"," • uid ",_l($e,10)]})]},$e||`idx:${X}`)}):e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"No messages."})})]})]}),e.jsx("div",{className:"pane",children:e.jsx("div",{className:"pane_body",children:H?ee?e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Loading email…"}):Te?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)"},children:Te}):I?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"row",style:{alignItems:"center",justifyContent:"space-between",gap:"8px",flexWrap:"wrap"},children:[e.jsxs("div",{className:"row",style:{gap:"8px",alignItems:"center",flexWrap:"wrap"},children:[e.jsx("div",{className:"mono",style:{fontWeight:700},children:String((I==null?void 0:I.subject)||"").trim()||"(no subject)"}),e.jsx("span",{className:"pill muted",children:String((I==null?void 0:I.account)||"").trim()||m}),e.jsx("span",{className:"pill muted",children:String((I==null?void 0:I.mailbox)||"").trim()||"(mailbox?)"}),e.jsxs("span",{className:"pill muted",children:["uid ",_l(String((I==null?void 0:I.uid)||H),12)]})]}),e.jsxs("div",{className:"row",style:{gap:"8px",justifyContent:"flex-end"},children:[e.jsx("button",{className:"btn",onClick:()=>yn(String((I==null?void 0:I.message_id)||"")),disabled:!String((I==null?void 0:I.message_id)||"").trim(),title:"Copy Message-ID",children:"Copy msg-id"}),e.jsx("button",{className:"btn",onClick:()=>yn(String(H||"")),disabled:!String(H||"").trim(),title:"Copy UID",children:"Copy uid"}),e.jsx("button",{className:"btn primary",onClick:()=>ye(),disabled:!xe||!String((I==null?void 0:I.from)||"").trim(),children:"Reply"})]})]}),e.jsx("div",{className:"section_divider"}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"From"}),e.jsx("div",{className:"mono",children:String((I==null?void 0:I.from)||"").trim()||"(from?)"})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"To"}),e.jsx("div",{className:"mono",children:String((I==null?void 0:I.to)||"").trim()||"(to?)"})]}),String((I==null?void 0:I.cc)||"").trim()?e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Cc"}),e.jsx("div",{className:"mono",children:String((I==null?void 0:I.cc)||"").trim()})]}):null,e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Date"}),e.jsx("div",{className:"mono",children:xf(String((I==null?void 0:I.date)||(ot==null?void 0:ot.date)||"").trim())||String((I==null?void 0:I.date)||(ot==null?void 0:ot.date)||"").trim()||"(date?)"})]}),Array.isArray(I==null?void 0:I.attachments)&&I.attachments.length?e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Attachments"}),e.jsx("div",{className:"mono",children:I.attachments.map((R,X)=>e.jsxs("div",{children:[String((R==null?void 0:R.filename)||"").trim()||"(file?)"," ",e.jsx("span",{className:"muted",children:String((R==null?void 0:R.content_type)||"").trim()?`(${String((R==null?void 0:R.content_type)||"").trim()})`:""})]},`${(R==null?void 0:R.filename)||""}:${X}`))})]}):null,e.jsx("div",{className:"section_divider"}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:pe}),e.jsx("pre",{className:"mono",style:{whiteSpace:"pre-wrap",wordBreak:"break-word",padding:"10px",borderRadius:"10px",border:"1px solid rgba(255, 255, 255, 0.10)",background:"rgba(0, 0, 0, 0.12)",maxHeight:"60vh",overflow:"auto"},children:xt||"(empty)"})]})]}):e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Select an email to read."}):e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Select an email to read."})})})]}),e.jsxs(qa,{open:Y,title:`Compose (${String(m||"").trim()||"account"})`,onClose:()=>{Z||S(!1)},actions:e.jsxs("div",{className:"row",style:{gap:"8px",justifyContent:"flex-end"},children:[K?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginRight:"auto"},children:K}):null,e.jsx("button",{className:"btn",onClick:()=>S(!1),disabled:Z,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:()=>void Oe(),disabled:Z,children:Z?"Sending…":"Send"})]}),children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"To"}),e.jsx("input",{value:A,onChange:R=>U(String(R.target.value||"")),placeholder:"you@example.com"})]}),e.jsxs("div",{className:"row",style:{gap:"10px",flexWrap:"wrap"},children:[e.jsxs("div",{className:"field",style:{flex:"1 1 220px"},children:[e.jsx("label",{children:"Cc"}),e.jsx("input",{value:ie,onChange:R=>de(String(R.target.value||"")),placeholder:"(optional)"})]}),e.jsxs("div",{className:"field",style:{flex:"1 1 220px"},children:[e.jsx("label",{children:"Bcc"}),e.jsx("input",{value:L,onChange:R=>ke(String(R.target.value||"")),placeholder:"(optional)"})]})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Subject"}),e.jsx("input",{value:be,onChange:R=>Ie(String(R.target.value||"")),placeholder:"Subject"})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Body (text)"}),e.jsx("textarea",{value:Fe,onChange:R=>Ye(String(R.target.value||"")),placeholder:"Write your message…"})]}),e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-xs)"},children:"Tip: separate multiple recipients with commas or newlines."})]})]})}function wf(a){const s=String(a||"").trim();if(!s)return"";const r=s.split("/").filter(Boolean);return r.length?r[r.length-1]:""}function Bo(a){const s=String(a||"").trim();if(!s)return"";const r=Date.parse(s);return Number.isFinite(r)?new Date(r).toLocaleString():s}function _i(a,s){const r=String(a||"");return r.length<=s?r:`${r.slice(0,Math.max(0,s-1))}…`}function ov(a){const s=a.gateway,r=!!a.enable_triage,[l,c]=h.useState(r?"messages":"email"),[f,m]=h.useState([]),[p,_]=h.useState([]),[y,w]=h.useState([]),[x,N]=h.useState(!1),[$,P]=h.useState(""),[T,F]=h.useState(null),[D,J]=h.useState(""),[B,ee]=h.useState(!1),[C,Z]=h.useState(""),[ae,fe]=h.useState("pending"),[ge,Te]=h.useState(null),[Se,K]=h.useState(""),[te,z]=h.useState(null),[V,H]=h.useState(""),[ce,I]=h.useState(!1),[_e,Y]=h.useState(!1),[S,A]=h.useState(""),[U,ie]=h.useState(""),de=!!U,[L,ke]=h.useState(""),[be,Ie]=h.useState(""),[Fe,Ye]=h.useState(""),[he,Re]=h.useState(!1),ze=a.gateway_connected;h.useEffect(()=>{!r&&l!=="email"&&c("email")},[r,l]);const re=h.useMemo(()=>l==="bugs"?f:l==="features"?p:[],[l,f,p]);h.useEffect(()=>{l==="email"&&(P(""),N(!1))},[l]);async function xe(){const pe=await s.list_bug_reports();m(Array.isArray(pe==null?void 0:pe.items)?pe.items:[])}async function O(){const pe=await s.list_feature_requests();_(Array.isArray(pe==null?void 0:pe.items)?pe.items:[])}async function me(){const pe=await s.list_triage_decisions({status:ae||void 0,limit:500}),R=Array.isArray(pe==null?void 0:pe.decisions)?pe.decisions:[];w(R),ge&&!R.some(X=>X.decision_id===ge.decision_id)&&(Te(null),K(""),z(null),H(""))}async function De(){if(ze&&r&&l!=="email"){P(""),N(!0);try{l==="bugs"?await xe():l==="features"?await O():await me()}catch(pe){P(String((pe==null?void 0:pe.message)||pe||"Refresh failed"))}finally{N(!1)}}}h.useEffect(()=>{De()},[l,ze,ae,r]);async function G(pe){F(pe),J(""),Z(""),ee(!0);try{if(pe.report_type==="bug"){const R=await s.get_bug_report_content(pe.filename);J(String((R==null?void 0:R.content)||""))}else{const R=await s.get_feature_request_content(pe.filename);J(String((R==null?void 0:R.content)||""))}}catch(R){Z(String((R==null?void 0:R.message)||R||"Failed to load report"))}finally{ee(!1)}}async function le(pe){Te(pe),K(""),z(null),H("");const R=wf(pe.report_relpath);if(R)try{if(pe.report_type==="bug"){const X=await s.get_bug_report_content(R);K(String((X==null?void 0:X.content)||""))}else if(pe.report_type==="feature"){const X=await s.get_feature_request_content(R);K(String((X==null?void 0:X.content)||""))}}catch(X){H(String((X==null?void 0:X.message)||X||"Failed to load report"))}}async function ye(pe){H(""),z(null);const R=String(pe.draft_relpath||"").trim();if(!R)return;const X=wf(R);if(X)try{const $e=await s.backlog_content("proposed",X);z($e)}catch($e){H(String(($e==null?void 0:$e.message)||$e||"Failed to load draft (is repo root configured on gateway?)"))}}async function Oe(pe,R){if(ge&&!ce){H(""),I(!0);try{const X=await s.apply_triage_decision(ge.decision_id,{action:pe,defer_days:R??null});await me();const $e=String(ae||"").trim().toLowerCase(),Ae=String((X==null?void 0:X.status)||"").trim().toLowerCase();if(!(!$e||$e===Ae))Te(null),K(""),z(null);else if(Te(X),String(X.draft_relpath||"").trim())try{await ye(X)}catch{}}catch(X){H(String((X==null?void 0:X.message)||X||"Decision action failed"))}finally{I(!1)}}}async function ot(){if(!_e){P(""),Y(!0);try{const pe=await s.triage_run({write_drafts:!1,enable_llm:!1});A(`Scanned ${(pe==null?void 0:pe.reports)??0} report(s); updated ${(pe==null?void 0:pe.updated_decisions)??0} decision(s).`),await me()}catch(pe){P(String((pe==null?void 0:pe.message)||pe||"Triage failed"))}finally{Y(!1)}}}h.useEffect(()=>{de&&(Ye(""),Ie(""),Re(!1),ke(String(a.default_session_id||"").trim()))},[de,a.default_session_id]);async function xt(){var pe,R;if(U&&!he){Ye(""),Re(!0);try{const X=String(L||"").trim();if(!X)throw new Error("session_id is required");const $e=String(be||"").trim();if(!$e)throw new Error("description is required");const Ae={session_id:X,description:$e,active_run_id:String(a.default_active_run_id||"").trim()||void 0,workflow_id:String(a.default_workflow_id||"").trim()||void 0,client:"abstractcontinuum/web",client_version:"",user_agent:String(((pe=globalThis==null?void 0:globalThis.navigator)==null?void 0:pe.userAgent)||""),url:String(((R=globalThis==null?void 0:globalThis.location)==null?void 0:R.href)||"")};if(U==="bug"){const Ge=await s.bug_report_create(Ae),et=String((Ge==null?void 0:Ge.filename)||"").trim();ie(""),c("bugs");const ct=await s.list_bug_reports(),wt=Array.isArray(ct==null?void 0:ct.items)?ct.items:[];m(wt);const pt=wt.find(Ut=>Ut.filename===et)||null;pt&&await G(pt)}else{const Ge=await s.feature_report_create(Ae),et=String((Ge==null?void 0:Ge.filename)||"").trim();ie(""),c("features");const ct=await s.list_feature_requests(),wt=Array.isArray(ct==null?void 0:ct.items)?ct.items:[];_(wt);const pt=wt.find(Ut=>Ut.filename===et)||null;pt&&await G(pt)}}catch(X){Ye(String((X==null?void 0:X.message)||X||"Failed to create report"))}finally{Re(!1)}}}return e.jsxs("div",{className:"page page_pad",children:[e.jsxs("div",{className:"page_toolbar",children:[e.jsx("div",{className:"seg seg_scroll",role:"group","aria-label":"Inbox views",children:r?e.jsxs(e.Fragment,{children:[e.jsx("button",{"aria-pressed":l==="messages",className:`seg_btn ${l==="messages"?"active":""}`,onClick:()=>c("messages"),children:"Messages"}),e.jsx("button",{"aria-pressed":l==="email",className:`seg_btn ${l==="email"?"active":""}`,onClick:()=>c("email"),children:"Email"}),e.jsx("button",{"aria-pressed":l==="bugs",className:`seg_btn ${l==="bugs"?"active":""}`,onClick:()=>c("bugs"),children:"Bugs"}),e.jsx("button",{"aria-pressed":l==="features",className:`seg_btn ${l==="features"?"active":""}`,onClick:()=>c("features"),children:"Features"})]}):e.jsx("button",{"aria-pressed":l==="email",className:`seg_btn ${l==="email"?"active":""}`,onClick:()=>c("email"),children:"Email"})}),r&&l!=="email"&&S?e.jsx("span",{className:"page_hint mono",children:S}):null,r&&l!=="email"&&$?e.jsx("span",{className:"page_error mono",children:$}):null,e.jsx("div",{className:"page_toolbar_spacer"}),r?e.jsxs(e.Fragment,{children:[l==="messages"?e.jsxs(e.Fragment,{children:[e.jsxs("select",{value:ae,onChange:pe=>fe(String(pe.target.value)),title:"Filter triage decisions by status",children:[e.jsx("option",{value:"pending",children:"pending"}),e.jsx("option",{value:"approved",children:"approved"}),e.jsx("option",{value:"deferred",children:"deferred"}),e.jsx("option",{value:"rejected",children:"rejected"}),e.jsx("option",{value:"",children:"all"})]}),e.jsx("button",{className:"btn",onClick:()=>void De(),disabled:!ze||x,children:x?"Refreshing…":"Refresh"}),e.jsx("button",{className:"btn primary",onClick:()=>void ot(),disabled:!ze||_e,children:_e?"Running…":"Run triage"})]}):l==="email"?null:e.jsx("button",{className:"btn",onClick:()=>void De(),disabled:!ze||x,children:x?"Refreshing…":"Refresh"}),e.jsx("button",{className:"btn",onClick:()=>ie("bug"),disabled:!ze,children:"File bug"}),e.jsx("button",{className:"btn",onClick:()=>ie("feature"),disabled:!ze,children:"File feature"})]}):null]}),l==="email"?e.jsx(lv,{gateway:s,enabled:ze}):e.jsxs("div",{className:"inbox_layout exec_layout",children:[e.jsxs("div",{className:"pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:l==="messages"?"Triage decisions":l==="bugs"?"Bug reports":"Feature requests"}),e.jsx("span",{className:"pane_count",children:l==="messages"?y.length:re.length})]}),e.jsx("div",{className:"pane_body pane_body_list",children:l==="messages"?e.jsx(e.Fragment,{children:y.length?y.map(pe=>{const R=(ge==null?void 0:ge.decision_id)===pe.decision_id,X=Array.isArray(pe.missing_fields)?pe.missing_fields.length:0;return e.jsxs("button",{className:`inbox_item ${R?"active":""}`,onClick:()=>void le(pe),children:[e.jsxs("div",{className:"inbox_item_title",children:[e.jsx("span",{className:`pill ${String(pe.status||"").toLowerCase()}`,children:String(pe.status||"pending")}),e.jsx("span",{className:"mono",children:pe.report_type}),e.jsx("span",{className:"mono muted",children:_i(pe.decision_id,10)})]}),e.jsxs("div",{className:"inbox_item_meta mono muted",children:[X?`${X} missing`:"complete"," • ",Bo(pe.updated_at||pe.created_at)||"(time?)"]}),e.jsx("div",{className:"inbox_item_meta mono",children:_i(pe.report_relpath||"",46)})]},pe.decision_id)}):e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"No decisions."})}):e.jsx(e.Fragment,{children:re.length?re.map(pe=>{const R=(T==null?void 0:T.filename)===pe.filename&&(T==null?void 0:T.report_type)===pe.report_type,X=String(pe.triage_status||"").trim().toLowerCase();return e.jsxs("button",{className:`inbox_item ${R?"active":""}`,onClick:()=>void G(pe),children:[e.jsxs("div",{className:"inbox_item_title",children:[X?e.jsx("span",{className:`pill ${X}`,children:X}):null,e.jsx("span",{className:"mono",children:_i(pe.title||pe.filename,46)})]}),e.jsxs("div",{className:"inbox_item_meta mono muted",children:[Bo(pe.created_at)||"(time?)"," • ",pe.session_id?_i(pe.session_id,12):"session?"]}),e.jsx("div",{className:"inbox_item_meta mono",children:pe.filename})]},pe.relpath)}):e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"No reports."})})})]}),e.jsx("div",{className:"pane",children:e.jsx("div",{className:"pane_body",children:l==="messages"?ge?e.jsxs("div",{className:"inbox_detail",children:[e.jsxs("div",{className:"inbox_detail_header",children:[e.jsxs("div",{className:"inbox_detail_title",children:[e.jsx("span",{className:"mono",style:{fontWeight:700},children:"Triage decision"}),e.jsx("span",{className:"chip mono muted",children:ge.report_type}),e.jsx("span",{className:"chip mono muted",children:ge.status}),e.jsx("span",{className:"chip mono muted",children:_i(ge.decision_id,16)})]}),e.jsxs("div",{className:"inbox_detail_actions",children:[e.jsx("button",{className:"btn",onClick:()=>{yn(ge.report_relpath||"")},children:"Copy report path"}),ge.draft_relpath?e.jsx("button",{className:"btn",onClick:()=>void ye(ge),children:"Load draft"}):null,e.jsx("button",{className:"btn primary",onClick:()=>void Oe("approve"),disabled:ce,children:"Approve"}),e.jsx("button",{className:"btn",onClick:()=>void Oe("defer",1),disabled:ce,children:"Defer 1d"}),e.jsx("button",{className:"btn",onClick:()=>void Oe("defer",7),disabled:ce,children:"Defer 7d"}),e.jsx("button",{className:"btn",onClick:()=>void Oe("reject"),disabled:ce,children:"Reject"})]})]}),e.jsxs("div",{className:"inbox_detail_meta mono muted",style:{fontSize:"var(--font-size-sm)"},children:[ge.updated_at?`updated ${Bo(ge.updated_at)}`:null,ge.created_at?`${ge.updated_at?" • ":""}created ${Bo(ge.created_at)}`:null,ge.defer_until?` • defer until ${ge.defer_until}`:null]}),V?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:V}):null,e.jsxs("div",{className:"row",style:{gap:"12px"},children:[e.jsxs("div",{className:"col",style:{minWidth:240},children:[e.jsx("div",{className:"section_title",children:"Missing fields"}),ge.missing_fields&&ge.missing_fields.length?e.jsx("ul",{className:"inbox_list_ul mono",children:ge.missing_fields.map(pe=>e.jsx("li",{children:pe},pe))}):e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"None."}),e.jsx("div",{className:"section_title",style:{marginTop:"10px"},children:"Possible duplicates"}),ge.duplicates&&ge.duplicates.length?e.jsx("ul",{className:"inbox_list_ul mono",children:ge.duplicates.slice(0,20).map((pe,R)=>{const X=String((pe==null?void 0:pe.title)||(pe==null?void 0:pe.ref)||(pe==null?void 0:pe.kind)||"duplicate").trim(),$e=typeof(pe==null?void 0:pe.score)=="number"&&Number.isFinite(pe.score)?` (score ${pe.score.toFixed(2)})`:"";return e.jsxs("li",{children:[X,$e]},`${X}_${R}`)})}):e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"None."})]}),e.jsxs("div",{className:"col",style:{minWidth:240},children:[e.jsx("div",{className:"section_title",children:"Draft"}),ge.draft_relpath?e.jsxs("div",{className:"mono",style:{fontSize:"var(--font-size-sm)"},children:[e.jsx("div",{className:"mono muted",children:"path"}),e.jsx("div",{className:"mono",children:ge.draft_relpath})]}):e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"No draft yet. Approve to generate one (requires repo mounted on gateway host)."})]})]}),te?e.jsxs("div",{className:"inbox_markdown",children:[e.jsx("div",{className:"section_title",children:"Draft content"}),e.jsx(as,{className:"md_doc",text:String(te.content||"")})]}):null,e.jsxs("div",{className:"inbox_markdown",children:[e.jsx("div",{className:"section_title",children:"Source report"}),Se?e.jsx(as,{className:"md_doc",text:Se}):e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"No report preview loaded."})]})]}):e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Select a decision."}):T?e.jsxs("div",{className:"inbox_detail",children:[e.jsxs("div",{className:"inbox_detail_header",children:[e.jsxs("div",{className:"inbox_detail_title",children:[e.jsx("span",{className:"mono",style:{fontWeight:700},children:T.report_type==="bug"?"Bug report":"Feature request"}),T.triage_status?e.jsx("span",{className:`pill ${T.triage_status}`,children:T.triage_status}):null,e.jsx("span",{className:"chip mono muted",children:T.filename}),T.session_id?e.jsx("span",{className:"chip mono muted",children:_i(T.session_id,16)}):null]}),e.jsx("div",{className:"inbox_detail_actions",children:e.jsx("button",{className:"btn",onClick:()=>{yn(T.relpath||"")},children:"Copy path"})})]}),C?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:C}):null,B?e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Loading…"}):D?e.jsx(as,{className:"md_doc",text:D}):e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"No content loaded."})]}):e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Select a report."})})})]}),e.jsxs(qa,{open:de,title:U==="bug"?"File bug report":"File feature request",onClose:()=>ie(""),actions:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:()=>ie(""),disabled:he,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:()=>void xt(),disabled:he,children:he?"Submitting…":"Submit"})]}),children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Session ID"}),e.jsx("input",{value:L,onChange:pe=>ke(pe.target.value),placeholder:"session id (required)"}),e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"This correlates runs + attachments (via the session memory run)."})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:U==="bug"?"Bug description":"Feature description"}),e.jsx("textarea",{value:be,onChange:pe=>Ie(pe.target.value),placeholder:U==="bug"?"What is broken? What did you expect?":"What do you want to be able to do?",rows:6})]}),Fe?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)"},children:Fe}):null]})]})}const xh="abstractcontinuum_voice_override_v1",Tu={enabled:!1};function Ju(){try{const a=localStorage.getItem(xh);if(!a)return{...Tu};const s=JSON.parse(a);return!s||typeof s!="object"?{...Tu}:{enabled:!!s.enabled,provider:Is(s.provider),model:Is(s.model),profile:Is(s.profile),voice:Is(s.voice),quality_preset:Is(s.quality_preset)}}catch{return{...Tu}}}const Yu="abstractcontinuum:voice_override_changed";function cv(a){try{localStorage.setItem(xh,JSON.stringify(a))}catch{}try{window.dispatchEvent(new CustomEvent(Yu))}catch{}}function wh(a){if(!a)return{};const s={},r=Is(a.quality_preset);if(r&&(s.quality_preset=r),!a.enabled)return s;for(const l of["provider","model","profile","voice"]){const c=Is(a[l]);c&&(s[l]=c)}return s}function Is(a){return String(a??"").trim()||void 0}function bh(a){const s=a&&typeof a=="object"?a.routes:null;if(!Array.isArray(s))return{};const r=y=>s.find(w=>w&&typeof w=="object"&&String(w.key||"").trim()===y&&!!w.configured),l=r("output.voice.tts")||r("output.voice");if(!l)return{};const c={},f=Is(l.provider),m=Is(l.model),p=l.options,_=p&&typeof p=="object"?Is(p.voice):void 0;return f&&(c.provider=f),m&&(c.model=m),_&&(c.voice=_),c}function uv(a){let s=String(a||"");return s=s.replace(/```[\s\S]*?```/g," "),s=s.replace(/!\[([^\]]*)\]\([^)]*\)/g,"$1"),s=s.replace(/\[([^\]]+)\]\([^)]*\)/g,"$1"),s=s.replace(/`([^`]+)`/g,"$1"),s=s.replace(/^[ \t]*#{1,6}[ \t]+/gm,""),s=s.replace(/^[ \t]*>[ \t]?/gm,""),s=s.replace(/^[ \t]*[-*+][ \t]+/gm,""),s=s.replace(/^[ \t]*\d+[.)][ \t]+/gm,""),s=s.replace(/^[ \t]*\|/gm,"").replace(/\|[ \t]*$/gm,"").replace(/\|/g,", "),s=s.replace(/(\*\*|__|~~)(.*?)\1/g,"$2"),s=s.replace(/\*([^*\n]+)\*/g,"$1"),s=s.replace(/(^|[^\w])_([^_\n]+)_(?=[^\w]|$)/g,"$1$2"),s=s.replace(/^[ \t]*([-*_])(?:[ \t]*\1){2,}[ \t]*$/gm," "),s=s.replace(/\s+/g," ").trim(),s}const gl={loading:!1,error:"",providers:[],models_by_provider:{},profiles_by_provider:{},voices_by_provider:{},cloned_by_provider:{}};function dv(a){const s={};if(!Array.isArray(a))return s;for(const r of a){if(!r||typeof r!="object")continue;const l=r.voice_kinds;if(!(Array.isArray(l)&&l.some(_=>String(_).toLowerCase().includes("clone"))))continue;const f=String(r.provider||"").trim(),m=String(r.id||r.voice||r.name||"").trim();if(!m)continue;const p=f||"*";(s[p]||(s[p]=[])).push(m)}for(const r of Object.keys(s))s[r]=[...new Set(s[r])];return s}function Xu(a){if(!Array.isArray(a))return[];const s=[];for(const r of a)if(typeof r=="string"){const l=r.trim();l&&s.push(l)}else if(r&&typeof r=="object"){const l=String(r.id||r.name||r.voice||r.value||"").trim();l&&s.push(l)}return[...new Set(s)]}function Au(a){const s={};if(a&&typeof a=="object"&&!Array.isArray(a))for(const[r,l]of Object.entries(a)){const c=Xu(l);c.length&&(s[String(r)]=c)}return s}function mv(a){const{gateway:s,gateway_connected:r}=a,[l,c]=h.useState(()=>Ju()),[f,m]=h.useState(gl),[p,_]=h.useState(!1),[y,w]=h.useState(""),x=h.useRef(null),N=h.useCallback(B=>{c(ee=>{const C={...ee,...B};return cv(C),C})},[]);h.useEffect(()=>{if(!r){m(gl);return}if(typeof(s==null?void 0:s.voice_voices)!="function"){m(gl);return}let B=!0;m(C=>({...C,loading:!0,error:""}));let ee;try{ee=s.voice_voices()}catch(C){m({...gl,error:String((C==null?void 0:C.message)||C||"voice catalog unavailable")});return}return ee.then(C=>{if(!B)return;const Z=[...new Set([...Xu(C==null?void 0:C.providers),...Xu(C==null?void 0:C.tts_providers)])];m({loading:!1,error:"",providers:Z,models_by_provider:Au(C==null?void 0:C.tts_models_by_provider),profiles_by_provider:Au(C==null?void 0:C.tts_profiles_by_provider),voices_by_provider:Au(C==null?void 0:C.tts_voices_by_provider),cloned_by_provider:dv(C==null?void 0:C.items)})}).catch(C=>{B&&m({...gl,error:String((C==null?void 0:C.message)||C||"voice catalog unavailable")})}),()=>{B=!1}},[s,r]);const $=l.provider||"",P=$&&f.models_by_provider[$]?f.models_by_provider[$]:[],T=$&&f.voices_by_provider[$]?f.voices_by_provider[$]:[],F=$&&f.profiles_by_provider[$]?f.profiles_by_provider[$]:[],D=[...$&&f.cloned_by_provider[$]?f.cloned_by_provider[$]:[],...f.cloned_by_provider["*"]||[]];async function J(){if(!(p||!r)){_(!0),w("");try{const B=await ad("abstractcontinuum_team_voice");let ee={};if(typeof s.capability_defaults=="function")try{ee=bh(await s.capability_defaults())}catch{ee={}}const C=await s.voice_tts(B,{text:"This is the voice AbstractContinuum will use to read your messages.",...ee,...wh(l),timeout_s:30}),Z=C==null?void 0:C.audio_artifact,ae=Z&&typeof Z=="object"?String(Z.$artifact||"").trim():"";if(!ae)throw new Error("no audio returned");const fe=await s.download_run_artifact_content(B,ae),ge=URL.createObjectURL(fe);if(x.current)try{x.current.pause()}catch{}const Te=x.current;if(Te){try{Te.pause()}catch{}const K=Te.src;K.startsWith("blob:")&&URL.revokeObjectURL(K)}const Se=new Audio(ge);x.current=Se,Se.onended=()=>{URL.revokeObjectURL(ge),w("")};try{await Se.play(),w("Playing…")}catch(K){w(String((K==null?void 0:K.name)||"").includes("NotAllowed")?"Synthesized OK — click Test again to play.":`Playback failed: ${String((K==null?void 0:K.message)||K).slice(0,80)}`),URL.revokeObjectURL(ge)}}catch(B){w(`Test failed: ${String((B==null?void 0:B.message)||B||"synthesis error").slice(0,120)}`)}finally{_(!1)}}}return e.jsxs("div",{className:"pane",style:{marginTop:12},children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Voice"}),e.jsx("span",{className:"pane_subtitle",children:"message read-aloud — this browser"})]}),e.jsx("div",{className:"pane_body",children:r?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"muted team_note",style:{marginTop:0},children:"Each message can be read aloud (the speaker button on a message). By default the gateway's configured voice is used, streamed so playback starts immediately. Override it here for this browser."}),e.jsxs("label",{className:"settings_row",style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("input",{type:"checkbox",checked:l.enabled,onChange:B=>N({enabled:B.target.checked})}),"Override the gateway default voice"]}),f.error?e.jsxs("div",{className:"muted team_note",children:["Voice catalog unavailable (",f.error.slice(0,100),") — you can still type provider/model/voice values below; the gateway validates on Test."]}):null,f.loading?e.jsx("div",{className:"muted team_note",children:"Loading voices…"}):null,l.enabled&&!$&&(l.voice||l.profile)?e.jsx("div",{className:"muted team_note",style:{color:"var(--warning, #facc15)"},children:"A voice id is provider-specific — pick the provider it belongs to, or the gateway's default provider may reject it."}):null,l.enabled?e.jsxs("div",{style:{display:"grid",gap:8,marginTop:8},children:[e.jsxs("label",{className:"settings_field",children:[e.jsx("span",{className:"muted",children:"Provider"}),e.jsx(Uo,{value:$,options:f.providers,placeholder:"gateway default",onChange:B=>N({provider:B,model:"",voice:"",profile:""})})]}),e.jsxs("label",{className:"settings_field",children:[e.jsx("span",{className:"muted",children:"Model"}),e.jsx(Uo,{value:l.model||"",options:P,placeholder:"default",onChange:B=>N({model:B})})]}),e.jsxs("label",{className:"settings_field",children:[e.jsx("span",{className:"muted",children:"Base voice"}),e.jsx(Uo,{value:l.profile||"",options:F,placeholder:"default",onChange:B=>N({profile:B})})]}),e.jsxs("label",{className:"settings_field",children:[e.jsx("span",{className:"muted",children:"Cloned voice"}),e.jsx(Uo,{value:l.voice||"",options:[...D,...T],placeholder:"none",onChange:B=>N({voice:B})})]})]}):null,e.jsxs("label",{className:"settings_field",style:{marginTop:8},children:[e.jsx("span",{className:"muted",children:"Quality"}),e.jsxs("select",{className:"team_compose_control",value:l.quality_preset||"",onChange:B=>N({quality_preset:B.target.value}),children:[e.jsx("option",{value:"",children:"gateway default"}),e.jsx("option",{value:"low",children:"low (fastest)"}),e.jsx("option",{value:"standard",children:"standard"}),e.jsx("option",{value:"high",children:"high (best)"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:10},children:[e.jsx("button",{className:"btn primary",disabled:p,onClick:()=>void J(),children:p?"Synthesizing…":"Test voice"}),y?e.jsx("span",{className:"muted team_note",children:y}):null]})]}):e.jsx("div",{className:"muted team_note",children:"Connect to the gateway to configure and test message voice."})})]})}function Uo(a){const s=Gt.useId();return e.jsxs(e.Fragment,{children:[e.jsx("input",{className:"team_compose_control mono",list:s,value:a.value,placeholder:a.placeholder||"",onChange:r=>a.onChange(r.target.value.trim())}),a.options.length?e.jsx("datalist",{id:s,children:a.options.map(r=>e.jsx("option",{value:r},r))}):null]})}const fv=["minimal","low","medium","high","xhigh"];function hv(a){const{gateway:s,connected:r,model:l,value:c,onChange:f}=a,[m,p]=h.useState({state:"unknown",levels:[]}),[_,y]=h.useState(!1);if(h.useEffect(()=>{y(!1);const N=String(l||"").trim();if(!N||!r){p({state:"unknown",levels:[]});return}let $=!1;return p({state:"loading",levels:[]}),s.discovery_model_capabilities(N).then(P=>{if($)return;const T=P!=null&&P.capabilities&&typeof P.capabilities=="object"?P.capabilities:{},F=T.thinking_support,D=Array.isArray(T.reasoning_levels)?T.reasoning_levels.map(J=>String(J)):[];p(F===!0?{state:"supported",levels:D}:F===!1?{state:"unsupported",levels:[]}:{state:"unknown",levels:[]})}).catch(()=>{$||p({state:"unknown",levels:[]})}),()=>{$=!0}},[l,r]),!String(l||"").trim())return null;const w=m.state==="unsupported"||m.state==="unknown"&&!_||m.state==="loading",x=m.state==="supported"&&m.levels.length?m.levels:m.state==="unknown"&&_?[...fv]:[];return e.jsxs("div",{className:"field","data-testid":"reasoning_select",children:[e.jsxs("label",{children:["Reasoning (effort for ",l,")"]}),e.jsxs("select",{value:w?"":c,onChange:N=>f(String(N.target.value||"")),disabled:w,title:m.state==="supported"?"Efforts this model declares (gateway-served). Sent on the `thinking` wire key; blank = gateway default.":m.state==="unsupported"?"This model declares no reasoning support — effort is locked to none (contract v1: non-reasoning models naturally get none).":m.state==="loading"?"Checking the model's served capabilities…":"The gateway serves no reasoning facts for this model (unknown ≠ unsupported). Locked fail-safe; tick “set anyway” if you know the model reasons.",children:[e.jsx("option",{value:"",children:m.state==="unsupported"?"none — this model doesn't reason":m.state==="loading"?"checking…":m.state==="unknown"&&!_?"unknown — no served facts":"gateway default"}),x.map(N=>e.jsx("option",{value:N,children:N},N))]}),m.state==="unknown"&&!w?e.jsx("div",{className:"muted",style:{fontSize:"var(--font-size-sm)"},children:"Override active: efforts unverified for this model — the provider may reject or ignore them."}):null,m.state==="unknown"?e.jsxs("label",{className:"muted",style:{fontSize:"var(--font-size-sm)",display:"inline-flex",gap:"6px",alignItems:"center"},children:[e.jsx("input",{type:"checkbox",checked:_,onChange:N=>{y(N.target.checked),N.target.checked||f("")}}),"set anyway (I know this model reasons)"]}):null]})}function pv(a){const[s,r]=h.useState(!1),[l,c]=h.useState("");return s?e.jsxs("span",{style:{display:"flex",gap:6,alignItems:"center"},children:[e.jsx("input",{className:"mono",style:{minWidth:260},value:l,onChange:f=>c(f.target.value),placeholder:"/path/to/abstractframework",disabled:a.busy}),e.jsx("button",{className:"btn primary",disabled:a.busy||!l.trim(),onClick:()=>{a.on_apply(l.trim()),r(!1)},children:"Apply"}),e.jsx("button",{className:"btn",disabled:a.busy,onClick:()=>r(!1),children:"Cancel"})]}):e.jsx("button",{className:"btn",disabled:a.busy,onClick:()=>{c(a.current),r(!0)},children:a.current?"Change…":"Set…"})}function _v(a){var K,te;const{gateway:s,gateway_connected:r,settings:l,set_settings:c}=a,f=(te=(K=a.connection)==null?void 0:K.gateway)==null?void 0:te.principal,[m,p]=h.useState({loaded:!1,process_manager:null,backlog_root:null,exec_pipeline:null,exec_detail:"",executor:""}),[_,y]=h.useState(null),[w,x]=h.useState(null),[N,$]=h.useState(!1),[P,T]=h.useState(null),[F,D]=h.useState([]),[J,B]=h.useState(""),[ee,C]=h.useState(!1),[Z,ae]=h.useState(0);async function fe(z){if(!ee){C(!0),B("");try{const V=await s.admin_runtime_config_update(z);y(V),ae(H=>H+1)}catch(V){B(String((V==null?void 0:V.message)||V||"Config update refused"))}finally{C(!1)}}}h.useEffect(()=>{if(!r)return;let z=!1;return(async()=>{const V={loaded:!0,process_manager:null,backlog_root:null,exec_pipeline:null,exec_detail:"",executor:""};try{const H=await s.backlog_exec_config(),ce=!!(H!=null&&H.runner_enabled),I=!!(H!=null&&H.runner_alive),_e=(H==null?void 0:H.can_execute)===!0;V.exec_pipeline=_e?"on":ce||I?"degraded":"off",V.exec_detail=_e?"":ce?I?"runner alive but cannot execute (executor missing?)":"runner enabled but not alive":"runner disabled",V.executor=String((H==null?void 0:H.executor)||"").trim()}catch{V.exec_pipeline=null}try{const H=await s.admin_runtime_config();if(H&&typeof H=="object"){z||(y(H),V.process_manager=pi(H.process_manager),V.backlog_root=pi(H.triage_repo_root),p(V));return}}catch{}try{const H=await s.list_processes();V.process_manager=!!(H!=null&&H.enabled)}catch{V.process_manager=null}try{await s.backlog_template(),V.backlog_root=!0}catch(H){V.backlog_root=El(H)?!1:null}z||p(V)})(),(async()=>{try{const V=await s.admin_data_homes();z||(T(Array.isArray(V==null?void 0:V.homes)?V.homes:[]),D(Array.isArray(V==null?void 0:V.warnings)?V.warnings:[]))}catch{z||T(null)}})(),(async()=>{try{const V=await s.list_bundles(),H=Array.isArray(V==null?void 0:V.items)?V.items:Array.isArray(V==null?void 0:V.bundles)?V.bundles:Array.isArray(V)?V:[],ce=[];for(const Y of H){const S=String((Y==null?void 0:Y.bundle_id)||(Y==null?void 0:Y.id)||"").trim();if(!S)continue;const A=Array.isArray(Y==null?void 0:Y.entrypoints)?Y.entrypoints:[];for(const U of A){if((U==null?void 0:U.deprecated)===!0||!(Array.isArray(U==null?void 0:U.interfaces)?U.interfaces:[]).some(L=>String(L||"").trim().length>0))continue;const de=String((U==null?void 0:U.name)||"").trim();ce.push({id:S,name:de?`${S} · ${de}`:S,description:String((U==null?void 0:U.description)||"").trim()||void 0})}}const I=new Set,_e=ce.filter(Y=>I.has(Y.id)?!1:(I.add(Y.id),!0));_e.sort((Y,S)=>Y.name.localeCompare(S.name)),z||x(_e)}catch{z||x(null)}})(),()=>{z=!0}},[s,r,Z]);function ge(z){return typeof z!="number"||!Number.isFinite(z)||z<0?"":z>=1e12?`${(z/1e12).toFixed(1)} TB`:z>=1e9?`${(z/1e9).toFixed(1)} GB`:z>=1e6?`${(z/1e6).toFixed(1)} MB`:z>=1e3?`${(z/1e3).toFixed(1)} KB`:`${z} B`}function Te(z,V="on",H="off"){return z===null?e.jsx("span",{className:"chip mono muted",children:"unknown"}):e.jsx("span",{className:`chip mono ${z?"ok":"warn"}`,children:z?V:H})}function Se(z){const V=String(z||"").trim();return V?e.jsx("span",{className:"chip mono muted",title:"Config resolution: stored > env > default",children:V}):null}return e.jsx("div",{className:"page page_scroll",children:e.jsxs("div",{className:"page_inner page_pad constrained",children:[e.jsxs("div",{className:"pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Execution defaults"}),e.jsx("span",{className:"pane_subtitle",children:"preference — this browser"})]}),e.jsxs("div",{className:"pane_body",children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Default execution mode (preselected in execute dialogs)"}),e.jsxs("select",{value:l.default_execution_mode,onChange:z=>c(V=>({...V,default_execution_mode:z.target.value==="inplace"?"inplace":"uat"})),children:[e.jsx("option",{value:"uat",children:"UAT (staged, safe) — recommended"}),e.jsx("option",{value:"inplace",children:"Inplace (dangerous, edits prod)"})]})]}),e.jsx("div",{className:"muted",style:{fontSize:"var(--font-size-sm)"},children:"Every execute dialog still shows the mode selector — this only sets what it starts on."})]})]}),e.jsxs("div",{className:"pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"AI assistance"}),e.jsx("span",{className:"pane_subtitle",children:"preference — this browser"})]}),e.jsxs("div",{className:"pane_body",children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Maintenance AI (backlog assist — refine/dod/labels)"}),e.jsx($p,{disabled:!r,value:{provider:l.maintenance_ai_provider,model:l.maintenance_ai_model},onChange:z=>c(V=>({...V,maintenance_ai_provider:z.provider,maintenance_ai_model:z.model,maintenance_ai_reasoning:z.model===V.maintenance_ai_model?V.maintenance_ai_reasoning:""})),fetchProviders:async()=>{const z=await s.discovery_providers();return(Array.isArray(z==null?void 0:z.items)?z.items:[]).map(V=>({name:V.name,display_name:V.display_name}))},fetchModels:async z=>{const V=await s.discovery_provider_models(z);return Array.isArray(V==null?void 0:V.models)?V.models:[]},defaultHint:"Uses the gateway's configured default provider and model for maintenance calls."})]}),e.jsx(hv,{gateway:s,connected:r,model:l.maintenance_ai_model,value:l.maintenance_ai_reasoning,onChange:z=>c(V=>({...V,maintenance_ai_reasoning:z}))}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Advisor workflow (executable workflows served by this gateway)"}),w===null?e.jsx("input",{className:"mono",value:l.backlog_advisor_agent,onChange:z=>c(V=>({...V,backlog_advisor_agent:String(z.target.value||"")})),placeholder:"basic-agent",title:"This gateway does not serve the workflow catalog — enter a bundle id."}):(()=>{const z=String(l.backlog_advisor_agent||"").trim(),V=z===""||w.some(H=>H.id===z);return e.jsxs(e.Fragment,{children:[e.jsxs("select",{value:V&&!N?z:"__custom__",onChange:H=>{const ce=H.target.value;ce==="__custom__"?$(!0):($(!1),c(I=>({...I,backlog_advisor_agent:ce})))},title:"Workflows the gateway can run for advice; blank = the shipped basic-agent",children:[e.jsx("option",{value:"",children:"gateway default (basic-agent)"}),w.map(H=>e.jsx("option",{value:H.id,title:H.description||void 0,children:H.name||H.id},H.id)),e.jsx("option",{value:"__custom__",children:"custom bundle id…"})]}),!V||N?e.jsx("input",{className:"mono",style:{marginTop:6},value:l.backlog_advisor_agent,onChange:H=>c(ce=>({...ce,backlog_advisor_agent:String(H.target.value||"")})),placeholder:"bundle id (e.g. docs-qa@0.1.0)"}):null]})})()]})]})]}),e.jsx(mv,{gateway:s,gateway_connected:r}),e.jsxs("div",{className:"pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Gateway administration"}),e.jsx("span",{className:"pane_subtitle",children:"server-side — the gateway is the gatekeeper"})]}),e.jsx("div",{className:"pane_body",children:r?e.jsxs(e.Fragment,{children:[f!=null&&f.user_id?e.jsxs("div",{style:{fontSize:"var(--font-size-sm)",marginBottom:"8px"},children:["Signed in as ",e.jsx("strong",{children:f.user_id}),f.admin===!0?e.jsx("span",{className:"chip mono ok",style:{marginLeft:6},children:"gateway admin"}):f.admin===!1?e.jsx("span",{className:"chip mono muted",style:{marginLeft:6},title:"This pane stays read-only for non-admin principals.",children:"not admin"}):null]}):null,(()=>{var H,ce,I,_e;const z=(_==null?void 0:_.writable)===!0,V=Array.isArray(_==null?void 0:_.executors)?_.executors:[];return e.jsxs("div",{children:[e.jsxs("div",{className:"admin_row",children:[e.jsxs("div",{className:"admin_row_top",children:[e.jsx("span",{className:"admin_row_name",children:"Backlog browsing"}),Te(m.backlog_root,"configured","not configured"),Se((H=_==null?void 0:_.triage_repo_root)==null?void 0:H.source),e.jsx("div",{className:"admin_row_action",children:z?e.jsx(pv,{current:qo(_==null?void 0:_.triage_repo_root),busy:ee,on_apply:Y=>void fe({triage_repo_root:Y})}):null})]}),e.jsxs("div",{className:"admin_row_detail",children:["The AbstractFramework checkout the backlog lives in — ",e.jsx("code",{children:"ABSTRACTGATEWAY_TRIAGE_REPO_ROOT"}),qo(_==null?void 0:_.triage_repo_root)?e.jsxs(e.Fragment,{children:[" (currently ",qo(_==null?void 0:_.triage_repo_root),")"]}):null]})]}),e.jsxs("div",{className:"admin_row",children:[e.jsxs("div",{className:"admin_row_top",children:[e.jsx("span",{className:"admin_row_name",children:"Exec pipeline"}),m.exec_pipeline===null?e.jsx("span",{className:"chip mono muted",children:"unknown"}):e.jsx("span",{className:`chip mono ${m.exec_pipeline==="on"?"ok":"warn"}`,children:m.exec_pipeline}),Se((ce=_==null?void 0:_.backlog_exec_runner)==null?void 0:ce.source),e.jsx("div",{className:"admin_row_action",children:z?e.jsx("button",{className:"btn",disabled:ee,onClick:()=>void fe({backlog_exec_runner:pi(_==null?void 0:_.backlog_exec_runner)!==!0}),children:pi(_==null?void 0:_.backlog_exec_runner)===!0?"Disable":"Enable"}):null})]}),e.jsxs("div",{className:"admin_row_detail",children:["Runs queued executions — ",e.jsx("code",{children:"ABSTRACTGATEWAY_BACKLOG_EXEC_RUNNER=1"}),m.exec_detail?e.jsxs(e.Fragment,{children:[" — ",m.exec_detail]}):null]})]}),e.jsxs("div",{className:"admin_row",children:[e.jsxs("div",{className:"admin_row_top",children:[e.jsx("span",{className:"admin_row_name",children:"Executor"}),m.executor&&m.executor!=="none"?e.jsx("span",{className:"chip mono ok",children:m.executor}):e.jsx("span",{className:"chip mono warn",children:"none"}),Se((I=_==null?void 0:_.executor)==null?void 0:I.source),e.jsx("div",{className:"admin_row_action",children:z&&V.length?e.jsx("select",{value:qo(_==null?void 0:_.executor),disabled:ee,onChange:Y=>void fe({executor:String(Y.target.value||"")}),title:"Pick the execution agent (validated by the gateway registry)",children:V.map(Y=>e.jsxs("option",{value:Y.id,disabled:Y.available===!1,children:[Y.display||Y.id,Y.available===!1?" (unavailable)":""]},Y.id))}):null})]}),e.jsxs("div",{className:"admin_row_detail",children:["The execution agent seam (registry-pluggable: codex today, claude-code/opencode/abstractcode as they land) —"," ",e.jsx("code",{children:"ABSTRACTGATEWAY_BACKLOG_EXECUTOR"})]})]}),e.jsxs("div",{className:"admin_row",children:[e.jsxs("div",{className:"admin_row_top",children:[e.jsx("span",{className:"admin_row_name",children:"Process manager"}),Te(m.process_manager,"enabled","disabled"),Se((_e=_==null?void 0:_.process_manager)==null?void 0:_e.source),e.jsx("div",{className:"admin_row_action",children:z?e.jsx("button",{className:"btn",disabled:ee,onClick:()=>void fe({process_manager:pi(_==null?void 0:_.process_manager)!==!0}),children:pi(_==null?void 0:_.process_manager)===!0?"Disable":"Enable"}):null})]}),e.jsxs("div",{className:"admin_row_detail",children:["Powers the Services page — ",e.jsx("code",{children:"ABSTRACTGATEWAY_ENABLE_PROCESS_MANAGER=1"}),". High trust: whoever reaches Services can redeploy."]})]})]})})(),J?e.jsx("div",{className:"page_error mono",style:{marginTop:"6px"},children:J}):null,e.jsx("div",{className:"muted",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:_?_.writable===!0?"Changes persist gateway-side (stored beats env beats default) and are principal-stamped. Some knobs may need a gateway restart to take full effect — the posture above is what the gateway reports.":_.writable===!1?"This gateway serves the admin config surface, but your principal is not authorized to change it (admin only).":"This gateway serves the admin config surface (write authority unknown — it predates the writable flag).":"These are env-set on the gateway host today (restart to apply). Self-serve configuration from this pane — admin-only, authorized by the gateway — is requested from the gateway seat (commons c1550/c1554); the controls light up automatically when its surface ships."})]}):e.jsx("div",{className:"muted",style:{fontSize:"var(--font-size-sm)"},children:"Connect to a gateway to see its posture (top-right control)."})})]}),e.jsxs("div",{className:"pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Data and caches"}),e.jsx("span",{className:"pane_subtitle",children:P?`server-side — ${P.length} registered home${P.length===1?"":"s"}`:"server-side — read-only telemetry"})]}),e.jsx("div",{className:"pane_body",children:r?P===null?e.jsx("div",{className:"muted",style:{fontSize:"var(--font-size-sm)"},children:"This gateway does not serve the data-homes registry yet (older build) — the table lights up on its next restart. Purge actions live on the gateway console either way; this card is read-only by design."}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"table_scroll",children:e.jsxs("table",{className:"data_table mono",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"name"}),e.jsx("th",{children:"kind"}),e.jsx("th",{children:"owner"}),e.jsx("th",{children:"size"}),e.jsx("th",{children:"purge"})]})}),e.jsx("tbody",{children:[...P].sort((z,V)=>(V.size_bytes||0)-(z.size_bytes||0)).map(z=>e.jsxs("tr",{title:z.description||z.path,children:[e.jsx("td",{children:z.name}),e.jsx("td",{children:e.jsx("span",{className:"chip mono muted",children:z.kind})}),e.jsx("td",{className:"muted",children:z.owner}),e.jsx("td",{children:z.exists===!1?e.jsx("span",{className:"chip mono warn",children:"missing"}):ge(z.size_bytes)}),e.jsx("td",{children:z.safe_to_purge?e.jsx("span",{className:"chip mono ok",children:"purgeable"}):e.jsx("span",{className:"chip mono warn",title:z.description||"Protected — the owner's rule refuses purge",children:"protected"})})]},z.name))})]})}),F.map((z,V)=>e.jsx("div",{className:"page_error mono",style:{marginTop:"6px"},children:z},`dhw:${V}`)),e.jsx("div",{className:"muted",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:"Read-only view over the framework data registry (hover a row for its path and purge rule). Purge verbs live on the gateway console — one management surface, per the cache-management split ruling."})]}):e.jsx("div",{className:"muted",style:{fontSize:"var(--font-size-sm)"},children:"Connect to a gateway to see its data footprint."})})]})]})})}const gv=/^(```+|~~~+)\s*mermaid\s*$/i;function vv(a){const s=String(a||"").split(`
92
- `),r=[];let l=[],c=0;for(;c<s.length;){const f=s[c].match(gv);if(!f){l.push(s[c]),c+=1;continue}const m=f[1];let p=-1;for(let _=c+1;_<s.length;_++){const y=s[_].trimEnd();if(y.startsWith(m[0].repeat(3))&&/^(`{3,}|~{3,})\s*$/.test(y)&&y[0]===m[0]){p=_;break}}if(p===-1){l.push(s[c]),c+=1;continue}l.length&&(r.push({kind:"md",text:l.join(`
93
- `)}),l=[]),r.push({kind:"mermaid",text:s.slice(c+1,p).join(`
94
- `)}),c=p+1}return l.length&&r.push({kind:"md",text:l.join(`
95
- `)}),r}const yv="modulepreload",xv=function(a){return"/"+a},bf={},wv=function(s,r,l){let c=Promise.resolve();if(r&&r.length>0){let m=function(y){return Promise.all(y.map(w=>Promise.resolve(w).then(x=>({status:"fulfilled",value:x}),x=>({status:"rejected",reason:x}))))};document.getElementsByTagName("link");const p=document.querySelector("meta[property=csp-nonce]"),_=(p==null?void 0:p.nonce)||(p==null?void 0:p.getAttribute("nonce"));c=m(r.map(y=>{if(y=xv(y),y in bf)return;bf[y]=!0;const w=y.endsWith(".css"),x=w?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${y}"]${x}`))return;const N=document.createElement("link");if(N.rel=w?"stylesheet":yv,w||(N.as="script"),N.crossOrigin="",N.href=y,_&&N.setAttribute("nonce",_),document.head.appendChild(N),w)return new Promise(($,P)=>{N.addEventListener("load",$),N.addEventListener("error",()=>P(new Error(`Unable to preload CSS for ${y}`)))})}))}function f(m){const p=new Event("vite:preloadError",{cancelable:!0});if(p.payload=m,window.dispatchEvent(p),!p.defaultPrevented)throw m}return c.then(m=>{for(const p of m||[])p.status==="rejected"&&f(p.reason);return s().catch(f)})};let Ru=null;function bv(){return Ru||(Ru=wv(()=>import("./mermaid.core-CrABX5SH.js").then(a=>a.bp),[]).then(a=>{const s=a.default||a;return s.initialize({startOnLoad:!1,securityLevel:"strict",theme:"dark"}),s})),Ru}let jv=0;function kv(a){const s=h.useRef(null),[r,l]=h.useState("");return h.useEffect(()=>{let c=!0;return l(""),bv().then(async f=>{const m=`af_mermaid_${jv+=1}`,{svg:p}=await f.render(m,a.text);c&&s.current&&(s.current.innerHTML=p)}).catch(f=>{c&&l(String((f==null?void 0:f.message)||f||"mermaid render failed"))}),()=>{c=!1}},[a.text]),r?e.jsxs("div",{className:"team_mermaid_error",children:[e.jsxs("div",{className:"muted team_note",children:["#FALLBACK diagram did not render (",r.slice(0,120),") — source below:"]}),e.jsx("pre",{className:"team_mermaid_src",children:a.text})]}):e.jsx("div",{className:"team_mermaid",ref:s})}const Sv=400;function Nv(a){const s=new Map;for(const c of a)s.set(c.id,c);const r=c=>{let f=c,m=!1;const p=new Set([f.id]);for(let _=0;_<Sv;_++){const y=String(f.reply_to||"");if(!y)break;const w=s.get(y);if(!w){m=f.id===c.id||m;break}if(p.has(w.id))break;p.add(w.id),f=w}return{root:f,orphan:m&&f.id===c.id}},l=new Map;for(const c of[...a].sort((f,m)=>(f.seq||0)-(m.seq||0))){const{root:f,orphan:m}=r(c);let p=l.get(f.id);p||(p={root:f,replies:[],orphan:f.id===c.id?m:!1,last_seq:f.seq||0},l.set(f.id,p)),c.id!==f.id&&(p.replies.push(c),p.last_seq=Math.max(p.last_seq,c.seq||0))}return[...l.values()].sort((c,f)=>c.last_seq-f.last_seq||(c.root.seq||0)-(f.root.seq||0))}const jf=[{id:"all",label:"All",title:"Every message in the window"},{id:"unread",label:"Unread",title:"Unread MESSAGES (same number as the blue channel badge); the list shows the threads containing them"},{id:"asks",label:"Asks",title:"Threads with open/blocked messages — something expects an answer"},{id:"vigilance",label:"Needs vigilance",title:"Threads with unanswered asks, critical messages, or messages addressed to your seat"},{id:"fyi",label:"FYI",title:"Threads of fyi/system traffic"},{id:"resolved",label:"Resolved",title:"Threads closed by a resolved reply (the ✓ Resolve act) or a resolved root"},{id:"to_me",label:"@me",title:"Threads with messages addressed to your seat"}];function jh(a,s,r){var c,f,m,p,_;if(a.retracted===!0)return s==="all"?!0:s==="unread"?!!((c=r.unread_seqs)!=null&&c.has(a.seq)||(f=r.unread_snapshot_seqs)!=null&&f.has(a.seq)):!1;const l=String(a.status||"").toLowerCase();switch(s){case"all":return!0;case"unread":return!!((m=r.unread_seqs)!=null&&m.has(a.seq)||(p=r.unread_snapshot_seqs)!=null&&p.has(a.seq));case"asks":return l==="open"||l==="blocked";case"fyi":return l==="fyi";case"resolved":return l==="resolved";case"to_me":return Array.isArray(a.to)&&a.to.includes(r.seat);case"vigilance":{const y=(l==="open"||l==="blocked")&&a.has_resolved_reply!==!0,w=a.critical===!0,x=Array.isArray(a.to)&&a.to.includes(r.seat),N=!!((_=r.escalated_seqs)!=null&&_.has(a.seq));return y||w||x||N}}}function kf(a,s,r){return s==="all"?a:a.filter(l=>[l.root,...l.replies].some(c=>jh(c,s,r)))}function Cv(a,s,r){return jh(a,s,r)}function $v(a){const s={},r={};for(const l of a){const c=String(l.channel||"");if(!c)continue;const f=Number(l.seq);if(Number.isFinite(f)){const m=s[c]||(s[c]=new Set);if(m.has(f))continue;m.add(f)}r[c]=(r[c]||0)+1}return r}function Ev(a){const s={};for(const r of a){const l=String(r.channel||""),c=Number(r.seq);!l||!Number.isFinite(c)||(s[l]||(s[l]=new Set)).add(c)}return s}function Tv(a,s){const r={};for(const l of a){const c=String(l.channel||""),f=Number(l.seq);if(!c||!Number.isFinite(f))continue;const m=String(l.status||"").toLowerCase(),p=Array.isArray(l.to)&&s?l.to.includes(s):!1;(m==="open"||m==="blocked"||(m==="reply"||m==="fyi")&&p)&&(r[c]||(r[c]=new Set)).add(f)}return r}function Av(a){const s={};for(const r of a){const l=String(r.channel||""),c=Number(r.seq);if(!l||!Number.isFinite(c))continue;const f=String(r.effective_urgency||"").toLowerCase();(r.escalated===!0||f==="interrupt")&&(s[l]||(s[l]=new Set)).add(c)}return s}function Rv(a,s){const r=s?s.replace(/\/+$/,"")+"/":"",l=new Map,c=[];for(const f of a){const m=String(f.path||"");if(!m.startsWith(r))continue;const p=m.slice(r.length);if(!p)continue;const _=p.indexOf("/");if(_===-1)c.push(f);else{const y=p.slice(0,_);l.set(y,(l.get(y)||0)+1)}}return{dirs:[...l.entries()].map(([f,m])=>({name:f,path:r+f,count:m})).sort((f,m)=>f.name.localeCompare(m.name)),leaves:c.sort((f,m)=>f.path.localeCompare(m.path))}}function Sf(a,s){const r=String(a||"");if(!r.startsWith("dm:")||!s)return"";const l=r.slice(3);return l.startsWith(`${s}--`)?l.slice(s.length+2):l.endsWith(`--${s}`)?l.slice(0,l.length-s.length-2):""}function Lv(a){return a.is_reply?"reply":a.in_dm||a.kind==="ask"?"open":"fyi"}function Mv(a){const s=new Map;for(const l of a)l.id&&s.set(l.id,String(l.sender||""));const r=new Set;for(const l of a){const c=l.reply_to?String(l.reply_to):"";if(!c)continue;const f=s.get(c);(f===void 0||f!==String(l.sender||""))&&r.add(c)}return r}const zv=/(?:^|[\s("'`])((?:[A-Za-z0-9_][A-Za-z0-9_.-]*\/)+[A-Za-z0-9_][A-Za-z0-9_.-]*\.(?:md|markdown|txt|json|yaml|yml|csv|log))\b/g,Pv=4;function Iv(a){const s=[];for(const r of String(a||"").matchAll(zv)){const l=r[1],c=r.index===void 0?-1:r.index,f=c>=0?String(a).slice(Math.max(0,c-12),c+1):"";if(!(f.includes("://")||f.includes("/api/"))&&(s.includes(l)||s.push(l),s.length>=Pv))break}return s}function Ov(a,s,r){var c,f;const l=a.split("/").pop()||a;if(s!=null&&s.has(a))return{kind:"fs",path:a,rewritten:!1};for(let m=0;m<r.length;m++)if(String(((c=r[m])==null?void 0:c.filename)||"")===a)return{kind:"attachment",attachment_index:m};if(s){const m=[];for(const p of s)(p===l||p.endsWith(`/${l}`))&&m.push(p);if(m.length===1)return{kind:"fs",path:m[0],rewritten:m[0]!==a}}for(let m=0;m<r.length;m++){const p=String(((f=r[m])==null?void 0:f.filename)||"");if(p&&(p===l||p.split("/").pop()===l))return{kind:"attachment",attachment_index:m}}return null}const Nf=/@([A-Za-z0-9][A-Za-z0-9_.-]*)/g;function Lu(a){const s=[];for(const l of a.matchAll(Nf)){const c=l[1].toLowerCase();s.includes(c)||s.push(c)}return{title:a.replace(Nf," ").split(/\s+/).join(" ").trim().replace(/^[\s,;:-]+|[\s,;:-]+$/g,""),members:s}}function Mu(a){const s=[];for(const r of String(a||"").split(/[\s,;]+/)){const l=r.replace(/^@/,"").toLowerCase();!l||!/^[a-z0-9][a-z0-9_.-]*$/.test(l)||s.includes(l)||s.push(l)}return s}function zu(a,s){let r=a.toLowerCase().replace(/[^a-z0-9_.-]+/g,"-").replace(/^[-.]+|[-.]+$/g,"");r||(r="group"),r=r.slice(0,40).replace(/[-.]+$/g,"");let l=r,c=1;for(;s.has(l);)c+=1,l=`${r}-${c}`;return l}const Cf=400,$f=/([.;:!?…]["')\]]*) +(\((?:\d{1,2}|[a-z])\)|\[\d{1,2}\]) (?=["'([{]?[A-Za-z0-9])/g,Ef=/([.;:!?…]["')\]]*) +(?=[A-Z][A-Z'-]+(?: [A-Z][A-Z'-]*)+)/g;function Dv(a){if(!a||a.length<Cf)return a;const s=a.split(/(```[\s\S]*?(?:```|$))/),r=[];for(const l of s){if(l.startsWith("```")){r.push(l);continue}const c=l.split(/(\n{2,})/);for(const f of c){if(/\n/.test(f)||f.length<Cf){r.push(f);continue}const m=f.split(/(`[^`\n]*`)/);let p=0;for(const _ of m)_.startsWith("`")||(p+=(_.match($f)||[]).length+(_.match(Ef)||[]).length);if(p<2){r.push(f);continue}r.push(m.map(_=>_.startsWith("`")?_:_.replace($f,`$1
96
-
97
- $2 `).replace(Ef,`$1
98
-
99
- `)).join(""))}}return r.join("")}const Fv=/https?:\/\/[^\s<>()[\]{}"'`]+/g,qv=/\.(png|jpe?g|gif|webp)$/i;function Bv(a,s){if(!s)return a;const r=s.replace(/\/+$/,"");if(!a.startsWith(r+"/"))return a;const c=a.slice(r.length).match(/^\/channels\/([^/]+)\/attachments\/([A-Za-z0-9_.-]+)$/);return c?`/api/hub/channels/${c[1]}/attachments/${c[2]}`:a}function Uv(a,s){if(!a||!/https?:\/\//.test(a))return a;const r=(s==null?void 0:s.hub_base)||"",l=(s==null?void 0:s.app_origin)||"",c=a.split(/(```[\s\S]*?(?:```|$))/),f=[];for(let m=0;m<c.length;m++){const p=c[m];if(p.startsWith("```")){f.push(p);continue}const _=p.split(/(`[^`\n]*`)/);for(let y=0;y<_.length;y++){const w=_[y];if(w.startsWith("`")){f.push(w);continue}f.push(w.replace(Fv,(x,N)=>{const $=w.slice(Math.max(0,N-2),N);if($.endsWith("](")||$.endsWith("("))return x;const P=x.replace(/[.,;:!?]+$/,""),T=x.slice(P.length);let F="";try{F=new URL(P).pathname}catch{return x}const D=Bv(P,r),J=qv.test(F),B=D.startsWith("/")||l!==""&&D.startsWith(l+"/");return J&&B?`![image](${D})${T}`:`[${P}](${D})${T}`}))}}return f.join("")}const Wv=/^\/api\/hub\/channels\/[^/]+\/attachments\/[A-Za-z0-9_-]+$/;function Hv(a){const s=a.trim();return s.startsWith("/api/")?/\s/.test(s)||s.includes("..")?!0:!Wv.test(s):!1}function jl(a){if(!a||!a.includes("/api/"))return a;const s=/(!?)\[([^\]]*)\]\(([^)]+)\)/g;return a.replace(s,(r,l,c,f)=>Hv(String(f))?"`"+(String(c||"").trim()||String(f)).replace(/`/g,"")+" (blocked link)`":r)}function dd(a){let s=0;for(let r=0;r<a.length;r++)s=s*31+a.charCodeAt(r)>>>0;return s%360}const Vv=24e3,Gv=160;function Tf(a,s){var y,w,x,N;const r=Vv,l=Math.max(500,Math.floor(r/2)),c=[...a].sort(($,P)=>($.seq||0)-(P.seq||0)),f=[];for(const $ of c){const P=Array.isArray($.to)&&$.to.length?` to=[${$.to.join(",")}]`:"",T=(w=(y=$.data)==null?void 0:y.asks)!=null&&w.length?` asks=${$.data.asks.map(B=>`${B.id}:"${B.text}"`).join("; ")}`:"",F=(N=(x=$.data)==null?void 0:x.answers)!=null&&N.length?` answers=[${$.data.answers.join(",")}]`:"",D=$.reply_to?` reply_to=${$.reply_to}`:"";let J=`#${$.seq} [${$.sender}] (${$.status})${P}${D}${T}${F}
100
- ${$.title?`title: ${$.title}
101
- `:""}${String($.body||"").trim()}`;J.length>l&&(J=J.slice(0,l)+`
102
- [#TRUNCATION: message #${$.seq} clamped to fit the context budget]`),f.push(J)}let m=0,p=f.reduce(($,P)=>$+P.length+2,0);for(;f.length>1&&p>r-Gv;){const $=f.shift();p-=$.length+2,m++}return(m>0?`#TRUNCATION: the ${m} oldest message(s) were dropped to fit the context budget.
103
-
104
- `:"")+f.join(`
105
-
106
- `)}function Kv(a,s){let r=Number(a.up||0),l=Number(a.down||0),c=Number(a.mine||0);return s===void 0?{up:r,down:l,mine:c,caught_up:!1}:s===c?{up:r,down:l,mine:c,caught_up:!0}:(c>0?r-=1:c<0&&(l-=1),s>0?r+=1:s<0&&(l+=1),{up:Math.max(0,r),down:Math.max(0,l),mine:s,caught_up:!1})}function Qv(a,s){const r=Array.from(String(a??"")),l=(s??[]).filter(m=>Array.isArray(m)&&m.length>=2&&Number.isFinite(m[0])&&Number.isFinite(m[1])&&m[0]>=0&&m[1]>0).sort((m,p)=>m[0]-p[0]),c=[];let f=0;for(const[m,p]of l){if(m>=r.length)break;const _=Math.max(m,f),y=Math.min(m+p,r.length);y<=_||(_>f&&c.push({text:r.slice(f,_).join(""),hit:!1}),c.push({text:r.slice(_,y).join(""),hit:!0}),f=y)}return f<r.length&&c.push({text:r.slice(f).join(""),hit:!1}),!c.length&&r.length&&c.push({text:r.join(""),hit:!1}),c}const Wo=[{id:"decisions",label:"Decisions",kind:"decision"},{id:"open_threads",label:"Open threads",kind:null},{id:"work",label:"Work",kind:"work"},{id:"people",label:"People",kind:"agent"},{id:"files",label:"Files",kind:"file"},{id:"messages",label:"Messages",kind:"message"}],Jv=new Set(["image/png","image/jpeg","image/gif","image/webp"]);function Sr(a,s){const r=a.toLowerCase().split(".").pop()||"",l=String(s||"").toLowerCase();if(r==="md"||r==="markdown"||l==="text/markdown")return"md";if(Jv.has(l))return"image";const c=new Set(["txt","json","yaml","yml","csv","log","ts","tsx","js","py","sh","toml","ini","env"]);return!(l.includes("html")||l.includes("xml")||l.includes("svg"))&&(l.startsWith("text/")||c.has(r))?"text":"download"}function Yv({url:a,name:s}){const[r,l]=Gt.useState(!1);return r?e.jsxs("div",{className:"team_fileview_dl",children:[e.jsx("p",{className:"muted team_note",children:"The image failed to decode in the browser — the bytes may be corrupt or mistyped."}),e.jsxs("a",{className:"btn primary",href:a,target:"_blank",rel:"noreferrer",download:!0,children:["Download ",s]})]}):e.jsx("img",{className:"team_fileview_img",src:a,alt:s,onError:()=>l(!0)})}function Xv({view:a,onClose:s}){if(!a)return null;const r=a.url?e.jsxs("a",{className:"btn primary",href:a.url,target:"_blank",rel:"noreferrer",download:!0,children:["Download ",a.name]}):null;return e.jsxs(qa,{open:!0,title:a.name,onClose:s,variant:"default",children:[a.meta?e.jsx("div",{className:"muted team_note",style:{marginBottom:8},children:a.meta}):null,a.loading?e.jsx("div",{className:"muted team_note",children:"Loading…"}):a.error?e.jsxs("div",{className:"team_fileview_dl",children:[e.jsx("div",{className:"page_error mono",children:a.error}),r]}):a.mode==="md"?e.jsx("div",{className:"team_fileview_md",children:vv(a.text||"").map((l,c)=>l.kind==="mermaid"?e.jsx(kv,{text:l.text},c):e.jsx(as,{className:"md_doc",text:jl(l.text)},c))}):a.mode==="text"?e.jsx("pre",{className:"team_fileview_text",children:a.text||""}):a.mode==="image"&&a.url?e.jsx(Yv,{url:a.url,name:a.name},a.url):e.jsxs("div",{className:"team_fileview_dl",children:[e.jsxs("p",{className:"muted team_note",children:["Inline preview isn't available for this file type",a.content_type?` (${a.content_type})`:"","."]}),r]})]})}const Zv=Gt.memo(as),ey=["id","channel","seq","sender","kind","status","urgency","critical","downgraded","to","title","body","data","reply_to","created_at"];function Af(a){let s='"';for(let r=0;r<a.length;r++){const l=a.charCodeAt(r),c=a[r];c==='"'?s+='\\"':c==="\\"?s+="\\\\":l===8?s+="\\b":l===9?s+="\\t":l===10?s+="\\n":l===12?s+="\\f":l===13?s+="\\r":l<32||l>126?s+="\\u"+l.toString(16).padStart(4,"0"):s+=c}return s+'"'}class kh{constructor(s){this.value=s}}function Rf(a){if(!Number.isFinite(a))throw new Error("py_float_repr: non-finite");if(Object.is(a,-0))return"-0.0";if(a===0)return"0.0";const s=a<0,r=Math.abs(a),c=r.toExponential().match(/^(\d)(?:\.(\d+))?e([+-]\d+)$/);if(!c)return(s?"-":"")+String(r);const f=c[1]+(c[2]||""),p=parseInt(c[3],10)+1;let _;if(p<=-4||p>16){const y=f.length>1?`${f[0]}.${f.slice(1)}`:f[0],w=p-1,x=(w<0?"-":"+")+String(Math.abs(w)).padStart(2,"0");_=`${y}e${x}`}else p<=0?_="0."+"0".repeat(-p)+f:p>=f.length?_=f+"0".repeat(p-f.length)+".0":_=f.slice(0,p)+"."+f.slice(p);return(s?"-":"")+_}function Zu(a){if(a==null)return"null";if(typeof a=="boolean")return a?"true":"false";if(a instanceof kh){if(!Number.isFinite(a.value))throw new Error("canonical_json: non-finite number");return Rf(a.value)}if(typeof a=="number"){if(!Number.isFinite(a))throw new Error("canonical_json: non-finite number");return Number.isInteger(a)&&!Object.is(a,-0)?String(a):Rf(a)}if(typeof a=="string")return Af(a);if(Array.isArray(a))return"["+a.map(Zu).join(",")+"]";if(typeof a=="object")return"{"+Object.keys(a).sort().map(r=>Af(r)+":"+Zu(a[r])).join(",")+"}";throw new Error(`canonical_json: unsupported type ${typeof a}`)}async function ty(a){const s=new TextEncoder().encode(a),r=await crypto.subtle.digest("SHA-256",s);return[...new Uint8Array(r)].map(l=>l.toString(16).padStart(2,"0")).join("")}async function ny(a,s,r){const l={};for(const c of ey)c!=="channel"&&(l[c]=s[c]??null);return l.channel=r,typeof l.created_at=="number"&&(l.created_at=new kh(l.created_at)),await ty(a+`
107
- `+Zu(l))}async function sy(a){const s=a.channel;let r="",l=0,c=0,f=null,m="";for(const _ of a.turns){if(_.hash===null||_.hash===void 0){l>0&&f===null&&(f=_.seq),c+=1,r="";continue}const y=await ny(r,_,s);y!==_.hash&&f===null&&(f=_.seq),r=_.hash,m=y,l+=1}const p=f===null&&String(a.head||"")!==m;return{ok:f===null&&!p,broken_at:f,head_mismatch:p,computed_head:m,hashed:l,legacy:c}}const ay=5e3,ry=6,ma=200,iy=50,Ho=380,Lf=240,Mf=2,ly=12,vl=8,zf=16*1024*1024,oy=new Set(["image/png","image/jpeg","image/gif","image/webp"]),Sl=256*1024;function cy(){return e.jsx("svg",{width:"15",height:"15",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinejoin:"round","aria-hidden":!0,children:e.jsx("path",{d:"M1.8 4a1 1 0 0 1 1-1h3.4l1.6 1.8h6.4a1 1 0 0 1 1 1V12a1 1 0 0 1-1 1H2.8a1 1 0 0 1-1-1z"})})}function Pf(){return e.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinejoin:"round","aria-hidden":!0,children:[e.jsx("path",{d:"M4.2 1.8h5.2l2.8 2.8v9a.9.9 0 0 1-.9.9H4.2a.9.9 0 0 1-.9-.9V2.7a.9.9 0 0 1 .9-.9z"}),e.jsx("path",{d:"M9.2 1.8v3h3"})]})}function Vo(a){return a.length<=Sl?a:a.slice(0,Sl)+`
108
-
109
- ---
110
- #TRUNCATION: preview clamped at ${On(Sl)} of ${On(a.length)} — download the file for the full content.`}function Pu(a,s){try{return JSON.stringify(a)===JSON.stringify(s)}catch{return!1}}function Iu(a,s){const r=Object.keys(a);if(r.length!==Object.keys(s).length)return!1;for(const l of r){const c=a[l],f=s[l];if(!f||c.size!==f.size)return!1;for(const m of c)if(!f.has(m))return!1}return!0}function On(a){if(!Number.isFinite(a)||a<0)return"—";if(a<1024)return`${a} B`;const s=a/1024;return s<1024?`${Math.round(s)} KiB`:`${(a/(1024*1024)).toFixed(1)} MiB`}const Sh="abstractcontinuum_team_drafts_v1";function uy(){try{const a=window.localStorage.getItem(Sh),s=a?JSON.parse(a):{};return s&&typeof s=="object"?s:{}}catch{return{}}}function yl(a){try{window.localStorage.setItem(Sh,JSON.stringify(a))}catch{}}const Go="agora/0.4";function xl(a){if(!a)return"";const s=Math.max(0,Math.floor(Date.now()/1e3-a));return s<60?`${s}s`:s<3600?`${Math.floor(s/60)}m`:s<86400?`${Math.floor(s/3600)}h`:`${Math.floor(s/86400)}d`}function wl(a){if(!a)return"";try{return new Date(a*1e3).toLocaleString()}catch{return""}}function If(a){return{color:`hsl(${dd(a)}, 60%, 55%)`}}function Ia(a){const s=dd(a),r=s>=40&&s<=190?36:45;return{background:`hsl(${s}, 55%, ${r}%)`,color:"#fff"}}const vi=[{id:"trust",label:"Trust",help:"Claim ↔ action: does it say what it does, and do what it says?"},{id:"wisdom",label:"Wisdom",help:"Often right — takes the right decisions and leads by example."},{id:"thorough",label:"Thorough",help:"Takes a task end-to-end and doesn't stop until it is fully resolved and functional, with proofs."},{id:"helper",label:"Helper",help:"Contributes to OTHERS' work — detects issues, contributes positively."}],dy=[{id:"ruling",help:"May decide in the operator's name — seats treat its rulings as operator rulings while the grant stands."},{id:"operational",help:"Day-to-day operational writes (queues, coordination surfaces) in the operator's name."},{id:"reporting",help:"Receives and reads operator-grade reports and status surfaces."},{id:"moderation",help:"Moderation acts (pause, kick, retire) in the operator's name."}],Of={general:"Message thumbs — every standing ±1 on this agent's messages counts (operator ruling dm#161: a vote is a vote; a flip revises its own message, never stacks).",...Object.fromEntries(vi.map(a=>[a.id,`${a.help} Every standing vote counts.`]))};function bl(a){const s=vi.find(r=>r.id===a);return s?s.label:a==="general"?"General":a.charAt(0).toUpperCase()+a.slice(1)}function my(a){if(!a)return"";try{return new Date(a*1e3).toLocaleDateString(void 0,{weekday:"long",month:"short",day:"numeric"})}catch{return""}}function fy(a){var aa,hr,si,ra,ps,Nt;const s=a.gateway,r=!!a.gateway_connected,l=h.useMemo(()=>new ud,[]),c=h.useMemo(()=>{if(a.advisor)return a.advisor;if(!r||!s)return;const u=a.advisor_agent;return async(v,k)=>{const b=[...k.map(ne=>({role:ne.role,content:ne.content})),{role:"user",content:v}],E=await s.backlog_advisor({messages:b,agent:u||null});return String((E==null?void 0:E.reply)||"").trim()||"(the model returned an empty reply)"}},[a.advisor,s,r,a.advisor_agent]),f=!!c,[m,p]=h.useState(""),[_,y]=h.useState(()=>Ju()),[w,x]=h.useState(""),N=h.useRef(_);N.current=_;const $=h.useRef({});h.useEffect(()=>{if(!r||!s){p("");return}let u=!0;return(async()=>{try{const v=await ad("abstractcontinuum_team_voice");u&&p(v)}catch{u&&p("")}})(),typeof s.capability_defaults=="function"&&Promise.resolve().then(()=>s.capability_defaults()).then(v=>{u&&($.current=bh(v))}).catch(()=>{u&&($.current={})}),()=>{u=!1}},[s,r]),h.useEffect(()=>{const u=()=>y(Ju());return window.addEventListener(Yu,u),window.addEventListener("storage",u),()=>{window.removeEventListener(Yu,u),window.removeEventListener("storage",u)}},[]);const P=h.useMemo(()=>{const u=String(m||"").trim();if(!(!r||!s||!u))return v=>{const k=s.voice_stream_transport(u,{text:v,...$.current,...wh(N.current)});return c_({path:k.path,body:k.body,headers:k.headers})}},[s,r,m]),T=Hf({tts_stream:P,on_error:x});h.useEffect(()=>{if(!w)return;O(w);const u=setTimeout(()=>x(""),6e3);return()=>clearTimeout(u)},[w]);const[F,D]=h.useState(null),J=h.useRef(null);h.useEffect(()=>{J.current=F},[F]);const[B,ee]=h.useState(""),[C,Z]=h.useState(null),[ae,fe]=h.useState([]),[ge,Te]=h.useState({}),[Se,K]=h.useState({}),[te,z]=h.useState({}),[V,H]=h.useState({}),[ce,I]=h.useState(null),[_e,Y]=h.useState(""),S=h.useRef(0),A=h.useRef(!1),U=h.useRef(!1);async function ie(){if(!A.current&&!(Date.now()-S.current<3e4)){S.current=Date.now();try{const u=await l.desk();I(v=>v==="loading"?v:u),u.rows.length&&!U.current&&Xt(v=>v!==""?v:(U.current=!0,"desk"))}catch(u){((u==null?void 0:u.status)===403||(u==null?void 0:u.status)===404)&&(A.current=!0)}}}async function de(){I("loading"),Y("");try{const u=await l.desk();I(u),S.current=Date.now(),A.current=!1}catch(u){I(null),Y((u==null?void 0:u.status)===403?"The desk serves operators and reporting delegates only — this console's seat is neither.":(u==null?void 0:u.status)===404?'The hub does not answer GET /desk (older hub build) — the amber "needs reply" pills on messages still mark what waits on you.':`The desk read failed (${String((u==null?void 0:u.message)||u||"network error").slice(0,120)}) — transient; Refresh retries.`)}}const[L,ke]=h.useState(""),[be,Ie]=h.useState([]),[Fe,Ye]=h.useState("all"),he=h.useRef(null),[Re,ze]=h.useState(null),re=h.useRef(""),[xe,O]=h.useState(""),[me,De]=h.useState(!1),[G,le]=h.useState({}),[ye,Oe]=h.useState({}),[ot,xt]=h.useState({}),pe=h.useRef(new Set),R=h.useRef(0),[X,$e]=h.useState(""),[Ae,Ge]=h.useState(""),[et,ct]=h.useState([]),[wt,pt]=h.useState(!1),Ut=h.useRef(null),[Dt,Le]=h.useState(!1),rt=h.useRef(null);h.useEffect(()=>{const u=rt.current;u&&(u.style.height="auto",u.style.height=`${Math.min(u.scrollHeight+2,160)}px`)},[X,L]);const[Ze,we]=h.useState("fyi"),[je,Ke]=h.useState(""),[it,ht]=h.useState(""),[Xe,ws]=h.useState(null),[Jt,$t]=h.useState({}),[Yt,un]=h.useState(""),Ft=h.useRef(uy()),Ba=h.useRef(""),[Kn,Fn]=h.useState(!1),[ha,Er]=h.useState(!1),[xi,ut]=h.useState(""),[Wt,Qn]=h.useState(null),[Tt,Ua]=h.useState(null),[Tl,wi]=h.useState({});function Tr(u,v){v.length&&wi(k=>{const b={...k},E=new Set(b[u]||[]);for(const ne of v)E.add(ne);return b[u]=E,b})}function bi(u,v){const k=new Set(v.map(b=>String(b.agent_id||"")).filter(Boolean));k.size&&wi(b=>{const E=b[u];if(!E||![...E].some(ve=>k.has(ve)))return b;const ne=new Set([...E].filter(ve=>!k.has(ve))),q={...b};return ne.size?q[u]=ne:delete q[u],q})}const Wa=h.useRef(0),[Al,Ar]=h.useState(""),[At,Rl]=h.useState(null),[Ha,Fs]=h.useState(""),[rs,Rr]=h.useState(!1),[pa,Va]=h.useState(""),[dn,Ll]=h.useState([]);function kn(){l.delegations().then(u=>{Rl(u),Fs("")}).catch(u=>{Rl([]);const v=String((u==null?void 0:u.message)||u);Fs((u==null?void 0:u.status)===404||/allowlist/i.test(v)?"Delegation needs the updated console/hub — restart the stack to pick it up.":v)})}async function Zo(){if(!(!pa||!dn.length||rs)){Rr(!0),Fs("");try{await l.set_delegation(pa,dn),Va(""),Ll([]),kn()}catch(u){Fs(String((u==null?void 0:u.message)||u||"delegation failed"))}finally{Rr(!1)}}}async function ec(u){if(!rs){Rr(!0),Fs("");try{await l.revoke_delegation(u),kn()}catch(v){Fs(String((v==null?void 0:v.message)||v||"resign failed"))}finally{Rr(!1)}}}const[qn,Jn]=h.useState(null),[qs,Yn]=h.useState(null),[Pt,nn]=h.useState(""),[Lr,bs]=h.useState(null),[Bs,Mr]=h.useState([]),[Mt,js]=h.useState(""),[zr,dt]=h.useState(""),[Pr,ji]=h.useState(""),[Ga,ki]=h.useState(!1),[Si,Ka]=h.useState(""),[ks,Us]=h.useState({open:!1,name:"",is_private:!1}),[Ht,mn]=h.useState(!1),[Ss,is]=h.useState({}),[jt,Xt]=h.useState(""),[Bn,Ir]=h.useState(null),[Ws,Ml]=h.useState(""),[Un,Qa]=h.useState("channel"),[Ja,zl]=h.useState(""),[Hs,ls]=h.useState(null),[Vs,Ya]=h.useState(""),[Ni,Pl]=h.useState(""),[Gs,Xn]=h.useState(""),[_a,Or]=h.useState(null),[Zn,Xa]=h.useState(""),[os,ga]=h.useState(""),[Dr,qt]=h.useState(null),[Fr,fn]=h.useState([]),[Ks,Za]=h.useState(""),[Qs,Ci]=h.useState(!1),[qr,er]=h.useState(""),va=h.useRef(null),tr=h.useRef(0),Br=h.useRef(!1),Il=h.useRef(0),[$i,Ei]=h.useState(!1),Ur=h.useRef(""),$n=h.useRef([]),Ns=h.useRef([]),Cs=h.useRef(null),Ti=h.useRef(!1),Ai=h.useRef(null);Ur.current=L,$n.current=ae,Ns.current=be,h.useEffect(()=>{for(const u of be){const v=wa.current[u.id];v!==void 0&&u.ratings&&Number(u.ratings.mine||0)===v&&delete wa.current[u.id]}},[be]);const Wr=h.useRef(!1);async function tc(u){var v;try{const k=await l.inbox(),b=$v(k),E=Ev(k);K(Be=>Iu(Be,E)?Be:E);const ne=Tv(k,((v=J.current)==null?void 0:v.seat)||"");z(Be=>Iu(Be,ne)?Be:ne);const q=Av(k);H(Be=>Iu(Be,q)?Be:q),ie();const ve=u.slice(0,ly),Me=await Promise.allSettled(ve.map(Be=>l.digest(Be.name))),qe={};for(const Be of u)qe[Be.name]={unread:b[Be.name]||0,open_questions:0};Me.forEach((Be,Rt)=>{var An;const Ct=ve[Rt].name;if(Be.status==="fulfilled"){const gt=(An=Be.value)==null?void 0:An.counts;qe[Ct]={...qe[Ct],open_questions:Number((gt==null?void 0:gt.open_questions)||0)}}}),Te(Be=>Pu(Be,qe)?Be:qe)}catch{}}async function ya(u){if(Ti.current){Ai.current=u;return}Ti.current=!0;let v=u;try{for(;v;)Ai.current=null,await tc(v),v=Ai.current}finally{Ti.current=!1}}async function nr(){const v=[...await l.channels()];return v.sort((k,b)=>(b.last_at||0)-(k.last_at||0)),fe(k=>Pu(k,v)?k:v),$n.current=v,v}async function cs(){try{const[u,v]=await Promise.all([l.meta(),l.channels()]);D({seat:u.seat,seat_key_present:u.seat_key_present}),ee(String(u.hub_url||"")),l.healthz().then(E=>Z(E)).catch(()=>Z(null)),l.presence().then(E=>{const ne=[...new Set(E.map(q=>String(q.agent_id||"")).filter(q=>q&&q!==u.seat))].sort();Mr(ne)}).catch(()=>Mr([]));const k=[...v];k.sort((E,ne)=>(ne.last_at||0)-(E.last_at||0)),fe(k);const b=k.filter(E=>!E.name.startsWith("dm:"));!L&&b.length&&ke(b[0].name),O(""),ya(k)}catch(u){O(String((u==null?void 0:u.message)||u||"Hub unreachable"))}}async function us(u,v){var b,E,ne;if(!u)return;const k=R.current;v!=null&&v.background||De(!0);try{const q=Ns.current.length&&Ns.current[Ns.current.length-1].seq||0,ve=((b=$n.current.find(at=>at.name===u))==null?void 0:b.last_seq)||0;let Me=ve,qe=null;if(!(v!=null&&v.background))if(ve>0)qe=nr().catch(()=>null);else try{const at=await nr();if(k!==R.current)return;Me=((E=at.find(xn=>xn.name===u))==null?void 0:E.last_seq)||0}catch{}const Be=Math.max(0,Me-ma),Rt=v!=null&&v.background&&q>0?Math.max(0,q-iy):Be,Ct=await l.messages(u,{since:Rt,limit:ma});if(k!==R.current)return;const An=new Set(Ns.current.map(at=>at.id)),gt=Ct.some(at=>!An.has(at.id));if(v!=null&&v.background&&!gt&&q>0){const at=Date.now();if(at-Il.current>1e4){Il.current=at;try{const xn=await nr();if(k!==R.current)return;const vt=((ne=xn.find(Ue=>Ue.name===u))==null?void 0:ne.last_seq)||0;if(vt>0&&vt<q){const Ue=Math.max(0,vt-ma),St=await l.messages(u,{since:Ue,limit:ma});if(k!==R.current)return;St.sort((rn,Zt)=>(rn.seq||0)-(Zt.seq||0)),Ie(St),O("");return}}catch{}}}Ct.sort((at,xn)=>(at.seq||0)-(xn.seq||0)),Ie(at=>{if(v!=null&&v.background&&at.length){if(!Ct.length)return at;const xn=new Set(at.map(bt=>bt.id)),vt=Ct.filter(bt=>!xn.has(bt.id)),Ue=new Map(Ct.map(bt=>[bt.id,bt]));let St=0;const rn=at.map(bt=>{const ft=Ue.get(bt.id);if(!ft)return bt;const Lt=JSON.stringify(ft.ratings??null)!==JSON.stringify(bt.ratings??null)||(ft.has_resolved_reply??null)!==(bt.has_resolved_reply??null)||JSON.stringify(ft.pending_asks??null)!==JSON.stringify(bt.pending_asks??null)||!!ft.retracted!=!!bt.retracted;return Lt&&St++,Lt?ft:bt});if(!vt.length&&!St)return at;const Zt=[...St?rn:at,...vt];return Zt.length>ma*2?Zt.slice(Zt.length-ma*2):Zt}return Ct}),O(""),!(v!=null&&v.background)&&qe&&(async()=>{var at;try{const xn=await qe;if(k!==R.current||!xn)return;const vt=((at=xn.find(Ue=>Ue.name===u))==null?void 0:at.last_seq)||0;if(vt>0&&vt!==ve){const Ue=Math.max(0,vt-ma),St=await l.messages(u,{since:Ue,limit:ma});if(k!==R.current)return;St.sort((rn,Zt)=>(rn.seq||0)-(Zt.seq||0)),Ie(rn=>Pu(rn,St)?rn:St)}}catch{}})()}catch(q){if(k!==R.current)return;O(String((q==null?void 0:q.message)||q||"Failed to load messages"))}finally{!(v!=null&&v.background)&&k===R.current&&De(!1)}}h.useEffect(()=>{cs()},[]),h.useEffect(()=>{let u=null,v=!1,k=0,b=0;const E=()=>{if(!v){try{u=new WebSocket(l.ws_url())}catch{Ei(!1),k+=1,setTimeout(E,Math.min(15e3,1e3*Math.max(1,k)));return}u.onopen=()=>{Ei(!0),b=Date.now(),(!$n.current.length||!J.current)&&cs()},u.onmessage=ne=>{var q;try{const ve=JSON.parse(String(ne.data||"{}"));if((ve==null?void 0:ve.type)!=="envelope")return;const Me=String(((q=ve.envelope)==null?void 0:q.channel)||"");Me&&Me===Ur.current&&us(Me,{background:!0}),Me&&!$n.current.some(qe=>qe.name===Me)&&nr(),Cs.current&&clearTimeout(Cs.current),Cs.current=setTimeout(()=>void ya($n.current),800)}catch{}},u.onclose=()=>{Ei(!1),v||(b&&Date.now()-b>=15e3?k=0:k+=1,b=0,setTimeout(E,Math.min(15e3,1e3*Math.max(1,k))))},u.onerror=()=>{try{u==null||u.close()}catch{}}}};return E(),()=>{v=!0,Cs.current&&clearTimeout(Cs.current);try{u==null||u.close()}catch{}}},[]),h.useEffect(()=>{R.current+=1,le({}),Oe({}),xt({}),pe.current=new Set,Qn(null),Ua(null);try{T.stop_tts()}catch{}Wa.current=0,wa.current={},lr("recency"),ta(null),ei(""),Or(null),Xa(""),ga(""),qt(null),Jn(null),Yn(null),bs(null),nn(""),dt(""),is({}),fn([]),er(""),Ci(!1),Za(""),Ie([]),Ye(he.current||"all"),he.current=null,ws(null),$t({}),un(""),ct([]),Ba.current&&Ba.current!==L&&(X||Ae?Ft.current[Ba.current]={text:X,title:Ae,kind:Ze}:delete Ft.current[Ba.current],yl(Ft.current));const u=Ft.current[L];if($e((u==null?void 0:u.text)||""),Ge((u==null?void 0:u.title)||""),we((u==null?void 0:u.kind)||"fyi"),Ba.current=L,Wr.current=!0,us(L),!L)return;jt==="files"&&Ii(),jt==="members"&&Ri();const v=setInterval(()=>{tr.current+=1,Br.current||(Br.current=!0,us(L,{background:!0}).finally(()=>{Br.current=!1})),tr.current%ry===0&&(nr().then(k=>ya(k)).catch(()=>ya($n.current)),l.healthz().then(Z).catch(()=>{}),l.meta().then(k=>D(k)).catch(()=>{}))},ay);return()=>clearInterval(v)},[L]);const Ol=h.useRef({text:"",title:"",kind:"fyi",selected:""});Ol.current={text:X,title:Ae,kind:Ze,selected:L},h.useEffect(()=>{if(!L)return;const u=setTimeout(()=>{X||Ae?Ft.current[L]={text:X,title:Ae,kind:Ze}:delete Ft.current[L],yl(Ft.current)},300);return()=>clearTimeout(u)},[X,Ae,Ze,L]),h.useEffect(()=>{const u=()=>{const v=Ol.current;v.selected&&(v.text||v.title?Ft.current[v.selected]={text:v.text,title:v.title,kind:v.kind}:delete Ft.current[v.selected],yl(Ft.current))};return window.addEventListener("pagehide",u),window.addEventListener("beforeunload",u),()=>{window.removeEventListener("pagehide",u),window.removeEventListener("beforeunload",u),u()}},[]),h.useEffect(()=>{const u=va.current;if(!u||!be.length)return;if(Wr.current){Wr.current=!1,u.scrollTop=u.scrollHeight;return}u.scrollHeight-u.scrollTop-u.clientHeight<240&&(u.scrollTop=u.scrollHeight)},[be]),h.useEffect(()=>{if(Fe!=="unread"||!L){ze(null);return}const u=Se[L];ze(new Set(u||[])),re.current=""},[Fe,L]),h.useEffect(()=>{if(Fe!=="unread"||!L||!Re||!Re.size)return;const u=Math.min(...Re),v=be.length&&be[0].seq||0;if(!u||!v||v<=u)return;const k=`${L}:${u}`;if(re.current===k)return;re.current=k;const b=R.current;l.messages(L,{since:Math.max(0,u-1),limit:ma}).then(E=>{b!==R.current||!E.length||Ie(ne=>{const q=new Set(ne.map(Me=>Me.id)),ve=E.filter(Me=>!q.has(Me.id));return ve.length?[...ne,...ve].sort((Me,qe)=>(Me.seq||0)-(qe.seq||0)):ne})}).catch(()=>{b===R.current&&(ut("Couldn't load the older unread messages — the Unread list may be incomplete. Re-select Unread to retry."),setTimeout(()=>ut(""),6e3))})},[Fe,L,Re,be]);function Dl(u){pe.current.has(u.id)||(pe.current.add(u.id),l.read_message(u.channel,u.id).catch(()=>{}),l.ack(u.channel,u.seq).catch(()=>{}),K(v=>{const k=v[u.channel];if(!k||!k.has(u.seq))return v;const b=new Set(k);return b.delete(u.seq),{...v,[u.channel]:b}}),Cs.current&&clearTimeout(Cs.current),Cs.current=setTimeout(()=>void ya($n.current),500),u.critical&&(ut(`Read recorded for critical #${u.seq}.`),setTimeout(()=>ut(""),2500)))}function Fl(u){const v=!G[u.id];le(k=>({...k,[u.id]:v})),v&&Dl(u)}function ql(u){const v=window.getSelection();if(v&&!v.isCollapsed)return;const k=String(u.body||""),b=u.status==="reply"?Lf:Ho;k.length>b?Fl(u):Dl(u)}async function nc(){if(!L||Wt==="running")return;const u=R.current;Qn("running");try{const v=await l.ledger(L),k=await sy(v);if(u!==R.current)return;Qn(k)}catch(v){if(u!==R.current)return;Qn({error:String((v==null?void 0:v.message)||v||"verification failed")})}}function Ri(){{const u=R.current;Ua("loading"),Jn(null),Ar(""),Yn(null),l.channel_info(L).then(v=>{u===R.current&&Ua(v)}).catch(v=>{u===R.current&&Ua({error:String((v==null?void 0:v.message)||v||"info failed")})}),l.members(L).then(v=>{u===R.current&&(Jn(v),Ar(""),bi(L,v))}).catch(v=>{u===R.current&&(Jn([]),Ar(String((v==null?void 0:v.message)||v||"members unavailable")))}),l.list_blocks().then(v=>{u===R.current&&Yn(v)}).catch(()=>{u===R.current&&Yn([])}),l.retired_agents().then(v=>{u===R.current&&bs(v)}).catch(()=>{u===R.current&&bs([])})}}function xa(u){const v=jt===u?"":u;if(Xt(v),v==="files"&&Ii(),v==="members"){let k=0;for(const b of Ns.current)String(b.sender||"")==="hub"&&(b.seq||0)>k&&(k=b.seq||0);Wa.current=k,Ri(),kn()}v==="leaderboard"&&Li(Un),v==="desk"&&de()}function Li(u){const v=R.current;Ir(null),Ml(""),zl(""),ls(null),Xn(""),(u==="hub"?l.reputation_hub():l.reputation(L)).then(b=>{v===R.current&&Ir(b)}).catch(b=>{if(v!==R.current)return;const E=Number((b==null?void 0:b.status)||0);Ml(E===404||E===403?"Reputation ships with the next hub update — relaunch the hub (agora ≥ 0.12.7) and reopen this drawer.":String((b==null?void 0:b.message)||b||"failed to load leaderboard"))})}function Bl(u){const v=Ja===u?"":u;if(zl(v),ls(null),Xn(""),!v||Un==="hub")return;const k=R.current;l.reputation_votes(L,v).then(b=>{k===R.current&&ls(b)}).catch(b=>{k===R.current&&(ls(null),Xn(`votes list failed: ${String((b==null?void 0:b.message)||b||"fetch failed")}`))})}const[Mi,Ul]=h.useState(""),[$s,Js]=h.useState("");h.useEffect(()=>{if(!$s)return;const u=setTimeout(()=>Js(""),6e3);return()=>clearTimeout(u)},[$s]);async function sc(u){if($s!==u.id){Js(u.id);return}Js("");try{const v=Array.isArray(u.pending_asks)?u.pending_asks.filter(Boolean):[];await l.post_message(u.channel,{body:`Declined on the record by ${(F==null?void 0:F.seat)||"operator"} — closing without a substantive answer.`,status:"reply",reply_to:u.id,to:u.sender?[u.sender]:void 0,...v.length?{answers:v}:{}}),z(k=>{const b=k[u.channel];if(!(b!=null&&b.has(u.seq)))return k;const E=new Set(b);return E.delete(u.seq),{...k,[u.channel]:E}})}catch(v){O(String((v==null?void 0:v.message)||v||"decline failed"))}}const wa=h.useRef({});function Hr(u){const v=u.ratings;return v?Kv(v,wa.current[u.id]):null}async function zi(u,v){var E,ne;const k=(F==null?void 0:F.seat)||"";if(!u||!k||Mi)return;const b=Ns.current.find(q=>q.id===u)||((E=eo.current)==null?void 0:E.find(q=>q.id===u));if(b){Ul(`${u}:${v}`),Xn("");try{const q=((ne=Hr(b))==null?void 0:ne.mine)??0;q===v?await l.unrate_message(L,u):await l.rate_message(L,u,v),wa.current[u]=q===v?0:v}catch(q){Xn(String((q==null?void 0:q.message)||q||"rating failed"))}finally{Ul("")}}}async function Pi(u,v,k){if(!Ni){Pl(`${u}:${v}:${k}`),Xn("");try{await l.rate(L,u,v,k,Vs.trim()),Ya("");const b=R.current,[E,ne]=await Promise.all([l.reputation(L),l.reputation_votes(L,u)]);b===R.current&&(Ir(E),ls(ne))}catch(b){Xn(String((b==null?void 0:b.message)||b||"vote failed"))}finally{Pl("")}}}function Ii(){const u=R.current;Or(null),Xa(""),ga(""),l.fs_list(L).then(v=>{u===R.current&&Or(v)}).catch(v=>{u===R.current&&Xa(String((v==null?void 0:v.message)||v||"failed to list files"))})}async function ba(u){const v=R.current,k=Sr(u.path,"text/markdown"),b=`${u.updated_by||"?"} · ${wl(u.updated_at)} · v${u.version}`;qt({name:u.path,mode:k==="image"?"text":k,meta:b,loading:!0});try{const E=await l.fs_read(L,u.path);if(v!==R.current)return;const ne=Sr(u.path,E.mime);qt({name:u.path,mode:ne==="image"?"text":ne,text:Vo(E.content),content_type:E.mime,meta:b,loading:!1})}catch(E){if(v!==R.current)return;qt({name:u.path,mode:"text",meta:b,error:String((E==null?void 0:E.message)||E||"failed to read file")})}}const Ys=h.useRef(null);function sr(){const u=Ys.current,v=Ns.current;if(!u||!v.length)return;if(u.message_id?v.some(b=>b.id===u.message_id):!1){Ys.current=null,requestAnimationFrame(()=>{const b=document.getElementById(`hubmsg-${u.message_id}`);b==null||b.scrollIntoView({block:"center"}),b==null||b.classList.add("hit"),setTimeout(()=>b==null?void 0:b.classList.remove("hit"),2500)});return}if(u.seq&&Number.isFinite(u.seq)){const b=R.current,E=u.seq;Ys.current={...u,seq:void 0},l.messages(L,{since:Math.max(0,E-3),limit:10}).then(ne=>{b!==R.current||!ne.length||Ie(q=>{const ve=new Set(q.map(qe=>qe.id)),Me=ne.filter(qe=>!ve.has(qe.id));return Me.length?[...q,...Me].sort((qe,Be)=>(qe.seq||0)-(Be.seq||0)):q})}).catch(()=>{})}}h.useEffect(()=>{var b;if(!a.focus)return;const{channel:u,message_id:v,seq:k}=a.focus;(b=a.on_focus_consumed)==null||b.call(a),u&&(Ys.current={message_id:v,seq:k},u===L?sr():ke(u))},[a.focus]),h.useEffect(()=>{sr()},[be]),h.useEffect(()=>{if(jt!=="members"||!L)return;let u=0,v="";for(const b of be){if(b.channel&&b.channel!==L||String(b.sender||"")!=="hub")continue;const E=`${String(b.title||"")} ${String(b.body||"")}`;/\b(joined|left|kicked|banned|archived|reopened)\b/i.test(E)&&(b.seq||0)>u&&(u=b.seq||0,v=E)}if(!u||u<=Wa.current)return;const k=R.current;l.members(L).then(b=>{k===R.current&&(Wa.current=u,Jn(b),Ar(""),bi(L,b))}).catch(()=>{}),/\b(kicked|banned)\b/i.test(v)&&l.list_blocks(L).then(b=>{k===R.current&&Yn(b)}).catch(()=>{})},[be,jt,L]);const[ac,ar]=h.useState(null),Vr=h.useRef(0);h.useEffect(()=>{if(ar(null),Vr.current=0,!L)return;const u=R.current;l.fs_list(L).then(v=>{u===R.current&&ar(new Set(v.map(k=>String(k.path||"")).filter(Boolean)))}).catch(()=>{u===R.current&&ar(null)})},[L]),h.useEffect(()=>{const u=be.reduce((k,b)=>{if(b.channel&&b.channel!==L)return k;const E=String(b.title||"");return(E.startsWith("fs:put")||E.startsWith("fs:delete"))&&(b.seq||0)>k?b.seq||0:k},0);if(!u||u<=Vr.current)return;const v=R.current;l.fs_list(L).then(k=>{v===R.current&&(Vr.current=u,ar(new Set(k.map(b=>String(b.path||"")).filter(Boolean))))}).catch(()=>{})},[be,L]);async function rr(u){const v=R.current,k=Sr(u,"text/markdown");qt({name:u,mode:k==="image"?"text":k,loading:!0});try{const b=await l.fs_read(L,u);if(v!==R.current)return;const E=Sr(u,b.mime),ne=b.updated_by?`${b.updated_by} · ${wl(b.updated_at)} · v${b.version??"?"}`:void 0;qt({name:u,mode:E==="image"?"text":E,text:Vo(b.content),content_type:b.mime,meta:ne,loading:!1})}catch(b){if(v!==R.current)return;qt({name:u,mode:"text",error:String((b==null?void 0:b.message)||b||"failed to read file")+" — the file may have been rewritten under another path; check the Files drawer"})}}async function Es(u,v){const k=R.current,b=l.attachment_url(u,v.id),E=Sr(v.filename,v.content_type);if(E==="image"){qt({name:v.filename,mode:"image",url:b,content_type:v.content_type,size:v.size});return}if(E==="md"||E==="text"){if(v.size>Sl){qt({name:v.filename,mode:"download",url:b,content_type:v.content_type,size:v.size,error:`too large to preview inline (${On(v.size)} > ${On(Sl)}) — download to view`});return}qt({name:v.filename,mode:E,url:b,content_type:v.content_type,size:v.size,loading:!0});try{const ne=await fetch(b);if(!ne.ok)throw new Error(`fetch failed (${ne.status})`);const q=await ne.text();if(k!==R.current)return;qt({name:v.filename,mode:E,url:b,content_type:v.content_type,size:v.size,text:Vo(q)})}catch(ne){if(k!==R.current)return;qt({name:v.filename,mode:"download",url:b,content_type:v.content_type,size:v.size,error:String((ne==null?void 0:ne.message)||ne||"failed to load")})}return}qt({name:v.filename,mode:"download",url:b,content_type:v.content_type,size:v.size})}async function Gr(u,v,k="channel"){if(!Mt){js(`${k}:${v}:${u}`),dt("");try{k==="hub"?v==="unblock"?await l.hub_unblock(u):await l.hub_block(u,v==="kick"?{seconds:3600,reason:"hub kick (Continuum Team page)"}:{reason:"hub ban (Continuum Team page)"}):v==="unblock"?await l.unblock(L,u):await l.block(L,u,v==="kick"?{seconds:3600,reason:"kicked by the operator (Continuum Team page)"}:{reason:"banned by the operator (Continuum Team page)"}),ut(`${k==="hub"?"hub ":""}${v} → ${u} applied.`),setTimeout(()=>ut(""),3e3);const b=R.current,E=await l.members(L).catch(()=>null);E&&b===R.current&&Jn(E);const ne=await l.list_blocks().catch(()=>null);ne&&b===R.current&&Yn(ne)}catch(b){dt(String((b==null?void 0:b.message)||b||"moderation refused"))}finally{js("")}}}async function Kr(u){if(!Mt){js(`retire:${u}`),dt("");try{await l.retire_agent(u,"decommissioned via Continuum Team page"),nn(""),ut(`${u} retired (decommissioned — not banned).`),setTimeout(()=>ut(""),3500);const v=R.current,k=await l.members(L).catch(()=>null);k&&v===R.current&&Jn(k);const b=await l.retired_agents().catch(()=>null);b&&v===R.current&&bs(b)}catch(v){const k=v==null?void 0:v.status,b=String((v==null?void 0:v.message)||v||"");k===404||/not found|hub_route_not_allowed/i.test(b)?(ut("Agent retire ships with the next hub update — this control is wired and ready for it."),setTimeout(()=>ut(""),6e3)):dt(b||"retire refused")}finally{js("")}}}async function rc(u){if(!Mt){js(`unretire:${u}`),dt("");try{await l.unretire_agent(u),nn(""),ut(`${u} un-retired — it can rejoin channels explicitly.`),setTimeout(()=>ut(""),3500);const v=await l.retired_agents().catch(()=>null);v&&bs(v)}catch(v){dt(String((v==null?void 0:v.message)||v||"un-retire refused"))}finally{js("")}}}async function Wl(u){if(!Mt){js(`delete:${u}`),dt("");try{await l.delete_agent(u),nn(""),ut(`${u} deleted from the hub — off every roster and board; its id stays reserved.`),setTimeout(()=>ut(""),3500);const v=await l.retired_agents().catch(()=>null);v&&bs(v)}catch(v){const k=String((v==null?void 0:v.message)||v);dt((v==null?void 0:v.status)===404||/not found|allowlist/i.test(k)?"Delete needs the updated hub/console (0.12.41+) — restart the stack to pick it up.":/409|active/i.test(k)?`${u} is still active — retire it first, then delete.`:k||"delete refused")}finally{js("")}}}async function Qr(u){if(!Ht){mn(!0),dt("");try{let v={state:u},k;try{const b=await l.channel_meta(L);b&&typeof b.value=="object"&&b.value&&(v={...b.value,state:u}),typeof(b==null?void 0:b.version)=="number"&&(k=b.version)}catch{}await l.put_channel_meta(L,v,k),ut(u==="closed"?"Channel closed (member posts refused until reopened).":"Channel reopened."),setTimeout(()=>ut(""),3500),Ri(),cs()}catch(v){dt(String((v==null?void 0:v.message)||v||"channel state change refused"))}finally{mn(!1)}}}const[Oi,Di]=h.useState("");async function Hl(u){if(!Ht){mn(!0),O("");try{await l.leave(u),Di(""),L===u&&ke(""),await cs(),ut("Direct message removed from your list."),setTimeout(()=>ut(""),3e3)}catch(v){O(String((v==null?void 0:v.message)||v||"leave refused"))}finally{mn(!1)}}}const[Vl,Fi]=h.useState("");async function ic(u){if(!Ht){mn(!0),O("");try{await l.archive(u),Fi(""),L===u&&ke(""),await cs(),ut(`Channel #${u} archived (history preserved).`),setTimeout(()=>ut(""),3500)}catch(v){const k=String((v==null?void 0:v.message)||v||"");(v==null?void 0:v.status)===404||/not found|hub_route_not_allowed/i.test(k)?(Fi(""),ut("Channel archive ships with the next hub update — this control is wired and ready for it."),setTimeout(()=>ut(""),6e3)):O(k||"archive refused")}finally{mn(!1)}}}async function Gl(){const u=ks.name.trim();if(!(!u||Ht)){mn(!0),O("");try{await l.create_channel(u,ks.is_private),Us({open:!1,name:"",is_private:!1}),await cs(),ke(u),ut(`Channel #${u} created.`),setTimeout(()=>ut(""),3e3)}catch(v){O(String((v==null?void 0:v.message)||v||"channel create refused"))}finally{mn(!1)}}}async function Kl(u,v){if(!c)throw new Error("AI advisor is not available");return c(u,v)}async function lc(u){if(!f)return;const v=u.root.id,k=R.current,b=u.replies.length+1;is(E=>{var ne;return{...E,[v]:{busy:!0,text:((ne=E[v])==null?void 0:ne.text)||"",error:"",count:b}}});try{const ne=`Summarize this hub discussion thread in at most 5 short bullet points: the question or claim, the positions taken, decisions reached, and anything still open. Be concrete — name senders and receipts.
111
-
112
- THREAD TRANSCRIPT:
113
- ${Tf([u.root,...u.replies])}`,q=await Kl(ne,[]);if(k!==R.current)return;is(ve=>({...ve,[v]:{busy:!1,text:q,error:"",count:b}}))}catch(E){if(k!==R.current)return;is(ne=>({...ne,[v]:{busy:!1,text:"",error:String((E==null?void 0:E.message)||E||"summary failed"),count:b}}))}}async function En(u){const v=u.trim();if(!v||Qs||!f)return;const k=R.current;Xt("assistant"),Ci(!0),er(""),fn(b=>[...b,{role:"user",content:v}]);try{const b=Tf(be),E=`You are the operator's analyst for the agora hub channel #${L}. Answer from the transcript below — strategies used, deviations, who owes what, timeline of decisions. Cite message seqs like #123. If the transcript does not contain the answer, say so plainly.
114
-
115
- CHANNEL TRANSCRIPT (window):
116
- ${b}
117
-
118
- QUESTION: ${v}`,ne=await Kl(E,Fr);if(k!==R.current)return;fn(q=>[...q,{role:"assistant",content:ne}])}catch(b){if(k!==R.current)return;er(String((b==null?void 0:b.message)||b||"assistant failed"))}finally{k===R.current&&Ci(!1)}}const[Ts,qi]=h.useState(""),[ir,Bi]=h.useState("");async function Ql(u){if(!Kn){Fn(!0),O("");try{await l.retract_message(L,u.id),Bi(""),ut(`#${u.seq} retracted — readers see a tombstone, the words are gone from every agent-facing read.`),setTimeout(()=>ut(""),4e3),await us(L,{background:!0})}catch(v){const k=String((v==null?void 0:v.message)||v||"retract failed");O(/404|not found/i.test(k)?"Retraction ships with the hub's next bounce (0.12.16) — the running hub predates the verb. Nothing was changed.":k)}finally{Fn(!1)}}}async function Ui(u){if(!Kn){Fn(!0),O("");try{const v=Sf(L,kt);await l.post_message(L,{body:"Resolved.",status:"resolved",to:v?[v]:void 0,reply_to:u.id}),qi(""),ut(`Marked #${u.seq} resolved.`),setTimeout(()=>ut(""),3e3),await us(L,{background:!0})}catch(v){O(String((v==null?void 0:v.message)||v||"Resolve failed"))}finally{Fn(!1)}}}async function Jl(u){if(!u||!u.length||wt)return;const v=Array.from(u);if(et.length+v.length>vl){O(`At most ${vl} attachments per message.`);return}const k=v.find(q=>q.size>zf);if(k){O(`"${k.name}" is ${On(k.size)} — the limit is ${On(zf)}.`);return}const b=R.current,E=L;pt(!0),O("");let ne=0;try{for(const q of v){const ve=await l.upload_attachment(E,q);if(b!==R.current||L!==E)return;ct(Me=>[...Me,ve]),ne+=1}}catch(q){const ve=q==null?void 0:q.status,Me=String((q==null?void 0:q.message)||q||"");if(ve===404||/not found|hub_route_not_allowed/i.test(Me))ut("Attachments ship with the next hub update — the composer control is wired and ready for it."),setTimeout(()=>ut(""),6e3);else{const qe=v.length>1?` (${ne} of ${v.length} attached before this)`:"";O(`${Me||"attachment upload failed"}${qe}`)}}finally{pt(!1),Ut.current&&(Ut.current.value="")}}function oc(u){var k;ws(u);const v=((k=u.data)==null?void 0:k.asks)||[];$t(v.length===1?{[v[0].id]:!0}:{}),un(""),we("fyi")}function Xs(){ws(null),$t({}),un("")}async function Wi(u){const{title:v,members:k}=Lu(u);if(!k.length){O("/group: no @mentions found — usage: /group fix the voice outage @gateway @core");return}const b=v||`focused work with ${k.join(", ")}`;await Zs({title:b,members:k})}async function ja(u,v,k){const b=[],E=[];for(const ne of k)try{const q=await fetch(l.attachment_url(u,ne.id));if(!q.ok)throw new Error(`fetch ${q.status}`);const ve=await q.blob(),Me=new File([ve],ne.filename||"attachment",{type:ne.content_type||ve.type||"application/octet-stream"}),qe=await l.upload_attachment(v,Me);b.push({id:qe.id,filename:qe.filename||ne.filename})}catch(q){E.push(`${ne.filename||ne.id.slice(0,8)} (${String((q==null?void 0:q.message)||q)})`)}return{migrated:b,att_failed:E}}async function Jr(u,v,k){try{const b=await l.create_invite(u,v);return await l.send_dm(v,{title:`invite to ${u}${k?`: ${k}`:""}`.slice(0,120),body:`You are invited to '${u}'${k?` — ${k}`:""}. Join with join_channel(channel='${u}', invite_token='${b}'), read the recent messages, and work the topic THERE.`}),null}catch(b){return String((b==null?void 0:b.message)||b)}}async function Yl(u){var v,k;if(!(!L||!u)){ki(!0),Ka("");try{const b=Tt&&typeof Tt=="object"&&"meta"in Tt?String(((v=Tt.meta)==null?void 0:v.purpose)||""):"",E=!!((k=$n.current.find(q=>q.name===L))!=null&&k.private);let ne=null;if(E)ne=await Jr(L,u,b||void 0);else try{await l.send_dm(u,{title:`join ${L}${b?`: ${b}`:""}`.slice(0,120),body:`You are invited to '${L}' (public)${b?` — ${b}`:""}. Join with join_channel(channel='${L}'), read the recent messages, and work the topic THERE.`})}catch(q){ne=String((q==null?void 0:q.message)||q)}ne?Ka(ne.includes("outside the Team page allowlist")?"Invites need the updated console server — one stack restart activates them; nothing was sent.":`Invite failed: ${ne}`):(Ka(`Invited @${u} — join pointer DM'd.`),ji(""),Tr(L,[u]))}finally{ki(!1),setTimeout(()=>Ka(""),8e3)}}}async function Yr(u,v){var k;try{const b=Lu(v).members;if(!b.length)return;const E=await l.members(u),ne=new Set(E.map(Be=>String(Be.agent_id||""))),q=b.filter(Be=>!ne.has(Be)&&Bs.includes(Be)&&Be!==kt);if(!q.length)return;const ve=!!((k=$n.current.find(Be=>Be.name===u))!=null&&k.private),Me=[],qe=[];for(const Be of q)if(ve){const Rt=await Jr(u,Be);Rt?qe.push(`${Be} (${Rt})`):Me.push(Be)}else try{await l.send_dm(Be,{title:`you were mentioned in #${u}`.slice(0,120),body:`You were mentioned in #${u} (public). Join with join_channel(channel='${u}') and read the recent messages.`}),Me.push(Be)}catch(Rt){qe.push(`${Be} (${String((Rt==null?void 0:Rt.message)||Rt)})`)}Me.length&&(Tr(u,Me),ut(`Posted — @${Me.join(", @")} ${ve?"invited":"nudged"} (mentioned, not yet member${Me.length===1?"":"s"}).`)),qe.length&&O(qe.some(Be=>Be.includes("outside the Team page allowlist"))?"Posted; inviting mentioned non-members needs the updated console server (one stack restart).":`Posted; invite failed for ${qe.join("; ")}.`)}catch{}}async function Zs(u){var ne,q;const{title:v,members:k}=u,b=[...et],E=L;Fn(!0),O("");try{const ve=new Set($n.current.map(gt=>gt.name)),Me=zu(v,ve);let qe=[],Be=[],Rt=!1;try{const gt=await l.create_group({name:Me,members:k,purpose:v,opening_post:((ne=u.opening_body)==null?void 0:ne.trim())||v,private:!0});Rt=!0,qe=Array.isArray(gt==null?void 0:gt.invited)?gt.invited.map(String):k,Be=Array.isArray(gt==null?void 0:gt.failed)?gt.failed.map(at=>typeof at=="string"?at:`${(at==null?void 0:at.agent)||(at==null?void 0:at.member)||(at==null?void 0:at.peer)||"?"} (${String((at==null?void 0:at.error)||(at==null?void 0:at.detail)||"failed")})`):[]}catch(gt){const at=String((gt==null?void 0:gt.message)||gt||"");if(!((gt==null?void 0:gt.status)===404||at.includes("outside the Team page allowlist")||at.includes("Not Found")))throw gt;try{await l.create_invite("__group-preflight__",k[0])}catch(vt){if(String((vt==null?void 0:vt.message)||vt).includes("outside the Team page allowlist")){O("/group needs the updated console server — this process predates the invite route. Restart the console (next stack restart picks it up) and retry; nothing was created.");return}}await l.create_channel(Me,!0),await l.put_channel_meta(Me,{purpose:v},0);for(const vt of k)try{const Ue=await l.create_invite(Me,vt);await l.send_dm(vt,{title:`invite to ${Me}: ${v}`.slice(0,120),body:`You are invited to '${Me}' — focused room: ${v}. Join with join_channel(channel='${Me}', invite_token='${Ue}'), read the opening post, and work the topic THERE (not in commons).`}),qe.push(vt)}catch(Ue){Be.push(`${vt} (${String((Ue==null?void 0:Ue.message)||Ue)})`)}}const{migrated:Ct,att_failed:An}=await ja(E,Me,b);Rt?Ct.length&&await l.post_message(Me,{body:"Attachments carried over from the create request.",status:"fyi",attachments:Ct}):await l.post_message(Me,{body:((q=u.opening_body)==null?void 0:q.trim())||v,title:v.slice(0,120),status:"open",attachments:Ct.length?Ct:void 0}),Tr(Me,qe),ut(`Room '${Me}' created — private, ${qe.length} invited${qe.length?`: ${qe.join(", ")}`:""}.`+(Ct.length?` ${Ct.length} attachment(s) carried over.`:"")+(Be.length?` Invite FAILED for ${Be.join("; ")}.`:"")),Be.length&&O(`Some invites failed — ${Be.join("; ")}. Mint them again from the room's Members drawer or re-run /group.`),An.length&&O(`Attachment carry-over failed for ${An.join("; ")} — the room and post were created; re-attach in the new room.`),$e(""),Ge(""),ht(""),we("fyi"),ct([]),delete Ft.current[L],yl(Ft.current),await cs(),ke(Me),setTimeout(()=>ut(""),6e3)}catch(ve){O(`group creation failed: ${String((ve==null?void 0:ve.message)||ve)}`)}finally{Fn(!1)}}async function Xr(){var ne;const u=X.trim(),v=et.length>0,k=!Xe&&!L.startsWith("dm:")&&Ze==="group";if(!u&&!v&&!k||Kn||!L)return;if(k){const q=Mu(it);if(!q.length){O("Group needs at least one member — write their names like: @entity @assistant");return}const ve=Ae.trim()||(u?u.split(`
119
- `)[0].slice(0,80):`focused work with ${q.join(", ")}`);await Zs({title:ve,members:q,opening_body:u});return}if(/^\/assistant(?=\s|$)/i.test(u)){if(!f){O("AI advisor is not configured — connect a gateway or inject an advisor.");return}const q=u.replace(/^\/assistant/i,"").trim();$e(""),q?En(q):Xt("assistant");return}if(/^\/group(?=\s|$)/i.test(u)){await Wi(u.replace(/^\/group/i,"").trim());return}if(/^\//.test(u)){O(`Unknown command "${u.split(/\s/)[0]}" — only /assistant and /group are supported. Remove the leading "/" to post this as a message.`);return}const b=Object.entries(Jt).filter(([,q])=>q).map(([q])=>q),E=L.startsWith("dm:");if(Xe&&(((ne=Xe.data)==null?void 0:ne.asks)||[]).length&&!b.length&&Yt!=="void_reply"){un("void_reply");return}if(!Xe&&!E&&Ze==="ask"&&!Ae.trim()&&Yt!=="untitled_open"){un("untitled_open");return}if(!Xe&&!E&&Ze==="dm"&&!je.trim()){O("Pick a recipient for the direct message.");return}Fn(!0),O("");try{if(!Xe&&!E&&Ze==="dm"){const q=je.trim(),ve=[...et],Me=L;await l.send_dm(q,{body:u||(ve.length?`(${ve.length} attachment${ve.length===1?"":"s"})`:u),title:Ae.trim()||void 0});const qe=`dm:${[kt,q].sort().join("--")}`;if(ve.length){const{migrated:Be,att_failed:Rt}=await ja(Me,qe,ve);Be.length&&await l.post_message(qe,{body:"",to:[q],attachments:Be}),ut(`DM sent to ${q}${Be.length?` with ${Be.length} attachment(s)`:""}.`),Rt.length&&O(`Attachment carry-over failed for ${Rt.join("; ")} — the DM text was sent; re-attach inside the conversation.`)}else ut(`DM sent to ${q}.`);await cs(),ke(qe)}else{const q=et.map(qe=>({id:qe.id,filename:qe.filename})),ve=E?Sf(L,kt):"";E&&!ve&&O(`#FALLBACK this dm's pair does not include seat '${kt}' — sent unaddressed (no to-me wake; check ABSTRACTCONTINUUM_HUB_SEAT).`);const Me={body:u,title:Ae.trim()||void 0,status:Lv({is_reply:!!Xe,in_dm:E,kind:Ze}),to:ve?[ve]:void 0,reply_to:Xe==null?void 0:Xe.id,answers:Xe&&b.length?b:void 0,attachments:q.length?q:void 0};try{await l.post_message(L,Me)}catch(qe){if(ve&&/address non-members/i.test(String((qe==null?void 0:qe.message)||qe)))await l.post_message(L,{...Me,to:void 0}),O(`#FALLBACK '${ve}' is no longer a member of this dm — message delivered unaddressed (their listener will not get a to-me wake).`);else throw qe}ut(E?"Sent.":"Posted."),await us(L,{background:!0}),!E&&u&&Yr(L,u)}$e(""),Ge(""),ct([]),ws(null),$t({}),we("fyi"),Ke(""),un(""),delete Ft.current[L],yl(Ft.current),setTimeout(()=>ut(""),3e3)}catch(q){O(String((q==null?void 0:q.message)||q||"Post failed"))}finally{Fn(!1)}}async function Xl(u){if(!(!L||!u||ha||me)){Er(!0);try{await l.ack(L,u),ut(`Marked read to #${u}.`),setTimeout(()=>ut(""),3e3),ya($n.current)}catch(v){O(String((v==null?void 0:v.message)||v||"Ack failed"))}finally{Er(!1)}}}const hn=!!(F!=null&&F.seat_key_present)&&!(C!=null&&C.paused),kt=(F==null?void 0:F.seat)||"",Kt=L.startsWith("dm:"),Zr=(()=>{if(!Kt)return"";const u=L.slice(3);return kt&&u.startsWith(`${kt}--`)?u.slice(kt.length+2):kt&&u.endsWith(`--${kt}`)?u.slice(0,u.length-kt.length-2):u||L})(),Zl=h.useMemo(()=>Mv(be),[be]),ds=h.useMemo(()=>({seat:kt,unread_seqs:Se[L],unread_snapshot_seqs:Fe==="unread"&&Re||void 0,escalated_seqs:V[L]}),[kt,Se,L,Fe,Re,V]),ms=h.useMemo(()=>{if(Xe)return null;const u=new Set(ae.map(k=>k.name)),v=X.trimStart();if(/^\/group(\s|$)/i.test(v)){const{title:k,members:b}=Lu(v.replace(/^\/group/i,"").trim()),E=k||(b.length?`focused work with ${b.join(", ")}`:"");return{name:E?zu(E,u):"group",members:b,source:"slash"}}if(Ze==="group"&&!L.startsWith("dm:")){const k=Mu(it),b=Ae.trim()||(k.length?`focused work with ${k.join(", ")}`:"");return{name:b?zu(b,u):"group",members:k,source:"kind"}}return null},[X,Xe,ae,Ze,it,Ae,L]),sn=h.useMemo(()=>Nv(be),[be]),As=h.useMemo(()=>kf(sn,Fe,ds),[sn,Fe,ds]),[ea,lr]=h.useState("recency"),[or,ta]=h.useState(null),eo=h.useRef(null);h.useEffect(()=>{eo.current=or},[or]);const[Hi,ei]=h.useState("");function Et(){const u=R.current;ta(null),ei(""),l.messages(L,{sort:"votes",limit:50}).then(v=>{u===R.current&&ta(v)}).catch(v=>{if(u!==R.current)return;const k=String((v==null?void 0:v.message)||v);ei((v==null?void 0:v.status)===400||(v==null?void 0:v.status)===404||/allowlist/i.test(k)?"Top-voted needs the next hub update (this hub predates sort=votes) — Recency still works.":k)})}function Vi(u){Ys.current={message_id:u.id,seq:u.seq},lr("recency"),requestAnimationFrame(()=>sr())}const[cr,ka]=h.useState(""),[na,Gi]=h.useState("all"),[an,Sa]=h.useState(""),[pn,ur]=h.useState(null),[Ki,fs]=h.useState(null),Wn=h.useRef(0);function sa(u,v,k){if(!u&&!k)return;const b=++Wn.current;fs(null),ur({q:u,report:null,error:"",busy:!0}),l.search({q:u,channel:v==="channel"&&L?[L]:void 0,rated:k||void 0,sort:!u&&k?"votes":void 0}).then(E=>{b===Wn.current&&ur({q:u,report:E,error:"",busy:!1})}).catch(E=>{if(b!==Wn.current)return;const ne=String((E==null?void 0:E.message)||E);ur({q:u,report:null,busy:!1,error:(E==null?void 0:E.status)===404||/allowlist/i.test(ne)?"Search needs the next hub update (this hub predates search-grouped) — everything else still works.":ne})})}function ti(u){sa(u.trim(),na,an)}function dr(){Wn.current+=1,ur(null),fs(null),Sa("")}function Qi(u,v){const k=(pn==null?void 0:pn.q)||"";if(!k&&!an)return;const b=++Wn.current;fs({label:u,kind:v,hits:[],total:0,cursor:null,busy:!0,error:""}),l.search({q:k,kind:v,sort:"recent",limit:50,rated:an||void 0,channel:na==="channel"&&L?[L]:void 0}).then(E=>{if(b!==Wn.current)return;const ne=ni(E,v);fs({label:u,kind:v,hits:ne.hits,total:ne.total,cursor:E.next_cursor??null,busy:!1,error:""})}).catch(E=>{b===Wn.current&&fs({label:u,kind:v,hits:[],total:0,cursor:null,busy:!1,error:String((E==null?void 0:E.message)||E)})})}function Ji(){const u=Ki,v=(pn==null?void 0:pn.q)||"";if(!u||!u.cursor||u.busy||!v&&!an)return;const k=Wn.current;fs({...u,busy:!0}),l.search({q:v,kind:u.kind,sort:"recent",limit:50,cursor:u.cursor,rated:an||void 0,channel:na==="channel"&&L?[L]:void 0}).then(b=>{if(k!==Wn.current)return;const E=ni(b,u.kind);fs(ne=>ne&&ne.kind===u.kind?{...ne,hits:[...ne.hits,...E.hits],cursor:b.next_cursor??null,busy:!1}:ne)}).catch(b=>{k===Wn.current&&fs(E=>E&&E.kind===u.kind?{...E,busy:!1,error:String((b==null?void 0:b.message)||b)}:E)})}function ni(u,v){const k=Wo.find(E=>E.kind===v),b=k?u[k.id]:void 0;return b?{hits:b.hits||[],total:b.total||0}:{hits:[],total:0}}function cc(u){const v=String(u.channel||"");v&&(Ys.current={message_id:u.kind==="message"?u.ref:void 0,seq:u.seq??void 0},dr(),lr("recency"),v===L?sr():ke(v))}async function to(u){const v=String(u.channel||""),k=String(u.ref||"");if(!v||!k)return;const b=Sr(k,"text/markdown");qt({name:k,mode:b==="image"?"text":b,meta:`#${v}`,loading:!0});try{const E=await l.fs_read(v,k),ne=Sr(k,E.mime);qt({name:k,mode:ne==="image"?"text":ne,text:Vo(E.content),content_type:E.mime,meta:`#${v} · ${E.updated_by||"?"} · v${E.version??"?"}`,loading:!1})}catch(E){qt({name:k,mode:"text",meta:`#${v}`,error:String((E==null?void 0:E.message)||E||"failed to read file")})}}function no(u){const v=u.kind==="message"&&!!u.channel,k=u.kind==="file"&&!!u.channel,b=v||k,E=Qv(String(u.snippet||""),u.highlights),ne=u.ratings,q=String(u.channel||""),ve=q?q.startsWith("dm:")?q:`#${q}`:"";return e.jsxs("div",{className:`team_search_hit${b?" clickable":""}`,onClick:b?()=>k?void to(u):cc(u):void 0,role:b?"button":void 0,title:v?"Open this message in its thread":k?"Open this file":void 0,children:[e.jsxs("div",{className:"team_search_hit_head",children:[u.kind!=="message"?e.jsx("span",{className:"team_search_kind mono",children:u.kind}):null,ve?e.jsx("span",{className:"team_search_chan mono",children:ve}):null,u.sender?e.jsx("span",{className:"team_search_sender",style:{color:`hsl(${dd(String(u.sender))}, 60%, 55%)`},children:u.sender}):null,typeof u.seq=="number"&&u.seq>0?e.jsxs("span",{className:"muted mono",children:["#",u.seq]}):null,u.status==="open"||u.status==="blocked"?e.jsx("span",{className:"team_search_status mono",title:"This thread still carries an unresolved obligation",children:u.status}):null,typeof u.thread_hits=="number"&&u.thread_hits>1?e.jsxs("span",{className:"muted",title:"More matches in the same thread",children:[u.thread_hits," in thread"]}):null,ne&&(ne.up||ne.down)?e.jsxs("span",{className:"team_search_tally mono",title:"Standing ±1 ratings on this message (read-only here — vote from the thread)",children:["▲",ne.up," ▽",ne.down]}):null,u.created_at?e.jsx("span",{className:"muted team_search_time",children:wl(u.created_at)}):null]}),String(u.title||"").trim()?e.jsx("div",{className:"team_search_title",children:u.title}):null,E.length?e.jsx("div",{className:"team_search_snippet",children:E.map((Me,qe)=>Me.hit?e.jsx("mark",{children:Me.text},qe):e.jsx(Gt.Fragment,{children:Me.text},qe))}):null,!v&&!k&&u.kind!=="agent"?e.jsx("div",{className:"team_search_ref mono muted",children:u.ref}):null]},`${u.kind}:${q}:${u.ref}`)}const uc=h.useMemo(()=>{let u=0;for(const v of As)for(const k of[v.root,...v.replies])u=Math.max(u,k.seq||0);return u},[As]),Yi=h.useMemo(()=>{const u={};for(const v of["asks","vigilance","fyi","resolved","to_me"])u[v]=kf(sn,v,ds).length;return u.unread=be.filter(v=>{var k,b;return((k=ds.unread_seqs)==null?void 0:k.has(v.seq))||((b=ds.unread_snapshot_seqs)==null?void 0:b.has(v.seq))}).length,u},[sn,be,ds]);function Rs(){var u,v;return Tt==="loading"?e.jsx("span",{className:"muted team_note",children:"Loading channel info…"}):Tt&&typeof Tt=="object"&&"error"in Tt?e.jsx("span",{className:"page_error mono",children:Tt.error}):Tt?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"team_info_row",children:[Tt.state?e.jsx(In,{tone:Tt.state==="open"?"success":"warning",size:"sm",children:Tt.state}):null,(u=Tt.channel)!=null&&u.private?e.jsx(In,{tone:"muted",size:"sm",children:"private"}):e.jsx(In,{tone:"muted",size:"sm",children:"public"}),Tt.response_sla_minutes?e.jsxs(In,{tone:"muted",size:"sm",title:"Expected response SLA",children:["SLA ",Math.round(Number(Tt.response_sla_minutes)/60),"h"]}):null,e.jsxs("span",{className:"muted team_note",children:[(qn??Tt.members??[]).length," members"]})]}),(v=Tt.meta)!=null&&v.purpose?e.jsx("div",{className:"team_info_purpose",children:Tt.meta.purpose}):null,Tt.charter?e.jsxs("div",{className:"team_info_charter",children:[e.jsx("div",{className:"muted team_note",style:{marginBottom:4},children:"Charter"}),e.jsx(as,{className:"md_doc",text:jl(String(Tt.charter))})]}):e.jsx("div",{className:"muted team_note",children:"No charter set for this channel."}),e.jsxs("div",{className:"team_members",children:[e.jsxs("div",{className:"muted team_note",style:{marginBottom:4},children:["Members ",qn?`(${qn.length})`:""]}),!Kt&&qn!==null?e.jsxs("div",{className:"team_invite_row",children:[e.jsxs("select",{className:"team_compose_control team_invite_select",value:Pr,onChange:k=>ji(k.target.value),disabled:!!Ga,title:"Agents on the hub not yet in this channel",children:[e.jsx("option",{value:"",children:"invite: agent…"}),Bs.filter(k=>!(qn||[]).some(b=>String(b.agent_id||"")===k)).filter(k=>!(Tl[L]||new Set).has(k)).map(k=>e.jsx("option",{value:k,children:k},k))]}),e.jsx("button",{className:"btn",disabled:!Pr||!!Ga,title:"Mint a single-use invite token and DM it with the join pointer",onClick:()=>void Yl(Pr),children:Ga?"Inviting…":"Invite"})]}):null,Si?e.jsx("div",{className:"muted team_note",children:Si}):null,(()=>{const k=[...Tl[L]||[]].filter(b=>!(qn||[]).some(E=>String(E.agent_id||"")===b));return!k.length||qn===null?null:k.map(b=>e.jsxs("div",{className:"team_member_row team_member_invited",children:[e.jsx("span",{className:"team_avatar",style:Ia(b),"aria-hidden":"true",children:(b[0]||"?").toUpperCase()}),e.jsx("span",{className:"team_member_id",children:b}),e.jsx("span",{className:"chip mono warn",title:"The invite DM is in their inbox (status=open, owed) — agents join on their next wake; this row clears itself when they do.",children:"invited — awaiting join"})]},`inv:${b}`))})(),Al?e.jsxs("div",{className:"muted team_note",children:["Members list unavailable (",Al.slice(0,100),") — an empty list below means the FETCH failed, not an empty channel. Reopen the drawer to retry."]}):null,qn===null?e.jsx("span",{className:"muted team_note",children:"Loading members…"}):qn.map(k=>{const b=String(k.agent_id||"");return b?e.jsxs("div",{className:"team_member_row",children:[e.jsx("span",{className:"team_avatar",style:Ia(b),"aria-hidden":"true",children:(b[0]||"?").toUpperCase()}),e.jsx("span",{className:"team_member_id",title:String(k.about||""),children:b}),b!==kt&&!Kt?e.jsxs("span",{className:"team_member_actions",children:[e.jsx("button",{className:"team_row_expand",disabled:!!Mt,title:"Kick: 1-hour block from THIS channel (hub authorizes — owner/operator only)",onClick:()=>void Gr(b,"kick"),children:Mt===`channel:kick:${b}`?"kicking…":"kick"}),e.jsx("button",{className:`team_row_expand ${Pt===`channel:ban:${b}`?"team_danger":""}`,disabled:!!Mt,title:"Ban: INDEFINITE block from this channel (two clicks — the first arms, the second confirms)",onClick:()=>{Pt===`channel:ban:${b}`?(nn(""),Gr(b,"ban")):nn(`channel:ban:${b}`)},children:Mt===`channel:ban:${b}`?"banning…":Pt===`channel:ban:${b}`?"confirm ban":"ban"}),e.jsx("button",{className:`team_row_expand ${Pt===`hub:ban:${b}`?"team_danger":""}`,disabled:!!Mt,title:"Hub ban: INDEFINITE lockout from the ENTIRE hub — every channel, re-registration refused, live connection severed (operator-only). Two clicks to confirm.",onClick:()=>{Pt===`hub:ban:${b}`?(nn(""),Gr(b,"ban","hub")):nn(`hub:ban:${b}`)},children:Mt===`hub:ban:${b}`?"hub-banning…":Pt===`hub:ban:${b}`?"confirm hub ban":"hub ban"}),e.jsx("button",{className:`team_row_expand ${Pt===`retire:${b}`?"team_danger":""}`,disabled:!!Mt,title:"Retire: decommission this agent WITHOUT blame — removed from all channels/rosters, the id is reserved (never reused), never shown as blocked (operator-only). Two clicks to confirm.",onClick:()=>{Pt===`retire:${b}`?(nn(""),Kr(b)):nn(`retire:${b}`)},children:Mt===`retire:${b}`?"retiring…":Pt===`retire:${b}`?"confirm retire":"retire"})]}):b===kt?e.jsx("span",{className:"chip mono ok",style:{marginLeft:"auto"},children:"you"}):null]},b):null})]}),!Kt&&qs&&qs.length?e.jsxs("div",{className:"team_members",children:[e.jsxs("div",{className:"muted team_note",style:{marginBottom:4},children:["Blocked (",qs.length,")"]}),qs.map(k=>{const b=String(k.agent_id||k.agent||"");if(!b)return null;const E=String(k.scope||""),ne=E==="hub",q=ne?"hub":"channel",ve=k.expires_at?` · until ${new Date(Number(k.expires_at)*1e3).toLocaleString()}`:" · indefinite",Me=ne?"hub-wide":`#${E}`;return e.jsxs("div",{className:"team_member_row",children:[e.jsx("span",{className:"team_avatar",style:Ia(b),"aria-hidden":"true",children:(b[0]||"?").toUpperCase()}),e.jsxs("span",{className:"team_member_id",title:String(k.reason||""),children:[b,e.jsxs("span",{className:"muted team_note",children:[Me,ve]})]}),e.jsx("span",{className:"team_member_actions",children:e.jsx("button",{className:"team_row_expand",disabled:!!Mt,title:ne?"Lift this HUB-WIDE block (the agent can re-register and rejoin)":"Lift this channel block (the agent can rejoin/post again)",onClick:()=>void Gr(b,"unblock",q),children:Mt===`${q}:unblock:${b}`?"unblocking…":"unblock"})})]},`blocked:${E}:${b}`)})]}):null,!Kt&&Lr&&Lr.length?e.jsxs("div",{className:"team_members",children:[e.jsxs("div",{className:"muted team_note",style:{marginBottom:4},children:["Retired agents (",Lr.length,")"]}),Lr.map(k=>{const b=String(k.id||"");if(!b)return null;const E=k.retired_at?` · ${new Date(Number(k.retired_at)*1e3).toLocaleDateString()}`:"";return e.jsxs("div",{className:"team_member_row",children:[e.jsx("span",{className:"team_avatar",style:Ia(b),"aria-hidden":"true",children:(b[0]||"?").toUpperCase()}),e.jsxs("span",{className:"team_member_id",title:String(k.reason||""),children:[b,e.jsxs("span",{className:"muted team_note",children:["decommissioned",E]})]}),e.jsxs("span",{className:"team_member_actions",children:[e.jsx("button",{className:`team_row_expand ${Pt===`unretire:${b}`?"team_danger":""}`,disabled:!!Mt,title:"Un-retire: restore this agent's access (it rejoins channels explicitly). Two clicks to confirm.",onClick:()=>{Pt===`unretire:${b}`?(nn(""),rc(b)):nn(`unretire:${b}`)},children:Mt===`unretire:${b}`?"un-retiring…":Pt===`unretire:${b}`?"confirm un-retire":"un-retire"}),e.jsx("button",{className:`team_row_expand ${Pt===`delete:${b}`?"team_danger":""}`,disabled:!!Mt,title:"Delete from the hub: irreversible cleanup — removes this agent from every roster and board (its votes/ratings purged), id stays reserved. History keeps its old messages. Two clicks to confirm.",onClick:()=>{Pt===`delete:${b}`?(nn(""),Wl(b)):nn(`delete:${b}`)},children:Mt===`delete:${b}`?"deleting…":Pt===`delete:${b}`?"confirm delete":"delete"})]})]},`retired:${b}`)})]}):null,e.jsxs("div",{className:"team_delegation",children:[e.jsxs("div",{className:"muted team_note team_delegation_head",children:["Hub delegation ",e.jsx("span",{title:"Hub-wide, not per-channel: a delegate holds named powers in the operator's name until the grant expires or is resigned. Every seat can verify who holds what (the list is public).",children:"ⓘ"})]}),At===null?e.jsx("span",{className:"muted team_note",children:Ha||"Loading delegations…"}):e.jsxs(e.Fragment,{children:[At.length===0?e.jsx("span",{className:"muted team_note",children:"No active delegate."}):null,At.map(k=>{const b=String(k.agent_id||""),E=Array.isArray(k.powers)?k.powers.map(String):[],ne=Number(k.expires_at||k.expires||0);return e.jsxs("div",{className:"team_delegation_row",children:[e.jsx("span",{className:"team_avatar",style:Ia(b),"aria-hidden":"true",children:(b[0]||"?").toUpperCase()}),e.jsx("span",{className:"team_member_id",children:b}),e.jsxs("span",{className:"team_delegation_powers mono",title:String(k.note||""),children:[E.join(" + ")||"(no powers?)",ne?` · until ${new Date(ne*1e3).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}`:""]}),e.jsx("button",{className:`team_row_expand ${Pt===`resign:${b}`?"team_danger":""}`,disabled:rs,title:"Resign this delegate: the grant is revoked hub-wide, on the record (two clicks)",onClick:()=>{Pt===`resign:${b}`?(nn(""),ec(b)):nn(`resign:${b}`)},children:rs?"resigning…":Pt===`resign:${b}`?"confirm resign":"resign"})]},b)}),e.jsxs("div",{className:"team_delegation_assign",children:[e.jsxs("select",{className:"team_compose_control team_invite_select",value:pa,onChange:k=>Va(k.target.value),title:"Assign a delegate: any registered agent except operators and current delegates",children:[e.jsx("option",{value:"",children:"assign a delegate…"}),(qn??Tt.members??[]).map(k=>String(typeof k=="string"?k:(k==null?void 0:k.agent_id)||(k==null?void 0:k.id)||"")).filter(k=>k&&k!==kt&&!At.some(b=>String(b.agent_id)===k)).map(k=>e.jsx("option",{value:k,children:k},k))]}),pa?e.jsxs("div",{className:"team_delegation_powers_pick",children:[dy.map(k=>e.jsxs("label",{className:"team_delegation_power",title:k.help,children:[e.jsx("input",{type:"checkbox",checked:dn.includes(k.id),onChange:b=>Ll(E=>b.target.checked?[...E,k.id]:E.filter(ne=>ne!==k.id))}),k.id]},k.id)),e.jsx("button",{className:"btn",disabled:rs||!dn.length,title:dn.length?`Grant ${pa} the powers: ${dn.join(", ")} (7-day TTL, renewable; on the record)`:"Pick at least one power",onClick:()=>void Zo(),children:rs?"Assigning…":"Assign"})]}):null]}),Ha?e.jsx("div",{className:"page_error mono",children:Ha}):null]})]}),Kt?null:e.jsx("div",{className:"team_chan_admin",children:fr?String(Tt.state||"open")==="open"?e.jsx("button",{className:"btn",disabled:Ht,title:"Close this channel — member posts refuse until reopened (owner-only; the hub authorizes)",onClick:()=>void Qr("closed"),children:Ht?"Closing…":"Close channel"}):e.jsx("button",{className:"btn",disabled:Ht,title:"Reopen this channel for member posts",onClick:()=>void Qr("open"),children:Ht?"Reopening…":"Reopen channel"}):e.jsxs("span",{className:"muted team_note",children:["Close/reopen is owner-only on the hub (this channel's owner: ",Ls||"unknown",")."]})}),zr?e.jsx("div",{className:"page_error mono",children:zr}):null]}):e.jsx("span",{className:"muted team_note",children:"Open a channel to see its members."})}function so(u){var k;const v=((k=u.data)==null?void 0:k.attachments)||u.attachments||[];return v.length?e.jsx("div",{className:"team_attachments",children:v.map((b,E)=>{const ne=`${b.id}:${E}`,q=l.attachment_url(u.channel,b.id);return oy.has(String(b.content_type||"").toLowerCase())?e.jsxs("button",{className:"team_attach_img_link",title:`${b.filename} · ${On(b.size)} — click to preview`,onClick:()=>void Es(u.channel,b),children:[e.jsx("img",{className:"team_attach_img",src:q,alt:b.filename,loading:"lazy",onError:Me=>{var Rt;const qe=Me.currentTarget;qe.style.display="none";const Be=(Rt=qe.parentElement)==null?void 0:Rt.querySelector(".team_attach_fallback");Be&&(Be.style.display="inline-flex")}}),e.jsxs("span",{className:"team_attach_chip team_attach_fallback",style:{display:"none"},children:[e.jsx(st,{name:"paperclip",size:11}),e.jsx("span",{className:"team_attach_name",children:b.filename}),e.jsx("span",{className:"muted",children:On(b.size)})]})]},ne):e.jsxs("button",{className:"team_attach_chip team_attach_dl",title:`${b.content_type} · ${On(b.size)} — click to preview`,onClick:()=>void Es(u.channel,b),children:[e.jsx(st,{name:"paperclip",size:11}),e.jsx("span",{className:"team_attach_name",children:b.filename}),e.jsx("span",{className:"muted",children:On(b.size)})]},ne)})}):null}function Na(u,v){var ve;const k=[],b=String(u.status||"").toLowerCase();(b==="open"||b==="blocked")&&(u.has_resolved_reply===!0||(u.id?Zl.has(u.id):!1))?k.push(e.jsx(In,{tone:"success",size:"sm",title:"This ask already has a reply from another seat.",children:"answered"},"st")):b==="open"||b==="blocked"?k.push(e.jsx(In,{tone:b==="blocked"?"error":"warning",size:"sm",children:b},"st")):b==="resolved"&&v&&k.push(e.jsx(In,{tone:"success",size:"sm",children:"resolved"},"st")),u.critical&&k.push(e.jsx(In,{tone:"error",size:"sm",title:"Critical: unpins only on explicit read — click the row to record the read",children:"critical"},"crit"));const ne=((ve=u.data)==null?void 0:ve.answers)||[];b==="reply"&&ne.length&&k.push(e.jsxs(In,{tone:"success",size:"sm",title:`This reply discharges ask(s) ${ne.join(", ")} of its parent.`,children:["✓ answers ",ne.join(",")]},"dis"));const q=u.to||[];for(const Me of q.slice(0,2))k.push(e.jsxs(In,{tone:"muted",size:"sm",children:["@",Me]},`to:${Me}`));return q.length>2&&k.push(e.jsxs(In,{tone:"muted",size:"sm",title:q.map(Me=>`@${Me}`).join(" "),children:["+",q.length-2]},"to+")),k}function Tn(u,v){return e.jsx(vh,{resetKey:`${u.retracted?1:0}:${(u.body||"").length}:${(u.title||"").length}`,fallback:e.jsx("div",{className:"team_row team_row_broken",id:`hubmsg-${u.id}`,children:e.jsxs("div",{className:"team_row_main",children:[e.jsxs("div",{className:"team_row_head",children:[e.jsx("span",{className:"team_row_sender",style:If(u.sender),children:u.sender}),e.jsxs("span",{className:"team_row_meta mono",children:["#",u.seq," · ",xl(u.created_at)]}),e.jsx("span",{className:"chip mono warn",title:"This message failed to render; showing its raw text so nothing is hidden.",children:"render failed"})]}),e.jsx("pre",{className:"team_row_raw",children:(u.title?u.title+`
120
- `:"")+String(u.body||"(no text)")})]})}),children:mr(u,v)},u.id)}function mr(u,v){var gt,at,xn,vt;const k=!!G[u.id],b=String(u.body||""),E=v.is_root?Ho:Lf,ne=b.length>E,q=ne&&!k,ve=((gt=u.data)==null?void 0:gt.asks)||[],Me=!!((at=ds.unread_seqs)!=null&&at.has(u.seq)),qe=Fe!=="all"&&Cv(u,Fe,ds),Be=String(u.title||"").trim(),Rt=((xn=b.trim().split(`
121
- `)[0])==null?void 0:xn.trim())||"",Ct=Be&&(Be===b.trim()||Be===Rt),An=(Xe==null?void 0:Xe.id)===u.id;return e.jsxs("div",{className:`team_row ${u.sender===kt?"own":""} ${qe?"hit":""} ${An?"replying":""} ${Me?"unread":""} ${u.retracted?"retracted":""}`,id:`hubmsg-${u.id}`,onClick:()=>ql(u),title:ne?void 0:u.critical?"Click to record the read (critical unpins on it)":void 0,children:[e.jsx("span",{className:"team_avatar",style:Ia(u.sender),"aria-hidden":"true",children:(u.sender[0]||"?").toUpperCase()}),e.jsxs("div",{className:"team_row_main",children:[e.jsxs("div",{className:"team_row_head",children:[(vt=te[u.channel])!=null&&vt.has(u.seq)?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"team_chip_debt",title:"Pinned by the hub until answered: this is an open ask or a directive addressed to you — reading is not answering; reply, Decline, or Resolve the thread to clear it",children:"needs reply"}),e.jsx("button",{className:`team_chip_decline ${$s===u.id?"armed":""}`,title:$s===u.id?"Click again to decline on the record (posts a closing reply)":"Decline: close this ask without answering — posts an on-the-record reply so it stops showing everywhere",onClick:Ue=>{Ue.stopPropagation(),sc(u)},children:$s===u.id?"sure? declines on the record":"decline"})]}):Me?e.jsx("span",{className:"team_chip_new",title:"Unread — your seat has not read past this message yet; clicking the row records the read",children:"new"}):u.read===!1&&v.is_root?e.jsx("span",{className:"team_chip_seen",title:"Swept read by the cursor but never opened — you caught the tail of a burst and this one was marked read without being seen. Click to actually read it.",children:"missed?"}):null,e.jsx("span",{className:"team_row_sender",style:If(u.sender),children:u.sender}),Na(u,v.is_root),(()=>{const Ue=Hr(u);return!Ue||!Ue.up&&!Ue.down?null:e.jsxs("span",{className:`team_reaction_tally mono ${Ue.mine>0?"pos":Ue.mine<0?"neg":""}`,title:"±1 ratings feed the sender's reputation (one system). Green/red tint = YOUR standing vote on this message; counts refresh with the poll.",children:[Ue.up?`▲${Ue.up}`:"",Ue.up&&Ue.down?" ":"",Ue.down?`▼${Ue.down}`:""]})})(),e.jsxs("span",{className:"team_row_meta mono",title:wl(u.created_at),children:["#",u.seq," · ",xl(u.created_at)]})]}),Be&&!Ct?e.jsx("div",{className:"team_row_title",children:Be}):null,e.jsx("div",{className:`team_row_body ${q?v.is_root?"clamp_root":"clamp_reply":""}`,children:e.jsx(Zv,{className:"md_doc",text:jl(Uv(Dv(b),{hub_base:B}))})}),so(u),(()=>{var bt;const Ue=Iv(`${String(u.title||"")}
122
- ${b}`),St=((bt=u.data)==null?void 0:bt.attachments)||u.attachments||[],rn=Ue.map(ft=>({mention:ft,res:Ov(ft,ac,St)})).filter(ft=>ft.res!==null).filter(ft=>{var Lt;return!(ft.res.kind==="attachment"&&String(((Lt=St[ft.res.attachment_index])==null?void 0:Lt.filename)||"")===ft.mention)}),Zt=a.on_open_board?mg(`${String(u.title||"")}
123
- ${b}`):[];return!rn.length&&!Zt.length?null:e.jsxs("div",{className:"team_fs_chips",children:[rn.map(({mention:ft,res:Lt})=>e.jsxs("button",{className:"team_attach_chip team_fs_chip",title:Lt.kind==="fs"?Lt.rewritten?`Opens ${Lt.path} (the mention's path moved — matched by name in #${L}'s files)`:`Open ${Lt.path} from #${L}'s virtual filesystem`:"Opens the file attached to this message (the path in the text belongs to the sender's workspace)",onClick:Rn=>{Rn.stopPropagation(),Lt.kind==="fs"?rr(Lt.path):Es(u.channel,St[Lt.attachment_index])},children:[e.jsx(Pf,{}),e.jsx("span",{className:"team_attach_name",children:ft}),Lt.kind==="attachment"?e.jsx("span",{className:"team_fs_chip_note",children:"attached"}):Lt.rewritten?e.jsx("span",{className:"team_fs_chip_note",children:"moved"}):null]},ft)),Zt.map(ft=>e.jsxs("button",{className:"team_attach_chip team_fs_chip team_work_chip",title:`Work item ${ft} — open the Board filtered to it`,onClick:Lt=>{var Rn;Lt.stopPropagation(),(Rn=a.on_open_board)==null||Rn.call(a,ft)},children:[e.jsx("span",{className:"team_work_glyph","aria-hidden":!0,children:"⛭"}),e.jsx("span",{className:"team_attach_name mono",children:ft})]},`w:${ft}`))]})})(),ve.length?e.jsx("div",{className:"team_row_asks",children:ve.map(Ue=>e.jsxs("span",{className:"team_ask",title:Ue.text,children:["ask ",Ue.id,": ",Ue.text.length>90?Ue.text.slice(0,90)+"…":Ue.text]},Ue.id))}):null,ne?e.jsx("button",{className:"team_row_expand",onClick:Ue=>{Ue.stopPropagation(),Fl(u)},children:k?"collapse":"show more"}):null]}),hn?e.jsxs("div",{className:"team_row_rail",children:[u.id&&u.sender!==kt&&u.sender!=="hub"&&!u.retracted?(()=>{const Ue=Hr(u);return Ue?e.jsxs("span",{className:"team_vote_thumbs",children:[e.jsxs("button",{className:`btn btn_icon team_thumb ${Ue.mine>0?"up_on":""}`,title:Ue.mine>0?"Withdraw your +1 on this message":"+1 this message",disabled:!!Mi,onClick:St=>{St.stopPropagation(),zi(u.id,1)},children:[e.jsx(st,{name:Ue.mine>0?"thumbsUpFilled":"thumbsUp",size:13}),Ue.up?e.jsx("span",{className:"team_thumb_count",children:Ue.up}):null]}),e.jsxs("button",{className:`btn btn_icon team_thumb ${Ue.mine<0?"down_on":""}`,title:Ue.mine<0?"Withdraw your −1 on this message":"−1 this message",disabled:!!Mi,onClick:St=>{St.stopPropagation(),zi(u.id,-1)},children:[e.jsx(st,{name:Ue.mine<0?"thumbsDownFilled":"thumbsDown",size:13}),Ue.down?e.jsx("span",{className:"team_thumb_count",children:Ue.down}):null]})]}):null})():null,T.tts_supported&&u.id?(()=>{const Ue=T.tts_playback.key===u.id&&T.tts_playback.status==="playing",St=T.tts_playback.key===u.id&&T.tts_playback.status==="loading";return e.jsx("button",{className:`btn btn_icon ${Ue||St?"team_speak_on":""}`,title:Ue?"Pause":St?"Synthesizing…":_.enabled?"Read aloud (your voice override)":"Read aloud (gateway voice)","aria-label":Ue?"Pause reading":"Read this message aloud",onClick:rn=>{rn.stopPropagation();const Zt=uv(u.body||u.title||"");Zt?T.toggle_tts(u.id,Zt):O("Nothing readable to speak in this message (code/markup only).")},children:e.jsx(st,{name:Ue?"pause":St?"refresh":"speaker",size:13})})})():null,e.jsx("button",{className:"btn btn_icon",title:ve.length?"Reply and discharge this message's asks":"Reply in this trail (status=reply, linked to this message)",onClick:Ue=>{Ue.stopPropagation(),oc(u)},children:"↩ Reply"}),u.sender===kt&&!u.retracted?e.jsx("button",{className:`btn btn_icon ${ir===u.id?"team_danger":""}`,title:ir===u.id?"Click again to retract: the words are redacted for every reader and the message stops demanding anything":"Retract this message (agents and entities will never read the words; two clicks)",onClick:Ue=>{Ue.stopPropagation(),ir===u.id?Ql(u):Bi(u.id)},children:ir===u.id?"⌫ confirm retract":"⌫ Retract"}):null,v.is_root&&(String(u.status||"").toLowerCase()==="open"||String(u.status||"").toLowerCase()==="blocked")?e.jsx("button",{className:`btn btn_icon ${Ts===u.id?"team_danger":""}`,title:Ts===u.id?"Click again to close this topic (posts a resolved reply)":"Mark this topic resolved — closes the thread on the hub (two clicks)",onClick:Ue=>{Ue.stopPropagation(),Ts===u.id?Ui(u):qi(u.id)},children:Ts===u.id?"✓ confirm resolve":"✓ Resolve"}):null]}):null]},u.id)}function hs(u){const v=u.replies.length,k=!!ot[u.root.id],b=!!ye[u.root.id],E=k?[]:b||Fe!=="all"||v<=Mf+1?u.replies:u.replies.slice(v-Mf),ne=k?v:v-E.length,q=Ss[u.root.id];return e.jsxs("div",{className:`team_thread_group ${v?"has_replies":""}`,children:[u.orphan?e.jsx("div",{className:"team_orphan mono",title:"The parent message is older than the fetched window — the trail starts mid-flight.",children:"↩ reply to an earlier message (outside the window)"}):null,Tn(u.root,{is_root:!0}),ne>0||v>0||String(u.root.body||"").length>Ho?e.jsxs("div",{className:"team_trail_bar",children:[v>0?e.jsx("button",{className:"team_replies_more",onClick:()=>xt(ve=>({...ve,[u.root.id]:!ve[u.root.id]})),children:k?`show ${v} repl${v===1?"y":"ies"}`:"fold thread"}):null,!k&&ne>0?e.jsxs("button",{className:"team_replies_more",onClick:()=>Oe(ve=>({...ve,[u.root.id]:!0})),children:["↓ ",ne," earlier repl",ne===1?"y":"ies"]}):null,!k&&f&&(v>0||String(u.root.body||"").length>Ho)?e.jsx("button",{className:"team_replies_more team_summarize",disabled:!!(q!=null&&q.busy),title:"LLM summary of this trail (root + replies) — read-only, never posts",onClick:()=>void lc(u),children:q!=null&&q.busy?"✦ summarizing…":`✦ Summarize (${v+1})`}):null]}):null,!k&&v>0?e.jsx("div",{className:"team_replies",children:E.map(ve=>Tn(ve,{is_root:!1}))}):null,!k&&(q!=null&&q.text)?e.jsxs("div",{className:"team_summary",children:[e.jsxs("div",{className:"team_summary_head",children:[e.jsxs("span",{children:["AI summary — ",q.count," message",q.count===1?"":"s"]}),e.jsx("button",{className:"team_row_expand",onClick:()=>is(ve=>({...ve,[u.root.id]:{busy:!1,text:"",error:"",count:0}})),children:"dismiss"})]}),e.jsx(as,{className:"md_doc",text:jl(q.text)})]}):null,q!=null&&q.error?e.jsx("div",{className:"page_error mono",children:q.error}):null]},u.root.id)}const Xi=be.length?be[be.length-1].seq:0,dc=Math.max(Xi,((aa=ae.find(u=>u.name===L))==null?void 0:aa.last_seq)||0),ao=((hr=ae.find(u=>u.name===L))==null?void 0:hr.member_count)||0,Ls=((si=(qn||[]).find(u=>String(u.role||"")==="owner"))==null?void 0:si.agent_id)||"",fr=!!kt&&Ls===kt;return e.jsxs("div",{className:"page page_pad team_page",onDragOver:u=>{var v;Array.from(((v=u.dataTransfer)==null?void 0:v.types)||[]).includes("Files")&&(u.preventDefault(),hn&&!wt&&Le(!0))},onDragLeave:u=>{u.currentTarget.contains(u.relatedTarget)||Le(!1)},onDrop:u=>{var v,k;(k=(v=u.dataTransfer)==null?void 0:v.files)!=null&&k.length&&(u.preventDefault(),Le(!1),!(!hn||wt)&&Jl(u.dataTransfer.files))},children:[Dt?e.jsx("div",{className:"team_drop_overlay",children:e.jsxs("div",{className:"team_drop_overlay_card",children:["Drop to attach to ",Kt?Zr:`#${L}`]})}):null,C!=null&&C.protocol&&C.protocol!==Go||C!=null&&C.paused||xe||Gs||xi||F&&!F.seat_key_present?e.jsxs("div",{className:"team_statusstrip",children:[F&&!F.seat_key_present?e.jsx("span",{className:"chip mono warn",title:"No hub key for the operator seat — read-only until the proxy can read it (ABSTRACTCONTINUUM_HUB_KEY or ~/.agora/keys.json).",children:"read-only (no seat key)"}):null,C!=null&&C.protocol&&C.protocol!==Go?e.jsxs("span",{className:"chip mono warn",title:`The hub advertises ${C.protocol}; this page was written against ${Go}. Meaning may have shifted — rendering continues (protocol.md: warn, never refuse).`,children:["protocol ",C.protocol," ≠ ",Go]}):null,C!=null&&C.paused?e.jsx("span",{className:"chip mono warn",title:"The operator paused the hub — posting resumes when it does.",children:"hub paused"}):null,xe?e.jsx("span",{className:"page_error mono",children:xe}):null,Gs?e.jsxs("span",{className:"page_error mono",children:["±1 failed: ",Gs]}):null,xi?e.jsx("span",{className:"chip mono ok",children:xi}):null]}):null,e.jsxs("div",{className:`team_layout ${jt?"with_drawer":""} ${jt==="leaderboard"?"drawer_wide":""}`,children:[e.jsxs("div",{className:"pane team_channels_pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Channels"}),e.jsx("span",{className:"pane_count",children:ae.filter(u=>!u.name.startsWith("dm:")).length}),e.jsx("span",{className:"pane_header_actions",children:e.jsx("button",{className:"btn btn_icon",title:"Create a channel (you become its owner)","aria-label":"New channel",onClick:()=>Us(u=>({...u,open:!u.open})),children:e.jsx(st,{name:"plus",size:14})})})]}),ks.open?e.jsxs("div",{className:"team_new_channel",children:[e.jsx("input",{value:ks.name,onChange:u=>Us(v=>({...v,name:u.target.value})),placeholder:"channel-name (simple slug)",onKeyDown:u=>{u.key==="Enter"&&Gl()}}),e.jsxs("label",{title:"Private channels need invites; public ones are joinable by any registered agent.",children:[e.jsx("input",{type:"checkbox",checked:ks.is_private,onChange:u=>Us(v=>({...v,is_private:u.target.checked}))}),"private"]}),e.jsx("button",{className:"btn primary",disabled:!ks.name.trim()||Ht,onClick:()=>void Gl(),children:Ht?"Creating…":"Create"})]}):null,e.jsxs("div",{className:"pane_body pane_body_list",children:[ae.length?null:e.jsx("div",{className:"muted team_note team_rail_degraded",children:xe?"Channels unavailable — the hub is unreachable. Retrying automatically; check that the hub is running if this persists.":"Loading channels…"}),ae.filter(u=>!u.name.startsWith("dm:")).map(u=>{const v=ge[u.name],k=Vl===u.name;return e.jsxs("div",{className:`team_channel team_dm_row ${L===u.name?"selected":""}`,role:"button",tabIndex:0,onClick:()=>ke(u.name),onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&ke(u.name)},children:[e.jsxs("span",{className:"team_channel_line",children:[e.jsxs("span",{className:`team_channel_name ${v!=null&&v.unread?"has_unread":""}`,children:["#",u.name]}),e.jsxs("span",{className:"team_channel_badges",children:[v!=null&&v.unread?e.jsx("span",{className:"team_badge unread",role:"button",tabIndex:0,title:`${v.unread>=100?"100 or more":v.unread} unread message(s) for your seat — the Unread tab shows the same number. Click to open with the Unread filter.`,onClick:b=>{b.stopPropagation(),u.name!==L&&(he.current="unread"),ke(u.name),Ye("unread")},onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&(b.stopPropagation(),u.name!==L&&(he.current="unread"),ke(u.name),Ye("unread"))},children:v.unread>=100?"99+":v.unread}):null,v!=null&&v.open_questions?e.jsx("span",{className:"team_badge asks",role:"button",tabIndex:0,title:`${v.open_questions} open question(s) in this room still awaiting answers (channel digest) — click to open with the Asks filter`,onClick:b=>{b.stopPropagation(),u.name!==L&&(he.current="asks"),ke(u.name),Ye("asks")},onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&(b.stopPropagation(),u.name!==L&&(he.current="asks"),ke(u.name),Ye("asks"))},children:v.open_questions}):null,e.jsx("button",{className:`team_dm_trash ${k?"arming":""}`,title:k?"Click again to archive this channel (evicts members; history preserved)":"Archive this channel — evicts everyone and drops it off rails; messages are preserved (owner/operator)","aria-label":k?"Confirm archive channel":"Archive channel",disabled:Ht,onClick:b=>{b.stopPropagation(),k?ic(u.name):Fi(u.name)},children:e.jsx(st,{name:k?"x":"trash",size:12})})]})]}),e.jsx("span",{className:"team_channel_meta mono",children:k?"archive? click ✕":`${u.member_count} seats · ${xl(u.last_at)}`})]},u.name)}),(()=>{const u=ae.filter(v=>v.name.startsWith("dm:"));return u.length?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"team_rail_section",children:"Direct messages"}),u.map(v=>{const k=ge[v.name],b=v.name.replace(/^dm:/,"").split("--").filter(ne=>ne!==kt).join("")||v.name,E=Oi===v.name;return e.jsxs("div",{className:`team_channel team_dm_row ${L===v.name?"selected":""}`,role:"button",tabIndex:0,onClick:()=>ke(v.name),onKeyDown:ne=>{(ne.key==="Enter"||ne.key===" ")&&ke(v.name)},children:[e.jsxs("span",{className:"team_channel_line",children:[e.jsxs("span",{className:`team_channel_name ${k!=null&&k.unread?"has_unread":""}`,children:["@",b]}),e.jsxs("span",{className:"team_channel_badges",children:[k!=null&&k.unread?e.jsx("span",{className:"team_badge unread",title:`${k.unread>=100?"100 or more":k.unread} unread message(s)`,children:k.unread>=100?"99+":k.unread}):null,e.jsx("button",{className:`team_dm_trash ${E?"arming":""}`,title:E?"Click again to remove this DM from your list":"Remove this DM from your list (history is kept; it reopens if they message you)","aria-label":E?"Confirm remove direct message":"Remove direct message",disabled:Ht,onClick:ne=>{ne.stopPropagation(),E?Hl(v.name):Di(v.name)},children:e.jsx(st,{name:E?"x":"trash",size:12})})]})]}),e.jsx("span",{className:"team_channel_meta mono",children:E?"remove? click ✕":xl(v.last_at)})]},v.name)})]}):null})()]})]}),e.jsxs("div",{className:"pane team_thread_pane",children:[e.jsxs("div",{className:"pane_header team_thread_header",children:[e.jsx("span",{className:"pane_title team_pane_title",children:L?Kt?`@${Zr} — direct`:`#${L}`:"Select a channel"}),L&&ao?e.jsxs("button",{className:"chip team_members_chip",onClick:()=>{jt!=="members"&&xa("members")},title:"View the channel members (opens the Members drawer, roster + moderation)",children:[ao," members"]}):null,me?e.jsx("span",{className:"muted team_note",children:"loading…"}):null,e.jsxs("span",{className:"pane_header_actions",children:[T.tts_playback.status!=="idle"?e.jsx("button",{className:"btn team_speak_stop",title:"Stop reading aloud",onClick:()=>T.stop_tts(),children:"◼ Stop reading"}):null,(()=>{const u=Fe==="all"?dc:uc;return e.jsx("button",{className:"btn",onClick:()=>void Xl(u),disabled:!L||!be.length||!u||ha||me,title:Fe==="all"?"Moves your inbox cursor for this channel to the latest message in the window. The ONE explicit 'I have seen this' act (nothing acks on render).":"Moves your inbox cursor to the last message VISIBLE under this filter — messages newer than it stay unread. (The cursor is a single high-water mark: hidden rows BELOW it are cleared too.)",children:ha?"Marking…":`Mark read → #${u||"…"}`})})(),e.jsx("button",{className:"btn btn_icon",onClick:()=>{cs(),us(L)},title:"Refresh channels, badges, and the thread window (the page also polls every 5s)","aria-label":"Refresh",children:e.jsx(st,{name:"refresh",size:14})}),Wt&&Wt!=="running"&&typeof Wt=="object"&&"ok"in Wt?Wt.ok?e.jsxs(In,{tone:"success",size:"sm",title:`Hash chain recomputed client-side over ${Wt.hashed} hashed turns (${Wt.legacy} pre-ledger); served head matches.`,children:["transcript intact (",Wt.hashed,")"]}):e.jsxs(In,{tone:"error",size:"sm",title:Wt.broken_at!==null?`Recomputed chain diverges at seq ${Wt.broken_at} — a hashed turn was edited, inserted, or reordered.`:"Chain internally consistent but the served head does not match the last turn — the hub is presenting a different commitment.",children:["TAMPERED",Wt.broken_at!==null?` at #${Wt.broken_at}`:" (head mismatch)"]}):null,Wt&&typeof Wt=="object"&&"error"in Wt?e.jsx(In,{tone:"warning",size:"sm",title:Wt.error,children:"verify failed"}):null,e.jsx("button",{className:"btn btn_icon",onClick:()=>void nc(),disabled:!L||Wt==="running",title:"Fetch the channel's verbatim ledger and recompute the sha256 hash chain in this browser — independent of the hub's own verified flag.",children:Wt==="running"?"Verifying…":"Verify transcript"})]})]}),e.jsxs("div",{className:"team_filterbar",children:[e.jsx("div",{className:"seg seg_scroll",role:"group","aria-label":"Message filters",children:jf.map(u=>{const v=Fe===u.id,k=Yi[u.id];return e.jsxs("button",{className:`seg_btn ${v?"active":""}`,"aria-pressed":v,title:u.title,onClick:()=>Ye(u.id),children:[u.label,typeof k=="number"&&k>0?e.jsx("span",{className:"team_filter_count",children:k}):null]},u.id)})}),e.jsxs("form",{className:"team_search_bar",onSubmit:u=>{u.preventDefault();const v=cr.trim();if(!v&&!an){Sa("down"),sa("",na,"down");return}ti(v)},children:[e.jsx("input",{className:"team_search_input",type:"search",placeholder:"Search the hub…",value:cr,onChange:u=>ka(u.target.value),onKeyDown:u=>{u.key==="Escape"&&(pn&&dr(),ka(""))},title:"Search everything your seat can read (Enter). Served as a grouped report: decisions, open threads, work, people, files, messages. Enter on an empty box browses rated messages (most-downvoted first).","aria-label":"Search the hub"}),pn?e.jsx("button",{type:"button",className:"btn btn_icon team_search_close",onClick:dr,title:"Close search results (Esc)","aria-label":"Close search results",children:"✕"}):null]}),e.jsxs("div",{className:"seg",role:"group","aria-label":"Sort order",children:[e.jsx("button",{className:`seg_btn ${ea==="recency"?"active":""}`,"aria-pressed":ea==="recency",title:"Threads by last activity (default)",onClick:()=>lr("recency"),children:"Recency"}),e.jsx("button",{className:`seg_btn ${ea==="votes"?"active":""}`,"aria-pressed":ea==="votes",title:"The channel's most-voted messages — whole channel, ranked by net standing ±1 (hub-served order)",onClick:()=>{lr("votes"),Et()},children:"Top voted"})]}),e.jsxs("span",{className:"team_filterbar_meta",children:[e.jsx("span",{className:`team_live_dot ${$i?"on":""}`,title:$i?"Live: agents' posts push instantly over a websocket. Your own posts from OTHER windows arrive with the 5s poll (the hub skips echoing your seat's frames back).":"Polling every 5s — the live socket is down (it reconnects automatically).",children:$i?"● live":"◌ polling"})," · ",As.length!==sn.length?`${As.length} of ${sn.length} threads`:sn.length?`${sn.length} threads`:"",F!=null&&F.seat_key_present?e.jsxs("span",{title:"Posts are authored under this hub seat — your own identity, key held server-side.",children:[" · as ",F.seat]}):null]})]}),e.jsx("div",{className:"pane_body team_thread",ref:va,children:pn?(()=>{const u=pn;if(u.error)return e.jsx("div",{className:"muted team_note",children:u.error});if(u.busy||!u.report)return e.jsx("div",{className:"muted team_note",children:u.q?`Searching “${u.q}”…`:"Browsing rated messages…"});const v=u.report;if(Ki){const E=Ki;return e.jsxs("div",{className:"team_search_results",children:[e.jsxs("div",{className:"team_search_meta",children:[e.jsx("button",{className:"team_replies_more",onClick:()=>fs(null),children:"← All results"}),e.jsxs("span",{className:"muted",children:[E.label," matching “",u.q,"” — newest first",E.total?` · ${E.hits.length} of ${E.total}`:""]})]}),E.error?e.jsx("div",{className:"muted team_note",children:E.error}):null,E.hits.map(ne=>no(ne)),E.busy?e.jsx("div",{className:"muted team_note",children:"Loading…"}):null,!E.busy&&E.cursor?e.jsx("button",{className:"team_replies_more team_search_more",onClick:Ji,children:"Load more"}):null,!E.busy&&!E.hits.length&&!E.error?e.jsxs("div",{className:"muted team_note",children:["Nothing in ",E.label.toLowerCase()," matches “",u.q,"”."]}):null]})}const k=Wo.filter(E=>{var ne;return!((((ne=v[E.id])==null?void 0:ne.total)??0)>0)}),b=k.length<Wo.length;return e.jsxs("div",{className:"team_search_results",children:[v.relaxed&&(!v.mode_used||v.mode_used==="lexical")?e.jsx("div",{className:"team_search_relaxed",title:"The strict query (all terms) found nothing, so the hub re-ran it as ANY-term (OR). Matches below are looser than what you typed.",children:"No exact matches — showing loosened (any-term) matches instead."}):null,v.notice?e.jsx("div",{className:"team_search_notice",title:"Served by the hub while search is degraded — quote this text in anything you conclude from these results.",children:v.notice}):null,e.jsxs("div",{className:"team_search_meta",children:[e.jsxs("span",{className:"muted",children:[u.q?`“${u.q}”`:`rated messages${an?` (${an==="down"?"↓ downvoted":"↑ upvoted"}, net-vote order)`:""}`," · ",v.channels_searched??0," channel",(v.channels_searched??0)===1?"":"s"," searched",v.mode_used?e.jsxs("span",{className:"team_search_mode mono",title:"Which search engine answered: fused = word + meaning matches blended; lexical = words only; semantic = meaning only. Served verbatim by the hub.",children:[" ","· ",v.mode_used,typeof v.semantic_coverage=="number"?` (${Math.round(v.semantic_coverage*100)}% embedded)`:""]}):null]}),e.jsx("span",{className:"seg team_search_rated",role:"group","aria-label":"Rated filter",children:["up","down"].map(E=>e.jsx("button",{className:`seg_btn ${an===E?"active":""}`,"aria-pressed":an===E,title:E==="up"?"Only messages with net-positive standing ratings (toggle re-runs)":"Only messages with net-negative standing ratings — where displeasure lives (toggle re-runs)",onClick:()=>{const ne=an===E?"":E;Sa(ne),sa(u.q,na,ne)},children:E==="up"?"▲ rated":"▼ rated"},E))}),e.jsxs("label",{className:"team_search_scope",title:"Limit the search to the channel currently open in the rail (re-runs the query)",children:[e.jsx("input",{type:"checkbox",checked:na==="channel",onChange:E=>{const ne=E.target.checked?"channel":"all";Gi(ne),sa(u.q,ne,an)}}),"this channel only"]})]}),Wo.map(E=>{const ne=v[E.id],q=(ne==null?void 0:ne.shown)??0,ve=(ne==null?void 0:ne.total)??0,Me=(ne==null?void 0:ne.hits)??[];return!ne||!ve&&!Me.length?null:e.jsxs("div",{className:"team_search_section",children:[e.jsxs("div",{className:"team_search_section_head",children:[e.jsx("span",{className:"team_search_section_label",children:E.label}),e.jsx("span",{className:"muted mono",children:q<ve?`showing ${q} of ${ve}`:`${ve}`}),q<ve&&E.kind?e.jsx("button",{className:"team_replies_more",onClick:()=>Qi(E.label,E.kind),title:`All ${ve} ${E.label.toLowerCase()} matches, newest first (paged)`,children:"view all →"}):null]}),Me.map(qe=>no(qe))]},E.id)}),b?k.length?e.jsxs("div",{className:"muted team_search_empties",children:["nothing in ",k.map(E=>E.label.toLowerCase()).join(", ")]}):null:e.jsx("div",{className:"muted team_note",children:u.q?`Nothing matches “${u.q}” in the channels this seat can read.`:"No rated messages match this lens."})]})})():ea==="votes"?Hi?e.jsx("div",{className:"muted team_note",children:Hi}):or===null?e.jsx("div",{className:"muted team_note",children:"Loading the channel's top-voted messages…"}):or.length?or.map((u,v)=>e.jsxs("div",{className:"team_top_row",children:[e.jsxs("div",{className:"team_top_rank_line",children:[e.jsxs("span",{className:"team_top_rank mono",title:"Rank by net standing rating (hub-served order)",children:["#",v+1]}),e.jsx("button",{className:"team_replies_more",onClick:()=>Vi(u),title:"Switch back to recency and scroll to this message in its thread",children:"view in thread"})]}),Tn(u,{is_root:!0})]},u.id)):e.jsx("div",{className:"muted team_note",children:"No rated messages in this channel yet — cast the first ±1 from any message's thumbs."}):e.jsxs(e.Fragment,{children:[(()=>{const u=[];let v="";for(const k of As){const b=k.replies.length?k.replies[k.replies.length-1]:k.root,E=my(b.created_at);E&&E!==v&&(v=E,u.push(e.jsx("div",{className:"team_day_divider",children:e.jsx("span",{children:E})},`day:${E}:${k.root.id}`))),u.push(hs(k))}return u})(),!As.length&&L&&!me?e.jsx("div",{className:"muted team_note",children:sn.length?e.jsxs(e.Fragment,{children:["Nothing matches the ",e.jsx("strong",{children:((ra=jf.find(u=>u.id===Fe))==null?void 0:ra.label)||Fe})," filter in this channel — the messages exist under All."," ",e.jsx("button",{className:"team_replies_more",onClick:()=>Ye("all"),children:"Show all"})]}):"No messages in the window."}):null]})}),e.jsxs("div",{className:"team_composer",onKeyDown:u=>{u.key==="Escape"&&Xe&&Xs()},children:[Xe?e.jsxs("div",{className:"team_reply_banner",children:[e.jsxs("button",{className:"team_reply_target",title:"Jump to the message you are replying to",onClick:()=>{var u;(u=document.getElementById(`hubmsg-${Xe.id}`))==null||u.scrollIntoView({block:"center"})},children:["↩ #",Xe.seq," (",Xe.sender,") —"," ",(String(Xe.title||"").trim()||String(Xe.body||"").trim()).slice(0,80)||"(no text)"]}),(((ps=Xe.data)==null?void 0:ps.asks)||[]).length?e.jsx("span",{className:"team_reply_asks",children:(((Nt=Xe.data)==null?void 0:Nt.asks)||[]).map(u=>e.jsxs("label",{title:u.text,children:[e.jsx("input",{type:"checkbox",checked:!!Jt[u.id],onChange:v=>$t(k=>({...k,[u.id]:v.target.checked}))}),e.jsxs("span",{className:"team_reply_ask_text",children:["ask ",u.id,": ",u.text.length>70?u.text.slice(0,70)+"…":u.text]})]},u.id))}):null,e.jsx("button",{className:"team_row_expand",onClick:Xs,children:"cancel (Esc)"})]}):null,Yt==="void_reply"?e.jsxs("div",{className:"team_nudge",children:["This reply discharges NO asks — the parent stays formally open on the hub. Check an ask above, or press ",Xe?"Reply":"Post"," again to send as-is."]}):null,Yt==="untitled_open"?e.jsxs("div",{className:"team_nudge",children:["An ",e.jsx("code",{children:"open"})," post without a title — receivers triage by headline (hub etiquette). Add one, or press Ask again to send untitled."]}):null,ms?e.jsx("div",{className:"team_group_preview",title:"Creates a private room, DMs invites to the mentioned seats, posts the topic as the opening open message, and switches you in",children:ms.members.length?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"team_group_label",children:"group room"}),e.jsxs("span",{className:"mono team_group_name",children:["#",ms.name]}),e.jsxs("span",{className:"team_group_invites",children:["invites: ",ms.members.map(u=>`@${u}`).join(" ")]})]}):e.jsx("span",{className:"muted",children:ms.source==="kind"?"Add members below — write their names like @entity @assistant":"/group needs @mentions — e.g. /group fix the voice outage @gateway @core"})}):null,!Xe&&!Kt&&(Ze==="ask"||Ze==="group")?e.jsx("input",{className:"team_ask_title",value:Ae,onChange:u=>Ge(u.target.value),placeholder:Ze==="group"?"Group topic — names the room (e.g. fix the voice outage)":"Title — receivers triage asks by headline",disabled:!hn}):null,!Xe&&!Kt&&Ze==="group"?e.jsx("input",{className:"team_ask_title team_group_members",value:it,onChange:u=>ht(u.target.value),placeholder:"Members — write their names: @entity @assistant @gateway",disabled:!hn,list:"team_roster_options"}):null,!Xe&&!Kt&&Ze==="group"&&Bs.length?e.jsx("datalist",{id:"team_roster_options",children:Bs.map(u=>e.jsx("option",{value:`@${u}`},u))}):null,et.length?e.jsx("div",{className:"team_attach_pending",children:et.map(u=>e.jsxs("span",{className:"team_attach_chip",title:`${u.content_type} · ${On(u.size)} — click to preview`,children:[e.jsxs("button",{className:"team_attach_open",onClick:()=>void Es(L,u),"aria-label":`Preview ${u.filename}`,children:[e.jsx(st,{name:"paperclip",size:11}),e.jsx("span",{className:"team_attach_name",children:u.filename}),e.jsx("span",{className:"muted",children:On(u.size)})]}),e.jsx("button",{className:"team_attach_x","aria-label":`Remove ${u.filename}`,title:"Remove this attachment",onClick:()=>ct(v=>v.filter(k=>k.id!==u.id)),children:e.jsx(st,{name:"x",size:10})})]},u.id))}):null,e.jsxs("div",{className:"team_compose_row",children:[!Xe&&!Kt?e.jsxs("select",{className:"team_compose_control team_kind_select",value:Ze,onChange:u=>{const v=u.target.value,k=v==="ask"?"ask":v==="dm"?"dm":v==="group"?"group":"fyi";we(k),k!=="ask"&&k!=="group"&&Ge(""),k!=="group"&&ht("")},disabled:!hn,title:"fyi = informational · ask = expects replies (posts as status=open) · dm = private direct message · group = focused private room with invited members",children:[e.jsx("option",{value:"fyi",children:"fyi"}),e.jsx("option",{value:"ask",children:"ask"}),e.jsx("option",{value:"dm",children:"dm"}),e.jsx("option",{value:"group",children:"group"})]}):null,!Xe&&!Kt&&Ze==="dm"?Bs.length?e.jsxs("select",{className:"team_compose_control team_dm_peer",value:je,onChange:u=>Ke(u.target.value),disabled:!hn,title:"Recipient — every agent on the hub you share a channel with, connected or not",children:[e.jsx("option",{value:"",children:"to: member…"}),Bs.map(u=>e.jsx("option",{value:u,children:u},u))]}):e.jsx("input",{className:"team_compose_control team_dm_peer",value:je,onChange:u=>Ke(u.target.value),placeholder:"to: agent id",disabled:!hn,title:"Recipient agent id (roster unavailable — type it; #FALLBACK)"}):null,e.jsx("textarea",{ref:rt,className:"team_compose_text",rows:2,value:X,onChange:u=>$e(u.target.value),placeholder:hn?Xe?`Reply to #${Xe.seq} in #${L}…`:Kt?`Message ${Zr}…`:Ze==="dm"?`Direct message${je.trim()?` to ${je.trim()}`:""}…`:f?`Message #${L||"…"} as ${(F==null?void 0:F.seat)||"operator"} — or /assistant <question>`:`Message #${L||"…"} as ${(F==null?void 0:F.seat)||"operator"}`:C!=null&&C.paused?"The hub is paused by the operator — posting resumes when it does.":"Read-only: the proxy has no operator seat key.",disabled:!hn,onKeyDown:u=>{u.key!=="Enter"||u.shiftKey||u.nativeEvent.isComposing||u.keyCode===229||(u.preventDefault(),!Kn&&(X.trim()||et.length)&&Xr())}}),e.jsx("input",{ref:Ut,type:"file",multiple:!0,style:{display:"none"},onChange:u=>void Jl(u.target.files)}),e.jsx("button",{className:"btn team_attach_btn",disabled:!hn||wt||et.length>=vl,title:et.length>=vl?`Attachment limit (${vl}) reached`:"Attach a file or image (delivered to every recipient)","aria-label":"Attach a file",onClick:()=>{var u;return(u=Ut.current)==null?void 0:u.click()},children:e.jsx(st,{name:"paperclip",size:14})}),e.jsx("button",{className:"btn primary team_send",disabled:!hn||Kn||!X.trim()&&!et.length&&!(Ze==="group"&&!Xe&&!Kt&&Mu(it).length>0),onClick:()=>void Xr(),children:Kn?"Sending…":ms!=null&&ms.members.length||!Xe&&!Kt&&Ze==="group"?"Create room":Xe?"Reply":Kt||Ze==="dm"?"Send DM":Ze==="ask"?"Ask":"Send"})]})]})]}),jt==="assistant"?e.jsxs("div",{className:"pane team_drawer team_ai_pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Assistant"}),e.jsxs("span",{className:"pane_count",children:["#",L]}),e.jsx("span",{className:"pane_header_actions",children:e.jsx("button",{className:"btn btn_icon",onClick:()=>Xt(""),title:"Close",children:"✕"})})]}),e.jsxs("div",{className:"pane_body team_ai_thread",children:[Fr.length?null:e.jsxs("div",{className:"muted team_note",children:["Ask anything about #",L," — strategies used, deviations, who owes what, how a decision was reached. The model reads the current channel window (",be.length," messages) and cites seqs. It never posts to the room."]}),Fr.map((u,v)=>e.jsxs("div",{className:`team_ai_turn ${u.role}`,children:[e.jsx("div",{className:"team_ai_role mono",children:u.role==="user"?"you":"analyst"}),e.jsx(as,{className:"md_doc",text:jl(u.content)})]},v)),Qs?e.jsx("div",{className:"muted team_note",children:"thinking…"}):null,qr?e.jsx("div",{className:"page_error mono",children:qr}):null]}),e.jsx("div",{className:"team_composer",children:e.jsx(Xo,{value:Ks,onChange:Za,onSubmit:()=>{const u=Ks;Za(""),En(u)},placeholder:f?`Ask about #${L}…`:"AI advisor is not configured for this shell.",disabled:!f,busy:Qs,rows:2,sendLabel:"Ask",busyLabel:"Asking…"})})]}):null,jt==="members"?e.jsxs("div",{className:"pane team_drawer team_members_pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Members"}),e.jsxs("span",{className:"pane_count",children:["#",L]}),e.jsx("span",{className:"pane_header_actions",children:e.jsx("button",{className:"btn btn_icon",onClick:()=>Xt(""),title:"Close",children:"✕"})})]}),e.jsx("div",{className:"pane_body team_members_body",children:Rs()})]}):null,jt==="files"?e.jsxs("div",{className:"pane team_drawer team_files_pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Files"}),e.jsxs("span",{className:"pane_count",children:["#",L]}),e.jsx("span",{className:"pane_header_actions",children:e.jsx("button",{className:"btn btn_icon",onClick:()=>Xt(""),title:"Close",children:"✕"})})]}),e.jsxs("div",{className:"team_fs_crumbs",children:[e.jsxs("button",{className:`team_fs_crumb ${os===""?"active":""}`,onClick:()=>ga(""),title:"Channel root",children:["#",L||"…"]}),os?os.split("/").map((u,v,k)=>{const b=k.slice(0,v+1).join("/");return e.jsxs(Gt.Fragment,{children:[e.jsx("span",{className:"team_fs_crumb_sep",children:"/"}),e.jsx("button",{className:`team_fs_crumb ${v===k.length-1?"active":""}`,onClick:()=>ga(b),children:u})]},b)}):null]}),e.jsx("div",{className:"pane_body pane_body_list",children:_a===null&&!Zn?e.jsx("div",{className:"muted team_note",children:"Loading files…"}):Zn?e.jsx("div",{className:"page_error mono",children:Zn}):_a&&_a.length?(()=>{const{dirs:u,leaves:v}=Rv(_a,os);return!u.length&&!v.length?e.jsx("div",{className:"muted team_note",children:"Empty folder."}):e.jsxs(e.Fragment,{children:[u.map(k=>e.jsxs("button",{className:"team_file_row team_fs_dir",onClick:()=>ga(k.path),title:`${k.count} file(s) inside`,children:[e.jsx("span",{className:"team_fs_icon",children:e.jsx(cy,{})}),e.jsx("span",{className:"team_file_path",children:k.name}),e.jsx("span",{className:"team_file_meta mono",children:k.count})]},k.path)),v.map(k=>e.jsxs("button",{className:"team_file_row",onClick:()=>void ba(k),title:`${k.updated_by||"?"} · ${wl(k.updated_at)} · v${k.version} · ${On(k.size)}`,children:[e.jsx("span",{className:"team_fs_icon",children:e.jsx(Pf,{})}),e.jsxs("span",{className:"team_file_name_wrap",children:[e.jsx("span",{className:"team_file_path",children:k.path.slice(os?os.length+1:0)}),k.description?e.jsx("span",{className:"team_file_desc muted",children:k.description}):null]}),e.jsxs("span",{className:"team_file_meta mono",children:[On(k.size)," · ",xl(k.updated_at)]})]},k.path))]})})():e.jsx("div",{className:"muted team_note",children:"No files in this channel's virtual filesystem yet."})})]}):null,jt==="leaderboard"?e.jsxs("div",{className:"pane team_drawer team_lb_pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Leaderboard"}),e.jsx("span",{className:"pane_count",children:Un==="hub"?"hub-wide":`#${L}`}),e.jsxs("span",{className:"pane_header_actions",children:[e.jsxs("span",{className:"team_lb_scope",role:"tablist","aria-label":"Leaderboard scope",children:[e.jsx("button",{className:`team_lb_scope_btn ${Un==="channel"?"active":""}`,onClick:()=>{Qa("channel"),Li("channel")},disabled:!L,title:`This channel's board (#${L||"…"})`,children:"Channel"}),e.jsx("button",{className:`team_lb_scope_btn ${Un==="hub"?"active":""}`,onClick:()=>{Qa("hub"),Li("hub")},title:"Hub-wide: the sum of every channel's scores",children:"Hub"})]}),e.jsx("button",{className:"btn btn_icon",onClick:()=>Xt(""),title:"Close",children:"✕"})]})]}),e.jsx("div",{className:"pane_body pane_body_list team_lb_body",children:Bn===null&&!Ws?e.jsx("div",{className:"muted team_note",children:"Loading leaderboard…"}):Ws?e.jsx("div",{className:"muted team_note",children:Ws}):!Bn||Bn.leaderboard.length===0?e.jsx("div",{className:"muted team_note",children:Array.isArray(Bn==null?void 0:Bn.categories)?`No reputation yet${Un==="channel"?" in this channel":""}. Scores form two ways: ±1 thumbs on any message (the 'general' category) and specific opinions on four axes — trust, wisdom, thorough, helper. Every standing vote counts: score = upvotes − downvotes. Be the first to rate.`:`No reputation votes yet${Un==="channel"?" in this channel":""}. Votes are ±1 on four axes — trust, wisdom, thorough, helper — cast by humans and agents alike; expand an agent below once scores exist, or be the first to rate.`}):e.jsx(e.Fragment,{children:(()=>{var b;const u=Array.isArray(Bn.categories)||Bn.leaderboard.some(E=>E.breakdown!=null||typeof E.score=="number"),v=u?(b=Bn.categories)!=null&&b.length?Bn.categories:["general",...vi.map(E=>E.id)]:[],k=u&&v.length!==5?{gridTemplateColumns:`20px 22px minmax(70px, 1.5fr) minmax(40px, 0.7fr) repeat(${v.length}, minmax(40px, 0.8fr))`}:void 0;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"team_lb_legend","aria-hidden":"true",style:k,children:[e.jsx("span",{className:"team_lb_legend_rank",children:"#"}),e.jsx("span",{className:"team_lb_legend_avatar"}),e.jsx("span",{className:"team_lb_legend_agent",children:"Agent"}),u?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"team_lb_legend_total",title:"THE reputation score (operator ruling dm#129): one number — sum of every category's score. Thumbs are the 'general' category; specific opinions are their named category.",children:"Score"}),v.map(E=>e.jsx("span",{className:"team_lb_legend_axis",title:Of[E]||`${bl(E)} — reputation category.`,children:bl(E)},E))]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"team_lb_legend_total",title:"Sum of all axis scores",children:"Total"}),vi.map(E=>e.jsx("span",{className:"team_lb_legend_axis",title:E.help,children:E.label},E.id)),e.jsx("span",{className:"team_lb_legend_axis",title:"Message ratings, collapsed per rater (agora-0122): each rater contributes ONE net sign across the agent's messages — flips cancel, farming doesn't count. ▲ raters up · ▼ raters down.",children:"Msgs"})]})]}),Bn.leaderboard.map((E,ne)=>e.jsxs(Gt.Fragment,{children:[e.jsxs("div",{className:`team_lb_row ${Ja===E.target?"open":""}`,style:k,onClick:()=>Bl(E.target),role:"button",tabIndex:0,onKeyDown:q=>{(q.key==="Enter"||q.key===" ")&&(q.preventDefault(),Bl(E.target))},title:Un==="hub"?`${E.target}: rated in ${E.channels||0} channel(s) by ${E.raters} rater(s)`:u?`${E.target}: ${E.raters} rater(s) — click for attributed OPINION votes (general/thumbs live on the messages themselves)`:`${E.target}: ${E.raters} rater(s) — click for the votes behind the score`,children:[e.jsx("span",{className:`team_lb_rank ${ne<3?`top${ne+1}`:""}`,"aria-hidden":"true",children:ne<3?"●":ne+1}),e.jsx("span",{className:"team_avatar",style:Ia(E.target),"aria-hidden":"true",children:E.target.slice(0,1).toUpperCase()}),e.jsx("span",{className:"team_lb_agent",children:E.target}),u?e.jsxs(e.Fragment,{children:[(()=>{const q=Number(E.score||0),ve=E.votes;return e.jsxs("span",{className:`team_lb_total ${q>0?"pos":q<0?"neg":""}`,title:(()=>{const Me=Object.entries(E.breakdown||{}).filter(([,qe])=>qe&&Number(qe.score||0)!==0).map(([qe,Be])=>`${bl(qe)} ${Number(Be.score)>0?"+":""}${Number(Be.score)}`).join(" · ");return`${E.target}: score ${q>0?"+":""}${q} = ${Me||"no standing voices"} (categories sum; every standing vote counts — operator ruling dm#161)${ve?` — total: ${ve.up} up, ${ve.down} down`:""}`})(),children:[q>0?`+${q}`:q,ve&&(ve.up||ve.down)?e.jsxs("span",{className:"team_lb_rawvotes mono",children:[" ",e.jsxs("span",{className:"rv_up",children:[ve.up,"↑"]}),e.jsxs("span",{className:ve.down>0?"rv_down_hot":"rv_down",children:[ve.down,"↓"]})]}):null]})})(),v.map(q=>{var Be;const ve=(Be=E.breakdown)==null?void 0:Be[q],Me=Number((ve==null?void 0:ve.score)||0),qe=!!(ve&&(ve.up||ve.down||ve.raters));return e.jsx("span",{className:`team_lb_axis ${Me>0?"pos":Me<0?"neg":""}`,title:qe?`${bl(q)}: ${Me>0?"+":""}${Me} (▲${ve.up} ▼${ve.down} voices · ${ve.raters} engaged colleague${ve.raters===1?"":"s"}) — ${Of[q]||"reputation category"}`:`${bl(q)}: no standing input`,children:qe?Me>0?`+${Me}`:Me:"·"},q)})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:`team_lb_total ${(E.total||0)>0?"pos":(E.total||0)<0?"neg":""}`,children:(E.total||0)>0?`+${E.total}`:E.total||0}),vi.map(q=>{var qe;const ve=(qe=E.axes)==null?void 0:qe[q.id],Me=(ve==null?void 0:ve.score)||0;return e.jsx("span",{className:`team_lb_axis ${Me>0?"pos":Me<0?"neg":""}`,title:ve?`${q.label}: ${ve.up} up, ${ve.down} down`:`${q.label}: no votes`,children:ve?Me>0?`+${Me}`:Me:"·"},q.id)}),(()=>{const q=E.messages,ve=q?q.up-q.down:0;return e.jsx("span",{className:`team_lb_axis ${ve>0?"pos":ve<0?"neg":""}`,title:q&&(q.up||q.down)?`Message ratings: ${q.up} rater(s) net-up, ${q.down} net-down (per-rater collapse — flips cancel)`:"Message ratings: none standing",children:q&&(q.up||q.down)?`▲${q.up}${q.down?` ▼${q.down}`:""}`:"·"})})()]})]}),Ja===E.target&&Un==="channel"?e.jsxs("div",{className:"team_lb_detail",children:[e.jsxs("div",{className:"team_lb_cast",children:[e.jsxs("span",{className:"team_lb_cast_label",title:`Your standing vote as ${kt} — one live ±1 per axis; casting again revises, never stacks`,children:["rate as ",kt||"operator",":"]}),vi.map(q=>e.jsxs("span",{className:"team_lb_cast_axis",title:q.help,children:[e.jsx("span",{className:"team_lb_cast_axis_name",children:q.label}),e.jsx("button",{className:"btn btn_icon team_lb_vote up",disabled:!!Ni||E.target===kt,onClick:ve=>{ve.stopPropagation(),Pi(E.target,q.id,1)},title:`+1 ${q.label} for ${E.target}`,children:e.jsx(st,{name:"thumbsUp",size:12})}),e.jsx("button",{className:"btn btn_icon team_lb_vote down",disabled:!!Ni||E.target===kt,onClick:ve=>{ve.stopPropagation(),Pi(E.target,q.id,-1)},title:`-1 ${q.label} for ${E.target}`,children:e.jsx(st,{name:"thumbsDown",size:12})})]},q.id))]}),e.jsx("input",{className:"team_lb_note",placeholder:"why — one line, on the record (optional, applies to your next vote)",value:Vs,maxLength:280,onChange:q=>Ya(q.target.value),onClick:q=>q.stopPropagation()}),Gs?e.jsx("div",{className:"team_lb_error",children:Gs}):null,Hs===null?e.jsx("div",{className:"muted team_note",children:"Loading votes…"}):Hs.length===0?e.jsx("div",{className:"muted team_note",children:u?"No attributed opinion votes yet — if this row carries a score, it comes from message thumbs ('general'), which live on the messages themselves (hover any message to see its tally).":"No attributed votes yet."}):Hs.map(q=>e.jsxs("div",{className:"team_lb_vote_row",children:[e.jsx("span",{className:"team_avatar team_avatar_sm",style:Ia(q.rater),"aria-hidden":"true",children:q.rater.slice(0,1).toUpperCase()}),e.jsx("span",{className:"team_lb_vote_rater",children:q.rater}),e.jsx("span",{className:"team_lb_vote_axis",children:q.axis}),e.jsx(st,{name:q.value>0?"thumbsUpFilled":"thumbsDownFilled",size:12,className:`team_lb_vote_val ${q.value>0?"pos":"neg"}`,title:q.value>0?"+1":"-1"}),e.jsx("span",{className:"team_lb_vote_note",title:q.note,children:q.note||e.jsx("span",{className:"muted",children:"no note"})})]},`${q.rater}:${q.axis}`))]}):null,Ja===E.target&&Un==="hub"?e.jsx("div",{className:"team_lb_detail",children:e.jsx("div",{className:"muted team_note",children:u?"How this score counts (operator ruling dm#161): score = ALL standing upvotes − ALL standing downvotes, across every category and channel. A flip revises its own vote; withdrawing removes it. Thumbs are cast on messages where the evidence is; switch to a channel scope to cast opinion votes.":"Hub rows count DISTINCT VOUCHERS — each rater contributes at most ±1 per axis no matter how many channels you share, so scores can't be farmed. Switch to a channel scope to see attributed votes and cast yours."})}):null]},E.target)),e.jsx("div",{className:"muted team_lb_footnote",children:u?"One reputation score (operator ruling): score = ALL upvotes − ALL downvotes, across every category. Thumbs on messages feed 'general'; named categories are specific opinions. Expand a row to cast opinions; self-votes refused.":"Tip: the quickest way to vote is the △▽ thumbs on any message — one tap vouches for (or flags) its author on trust, right where the evidence is. This board is the rollup; expand a row for the four axes, who stands where, and why. ±1 per rater per axis, revising replaces, self-votes refused."})]})})()})})]}):null,jt==="desk"?e.jsxs("div",{className:"pane team_drawer_pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Operator desk"}),e.jsxs("span",{className:"pane_header_actions",style:{marginLeft:"auto",display:"inline-flex",gap:6},children:[e.jsx("button",{className:"btn",onClick:()=>void de(),title:"Reload",children:"Refresh"}),e.jsx("button",{className:"btn btn_icon",onClick:()=>Xt(""),title:"Close",children:"✕"})]})]}),e.jsxs("div",{className:"pane_body pane_body_list",children:[ce==="loading"?e.jsx("div",{className:"muted team_note",children:"Loading…"}):null,ce===null&&_e?e.jsx("div",{className:"muted team_note",children:_e}):null,ce!==null&&ce!=="loading"?e.jsxs(e.Fragment,{children:[ce.rows.length?null:e.jsx("div",{className:"muted team_note",children:"Nothing waits on you. Clear desk."}),ce.rows.map((u,v)=>{const k=Number(u.age_minutes),b=Number.isFinite(k)?k<60?`${Math.max(1,Math.round(k))}m`:k<2880?`${Math.round(k/60)}h`:`${Math.round(k/1440)}d`:"";return e.jsxs("div",{className:"team_desk_row",children:[e.jsxs("div",{className:"team_desk_row_head",children:[e.jsx("span",{className:`chip mono ${String(u.kind)==="ask"?"warn":""}`,children:String(u.kind||"ask")}),e.jsx("span",{className:"mono muted",children:String(u.who_waits||"?")}),e.jsx("span",{className:"muted",style:{marginLeft:"auto"},title:"Waiting since (oldest first)",children:b})]}),e.jsx("div",{className:"team_desk_row_what",children:String(u.what||"")}),u.one_action?e.jsxs("div",{className:"team_desk_row_needed muted",children:["→ ",String(u.one_action)]}):null,u.channel?e.jsx("button",{className:"team_row_expand",onClick:()=>{Ys.current={message_id:u.id?String(u.id):void 0,seq:Number(u.seq)||void 0},String(u.channel)===L?sr():ke(String(u.channel)),Xt("")},title:"Open the message that waits on you",children:"open ↗"}):null]},String(u.id||u.key||v))}),ce.satisfied.length?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"muted team_note team_desk_satisfied_head",children:"Satisfied — the hub observed each item's done-condition; these clear themselves:"}),ce.satisfied.map((u,v)=>e.jsxs("div",{className:"team_desk_row satisfied",children:[e.jsxs("div",{className:"team_desk_row_head",children:[e.jsx("span",{className:"chip mono ok",children:"done"}),e.jsx("span",{className:"mono muted",children:String(u.who_waits||"")})]}),e.jsx("div",{className:"team_desk_row_what muted",children:String(u.what||"")})]},String(u.key||v)))]}):null]}):null]})]}):null,e.jsxs("div",{className:"team_drawer_rail",children:[f?e.jsx("button",{className:`team_drawer_tab ${jt==="assistant"?"active":""}`,onClick:()=>xa("assistant"),disabled:!L,"aria-pressed":jt==="assistant",title:"Channel assistant — ask an LLM about this channel (also: type /assistant in the composer)",children:"Assistant"}):null,e.jsx("button",{className:`team_drawer_tab ${jt==="members"?"active":""}`,onClick:()=>xa("members"),disabled:!L,"aria-pressed":jt==="members","aria-label":"Open channel members drawer",title:"Channel members — roster, moderation, and channel lifecycle",children:"Members"}),e.jsx("button",{className:`team_drawer_tab ${jt==="files"?"active":""}`,onClick:()=>xa("files"),disabled:!L,"aria-pressed":jt==="files","aria-label":"Open channel files drawer",title:"Channel files — browse this channel's virtual filesystem (/fs)",children:"Files"}),e.jsx("button",{className:`team_drawer_tab ${jt==="leaderboard"?"active":""}`,onClick:()=>xa("leaderboard"),disabled:!L,"aria-pressed":jt==="leaderboard","aria-label":"Open reputation leaderboard drawer",title:"Reputation leaderboard — trust, wisdom, thorough, helper; per-channel and hub-wide",children:"Leaderboard"}),(()=>{const u=ce!==null&&ce!=="loading"?ce:null,v=u?u.rows.length:0,k=u?u.satisfied.length:0;return e.jsxs("button",{className:`team_drawer_tab ${jt==="desk"?"active":""}`,onClick:()=>xa("desk"),"aria-pressed":jt==="desk","aria-label":v?`Open the operator desk — ${v} item(s) wait on you`:"Open the operator desk",title:"Operator desk — everything blocked on YOU, with age (asks addressed to you, queue items, escalations)",children:["Desk",v?e.jsx("span",{className:"team_desk_tab_badge",children:v>99?"99+":v}):null,!v&&k?e.jsx("span",{className:"team_desk_tab_badge ok",title:"Satisfied queue items — waits you can close",children:k>99?"99+":k}):null]})})()]})]}),e.jsx(Xv,{view:Dr,onClose:()=>qt(null)})]})}const Df=[{id:"board",label:"Board",icon:"board"},{id:"executions",label:"Executions",icon:"playCircle"},{id:"backlog",label:"Backlog",icon:"list"},{id:"agents",label:"Agents & Entities",icon:"agent"},{id:"team",label:"Team",icon:"chat"},{id:"inbox",label:"Inbox",icon:"inbox"},{id:"services",label:"Services",icon:"server"},{id:"settings",label:"Settings",icon:"gear"}],ed="abstractcontinuum_settings_v1";function hy(){try{const a=window.localStorage.getItem(ed)||"{}",s=JSON.parse(a);if(s&&(s.auth_token||s.gateway_url)){delete s.auth_token,delete s.gateway_url;try{window.localStorage.setItem(ed,JSON.stringify(s))}catch{}}return{maintenance_ai_provider:String((s==null?void 0:s.maintenance_ai_provider)||""),maintenance_ai_model:String((s==null?void 0:s.maintenance_ai_model)||""),maintenance_ai_reasoning:String((s==null?void 0:s.maintenance_ai_reasoning)||""),backlog_advisor_agent:String((s==null?void 0:s.backlog_advisor_agent)||""),default_execution_mode:(s==null?void 0:s.default_execution_mode)==="inplace"?"inplace":"uat"}}catch{return{maintenance_ai_provider:"",maintenance_ai_model:"",maintenance_ai_reasoning:"",backlog_advisor_agent:"",default_execution_mode:"uat"}}}function py(){var A;const[a,s]=h.useState("board"),[r,l]=h.useState(null),[c,f]=h.useState(null),[m,p]=h.useState(()=>hy()),[_,y]=h.useState(!1),[w,x]=h.useState(!1),[N,$]=h.useState(0),[P,T]=h.useState(!1),[F,D]=h.useState(!1),[J,B]=l_("continuum"),[ee,C]=h.useState(0),[Z,ae]=h.useState(null),[fe,ge]=h.useState("");h.useEffect(()=>{if(!Z)return;const U=setTimeout(()=>ae(null),8e3);return()=>clearTimeout(U)},[Z]);const[Te,Se]=h.useState(!1);h.useEffect(()=>{var be;const U=((be=document.querySelector('script[type="module"][src*="/assets/"]'))==null?void 0:be.getAttribute("src"))||"";if(!U)return;let ie=!1;async function de(){try{const Ie=await fetch("/",{cache:"no-store",signal:AbortSignal.timeout(8e3)});if(!Ie.ok)return;const Ye=(await Ie.text()).match(/<script[^>]+type="module"[^>]+src="([^"]+)"/),he=(Ye==null?void 0:Ye[1])||"";!ie&&he&&U&&he!==U&&Se(!0)}catch{}}const L=()=>void de();window.addEventListener("focus",L);const ke=setInterval(()=>void de(),300*1e3);return de(),()=>{ie=!0,window.removeEventListener("focus",L),clearInterval(ke)}},[]);function K(U){ge(String(U||"")),s("executions")}h.useEffect(()=>{const U=ie=>{var de;Array.from(((de=ie.dataTransfer)==null?void 0:de.types)||[]).includes("Files")&&ie.preventDefault()};return window.addEventListener("dragover",U),window.addEventListener("drop",U),()=>{window.removeEventListener("dragover",U),window.removeEventListener("drop",U)}},[]);const[te,z]=h.useState(!1);h.useEffect(()=>{a==="team"&&z(!0)},[a]);function V(U){var ke;const ie=U.target,de=(ke=ie==null?void 0:ie.closest)==null?void 0:ke.call(ie,"a[href]");if(!de||de.target==="_blank"||de.hasAttribute("download"))return;const L=de.getAttribute("href")||"";L.startsWith("/")&&(U.preventDefault(),window.open(L,"_blank","noopener"))}h.useEffect(()=>{try{window.localStorage.setItem(ed,JSON.stringify(m))}catch{}},[m]);const H=h.useMemo(()=>new G_({base_url:""}),[]),ce=Xp({appName:"AbstractContinuum",onStatusChange:()=>$(U=>U+1)}),I=ce.status,_e=h.useRef(0);h.useEffect(()=>{let U=!1,ie;return(async()=>{try{await H.list_processes(),U||(_e.current=0,y(!0))}catch{if(U)return;_e.current+=1,_e.current>=2?y(!1):ie=window.setTimeout(()=>{U||$(de=>de+1)},2e3)}})(),()=>{U=!0,ie!==void 0&&window.clearTimeout(ie)}},[H,a,N]);const Y=h.useRef(_);h.useEffect(()=>{Y.current&&!_&&(I!=null&&I.has_session)&&ce.refresh(),Y.current=_},[_,I==null?void 0:I.has_session]);async function S(U,ie){const de=[...ie.history.map(ke=>({role:ke.role,content:ke.content})),{role:"user",content:U}],L=await H.backlog_advisor({messages:de,agent:m.backlog_advisor_agent||null});return String((L==null?void 0:L.reply)||"").trim()||"(the advisor returned an empty reply)"}return e.jsxs("div",{className:"shell",onClickCapture:V,children:[e.jsxs("aside",{className:"shell_sidebar",children:[e.jsxs("div",{className:"shell_brand",title:"AbstractContinuum — continuous development console",children:[e.jsx("span",{className:"shell_brand_mark",children:"∞"}),e.jsx("span",{className:"shell_brand_name",children:"Continuum"})]}),e.jsx("nav",{className:"shell_nav",children:Df.map(U=>e.jsxs("button",{className:`shell_nav_item ${a===U.id?"active":""}`,onClick:()=>s(U.id),title:U.label,children:[e.jsx("span",{className:"shell_nav_icon",children:e.jsx(st,{name:U.icon,size:16})}),e.jsx("span",{className:"shell_nav_label",children:U.label})]},U.id))})]}),e.jsxs("div",{className:"shell_main",children:[e.jsxs("header",{className:"shell_header",children:[e.jsx("div",{className:"shell_header_title",children:((A=Df.find(U=>U.id===a))==null?void 0:A.label)||""}),e.jsx("div",{className:"shell_header_actions",children:e.jsx(a_,{assistant:{open:P,onToggle:()=>T(U=>!U)},appearance:{onOpen:()=>D(!0)},extraActions:e.jsx("button",{className:"btn primary",onClick:()=>x(!0),disabled:!_,children:"+ New task"}),connection:{phase:ce.phase,signingOut:ce.signingOut,onConnect:ce.openModal,onDisconnect:()=>void ce.signOut()}})})]}),!_&&a!=="settings"?e.jsxs("div",{className:"shell_banner",children:[e.jsx("span",{children:"Gateway unreachable or not signed in."}),e.jsx("button",{className:"btn",onClick:ce.openModal,children:"Connect"})]}):null,ce.signOutError?e.jsx("div",{className:"shell_banner",children:e.jsxs("span",{children:["Sign-out failed: ",ce.signOutError," — the session may still be live."]})}):null,Z?e.jsxs("div",{className:`shell_banner ${Z.tone==="warn"?"":"shell_banner_ok"}`,children:[e.jsx("span",{children:Z.text}),e.jsx("button",{className:"btn",onClick:()=>ae(null),children:"Dismiss"})]}):null,Te?e.jsxs("div",{className:"shell_banner",children:[e.jsx("span",{children:"This tab is running an older build of the console — features may render wrong until you reload."}),e.jsx("button",{className:"btn",onClick:()=>window.location.reload(),children:"Reload now"})]}):null,e.jsxs("main",{className:"shell_content",children:[a==="board"?e.jsx(Bg,{gateway:H,gateway_connected:_,data_nonce:ee,on_mutated:()=>C(U=>U+1),on_open_executions:K,default_execution_mode:m.default_execution_mode,query_preset:r,on_query_preset_consumed:()=>l(null),on_open_team:U=>{f(U),s("team")}}):null,a==="executions"?e.jsx(sv,{gateway:H,gateway_connected:_,focus_request_id:fe,on_focus_consumed:()=>ge(""),on_open_settings:()=>s("settings")}):null,a==="backlog"?e.jsx(Eg,{gateway:H,gateway_connected:_,maintenance_ai_provider:m.maintenance_ai_provider,maintenance_ai_model:m.maintenance_ai_model,maintenance_ai_reasoning:m.maintenance_ai_reasoning,backlog_advisor_agent:m.backlog_advisor_agent,default_execution_mode:m.default_execution_mode,on_open_executions:K}):null,a==="agents"?e.jsx(lg,{gateway:H,gateway_connected:_,backlog_advisor_agent:m.backlog_advisor_agent,on_open_assistant:()=>T(!0),on_open_team:()=>s("team"),on_open_executions:()=>K()}):null,te?e.jsx("div",{style:{display:a==="team"?"contents":"none"},children:e.jsx(vh,{fallback:U=>e.jsx("div",{className:"page page_pad",children:e.jsxs("div",{className:"callout callout_warn",children:[e.jsx("strong",{children:"The Team view hit a render error."}),e.jsx("div",{className:"muted",style:{margin:"6px 0"},children:String(U.message||U)}),e.jsx("button",{className:"btn",onClick:()=>window.location.reload(),children:"Reload"})]})}),children:e.jsx(fy,{gateway:H,gateway_connected:_,advisor:_?async(U,ie)=>{const de=[...ie.map(ke=>({role:ke.role,content:ke.content})),{role:"user",content:U}],L=await H.backlog_advisor({messages:de,agent:m.backlog_advisor_agent||null});return String((L==null?void 0:L.reply)||"").trim()||"(the model returned an empty reply)"}:void 0,advisor_agent:m.backlog_advisor_agent,on_open_board:U=>{l(U||null),s("board")},focus:c,on_focus_consumed:()=>f(null)})})}):null,a==="inbox"?e.jsx(ov,{gateway:H,gateway_connected:_,enable_triage:!0}):null,a==="services"?e.jsx(iv,{gateway:H,gateway_connected:_}):null,a==="settings"?e.jsx(_v,{gateway:H,gateway_connected:_,settings:m,set_settings:p,connection:I}):null]})]}),e.jsx(Jp,{...ce.modalProps}),e.jsx(s_,{open:P,onClose:()=>T(!1),label:"Assistant",title:"Continuum assistant",children:e.jsx(B_,{ask:S,assistantName:"Continuum advisor",blockedNotice:_?void 0:"Connect to the gateway to use the assistant."})}),e.jsx(o_,{open:F,onClose:()=>D(!1),value:J,onChange:B}),e.jsx(Tg,{open:w,gateway:H,can_use_gateway:_,maint_provider:m.maintenance_ai_provider,maint_model:m.maintenance_ai_model,maint_reasoning:m.maintenance_ai_reasoning,on_close:()=>x(!1),on_created:async(U,ie,de)=>{C(ke=>ke+1);const L=String(U||"");s(L==="recurrent"?"backlog":"board"),ae(de?{text:`Task created (${ie}), but attachments failed: ${de}`,tone:"warn"}:{text:`Task created: ${ie} (${L||"?"})${L==="recurrent"?" — recurrent items live on the Backlog page":""}`,tone:"ok"})}})]})}const Nh=document.getElementById("root");if(!Nh)throw new Error("root element missing");gp.createRoot(Nh).render(e.jsx(Gt.StrictMode,{children:e.jsx(py,{})}));export{wv as _,cp as g};
124
- //# sourceMappingURL=index-DmnZnFTc.js.map