@abstractframework/continuum 0.5.0 → 0.6.0

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 (67) hide show
  1. package/README.md +11 -4
  2. package/dist/assets/{abnfDiagram-VRR7QNED-E9lbmtBV.js → abnfDiagram-VRR7QNED-DUoj6rgR.js} +2 -2
  3. package/dist/assets/{arc-XVGGKtJ-.js → arc-I6yCEc-n.js} +2 -2
  4. package/dist/assets/{architectureDiagram-ZJ3FMSHR-GRV2Ej0c.js → architectureDiagram-ZJ3FMSHR-DJYsy6Ke.js} +2 -2
  5. package/dist/assets/{blockDiagram-677ZJIJ3-Dz8wPMHC.js → blockDiagram-677ZJIJ3-BjB9Abvu.js} +2 -2
  6. package/dist/assets/{c4Diagram-LMCZKHZV-CAHne5Am.js → c4Diagram-LMCZKHZV-DiukFpvk.js} +2 -2
  7. package/dist/assets/channel-CsGWNVeB.js +2 -0
  8. package/dist/assets/{chunk-2Q5K7J3B-DFXMgoy3.js → chunk-2Q5K7J3B-Bzj3nCUE.js} +2 -2
  9. package/dist/assets/{chunk-32BRIVSS-D9T7Whin.js → chunk-32BRIVSS-P-cd15lV.js} +2 -2
  10. package/dist/assets/{chunk-5VM5RSS4-D8jr-VV1.js → chunk-5VM5RSS4-C926qres.js} +2 -2
  11. package/dist/assets/{chunk-EX3LRPZG-BSkCDWzU.js → chunk-EX3LRPZG-D-8MH237.js} +2 -2
  12. package/dist/assets/{chunk-JWPE2WC7-iYmSeuV1.js → chunk-JWPE2WC7-xesmSJf_.js} +2 -2
  13. package/dist/assets/{chunk-MOJQB5TN-BxgBSbz5.js → chunk-MOJQB5TN-Cur1aPrT.js} +2 -2
  14. package/dist/assets/{chunk-RYQCIY6F-D5JkyQAc.js → chunk-RYQCIY6F-BVTILQCf.js} +2 -2
  15. package/dist/assets/{chunk-V7JOEXUC-B_6OmmFi.js → chunk-V7JOEXUC-DH8DqqLP.js} +2 -2
  16. package/dist/assets/{chunk-VR4S4FIN-BsoDEIUS.js → chunk-VR4S4FIN-DONA5ZQE.js} +2 -2
  17. package/dist/assets/{chunk-XXDRQBXY-DG-goPoO.js → chunk-XXDRQBXY-Cj5h3H9W.js} +2 -2
  18. package/dist/assets/classDiagram-OUVF2IWQ-BRgLg1Zt.js +2 -0
  19. package/dist/assets/classDiagram-v2-EOCWNBFH-BRgLg1Zt.js +2 -0
  20. package/dist/assets/{cose-bilkent-JH36ORCC-C95YoC9P.js → cose-bilkent-JH36ORCC-DPp5nz7X.js} +2 -2
  21. package/dist/assets/{cynefin-VYW2F7L2-A7Vh09t2.js → cynefin-VYW2F7L2-Cb1VDqjx.js} +2 -2
  22. package/dist/assets/{cynefinDiagram-TSTJHNR4-BI8-04G-.js → cynefinDiagram-TSTJHNR4-BkVCVAKN.js} +2 -2
  23. package/dist/assets/{dagre-VKFMJZFB-owAzFOdh.js → dagre-VKFMJZFB-C69yqHLO.js} +2 -2
  24. package/dist/assets/{diagram-FQU43EPY-B8FPxd72.js → diagram-FQU43EPY-Cu2AB9_p.js} +2 -2
  25. package/dist/assets/{diagram-G47NLZAW-CwooMJF9.js → diagram-G47NLZAW-CxoS06le.js} +2 -2
  26. package/dist/assets/{diagram-NH7WQ7WH-Cr-bMH-G.js → diagram-NH7WQ7WH-BfWvQlGK.js} +2 -2
  27. package/dist/assets/{diagram-OA4YK3LP-3rHTMgXR.js → diagram-OA4YK3LP-BT4lqaBM.js} +2 -2
  28. package/dist/assets/{diagram-WEI45ONY-BG4PjrBn.js → diagram-WEI45ONY-DzN57p-J.js} +2 -2
  29. package/dist/assets/{ebnfDiagram-CCIWWBDH-B6uukG4X.js → ebnfDiagram-CCIWWBDH-DENI1vQm.js} +2 -2
  30. package/dist/assets/{erDiagram-Q63AITRT-D3OgqYHT.js → erDiagram-Q63AITRT-D0Xg--j1.js} +2 -2
  31. package/dist/assets/{flowDiagram-23GEKE2U-CxTaDERr.js → flowDiagram-23GEKE2U-V_z3dBhe.js} +2 -2
  32. package/dist/assets/{ganttDiagram-NO4QXBWP-CN7iAeQh.js → ganttDiagram-NO4QXBWP-9QKS4cRZ.js} +2 -2
  33. package/dist/assets/{gitGraphDiagram-IHSO6WYX-DbvcWmmM.js → gitGraphDiagram-IHSO6WYX-DfBBOfgk.js} +2 -2
  34. package/dist/assets/index-C_TjOHlB.css +1 -0
  35. package/dist/assets/index-SU9S3HCp.js +122 -0
  36. package/dist/assets/{infoDiagram-FWYZ7A6U-DX4NPNgR.js → infoDiagram-FWYZ7A6U-2PxB9AEr.js} +2 -2
  37. package/dist/assets/{ishikawaDiagram-FXEZZL3T-DtL3v287.js → ishikawaDiagram-FXEZZL3T-BPs88htZ.js} +2 -2
  38. package/dist/assets/{journeyDiagram-5HDEW3XC-CtAZFiGl.js → journeyDiagram-5HDEW3XC-D59tgM9D.js} +2 -2
  39. package/dist/assets/{kanban-definition-HUTT4EX6-CvrCkrKt.js → kanban-definition-HUTT4EX6-MfmvVLTi.js} +2 -2
  40. package/dist/assets/{linear-CbLBdTPp.js → linear-DUi9ti0c.js} +2 -2
  41. package/dist/assets/{mermaid.core-zt0bcQ8D.js → mermaid.core-i20J3FaS.js} +5 -5
  42. package/dist/assets/{mindmap-definition-LN4V7U3C-DU-r_mE6.js → mindmap-definition-LN4V7U3C-D2Q7oe5w.js} +2 -2
  43. package/dist/assets/{pegDiagram-2B236MQR-CoiPuGzc.js → pegDiagram-2B236MQR-CNmY3KTl.js} +2 -2
  44. package/dist/assets/{pieDiagram-ENE6RG2P-ClUZORQg.js → pieDiagram-ENE6RG2P-Ch2esIfg.js} +2 -2
  45. package/dist/assets/{quadrantDiagram-ABIIQ3AL-D0i0p2xo.js → quadrantDiagram-ABIIQ3AL-CJHDjhnh.js} +2 -2
  46. package/dist/assets/{railroadDiagram-RFXS5EU6-wI6Hdpa5.js → railroadDiagram-RFXS5EU6-C_mgIhjT.js} +2 -2
  47. package/dist/assets/{requirementDiagram-TGXJPOKE-Bm4qvEra.js → requirementDiagram-TGXJPOKE-C-tQSD22.js} +2 -2
  48. package/dist/assets/{sankeyDiagram-HTMAVEWB-DX8is9uB.js → sankeyDiagram-HTMAVEWB-D2zvcJ4r.js} +2 -2
  49. package/dist/assets/{sequenceDiagram-DBY2YBRQ-5RpIQiJh.js → sequenceDiagram-DBY2YBRQ-CI0liPpW.js} +2 -2
  50. package/dist/assets/{sizeCapture-X5ZJPWSS-ChX6cFSk.js → sizeCapture-X5ZJPWSS-8-Z0Kdmg.js} +2 -2
  51. package/dist/assets/{stateDiagram-2N3HPSRC-Tea20pcW.js → stateDiagram-2N3HPSRC-D335WS9r.js} +2 -2
  52. package/dist/assets/stateDiagram-v2-6OUMAXLB-DnoX14wc.js +2 -0
  53. package/dist/assets/{swimlanes-5IMT3BWC-BY7gSBH7.js → swimlanes-5IMT3BWC-BO-KsJgL.js} +3 -3
  54. package/dist/assets/swimlanesDiagram-G3AALYLV-DIwiFP1r.js +9 -0
  55. package/dist/assets/{timeline-definition-FHXFAJF6-Bq52M8-r.js → timeline-definition-FHXFAJF6-BuN-EhNZ.js} +2 -2
  56. package/dist/assets/{vennDiagram-L72KCM5P-BGBcMmhw.js → vennDiagram-L72KCM5P-CeZevnKl.js} +2 -2
  57. package/dist/assets/{wardleyDiagram-EHGQE667-T3JqsmMn.js → wardleyDiagram-EHGQE667-D7kBjKl4.js} +2 -2
  58. package/dist/assets/{xychartDiagram-FW5EYKEG-B0yTh8-d.js → xychartDiagram-FW5EYKEG-D7uR7Ic7.js} +2 -2
  59. package/dist/index.html +2 -2
  60. package/package.json +3 -3
  61. package/dist/assets/channel-BbrZydfX.js +0 -2
  62. package/dist/assets/classDiagram-OUVF2IWQ-BvV49U6G.js +0 -2
  63. package/dist/assets/classDiagram-v2-EOCWNBFH-BvV49U6G.js +0 -2
  64. package/dist/assets/index-Ca1Qebcu.js +0 -121
  65. package/dist/assets/index-fh60G2KG.css +0 -1
  66. package/dist/assets/stateDiagram-v2-6OUMAXLB-CCBRDLbX.js +0 -2
  67. package/dist/assets/swimlanesDiagram-G3AALYLV-Dtz4rZCK.js +0 -9
@@ -0,0 +1,122 @@
1
+ var Dp=Object.defineProperty;var Fp=(a,s,r)=>s in a?Dp(a,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[s]=r;var Rr=(a,s,r)=>Fp(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 d of c)if(d.type==="childList")for(const p of d.addedNodes)p.tagName==="LINK"&&p.rel==="modulepreload"&&l(p)}).observe(document,{childList:!0,subtree:!0});function r(c){const d={};return c.integrity&&(d.integrity=c.integrity),c.referrerPolicy&&(d.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?d.credentials="include":c.crossOrigin==="anonymous"?d.credentials="omit":d.credentials="same-origin",d}function l(c){if(c.ep)return;c.ep=!0;const d=r(c);fetch(c.href,d)}})();function qp(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var wu={exports:{}},kl={},ju={exports:{}},pt={};/**
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 Ym;function Bp(){if(Ym)return pt;Ym=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"),d=Symbol.for("react.provider"),p=Symbol.for("react.context"),m=Symbol.for("react.forward_ref"),_=Symbol.for("react.suspense"),x=Symbol.for("react.memo"),b=Symbol.for("react.lazy"),y=Symbol.iterator;function C(w){return w===null||typeof w!="object"?null:(w=y&&w[y]||w["@@iterator"],typeof w=="function"?w:null)}var A={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},E=Object.assign,$={};function L(w,N,Z){this.props=w,this.context=N,this.refs=$,this.updater=Z||A}L.prototype.isReactComponent={},L.prototype.setState=function(w,N){if(typeof w!="object"&&typeof w!="function"&&w!=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,w,N,"setState")},L.prototype.forceUpdate=function(w){this.updater.enqueueForceUpdate(this,w,"forceUpdate")};function q(){}q.prototype=L.prototype;function O(w,N,Z){this.props=w,this.context=N,this.refs=$,this.updater=Z||A}var D=O.prototype=new q;D.constructor=O,E(D,L.prototype),D.isPureReactComponent=!0;var K=Array.isArray,T=Object.prototype.hasOwnProperty,te={current:null},ue={key:!0,ref:!0,__self:!0,__source:!0};function re(w,N,Z){var pe,oe={},I=null,be=null;if(N!=null)for(pe in N.ref!==void 0&&(be=N.ref),N.key!==void 0&&(I=""+N.key),N)T.call(N,pe)&&!ue.hasOwnProperty(pe)&&(oe[pe]=N[pe]);var Re=arguments.length-2;if(Re===1)oe.children=Z;else if(1<Re){for(var qe=Array(Re),Oe=0;Oe<Re;Oe++)qe[Oe]=arguments[Oe+2];oe.children=qe}if(w&&w.defaultProps)for(pe in Re=w.defaultProps,Re)oe[pe]===void 0&&(oe[pe]=Re[pe]);return{$$typeof:a,type:w,key:I,ref:be,props:oe,_owner:te.current}}function Te(w,N){return{$$typeof:a,type:w.type,key:N,ref:w.ref,props:w.props,_owner:w._owner}}function je(w){return typeof w=="object"&&w!==null&&w.$$typeof===a}function Ce(w){var N={"=":"=0",":":"=2"};return"$"+w.replace(/[=:]/g,function(Z){return N[Z]})}var xe=/\/+/g;function J(w,N){return typeof w=="object"&&w!==null&&w.key!=null?Ce(""+w.key):N.toString(36)}function ne(w,N,Z,pe,oe){var I=typeof w;(I==="undefined"||I==="boolean")&&(w=null);var be=!1;if(w===null)be=!0;else switch(I){case"string":case"number":be=!0;break;case"object":switch(w.$$typeof){case a:case s:be=!0}}if(be)return be=w,oe=oe(be),w=pe===""?"."+J(be,0):pe,K(oe)?(Z="",w!=null&&(Z=w.replace(xe,"$&/")+"/"),ne(oe,N,Z,"",function(Oe){return Oe})):oe!=null&&(je(oe)&&(oe=Te(oe,Z+(!oe.key||be&&be.key===oe.key?"":(""+oe.key).replace(xe,"$&/")+"/")+w)),N.push(oe)),1;if(be=0,pe=pe===""?".":pe+":",K(w))for(var Re=0;Re<w.length;Re++){I=w[Re];var qe=pe+J(I,Re);be+=ne(I,N,Z,qe,oe)}else if(qe=C(w),typeof qe=="function")for(w=qe.call(w),Re=0;!(I=w.next()).done;)I=I.value,qe=pe+J(I,Re++),be+=ne(I,N,Z,qe,oe);else if(I==="object")throw N=String(w),Error("Objects are not valid as a React child (found: "+(N==="[object Object]"?"object with keys {"+Object.keys(w).join(", ")+"}":N)+"). If you meant to render a collection of children, use an array instead.");return be}function ve(w,N,Z){if(w==null)return w;var pe=[],oe=0;return ne(w,pe,"","",function(I){return N.call(Z,I,oe++)}),pe}function W(w){if(w._status===-1){var N=w._result;N=N(),N.then(function(Z){(w._status===0||w._status===-1)&&(w._status=1,w._result=Z)},function(Z){(w._status===0||w._status===-1)&&(w._status=2,w._result=Z)}),w._status===-1&&(w._status=0,w._result=N)}if(w._status===1)return w._result.default;throw w._result}var Y={current:null},z={transition:null},V={ReactCurrentDispatcher:Y,ReactCurrentBatchConfig:z,ReactCurrentOwner:te};function U(){throw Error("act(...) is not supported in production builds of React.")}return pt.Children={map:ve,forEach:function(w,N,Z){ve(w,function(){N.apply(this,arguments)},Z)},count:function(w){var N=0;return ve(w,function(){N++}),N},toArray:function(w){return ve(w,function(N){return N})||[]},only:function(w){if(!je(w))throw Error("React.Children.only expected to receive a single React element child.");return w}},pt.Component=L,pt.Fragment=r,pt.Profiler=c,pt.PureComponent=O,pt.StrictMode=l,pt.Suspense=_,pt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=V,pt.act=U,pt.cloneElement=function(w,N,Z){if(w==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+w+".");var pe=E({},w.props),oe=w.key,I=w.ref,be=w._owner;if(N!=null){if(N.ref!==void 0&&(I=N.ref,be=te.current),N.key!==void 0&&(oe=""+N.key),w.type&&w.type.defaultProps)var Re=w.type.defaultProps;for(qe in N)T.call(N,qe)&&!ue.hasOwnProperty(qe)&&(pe[qe]=N[qe]===void 0&&Re!==void 0?Re[qe]:N[qe])}var qe=arguments.length-2;if(qe===1)pe.children=Z;else if(1<qe){Re=Array(qe);for(var Oe=0;Oe<qe;Oe++)Re[Oe]=arguments[Oe+2];pe.children=Re}return{$$typeof:a,type:w.type,key:oe,ref:I,props:pe,_owner:be}},pt.createContext=function(w){return w={$$typeof:p,_currentValue:w,_currentValue2:w,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},w.Provider={$$typeof:d,_context:w},w.Consumer=w},pt.createElement=re,pt.createFactory=function(w){var N=re.bind(null,w);return N.type=w,N},pt.createRef=function(){return{current:null}},pt.forwardRef=function(w){return{$$typeof:m,render:w}},pt.isValidElement=je,pt.lazy=function(w){return{$$typeof:b,_payload:{_status:-1,_result:w},_init:W}},pt.memo=function(w,N){return{$$typeof:x,type:w,compare:N===void 0?null:N}},pt.startTransition=function(w){var N=z.transition;z.transition={};try{w()}finally{z.transition=N}},pt.unstable_act=U,pt.useCallback=function(w,N){return Y.current.useCallback(w,N)},pt.useContext=function(w){return Y.current.useContext(w)},pt.useDebugValue=function(){},pt.useDeferredValue=function(w){return Y.current.useDeferredValue(w)},pt.useEffect=function(w,N){return Y.current.useEffect(w,N)},pt.useId=function(){return Y.current.useId()},pt.useImperativeHandle=function(w,N,Z){return Y.current.useImperativeHandle(w,N,Z)},pt.useInsertionEffect=function(w,N){return Y.current.useInsertionEffect(w,N)},pt.useLayoutEffect=function(w,N){return Y.current.useLayoutEffect(w,N)},pt.useMemo=function(w,N){return Y.current.useMemo(w,N)},pt.useReducer=function(w,N,Z){return Y.current.useReducer(w,N,Z)},pt.useRef=function(w){return Y.current.useRef(w)},pt.useState=function(w){return Y.current.useState(w)},pt.useSyncExternalStore=function(w,N,Z){return Y.current.useSyncExternalStore(w,N,Z)},pt.useTransition=function(){return Y.current.useTransition()},pt.version="18.3.1",pt}var Xm;function md(){return Xm||(Xm=1,ju.exports=Bp()),ju.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 Zm;function Up(){if(Zm)return kl;Zm=1;var a=md(),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,d={key:!0,ref:!0,__self:!0,__source:!0};function p(m,_,x){var b,y={},C=null,A=null;x!==void 0&&(C=""+x),_.key!==void 0&&(C=""+_.key),_.ref!==void 0&&(A=_.ref);for(b in _)l.call(_,b)&&!d.hasOwnProperty(b)&&(y[b]=_[b]);if(m&&m.defaultProps)for(b in _=m.defaultProps,_)y[b]===void 0&&(y[b]=_[b]);return{$$typeof:s,type:m,key:C,ref:A,props:y,_owner:c.current}}return kl.Fragment=r,kl.jsx=p,kl.jsxs=p,kl}var ef;function Wp(){return ef||(ef=1,wu.exports=Up()),wu.exports}var e=Wp(),f=md();const Wt=qp(f);var Qo={},ku={exports:{}},Wn={},Su={exports:{}},Nu={};/**
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 tf;function Hp(){return tf||(tf=1,(function(a){function s(z,V){var U=z.length;z.push(V);e:for(;0<U;){var w=U-1>>>1,N=z[w];if(0<c(N,V))z[w]=V,z[U]=N,U=w;else break e}}function r(z){return z.length===0?null:z[0]}function l(z){if(z.length===0)return null;var V=z[0],U=z.pop();if(U!==V){z[0]=U;e:for(var w=0,N=z.length,Z=N>>>1;w<Z;){var pe=2*(w+1)-1,oe=z[pe],I=pe+1,be=z[I];if(0>c(oe,U))I<N&&0>c(be,oe)?(z[w]=be,z[I]=U,w=I):(z[w]=oe,z[pe]=U,w=pe);else if(I<N&&0>c(be,U))z[w]=be,z[I]=U,w=I;else break e}}return V}function c(z,V){var U=z.sortIndex-V.sortIndex;return U!==0?U:z.id-V.id}if(typeof performance=="object"&&typeof performance.now=="function"){var d=performance;a.unstable_now=function(){return d.now()}}else{var p=Date,m=p.now();a.unstable_now=function(){return p.now()-m}}var _=[],x=[],b=1,y=null,C=3,A=!1,E=!1,$=!1,L=typeof setTimeout=="function"?setTimeout:null,q=typeof clearTimeout=="function"?clearTimeout:null,O=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function D(z){for(var V=r(x);V!==null;){if(V.callback===null)l(x);else if(V.startTime<=z)l(x),V.sortIndex=V.expirationTime,s(_,V);else break;V=r(x)}}function K(z){if($=!1,D(z),!E)if(r(_)!==null)E=!0,W(T);else{var V=r(x);V!==null&&Y(K,V.startTime-z)}}function T(z,V){E=!1,$&&($=!1,q(re),re=-1),A=!0;var U=C;try{for(D(V),y=r(_);y!==null&&(!(y.expirationTime>V)||z&&!Ce());){var w=y.callback;if(typeof w=="function"){y.callback=null,C=y.priorityLevel;var N=w(y.expirationTime<=V);V=a.unstable_now(),typeof N=="function"?y.callback=N:y===r(_)&&l(_),D(V)}else l(_);y=r(_)}if(y!==null)var Z=!0;else{var pe=r(x);pe!==null&&Y(K,pe.startTime-V),Z=!1}return Z}finally{y=null,C=U,A=!1}}var te=!1,ue=null,re=-1,Te=5,je=-1;function Ce(){return!(a.unstable_now()-je<Te)}function xe(){if(ue!==null){var z=a.unstable_now();je=z;var V=!0;try{V=ue(!0,z)}finally{V?J():(te=!1,ue=null)}}else te=!1}var J;if(typeof O=="function")J=function(){O(xe)};else if(typeof MessageChannel<"u"){var ne=new MessageChannel,ve=ne.port2;ne.port1.onmessage=xe,J=function(){ve.postMessage(null)}}else J=function(){L(xe,0)};function W(z){ue=z,te||(te=!0,J())}function Y(z,V){re=L(function(){z(a.unstable_now())},V)}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(z){z.callback=null},a.unstable_continueExecution=function(){E||A||(E=!0,W(T))},a.unstable_forceFrameRate=function(z){0>z||125<z?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):Te=0<z?Math.floor(1e3/z):5},a.unstable_getCurrentPriorityLevel=function(){return C},a.unstable_getFirstCallbackNode=function(){return r(_)},a.unstable_next=function(z){switch(C){case 1:case 2:case 3:var V=3;break;default:V=C}var U=C;C=V;try{return z()}finally{C=U}},a.unstable_pauseExecution=function(){},a.unstable_requestPaint=function(){},a.unstable_runWithPriority=function(z,V){switch(z){case 1:case 2:case 3:case 4:case 5:break;default:z=3}var U=C;C=z;try{return V()}finally{C=U}},a.unstable_scheduleCallback=function(z,V,U){var w=a.unstable_now();switch(typeof U=="object"&&U!==null?(U=U.delay,U=typeof U=="number"&&0<U?w+U:w):U=w,z){case 1:var N=-1;break;case 2:N=250;break;case 5:N=1073741823;break;case 4:N=1e4;break;default:N=5e3}return N=U+N,z={id:b++,callback:V,priorityLevel:z,startTime:U,expirationTime:N,sortIndex:-1},U>w?(z.sortIndex=U,s(x,z),r(_)===null&&z===r(x)&&($?(q(re),re=-1):$=!0,Y(K,U-w))):(z.sortIndex=N,s(_,z),E||A||(E=!0,W(T))),z},a.unstable_shouldYield=Ce,a.unstable_wrapCallback=function(z){var V=C;return function(){var U=C;C=V;try{return z.apply(this,arguments)}finally{C=U}}}})(Nu)),Nu}var nf;function Vp(){return nf||(nf=1,Su.exports=Hp()),Su.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 sf;function Gp(){if(sf)return Wn;sf=1;var a=md(),s=Vp();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 d(t,n){p(t,n),p(t+"Capture",n)}function p(t,n){for(c[t]=n,t=0;t<n.length;t++)l.add(n[t])}var m=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),_=Object.prototype.hasOwnProperty,x=/^[: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]*$/,b={},y={};function C(t){return _.call(y,t)?!0:_.call(b,t)?!1:x.test(t)?y[t]=!0:(b[t]=!0,!1)}function A(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 E(t,n,i,o){if(n===null||typeof n>"u"||A(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,n,i,o,h,g,j){this.acceptsBooleans=n===2||n===3||n===4,this.attributeName=o,this.attributeNamespace=h,this.mustUseProperty=i,this.propertyName=t,this.type=n,this.sanitizeURL=g,this.removeEmptyString=j}var L={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){L[t]=new $(t,0,!1,t,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var n=t[0];L[n]=new $(n,1,!1,t[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(t){L[t]=new $(t,2,!1,t.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){L[t]=new $(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){L[t]=new $(t,3,!1,t.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(t){L[t]=new $(t,3,!0,t,null,!1,!1)}),["capture","download"].forEach(function(t){L[t]=new $(t,4,!1,t,null,!1,!1)}),["cols","rows","size","span"].forEach(function(t){L[t]=new $(t,6,!1,t,null,!1,!1)}),["rowSpan","start"].forEach(function(t){L[t]=new $(t,5,!1,t.toLowerCase(),null,!1,!1)});var q=/[\-:]([a-z])/g;function O(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(q,O);L[n]=new $(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(q,O);L[n]=new $(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(q,O);L[n]=new $(n,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(t){L[t]=new $(t,1,!1,t.toLowerCase(),null,!1,!1)}),L.xlinkHref=new $("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(t){L[t]=new $(t,1,!1,t.toLowerCase(),null,!0,!0)});function D(t,n,i,o){var h=L.hasOwnProperty(n)?L[n]:null;(h!==null?h.type!==0:o||!(2<n.length)||n[0]!=="o"&&n[0]!=="O"||n[1]!=="n"&&n[1]!=="N")&&(E(n,i,h,o)&&(i=null),o||h===null?C(n)&&(i===null?t.removeAttribute(n):t.setAttribute(n,""+i)):h.mustUseProperty?t[h.propertyName]=i===null?h.type===3?!1:"":i:(n=h.attributeName,o=h.attributeNamespace,i===null?t.removeAttribute(n):(h=h.type,i=h===3||h===4&&i===!0?"":""+i,o?t.setAttributeNS(o,n,i):t.setAttribute(n,i))))}var K=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,T=Symbol.for("react.element"),te=Symbol.for("react.portal"),ue=Symbol.for("react.fragment"),re=Symbol.for("react.strict_mode"),Te=Symbol.for("react.profiler"),je=Symbol.for("react.provider"),Ce=Symbol.for("react.context"),xe=Symbol.for("react.forward_ref"),J=Symbol.for("react.suspense"),ne=Symbol.for("react.suspense_list"),ve=Symbol.for("react.memo"),W=Symbol.for("react.lazy"),Y=Symbol.for("react.offscreen"),z=Symbol.iterator;function V(t){return t===null||typeof t!="object"?null:(t=z&&t[z]||t["@@iterator"],typeof t=="function"?t:null)}var U=Object.assign,w;function N(t){if(w===void 0)try{throw Error()}catch(i){var n=i.stack.trim().match(/\n( *(at )?)/);w=n&&n[1]||""}return`
34
+ `+w+t}var Z=!1;function pe(t,n){if(!t||Z)return"";Z=!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(me){var o=me}Reflect.construct(t,[],n)}else{try{n.call()}catch(me){o=me}t.call(n.prototype)}else{try{throw Error()}catch(me){o=me}t()}}catch(me){if(me&&o&&typeof me.stack=="string"){for(var h=me.stack.split(`
35
+ `),g=o.stack.split(`
36
+ `),j=h.length-1,P=g.length-1;1<=j&&0<=P&&h[j]!==g[P];)P--;for(;1<=j&&0<=P;j--,P--)if(h[j]!==g[P]){if(j!==1||P!==1)do if(j--,P--,0>P||h[j]!==g[P]){var B=`
37
+ `+h[j].replace(" at new "," at ");return t.displayName&&B.includes("<anonymous>")&&(B=B.replace("<anonymous>",t.displayName)),B}while(1<=j&&0<=P);break}}}finally{Z=!1,Error.prepareStackTrace=i}return(t=t?t.displayName||t.name:"")?N(t):""}function oe(t){switch(t.tag){case 5:return N(t.type);case 16:return N("Lazy");case 13:return N("Suspense");case 19:return N("SuspenseList");case 0:case 2:case 15:return t=pe(t.type,!1),t;case 11:return t=pe(t.type.render,!1),t;case 1:return t=pe(t.type,!0),t;default:return""}}function I(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 ue:return"Fragment";case te:return"Portal";case Te:return"Profiler";case re:return"StrictMode";case J:return"Suspense";case ne:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case Ce:return(t.displayName||"Context")+".Consumer";case je:return(t._context.displayName||"Context")+".Provider";case xe:var n=t.render;return t=t.displayName,t||(t=n.displayName||n.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case ve:return n=t.displayName||null,n!==null?n:I(t.type)||"Memo";case W:n=t._payload,t=t._init;try{return I(t(n))}catch{}}return null}function be(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 I(n);case 8:return n===re?"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 Re(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function qe(t){var n=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function Oe(t){var n=qe(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 h=i.get,g=i.set;return Object.defineProperty(t,n,{configurable:!0,get:function(){return h.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 ut(t){t._valueTracker||(t._valueTracker=Oe(t))}function he(t){if(!t)return!1;var n=t._valueTracker;if(!n)return!0;var i=n.getValue(),o="";return t&&(o=qe(t)?t.checked?"true":"false":t.value),t=o,t!==i?(n.setValue(t),!0):!1}function Fe(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 Le(t,n){var i=n.checked;return U({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i??t._wrapperState.initialChecked})}function Ge(t,n){var i=n.defaultValue==null?"":n.defaultValue,o=n.checked!=null?n.checked:n.defaultChecked;i=Re(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 de(t,n){n=n.checked,n!=null&&D(t,"checked",n,!1)}function H(t,n){de(t,n);var i=Re(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")?we(t,n.type,i):n.hasOwnProperty("defaultValue")&&we(t,n.type,Re(n.defaultValue)),n.checked==null&&n.defaultChecked!=null&&(t.defaultChecked=!!n.defaultChecked)}function fe(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 we(t,n,i){(n!=="number"||Fe(t.ownerDocument)!==t)&&(i==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+i&&(t.defaultValue=""+i))}var X=Array.isArray;function Q(t,n,i,o){if(t=t.options,n){n={};for(var h=0;h<i.length;h++)n["$"+i[h]]=!0;for(i=0;i<t.length;i++)h=n.hasOwnProperty("$"+t[i].value),t[i].selected!==h&&(t[i].selected=h),h&&o&&(t[i].defaultSelected=!0)}else{for(i=""+Re(i),n=null,h=0;h<t.length;h++){if(t[h].value===i){t[h].selected=!0,o&&(t[h].defaultSelected=!0);return}n!==null||t[h].disabled||(n=t[h])}n!==null&&(n.selected=!0)}}function _e(t,n){if(n.dangerouslySetInnerHTML!=null)throw Error(r(91));return U({},n,{value:void 0,defaultValue:void 0,children:""+t._wrapperState.initialValue})}function Ie(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(X(i)){if(1<i.length)throw Error(r(93));i=i[0]}n=i}n==null&&(n=""),i=n}t._wrapperState={initialValue:Re(i)}}function ot(t,n){var i=Re(n.value),o=Re(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 ce(t){var n=t.textContent;n===t._wrapperState.initialValue&&n!==""&&n!==null&&(t.value=n)}function ke(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 Be(t,n){return t==null||t==="http://www.w3.org/1999/xhtml"?ke(n):t==="http://www.w3.org/2000/svg"&&n==="foreignObject"?"http://www.w3.org/1999/xhtml":t}var $e,ze=(function(t){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(n,i,o,h){MSApp.execUnsafeLocalFunction(function(){return t(n,i,o,h)})}:t})(function(t,n){if(t.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in t)t.innerHTML=n;else{for($e=$e||document.createElement("div"),$e.innerHTML="<svg>"+n.valueOf().toString()+"</svg>",n=$e.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;n.firstChild;)t.appendChild(n.firstChild)}});function ee(t,n){if(n){var i=t.firstChild;if(i&&i===t.lastChild&&i.nodeType===3){i.nodeValue=n;return}}t.textContent=n}var M={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},ie=["Webkit","ms","Moz","O"];Object.keys(M).forEach(function(t){ie.forEach(function(n){n=n+t.charAt(0).toUpperCase()+t.substring(1),M[n]=M[t]})});function Ke(t,n,i){return n==null||typeof n=="boolean"||n===""?"":i||typeof n!="number"||n===0||M.hasOwnProperty(t)&&M[t]?(""+n).trim():n+"px"}function et(t,n){t=t.style;for(var i in n)if(n.hasOwnProperty(i)){var o=i.indexOf("--")===0,h=Ke(i,n[i],o);i==="float"&&(i="cssFloat"),o?t.setProperty(i,h):t[i]=h}}var rt=U({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 mt(t,n){if(n){if(rt[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 ft(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 Ee=null;function nt(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var ht=null,zt=null,wt=null;function tn(t){if(t=jr(t)){if(typeof ht!="function")throw Error(r(280));var n=t.stateNode;n&&(n=ci(n),ht(t.stateNode,t.type,n))}}function ge(t){zt?wt?wt.push(t):wt=[t]:zt=t}function Se(){if(zt){var t=zt,n=wt;if(wt=zt=null,tn(t),n)for(t=0;t<n.length;t++)tn(n[t])}}function Ye(t,n){return t(n)}function vt(){}var _t=!1;function jt(t,n,i){if(_t)return t(n,i);_t=!0;try{return Ye(t,n,i)}finally{_t=!1,(zt!==null||wt!==null)&&(vt(),Se())}}function it(t,n){var i=t.stateNode;if(i===null)return null;var o=ci(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 Cn=!1;if(m)try{var Cs={};Object.defineProperty(Cs,"passive",{get:function(){Cn=!0}}),window.addEventListener("test",Cs,Cs),window.removeEventListener("test",Cs,Cs)}catch{Cn=!1}function Xa(t,n,i,o,h,g,j,P,B){var me=Array.prototype.slice.call(arguments,3);try{n.apply(i,me)}catch(Ae){this.onError(Ae)}}var $s=!1,os=null,nn=!1,Vs=null,Gs={onError:function(t){$s=!0,os=t}};function Es(t,n,i,o,h,g,j,P,B){$s=!1,os=null,Xa.apply(Gs,arguments)}function $i(t,n,i,o,h,g,j,P,B){if(Es.apply(this,arguments),$s){if($s){var me=os;$s=!1,os=null}else throw Error(r(198));nn||(nn=!0,Vs=me)}}function Ts(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 Or(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 dt(t){if(Ts(t)!==t)throw Error(r(188))}function Ht(t){var n=t.alternate;if(!n){if(n=Ts(t),n===null)throw Error(r(188));return n!==t?null:t}for(var i=t,o=n;;){var h=i.return;if(h===null)break;var g=h.alternate;if(g===null){if(o=h.return,o!==null){i=o;continue}break}if(h.child===g.child){for(g=h.child;g;){if(g===i)return dt(h),t;if(g===o)return dt(h),n;g=g.sibling}throw Error(r(188))}if(i.return!==o.return)i=h,o=g;else{for(var j=!1,P=h.child;P;){if(P===i){j=!0,i=h,o=g;break}if(P===o){j=!0,o=h,i=g;break}P=P.sibling}if(!j){for(P=g.child;P;){if(P===i){j=!0,i=g,o=h;break}if(P===o){j=!0,o=g,i=h;break}P=P.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 Za(t){return t=Ht(t),t!==null?Mt(t):null}function Mt(t){if(t.tag===5||t.tag===6)return t;for(t=t.child;t!==null;){var n=Mt(t);if(n!==null)return n;t=t.sibling}return null}var er=s.unstable_scheduleCallback,Ei=s.unstable_cancelCallback,Wl=s.unstable_shouldYield,Ti=s.unstable_requestPaint,It=s.unstable_now,Dr=s.unstable_getCurrentPriorityLevel,Fr=s.unstable_ImmediatePriority,tr=s.unstable_UserBlockingPriority,Ks=s.unstable_NormalPriority,Hl=s.unstable_LowPriority,qr=s.unstable_IdlePriority,cs=null,hn=null;function Br(t){if(hn&&typeof hn.onCommitFiberRoot=="function")try{hn.onCommitFiberRoot(cs,t,void 0,(t.current.flags&128)===128)}catch{}}var pn=Math.clz32?Math.clz32:Gl,Vl=Math.log,pa=Math.LN2;function Gl(t){return t>>>=0,t===0?32:31-(Vl(t)/pa|0)|0}var _a=64,Ur=4194304;function nr(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 bn(t,n){var i=t.pendingLanes;if(i===0)return 0;var o=0,h=t.suspendedLanes,g=t.pingedLanes,j=i&268435455;if(j!==0){var P=j&~h;P!==0?o=nr(P):(g&=j,g!==0&&(o=nr(g)))}else j=i&~h,j!==0?o=nr(j):g!==0&&(o=nr(g));if(o===0)return 0;if(n!==0&&n!==o&&(n&h)===0&&(h=o&-o,g=n&-n,h>=g||h===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-pn(n),h=1<<i,o|=t[i],n&=~h;return o}function Qs(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 Wr(t,n){for(var i=t.suspendedLanes,o=t.pingedLanes,h=t.expirationTimes,g=t.pendingLanes;0<g;){var j=31-pn(g),P=1<<j,B=h[j];B===-1?((P&i)===0||(P&o)!==0)&&(h[j]=Qs(P,n)):B<=n&&(t.expiredLanes|=P),g&=~P}}function As(t){return t=t.pendingLanes&-1073741825,t!==0?t:t&1073741824?1073741824:0}function Vt(){var t=_a;return _a<<=1,(_a&4194240)===0&&(_a=64),t}function Xt(t){for(var n=[],i=0;31>i;i++)n.push(t);return n}function Rs(t,n,i){t.pendingLanes|=n,n!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,n=31-pn(n),t[n]=i}function ga(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 h=31-pn(i),g=1<<h;n[h]=0,o[h]=-1,t[h]=-1,i&=~g}}function Ls(t,n){var i=t.entangledLanes|=n;for(t=t.entanglements;i;){var o=31-pn(i),h=1<<o;h&n|t[o]&n&&(t[o]|=n),i&=~h}}var kt=0;function Gt(t){return t&=-t,1<t?4<t?(t&268435455)!==0?16:536870912:4:1}var us,Hr,zn,Vr,Ai,sr=!1,ar=[],ds=null,Kn=null,$n=null,Ms=new Map,on=new Map,_n=[],dc="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 va(t,n){switch(t){case"focusin":case"focusout":ds=null;break;case"dragenter":case"dragleave":Kn=null;break;case"mouseover":case"mouseout":$n=null;break;case"pointerover":case"pointerout":Ms.delete(n.pointerId);break;case"gotpointercapture":case"lostpointercapture":on.delete(n.pointerId)}}function Et(t,n,i,o,h,g){return t===null||t.nativeEvent!==g?(t={blockedOn:n,domEventName:i,eventSystemFlags:o,nativeEvent:g,targetContainers:[h]},n!==null&&(n=jr(n),n!==null&&Hr(n)),t):(t.eventSystemFlags|=o,n=t.targetContainers,h!==null&&n.indexOf(h)===-1&&n.push(h),t)}function Qn(t,n,i,o,h){switch(n){case"focusin":return ds=Et(ds,t,n,i,o,h),!0;case"dragenter":return Kn=Et(Kn,t,n,i,o,h),!0;case"mouseover":return $n=Et($n,t,n,i,o,h),!0;case"pointerover":var g=h.pointerId;return Ms.set(g,Et(Ms.get(g)||null,t,n,i,o,h)),!0;case"gotpointercapture":return g=h.pointerId,on.set(g,Et(on.get(g)||null,t,n,i,o,h)),!0}return!1}function Pn(t){var n=ys(t.target);if(n!==null){var i=Ts(n);if(i!==null){if(n=i.tag,n===13){if(n=Or(i),n!==null){t.blockedOn=n,Ai(t.priority,function(){zn(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 ya(t){if(t.blockedOn!==null)return!1;for(var n=t.targetContainers;0<n.length;){var i=or(t.domEventName,t.eventSystemFlags,n[0],t.nativeEvent);if(i===null){i=t.nativeEvent;var o=new i.constructor(i.type,i);Ee=o,i.target.dispatchEvent(o),Ee=null}else return n=jr(i),n!==null&&Hr(n),t.blockedOn=i,!1;n.shift()}return!0}function Gr(t,n,i){ya(t)&&i.delete(n)}function Kl(){sr=!1,ds!==null&&ya(ds)&&(ds=null),Kn!==null&&ya(Kn)&&(Kn=null),$n!==null&&ya($n)&&($n=null),Ms.forEach(Gr),on.forEach(Gr)}function wn(t,n){t.blockedOn===n&&(t.blockedOn=null,sr||(sr=!0,s.unstable_scheduleCallback(s.unstable_NormalPriority,Kl)))}function xa(t){function n(h){return wn(h,t)}if(0<ar.length){wn(ar[0],t);for(var i=1;i<ar.length;i++){var o=ar[i];o.blockedOn===t&&(o.blockedOn=null)}}for(ds!==null&&wn(ds,t),Kn!==null&&wn(Kn,t),$n!==null&&wn($n,t),Ms.forEach(n),on.forEach(n),i=0;i<_n.length;i++)o=_n[i],o.blockedOn===t&&(o.blockedOn=null);for(;0<_n.length&&(i=_n[0],i.blockedOn===null);)Pn(i),i.blockedOn===null&&_n.shift()}var ms=K.ReactCurrentBatchConfig,rr=!0;function Ri(t,n,i,o){var h=kt,g=ms.transition;ms.transition=null;try{kt=1,Kr(t,n,i,o)}finally{kt=h,ms.transition=g}}function ir(t,n,i,o){var h=kt,g=ms.transition;ms.transition=null;try{kt=4,Kr(t,n,i,o)}finally{kt=h,ms.transition=g}}function Kr(t,n,i,o){if(rr){var h=or(t,n,i,o);if(h===null)yr(t,n,o,lr,i),va(t,o);else if(Qn(h,t,n,i,o))o.stopPropagation();else if(va(t,o),n&4&&-1<dc.indexOf(t)){for(;h!==null;){var g=jr(h);if(g!==null&&us(g),g=or(t,n,i,o),g===null&&yr(t,n,o,lr,i),g===h)break;h=g}h!==null&&o.stopPropagation()}else yr(t,n,o,null,i)}}var lr=null;function or(t,n,i,o){if(lr=null,t=nt(o),t=ys(t),t!==null)if(n=Ts(t),n===null)t=null;else if(i=n.tag,i===13){if(t=Or(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 lr=t,null}function Li(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(Dr()){case Fr:return 1;case tr:return 4;case Ks:case Hl:return 16;case qr:return 536870912;default:return 16}default:return 16}}var In=null,fs=null,Js=null;function Qr(){if(Js)return Js;var t,n=fs,i=n.length,o,h="value"in In?In.value:In.textContent,g=h.length;for(t=0;t<i&&n[t]===h[t];t++);var j=i-t;for(o=1;o<=j&&n[i-o]===h[g-o];o++);return Js=h.slice(t,1<o?1-o:void 0)}function ba(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 wa(){return!0}function Ys(){return!1}function sn(t){function n(i,o,h,g,j){this._reactName=i,this._targetInst=h,this.type=o,this.nativeEvent=g,this.target=j,this.currentTarget=null;for(var P in t)t.hasOwnProperty(P)&&(i=t[P],this[P]=i?i(g):g[P]);return this.isDefaultPrevented=(g.defaultPrevented!=null?g.defaultPrevented:g.returnValue===!1)?wa:Ys,this.isPropagationStopped=Ys,this}return U(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=wa)},stopPropagation:function(){var i=this.nativeEvent;i&&(i.stopPropagation?i.stopPropagation():typeof i.cancelBubble!="unknown"&&(i.cancelBubble=!0),this.isPropagationStopped=wa)},persist:function(){},isPersistent:wa}),n}var ja={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Kt=sn(ja),zs=U({},ja,{view:0,detail:0}),Mi=sn(zs),Jr,cr,Xs,ka=U({},zs,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:ur,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!==Xs&&(Xs&&t.type==="mousemove"?(Jr=t.screenX-Xs.screenX,cr=t.screenY-Xs.screenY):cr=Jr=0,Xs=t),Jr)},movementY:function(t){return"movementY"in t?t.movementY:cr}}),zi=sn(ka),Pi=U({},ka,{dataTransfer:0}),Ql=sn(Pi),Jl=U({},zs,{relatedTarget:0}),Yr=sn(Jl),Yl=U({},ja,{animationName:0,elapsedTime:0,pseudoElement:0}),Ii=sn(Yl),Xl=U({},ja,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),Oi=sn(Xl),Di=U({},ja,{data:0}),Fi=sn(Di),On={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Ps={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"},Is={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function qi(t){var n=this.nativeEvent;return n.getModifierState?n.getModifierState(t):(t=Is[t])?!!n[t]:!1}function ur(){return qi}var Bi=U({},zs,{key:function(t){if(t.key){var n=On[t.key]||t.key;if(n!=="Unidentified")return n}return t.type==="keypress"?(t=ba(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?Ps[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:ur,charCode:function(t){return t.type==="keypress"?ba(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?ba(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),mc=sn(Bi),Sa=U({},ka,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Na=sn(Sa),hs=U({},zs,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:ur}),Zs=sn(hs),Zl=U({},ja,{propertyName:0,elapsedTime:0,pseudoElement:0}),eo=sn(Zl),to=U({},ka,{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}),fc=sn(to),hc=[9,13,27,32],dr=m&&"CompositionEvent"in window,ns=null;m&&"documentMode"in document&&(ns=document.documentMode);var Ui=m&&"TextEvent"in window&&!ns,Wi=m&&(!dr||ns&&8<ns&&11>=ns),Xr=" ",Hi=!1;function ea(t,n){switch(t){case"keyup":return hc.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Zr(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var Ca=!1;function mr(t,n){switch(t){case"compositionend":return Zr(n);case"keypress":return n.which!==32?null:(Hi=!0,Xr);case"textInput":return t=n.data,t===Xr&&Hi?null:t;default:return null}}function Vi(t,n){if(Ca)return t==="compositionend"||!dr&&ea(t,n)?(t=Qr(),Js=fs=In=null,Ca=!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 Wi&&n.locale!=="ko"?null:n.data;default:return null}}var no={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 Gi(t){var n=t&&t.nodeName&&t.nodeName.toLowerCase();return n==="input"?!!no[t.type]:n==="textarea"}function Ki(t,n,i,o){ge(o),n=li(n,"onChange"),0<n.length&&(i=new Kt("onChange","change",null,i,o),t.push({event:i,listeners:n}))}var fr=null,Jn=null;function hr(t){Ea(t,0)}function ei(t){var n=Pa(t);if(he(n))return t}function ti(t,n){if(t==="change")return n}var ni=!1;if(m){var Qi;if(m){var $a="oninput"in document;if(!$a){var pr=document.createElement("div");pr.setAttribute("oninput","return;"),$a=typeof pr.oninput=="function"}Qi=$a}else Qi=!1;ni=Qi&&(!document.documentMode||9<document.documentMode)}function so(){fr&&(fr.detachEvent("onpropertychange",ao),Jn=fr=null)}function ao(t){if(t.propertyName==="value"&&ei(Jn)){var n=[];Ki(n,Jn,t,nt(t)),jt(hr,n)}}function pc(t,n,i){t==="focusin"?(so(),fr=n,Jn=i,fr.attachEvent("onpropertychange",ao)):t==="focusout"&&so()}function ro(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return ei(Jn)}function _c(t,n){if(t==="click")return ei(n)}function io(t,n){if(t==="input"||t==="change")return ei(n)}function gc(t,n){return t===n&&(t!==0||1/t===1/n)||t!==t&&n!==n}var Yn=typeof Object.is=="function"?Object.is:gc;function ta(t,n){if(Yn(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 h=i[o];if(!_.call(n,h)||!Yn(t[h],n[h]))return!1}return!0}function lo(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function Ji(t,n){var i=lo(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=lo(i)}}function Yi(t,n){return t&&n?t===n?!0:t&&t.nodeType===3?!1:n&&n.nodeType===3?Yi(t,n.parentNode):"contains"in t?t.contains(n):t.compareDocumentPosition?!!(t.compareDocumentPosition(n)&16):!1:!1}function oo(){for(var t=window,n=Fe();n instanceof t.HTMLIFrameElement;){try{var i=typeof n.contentWindow.location.href=="string"}catch{i=!1}if(i)t=n.contentWindow;else break;n=Fe(t.document)}return n}function si(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 ai(t){var n=oo(),i=t.focusedElem,o=t.selectionRange;if(n!==i&&i&&i.ownerDocument&&Yi(i.ownerDocument.documentElement,i)){if(o!==null&&si(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 h=i.textContent.length,g=Math.min(o.start,h);o=o.end===void 0?g:Math.min(o.end,h),!t.extend&&g>o&&(h=o,o=g,g=h),h=Ji(i,g);var j=Ji(i,o);h&&j&&(t.rangeCount!==1||t.anchorNode!==h.node||t.anchorOffset!==h.offset||t.focusNode!==j.node||t.focusOffset!==j.offset)&&(n=n.createRange(),n.setStart(h.node,h.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 co=m&&"documentMode"in document&&11>=document.documentMode,ps=null,ri=null,_r=null,Xi=!1;function Zi(t,n,i){var o=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;Xi||ps==null||ps!==Fe(o)||(o=ps,"selectionStart"in o&&si(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}),_r&&ta(_r,o)||(_r=o,o=li(ri,"onSelect"),0<o.length&&(n=new Kt("onSelect","select",null,n,i),t.push({event:n,listeners:o}),n.target=ps)))}function ii(t,n){var i={};return i[t.toLowerCase()]=n.toLowerCase(),i["Webkit"+t]="webkit"+n,i["Moz"+t]="moz"+n,i}var na={animationend:ii("Animation","AnimationEnd"),animationiteration:ii("Animation","AnimationIteration"),animationstart:ii("Animation","AnimationStart"),transitionend:ii("Transition","TransitionEnd")},el={},tl={};m&&(tl=document.createElement("div").style,"AnimationEvent"in window||(delete na.animationend.animation,delete na.animationiteration.animation,delete na.animationstart.animation),"TransitionEvent"in window||delete na.transitionend.transition);function gr(t){if(el[t])return el[t];if(!na[t])return t;var n=na[t],i;for(i in n)if(n.hasOwnProperty(i)&&i in tl)return el[t]=n[i];return t}var uo=gr("animationend"),mo=gr("animationiteration"),nl=gr("animationstart"),sl=gr("transitionend"),fo=new Map,En="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 yt(t,n){fo.set(t,n),d(n,[t])}for(var Qt=0;Qt<En.length;Qt++){var vr=En[Qt],vc=vr.toLowerCase(),Os=vr[0].toUpperCase()+vr.slice(1);yt(vc,"on"+Os)}yt(uo,"onAnimationEnd"),yt(mo,"onAnimationIteration"),yt(nl,"onAnimationStart"),yt("dblclick","onDoubleClick"),yt("focusin","onFocus"),yt("focusout","onBlur"),yt(sl,"onTransitionEnd"),p("onMouseEnter",["mouseout","mouseover"]),p("onMouseLeave",["mouseout","mouseover"]),p("onPointerEnter",["pointerout","pointerover"]),p("onPointerLeave",["pointerout","pointerover"]),d("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),d("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),d("onBeforeInput",["compositionend","keypress","textInput","paste"]),d("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),d("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),d("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Dn="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(" "),_s=new Set("cancel close invalid load scroll toggle".split(" ").concat(Dn));function sa(t,n,i){var o=t.type||"unknown-event";t.currentTarget=i,$i(o,n,void 0,t),t.currentTarget=null}function Ea(t,n){n=(n&4)!==0;for(var i=0;i<t.length;i++){var o=t[i],h=o.event;o=o.listeners;e:{var g=void 0;if(n)for(var j=o.length-1;0<=j;j--){var P=o[j],B=P.instance,me=P.currentTarget;if(P=P.listener,B!==g&&h.isPropagationStopped())break e;sa(h,P,me),g=B}else for(j=0;j<o.length;j++){if(P=o[j],B=P.instance,me=P.currentTarget,P=P.listener,B!==g&&h.isPropagationStopped())break e;sa(h,P,me),g=B}}}if(nn)throw t=Vs,nn=!1,Vs=null,t}function Ct(t,n){var i=n[ol];i===void 0&&(i=n[ol]=new Set);var o=t+"__bubble";i.has(o)||(al(n,t,2,!1),i.add(o))}function aa(t,n,i){var o=0;n&&(o|=4),al(i,t,o,n)}var Ta="_reactListening"+Math.random().toString(36).slice(2);function Aa(t){if(!t[Ta]){t[Ta]=!0,l.forEach(function(i){i!=="selectionchange"&&(_s.has(i)||aa(i,!1,t),aa(i,!0,t))});var n=t.nodeType===9?t:t.ownerDocument;n===null||n[Ta]||(n[Ta]=!0,aa("selectionchange",!1,n))}}function al(t,n,i,o){switch(Li(n)){case 1:var h=Ri;break;case 4:h=ir;break;default:h=Kr}i=h.bind(null,n,i,t),h=void 0,!Cn||n!=="touchstart"&&n!=="touchmove"&&n!=="wheel"||(h=!0),o?h!==void 0?t.addEventListener(n,i,{capture:!0,passive:h}):t.addEventListener(n,i,!0):h!==void 0?t.addEventListener(n,i,{passive:h}):t.addEventListener(n,i,!1)}function yr(t,n,i,o,h){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 P=o.stateNode.containerInfo;if(P===h||P.nodeType===8&&P.parentNode===h)break;if(j===4)for(j=o.return;j!==null;){var B=j.tag;if((B===3||B===4)&&(B=j.stateNode.containerInfo,B===h||B.nodeType===8&&B.parentNode===h))return;j=j.return}for(;P!==null;){if(j=ys(P),j===null)return;if(B=j.tag,B===5||B===6){o=g=j;continue e}P=P.parentNode}}o=o.return}jt(function(){var me=g,Ae=nt(i),Me=[];e:{var Ne=fo.get(t);if(Ne!==void 0){var He=Kt,Je=t;switch(t){case"keypress":if(ba(i)===0)break e;case"keydown":case"keyup":He=mc;break;case"focusin":Je="focus",He=Yr;break;case"focusout":Je="blur",He=Yr;break;case"beforeblur":case"afterblur":He=Yr;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":He=zi;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":He=Ql;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":He=Zs;break;case uo:case mo:case nl:He=Ii;break;case sl:He=eo;break;case"scroll":He=Mi;break;case"wheel":He=fc;break;case"copy":case"cut":case"paste":He=Oi;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":He=Na}var Xe=(n&4)!==0,Yt=!Xe&&t==="scroll",ae=Xe?Ne!==null?Ne+"Capture":null:Ne;Xe=[];for(var G=me,le;G!==null;){le=G;var De=le.stateNode;if(le.tag===5&&De!==null&&(le=De,ae!==null&&(De=it(G,ae),De!=null&&Xe.push(xr(G,De,le)))),Yt)break;G=G.return}0<Xe.length&&(Ne=new He(Ne,Je,null,i,Ae),Me.push({event:Ne,listeners:Xe}))}}if((n&7)===0){e:{if(Ne=t==="mouseover"||t==="pointerover",He=t==="mouseout"||t==="pointerout",Ne&&i!==Ee&&(Je=i.relatedTarget||i.fromElement)&&(ys(Je)||Je[vs]))break e;if((He||Ne)&&(Ne=Ae.window===Ae?Ae:(Ne=Ae.ownerDocument)?Ne.defaultView||Ne.parentWindow:window,He?(Je=i.relatedTarget||i.toElement,He=me,Je=Je?ys(Je):null,Je!==null&&(Yt=Ts(Je),Je!==Yt||Je.tag!==5&&Je.tag!==6)&&(Je=null)):(He=null,Je=me),He!==Je)){if(Xe=zi,De="onMouseLeave",ae="onMouseEnter",G="mouse",(t==="pointerout"||t==="pointerover")&&(Xe=Na,De="onPointerLeave",ae="onPointerEnter",G="pointer"),Yt=He==null?Ne:Pa(He),le=Je==null?Ne:Pa(Je),Ne=new Xe(De,G+"leave",He,i,Ae),Ne.target=Yt,Ne.relatedTarget=le,De=null,ys(Ae)===me&&(Xe=new Xe(ae,G+"enter",Je,i,Ae),Xe.target=le,Xe.relatedTarget=Yt,De=Xe),Yt=De,He&&Je)t:{for(Xe=He,ae=Je,G=0,le=Xe;le;le=ra(le))G++;for(le=0,De=ae;De;De=ra(De))le++;for(;0<G-le;)Xe=ra(Xe),G--;for(;0<le-G;)ae=ra(ae),le--;for(;G--;){if(Xe===ae||ae!==null&&Xe===ae.alternate)break t;Xe=ra(Xe),ae=ra(ae)}Xe=null}else Xe=null;He!==null&&rl(Me,Ne,He,Xe,!1),Je!==null&&Yt!==null&&rl(Me,Yt,Je,Xe,!0)}}e:{if(Ne=me?Pa(me):window,He=Ne.nodeName&&Ne.nodeName.toLowerCase(),He==="select"||He==="input"&&Ne.type==="file")var Ze=ti;else if(Gi(Ne))if(ni)Ze=io;else{Ze=ro;var st=pc}else(He=Ne.nodeName)&&He.toLowerCase()==="input"&&(Ne.type==="checkbox"||Ne.type==="radio")&&(Ze=_c);if(Ze&&(Ze=Ze(t,me))){Ki(Me,Ze,i,Ae);break e}st&&st(t,Ne,me),t==="focusout"&&(st=Ne._wrapperState)&&st.controlled&&Ne.type==="number"&&we(Ne,"number",Ne.value)}switch(st=me?Pa(me):window,t){case"focusin":(Gi(st)||st.contentEditable==="true")&&(ps=st,ri=me,_r=null);break;case"focusout":_r=ri=ps=null;break;case"mousedown":Xi=!0;break;case"contextmenu":case"mouseup":case"dragend":Xi=!1,Zi(Me,i,Ae);break;case"selectionchange":if(co)break;case"keydown":case"keyup":Zi(Me,i,Ae)}var at;if(dr)e:{switch(t){case"compositionstart":var ct="onCompositionStart";break e;case"compositionend":ct="onCompositionEnd";break e;case"compositionupdate":ct="onCompositionUpdate";break e}ct=void 0}else Ca?ea(t,i)&&(ct="onCompositionEnd"):t==="keydown"&&i.keyCode===229&&(ct="onCompositionStart");ct&&(Wi&&i.locale!=="ko"&&(Ca||ct!=="onCompositionStart"?ct==="onCompositionEnd"&&Ca&&(at=Qr()):(In=Ae,fs="value"in In?In.value:In.textContent,Ca=!0)),st=li(me,ct),0<st.length&&(ct=new Fi(ct,t,null,i,Ae),Me.push({event:ct,listeners:st}),at?ct.data=at:(at=Zr(i),at!==null&&(ct.data=at)))),(at=Ui?mr(t,i):Vi(t,i))&&(me=li(me,"onBeforeInput"),0<me.length&&(Ae=new Fi("onBeforeInput","beforeinput",null,i,Ae),Me.push({event:Ae,listeners:me}),Ae.data=at))}Ea(Me,n)})}function xr(t,n,i){return{instance:t,listener:n,currentTarget:i}}function li(t,n){for(var i=n+"Capture",o=[];t!==null;){var h=t,g=h.stateNode;h.tag===5&&g!==null&&(h=g,g=it(t,i),g!=null&&o.unshift(xr(t,g,h)),g=it(t,n),g!=null&&o.push(xr(t,g,h))),t=t.return}return o}function ra(t){if(t===null)return null;do t=t.return;while(t&&t.tag!==5);return t||null}function rl(t,n,i,o,h){for(var g=n._reactName,j=[];i!==null&&i!==o;){var P=i,B=P.alternate,me=P.stateNode;if(B!==null&&B===o)break;P.tag===5&&me!==null&&(P=me,h?(B=it(i,g),B!=null&&j.unshift(xr(i,B,P))):h||(B=it(i,g),B!=null&&j.push(xr(i,B,P)))),i=i.return}j.length!==0&&t.push({event:n,listeners:j})}var Ra=/\r\n?/g,yc=/\u0000|\uFFFD/g;function Tn(t){return(typeof t=="string"?t:""+t).replace(Ra,`
38
+ `).replace(yc,"")}function La(t,n,i){if(n=Tn(n),Tn(t)!==n&&i)throw Error(r(425))}function An(){}var Ma=null,br=null;function Xn(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 Fn=typeof setTimeout=="function"?setTimeout:void 0,oi=typeof clearTimeout=="function"?clearTimeout:void 0,ho=typeof Promise=="function"?Promise:void 0,il=typeof queueMicrotask=="function"?queueMicrotask:typeof ho<"u"?function(t){return ho.resolve(null).then(t).catch(xc)}:Fn;function xc(t){setTimeout(function(){throw t})}function ll(t,n){var i=n,o=0;do{var h=i.nextSibling;if(t.removeChild(i),h&&h.nodeType===8)if(i=h.data,i==="/$"){if(o===0){t.removeChild(h),xa(n);return}o--}else i!=="$"&&i!=="$?"&&i!=="$!"||o++;i=h}while(i);xa(n)}function gs(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 po(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 za=Math.random().toString(36).slice(2),Zn="__reactFiber$"+za,wr="__reactProps$"+za,vs="__reactContainer$"+za,ol="__reactEvents$"+za,bc="__reactListeners$"+za,wc="__reactHandles$"+za;function ys(t){var n=t[Zn];if(n)return n;for(var i=t.parentNode;i;){if(n=i[vs]||i[Zn]){if(i=n.alternate,n.child!==null||i!==null&&i.child!==null)for(t=po(t);t!==null;){if(i=t[Zn])return i;t=po(t)}return n}t=i,i=t.parentNode}return null}function jr(t){return t=t[Zn]||t[vs],!t||t.tag!==5&&t.tag!==6&&t.tag!==13&&t.tag!==3?null:t}function Pa(t){if(t.tag===5||t.tag===6)return t.stateNode;throw Error(r(33))}function ci(t){return t[wr]||null}var cl=[],ia=-1;function xs(t){return{current:t}}function At(t){0>ia||(t.current=cl[ia],cl[ia]=null,ia--)}function Tt(t,n){ia++,cl[ia]=t.current,t.current=n}var bs={},an=xs(bs),gn=xs(!1),Ds=bs;function la(t,n){var i=t.type.contextTypes;if(!i)return bs;var o=t.stateNode;if(o&&o.__reactInternalMemoizedUnmaskedChildContext===n)return o.__reactInternalMemoizedMaskedChildContext;var h={},g;for(g in i)h[g]=n[g];return o&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=n,t.__reactInternalMemoizedMaskedChildContext=h),h}function u(t){return t=t.childContextTypes,t!=null}function v(){At(gn),At(an)}function S(t,n,i){if(an.current!==bs)throw Error(r(168));Tt(an,n),Tt(gn,i)}function k(t,n,i){var o=t.stateNode;if(n=n.childContextTypes,typeof o.getChildContext!="function")return i;o=o.getChildContext();for(var h in o)if(!(h in n))throw Error(r(108,be(t)||"Unknown",h));return U({},i,o)}function R(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||bs,Ds=an.current,Tt(an,t),Tt(gn,gn.current),!0}function se(t,n,i){var o=t.stateNode;if(!o)throw Error(r(169));i?(t=k(t,n,Ds),o.__reactInternalMemoizedMergedChildContext=t,At(gn),At(an),Tt(an,t)):At(gn),Tt(gn,i)}var F=null,ye=!1,Pe=!1;function Ue(t){F===null?F=[t]:F.push(t)}function Ve(t){ye=!0,Ue(t)}function $t(){if(!Pe&&F!==null){Pe=!0;var t=0,n=kt;try{var i=F;for(kt=1;t<i.length;t++){var o=i[t];do o=o(!0);while(o!==null)}F=null,ye=!1}catch(h){throw F!==null&&(F=F.slice(t+1)),er(Fr,$t),h}finally{kt=n,Pe=!1}}return null}var Pt=[],jn=0,xt=null,lt=0,Rt=[],gt=0,We=null,St=1,Dt="";function Bt(t,n){Pt[jn++]=lt,Pt[jn++]=xt,xt=t,lt=n}function Zt(t,n,i){Rt[gt++]=St,Rt[gt++]=Dt,Rt[gt++]=We,We=t;var o=St;t=Dt;var h=32-pn(o)-1;o&=~(1<<h),i+=1;var g=32-pn(n)+h;if(30<g){var j=h-h%5;g=(o&(1<<j)-1).toString(32),o>>=j,h-=j,St=1<<32-pn(n)+h|i<<h|o,Dt=g+t}else St=1<<g|i<<h|o,Dt=t}function Lt(t){t.return!==null&&(Bt(t,1),Zt(t,1,0))}function Jt(t){for(;t===xt;)xt=Pt[--jn],Pt[jn]=null,lt=Pt[--jn],Pt[jn]=null;for(;t===We;)We=Rt[--gt],Rt[gt]=null,Dt=Rt[--gt],Rt[gt]=null,St=Rt[--gt],Rt[gt]=null}var cn=null,es=null,Ot=!1,ws=null;function kd(t,n){var i=is(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 Sd(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,cn=t,es=gs(n.firstChild),!0):!1;case 6:return n=t.pendingProps===""||n.nodeType!==3?null:n,n!==null?(t.stateNode=n,cn=t,es=null,!0):!1;case 13:return n=n.nodeType!==8?null:n,n!==null?(i=We!==null?{id:St,overflow:Dt}:null,t.memoizedState={dehydrated:n,treeContext:i,retryLane:1073741824},i=is(18,null,null,0),i.stateNode=n,i.return=t,t.child=i,cn=t,es=null,!0):!1;default:return!1}}function jc(t){return(t.mode&1)!==0&&(t.flags&128)===0}function kc(t){if(Ot){var n=es;if(n){var i=n;if(!Sd(t,n)){if(jc(t))throw Error(r(418));n=gs(i.nextSibling);var o=cn;n&&Sd(t,n)?kd(o,i):(t.flags=t.flags&-4097|2,Ot=!1,cn=t)}}else{if(jc(t))throw Error(r(418));t.flags=t.flags&-4097|2,Ot=!1,cn=t}}}function Nd(t){for(t=t.return;t!==null&&t.tag!==5&&t.tag!==3&&t.tag!==13;)t=t.return;cn=t}function _o(t){if(t!==cn)return!1;if(!Ot)return Nd(t),Ot=!0,!1;var n;if((n=t.tag!==3)&&!(n=t.tag!==5)&&(n=t.type,n=n!=="head"&&n!=="body"&&!Xn(t.type,t.memoizedProps)),n&&(n=es)){if(jc(t))throw Cd(),Error(r(418));for(;n;)kd(t,n),n=gs(n.nextSibling)}if(Nd(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){es=gs(t.nextSibling);break e}n--}else i!=="$"&&i!=="$!"&&i!=="$?"||n++}t=t.nextSibling}es=null}}else es=cn?gs(t.stateNode.nextSibling):null;return!0}function Cd(){for(var t=es;t;)t=gs(t.nextSibling)}function ui(){es=cn=null,Ot=!1}function Sc(t){ws===null?ws=[t]:ws.push(t)}var rp=K.ReactCurrentBatchConfig;function ul(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 h=o,g=""+t;return n!==null&&n.ref!==null&&typeof n.ref=="function"&&n.ref._stringRef===g?n.ref:(n=function(j){var P=h.refs;j===null?delete P[g]:P[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 go(t,n){throw t=Object.prototype.toString.call(n),Error(r(31,t==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":t))}function $d(t){var n=t._init;return n(t._payload)}function Ed(t){function n(ae,G){if(t){var le=ae.deletions;le===null?(ae.deletions=[G],ae.flags|=16):le.push(G)}}function i(ae,G){if(!t)return null;for(;G!==null;)n(ae,G),G=G.sibling;return null}function o(ae,G){for(ae=new Map;G!==null;)G.key!==null?ae.set(G.key,G):ae.set(G.index,G),G=G.sibling;return ae}function h(ae,G){return ae=Wa(ae,G),ae.index=0,ae.sibling=null,ae}function g(ae,G,le){return ae.index=le,t?(le=ae.alternate,le!==null?(le=le.index,le<G?(ae.flags|=2,G):le):(ae.flags|=2,G)):(ae.flags|=1048576,G)}function j(ae){return t&&ae.alternate===null&&(ae.flags|=2),ae}function P(ae,G,le,De){return G===null||G.tag!==6?(G=_u(le,ae.mode,De),G.return=ae,G):(G=h(G,le),G.return=ae,G)}function B(ae,G,le,De){var Ze=le.type;return Ze===ue?Ae(ae,G,le.props.children,De,le.key):G!==null&&(G.elementType===Ze||typeof Ze=="object"&&Ze!==null&&Ze.$$typeof===W&&$d(Ze)===G.type)?(De=h(G,le.props),De.ref=ul(ae,G,le),De.return=ae,De):(De=qo(le.type,le.key,le.props,null,ae.mode,De),De.ref=ul(ae,G,le),De.return=ae,De)}function me(ae,G,le,De){return G===null||G.tag!==4||G.stateNode.containerInfo!==le.containerInfo||G.stateNode.implementation!==le.implementation?(G=gu(le,ae.mode,De),G.return=ae,G):(G=h(G,le.children||[]),G.return=ae,G)}function Ae(ae,G,le,De,Ze){return G===null||G.tag!==7?(G=Ar(le,ae.mode,De,Ze),G.return=ae,G):(G=h(G,le),G.return=ae,G)}function Me(ae,G,le){if(typeof G=="string"&&G!==""||typeof G=="number")return G=_u(""+G,ae.mode,le),G.return=ae,G;if(typeof G=="object"&&G!==null){switch(G.$$typeof){case T:return le=qo(G.type,G.key,G.props,null,ae.mode,le),le.ref=ul(ae,null,G),le.return=ae,le;case te:return G=gu(G,ae.mode,le),G.return=ae,G;case W:var De=G._init;return Me(ae,De(G._payload),le)}if(X(G)||V(G))return G=Ar(G,ae.mode,le,null),G.return=ae,G;go(ae,G)}return null}function Ne(ae,G,le,De){var Ze=G!==null?G.key:null;if(typeof le=="string"&&le!==""||typeof le=="number")return Ze!==null?null:P(ae,G,""+le,De);if(typeof le=="object"&&le!==null){switch(le.$$typeof){case T:return le.key===Ze?B(ae,G,le,De):null;case te:return le.key===Ze?me(ae,G,le,De):null;case W:return Ze=le._init,Ne(ae,G,Ze(le._payload),De)}if(X(le)||V(le))return Ze!==null?null:Ae(ae,G,le,De,null);go(ae,le)}return null}function He(ae,G,le,De,Ze){if(typeof De=="string"&&De!==""||typeof De=="number")return ae=ae.get(le)||null,P(G,ae,""+De,Ze);if(typeof De=="object"&&De!==null){switch(De.$$typeof){case T:return ae=ae.get(De.key===null?le:De.key)||null,B(G,ae,De,Ze);case te:return ae=ae.get(De.key===null?le:De.key)||null,me(G,ae,De,Ze);case W:var st=De._init;return He(ae,G,le,st(De._payload),Ze)}if(X(De)||V(De))return ae=ae.get(le)||null,Ae(G,ae,De,Ze,null);go(G,De)}return null}function Je(ae,G,le,De){for(var Ze=null,st=null,at=G,ct=G=0,mn=null;at!==null&&ct<le.length;ct++){at.index>ct?(mn=at,at=null):mn=at.sibling;var Nt=Ne(ae,at,le[ct],De);if(Nt===null){at===null&&(at=mn);break}t&&at&&Nt.alternate===null&&n(ae,at),G=g(Nt,G,ct),st===null?Ze=Nt:st.sibling=Nt,st=Nt,at=mn}if(ct===le.length)return i(ae,at),Ot&&Bt(ae,ct),Ze;if(at===null){for(;ct<le.length;ct++)at=Me(ae,le[ct],De),at!==null&&(G=g(at,G,ct),st===null?Ze=at:st.sibling=at,st=at);return Ot&&Bt(ae,ct),Ze}for(at=o(ae,at);ct<le.length;ct++)mn=He(at,ae,ct,le[ct],De),mn!==null&&(t&&mn.alternate!==null&&at.delete(mn.key===null?ct:mn.key),G=g(mn,G,ct),st===null?Ze=mn:st.sibling=mn,st=mn);return t&&at.forEach(function(Ha){return n(ae,Ha)}),Ot&&Bt(ae,ct),Ze}function Xe(ae,G,le,De){var Ze=V(le);if(typeof Ze!="function")throw Error(r(150));if(le=Ze.call(le),le==null)throw Error(r(151));for(var st=Ze=null,at=G,ct=G=0,mn=null,Nt=le.next();at!==null&&!Nt.done;ct++,Nt=le.next()){at.index>ct?(mn=at,at=null):mn=at.sibling;var Ha=Ne(ae,at,Nt.value,De);if(Ha===null){at===null&&(at=mn);break}t&&at&&Ha.alternate===null&&n(ae,at),G=g(Ha,G,ct),st===null?Ze=Ha:st.sibling=Ha,st=Ha,at=mn}if(Nt.done)return i(ae,at),Ot&&Bt(ae,ct),Ze;if(at===null){for(;!Nt.done;ct++,Nt=le.next())Nt=Me(ae,Nt.value,De),Nt!==null&&(G=g(Nt,G,ct),st===null?Ze=Nt:st.sibling=Nt,st=Nt);return Ot&&Bt(ae,ct),Ze}for(at=o(ae,at);!Nt.done;ct++,Nt=le.next())Nt=He(at,ae,ct,Nt.value,De),Nt!==null&&(t&&Nt.alternate!==null&&at.delete(Nt.key===null?ct:Nt.key),G=g(Nt,G,ct),st===null?Ze=Nt:st.sibling=Nt,st=Nt);return t&&at.forEach(function(Op){return n(ae,Op)}),Ot&&Bt(ae,ct),Ze}function Yt(ae,G,le,De){if(typeof le=="object"&&le!==null&&le.type===ue&&le.key===null&&(le=le.props.children),typeof le=="object"&&le!==null){switch(le.$$typeof){case T:e:{for(var Ze=le.key,st=G;st!==null;){if(st.key===Ze){if(Ze=le.type,Ze===ue){if(st.tag===7){i(ae,st.sibling),G=h(st,le.props.children),G.return=ae,ae=G;break e}}else if(st.elementType===Ze||typeof Ze=="object"&&Ze!==null&&Ze.$$typeof===W&&$d(Ze)===st.type){i(ae,st.sibling),G=h(st,le.props),G.ref=ul(ae,st,le),G.return=ae,ae=G;break e}i(ae,st);break}else n(ae,st);st=st.sibling}le.type===ue?(G=Ar(le.props.children,ae.mode,De,le.key),G.return=ae,ae=G):(De=qo(le.type,le.key,le.props,null,ae.mode,De),De.ref=ul(ae,G,le),De.return=ae,ae=De)}return j(ae);case te:e:{for(st=le.key;G!==null;){if(G.key===st)if(G.tag===4&&G.stateNode.containerInfo===le.containerInfo&&G.stateNode.implementation===le.implementation){i(ae,G.sibling),G=h(G,le.children||[]),G.return=ae,ae=G;break e}else{i(ae,G);break}else n(ae,G);G=G.sibling}G=gu(le,ae.mode,De),G.return=ae,ae=G}return j(ae);case W:return st=le._init,Yt(ae,G,st(le._payload),De)}if(X(le))return Je(ae,G,le,De);if(V(le))return Xe(ae,G,le,De);go(ae,le)}return typeof le=="string"&&le!==""||typeof le=="number"?(le=""+le,G!==null&&G.tag===6?(i(ae,G.sibling),G=h(G,le),G.return=ae,ae=G):(i(ae,G),G=_u(le,ae.mode,De),G.return=ae,ae=G),j(ae)):i(ae,G)}return Yt}var di=Ed(!0),Td=Ed(!1),vo=xs(null),yo=null,mi=null,Nc=null;function Cc(){Nc=mi=yo=null}function $c(t){var n=vo.current;At(vo),t._currentValue=n}function Ec(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 fi(t,n){yo=t,Nc=mi=null,t=t.dependencies,t!==null&&t.firstContext!==null&&((t.lanes&n)!==0&&(qn=!0),t.firstContext=null)}function ss(t){var n=t._currentValue;if(Nc!==t)if(t={context:t,memoizedValue:n,next:null},mi===null){if(yo===null)throw Error(r(308));mi=t,yo.dependencies={lanes:0,firstContext:t}}else mi=mi.next=t;return n}var kr=null;function Tc(t){kr===null?kr=[t]:kr.push(t)}function Ad(t,n,i,o){var h=n.interleaved;return h===null?(i.next=i,Tc(n)):(i.next=h.next,h.next=i),n.interleaved=i,oa(t,o)}function oa(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 Ia=!1;function Ac(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Rd(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 ca(t,n){return{eventTime:t,lane:n,tag:0,payload:null,callback:null,next:null}}function Oa(t,n,i){var o=t.updateQueue;if(o===null)return null;if(o=o.shared,(bt&2)!==0){var h=o.pending;return h===null?n.next=n:(n.next=h.next,h.next=n),o.pending=n,oa(t,i)}return h=o.interleaved,h===null?(n.next=n,Tc(o)):(n.next=h.next,h.next=n),o.interleaved=n,oa(t,i)}function xo(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,Ls(t,i)}}function Ld(t,n){var i=t.updateQueue,o=t.alternate;if(o!==null&&(o=o.updateQueue,i===o)){var h=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?h=g=j:g=g.next=j,i=i.next}while(i!==null);g===null?h=g=n:g=g.next=n}else h=g=n;i={baseState:o.baseState,firstBaseUpdate:h,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 bo(t,n,i,o){var h=t.updateQueue;Ia=!1;var g=h.firstBaseUpdate,j=h.lastBaseUpdate,P=h.shared.pending;if(P!==null){h.shared.pending=null;var B=P,me=B.next;B.next=null,j===null?g=me:j.next=me,j=B;var Ae=t.alternate;Ae!==null&&(Ae=Ae.updateQueue,P=Ae.lastBaseUpdate,P!==j&&(P===null?Ae.firstBaseUpdate=me:P.next=me,Ae.lastBaseUpdate=B))}if(g!==null){var Me=h.baseState;j=0,Ae=me=B=null,P=g;do{var Ne=P.lane,He=P.eventTime;if((o&Ne)===Ne){Ae!==null&&(Ae=Ae.next={eventTime:He,lane:0,tag:P.tag,payload:P.payload,callback:P.callback,next:null});e:{var Je=t,Xe=P;switch(Ne=n,He=i,Xe.tag){case 1:if(Je=Xe.payload,typeof Je=="function"){Me=Je.call(He,Me,Ne);break e}Me=Je;break e;case 3:Je.flags=Je.flags&-65537|128;case 0:if(Je=Xe.payload,Ne=typeof Je=="function"?Je.call(He,Me,Ne):Je,Ne==null)break e;Me=U({},Me,Ne);break e;case 2:Ia=!0}}P.callback!==null&&P.lane!==0&&(t.flags|=64,Ne=h.effects,Ne===null?h.effects=[P]:Ne.push(P))}else He={eventTime:He,lane:Ne,tag:P.tag,payload:P.payload,callback:P.callback,next:null},Ae===null?(me=Ae=He,B=Me):Ae=Ae.next=He,j|=Ne;if(P=P.next,P===null){if(P=h.shared.pending,P===null)break;Ne=P,P=Ne.next,Ne.next=null,h.lastBaseUpdate=Ne,h.shared.pending=null}}while(!0);if(Ae===null&&(B=Me),h.baseState=B,h.firstBaseUpdate=me,h.lastBaseUpdate=Ae,n=h.shared.interleaved,n!==null){h=n;do j|=h.lane,h=h.next;while(h!==n)}else g===null&&(h.shared.lanes=0);Cr|=j,t.lanes=j,t.memoizedState=Me}}function Md(t,n,i){if(t=n.effects,n.effects=null,t!==null)for(n=0;n<t.length;n++){var o=t[n],h=o.callback;if(h!==null){if(o.callback=null,o=i,typeof h!="function")throw Error(r(191,h));h.call(o)}}}var dl={},Fs=xs(dl),ml=xs(dl),fl=xs(dl);function Sr(t){if(t===dl)throw Error(r(174));return t}function Rc(t,n){switch(Tt(fl,n),Tt(ml,t),Tt(Fs,dl),t=n.nodeType,t){case 9:case 11:n=(n=n.documentElement)?n.namespaceURI:Be(null,"");break;default:t=t===8?n.parentNode:n,n=t.namespaceURI||null,t=t.tagName,n=Be(n,t)}At(Fs),Tt(Fs,n)}function hi(){At(Fs),At(ml),At(fl)}function zd(t){Sr(fl.current);var n=Sr(Fs.current),i=Be(n,t.type);n!==i&&(Tt(ml,t),Tt(Fs,i))}function Lc(t){ml.current===t&&(At(Fs),At(ml))}var Ft=xs(0);function wo(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 Mc=[];function zc(){for(var t=0;t<Mc.length;t++)Mc[t]._workInProgressVersionPrimary=null;Mc.length=0}var jo=K.ReactCurrentDispatcher,Pc=K.ReactCurrentBatchConfig,Nr=0,qt=null,rn=null,un=null,ko=!1,hl=!1,pl=0,ip=0;function kn(){throw Error(r(321))}function Ic(t,n){if(n===null)return!1;for(var i=0;i<n.length&&i<t.length;i++)if(!Yn(t[i],n[i]))return!1;return!0}function Oc(t,n,i,o,h,g){if(Nr=g,qt=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,jo.current=t===null||t.memoizedState===null?up:dp,t=i(o,h),hl){g=0;do{if(hl=!1,pl=0,25<=g)throw Error(r(301));g+=1,un=rn=null,n.updateQueue=null,jo.current=mp,t=i(o,h)}while(hl)}if(jo.current=Co,n=rn!==null&&rn.next!==null,Nr=0,un=rn=qt=null,ko=!1,n)throw Error(r(300));return t}function Dc(){var t=pl!==0;return pl=0,t}function qs(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return un===null?qt.memoizedState=un=t:un=un.next=t,un}function as(){if(rn===null){var t=qt.alternate;t=t!==null?t.memoizedState:null}else t=rn.next;var n=un===null?qt.memoizedState:un.next;if(n!==null)un=n,rn=t;else{if(t===null)throw Error(r(310));rn=t,t={memoizedState:rn.memoizedState,baseState:rn.baseState,baseQueue:rn.baseQueue,queue:rn.queue,next:null},un===null?qt.memoizedState=un=t:un=un.next=t}return un}function _l(t,n){return typeof n=="function"?n(t):n}function Fc(t){var n=as(),i=n.queue;if(i===null)throw Error(r(311));i.lastRenderedReducer=t;var o=rn,h=o.baseQueue,g=i.pending;if(g!==null){if(h!==null){var j=h.next;h.next=g.next,g.next=j}o.baseQueue=h=g,i.pending=null}if(h!==null){g=h.next,o=o.baseState;var P=j=null,B=null,me=g;do{var Ae=me.lane;if((Nr&Ae)===Ae)B!==null&&(B=B.next={lane:0,action:me.action,hasEagerState:me.hasEagerState,eagerState:me.eagerState,next:null}),o=me.hasEagerState?me.eagerState:t(o,me.action);else{var Me={lane:Ae,action:me.action,hasEagerState:me.hasEagerState,eagerState:me.eagerState,next:null};B===null?(P=B=Me,j=o):B=B.next=Me,qt.lanes|=Ae,Cr|=Ae}me=me.next}while(me!==null&&me!==g);B===null?j=o:B.next=P,Yn(o,n.memoizedState)||(qn=!0),n.memoizedState=o,n.baseState=j,n.baseQueue=B,i.lastRenderedState=o}if(t=i.interleaved,t!==null){h=t;do g=h.lane,qt.lanes|=g,Cr|=g,h=h.next;while(h!==t)}else h===null&&(i.lanes=0);return[n.memoizedState,i.dispatch]}function qc(t){var n=as(),i=n.queue;if(i===null)throw Error(r(311));i.lastRenderedReducer=t;var o=i.dispatch,h=i.pending,g=n.memoizedState;if(h!==null){i.pending=null;var j=h=h.next;do g=t(g,j.action),j=j.next;while(j!==h);Yn(g,n.memoizedState)||(qn=!0),n.memoizedState=g,n.baseQueue===null&&(n.baseState=g),i.lastRenderedState=g}return[g,o]}function Pd(){}function Id(t,n){var i=qt,o=as(),h=n(),g=!Yn(o.memoizedState,h);if(g&&(o.memoizedState=h,qn=!0),o=o.queue,Bc(Fd.bind(null,i,o,t),[t]),o.getSnapshot!==n||g||un!==null&&un.memoizedState.tag&1){if(i.flags|=2048,gl(9,Dd.bind(null,i,o,h,n),void 0,null),dn===null)throw Error(r(349));(Nr&30)!==0||Od(i,n,h)}return h}function Od(t,n,i){t.flags|=16384,t={getSnapshot:n,value:i},n=qt.updateQueue,n===null?(n={lastEffect:null,stores:null},qt.updateQueue=n,n.stores=[t]):(i=n.stores,i===null?n.stores=[t]:i.push(t))}function Dd(t,n,i,o){n.value=i,n.getSnapshot=o,qd(n)&&Bd(t)}function Fd(t,n,i){return i(function(){qd(n)&&Bd(t)})}function qd(t){var n=t.getSnapshot;t=t.value;try{var i=n();return!Yn(t,i)}catch{return!0}}function Bd(t){var n=oa(t,1);n!==null&&Ns(n,t,1,-1)}function Ud(t){var n=qs();return typeof t=="function"&&(t=t()),n.memoizedState=n.baseState=t,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:_l,lastRenderedState:t},n.queue=t,t=t.dispatch=cp.bind(null,qt,t),[n.memoizedState,t]}function gl(t,n,i,o){return t={tag:t,create:n,destroy:i,deps:o,next:null},n=qt.updateQueue,n===null?(n={lastEffect:null,stores:null},qt.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 Wd(){return as().memoizedState}function So(t,n,i,o){var h=qs();qt.flags|=t,h.memoizedState=gl(1|n,i,void 0,o===void 0?null:o)}function No(t,n,i,o){var h=as();o=o===void 0?null:o;var g=void 0;if(rn!==null){var j=rn.memoizedState;if(g=j.destroy,o!==null&&Ic(o,j.deps)){h.memoizedState=gl(n,i,g,o);return}}qt.flags|=t,h.memoizedState=gl(1|n,i,g,o)}function Hd(t,n){return So(8390656,8,t,n)}function Bc(t,n){return No(2048,8,t,n)}function Vd(t,n){return No(4,2,t,n)}function Gd(t,n){return No(4,4,t,n)}function Kd(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 Qd(t,n,i){return i=i!=null?i.concat([t]):null,No(4,4,Kd.bind(null,n,t),i)}function Uc(){}function Jd(t,n){var i=as();n=n===void 0?null:n;var o=i.memoizedState;return o!==null&&n!==null&&Ic(n,o[1])?o[0]:(i.memoizedState=[t,n],t)}function Yd(t,n){var i=as();n=n===void 0?null:n;var o=i.memoizedState;return o!==null&&n!==null&&Ic(n,o[1])?o[0]:(t=t(),i.memoizedState=[t,n],t)}function Xd(t,n,i){return(Nr&21)===0?(t.baseState&&(t.baseState=!1,qn=!0),t.memoizedState=i):(Yn(i,n)||(i=Vt(),qt.lanes|=i,Cr|=i,t.baseState=!0),n)}function lp(t,n){var i=kt;kt=i!==0&&4>i?i:4,t(!0);var o=Pc.transition;Pc.transition={};try{t(!1),n()}finally{kt=i,Pc.transition=o}}function Zd(){return as().memoizedState}function op(t,n,i){var o=Ba(t);if(i={lane:o,action:i,hasEagerState:!1,eagerState:null,next:null},em(t))tm(n,i);else if(i=Ad(t,n,i,o),i!==null){var h=Ln();Ns(i,t,o,h),nm(i,n,o)}}function cp(t,n,i){var o=Ba(t),h={lane:o,action:i,hasEagerState:!1,eagerState:null,next:null};if(em(t))tm(n,h);else{var g=t.alternate;if(t.lanes===0&&(g===null||g.lanes===0)&&(g=n.lastRenderedReducer,g!==null))try{var j=n.lastRenderedState,P=g(j,i);if(h.hasEagerState=!0,h.eagerState=P,Yn(P,j)){var B=n.interleaved;B===null?(h.next=h,Tc(n)):(h.next=B.next,B.next=h),n.interleaved=h;return}}catch{}finally{}i=Ad(t,n,h,o),i!==null&&(h=Ln(),Ns(i,t,o,h),nm(i,n,o))}}function em(t){var n=t.alternate;return t===qt||n!==null&&n===qt}function tm(t,n){hl=ko=!0;var i=t.pending;i===null?n.next=n:(n.next=i.next,i.next=n),t.pending=n}function nm(t,n,i){if((i&4194240)!==0){var o=n.lanes;o&=t.pendingLanes,i|=o,n.lanes=i,Ls(t,i)}}var Co={readContext:ss,useCallback:kn,useContext:kn,useEffect:kn,useImperativeHandle:kn,useInsertionEffect:kn,useLayoutEffect:kn,useMemo:kn,useReducer:kn,useRef:kn,useState:kn,useDebugValue:kn,useDeferredValue:kn,useTransition:kn,useMutableSource:kn,useSyncExternalStore:kn,useId:kn,unstable_isNewReconciler:!1},up={readContext:ss,useCallback:function(t,n){return qs().memoizedState=[t,n===void 0?null:n],t},useContext:ss,useEffect:Hd,useImperativeHandle:function(t,n,i){return i=i!=null?i.concat([t]):null,So(4194308,4,Kd.bind(null,n,t),i)},useLayoutEffect:function(t,n){return So(4194308,4,t,n)},useInsertionEffect:function(t,n){return So(4,2,t,n)},useMemo:function(t,n){var i=qs();return n=n===void 0?null:n,t=t(),i.memoizedState=[t,n],t},useReducer:function(t,n,i){var o=qs();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=op.bind(null,qt,t),[o.memoizedState,t]},useRef:function(t){var n=qs();return t={current:t},n.memoizedState=t},useState:Ud,useDebugValue:Uc,useDeferredValue:function(t){return qs().memoizedState=t},useTransition:function(){var t=Ud(!1),n=t[0];return t=lp.bind(null,t[1]),qs().memoizedState=t,[n,t]},useMutableSource:function(){},useSyncExternalStore:function(t,n,i){var o=qt,h=qs();if(Ot){if(i===void 0)throw Error(r(407));i=i()}else{if(i=n(),dn===null)throw Error(r(349));(Nr&30)!==0||Od(o,n,i)}h.memoizedState=i;var g={value:i,getSnapshot:n};return h.queue=g,Hd(Fd.bind(null,o,g,t),[t]),o.flags|=2048,gl(9,Dd.bind(null,o,g,i,n),void 0,null),i},useId:function(){var t=qs(),n=dn.identifierPrefix;if(Ot){var i=Dt,o=St;i=(o&~(1<<32-pn(o)-1)).toString(32)+i,n=":"+n+"R"+i,i=pl++,0<i&&(n+="H"+i.toString(32)),n+=":"}else i=ip++,n=":"+n+"r"+i.toString(32)+":";return t.memoizedState=n},unstable_isNewReconciler:!1},dp={readContext:ss,useCallback:Jd,useContext:ss,useEffect:Bc,useImperativeHandle:Qd,useInsertionEffect:Vd,useLayoutEffect:Gd,useMemo:Yd,useReducer:Fc,useRef:Wd,useState:function(){return Fc(_l)},useDebugValue:Uc,useDeferredValue:function(t){var n=as();return Xd(n,rn.memoizedState,t)},useTransition:function(){var t=Fc(_l)[0],n=as().memoizedState;return[t,n]},useMutableSource:Pd,useSyncExternalStore:Id,useId:Zd,unstable_isNewReconciler:!1},mp={readContext:ss,useCallback:Jd,useContext:ss,useEffect:Bc,useImperativeHandle:Qd,useInsertionEffect:Vd,useLayoutEffect:Gd,useMemo:Yd,useReducer:qc,useRef:Wd,useState:function(){return qc(_l)},useDebugValue:Uc,useDeferredValue:function(t){var n=as();return rn===null?n.memoizedState=t:Xd(n,rn.memoizedState,t)},useTransition:function(){var t=qc(_l)[0],n=as().memoizedState;return[t,n]},useMutableSource:Pd,useSyncExternalStore:Id,useId:Zd,unstable_isNewReconciler:!1};function js(t,n){if(t&&t.defaultProps){n=U({},n),t=t.defaultProps;for(var i in t)n[i]===void 0&&(n[i]=t[i]);return n}return n}function Wc(t,n,i,o){n=t.memoizedState,i=i(o,n),i=i==null?n:U({},n,i),t.memoizedState=i,t.lanes===0&&(t.updateQueue.baseState=i)}var $o={isMounted:function(t){return(t=t._reactInternals)?Ts(t)===t:!1},enqueueSetState:function(t,n,i){t=t._reactInternals;var o=Ln(),h=Ba(t),g=ca(o,h);g.payload=n,i!=null&&(g.callback=i),n=Oa(t,g,h),n!==null&&(Ns(n,t,h,o),xo(n,t,h))},enqueueReplaceState:function(t,n,i){t=t._reactInternals;var o=Ln(),h=Ba(t),g=ca(o,h);g.tag=1,g.payload=n,i!=null&&(g.callback=i),n=Oa(t,g,h),n!==null&&(Ns(n,t,h,o),xo(n,t,h))},enqueueForceUpdate:function(t,n){t=t._reactInternals;var i=Ln(),o=Ba(t),h=ca(i,o);h.tag=2,n!=null&&(h.callback=n),n=Oa(t,h,o),n!==null&&(Ns(n,t,o,i),xo(n,t,o))}};function sm(t,n,i,o,h,g,j){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(o,g,j):n.prototype&&n.prototype.isPureReactComponent?!ta(i,o)||!ta(h,g):!0}function am(t,n,i){var o=!1,h=bs,g=n.contextType;return typeof g=="object"&&g!==null?g=ss(g):(h=u(n)?Ds:an.current,o=n.contextTypes,g=(o=o!=null)?la(t,h):bs),n=new n(i,g),t.memoizedState=n.state!==null&&n.state!==void 0?n.state:null,n.updater=$o,t.stateNode=n,n._reactInternals=t,o&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=h,t.__reactInternalMemoizedMaskedChildContext=g),n}function rm(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&&$o.enqueueReplaceState(n,n.state,null)}function Hc(t,n,i,o){var h=t.stateNode;h.props=i,h.state=t.memoizedState,h.refs={},Ac(t);var g=n.contextType;typeof g=="object"&&g!==null?h.context=ss(g):(g=u(n)?Ds:an.current,h.context=la(t,g)),h.state=t.memoizedState,g=n.getDerivedStateFromProps,typeof g=="function"&&(Wc(t,n,g,i),h.state=t.memoizedState),typeof n.getDerivedStateFromProps=="function"||typeof h.getSnapshotBeforeUpdate=="function"||typeof h.UNSAFE_componentWillMount!="function"&&typeof h.componentWillMount!="function"||(n=h.state,typeof h.componentWillMount=="function"&&h.componentWillMount(),typeof h.UNSAFE_componentWillMount=="function"&&h.UNSAFE_componentWillMount(),n!==h.state&&$o.enqueueReplaceState(h,h.state,null),bo(t,i,h,o),h.state=t.memoizedState),typeof h.componentDidMount=="function"&&(t.flags|=4194308)}function pi(t,n){try{var i="",o=n;do i+=oe(o),o=o.return;while(o);var h=i}catch(g){h=`
39
+ Error generating stack: `+g.message+`
40
+ `+g.stack}return{value:t,source:n,stack:h,digest:null}}function Vc(t,n,i){return{value:t,source:null,stack:i??null,digest:n??null}}function Gc(t,n){try{console.error(n.value)}catch(i){setTimeout(function(){throw i})}}var fp=typeof WeakMap=="function"?WeakMap:Map;function im(t,n,i){i=ca(-1,i),i.tag=3,i.payload={element:null};var o=n.value;return i.callback=function(){zo||(zo=!0,ou=o),Gc(t,n)},i}function lm(t,n,i){i=ca(-1,i),i.tag=3;var o=t.type.getDerivedStateFromError;if(typeof o=="function"){var h=n.value;i.payload=function(){return o(h)},i.callback=function(){Gc(t,n)}}var g=t.stateNode;return g!==null&&typeof g.componentDidCatch=="function"&&(i.callback=function(){Gc(t,n),typeof o!="function"&&(Fa===null?Fa=new Set([this]):Fa.add(this));var j=n.stack;this.componentDidCatch(n.value,{componentStack:j!==null?j:""})}),i}function om(t,n,i){var o=t.pingCache;if(o===null){o=t.pingCache=new fp;var h=new Set;o.set(n,h)}else h=o.get(n),h===void 0&&(h=new Set,o.set(n,h));h.has(i)||(h.add(i),t=Cp.bind(null,t,n,i),n.then(t,t))}function cm(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 um(t,n,i,o,h){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=ca(-1,1),n.tag=2,Oa(i,n,1))),i.lanes|=1),t):(t.flags|=65536,t.lanes=h,t)}var hp=K.ReactCurrentOwner,qn=!1;function Rn(t,n,i,o){n.child=t===null?Td(n,null,i,o):di(n,t.child,i,o)}function dm(t,n,i,o,h){i=i.render;var g=n.ref;return fi(n,h),o=Oc(t,n,i,o,g,h),i=Dc(),t!==null&&!qn?(n.updateQueue=t.updateQueue,n.flags&=-2053,t.lanes&=~h,ua(t,n,h)):(Ot&&i&&Lt(n),n.flags|=1,Rn(t,n,o,h),n.child)}function mm(t,n,i,o,h){if(t===null){var g=i.type;return typeof g=="function"&&!pu(g)&&g.defaultProps===void 0&&i.compare===null&&i.defaultProps===void 0?(n.tag=15,n.type=g,fm(t,n,g,o,h)):(t=qo(i.type,null,o,n,n.mode,h),t.ref=n.ref,t.return=n,n.child=t)}if(g=t.child,(t.lanes&h)===0){var j=g.memoizedProps;if(i=i.compare,i=i!==null?i:ta,i(j,o)&&t.ref===n.ref)return ua(t,n,h)}return n.flags|=1,t=Wa(g,o),t.ref=n.ref,t.return=n,n.child=t}function fm(t,n,i,o,h){if(t!==null){var g=t.memoizedProps;if(ta(g,o)&&t.ref===n.ref)if(qn=!1,n.pendingProps=o=g,(t.lanes&h)!==0)(t.flags&131072)!==0&&(qn=!0);else return n.lanes=t.lanes,ua(t,n,h)}return Kc(t,n,i,o,h)}function hm(t,n,i){var o=n.pendingProps,h=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},Tt(gi,ts),ts|=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,Tt(gi,ts),ts|=t,null;n.memoizedState={baseLanes:0,cachePool:null,transitions:null},o=g!==null?g.baseLanes:i,Tt(gi,ts),ts|=o}else g!==null?(o=g.baseLanes|i,n.memoizedState=null):o=i,Tt(gi,ts),ts|=o;return Rn(t,n,h,i),n.child}function pm(t,n){var i=n.ref;(t===null&&i!==null||t!==null&&t.ref!==i)&&(n.flags|=512,n.flags|=2097152)}function Kc(t,n,i,o,h){var g=u(i)?Ds:an.current;return g=la(n,g),fi(n,h),i=Oc(t,n,i,o,g,h),o=Dc(),t!==null&&!qn?(n.updateQueue=t.updateQueue,n.flags&=-2053,t.lanes&=~h,ua(t,n,h)):(Ot&&o&&Lt(n),n.flags|=1,Rn(t,n,i,h),n.child)}function _m(t,n,i,o,h){if(u(i)){var g=!0;R(n)}else g=!1;if(fi(n,h),n.stateNode===null)To(t,n),am(n,i,o),Hc(n,i,o,h),o=!0;else if(t===null){var j=n.stateNode,P=n.memoizedProps;j.props=P;var B=j.context,me=i.contextType;typeof me=="object"&&me!==null?me=ss(me):(me=u(i)?Ds:an.current,me=la(n,me));var Ae=i.getDerivedStateFromProps,Me=typeof Ae=="function"||typeof j.getSnapshotBeforeUpdate=="function";Me||typeof j.UNSAFE_componentWillReceiveProps!="function"&&typeof j.componentWillReceiveProps!="function"||(P!==o||B!==me)&&rm(n,j,o,me),Ia=!1;var Ne=n.memoizedState;j.state=Ne,bo(n,o,j,h),B=n.memoizedState,P!==o||Ne!==B||gn.current||Ia?(typeof Ae=="function"&&(Wc(n,i,Ae,o),B=n.memoizedState),(P=Ia||sm(n,i,P,o,Ne,B,me))?(Me||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=B),j.props=o,j.state=B,j.context=me,o=P):(typeof j.componentDidMount=="function"&&(n.flags|=4194308),o=!1)}else{j=n.stateNode,Rd(t,n),P=n.memoizedProps,me=n.type===n.elementType?P:js(n.type,P),j.props=me,Me=n.pendingProps,Ne=j.context,B=i.contextType,typeof B=="object"&&B!==null?B=ss(B):(B=u(i)?Ds:an.current,B=la(n,B));var He=i.getDerivedStateFromProps;(Ae=typeof He=="function"||typeof j.getSnapshotBeforeUpdate=="function")||typeof j.UNSAFE_componentWillReceiveProps!="function"&&typeof j.componentWillReceiveProps!="function"||(P!==Me||Ne!==B)&&rm(n,j,o,B),Ia=!1,Ne=n.memoizedState,j.state=Ne,bo(n,o,j,h);var Je=n.memoizedState;P!==Me||Ne!==Je||gn.current||Ia?(typeof He=="function"&&(Wc(n,i,He,o),Je=n.memoizedState),(me=Ia||sm(n,i,me,o,Ne,Je,B)||!1)?(Ae||typeof j.UNSAFE_componentWillUpdate!="function"&&typeof j.componentWillUpdate!="function"||(typeof j.componentWillUpdate=="function"&&j.componentWillUpdate(o,Je,B),typeof j.UNSAFE_componentWillUpdate=="function"&&j.UNSAFE_componentWillUpdate(o,Je,B)),typeof j.componentDidUpdate=="function"&&(n.flags|=4),typeof j.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof j.componentDidUpdate!="function"||P===t.memoizedProps&&Ne===t.memoizedState||(n.flags|=4),typeof j.getSnapshotBeforeUpdate!="function"||P===t.memoizedProps&&Ne===t.memoizedState||(n.flags|=1024),n.memoizedProps=o,n.memoizedState=Je),j.props=o,j.state=Je,j.context=B,o=me):(typeof j.componentDidUpdate!="function"||P===t.memoizedProps&&Ne===t.memoizedState||(n.flags|=4),typeof j.getSnapshotBeforeUpdate!="function"||P===t.memoizedProps&&Ne===t.memoizedState||(n.flags|=1024),o=!1)}return Qc(t,n,i,o,g,h)}function Qc(t,n,i,o,h,g){pm(t,n);var j=(n.flags&128)!==0;if(!o&&!j)return h&&se(n,i,!1),ua(t,n,g);o=n.stateNode,hp.current=n;var P=j&&typeof i.getDerivedStateFromError!="function"?null:o.render();return n.flags|=1,t!==null&&j?(n.child=di(n,t.child,null,g),n.child=di(n,null,P,g)):Rn(t,n,P,g),n.memoizedState=o.state,h&&se(n,i,!0),n.child}function gm(t){var n=t.stateNode;n.pendingContext?S(t,n.pendingContext,n.pendingContext!==n.context):n.context&&S(t,n.context,!1),Rc(t,n.containerInfo)}function vm(t,n,i,o,h){return ui(),Sc(h),n.flags|=256,Rn(t,n,i,o),n.child}var Jc={dehydrated:null,treeContext:null,retryLane:0};function Yc(t){return{baseLanes:t,cachePool:null,transitions:null}}function ym(t,n,i){var o=n.pendingProps,h=Ft.current,g=!1,j=(n.flags&128)!==0,P;if((P=j)||(P=t!==null&&t.memoizedState===null?!1:(h&2)!==0),P?(g=!0,n.flags&=-129):(t===null||t.memoizedState!==null)&&(h|=1),Tt(Ft,h&1),t===null)return kc(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=Bo(j,o,0,null),t=Ar(t,o,i,null),g.return=n,t.return=n,g.sibling=t,n.child=g,n.child.memoizedState=Yc(i),n.memoizedState=Jc,t):Xc(n,j));if(h=t.memoizedState,h!==null&&(P=h.dehydrated,P!==null))return pp(t,n,j,o,P,h,i);if(g){g=o.fallback,j=n.mode,h=t.child,P=h.sibling;var B={mode:"hidden",children:o.children};return(j&1)===0&&n.child!==h?(o=n.child,o.childLanes=0,o.pendingProps=B,n.deletions=null):(o=Wa(h,B),o.subtreeFlags=h.subtreeFlags&14680064),P!==null?g=Wa(P,g):(g=Ar(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?Yc(i):{baseLanes:j.baseLanes|i,cachePool:null,transitions:j.transitions},g.memoizedState=j,g.childLanes=t.childLanes&~i,n.memoizedState=Jc,o}return g=t.child,t=g.sibling,o=Wa(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 Xc(t,n){return n=Bo({mode:"visible",children:n},t.mode,0,null),n.return=t,t.child=n}function Eo(t,n,i,o){return o!==null&&Sc(o),di(n,t.child,null,i),t=Xc(n,n.pendingProps.children),t.flags|=2,n.memoizedState=null,t}function pp(t,n,i,o,h,g,j){if(i)return n.flags&256?(n.flags&=-257,o=Vc(Error(r(422))),Eo(t,n,j,o)):n.memoizedState!==null?(n.child=t.child,n.flags|=128,null):(g=o.fallback,h=n.mode,o=Bo({mode:"visible",children:o.children},h,0,null),g=Ar(g,h,j,null),g.flags|=2,o.return=n,g.return=n,o.sibling=g,n.child=o,(n.mode&1)!==0&&di(n,t.child,null,j),n.child.memoizedState=Yc(j),n.memoizedState=Jc,g);if((n.mode&1)===0)return Eo(t,n,j,null);if(h.data==="$!"){if(o=h.nextSibling&&h.nextSibling.dataset,o)var P=o.dgst;return o=P,g=Error(r(419)),o=Vc(g,o,void 0),Eo(t,n,j,o)}if(P=(j&t.childLanes)!==0,qn||P){if(o=dn,o!==null){switch(j&-j){case 4:h=2;break;case 16:h=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:h=32;break;case 536870912:h=268435456;break;default:h=0}h=(h&(o.suspendedLanes|j))!==0?0:h,h!==0&&h!==g.retryLane&&(g.retryLane=h,oa(t,h),Ns(o,t,h,-1))}return hu(),o=Vc(Error(r(421))),Eo(t,n,j,o)}return h.data==="$?"?(n.flags|=128,n.child=t.child,n=$p.bind(null,t),h._reactRetry=n,null):(t=g.treeContext,es=gs(h.nextSibling),cn=n,Ot=!0,ws=null,t!==null&&(Rt[gt++]=St,Rt[gt++]=Dt,Rt[gt++]=We,St=t.id,Dt=t.overflow,We=n),n=Xc(n,o.children),n.flags|=4096,n)}function xm(t,n,i){t.lanes|=n;var o=t.alternate;o!==null&&(o.lanes|=n),Ec(t.return,n,i)}function Zc(t,n,i,o,h){var g=t.memoizedState;g===null?t.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:o,tail:i,tailMode:h}:(g.isBackwards=n,g.rendering=null,g.renderingStartTime=0,g.last=o,g.tail=i,g.tailMode=h)}function bm(t,n,i){var o=n.pendingProps,h=o.revealOrder,g=o.tail;if(Rn(t,n,o.children,i),o=Ft.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&&xm(t,i,n);else if(t.tag===19)xm(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(Tt(Ft,o),(n.mode&1)===0)n.memoizedState=null;else switch(h){case"forwards":for(i=n.child,h=null;i!==null;)t=i.alternate,t!==null&&wo(t)===null&&(h=i),i=i.sibling;i=h,i===null?(h=n.child,n.child=null):(h=i.sibling,i.sibling=null),Zc(n,!1,h,i,g);break;case"backwards":for(i=null,h=n.child,n.child=null;h!==null;){if(t=h.alternate,t!==null&&wo(t)===null){n.child=h;break}t=h.sibling,h.sibling=i,i=h,h=t}Zc(n,!0,i,null,g);break;case"together":Zc(n,!1,null,null,void 0);break;default:n.memoizedState=null}return n.child}function To(t,n){(n.mode&1)===0&&t!==null&&(t.alternate=null,n.alternate=null,n.flags|=2)}function ua(t,n,i){if(t!==null&&(n.dependencies=t.dependencies),Cr|=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=Wa(t,t.pendingProps),n.child=i,i.return=n;t.sibling!==null;)t=t.sibling,i=i.sibling=Wa(t,t.pendingProps),i.return=n;i.sibling=null}return n.child}function _p(t,n,i){switch(n.tag){case 3:gm(n),ui();break;case 5:zd(n);break;case 1:u(n.type)&&R(n);break;case 4:Rc(n,n.stateNode.containerInfo);break;case 10:var o=n.type._context,h=n.memoizedProps.value;Tt(vo,o._currentValue),o._currentValue=h;break;case 13:if(o=n.memoizedState,o!==null)return o.dehydrated!==null?(Tt(Ft,Ft.current&1),n.flags|=128,null):(i&n.child.childLanes)!==0?ym(t,n,i):(Tt(Ft,Ft.current&1),t=ua(t,n,i),t!==null?t.sibling:null);Tt(Ft,Ft.current&1);break;case 19:if(o=(i&n.childLanes)!==0,(t.flags&128)!==0){if(o)return bm(t,n,i);n.flags|=128}if(h=n.memoizedState,h!==null&&(h.rendering=null,h.tail=null,h.lastEffect=null),Tt(Ft,Ft.current),o)break;return null;case 22:case 23:return n.lanes=0,hm(t,n,i)}return ua(t,n,i)}var wm,eu,jm,km;wm=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}},eu=function(){},jm=function(t,n,i,o){var h=t.memoizedProps;if(h!==o){t=n.stateNode,Sr(Fs.current);var g=null;switch(i){case"input":h=Le(t,h),o=Le(t,o),g=[];break;case"select":h=U({},h,{value:void 0}),o=U({},o,{value:void 0}),g=[];break;case"textarea":h=_e(t,h),o=_e(t,o),g=[];break;default:typeof h.onClick!="function"&&typeof o.onClick=="function"&&(t.onclick=An)}mt(i,o);var j;i=null;for(me in h)if(!o.hasOwnProperty(me)&&h.hasOwnProperty(me)&&h[me]!=null)if(me==="style"){var P=h[me];for(j in P)P.hasOwnProperty(j)&&(i||(i={}),i[j]="")}else me!=="dangerouslySetInnerHTML"&&me!=="children"&&me!=="suppressContentEditableWarning"&&me!=="suppressHydrationWarning"&&me!=="autoFocus"&&(c.hasOwnProperty(me)?g||(g=[]):(g=g||[]).push(me,null));for(me in o){var B=o[me];if(P=h!=null?h[me]:void 0,o.hasOwnProperty(me)&&B!==P&&(B!=null||P!=null))if(me==="style")if(P){for(j in P)!P.hasOwnProperty(j)||B&&B.hasOwnProperty(j)||(i||(i={}),i[j]="");for(j in B)B.hasOwnProperty(j)&&P[j]!==B[j]&&(i||(i={}),i[j]=B[j])}else i||(g||(g=[]),g.push(me,i)),i=B;else me==="dangerouslySetInnerHTML"?(B=B?B.__html:void 0,P=P?P.__html:void 0,B!=null&&P!==B&&(g=g||[]).push(me,B)):me==="children"?typeof B!="string"&&typeof B!="number"||(g=g||[]).push(me,""+B):me!=="suppressContentEditableWarning"&&me!=="suppressHydrationWarning"&&(c.hasOwnProperty(me)?(B!=null&&me==="onScroll"&&Ct("scroll",t),g||P===B||(g=[])):(g=g||[]).push(me,B))}i&&(g=g||[]).push("style",i);var me=g;(n.updateQueue=me)&&(n.flags|=4)}},km=function(t,n,i,o){i!==o&&(n.flags|=4)};function vl(t,n){if(!Ot)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 Sn(t){var n=t.alternate!==null&&t.alternate.child===t.child,i=0,o=0;if(n)for(var h=t.child;h!==null;)i|=h.lanes|h.childLanes,o|=h.subtreeFlags&14680064,o|=h.flags&14680064,h.return=t,h=h.sibling;else for(h=t.child;h!==null;)i|=h.lanes|h.childLanes,o|=h.subtreeFlags,o|=h.flags,h.return=t,h=h.sibling;return t.subtreeFlags|=o,t.childLanes=i,n}function gp(t,n,i){var o=n.pendingProps;switch(Jt(n),n.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Sn(n),null;case 1:return u(n.type)&&v(),Sn(n),null;case 3:return o=n.stateNode,hi(),At(gn),At(an),zc(),o.pendingContext&&(o.context=o.pendingContext,o.pendingContext=null),(t===null||t.child===null)&&(_o(n)?n.flags|=4:t===null||t.memoizedState.isDehydrated&&(n.flags&256)===0||(n.flags|=1024,ws!==null&&(du(ws),ws=null))),eu(t,n),Sn(n),null;case 5:Lc(n);var h=Sr(fl.current);if(i=n.type,t!==null&&n.stateNode!=null)jm(t,n,i,o,h),t.ref!==n.ref&&(n.flags|=512,n.flags|=2097152);else{if(!o){if(n.stateNode===null)throw Error(r(166));return Sn(n),null}if(t=Sr(Fs.current),_o(n)){o=n.stateNode,i=n.type;var g=n.memoizedProps;switch(o[Zn]=n,o[wr]=g,t=(n.mode&1)!==0,i){case"dialog":Ct("cancel",o),Ct("close",o);break;case"iframe":case"object":case"embed":Ct("load",o);break;case"video":case"audio":for(h=0;h<Dn.length;h++)Ct(Dn[h],o);break;case"source":Ct("error",o);break;case"img":case"image":case"link":Ct("error",o),Ct("load",o);break;case"details":Ct("toggle",o);break;case"input":Ge(o,g),Ct("invalid",o);break;case"select":o._wrapperState={wasMultiple:!!g.multiple},Ct("invalid",o);break;case"textarea":Ie(o,g),Ct("invalid",o)}mt(i,g),h=null;for(var j in g)if(g.hasOwnProperty(j)){var P=g[j];j==="children"?typeof P=="string"?o.textContent!==P&&(g.suppressHydrationWarning!==!0&&La(o.textContent,P,t),h=["children",P]):typeof P=="number"&&o.textContent!==""+P&&(g.suppressHydrationWarning!==!0&&La(o.textContent,P,t),h=["children",""+P]):c.hasOwnProperty(j)&&P!=null&&j==="onScroll"&&Ct("scroll",o)}switch(i){case"input":ut(o),fe(o,g,!0);break;case"textarea":ut(o),ce(o);break;case"select":case"option":break;default:typeof g.onClick=="function"&&(o.onclick=An)}o=h,n.updateQueue=o,o!==null&&(n.flags|=4)}else{j=h.nodeType===9?h:h.ownerDocument,t==="http://www.w3.org/1999/xhtml"&&(t=ke(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[Zn]=n,t[wr]=o,wm(t,n,!1,!1),n.stateNode=t;e:{switch(j=ft(i,o),i){case"dialog":Ct("cancel",t),Ct("close",t),h=o;break;case"iframe":case"object":case"embed":Ct("load",t),h=o;break;case"video":case"audio":for(h=0;h<Dn.length;h++)Ct(Dn[h],t);h=o;break;case"source":Ct("error",t),h=o;break;case"img":case"image":case"link":Ct("error",t),Ct("load",t),h=o;break;case"details":Ct("toggle",t),h=o;break;case"input":Ge(t,o),h=Le(t,o),Ct("invalid",t);break;case"option":h=o;break;case"select":t._wrapperState={wasMultiple:!!o.multiple},h=U({},o,{value:void 0}),Ct("invalid",t);break;case"textarea":Ie(t,o),h=_e(t,o),Ct("invalid",t);break;default:h=o}mt(i,h),P=h;for(g in P)if(P.hasOwnProperty(g)){var B=P[g];g==="style"?et(t,B):g==="dangerouslySetInnerHTML"?(B=B?B.__html:void 0,B!=null&&ze(t,B)):g==="children"?typeof B=="string"?(i!=="textarea"||B!=="")&&ee(t,B):typeof B=="number"&&ee(t,""+B):g!=="suppressContentEditableWarning"&&g!=="suppressHydrationWarning"&&g!=="autoFocus"&&(c.hasOwnProperty(g)?B!=null&&g==="onScroll"&&Ct("scroll",t):B!=null&&D(t,g,B,j))}switch(i){case"input":ut(t),fe(t,o,!1);break;case"textarea":ut(t),ce(t);break;case"option":o.value!=null&&t.setAttribute("value",""+Re(o.value));break;case"select":t.multiple=!!o.multiple,g=o.value,g!=null?Q(t,!!o.multiple,g,!1):o.defaultValue!=null&&Q(t,!!o.multiple,o.defaultValue,!0);break;default:typeof h.onClick=="function"&&(t.onclick=An)}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 Sn(n),null;case 6:if(t&&n.stateNode!=null)km(t,n,t.memoizedProps,o);else{if(typeof o!="string"&&n.stateNode===null)throw Error(r(166));if(i=Sr(fl.current),Sr(Fs.current),_o(n)){if(o=n.stateNode,i=n.memoizedProps,o[Zn]=n,(g=o.nodeValue!==i)&&(t=cn,t!==null))switch(t.tag){case 3:La(o.nodeValue,i,(t.mode&1)!==0);break;case 5:t.memoizedProps.suppressHydrationWarning!==!0&&La(o.nodeValue,i,(t.mode&1)!==0)}g&&(n.flags|=4)}else o=(i.nodeType===9?i:i.ownerDocument).createTextNode(o),o[Zn]=n,n.stateNode=o}return Sn(n),null;case 13:if(At(Ft),o=n.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(Ot&&es!==null&&(n.mode&1)!==0&&(n.flags&128)===0)Cd(),ui(),n.flags|=98560,g=!1;else if(g=_o(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[Zn]=n}else ui(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;Sn(n),g=!1}else ws!==null&&(du(ws),ws=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||(Ft.current&1)!==0?ln===0&&(ln=3):hu())),n.updateQueue!==null&&(n.flags|=4),Sn(n),null);case 4:return hi(),eu(t,n),t===null&&Aa(n.stateNode.containerInfo),Sn(n),null;case 10:return $c(n.type._context),Sn(n),null;case 17:return u(n.type)&&v(),Sn(n),null;case 19:if(At(Ft),g=n.memoizedState,g===null)return Sn(n),null;if(o=(n.flags&128)!==0,j=g.rendering,j===null)if(o)vl(g,!1);else{if(ln!==0||t!==null&&(t.flags&128)!==0)for(t=n.child;t!==null;){if(j=wo(t),j!==null){for(n.flags|=128,vl(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 Tt(Ft,Ft.current&1|2),n.child}t=t.sibling}g.tail!==null&&It()>vi&&(n.flags|=128,o=!0,vl(g,!1),n.lanes=4194304)}else{if(!o)if(t=wo(j),t!==null){if(n.flags|=128,o=!0,i=t.updateQueue,i!==null&&(n.updateQueue=i,n.flags|=4),vl(g,!0),g.tail===null&&g.tailMode==="hidden"&&!j.alternate&&!Ot)return Sn(n),null}else 2*It()-g.renderingStartTime>vi&&i!==1073741824&&(n.flags|=128,o=!0,vl(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=It(),n.sibling=null,i=Ft.current,Tt(Ft,o?i&1|2:i&1),n):(Sn(n),null);case 22:case 23:return fu(),o=n.memoizedState!==null,t!==null&&t.memoizedState!==null!==o&&(n.flags|=8192),o&&(n.mode&1)!==0?(ts&1073741824)!==0&&(Sn(n),n.subtreeFlags&6&&(n.flags|=8192)):Sn(n),null;case 24:return null;case 25:return null}throw Error(r(156,n.tag))}function vp(t,n){switch(Jt(n),n.tag){case 1:return u(n.type)&&v(),t=n.flags,t&65536?(n.flags=t&-65537|128,n):null;case 3:return hi(),At(gn),At(an),zc(),t=n.flags,(t&65536)!==0&&(t&128)===0?(n.flags=t&-65537|128,n):null;case 5:return Lc(n),null;case 13:if(At(Ft),t=n.memoizedState,t!==null&&t.dehydrated!==null){if(n.alternate===null)throw Error(r(340));ui()}return t=n.flags,t&65536?(n.flags=t&-65537|128,n):null;case 19:return At(Ft),null;case 4:return hi(),null;case 10:return $c(n.type._context),null;case 22:case 23:return fu(),null;case 24:return null;default:return null}}var Ao=!1,Nn=!1,yp=typeof WeakSet=="function"?WeakSet:Set,Qe=null;function _i(t,n){var i=t.ref;if(i!==null)if(typeof i=="function")try{i(null)}catch(o){Ut(t,n,o)}else i.current=null}function tu(t,n,i){try{i()}catch(o){Ut(t,n,o)}}var Sm=!1;function xp(t,n){if(Ma=rr,t=oo(),si(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 h=o.anchorOffset,g=o.focusNode;o=o.focusOffset;try{i.nodeType,g.nodeType}catch{i=null;break e}var j=0,P=-1,B=-1,me=0,Ae=0,Me=t,Ne=null;t:for(;;){for(var He;Me!==i||h!==0&&Me.nodeType!==3||(P=j+h),Me!==g||o!==0&&Me.nodeType!==3||(B=j+o),Me.nodeType===3&&(j+=Me.nodeValue.length),(He=Me.firstChild)!==null;)Ne=Me,Me=He;for(;;){if(Me===t)break t;if(Ne===i&&++me===h&&(P=j),Ne===g&&++Ae===o&&(B=j),(He=Me.nextSibling)!==null)break;Me=Ne,Ne=Me.parentNode}Me=He}i=P===-1||B===-1?null:{start:P,end:B}}else i=null}i=i||{start:0,end:0}}else i=null;for(br={focusedElem:t,selectionRange:i},rr=!1,Qe=n;Qe!==null;)if(n=Qe,t=n.child,(n.subtreeFlags&1028)!==0&&t!==null)t.return=n,Qe=t;else for(;Qe!==null;){n=Qe;try{var Je=n.alternate;if((n.flags&1024)!==0)switch(n.tag){case 0:case 11:case 15:break;case 1:if(Je!==null){var Xe=Je.memoizedProps,Yt=Je.memoizedState,ae=n.stateNode,G=ae.getSnapshotBeforeUpdate(n.elementType===n.type?Xe:js(n.type,Xe),Yt);ae.__reactInternalSnapshotBeforeUpdate=G}break;case 3:var le=n.stateNode.containerInfo;le.nodeType===1?le.textContent="":le.nodeType===9&&le.documentElement&&le.removeChild(le.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(r(163))}}catch(De){Ut(n,n.return,De)}if(t=n.sibling,t!==null){t.return=n.return,Qe=t;break}Qe=n.return}return Je=Sm,Sm=!1,Je}function yl(t,n,i){var o=n.updateQueue;if(o=o!==null?o.lastEffect:null,o!==null){var h=o=o.next;do{if((h.tag&t)===t){var g=h.destroy;h.destroy=void 0,g!==void 0&&tu(n,i,g)}h=h.next}while(h!==o)}}function Ro(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 nu(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 Nm(t){var n=t.alternate;n!==null&&(t.alternate=null,Nm(n)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(n=t.stateNode,n!==null&&(delete n[Zn],delete n[wr],delete n[ol],delete n[bc],delete n[wc])),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 Cm(t){return t.tag===5||t.tag===3||t.tag===4}function $m(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||Cm(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 su(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=An));else if(o!==4&&(t=t.child,t!==null))for(su(t,n,i),t=t.sibling;t!==null;)su(t,n,i),t=t.sibling}function au(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(au(t,n,i),t=t.sibling;t!==null;)au(t,n,i),t=t.sibling}var vn=null,ks=!1;function Da(t,n,i){for(i=i.child;i!==null;)Em(t,n,i),i=i.sibling}function Em(t,n,i){if(hn&&typeof hn.onCommitFiberUnmount=="function")try{hn.onCommitFiberUnmount(cs,i)}catch{}switch(i.tag){case 5:Nn||_i(i,n);case 6:var o=vn,h=ks;vn=null,Da(t,n,i),vn=o,ks=h,vn!==null&&(ks?(t=vn,i=i.stateNode,t.nodeType===8?t.parentNode.removeChild(i):t.removeChild(i)):vn.removeChild(i.stateNode));break;case 18:vn!==null&&(ks?(t=vn,i=i.stateNode,t.nodeType===8?ll(t.parentNode,i):t.nodeType===1&&ll(t,i),xa(t)):ll(vn,i.stateNode));break;case 4:o=vn,h=ks,vn=i.stateNode.containerInfo,ks=!0,Da(t,n,i),vn=o,ks=h;break;case 0:case 11:case 14:case 15:if(!Nn&&(o=i.updateQueue,o!==null&&(o=o.lastEffect,o!==null))){h=o=o.next;do{var g=h,j=g.destroy;g=g.tag,j!==void 0&&((g&2)!==0||(g&4)!==0)&&tu(i,n,j),h=h.next}while(h!==o)}Da(t,n,i);break;case 1:if(!Nn&&(_i(i,n),o=i.stateNode,typeof o.componentWillUnmount=="function"))try{o.props=i.memoizedProps,o.state=i.memoizedState,o.componentWillUnmount()}catch(P){Ut(i,n,P)}Da(t,n,i);break;case 21:Da(t,n,i);break;case 22:i.mode&1?(Nn=(o=Nn)||i.memoizedState!==null,Da(t,n,i),Nn=o):Da(t,n,i);break;default:Da(t,n,i)}}function Tm(t){var n=t.updateQueue;if(n!==null){t.updateQueue=null;var i=t.stateNode;i===null&&(i=t.stateNode=new yp),n.forEach(function(o){var h=Ep.bind(null,t,o);i.has(o)||(i.add(o),o.then(h,h))})}}function Ss(t,n){var i=n.deletions;if(i!==null)for(var o=0;o<i.length;o++){var h=i[o];try{var g=t,j=n,P=j;e:for(;P!==null;){switch(P.tag){case 5:vn=P.stateNode,ks=!1;break e;case 3:vn=P.stateNode.containerInfo,ks=!0;break e;case 4:vn=P.stateNode.containerInfo,ks=!0;break e}P=P.return}if(vn===null)throw Error(r(160));Em(g,j,h),vn=null,ks=!1;var B=h.alternate;B!==null&&(B.return=null),h.return=null}catch(me){Ut(h,n,me)}}if(n.subtreeFlags&12854)for(n=n.child;n!==null;)Am(n,t),n=n.sibling}function Am(t,n){var i=t.alternate,o=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:if(Ss(n,t),Bs(t),o&4){try{yl(3,t,t.return),Ro(3,t)}catch(Xe){Ut(t,t.return,Xe)}try{yl(5,t,t.return)}catch(Xe){Ut(t,t.return,Xe)}}break;case 1:Ss(n,t),Bs(t),o&512&&i!==null&&_i(i,i.return);break;case 5:if(Ss(n,t),Bs(t),o&512&&i!==null&&_i(i,i.return),t.flags&32){var h=t.stateNode;try{ee(h,"")}catch(Xe){Ut(t,t.return,Xe)}}if(o&4&&(h=t.stateNode,h!=null)){var g=t.memoizedProps,j=i!==null?i.memoizedProps:g,P=t.type,B=t.updateQueue;if(t.updateQueue=null,B!==null)try{P==="input"&&g.type==="radio"&&g.name!=null&&de(h,g),ft(P,j);var me=ft(P,g);for(j=0;j<B.length;j+=2){var Ae=B[j],Me=B[j+1];Ae==="style"?et(h,Me):Ae==="dangerouslySetInnerHTML"?ze(h,Me):Ae==="children"?ee(h,Me):D(h,Ae,Me,me)}switch(P){case"input":H(h,g);break;case"textarea":ot(h,g);break;case"select":var Ne=h._wrapperState.wasMultiple;h._wrapperState.wasMultiple=!!g.multiple;var He=g.value;He!=null?Q(h,!!g.multiple,He,!1):Ne!==!!g.multiple&&(g.defaultValue!=null?Q(h,!!g.multiple,g.defaultValue,!0):Q(h,!!g.multiple,g.multiple?[]:"",!1))}h[wr]=g}catch(Xe){Ut(t,t.return,Xe)}}break;case 6:if(Ss(n,t),Bs(t),o&4){if(t.stateNode===null)throw Error(r(162));h=t.stateNode,g=t.memoizedProps;try{h.nodeValue=g}catch(Xe){Ut(t,t.return,Xe)}}break;case 3:if(Ss(n,t),Bs(t),o&4&&i!==null&&i.memoizedState.isDehydrated)try{xa(n.containerInfo)}catch(Xe){Ut(t,t.return,Xe)}break;case 4:Ss(n,t),Bs(t);break;case 13:Ss(n,t),Bs(t),h=t.child,h.flags&8192&&(g=h.memoizedState!==null,h.stateNode.isHidden=g,!g||h.alternate!==null&&h.alternate.memoizedState!==null||(lu=It())),o&4&&Tm(t);break;case 22:if(Ae=i!==null&&i.memoizedState!==null,t.mode&1?(Nn=(me=Nn)||Ae,Ss(n,t),Nn=me):Ss(n,t),Bs(t),o&8192){if(me=t.memoizedState!==null,(t.stateNode.isHidden=me)&&!Ae&&(t.mode&1)!==0)for(Qe=t,Ae=t.child;Ae!==null;){for(Me=Qe=Ae;Qe!==null;){switch(Ne=Qe,He=Ne.child,Ne.tag){case 0:case 11:case 14:case 15:yl(4,Ne,Ne.return);break;case 1:_i(Ne,Ne.return);var Je=Ne.stateNode;if(typeof Je.componentWillUnmount=="function"){o=Ne,i=Ne.return;try{n=o,Je.props=n.memoizedProps,Je.state=n.memoizedState,Je.componentWillUnmount()}catch(Xe){Ut(o,i,Xe)}}break;case 5:_i(Ne,Ne.return);break;case 22:if(Ne.memoizedState!==null){Mm(Me);continue}}He!==null?(He.return=Ne,Qe=He):Mm(Me)}Ae=Ae.sibling}e:for(Ae=null,Me=t;;){if(Me.tag===5){if(Ae===null){Ae=Me;try{h=Me.stateNode,me?(g=h.style,typeof g.setProperty=="function"?g.setProperty("display","none","important"):g.display="none"):(P=Me.stateNode,B=Me.memoizedProps.style,j=B!=null&&B.hasOwnProperty("display")?B.display:null,P.style.display=Ke("display",j))}catch(Xe){Ut(t,t.return,Xe)}}}else if(Me.tag===6){if(Ae===null)try{Me.stateNode.nodeValue=me?"":Me.memoizedProps}catch(Xe){Ut(t,t.return,Xe)}}else if((Me.tag!==22&&Me.tag!==23||Me.memoizedState===null||Me===t)&&Me.child!==null){Me.child.return=Me,Me=Me.child;continue}if(Me===t)break e;for(;Me.sibling===null;){if(Me.return===null||Me.return===t)break e;Ae===Me&&(Ae=null),Me=Me.return}Ae===Me&&(Ae=null),Me.sibling.return=Me.return,Me=Me.sibling}}break;case 19:Ss(n,t),Bs(t),o&4&&Tm(t);break;case 21:break;default:Ss(n,t),Bs(t)}}function Bs(t){var n=t.flags;if(n&2){try{e:{for(var i=t.return;i!==null;){if(Cm(i)){var o=i;break e}i=i.return}throw Error(r(160))}switch(o.tag){case 5:var h=o.stateNode;o.flags&32&&(ee(h,""),o.flags&=-33);var g=$m(t);au(t,g,h);break;case 3:case 4:var j=o.stateNode.containerInfo,P=$m(t);su(t,P,j);break;default:throw Error(r(161))}}catch(B){Ut(t,t.return,B)}t.flags&=-3}n&4096&&(t.flags&=-4097)}function bp(t,n,i){Qe=t,Rm(t)}function Rm(t,n,i){for(var o=(t.mode&1)!==0;Qe!==null;){var h=Qe,g=h.child;if(h.tag===22&&o){var j=h.memoizedState!==null||Ao;if(!j){var P=h.alternate,B=P!==null&&P.memoizedState!==null||Nn;P=Ao;var me=Nn;if(Ao=j,(Nn=B)&&!me)for(Qe=h;Qe!==null;)j=Qe,B=j.child,j.tag===22&&j.memoizedState!==null?zm(h):B!==null?(B.return=j,Qe=B):zm(h);for(;g!==null;)Qe=g,Rm(g),g=g.sibling;Qe=h,Ao=P,Nn=me}Lm(t)}else(h.subtreeFlags&8772)!==0&&g!==null?(g.return=h,Qe=g):Lm(t)}}function Lm(t){for(;Qe!==null;){var n=Qe;if((n.flags&8772)!==0){var i=n.alternate;try{if((n.flags&8772)!==0)switch(n.tag){case 0:case 11:case 15:Nn||Ro(5,n);break;case 1:var o=n.stateNode;if(n.flags&4&&!Nn)if(i===null)o.componentDidMount();else{var h=n.elementType===n.type?i.memoizedProps:js(n.type,i.memoizedProps);o.componentDidUpdate(h,i.memoizedState,o.__reactInternalSnapshotBeforeUpdate)}var g=n.updateQueue;g!==null&&Md(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}Md(n,j,i)}break;case 5:var P=n.stateNode;if(i===null&&n.flags&4){i=P;var B=n.memoizedProps;switch(n.type){case"button":case"input":case"select":case"textarea":B.autoFocus&&i.focus();break;case"img":B.src&&(i.src=B.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(n.memoizedState===null){var me=n.alternate;if(me!==null){var Ae=me.memoizedState;if(Ae!==null){var Me=Ae.dehydrated;Me!==null&&xa(Me)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(r(163))}Nn||n.flags&512&&nu(n)}catch(Ne){Ut(n,n.return,Ne)}}if(n===t){Qe=null;break}if(i=n.sibling,i!==null){i.return=n.return,Qe=i;break}Qe=n.return}}function Mm(t){for(;Qe!==null;){var n=Qe;if(n===t){Qe=null;break}var i=n.sibling;if(i!==null){i.return=n.return,Qe=i;break}Qe=n.return}}function zm(t){for(;Qe!==null;){var n=Qe;try{switch(n.tag){case 0:case 11:case 15:var i=n.return;try{Ro(4,n)}catch(B){Ut(n,i,B)}break;case 1:var o=n.stateNode;if(typeof o.componentDidMount=="function"){var h=n.return;try{o.componentDidMount()}catch(B){Ut(n,h,B)}}var g=n.return;try{nu(n)}catch(B){Ut(n,g,B)}break;case 5:var j=n.return;try{nu(n)}catch(B){Ut(n,j,B)}}}catch(B){Ut(n,n.return,B)}if(n===t){Qe=null;break}var P=n.sibling;if(P!==null){P.return=n.return,Qe=P;break}Qe=n.return}}var wp=Math.ceil,Lo=K.ReactCurrentDispatcher,ru=K.ReactCurrentOwner,rs=K.ReactCurrentBatchConfig,bt=0,dn=null,en=null,yn=0,ts=0,gi=xs(0),ln=0,xl=null,Cr=0,Mo=0,iu=0,bl=null,Bn=null,lu=0,vi=1/0,da=null,zo=!1,ou=null,Fa=null,Po=!1,qa=null,Io=0,wl=0,cu=null,Oo=-1,Do=0;function Ln(){return(bt&6)!==0?It():Oo!==-1?Oo:Oo=It()}function Ba(t){return(t.mode&1)===0?1:(bt&2)!==0&&yn!==0?yn&-yn:rp.transition!==null?(Do===0&&(Do=Vt()),Do):(t=kt,t!==0||(t=window.event,t=t===void 0?16:Li(t.type)),t)}function Ns(t,n,i,o){if(50<wl)throw wl=0,cu=null,Error(r(185));Rs(t,i,o),((bt&2)===0||t!==dn)&&(t===dn&&((bt&2)===0&&(Mo|=i),ln===4&&Ua(t,yn)),Un(t,o),i===1&&bt===0&&(n.mode&1)===0&&(vi=It()+500,ye&&$t()))}function Un(t,n){var i=t.callbackNode;Wr(t,n);var o=bn(t,t===dn?yn:0);if(o===0)i!==null&&Ei(i),t.callbackNode=null,t.callbackPriority=0;else if(n=o&-o,t.callbackPriority!==n){if(i!=null&&Ei(i),n===1)t.tag===0?Ve(Im.bind(null,t)):Ue(Im.bind(null,t)),il(function(){(bt&6)===0&&$t()}),i=null;else{switch(Gt(o)){case 1:i=Fr;break;case 4:i=tr;break;case 16:i=Ks;break;case 536870912:i=qr;break;default:i=Ks}i=Hm(i,Pm.bind(null,t))}t.callbackPriority=n,t.callbackNode=i}}function Pm(t,n){if(Oo=-1,Do=0,(bt&6)!==0)throw Error(r(327));var i=t.callbackNode;if(yi()&&t.callbackNode!==i)return null;var o=bn(t,t===dn?yn:0);if(o===0)return null;if((o&30)!==0||(o&t.expiredLanes)!==0||n)n=Fo(t,o);else{n=o;var h=bt;bt|=2;var g=Dm();(dn!==t||yn!==n)&&(da=null,vi=It()+500,Er(t,n));do try{Sp();break}catch(P){Om(t,P)}while(!0);Cc(),Lo.current=g,bt=h,en!==null?n=0:(dn=null,yn=0,n=ln)}if(n!==0){if(n===2&&(h=As(t),h!==0&&(o=h,n=uu(t,h))),n===1)throw i=xl,Er(t,0),Ua(t,o),Un(t,It()),i;if(n===6)Ua(t,o);else{if(h=t.current.alternate,(o&30)===0&&!jp(h)&&(n=Fo(t,o),n===2&&(g=As(t),g!==0&&(o=g,n=uu(t,g))),n===1))throw i=xl,Er(t,0),Ua(t,o),Un(t,It()),i;switch(t.finishedWork=h,t.finishedLanes=o,n){case 0:case 1:throw Error(r(345));case 2:Tr(t,Bn,da);break;case 3:if(Ua(t,o),(o&130023424)===o&&(n=lu+500-It(),10<n)){if(bn(t,0)!==0)break;if(h=t.suspendedLanes,(h&o)!==o){Ln(),t.pingedLanes|=t.suspendedLanes&h;break}t.timeoutHandle=Fn(Tr.bind(null,t,Bn,da),n);break}Tr(t,Bn,da);break;case 4:if(Ua(t,o),(o&4194240)===o)break;for(n=t.eventTimes,h=-1;0<o;){var j=31-pn(o);g=1<<j,j=n[j],j>h&&(h=j),o&=~g}if(o=h,o=It()-o,o=(120>o?120:480>o?480:1080>o?1080:1920>o?1920:3e3>o?3e3:4320>o?4320:1960*wp(o/1960))-o,10<o){t.timeoutHandle=Fn(Tr.bind(null,t,Bn,da),o);break}Tr(t,Bn,da);break;case 5:Tr(t,Bn,da);break;default:throw Error(r(329))}}}return Un(t,It()),t.callbackNode===i?Pm.bind(null,t):null}function uu(t,n){var i=bl;return t.current.memoizedState.isDehydrated&&(Er(t,n).flags|=256),t=Fo(t,n),t!==2&&(n=Bn,Bn=i,n!==null&&du(n)),t}function du(t){Bn===null?Bn=t:Bn.push.apply(Bn,t)}function jp(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 h=i[o],g=h.getSnapshot;h=h.value;try{if(!Yn(g(),h))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 Ua(t,n){for(n&=~iu,n&=~Mo,t.suspendedLanes|=n,t.pingedLanes&=~n,t=t.expirationTimes;0<n;){var i=31-pn(n),o=1<<i;t[i]=-1,n&=~o}}function Im(t){if((bt&6)!==0)throw Error(r(327));yi();var n=bn(t,0);if((n&1)===0)return Un(t,It()),null;var i=Fo(t,n);if(t.tag!==0&&i===2){var o=As(t);o!==0&&(n=o,i=uu(t,o))}if(i===1)throw i=xl,Er(t,0),Ua(t,n),Un(t,It()),i;if(i===6)throw Error(r(345));return t.finishedWork=t.current.alternate,t.finishedLanes=n,Tr(t,Bn,da),Un(t,It()),null}function mu(t,n){var i=bt;bt|=1;try{return t(n)}finally{bt=i,bt===0&&(vi=It()+500,ye&&$t())}}function $r(t){qa!==null&&qa.tag===0&&(bt&6)===0&&yi();var n=bt;bt|=1;var i=rs.transition,o=kt;try{if(rs.transition=null,kt=1,t)return t()}finally{kt=o,rs.transition=i,bt=n,(bt&6)===0&&$t()}}function fu(){ts=gi.current,At(gi)}function Er(t,n){t.finishedWork=null,t.finishedLanes=0;var i=t.timeoutHandle;if(i!==-1&&(t.timeoutHandle=-1,oi(i)),en!==null)for(i=en.return;i!==null;){var o=i;switch(Jt(o),o.tag){case 1:o=o.type.childContextTypes,o!=null&&v();break;case 3:hi(),At(gn),At(an),zc();break;case 5:Lc(o);break;case 4:hi();break;case 13:At(Ft);break;case 19:At(Ft);break;case 10:$c(o.type._context);break;case 22:case 23:fu()}i=i.return}if(dn=t,en=t=Wa(t.current,null),yn=ts=n,ln=0,xl=null,iu=Mo=Cr=0,Bn=bl=null,kr!==null){for(n=0;n<kr.length;n++)if(i=kr[n],o=i.interleaved,o!==null){i.interleaved=null;var h=o.next,g=i.pending;if(g!==null){var j=g.next;g.next=h,o.next=j}i.pending=o}kr=null}return t}function Om(t,n){do{var i=en;try{if(Cc(),jo.current=Co,ko){for(var o=qt.memoizedState;o!==null;){var h=o.queue;h!==null&&(h.pending=null),o=o.next}ko=!1}if(Nr=0,un=rn=qt=null,hl=!1,pl=0,ru.current=null,i===null||i.return===null){ln=1,xl=n,en=null;break}e:{var g=t,j=i.return,P=i,B=n;if(n=yn,P.flags|=32768,B!==null&&typeof B=="object"&&typeof B.then=="function"){var me=B,Ae=P,Me=Ae.tag;if((Ae.mode&1)===0&&(Me===0||Me===11||Me===15)){var Ne=Ae.alternate;Ne?(Ae.updateQueue=Ne.updateQueue,Ae.memoizedState=Ne.memoizedState,Ae.lanes=Ne.lanes):(Ae.updateQueue=null,Ae.memoizedState=null)}var He=cm(j);if(He!==null){He.flags&=-257,um(He,j,P,g,n),He.mode&1&&om(g,me,n),n=He,B=me;var Je=n.updateQueue;if(Je===null){var Xe=new Set;Xe.add(B),n.updateQueue=Xe}else Je.add(B);break e}else{if((n&1)===0){om(g,me,n),hu();break e}B=Error(r(426))}}else if(Ot&&P.mode&1){var Yt=cm(j);if(Yt!==null){(Yt.flags&65536)===0&&(Yt.flags|=256),um(Yt,j,P,g,n),Sc(pi(B,P));break e}}g=B=pi(B,P),ln!==4&&(ln=2),bl===null?bl=[g]:bl.push(g),g=j;do{switch(g.tag){case 3:g.flags|=65536,n&=-n,g.lanes|=n;var ae=im(g,B,n);Ld(g,ae);break e;case 1:P=B;var G=g.type,le=g.stateNode;if((g.flags&128)===0&&(typeof G.getDerivedStateFromError=="function"||le!==null&&typeof le.componentDidCatch=="function"&&(Fa===null||!Fa.has(le)))){g.flags|=65536,n&=-n,g.lanes|=n;var De=lm(g,P,n);Ld(g,De);break e}}g=g.return}while(g!==null)}qm(i)}catch(Ze){n=Ze,en===i&&i!==null&&(en=i=i.return);continue}break}while(!0)}function Dm(){var t=Lo.current;return Lo.current=Co,t===null?Co:t}function hu(){(ln===0||ln===3||ln===2)&&(ln=4),dn===null||(Cr&268435455)===0&&(Mo&268435455)===0||Ua(dn,yn)}function Fo(t,n){var i=bt;bt|=2;var o=Dm();(dn!==t||yn!==n)&&(da=null,Er(t,n));do try{kp();break}catch(h){Om(t,h)}while(!0);if(Cc(),bt=i,Lo.current=o,en!==null)throw Error(r(261));return dn=null,yn=0,ln}function kp(){for(;en!==null;)Fm(en)}function Sp(){for(;en!==null&&!Wl();)Fm(en)}function Fm(t){var n=Wm(t.alternate,t,ts);t.memoizedProps=t.pendingProps,n===null?qm(t):en=n,ru.current=null}function qm(t){var n=t;do{var i=n.alternate;if(t=n.return,(n.flags&32768)===0){if(i=gp(i,n,ts),i!==null){en=i;return}}else{if(i=vp(i,n),i!==null){i.flags&=32767,en=i;return}if(t!==null)t.flags|=32768,t.subtreeFlags=0,t.deletions=null;else{ln=6,en=null;return}}if(n=n.sibling,n!==null){en=n;return}en=n=t}while(n!==null);ln===0&&(ln=5)}function Tr(t,n,i){var o=kt,h=rs.transition;try{rs.transition=null,kt=1,Np(t,n,i,o)}finally{rs.transition=h,kt=o}return null}function Np(t,n,i,o){do yi();while(qa!==null);if((bt&6)!==0)throw Error(r(327));i=t.finishedWork;var h=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(ga(t,g),t===dn&&(en=dn=null,yn=0),(i.subtreeFlags&2064)===0&&(i.flags&2064)===0||Po||(Po=!0,Hm(Ks,function(){return yi(),null})),g=(i.flags&15990)!==0,(i.subtreeFlags&15990)!==0||g){g=rs.transition,rs.transition=null;var j=kt;kt=1;var P=bt;bt|=4,ru.current=null,xp(t,i),Am(i,t),ai(br),rr=!!Ma,br=Ma=null,t.current=i,bp(i),Ti(),bt=P,kt=j,rs.transition=g}else t.current=i;if(Po&&(Po=!1,qa=t,Io=h),g=t.pendingLanes,g===0&&(Fa=null),Br(i.stateNode),Un(t,It()),n!==null)for(o=t.onRecoverableError,i=0;i<n.length;i++)h=n[i],o(h.value,{componentStack:h.stack,digest:h.digest});if(zo)throw zo=!1,t=ou,ou=null,t;return(Io&1)!==0&&t.tag!==0&&yi(),g=t.pendingLanes,(g&1)!==0?t===cu?wl++:(wl=0,cu=t):wl=0,$t(),null}function yi(){if(qa!==null){var t=Gt(Io),n=rs.transition,i=kt;try{if(rs.transition=null,kt=16>t?16:t,qa===null)var o=!1;else{if(t=qa,qa=null,Io=0,(bt&6)!==0)throw Error(r(331));var h=bt;for(bt|=4,Qe=t.current;Qe!==null;){var g=Qe,j=g.child;if((Qe.flags&16)!==0){var P=g.deletions;if(P!==null){for(var B=0;B<P.length;B++){var me=P[B];for(Qe=me;Qe!==null;){var Ae=Qe;switch(Ae.tag){case 0:case 11:case 15:yl(8,Ae,g)}var Me=Ae.child;if(Me!==null)Me.return=Ae,Qe=Me;else for(;Qe!==null;){Ae=Qe;var Ne=Ae.sibling,He=Ae.return;if(Nm(Ae),Ae===me){Qe=null;break}if(Ne!==null){Ne.return=He,Qe=Ne;break}Qe=He}}}var Je=g.alternate;if(Je!==null){var Xe=Je.child;if(Xe!==null){Je.child=null;do{var Yt=Xe.sibling;Xe.sibling=null,Xe=Yt}while(Xe!==null)}}Qe=g}}if((g.subtreeFlags&2064)!==0&&j!==null)j.return=g,Qe=j;else e:for(;Qe!==null;){if(g=Qe,(g.flags&2048)!==0)switch(g.tag){case 0:case 11:case 15:yl(9,g,g.return)}var ae=g.sibling;if(ae!==null){ae.return=g.return,Qe=ae;break e}Qe=g.return}}var G=t.current;for(Qe=G;Qe!==null;){j=Qe;var le=j.child;if((j.subtreeFlags&2064)!==0&&le!==null)le.return=j,Qe=le;else e:for(j=G;Qe!==null;){if(P=Qe,(P.flags&2048)!==0)try{switch(P.tag){case 0:case 11:case 15:Ro(9,P)}}catch(Ze){Ut(P,P.return,Ze)}if(P===j){Qe=null;break e}var De=P.sibling;if(De!==null){De.return=P.return,Qe=De;break e}Qe=P.return}}if(bt=h,$t(),hn&&typeof hn.onPostCommitFiberRoot=="function")try{hn.onPostCommitFiberRoot(cs,t)}catch{}o=!0}return o}finally{kt=i,rs.transition=n}}return!1}function Bm(t,n,i){n=pi(i,n),n=im(t,n,1),t=Oa(t,n,1),n=Ln(),t!==null&&(Rs(t,1,n),Un(t,n))}function Ut(t,n,i){if(t.tag===3)Bm(t,t,i);else for(;n!==null;){if(n.tag===3){Bm(n,t,i);break}else if(n.tag===1){var o=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof o.componentDidCatch=="function"&&(Fa===null||!Fa.has(o))){t=pi(i,t),t=lm(n,t,1),n=Oa(n,t,1),t=Ln(),n!==null&&(Rs(n,1,t),Un(n,t));break}}n=n.return}}function Cp(t,n,i){var o=t.pingCache;o!==null&&o.delete(n),n=Ln(),t.pingedLanes|=t.suspendedLanes&i,dn===t&&(yn&i)===i&&(ln===4||ln===3&&(yn&130023424)===yn&&500>It()-lu?Er(t,0):iu|=i),Un(t,n)}function Um(t,n){n===0&&((t.mode&1)===0?n=1:(n=Ur,Ur<<=1,(Ur&130023424)===0&&(Ur=4194304)));var i=Ln();t=oa(t,n),t!==null&&(Rs(t,n,i),Un(t,i))}function $p(t){var n=t.memoizedState,i=0;n!==null&&(i=n.retryLane),Um(t,i)}function Ep(t,n){var i=0;switch(t.tag){case 13:var o=t.stateNode,h=t.memoizedState;h!==null&&(i=h.retryLane);break;case 19:o=t.stateNode;break;default:throw Error(r(314))}o!==null&&o.delete(n),Um(t,i)}var Wm;Wm=function(t,n,i){if(t!==null)if(t.memoizedProps!==n.pendingProps||gn.current)qn=!0;else{if((t.lanes&i)===0&&(n.flags&128)===0)return qn=!1,_p(t,n,i);qn=(t.flags&131072)!==0}else qn=!1,Ot&&(n.flags&1048576)!==0&&Zt(n,lt,n.index);switch(n.lanes=0,n.tag){case 2:var o=n.type;To(t,n),t=n.pendingProps;var h=la(n,an.current);fi(n,i),h=Oc(null,n,o,t,h,i);var g=Dc();return n.flags|=1,typeof h=="object"&&h!==null&&typeof h.render=="function"&&h.$$typeof===void 0?(n.tag=1,n.memoizedState=null,n.updateQueue=null,u(o)?(g=!0,R(n)):g=!1,n.memoizedState=h.state!==null&&h.state!==void 0?h.state:null,Ac(n),h.updater=$o,n.stateNode=h,h._reactInternals=n,Hc(n,o,t,i),n=Qc(null,n,o,!0,g,i)):(n.tag=0,Ot&&g&&Lt(n),Rn(null,n,h,i),n=n.child),n;case 16:o=n.elementType;e:{switch(To(t,n),t=n.pendingProps,h=o._init,o=h(o._payload),n.type=o,h=n.tag=Ap(o),t=js(o,t),h){case 0:n=Kc(null,n,o,t,i);break e;case 1:n=_m(null,n,o,t,i);break e;case 11:n=dm(null,n,o,t,i);break e;case 14:n=mm(null,n,o,js(o.type,t),i);break e}throw Error(r(306,o,""))}return n;case 0:return o=n.type,h=n.pendingProps,h=n.elementType===o?h:js(o,h),Kc(t,n,o,h,i);case 1:return o=n.type,h=n.pendingProps,h=n.elementType===o?h:js(o,h),_m(t,n,o,h,i);case 3:e:{if(gm(n),t===null)throw Error(r(387));o=n.pendingProps,g=n.memoizedState,h=g.element,Rd(t,n),bo(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){h=pi(Error(r(423)),n),n=vm(t,n,o,i,h);break e}else if(o!==h){h=pi(Error(r(424)),n),n=vm(t,n,o,i,h);break e}else for(es=gs(n.stateNode.containerInfo.firstChild),cn=n,Ot=!0,ws=null,i=Td(n,null,o,i),n.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if(ui(),o===h){n=ua(t,n,i);break e}Rn(t,n,o,i)}n=n.child}return n;case 5:return zd(n),t===null&&kc(n),o=n.type,h=n.pendingProps,g=t!==null?t.memoizedProps:null,j=h.children,Xn(o,h)?j=null:g!==null&&Xn(o,g)&&(n.flags|=32),pm(t,n),Rn(t,n,j,i),n.child;case 6:return t===null&&kc(n),null;case 13:return ym(t,n,i);case 4:return Rc(n,n.stateNode.containerInfo),o=n.pendingProps,t===null?n.child=di(n,null,o,i):Rn(t,n,o,i),n.child;case 11:return o=n.type,h=n.pendingProps,h=n.elementType===o?h:js(o,h),dm(t,n,o,h,i);case 7:return Rn(t,n,n.pendingProps,i),n.child;case 8:return Rn(t,n,n.pendingProps.children,i),n.child;case 12:return Rn(t,n,n.pendingProps.children,i),n.child;case 10:e:{if(o=n.type._context,h=n.pendingProps,g=n.memoizedProps,j=h.value,Tt(vo,o._currentValue),o._currentValue=j,g!==null)if(Yn(g.value,j)){if(g.children===h.children&&!gn.current){n=ua(t,n,i);break e}}else for(g=n.child,g!==null&&(g.return=n);g!==null;){var P=g.dependencies;if(P!==null){j=g.child;for(var B=P.firstContext;B!==null;){if(B.context===o){if(g.tag===1){B=ca(-1,i&-i),B.tag=2;var me=g.updateQueue;if(me!==null){me=me.shared;var Ae=me.pending;Ae===null?B.next=B:(B.next=Ae.next,Ae.next=B),me.pending=B}}g.lanes|=i,B=g.alternate,B!==null&&(B.lanes|=i),Ec(g.return,i,n),P.lanes|=i;break}B=B.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,P=j.alternate,P!==null&&(P.lanes|=i),Ec(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}Rn(t,n,h.children,i),n=n.child}return n;case 9:return h=n.type,o=n.pendingProps.children,fi(n,i),h=ss(h),o=o(h),n.flags|=1,Rn(t,n,o,i),n.child;case 14:return o=n.type,h=js(o,n.pendingProps),h=js(o.type,h),mm(t,n,o,h,i);case 15:return fm(t,n,n.type,n.pendingProps,i);case 17:return o=n.type,h=n.pendingProps,h=n.elementType===o?h:js(o,h),To(t,n),n.tag=1,u(o)?(t=!0,R(n)):t=!1,fi(n,i),am(n,o,h),Hc(n,o,h,i),Qc(null,n,o,!0,t,i);case 19:return bm(t,n,i);case 22:return hm(t,n,i)}throw Error(r(156,n.tag))};function Hm(t,n){return er(t,n)}function Tp(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 is(t,n,i,o){return new Tp(t,n,i,o)}function pu(t){return t=t.prototype,!(!t||!t.isReactComponent)}function Ap(t){if(typeof t=="function")return pu(t)?1:0;if(t!=null){if(t=t.$$typeof,t===xe)return 11;if(t===ve)return 14}return 2}function Wa(t,n){var i=t.alternate;return i===null?(i=is(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 qo(t,n,i,o,h,g){var j=2;if(o=t,typeof t=="function")pu(t)&&(j=1);else if(typeof t=="string")j=5;else e:switch(t){case ue:return Ar(i.children,h,g,n);case re:j=8,h|=8;break;case Te:return t=is(12,i,n,h|2),t.elementType=Te,t.lanes=g,t;case J:return t=is(13,i,n,h),t.elementType=J,t.lanes=g,t;case ne:return t=is(19,i,n,h),t.elementType=ne,t.lanes=g,t;case Y:return Bo(i,h,g,n);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case je:j=10;break e;case Ce:j=9;break e;case xe:j=11;break e;case ve:j=14;break e;case W:j=16,o=null;break e}throw Error(r(130,t==null?t:typeof t,""))}return n=is(j,i,n,h),n.elementType=t,n.type=o,n.lanes=g,n}function Ar(t,n,i,o){return t=is(7,t,o,n),t.lanes=i,t}function Bo(t,n,i,o){return t=is(22,t,o,n),t.elementType=Y,t.lanes=i,t.stateNode={isHidden:!1},t}function _u(t,n,i){return t=is(6,t,null,n),t.lanes=i,t}function gu(t,n,i){return n=is(4,t.children!==null?t.children:[],t.key,n),n.lanes=i,n.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},n}function Rp(t,n,i,o,h){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=Xt(0),this.expirationTimes=Xt(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Xt(0),this.identifierPrefix=o,this.onRecoverableError=h,this.mutableSourceEagerHydrationData=null}function vu(t,n,i,o,h,g,j,P,B){return t=new Rp(t,n,i,P,B),n===1?(n=1,g===!0&&(n|=8)):n=0,g=is(3,null,null,n),t.current=g,g.stateNode=t,g.memoizedState={element:o,isDehydrated:i,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ac(g),t}function Lp(t,n,i){var o=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:te,key:o==null?null:""+o,children:t,containerInfo:n,implementation:i}}function Vm(t){if(!t)return bs;t=t._reactInternals;e:{if(Ts(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(u(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(u(i))return k(t,i,n)}return n}function Gm(t,n,i,o,h,g,j,P,B){return t=vu(i,o,!0,t,h,g,j,P,B),t.context=Vm(null),i=t.current,o=Ln(),h=Ba(i),g=ca(o,h),g.callback=n??null,Oa(i,g,h),t.current.lanes=h,Rs(t,h,o),Un(t,o),t}function Uo(t,n,i,o){var h=n.current,g=Ln(),j=Ba(h);return i=Vm(i),n.context===null?n.context=i:n.pendingContext=i,n=ca(g,j),n.payload={element:t},o=o===void 0?null:o,o!==null&&(n.callback=o),t=Oa(h,n,j),t!==null&&(Ns(t,h,j,g),xo(t,h,j)),j}function Wo(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 Km(t,n){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var i=t.retryLane;t.retryLane=i!==0&&i<n?i:n}}function yu(t,n){Km(t,n),(t=t.alternate)&&Km(t,n)}function Mp(){return null}var Qm=typeof reportError=="function"?reportError:function(t){console.error(t)};function xu(t){this._internalRoot=t}Ho.prototype.render=xu.prototype.render=function(t){var n=this._internalRoot;if(n===null)throw Error(r(409));Uo(t,n,null,null)},Ho.prototype.unmount=xu.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var n=t.containerInfo;$r(function(){Uo(null,t,null,null)}),n[vs]=null}};function Ho(t){this._internalRoot=t}Ho.prototype.unstable_scheduleHydration=function(t){if(t){var n=Vr();t={blockedOn:null,target:t,priority:n};for(var i=0;i<_n.length&&n!==0&&n<_n[i].priority;i++);_n.splice(i,0,t),i===0&&Pn(t)}};function bu(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function Vo(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11&&(t.nodeType!==8||t.nodeValue!==" react-mount-point-unstable "))}function Jm(){}function zp(t,n,i,o,h){if(h){if(typeof o=="function"){var g=o;o=function(){var me=Wo(j);g.call(me)}}var j=Gm(n,o,t,0,null,!1,!1,"",Jm);return t._reactRootContainer=j,t[vs]=j.current,Aa(t.nodeType===8?t.parentNode:t),$r(),j}for(;h=t.lastChild;)t.removeChild(h);if(typeof o=="function"){var P=o;o=function(){var me=Wo(B);P.call(me)}}var B=vu(t,0,!1,null,null,!1,!1,"",Jm);return t._reactRootContainer=B,t[vs]=B.current,Aa(t.nodeType===8?t.parentNode:t),$r(function(){Uo(n,B,i,o)}),B}function Go(t,n,i,o,h){var g=i._reactRootContainer;if(g){var j=g;if(typeof h=="function"){var P=h;h=function(){var B=Wo(j);P.call(B)}}Uo(n,j,t,h)}else j=zp(i,n,t,h,o);return Wo(j)}us=function(t){switch(t.tag){case 3:var n=t.stateNode;if(n.current.memoizedState.isDehydrated){var i=nr(n.pendingLanes);i!==0&&(Ls(n,i|1),Un(n,It()),(bt&6)===0&&(vi=It()+500,$t()))}break;case 13:$r(function(){var o=oa(t,1);if(o!==null){var h=Ln();Ns(o,t,1,h)}}),yu(t,1)}},Hr=function(t){if(t.tag===13){var n=oa(t,134217728);if(n!==null){var i=Ln();Ns(n,t,134217728,i)}yu(t,134217728)}},zn=function(t){if(t.tag===13){var n=Ba(t),i=oa(t,n);if(i!==null){var o=Ln();Ns(i,t,n,o)}yu(t,n)}},Vr=function(){return kt},Ai=function(t,n){var i=kt;try{return kt=t,n()}finally{kt=i}},ht=function(t,n,i){switch(n){case"input":if(H(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 h=ci(o);if(!h)throw Error(r(90));he(o),H(o,h)}}}break;case"textarea":ot(t,i);break;case"select":n=i.value,n!=null&&Q(t,!!i.multiple,n,!1)}},Ye=mu,vt=$r;var Pp={usingClientEntryPoint:!1,Events:[jr,Pa,ci,ge,Se,mu]},jl={findFiberByHostInstance:ys,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Ip={bundleType:jl.bundleType,version:jl.version,rendererPackageName:jl.rendererPackageName,rendererConfig:jl.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:K.ReactCurrentDispatcher,findHostInstanceByFiber:function(t){return t=Za(t),t===null?null:t.stateNode},findFiberByHostInstance:jl.findFiberByHostInstance||Mp,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 Ko=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Ko.isDisabled&&Ko.supportsFiber)try{cs=Ko.inject(Ip),hn=Ko}catch{}}return Wn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Pp,Wn.createPortal=function(t,n){var i=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!bu(n))throw Error(r(200));return Lp(t,n,null,i)},Wn.createRoot=function(t,n){if(!bu(t))throw Error(r(299));var i=!1,o="",h=Qm;return n!=null&&(n.unstable_strictMode===!0&&(i=!0),n.identifierPrefix!==void 0&&(o=n.identifierPrefix),n.onRecoverableError!==void 0&&(h=n.onRecoverableError)),n=vu(t,1,!1,null,null,i,!1,o,h),t[vs]=n.current,Aa(t.nodeType===8?t.parentNode:t),new xu(n)},Wn.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=Za(n),t=t===null?null:t.stateNode,t},Wn.flushSync=function(t){return $r(t)},Wn.hydrate=function(t,n,i){if(!Vo(n))throw Error(r(200));return Go(null,t,n,!0,i)},Wn.hydrateRoot=function(t,n,i){if(!bu(t))throw Error(r(405));var o=i!=null&&i.hydratedSources||null,h=!1,g="",j=Qm;if(i!=null&&(i.unstable_strictMode===!0&&(h=!0),i.identifierPrefix!==void 0&&(g=i.identifierPrefix),i.onRecoverableError!==void 0&&(j=i.onRecoverableError)),n=Gm(n,null,t,1,i??null,h,!1,g,j),t[vs]=n.current,Aa(t),o)for(t=0;t<o.length;t++)i=o[t],h=i._getVersion,h=h(i._source),n.mutableSourceEagerHydrationData==null?n.mutableSourceEagerHydrationData=[i,h]:n.mutableSourceEagerHydrationData.push(i,h);return new Ho(n)},Wn.render=function(t,n,i){if(!Vo(n))throw Error(r(200));return Go(null,t,n,!1,i)},Wn.unmountComponentAtNode=function(t){if(!Vo(t))throw Error(r(40));return t._reactRootContainer?($r(function(){Go(null,null,t,!1,function(){t._reactRootContainer=null,t[vs]=null})}),!0):!1},Wn.unstable_batchedUpdates=mu,Wn.unstable_renderSubtreeIntoContainer=function(t,n,i,o){if(!Vo(i))throw Error(r(200));if(t==null||t._reactInternals===void 0)throw Error(r(38));return Go(t,n,i,!1,o)},Wn.version="18.3.1-next-f1338f8080-20240426",Wn}var af;function lh(){if(af)return ku.exports;af=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(),ku.exports=Gp(),ku.exports}var rf;function Kp(){if(rf)return Qo;rf=1;var a=lh();return Qo.createRoot=a.createRoot,Qo.hydrateRoot=a.hydrateRoot,Qo}var Qp=Kp();const oh=[{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"]}];oh.map(a=>({id:a.id,label:a.label}));function Jp(a){return`theme-${String(a||"").trim()||"dark"}`}function lf(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(Jp(a))}catch{}}const Ku=[{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}],Qu=[{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 Ku.find(r=>r.id===s)||Ku[1]}function Xp(a){const s=String(a).trim();return Qu.find(r=>r.id===s)||Qu[1]}function of(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{}}function Zp(a){try{return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia(a).matches}catch{return!1}}function e_(a){const[s,r]=f.useState(()=>Zp(a));return f.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const l=window.matchMedia(a),c=()=>r(l.matches);return c(),typeof l.addEventListener=="function"?l.addEventListener("change",c):l.addListener(c),()=>{typeof l.removeEventListener=="function"?l.removeEventListener("change",c):l.removeListener(c)}},[a]),s}let Sl=null;function t_(a,s){const r=Math.max(0,Math.round(a));if(!(s.scale<=1.01))return{vvHeight:r,keyboardInset:0};const l=Math.max(0,Math.min(r,Math.round(s.height))),c=Math.max(0,Math.round(a-s.height-Math.max(0,s.offsetTop)));return{vvHeight:l,keyboardInset:c}}function n_(){if(Sl)return Sl;if(typeof window>"u"||typeof document>"u")return()=>{};const a=window.visualViewport;if(!a)return()=>{};const s=document.documentElement;let r=0;const l=()=>{r=0;const{vvHeight:d,keyboardInset:p}=t_(window.innerHeight,{height:a.height,offsetTop:a.offsetTop,scale:a.scale||1});s.style.setProperty("--vv-height",`${d}px`),s.style.setProperty("--keyboard-inset",`${p}px`)},c=()=>{r||(r=window.requestAnimationFrame(l))};return l(),a.addEventListener("resize",c),a.addEventListener("scroll",c),window.addEventListener("orientationchange",c),Sl=()=>{a.removeEventListener("resize",c),a.removeEventListener("scroll",c),window.removeEventListener("orientationchange",c),r&&window.cancelAnimationFrame(r),s.style.removeProperty("--vv-height"),s.style.removeProperty("--keyboard-inset"),Sl=null},Sl}var ch=lh();function xi(...a){return a.filter(Boolean).join(" ")}function Ir({value:a,options:s,placeholder:r="Select…",disabled:l=!1,loading:c=!1,searchable:d=!0,searchPlaceholder:p="Search…",allowCustom:m=!1,clearable:_=!1,minPopoverWidth:x=240,variant:b="panel",className:y,triggerClassName:C,ariaLabel:A,id:E,includeValueOption:$=!1,onOpen:L,customOptionLabel:q,validateCustomValue:O,onChange:D,renderOption:K,renderValue:T}){const te=f.useRef(null),ue=f.useRef(null),re=f.useRef(null),Te=f.useRef(L),je=f.useId(),Ce=E||`af-select-${je.replace(/[^a-zA-Z0-9_-]/g,"")}`,xe=`${Ce}-listbox`,[J,ne]=f.useState(!1),[ve,W]=f.useState(""),[Y,z]=f.useState(0),[V,U]=f.useState("bottom"),[w,N]=f.useState({left:0,top:0,width:0});f.useEffect(()=>{Te.current=L},[L]);const Z=f.useMemo(()=>{if(!$)return s;const X=String(a??"").trim();return!X||s.some(Q=>Q.value===X)?s:[...s,{value:X,label:X}]},[$,s,a]),pe=f.useMemo(()=>{const X=String(a??"");return Z.find(Q=>Q.value===X)||null},[Z,a]),oe=f.useMemo(()=>(pe==null?void 0:pe.label)||String(a||"").trim()||"",[pe,a]),I=f.useMemo(()=>{const X=ve.trim().toLowerCase();return X?Z.filter(Q=>Q.label.toLowerCase().includes(X)||Q.value.toLowerCase().includes(X)):Z},[Z,ve]),be=f.useMemo(()=>{if(!m)return null;const X=ve.trim();if(!X||Z.some(Ie=>Ie.value===X))return null;const _e=(O==null?void 0:O(X,{options:Z}))||"";return{value:X,label:q?q(X):`Use "${X}"`,disabled:!!_e,reason:_e}},[m,q,Z,ve,O]),Re=f.useMemo(()=>{const X=be?[be,...I]:I;if(X.length>0)return X;const Q=String(a??"").trim();return c&&Q?[{value:Q,label:oe||Q}]:X},[be,I,c,oe,a]),qe=f.useCallback(()=>{const X=te.current;if(!X)return;const Q=X.getBoundingClientRect(),_e=Math.max(Q.width,x),Ie=Math.max(8,Math.min(Q.left,window.innerWidth-_e-8)),ot=window.innerHeight-Q.bottom,ce=Q.top,ke=ot>=220||ot>=ce?"bottom":"top";U(ke);const Be=ke==="bottom"?Q.bottom+6:Q.top-6;N({left:Ie,top:Be,width:_e})},[x]),Oe=f.useCallback(()=>{ne(!1),W("")},[]);f.useEffect(()=>{var X;J&&((X=Te.current)==null||X.call(Te))},[J]),f.useEffect(()=>{if(!J)return;qe();const X=()=>qe();return window.addEventListener("resize",X),window.addEventListener("scroll",X,!0),()=>{window.removeEventListener("resize",X),window.removeEventListener("scroll",X,!0)}},[J,qe]),f.useEffect(()=>{if(!J)return;const X=Q=>{var Ie,ot;const _e=Q.target;_e&&((Ie=te.current)!=null&&Ie.contains(_e)||(ot=ue.current)!=null&&ot.contains(_e)||Oe())};return document.addEventListener("mousedown",X,!0),()=>document.removeEventListener("mousedown",X,!0)},[J,Oe]),f.useEffect(()=>{if(!J)return;const X=Math.max(0,Re.findIndex(Q=>Q.value===a));z(X===-1?0:X),d&&setTimeout(()=>{var Q;return(Q=re.current)==null?void 0:Q.focus()},0)},[J,d,a,Re]);const ut=X=>{var _e;const Q=Re.find(Ie=>Ie.value===X);Q!=null&&Q.disabled||(D(X),Oe(),(_e=te.current)==null||_e.focus())},he=X=>{var Q,_e;if(X.key==="Escape")return X.preventDefault(),Oe(),(Q=te.current)==null||Q.focus(),!0;if(X.key==="Tab")return Oe(),(_e=te.current)==null||_e.focus(),!1;if(X.key==="ArrowDown")return X.preventDefault(),z(Ie=>Math.min(Ie+1,Math.max(0,Re.length-1))),!0;if(X.key==="ArrowUp")return X.preventDefault(),z(Ie=>Math.max(Ie-1,0)),!0;if(X.key==="Home")return X.preventDefault(),z(0),!0;if(X.key==="End")return X.preventDefault(),z(Math.max(0,Re.length-1)),!0;if(X.key==="Enter"){X.preventDefault();const Ie=Re[Y];return Ie&&ut(Ie.value),!0}return!1},Fe=X=>{if(!l){if(J){if(he(X))return;if(X.key===" "&&!d){X.preventDefault();const Q=Re[Y];Q&&ut(Q.value)}return}(X.key==="Enter"||X.key===" "||X.key==="ArrowDown"||X.key==="ArrowUp")&&(X.preventDefault(),ne(!0))}},Le=!!String(a||"").trim(),Ge=Le?oe:r,de=be!=null&&be.disabled?be.reason||"Unavailable":"",H=J&&Re.length>0?`${Ce}-opt-${Y}`:void 0,fe=e.jsx("span",{className:xi("af-select-value",!Le&&"af-select-value--placeholder"),children:c&&!Le?"Loading…":Ge}),we=T?T(pe,String(a||"")):fe;return e.jsxs("span",{className:xi("af-select",b==="pin"?"af-select--pin":"af-select--panel",y),children:[e.jsxs("button",{ref:te,id:Ce,type:"button",className:xi("af-select-trigger",_&&Le&&"af-select-trigger--clearable",C),disabled:l,onMouseDown:X=>X.stopPropagation(),onClick:X=>{X.stopPropagation(),!l&&ne(Q=>!Q)},onKeyDown:Fe,role:d?void 0:"combobox","aria-haspopup":"listbox","aria-expanded":J,"aria-controls":J?xe:void 0,"aria-activedescendant":d?void 0:H,"aria-label":A,children:[we,e.jsx("span",{className:xi("af-select-caret",J&&"af-select-caret--open"),children:"▾"})]}),_&&Le?e.jsx("button",{type:"button",className:"af-select-clear-btn","aria-label":"Clear selection",disabled:l,onMouseDown:X=>{X.preventDefault(),X.stopPropagation()},onClick:X=>{var Q;X.preventDefault(),X.stopPropagation(),D(""),Oe(),(Q=te.current)==null||Q.focus()},title:"Clear",children:"×"}):null,J?ch.createPortal(e.jsxs("div",{ref:ue,className:xi("af-select-popover",V==="top"&&"af-select-popover--top"),style:{position:"fixed",left:`${w.left}px`,top:`${w.top}px`,width:`${w.width}px`},onMouseDown:X=>X.stopPropagation(),onClick:X=>X.stopPropagation(),onWheel:X=>X.stopPropagation(),onKeyDown:he,tabIndex:-1,children:[d?e.jsxs("div",{className:"af-select-search",children:[e.jsx("input",{ref:re,className:"af-select-search-input",value:ve,onChange:X=>W(X.target.value),placeholder:p,onKeyDown:he,role:"combobox","aria-expanded":!0,"aria-controls":xe,"aria-activedescendant":H,"aria-invalid":!!de,"aria-describedby":de?`${Ce}-custom-error`:void 0}),de?e.jsx("div",{id:`${Ce}-custom-error`,className:"af-select-custom-error",role:"alert",children:de}):null]}):null,e.jsx("div",{className:"af-select-options",role:"listbox",id:xe,"aria-label":A,children:c&&Re.length===0?e.jsx("div",{className:"af-select-empty",children:"Loading…"}):Re.length===0?e.jsx("div",{className:"af-select-empty",children:"No results"}):Re.map((X,Q)=>{var Be;const _e=X.value===a,Ie=Q===Y,ot=String(X.group||"").trim(),ce=Q>0?String(((Be=Re[Q-1])==null?void 0:Be.group)||"").trim():"",ke=!!ot&&ot!==ce;return e.jsxs(Wt.Fragment,{children:[ke?e.jsx("div",{className:"af-select-group",role:"presentation",children:ot}):null,e.jsx("div",{id:`${Ce}-opt-${Q}`,role:"option","aria-selected":_e,className:xi("af-select-option",_e&&"af-select-option--selected",Ie&&"af-select-option--highlighted",X.disabled&&"af-select-option--disabled"),title:X.disabled?X.reason||"Unavailable":void 0,onMouseEnter:()=>z(Q),onMouseDown:$e=>{$e.preventDefault(),$e.stopPropagation()},onClick:()=>ut(X.value),"aria-disabled":X.disabled?!0:void 0,children:K?K(X,{selected:_e,highlighted:Ie}):e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"af-select-option-label",children:[e.jsx("span",{children:X.label}),X.reason?e.jsx("small",{className:"af-select-option-reason",children:X.reason}):null]}),_e?e.jsx("span",{className:"af-select-check",children:"✓"}):null]})})]},X.value)})})]}),document.body):null]})}function s_(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 a_(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 r_(a){const s=a.disabled===!0,r=a.layout||"stack",l=a.allowGatewayDefault!==!1,c=String(a.gatewayDefaultLabel||"(gateway default)"),d=String(a.providerLabel||"Provider"),p=String(a.modelLabel||"Model"),m=String(a.providerPlaceholder||"(select)"),_=String(a.modelPlaceholder||"(select)"),x=String(a.provider||"").trim(),b=String(a.model||"").trim(),y=s_(a.providers),C=a_(a.models),A=s||!!a.loadingProviders,E=s||!!a.loadingModels,$=[...l?[{value:"",label:c}]:[],...y.map(q=>({value:q.name,label:q.display_name?`${q.display_name} (${q.name})`:q.name}))],L=[...l?[{value:"",label:c}]:[],...C.map(q=>({value:q,label:q}))];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:d}),e.jsx(Ir,{value:x,options:$,placeholder:l?c:m,disabled:A,loading:!!a.loadingProviders,searchable:!0,allowCustom:a.allowCustomProvider===!0,clearable:l,variant:"panel",triggerClassName:a.selectClassName,ariaLabel:d,onChange:q=>a.onChange({provider:String(q||"").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:p}),e.jsx(Ir,{value:b,options:L,placeholder:l?c:_,disabled:E,loading:!!a.loadingModels,searchable:!0,allowCustom:a.allowCustomModel===!0,clearable:l,variant:"panel",triggerClassName:a.selectClassName,ariaLabel:p,onChange:q=>a.onChange({provider:x,model:String(q||"").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 i_(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 l_(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 cf(a){const s=i_(a);return s===!1?"off":s?String(s.num_draft_tokens):""}function o_(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 c_(a){const s=l_(a.capabilities),r=cf(a.value),l=(s==null?void 0:s.supported_depths.map(String))||[],c=cf(s==null?void 0:s.default),d=a.inheritLabel||"Workflow / Gateway default",p=c?`${d} (${c==="off"?"Off":`depth ${c}`})`:d,m=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(Ir,{ariaLabel:"MTP depth",value:r,placeholder:p,disabled:a.disabled||a.loading,options:[{value:"",label:p},{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(o_(_))}),m?e.jsx("div",{role:"status",className:"af-pmp__hint",children:m}):null]})}function u_(a){var z,V;const s=a.disabled===!0,r=a.value||{provider:"",model:""},l=!String(r.provider||"").trim()&&!String(r.model||"").trim(),[c,d]=f.useState(!l),p=l&&!c,m=f.useRef(l);f.useEffect(()=>{l&&!m.current&&d(!1),m.current=l},[l]);const[_,x]=f.useState([]),[b,y]=f.useState(!1),[C,A]=f.useState(""),[E,$]=f.useState([]),[L,q]=f.useState(!1),[O,D]=f.useState(""),K=f.useRef(a);K.current=a,f.useEffect(()=>{if(p||s)return;let U=!0;return y(!0),(async()=>{try{const w=await K.current.fetchProviders();if(!U)return;x(Array.isArray(w)?w:[]),A("")}catch(w){if(!U)return;x([]),A(`#FALLBACK provider discovery failed: ${String((w==null?void 0:w.message)||w)}`)}finally{U&&y(!1)}})(),()=>{U=!1}},[p,s]);const T=String(r.provider||"").trim();f.useEffect(()=>{if(!T||s){$([]),D(""),q(!1);return}let U=!0;return $([]),q(!0),D(""),(async()=>{try{const w=await K.current.fetchModels(T);if(!U)return;$(Array.isArray(w)?w:[])}catch(w){if(!U)return;$([]),D(`#FALLBACK model discovery failed: ${String((w==null?void 0:w.message)||w)}`)}finally{U&&q(!1)}})(),()=>{U=!1}},[T,s]);const te=f.useMemo(()=>{const U=[..._];return T&&!U.some(w=>w.name===T)&&U.unshift({name:T}),U},[_,T]),ue=String(r.model||"").trim(),re=f.useMemo(()=>{const U=[...E];return ue&&!U.includes(ue)&&U.unshift(ue),U},[E,ue]),Te=a.defaultModeLabel||"Gateway default",je=a.customModeLabel||"Custom",Ce=T||((z=a.effectiveDefault)==null?void 0:z.provider)||"",xe=ue||(T?"":(V=a.effectiveDefault)==null?void 0:V.model)||"",[J,ne]=f.useState({levels:[],error:"",loading:!1}),ve=!!a.fetchModelCapabilities,[W,Y]=f.useState();return f.useEffect(()=>{let U=!0;if(Y(void 0),ne({levels:[],error:"",loading:ve&&!!xe}),!(!ve||!xe||s))return K.current.fetchModelCapabilities(xe,Ce).then(w=>{var oe;if(!U)return;if(w!=null&&w.error)throw new Error(String(w.error));Y(w);const N=(w==null?void 0:w.capabilities)||w||{},Z=N.reasoning_levels||N.thinking_levels,pe=Array.isArray(Z)?[...new Set(Z.filter(I=>typeof I=="string"&&!!I.trim()))]:[];!pe.length&&N.thinking_support===!0&&((oe=N.thinking_control)!=null&&oe.prompt_disable_token)&&pe.push("off","auto"),ne({levels:pe,error:"",loading:!1})}).catch(w=>{U&&ne({levels:[],error:`Reasoning options unavailable: ${String((w==null?void 0:w.message)||w)}`,loading:!1})}),()=>{U=!1}},[Ce,xe,ve,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":p,className:`af-pmp__seg-btn${p?" is-active":""}`,onClick:()=>{d(!1),a.onChange({...r,provider:"",model:"",...ve?{reasoning:""}:{}})},disabled:s,children:Te}),e.jsx("button",{type:"button",role:"tab","aria-selected":!p,className:`af-pmp__seg-btn${p?"":" is-active"}`,onClick:()=>{d(!0)},disabled:s,children:je})]}),p?e.jsx("div",{className:"af-pmp__hint",children:a.defaultHint||"The gateway picks its configured default provider and model for this task."}):e.jsx(r_,{provider:T,model:ue,providers:te,models:re,disabled:s,loadingProviders:b,loadingModels:L,providerError:C||void 0,modelError:O||void 0,providerLabel:a.providerLabel,modelLabel:a.modelLabel,allowGatewayDefault:!1,allowCustomProvider:a.allowCustom!==!1,allowCustomModel:a.allowCustom!==!1,onChange:U=>a.onChange({...r,provider:U.provider,model:U.model,...ve?{reasoning:""}:{}})}),ve&&(J.levels.length>0||r.reasoning)?e.jsxs("div",{className:"af-pmp__reasoning",children:[e.jsx("label",{children:a.reasoningLabel||"Reasoning effort"}),e.jsx(Ir,{ariaLabel:a.reasoningLabel||"Reasoning effort",placeholder:"Workflow / Gateway default",value:r.reasoning||"",options:[{value:"",label:"Workflow / Gateway default"},...J.levels.map(U=>({value:U,label:U})),...r.reasoning&&!J.levels.includes(r.reasoning)?[{value:r.reasoning,label:`${r.reasoning} (saved; not advertised)`}]:[]],disabled:s||J.loading,onChange:U=>a.onChange({...r,reasoning:U})})]}):null,J.error?e.jsx("div",{role:"status",className:"af-pmp__hint",children:J.error}):null,a.enableSpeculation?e.jsx(c_,{value:r.speculation,onChange:U=>a.onChange({...r,speculation:U}),capabilities:W,disabled:s,loading:J.loading,error:J.error?J.error.replace("Reasoning options","MTP options"):void 0}):null]})}function uf(...a){return a.filter(Boolean).join(" ")}function d_({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="Not signed in",statusTone:c="neutral",showGatewayUrl:d=!1,gatewayUrl:p="",gatewayUrlPlaceholder:m="http://127.0.0.1:8080",onGatewayUrlChange:_,userId:x,userPlaceholder:b="admin",onUserIdChange:y,token:C,tokenPlaceholder:A="Paste Gateway user token",showToken:E=!1,onTokenChange:$,onShowTokenChange:L,remember:q=!1,rememberLabel:O="Remember this browser",onRememberChange:D,loading:K=!1,submitting:T=!1,submitDisabled:te=!1,submitLabel:ue="Sign in",submittingLabel:re="Signing in...",closeLabel:Te="Close",signOutLabel:je="Sign out",showClose:Ce=!1,showSignOut:xe=!1,error:J,message:ne,className:ve,onSubmit:W,onClose:Y,onSignOut:z}){const V=K||T,U=V||te||!String(x||"").trim()||!String(C||"").trim(),w=N=>{N.preventDefault(),!U&&W()};return e.jsxs("form",{className:uf("af-gateway-signin",ve),onSubmit:w,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.jsx("div",{className:"af-gateway-signin__status-row",children:e.jsx("span",{className:uf("af-gateway-signin__status",`af-gateway-signin__status--${c}`),children:l})}),e.jsxs("div",{className:"af-gateway-signin__form",children:[d?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:N=>_==null?void 0:_(N.target.value),placeholder:m,autoComplete:"url",disabled:V})]}):null,e.jsx("label",{className:"af-gateway-signin__label",htmlFor:"gateway-session-user",children:"Gateway user"}),e.jsx("input",{id:"gateway-session-user",value:x,onChange:N=>y(N.target.value),placeholder:b,autoComplete:"username",disabled:V}),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:E?"text":"password",value:C,onChange:N=>$(N.target.value),placeholder:A,autoComplete:"current-password",disabled:V}),e.jsx("button",{className:"af-gateway-signin__secondary",type:"button",onClick:()=>L==null?void 0:L(!E),disabled:V,children:E?"Hide":"Show"})]}),e.jsxs("label",{className:"af-gateway-signin__checkbox",children:[e.jsx("input",{type:"checkbox",checked:!!q,onChange:N=>D==null?void 0:D(N.target.checked),disabled:V}),O]})]}),J?e.jsx("div",{className:"af-gateway-signin__message af-gateway-signin__message--error",children:J}):null,!J&&ne?e.jsx("div",{className:"af-gateway-signin__message af-gateway-signin__message--ok",children:ne}):null,e.jsxs("div",{className:"af-gateway-signin__actions",children:[Ce?e.jsx("button",{className:"af-gateway-signin__secondary",type:"button",onClick:Y,disabled:V,children:Te}):null,xe?e.jsx("button",{className:"af-gateway-signin__secondary",type:"button",onClick:()=>void(z==null?void 0:z()),disabled:V,children:je}):null,e.jsx("button",{className:"af-gateway-signin__primary",type:"submit",disabled:U,children:T?re:ue})]})]})}function m_(a){return a==="light"?"Light":"Dark"}function f_(a){const s=a.themes&&a.themes.length?a.themes:oh,r=a.showSwatches!==!1,l=a.variant||"panel",c=f.useMemo(()=>{const p={};for(const m of s)p[m.id]=m;return p},[s]),d=f.useMemo(()=>s.map(p=>({value:p.id,label:p.label,group:m_(p.group)})),[s]);return e.jsx(Ir,{value:a.value,options:d,placeholder:a.placeholder||"Select theme…",disabled:a.disabled===!0,searchable:!0,allowCustom:!1,clearable:!1,variant:l,className:a.className,triggerClassName:a.triggerClassName,onChange:p=>a.onChange(String(p||"").trim()),renderValue:(p,m)=>{const _=String(m||"").trim(),x=c[_],b=(x==null?void 0:x.label)||_||a.placeholder||"Select theme…",y=(x==null?void 0:x.swatches)||null,C=!_;return e.jsxs("span",{className:"af-theme-value",children:[e.jsx("span",{className:`af-theme-label ${C?"af-theme-label--placeholder":""}`.trim(),children:b}),r&&y?e.jsx("span",{className:"af-theme-swatches","aria-hidden":"true",children:y.map((A,E)=>e.jsx("span",{className:"af-theme-swatch",style:{background:A}},`${_}:${E}`))}):null]})},renderOption:(p,m)=>{const _=String(p.value||"").trim(),x=c[_],b=(x==null?void 0:x.swatches)||null;return e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"af-theme-option-label",children:p.label}),e.jsxs("span",{className:"af-theme-option-right",children:[r&&b?e.jsx("span",{className:"af-theme-swatches","aria-hidden":"true",children:b.map((y,C)=>e.jsx("span",{className:"af-theme-swatch",style:{background:y}},`${_}:${C}`))}):null,m.selected?e.jsx("span",{className:"af-select-check",children:"✓"}):null]})]})}})}function h_(a){const s=a.scales&&a.scales.length?a.scales:Ku,r=a.variant||"panel",l=f.useMemo(()=>s.map(c=>({value:c.id,label:c.label})),[s]);return e.jsx(Ir,{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 p_(a){const s=a.densities&&a.densities.length?a.densities:Qu,r=a.variant||"panel",l=f.useMemo(()=>s.map(c=>({value:c.id,label:c.label})),[s]);return e.jsx(Ir,{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 __=new Set(["board","inbox","server","agent","playCircle","list","gear"]);function g_(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"})]});case"play":return e.jsx("path",{d:"M7 4.5v15a1 1 0 0 0 1.5.86l12-7.5a1 1 0 0 0 0-1.72l-12-7.5A1 1 0 0 0 7 4.5z",fill:"currentColor",stroke:"none"});case"stop":return e.jsx("rect",{x:"5",y:"5",width:"14",height:"14",rx:"2",fill:"currentColor",stroke:"none"});case"folder":return e.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"});case"file":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("path",{d:"M14 2v6h6"})]});case"archive":return e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"2",y:"3",width:"20",height:"5",rx:"1"}),e.jsx("path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8"}),e.jsx("path",{d:"M10 12h4"})]});case"clock":return e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M12 6v6h4"})]});default:return null}}function tt({name:a,size:s=16,className:r,title:l,...c}){const d=l?void 0:!0,p=__.has(a);return e.jsxs("svg",{width:s,height:s,viewBox:p?"0 0 16 16":"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:p?1.4:2,strokeLinecap:"round",strokeLinejoin:"round",className:r,"aria-hidden":d,role:l?"img":"presentation",...c,children:[l?e.jsx("title",{children:l}):null,g_(a)]})}const Ci="api/connection/gateway";function df(a,s){const r=String(s||"");if(r.startsWith("/"))throw new Error(`joinBaseUrl takes a relative path, got ${JSON.stringify(r)}.`);let l=String(a??"");for(;l.endsWith("/");)l=l.slice(0,-1);return l?`${l}/${r}`:r}function v_(a){return!String(a.unavailableReason||"").trim()&&!a.busy}function y_(a){return v_(a)?!a.checked:null}let x_=0;function Si(a){const{label:s,checked:r,onChange:l,description:c,reasonVisible:d=!0,describedBy:p,hint:m,busy:_=!1,variant:x="inline",ariaLabel:b,className:y,id:C,action:A}=a,E=String(a.unavailableReason||"").trim(),$=!!E,L=p||(C?`${C}-reason`:$?`af-switch-reason-${++x_}`:void 0),q=["af-switch",x==="row"?"af-switch--row":x==="sm"?"af-switch--sm":"",$?"af-switch--unavailable":"",y||""].filter(Boolean).join(" "),O=K=>{const T=y_({checked:r,unavailableReason:E,busy:_});if(T===null){K.preventDefault();return}l==null||l(T)},D=e.jsxs("button",{type:"button",role:"switch",id:C,className:q,"data-action":A,"aria-checked":r?"true":"false","aria-disabled":$?"true":void 0,"aria-describedby":$?L:void 0,"aria-busy":_?"true":void 0,"aria-label":b,"aria-description":c?void 0:m,title:$?m?`${E}
41
+ ${m}`:E:m,onClick:O,children:[e.jsx("span",{className:"af-switch__track","aria-hidden":"true",children:e.jsx("span",{className:"af-switch__thumb"})}),e.jsxs("span",{className:"af-switch__text",children:[e.jsx("span",{className:"af-switch__label",children:s}),c?e.jsx("span",{className:"af-switch__desc",children:c}):null]})]});return!$||p?D:e.jsxs("span",{className:x==="row"?"af-switch-wrap af-switch-wrap--row":"af-switch-wrap",children:[D,e.jsx("span",{id:L,className:d?"af-switch__reason":"af-switch__reason af-switch__reason--hidden",children:E})]})}const Cu=1;function Ka(a){return typeof a=="object"&&a!==null&&!Array.isArray(a)}const b_=["granted","denied","structurally_unavailable","trust_gated"],w_=["attachable","requires_review","blocked"],j_=["default","operator","structural"],k_=["grant","deny","clear"],S_=new Set(["__proto__","constructor","prototype"]);function N_(a,s){if(!Ka(a))return{ok:!1,reason:`${s}: cell is not an object`};const r=String(a.availability||"");if(!b_.includes(r))return{ok:!1,reason:`${s}: unknown availability "${r}"`};const l=String(a.provenance||"");if(!j_.includes(l))return{ok:!1,reason:`${s}: unknown provenance "${l}"`};let c;if(r==="trust_gated"){const d=String(a.trust_state||"");if(!w_.includes(d))return{ok:!1,reason:`${s}: trust_gated cell without a valid trust_state ("${d}")`};c=d}for(const d of["assigned","resolved_value","executable"]){const p=a[d];if(p!==void 0&&typeof p!="boolean")return{ok:!1,reason:`${s}: "${d}" 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 uh(a){if(!Ka(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)!==Cu)return{ok:!1,reason:`unsupported schema_version ${s} (this build understands ${Cu}); 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 p of a.phases){if(!Ka(p)||typeof p.id!="string"||!p.id.trim())return{ok:!1,reason:"phase without a string id"};const m=p.id.trim();if(S_.has(m))return{ok:!1,reason:`reserved phase id "${m}"`};if(l.has(m))return{ok:!1,reason:`duplicate phase id "${m}"`};l.add(m),r.push({id:m,label:typeof p.label=="string"?p.label:void 0,hint:typeof p.hint=="string"?p.hint:void 0})}const c=[],d=new Set;for(const p of a.sections){if(!Ka(p)||typeof p.id!="string"||!p.id.trim())return{ok:!1,reason:"section without a string id"};const m=p.id.trim();if(d.has(m))return{ok:!1,reason:`duplicate section id "${m}"`};if(d.add(m),!Array.isArray(p.items))return{ok:!1,reason:`section "${m}" has no items array`};const _=[],x=new Set;for(const b of p.items){if(!Ka(b)||typeof b.id!="string"||!b.id.trim())return{ok:!1,reason:`section "${m}": item without a string id`};const y=b.id.trim();if(x.has(y))return{ok:!1,reason:`section "${m}": duplicate item id "${y}"`};if(x.add(y),b.cells!==void 0&&!Ka(b.cells))return{ok:!1,reason:`section "${m}" item "${y}": cells is not an object`};const C=Object.create(null),A=Ka(b.cells)?b.cells:{};for(const[E,$]of Object.entries(A)){if(!l.has(E))return{ok:!1,reason:`section "${m}" item "${y}": cell for undeclared phase "${E}"`};const L=N_($,`section "${m}" item "${y}" phase "${E}"`);if(!L.ok)return L;C[E]=L.cell}_.push({id:y,label:typeof b.label=="string"?b.label:void 0,description:typeof b.description=="string"?b.description:void 0,cells:C})}c.push({id:m,label:typeof p.label=="string"?p.label:void 0,items:_})}return{ok:!0,payload:{schema_version:Cu,phases:r,sections:c}}}function C_(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 fd(a,s,r,l,c){const d=a.sections.find(E=>E.id===r),p=d==null?void 0:d.items.find(E=>E.id===l),m=p&&p.cells[c]||null,_=C_(s,r,l,c);if(!m)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 x=m.availability==="structurally_unavailable"||m.availability==="trust_gated"&&m.trust_state==="blocked";let b=m.resolved_value;_==="grant"?b=!0:_==="deny"?b=!1:_==="clear"&&(b=m.provenance==="operator"?null:m.resolved_value);const y=m.availability==="trust_gated"&&m.trust_state==="requires_review",C=x?!1:b;let A;return x?A={kind:"blocked",blocked_kind:m.availability==="trust_gated"?"trust":"structural"}:y&&C!==!0?A={kind:"approval"}:A={kind:"tristate",options:["grant","clear","deny"],active_op:_!==null?_:m.assigned?m.resolved_value?"grant":"deny":"clear"},{cell:m,pending:_,effective_value:C,interactive:!x,approval_required:y,standing_config:!x&&m.executable===!1,reason:m.reason||(x?m.availability:null),control:A}}function $_(a,s,r){const l=fd(a,s,r.section,r.item,r.phase);if(!l.cell||!l.interactive)return s;const c=s.filter(m=>!(m.section===r.section&&m.item===r.item&&m.phase===r.phase)),d=l.cell;return r.op==="clear"?d.assigned?[...c,r]:c:d.assigned&&d.provenance==="operator"&&d.resolved_value===(r.op==="grant")?c:[...c,r]}function E_(a,s){const r=new Set,l=[];for(const c of s){if(!Ka(c)||!k_.includes(c.op))continue;const d=`${c.section}\0${c.item}\0${c.phase}`;if(r.has(d))continue;r.add(d);const p=fd(a,[],c.section,c.item,c.phase);!p.cell||!p.interactive||l.push(c)}return l}function T_(a){return a==="grant"?"Grant":a==="deny"?"Deny":"Default"}function A_(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,d=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(p=>e.jsx("button",{type:"button","aria-pressed":l.active_op===p,className:`af-matrix__tri-btn is-${p} ${l.active_op===p?"is-active":""}`.trim(),disabled:r,onClick:()=>a.onAct(p),children:T_(p)},p))}),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:d}),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 R_(a){const s=a.disabled===!0,r=f.useMemo(()=>uh(a.payload),[a.payload]),l=f.useMemo(()=>r.ok?E_(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,d=(p,m,_,x)=>{if(s)return;const b=$_(c,l,{section:p,item:m,phase:_,op:x});a.onPatchesChange(b)};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(p=>e.jsxs("th",{className:"af-matrix__phase",title:p.hint||void 0,children:[e.jsx("span",{className:"af-matrix__phase-label",children:p.label||p.id}),p.hint?e.jsx("span",{className:"af-matrix__phase-hint",children:p.hint}):null]},p.id))]})}),c.sections.map(p=>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:p.label||p.id})}),p.items.map(m=>e.jsxs("tr",{className:"af-matrix__item-row",children:[e.jsx("th",{className:"af-matrix__item",title:m.description||void 0,children:e.jsx("span",{className:"af-matrix__item-name",children:m.label||m.id})}),c.phases.map(_=>{const x=fd(c,l,p.id,m.id,_.id);return e.jsx("td",{className:"af-matrix__cell-td",children:e.jsx(A_,{view:x,cellLabel:`${m.label||m.id} — ${_.label||_.id}`,disabled:s,onAct:b=>d(p.id,m.id,_.id,b)})},_.id)})]},m.id)),p.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]},p.id))]})})]})}async function Ju(a=Ci){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 L_(a,s=Ci){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 dh(a=Ci){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 $u(a){let s=String(a||"").trim();for(let r=0;r<2&&s;r+=1){try{const d=JSON.parse(s);if(typeof d=="string"&&d!==s){s=d.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 M_(a){var d,p;if(!a)return{label:"Signed out",tone:"warn"};if(!a.has_session)return{label:"Signed out",tone:"warn"};const s=a.gateway||{},r=(d=s.principal)==null?void 0:d.user_id,l=(p=s.principal)==null?void 0:p.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 z_(a){const s=a.connectionPath||Ci,[r,l]=f.useState(!1),[c,d]=f.useState(!1),[p,m]=f.useState(null),[_,x]=f.useState(!1);f.useEffect(()=>{a.isOpen||x(!1)},[a.isOpen]);const[b,y]=f.useState(a.defaultGatewayUrl||"http://127.0.0.1:8080"),[C,A]=f.useState("admin"),[E,$]=f.useState(""),[L,q]=f.useState(!1),[O,D]=f.useState(!0),[K,T]=f.useState(""),[te,ue]=f.useState(""),re=f.useMemo(()=>M_(p),[p]),Te=J=>{var ne;m(J),(ne=a.onStatusChange)==null||ne.call(a,J)},je=f.useRef(!1);if(f.useEffect(()=>{var ne;if(!a.isOpen)return;const J=!je.current;if(je.current=!0,J&&a.initialStatus!==void 0&&a.initialStatus!==null){const ve=a.initialStatus;Te(ve),typeof ve.gateway_url=="string"&&ve.gateway_url.trim()&&y($u(ve.gateway_url));const W=(ne=ve.gateway)==null?void 0:ne.principal;W!=null&&W.user_id&&A(W.user_id);return}l(!0),T(""),Ju(s).then(ve=>{var Y;Te(ve),typeof ve.gateway_url=="string"&&ve.gateway_url.trim()&&y($u(ve.gateway_url));const W=(Y=ve.gateway)==null?void 0:Y.principal;W!=null&&W.user_id&&A(W.user_id)}).catch(ve=>T(`Failed to load connection status: ${String((ve==null?void 0:ve.message)||ve)}`)).finally(()=>l(!1))},[a.isOpen]),f.useEffect(()=>{if(!a.isOpen)return;const J=ne=>{ne.key==="Escape"&&!ne.defaultPrevented&&!a.blocking&&(ne.preventDefault(),a.onClose())};return window.addEventListener("keydown",J),()=>window.removeEventListener("keydown",J)},[a.isOpen,a.blocking,a.onClose]),!a.isOpen||_)return null;const Ce=async()=>{d(!0),T(""),ue("");try{const J=$u(b);y(J);const ne=await L_({gateway_url:J,gateway_user_id:C,gateway_token:E,persist:O},s);Te(ne),$(""),x(!0),a.onClose()}catch(J){T(String((J==null?void 0:J.message)||J))}finally{d(!1)}},xe=async()=>{d(!0),T(""),ue("");try{await dh(s),$("");const J=await Ju(s).catch(()=>null);Te(J),ue("Signed out. This browser no longer holds a gateway session.")}catch(J){T(String((J==null?void 0:J.message)||J))}finally{d(!1)}};return e.jsx("div",{className:"af-connect-overlay",role:"presentation",onMouseDown:J=>{!a.blocking&&J.target===J.currentTarget&&a.onClose()},children:e.jsx("div",{className:"af-connect-modal",role:"dialog","aria-modal":"true","aria-label":"Gateway connection",children:e.jsx(d_,{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:re.label,statusTone:re.tone,showGatewayUrl:!0,gatewayUrl:b,onGatewayUrlChange:J=>y(J),userId:C,onUserIdChange:A,token:E,tokenPlaceholder:p!=null&&p.has_session?"(browser session already signed in)":"Paste Gateway user token",showToken:L,onTokenChange:$,onShowTokenChange:q,remember:O,rememberLabel:"Keep this browser signed in",onRememberChange:D,loading:r,submitting:c,submittingLabel:"Signing in...",showClose:!a.blocking,onClose:a.onClose,showSignOut:!a.blocking&&!!(p!=null&&p.has_session),onSignOut:xe,error:K,message:te,onSubmit:Ce})})})}function P_(a){return!!(a&&a.ok===!0&&a.has_session===!0)}function I_(a){const s=a||{},r=s.connectionPath||Ci,l=s.variant||"dismissable",c=f.useRef(s.onStatusChange);c.current=s.onStatusChange;const d=f.useRef(l);d.current=l;const p=f.useRef(!!s.autoOpenMidSession);p.current=!!s.autoOpenMidSession;const[m,_]=f.useState(null),[x,b]=f.useState("loading"),[y,C]=f.useState(!1),A=f.useRef(!1),E=f.useRef(!1),$=f.useRef("loading"),L=f.useRef("none"),q=f.useRef(!1),O=f.useRef(0),D=f.useCallback(ne=>{var W;O.current+=1,_(ne),(W=c.current)==null||W.call(c,ne);const ve=P_(ne);if(ve)b("connected"),$.current="connected",A.current=!1,L.current="none",E.current||C(!1);else if(ne!==null){const Y=$.current;b("disconnected"),$.current="disconnected",Y!=="disconnected"&&(L.current=q.current?"signout":Y==="connected"?"mid":"boot");const z=d.current==="blocking"||L.current!=="mid"||p.current;!A.current&&z&&C(!0)}ne!==null&&(E.current=ve)},[]),K=f.useCallback(async()=>{const ne=O.current;try{const ve=await Ju(r);if(O.current!==ne)return;D(ve)}catch{if(O.current!==ne)return;D(null)}},[r,D]),[T,te]=f.useState(!1),[ue,re]=f.useState(null),Te=f.useCallback(async()=>{te(!0),re(null),O.current+=1;let ne=null;try{await dh(r)}catch(ve){ne=String((ve==null?void 0:ve.message)||ve||"Sign-out request failed")}q.current=!0;try{await K()}finally{q.current=!1}re(ne),te(!1)},[r,K]),je=f.useRef(!1);f.useEffect(()=>{je.current||(je.current=!0,K())},[K]);const Ce=f.useCallback(()=>{C(!0)},[]),xe=f.useCallback(()=>{const ne=$.current;l==="blocking"&&ne==="disconnected"||(ne==="disconnected"&&(A.current=!0),C(!1))},[l]),J=f.useMemo(()=>({isOpen:y,onClose:xe,blocking:l==="blocking"&&x!=="connected",appName:s.appName,connectionPath:r,defaultGatewayUrl:s.defaultGatewayUrl,initialStatus:m,onStatusChange:D}),[y,xe,l,x,s.appName,r,s.defaultGatewayUrl,m,D]);return{status:m,phase:x,connected:x==="connected",modalOpen:y,signingOut:T,signOutError:ue,openModal:Ce,refresh:K,signOut:Te,modalProps:J}}function O_(){return globalThis.crypto}function D_(a){if(a.length<16)throw new Error("uuidV4FromBytes: needs 16 bytes");const s=Array.from(a.subarray(0,16));s[6]=s[6]&15|64,s[8]=s[8]&63|128;const r=s.map(l=>l.toString(16).padStart(2,"0")).join("");return`${r.slice(0,8)}-${r.slice(8,12)}-${r.slice(12,16)}-${r.slice(16,20)}-${r.slice(20)}`}function F_(){const a=O_();if(a&&typeof a.randomUUID=="function")try{return a.randomUUID()}catch{}if(a&&typeof a.getRandomValues=="function")return D_(a.getRandomValues(new Uint8Array(16)));throw new Error("randomId: Web Crypto (crypto.getRandomValues) is unavailable")}function mh(a){return globalThis.isSecureContext!==!1?null:`This page is loaded over http, so ${a} is unavailable — open it over https (for example through tailscale serve; the gateway console's Network page explains how) or on the gateway's own computer.`}const Eu={neutral:"var(--text-secondary)",muted:"var(--text-muted)",accent:"var(--accent)",info:"var(--info)",success:"var(--success)",warning:"var(--warning)",error:"var(--error)"},q_=/^var\(--[a-z0-9-]+\)$/i;function B_(a,s){const r=a||"neutral";if(r==="custom"){const l=String(s||"").trim();return q_.test(l)?l:Eu.neutral}return Eu[r]||Eu.neutral}function U_(a,s,r){return[a,`${a}--${s.tone||"neutral"}`,s.size==="sm"?`${a}--sm`:"",r||"",s.className||""].filter(Boolean).join(" ")}function W_(a){return{"--af-chip-hue":B_(a.tone,a.hue)}}function Hn(a){return e.jsxs("span",{className:U_("af-chip",a,a.onRemove?"af-chip--removable":""),style:W_(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 mf(a){const s=a.closeOnEscape!==!1,r=f.useRef(null);return f.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]),f.useEffect(()=>{const l=r.current;l&&(a.open?l.removeAttribute("inert"):l.setAttribute("inert",""))},[a.open]),e.jsxs(e.Fragment,{children:[a.backdrop&&a.open?e.jsx("div",{className:"af-drawer-backdrop","aria-hidden":"true",onClick:a.onClose,style:{top:a.topOffset||0}}):null,e.jsxs("div",{ref:r,className:`af-drawer${a.side==="left"?" af-drawer--left":""}${a.topOffset?" af-drawer--offset":""}${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})]})]})}const H_={name:"AbstractFramework",website:"https://abstractframework.ai",author:"Laurent-Philippe Albou, PhD",years:"2023-2026",copyright:"© 2023-2026 Laurent-Philippe Albou, PhD. Released under the MIT License.",contact_email:"contact@abstractframework.ai"},V_={abstractframework:{name:"AbstractFramework",website:"https://abstractframework.ai",repo:"https://github.com/lpalbou/AbstractFramework",docs:"https://github.com/lpalbou/AbstractFramework/tree/main/docs",issues:"https://github.com/lpalbou/AbstractFramework/issues",feedback:"https://github.com/lpalbou/AbstractFramework/issues/new?labels=feedback"},abstractgateway:{name:"AbstractGateway",website:"https://abstractframework.ai/gateway",repo:"https://github.com/lpalbou/AbstractGateway",docs:"https://www.lpalbou.info/AbstractGateway/",issues:"https://github.com/lpalbou/AbstractGateway/issues",feedback:"https://github.com/lpalbou/AbstractGateway/issues/new?labels=feedback"},abstractcode:{name:"AbstractCode",website:"https://abstractframework.ai/code",repo:"https://github.com/lpalbou/AbstractCode",docs:"https://github.com/lpalbou/AbstractCode/tree/main/docs",issues:"https://github.com/lpalbou/AbstractCode/issues",feedback:"https://github.com/lpalbou/AbstractCode/issues/new?labels=feedback"},abstractassistant:{name:"AbstractAssistant",website:"https://abstractframework.ai/assistant",repo:"https://github.com/lpalbou/AbstractAssistant",docs:"https://github.com/lpalbou/AbstractAssistant/blob/main/docs/README.md",issues:"https://github.com/lpalbou/AbstractAssistant/issues",feedback:"https://github.com/lpalbou/AbstractAssistant/issues/new?labels=feedback"},abstractflow:{name:"AbstractFlow",website:"https://abstractframework.ai/flow",repo:"https://github.com/lpalbou/AbstractFlow",docs:"https://github.com/lpalbou/AbstractFlow#readme",issues:"https://github.com/lpalbou/AbstractFlow/issues",feedback:"https://github.com/lpalbou/AbstractFlow/issues/new?labels=feedback"},abstractcontinuum:{name:"AbstractContinuum",website:"https://abstractframework.ai",repo:"https://github.com/lpalbou/AbstractContinuum",docs:"https://github.com/lpalbou/AbstractContinuum/tree/main/docs",issues:"https://github.com/lpalbou/AbstractContinuum/issues",feedback:"https://github.com/lpalbou/AbstractContinuum/issues/new?labels=feedback"},abstractentity:{name:"AbstractEntity",website:"https://abstractframework.ai",repo:"https://github.com/lpalbou/AbstractEntity",docs:"https://github.com/lpalbou/AbstractEntity/tree/main/docs",issues:"https://github.com/lpalbou/AbstractEntity/issues",feedback:"https://github.com/lpalbou/AbstractEntity/issues/new?labels=feedback"},abstractobserver:{name:"AbstractObserver",website:"https://abstractframework.ai/observer",repo:"https://github.com/lpalbou/AbstractObserver",docs:"https://github.com/lpalbou/AbstractObserver#readme",issues:"https://github.com/lpalbou/AbstractObserver/issues",feedback:"https://github.com/lpalbou/AbstractObserver/issues/new?labels=feedback"},abstractcore:{name:"AbstractCore",website:"https://www.abstractcore.ai",repo:"https://github.com/lpalbou/AbstractCore",docs:"https://github.com/lpalbou/AbstractCore/tree/main/docs",issues:"https://github.com/lpalbou/AbstractCore/issues",feedback:"https://github.com/lpalbou/AbstractCore/issues/new?labels=feedback"},abstractuic:{name:"AbstractUIC",website:"https://abstractframework.ai",repo:"https://github.com/lpalbou/AbstractUIC",docs:"https://github.com/lpalbou/AbstractUIC/tree/main/docs",issues:"https://github.com/lpalbou/AbstractUIC/issues",feedback:"https://github.com/lpalbou/AbstractUIC/issues/new?labels=feedback"}},G_={framework:H_,apps:V_},lc=G_;function K_(){return Object.keys(lc.apps).sort()}function Q_(a,s){const r=Object.prototype.hasOwnProperty.call(lc.apps,a)?lc.apps[a]:void 0;if(!r)throw new Error(`appIdentity: unknown application id "${a}" (known: ${K_().join(", ")})`);return{id:a,name:r.name,version:s,website:r.website,repo:r.repo,docs:r.docs,issues:r.issues,feedback:r.feedback}}function J_(a,s){const r=lc.framework,l=[["Application",`${a.name} ${a.version}`],["Part of",`${r.name} — ${r.website}`],["Author",`${r.author} (${r.years})`],["Copyright",r.copyright],["Website",a.website],["Source",a.repo],["Documentation",a.docs],["Report an issue",a.issues],["Give feedback",a.feedback],["Contact",r.contact_email]];for(const[c,d]of s||[])l.push([String(c),String(d)]);return l}function Tu(a){return typeof a=="string"?a.trim():""}function ff(a,s){if(s!=null)return[["Gateway",`unavailable (${String(s).trim()||"unknown error"})`]];const r=a&&typeof a=="object"&&!Array.isArray(a)?a:{},l=Tu(r.abstractgateway);if(!l)return[["Gateway","unavailable (the gateway did not report its version)"]];const c=Tu(r.abstractframework),d=[["Gateway",`AbstractGateway ${l}`],["Gateway framework",c?`AbstractFramework ${c}`:"not installed on the gateway host"]],p=r.packages&&typeof r.packages=="object"&&!Array.isArray(r.packages)?r.packages:{},m=Object.keys(p).filter(_=>_!=="abstractgateway"&&_!=="abstractframework").sort((_,x)=>_<x?-1:_>x?1:0);for(const _ of m){const x=Tu(p[_]);x&&d.push([`Gateway package ${_}`,x])}return d}const Y_='a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])';function X_(a,s,r){if(a.key!=="Tab"||!s)return;const l=Array.from(s.querySelectorAll(Y_));if(l.length===0){a.preventDefault();return}const c=l[0],d=l[l.length-1],p=!!r&&s.contains(r);a.shiftKey?(r===c||!p)&&(a.preventDefault(),d.focus()):(r===d||!p)&&(a.preventDefault(),c.focus())}const Z_=/https?:\/\/[^\s<>"]+/g;function eg(a,s){if(a==="Contact")return[{text:s,href:`mailto:${s}`}];const r=[];let l=0;for(const c of s.matchAll(Z_)){const d=c.index??0;d>l&&r.push({text:s.slice(l,d)}),r.push({text:c[0],href:c[0]}),l=d+c[0].length}return(l<s.length||r.length===0)&&r.push({text:s.slice(l)}),r}function tg({label:a,value:s}){return e.jsx("span",{children:eg(a,s).map((r,l)=>r.href===void 0?e.jsx(Wt.Fragment,{children:r.text},l):r.href.startsWith("mailto:")?e.jsx("a",{className:"af-about__link",href:r.href,children:r.text},l):e.jsx("a",{className:"af-about__link",href:r.href,target:"_blank",rel:"noopener noreferrer",children:r.text},l))})}function ng(a){const s=f.useRef(null),r=f.useRef(null),l=f.useId(),c=f.useRef(a.onClose);if(c.current=a.onClose,f.useEffect(()=>{var x;if(!a.open)return;const m=document.activeElement;(x=s.current)==null||x.focus();const _=b=>{if(!b.defaultPrevented){if(b.key==="Escape"){b.preventDefault(),c.current();return}X_(b,r.current,document.activeElement)}};return window.addEventListener("keydown",_),()=>{window.removeEventListener("keydown",_),m&&typeof m.focus=="function"&&m.focus()}},[a.open]),!a.open)return null;const d=a.title||`About ${a.identity.name}`,p=J_(a.identity,a.extraRows);return e.jsx("div",{className:"af-appearance-overlay af-about-overlay",onClick:a.onClose,role:"presentation",children:e.jsxs("div",{ref:r,className:"af-appearance af-about",role:"dialog","aria-modal":"true","aria-labelledby":l,onClick:m=>m.stopPropagation(),children:[e.jsx("div",{className:"af-appearance__title",id:l,children:d}),e.jsx("dl",{className:"af-about__rows",children:p.map(([m,_],x)=>e.jsxs("div",{className:"af-about__row",children:[e.jsx("dt",{className:"af-about__label",children:m}),e.jsx("dd",{className:"af-about__value",children:e.jsx(tg,{label:m,value:_})})]},`${x}:${m}`))}),e.jsx("div",{className:"af-appearance__actions",children:e.jsx("button",{ref:s,type:"button",className:"af-appearance__close",onClick:a.onClose,children:"Close"})})]})})}function sg(a){const{connection:s}=a,r=s.phase,l=s.signingOut===!0,[c,d]=f.useState(!1),p=a.about,m=l?"Signing out…":r==="connected"?"Disconnect":r==="loading"?"Connecting…":"Connect",_=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(tt,{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(tt,{name:"contrast",size:16})}):null,p?e.jsx("button",{type:"button",className:"af-topbar__btn af-topbar__btn--about","aria-label":p.label||`About ${p.identity.name}`,title:p.label||"About","aria-haspopup":"dialog",onClick:()=>{var x;d(!0),(x=p.onOpen)==null||x.call(p)},children:e.jsx(tt,{name:"info",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:_,"aria-label":_,children:[e.jsx("span",{className:`af-topbar__dot af-topbar__dot--${r}`,"aria-hidden":"true"}),e.jsx("span",{className:"af-topbar__pill-label",children:m})]}),p?e.jsx(ng,{open:c,onClose:()=>d(!1),identity:p.identity,extraRows:p.extraRows}):null]})}const ac={theme:"dark",font_scale:"md",header_density:"standard"};function ag(a){const s=a&&typeof a=="object"?a:{};return{theme:typeof s.theme=="string"&&s.theme?s.theme:ac.theme,font_scale:typeof s.font_scale=="string"&&s.font_scale?s.font_scale:ac.font_scale,header_density:typeof s.header_density=="string"&&s.header_density?s.header_density:ac.header_density}}function rg(a){return`af_appearance_${a}_v1`}function ig(a,s){const r=rg(a),l=f.useMemo(()=>({...ac}),[JSON.stringify({})]),[c,d]=f.useState(()=>{let p=l;try{const m=localStorage.getItem(r)??(s!=null&&s.legacyKey?localStorage.getItem(s.legacyKey):null);m&&(p=ag({...l,...JSON.parse(m)}))}catch{}try{lf(p.theme),of({font_scale:p.font_scale,header_density:p.header_density})}catch{}return p});return f.useEffect(()=>{lf(c.theme),of({font_scale:c.font_scale,header_density:c.header_density});try{localStorage.setItem(r,JSON.stringify(c))}catch{}},[r,c]),[c,d]}function lg(a){return f.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(f_,{value:a.value.theme,onChange:s=>a.onChange({...a.value,theme:s})}),e.jsx("label",{className:"af-appearance__label",children:"Font size"}),e.jsx(h_,{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(p_,{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*og(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 p=await r.json().catch(()=>null),m=p&&typeof p=="object"&&p.detail?String(p.detail):`HTTP ${r.status}`;throw new Error(m)}if(!r.body)throw new Error("TTS stream has no body");const l=r.body.getReader(),c=new TextDecoder;let d="";for(;;){const{done:p,value:m}=await l.read();if(p)break;d+=c.decode(m,{stream:!0});let _;for(;(_=d.indexOf(`
42
+ `))>=0;){const x=d.slice(0,_).trim();if(d=d.slice(_+1),!x)continue;let b=null;try{b=JSON.parse(x)}catch{continue}if(b&&b.type==="error")throw new Error(String(b.error||"TTS stream error"));const y=b&&typeof b.audio_b64=="string"?b.audio_b64:"";if(y){const C=atob(y),A=new Uint8Array(C.length);for(let E=0;E<C.length;E+=1)A[E]=C.charCodeAt(E);yield A.buffer}if(b&&(b.type==="done"||b.type==="cancelled"))return}}}finally{s.abort()}}function cg(){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 ug(){if(typeof window>"u")return!1;const a=window;return!!(a!=null&&a.AudioContext||a!=null&&a.webkitAudioContext)}function dg(){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 Au(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 d=l(r);if(d&&typeof d.then=="function")return await d}catch{}return await new Promise((d,p)=>{try{l(r,d,p)}catch(m){p(m)}})}function mg(a){const s=new Uint8Array(a);if(s.length<44)return null;const r=d=>String.fromCharCode(s[d],s[d+1],s[d+2],s[d+3]);if(r(0)!=="RIFF"||r(8)!=="WAVE")return null;const l=new DataView(a);let c=12;for(;c+8<=s.length;){const d=r(c),p=l.getUint32(c+4,!0);if(d==="data")return s.slice(0,c+8);c+=8+p+p%2}return null}function fg(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 fh(a){const s=f.useRef(a);s.current=a;const r=he=>{var Fe,Le;return(Le=(Fe=s.current).on_error)==null?void 0:Le.call(Fe,he)},l=f.useMemo(()=>ug()&&(typeof a.tts=="function"||typeof a.tts_stream=="function"),[a.tts,a.tts_stream]),c=f.useMemo(()=>cg()&&typeof a.transcribe=="function",[a.transcribe]),[d,p]=f.useState({key:"",status:"idle"}),m=f.useRef(d),_=f.useCallback(he=>{m.current=he,p(Fe=>Fe.key===he.key&&Fe.status===he.status?Fe:he)},[]),x=f.useRef(""),b=f.useRef(""),y=f.useRef(null),C=f.useRef(null),A=f.useRef(null),E=f.useRef(null),$=f.useRef(0),L=f.useRef(0),q=f.useRef(0),O=f.useRef([]),D=f.useRef(0),K=f.useRef(!0),T=f.useRef(!1),te=()=>{try{const he=globalThis,Fe=(he==null?void 0:he.AudioContext)||(he==null?void 0:he.webkitAudioContext);if(!Fe)return null;if(!y.current){const de=new Fe,H=de.createGain();H.gain.value=1,H.connect(de.destination),y.current=de,C.current=H}const Le=y.current,Ge=C.current;if(!Le||!Ge)return null;try{Le.state==="suspended"&&Le.resume()}catch{}return{ctx:Le,gain:Ge}}catch{return null}},ue=f.useCallback(()=>{const he=A.current;if(A.current=null,!!he){try{he.onended=null}catch{}try{he.stop()}catch{}try{he.disconnect()}catch{}}},[]),re=f.useCallback(()=>{ue(),q.current+=1,O.current=[],D.current=0,K.current=!0,T.current=!1,b.current="",x.current="",E.current=null,$.current=0,L.current=0,_({key:"",status:"idle"})},[ue,_]);f.useEffect(()=>()=>{var he,Fe;re();try{(he=C.current)==null||he.disconnect()}catch{}try{(Fe=y.current)==null||Fe.close()}catch{}y.current=null,C.current=null,E.current=null},[]);const Te=async(he,Fe,Le)=>{const Ge=q.current,de=te();if(!de)throw new Error("TTS playback is not supported in this browser");const{ctx:H,gain:fe}=de;try{H.state==="suspended"&&await H.resume()}catch{}if(Ge!==q.current)return;ue();const we=H.createBufferSource();we.buffer=Fe,we.connect(fe);const X=Number.isFinite(Number(Fe.duration))?Number(Fe.duration):0,Q=Math.max(0,Math.min(Number(Le||0),X>0?Math.max(0,X-.01):0));L.current=H.currentTime-Q,$.current=Q,A.current=we,x.current=he,we.onended=()=>{A.current===we&&(A.current=null,$.current=0,L.current=0,x.current="",_({key:"",status:"idle"}))},we.start(0,Q),_({key:he,status:"playing"})},je=(he,Fe)=>{if(Fe!==q.current)return;const Le=te();if(!Le)return;const Ge=O.current,de=D.current;if(de>=Ge.length){K.current&&(x.current="",$.current=0,L.current=0,_({key:"",status:"idle"}));return}const H=Ge[de],{ctx:fe,gain:we}=Le;ue();const X=fe.createBufferSource();X.buffer=H,X.connect(we);const Q=Number.isFinite(Number(H.duration))?Number(H.duration):0,_e=Math.max(0,Math.min(Number($.current||0),Q>0?Math.max(0,Q-.01):0));L.current=fe.currentTime-_e,A.current=X,x.current=he,X.onended=()=>{Fe===q.current&&A.current===X&&(A.current=null,D.current=de+1,$.current=0,je(he,Fe))};try{fe.state==="suspended"&&fe.resume()}catch{}X.start(0,_e),_({key:he,status:"playing"})},Ce=async(he,Fe,Le)=>{const Ge=te();if(!Ge){r==null||r("TTS playback is not supported in this browser.");return}ue();const de=++q.current;O.current=[],D.current=0,K.current=!1,T.current=!1,E.current=null,$.current=0,L.current=0,x.current=he,b.current=he,_({key:he,status:"loading"}),r==null||r("");let H=null;try{for await(const fe of Le(Fe)){if(de!==q.current)return;let we;try{we=await Au(Ge.ctx,fe),H||(H=mg(fe))}catch{if(!H)continue;try{we=await Au(Ge.ctx,fg(H,fe))}catch{continue}}if(de!==q.current)return;O.current.push(we),!A.current&&!T.current&&(b.current="",je(he,de))}if(de!==q.current)return;if(K.current=!0,O.current.length===0){r==null||r("TTS stream produced no audio."),re();return}!A.current&&!T.current&&je(he,de)}catch(fe){if(de!==q.current)return;r==null||r(String((fe==null?void 0:fe.message)||fe||"TTS stream failed")),re()}},xe=f.useCallback(async(he,Fe)=>{const Le=String(he||"").trim(),Ge=String(Fe||"").trim();if(!Le||!Ge)return;const de=s.current.tts,H=s.current.tts_stream;if(typeof de!="function"&&typeof H!="function"){r==null||r("TTS is not available.");return}const fe=te();if(!fe){r==null||r("TTS playback is not supported in this browser.");return}const we=m.current,X=we.key===Le;if(X&&we.status==="playing"){if(A.current){const _e=Math.max(0,fe.ctx.currentTime-Number(L.current||0));$.current=_e}else $.current=0;T.current=!0,ue(),_({key:Le,status:"paused"});return}if(X&&we.status==="paused"){if(O.current.length>0){r==null||r(""),T.current=!1,_({key:Le,status:"playing"}),je(Le,q.current);return}const _e=E.current;if(_e){r==null||r(""),T.current=!1;try{await Te(Le,_e,$.current)}catch(Ie){r==null||r(String((Ie==null?void 0:Ie.message)||Ie||"TTS play failed")),_({key:"",status:"idle"})}return}}if(X&&we.status==="loading")return;if(typeof H=="function"){await Ce(Le,Ge,H);return}ue(),q.current+=1;const Q=q.current;O.current=[],D.current=0,K.current=!0,T.current=!1,E.current=null,$.current=0,L.current=0,x.current=Le,b.current=Le,_({key:Le,status:"loading"}),r==null||r("");try{const _e=await de(Ge);if(b.current!==Le||q.current!==Q)return;const Ie=await Au(fe.ctx,_e);if(b.current!==Le||q.current!==Q)return;E.current=Ie,$.current=0,await Te(Le,Ie,0)}catch(_e){if(q.current!==Q)return;b.current===Le&&(b.current="",x.current="",_({key:"",status:"idle"})),r==null||r(String((_e==null?void 0:_e.message)||_e||"TTS failed"))}},[]),[J,ne]=f.useState(!1),[ve,W]=f.useState(!1),Y=f.useRef(!1),z=f.useRef(c);z.current=c;const V=f.useCallback(he=>{Y.current=he,ne(Fe=>Fe===he?Fe:he)},[]),U=f.useRef(!1),w=f.useRef(null),N=f.useRef(null),Z=f.useRef([]),pe=f.useRef(""),oe=f.useRef(0),I=f.useRef(!1);function be(){var he,Fe;try{(Fe=(he=w.current)==null?void 0:he.getTracks)==null||Fe.call(he).forEach(Le=>{try{Le.stop()}catch{}})}catch{}w.current=null}const Re=f.useCallback(()=>{oe.current+=1,I.current=!1;const he=N.current;if(he){he.onstop=null,he.ondataavailable=null,he.onerror=null;try{he.stop()}catch{}}N.current=null,be(),V(!1),U.current=!1,W(!1),Z.current=[]},[V]);f.useEffect(()=>()=>Re(),[Re]);async function qe(he,Fe){var de,H;if(r==null||r(""),!he||!he.size||U.current)return;const Le=s.current.transcribe;if(typeof Le!="function"){r==null||r("Transcription is not available.");return}U.current=!0;const Ge=oe.current;W(!0);try{const fe=String(await Le(he,Fe)||"").trim();Ge===oe.current&&fe&&((H=(de=s.current).on_transcript)==null||H.call(de,fe))}catch(fe){Ge===oe.current&&(r==null||r(String((fe==null?void 0:fe.message)||fe||"Transcription failed")))}finally{Ge===oe.current&&(U.current=!1,W(!1))}}const Oe=f.useCallback(async()=>{if(r==null||r(""),!z.current){r==null||r(mh("the microphone")??"Voice recording is not supported in this browser (MediaRecorder/getUserMedia unavailable).");return}if(U.current||I.current||Y.current||N.current)return;Z.current=[];const he=oe.current;I.current=!0;try{const Fe=await navigator.mediaDevices.getUserMedia({audio:!0});if(he!==oe.current){Fe.getTracks().forEach(de=>de.stop());return}w.current=Fe;const Le=dg();pe.current=Le;const Ge=Le?new MediaRecorder(Fe,{mimeType:Le}):new MediaRecorder(Fe);N.current=Ge,Ge.ondataavailable=de=>{if(he===oe.current)try{de!=null&&de.data&&Z.current.push(de.data)}catch{}},Ge.onerror=()=>{he===oe.current&&(r==null||r("Recording failed."))},Ge.onstop=()=>{if(he===oe.current){V(!1),be(),N.current=null;try{const de=new Blob(Z.current,{type:pe.current||""});qe(de,pe.current)}catch(de){r==null||r(String((de==null?void 0:de.message)||de||"Failed to build recording"))}}},Ge.start(),V(!0)}catch(Fe){if(he!==oe.current)return;be(),N.current=null,V(!1);const Le=String((Fe==null?void 0:Fe.message)||Fe||"Failed to access microphone");r==null||r(Le.toLowerCase().includes("permission")?`Microphone permission denied: ${Le}`:Le)}finally{he===oe.current&&(I.current=!1)}},[]),ut=f.useCallback(()=>{const he=N.current;if(!(!Y.current||!he)){V(!1);try{he.stop()}catch(Fe){r==null||r(String((Fe==null?void 0:Fe.message)||Fe||"Failed to stop recording"))}}},[]);return f.useEffect(()=>{if(!J)return;const he=()=>ut();return window.addEventListener("pointerup",he),window.addEventListener("pointercancel",he),()=>{window.removeEventListener("pointerup",he),window.removeEventListener("pointercancel",he)}},[J]),{tts_supported:l,tts_playback:d,toggle_tts:xe,stop_tts:re,voice_ptt_supported:c,voice_ptt_recording:J,voice_ptt_busy:ve,start_voice_ptt_recording:Oe,stop_voice_ptt_recording:ut,cancel_voice_ptt_recording:Re}}function hg(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 fn(a){var r;const s=String(a||"");if(!s)return!1;try{if(typeof navigator<"u"&&typeof((r=navigator.clipboard)==null?void 0:r.writeText)=="function")return await navigator.clipboard.writeText(s),!0}catch{}try{const l=document.createElement("textarea");l.value=s,l.style.position="fixed",l.style.left="-9999px",document.body.appendChild(l),l.select();const c=document.execCommand("copy")===!0;return document.body.removeChild(l),c}catch{return!1}}const pg=3,_g=Number.MAX_SAFE_INTEGER;function hh(a){return!!a&&typeof a=="object"&&!Array.isArray(a)}function ph(a){return Array.isArray(a)}function gg(a){if(a==null)return"";if(typeof a=="string")return a;try{return JSON.stringify(a,null,2)}catch{return String(a)}}function wi({kind:a,children:s}){return e.jsx("span",{className:`pc-json-token ${a}`,children:s})}function vg(a){const s=JSON.stringify(a.value),r=s.length>96||s.includes("\\n")||s.includes("\\r")||s.includes("\\t"),[l,c]=f.useState(!r||a.expansionMode==="unfolded");return f.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(d=>!d),"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(wi,{kind:"string",children:s})}function yg(a,s,r){return a===null?e.jsx(wi,{kind:"null",children:"null"}):typeof a=="string"?e.jsx(vg,{value:a,expansionMode:s,expansionVersion:r}):typeof a=="number"?e.jsx(wi,{kind:"number",children:String(a)}):typeof a=="boolean"?e.jsx(wi,{kind:"boolean",children:a?"true":"false"}):e.jsx(wi,{kind:"string",children:JSON.stringify(String(a))})}function xg(a){return ph(a)?a.length===1?"1 item":`${a.length} items`:hh(a)?Object.keys(a).length===1?"1 key":`${Object.keys(a).length} keys`:""}function _h(a){const{label:s,value:r,depth:l,collapseAfterDepth:c,expansionMode:d,expansionVersion:p,trailingComma:m}=a,_=l*14,x=hh(r),b=ph(r),y=x||b,C=l<c,[A,E]=f.useState(C);f.useEffect(()=>{E(C)},[C,p]);const $=s?e.jsxs(e.Fragment,{children:[e.jsx(wi,{kind:"key",children:JSON.stringify(s)}),": "]}):null;if(!y)return e.jsxs("div",{className:"pc-json-viewer__line",style:{paddingLeft:_},children:[$,yg(r,d,p),m?",":""]});const L=b?"[":"{",q=b?"]":"}",O=xg(r),D=A?`${L}`:`${L}…${q}${O?` (${O})`:""}`,K=b?r.map((T,te)=>({key:String(te),label:void 0,value:T})):Object.entries(r).map(([T,te])=>({key:T,label:T,value:te}));return e.jsxs("details",{className:"pc-json-viewer__details",open:A,onToggle:T=>E(T.currentTarget.open),children:[e.jsxs("summary",{className:"pc-json-viewer__summary",style:{paddingLeft:_},children:[$,e.jsx("span",{className:"pc-json-viewer__caret","aria-hidden":"true",children:A?"▾":"▸"}),e.jsx("span",{className:"pc-json-viewer__punct",children:D}),!A&&m?e.jsx("span",{className:"pc-json-viewer__punct",children:","}):null]}),A?e.jsx("div",{className:"pc-json-viewer__children",children:K.length===0?e.jsxs("div",{className:"pc-json-viewer__line",style:{paddingLeft:_},children:[e.jsx("span",{className:"pc-json-viewer__punct",children:q}),m?",":""]}):e.jsxs(e.Fragment,{children:[K.map((T,te)=>{const ue=te===K.length-1;return e.jsx(_h,{label:T.label,value:T.value,depth:l+1,collapseAfterDepth:c,expansionMode:d,expansionVersion:p,trailingComma:!ue},`${l}:${s||"root"}:${T.key}`)}),e.jsxs("div",{className:"pc-json-viewer__line",style:{paddingLeft:_},children:[e.jsx("span",{className:"pc-json-viewer__punct",children:q}),m?",":""]})]})}):null]})}function bg(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 rc(a){const{value:s,className:r,showCopy:l=!0}=a,[c,d]=f.useState({mode:"folded",version:0}),[p,m]=f.useState("idle"),_=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):pg,x=c.mode==="unfolded"?_g:_,b=f.useMemo(()=>typeof s=="string"?bg(s):s,[s]),y=f.useMemo(()=>gg(s),[s]),C=["pc-json-viewer",r].filter(Boolean).join(" ");f.useEffect(()=>{d(E=>({mode:"folded",version:E.version+1}))},[b]);const A=()=>{d(E=>({mode:E.mode==="unfolded"?"folded":"unfolded",version:E.version+1}))};return e.jsxs("div",{className:C,children:[e.jsxs("div",{className:"pc-json-viewer__toolbar",children:[e.jsx("button",{type:"button",className:"pc-btn pc-json-viewer__toggle-all",onClick:A,"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 fn(y).then(E=>{m(E?"copied":"failed"),window.setTimeout(()=>m("idle"),2e3)}),children:p==="copied"?"Copied":p==="failed"?"Copy failed — select and copy":"Copy JSON"}):null]}),e.jsx("div",{className:"pc-json-viewer__tree",role:"tree","aria-label":"JSON viewer",children:e.jsx(_h,{value:b,depth:0,collapseAfterDepth:x,expansionMode:c.mode,expansionVersion:c.version,trailingComma:!1})})]})}function Nl(a,s){const r=String(a??"");if(!s||!s.needles.length)return[r];const l=[],c=r.toLowerCase();let d=0;for(;d<r.length;){let p=-1,m="";for(let b=0;b<s.needlesLower.length;b++){const y=s.needlesLower[b];if(!y)continue;const C=c.indexOf(y,d);if(C===-1)continue;const A=s.needles[b]||"";A&&(p===-1||C<p||C===p&&A.length>m.length)&&(p=C,m=A)}if(p===-1||!m){l.push(r.slice(d));break}p>d&&l.push(r.slice(d,p));const _=s.hits===0&&s.id?s.id:void 0,x=r.slice(p,p+m.length);l.push(e.jsx("span",{id:_,className:s.className,children:x},`hl:${s.hits}`)),s.hits+=1,d=p+m.length}return l}function gh(a){const s=String(a||"").trim();if(s&&/^(https?:|mailto:|tel:|#|\/)/i.test(s))return s}const Yu="http://same-origin.invalid/";function wg(a){try{const s=new URL(a,Yu);return s.protocol==="http:"&&s.origin===new URL(Yu).origin}catch{return!1}}function vh(a){const s=String(a||"").trim();return gh(s)??(s&&wg(s)?s:void 0)}let zr=null;function jg(a){const s=String(a||"").trim();if(!s)return!1;const r=typeof document<"u"&&document.baseURI?document.baseURI:null;if(r===null&&/^[a-z][a-z0-9+.-]*:/i.test(s))return!1;const l=r??Yu;let c,d;try{c=new URL(l).origin,d=new URL(s,l)}catch{return!1}return d.protocol!=="http:"&&d.protocol!=="https:"?!1:d.origin===c}function yh(a,s,r){return e.jsx("a",{className:"pc-md_link pc-md_image_link",href:s,target:"_blank",rel:"noopener noreferrer",children:`image: ${r||s}`},a)}function Qa(a,s){const r=[],l=String(a??"");let c=0,d="";const p=()=>{if(d){for(const m of Nl(d,s))r.push(m);d=""}};for(;c<l.length;){const m=l[c];if(m==="!"&&l[c+1]==="["){const _=l.indexOf("]",c+2);if(_!==-1&&l[_+1]==="("){const x=l.indexOf(")",_+2);if(x!==-1){const b=l.slice(c+2,_),y=vh(l.slice(_+2,x));if(y&&zr&&!zr(y)){p(),r.push(yh(`img:${c}`,y,b)),c=x+1;continue}if(y){p(),r.push(e.jsxs("span",{className:"pc-md_image_inline",children:[e.jsx("img",{className:"pc-md_img",src:y,alt:b,loading:"lazy"}),b?e.jsx("span",{className:"pc-md_img_caption",children:s?Nl(b,s):b}):null]},`img:${c}`)),c=x+1;continue}}}}if(m==="["){const _=l.indexOf("]",c+1);if(_!==-1&&l[_+1]==="("){const x=l.indexOf(")",_+2);if(x!==-1){const b=l.slice(c+1,_),y=gh(l.slice(_+2,x));if(y){p(),r.push(e.jsx("a",{className:"pc-md_link",href:y,target:y.startsWith("#")?void 0:"_blank",rel:"noreferrer",children:Qa(b,s)},`link:${c}`)),c=x+1;continue}}}}if(m==="`"){const _=l.indexOf("`",c+1);if(_!==-1){p();const x=l.slice(c+1,_);r.push(e.jsx("code",{children:s?Nl(x,s):x},`code:${c}`)),c=_+1;continue}}if(m==="*"&&l[c+1]==="*"){const _=l.indexOf("**",c+2);if(_!==-1){p();const x=l.slice(c+2,_);r.push(e.jsx("strong",{children:s?Nl(x,s):x},`bold:${c}`)),c=_+2;continue}}if(m==="*"&&l[c+1]!=="*"){const _=l.indexOf("*",c+1);if(_!==-1){p();const x=l.slice(c+1,_);r.push(e.jsx("em",{children:s?Nl(x,s):x},`em:${c}`)),c=_+1;continue}}d+=m,c+=1}return p(),r}function kg(a){return String(a??"").replace(/\r\n/g,`
43
+ `).replace(/\r/g,`
44
+ `).split(`
45
+ `)}function ic(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 Sg(a){const s=[];for(const c of a){const d=ic(c);d?s.push(d):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 d=l.length>0?l[l.length-1]:null;if(d&&c.indent>d.indent){const p=d.node.items,m=p[p.length-1];if(m){const _={ordered:c.ordered,start:c.start,items:[]};m.children.push(_),l.push({indent:c.indent,node:_}),d=l[l.length-1]}}else if(d&&d.node.ordered!==c.ordered){l.pop();const p=l.length>0?l[l.length-1]:null,m={ordered:c.ordered,start:c.start,items:[]};if(p){const _=p.node.items,x=_[_.length-1];x?x.children.push(m):p.node.items.push({content:"",children:[m]})}else r.push(m);l.push({indent:c.indent,node:m}),d=l[l.length-1]}if(!d){const p={ordered:c.ordered,start:c.start,items:[]};r.push(p),l.push({indent:c.indent,node:p}),d=l[l.length-1]}d.node.items.push({content:c.content,children:[]})}return r}function xh(a,s,r){const l=a.items.map((c,d)=>e.jsxs("li",{children:[Qa(c.content,s),c.children.map((p,m)=>xh(p,s,`${r}:${d}:${m}`))]},`${r}:li:${d}`));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 Ng(a,s,r){return Sg(a).map((l,c)=>xh(l,s,`${r}:${c}`))}function hf(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 pf(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))}const _f=/^(#{1,5})\s+(.*)$/;function gf(a){return a.trim().startsWith("```")}function vf(a){return a.trimStart().startsWith(">")}function ls(a){const s=zr;zr=a.images==="link"?a.inlineImage||jg:null;try{return Cg(a)}finally{zr=s}}function Cg({text:a,className:s,highlight:r,highlights:l,highlightClassName:c,highlightId:d}){const p=kg(a),m=[],_=[];Array.isArray(l)&&_.push(...l),typeof r=="string"&&r.trim()&&_.push(r);const x=Array.from(new Set(_.map(A=>String(A??"").trim()).filter(Boolean))).filter(A=>A.length>=4),b=x.length?{needles:x,needlesLower:x.map(A=>A.toLowerCase()),className:c||"pc-md_hl",id:d,hits:0}:null;let y=0;for(;y<p.length;){const A=String(p[y]??"");if(!A.trim()){y+=1;continue}const E=A.trim();if(/^([-_*])(\s*\1){2,}$/.test(E)){m.push(e.jsx("hr",{className:"pc-md_hr"},`hr:${y}`)),y+=1;continue}const $=A.match(/^\s*!\[([^\]]*)\]\(([^)]+)\)\s*$/);if($){const O=vh($[2]||"");if(O&&zr&&!zr(O)){m.push(e.jsx("p",{className:"pc-md_p",children:yh(`img:${y}`,O,$[1]||"")},`p:${y}`)),y+=1;continue}if(O){const D=$[1]||"";m.push(e.jsxs("figure",{className:"pc-md_figure",children:[e.jsx("img",{className:"pc-md_img",src:O,alt:D,loading:"lazy"}),D?e.jsx("figcaption",{children:Qa(D,b)}):null]},`figure:${y}`)),y+=1;continue}}if(gf(A)){const D=A.trim().replace(/```/g,"").trim(),K=[];for(y+=1;y<p.length&&!String(p[y]??"").trim().startsWith("```");)K.push(String(p[y]??"")),y+=1;y<p.length&&(y+=1);const T=K.join(`
46
+ `);m.push(e.jsx("pre",{className:"pc-md_pre",children:e.jsx("code",{className:D?`language-${D}`:void 0,children:T})},`pre:${y}`));continue}const L=A.match(_f);if(L){const O=L[1].length,D=L[2]||"",K=Qa(D,b);O===1?m.push(e.jsx("h1",{children:K},`h1:${y}`)):O===2?m.push(e.jsx("h2",{children:K},`h2:${y}`)):O===3?m.push(e.jsx("h3",{children:K},`h3:${y}`)):O===4?m.push(e.jsx("h4",{children:K},`h4:${y}`)):m.push(e.jsx("h5",{children:K},`h5:${y}`)),y+=1;continue}if(vf(A)){const O=[];for(;y<p.length&&String(p[y]??"").trimStart().startsWith(">");){const K=String(p[y]??"").trimStart();O.push(K.replace(/^>\s?/,"")),y+=1}m.push(e.jsx("blockquote",{className:"pc-md_quote",children:O.map((D,K)=>e.jsxs(Wt.Fragment,{children:[Qa(D,b),K<O.length-1?e.jsx("br",{}):null]},`q:${y}:${K}`))},`quote:${y}`));continue}if(A.includes("|")&&y+1<p.length&&pf(String(p[y+1]??""))){const O=hf(A),D=Math.max(1,O.length),K=[];for(y+=2;y<p.length;){const T=String(p[y]??"");if(!T.trim()||!T.includes("|"))break;const te=hf(T),ue=[];for(let re=0;re<D;re++)ue.push(te[re]??"");K.push(ue),y+=1}m.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:O.slice(0,D).map((T,te)=>e.jsx("th",{children:Qa(T,b)},`th:${y}:${te}`))})}),e.jsx("tbody",{children:K.map((T,te)=>e.jsx("tr",{children:T.map((ue,re)=>e.jsx("td",{children:Qa(ue,b)},`td:${y}:${te}:${re}`))},`tr:${y}:${te}`))})]})},`table:${y}`));continue}if(ic(A)){const O=[];for(;y<p.length;){const D=String(p[y]??"");if(!D.trim()||D.trimStart().startsWith("```"))break;if(ic(D)||/^\s{2,}\S/.test(D)){O.push(D),y+=1;continue}break}m.push(e.jsx(Wt.Fragment,{children:Ng(O,b,`list:${y}`)},`list:${y}`));continue}const q=[];for(;y<p.length&&String(p[y]??"").trim()&&!(q.length>0&&ic(String(p[y]??"")));){const O=String(p[y]??"");if(q.length>0&&(_f.test(O)||gf(O)||vf(O))||q.length>0&&O.includes("|")&&y+1<p.length&&pf(String(p[y+1]??"")))break;q.push(O),y+=1}m.push(e.jsx("p",{className:"pc-md_p",children:q.map((O,D)=>e.jsxs(Wt.Fragment,{children:[Qa(O,b),D<q.length-1?e.jsx("br",{}):null]},`pl:${y}:${D}`))},`p:${y}`))}const C=["pc-md",s].filter(Boolean).join(" ");return e.jsx("div",{className:C,children:m})}function $g(a){const s=String(a.text??""),r=f.useMemo(()=>hg(s),[s]),l=["pc-chat-content",a.className].filter(Boolean).join(" ");return r!==null?e.jsx("div",{className:l,children:e.jsx(rc,{value:r,collapseAfterDepth:a.jsonCollapseAfterDepth})}):a.renderMarkdown?e.jsx("div",{className:l,children:a.renderMarkdown(s)}):e.jsx("div",{className:l,children:e.jsx(ls,{text:s,images:a.images,inlineImage:a.inlineImage})})}function bh(a){if(typeof a!="string")return a;try{return JSON.parse(a)}catch{return a}}function Eg(a){const s=bh(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(d=>r.find(([p])=>p===d)).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 wh({tool:a,showCopy:s=!0}){const[r,l]=f.useState(!1),c=bh(a.arguments),d=Eg(a.arguments),p=["file path","path"].includes(d.label)&&d.value.length>60?`${d.value.split(/[\\/]/).pop()} · ${d.value.slice(0,24)}…`:d.value,m=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"},x=a.startedAt&&a.endedAt?Date.parse(a.endedAt)-Date.parse(a.startedAt):NaN,b=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(tt,{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:d.value,children:d.value?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"pc-tool-activity__key",children:d.label}),p]}):"No parameters"}),e.jsx("span",{className:"pc-tool-activity__status",children:_[a.status]}),Number.isFinite(x)&&x>=0?e.jsxs("span",{className:"pc-tool-activity__duration",children:[(x/1e3).toFixed(1),"s"]}):null,e.jsx("span",{className:"pc-tool-activity__chevron","aria-hidden":"true",children:e.jsx(tt,{name:"chevronRight",size:13})}),a.error?e.jsx("span",{className:"pc-tool-activity__error",title:a.error,children:m}):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 fn(JSON.stringify(a,null,2))),children:[e.jsx(tt,{name:"copy",size:13}),r?"Copied":"Copy details"]}):null]}),b?e.jsx("dl",{className:"pc-tool-activity__parameters",children:b.map(([y,C])=>e.jsxs(Wt.Fragment,{children:[e.jsx("dt",{children:y}),e.jsx("dd",{children:C&&typeof C=="object"?e.jsx(rc,{value:C}):e.jsx("code",{children:typeof C=="string"?C:JSON.stringify(C)})})]},y))}):a.arguments===void 0?e.jsx("p",{children:"Arguments are unavailable in this ledger."}):e.jsx(rc,{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(rc,{value:a.output})})]}):null]})]})}function Tg({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(tt,{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(wh,{tool:l,showCopy:s},l.id))]})}const xn="not reported",Mn=a=>a===void 0?xn:Math.round(a).toLocaleString(),Gn=a=>{if(a===void 0)return xn;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`},jh=a=>a===void 0?xn:`${Math.round(a).toLocaleString()} tok/s`,Ag=(a,s)=>s>0?`${Math.round(a/s*100)}%`:"",Pr=(a,s,r=`${s}s`)=>`${a.toLocaleString()} ${a===1?s:r}`,Rg=a=>{const s=a.split("#")[0].replace(/\/+$/,"");return s.slice(s.lastIndexOf("/")+1)||a};function Lg(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 oc(a){const s=[],r=(a.models||[]).map(Rg),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 Mg(a){const s=a.modelCalls||[],r=[],l=[{label:"Input",value:Mn(a.inputTokens)},{label:"Output",value:Mn(a.outputTokens)}];if(a.reasoningTokens!==void 0&&l.push({label:"Reasoning",value:Mn(a.reasoningTokens),hint:"part of output"}),l.push({label:"Total",value:Mn(a.totalTokens)}),r.push({heading:`Usage · ${Pr(a.llmCalls,"model call")}`,rows:l}),a.measuredCacheCalls){const d=a.cachedTokens||0,p=a.fedTokens||0,m=[{label:"Reused from cache",value:`${Mn(d)}${d+p?` (${Ag(d,d+p)})`:""}`},{label:"Newly processed",value:Mn(a.fedTokens)},{label:"Outcome",value:Lg(s.map(_=>_.cacheOutcome))||(a.cacheOutcomes||[]).join(" · ")||xn},{label:"Backend",value:(a.cacheBackends||[]).join(", ")||xn}];a.measuredCacheCalls!==a.llmCalls&&m.push({label:"Measured on",value:`${a.measuredCacheCalls} of ${a.llmCalls} calls`}),r.push({heading:"Prompt cache",rows:m})}else a.llmCalls&&r.push({heading:"Prompt cache",rows:[{label:"Cache reuse",value:xn}]});const c=s.filter(d=>d.inputTokens!==void 0);return c.length===1&&s.length===1?r.push({heading:"Context",rows:[{label:"Prompt size",value:`${Mn(c[0].inputTokens)} tokens`}]}):c.length>1&&r.push({heading:"Context",rows:[{label:"First → last call",value:`${Mn(c[0].inputTokens)} → ${Mn(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((d,p)=>[String(p+1),Mn(d.inputTokens),d.cachedTokens===void 0?"—":Mn(d.cachedTokens),d.fedTokens===void 0?"—":Mn(d.fedTokens),Mn(d.outputTokens),d.cacheOutcome||"—"])}}),{kind:"tokens",title:"Tokens",headline:a.totalTokens===void 0?xn:`${a.totalTokens.toLocaleString()} total`,sections:r,footer:oc(a)}}function Jo(a,s,r,l){if(a===void 0)return xn;const c=[Gn(a)];return s!==void 0&&c.push(`${s.toLocaleString()} ${l}${r!==void 0?` at ${jh(r)}`:""}`),c.join(" · ")}function zg(a){var x,b,y;const s=a.modelCalls||[],r=[],l=a.durationMs,c=[{label:"Wall clock",value:Gn(l)}];if(c.push({label:"Model",value:a.genTimeMs===void 0?xn:`${Gn(a.genTimeMs)} · ${Pr(a.timedCalls||0,"call")}${a.timedCalls!==a.llmCalls?` (of ${a.llmCalls})`:""}`}),c.push({label:"Tools",value:a.toolTimeMs!==void 0?`${Gn(a.toolTimeMs)} · ${Pr(a.toolBatches||0,"batch","batches")}`:a.toolCalls?xn:"none",hint:a.toolTimeIncludesApproval?"includes approval wait":void 0}),l!==void 0&&a.genTimeMs!==void 0){const C=l-a.genTimeMs-(a.toolTimeMs||0);c.push({label:"Orchestration",value:C>=0?Gn(C):"overlaps (parallel runs)",hint:"wall − model − tools: routing, hand-offs, model load"})}r.push({heading:"Turn",rows:c});const d=[],p=a.ttftCalls||0,m=a.promptPhaseCalls||0;a.promptPhaseMs!==void 0?d.push({label:p&&p===m?"Prefill (TTFT)":"Prefill",value:Jo(a.promptPhaseMs,a.promptPhaseNewTokens,a.promptPhaseTokensPerSecond,"new tok"),hint:p===m?"measured time to first token":p?`TTFT measured on ${p} of ${m}; rest from provider rate`:"derived: prompt ÷ provider rate"}):a.prefillMs!==void 0&&a.prefillNewTokensPerSecond!==void 0?d.push({label:"Prefill",value:Jo(a.prefillMs,a.prefillNewTokens,a.prefillNewTokensPerSecond,"new tok"),hint:"derived: prompt ÷ provider rate"}):a.prefillMs!==void 0?d.push({label:"Prefill",value:`${Gn(a.prefillMs)}${a.promptTokensPerSecond!==void 0?` at ${jh(a.promptTokensPerSecond)}`:""}`,hint:"provider rate over all prompt tokens, restored included"}):d.push({label:"Prefill",value:xn}),a.cachedTokens&&(a.promptPhaseMs??a.prefillMs)!==void 0&&d.push({label:"Restored",value:`${a.cachedTokens.toLocaleString()} tok from cache`,hint:"not recomputed"}),d.push({label:"Generation",value:a.generationPhaseMs!==void 0?Jo(a.generationPhaseMs,a.generationPhaseTokens,a.generationPhaseTokensPerSecond,"tok"):Jo(a.decodeMs,a.outputTokens,a.generationTokensPerSecond,"tok")}),a.measuredSpeedCalls&&a.measuredSpeedCalls!==a.llmCalls&&d.push({label:"Speeds from",value:`${a.measuredSpeedCalls} of ${a.llmCalls} calls`}),r.push({heading:"Model",rows:d});const _=a.speculation;if(_){const C=(_.draftKinds||[]).map(E=>E.toUpperCase()).join(", "),A=[{label:"Mode",value:`${_.used?"on":"off"}${C?` · ${C}`:""}${(x=_.modes)!=null&&x.length?` (${_.modes.join(", ")})`:""}`,hint:_.calls!==a.llmCalls||_.used!==_.calls?`used on ${_.used} of ${a.llmCalls} calls`:void 0},{label:"Acceptance",value:_.acceptanceRate===void 0?xn:`${Math.round(_.acceptanceRate*100)}% · ${Mn(_.acceptedTokens)} of ${Mn(_.draftedTokens)} drafted`}];((b=_.draftLengths)!=null&&b.length||_.rounds!==void 0)&&A.push({label:"Draft length",value:`${(y=_.draftLengths)!=null&&y.length?`${_.draftLengths.join("/")} tok/round`:xn}${_.rounds!==void 0?` · ${_.rounds.toLocaleString()} rounds`:""}`}),r.push({heading:"Speculation",rows:A})}return a.slowestToolBatch&&r.push({heading:"Tools",rows:[{label:"Total",value:`${Gn(a.toolTimeMs)} · ${Pr(a.toolBatches||0,"batch","batches")}`},{label:"Slowest",value:`${Gn(a.slowestToolBatch.ms)} · ${kh(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((C,A)=>[String(A+1),C.promptMs===void 0?"—":`${Gn(C.promptMs)}${C.promptSource==="rate"?"*":""}`,C.promptNewTokensPerSecond===void 0?"—":Math.round(C.promptNewTokensPerSecond).toLocaleString(),C.generationMs===void 0?"—":Gn(C.generationMs),C.generationTokensPerSecond===void 0?"—":Math.round(C.generationTokensPerSecond).toLocaleString(),C.cacheOutcome||"—"])},note:s.some(C=>C.promptSource==="rate")?"* derived from the provider's prompt rate (no TTFT event).":void 0}),{kind:"time",title:"Time",headline:l===void 0?xn:`${Gn(l)} wall clock`,sections:r,footer:oc(a)}}function kh(a){return a.tools.length===1?`${a.tools[0]} ×${a.calls}`:`${Pr(a.calls,"call")} (${a.tools.join(", ")})`}function Pg(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:oc(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((m,_)=>_[1].calls-m[1].calls||m[0].localeCompare(_[0]));c.length&&s.push({heading:"By tool",table:{columns:["Tool","Calls","Failed","Time"],rows:c.map(([m,_])=>[m,_.calls.toLocaleString(),_.failed.toLocaleString(),_.ms!==void 0?`${Gn(_.ms)}${_.sharedBatches?" +shared":""}`:_.sharedBatches?"shared":xn])},note:c.some(([,m])=>m.sharedBatches)?"A batch that mixed tools ran them together; its time is not split between them.":void 0});const d=c.filter(([,m])=>m.errors&&Object.keys(m.errors).length);d.length&&s.push({heading:"Failures",rows:d.map(([m,_])=>({label:m,value:Object.entries(_.errors).sort((x,b)=>b[1]-x[1]).map(([x,b])=>b>1?`${x} ×${b}`:x).join(" · ")}))});const p=[{label:"Tool time",value:a.toolTimeMs===void 0?xn:`${Gn(a.toolTimeMs)} · ${Pr(a.toolBatches||0,"batch","batches")}`}];return a.slowestToolBatch&&p.push({label:"Slowest batch",value:`${Gn(a.slowestToolBatch.ms)} · ${kh(a.slowestToolBatch)}`}),s.push({heading:"Timing",rows:p,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:`${Pr(a.toolCalls,"call")}${a.toolsFailed?` · ${a.toolsFailed} failed`:""}`,sections:s,footer:oc(a)}}function Ru(a,s){return a==="tokens"?Mg(s):a==="time"?zg(s):Pg(s)}function Ig(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(Wt.Fragment,{children:[e.jsx("dt",{children:c.label}),e.jsxs("dd",{children:[e.jsx("span",{className:c.value===xn?"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,d)=>e.jsx("tr",{children:c.map((p,m)=>e.jsx("td",{children:p},m))},d))})]}):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 ma=8;function Og(a){const[s,r]=f.useState(!!a.defaultOpen),[l,c]=f.useState(null),d=f.useRef(null),p=f.useRef(null),m=f.useRef(null),_=`pc-stat-${f.useId().replace(/[^a-zA-Z0-9_-]/g,"")}`,x=f.useCallback(()=>{m.current!==null&&window.clearTimeout(m.current),m.current=null},[]),b=f.useCallback(()=>{x(),r(!0)},[x]),y=f.useCallback(()=>{x(),m.current=window.setTimeout(()=>r(!1),120)},[x]);f.useEffect(()=>x,[x]),f.useLayoutEffect(()=>{if(!s){c(null);return}const $=()=>{const L=d.current,q=p.current;if(!L||!q)return;const O=L.getBoundingClientRect(),D=q.offsetWidth,K=q.offsetHeight,T=window.innerWidth,te=window.innerHeight,ue=O.top-ma-K,re=O.bottom+ma,Te=ue>=ma?ue:re+K<=te-ma?re:Math.max(ma,te-ma-K),je=Math.min(Math.max(ma,O.left),Math.max(ma,T-ma-D));c({top:Te,left:je})};return $(),window.addEventListener("resize",$),window.addEventListener("scroll",$,!0),()=>{window.removeEventListener("resize",$),window.removeEventListener("scroll",$,!0)}},[s]),f.useEffect(()=>{if(!s)return;const $=L=>{L.key==="Escape"&&r(!1)};return document.addEventListener("keydown",$),()=>document.removeEventListener("keydown",$)},[s]);const C=typeof a.onClick=="function",A=C?"button":"span",E=s?e.jsx(Ig,{detail:a.detail,id:_,panelRef:p,onMouseEnter:x,onMouseLeave:y,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(A,{ref:d,...C?{type:"button"}:{tabIndex:0},className:["pc-chat-stat","pc-chat-stat--detail",C?"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:b,onMouseLeave:y,onFocus:b,onBlur:()=>r(!1),onKeyDown:$=>{$.key==="Escape"&&r(!1)},onClick:C?()=>{var $;return($=a.onClick)==null?void 0:$.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})]}),E&&typeof document<"u"?ch.createPortal(E,document.body):E]})}function Dg(a){const s=a.totalTokens!==void 0?Ru("tokens",a):null,r=Ru("tools",a),l=a.durationMs!==void 0?Ru("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(`
47
+ `)}]:[],...l?[{label:`${(a.durationMs/1e3).toFixed(a.durationMs<1e4?1:0)}s`,detail:l}]:[]]}function Fg(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 qg(a){var q;const s=a.message,r=f.useMemo(()=>Fg(s),[s.kind,s.level,s.role,s.title]),l=String(s.ts||"").trim(),c=f.useMemo(()=>{if(!l)return"";const O=new Date(l);return Number.isFinite(O.getTime())?O.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):""},[l]),[d,p]=f.useState("idle"),m=f.useRef(null);f.useEffect(()=>()=>{m.current!==null&&window.clearTimeout(m.current)},[]);const _=s.live,x=!_&&typeof a.onSpeakToggle=="function"&&r.variant==="assistant"&&!!String(s.content||"").trim(),b=x&&((q=a.getSpeakState)==null?void 0:q.call(a,s))||"idle",y=b==="loading"?"loader":b==="playing"?"pause":"speaker",C=b==="loading"?"Generating audio…":b==="playing"?"Pause":b==="paused"?"Resume":"Speak (TTS)",A=a.showCopy!==!1,E=Array.isArray(a.attachments)?a.attachments:[],$=s.statistics,L=f.useMemo(()=>Array.isArray(a.stats)?a.stats:$?Dg($):[],[a.stats,$]);return s.toolActivity?e.jsx(wh,{tool:s.toolActivity,showCopy:a.showCopy}):e.jsxs("div",{className:["pc-chat-item",`pc-chat-item--${r.variant}`,_?"pc-chat-item--live":"",a.className].filter(Boolean).join(" "),..._?{"aria-busy":!0}:{},children:[e.jsxs("div",{className:"pc-chat-header",children:[e.jsx("div",{className:"pc-chat-avatar","aria-hidden":"true",children:e.jsx(tt,{name:r.icon,size:14})}),e.jsx("span",{className:"pc-chat-role",children:r.label}),_?e.jsxs("span",{className:"pc-chat-live-indicator",title:"The reply is still being written",children:[e.jsx("span",{className:"pc-chat-live-dot","aria-hidden":"true"}),"streaming"]}):null,_!=null&&_.caption?e.jsx("span",{className:"pc-chat-live-caption",children:_.caption}):null,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:[x?e.jsx("button",{className:"pc-chat-icon-btn",type:"button","aria-label":C,title:C,onClick:()=>{var O;return(O=a.onSpeakToggle)==null?void 0:O.call(a,s)},children:e.jsx(tt,{name:y,size:22})}):null,A?e.jsx("button",{className:`pc-chat-icon-btn ${d!=="idle"?`pc-chat-icon-btn--${d}`:""}`.trim(),type:"button","aria-label":"Copy message",title:d==="idle"?"Copy":d==="copied"?"Copied":"Copy failed",onClick:async()=>{const O=await fn(String(s.content||""));p(O?"copied":"failed"),m.current!==null&&window.clearTimeout(m.current),m.current=window.setTimeout(()=>p("idle"),900)},children:e.jsx(tt,{name:"copy",size:22})}):null]})]}),_!=null&&_.reasoning?e.jsxs("details",{className:"pc-chat-thinking",children:[e.jsx("summary",{children:"Thinking"}),e.jsx("div",{className:"pc-chat-thinking-body",children:_.reasoning})]}):null,!_||String(s.content||"").trim()?e.jsx("div",{className:"pc-chat-body",children:e.jsx($g,{text:String(s.content||""),renderMarkdown:a.renderMarkdown,jsonCollapseAfterDepth:a.jsonCollapseAfterDepth,images:a.images||(r.variant==="user"?"inline":"link"),inlineImage:a.inlineImage})}):null,E.length?e.jsx("div",{className:"pc-chat-attachments","aria-label":"Attachments",children:E.slice(0,24).map((O,D)=>{const K=String(O.label||"").trim()||"attachment",T=String(O.target||"").trim(),te=String(O.title||"").trim(),ue=!!O.disabled||typeof O.onClick!="function";return e.jsxs("button",{type:"button",className:"pc-chat-attachment-chip",title:te||K,onClick:ue?void 0:O.onClick,disabled:ue,children:[e.jsx(tt,{name:"paperclip",size:14}),T?e.jsx("span",{className:`pc-chat-attachment-target pc-chat-attachment-target--${T}`,children:T}):null,e.jsx("span",{className:"pc-chat-attachment-name",children:K})]},O.id||`${K}:${D}`)})}):null,L.length?e.jsx("div",{className:"pc-chat-stats","aria-label":"Stats",children:L.slice(0,12).map((O,D)=>{const K=String(O.label||"").trim();if(!K)return null;if(O.detail)return e.jsx(Og,{label:K,detail:O.detail,icon:O.icon,onClick:O.onClick},O.id||`${K}:${D}`);const T=String(O.title||"").trim(),te=typeof O.onClick=="function",ue=te?"button":"span";return e.jsxs(ue,{...te?{type:"button"}:{},className:["pc-chat-stat",te?"pc-chat-stat--clickable":""].filter(Boolean).join(" "),title:T||void 0,onClick:te?()=>{var re;return(re=O.onClick)==null?void 0:re.call(O)}:void 0,children:[O.icon?e.jsx("span",{className:"pc-chat-stat-icon","aria-hidden":"true",children:O.icon}):null,e.jsx("span",{className:"pc-chat-stat-label",children:K})]},O.id||`${K}:${D}`)})}):null]})}function Bg(a,s){const r=Math.max(0,Math.trunc(s));return a.scrollHeight-a.scrollTop-a.clientHeight<=r}function hd(a){const s=typeof a.autoScrollThresholdPx=="number"&&Number.isFinite(a.autoScrollThresholdPx)?a.autoScrollThresholdPx:120,r=a.autoScroll!==!1,l=f.useRef(null),c=f.useRef(null),[d,p]=f.useState(!0),m=f.useMemo(()=>Array.isArray(a.messages)?a.messages:[],[a.messages]),_=f.useMemo(()=>{var y;const b=[];for(const C of m){const A=b[b.length-1];C.toolActivity&&((y=A==null?void 0:A[0])!=null&&y.toolActivity)&&A[0].runId===C.runId?A.push(C):b.push([C])}return b},[m]);f.useEffect(()=>{if(!r)return;const b=l.current;if(!b)return;const y=()=>{p(Bg(b,s))};return b.addEventListener("scroll",y,{passive:!0}),y(),()=>b.removeEventListener("scroll",y)},[r,s]);const x=f.useMemo(()=>{let b=0;for(const y of m)b+=String(y.content??"").length;return`${m.length}:${b}:${String(a.afterKey??"")}`},[m,a.afterKey]);return f.useEffect(()=>{if(!r||!d)return;const b=l.current;b&&(b.scrollTop=b.scrollHeight)},[r,d,x]),e.jsxs("div",{ref:l,className:["pc-chat-thread",a.className].filter(Boolean).join(" "),children:[m.length?null:a.empty||null,_.map((b,y)=>{var E;const C=b[0],A=String(C.id||"")||String(C.ts||"")+":"+String(C.role||"")+":"+y;return C.toolActivity?e.jsx(Tg,{tools:b.map($=>$.toolActivity),showCopy:(E=a.messageProps)==null?void 0:E.showCopy},A):e.jsx(qg,{message:C,...a.messageProps||{}},A)}),a.after,e.jsx("div",{ref:c})]})}const uc=Wt.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,d=!!s.busy,p=!c&&!d&&!!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:m=>s.onChange(m.target.value),rows:l,style:{"--pc-composer-rows":String(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:m=>{m.key!=="Enter"||m.shiftKey||m.nativeEvent.isComposing||m.keyCode===229||(m.preventDefault(),p&&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:!p,onClick:()=>s.onSubmit(),children:d?s.busyLabel||"Thinking…":s.sendLabel||"Send"})]}),s.overlay]})});function Ug(a){return!!(a&&typeof a[Symbol.asyncIterator]=="function")}function Wg(a){const[s,r]=f.useState([]),l=a.messages??s,c=$=>{a.onMessagesChange&&a.onMessagesChange($),a.messages===void 0&&r($)},d=f.useRef(l);d.current=l;const[p,m]=f.useState(""),[_,x]=f.useState(!1),b=f.useRef(null),y=a.assistantName||"Assistant",C=!!a.blockedNotice,A=async $=>{const L=String($||"").trim();if(!L||_||C)return;m("");const q=d.current,O=[...q,{role:"user",content:L,ts:new Date().toISOString()}];c(O),x(!0);const D=new AbortController;b.current=D;try{const K=a.ask(L,{signal:D.signal,history:q});if(Ug(K)){let T="";const te=[...O,{role:"assistant",title:y,content:"",ts:new Date().toISOString()}];c(te);for await(const ue of K){if(D.signal.aborted)break;T+=String(ue??""),c([...O,{role:"assistant",title:y,content:T,ts:new Date().toISOString()}])}!T.trim()&&!D.signal.aborted&&c([...O,{role:"assistant",title:y,content:"#FALLBACK the assistant returned no answer.",level:"warn",ts:new Date().toISOString()}])}else{const T=String(await K??"").trim();c([...O,T?{role:"assistant",title:y,content:T,ts:new Date().toISOString()}:{role:"assistant",title:y,content:"#FALLBACK the assistant returned no answer.",level:"warn",ts:new Date().toISOString()}])}}catch(K){D.signal.aborted||c([...d.current,{role:"assistant",title:y,content:`#FALLBACK assistant request failed: ${String((K==null?void 0:K.message)||K||"unknown error")}`,level:"error",ts:new Date().toISOString()}])}finally{b.current===D&&(b.current=null),x(!1)}},E=f.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($=>e.jsx("button",{type:"button",className:"pc-assistant__suggestion",onClick:()=>void A($),disabled:_||C,children:$},$))}):null]}),[l.length,a.emptyState,a.suggestions,_,C]);return e.jsxs("div",{className:`pc-assistant${a.className?` ${a.className}`:""}`,children:[e.jsxs("div",{className:"pc-assistant__thread",children:[E,e.jsx(hd,{messages:l,autoScroll:!0}),C?e.jsx("div",{className:"pc-assistant__blocked",children:a.blockedNotice}):null]}),e.jsx("div",{className:"pc-assistant__composer",children:e.jsx(uc,{value:p,onChange:m,onSubmit:()=>void A(p),placeholder:a.placeholder||"Ask about this app…",disabled:C,busy:_,rows:2,actions:_?e.jsx("button",{type:"button",className:"pc-btn",onClick:()=>{var $;($=b.current)==null||$.abort()},children:"Stop"}):null})})]})}function Hg(a){const s=a.trim();if(!s)throw new Error("AbstractContinuum was built without __APP_VERSION__ (see vite.config.ts define)");return s}const Vg=Hg("0.6.0");function Yo(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 Cl(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 yf="abstractcontinuum_gateway_csrf",Gg="x-abstractcontinuum-csrf",Kg="x-abstract-csrf";function xf(a){var l;const s=(a||"").trim(),r={};s&&(r.Authorization=`Bearer ${s}`);try{const c=(l=document.cookie.split(";").map(d=>d.trim()).find(d=>d.startsWith(`${yf}=`)))==null?void 0:l.slice(`${yf}=`.length);if(c){const d=decodeURIComponent(c);r[Gg]=d,r[Kg]=d}}catch{}return r}function bf(a){const s={},r=(l,c)=>{const d=String(c||"").trim();d&&(s[l]=d)};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 Qg(a){try{const s=await a.text();return s!=null&&s.trim()?s.trim():`${a.status}`}catch{return`${a.status}`}}class Sh extends Error{constructor(r,l,c){super(r);Rr(this,"status");Rr(this,"body");this.name="GatewayRequestError",this.status=l,this.body=c}}const Lu=[15,30,60,120];class Jg{constructor(s){Rr(this,"_cfg");Rr(this,"_backoff_until",0);Rr(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(df(this._cfg.base_url,r),{...l,headers:{...l==null?void 0:l.headers,...xf(this._cfg.auth_token)}});if(c.ok)return this._backoff_step=0,this._backoff_until=0,c;const d=await Qg(c);let p=null;try{p=JSON.parse(d)}catch{}let m=d;if(p&&typeof p=="object"&&p.detail!==void 0&&(m=typeof p.detail=="string"?p.detail:JSON.stringify(p.detail)),c.status===429||/too many requests|auth lockout|locked/i.test(m)){const x=Lu[Math.min(this._backoff_step,Lu.length-1)];this._backoff_until=Date.now()+x*1e3,this._backoff_step<Lu.length-1&&(this._backoff_step+=1)}throw new Sh(`${s} failed: ${m}`,c.status,p)}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(),d=String(r||"").trim();if(!c)throw new Error("download_run_artifact_content: run_id is required");if(!d)throw new Error("download_run_artifact_content: artifact_id is required");const p=String((l==null?void 0:l.access)||"").trim(),m=p?`?access=${encodeURIComponent(p)}`:"";return await(await this._fetch("download_run_artifact_content",`api/gateway/runs/${encodeURIComponent(c)}/artifacts/${encodeURIComponent(d)}/content${m}`)).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 d=String((l==null?void 0:l.filename)||"").trim()||String((r==null?void 0:r.name)||"").trim()||"upload.bin",p=String((l==null?void 0:l.content_type)||"").trim()||String((r==null?void 0:r.type)||"").trim(),m=new FormData;m.append("session_id",c),m.append("file",r,d),m.append("filename",d),p&&m.append("content_type",p);const _=await this._post_form("attachments_upload","api/gateway/attachments/upload",m),x=_==null?void 0:_.attachment;if(!x||typeof x!="object")throw new Error("attachments_upload: missing attachment");if(!String(x.$artifact||"").trim())throw new Error("attachments_upload: missing attachment.$artifact");return x}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 p={audio_artifact:c},m=String((r==null?void 0:r.language)||"").trim();m&&(p.language=m);const _=String((r==null?void 0:r.request_id)||"").trim();_&&(p.request_id=_);const x=await this._post_json("audio_transcribe",`api/gateway/runs/${encodeURIComponent(l)}/audio/transcribe`,p);return{ok:!!(x!=null&&x.ok),run_id:String((x==null?void 0:x.run_id)||""),request_id:String((x==null?void 0:x.request_id)||""),text:String((x==null?void 0:x.text)||""),transcript_artifact:x==null?void 0:x.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 d={text:c,...bf(r)},p=String((r==null?void 0:r.format)||"").trim();p&&(d.format=p),typeof(r==null?void 0:r.timeout_s)=="number"&&r.timeout_s>0&&(d.timeout_s=r.timeout_s);const m=String((r==null?void 0:r.request_id)||"").trim();m&&(d.request_id=m);const _=await this._post_json("voice_tts",`api/gateway/runs/${encodeURIComponent(l)}/voice/tts`,d);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:df(this._cfg.base_url,`api/gateway/runs/${encodeURIComponent(l)}/voice/tts/stream`),body:{text:String((r==null?void 0:r.text)||""),format:"wav",...bf(r)},headers:xf(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",wf(s,"bug_report_create"))}async feature_report_create(s){return await this._post_json("feature_report_create","api/gateway/features/report",wf(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 d=String((s==null?void 0:s.since)||"").trim();d&&r.set("since",d);const p=String((s==null?void 0:s.status)||"").trim();return p&&r.set("status",p),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,d=String((r==null?void 0:r.account)||"").trim();d&&c.set("account",d);const p=String((r==null?void 0:r.mailbox)||"").trim();p&&c.set("mailbox",p);const m=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(m)),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 d={action:c};if(c==="defer"){const p=r==null?void 0:r.defer_days;typeof p=="number"&&Number.isFinite(p)&&p>0&&(d.defer_days=Number(p))}return await this._post_json("apply_triage_decision",`api/gateway/triage/decisions/${encodeURIComponent(l)}/apply`,d)}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_status(){return await this._get_json("backlog_status","api/gateway/backlog/status")}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)??"")},d=String((s==null?void 0:s.expected_sha256)||"").trim();return d&&(c.expected_sha256=d),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 d={kind:r,package:l,title:c},p=String((s==null?void 0:s.task_type)||"").trim();p&&(d.task_type=p);const m=String((s==null?void 0:s.summary)||"").trim();m&&(d.summary=m);const _=(s==null?void 0:s.content)==null?"":String((s==null?void 0:s.content)??"");return _.trim()&&(d.content=_),await this._post_json("backlog_create","api/gateway/backlog/create",d)}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(),d=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(d.length<2)throw new Error("backlog_merge: at least 2 items are required");const p={kind:r,package:l,title:c,items:d.map(x=>({kind:String((x==null?void 0:x.kind)||"").trim(),filename:String((x==null?void 0:x.filename)||"").trim()}))},m=String((s==null?void 0:s.task_type)||"").trim();m&&(p.task_type=m);const _=String((s==null?void 0:s.summary)||"").trim();return _&&(p.summary=_),await this._post_json("backlog_merge","api/gateway/backlog/merge",p)}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 d=new FormData;return d.set("overwrite",(s==null?void 0:s.overwrite)===!0?"true":"false"),d.set("file",c,c.name||"attachment"),await this._post_form("backlog_upload_attachment",`api/gateway/backlog/${encodeURIComponent(r)}/${encodeURIComponent(l)}/attachments/upload`,d)}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 d={kind:r,package:l,title:c,messages:Array.isArray(s==null?void 0:s.messages)?s.messages:[]},p=String((s==null?void 0:s.summary)||"").trim();p&&(d.summary=p);const m=(s==null?void 0:s.draft_markdown)==null?"":String(s.draft_markdown??"");m.trim()&&(d.draft_markdown=m);const _=String((s==null?void 0:s.provider)||"").trim();_&&(d.provider=_);const x=String((s==null?void 0:s.model)||"").trim();x&&(d.model=x);const b=String((s==null?void 0:s.thinking)||"").trim();return b&&(d.thinking=b),await this._post_json("backlog_assist","api/gateway/backlog/assist",d)}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(),d=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(!d)throw new Error("backlog_maintain: title is required");const p={kind:r,filename:l,package:c,title:d,messages:Array.isArray(s==null?void 0:s.messages)?s.messages:[]},m=String((s==null?void 0:s.summary)||"").trim();m&&(p.summary=m);const _=(s==null?void 0:s.draft_markdown)==null?"":String(s.draft_markdown??"");_.trim()&&(p.draft_markdown=_);const x=String((s==null?void 0:s.provider)||"").trim();x&&(p.provider=x);const b=String((s==null?void 0:s.model)||"").trim();return b&&(p.model=b),await this._post_json("backlog_maintain","api/gateway/backlog/maintain",p)}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 d=String((s==null?void 0:s.thinking)||"").trim();d&&(r.thinking=d);const p=String((s==null?void 0:s.agent)||"").trim();p&&(r.agent=p),(s==null?void 0:s.include_trace)===!0&&(r.include_trace=!0);const m=String((s==null?void 0:s.focus_kind)||"").trim();m&&(r.focus_kind=m);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,d=String((s==null?void 0:s.execution_mode)||"").trim();d&&c.set("execution_mode",d);const p=String((s==null?void 0:s.executor)||"").trim();p&&c.set("executor",p);const m=String((s==null?void 0:s.target_model)||"").trim();m&&c.set("target_model",m);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 d=String((s==null?void 0:s.executor)||"").trim();d&&(l.executor=d);const p=String((s==null?void 0:s.target_model)||"").trim();p&&(l.target_model=p);const m=String((s==null?void 0:s.target_reasoning_effort)||"").trim();return m&&(l.target_reasoning_effort=m),(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 d=typeof(s==null?void 0:s.max_bytes)=="number"&&Number.isFinite(s.max_bytes)?Number(s.max_bytes):0;d>0&&l.set("max_bytes",String(Math.floor(d)));const p=typeof(s==null?void 0:s.after_bytes)=="number"&&Number.isFinite(s.after_bytes)?Math.max(0,Math.floor(s.after_bytes)):null;return p!==null&&l.set("after_bytes",String(p)),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 gateway_about(){return await this._get_json("gateway_about","api/gateway/about")}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 wf(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 p of["active_run_id","workflow_id","client","client_version","user_agent","url","provider","model","template"]){const m=String((a==null?void 0:a[p])||"").trim();m&&(c[p]=m)}const d=a==null?void 0:a.context;return d&&typeof d=="object"&&(c.context=d),c}const jf=[["Gateway","checking…"]];function Yg(a){if(a instanceof Sh){const r=a.message.replace(/^gateway_about failed:\s*/,"").trim();return`HTTP ${a.status}${r&&r!==String(a.status)?`: ${r}`:""}`}return(a instanceof Error?a.message:String(a))||"request failed"}async function Xg(a){let s;try{s=await a.gateway_about()}catch(r){return ff(null,Yg(r))}return ff(s)}const kf=mh("voice and camera")??"Voice and camera are not supported in this browser (getUserMedia unavailable).",Zg="Copy failed — select and copy";function Sf(){var s;const a=globalThis.navigator;return typeof((s=a==null?void 0:a.mediaDevices)==null?void 0:s.getUserMedia)=="function"}function ev(a){var c;const s=globalThis.document;if(!s||!s.body||typeof s.execCommand!="function")return!1;const r=s.createElement("textarea");r.value=a,r.setAttribute("readonly",""),r.style.position="fixed",r.style.top="0",r.style.left="-9999px",r.style.opacity="0";const l=s.activeElement;s.body.appendChild(r);try{return r.select(),r.setSelectionRange(0,a.length),s.execCommand("copy")===!0}catch{return!1}finally{s.body.removeChild(r);try{(c=l==null?void 0:l.focus)==null||c.call(l)}catch{}}}async function tv(a){var l;const s=String(a??""),r=globalThis.navigator;if(typeof((l=r==null?void 0:r.clipboard)==null?void 0:l.writeText)=="function")try{return await r.clipboard.writeText(s),!0}catch{}return ev(s)}const nv=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function sv(a){const s=a.length,r=new Uint8Array(s+9+63>>6<<6);r.set(a),r[s]=128;const l=new DataView(r.buffer);l.setUint32(r.length-8,Math.floor(s/536870912),!1),l.setUint32(r.length-4,s<<3>>>0,!1);const c=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),d=new Uint32Array(64),p=(m,_)=>m>>>_|m<<32-_;for(let m=0;m<r.length;m+=64){for(let L=0;L<16;L++)d[L]=l.getUint32(m+L*4,!1);for(let L=16;L<64;L++){const q=p(d[L-15],7)^p(d[L-15],18)^d[L-15]>>>3,O=p(d[L-2],17)^p(d[L-2],19)^d[L-2]>>>10;d[L]=d[L-16]+q+d[L-7]+O>>>0}let[_,x,b,y,C,A,E,$]=[c[0],c[1],c[2],c[3],c[4],c[5],c[6],c[7]];for(let L=0;L<64;L++){const q=p(C,6)^p(C,11)^p(C,25),O=C&A^~C&E,D=$+q+O+nv[L]+d[L]>>>0,K=p(_,2)^p(_,13)^p(_,22),T=_&x^_&b^x&b,te=K+T>>>0;$=E,E=A,A=C,C=y+D>>>0,y=b,b=x,x=_,_=D+te>>>0}c[0]=c[0]+_>>>0,c[1]=c[1]+x>>>0,c[2]=c[2]+b>>>0,c[3]=c[3]+y>>>0,c[4]=c[4]+C>>>0,c[5]=c[5]+A>>>0,c[6]=c[6]+E>>>0,c[7]=c[7]+$>>>0}return Array.from(c,m=>m.toString(16).padStart(8,"0")).join("")}async function Nh(a){var l;const s=new TextEncoder().encode(String(a??"")),r=(l=globalThis.crypto)==null?void 0:l.subtle;if(r&&typeof r.digest=="function"){const c=await r.digest("SHA-256",s);return Array.from(new Uint8Array(c),d=>d.toString(16).padStart(2,"0")).join("")}return sv(s)}const av=/^[a-zA-Z0-9_-]+$/;function Nf(a){return av.test(String(a||"").trim())}async function rv(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(d=>d.toString(16).padStart(2,"0")).join("")}async function pd(a){const s=String(a||"").trim();if(!s)throw new Error("session_id is required");if(Nf(s)){const l=`session_memory_${s}`;if(Nf(l))return l}return`session_memory_sha_${(await rv(s)).slice(0,32)}`}const Ja=["bug","feature","improvement","task"];function Dl(a){return String(a||"").trim().toLowerCase()}function Ch(a){return Ja.includes(Dl(a))}function $h(a){const s=Dl(a);return Ch(s)?s:"task"}function Eh(a){return a.toUpperCase()}function Th(a){return a==="bug"?"danger":a==="feature"?"ok":a==="improvement"?"info":a==="task"?"task":"muted"}function Ah(a){return Ch(a)?void 0:`"${a}" is not in the ruled type vocabulary (${Ja.join(" / ")})`}function Rh(a){const s=String(a||"").trim();return s.replace(/^\[(bug|feature|improvement|task)\]\s*/i,"").trim()||s}function ha(a,s){const r=String(a||"");return r.length<=s?r:`${r.slice(0,Math.max(0,s-1))}…`}function Xu(a=new Date){const s=m=>String(m).padStart(2,"0"),r=-a.getTimezoneOffset(),l=r>=0?"+":"-",c=Math.abs(r),d=s(Math.floor(c/60)),p=s(c%60);return`${a.getFullYear()}-${s(a.getMonth()+1)}-${s(a.getDate())} ${s(a.getHours())}:${s(a.getMinutes())}:${s(a.getSeconds())} ${l}${d}${p}`}function iv(a){try{return JSON.parse(a)}catch{return null}}function Cf(a,s){return a.scrollHeight-a.scrollTop-a.clientHeight<=s}function Mu(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 Ws(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,d=Math.floor(l/60),p=d%24,m=Math.floor(d/24);return m>0?`${m}d ${p}h`:d>0?`${d}h ${c}m`:l>0?`${l}m ${r}s`:`${s}s`}async function Zu(a){return Nh(String(a||""))}function Il(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 lv(a,s){return a==="processing"?"queued,running,awaiting_qa":a==="failed"?"failed":a==="completed"&&s==="runs"?"completed,promoted":""}function $l(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:{},d=r.executor&&typeof r.executor=="object"?r.executor:{},p=String(c.last_message||"").trim(),m=String(r.target_model||d.model||"").trim(),_=String(r.target_reasoning_effort||d.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:m||null,target_reasoning_effort:_||null,executor_type:d.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:ov(p)}}const zu=1200;function ov(a){const s=String(a||"");return s?s.length<=zu?s:`${s.slice(0,zu)}
48
+ … [#TRUNCATION: ${zu} of ${s.length} chars; the full last_message is in the run directory]`:null}function cv(a){const s=String(a||""),r=s.split(/\r?\n/).filter(d=>String(d||"").trim().length>0),l=[];let c=0;for(let d=0;d<r.length;d+=1){const p=String(r[d]||"").trim(),m=iv(p);if(!m||typeof m!="object"){c+=1,l.push({idx:d,type:"raw",payload:null,raw:p});continue}const _=String(m.type||m.event||"event");l.push({idx:d,type:_,payload:m,raw:p})}return{total:r.length,bad:c,events:l,raw:s}}function uv(a){if(!a)return null;let s=0,r=0,l=0,c=0,d=0;for(const m of a.events){const _=m.payload,x=_&&typeof _.usage=="object"?_.usage:null;x&&(Number.isFinite(Number(x.input_tokens))&&(s+=Number(x.input_tokens)),Number.isFinite(Number(x.cached_input_tokens))&&(r+=Number(x.cached_input_tokens)),Number.isFinite(Number(x.output_tokens))&&(l+=Number(x.output_tokens)));const b=_&&typeof _.item=="object"?_.item:null;b&&String(b.type||"").trim()==="command_execution"&&(c+=1,String(b.status||"").trim().toLowerCase()==="failed"&&(d+=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:d}}function Fl(a,s=Date.now()){const r=Mu(a==null?void 0:a.created_at),l=Mu(a==null?void 0:a.started_at),c=Mu(a==null?void 0:a.finished_at),d=String((a==null?void 0:a.status)||"").trim().toLowerCase(),p=c??(d==="running"?s:null),m=c!=null,_=r!=null&&l!=null?Math.max(0,l-r):null,x=l!=null&&p!=null?Math.max(0,p-l):null,b=r!=null&&p!=null?Math.max(0,p-r):null,y=!m&&r!=null?Math.max(0,s-r):null;return{is_done:m,queue_delay_ms:_,run_ms:x,total_ms:b,age_ms:y}}function dv(a,s){const r=String(s.package_name).trim()||"{Package}",l=Rh(String(s.title||"").trim()||"{Title}"),c=String(s.summary||"").trim(),d=$h(s.task_type),p=`# {ID}-${r}: [${Eh(d)}] ${l}`.trim();let m=String(a||"");m=m.split("{Package}").join(r).split("{Title}").join(l);const _=m.split(/\r?\n/);let x=!1;for(let E=0;E<_.length;E+=1){const $=String(_[E]||"");if($.trim().startsWith("# ")){_[E]=p,x=!0;break}if($.trim())break}x||(_.unshift("",p),_.shift());const b=`> Created: ${String(s.created_at||"").trim()}`.trim();let y=!1;for(let E=0;E<Math.min(_.length,40);E+=1)if(String(_[E]||"").trim().toLowerCase().startsWith("> created:")){_[E]=b,y=!0;break}if(!y){const E=_.length>1&&!String(_[1]||"").trim()?2:1;_.splice(E,0,b,"")}const C=`> Type: ${d}`.trim();let A=!1;for(let E=0;E<Math.min(_.length,60);E+=1)if(String(_[E]||"").trim().toLowerCase().startsWith("> type:")){_[E]=C,A=!0;break}if(!A){let E=-1;for(let $=0;$<Math.min(_.length,60);$+=1)if(String(_[$]||"").trim().toLowerCase().startsWith("> created:")){E=$;break}if(E>=0){const $=E+1;$<_.length&&!String(_[$]||"").trim()?_.splice($,0,C):_.splice($,0,C,"")}else{const $=_.length>1&&!String(_[1]||"").trim()?2:1;_.splice($,0,C,"")}}if(c){for(let E=0;E<_.length;E+=1)if(String(_[E]||"").trim().toLowerCase()==="## summary"){let $=E+1;for(;$<_.length&&!String(_[$]||"").trim();)$+=1;($<_.length?String(_[$]||""):"").trim().toLowerCase().startsWith("one paragraph describing")?_[$]=c:_.splice(E+1,0,c,"");break}}return m=_.join(`
49
+ `),m.endsWith(`
50
+ `)||(m+=`
51
+ `),m}function Va(a){return String(a||"").split(/\r?\n/).map(s=>s.trim()).filter(Boolean)}function mv(a){const s=String(a.package_name||"").trim()||"{Package}",r=Rh(String(a.title||"").trim()||"{Title}"),l=$h(a.task_type),c=String(a.created_at||"").trim()||Xu(),d=String(a.diagram||"").trim(),p=String(a.context||"").trim(),m=[];return m.push(`# {ID}-${s}: [${Eh(l)}] ${r}`),m.push(""),m.push(`> Created: ${c}`),m.push(`> Type: ${l}`),m.push(""),m.push("## Summary"),m.push(a.summary.trim()||"One paragraph describing what this task accomplishes (user value + outcome)."),m.push(""),m.push("## Diagram"),m.push("```"),m.push(d||`ASCII diagram of the system change.
52
+ Show inputs/outputs and where code lives.`),m.push("```"),m.push(""),m.push("## Context"),m.push(p||"(why is this needed? link to evidence: bug/feature report paths, discussions, etc.)"),m.push(""),m.push("## Scope"),m.push("### Included"),a.included.length?m.push(...a.included.map(_=>`- ${_}`)):m.push("- "),m.push(""),m.push("### Excluded"),a.excluded.length?m.push(...a.excluded.map(_=>`- ${_}`)):m.push("- "),m.push(""),m.push("## Implementation Plan"),a.plan.length?m.push(...a.plan.map((_,x)=>`${x+1}. ${_}`)):m.push("1. "),m.push(""),m.push("## Dependencies"),a.dependencies.length?m.push(...a.dependencies.map(_=>`- ${_}`)):m.push("- Related backlog items / ADRs"),m.push(""),m.push("## Acceptance Criteria"),a.acceptance.length?m.push(...a.acceptance.map(_=>`- [ ] ${_}`)):m.push("- [ ] Criterion 1 (clear, testable)"),m.push(""),m.push("## Testing (ADR-0019)"),m.push("- Level A:"),a.tests_a.length?m.push(...a.tests_a.map(_=>` - \`${_}\``)):m.push(" - `...`"),m.push("- Level B:"),a.tests_b.length?m.push(...a.tests_b.map(_=>` - \`${_}\``)):m.push(" - `...`"),m.push("- Level C (optional / opt-in):"),a.tests_c.length?m.push(...a.tests_c.map(_=>` - \`${_}\``)):m.push(" - n/a"),m.push(""),m.push("## Related"),m.push("- ADRs:"),m.push("- Code:"),m.push("- Reports:"),a.attachments.length&&(m.push("- Attachments:"),m.push(...a.attachments.map(_=>` - ${_}`))),m.push(""),m.push("---"),m.push("## Report (added when completed)"),m.push(""),m.push("> Completed: YYYY-MM-DD"),m.push(""),m.push("### What changed"),m.push("- "),m.push(""),m.push("### Security / hardening"),m.push("- "),m.push(""),m.push("### Testing (ADR-0019)"),m.push("Levels executed:"),m.push("- A:"),m.push("- B:"),m.push("- C (if any):"),m.push(""),m.push("Commands run:"),m.push("- `...`"),m.push(""),m.push("### Follow-ups"),m.push("- "),m.push(""),m.join(`
53
+ `)}function fv(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()),d=c.findIndex(_=>_.trim()==="## related");if(d<0)return`${String(a||"").trimEnd()}
54
+
55
+ ## Related
56
+ - Attachments:
57
+ ${r.map(x=>` - ${x}`).join(`
58
+ `)}
59
+ `;let p=-1;for(let _=d+1;_<l.length;_+=1){const x=c[_].trim();if(x.startsWith("## ")||x.startsWith("---"))break;if(x.startsWith("- attachments:")){p=_;break}}const m=["- Attachments:",...r.map(_=>` - ${_}`)];if(p>=0){let _=p+1;for(;_<l.length&&/^\s+-\s/.test(l[_]);)_+=1;l.splice(_,0,...r.map(x=>` - ${x}`))}else{let _=d+1;for(let x=d+1;x<l.length;x+=1){const b=c[x].trim();if(b.startsWith("## ")||b.startsWith("---")){_=x;break}_=x+1}l.splice(_,0,...m,"")}return l.join(`
60
+ `)}function hv(a,s){const r=uh(a);if(!r.ok)return null;const l=r.payload.phases.map(p=>p.id),c=new Map;for(const p of s)c.set(`${p.section}\0${p.item}\0${p.phase}`,p.op);const d=[];for(const p of r.payload.sections)for(const m of p.items){const _=[];for(const x of l){const b=m.cells[x];if(!b)continue;const y=c.get(`${p.id}\0${m.id}\0${x}`);(y?y==="grant":!!b.assigned)&&_.push(x)}_.length&&(_.length===l.length?d.push({name:m.id}):d.push({name:m.id,phases:_}))}return d}function pv(a){var T,te;const{gateway:s,entity_name:r}=a,[l,c]=f.useState(null),[d,p]=f.useState(""),[m,_]=f.useState(!1),[x,b]=f.useState([]),[y,C]=f.useState(!1),[A,E]=f.useState(""),[$,L]=f.useState(""),q=f.useCallback(async()=>{_(!0),p("");try{c(await s.entity_skills(r))}catch(ue){c(null),p(String((ue==null?void 0:ue.message)||ue))}finally{_(!1)}},[s,r]);f.useEffect(()=>{b([]),L(""),E(""),q()},[q]);async function O(){if(!(l!=null&&l.matrix))return;const ue=hv(l.matrix,x);if(ue===null){E("Cannot serialize the selection: the matrix payload failed validation — refresh and retry.");return}C(!0),E("");try{const re=await s.put_entity_skills(r,ue);c(re),b([]),L("Selection saved — recorded as a host marker on the entity's stream."),setTimeout(()=>L(""),5e3)}catch(re){E(String((re==null?void 0:re.message)||re))}finally{C(!1)}}const D=Array.isArray((T=l==null?void 0:l.selection)==null?void 0:T.warnings)?l.selection.warnings.map(String):[],K=Array.isArray((te=l==null?void 0:l.resolved)==null?void 0:te.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 q(),disabled:m||y,title:"Reload the resolved view (discards pending edits)",children:m?"Loading…":"Refresh"}),e.jsx("button",{className:"btn",onClick:a.on_close,children:"Close"})]})]}),d?e.jsxs("div",{className:"page_error",children:["Skills unavailable: ",d]}):null,D.length?e.jsx("div",{className:"detail_warn",style:{marginTop:4},children:D.join(" · ")}):null,K.length?e.jsx("div",{className:"entity_skills_resolved",children:K.map(ue=>{const re=String((ue==null?void 0:ue.name)||""),Te=!!(ue!=null&&ue.active),je=!!(ue!=null&&ue.blocked),Ce=!!(ue!=null&&ue.requires_review),xe=ue==null?void 0:ue.requires_unmet,J=Array.isArray(xe)?xe.map(String):xe&&typeof xe=="object"?Object.entries(xe).map(([Y,z])=>`${Y}: ${String(z)}`):[],ne=Te?"ok":je?"danger":J.length||Ce?"warn":"muted",ve=Te?"active":je?"blocked":J.length?"requires unmet":Ce?"requires review":"inactive",W=[...Array.isArray(ue==null?void 0:ue.reasons)?ue.reasons.map(String):[],...J].join("; ");return e.jsxs("span",{className:`chip mono ${ne}`,title:W||void 0,children:[re," · ",ve]},re)})}):null,e.jsx(R_,{payload:l==null?void 0:l.matrix,patches:x,onPatchesChange:b,disabled:y||m,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 O(),disabled:y||!x.length,title:x.length?`Save ${x.length} pending change(s)`:"No pending changes",children:y?"Saving…":x.length?`Save ${x.length} change${x.length>1?"s":""}`:"Save"}),x.length?e.jsx("button",{className:"btn",onClick:()=>b([]),disabled:y,children:"Discard edits"}):null,A?e.jsx("span",{className:"page_error",style:{margin:0},children:A}):null,$?e.jsx("span",{className:"chip mono ok",children:$}):null]})]})}function _v(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 d=String(r.status||"").toLowerCase();d==="queued"||d==="running"?c.active+=1:d==="promoted"?c.promoted+=1:d==="completed"?c.completed+=1:d==="failed"?c.failed+=1:d==="awaiting_qa"&&(c.awaiting_qa+=1);const p=Fl(r);p.run_ms!=null&&(c.total_run_ms+=p.run_ms,c.timed_runs+=1);const m=String(r.finished_at||r.started_at||r.created_at||"");m>c.last_active&&(c.last_active=m)}return[...s.values()].sort((r,l)=>l.runs-r.runs)}function gv(a){const{gateway:s,gateway_connected:r}=a,l=String(a.backlog_advisor_agent||"").trim()||"basic-agent",[c,d]=f.useState(null),[p,m]=f.useState([]),[_,x]=f.useState([]),[b,y]=f.useState(""),[C,A]=f.useState(null),[E,$]=f.useState(!1),[L,q]=f.useState(""),[O,D]=f.useState(!1),[K,T]=f.useState(""),[te,ue]=f.useState(null),re=f.useRef(0);async function Te(){if(!r||E)return;const w=++re.current;$(!0),q("");try{const[N,Z,pe]=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(w!==re.current)return;d(N),m([...Array.isArray(Z==null?void 0:Z.requests)?Z.requests:[],...Array.isArray(pe==null?void 0:pe.requests)?pe.requests:[]])}catch(N){w===re.current&&q(String((N==null?void 0:N.message)||N||"Failed to load agents"))}finally{re.current,$(!1)}try{const N=await s.list_entities();if(w!==re.current)return;x(Array.isArray(N==null?void 0:N.entities)?N.entities:[]),y("")}catch(N){if(w!==re.current)return;x([]),y(`#FALLBACK entity registry unavailable: ${String((N==null?void 0:N.message)||N)}`)}try{const N=await s.admin_executors();if(w!==re.current)return;const Z=Array.isArray(N)?N:Array.isArray(N==null?void 0:N.executors)?N.executors:[];A(Z)}catch{w===re.current&&A(N=>N===null?null:N)}try{const N=await s.admin_runtime_config();w===re.current&&D((N==null?void 0:N.writable)===!0)}catch{w===re.current&&D(!1)}}async function je(){re.current+=1;try{const w=await s.list_entities();x(Array.isArray(w==null?void 0:w.entities)?w.entities:[]),y("")}catch(w){y(`#FALLBACK entity registry unavailable: ${String((w==null?void 0:w.message)||w)}`)}}async function Ce(){re.current+=1;try{const w=await s.admin_executors(),N=Array.isArray(w)?w:Array.isArray(w==null?void 0:w.executors)?w.executors:[];A(N)}catch{}try{d(await s.backlog_exec_config())}catch{}}async function xe(w){if(K)return;const N=`executor:${w}`;T(N),ue(null);try{await s.admin_runtime_config_update({executor:w}),await Ce()}catch(Z){ue({key:N,text:String((Z==null?void 0:Z.message)||Z||"Executor change refused")})}finally{T("")}}const[J,ne]=f.useState(null);async function ve(w,N){if(K)return;const Z=String(w.slug||w.name||"").trim();if(!Z)return;const pe=`entity:${Z}`;T(pe),ue(null);try{await s.entity_state(Z,{state:N,reason:"by the operator via Continuum (Agents & Entities)"}),await je()}catch(oe){ue({key:pe,text:String((oe==null?void 0:oe.message)||oe||"State change refused")})}finally{T("")}}f.useEffect(()=>{Te()},[r]);const W=f.useMemo(()=>_v(p),[p]),Y=!!(c!=null&&c.runner_alive),z=String((c==null?void 0:c.executor)||"").trim(),V=!z||z==="none",U=V?"No execution agent":z;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."}),L?e.jsx("span",{className:"page_error mono",children:L}):null,e.jsx("div",{className:"page_toolbar_spacer"}),e.jsx("button",{className:`btn btn_icon ${E?"is_loading":""}`,onClick:()=>void Te(),disabled:!r||E,title:"Refresh","aria-label":"Refresh",children:e.jsx(tt,{name:"refresh",size:16})})]}),e.jsxs("div",{className:"agents_grid",children:[C!==null&&C.length?C.map(w=>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(tt,{name:"terminal",size:16})}),e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{className:"entity_card_title",children:w.display||w.id}),e.jsxs("div",{className:"entity_card_sub",children:["execution agent",w.default?" · gateway default":""]})]}),e.jsx("span",{className:`chip mono ${w.available?"ok":"danger"}`,style:{marginLeft:"auto"},children:w.available?"available":"unavailable"})]}),e.jsx("div",{className:"agent_facts",children:Array.isArray(w.models)&&w.models.length?e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"models:"})," ",w.models.slice(0,4).join(", "),w.models.length>4?` +${w.models.length-4}`:""]}):null}),e.jsx("div",{className:"entity_card_actions",children:w.default?e.jsx("span",{className:"chip mono ok",title:"New executions run under this agent unless the request overrides it.",children:"gateway default"}):O?e.jsx("button",{className:"btn",disabled:!!K||w.available===!1,title:w.available===!1?"Unavailable on the gateway host — the binary is not on its PATH":K&&K!==`executor:${w.id}`?"Another action is in flight":"Make this the gateway's default executor (admin, persisted gateway-side)",onClick:()=>void xe(w.id),children:K===`executor:${w.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"})}),(te==null?void 0:te.key)===`executor:${w.id}`?e.jsx("div",{className:"detail_warn",children:te.text}):null]},w.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(tt,{name:"terminal",size:16})}),e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{className:"entity_card_title",children:U}),e.jsx("div",{className:"entity_card_sub",children:V?"enable one from Settings → Gateway administration":"execution agent (gateway-configured)"})]}),e.jsx("span",{className:`chip mono ${Y?"ok":V?"warn":"danger"}`,style:{marginLeft:"auto"},children:Y?"available":V?"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(tt,{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 w;return(w=a.on_open_assistant)==null?void 0:w.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:[b?e.jsx("div",{className:"page_error",style:{fontSize:"var(--font-size-sm)"},children:b}):null,!b&&!_.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(w=>{var I,be,Re,qe,Oe,ut;if(w.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(tt,{name:"warning",size:16})}),e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{className:"entity_card_title",children:w.name||w.slug||"(unreadable home)"}),e.jsx("div",{className:"entity_card_sub mono",children:w.entity_id||w.slug})]}),e.jsx("span",{className:"chip mono danger",style:{marginLeft:"auto"},children:"error"})]}),e.jsx("div",{className:"detail_warn",style:{marginTop:0},children:w.error})]},w.entity_id||w.slug||w.name);const N=String(((I=w.state)==null?void 0:I.state)||"unknown").toLowerCase(),Z=N==="awake"?"ok":N==="asleep"?"info":N==="paused"?"warn":"muted",oe=String(w.liveness||((be=w.state)==null?void 0:be.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(tt,{name:"agent",size:16})}),e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{className:"entity_card_title",children:w.name||w.slug}),e.jsx("div",{className:"entity_card_sub mono",children:w.entity_id})]}),oe?e.jsx("span",{className:"chip mono danger",style:{marginLeft:"auto"},title:`The kill switch: served liveness=stopped (state: ${N}). Restore lives on the gateway console.`,children:"STOPPED"}):e.jsx("span",{className:`chip mono ${Z}`,style:{marginLeft:"auto"},children:N})]}),e.jsxs("div",{className:"agent_facts",children:[w.created_at?e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"born:"})," ",new Date(w.created_at).toLocaleDateString()]}):null,(Re=w.state)!=null&&Re.reason?e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"state reason:"})," ",w.state.reason]}):null,e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"home:"})," spark ",(qe=w.files)!=null&&qe.spark?"✓":"—"," · memory ",(Oe=w.files)!=null&&Oe.memory?"✓":"—"," · book ",(ut=w.files)!=null&&ut.book?"✓":"—"]})]}),e.jsxs("div",{className:"entity_card_actions",children:[!oe&&(N==="asleep"||N==="paused")?e.jsx("button",{className:"btn",disabled:!!K,title:K&&K!==`entity:${w.slug||w.name}`?"Another action is in flight":"Wake this entity (operator act, recorded as a host marker; the gateway authorizes or refuses)",onClick:()=>void ve(w,"awake"),children:K===`entity:${w.slug||w.name}`?"Waking…":"Wake"}):null,!oe&&N==="awake"?e.jsx("button",{className:"btn",disabled:!!K,title:K&&K!==`entity:${w.slug||w.name}`?"Another action is in flight":"Graceful sleep (in-flight work finishes; reflection runs). The gateway refuses if a visit is live.",onClick:()=>void ve(w,"asleep"),children:K===`entity:${w.slug||w.name}`?"Sending…":"Sleep"}):null,oe?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:()=>ne(he=>he===(w.name||w.slug)?null:w.name||w.slug||null),title:"What this mind is taught, per phase (selection persists in the entity's home; changes record as host markers)",children:J===(w.name||w.slug)?"Hide skills":"Skills"})]}),(te==null?void 0:te.key)===`entity:${w.slug||w.name}`?e.jsx("div",{className:"detail_warn",children:te.text}):null]},w.entity_id||w.slug)})}):null,J?e.jsx(pv,{gateway:s,entity_name:J,on_close:()=>ne(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:[W.length," agent",W.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:W.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:W.map(w=>e.jsxs("tr",{children:[e.jsx("td",{className:"td_agent mono",children:w.agent}),e.jsx("td",{children:w.runs}),e.jsx("td",{className:"col_aux",children:w.active||""}),e.jsx("td",{className:"col_aux",children:w.promoted||""}),e.jsx("td",{className:"col_aux",children:w.completed||""}),e.jsx("td",{className:"col_aux",children:w.awaiting_qa||""}),e.jsx("td",{className:w.failed?"page_error":"",children:w.failed||""}),e.jsx("td",{className:"col_aux2 td_time",children:w.timed_runs?Ws(w.total_run_ms/w.timed_runs):""}),e.jsx("td",{className:"col_aux2 td_time",children:w.last_active?new Date(w.last_active).toLocaleString():""})]},w.agent))})]})}):e.jsx("div",{className:"muted",style:{fontSize:"var(--font-size-sm)",padding:"12px"},children:"No execution history yet."})})]})]})})}function Hs(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 $f(a,s){const r=String(s||"").match(/^(\d{1,4})[-_]/);return!r||!a?null:`${a.toLowerCase()}-${r[1].padStart(4,"0")}`}function vv(a){return String(a||"").replace(/\\/g,"/").split("/").filter(Boolean).pop()||""}function yv(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 xv=/\b([a-z][a-z0-9_.-]{3,60}-\d{4})\b/g,bv=6;function wv(a){const s=[];for(const r of String(a||"").matchAll(xv)){const l=r[1];if(Hs(l)&&(s.includes(l)||s.push(l),s.length>=bv))break}return s}function Lh(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 m=Date.parse(String(l));if(Number.isNaN(m))return null;c=m}const d=Math.max(0,(s-c)/36e5);return{label:d<1?`claimed ${Math.max(1,Math.round(d*60))}m`:d<48?`claimed ${Math.round(d)}h`:`claimed ${Math.round(d/24)}d`,stale:d>=r}}const ql=["P0","P1","P2","P3"],Mh={P0:"P0 · critical",P1:"P1 · high",P2:"P2 · normal",P3:"P3 · low"},zh=/^>\s*priority:\s*(p[0-3])\b/i,Ph=/^>\s*labels:\s*(.+)$/i;function _d(a){return String(a||"").split(",").map(s=>s.trim().toLowerCase().replace(/\s+/g,"-")).filter(s=>!!s&&s.length<=40).slice(0,12)}function Pu(a,s){const r=[];let l=!1;for(const c of a){const d=c.trim();if(/^#{1,6}\s/.test(d)){l=s.test(d);continue}l&&r.push(c)}return r}const jv=["one paragraph describing","criterion 1 (clear, testable)"];function Ef(a){const s=a.trim().toLowerCase();return s?jv.some(r=>s.startsWith(r)):!0}function Ni(a){const s=String(a||"").split(/\r?\n/);let r=null,l=[];for(const _ of s.slice(0,60)){const x=_.trim();if(/^##+\s/.test(x))break;const b=zh.exec(x);b&&!r&&(r=b[1].toUpperCase());const y=Ph.exec(x);y&&!l.length&&(l=_d(y[1]))}const c=[];for(const _ of Pu(s,/acceptance criteria/i)){const x=/^\s*[-*]\s*\[( |x|X)\]\s*(.+)$/.exec(_);if(!x)continue;const b=x[2].trim();Ef(b)||c.push({text:b,checked:x[1].toLowerCase()==="x"})}const d=[];for(const _ of Pu(s,/testing/i))for(const x of _.matchAll(/`([^`]+)`/g)){const b=x[1].trim();!b||b==="..."||b.toLowerCase()==="n/a"||d.push(b)}const p=Pu(s,/^#{1,6}\s*summary\b/i).map(_=>_.trim()).filter(Boolean),m=p.length>0&&!p.every(Ef);return{priority:r,labels:l,acceptance:c,test_commands:d,has_summary:m}}function gd(a,s){const r=String(a.task_type||"").trim().toLowerCase(),l=[{id:"type",label:`Work type is set (${Ja.join(" / ")})`,ok:Ja.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}: "${Tf(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}: \`${Tf(s.test_commands[0],60)}\``:"none found under ## Testing"}];return{ok:l.every(c=>c.ok),checks:l}}function Tf(a,s){const r=String(a||"");return r.length<=s?r:`${r.slice(0,Math.max(0,s-1))}…`}function ed(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 d=(Array.isArray(l.checks)?l.checks:Array.isArray(l.members)?l.members.flatMap(p=>(Array.isArray(p==null?void 0:p.checks)?p.checks:[]).map(m=>({...m,label:p!=null&&p.relpath?`${p.relpath}: ${String((m==null?void 0:m.label)||"")}`:m==null?void 0:m.label}))):[]).map(p=>({id:String((p==null?void 0:p.id)||""),label:String((p==null?void 0:p.label)||""),ok:(p==null?void 0:p.ok)===!0,evidence:p!=null&&p.evidence?String(p.evidence):void 0}));return d.length?{ok:d.every(p=>p.ok),checks:d}:null}function td(a,s){const l=[...String(a||"").split(/\r?\n/)];function c(d,p){const m=[];for(let x=0;x<Math.min(l.length,60);x+=1){const b=l[x].trim();if(/^##+\s/.test(b))break;d.test(b)&&m.push(x)}if(m.length){for(let x=m.length-1;x>=1;x-=1)l.splice(m[x],1);p?l[m[0]]=p:l.splice(m[0],1);return}if(!p)return;let _=-1;for(let x=0;x<Math.min(l.length,60);x+=1){const b=l[x].trim();if(b.startsWith("> ")&&(_=x),/^##\s/.test(b))break}if(_<0){const x=l.findIndex(b=>b.trim().startsWith("# "));if(x>=0)_=x;else{l.unshift(p);return}}l.splice(_+1,0,p)}return c(zh,s.priority?`> Priority: ${s.priority}`:null),c(Ph,s.labels.length?`> Labels: ${s.labels.join(", ")}`:null),l.join(`
61
+ `)}const Af=[{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 nd(a){const s=String(a||"").trim().toUpperCase();return ql.includes(s)?s:null}function sd(a){return a.priority!==void 0||a.labels!==void 0}const kv="decision-gate";function Sv(a){return Array.isArray(a)&&a.some(s=>String(s||"").trim().toLowerCase()===kv)}function Ih(a,s){return Sv(a.labels!==void 0?a.labels:s==null?void 0:s.labels)}function Oh(a){return a.priority!==void 0||a.labels!==void 0}function ad(a,s){return a.priority!==void 0?a.priority:(s==null?void 0:s.priority)??null}function rd(a,s){return a.labels!==void 0?a.labels:(s==null?void 0:s.labels)??[]}const Nv=new Set(["queued","running"]);function Cv(a){const s=String(a||"").split("/").filter(Boolean);return s.length?s[s.length-1]:""}const $v=/^batch\((\d+)\)$/i;function Rf(a){const s=$v.exec(String(a||"").trim());return s?Number(s[1]):null}function Ev(a){const s=a.recent_limit??12,r=[],l=new Set;for(const b of a.active_items){const y=String(b.filename||"").trim();y&&l.add(y)}const c=(b,y,C)=>{const A=String(b.backlog_filename||"").trim()||Cv(String(b.backlog_relpath||"")),E=Rf(A),$=E!==null?"":A;return $&&C&&l.add($),{key:$&&C?`file:${$}`:`req:${b.request_id}`,column:y,title:E!==null?`Batch execution (${E} items)`:$||`Execution ${b.request_id.slice(0,8)}…`,filename:$||void 0,request_id:b.request_id,exec_status:String(b.status||"").trim().toLowerCase(),created_at:b.created_at??null,started_at:b.started_at??null,finished_at:b.finished_at??null,target_agent:b.target_agent??(b.target_model?`${String(b.executor_type||"agent").trim()||"agent"}:${b.target_model}`:null),batch_size:E!==null?E:void 0}};for(const b of a.active_requests){const y=String(b.status||"").trim().toLowerCase();Nv.has(y)?r.push(c(b,"in_progress",!0)):y==="awaiting_qa"&&r.push(c(b,"in_review",!0))}const d=[...a.terminal_requests].sort((b,y)=>{const C=String(b.finished_at||b.started_at||b.created_at||"");return String(y.finished_at||y.started_at||y.created_at||"").localeCompare(C)}),p=new Map;let m=0,_=0;for(const b of d){const y=String(b.status||"").trim().toLowerCase();if(y==="failed"){const C=String(b.backlog_filename||"").trim();C&&Rf(C)===null&&p.set(C,(p.get(C)||0)+1),_<s&&(r.push(c(b,"failed",!1)),_+=1)}else(y==="promoted"||y==="completed")&&m<s&&(r.push(c(b,"done",!1)),m+=1)}for(const b of a.planned){const y=String(b.filename||"").trim();!y||l.has(y)||r.push({key:`file:${y}`,column:"ready",title:b.title||y,kind:"planned",filename:y,item_id:b.item_id,package:b.package,task_type:b.task_type,summary:b.summary,recent_failures:p.get(y)||void 0,priority:sd(b)?nd(b.priority):void 0,labels:Array.isArray(b.labels)?b.labels:void 0})}for(const b of a.proposed){const y=String(b.filename||"").trim();!y||l.has(y)||r.push({key:`file:${y}`,column:"triage",title:b.title||y,kind:"proposed",filename:y,item_id:b.item_id,package:b.package,task_type:b.task_type,summary:b.summary,priority:sd(b)?nd(b.priority):void 0,labels:Array.isArray(b.labels)?b.labels:void 0})}const x=new Map;for(const b of[...a.planned,...a.proposed])x.set(String(b.filename||"").trim(),b);for(const b of r){if(!b.filename||b.kind)continue;const y=x.get(b.filename);y&&(b.title=y.title||b.title,b.item_id=y.item_id,b.package=y.package,b.task_type=y.task_type,b.summary=y.summary)}return r}const Tv=200;function Av(a,s){var b;const{live:r,done:l}=s,c=s.work||new Map;if(!r.size&&!l.length&&!c.size)return a;const d=new Set,p=new Set;for(const y of a){if(!y.filename||!y.package)continue;const C=$f(y.package,y.filename);C&&p.add(C)}const m=a.map(y=>{if(y.column!=="ready"||y.kind!=="planned"||!y.filename||!y.package)return y;const C=$f(y.package,y.filename);if(!C)return y;const A=r.get(C);return!A||!A.owner?y:(d.add(C),{...y,column:"in_progress",work_id:C,claim_owner:A.owner,claim_started_at:A.started_at})}),_=new Map;m.forEach((y,C)=>{y.filename&&_.set(y.filename,C)});for(const[y,C]of c){const A=C.card?_.get(vv(C.card)):void 0;if(p.has(y)||A!==void 0){if(A!==void 0){const L=m[A],q={...L,work_id:L.work_id||y,card_path:L.card_path||C.card},O=r.get(y);O!=null&&O.owner&&(d.add(y),q.claim_owner||(q.claim_owner=O.owner,q.claim_started_at=O.started_at)),m[A]=q}continue}if(C.status==="deprecated")continue;const E=r.get(y),$=C.status==="completed"?"done":C.status==="planned"?E!=null&&E.owner?"in_progress":"ready":"triage";E!=null&&E.owner&&d.add(y),m.push({key:`work:${y}`,column:$,title:C.title||y,work_id:y,package:(b=Hs(y))==null?void 0:b.package,summary:C.receipt,card_path:C.card,claim_owner:(E==null?void 0:E.owner)||(C.status==="completed"?C.owner:void 0),claim_started_at:E==null?void 0:E.started_at})}for(const[y,C]of r){if(d.has(y)||!C.owner)continue;const A=Hs(y);m.push({key:`claim:${y}`,column:"in_progress",title:typeof C.task=="string"&&C.task?C.task:y,work_id:A?y:void 0,package:A==null?void 0:A.package,claim_owner:C.owner,claim_started_at:C.started_at})}const x=new Set(m.filter(y=>y.column==="done").map(y=>y.work_id).filter(Boolean));for(const y of l.slice(0,Tv)){if(x.has(y.item))continue;const C=Hs(y.item);m.push({key:`claim-done:${y.item}`,column:"done",title:y.item,work_id:C?y.item:void 0,package:C==null?void 0:C.package,claim_owner:y.owner,summary:y.receipt})}return m}function ki(a){const s=String((a==null?void 0:a.message)??a??"");return/backlog folder not available|backlog browsing not configured/i.test(s)}function Lf(a){return String((a==null?void 0:a.message)??a??"").trim().replace(/^[a-z_]+ failed: /,"")}function vd(a,s,r){const[l,c]=f.useState({status:null,legacy:!1});return f.useEffect(()=>{if(!s)return;let d=!1;return(async()=>{try{const p=await a.backlog_status();d||c({status:p,legacy:!1})}catch(p){d||c({status:null,legacy:Number(p==null?void 0:p.status)===404})}})(),()=>{d=!0}},[a,s,r]),l}function Rv(){return e.jsxs(e.Fragment,{children:["Ask the gateway admin to set the backlog folder (gateway console → Apps → Backlog settings, or"," ",e.jsx("code",{className:"mono",children:"abstractgateway config set triage_repo_root PATH"})," on the gateway's computer)."]})}function yd(a){const{gateway:s,surface:r,status:l,legacy:c,on_changed:d}=a,[p,m]=f.useState(!1),[_,x]=f.useState(""),[b,y]=f.useState(!1),[C,A]=f.useState(""),[E,$]=f.useState((l==null?void 0:l.writable)??null);f.useEffect(()=>{if((l==null?void 0:l.writable)!==void 0){$(!!l.writable);return}if(!c)return;let D=!1;return s.admin_runtime_config().then(K=>{D||$((K==null?void 0:K.writable)===!0)}).catch(()=>{D||$(!1)}),()=>{D=!0}},[s,l==null?void 0:l.writable,c]);async function L(D){if(!b){y(!0),A("");try{await s.admin_runtime_config_update({triage_repo_root:D}),m(!1),d==null||d()}catch(K){A(Lf(K))}finally{y(!1)}}}const q=String((l==null?void 0:l.reason)||"").trim()||(a.error?Lf(a.error):""),O=String((l==null?void 0:l.default_path)||"").trim();return e.jsxs("div",{className:"pane setup_callout","data-testid":"backlog_unavailable",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"This gateway's backlog folder is not available"}),e.jsxs("span",{className:"chip mono warn",children:[r," has no data"]})]}),e.jsxs("div",{className:"pane_body",children:[e.jsxs("div",{style:{fontSize:"var(--font-size-md)"},children:[l!=null&&l.path?e.jsxs(e.Fragment,{children:[e.jsx("code",{className:"mono",children:l.path})," —"," "]}):null,q||"the gateway did not say why."]}),E===!0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"callout_actions",style:{marginTop:"10px"},children:[O?e.jsx("button",{className:"btn primary",disabled:b,onClick:()=>void L(O),title:O,children:"Use the gateway's own folder"}):null,e.jsx("button",{className:"btn",disabled:b,onClick:()=>m(D=>!D),children:"Choose a folder…"})]}),O?e.jsxs("div",{className:"muted",style:{fontSize:"var(--font-size-sm)",marginTop:"6px"},children:["The gateway's own folder is ",e.jsx("code",{className:"mono",children:O}),"; it is created with a starter overview and item template."]}):null,p?e.jsxs("form",{className:"field",style:{marginTop:"10px"},onSubmit:D=>{D.preventDefault(),_.trim()&&L(_.trim())},children:[e.jsx("label",{htmlFor:"backlog_folder_path",children:"Folder on the gateway's computer that contains docs/backlog"}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsx("input",{id:"backlog_folder_path",className:"mono",value:_,onChange:D=>x(String(D.target.value||"")),placeholder:"/path/to/your/project",autoFocus:!0}),e.jsx("button",{className:"btn primary",type:"submit",disabled:b||!_.trim(),children:b?"Saving…":"Use this folder"})]})]}):null,C?e.jsx("div",{className:"page_error mono",role:"alert",style:{marginTop:"8px"},children:C}):null]}):E===!1?e.jsx("div",{className:"muted",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:e.jsx(Rv,{})}):null]})]})}function Lv(a){const{status:s,on_create:r}=a,[l,c]=f.useState(!1),d=String((s==null?void 0:s.path)||"").trim(),p=d?`${d.replace(/\/+$/,"")}/docs/backlog/proposed/`:"docs/backlog/proposed/",m=d?`${d.replace(/\/+$/,"")}/${(s==null?void 0:s.template_relpath)||"docs/backlog/template.md"}`:(s==null?void 0:s.template_relpath)||"docs/backlog/template.md";return e.jsxs("div",{className:"pane setup_callout","data-testid":"backlog_empty",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Your backlog is empty"}),s!=null&&s.is_default?e.jsx("span",{className:"chip mono muted",children:"the gateway's own folder"}):null]}),e.jsxs("div",{className:"pane_body",children:[d?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap"},children:[e.jsx("span",{className:"muted",style:{fontSize:"var(--font-size-sm)"},children:"Backlog folder"}),e.jsx("code",{className:"mono",children:d}),e.jsx("button",{className:"btn",onClick:()=>{fn(d),c(!0)},children:l?"Copied":"Copy"})]}):null,e.jsxs("div",{className:"callout_text",style:{marginTop:"8px"},children:["Each item is a Markdown file: new ones land in ",e.jsx("code",{className:"mono",children:p})," (Triage), accepted ones move to"," ",e.jsx("code",{className:"mono",children:"planned/"})," (Ready). Start from the template ",e.jsx("code",{className:"mono",children:m}),", or let Continuum write it for you."]}),r?e.jsx("div",{className:"callout_actions",style:{marginTop:"10px"},children:e.jsx("button",{className:"btn primary",onClick:r,children:"Create your first item"})}):null]})]})}function Mv(a){return a.kind?[a.kind]:["completed","planned","proposed"]}function Dh(a){const{gateway:s,can_use_gateway:r,target:l,on_close:c,on_mutated:d,on_open_executions:p}=a,m=!!l,[_,x]=f.useState("spec"),[b,y]=f.useState(""),[C,A]=f.useState(""),[E,$]=f.useState(null),[L,q]=f.useState(!1),[O,D]=f.useState(""),[K,T]=f.useState(!1),[te,ue]=f.useState(""),[re,Te]=f.useState(!1),[je,Ce]=f.useState(""),[xe,J]=f.useState(""),[ne,ve]=f.useState(!1),[W,Y]=f.useState([]),[z,V]=f.useState(!1),[U,w]=f.useState(null),[N,Z]=f.useState(null),[pe,oe]=f.useState(""),[I,be]=f.useState(!1),[Re,qe]=f.useState(""),[Oe,ut]=f.useState({}),he=f.useMemo(()=>Ni(b),[b]);f.useEffect(()=>{if(!m||!l)return;const Q=_e=>{_e.key!=="Escape"||_e.defaultPrevented||zv(_e.target)||K||document.querySelector(".modal_backdrop")||(_e.preventDefault(),c())};return window.addEventListener("keydown",Q),()=>window.removeEventListener("keydown",Q)},[m,l,c,K]),f.useEffect(()=>{!m||!l||(x(l.initial_tab||"spec"),T(!1),D(""),qe(""),oe(""),ut({}),fe(!1),w(null),Z(null),$(null),Fe(l),Le(l))},[m,l==null?void 0:l.filename,l==null?void 0:l.kind,l==null?void 0:l.request_id]);async function Fe(Q){if(!Q.filename){y(""),A("");return}q(!0);try{let _e=null,Ie=null;for(const ce of Mv(Q))try{const ke=await s.backlog_content(ce,Q.filename);_e={kind:ce,text:String((ke==null?void 0:ke.content)||"")};break}catch(ke){Ie=ke}if(!_e)throw Ie||new Error("Spec not found in any backlog kind");$(_e.kind),y(_e.text),A(await Zu(_e.text));const ot=Ni(_e.text);Ce(ot.priority||""),J(ot.labels.join(", "))}catch(_e){D(String((_e==null?void 0:_e.message)||_e||"Failed to load the spec"))}finally{q(!1)}}async function Le(Q){V(!0);try{const[_e,Ie]=await Promise.all([s.backlog_exec_requests({status:"queued,running,awaiting_qa",limit:200}),s.backlog_exec_requests({status:"promoted,completed,failed",limit:200})]),ce=[...Array.isArray(_e==null?void 0:_e.requests)?_e.requests:[],...Array.isArray(Ie==null?void 0:Ie.requests)?Ie.requests:[]].filter(Be=>Q.filename&&String(Be.backlog_filename||"").trim()===Q.filename||Be.request_id===Q.request_id);ce.sort((Be,$e)=>String($e.created_at||"").localeCompare(String(Be.created_at||""))),Y(ce);const ke=ce.find(Be=>String(Be.status||"").toLowerCase()==="awaiting_qa")||null;if(w(ke),ke)try{const Be=await s.backlog_exec_request(ke.request_id);Z((Be==null?void 0:Be.payload)??null)}catch{Z(null)}}catch{Y([])}finally{V(!1)}}async function Ge(){if(!l||re)return;const Q=E||l.kind;if(Q){Te(!0),D("");try{const _e=await s.backlog_update({kind:Q,filename:l.filename,content:te,expected_sha256:C||null}),Ie=te.endsWith(`
62
+ `)?te:`${te}
63
+ `;y(Ie),A(String((_e==null?void 0:_e.sha256)||"")),T(!1),await d()}catch(_e){D(String((_e==null?void 0:_e.message)||_e||"Save failed"))}finally{Te(!1)}}}async function de(){if(!l||ne)return;const Q=E||l.kind;if(Q){ve(!0),D("");try{const _e=td(b,{priority:je||null,labels:_d(xe)}),Ie=await s.backlog_update({kind:Q,filename:l.filename,content:_e,expected_sha256:C||null});y(_e.endsWith(`
64
+ `)?_e:`${_e}
65
+ `),A(String((Ie==null?void 0:Ie.sha256)||"")),await d()}catch(_e){D(String((_e==null?void 0:_e.message)||_e||"Metadata save failed"))}finally{ve(!1)}}}const[H,fe]=f.useState(!1);async function we(Q){if(!(!U||I)){if(Q==="feedback"&&!pe.trim()){qe("Feedback is required.");return}be(!0),qe("");try{Q==="feedback"?await s.backlog_exec_feedback({request_id:U.request_id,feedback:pe}):Q==="promote"?await s.backlog_exec_promote({request_id:U.request_id,redeploy:!0}):await s.backlog_exec_deploy_uat({request_id:U.request_id}),oe(""),fe(!1),l&&await Le(l),await d()}catch(_e){qe(String((_e==null?void 0:_e.message)||_e||"QA action failed"));try{const Ie=await s.backlog_exec_request(U.request_id);Z((Ie==null?void 0:Ie.payload)??null)}catch{}}finally{be(!1)}}}if(!m||!l)return null;const X=he.acceptance.filter((Q,_e)=>!Oe[`${_e}:${Q.text}`]).length;return e.jsx("div",{className:"drawer_backdrop",onMouseDown:Q=>{Q.target===Q.currentTarget&&c()},children:e.jsxs("div",{className:"drawer_panel work_drawer",role:"dialog","aria-modal":"true","aria-label":l.title||"Work item",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:[E||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:()=>fn(`docs/backlog/${E||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:()=>x("spec"),children:"Spec"}),e.jsxs("button",{className:`tab ${_==="runs"?"active":""}`,onClick:()=>x("runs"),children:["Runs ",W.length?`(${W.length})`:""]}),e.jsxs("button",{className:`tab ${_==="review"?"active":""}`,onClick:()=>x("review"),children:["Review",U?" ●":""]})]}),e.jsxs("div",{className:"drawer_body work_drawer_body",children:[O?e.jsx("div",{className:"mono board_error",children:O}):null,_==="spec"?e.jsxs(e.Fragment,{children:[l.has_live_request?e.jsx("div",{className:"mono work_drawer_warn",style:{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:je,onChange:Q=>Ce(Q.target.value),disabled:ne,title:"Priority",children:[e.jsx("option",{value:"",children:"priority: unset"}),ql.map(Q=>e.jsx("option",{value:Q,children:Mh[Q]},Q))]}),e.jsx("input",{value:xe,onChange:Q=>J(Q.target.value),placeholder:"labels (comma-separated; sprints: sprint-29)",disabled:ne}),e.jsx("button",{className:"btn",onClick:()=>void de(),disabled:ne||!r||L,children:ne?"Saving…":"Save metadata"}),K?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:()=>T(!1),disabled:re,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:()=>void Ge(),disabled:re,children:re?"Saving…":"Save spec"})]}):e.jsx("button",{className:"btn",onClick:()=>{ue(b),T(!0)},disabled:L,children:"Edit spec"})]}):null,L?e.jsx("div",{className:"mono muted",children:"Loading…"}):K?e.jsx("textarea",{className:"mono work_spec_editor",value:te,onChange:Q=>ue(Q.target.value),rows:24}):b?e.jsxs(e.Fragment,{children:[e.jsx(ls,{className:"md_doc",text:b}),e.jsx("div",{className:"mono muted work_drawer_hint",style:{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:[z?e.jsx("div",{className:"mono muted",children:"Loading…"}):null,!z&&!W.length?e.jsx("div",{className:"mono muted",children:"No executions for this item in recent history (window: live + last 200 finished)."}):null,W.map(Q=>{const _e=String(Q.status||"").toLowerCase(),Ie=Fl(Q);return e.jsxs("div",{className:"work_run_row",children:[e.jsx("span",{className:`chip mono ${Il(_e)}`,children:_e}),e.jsx("span",{className:"mono muted",children:ha(Q.request_id,18)}),e.jsx("span",{className:"mono muted",children:Q.created_at?new Date(Q.created_at).toLocaleString():""}),e.jsx("span",{className:"mono muted",children:Ie.run_ms!=null?`ran ${Ws(Ie.run_ms)}`:""}),Q.target_agent?e.jsx("span",{className:"chip mono muted",children:Q.target_agent}):null,_e==="running"||_e==="queued"||_e==="awaiting_qa"?e.jsx("button",{className:"btn",onClick:()=>p(Q.request_id),children:_e==="awaiting_qa"?"View logs":"Follow live"}):null]},Q.request_id)})]}):null,_==="review"?U?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 work_drawer_hint",style:{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((Q,_e)=>e.jsxs("label",{className:"work_dod_item",children:[e.jsx("input",{type:"checkbox",checked:!!Oe[`${_e}:${Q.text}`],onChange:Ie=>ut(ot=>({...ot,[`${_e}:${Q.text}`]:Ie.target.checked}))}),e.jsx("span",{children:Q.text})]},`dod:${_e}:${Q.text}`))}):e.jsx("div",{className:"mono muted",children:"This spec declares no acceptance criteria — review against the diff and logs."}),(()=>{const Q=String((N==null?void 0:N.execution_mode)||"uat").toLowerCase(),_e=String((N==null?void 0:N.candidate_relpath)||"").trim(),Ie=N==null?void 0:N.promotion_report,ot=!!(Ie!=null&&Ie.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 work_review_meta",children:["mode: ",Q,_e?` • candidate: ${_e}`:""]}),e.jsx("button",{className:"btn",onClick:()=>p(U.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((Ie==null?void 0:Ie.reason)||"conflicts")," — iterate on top of current prod or resolve manually."]}):null]})})(),he.acceptance.length&&X>0?e.jsxs("div",{className:"mono work_drawer_warn",style:{marginTop:"8px"},children:[X," acceptance criteri",X===1?"on":"a"," unconfirmed — promoting anyway is an override."]}):null,e.jsx("textarea",{value:pe,onChange:Q=>oe(Q.target.value),rows:3,placeholder:"QA feedback (what to change / fix)…",style:{width:"100%",marginTop:"10px"},disabled:I}),Re?e.jsx("div",{className:"mono board_error",children:Re}):null,e.jsxs("div",{className:"row",style:{gap:8,marginTop:"10px",flexWrap:"wrap",alignItems:"center"},children:[e.jsx("button",{className:"btn",onClick:()=>void we("deploy_uat"),disabled:I,children:"Restart UAT"}),H?e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"btn danger",onClick:()=>void we("promote"),disabled:I,children:["Confirm: promote to prod",X>0?` (${X} unconfirmed)`:""," + redeploy"]}),e.jsx("button",{className:"btn",onClick:()=>fe(!1),disabled:I,children:"Cancel"})]}):e.jsx("button",{className:"btn primary",onClick:()=>fe(!0),disabled:I,children:he.acceptance.length&&X>0?"Promote (override)…":"Approve → promote…"}),e.jsx("button",{className:"btn",onClick:()=>void we("feedback"),disabled:I,children:"Iterate (send feedback)"})]})]}):e.jsx("div",{className:"mono muted",children:"Nothing awaiting review for this item."}):null]})]})})}function zv(a){const s=a;return!s||typeof s.closest!="function"?!1:!!s.closest("input, textarea, select, [contenteditable=''], [contenteditable='true']")}function Mr(){return F_()}async function Pv(a){const s=[],r=[];for(const l of a){const c=String((l==null?void 0:l.name)||"").trim()||"attachment";r.push(c);try{const d=await l.text();s.push(`[attached file: ${c}]
66
+
67
+ \`\`\`
68
+ ${d}
69
+ \`\`\``)}catch{s.push(`[attached file: ${c}] (unreadable in browser)`)}}return{picked:r,text:s.join(`
70
+
71
+ `)}}function Iv(a){const{gateway:s,can_use_gateway:r,is_compact_layout:l,maint_provider:c,maint_model:d,maint_reasoning:p,advisor_agent:m,focus_kind:_,focus_type:x}=a,[b,y]=f.useState(!1),[C,A]=f.useState([]),[E,$]=f.useState(""),[L,q]=f.useState(!1),[O,D]=f.useState(""),[K,T]=f.useState(!1),[te,ue]=f.useState([]),re=f.useRef(null),Te=f.useRef(null),je=String(a.voice_session_id||"").trim()||"abstractcontinuum_backlog_advisor",[Ce,xe]=f.useState(""),[J,ne]=f.useState("");f.useEffect(()=>{(async()=>{try{const N=await pd(je);xe(N)}catch{xe("")}})()},[je]);const ve=f.useMemo(()=>{if(!r)return{};const N=String(Ce||"").trim(),Z=je;return{tts:async pe=>{if(!N)throw new Error("Voice store not available (missing run_id).");const oe=await s.voice_tts(N,{text:pe,request_id:Mr()}),I=oe==null?void 0:oe.audio_artifact,be=I&&typeof I=="object"&&!Array.isArray(I)?String(I.$artifact||"").trim():"";if(!be)throw new Error("TTS failed: missing audio artifact");return await(await s.download_run_artifact_content(N,be)).arrayBuffer()},transcribe:async(pe,oe)=>{if(!N)throw new Error("Voice input unavailable (missing run_id).");const I=String(oe||pe.type||"").toLowerCase(),be=I.includes("mp4")?"m4a":I.includes("ogg")?"ogg":I.includes("wav")?"wav":"webm",Re=new File([pe],`recording.${be}`,{type:I||"audio/webm"}),qe=await s.attachments_upload(Z,Re,{filename:Re.name,content_type:Re.type}),Oe=await s.audio_transcribe(N,{audio_artifact:qe,request_id:Mr()});return String((Oe==null?void 0:Oe.text)||"").trim()}}},[r,s,Ce,je]),W=fh({...ve,on_error:ne,on_transcript:N=>{const Z=String(N||"").trim();Z&&($(pe=>{const oe=String(pe||"");return oe.trim()?`${oe.trimEnd()}
72
+ ${Z}`:Z}),window.setTimeout(()=>{var pe;return(pe=re.current)==null?void 0:pe.focus()},0))}});f.useEffect(()=>{if(!b)return;const N=Z=>{Z.key==="Escape"&&(w(),y(!1))};return window.addEventListener("keydown",N),setTimeout(()=>{var Z;return(Z=re.current)==null?void 0:Z.focus()},0),()=>window.removeEventListener("keydown",N)},[b]);async function Y(){if(L||!r)return;if(W.voice_ptt_busy){ne("Wait for transcription to finish.");return}D(""),ne("");const N=E.trim();if(!N)return;const Z={id:Mr(),role:"user",content:N,ts:new Date().toISOString()},pe=[...C,Z];A(pe),$(""),q(!0);try{const oe=await s.backlog_advisor({messages:pe.map(qe=>({role:qe.role,content:qe.content})),provider:c||null,model:d||null,thinking:p||null,agent:m||null,include_trace:K,focus_kind:_,focus_type:x}),I=K&&Array.isArray(oe==null?void 0:oe.tool_trace)?oe.tool_trace:[],be=String((oe==null?void 0:oe.run_id)||"").trim(),Re=String((oe==null?void 0:oe.reply)||"").trim();if(K&&I.length){const qe={id:Mr(),role:"system",title:"Tool execution",level:"info",ts:new Date().toISOString(),content:JSON.stringify({run_id:be||null,tool_trace:I},null,2)};A(Oe=>[...Oe,qe])}Re&&A(qe=>[...qe,{id:Mr(),role:"assistant",content:Re,ts:new Date().toISOString()}])}catch(oe){D(String((oe==null?void 0:oe.message)||oe||"Backlog advisor failed"))}finally{q(!1)}}async function z(N){var I;const Z=Array.from(N||[]);if(!Z.length)return;const{picked:pe,text:oe}=await Pv(Z);ue(be=>[...pe,...be].slice(0,12)),$(be=>{const Re=String(be||"").trim();return Re?`${Re}
73
+
74
+ ${oe}`:oe});try{(I=re.current)==null||I.focus()}catch{}}function V(N){const Z=String(N.id||N.ts||"").trim(),pe=String(N.content||"").trim();!Z||!pe||(ne(""),W.toggle_tts(Z,pe))}function U(N){const Z=String(N.id||N.ts||"").trim(),pe=W.tts_playback;return!Z||!pe.key||pe.key!==Z?"idle":pe.status}function w(){W.stop_voice_ptt_recording(),W.stop_tts()}return e.jsxs(e.Fragment,{children:[e.jsx("button",{className:`advisor_toggle ${b?"open":""}`,onClick:()=>{y(N=>{const Z=!N;return Z||w(),Z})},title:"Open backlog advisor (read-only)","aria-label":"Open backlog advisor",children:e.jsx("span",{className:"advisor_toggle_label",children:"Advisor"})}),b?e.jsx("div",{className:"drawer_backdrop",onMouseDown:N=>{N.target===N.currentTarget&&(w(),y(!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: ",m||"basic-agent"," • Using: ",c||"(gateway default)"," / ",d||"(gateway default)"]})]}),e.jsxs("div",{className:"row",style:{gap:8,justifyContent:"flex-end"},children:[e.jsxs("button",{className:`btn btn_icon ${K?"primary":""}`,onClick:()=>T(N=>!N),disabled:L,title:K?"Hide tool execution":"Show tool execution","aria-label":K?"Hide tool execution":"Show tool execution",children:[e.jsx(tt,{name:"terminal",size:16}),l?null:K?"Tools on":"Tools"]}),e.jsx("button",{className:"btn",onClick:()=>A([]),disabled:L||!C.length,children:"Clear"}),e.jsx("button",{className:"btn",onClick:()=>{w(),y(!1)},children:"Close"})]})]}),e.jsxs("div",{className:"drawer_body",children:[e.jsx(hd,{messages:C,className:"drawer_chat_thread",messageProps:W.tts_supported&&r&&Ce.trim()?{onSpeakToggle:V,getSpeakState:U,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:Te,type:"file",multiple:!0,style:{display:"none"},onChange:N=>{const Z=Array.from(N.currentTarget.files||[]);N.currentTarget.value="",Z.length&&z(Z)}}),e.jsx(uc,{ref:re,value:E,onChange:$,onSubmit:()=>void Y(),placeholder:"Message to backlog advisor…",disabled:!r,busy:L||W.voice_ptt_busy,rows:3,sendButtonClassName:"btn primary",busyLabel:W.voice_ptt_busy?"Transcribing…":"Thinking…",actions:e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:`btn btn_icon voice_btn${W.voice_ptt_recording?" danger":""}`,type:"button",disabled:!r||!Ce.trim()||L||W.voice_ptt_busy||!W.voice_ptt_supported,title:W.voice_ptt_supported?W.voice_ptt_busy?"Transcribing…":W.voice_ptt_recording?"Recording… release to transcribe":"Hold to talk (record + transcribe)":Sf()?"Voice recording is not supported in this browser":kf,"aria-label":"Voice input",onPointerDown:N=>{var Z,pe;if(!(!r||!Ce.trim()||L||W.voice_ptt_busy||!W.voice_ptt_supported)){N.preventDefault();try{(pe=(Z=N.currentTarget)==null?void 0:Z.setPointerCapture)==null||pe.call(Z,N.pointerId)}catch{}W.start_voice_ptt_recording()}},onPointerUp:N=>{N.preventDefault(),W.stop_voice_ptt_recording()},onPointerCancel:N=>{N.preventDefault(),W.stop_voice_ptt_recording()},children:[e.jsx(tt,{name:W.voice_ptt_recording?"x":"mic",size:16}),l?null:W.voice_ptt_busy?"Transcribing…":W.voice_ptt_recording?"Recording…":"Voice"]}),e.jsxs("button",{className:"btn btn_icon",type:"button",onClick:()=>{var N;return(N=Te.current)==null?void 0:N.click()},disabled:L,title:"Attach a local file to your message","aria-label":"Attach file",children:[e.jsx(tt,{name:"paperclip",size:16}),l?null:"Attach"]})]})}),te.length?e.jsxs("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"6px"},children:["Last attached: ",te[0]]}):null,O?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:O}):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,Sf()?null:e.jsx("div",{className:"muted","data-testid":"voice-https-hint",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:kf}),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 Ya({open:a,title:s,children:r,actions:l,variant:c="default",onClose:d}){if(f.useEffect(()=>{if(!a)return;const m=_=>{_.key!=="Escape"||_.defaultPrevented||(_.preventDefault(),d())};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[a,d]),!a)return null;const p=c==="fullscreen";return e.jsx("div",{className:`modal_backdrop${p?" fullscreen":""}`,onMouseDown:m=>{m.target===m.currentTarget&&d()},children:e.jsxs("div",{className:`modal_panel${p?" fullscreen":""}`,role:"dialog","aria-modal":"true","aria-label":s,children:[e.jsxs("div",{className:"modal_header",children:[e.jsx("div",{className:"modal_title",children:s}),e.jsx("button",{className:"btn",onClick:d,children:"Close"})]}),e.jsx("div",{className:"modal_body",children:r}),l?e.jsx("div",{className:"modal_footer",children:l}):null]})})}function Ov(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 config set backlog_exec_runner on # or: Settings → Gateway administration → Enable","abstractgateway config set 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 from the gateway's computer (terminal)"}),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(`
75
+ `)}),e.jsx("button",{className:"btn",style:{marginTop:"4px"},onClick:()=>fn(l.join(`
76
+ `)),children:"Copy setup"})]})]}):null]})}function qh(a){const{value:s,onChange:r,disabled:l,inplace_warning:c,uat_note:d}=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:p=>r(p.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:d})]})}const Dv=["minimal","low","medium","high"];function Bh(a){const{executors:s,value:r,onChange:l,disabled:c}=a;if(!s||!s.length)return null;const d=s.find(p=>p.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:p=>l(p.target.value),disabled:c,style:{width:"100%"},children:[e.jsxs("option",{value:"",children:["gateway default",d?` (${d.display||d.id})`:""]}),s.map(p=>e.jsxs("option",{value:p.id,disabled:p.available===!1,children:[p.display||p.id,p.available===!1?" (unavailable on the gateway host)":""]},p.id))]})]})}function Fv(a){const{exec_cfg:s,model:r,set_model:l,effort:c,set_effort:d,disabled:p}=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:m=>l(m.target.value),placeholder:String((s==null?void 0:s.codex_model)||"gateway default"),disabled:p})]})}),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:m=>d(m.target.value),disabled:p,children:[e.jsx("option",{value:"",children:"gateway default"}),Dv.map(m=>e.jsx("option",{value:m,children:m},m))]})]})})]}),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 Uh(a){const{open:s,target:r,execute_mode:l,set_execute_mode:c,action_loading:d,action_error:p,exec_cfg:m,exec_cfg_loading:_,exec_cfg_error:x,on_confirm:b,on_close:y}=a,C=a.readiness??null,A=a.show_readiness===!0,[E,$]=Wt.useState(""),[L,q]=Wt.useState(""),[O,D]=Wt.useState(""),K=(r==null?void 0:r.filename)||"";Wt.useEffect(()=>{$(""),q(""),D("")},[K]);const T=E.trim()||L||O?{executor:O||void 0,target_model:E.trim()||void 0,target_reasoning_effort:L||void 0}:void 0;return e.jsxs(Ya,{open:s,title:"Execute backlog item?",onClose:y,actions:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:y,disabled:d,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:()=>b(T),disabled:d||_||!r||(m==null?void 0:m.can_execute)!==!0,children:d?"Executing…":A&&!C?"Execute (readiness unknown)":C&&!C.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)"})]}),m?e.jsxs("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"6px"},children:["Agent: ",String(m.executor||"executor"),m.codex_model?` · ${m.codex_model}`:"",m.codex_reasoning_effort?` (reasoning ${m.codex_reasoning_effort})`:""]}):null,e.jsx(Bh,{executors:a.executors??null,value:O,onChange:D,disabled:d}),e.jsx(Fv,{exec_cfg:m,model:E,set_model:$,effort:L,set_effort:q,disabled:d}),A?e.jsx(Ov,{readiness:C,server_refused:a.server_refused,on_open_spec:a.on_open_spec}):null,e.jsx(qh,{value:l,onChange:c,disabled:d,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,!_&&(m==null?void 0:m.can_execute)!==!0?e.jsx(Fh,{exec_cfg:m,with_setup:!0}):null,x?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"10px"},children:x}):null,p?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"10px"},children:p}):null]})}function qv(a){const{open:s,batch_selected_items:r,batch_execute_mode:l,set_batch_execute_mode:c,batch_execute_loading:d,batch_execute_error:p,exec_cfg:m,exec_cfg_loading:_,exec_cfg_error:x,on_confirm:b,on_close:y}=a,[C,A]=Wt.useState("");return Wt.useEffect(()=>{s||A("")},[s]),e.jsxs(Ya,{open:s,title:"Execute batch (single context)?",onClose:y,actions:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:y,disabled:d,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:()=>b(C||void 0),disabled:d||_||r.length<2||(m==null?void 0:m.can_execute)!==!0,children:d?"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(Bh,{executors:a.executors??null,value:C,onChange:A,disabled:d}),e.jsx(qh,{value:l,onChange:c,disabled:d,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(E=>e.jsxs("div",{children:["- docs/backlog/planned/",E.filename]},`batchitem:${E.filename}`))}):null,_?e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"10px"},children:"Checking worker…"}):null,!_&&(m==null?void 0:m.can_execute)!==!0?e.jsx(Fh,{exec_cfg:m}):null,x?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"10px"},children:x}):null,p?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"10px"},children:p}):null]})}function Bv(a){const{open:s,batch_selected_items:r,merge_package:l,set_merge_package:c,merge_task_type:d,set_merge_task_type:p,merge_title:m,set_merge_title:_,merge_summary:x,set_merge_summary:b,merge_loading:y,merge_error:C,on_confirm:A,on_close:E}=a;return e.jsxs(Ya,{open:s,title:"Merge planned items into master backlog?",onClose:E,actions:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:E,disabled:y,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:A,disabled:y||r.length<2||!m.trim()||!l.trim(),children:y?"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:$=>c($.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:d,onChange:$=>p($.target.value),children:Ja.map($=>e.jsx("option",{value:$,children:$},$))})]})})]}),e.jsxs("div",{className:"field",style:{marginTop:"10px"},children:[e.jsx("label",{children:"Title"}),e.jsx("input",{value:m,onChange:$=>_($.target.value),placeholder:"Master backlog"})]}),e.jsxs("div",{className:"field",style:{marginTop:"10px"},children:[e.jsx("label",{children:"Summary (optional)"}),e.jsx("textarea",{value:x,onChange:$=>b($.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($=>e.jsxs("div",{children:["- docs/backlog/planned/",$.filename]},`mergeitem:${$.filename}`))})]}):null,C?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"10px"},children:C}):null]})}function xd(a){const s=()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(a).matches,[r,l]=f.useState(s);return f.useEffect(()=>{var p;if(typeof window>"u"||typeof window.matchMedia!="function")return;const c=window.matchMedia(a),d=()=>l(c.matches);return d(),typeof c.addEventListener=="function"?c.addEventListener("change",d):(p=c.addListener)==null||p.call(c,d),()=>{var m;typeof c.removeEventListener=="function"?c.removeEventListener("change",d):(m=c.removeListener)==null||m.call(c,d)}},[a]),r}function Wh(a,s){const[r,l]=f.useState(null);return f.useEffect(()=>{if(!s){l(null);return}let c=!1;return(async()=>{try{const d=await a.admin_executors(),p=Array.isArray(d)?d:Array.isArray(d==null?void 0:d.executors)?d.executors:[];c||l(p)}catch{c||l(null)}})(),()=>{c=!0}},[s]),r}function bd(a){const{gateway:s,can_use_gateway:r,kind:l,completed_view:c,is_exec_view:d,is_compact_layout:p,set_compact_pane:m,on_status_transfer:_}=a,[x,b]=f.useState(null),[y,C]=f.useState(!1),[A,E]=f.useState(""),[$,L]=f.useState([]),[q,O]=f.useState(!1),[D,K]=f.useState(""),[T,te]=f.useState(null),[ue,re]=f.useState(null),[Te,je]=f.useState(!1),[Ce,xe]=f.useState(""),[J,ne]=f.useState(""),[ve,W]=f.useState(!1),[Y,z]=f.useState(""),[V,U]=f.useState("events"),[w,N]=f.useState(""),[Z,pe]=f.useState(!1),[oe,I]=f.useState(""),[be,Re]=f.useState(!1),[qe,Oe]=f.useState(!0),ut=f.useRef(null),he=f.useRef(!0),Fe=f.useRef(null),Le=f.useRef(!1),Ge=f.useRef(!1),de=1e6,H=f.useMemo(()=>V!=="events"?null:cv(w),[w,V]),fe=f.useMemo(()=>uv(H),[H]),we=Fl(T);function X(){te(null),re(null),xe(""),N(""),I(""),Re(!1),Fe.current=null}async function Q(){if(!r)return null;if(y)return x;E(""),C(!0);try{const $e=await s.backlog_exec_config();return b($e),$e}catch($e){const ze=String(($e==null?void 0:$e.message)||$e||"Failed to load backlog exec config");return E(ze),b(null),null}finally{C(!1)}}async function _e($e,ze,ee){if(Ge.current)return $;Ge.current=!0,ee!=null&&ee.background||O(!0);const M=$e||l;try{const ie=lv(M,ze||c),Ke=await s.backlog_exec_requests({status:ie,limit:200}),et=Array.isArray(Ke==null?void 0:Ke.requests)?Ke.requests:[];K(""),L(et);const rt=String((T==null?void 0:T.status)||"").trim().toLowerCase(),mt=rt==="failed"||rt==="completed"||rt==="promoted";if(M==="processing"&&(T!=null&&T.request_id)&&!mt&&!et.some(ft=>ft.request_id===T.request_id))try{const ft=await s.backlog_exec_request(T.request_id),Ee=ft==null?void 0:ft.payload,nt=String((Ee==null?void 0:Ee.status)||"").trim().toLowerCase();(nt==="failed"||nt==="completed"||nt==="promoted")&&(_(nt),re(Ee),te($l(Ee,T.request_id)))}catch{}if(T!=null&&T.request_id){const ft=et.find(Ee=>Ee.request_id===T.request_id)||null;ft&&te(ft)}return et}catch(ie){return K(String((ie==null?void 0:ie.message)||ie||"Failed to load backlog exec requests")),[]}finally{Ge.current=!1,ee!=null&&ee.background||O(!1)}}async function Ie($e){if(r){te($e),p&&m("detail"),re(null),xe(""),je(!0),z(""),ne(""),N(""),I(""),Re(!1),Fe.current=null;try{const ze=await s.backlog_exec_request($e.request_id);re((ze==null?void 0:ze.payload)??null)}catch(ze){xe(String((ze==null?void 0:ze.message)||ze||"Failed to load request"))}finally{je(!1)}}}async function ot($e){if(!r)return;const ze=String((T==null?void 0:T.request_id)||"").trim();if(!ze||ve)return;const ee=String(J||"");if(!ee.trim()){z("Feedback is required.");return}z(""),W(!0);try{const M=await s.backlog_exec_feedback({request_id:ze,feedback:ee}),ie=(M==null?void 0:M.payload)??null;re(ie),ie&&te($l(ie,ze)),ne(""),await $e()}catch(M){z(String((M==null?void 0:M.message)||M||"Failed to send feedback"))}finally{W(!1)}}async function ce($e){if(!r)return;const ze=String((T==null?void 0:T.request_id)||"").trim();if(ze&&!ve){z(""),W(!0);try{const ee=await s.backlog_exec_promote({request_id:ze,redeploy:!0}),M=(ee==null?void 0:ee.payload)??null;re(M),M&&te($l(M,ze)),ne(""),await $e()}catch(ee){z(String((ee==null?void 0:ee.message)||ee||"Failed to promote to prod"));try{const M=await s.backlog_exec_request(ze),ie=(M==null?void 0:M.payload)??null;re(ie),ie&&te($l(ie,ze))}catch{}}finally{W(!1)}}}async function ke($e){if(!r)return;const ze=String((T==null?void 0:T.request_id)||"").trim();if(ze&&!ve){z(""),W(!0);try{const ee=await s.backlog_exec_deploy_uat({request_id:ze}),M=(ee==null?void 0:ee.payload)??null;re(M),M&&te($l(M,ze)),await $e()}catch(ee){z(String((ee==null?void 0:ee.message)||ee||"Failed to deploy to UAT"))}finally{W(!1)}}}async function Be($e){if(!r)return;const ze=String(($e==null?void 0:$e.request_id)||(T==null?void 0:T.request_id)||"").trim();if(!ze)return;const ee=($e==null?void 0:$e.name)||V,M=typeof($e==null?void 0:$e.max_bytes)=="number"&&Number.isFinite($e.max_bytes)?Number($e.max_bytes):16e4;if(!Le.current){Le.current=!0,I(""),pe(!0);try{const ie=`${ze}::${String(ee)}`,Ke=Fe.current,et=Ke!==null&&Ke.key===ie,rt=await s.backlog_exec_log_tail({request_id:ze,name:String(ee),max_bytes:M,...et?{after_bytes:Ke.offset}:{}}),mt=typeof(rt==null?void 0:rt.next_offset)=="number"&&Number.isFinite(rt.next_offset),ft=String((rt==null?void 0:rt.content)||"");et&&mt&&(rt==null?void 0:rt.reset)!==!0?(ft&&N(Ee=>{let nt=Ee+ft;if(nt.length>de){const ht=nt.length-de,zt=nt.indexOf(`
77
+ `,ht);nt=zt>=0?nt.slice(zt+1):nt.slice(ht),Re(!0)}return nt}),Fe.current={key:ie,offset:Number(rt.next_offset)}):(N(ft),Re(!!(rt!=null&&rt.truncated)),Fe.current=mt?{key:ie,offset:Number(rt.next_offset)}:null)}catch(ie){I(String((ie==null?void 0:ie.message)||ie||"Failed to load logs"))}finally{Le.current=!1,pe(!1)}}}return f.useEffect(()=>{r&&d&&Q()},[d,r]),f.useEffect(()=>{if(!r||!d)return;const ze=setInterval(()=>{s.is_backing_off()||_e(l,void 0,{background:!0})},l==="processing"?2e3:5e3);return()=>clearInterval(ze)},[l,c,r,d,T==null?void 0:T.request_id]),f.useEffect(()=>{r&&d&&T!=null&&T.request_id&&Be({request_id:T.request_id,name:V})},[T==null?void 0:T.request_id,V,d,r]),f.useEffect(()=>{he.current=!0},[T==null?void 0:T.request_id,V]),f.useEffect(()=>{if(!ut.current||!he.current)return;const ze=window.requestAnimationFrame(()=>{const ee=ut.current;ee&&(ee.scrollTop=ee.scrollHeight)});return()=>window.cancelAnimationFrame(ze)},[w,V,T==null?void 0:T.request_id]),f.useEffect(()=>{if(!r||!d||!(T!=null&&T.request_id))return;const $e=String(T.status||"").trim().toLowerCase();if($e==="completed"||$e==="promoted"||$e==="failed"||$e!=="running"&&qe!==!0)return;const ee=setInterval(()=>{s.is_backing_off()||Be({request_id:T.request_id,name:V})},$e==="running"?1500:2500);return()=>clearInterval(ee)},[T==null?void 0:T.request_id,T==null?void 0:T.status,V,d,r,qe]),{exec_cfg:x,exec_cfg_loading:y,exec_cfg_error:A,exec_requests:$,exec_loading:q,exec_error:D,exec_selected:T,set_exec_selected:te,exec_detail:ue,set_exec_detail:re,exec_detail_loading:Te,exec_detail_error:Ce,set_exec_detail_error:xe,exec_qa_feedback:J,set_exec_qa_feedback:ne,exec_qa_loading:ve,exec_qa_error:Y,exec_log_name:V,set_exec_log_name:U,exec_log_text:w,exec_log_loading:Z,exec_log_error:oe,exec_log_truncated:be,exec_log_auto:qe,set_exec_log_auto:Oe,exec_log_scroll_el_ref:ut,exec_log_follow_ref:he,parsed_exec_events:H,event_stats:fe,time_stats:we,clear_exec_selection:X,load_exec_config:Q,refresh_exec_list:_e,load_exec_request:Ie,exec_send_feedback:ot,exec_promote_to_prod:ce,exec_deploy_uat_now:ke,load_exec_log_tail:Be}}const Mf=[{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 Uv(a){var tn;const s=a.gateway,r=a.gateway_connected,l=String(a.maintenance_ai_provider||"").trim(),c=String(a.maintenance_ai_model||"").trim(),d=String(a.maintenance_ai_reasoning||"").trim(),p=String(a.backlog_advisor_agent||"").trim()||"basic-agent",m=a.default_execution_mode==="inplace"?"inplace":"uat",_=xd("(max-width: 767.98px)"),[x,b]=f.useState("planned"),[y,C]=f.useState([]),[A,E]=f.useState(!1),[$,L]=f.useState(""),[q,O]=f.useState(""),[D,K]=f.useState("all"),[T,te]=f.useState(""),[ue,re]=f.useState(new Set),Te=f.useRef(0),[je,Ce]=f.useState(null),[xe,J]=f.useState([]),[ne,ve]=f.useState(null),[W,Y]=f.useState(m),[z,V]=f.useState(!1),U=Wh(s,r),[w,N]=f.useState(""),[Z,pe]=f.useState(!1),[oe,I]=f.useState(m),[be,Re]=f.useState(!1),[qe,Oe]=f.useState(""),[ut,he]=f.useState(!1),[Fe,Le]=f.useState(!1),[Ge,de]=f.useState("framework"),[H,fe]=f.useState("task"),[we,X]=f.useState(""),[Q,_e]=f.useState(""),[Ie,ot]=f.useState(!1),[ce,ke]=f.useState(""),Be=bd({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 $e(){if(!r)return;const ge=++Te.current;E(!0),L("");try{const Se=await s.backlog_list(x);if(ge!==Te.current)return;C(Array.isArray(Se==null?void 0:Se.items)?Se.items:[])}catch(Se){if(ge!==Te.current)return;C([]),L(String((Se==null?void 0:Se.message)||Se||"Failed to load backlog"))}finally{ge===Te.current&&E(!1)}if(x==="planned")try{const Se=await s.backlog_exec_active_items();if(ge!==Te.current)return;const Ye=new Set;for(const vt of Array.isArray(Se==null?void 0:Se.items)?Se.items:[]){const _t=String((vt==null?void 0:vt.filename)||"").trim();_t&&Ye.add(_t)}re(Ye)}catch{ge===Te.current&&re(new Set)}else re(new Set)}f.useEffect(()=>{J([]),te(""),$e()},[x,r]),f.useEffect(()=>{J(ge=>{const Se=new Set(y.map(vt=>String(vt.filename||"").trim())),Ye=ge.filter(vt=>Se.has(vt));return Ye.length===ge.length?ge:Ye})},[y]);const ze=f.useMemo(()=>{const ge=q.trim().toLowerCase(),Se=D.trim().toLowerCase();return y.filter(Ye=>{if(Se&&Se!=="all"&&Dl(Ye.task_type)!==Se)return!1;if(!ge)return!0;const vt=Array.isArray(Ye.labels)?Ye.labels.join(" "):"";return`${Ye.item_id||""} ${Ye.package||""} ${Ye.title||""} ${Ye.task_type||""} ${Ye.summary||""} ${Ye.filename||""} ${vt} ${Ye.priority||""}`.toLowerCase().includes(ge)})},[y,q,D]),ee=f.useMemo(()=>y.filter(ge=>xe.includes(String(ge.filename||"").trim())),[y,xe]),M=ki($),[ie,Ke]=f.useState(0),et=vd(s,r&&M,ie);function rt(ge){Ce({filename:String(ge.filename||""),kind:x,title:ge.title||ge.filename,initial_tab:"spec"})}async function mt(ge,Se){te("");try{await s.backlog_move({from_kind:x,to_kind:Se,filename:String(ge.filename||"")}),await $e()}catch(Ye){te(String((Ye==null?void 0:Ye.message)||Ye||"Move failed"))}}async function ft(ge){const Se=String(ge.filename||"").trim();if(!Se)return;let Ye=null;try{const vt=await s.backlog_content("planned",Se);Ye=gd({task_type:ge.task_type},Ni(String((vt==null?void 0:vt.content)||"")))}catch{Ye=null}N(""),Y(m),ve({filename:Se,title:ge.title||Se,readiness:Ye}),Be.load_exec_config()}async function Ee(ge){if(!(!ne||z)){V(!0),N("");try{const Se=Be.exec_cfg||await Be.load_exec_config();if(!Se||Se.can_execute!==!0){N((Se==null?void 0:Se.runner_error)||"Backlog exec is not available on this gateway.");return}const Ye=!!(ne.readiness&&!ne.readiness.ok);await s.backlog_execute({kind:"planned",filename:ne.filename,execution_mode:W,executor:ge==null?void 0:ge.executor,target_model:ge==null?void 0:ge.target_model,target_reasoning_effort:ge==null?void 0:ge.target_reasoning_effort,dor:"check",override:Ye}),ve(null),await $e()}catch(Se){const Ye=ed(Se);Ye?(ve(vt=>vt&&{...vt,readiness:Ye,server_refused:!0}),N("")):N(String((Se==null?void 0:Se.message)||Se||"Execute failed"))}finally{V(!1)}}}async function nt(ge){if(!(be||ee.length<2)){Oe(""),Re(!0);try{const Se=Be.exec_cfg||await Be.load_exec_config();if(!Se||Se.can_execute!==!0){Oe((Se==null?void 0:Se.runner_error)||"Backlog exec is not available on this gateway.");return}await s.backlog_execute_batch({items:ee.map(Ye=>({kind:"planned",filename:String(Ye.filename||"")})),execution_mode:oe,executor:ge,dor:"check",override:ut}),pe(!1),J([]),he(!1),await $e()}catch(Se){const Ye=ed(Se);if(Ye){const vt=Ye.checks.filter(_t=>!_t.ok);he(!0),Oe(`Definition of Ready refused by the gateway:
78
+ ${vt.map(_t=>`○ ${_t.label}${_t.evidence?` — ${_t.evidence}`:""}`).join(`
79
+ `)}
80
+ Execute batch again to override (recorded as dor_overridden).`)}else Oe(String((Se==null?void 0:Se.message)||Se||"Execute batch failed"))}finally{Re(!1)}}}async function ht(){if(Ie||ee.length<2)return;const ge=we.trim();if(!ge){ke("Title is required.");return}ke(""),ot(!0);try{await s.backlog_merge({kind:"planned",items:ee.map(Se=>({kind:"planned",filename:String(Se.filename||"")})),package:Ge.trim()||"framework",task_type:H,title:ge,summary:Q.trim()||void 0}),Le(!1),J([]),await $e()}catch(Se){ke(String((Se==null?void 0:Se.message)||Se||"Merge failed"))}finally{ot(!1)}}function zt(ge){const Se=String(ge||"").trim();J(Ye=>Ye.includes(Se)?Ye.filter(vt=>vt!==Se):[...Ye,Se])}function wt(ge){if(x==="planned"){const Se=ue.has(String(ge.filename||"").trim());return e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:()=>void ft(ge),disabled:!r||Se,title:Se?"A live execution request already exists for this item":void 0,children:Se?"Processing…":"Execute"}),e.jsx("button",{className:"btn",title:"Move back to Triage (proposed)",onClick:()=>void mt(ge,"proposed"),disabled:!r,children:"→ Triage"}),e.jsx("button",{className:"btn",title:"Move to trash",onClick:()=>void mt(ge,"trash"),disabled:!r,children:"Trash"})]})}return x==="proposed"?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",title:"Promote to Ready (planned)",onClick:()=>void mt(ge,"planned"),disabled:!r,children:"→ Ready"}),e.jsx("button",{className:"btn",title:"Deprecate",onClick:()=>void mt(ge,"deprecated"),disabled:!r,children:"Deprecate"}),e.jsx("button",{className:"btn",title:"Move to trash",onClick:()=>void mt(ge,"trash"),disabled:!r,children:"Trash"})]}):x==="recurrent"?e.jsx("button",{className:"btn",title:"Move to trash",onClick:()=>void mt(ge,"trash"),disabled:!r,children:"Trash"}):x==="deprecated"||x==="trash"?e.jsx("button",{className:"btn",title:"Restore to Triage (proposed)",onClick:()=>void mt(ge,"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:Mf.map(ge=>e.jsx("button",{"aria-pressed":x===ge.id,className:`seg_btn ${x===ge.id?"active":""}`,onClick:()=>b(ge.id),children:ge.label},ge.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 ${A?"is_loading":""}`,onClick:()=>void $e(),disabled:!r||A,title:"Refresh","aria-label":"Refresh",children:[e.jsx(tt,{name:"refresh",size:16}),A?"Refreshing":"Refresh"]})]}),M?e.jsx(yd,{gateway:s,surface:"the backlog archive",status:et.status,legacy:et.legacy,error:$,on_changed:()=>{Ke(ge=>ge+1),$e()}}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"page_toolbar",children:[e.jsx("input",{className:"board_search",value:q,onChange:ge=>O(ge.target.value),placeholder:"Search backlog (id/title/package/filename…)"}),e.jsxs("select",{value:D,onChange:ge=>K(ge.target.value),title:"Filter by type",children:[e.jsx("option",{value:"all",children:"all types"}),Ja.map(ge=>e.jsx("option",{value:ge,children:ge},ge))]}),e.jsx("div",{className:"page_toolbar_spacer"}),x==="planned"&&xe.length?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"chip mono info",children:[xe.length," selected"]}),e.jsx("button",{className:"btn primary",disabled:xe.length<2,onClick:()=>{Oe(""),I(m),he(!1),pe(!0),Be.load_exec_config()},children:"Execute batch"}),e.jsx("button",{className:"btn",disabled:xe.length<2,onClick:()=>{const ge=ee.map(Se=>String(Se.package||"").trim()).filter(Boolean);de(ge.length&&ge.every(Se=>Se===ge[0])?ge[0]:"framework"),fe("task"),X(`Master backlog (${ee.length} items)`),_e(""),ke(""),Le(!0)},children:"Merge → master"})]}):null,e.jsxs("span",{className:"mono muted backlog_count",style:{fontSize:"var(--font-size-sm)"},children:[ze.length,"/",y.length]})]}),$&&!M?e.jsx("div",{className:"page_error mono",children:$}):null,T?e.jsx("div",{className:"page_error mono",children:T}):null,e.jsxs("div",{className:"pane backlog_table_pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:(tn=Mf.find(ge=>ge.id===x))==null?void 0:tn.label}),e.jsxs("span",{className:"pane_count",children:[ze.length," item",ze.length===1?"":"s"]})]}),e.jsx("div",{className:"pane_body",style:{padding:0},children:ze.length?e.jsxs("table",{className:"data_table backlog_table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[x==="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"}),x!=="completed"?e.jsx("th",{className:"backlog_table_actions col_actions",children:"actions"}):null]})}),e.jsx("tbody",{children:ze.map(ge=>{const Se=String(ge.filename||"").trim(),Ye=Dl(ge.task_type),vt=sd(ge)?nd(ge.priority):null,_t=Array.isArray(ge.labels)?ge.labels:[];return e.jsxs("tr",{className:"backlog_row",onClick:()=>rt(ge),children:[x==="planned"?e.jsx("td",{className:"backlog_table_sel col_sel",onClick:jt=>jt.stopPropagation(),children:e.jsx("label",{className:"backlog_sel_hit",children:e.jsx("input",{type:"checkbox",checked:xe.includes(Se),onChange:()=>zt(Se),"aria-label":`Select ${Se}`})})}):null,e.jsx("td",{className:"mono muted col_id",children:ge.item_id||""}),e.jsx("td",{className:"col_type",children:Ye?e.jsx("span",{className:`chip mono ${Th(Ye)}`,title:Ah(Ye),children:Ye}):null}),e.jsx("td",{className:"mono muted col_package",title:ge.package||"",children:ge.package||""}),e.jsx("td",{className:"backlog_table_title",title:Se,children:ge.title||Se}),e.jsx("td",{className:"col_priority",children:vt?e.jsx("span",{className:`chip mono board_prio_${vt.toLowerCase()}`,children:vt}):null}),e.jsxs("td",{className:"col_labels",title:_t.join(", "),children:[_t.slice(0,2).map(jt=>e.jsx("span",{className:"chip mono info",style:{marginRight:4},children:jt},jt)),_t.length>2?e.jsxs("span",{className:"chip mono muted",children:["+",_t.length-2]}):null]}),x!=="completed"?e.jsx("td",{className:"backlog_table_actions col_actions",onClick:jt=>jt.stopPropagation(),children:e.jsx("div",{className:"entity_card_actions",children:wt(ge)})}):null]},`${x}:${Se}`)})})]}):e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",padding:"12px"},children:A?"Loading…":"No items."})})]})]}),e.jsx(Uh,{open:!!ne,target:ne?{kind:"planned",filename:ne.filename,title:ne.title}:null,execute_mode:W,set_execute_mode:Y,action_loading:z,action_error:w,exec_cfg:Be.exec_cfg,exec_cfg_loading:Be.exec_cfg_loading,exec_cfg_error:Be.exec_cfg_error,executors:U,readiness:(ne==null?void 0:ne.readiness)??null,server_refused:(ne==null?void 0:ne.server_refused)===!0,show_readiness:!0,on_open_spec:ne?()=>{const ge=ne;ve(null),Ce({filename:ge.filename,kind:"planned",title:ge.title,initial_tab:"spec"})}:void 0,on_confirm:ge=>void Ee(ge),on_close:()=>ve(null)}),e.jsx(qv,{open:Z,batch_selected_items:ee,batch_execute_mode:oe,set_batch_execute_mode:I,batch_execute_loading:be,batch_execute_error:qe,executors:U,exec_cfg:Be.exec_cfg,exec_cfg_loading:Be.exec_cfg_loading,exec_cfg_error:Be.exec_cfg_error,on_confirm:ge=>void nt(ge),on_close:()=>{pe(!1),Oe(""),he(!1)}}),e.jsx(Bv,{open:Fe,batch_selected_items:ee,merge_package:Ge,set_merge_package:de,merge_task_type:H,set_merge_task_type:fe,merge_title:we,set_merge_title:X,merge_summary:Q,set_merge_summary:_e,merge_loading:Ie,merge_error:ce,on_confirm:()=>void ht(),on_close:()=>{Le(!1),ke("")}}),e.jsx(Dh,{gateway:s,can_use_gateway:r,target:je,on_close:()=>Ce(null),on_mutated:async()=>{await $e()},on_open_executions:ge=>{var Se;return(Se=a.on_open_executions)==null?void 0:Se.call(a,ge)}}),e.jsx(Iv,{gateway:s,can_use_gateway:r,is_compact_layout:_,maint_provider:l,maint_model:c,maint_reasoning:d,advisor_agent:p,focus_kind:x,focus_type:D,voice_session_id:a.voice_session_id})]})}function Wv(a){const{open:s,gateway:r,can_use_gateway:l,maint_provider:c,maint_model:d,maint_reasoning:p,on_close:m,on_created:_}=a,[x,b]=f.useState(""),[y,C]=f.useState(!1),[A,E]=f.useState(""),[$,L]=f.useState("proposed"),[q,O]=f.useState("feature"),[D,K]=f.useState("framework"),[T,te]=f.useState(""),[ue,re]=f.useState(""),[Te,je]=f.useState(""),[Ce,xe]=f.useState(""),[J,ne]=f.useState(""),[ve,W]=f.useState(""),[Y,z]=f.useState(!1),[V,U]=f.useState(""),[w,N]=f.useState(""),[Z,pe]=f.useState(""),[oe,I]=f.useState(""),[be,Re]=f.useState(""),[qe,Oe]=f.useState(""),[ut,he]=f.useState(""),[Fe,Le]=f.useState(""),[Ge,de]=f.useState(""),[H,fe]=f.useState(""),[we,X]=f.useState([]),[Q,_e]=f.useState(!1),[Ie,ot]=f.useState(""),[ce,ke]=f.useState([]),[Be,$e]=f.useState(""),[ze,ee]=f.useState(!1);function M(){L("proposed"),O("feature"),K("framework"),te(""),re(""),je(""),xe(""),ne(""),W(""),z(!1),U(""),N(""),pe(""),I(""),Re(""),Oe(""),he(""),Le(""),de(""),fe(""),X([]),_e(!1),ot(""),ke([]),$e(""),ee(!1)}function ie(){m(),M()}async function Ke(){const Ee=String(x||"").trim();if(Ee)return Ee;if(y)return"";E(""),C(!0);try{const nt=await r.backlog_template(),ht=String((nt==null?void 0:nt.content)||"");return b(ht),ht}catch(nt){return E(String((nt==null?void 0:nt.message)||nt||"Failed to load backlog template")),""}finally{C(!1)}}async function et(Ee){if(!l)return;const nt=(Ee==null?void 0:Ee.force)===!0;if(!nt&&J.trim())return;const ht=await Ke();if(!ht.trim())return;const zt=String(D||"").trim().toLowerCase()||"{Package}",wt=Xu(),tn=dv(ht,{package_name:zt,title:T,task_type:q,summary:ue,created_at:wt});ne(ge=>nt||!String(ge||"").trim()?tn:ge)}f.useEffect(()=>{s&&l&&et()},[s,l]);function rt(Ee){if(J.trim()&&!globalThis.confirm("Overwrite the current draft markdown with a guided draft?"))return;const nt=String(D||"").trim().toLowerCase()||"{Package}",ht=Xu(),zt=mv({package_name:nt,title:T,task_type:q,summary:ue,diagram:V,context:w,included:Va(Z),excluded:Va(oe),plan:Va(be),dependencies:Va(qe),acceptance:Va(ut),tests_a:Va(Fe),tests_b:Va(Ge),tests_c:Va(H),created_at:ht,attachments:[]});ne(zt)}async function mt(){var nt;if(Y)return;W(""),z(!0),ot("");let Ee="";try{const ht=String(D||"").trim().toLowerCase(),zt=_d(Ce),wt=!!(Te||zt.length);let tn=J||"";wt&&tn.trim()&&(tn=td(tn,{priority:Te||null,labels:zt}));const ge=await r.backlog_create({kind:$,package:ht,title:T,task_type:q,summary:ue||null,content:tn||null}),Se=String((ge==null?void 0:ge.kind)||"").trim(),Ye=String((ge==null?void 0:ge.filename)||"").trim();if(wt&&!tn.trim()&&Se&&Ye)try{const _t=await r.backlog_content(Se,Ye),jt=String((_t==null?void 0:_t.content)||""),it=await Zu(jt),Cn=td(jt,{priority:Te||null,labels:zt});await r.backlog_update({kind:Se,filename:Ye,content:Cn,expected_sha256:it||null})}catch(_t){Ee=[Ee,`metadata lines not written: ${String((_t==null?void 0:_t.message)||_t)}`].filter(Boolean).join("; ")}const vt=[...we||[]];if(Se&&Ye&&vt.length){_e(!0);const _t=[];try{for(const jt of vt){const it=await r.backlog_upload_attachment({kind:Se,filename:Ye,file:jt,overwrite:!1}),Cn=String(((nt=it==null?void 0:it.stored)==null?void 0:nt.relpath)||"").trim();Cn&&_t.push(Cn)}}catch(jt){Ee=[Ee,String((jt==null?void 0:jt.message)||jt||"Attachment upload failed")].filter(Boolean).join("; "),ot(Ee)}finally{if(_t.length)try{const jt=await r.backlog_content(Se,Ye),it=String((jt==null?void 0:jt.content)||""),Cn=await Zu(it),Cs=fv(it,_t);await r.backlog_update({kind:Se,filename:Ye,content:Cs,expected_sha256:Cn||null})}catch(jt){Ee=[Ee,`uploaded files not linked: ${String((jt==null?void 0:jt.message)||jt)}`].filter(Boolean).join("; ")}_e(!1)}}m(),M();try{await _(Se,Ye,Ee)}catch{}}catch(ht){W(String((ht==null?void 0:ht.message)||ht||"Create failed"))}finally{z(!1)}}async function ft(){if(ze)return;W("");const Ee=Be.trim();if(!Ee)return;if(!T.trim()){W("Title is required before using AI assist.");return}const nt=String(D||"").trim().toLowerCase();if(!nt){W("Package is required before using AI assist.");return}const ht={id:Mr(),role:"user",content:Ee,ts:new Date().toISOString()},zt=[...ce,ht];ke(zt),$e(""),ee(!0);try{const wt=await r.backlog_assist({kind:$,package:nt,title:T,summary:ue||null,draft_markdown:J||null,messages:zt.map(Se=>({role:Se.role,content:Se.content})),provider:c||null,model:d||null,thinking:p||null}),tn=String((wt==null?void 0:wt.reply)||"").trim(),ge=String((wt==null?void 0:wt.draft_markdown)||"").trim();tn&&ke(Se=>[...Se,{id:Mr(),role:"assistant",content:tn,ts:new Date().toISOString()}]),ge&&ne(ge)}catch(wt){W(String((wt==null?void 0:wt.message)||wt||"AI assist failed"))}finally{ee(!1)}}return e.jsxs(Ya,{open:s,title:"New backlog task",onClose:ie,actions:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:ie,disabled:Y||ze,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:()=>void mt(),disabled:Y||!T.trim()||!D.trim(),children:Y?"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:$,onChange:Ee=>L(Ee.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:q,onChange:Ee=>O(Ee.target.value),children:Ja.map(Ee=>e.jsx("option",{value:Ee,children:Ee},Ee))})]})}),e.jsx("div",{className:"col",style:{minWidth:220},children:e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Package"}),e.jsx("input",{value:D,onChange:Ee=>K(Ee.target.value),placeholder:"framework"})]})})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Title"}),e.jsx("input",{value:T,onChange:Ee=>te(Ee.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:Te,onChange:Ee=>je(Ee.target.value),children:[e.jsx("option",{value:"",children:"unset"}),ql.map(Ee=>e.jsx("option",{value:Ee,children:Mh[Ee]},Ee))]})]})}),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:Ce,onChange:Ee=>xe(Ee.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:ue,onChange:Ee=>re(Ee.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:V,onChange:Ee=>U(Ee.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:w,onChange:Ee=>N(Ee.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:Z,onChange:Ee=>pe(Ee.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:oe,onChange:Ee=>I(Ee.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:be,onChange:Ee=>Re(Ee.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:qe,onChange:Ee=>Oe(Ee.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:ut,onChange:Ee=>he(Ee.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:Fe,onChange:Ee=>Le(Ee.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:Ge,onChange:Ee=>de(Ee.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:H,onChange:Ee=>fe(Ee.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:()=>rt(),disabled:Y||ze,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:Ee=>{const nt=Array.from(Ee.target.files||[]);nt.length&&(X(ht=>[...ht,...nt]),Ee.currentTarget.value="")}})}),we.length?e.jsx("div",{className:"mono",style:{fontSize:"var(--font-size-sm)",marginTop:"6px"},children:we.map((Ee,nt)=>e.jsxs("div",{className:"row",style:{alignItems:"center",justifyContent:"space-between",marginTop:"4px"},children:[e.jsxs("span",{className:"mono muted",style:{paddingRight:"10px"},children:[Ee.name," (",Math.round(Ee.size/1024)," KB)"]}),e.jsx("button",{className:"btn",onClick:()=>X(ht=>ht.filter((zt,wt)=>wt!==nt)),disabled:Y||Q,children:"Remove"})]},`${Ee.name}_${Ee.size}_${nt}`))}):null,Q?e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:"Uploading attachments…"}):null,Ie?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:Ie}):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."}),y?e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:"Loading template…"}):null,A?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:A}):null,e.jsx("div",{className:"row",style:{marginTop:"10px",justifyContent:"flex-end",gap:"8px"},children:e.jsx("button",{className:"btn",onClick:()=>{J.trim()&&!globalThis.confirm("Reset the draft markdown to the backlog template?")||et({force:!0})},disabled:Y||ze||y||!l,children:"Reset from template"})}),e.jsx("div",{className:"field",children:e.jsx("textarea",{value:J,onChange:Ee=>ne(Ee.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(hd,{messages:ce,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(uc,{value:Be,onChange:$e,onSubmit:()=>void ft(),placeholder:"Message to AI (e.g. refine acceptance criteria…)",disabled:!l||!T.trim(),busy:ze,rows:3,sendButtonClassName:"btn primary"})}),ve?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:ve}):null]})}class Hh extends Wt.Component{constructor(){super(...arguments);Rr(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,d;try{(d=(c=this.props).onError)==null||d.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}}function Vh(a){return`abstractcontinuum_list_open_${a}`}function Gh(){try{return typeof localStorage>"u"?null:localStorage}catch{return null}}function id(a,s=Gh()){try{return(s==null?void 0:s.getItem(Vh(a)))!=="0"}catch{return!0}}function Kh(a,s,r=Gh()){try{r==null||r.setItem(Vh(a),s?"1":"0")}catch{}}function cc(a){const[s,r]=f.useState(()=>id(a)),l=f.useCallback(()=>{r(c=>{const d=!c;return Kh(a,d),d})},[a]);return[s,l]}function Hv(a){const[s,r]=f.useState({}),l=f.useCallback(d=>d in s?s[d]:id(`${a}_${d}`),[s,a]),c=f.useCallback(d=>{r(p=>{const m=!(d in p?p[d]:id(`${a}_${d}`));return Kh(`${a}_${d}`,m),{...p,[d]:m}})},[a]);return[l,c]}function Bl(a){return e.jsxs("button",{type:"button",className:"list_disclosure","aria-expanded":a.open,"aria-controls":a.controls,onClick:a.on_toggle,title:a.open?`Hide ${a.title.toLowerCase()}`:`Show ${a.title.toLowerCase()}`,children:[e.jsx(tt,{name:a.open?"chevronDown":"chevronRight",size:14}),e.jsx("span",{className:a.title_class||"pane_title",children:a.title}),a.count!==void 0?e.jsx("span",{className:a.count_class||"pane_count",children:a.count}):null]})}function Ul(a){var s,r;try{if(!a||typeof window>"u"||!((s=window.matchMedia)!=null&&s.call(window,"(max-width: 767.98px)").matches))return;(r=a.scrollIntoView)==null||r.call(a,{block:"start",behavior:"smooth"})}catch{}}class wd{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"}:{}}}),d=await c.text();let p=null;try{p=JSON.parse(d)}catch{}if(!c.ok){const m=p&&typeof p=="object"&&(p.detail||p.error)||d,_=new Error(`${s} failed: ${m}`);throw _.status=c.status,_}return p}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)}),d=await c.text();let p=null;try{p=JSON.parse(d)}catch{}if(!c.ok){const m=p&&typeof p=="object"&&(p.detail||p.error)||d,_=new Error(`upload failed: ${m}`);throw _.status=c.status,_}if(!p||typeof p!="object"||!p.id)throw new Error("upload returned no attachment id (unexpected hub response shape)");return p}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 d={value:l,note:c};return await this._fetch("hub_rate_message",`/channels/${encodeURIComponent(s)}/messages/${encodeURIComponent(r)}/rating`,{method:"PUT",body:JSON.stringify(d)})}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,d=""){return await this._fetch("hub_rate",`/channels/${encodeURIComponent(s)}/reputation/${encodeURIComponent(r)}`,{method:"PUT",body:JSON.stringify({axis:l,value:c,note:d})})}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(){const s=new URL("api/hub/ws",document.baseURI);return s.protocol=s.protocol==="https:"?"wss:":"ws:",s.href}}const Vv=["commons"],Gv=3e4,Kv=5*6e4,zf={live:new Map,done:[],work:new Map},Pf=new Set(["proposed","planned","completed","deprecated"]);function Qv(a,s){const r=s&&typeof s=="object"?String(s.item||""):"";if(r&&Hs(r))return r;const l=a.startsWith("claim:")?a.slice(6):"";return l&&Hs(l)?l:null}function Jv(a){const[s,r]=f.useState(zf),l=f.useRef(new wd),c=f.useRef(new Map),d=f.useRef(0),p=f.useRef(!1);return f.useEffect(()=>{let m=!0;const _=async()=>{if(!(p.current||Date.now()<d.current)){p.current=!0;try{const b=new Map,y=[],C=new Map;for(const A of Vv){let E=!1;try{const L=await l.current.work_rows(A);for(const q of L){const O=String(q.id||q.item||""),D=String(q.status||"").toLowerCase();!Hs(O)||!Pf.has(D)||C.set(O,{item:O,title:typeof q.title=="string"?q.title:void 0,status:D,owner:typeof q.owner=="string"?q.owner:void 0,receipt:typeof q.receipt=="string"?q.receipt:void 0,card:typeof q.card=="string"?q.card:void 0,updated_at:q.updated_at})}E=!0}catch{}const $=await l.current.store_keys(A);for(const L of $){const q=String(L.key||"");if(q.startsWith("work:")){if(E)continue;const re=q.slice(5);if(!Hs(re))continue;const Te=Number(L.version||0),je=`${A}\0${q}`,Ce=c.current.get(je);let xe;if(Ce&&Ce.version===Te)xe=Ce.value;else{const ne=await l.current.store_get(A,q);xe=ne==null?void 0:ne.value,c.current.set(je,{version:Te,value:xe})}const J=xe&&typeof xe=="object"?String(xe.status||"").toLowerCase():"";if(!Pf.has(J))continue;C.set(re,{item:re,title:typeof xe.title=="string"?xe.title:void 0,status:J,owner:typeof xe.owner=="string"?xe.owner:void 0,receipt:typeof xe.receipt=="string"?xe.receipt:void 0,card:typeof xe.card=="string"?xe.card:void 0,updated_at:L.updated_at});continue}if(!q.startsWith("claim:"))continue;const O=Number(L.version||0),D=`${A}\0${q}`,K=c.current.get(D);let T;if(K&&K.version===O)T=K.value;else{const re=await l.current.store_get(A,q);T=re==null?void 0:re.value,c.current.set(D,{version:O,value:T})}if(!T||typeof T!="object"||typeof T.owner!="string"||!T.owner)continue;const te=Qv(q,T)||q.slice(6);if(!te)continue;!!T.done||String(T.status||"").toLowerCase()==="done"?y.push({item:te,owner:T.owner,receipt:typeof T.receipt=="string"?T.receipt:void 0,updated_at:L.updated_at}):b.has(te)||b.set(te,T)}}y.sort((A,E)=>(E.updated_at||0)-(A.updated_at||0)),m&&r(A=>A.live.size===b.size&&[...b.keys()].every($=>JSON.stringify(A.live.get($))===JSON.stringify(b.get($)))&&JSON.stringify(A.done)===JSON.stringify(y)&&A.work.size===C.size&&[...C.keys()].every($=>JSON.stringify(A.work.get($))===JSON.stringify(C.get($)))?A:{live:b,done:y,work:C})}catch{d.current=Date.now()+Kv,m&&r(b=>b.live.size||b.done.length||b.work.size?zf:b)}finally{p.current=!1}}};_();const x=setInterval(()=>void _(),Gv);return()=>{m=!1,clearInterval(x)}},[a]),s}const Yv=40,Xv=4;function Zv(a){const{gateway:s,can_use_gateway:r,data_nonce:l}=a,[c,d]=f.useState([]),[p,m]=f.useState(!1),[_,x]=f.useState(""),[b,y]=f.useState(""),[C,A]=f.useState(null),[E,$]=f.useState(null),[L,q]=f.useState({}),O=f.useRef({}),D=f.useRef(!1),K=f.useCallback(async re=>{if(r&&!D.current){D.current=!0,re!=null&&re.background||m(!0);try{const[Te,je,Ce,xe,J]=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})]),ne=[],ve=[],W=(be,Re)=>be.status==="fulfilled"?be.value:(ne.push(Re),ve.push(be.reason),null),Y=W(Te,"proposed list"),z=W(je,"planned list"),V=W(Ce,"live requests"),U=W(xe,"recent history"),w=W(J,"busy set");if(A(ve.find(be=>ki(be))??null),!Y&&!z&&!V&&!U){x("Failed to load the board (all sources failed)");return}x("");const N=Array.isArray(V==null?void 0:V.requests)?V.requests:[];let Z=Array.isArray(w==null?void 0:w.items)?w.items:[];w||(Z=N.map(be=>({request_id:String(be.request_id||""),status:String(be.status||""),kind:"planned",filename:String(be.backlog_filename||"").trim(),relpath:String(be.backlog_relpath||"").trim()})).filter(be=>be.filename&&!/^batch\(\d+\)$/i.test(be.filename)));const pe=Array.isArray(Y==null?void 0:Y.items)?Y.items:[],oe=Array.isArray(z==null?void 0:z.items)?z.items:[];$(Y&&z?pe.length+oe.length:null);const I=Ev({proposed:pe,planned:oe,active_requests:N,terminal_requests:Array.isArray(U==null?void 0:U.requests)?U.requests:[],active_items:Z});d(I),y(ne.length?`#FALLBACK partial board — failed: ${ne.join(", ")}`:""),T(I,pe,oe)}finally{D.current=!1,re!=null&&re.background||m(!1)}}},[s,r]);async function T(re,Te,je){const Ce=new Map;for(const ve of Te)Ce.set(String(ve.filename||"").trim(),"proposed");for(const ve of je)Ce.set(String(ve.filename||"").trim(),"planned");const xe=re.filter(ve=>ve.filename&&!O.current[ve.filename]&&Ce.has(ve.filename)).filter(ve=>!Oh(ve)||ve.column==="ready").slice(0,Yv).map(ve=>({filename:ve.filename,kind:Ce.get(ve.filename)}));if(!xe.length)return;const J=[...xe],ne=Array.from({length:Math.min(Xv,J.length)},async()=>{for(;;){const ve=J.shift();if(!ve)return;try{const W=await s.backlog_content(ve.kind,ve.filename),Y=Ni(String((W==null?void 0:W.content)||""));O.current={...O.current,[ve.filename]:Y}}catch{}}});await Promise.all(ne),q(O.current)}const te=f.useCallback(async(re,Te)=>{try{const je=await s.backlog_content(re,Te),Ce=Ni(String((je==null?void 0:je.content)||""));O.current={...O.current,[Te]:Ce},q(O.current)}catch{}},[s]);return f.useEffect(()=>{K()},[K,l]),f.useEffect(()=>{if(!r)return;const re=setInterval(()=>{s.is_backing_off()||K({background:!0})},1e4);return()=>clearInterval(re)},[r,K,s]),{cards:c,loading:p,error:_,degraded:b,unconfigured:C!==null,unavailable:C,item_count:E,metadata:L,refresh:K,refresh_item_metadata:te}}function If(a,s){return a.length<=s?a:`${a.slice(0,s-1).trimEnd()}…`}const ey=new wd;function ty(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 ny(a){const{card:s}=a,r=s.work_id||"",l=!!(r&&Hs(r)),[c,d]=f.useState({loading:l,error:"",claims:[],decisions:[],messages:[]});f.useEffect(()=>{let _=!0;if(l)return d(x=>({...x,loading:!0,error:""})),ey.work(r).then(x=>{_&&d({loading:!1,error:"",claims:Array.isArray(x==null?void 0:x.claims)?x.claims:[],decisions:Array.isArray(x==null?void 0:x.decisions)?x.decisions:[],messages:(Array.isArray(x==null?void 0:x.messages)?x.messages:[]).slice().sort((b,y)=>(y.created_at||0)-(b.created_at||0))})}).catch(x=>{_&&d({loading:!1,error:String((x==null?void 0:x.message)||x||"activity unavailable"),claims:[],decisions:[],messages:[]})}),()=>{_=!1}},[r,l]);const p=c.messages[0],m=s.claim_started_at!==void 0&&s.claim_owner?Lh({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,m?e.jsxs("span",{className:"muted",children:[" · ",m.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," · ",ty(_.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:If(String(_.title),140)}):null,_.body?e.jsx("div",{className:"board_activity_msg_body muted",children:If(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(p?{channel:String(p.channel||"commons"),message_id:String(p.id||""),seq:Number(p.seq)}:{channel:"commons"}),title:p?"Open the most recent citing message in its channel":"Open the coordination channel",children:"Open discussion in Team"}):null})]})})}function sy(a){var ot;const{gateway:s,gateway_connected:r,data_nonce:l,on_mutated:c,on_open_executions:d}=a,p=a.default_execution_mode==="inplace"?"inplace":"uat",m=xd("(max-width: 767.98px)"),[_,x]=Hv("board_column"),b=Wh(s,r),y=Zv({gateway:s,can_use_gateway:r,data_nonce:l}),[C,A]=f.useState(0),E=vd(s,r,l+C),$=y.unconfigured||((ot=E.status)==null?void 0:ot.available)===!1,L=!$&&y.item_count===0&&!y.error,q=Jv(!0),O=f.useMemo(()=>Av(y.cards,q),[y.cards,q]),D=bd({gateway:s,can_use_gateway:r,kind:"planned",completed_view:"tasks",is_exec_view:!1,is_compact_layout:m,set_compact_pane:()=>{},on_status_transfer:()=>{}}),[K,T]=f.useState("");f.useEffect(()=>{var ke;if(!a.query_preset)return;const ce=Hs(a.query_preset);T(ce?ce.num.padStart(4,"0"):a.query_preset),(ke=a.on_query_preset_consumed)==null||ke.call(a)},[a.query_preset]);const[te,ue]=f.useState("all"),[re,Te]=f.useState("all"),[je,Ce]=f.useState(""),[xe,J]=f.useState(!1),[ne,ve]=f.useState(null),[W,Y]=f.useState(null),[z,V]=f.useState(null),[U,w]=f.useState("uat"),[N,Z]=f.useState(!1),[pe,oe]=f.useState(""),[I,be]=f.useState(""),[Re,qe]=f.useState(null),Oe=f.useRef(null),ut=O.some(ce=>ce.column==="in_progress"),[,he]=f.useState(0);f.useEffect(()=>{if(!ut)return;const ce=setInterval(()=>he(ke=>(ke+1)%3600),1e3);return()=>clearInterval(ce)},[ut]);const Fe=f.useMemo(()=>{const ce=new Set;for(const ke of O)ke.package&&ce.add(ke.package);return[...ce].sort()},[O]),Le=f.useMemo(()=>O.filter(ce=>ce.filename&&ce.kind).length,[O]),Ge=f.useMemo(()=>O.filter(ce=>ce.filename&&ce.kind&&(Oh(ce)||y.metadata[ce.filename])).length,[O,y.metadata]),de=f.useMemo(()=>{const ce=new Map;for(const ke of O)if(ke.filename)for(const Be of rd(ke,y.metadata[ke.filename]))ce.set(Be,(ce.get(Be)||0)+1);return[...ce.entries()].sort((ke,Be)=>Be[1]-ke[1]).slice(0,12)},[O,y.metadata]),H=f.useMemo(()=>{const ce=K.trim().toLowerCase();return O.filter(ke=>{if(te!=="all"&&(ke.package||"")!==te||re!=="all"&&String(ke.task_type||"").toLowerCase()!==re)return!1;const Be=ke.filename?y.metadata[ke.filename]:void 0,$e=rd(ke,Be);return je&&!$e.includes(je)||xe&&!$e.some(ee=>{const M=ee.toLowerCase();return M==="decision-gate"||M.startsWith("wave-")||M.startsWith("seat-")})?!1:ce?`${ke.item_id||""} ${ke.title} ${ke.filename||""} ${ke.package||""} ${ke.summary||""} ${ke.exec_status||""} ${$e.join(" ")} ${ad(ke,Be)||""}`.toLowerCase().includes(ce):!0})},[O,y.metadata,K,te,re,je,xe]),fe=f.useMemo(()=>{var Be;const ce=new Map;for(const $e of Af)ce.set($e.id,[]);for(const $e of H)(Be=ce.get($e.column))==null||Be.push($e);const ke=$e=>{const ze=$e.filename?ad($e,y.metadata[$e.filename]):null;return ze?ql.indexOf(ze):ql.length};for(const[$e,ze]of ce)($e==="triage"||$e==="ready")&&ze.sort((ee,M)=>ke(ee)-ke(M)||(M.item_id||0)-(ee.item_id||0));return ce},[H,y.metadata]);async function we(ce,ke){if(!(!ce.filename||!ce.kind||ce.kind==="completed")&&ce.kind!==ke){be("");try{await s.backlog_move({from_kind:ce.kind,to_kind:ke,filename:ce.filename}),await y.refresh(),c()}catch(Be){be(String((Be==null?void 0:Be.message)||Be||"Move failed"))}}}async function X(ce){if(!ce.filename)return;let ke=y.metadata[ce.filename];if(!ke)try{const $e=await s.backlog_content("planned",ce.filename);ke=Ni(String(($e==null?void 0:$e.content)||""))}catch{ke=void 0}const Be=ke?gd({task_type:ce.task_type},ke):null;oe(""),w(p),V({filename:ce.filename,title:ce.title,readiness:Be}),D.load_exec_config()}async function Q(ce){if(!(!z||N)){Z(!0),oe("");try{const ke=D.exec_cfg||await D.load_exec_config();if(!ke||ke.can_execute!==!0){oe((ke==null?void 0:ke.runner_error)||"Backlog exec is not available on this gateway.");return}const Be=!!(z.readiness&&!z.readiness.ok);await s.backlog_execute({kind:"planned",filename:z.filename,execution_mode:U,executor:ce==null?void 0:ce.executor,target_model:ce==null?void 0:ce.target_model,target_reasoning_effort:ce==null?void 0:ce.target_reasoning_effort,dor:"check",override:Be}),V(null),await y.refresh(),c()}catch(ke){const Be=ed(ke);Be?(V($e=>$e&&{...$e,readiness:Be,server_refused:!0}),oe("")):oe(String((ke==null?void 0:ke.message)||ke||"Execute failed"))}finally{Z(!1)}}}function _e(ce){if(!ce.filename&&!ce.request_id){const ke=yv(ce.card_path);if(ke&&r){s.backlog_content(ke.kind,ke.filename).then(()=>{ve({filename:ke.filename,kind:ke.kind,title:ce.title,work_id:ce.work_id,has_live_request:!1,initial_tab:"spec"})}).catch(()=>Y(ce));return}Y(ce);return}ve({filename:ce.filename||"",kind:ce.kind||null,request_id:ce.request_id,title:ce.title,work_id:ce.work_id,has_live_request:ce.column==="in_progress"||ce.column==="in_review",initial_tab:ce.column==="in_review"?"review":ce.column==="in_progress"?"runs":"spec"})}const Ie={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:K,onChange:ce=>T(ce.target.value),placeholder:"Search the board…"}),e.jsxs("select",{value:te,onChange:ce=>ue(ce.target.value),title:"Package",children:[e.jsx("option",{value:"all",children:"all packages"}),Fe.map(ce=>e.jsx("option",{value:ce,children:ce},ce))]}),e.jsxs("select",{value:re,onChange:ce=>Te(ce.target.value),title:"Type",children:[e.jsx("option",{value:"all",children:"all types"}),Ja.map(ce=>e.jsx("option",{value:ce,children:ce},ce))]}),e.jsx("button",{className:`chip mono board_facet ${xe?"active":"muted"}`,onClick:()=>J(ce=>!ce),"aria-pressed":xe,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&&!$?e.jsx("span",{className:"mono board_warn",title:y.degraded,children:"partial board"}):null,y.error&&!$?e.jsx("span",{className:"mono board_error",children:y.error}):null,I?e.jsx("span",{className:"mono board_error",children:I}):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"})]}),$?e.jsx(yd,{gateway:s,surface:"the board",status:E.status,legacy:E.legacy,error:y.unavailable,on_changed:()=>{A(ce=>ce+1),y.refresh()}}):null,L?e.jsx(Lv,{status:E.status,on_create:a.on_new_task}):null,!$&&(de.length||Le)?e.jsxs("div",{className:"board_facets",children:[e.jsx("span",{className:"mono muted board_facets_caption",children:"labels:"}),de.map(([ce,ke])=>e.jsxs("button",{className:`chip mono board_facet ${je===ce?"active":"info"}`,onClick:()=>Ce(Be=>Be===ce?"":ce),title:`${ke} scanned card(s) carry ${ce} — click to filter (sprints are labels: sprint-N)`,children:[ce," ",e.jsx("span",{className:"muted",children:ke})]},ce)),je?e.jsx("button",{className:"chip mono warn board_facet",onClick:()=>Ce(""),children:"clear ✕"}):null,Ge<Le?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 ",Ge,"/",Le]}):null]}):null,e.jsx("div",{className:"board_columns",style:$?{display:"none"}:void 0,children:Af.map(ce=>{const ke=fe.get(ce.id)||[],Be=Ie[ce.id],$e=_(ce.id);return e.jsxs("div",{className:`board_column board_column_${ce.id} ${Re===ce.id?"drag_over":""}${$e?"":" list_collapsed"}`,onDragOver:ze=>{!Be||!Oe.current||(ze.preventDefault(),qe(ce.id))},onDragLeave:()=>qe(ze=>ze===ce.id?null:ze),onDrop:ze=>{ze.preventDefault(),qe(null);const ee=Oe.current;Oe.current=null,ee&&Be&&we(ee,Be)},children:[e.jsx("div",{className:"board_column_header",title:ce.hint,children:e.jsx(Bl,{open:$e,on_toggle:()=>x(ce.id),controls:`board_column_body_${ce.id}`,title:ce.label,count:ke.length,title_class:"board_column_title",count_class:"board_column_count mono"})}),e.jsxs("div",{className:"board_column_body",id:`board_column_body_${ce.id}`,hidden:!$e,children:[ke.map(ze=>{const ee=Ih(ze,ze.filename?y.metadata[ze.filename]:void 0);return e.jsx(ay,{card:ze,metadata:ze.filename?y.metadata[ze.filename]:void 0,draggable:!ee&&!!(ze.kind&&ze.filename&&(ze.column==="triage"||ze.column==="ready")),on_drag_start:()=>{Oe.current=ze},on_drag_end:()=>{Oe.current=null,qe(null)},on_open:()=>_e(ze),on_promote:!ee&&ce.id==="triage"?()=>void we(ze,"planned"):void 0,on_demote:!ee&&ce.id==="ready"?()=>void we(ze,"proposed"):void 0,on_execute:!ee&&ce.id==="ready"?()=>void X(ze):void 0,on_follow:ze.exec_status==="running"||ze.exec_status==="queued"?()=>d(ze.request_id):void 0},ze.key)}),ke.length?null:e.jsx("div",{className:"board_column_empty mono muted",children:"—"})]})]},ce.id)})}),e.jsx(Uh,{open:!!z,target:z?{kind:"planned",filename:z.filename,title:z.title}:null,execute_mode:U,set_execute_mode:w,action_loading:N,action_error:pe,exec_cfg:D.exec_cfg,exec_cfg_loading:D.exec_cfg_loading,exec_cfg_error:D.exec_cfg_error,executors:b,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 ce=z;V(null),ve({filename:ce.filename,kind:"planned",title:ce.title,initial_tab:"spec"})}:void 0,on_confirm:ce=>void Q(ce),on_close:()=>V(null)}),e.jsx(Dh,{gateway:s,can_use_gateway:r,target:ne,on_close:()=>ve(null),on_mutated:async()=>{ne!=null&&ne.filename&&(ne.kind==="proposed"||ne.kind==="planned")&&await y.refresh_item_metadata(ne.kind,ne.filename),await y.refresh(),c()},on_open_executions:d}),W?e.jsx(ny,{card:W,on_close:()=>Y(null),on_open_team:a.on_open_team}):null]})}function ay(a){const{card:s,metadata:r,draggable:l,on_drag_start:c,on_drag_end:d,on_open:p,on_promote:m,on_demote:_,on_execute:x,on_follow:b}=a,y=ad(s,r),C=Ih(s,r),A=!C&&r?gd({task_type:s.task_type},r):null,E=Dl(s.task_type),$=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":""} ${C?"gate":""}`,onClick:p,role:"button",tabIndex:0,onKeyDown:L=>{(L.key==="Enter"||L.key===" ")&&(L.preventDefault(),p())},draggable:l,onDragStart:l?c:void 0,onDragEnd:l?d:void 0,children:[e.jsxs("div",{className:"board_card_title",children:[A?e.jsx("span",{className:`board_ready_dot ${A.ok?"ok":"warn"}`,title:A.ok?"Definition of Ready: satisfied":`Not ready: ${A.checks.filter(L=>!L.ok).map(L=>L.label).join("; ")}`}):null,e.jsx("span",{className:"board_card_title_text",children:s.title})]}),e.jsxs("div",{className:"board_card_chips",children:[C?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,E&&!C?e.jsx("span",{className:`chip mono ${Th(E)}`,title:Ah(E),children:E}):null,y?e.jsx("span",{className:`chip mono board_prio_${y.toLowerCase()}`,children:y}):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,rd(s,r).filter(L=>!C||L.toLowerCase()!=="decision-gate").slice(0,3).map(L=>e.jsx("span",{className:"chip mono info",children:L},L)),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,$!==null?e.jsx("span",{className:"chip mono info",children:Ws($)}):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 L=Lh({owner:s.claim_owner,started_at:s.claim_started_at},Date.now());return e.jsxs("span",{className:`chip mono ${L!=null&&L.stale?"warn":"info"}`,title:`Live hub claim${s.work_id?` (claim:${s.work_id})`:""}${L!=null&&L.stale?" — stale: claimed long ago with no receipt yet; open to re-claim on the record per the ruled process":""}`,children:["⛏ ",s.claim_owner,L?` · ${L.label.replace("claimed ","")}`:""]})})():null]}),m||_||x||b?e.jsxs("div",{className:"board_card_actions",onClick:L=>L.stopPropagation(),children:[m?e.jsx("button",{className:"btn",onClick:m,title:"Move to Ready (planned)",children:"→ Ready"}):null,x?e.jsx("button",{className:"btn primary",onClick:x,children:"Execute"}):null,_?e.jsx("button",{className:"btn",onClick:_,title:"Move back to Triage (proposed)",children:"→ Triage"}):null,b?e.jsx("button",{className:"btn",onClick:b,children:"Follow live"}):null]}):null]})}function Iu(a,s){const r=String(a||"").replace(/\r/g,"").trim();if(!r)return"";const c=(r.split(`
81
+ `,1)[0]||"").trim();return c.length<=s?c:`${c.slice(0,Math.max(0,s-1))}…`}function ry(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 Qh(a){const s=String(a||"").trim();if(!s)return"";const r=s.match(/^(?:\/bin\/)?(?:zsh|bash)\s+-lc\s+([\s\S]+)$/);return r?ry(String(r[1]||"").trim()):s}function iy(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 d=String(c.status||"").trim().toLowerCase();if(d==="failed")return"error";const p=c.exit_code,m=typeof p=="number"?p:Number.isFinite(Number(p))?Number(p):null;if(m!=null)return m===0?"ok":"error";if(d==="completed")return"ok"}return"info"}function ly(a,s){var x;const r=s&&typeof s=="object"?s:{},l=r.item&&typeof r.item=="object"?r.item:null,c=l?String(l.type||"").trim():"",d=l?String(l.text||"").trim():"",p=l?String(l.command||"").trim():"",m=l&&Array.isArray(l.items)?l.items:[],_=String((r==null?void 0:r.message)||((x=r==null?void 0:r.error)==null?void 0:x.message)||"").trim();if(c==="command_execution"&&p)return Qh(p)||p;if(c==="todo_list"&&m.length>0){const b=m.length,y=m.filter(q=>(q&&q.completed)===!0).length,C=m.find(q=>(q&&q.completed)!==!0),A=String((C==null?void 0:C.text)||"").trim(),E=b>1?` (+${b-1})`:"",$=b>0?` (${y}/${b})`:"",L=A?`todo: ${A}${E}`:`todo list (${b})`;return Iu(`${L}${$}`,96)}return d?Iu(d,96)||d:_?Iu(_,96)||_:c||String(a||"").trim()||"event"}function Of(a){const s=new Date(a),r=l=>String(l).padStart(2,"0");return`${r(s.getHours())}:${r(s.getMinutes())}`}function oy(a){var l,c,d;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,(d=s.item)==null?void 0:d.timestamp];for(const p of r)if(p!=null){if(typeof p=="number"&&Number.isFinite(p)){const m=p>1e11?p:p*1e3;return Of(m)}if(typeof p=="string"){const m=p.trim();if(!m)continue;const _=Date.parse(m.replace(/(\.\d{3})\d+/,"$1"));if(Number.isFinite(_))return Of(_)}}return null}function cy(a){var L;const{exec_selected:s,exec_detail:r,is_compact_layout:l,exec_log_name:c,set_exec_log_name:d,exec_log_text:p,exec_log_loading:m,exec_log_error:_,exec_log_truncated:x,exec_log_auto:b,set_exec_log_auto:y,exec_log_scroll_el_ref:C,exec_log_follow_ref:A,parsed_exec_events:E,load_exec_log_tail:$}=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:q=>d(q.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(Si,{variant:"sm",label:"Auto-refresh",action:"exec-log-auto",hint:"Follow the log as it grows.",checked:b,unavailableReason:s!=null&&s.request_id?null:"Pick an execution first.",reasonVisible:!1,onChange:q=>y(()=>q)}),e.jsxs("button",{className:`btn btn_icon ${m?"is_loading":""}`,onClick:()=>$(),disabled:m||!(s!=null&&s.request_id),"aria-label":"Refresh logs",title:"Refresh logs",children:[e.jsx(tt,{name:"refresh",size:16}),l?null:m?"Loading…":"Refresh"]})]})]}),_?e.jsx("div",{className:"detail_warn",children:_}):null,!_&&x?e.jsx("div",{className:"detail_hint",children:"#TRUNCATION: log tail truncated"}):null,c==="events"&&E?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"exec_log_scroll",ref:C,onScroll:q=>{A.current=Cf(q.currentTarget,12)},children:E.events.length===0?e.jsx("div",{className:"empty_note",children:"No events yet."}):E.events.map(q=>{var V;const O=q.payload,D=O&&typeof O.item=="object"?O.item:null,K=D?String(D.type||"").trim():"",T=D?String(D.id||"").trim():"",te=O?String(O.thread_id||"").trim():"",ue=iy(q.type,O),re=ue==="error"?"danger":ue==="ok"?"ok":"info",Te=oy(O),je=ly(q.type,O),Ce=String((O==null?void 0:O.message)||((V=O==null?void 0:O.error)==null?void 0:V.message)||"").trim(),xe=D?String(D.text||"").trim():"",J=D?String(D.command||"").trim():"",ne=D?String(D.status||"").trim():"",ve=D&&D.exit_code!=null?String(D.exit_code):"",W=D?String(D.aggregated_output||"").trim():"",Y=D&&Array.isArray(D.items)?D.items:[],z=J?Qh(J)||J:"";return e.jsxs("details",{className:`exec_event ${ue}`,children:[e.jsxs("summary",{className:"exec_event_summary",children:[Te?e.jsx("span",{className:"exec_event_when mono muted",children:Te}):null,Te?e.jsx("span",{className:"exec_event_sep mono muted",children:"|"}):null,e.jsx("span",{className:"exec_event_main mono",title:je,children:je}),e.jsx("span",{className:`chip mono ${re}`,children:K||q.type}),ve?e.jsxs("span",{className:"mono muted exec_event_right",children:["exit=",ve]}):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:q.type}),T?e.jsx("span",{className:"mono muted",style:{fontSize:"var(--font-size-xs)"},children:T}):null,te?e.jsxs("span",{className:"mono muted",style:{fontSize:"var(--font-size-xs)"},children:["thread ",ha(te,18)]}):null]}),Ce?e.jsx("pre",{className:"mono",style:{whiteSpace:"pre-wrap",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:Ce}):null,Y&&Y.length>0?e.jsx("div",{className:"mono",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:Y.map((U,w)=>e.jsxs("div",{children:[(U&&U.completed)===!0?"✓":"○"," ",String((U==null?void 0:U.text)||"").trim()]},`${q.idx}-todo-${w}`))}):null,J?e.jsxs("div",{style:{marginTop:"8px"},children:[e.jsxs("div",{className:"mono muted",style:{fontSize:"var(--font-size-xs)"},children:["command_execution ",ne?`(${ne})`:""," ",ve?`exit=${ve}`:""]}),e.jsx("pre",{className:"mono",style:{whiteSpace:"pre-wrap",fontSize:"var(--font-size-sm)",marginTop:"6px"},children:z})]}):null,W?e.jsxs("details",{style:{marginTop:"8px"},children:[e.jsxs("summary",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",cursor:"pointer"},children:["output (",W.length.toLocaleString()," chars)"]}),e.jsx("pre",{className:"mono",style:{whiteSpace:"pre-wrap",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:W})]}):null,xe?e.jsx("div",{style:{marginTop:"8px"},children:e.jsx(ls,{className:"md_doc",text:xe})}):null]})]},`${q.idx}-${T}-${q.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",E.bad?` (${E.bad} unparsable line(s))`:""]}),e.jsx("pre",{className:"mono exec_raw_log",children:E.raw||""})]})]}):e.jsx("div",{className:"exec_log_scroll",ref:C,onScroll:q=>{A.current=Cf(q.currentTarget,12)},children:e.jsx("pre",{className:"mono",style:{whiteSpace:"pre-wrap",fontSize:"var(--font-size-sm)"},children:(()=>{var O;if(String(p||"").trim())return p;if(c==="last_message"){const D=String(((O=r==null?void 0:r.result)==null?void 0:O.last_message)||s.last_message||"").trim();if(D)return D;const K=String(s.status||"").trim().toLowerCase();return K==="queued"||K==="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)"})()})}),(L=r==null?void 0:r.result)!=null&&L.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 uy(a){const{pipeline:s,is_compact_layout:r,on_back_to_list:l,on_send_feedback:c,on_promote:d,on_deploy_uat:p}=a,m=s.exec_selected;if(!m)return e.jsx("div",{className:"empty_note",children:"Select an exec request."});const{exec_detail:_,exec_detail_loading:x,exec_detail_error:b,exec_qa_feedback:y,set_exec_qa_feedback:C,exec_qa_loading:A,exec_qa_error:E,event_stats:$,time_stats:L,exec_log_name:q}=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:m.backlog_filename||m.backlog_relpath||m.request_id}),(()=>{const O=String(m.status||"").trim().toLowerCase();return e.jsx("span",{className:`chip mono ${Il(O)}`,children:O||"unknown"})})(),e.jsx("span",{className:"chip mono muted",children:ha(m.request_id,16)})]}),e.jsxs("div",{className:"inbox_detail_actions",children:[r?e.jsx("button",{className:"btn",onClick:l,disabled:x,children:"Back"}):null,e.jsxs("button",{className:"btn btn_icon",onClick:()=>fn(m.request_id),disabled:x,"aria-label":"Copy request id",title:"Copy request id",children:[e.jsx(tt,{name:"copy",size:16}),r?null:"Copy request id"]}),m.backlog_relpath?e.jsxs("button",{className:"btn btn_icon",onClick:()=>fn(m.backlog_relpath||""),disabled:x,"aria-label":"Copy backlog path",title:"Copy backlog path",children:[e.jsx(tt,{name:"copy",size:16}),r?null:"Copy backlog path"]}):null,(()=>{var K;const D=(Array.isArray((K=_==null?void 0:_.backlog_queue)==null?void 0:K.items)?_.backlog_queue.items:[]).map(T=>String((T==null?void 0:T.relpath)||"").trim()).filter(Boolean);return D.length?e.jsxs("button",{className:"btn btn_icon",onClick:()=>fn(D.join(`
82
+ `)),disabled:x,"aria-label":"Copy backlog paths",title:"Copy backlog paths",children:[e.jsx(tt,{name:"copy",size:16}),r?null:"Copy backlog paths"]}):null})(),m.run_dir_relpath?e.jsxs("button",{className:"btn btn_icon",onClick:()=>fn(m.run_dir_relpath||""),disabled:x,"aria-label":"Copy run dir",title:"Copy run dir",children:[e.jsx(tt,{name:"copy",size:16}),r?null:"Copy run dir"]}):null]})]}),e.jsxs("div",{className:"detail_hint",style:{marginTop:0},children:[m.created_at?`created ${new Date(m.created_at).toLocaleString()}`:"",m.started_at?` • started ${new Date(m.started_at).toLocaleString()}`:"",m.finished_at?` • finished ${new Date(m.finished_at).toLocaleString()}`:""]}),m.error?e.jsx("div",{className:"detail_warn",children:m.error}):null,b?e.jsx("div",{className:"detail_warn",children:b}):null,e.jsx("div",{style:{marginTop:"12px"},children:x?e.jsx("div",{className:"empty_note",children:"Loading…"}):e.jsxs(e.Fragment,{children:[e.jsx(dy,{exec_selected:m,exec_detail:_,exec_qa_feedback:y,set_exec_qa_feedback:C,exec_qa_loading:A,exec_qa_error:E,on_send_feedback:c,on_promote:d,on_deploy_uat:p}),e.jsx(my,{exec_selected:m,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:m.status||"unknown"})]}),m.executor_type?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"executor"}),e.jsx("span",{className:"fact_value",children:m.executor_type})]}):null,m.target_agent?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"target agent"}),e.jsx("span",{className:"fact_value",children:m.target_agent})]}):null,m.target_model?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"model"}),e.jsxs("span",{className:"fact_value",children:[m.target_model,m.target_reasoning_effort?` (reasoning ${m.target_reasoning_effort})`:""]})]}):null,m.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(m.exit_code)})]}):null,L.age_ms!=null?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"age"}),e.jsx("span",{className:"fact_value",children:Ws(L.age_ms)})]}):null,L.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:Ws(L.queue_delay_ms)})]}):null,L.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:Ws(L.run_ms)})]}):null,L.total_ms!=null&&L.is_done?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"total time"}),e.jsx("span",{className:"fact_value",children:Ws(L.total_ms)})]}):null,$?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"commands"}),e.jsxs("span",{className:"fact_value",children:[$.command_count.toLocaleString(),$.command_fail_count?` (${$.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:$!=null&&$.has_tokens?e.jsxs(e.Fragment,{children:["in ",$.input_tokens.toLocaleString(),$.cached_input_tokens?` (cached ${$.cached_input_tokens.toLocaleString()})`:"",", out ",$.output_tokens.toLocaleString(),", total ",$.total_tokens.toLocaleString()]}):e.jsx("span",{className:"muted",children:q==="events"?"n/a":'select "events"'})})]}),m.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:m.run_dir_relpath})]}):null]}),e.jsx(py,{exec_detail:_}),e.jsx(fy,{exec_detail:_,exec_qa_loading:A,status:String(m.status||"")}),e.jsx(hy,{exec_detail:_}),e.jsx(_y,{exec_selected:m,exec_detail:_}),e.jsx("div",{className:"section_divider"}),e.jsx(cy,{exec_selected:m,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:O=>s.set_exec_log_auto(O),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 dy(a){const{exec_selected:s,exec_detail:r,exec_qa_feedback:l,set_exec_qa_feedback:c,exec_qa_loading:d,exec_qa_error:p,on_send_feedback:m,on_promote:_,on_deploy_uat:x}=a;if(String(s.status||"").trim().toLowerCase()!=="awaiting_qa")return null;const y=String((r==null?void 0:r.execution_mode)||"").trim().toLowerCase()||"uat",C=String((r==null?void 0:r.candidate_relpath)||"").trim(),A=String((r==null?void 0:r.candidate_patch_relpath)||"").trim(),E=String((r==null?void 0:r.candidate_manifest_relpath)||"").trim(),$=String((r==null?void 0:r.uat_current_relpath)||"").trim(),L=String((r==null?void 0:r.uat_lock_owner_request_id)||"").trim(),q=!!(r!=null&&r.uat_lock_acquired),O=!!(r!=null&&r.uat_pending),D=(r==null?void 0:r.uat_deploy)??null,K=String((r==null?void 0:r.uat_deploy_error)||"").trim(),T=r==null?void 0:r.attempt,te=(r==null?void 0:r.promotion_report)??null,ue=!!(te!=null&&te.blocked),re=String((te==null?void 0:te.reason)||"").trim(),Te=Array.isArray(te==null?void 0:te.conflicts)?(te==null?void 0:te.conflicts).slice(0,8):[],je=typeof(te==null?void 0:te.conflicts_total)=="number"?Number(te.conflicts_total):Te.length;let Ce="",xe="";const J=[];try{const ne=D==null?void 0:D.processes;if(ne&&typeof ne=="object"&&!Array.isArray(ne)){typeof ne.status=="string"&&(Ce=String(ne.status||"").trim()),typeof ne.reason=="string"&&(xe=String(ne.reason||"").trim());for(const[ve,W]of Object.entries(ne)){if(!W||typeof W!="object"||Array.isArray(W))continue;const Y=W.probe;!Y||typeof Y!="object"||Y.ok===!1&&J.push(String(ve))}}}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:y})]}),typeof T=="number"?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"attempt"}),e.jsx("span",{className:"fact_value",children:T})]}):null,y==="uat"&&L?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"uat lock"}),e.jsxs("span",{className:"fact_value",children:[ha(L,18),q?" (owned)":O?" (pending)":""]})]}):null,C?e.jsxs("div",{className:"fact fact_wide",children:[e.jsx("span",{className:"fact_label",children:"candidate"}),e.jsx("span",{className:"fact_value mono",children:C})]}):null,E?e.jsxs("div",{className:"fact fact_wide",children:[e.jsx("span",{className:"fact_label",children:"manifest"}),e.jsx("span",{className:"fact_value mono",children:E})]}):null,A?e.jsxs("div",{className:"fact fact_wide",children:[e.jsx("span",{className:"fact_label",children:"patch"}),e.jsx("span",{className:"fact_value mono",children:A})]}):null,$?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:$})]}):null]}),y==="inplace"?e.jsx("div",{className:"detail_warn",children:"Inplace mode: prod may already be mutated. Approving only finalizes the request status."}):y==="uat"&&O&&L&&!q?e.jsxs("div",{className:"detail_warn",children:["UAT currently points to ",ha(L,16),". Click “Restart UAT” to switch the shared UAT stack to this request."]}):y==="uat"&&q?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."}),J.length?e.jsxs("div",{className:"detail_warn",children:["UAT may be unreachable: URL probe failed for ",J.slice(0,4).join(", "),J.length>4?"…":"",". Click “Restart UAT” and check process logs."]}):null]}):null,y==="uat"&&Ce==="skipped"&&xe==="process_manager_disabled"?e.jsxs("div",{className:"detail_warn",children:["UAT services were not started: the process manager is off. An admin turns it on in Settings → Gateway administration (or"," ",e.jsx("code",{children:"abstractgateway config set process_manager on"}),")."]}):null,K?e.jsxs("div",{className:"detail_warn",children:["UAT deploy failed: ",K]}):null,ue&&re==="conflicts"?e.jsxs("div",{className:"detail_warn",children:["Promotion blocked: prod diverged from the candidate base (",je," conflict",je===1?"":"s","). Use “Iterate” to re-run the request on top of current prod, or resolve conflicts manually.",Te.length?e.jsx("ul",{style:{marginTop:"8px",paddingLeft:"18px"},children:Te.map((ne,ve)=>e.jsxs("li",{children:[String((ne==null?void 0:ne.repo)||""),"/",String((ne==null?void 0:ne.path)||"")," (",String((ne==null?void 0:ne.reason)||"conflict"),")"]},`c:${ve}`))}):null]}):null,e.jsxs("div",{className:"row",style:{flexWrap:"wrap",gap:"6px",marginTop:"8px"},children:[A?e.jsxs("button",{className:"btn btn_icon",onClick:()=>fn(A),disabled:d,children:[e.jsx(tt,{name:"copy",size:16}),"Copy patch path"]}):null,E?e.jsxs("button",{className:"btn btn_icon",onClick:()=>fn(E),disabled:d,children:[e.jsx(tt,{name:"copy",size:16}),"Copy manifest path"]}):null,C?e.jsxs("button",{className:"btn btn_icon",onClick:()=>fn(C),disabled:d,children:[e.jsx(tt,{name:"copy",size:16}),"Copy candidate path"]}):null]}),e.jsx("div",{style:{marginTop:"10px"},children:e.jsx("textarea",{value:l,onChange:ne=>c(ne.target.value),rows:3,placeholder:"QA feedback (what to change / fix)…",style:{width:"100%",resize:"vertical",minHeight:"72px"},disabled:d})}),p?e.jsx("div",{className:"detail_warn",children:p}):null,e.jsxs("div",{className:"row",style:{flexWrap:"wrap",gap:"8px",marginTop:"10px"},children:[y==="uat"?e.jsx("button",{className:"btn",onClick:x,disabled:d,children:"Restart UAT"}):null,e.jsx("button",{className:"btn primary",onClick:_,disabled:d,children:y==="inplace"?"Approve (finalize)":"Approve → promote to prod"}),e.jsx("button",{className:"btn",onClick:m,disabled:d,children:"Iterate (send feedback)"})]}),e.jsx("div",{className:"section_divider"})]})}function my(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(),d=(r==null?void 0:r.promotion)??null,p=(r==null?void 0:r.promotion_report)??null,m=typeof(d==null?void 0:d.copied)=="number"?Number(d==null?void 0:d.copied):null,_=typeof(d==null?void 0:d.deleted)=="number"?Number(d==null?void 0:d.deleted):null,x=String((d==null?void 0:d.manifest_sha256)||"").trim(),b=String((d==null?void 0:d.mode)||"").trim(),y=(p==null?void 0:p.redeploy)??null,C=String((y==null?void 0:y.status)||"").trim(),A=String((y==null?void 0:y.reason)||"").trim(),E=String((p==null?void 0:p.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,b?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"mode"}),e.jsx("span",{className:"fact_value",children:b})]}):null,x?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"manifest sha256"}),e.jsxs("span",{className:"fact_value",children:[x.slice(0,16),"…"]})]}):null,m!=null?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"copied"}),e.jsxs("span",{className:"fact_value",children:[m," 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,C?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"redeploy"}),e.jsxs("span",{className:"fact_value",children:[C,A?` (${A})`:""]})]}):null,E?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:E})]}):null]}),e.jsx("div",{className:"section_divider"})]})}function fy(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,d=String((l==null?void 0:l.mode)||"").trim(),p=(l==null?void 0:l.copied)!=null?String(l.copied):"",m=(l==null?void 0:l.deleted)!=null?String(l.deleted):"",_=String((l==null?void 0:l.manifest_sha256)||"").trim(),x=c&&typeof c.redeploy=="object"?c.redeploy:null,b=x?String(x.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:[d?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"mode"}),e.jsx("span",{className:"fact_value",children:d})]}):null,p?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"copied"}),e.jsxs("span",{className:"fact_value",children:[p," files"]})]}):null,m?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"deleted"}),e.jsxs("span",{className:"fact_value",children:[m," 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:()=>fn(_),disabled:r,title:"Copy the full sha","aria-label":"Copy manifest sha256",children:e.jsx(tt,{name:"copy",size:12})})]}),e.jsxs("span",{className:"fact_value mono",children:[_.slice(0,16),"…"]})]}):null,b?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"redeploy"}),e.jsx("span",{className:"fact_value",children:b})]}):null]})]})}function hy(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(d=>String((d==null?void 0:d.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(d=>e.jsx("div",{children:d},`bq:${d}`))})]}):null}function py(a){var _,x,b;const s=((_=a.exec_detail)==null?void 0:_.skills)||((b=(x=a.exec_detail)==null?void 0:x.payload)==null?void 0:b.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:{},d=Array.isArray(s.verdicts)?s.verdicts:[];if(!r.length&&!l.length&&!d.length)return null;const p=new Set(l.map(y=>String(y))),m=d.filter(y=>{const C=String((y==null?void 0:y.status)||(y==null?void 0:y.state)||"").toLowerCase();return C&&C!=="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(y=>{const C=p.has(String(y)),A=c[String(y)];return e.jsxs("span",{className:`chip mono ${C?"ok":"warn"}`,title:C?A?`active · ${String(A).slice(0,12)}`:"active":"requested but not active — see verdict below",children:[y,C?"":" (held)"]},`skill:${y}`)})}),m.map((y,C)=>{const A=String((y==null?void 0:y.name)||(y==null?void 0:y.skill)||"skill"),E=String((y==null?void 0:y.reason)||(y==null?void 0:y.detail)||(y==null?void 0:y.status)||"held");return e.jsxs("div",{className:"detail_warn",children:[A,": ",E]},`verdict:${C}:${A}`)})]})}function _y(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(ls,{className:"md_doc",text:s})})]}):null}const gy=10;function vy(a){const{gateway:s,gateway_connected:r}=a,l=xd("(max-width: 767.98px)"),c=f.useRef(null),d=f.useRef(null),p=z=>{const V=z==="detail"?d:c;requestAnimationFrame(()=>Ul(V.current))},[m,_]=cc("exec_active"),[x,b]=cc("exec_recent"),[y,C]=f.useState(null);async function A(){try{const z=await s.admin_executors(),V=Array.isArray(z)?z:Array.isArray(z==null?void 0:z.executors)?z.executors:[];C(V)}catch{C(null)}}f.useEffect(()=>{if(!r){C(null);return}A()},[s,r]);const E=bd({gateway:s,can_use_gateway:r,kind:"processing",completed_view:"tasks",is_exec_view:!0,is_compact_layout:l,set_compact_pane:p,on_status_transfer:()=>{D()}}),[$,L]=f.useState([]),[q,O]=f.useState("");async function D(){if(r)try{const z=await s.backlog_exec_requests({status:"completed,promoted,failed",limit:50}),V=Array.isArray(z==null?void 0:z.requests)?z.requests:[];V.sort((U,w)=>{const N=String(U.finished_at||U.started_at||U.created_at||"");return String(w.finished_at||w.started_at||w.created_at||"").localeCompare(N)}),L(V.slice(0,gy)),O("")}catch(z){O(String((z==null?void 0:z.message)||z||"Failed to load recent executions"))}}f.useEffect(()=>{if(!r)return;(async()=>{var w;const V=await E.refresh_exec_list("processing");await D();const U=String(a.focus_request_id||"").trim();if(U){const N=V.find(Z=>Z.request_id===U);if(N)await E.load_exec_request(N);else try{const Z=await s.backlog_exec_request(U);Z!=null&&Z.payload&&await E.load_exec_request({request_id:U,status:String(Z.payload.status||"unknown")})}catch{}(w=a.on_focus_consumed)==null||w.call(a)}})();const z=setInterval(()=>{s.is_backing_off()||D()},15e3);return()=>clearInterval(z)},[r,a.focus_request_id]);const K=E.exec_requests.some(z=>String(z.status||"").toLowerCase()==="running"),[,T]=f.useState(0);f.useEffect(()=>{if(!K)return;const z=setInterval(()=>T(V=>(V+1)%3600),1e3);return()=>clearInterval(z)},[K]);const te=E.exec_requests,ue=f.useMemo(()=>{let z=0,V=0,U=0;for(const w of te){const N=String(w.status||"").trim().toLowerCase();N==="queued"?z+=1:N==="running"?V+=1:N==="awaiting_qa"&&(U+=1)}return{queued:z,running:V,awaiting:U}},[te]),re=E.exec_cfg,Te=!!(re!=null&&re.runner_alive),je=String((re==null?void 0:re.executor)||"").trim(),Ce=!je||je==="none",xe=Ce?"execution agent":je,J=!!(re!=null&&re.can_execute),ne=ki(E.exec_error)||ki(q),[ve,W]=f.useState(0),Y=vd(s,r&&ne,ve);return e.jsxs("div",{className:"page page_pad exec_page",children:[e.jsxs("div",{className:"page_toolbar",children:[r&&re?e.jsxs("span",{className:`chip mono ${J?"ok":"warn"}`,title:re.codex_model?`${xe}: ${re.codex_model}${re.codex_reasoning_effort?` (reasoning ${re.codex_reasoning_effort})`:""}`:void 0,children:[Ce?"no execution agent":`${xe} worker ${Te?"on":"off"}`,!l&&re.codex_model?` · ${re.codex_model}`:""]}):null,r?null:e.jsx("span",{className:"page_hint",children:"Not connected — use the connection control (top right)."}),!ne&&E.exec_error?e.jsx("span",{className:"page_error mono",children:E.exec_error}):null,e.jsx("div",{className:"page_toolbar_spacer"}),e.jsx("button",{className:`btn btn_icon ${E.exec_loading?"is_loading":""}`,onClick:()=>{E.refresh_exec_list("processing"),D(),E.load_exec_config(),A()},disabled:!r||E.exec_loading,title:"Refresh runs, worker config, and the executor registry","aria-label":"Refresh",children:e.jsx(tt,{name:"refresh",size:16})})]}),r&&re&&!J&&!ne?e.jsxs("div",{className:"callout callout_warn",children:[e.jsx("div",{className:"callout_icon","aria-hidden":"true",children:e.jsx(tt,{name:"warning",size:18})}),e.jsxs("div",{className:"callout_main",children:[e.jsxs("div",{className:"callout_title",children:[Ce?y!=null&&y.length?"No default executor selected":"No execution agent on this gateway":Te?"The pipeline cannot execute":"The exec worker is not running",e.jsx("span",{className:"chip mono warn",children:Ce?"setup required":Te?"cannot execute":"queued until it returns"})]}),e.jsx("p",{className:"callout_text",children:(()=>{if(!Ce)return re.runner_error?`The worker reports: ${re.runner_error} — new executions queue until it comes back.`:Te?"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(!(y!=null&&y.length))return"The gateway serves the pipeline but has no executor configured — nothing can run until one is enabled on the gateway host.";const z=y.map(w=>w.display||w.id),V=z.slice(0,4).join(", ")+(z.length>4?` +${z.length-4} more`:"");return y.some(w=>w.available!==!1)?`The gateway's registry serves ${y.length} executor${y.length===1?"":"s"} (${V}), but no default is selected — pick one in Settings → Gateway administration (gateway admin).`:`The gateway's registry serves ${y.length} executor${y.length===1?"":"s"} (${V}), but none is currently available — install an executor binary on the gateway host (PATH), then pick it in Settings.`})()}),(!(y!=null&&y.length)||!y.some(z=>z.available!==!1))&&(Ce||!Te)?e.jsx("pre",{className:"mono setup_callout_pre",children:`abstractgateway config set backlog_exec_runner on # enables the exec worker
83
+ abstractgateway config set executor codex # canonical ids: codex | claude | cursor-agent | abstractcode
84
+ # the agent program must be installed on the gateway's computer (on its PATH)`}):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.jsxs("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). On the gateway's computer the same settings are"," ",e.jsx("code",{children:"abstractgateway config set …"}),"."]})]})]}):null,ne?e.jsx(yd,{gateway:s,surface:"the execution pipeline",status:Y.status,legacy:Y.legacy,error:ki(E.exec_error)?E.exec_error:q,on_changed:()=>{W(z=>z+1),E.refresh_exec_list("processing")}}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"stat_strip",children:[e.jsxs("div",{className:`stat_card ${ue.running?"tone_info":""}`,children:[e.jsx("span",{className:"stat_value",children:ue.running}),e.jsx("span",{className:"stat_label",children:"running"})]}),e.jsxs("div",{className:`stat_card ${ue.awaiting?"tone_warn":""}`,children:[e.jsx("span",{className:"stat_value",children:ue.awaiting}),e.jsx("span",{className:"stat_label",children:"awaiting QA"})]}),e.jsxs("div",{className:"stat_card",children:[e.jsx("span",{className:"stat_value",children:ue.queued}),e.jsx("span",{className:"stat_label",children:"queued"})]}),e.jsxs("div",{className:`stat_card ${J?"tone_ok":"tone_danger"}`,children:[e.jsx("span",{className:"stat_value",children:J?"on":Ce?"none":"off"}),e.jsxs("span",{className:"stat_label",children:[xe,Ce?"":" worker"]})]})]}),e.jsxs("div",{className:"inbox_layout exec_layout",children:[e.jsxs("div",{className:"exec_side",ref:c,children:[e.jsxs("div",{className:`pane exec_pane_active${m?"":" list_collapsed"}`,children:[e.jsx("div",{className:"pane_header",children:e.jsx(Bl,{open:m,on_toggle:_,controls:"exec_active_list",title:"Active",count:te.length})}),e.jsx("div",{className:"pane_body pane_body_list",id:"exec_active_list",hidden:!m,children:te.length?te.map(z=>{var oe;const V=String(z.status||"").trim().toLowerCase(),U=Fl(z),w=((oe=E.exec_selected)==null?void 0:oe.request_id)===z.request_id,N=V==="running"&&z.started_at?Math.max(0,Date.now()-Date.parse(z.started_at)):null,Z=String(z.backlog_filename||z.backlog_relpath||"").trim(),pe=z.target_agent||(z.target_model?`${String(z.executor_type||"agent").trim()||"agent"}:${z.target_model}`:"");return e.jsxs("button",{className:`run_card ${w?"selected":""} ${V==="running"?"is_running":""}`,onClick:()=>void E.load_exec_request(z),children:[e.jsxs("div",{className:"run_card_head",children:[e.jsx("span",{className:"run_card_title",title:Z,children:Z||`request ${ha(z.request_id,12)}`}),e.jsx("span",{className:`chip mono ${Il(V)}`,children:V||"unknown"})]}),e.jsxs("div",{className:"run_card_meta",children:[e.jsx("span",{className:"run_card_time",children:N!==null?`running ${Ws(N)}`:U.queue_delay_ms!=null?`queued ${Ws(U.queue_delay_ms)}`:" "}),pe?e.jsx("span",{className:"chip mono muted",children:pe}):null,e.jsx("span",{className:"run_card_id mono",children:ha(z.request_id,14)})]})]},z.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${x?"":" list_collapsed"}`,children:[e.jsx("div",{className:"pane_header",children:e.jsx(Bl,{open:x,on_toggle:b,controls:"exec_recent_list",title:"Recently finished",count:$.length})}),e.jsxs("div",{className:"pane_body exec_recent_body",id:"exec_recent_list",hidden:!x,children:[q&&!ne?e.jsx("div",{className:"page_error mono",style:{padding:"10px 12px"},children:q}):null,!q&&!$.length?e.jsx("div",{className:"empty_note",style:{padding:"10px 12px"},children:"No finished executions yet."}):null,$.length?e.jsx("div",{className:"recent_list",children:$.map(z=>{var Z;const V=String(z.status||"").trim().toLowerCase(),U=Fl(z),w=((Z=E.exec_selected)==null?void 0:Z.request_id)===z.request_id,N=ha(z.backlog_filename||z.backlog_relpath||"request",44);return e.jsxs("button",{className:`recent_row ${w?"selected":""}`,onClick:()=>void E.load_exec_request(z),title:String(z.backlog_filename||z.backlog_relpath||z.request_id),children:[e.jsx("span",{className:`chip mono ${Il(V)}`,children:V||"?"}),e.jsx("span",{className:"recent_row_name",children:N}),e.jsx("span",{className:"recent_row_time mono",children:U.run_ms!=null?Ws(U.run_ms):""})]},`recent:${z.request_id}`)})}):null]})]})]}),e.jsxs("div",{className:"pane exec_detail_pane",ref:d,children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Run detail"}),E.exec_selected?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:`chip mono ${Il(String(E.exec_selected.status||"").toLowerCase())}`,children:String(E.exec_selected.status||"?").toLowerCase()}),e.jsx("span",{className:"pane_count mono",children:ha(E.exec_selected.request_id,20)})]}):e.jsx("span",{className:"pane_count",children:"select a run"})]}),e.jsx("div",{className:"pane_body",children:e.jsx(uy,{pipeline:E,is_compact_layout:l,on_back_to_list:()=>p("list"),on_send_feedback:()=>void E.exec_send_feedback(async()=>{await E.refresh_exec_list("processing")}),on_promote:()=>void E.exec_promote_to_prod(async()=>{await E.refresh_exec_list("processing"),await D()}),on_deploy_uat:()=>void E.exec_deploy_uat_now(async()=>{await E.refresh_exec_list("processing")})})})]})]})]})]})}function Ou(a,s){const r=String(a||"");return r.length<=s?r:`${r.slice(0,Math.max(0,s-1))}…`}function yy(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 Df(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),d=s(l);if(c!==d)return c-d;const p=String((r==null?void 0:r.label)||(r==null?void 0:r.id)||"").toLowerCase(),m=String((l==null?void 0:l.label)||(l==null?void 0:l.id)||"").toLowerCase();return p<m?-1:p>m?1:0})}function xy(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 by({gateway:a,gateway_connected:s}){const[r,l]=f.useState("prod"),[c,d]=f.useState(null),[p,m]=f.useState([]),[_,x]=f.useState(!1),[b,y]=f.useState(""),[C,A]=f.useState(!1),[E,$]=f.useState(null),[L,q]=f.useState([]),[O,D]=f.useState(!1),[K,T]=f.useState(""),[te,ue]=f.useState({}),[re,Te]=f.useState(!1),[je,Ce]=f.useState(null),[xe,J]=f.useState(""),[ne,ve]=f.useState(""),[W,Y]=f.useState(!1),[z,V]=f.useState("idle"),U=f.useRef(null),w=f.useMemo(()=>Df(p.filter(H=>!String((H==null?void 0:H.id)||"").trim().endsWith("_uat"))),[p]),N=f.useMemo(()=>Df(p.filter(H=>String((H==null?void 0:H.id)||"").trim().endsWith("_uat"))),[p]),Z=r==="uat"?N:w,pe=f.useCallback(async()=>{if(s){x(!0),y("");try{const H=await a.list_processes();d(!!(H!=null&&H.enabled));const fe=Array.isArray(H==null?void 0:H.processes)?H.processes:[];m(fe)}catch(H){y(String((H==null?void 0:H.message)||H||"Failed to list processes"))}finally{x(!1)}}},[a,s]),oe=f.useCallback(async()=>{if(s){D(!0),T("");try{const H=await a.list_process_env_vars();$(!!(H!=null&&H.enabled));const fe=Array.isArray(H==null?void 0:H.vars)?H.vars:[];q(fe);const we=String((H==null?void 0:H.error)||"").trim();we&&T(we)}catch(H){T(String((H==null?void 0:H.message)||H||"Failed to list env vars"))}finally{D(!1)}}},[a,s]),I=f.useCallback(async()=>{if(!s)return;const H=je;if(H){Y(!0);try{const fe=await a.process_log_tail(String(H.id||""),{max_bytes:16e4}),we=String((fe==null?void 0:fe.content)||""),X=typeof(fe==null?void 0:fe.bytes)=="number"?Number(fe.bytes):0,Q=!!(fe!=null&&fe.truncated),_e=String((fe==null?void 0:fe.log_relpath)||"");J(we),ve(`${X.toLocaleString()} bytes${Q?" (tail)":""}${_e?` • ${_e}`:""}`)}catch(fe){J(""),ve(String((fe==null?void 0:fe.message)||fe||"Failed to read logs"))}finally{Y(!1)}}},[a,s,je]),be=f.useCallback(async H=>{Ce(H),Te(!0)},[]),Re=f.useCallback(()=>{Te(!1),Ce(null),J(""),ve("")},[]);f.useEffect(()=>{s&&pe()},[s,pe]),f.useEffect(()=>{if(!s||r==="env"||!C)return;const H=window.setInterval(()=>{a.is_backing_off()||pe()},2e3);return()=>window.clearInterval(H)},[s,r,C,pe,a]),f.useEffect(()=>{s&&r==="env"&&oe()},[s,r,oe]),f.useEffect(()=>{if(s&&re)return I(),U.current&&window.clearInterval(U.current),U.current=window.setInterval(()=>{a.is_backing_off()||I()},1500),()=>{U.current&&window.clearInterval(U.current),U.current=null}},[s,re,I]);const qe=f.useRef(!1),[Oe,ut]=f.useState(!1);async function he(H,fe){if(!qe.current){qe.current=!0,ut(!0),y("");try{fe==="start"?await a.start_process(H.id):fe==="stop"?await a.stop_process(H.id):fe==="restart"?await a.restart_process(H.id):fe==="redeploy"&&await a.redeploy_process(H.id),await pe()}catch(we){y(String((we==null?void 0:we.message)||we||`Failed to ${fe}`))}finally{qe.current=!1,ut(!1)}}}async function Fe(H){const fe=String(H||"").trim();if(fe){T("");try{const we=String((te==null?void 0:te[fe])??""),X=await a.update_process_env_vars({set:{[fe]:we}});$(!!(X!=null&&X.enabled)),q(Array.isArray(X==null?void 0:X.vars)?X.vars:[]),ue(_e=>({..._e||{},[fe]:""}));const Q=String((X==null?void 0:X.error)||"").trim();Q&&T(Q)}catch(we){T(String((we==null?void 0:we.message)||we||"Failed to set env var"))}}}async function Le(H){const fe=String(H||"").trim();if(fe){T("");try{const we=await a.update_process_env_vars({unset:[fe]});$(!!(we!=null&&we.enabled)),q(Array.isArray(we==null?void 0:we.vars)?we.vars:[]),ue(Q=>({...Q||{},[fe]:""}));const X=String((we==null?void 0:we.error)||"").trim();X&&T(X)}catch(we){T(String((we==null?void 0:we.message)||we||"Failed to unset env var"))}}}const Ge=c===null?"…":c?"enabled":"disabled",de=E===null?"…":E?"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 ",Ge]}):null,s&&r==="env"?e.jsxs("span",{className:`chip mono ${E===!1?"warn":"muted"}`,children:["env ",de]}):null,e.jsx("div",{className:"page_toolbar_spacer"}),r!=="env"?e.jsxs(e.Fragment,{children:[e.jsx(Si,{variant:"sm",label:"Auto-refresh",action:"auto-refresh",hint:"Refresh this list every few seconds.",checked:C,onChange:H=>A(H)}),e.jsxs("button",{className:`btn btn_icon ${_?"is_loading":""}`,onClick:()=>void pe(),disabled:!s||_,children:[e.jsx(tt,{name:"refresh",size:16}),_?"Refreshing…":"Refresh"]})]}):e.jsxs("button",{className:`btn btn_icon ${O?"is_loading":""}`,onClick:()=>void oe(),disabled:!s||O,children:[e.jsx(tt,{name:"refresh",size:16}),O?"Refreshing…":"Refresh"]})]}),s&&r!=="env"&&c===!1?e.jsxs("div",{className:"page_hint mono",children:["The process manager is off on this gateway. An admin turns it on in Settings → Gateway administration (or"," ",e.jsx("span",{className:"mono",children:"abstractgateway config set process_manager on"}),"). Process control also needs the framework checkout it manages: set the backlog folder to it (Settings → Backlog folder)."]}):null,s&&r==="env"&&E===!1?e.jsxs("div",{className:"page_hint mono",children:["The process manager is off on this gateway. An admin turns it on in Settings → Gateway administration (or"," ",e.jsx("span",{className:"mono",children:"abstractgateway config set process_manager on"}),")."]}):null,r!=="env"&&b?e.jsx("div",{className:"page_error mono",children:b}):null,r==="env"&&K?e.jsx("div",{className:"page_error mono",children:K}):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:Z.length})]}),e.jsxs("div",{className:"pane_body pane_body_list",children:[Z.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."]}),Z.map(H=>{const fe=String(H.id||"").trim(),we=String(H.label||fe).trim()||fe,X=yy(String(H.status||"")),_e=String(H.status||"").trim().toLowerCase()==="running",Ie=Array.isArray(H==null?void 0:H.actions)?H.actions.map(mt=>String(mt||"").trim()):[],ot=Ie.includes("start"),ce=Ie.includes("stop"),ke=Ie.includes("restart"),Be=Ie.includes("redeploy"),$e=Ie.includes("logs"),ze=typeof(H==null?void 0:H.pid)=="number"?Number(H.pid):null,ee=String((H==null?void 0:H.url)||"").trim(),M=String((H==null?void 0:H.description)||"").trim(),ie=String((H==null?void 0:H.last_error)||"").trim(),Ke=typeof(H==null?void 0:H.exit_code)=="number"?Number(H.exit_code):null,et=[];ze&&et.push(`pid ${ze}`),Ke!==null&&et.push(`exit ${Ke}`);const rt=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:we}),e.jsx("span",{className:`chip mono ${X.cls}`,children:X.label}),e.jsx("span",{className:"chip mono muted",children:fe}),rt?e.jsx("span",{className:"entity_card_sub mono",children:rt}):null]}),M?e.jsx("div",{className:"entity_card_sub mono",children:Ou(M,220)}):null,ee?e.jsx("div",{className:"entity_card_sub mono",children:_e?e.jsx("a",{href:ee,target:"_blank",rel:"noreferrer",className:"mono",style:{opacity:.95},children:ee}):e.jsx("span",{className:"mono",children:ee})}):null,ie?e.jsx("div",{className:"page_error mono",children:Ou(ie,360)}):null,e.jsxs("div",{className:"entity_card_actions",children:[ot?e.jsx("button",{className:"btn primary",onClick:()=>void he(H,"start"),disabled:_||Oe,children:"Start"}):null,ce?e.jsx("button",{className:"btn danger",onClick:()=>void he(H,"stop"),disabled:_||Oe,children:"Stop"}):null,ke?e.jsx("button",{className:"btn",onClick:()=>void he(H,"restart"),disabled:_||Oe,children:"Restart"}):null,Be?e.jsx("button",{className:"btn",onClick:()=>void he(H,"redeploy"),disabled:_||Oe,children:"Redeploy"}):null,$e?e.jsx("button",{className:"btn",onClick:()=>void be(H),disabled:_,children:"Logs"}):null]})]},fe)})]})]}):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:L.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:[L.map(H=>{const fe=String((H==null?void 0:H.key)||"").trim();if(!fe)return null;const we=String((H==null?void 0:H.label)||fe).trim()||fe,X=String((H==null?void 0:H.description)||"").trim(),Q=String((H==null?void 0:H.source)||"").trim(),_e=!!(H!=null&&H.secret),Ie=String((H==null?void 0:H.updated_at)||"").trim(),ot=xy(Q),ce=String((te==null?void 0:te[fe])??"");return e.jsxs("div",{className:"entity_card",children:[e.jsxs("div",{className:"entity_card_head",children:[e.jsx("span",{className:"entity_card_title",children:we}),e.jsx("span",{className:`chip mono ${ot.cls}`,children:ot.label}),e.jsx("span",{className:"chip mono muted",children:fe})]}),X?e.jsx("div",{className:"entity_card_sub mono",children:Ou(X,280)}):null,Ie?e.jsxs("div",{className:"entity_card_sub mono",children:["updated ",Ie]}):null,e.jsxs("div",{className:"entity_card_actions",children:[e.jsx("input",{className:"input",value:ce,onChange:ke=>ue(Be=>({...Be||{},[fe]:String(ke.target.value||"")})),placeholder:_e?"••••••••":"value",type:_e?"password":"text",style:{flex:"1 1 320px",minWidth:"220px"},autoComplete:"off",spellCheck:!1}),e.jsx("button",{className:"btn primary",onClick:()=>void Fe(fe),disabled:O,children:"Set"}),e.jsx("button",{className:"btn",onClick:()=>void Le(fe),disabled:O,children:"Unset"})]})]},`env:${fe}`)}),L.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,re&&je?e.jsxs(Ya,{open:re,title:`${String(je.label||je.id||"logs").trim()||"Logs"}`,onClose:Re,children:[e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:ne}),e.jsxs("div",{className:"actions",style:{marginTop:"10px"},children:[e.jsxs("button",{className:`btn btn_icon ${W?"is_loading":""}`,onClick:()=>void I(),disabled:W,children:[e.jsx(tt,{name:"refresh",size:16}),W?"Refreshing…":"Refresh"]}),e.jsxs("button",{className:"btn btn_icon",onClick:()=>{tv(xe||"").then(H=>{V(H?"copied":"failed"),window.setTimeout(()=>V("idle"),2e3)})},disabled:!xe,children:[e.jsx(tt,{name:"copy",size:16}),z==="copied"?"Copied":z==="failed"?Zg:"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:xe||"(no logs yet)"})]}):null]})})}function Ff(a){const s=String(a||"").trim();if(!s)return"";const r=Date.parse(s);return Number.isFinite(r)?new Date(r).toLocaleString():s}function El(a,s){const r=String(a||"");return r.length<=s?r:`${r.slice(0,Math.max(0,s-1))}…`}function Du(a){const s=String(a||"").split(/[,\n]/g).map(r=>r.trim()).filter(Boolean);return s.length<=1?s[0]||"":s}function wy(a){const s=a.gateway,[r,l]=cc("inbox_email"),c=f.useRef(null),d=f.useRef(null),[p,m]=f.useState([]),[_,x]=f.useState(""),[b,y]=f.useState(""),[C,A]=f.useState(""),[E,$]=f.useState("7d"),[L,q]=f.useState("unread"),[O,D]=f.useState(25),[K,T]=f.useState(!1),[te,ue]=f.useState(!1),[re,Te]=f.useState(!1),[je,Ce]=f.useState(!1),[xe,J]=f.useState(""),[ne,ve]=f.useState(""),[W,Y]=f.useState(""),[z,V]=f.useState([]),[U,w]=f.useState(""),[N,Z]=f.useState(null),[pe,oe]=f.useState(!1),[I,be]=f.useState(""),[Re,qe]=f.useState(""),[Oe,ut]=f.useState(""),[he,Fe]=f.useState(""),[Le,Ge]=f.useState(""),de=a.enabled,H=f.useMemo(()=>(Array.isArray(p)?p:[]).map(ie=>({account:String((ie==null?void 0:ie.account)||"").trim(),can_read:(ie==null?void 0:ie.can_read)!==!1,can_send:(ie==null?void 0:ie.can_send)!==!1,label:""})).filter(ie=>!!ie.account),[p]),fe=f.useMemo(()=>{const M=String(b||"").trim();return M&&H.find(ie=>ie.account===M)||null},[H,b]),we=!!(fe!=null&&fe.can_read),X=!!(fe!=null&&fe.can_send),Q=f.useMemo(()=>H.map(M=>{const ie=M.can_read?M.can_send?"":" (read-only)":" (send-only)";return{...M,label:`${M.account}${ie}`}}),[H]);async function _e(){if(de){J(""),T(!0);try{const M=await s.email_list_accounts();m(Array.isArray(M==null?void 0:M.accounts)?M.accounts:[]),x(String((M==null?void 0:M.default_account)||"").trim())}catch(M){J(String((M==null?void 0:M.message)||M||"Failed to list email accounts")),m([]),x("")}finally{T(!1)}}}f.useEffect(()=>{_e()},[de]),f.useEffect(()=>{if(!de)return;const M=String(b||"").trim();if(M&&H.some(Ke=>Ke.account===M))return;const ie=String(localStorage.getItem("abstractcontinuum_email_account")||"").trim();if(ie&&H.some(Ke=>Ke.account===ie)){y(ie);return}if(_&&H.some(Ke=>Ke.account===_)){y(_);return}H.length&&y(H[0].account)},[de,b,_,H]),f.useEffect(()=>{const M=String(b||"").trim();M&&localStorage.setItem("abstractcontinuum_email_account",M)},[b]);async function Ie(){if(!de)return;const M=String(b||"").trim();if(M){if(!we){J("Selected account is not allowed to read email."),V([]),w(""),Z(null);return}J(""),ue(!0);try{const ie=await s.email_list_messages({account:M,mailbox:String(C||"").trim()||void 0,since:String(E||"").trim()||void 0,status:L,limit:O}),Ke=Array.isArray(ie==null?void 0:ie.messages)?ie.messages:[];V(Ke);const et=String(U||"").trim();et&&!Ke.some(rt=>String((rt==null?void 0:rt.uid)||"").trim()===et)&&(w(""),Z(null))}catch(ie){J(String((ie==null?void 0:ie.message)||ie||"Failed to list emails")),V([]),w(""),Z(null)}finally{ue(!1)}}}f.useEffect(()=>{de&&String(b||"").trim()&&Ie()},[de,b]);async function ot(M){if(!de)return;const ie=String(b||"").trim(),Ke=String(M||"").trim();if(!(!ie||!Ke)&&we){w(Ke),Z(null),ve(""),Te(!0);try{const et=await s.email_read_message(Ke,{account:ie,mailbox:String(C||"").trim()||void 0,max_body_chars:2e4});Z(et)}catch(et){ve(String((et==null?void 0:et.message)||et||"Failed to read email"))}finally{Te(!1)}}}function ce(M){Y(""),be(String((M==null?void 0:M.to)||"").trim()),qe(""),ut(""),Fe(String((M==null?void 0:M.subject)||"").trim()),Ge(String((M==null?void 0:M.body)||"")),oe(!0)}function ke(){if(!N)return;const M=String((N==null?void 0:N.from)||"").trim(),ie=String((N==null?void 0:N.subject)||"").trim(),Ke=ie.toLowerCase().startsWith("re:")?ie:`Re: ${ie||"(no subject)"}`,et=String((N==null?void 0:N.body_text)||"").trim(),rt=`
85
+
86
+ ---
87
+ On ${Ff((N==null?void 0:N.date)||"")}, ${M} wrote:
88
+
89
+ ${et}`;ce({to:M,subject:Ke,body:rt})}async function Be(){if(!de||je)return;const M=String(b||"").trim();if(M){if(!X){Y("Selected account is not allowed to send email.");return}Y(""),Ce(!0);try{const ie=Du(I);if(!ie)throw new Error("to is required");const Ke=String(he||"").trim();if(!Ke)throw new Error("subject is required");const et=String(Le||"").trim();if(!et)throw new Error("body is required");await s.email_send({account:M,to:ie,subject:Ke,body_text:et,cc:Du(Re),bcc:Du(Oe)}),oe(!1),be(""),qe(""),ut(""),Fe(""),Ge(""),await Ie()}catch(ie){Y(String((ie==null?void 0:ie.message)||ie||"Failed to send email"))}finally{Ce(!1)}}}const $e=f.useMemo(()=>{const M=String(U||"").trim();return M&&z.find(ie=>String((ie==null?void 0:ie.uid)||"").trim()===M)||null},[z,U]),ze=String((N==null?void 0:N.body_text)||"").trim()||String((N==null?void 0:N.body_html)||"").trim(),ee=String((N==null?void 0:N.body_text)||"").trim()?"Body (text)":String((N==null?void 0:N.body_html)||"").trim()?"Body (html, raw)":"Body";return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`inbox_layout exec_layout${r?"":" list_collapsed"}`,children:[e.jsxs("div",{className:`pane inbox_list_pane${r?"":" list_collapsed"}`,ref:c,onClickCapture:M=>{var ie,Ke;(Ke=(ie=M.target)==null?void 0:ie.closest)!=null&&Ke.call(ie,".inbox_item")&&requestAnimationFrame(()=>Ul(d.current))},children:[e.jsx("div",{className:"pane_header",children:e.jsx(Bl,{open:r,on_toggle:l,controls:"inbox_email_list",title:"Email",count:z.length})}),e.jsxs("div",{className:"pane_body email_list_body",id:"inbox_email_list",hidden:!r,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:b,onChange:M=>y(String(M.target.value||"")),disabled:!de||K,children:Q.length?Q.map(M=>e.jsx("option",{value:M.account,children:M.label},M.account)):e.jsx("option",{value:"",children:"(no accounts)"})}),e.jsx("button",{className:"btn",onClick:()=>void _e(),disabled:!de||K,children:K?"Loading…":"Accounts"})]}),e.jsxs("div",{className:"row",style:{gap:"8px",justifyContent:"flex-end"},children:[e.jsx("button",{className:"btn",onClick:()=>void Ie(),disabled:!de||te||!String(b||"").trim()||!we,children:te?"Refreshing…":"Refresh"}),e.jsx("button",{className:"btn primary",onClick:()=>ce(),disabled:!de||!String(b||"").trim()||!X,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:E,onChange:M=>$(String(M.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:L,onChange:M=>q(String(M.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(O),onChange:M=>D(Number(M.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:C,onChange:M=>A(String(M.target.value||"")),placeholder:"INBOX"})]}),e.jsx("div",{className:"row",style:{gap:"8px",alignItems:"center",marginTop:"18px"},children:e.jsx("button",{className:"btn",onClick:()=>void Ie(),disabled:!de||te||!String(b||"").trim()||!we,children:"Apply"})})]}),xe?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)"},children:xe}):null,e.jsx("div",{className:"inbox_list",children:z.length?z.map((M,ie)=>{const Ke=String((M==null?void 0:M.uid)||"").trim(),et=!!Ke&&Ke===String(U||"").trim(),rt=String((M==null?void 0:M.subject)||"").trim()||"(no subject)",mt=String((M==null?void 0:M.from)||"").trim(),ft=String((M==null?void 0:M.date)||"").trim(),Ee=!!(M!=null&&M.seen);return e.jsxs("button",{className:`inbox_item ${et?"active":""}`,onClick:()=>void ot(Ke),children:[e.jsxs("div",{className:"inbox_item_title",children:[e.jsx("span",{className:`pill ${Ee?"approved":"pending"}`,children:Ee?"read":"unread"}),e.jsx("span",{className:"item_title_text",children:El(rt,52)})]}),e.jsx("div",{className:"inbox_item_meta mono muted",children:El(mt,60)||"(from?)"}),e.jsxs("div",{className:"inbox_item_meta mono muted",children:[El(ft,36)||"(date?)"," • uid ",El(Ke,10)]})]},Ke||`idx:${ie}`)}):e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"No messages."})})]})]}),e.jsx("div",{className:"pane inbox_detail_pane",ref:d,children:e.jsxs("div",{className:"pane_body",children:[e.jsx("div",{className:"pane_back_bar",children:e.jsx("button",{type:"button",className:"btn pane_back_btn",onClick:()=>Ul(c.current),children:"← Back to the list"})}),U?re?e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Loading email…"}):ne?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)"},children:ne}):N?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((N==null?void 0:N.subject)||"").trim()||"(no subject)"}),e.jsx("span",{className:"pill muted",children:String((N==null?void 0:N.account)||"").trim()||b}),e.jsx("span",{className:"pill muted",children:String((N==null?void 0:N.mailbox)||"").trim()||"(mailbox?)"}),e.jsxs("span",{className:"pill muted",children:["uid ",El(String((N==null?void 0:N.uid)||U),12)]})]}),e.jsxs("div",{className:"row",style:{gap:"8px",justifyContent:"flex-end"},children:[e.jsx("button",{className:"btn",onClick:()=>fn(String((N==null?void 0:N.message_id)||"")),disabled:!String((N==null?void 0:N.message_id)||"").trim(),title:"Copy Message-ID",children:"Copy msg-id"}),e.jsx("button",{className:"btn",onClick:()=>fn(String(U||"")),disabled:!String(U||"").trim(),title:"Copy UID",children:"Copy uid"}),e.jsx("button",{className:"btn primary",onClick:()=>ke(),disabled:!X||!String((N==null?void 0:N.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((N==null?void 0:N.from)||"").trim()||"(from?)"})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"To"}),e.jsx("div",{className:"mono",children:String((N==null?void 0:N.to)||"").trim()||"(to?)"})]}),String((N==null?void 0:N.cc)||"").trim()?e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Cc"}),e.jsx("div",{className:"mono",children:String((N==null?void 0:N.cc)||"").trim()})]}):null,e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Date"}),e.jsx("div",{className:"mono",children:Ff(String((N==null?void 0:N.date)||($e==null?void 0:$e.date)||"").trim())||String((N==null?void 0:N.date)||($e==null?void 0:$e.date)||"").trim()||"(date?)"})]}),Array.isArray(N==null?void 0:N.attachments)&&N.attachments.length?e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Attachments"}),e.jsx("div",{className:"mono",children:N.attachments.map((M,ie)=>e.jsxs("div",{children:[String((M==null?void 0:M.filename)||"").trim()||"(file?)"," ",e.jsx("span",{className:"muted",children:String((M==null?void 0:M.content_type)||"").trim()?`(${String((M==null?void 0:M.content_type)||"").trim()})`:""})]},`${(M==null?void 0:M.filename)||""}:${ie}`))})]}):null,e.jsx("div",{className:"section_divider"}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:ee}),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:ze||"(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(Ya,{open:pe,title:`Compose (${String(b||"").trim()||"account"})`,onClose:()=>{je||oe(!1)},actions:e.jsxs("div",{className:"row",style:{gap:"8px",justifyContent:"flex-end"},children:[W?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginRight:"auto"},children:W}):null,e.jsx("button",{className:"btn",onClick:()=>oe(!1),disabled:je,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:()=>void Be(),disabled:je,children:je?"Sending…":"Send"})]}),children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"To"}),e.jsx("input",{value:I,onChange:M=>be(String(M.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:Re,onChange:M=>qe(String(M.target.value||"")),placeholder:"(optional)"})]}),e.jsxs("div",{className:"field",style:{flex:"1 1 220px"},children:[e.jsx("label",{children:"Bcc"}),e.jsx("input",{value:Oe,onChange:M=>ut(String(M.target.value||"")),placeholder:"(optional)"})]})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Subject"}),e.jsx("input",{value:he,onChange:M=>Fe(String(M.target.value||"")),placeholder:"Subject"})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Body (text)"}),e.jsx("textarea",{value:Le,onChange:M=>Ge(String(M.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 qf(a){const s=String(a||"").trim();if(!s)return"";const r=s.split("/").filter(Boolean);return r.length?r[r.length-1]:""}function Xo(a){const s=String(a||"").trim();if(!s)return"";const r=Date.parse(s);return Number.isFinite(r)?new Date(r).toLocaleString():s}function bi(a,s){const r=String(a||"");return r.length<=s?r:`${r.slice(0,Math.max(0,s-1))}…`}function jy(a){const s=a.gateway,r=!!a.enable_triage,[l,c]=cc("inbox_reports"),d=f.useRef(null),p=f.useRef(null),[m,_]=f.useState(r?"messages":"email"),[x,b]=f.useState([]),[y,C]=f.useState([]),[A,E]=f.useState([]),[$,L]=f.useState(!1),[q,O]=f.useState(""),[D,K]=f.useState(null),[T,te]=f.useState(""),[ue,re]=f.useState(!1),[Te,je]=f.useState(""),[Ce,xe]=f.useState("pending"),[J,ne]=f.useState(null),[ve,W]=f.useState(""),[Y,z]=f.useState(null),[V,U]=f.useState(""),[w,N]=f.useState(!1),[Z,pe]=f.useState(!1),[oe,I]=f.useState(""),[be,Re]=f.useState(""),qe=!!be,[Oe,ut]=f.useState(""),[he,Fe]=f.useState(""),[Le,Ge]=f.useState(""),[de,H]=f.useState(!1),fe=a.gateway_connected;f.useEffect(()=>{!r&&m!=="email"&&_("email")},[r,m]);const we=f.useMemo(()=>m==="bugs"?x:m==="features"?y:[],[m,x,y]);f.useEffect(()=>{m==="email"&&(O(""),L(!1))},[m]);async function X(){const ee=await s.list_bug_reports();b(Array.isArray(ee==null?void 0:ee.items)?ee.items:[])}async function Q(){const ee=await s.list_feature_requests();C(Array.isArray(ee==null?void 0:ee.items)?ee.items:[])}async function _e(){const ee=await s.list_triage_decisions({status:Ce||void 0,limit:500}),M=Array.isArray(ee==null?void 0:ee.decisions)?ee.decisions:[];E(M),J&&!M.some(ie=>ie.decision_id===J.decision_id)&&(ne(null),W(""),z(null),U(""))}async function Ie(){if(fe&&r&&m!=="email"){O(""),L(!0);try{m==="bugs"?await X():m==="features"?await Q():await _e()}catch(ee){O(String((ee==null?void 0:ee.message)||ee||"Refresh failed"))}finally{L(!1)}}}f.useEffect(()=>{Ie()},[m,fe,Ce,r]);async function ot(ee){K(ee),te(""),je(""),re(!0);try{if(ee.report_type==="bug"){const M=await s.get_bug_report_content(ee.filename);te(String((M==null?void 0:M.content)||""))}else{const M=await s.get_feature_request_content(ee.filename);te(String((M==null?void 0:M.content)||""))}}catch(M){je(String((M==null?void 0:M.message)||M||"Failed to load report"))}finally{re(!1)}}async function ce(ee){ne(ee),W(""),z(null),U("");const M=qf(ee.report_relpath);if(M)try{if(ee.report_type==="bug"){const ie=await s.get_bug_report_content(M);W(String((ie==null?void 0:ie.content)||""))}else if(ee.report_type==="feature"){const ie=await s.get_feature_request_content(M);W(String((ie==null?void 0:ie.content)||""))}}catch(ie){U(String((ie==null?void 0:ie.message)||ie||"Failed to load report"))}}async function ke(ee){U(""),z(null);const M=String(ee.draft_relpath||"").trim();if(!M)return;const ie=qf(M);if(ie)try{const Ke=await s.backlog_content("proposed",ie);z(Ke)}catch(Ke){U(String((Ke==null?void 0:Ke.message)||Ke||"Failed to load draft (is repo root configured on gateway?)"))}}async function Be(ee,M){if(J&&!w){U(""),N(!0);try{const ie=await s.apply_triage_decision(J.decision_id,{action:ee,defer_days:M??null});await _e();const Ke=String(Ce||"").trim().toLowerCase(),et=String((ie==null?void 0:ie.status)||"").trim().toLowerCase();if(!(!Ke||Ke===et))ne(null),W(""),z(null);else if(ne(ie),String(ie.draft_relpath||"").trim())try{await ke(ie)}catch{}}catch(ie){U(String((ie==null?void 0:ie.message)||ie||"Decision action failed"))}finally{N(!1)}}}async function $e(){if(!Z){O(""),pe(!0);try{const ee=await s.triage_run({write_drafts:!1,enable_llm:!1});I(`Scanned ${(ee==null?void 0:ee.reports)??0} report(s); updated ${(ee==null?void 0:ee.updated_decisions)??0} decision(s).`),await _e()}catch(ee){O(String((ee==null?void 0:ee.message)||ee||"Triage failed"))}finally{pe(!1)}}}f.useEffect(()=>{qe&&(Ge(""),Fe(""),H(!1),ut(String(a.default_session_id||"").trim()))},[qe,a.default_session_id]);async function ze(){var ee,M;if(be&&!de){Ge(""),H(!0);try{const ie=String(Oe||"").trim();if(!ie)throw new Error("session_id is required");const Ke=String(he||"").trim();if(!Ke)throw new Error("description is required");const et={session_id:ie,description:Ke,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(((ee=globalThis==null?void 0:globalThis.navigator)==null?void 0:ee.userAgent)||""),url:String(((M=globalThis==null?void 0:globalThis.location)==null?void 0:M.href)||"")};if(be==="bug"){const rt=await s.bug_report_create(et),mt=String((rt==null?void 0:rt.filename)||"").trim();Re(""),_("bugs");const ft=await s.list_bug_reports(),Ee=Array.isArray(ft==null?void 0:ft.items)?ft.items:[];b(Ee);const nt=Ee.find(ht=>ht.filename===mt)||null;nt&&await ot(nt)}else{const rt=await s.feature_report_create(et),mt=String((rt==null?void 0:rt.filename)||"").trim();Re(""),_("features");const ft=await s.list_feature_requests(),Ee=Array.isArray(ft==null?void 0:ft.items)?ft.items:[];C(Ee);const nt=Ee.find(ht=>ht.filename===mt)||null;nt&&await ot(nt)}}catch(ie){Ge(String((ie==null?void 0:ie.message)||ie||"Failed to create report"))}finally{H(!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":m==="messages",className:`seg_btn ${m==="messages"?"active":""}`,onClick:()=>_("messages"),children:"Messages"}),e.jsx("button",{"aria-pressed":m==="email",className:`seg_btn ${m==="email"?"active":""}`,onClick:()=>_("email"),children:"Email"}),e.jsx("button",{"aria-pressed":m==="bugs",className:`seg_btn ${m==="bugs"?"active":""}`,onClick:()=>_("bugs"),children:"Bugs"}),e.jsx("button",{"aria-pressed":m==="features",className:`seg_btn ${m==="features"?"active":""}`,onClick:()=>_("features"),children:"Features"})]}):e.jsx("button",{"aria-pressed":m==="email",className:`seg_btn ${m==="email"?"active":""}`,onClick:()=>_("email"),children:"Email"})}),r&&m!=="email"&&oe?e.jsx("span",{className:"page_hint mono",children:oe}):null,r&&m!=="email"&&q?e.jsx("span",{className:"page_error mono",children:q}):null,e.jsx("div",{className:"page_toolbar_spacer"}),r?e.jsxs(e.Fragment,{children:[m==="messages"?e.jsxs(e.Fragment,{children:[e.jsxs("select",{value:Ce,onChange:ee=>xe(String(ee.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 Ie(),disabled:!fe||$,children:$?"Refreshing…":"Refresh"}),e.jsx("button",{className:"btn primary",onClick:()=>void $e(),disabled:!fe||Z,children:Z?"Running…":"Run triage"})]}):m==="email"?null:e.jsx("button",{className:"btn",onClick:()=>void Ie(),disabled:!fe||$,children:$?"Refreshing…":"Refresh"}),e.jsx("button",{className:"btn",onClick:()=>Re("bug"),disabled:!fe,children:"File bug"}),e.jsx("button",{className:"btn",onClick:()=>Re("feature"),disabled:!fe,children:"File feature"})]}):null]}),m==="email"?e.jsx(wy,{gateway:s,enabled:fe}):e.jsxs("div",{className:`inbox_layout exec_layout${l?"":" list_collapsed"}`,children:[e.jsxs("div",{className:`pane inbox_list_pane${l?"":" list_collapsed"}`,ref:d,onClickCapture:ee=>{var M,ie;(ie=(M=ee.target)==null?void 0:M.closest)!=null&&ie.call(M,".inbox_item")&&requestAnimationFrame(()=>Ul(p.current))},children:[e.jsx("div",{className:"pane_header",children:e.jsx(Bl,{open:l,on_toggle:c,controls:"inbox_report_list",title:m==="messages"?"Triage decisions":m==="bugs"?"Bug reports":"Feature requests",count:m==="messages"?A.length:we.length})}),e.jsx("div",{className:"pane_body pane_body_list",id:"inbox_report_list",hidden:!l,children:m==="messages"?e.jsx(e.Fragment,{children:A.length?A.map(ee=>{const M=(J==null?void 0:J.decision_id)===ee.decision_id,ie=Array.isArray(ee.missing_fields)?ee.missing_fields.length:0;return e.jsxs("button",{className:`inbox_item ${M?"active":""}`,onClick:()=>void ce(ee),children:[e.jsxs("div",{className:"inbox_item_title",children:[e.jsx("span",{className:`pill ${String(ee.status||"").toLowerCase()}`,children:String(ee.status||"pending")}),e.jsx("span",{className:"mono",children:ee.report_type}),e.jsx("span",{className:"mono muted",children:bi(ee.decision_id,10)})]}),e.jsxs("div",{className:"inbox_item_meta mono muted",children:[ie?`${ie} missing`:"complete"," • ",Xo(ee.updated_at||ee.created_at)||"(time?)"]}),e.jsx("div",{className:"inbox_item_meta mono",children:bi(ee.report_relpath||"",46)})]},ee.decision_id)}):e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"No decisions."})}):e.jsx(e.Fragment,{children:we.length?we.map(ee=>{const M=(D==null?void 0:D.filename)===ee.filename&&(D==null?void 0:D.report_type)===ee.report_type,ie=String(ee.triage_status||"").trim().toLowerCase();return e.jsxs("button",{className:`inbox_item ${M?"active":""}`,onClick:()=>void ot(ee),children:[e.jsxs("div",{className:"inbox_item_title",children:[ie?e.jsx("span",{className:`pill ${ie}`,children:ie}):null,e.jsx("span",{className:"mono",children:bi(ee.title||ee.filename,46)})]}),e.jsxs("div",{className:"inbox_item_meta mono muted",children:[Xo(ee.created_at)||"(time?)"," • ",ee.session_id?bi(ee.session_id,12):"session?"]}),e.jsx("div",{className:"inbox_item_meta mono",children:ee.filename})]},ee.relpath)}):e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"No reports."})})})]}),e.jsx("div",{className:"pane inbox_detail_pane",ref:p,children:e.jsxs("div",{className:"pane_body",children:[e.jsx("div",{className:"pane_back_bar",children:e.jsx("button",{type:"button",className:"btn pane_back_btn",onClick:()=>Ul(d.current),children:"← Back to the list"})}),m==="messages"?J?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:J.report_type}),e.jsx("span",{className:"chip mono muted",children:J.status}),e.jsx("span",{className:"chip mono muted",children:bi(J.decision_id,16)})]}),e.jsxs("div",{className:"inbox_detail_actions",children:[e.jsx("button",{className:"btn",onClick:()=>{fn(J.report_relpath||"")},children:"Copy report path"}),J.draft_relpath?e.jsx("button",{className:"btn",onClick:()=>void ke(J),children:"Load draft"}):null,e.jsx("button",{className:"btn primary",onClick:()=>void Be("approve"),disabled:w,children:"Approve"}),e.jsx("button",{className:"btn",onClick:()=>void Be("defer",1),disabled:w,children:"Defer 1d"}),e.jsx("button",{className:"btn",onClick:()=>void Be("defer",7),disabled:w,children:"Defer 7d"}),e.jsx("button",{className:"btn",onClick:()=>void Be("reject"),disabled:w,children:"Reject"})]})]}),e.jsxs("div",{className:"inbox_detail_meta mono muted",style:{fontSize:"var(--font-size-sm)"},children:[J.updated_at?`updated ${Xo(J.updated_at)}`:null,J.created_at?`${J.updated_at?" • ":""}created ${Xo(J.created_at)}`:null,J.defer_until?` • defer until ${J.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"}),J.missing_fields&&J.missing_fields.length?e.jsx("ul",{className:"inbox_list_ul mono",children:J.missing_fields.map(ee=>e.jsx("li",{children:ee},ee))}):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"}),J.duplicates&&J.duplicates.length?e.jsx("ul",{className:"inbox_list_ul mono",children:J.duplicates.slice(0,20).map((ee,M)=>{const ie=String((ee==null?void 0:ee.title)||(ee==null?void 0:ee.ref)||(ee==null?void 0:ee.kind)||"duplicate").trim(),Ke=typeof(ee==null?void 0:ee.score)=="number"&&Number.isFinite(ee.score)?` (score ${ee.score.toFixed(2)})`:"";return e.jsxs("li",{children:[ie,Ke]},`${ie}_${M}`)})}):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"}),J.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:J.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)."})]})]}),Y?e.jsxs("div",{className:"inbox_markdown",children:[e.jsx("div",{className:"section_title",children:"Draft content"}),e.jsx(ls,{className:"md_doc",text:String(Y.content||"")})]}):null,e.jsxs("div",{className:"inbox_markdown",children:[e.jsx("div",{className:"section_title",children:"Source report"}),ve?e.jsx(ls,{className:"md_doc",text:ve}):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."}):D?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:D.report_type==="bug"?"Bug report":"Feature request"}),D.triage_status?e.jsx("span",{className:`pill ${D.triage_status}`,children:D.triage_status}):null,e.jsx("span",{className:"chip mono muted",children:D.filename}),D.session_id?e.jsx("span",{className:"chip mono muted",children:bi(D.session_id,16)}):null]}),e.jsx("div",{className:"inbox_detail_actions",children:e.jsx("button",{className:"btn",onClick:()=>{fn(D.relpath||"")},children:"Copy path"})})]}),Te?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:Te}):null,ue?e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Loading…"}):T?e.jsx(ls,{className:"md_doc",text:T}):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(Ya,{open:qe,title:be==="bug"?"File bug report":"File feature request",onClose:()=>Re(""),actions:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:()=>Re(""),disabled:de,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:()=>void ze(),disabled:de,children:de?"Submitting…":"Submit"})]}),children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Session ID"}),e.jsx("input",{value:Oe,onChange:ee=>ut(ee.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:be==="bug"?"Bug description":"Feature description"}),e.jsx("textarea",{value:he,onChange:ee=>Fe(ee.target.value),placeholder:be==="bug"?"What is broken? What did you expect?":"What do you want to be able to do?",rows:6})]}),Le?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)"},children:Le}):null]})]})}const ky="api/continuum/settings";async function Jh(a){const s=await fetch(ky,{...a,signal:AbortSignal.timeout(1e4),headers:a!=null&&a.body?{"Content-Type":"application/json"}:void 0}),r=await s.text();let l=null;try{l=JSON.parse(r)}catch{}if(!s.ok||!l||typeof l!="object"||!l.settings){const c=l&&typeof l=="object"?l.detail||l.error:"",d=new Error(c||`settings unavailable (HTTP ${s.status})`);throw d.status=s.status,d}return l}function Sy(){return Jh()}function Ny(a,s){return Jh({method:"PUT",body:JSON.stringify({[a]:s})})}const Yh="abstractcontinuum_voice_override_v1",Fu={enabled:!1};function ld(){try{const a=localStorage.getItem(Yh);if(!a)return{...Fu};const s=JSON.parse(a);return!s||typeof s!="object"?{...Fu}:{enabled:!!s.enabled,provider:Us(s.provider),model:Us(s.model),profile:Us(s.profile),voice:Us(s.voice),quality_preset:Us(s.quality_preset)}}catch{return{...Fu}}}const od="abstractcontinuum:voice_override_changed";function Cy(a){try{localStorage.setItem(Yh,JSON.stringify(a))}catch{}try{window.dispatchEvent(new CustomEvent(od))}catch{}}function Xh(a){if(!a)return{};const s={},r=Us(a.quality_preset);if(r&&(s.quality_preset=r),!a.enabled)return s;for(const l of["provider","model","profile","voice"]){const c=Us(a[l]);c&&(s[l]=c)}return s}function Us(a){return String(a??"").trim()||void 0}function Zh(a){const s=a&&typeof a=="object"?a.routes:null;if(!Array.isArray(s))return{};const r=x=>s.find(b=>b&&typeof b=="object"&&String(b.key||"").trim()===x&&!!b.configured),l=r("output.voice.tts")||r("output.voice");if(!l)return{};const c={},d=Us(l.provider),p=Us(l.model),m=l.options,_=m&&typeof m=="object"?Us(m.voice):void 0;return d&&(c.provider=d),p&&(c.model=p),_&&(c.voice=_),c}function $y(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 Tl={loading:!1,error:"",providers:[],models_by_provider:{},profiles_by_provider:{},voices_by_provider:{},cloned_by_provider:{}};function Ey(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 d=String(r.provider||"").trim(),p=String(r.id||r.voice||r.name||"").trim();if(!p)continue;const m=d||"*";(s[m]||(s[m]=[])).push(p)}for(const r of Object.keys(s))s[r]=[...new Set(s[r])];return s}function cd(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 qu(a){const s={};if(a&&typeof a=="object"&&!Array.isArray(a))for(const[r,l]of Object.entries(a)){const c=cd(l);c.length&&(s[String(r)]=c)}return s}function Ty(a){const{gateway:s,gateway_connected:r}=a,[l,c]=f.useState(()=>ld()),[d,p]=f.useState(Tl),[m,_]=f.useState(!1),[x,b]=f.useState(""),y=f.useRef(null),C=f.useCallback(D=>{c(K=>{const T={...K,...D};return Cy(T),T})},[]);f.useEffect(()=>{if(!r){p(Tl);return}if(typeof(s==null?void 0:s.voice_voices)!="function"){p(Tl);return}let D=!0;p(T=>({...T,loading:!0,error:""}));let K;try{K=s.voice_voices()}catch(T){p({...Tl,error:String((T==null?void 0:T.message)||T||"voice catalog unavailable")});return}return K.then(T=>{if(!D)return;const te=[...new Set([...cd(T==null?void 0:T.providers),...cd(T==null?void 0:T.tts_providers)])];p({loading:!1,error:"",providers:te,models_by_provider:qu(T==null?void 0:T.tts_models_by_provider),profiles_by_provider:qu(T==null?void 0:T.tts_profiles_by_provider),voices_by_provider:qu(T==null?void 0:T.tts_voices_by_provider),cloned_by_provider:Ey(T==null?void 0:T.items)})}).catch(T=>{D&&p({...Tl,error:String((T==null?void 0:T.message)||T||"voice catalog unavailable")})}),()=>{D=!1}},[s,r]);const A=l.provider||"",E=A&&d.models_by_provider[A]?d.models_by_provider[A]:[],$=A&&d.voices_by_provider[A]?d.voices_by_provider[A]:[],L=A&&d.profiles_by_provider[A]?d.profiles_by_provider[A]:[],q=[...A&&d.cloned_by_provider[A]?d.cloned_by_provider[A]:[],...d.cloned_by_provider["*"]||[]];async function O(){if(!(m||!r)){_(!0),b("");try{const D=await pd("abstractcontinuum_team_voice");let K={};if(typeof s.capability_defaults=="function")try{K=Zh(await s.capability_defaults())}catch{K={}}const T=await s.voice_tts(D,{text:"This is the voice AbstractContinuum will use to read your messages.",...K,...Xh(l),timeout_s:30}),te=T==null?void 0:T.audio_artifact,ue=te&&typeof te=="object"?String(te.$artifact||"").trim():"";if(!ue)throw new Error("no audio returned");const re=await s.download_run_artifact_content(D,ue),Te=URL.createObjectURL(re);if(y.current)try{y.current.pause()}catch{}const je=y.current;if(je){try{je.pause()}catch{}const xe=je.src;xe.startsWith("blob:")&&URL.revokeObjectURL(xe)}const Ce=new Audio(Te);y.current=Ce,Ce.onended=()=>{URL.revokeObjectURL(Te),b("")};try{await Ce.play(),b("Playing…")}catch(xe){b(String((xe==null?void 0:xe.name)||"").includes("NotAllowed")?"Synthesized OK — click Test again to play.":`Playback failed: ${String((xe==null?void 0:xe.message)||xe).slice(0,80)}`),URL.revokeObjectURL(Te)}}catch(D){b(`Test failed: ${String((D==null?void 0:D.message)||D||"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.jsx(Si,{variant:"row",label:"Custom voice",description:"Read messages with the voice below instead of the gateway's default, in this browser.",action:"custom-voice",checked:l.enabled,onChange:D=>C({enabled:D})}),d.error?e.jsxs("div",{className:"muted team_note",children:["Voice catalog unavailable (",d.error.slice(0,100),") — you can still type provider/model/voice values below; the gateway validates on Test."]}):null,d.loading?e.jsx("div",{className:"muted team_note",children:"Loading voices…"}):null,l.enabled&&!A&&(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(Zo,{value:A,options:d.providers,placeholder:"gateway default",onChange:D=>C({provider:D,model:"",voice:"",profile:""})})]}),e.jsxs("label",{className:"settings_field",children:[e.jsx("span",{className:"muted",children:"Model"}),e.jsx(Zo,{value:l.model||"",options:E,placeholder:"default",onChange:D=>C({model:D})})]}),e.jsxs("label",{className:"settings_field",children:[e.jsx("span",{className:"muted",children:"Base voice"}),e.jsx(Zo,{value:l.profile||"",options:L,placeholder:"default",onChange:D=>C({profile:D})})]}),e.jsxs("label",{className:"settings_field",children:[e.jsx("span",{className:"muted",children:"Cloned voice"}),e.jsx(Zo,{value:l.voice||"",options:[...q,...$],placeholder:"none",onChange:D=>C({voice:D})})]})]}):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:D=>C({quality_preset:D.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:m,onClick:()=>void O(),children:m?"Synthesizing…":"Test voice"}),x?e.jsx("span",{className:"muted team_note",children:x}):null]})]}):e.jsx("div",{className:"muted team_note",children:"Connect to the gateway to configure and test message voice."})})]})}function Zo(a){const s=Wt.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 Ay=["minimal","low","medium","high","xhigh"];function Ry(a){const{gateway:s,connected:r,model:l,value:c,onChange:d}=a,[p,m]=f.useState({state:"unknown",levels:[]}),[_,x]=f.useState(!1);if(f.useEffect(()=>{x(!1);const C=String(l||"").trim();if(!C||!r){m({state:"unknown",levels:[]});return}let A=!1;return m({state:"loading",levels:[]}),s.discovery_model_capabilities(C).then(E=>{if(A)return;const $=E!=null&&E.capabilities&&typeof E.capabilities=="object"?E.capabilities:{},L=$.thinking_support,q=Array.isArray($.reasoning_levels)?$.reasoning_levels.map(O=>String(O)):[];m(L===!0?{state:"supported",levels:q}:L===!1?{state:"unsupported",levels:[]}:{state:"unknown",levels:[]})}).catch(()=>{A||m({state:"unknown",levels:[]})}),()=>{A=!0}},[l,r]),!String(l||"").trim())return null;const b=p.state==="unsupported"||p.state==="unknown"&&!_||p.state==="loading",y=p.state==="supported"&&p.levels.length?p.levels:p.state==="unknown"&&_?[...Ay]:[];return e.jsxs("div",{className:"field","data-testid":"reasoning_select",children:[e.jsxs("label",{children:["Reasoning (effort for ",l,")"]}),e.jsxs("select",{value:b?"":c,onChange:C=>d(String(C.target.value||"")),disabled:b,title:p.state==="supported"?"Efforts this model declares (gateway-served). Sent on the `thinking` wire key; blank = gateway default.":p.state==="unsupported"?"This model declares no reasoning support — effort is locked to none (contract v1: non-reasoning models naturally get none).":p.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:p.state==="unsupported"?"none — this model doesn't reason":p.state==="loading"?"checking…":p.state==="unknown"&&!_?"unknown — no served facts":"gateway default"}),y.map(C=>e.jsx("option",{value:C,children:C},C))]}),p.state==="unknown"&&!b?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,p.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:C=>{x(C.target.checked),C.target.checked||d("")}}),"set anyway (I know this model reasons)"]}):null]})}function Ly(a){const[s,r]=f.useState(!1),[l,c]=f.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:d=>c(d.target.value),placeholder:"/path/to/a/folder/with/docs/backlog",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 My(a){const s=String(a||"").trim();if(!s)return null;const r={flag:["launch flag","info","Set by a launch flag of the running Continuum; a saved value applies once it restarts without the flag."],setting:["setting","info","Saved setting (here, or `abstractcontinuum config set`)."],env:["environment (legacy)","warn","Set by the environment Continuum was started with. Save a value here to replace it."],default:["default","muted","Nothing saved: Continuum's default."]},[l,c,d]=r[s]||[s,"muted",""];return e.jsx("span",{className:`chip mono ${c}`,title:d,"data-testid":"hub_seat_source",children:l})}function zy(){var E;const[a,s]=f.useState(null),[r,l]=f.useState(""),[c,d]=f.useState(""),[p,m]=f.useState(!1),[_,x]=f.useState("");f.useEffect(()=>{let $=!1;return Sy().then(L=>{var q;$||(s(L),d(String(((q=L.settings.hub_seat)==null?void 0:q.value)??"")))}).catch(L=>{$||l(String((L==null?void 0:L.message)||L))}),()=>{$=!0}},[]);async function b($){var L;m(!0),x("");try{const q=await Ny("hub_seat",$);s(q),d(String(((L=q.settings.hub_seat)==null?void 0:L.value)??""))}catch(q){x(String((q==null?void 0:q.message)||q||"Save refused"))}finally{m(!1)}}const y=a==null?void 0:a.settings.hub_seat,C=String((y==null?void 0:y.value)??""),A=!!((E=a==null?void 0:a.writable)!=null&&E.includes("hub_seat"));return e.jsxs("div",{className:"pane","data-testid":"hub_seat_pane",children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Team (agora hub)"}),e.jsx("span",{className:"pane_subtitle",children:"server-side — this Continuum"})]}),e.jsx("div",{className:"pane_body",children:a?e.jsxs("div",{className:"admin_row","data-testid":"admin_row_hub_seat",children:[e.jsxs("div",{className:"admin_row_top",children:[e.jsx("span",{className:"admin_row_name",children:"Hub seat"}),e.jsx("span",{className:"chip mono ok","data-testid":"hub_seat_value",children:C}),My(y==null?void 0:y.source),e.jsx("div",{className:"admin_row_action",children:A?e.jsxs("span",{style:{display:"flex",gap:6,alignItems:"center"},children:[e.jsx("input",{className:"mono","aria-label":"Hub seat",value:c,onChange:$=>d($.target.value),placeholder:"your seat",disabled:p}),e.jsx("button",{className:"btn primary",disabled:p||!c.trim()||c.trim()===C&&(y==null?void 0:y.source)==="setting",onClick:()=>void b(c.trim()),children:"Save"}),(y==null?void 0:y.source)==="setting"?e.jsx("button",{className:"btn",disabled:p,onClick:()=>void b(null),children:"Use default"}):null]}):null})]}),e.jsxs("div",{className:"admin_row_detail",children:["The seat the Team page reads and posts as — set it to your own seat. Saved in ",e.jsx("code",{children:a.settings_file}),"; the same setting: ",e.jsx("code",{children:"abstractcontinuum config set hub_seat <seat>"}),", or ",e.jsx("code",{children:"--hub-seat <seat>"})," for one run.",(y==null?void 0:y.source)==="flag"?" A launch flag sets the seat for this run; a saved value applies once Continuum restarts without it.":null]}),_?e.jsx("div",{className:"page_error mono",style:{marginTop:"6px"},children:_}):null]}):e.jsx("div",{className:"muted",style:{fontSize:"var(--font-size-sm)"},children:r?`Continuum's server settings are not available here (${r}). Set the seat with \`abstractcontinuum config set hub_seat <seat>\` or start Continuum with --hub-seat <seat>.`:"Loading…"})})]})}function Py(a){var ne,ve;const{gateway:s,gateway_connected:r,settings:l,set_settings:c}=a,d=(ve=(ne=a.connection)==null?void 0:ne.gateway)==null?void 0:ve.principal,[p,m]=f.useState({loaded:!1,process_manager:null,backlog_root:null,exec_pipeline:null,exec_detail:"",executor:""}),[_,x]=f.useState(null),[b,y]=f.useState(null),[C,A]=f.useState(!1),[E,$]=f.useState(null),[L,q]=f.useState([]),[O,D]=f.useState(""),[K,T]=f.useState(""),[te,ue]=f.useState(!1),[re,Te]=f.useState(0);async function je(W,Y=""){if(!te){ue(!0),D(""),T("");try{const z=await s.admin_runtime_config_update(W);x(z),T(Y),Te(V=>V+1)}catch(z){D(String((z==null?void 0:z.message)||z||"Config update refused"))}finally{ue(!1)}}}f.useEffect(()=>{if(!r)return;let W=!1;return(async()=>{var z;const Y={loaded:!0,process_manager:null,backlog_root:null,exec_pipeline:null,exec_detail:"",executor:""};try{const V=await s.backlog_exec_config(),U=!!(V!=null&&V.runner_enabled),w=!!(V!=null&&V.runner_alive),N=(V==null?void 0:V.can_execute)===!0;Y.exec_pipeline=N?"on":U||w?"degraded":"off",Y.exec_detail=N?"":U?w?"runner alive but cannot execute (executor missing?)":"runner enabled but not alive":"runner disabled",Y.executor=String((V==null?void 0:V.executor)||"").trim()}catch{Y.exec_pipeline=null}try{const V=await s.admin_runtime_config();if(V&&typeof V=="object"){W||(x(V),Y.process_manager=Yo(V.process_manager),Y.backlog_root=((z=V.triage_repo_root)==null?void 0:z.available)!==void 0?!!V.triage_repo_root.available:Yo(V.triage_repo_root),m(Y));return}}catch{}try{const V=await s.list_processes();Y.process_manager=!!(V!=null&&V.enabled)}catch{Y.process_manager=null}try{await s.backlog_template(),Y.backlog_root=!0}catch(V){Y.backlog_root=ki(V)?!1:null}W||m(Y)})(),(async()=>{try{const Y=await s.admin_data_homes();W||($(Array.isArray(Y==null?void 0:Y.homes)?Y.homes:[]),q(Array.isArray(Y==null?void 0:Y.warnings)?Y.warnings:[]))}catch{W||$(null)}})(),(async()=>{try{const Y=await s.list_bundles(),z=Array.isArray(Y==null?void 0:Y.items)?Y.items:Array.isArray(Y==null?void 0:Y.bundles)?Y.bundles:Array.isArray(Y)?Y:[],V=[];for(const N of z){const Z=String((N==null?void 0:N.bundle_id)||(N==null?void 0:N.id)||"").trim();if(!Z)continue;const pe=Array.isArray(N==null?void 0:N.entrypoints)?N.entrypoints:[];for(const oe of pe){if((oe==null?void 0:oe.deprecated)===!0||!(Array.isArray(oe==null?void 0:oe.interfaces)?oe.interfaces:[]).some(Re=>String(Re||"").trim().length>0))continue;const be=String((oe==null?void 0:oe.name)||"").trim();V.push({id:Z,name:be?`${Z} · ${be}`:Z,description:String((oe==null?void 0:oe.description)||"").trim()||void 0})}}const U=new Set,w=V.filter(N=>U.has(N.id)?!1:(U.add(N.id),!0));w.sort((N,Z)=>N.name.localeCompare(Z.name)),W||y(w)}catch{W||y(null)}})(),()=>{W=!0}},[s,r,re]);function Ce(W){return typeof W!="number"||!Number.isFinite(W)||W<0?"":W>=1e12?`${(W/1e12).toFixed(1)} TB`:W>=1e9?`${(W/1e9).toFixed(1)} GB`:W>=1e6?`${(W/1e6).toFixed(1)} MB`:W>=1e3?`${(W/1e3).toFixed(1)} KB`:`${W} B`}function xe(W,Y="on",z="off"){return W===null?e.jsx("span",{className:"chip mono muted",children:"unknown"}):e.jsx("span",{className:`chip mono ${W?"ok":"warn"}`,children:W?Y:z})}function J(W){const Y=String(W||"").trim();if(!Y)return null;const z={flag:["launch flag","info","Set by a launch flag of the running gateway; a saved value applies once it restarts without the flag."],stored:["setting","info","Saved setting (Settings here, the gateway console, or `abstractgateway config set`)."],env:["environment (legacy)","warn","Set by the environment the gateway was started with. Save a value here to replace it."],default:["default","muted","Nothing saved: the gateway's default."]},[V,U,w]=z[Y]||[Y,"muted",""];return e.jsx("span",{className:`chip mono ${U}`,title:w,"data-testid":"source_chip",children:V})}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:W=>c(Y=>({...Y,default_execution_mode:W.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(u_,{disabled:!r,value:{provider:l.maintenance_ai_provider,model:l.maintenance_ai_model},onChange:W=>c(Y=>({...Y,maintenance_ai_provider:W.provider,maintenance_ai_model:W.model,maintenance_ai_reasoning:W.model===Y.maintenance_ai_model?Y.maintenance_ai_reasoning:""})),fetchProviders:async()=>{const W=await s.discovery_providers();return(Array.isArray(W==null?void 0:W.items)?W.items:[]).map(Y=>({name:Y.name,display_name:Y.display_name}))},fetchModels:async W=>{const Y=await s.discovery_provider_models(W);return Array.isArray(Y==null?void 0:Y.models)?Y.models:[]},defaultHint:"Uses the gateway's configured default provider and model for maintenance calls."})]}),e.jsx(Ry,{gateway:s,connected:r,model:l.maintenance_ai_model,value:l.maintenance_ai_reasoning,onChange:W=>c(Y=>({...Y,maintenance_ai_reasoning:W}))}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Advisor workflow (executable workflows served by this gateway)"}),b===null?e.jsx("input",{className:"mono",value:l.backlog_advisor_agent,onChange:W=>c(Y=>({...Y,backlog_advisor_agent:String(W.target.value||"")})),placeholder:"basic-agent",title:"This gateway does not serve the workflow catalog — enter a bundle id."}):(()=>{const W=String(l.backlog_advisor_agent||"").trim(),Y=W===""||b.some(z=>z.id===W);return e.jsxs(e.Fragment,{children:[e.jsxs("select",{value:Y&&!C?W:"__custom__",onChange:z=>{const V=z.target.value;V==="__custom__"?A(!0):(A(!1),c(U=>({...U,backlog_advisor_agent:V})))},title:"Workflows the gateway can run for advice; blank = the shipped basic-agent",children:[e.jsx("option",{value:"",children:"gateway default (basic-agent)"}),b.map(z=>e.jsx("option",{value:z.id,title:z.description||void 0,children:z.name||z.id},z.id)),e.jsx("option",{value:"__custom__",children:"custom bundle id…"})]}),!Y||C?e.jsx("input",{className:"mono",style:{marginTop:6},value:l.backlog_advisor_agent,onChange:z=>c(V=>({...V,backlog_advisor_agent:String(z.target.value||"")})),placeholder:"bundle id (e.g. docs-qa@0.1.0)"}):null]})})()]})]})]}),e.jsx(Ty,{gateway:s,gateway_connected:r}),e.jsx(zy,{}),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:[d!=null&&d.user_id?e.jsxs("div",{style:{fontSize:"var(--font-size-sm)",marginBottom:"8px"},children:["Signed in as ",e.jsx("strong",{children:d.user_id}),d.admin===!0?e.jsx("span",{className:"chip mono ok",style:{marginLeft:6},children:"gateway admin"}):d.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 w,N,Z,pe,oe,I,be,Re,qe;const W=(_==null?void 0:_.writable)===!0,Y=Array.isArray(_==null?void 0:_.executors)?_.executors:[],z=W?null:_?_.writable===!1?"Only a gateway admin can change this.":"This gateway does not say whether you may change it.":"This gateway does not serve its settings to Continuum (older build).",V=_?Yo(_.backlog_exec_runner)===!0:p.exec_pipeline==="on"||p.exec_pipeline==="degraded",U=_?Yo(_.process_manager)===!0:p.process_manager===!0;return e.jsxs("div",{children:[e.jsxs("div",{className:"admin_row","data-testid":"admin_row_backlog_folder",children:[e.jsxs("div",{className:"admin_row_top",children:[e.jsx("span",{className:"admin_row_name",children:"Backlog folder"}),xe(p.backlog_root,"available","not available"),J((w=_==null?void 0:_.triage_repo_root)==null?void 0:w.source),e.jsxs("div",{className:"admin_row_action",children:[W&&((N=_==null?void 0:_.triage_repo_root)!=null&&N.default_path)&&Cl(_==null?void 0:_.triage_repo_root)!==_.triage_repo_root.default_path?e.jsx("button",{className:"btn",disabled:te,onClick:()=>{var Oe;return void je({triage_repo_root:((Oe=_==null?void 0:_.triage_repo_root)==null?void 0:Oe.default_path)||null})},title:_.triage_repo_root.default_path,children:"Use the gateway's own folder"}):null,W?e.jsx(Ly,{current:Cl(_==null?void 0:_.triage_repo_root),busy:te,on_apply:Oe=>void je({triage_repo_root:Oe})}):null]})]}),e.jsxs("div",{className:"admin_row_detail",children:[((Z=_==null?void 0:_.triage_repo_root)==null?void 0:Z.help)||"The folder whose docs/backlog holds the items the Board and Backlog pages show.",Cl(_==null?void 0:_.triage_repo_root)?e.jsxs(e.Fragment,{children:[" ","In use: ",e.jsx("code",{children:Cl(_==null?void 0:_.triage_repo_root)})]}):null,((pe=_==null?void 0:_.triage_repo_root)==null?void 0:pe.available)===!1&&_.triage_repo_root.reason?e.jsxs(e.Fragment,{children:[" — not available: ",_.triage_repo_root.reason]}):null]})]}),e.jsxs("div",{className:"admin_row","data-testid":"admin_row_exec_runner",children:[e.jsxs("div",{className:"admin_row_top",children:[e.jsx(Si,{label:"Exec runner",action:"exec-runner",checked:V,unavailableReason:z,busy:te,onChange:Oe=>void je({backlog_exec_runner:Oe},Oe?"Exec runner is on.":"Exec runner is off.")}),p.exec_pipeline===null?e.jsx("span",{className:"chip mono muted",title:"The gateway did not report the runner's state.",children:"state unknown"}):V&&p.exec_pipeline!=="on"?e.jsx("span",{className:"chip mono warn",title:p.exec_detail,children:"degraded"}):null,J((oe=_==null?void 0:_.backlog_exec_runner)==null?void 0:oe.source)]}),e.jsxs("div",{className:"admin_row_detail",children:[((I=_==null?void 0:_.backlog_exec_runner)==null?void 0:I.help)||"Runs the backlog items queued for execution on the gateway's computer.",p.exec_detail?e.jsxs(e.Fragment,{children:[" — ",p.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"}),p.executor&&p.executor!=="none"?e.jsx("span",{className:"chip mono ok",children:p.executor}):e.jsx("span",{className:"chip mono warn",children:"none"}),J((be=_==null?void 0:_.executor)==null?void 0:be.source),e.jsx("div",{className:"admin_row_action",children:W&&Y.length?e.jsx("select",{value:Cl(_==null?void 0:_.executor),disabled:te,onChange:Oe=>void je({executor:String(Oe.target.value||"")}),title:"Pick the execution agent (validated by the gateway registry)",children:Y.map(Oe=>e.jsxs("option",{value:Oe.id,disabled:Oe.available===!1,children:[Oe.display||Oe.id,Oe.available===!1?" (unavailable)":""]},Oe.id))}):null})]}),e.jsx("div",{className:"admin_row_detail",children:"The agent that runs queued items (the gateway lists what is installed on its computer)."})]}),e.jsxs("div",{className:"admin_row","data-testid":"admin_row_process_manager",children:[e.jsxs("div",{className:"admin_row_top",children:[e.jsx(Si,{label:"Process manager",action:"process-manager",checked:U,unavailableReason:z,busy:te,onChange:Oe=>void je({process_manager:Oe},Oe?"Process manager is on.":"Process manager is off.")}),!_&&p.process_manager===null?e.jsx("span",{className:"chip mono muted",title:"The gateway did not report the process manager's state.",children:"state unknown"}):null,J((Re=_==null?void 0:_.process_manager)==null?void 0:Re.source)]}),e.jsx("div",{className:"admin_row_detail",children:((qe=_==null?void 0:_.process_manager)==null?void 0:qe.help)||"Powers the Services page. High trust: whoever reaches Services can redeploy."})]})]})})(),O?e.jsx("div",{className:"page_error mono",style:{marginTop:"6px"},children:O}):null,K&&!O?e.jsx("div",{className:"muted",role:"status","data-testid":"admin_notice",style:{fontSize:"var(--font-size-sm)",marginTop:"6px"},children:K}):null,e.jsx("div",{className:"muted",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:_?_.writable===!0?"Changes are saved on the gateway and apply at once; a launch flag of the running gateway wins until it restarts without it. The same settings: gateway console (Apps → Backlog settings) or `abstractgateway config set <key> <value>` on the gateway's computer.":_.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).":"This gateway does not serve its settings to Continuum (older build): update the gateway to change these from here."})]}):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:E?`server-side — ${E.length} registered home${E.length===1?"":"s"}`:"server-side — read-only telemetry"})]}),e.jsx("div",{className:"pane_body",children:r?E===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:[...E].sort((W,Y)=>(Y.size_bytes||0)-(W.size_bytes||0)).map(W=>e.jsxs("tr",{title:W.description||W.path,children:[e.jsx("td",{children:W.name}),e.jsx("td",{children:e.jsx("span",{className:"chip mono muted",children:W.kind})}),e.jsx("td",{className:"muted",children:W.owner}),e.jsx("td",{children:W.exists===!1?e.jsx("span",{className:"chip mono warn",children:"missing"}):Ce(W.size_bytes)}),e.jsx("td",{children:W.safe_to_purge?e.jsx("span",{className:"chip mono ok",children:"purgeable"}):e.jsx("span",{className:"chip mono warn",title:W.description||"Protected — the owner's rule refuses purge",children:"protected"})})]},W.name))})]})}),L.map((W,Y)=>e.jsx("div",{className:"page_error mono",style:{marginTop:"6px"},children:W},`dhw:${Y}`)),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 Iy=/^(```+|~~~+)\s*mermaid\s*$/i;function Oy(a){const s=String(a||"").split(`
90
+ `),r=[];let l=[],c=0;for(;c<s.length;){const d=s[c].match(Iy);if(!d){l.push(s[c]),c+=1;continue}const p=d[1];let m=-1;for(let _=c+1;_<s.length;_++){const x=s[_].trimEnd();if(x.startsWith(p[0].repeat(3))&&/^(`{3,}|~{3,})\s*$/.test(x)&&x[0]===p[0]){m=_;break}}if(m===-1){l.push(s[c]),c+=1;continue}l.length&&(r.push({kind:"md",text:l.join(`
91
+ `)}),l=[]),r.push({kind:"mermaid",text:s.slice(c+1,m).join(`
92
+ `)}),c=m+1}return l.length&&r.push({kind:"md",text:l.join(`
93
+ `)}),r}const Dy="modulepreload",Fy=function(a,s){return new URL(a,s).href},Bf={},qy=function(s,r,l){let c=Promise.resolve();if(r&&r.length>0){let p=function(b){return Promise.all(b.map(y=>Promise.resolve(y).then(C=>({status:"fulfilled",value:C}),C=>({status:"rejected",reason:C}))))};const m=document.getElementsByTagName("link"),_=document.querySelector("meta[property=csp-nonce]"),x=(_==null?void 0:_.nonce)||(_==null?void 0:_.getAttribute("nonce"));c=p(r.map(b=>{if(b=Fy(b,l),b in Bf)return;Bf[b]=!0;const y=b.endsWith(".css"),C=y?'[rel="stylesheet"]':"";if(!!l)for(let $=m.length-1;$>=0;$--){const L=m[$];if(L.href===b&&(!y||L.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${b}"]${C}`))return;const E=document.createElement("link");if(E.rel=y?"stylesheet":Dy,y||(E.as="script"),E.crossOrigin="",E.href=b,x&&E.setAttribute("nonce",x),document.head.appendChild(E),y)return new Promise(($,L)=>{E.addEventListener("load",$),E.addEventListener("error",()=>L(new Error(`Unable to preload CSS for ${b}`)))})}))}function d(p){const m=new Event("vite:preloadError",{cancelable:!0});if(m.payload=p,window.dispatchEvent(m),!m.defaultPrevented)throw p}return c.then(p=>{for(const m of p||[])m.status==="rejected"&&d(m.reason);return s().catch(d)})};let Bu=null;function By(){return Bu||(Bu=qy(()=>import("./mermaid.core-i20J3FaS.js").then(a=>a.bp),[],import.meta.url).then(a=>{const s=a.default||a;return s.initialize({startOnLoad:!1,securityLevel:"strict",theme:"dark"}),s})),Bu}let Uy=0;function Wy(a){const s=f.useRef(null),[r,l]=f.useState("");return f.useEffect(()=>{let c=!0;return l(""),By().then(async d=>{const p=`af_mermaid_${Uy+=1}`,{svg:m}=await d.render(p,a.text);c&&s.current&&(s.current.innerHTML=m)}).catch(d=>{c&&l(String((d==null?void 0:d.message)||d||"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 ep=5e4,Hy="abstractcontinuum history_window.estimate_tokens (~4 chars per token)";function Vy(a){const s=String(a??"");return s?Math.max(1,Math.floor(s.length/4)):0}function Gy(a,s,r=ep){if(!Number.isInteger(r)||r<=0)throw new Error(`history window max_tokens must be a positive integer, got ${r}`);const l=a.map(_=>({item:_,tokens:s(_)}));let c=0,d=l.length,p=!1;for(let _=l.length-1;_>=0;_--){const x=l[_].tokens;if(c+x>r){d===l.length&&(p=!0,c+=x,d=_);break}c+=x,d=_}const m=l.slice(0,d);return{kept:l.slice(d).map(_=>_.item),report:{policy:"newest_whole_messages",max_tokens:r,token_estimator:Hy,total_messages:l.length,replayed_messages:l.length-d,replayed_tokens:c,dropped_messages:m.length,dropped_tokens:m.reduce((_,x)=>_+x.tokens,0),oversize_message_kept:p}}}const Ky=400;function Qy(a){const s=new Map;for(const c of a)s.set(c.id,c);const r=c=>{let d=c,p=!1;const m=new Set([d.id]);for(let _=0;_<Ky;_++){const x=String(d.reply_to||"");if(!x)break;const b=s.get(x);if(!b){p=d.id===c.id||p;break}if(m.has(b.id))break;m.add(b.id),d=b}return{root:d,orphan:p&&d.id===c.id}},l=new Map;for(const c of[...a].sort((d,p)=>(d.seq||0)-(p.seq||0))){const{root:d,orphan:p}=r(c);let m=l.get(d.id);m||(m={root:d,replies:[],orphan:d.id===c.id?p:!1,last_seq:d.seq||0},l.set(d.id,m)),c.id!==d.id&&(m.replies.push(c),m.last_seq=Math.max(m.last_seq,c.seq||0))}return[...l.values()].sort((c,d)=>c.last_seq-d.last_seq||(c.root.seq||0)-(d.root.seq||0))}const Uf=[{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 tp(a,s,r){var c,d,p,m,_;if(a.retracted===!0)return s==="all"?!0:s==="unread"?!!((c=r.unread_seqs)!=null&&c.has(a.seq)||(d=r.unread_snapshot_seqs)!=null&&d.has(a.seq)):!1;const l=String(a.status||"").toLowerCase();switch(s){case"all":return!0;case"unread":return!!((p=r.unread_seqs)!=null&&p.has(a.seq)||(m=r.unread_snapshot_seqs)!=null&&m.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 x=(l==="open"||l==="blocked")&&a.has_resolved_reply!==!0,b=a.critical===!0,y=Array.isArray(a.to)&&a.to.includes(r.seat),C=!!((_=r.escalated_seqs)!=null&&_.has(a.seq));return x||b||y||C}}}function Wf(a,s,r){return s==="all"?a:a.filter(l=>[l.root,...l.replies].some(c=>tp(c,s,r)))}function Jy(a,s,r){return tp(a,s,r)}function Yy(a){const s={},r={};for(const l of a){const c=String(l.channel||"");if(!c)continue;const d=Number(l.seq);if(Number.isFinite(d)){const p=s[c]||(s[c]=new Set);if(p.has(d))continue;p.add(d)}r[c]=(r[c]||0)+1}return r}function Xy(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 Zy(a,s){const r={};for(const l of a){const c=String(l.channel||""),d=Number(l.seq);if(!c||!Number.isFinite(d))continue;const p=String(l.status||"").toLowerCase(),m=Array.isArray(l.to)&&s?l.to.includes(s):!1;(p==="open"||p==="blocked"||(p==="reply"||p==="fyi")&&m)&&(r[c]||(r[c]=new Set)).add(d)}return r}function ex(a){const s={};for(const r of a){const l=String(r.channel||""),c=Number(r.seq);if(!l||!Number.isFinite(c))continue;const d=String(r.effective_urgency||"").toLowerCase();(r.escalated===!0||d==="interrupt")&&(s[l]||(s[l]=new Set)).add(c)}return s}function tx(a,s){const r=s?s.replace(/\/+$/,"")+"/":"",l=new Map,c=[];for(const d of a){const p=String(d.path||"");if(!p.startsWith(r))continue;const m=p.slice(r.length);if(!m)continue;const _=m.indexOf("/");if(_===-1)c.push(d);else{const x=m.slice(0,_);l.set(x,(l.get(x)||0)+1)}}return{dirs:[...l.entries()].map(([d,p])=>({name:d,path:r+d,count:p})).sort((d,p)=>d.name.localeCompare(p.name)),leaves:c.sort((d,p)=>d.path.localeCompare(p.path))}}function Hf(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 nx(a){return a.is_reply?"reply":a.in_dm||a.kind==="ask"?"open":"fyi"}function sx(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 d=s.get(c);(d===void 0||d!==String(l.sender||""))&&r.add(c)}return r}const ax=/(?:^|[\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,rx=4;function ix(a){const s=[];for(const r of String(a||"").matchAll(ax)){const l=r[1],c=r.index===void 0?-1:r.index,d=c>=0?String(a).slice(Math.max(0,c-12),c+1):"";if(!(d.includes("://")||/\/api\//.test(d))&&(s.includes(l)||s.push(l),s.length>=rx))break}return s}function lx(a,s,r){var c,d;const l=a.split("/").pop()||a;if(s!=null&&s.has(a))return{kind:"fs",path:a,rewritten:!1};for(let p=0;p<r.length;p++)if(String(((c=r[p])==null?void 0:c.filename)||"")===a)return{kind:"attachment",attachment_index:p};if(s){const p=[];for(const m of s)(m===l||m.endsWith(`/${l}`))&&p.push(m);if(p.length===1)return{kind:"fs",path:p[0],rewritten:p[0]!==a}}for(let p=0;p<r.length;p++){const m=String(((d=r[p])==null?void 0:d.filename)||"");if(m&&(m===l||m.split("/").pop()===l))return{kind:"attachment",attachment_index:p}}return null}const Vf=/@([A-Za-z0-9][A-Za-z0-9_.-]*)/g;function Uu(a){const s=[];for(const l of a.matchAll(Vf)){const c=l[1].toLowerCase();s.includes(c)||s.push(c)}return{title:a.replace(Vf," ").split(/\s+/).join(" ").trim().replace(/^[\s,;:-]+|[\s,;:-]+$/g,""),members:s}}function Wu(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 Hu(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 Gf=400,Kf=/([.;:!?…]["')\]]*) +(\((?:\d{1,2}|[a-z])\)|\[\d{1,2}\]) (?=["'([{]?[A-Za-z0-9])/g,Qf=/([.;:!?…]["')\]]*) +(?=[A-Z][A-Z'-]+(?: [A-Z][A-Z'-]*)+)/g;function ox(a){if(!a||a.length<Gf)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 d of c){if(/\n/.test(d)||d.length<Gf){r.push(d);continue}const p=d.split(/(`[^`\n]*`)/);let m=0;for(const _ of p)_.startsWith("`")||(m+=(_.match(Kf)||[]).length+(_.match(Qf)||[]).length);if(m<2){r.push(d);continue}r.push(p.map(_=>_.startsWith("`")?_:_.replace(Kf,`$1
94
+
95
+ $2 `).replace(Qf,`$1
96
+
97
+ `)).join(""))}}return r.join("")}const cx=/https?:\/\/[^\s<>()[\]{}"'`]+/g,ux=/\.(png|jpe?g|gif|webp)$/i;function dx(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 mx(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]*?(?:```|$))/),d=[];for(let p=0;p<c.length;p++){const m=c[p];if(m.startsWith("```")){d.push(m);continue}const _=m.split(/(`[^`\n]*`)/);for(let x=0;x<_.length;x++){const b=_[x];if(b.startsWith("`")){d.push(b);continue}d.push(b.replace(cx,(y,C)=>{const A=b.slice(Math.max(0,C-2),C);if(A.endsWith("](")||A.endsWith("("))return y;const E=y.replace(/[.,;:!?]+$/,""),$=y.slice(E.length);let L="";try{L=new URL(E).pathname}catch{return y}const q=dx(E,r),O=ux.test(L),D=q!==E||l!==""&&q.startsWith(l+"/");return O&&D?`![image](${q})${$}`:`[${E}](${q})${$}`}))}}return d.join("")}const fx=/^api\/hub\/channels\/[^/]+\/attachments\/[A-Za-z0-9_-]+$/;function hx(a){const s=a.trim(),r=s.replace(/^\.\//,"").replace(/^\//,"");return r.startsWith("api/")?s.startsWith("/")||/\s/.test(r)||r.includes("..")?!0:!fx.test(r):!1}function Pl(a){if(!a||!a.includes("api/"))return a;const s=/(!?)\[([^\]]*)\]\(([^)]+)\)/g;return a.replace(s,(r,l,c,d)=>hx(String(d))?"`"+(String(c||"").trim()||String(d)).replace(/`/g,"")+" (blocked link)`":r)}function jd(a){let s=0;for(let r=0;r<a.length;r++)s=s*31+a.charCodeAt(r)>>>0;return s%360}function px(a){var d,p,m,_;const s=Array.isArray(a.to)&&a.to.length?` to=[${a.to.join(",")}]`:"",r=(p=(d=a.data)==null?void 0:d.asks)!=null&&p.length?` asks=${a.data.asks.map(x=>`${x.id}:"${x.text}"`).join("; ")}`:"",l=(_=(m=a.data)==null?void 0:m.answers)!=null&&_.length?` answers=[${a.data.answers.join(",")}]`:"",c=a.reply_to?` reply_to=${a.reply_to}`:"";return`#${a.seq} [${a.sender}] (${a.status})${s}${c}${r}${l}
98
+ ${a.title?`title: ${a.title}
99
+ `:""}${String(a.body||"").trim()}`}function Jf(a,s){const r=ep,c=[...a].sort((_,x)=>(_.seq||0)-(x.seq||0)).map(px),{kept:d,report:p}=Gy(c,Vy,r),m=[`TRANSCRIPT WINDOW: ${p.replayed_messages} of ${p.total_messages} message(s), ~${p.replayed_tokens} tokens (the newest whole messages up to ${r} tokens).`];return p.dropped_messages>0&&m.push(`#TRUNCATION: the ${p.dropped_messages} oldest message(s) (~${p.dropped_tokens} tokens) were dropped by the history window (the newest whole messages up to ${r} tokens; abstractcontinuum team_model); this transcript starts mid-conversation.`),{text:`${m.join(`
100
+ `)}
101
+
102
+ ${d.join(`
103
+
104
+ `)}`,report:p}}function Yf(a){const s=r=>`message${r===1?"":"s"}`;return a.dropped_messages<=0?`${a.replayed_messages} ${s(a.replayed_messages)}`:`${a.replayed_messages} of ${a.total_messages} ${s(a.total_messages)} (${a.dropped_messages} oldest dropped by the ${a.max_tokens.toLocaleString("en-US")}-token history window)`}function _x(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 gx(a,s){const r=Array.from(String(a??"")),l=(s??[]).filter(p=>Array.isArray(p)&&p.length>=2&&Number.isFinite(p[0])&&Number.isFinite(p[1])&&p[0]>=0&&p[1]>0).sort((p,m)=>p[0]-m[0]),c=[];let d=0;for(const[p,m]of l){if(p>=r.length)break;const _=Math.max(p,d),x=Math.min(p+m,r.length);x<=_||(_>d&&c.push({text:r.slice(d,_).join(""),hit:!1}),c.push({text:r.slice(_,x).join(""),hit:!0}),d=x)}return d<r.length&&c.push({text:r.slice(d).join(""),hit:!1}),!c.length&&r.length&&c.push({text:r.join(""),hit:!1}),c}const ec=[{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"}],vx=new Set(["image/png","image/jpeg","image/gif","image/webp"]);function Lr(a,s){const r=a.toLowerCase().split(".").pop()||"",l=String(s||"").toLowerCase();if(r==="md"||r==="markdown"||l==="text/markdown")return"md";if(vx.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 yx({url:a,name:s}){const[r,l]=Wt.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 xx({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(Ya,{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:Oy(a.text||"").map((l,c)=>l.kind==="mermaid"?e.jsx(Wy,{text:l.text},c):e.jsx(ls,{className:"md_doc",text:Pl(l.text)},c))}):a.mode==="text"?e.jsx("pre",{className:"team_fileview_text",children:a.text||""}):a.mode==="image"&&a.url?e.jsx(yx,{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 bx=Wt.memo(ls),wx=["id","channel","seq","sender","kind","status","urgency","critical","downgraded","to","title","body","data","reply_to","created_at"];function Xf(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 np{constructor(s){this.value=s}}function Zf(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 d=c[1]+(c[2]||""),m=parseInt(c[3],10)+1;let _;if(m<=-4||m>16){const x=d.length>1?`${d[0]}.${d.slice(1)}`:d[0],b=m-1,y=(b<0?"-":"+")+String(Math.abs(b)).padStart(2,"0");_=`${x}e${y}`}else m<=0?_="0."+"0".repeat(-m)+d:m>=d.length?_=d+"0".repeat(m-d.length)+".0":_=d.slice(0,m)+"."+d.slice(m);return(s?"-":"")+_}function ud(a){if(a==null)return"null";if(typeof a=="boolean")return a?"true":"false";if(a instanceof np){if(!Number.isFinite(a.value))throw new Error("canonical_json: non-finite number");return Zf(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):Zf(a)}if(typeof a=="string")return Xf(a);if(Array.isArray(a))return"["+a.map(ud).join(",")+"]";if(typeof a=="object")return"{"+Object.keys(a).sort().map(r=>Xf(r)+":"+ud(a[r])).join(",")+"}";throw new Error(`canonical_json: unsupported type ${typeof a}`)}async function jx(a){return Nh(a)}async function kx(a,s,r){const l={};for(const c of wx)c!=="channel"&&(l[c]=s[c]??null);return l.channel=r,typeof l.created_at=="number"&&(l.created_at=new np(l.created_at)),await jx(a+`
105
+ `+ud(l))}async function Sx(a){const s=a.channel;let r="",l=0,c=0,d=null,p="";for(const _ of a.turns){if(_.hash===null||_.hash===void 0){l>0&&d===null&&(d=_.seq),c+=1,r="";continue}const x=await kx(r,_,s);x!==_.hash&&d===null&&(d=_.seq),r=_.hash,p=x,l+=1}const m=d===null&&String(a.head||"")!==p;return{ok:d===null&&!m,broken_at:d,head_mismatch:m,computed_head:p,hashed:l,legacy:c}}const Nx=5e3,Cx=6,fa=200,$x=50,tc=380,eh=240,th=2,Ex=12,Al=8,nh=16*1024*1024,Tx=new Set(["image/png","image/jpeg","image/gif","image/webp"]),Ol=256*1024;function Ax(){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 sh(){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 nc(a){return a.length<=Ol?a:a.slice(0,Ol)+`
106
+
107
+ ---
108
+ #TRUNCATION: preview clamped at ${Vn(Ol)} of ${Vn(a.length)} — download the file for the full content.`}function Vu(a,s){try{return JSON.stringify(a)===JSON.stringify(s)}catch{return!1}}function Gu(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],d=s[l];if(!d||c.size!==d.size)return!1;for(const p of c)if(!d.has(p))return!1}return!0}function Vn(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 sp="abstractcontinuum_team_drafts_v1";function Rx(){try{const a=window.localStorage.getItem(sp),s=a?JSON.parse(a):{};return s&&typeof s=="object"?s:{}}catch{return{}}}function Rl(a){try{window.localStorage.setItem(sp,JSON.stringify(a))}catch{}}const sc="agora/0.4";function Ll(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 Ml(a){if(!a)return"";try{return new Date(a*1e3).toLocaleString()}catch{return""}}function ah(a){return{color:`hsl(${jd(a)}, 60%, 55%)`}}function Ga(a){const s=jd(a),r=s>=40&&s<=190?36:45;return{background:`hsl(${s}, 55%, ${r}%)`,color:"#fff"}}const ji=[{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."}],Lx=[{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."}],rh={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(ji.map(a=>[a.id,`${a.help} Every standing vote counts.`]))};function zl(a){const s=ji.find(r=>r.id===a);return s?s.label:a==="general"?"General":a.charAt(0).toUpperCase()+a.slice(1)}function Mx(a){if(!a)return"";try{return new Date(a*1e3).toLocaleDateString(void 0,{weekday:"long",month:"short",day:"numeric"})}catch{return""}}function zx(a){var Tt,bs,an,gn,Ds,la;const s=a.gateway,r=!!a.gateway_connected,l=f.useMemo(()=>new wd,[]),c=f.useMemo(()=>{if(a.advisor)return a.advisor;if(!r||!s)return;const u=a.advisor_agent;return async(v,S)=>{const k=[...S.map(se=>({role:se.role,content:se.content})),{role:"user",content:v}],R=await s.backlog_advisor({messages:k,agent:u||null});return String((R==null?void 0:R.reply)||"").trim()||"(the model returned an empty reply)"}},[a.advisor,s,r,a.advisor_agent]),d=!!c,[p,m]=f.useState(""),[_,x]=f.useState(()=>ld()),[b,y]=f.useState(""),C=f.useRef(_);C.current=_;const A=f.useRef({});f.useEffect(()=>{if(!r||!s){m("");return}let u=!0;return(async()=>{try{const v=await pd("abstractcontinuum_team_voice");u&&m(v)}catch{u&&m("")}})(),typeof s.capability_defaults=="function"&&Promise.resolve().then(()=>s.capability_defaults()).then(v=>{u&&(A.current=Zh(v))}).catch(()=>{u&&(A.current={})}),()=>{u=!1}},[s,r]),f.useEffect(()=>{const u=()=>x(ld());return window.addEventListener(od,u),window.addEventListener("storage",u),()=>{window.removeEventListener(od,u),window.removeEventListener("storage",u)}},[]);const E=f.useMemo(()=>{const u=String(p||"").trim();if(!(!r||!s||!u))return v=>{const S=s.voice_stream_transport(u,{text:v,...A.current,...Xh(C.current)});return og({path:S.path,body:S.body,headers:S.headers})}},[s,r,p]),$=fh({tts_stream:E,on_error:y});f.useEffect(()=>{if(!b)return;Q(b);const u=setTimeout(()=>y(""),6e3);return()=>clearTimeout(u)},[b]);const[L,q]=f.useState(null),O=f.useRef(null);f.useEffect(()=>{O.current=L},[L]);const[D,K]=f.useState(""),[T,te]=f.useState(null),[ue,re]=f.useState([]),[Te,je]=f.useState({}),[Ce,xe]=f.useState({}),[J,ne]=f.useState({}),[ve,W]=f.useState({}),[Y,z]=f.useState(null),[V,U]=f.useState(""),w=f.useRef(0),N=f.useRef(!1),Z=f.useRef(!1);async function pe(){if(!N.current&&!(Date.now()-w.current<3e4)){w.current=Date.now();try{const u=await l.desk();z(v=>v==="loading"?v:u),u.rows.length&&!Z.current&&Qn(v=>v!==""?v:(Z.current=!0,"desk"))}catch(u){((u==null?void 0:u.status)===403||(u==null?void 0:u.status)===404)&&(N.current=!0)}}}async function oe(){z("loading"),U("");try{const u=await l.desk();z(u),w.current=Date.now(),N.current=!1}catch(u){z(null),U((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[I,be]=f.useState(""),[Re,qe]=f.useState("channels"),[Oe,ut]=f.useState(!1),[he,Fe]=f.useState([]),[Le,Ge]=f.useState("all"),de=f.useRef(null),[H,fe]=f.useState(null),we=f.useRef(""),[X,Q]=f.useState(""),[_e,Ie]=f.useState(!1),[ot,ce]=f.useState({}),[ke,Be]=f.useState({}),[$e,ze]=f.useState({}),ee=f.useRef(new Set),M=f.useRef(0),[ie,Ke]=f.useState(""),[et,rt]=f.useState(""),[mt,ft]=f.useState([]),[Ee,nt]=f.useState(!1),ht=f.useRef(null),[zt,wt]=f.useState(!1),tn=f.useRef(null);f.useEffect(()=>{const u=tn.current;u&&(u.style.height="auto",u.style.height=`${Math.min(u.scrollHeight+2,160)}px`)},[ie,I]);const[ge,Se]=f.useState("fyi"),[Ye,vt]=f.useState(""),[_t,jt]=f.useState(""),[it,Cn]=f.useState(null),[Cs,Xa]=f.useState({}),[$s,os]=f.useState(""),nn=f.useRef(Rx()),Vs=f.useRef(""),[Gs,Es]=f.useState(!1),[$i,Ts]=f.useState(!1),[Or,dt]=f.useState(""),[Ht,Za]=f.useState(null),[Mt,er]=f.useState(null),[Ei,Wl]=f.useState({});function Ti(u,v){v.length&&Wl(S=>{const k={...S},R=new Set(k[u]||[]);for(const se of v)R.add(se);return k[u]=R,k})}function It(u,v){const S=new Set(v.map(k=>String(k.agent_id||"")).filter(Boolean));S.size&&Wl(k=>{const R=k[u];if(!R||![...R].some(ye=>S.has(ye)))return k;const se=new Set([...R].filter(ye=>!S.has(ye))),F={...k};return se.size?F[u]=se:delete F[u],F})}const Dr=f.useRef(0),[Fr,tr]=f.useState(""),[Ks,Hl]=f.useState(null),[qr,cs]=f.useState(""),[hn,Br]=f.useState(!1),[pn,Vl]=f.useState(""),[pa,Gl]=f.useState([]);function _a(){l.delegations().then(u=>{Hl(u),cs("")}).catch(u=>{Hl([]);const v=String((u==null?void 0:u.message)||u);cs((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 Ur(){if(!(!pn||!pa.length||hn)){Br(!0),cs("");try{await l.set_delegation(pn,pa),Vl(""),Gl([]),_a()}catch(u){cs(String((u==null?void 0:u.message)||u||"delegation failed"))}finally{Br(!1)}}}async function nr(u){if(!hn){Br(!0),cs("");try{await l.revoke_delegation(u),_a()}catch(v){cs(String((v==null?void 0:v.message)||v||"resign failed"))}finally{Br(!1)}}}const[bn,Qs]=f.useState(null),[Wr,As]=f.useState(null),[Vt,Xt]=f.useState(""),[Rs,ga]=f.useState(null),[Ls,kt]=f.useState([]),[Gt,us]=f.useState(""),[Hr,zn]=f.useState(""),[Vr,Ai]=f.useState(""),[sr,ar]=f.useState(!1),[ds,Kn]=f.useState(""),[$n,Ms]=f.useState({open:!1,name:"",is_private:!1}),[on,_n]=f.useState(!1),[dc,va]=f.useState({}),[Et,Qn]=f.useState(""),[Pn,ya]=f.useState(null),[Gr,Kl]=f.useState(""),[wn,xa]=f.useState("channel"),[ms,rr]=f.useState(""),[Ri,ir]=f.useState(null),[Kr,lr]=f.useState(""),[or,Li]=f.useState(""),[In,fs]=f.useState(""),[Js,Qr]=f.useState(null),[ba,wa]=f.useState(""),[Ys,sn]=f.useState(""),[ja,Kt]=f.useState(null),[zs,Mi]=f.useState([]),[Jr,cr]=f.useState(""),[Xs,ka]=f.useState(!1),[zi,Pi]=f.useState(""),[Ql,Jl]=f.useState(""),Yr=f.useRef(null),Yl=f.useRef(0),Ii=f.useRef(!1),Xl=f.useRef(0),[Oi,Di]=f.useState(!1),Fi=f.useRef(""),On=f.useRef([]),Ps=f.useRef([]),Is=f.useRef(null),qi=f.useRef(!1),ur=f.useRef(null);Fi.current=I,On.current=ue,Ps.current=he,f.useEffect(()=>{for(const u of he){const v=mr.current[u.id];v!==void 0&&u.ratings&&Number(u.ratings.mine||0)===v&&delete mr.current[u.id]}},[he]);const Bi=f.useRef(!1);async function mc(u){var v;try{const S=await l.inbox(),k=Yy(S),R=Xy(S);xe(Ve=>Gu(Ve,R)?Ve:R);const se=Zy(S,((v=O.current)==null?void 0:v.seat)||"");ne(Ve=>Gu(Ve,se)?Ve:se);const F=ex(S);W(Ve=>Gu(Ve,F)?Ve:F),pe();const ye=u.slice(0,Ex),Pe=await Promise.allSettled(ye.map(Ve=>l.digest(Ve.name))),Ue={};for(const Ve of u)Ue[Ve.name]={unread:k[Ve.name]||0,open_questions:0};Pe.forEach((Ve,$t)=>{var jn;const Pt=ye[$t].name;if(Ve.status==="fulfilled"){const xt=(jn=Ve.value)==null?void 0:jn.counts;Ue[Pt]={...Ue[Pt],open_questions:Number((xt==null?void 0:xt.open_questions)||0)}}}),je(Ve=>Vu(Ve,Ue)?Ve:Ue)}catch{}}async function Sa(u){if(qi.current){ur.current=u;return}qi.current=!0;let v=u;try{for(;v;)ur.current=null,await mc(v),v=ur.current}finally{qi.current=!1}}async function Na(){const v=[...await l.channels()];return v.sort((S,k)=>(k.last_at||0)-(S.last_at||0)),re(S=>Vu(S,v)?S:v),On.current=v,v}async function hs(){try{const[u,v]=await Promise.all([l.meta(),l.channels()]);q({seat:u.seat,seat_key_present:u.seat_key_present}),K(String(u.hub_url||"")),l.healthz().then(R=>te(R)).catch(()=>te(null)),l.presence().then(R=>{const se=[...new Set(R.map(F=>String(F.agent_id||"")).filter(F=>F&&F!==u.seat))].sort();kt(se)}).catch(()=>kt([]));const S=[...v];S.sort((R,se)=>(se.last_at||0)-(R.last_at||0)),re(S);const k=S.filter(R=>!R.name.startsWith("dm:"));!I&&k.length&&be(k[0].name),Q(""),Sa(S)}catch(u){Q(String((u==null?void 0:u.message)||u||"Hub unreachable"))}}async function Zs(u,v){var k,R,se;if(!u)return;const S=M.current;v!=null&&v.background||Ie(!0);try{const F=Ps.current.length&&Ps.current[Ps.current.length-1].seq||0,ye=((k=On.current.find(lt=>lt.name===u))==null?void 0:k.last_seq)||0;let Pe=ye,Ue=null;if(!(v!=null&&v.background))if(ye>0)Ue=Na().catch(()=>null);else try{const lt=await Na();if(S!==M.current)return;Pe=((R=lt.find(Rt=>Rt.name===u))==null?void 0:R.last_seq)||0}catch{}const Ve=Math.max(0,Pe-fa),$t=v!=null&&v.background&&F>0?Math.max(0,F-$x):Ve,Pt=await l.messages(u,{since:$t,limit:fa});if(S!==M.current)return;const jn=new Set(Ps.current.map(lt=>lt.id)),xt=Pt.some(lt=>!jn.has(lt.id));if(v!=null&&v.background&&!xt&&F>0){const lt=Date.now();if(lt-Xl.current>1e4){Xl.current=lt;try{const Rt=await Na();if(S!==M.current)return;const gt=((se=Rt.find(We=>We.name===u))==null?void 0:se.last_seq)||0;if(gt>0&&gt<F){const We=Math.max(0,gt-fa),St=await l.messages(u,{since:We,limit:fa});if(S!==M.current)return;St.sort((Dt,Bt)=>(Dt.seq||0)-(Bt.seq||0)),Fe(St),Q("");return}}catch{}}}Pt.sort((lt,Rt)=>(lt.seq||0)-(Rt.seq||0)),Fe(lt=>{if(v!=null&&v.background&&lt.length){if(!Pt.length)return lt;const Rt=new Set(lt.map(Zt=>Zt.id)),gt=Pt.filter(Zt=>!Rt.has(Zt.id)),We=new Map(Pt.map(Zt=>[Zt.id,Zt]));let St=0;const Dt=lt.map(Zt=>{const Lt=We.get(Zt.id);if(!Lt)return Zt;const Jt=JSON.stringify(Lt.ratings??null)!==JSON.stringify(Zt.ratings??null)||(Lt.has_resolved_reply??null)!==(Zt.has_resolved_reply??null)||JSON.stringify(Lt.pending_asks??null)!==JSON.stringify(Zt.pending_asks??null)||!!Lt.retracted!=!!Zt.retracted;return Jt&&St++,Jt?Lt:Zt});if(!gt.length&&!St)return lt;const Bt=[...St?Dt:lt,...gt];return Bt.length>fa*2?Bt.slice(Bt.length-fa*2):Bt}return Pt}),Q(""),!(v!=null&&v.background)&&Ue&&(async()=>{var lt;try{const Rt=await Ue;if(S!==M.current||!Rt)return;const gt=((lt=Rt.find(We=>We.name===u))==null?void 0:lt.last_seq)||0;if(gt>0&&gt!==ye){const We=Math.max(0,gt-fa),St=await l.messages(u,{since:We,limit:fa});if(S!==M.current)return;St.sort((Dt,Bt)=>(Dt.seq||0)-(Bt.seq||0)),Fe(Dt=>Vu(Dt,St)?Dt:St)}}catch{}})()}catch(F){if(S!==M.current)return;Q(String((F==null?void 0:F.message)||F||"Failed to load messages"))}finally{!(v!=null&&v.background)&&S===M.current&&Ie(!1)}}f.useEffect(()=>{hs()},[]),f.useEffect(()=>{let u=null,v=!1,S=0,k=0;const R=()=>{if(!v){try{u=new WebSocket(l.ws_url())}catch{Di(!1),S+=1,setTimeout(R,Math.min(15e3,1e3*Math.max(1,S)));return}u.onopen=()=>{Di(!0),k=Date.now(),(!On.current.length||!O.current)&&hs()},u.onmessage=se=>{var F;try{const ye=JSON.parse(String(se.data||"{}"));if((ye==null?void 0:ye.type)!=="envelope")return;const Pe=String(((F=ye.envelope)==null?void 0:F.channel)||"");Pe&&Pe===Fi.current&&Zs(Pe,{background:!0}),Pe&&!On.current.some(Ue=>Ue.name===Pe)&&Na(),Is.current&&clearTimeout(Is.current),Is.current=setTimeout(()=>void Sa(On.current),800)}catch{}},u.onclose=()=>{Di(!1),v||(k&&Date.now()-k>=15e3?S=0:S+=1,k=0,setTimeout(R,Math.min(15e3,1e3*Math.max(1,S))))},u.onerror=()=>{try{u==null||u.close()}catch{}}}};return R(),()=>{v=!0,Is.current&&clearTimeout(Is.current);try{u==null||u.close()}catch{}}},[]),f.useEffect(()=>{M.current+=1,ce({}),Be({}),ze({}),ee.current=new Set,Za(null),er(null);try{$.stop_tts()}catch{}Dr.current=0,mr.current={},Ct("recency"),Ta(null),yr(""),Qr(null),wa(""),sn(""),Kt(null),Qs(null),As(null),ga(null),Xt(""),zn(""),va({}),Mi([]),Pi(""),Jl(""),ka(!1),cr(""),Fe([]),Ge(de.current||"all"),de.current=null,Cn(null),Xa({}),os(""),ft([]),Vs.current&&Vs.current!==I&&(ie||et?nn.current[Vs.current]={text:ie,title:et,kind:ge}:delete nn.current[Vs.current],Rl(nn.current));const u=nn.current[I];if(Ke((u==null?void 0:u.text)||""),rt((u==null?void 0:u.title)||""),Se((u==null?void 0:u.kind)||"fyi"),Vs.current=I,Bi.current=!0,Zs(I),!I)return;Et==="files"&&Ki(),Et==="members"&&dr();const v=setInterval(()=>{Yl.current+=1,Ii.current||(Ii.current=!0,Zs(I,{background:!0}).finally(()=>{Ii.current=!1})),Yl.current%Cx===0&&(Na().then(S=>Sa(S)).catch(()=>Sa(On.current)),l.healthz().then(te).catch(()=>{}),l.meta().then(S=>q(S)).catch(()=>{}))},Nx);return()=>clearInterval(v)},[I]);const Zl=f.useRef({text:"",title:"",kind:"fyi",selected:""});Zl.current={text:ie,title:et,kind:ge,selected:I},f.useEffect(()=>{if(!I)return;const u=setTimeout(()=>{ie||et?nn.current[I]={text:ie,title:et,kind:ge}:delete nn.current[I],Rl(nn.current)},300);return()=>clearTimeout(u)},[ie,et,ge,I]),f.useEffect(()=>{const u=()=>{const v=Zl.current;v.selected&&(v.text||v.title?nn.current[v.selected]={text:v.text,title:v.title,kind:v.kind}:delete nn.current[v.selected],Rl(nn.current))};return window.addEventListener("pagehide",u),window.addEventListener("beforeunload",u),()=>{window.removeEventListener("pagehide",u),window.removeEventListener("beforeunload",u),u()}},[]),f.useEffect(()=>{const u=Yr.current;if(!u||!he.length)return;if(Bi.current){Bi.current=!1,u.scrollTop=u.scrollHeight;return}u.scrollHeight-u.scrollTop-u.clientHeight<240&&(u.scrollTop=u.scrollHeight)},[he]),f.useEffect(()=>{if(Le!=="unread"||!I){fe(null);return}const u=Ce[I];fe(new Set(u||[])),we.current=""},[Le,I]),f.useEffect(()=>{if(Le!=="unread"||!I||!H||!H.size)return;const u=Math.min(...H),v=he.length&&he[0].seq||0;if(!u||!v||v<=u)return;const S=`${I}:${u}`;if(we.current===S)return;we.current=S;const k=M.current;l.messages(I,{since:Math.max(0,u-1),limit:fa}).then(R=>{k!==M.current||!R.length||Fe(se=>{const F=new Set(se.map(Pe=>Pe.id)),ye=R.filter(Pe=>!F.has(Pe.id));return ye.length?[...se,...ye].sort((Pe,Ue)=>(Pe.seq||0)-(Ue.seq||0)):se})}).catch(()=>{k===M.current&&(dt("Couldn't load the older unread messages — the Unread list may be incomplete. Re-select Unread to retry."),setTimeout(()=>dt(""),6e3))})},[Le,I,H,he]);function eo(u){ee.current.has(u.id)||(ee.current.add(u.id),l.read_message(u.channel,u.id).catch(()=>{}),l.ack(u.channel,u.seq).catch(()=>{}),xe(v=>{const S=v[u.channel];if(!S||!S.has(u.seq))return v;const k=new Set(S);return k.delete(u.seq),{...v,[u.channel]:k}}),Is.current&&clearTimeout(Is.current),Is.current=setTimeout(()=>void Sa(On.current),500),u.critical&&(dt(`Read recorded for critical #${u.seq}.`),setTimeout(()=>dt(""),2500)))}function to(u){const v=!ot[u.id];ce(S=>({...S,[u.id]:v})),v&&eo(u)}function fc(u){const v=window.getSelection();if(v&&!v.isCollapsed)return;const S=String(u.body||""),k=u.status==="reply"?eh:tc;S.length>k?to(u):eo(u)}async function hc(){if(!I||Ht==="running")return;const u=M.current;Za("running");try{const v=await l.ledger(I),S=await Sx(v);if(u!==M.current)return;Za(S)}catch(v){if(u!==M.current)return;Za({error:String((v==null?void 0:v.message)||v||"verification failed")})}}function dr(){{const u=M.current;er("loading"),Qs(null),tr(""),As(null),l.channel_info(I).then(v=>{u===M.current&&er(v)}).catch(v=>{u===M.current&&er({error:String((v==null?void 0:v.message)||v||"info failed")})}),l.members(I).then(v=>{u===M.current&&(Qs(v),tr(""),It(I,v))}).catch(v=>{u===M.current&&(Qs([]),tr(String((v==null?void 0:v.message)||v||"members unavailable")))}),l.list_blocks().then(v=>{u===M.current&&As(v)}).catch(()=>{u===M.current&&As([])}),l.retired_agents().then(v=>{u===M.current&&ga(v)}).catch(()=>{u===M.current&&ga([])})}}function ns(u){const v=Et===u?"":u;if(Qn(v),v==="files"&&Ki(),v==="members"){let S=0;for(const k of Ps.current)String(k.sender||"")==="hub"&&(k.seq||0)>S&&(S=k.seq||0);Dr.current=S,dr(),_a()}v==="leaderboard"&&Ui(wn),v==="desk"&&oe()}function Ui(u){const v=M.current;ya(null),Kl(""),rr(""),ir(null),fs(""),(u==="hub"?l.reputation_hub():l.reputation(I)).then(k=>{v===M.current&&ya(k)}).catch(k=>{if(v!==M.current)return;const R=Number((k==null?void 0:k.status)||0);Kl(R===404||R===403?"Reputation ships with the next hub update — relaunch the hub (agora ≥ 0.12.7) and reopen this drawer.":String((k==null?void 0:k.message)||k||"failed to load leaderboard"))})}function Wi(u){const v=ms===u?"":u;if(rr(v),ir(null),fs(""),!v||wn==="hub")return;const S=M.current;l.reputation_votes(I,v).then(k=>{S===M.current&&ir(k)}).catch(k=>{S===M.current&&(ir(null),fs(`votes list failed: ${String((k==null?void 0:k.message)||k||"fetch failed")}`))})}const[Xr,Hi]=f.useState(""),[ea,Zr]=f.useState("");f.useEffect(()=>{if(!ea)return;const u=setTimeout(()=>Zr(""),6e3);return()=>clearTimeout(u)},[ea]);async function Ca(u){if(ea!==u.id){Zr(u.id);return}Zr("");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 ${(L==null?void 0:L.seat)||"operator"} — closing without a substantive answer.`,status:"reply",reply_to:u.id,to:u.sender?[u.sender]:void 0,...v.length?{answers:v}:{}}),ne(S=>{const k=S[u.channel];if(!(k!=null&&k.has(u.seq)))return S;const R=new Set(k);return R.delete(u.seq),{...S,[u.channel]:R}})}catch(v){Q(String((v==null?void 0:v.message)||v||"decline failed"))}}const mr=f.useRef({});function Vi(u){const v=u.ratings;return v?_x(v,mr.current[u.id]):null}async function no(u,v){var R,se;const S=(L==null?void 0:L.seat)||"";if(!u||!S||Xr)return;const k=Ps.current.find(F=>F.id===u)||((R=Aa.current)==null?void 0:R.find(F=>F.id===u));if(k){Hi(`${u}:${v}`),fs("");try{const F=((se=Vi(k))==null?void 0:se.mine)??0;F===v?await l.unrate_message(I,u):await l.rate_message(I,u,v),mr.current[u]=F===v?0:v}catch(F){fs(String((F==null?void 0:F.message)||F||"rating failed"))}finally{Hi("")}}}async function Gi(u,v,S){if(!or){Li(`${u}:${v}:${S}`),fs("");try{await l.rate(I,u,v,S,Kr.trim()),lr("");const k=M.current,[R,se]=await Promise.all([l.reputation(I),l.reputation_votes(I,u)]);k===M.current&&(ya(R),ir(se))}catch(k){fs(String((k==null?void 0:k.message)||k||"vote failed"))}finally{Li("")}}}function Ki(){const u=M.current;Qr(null),wa(""),sn(""),l.fs_list(I).then(v=>{u===M.current&&Qr(v)}).catch(v=>{u===M.current&&wa(String((v==null?void 0:v.message)||v||"failed to list files"))})}async function fr(u){const v=M.current,S=Lr(u.path,"text/markdown"),k=`${u.updated_by||"?"} · ${Ml(u.updated_at)} · v${u.version}`;Kt({name:u.path,mode:S==="image"?"text":S,meta:k,loading:!0});try{const R=await l.fs_read(I,u.path);if(v!==M.current)return;const se=Lr(u.path,R.mime);Kt({name:u.path,mode:se==="image"?"text":se,text:nc(R.content),content_type:R.mime,meta:k,loading:!1})}catch(R){if(v!==M.current)return;Kt({name:u.path,mode:"text",meta:k,error:String((R==null?void 0:R.message)||R||"failed to read file")})}}const Jn=f.useRef(null);function hr(){const u=Jn.current,v=Ps.current;if(!u||!v.length)return;if(u.message_id?v.some(k=>k.id===u.message_id):!1){Jn.current=null,requestAnimationFrame(()=>{const k=document.getElementById(`hubmsg-${u.message_id}`);k==null||k.scrollIntoView({block:"center"}),k==null||k.classList.add("hit"),setTimeout(()=>k==null?void 0:k.classList.remove("hit"),2500)});return}if(u.seq&&Number.isFinite(u.seq)){const k=M.current,R=u.seq;Jn.current={...u,seq:void 0},l.messages(I,{since:Math.max(0,R-3),limit:10}).then(se=>{k!==M.current||!se.length||Fe(F=>{const ye=new Set(F.map(Ue=>Ue.id)),Pe=se.filter(Ue=>!ye.has(Ue.id));return Pe.length?[...F,...Pe].sort((Ue,Ve)=>(Ue.seq||0)-(Ve.seq||0)):F})}).catch(()=>{})}}f.useEffect(()=>{var k;if(!a.focus)return;const{channel:u,message_id:v,seq:S}=a.focus;(k=a.on_focus_consumed)==null||k.call(a),u&&(Jn.current={message_id:v,seq:S},qe("thread"),u===I?hr():be(u))},[a.focus]),f.useEffect(()=>{hr()},[he]),f.useEffect(()=>{if(Et!=="members"||!I)return;let u=0,v="";for(const k of he){if(k.channel&&k.channel!==I||String(k.sender||"")!=="hub")continue;const R=`${String(k.title||"")} ${String(k.body||"")}`;/\b(joined|left|kicked|banned|archived|reopened)\b/i.test(R)&&(k.seq||0)>u&&(u=k.seq||0,v=R)}if(!u||u<=Dr.current)return;const S=M.current;l.members(I).then(k=>{S===M.current&&(Dr.current=u,Qs(k),tr(""),It(I,k))}).catch(()=>{}),/\b(kicked|banned)\b/i.test(v)&&l.list_blocks(I).then(k=>{S===M.current&&As(k)}).catch(()=>{})},[he,Et,I]);const[ei,ti]=f.useState(null),ni=f.useRef(0);f.useEffect(()=>{if(ti(null),ni.current=0,!I)return;const u=M.current;l.fs_list(I).then(v=>{u===M.current&&ti(new Set(v.map(S=>String(S.path||"")).filter(Boolean)))}).catch(()=>{u===M.current&&ti(null)})},[I]),f.useEffect(()=>{const u=he.reduce((S,k)=>{if(k.channel&&k.channel!==I)return S;const R=String(k.title||"");return(R.startsWith("fs:put")||R.startsWith("fs:delete"))&&(k.seq||0)>S?k.seq||0:S},0);if(!u||u<=ni.current)return;const v=M.current;l.fs_list(I).then(S=>{v===M.current&&(ni.current=u,ti(new Set(S.map(k=>String(k.path||"")).filter(Boolean))))}).catch(()=>{})},[he,I]);async function Qi(u){const v=M.current,S=Lr(u,"text/markdown");Kt({name:u,mode:S==="image"?"text":S,loading:!0});try{const k=await l.fs_read(I,u);if(v!==M.current)return;const R=Lr(u,k.mime),se=k.updated_by?`${k.updated_by} · ${Ml(k.updated_at)} · v${k.version??"?"}`:void 0;Kt({name:u,mode:R==="image"?"text":R,text:nc(k.content),content_type:k.mime,meta:se,loading:!1})}catch(k){if(v!==M.current)return;Kt({name:u,mode:"text",error:String((k==null?void 0:k.message)||k||"failed to read file")+" — the file may have been rewritten under another path; check the Files drawer"})}}async function $a(u,v){const S=M.current,k=l.attachment_url(u,v.id),R=Lr(v.filename,v.content_type);if(R==="image"){Kt({name:v.filename,mode:"image",url:k,content_type:v.content_type,size:v.size});return}if(R==="md"||R==="text"){if(v.size>Ol){Kt({name:v.filename,mode:"download",url:k,content_type:v.content_type,size:v.size,error:`too large to preview inline (${Vn(v.size)} > ${Vn(Ol)}) — download to view`});return}Kt({name:v.filename,mode:R,url:k,content_type:v.content_type,size:v.size,loading:!0});try{const se=await fetch(k);if(!se.ok)throw new Error(`fetch failed (${se.status})`);const F=await se.text();if(S!==M.current)return;Kt({name:v.filename,mode:R,url:k,content_type:v.content_type,size:v.size,text:nc(F)})}catch(se){if(S!==M.current)return;Kt({name:v.filename,mode:"download",url:k,content_type:v.content_type,size:v.size,error:String((se==null?void 0:se.message)||se||"failed to load")})}return}Kt({name:v.filename,mode:"download",url:k,content_type:v.content_type,size:v.size})}async function pr(u,v,S="channel"){if(!Gt){us(`${S}:${v}:${u}`),zn("");try{S==="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(I,u):await l.block(I,u,v==="kick"?{seconds:3600,reason:"kicked by the operator (Continuum Team page)"}:{reason:"banned by the operator (Continuum Team page)"}),dt(`${S==="hub"?"hub ":""}${v} → ${u} applied.`),setTimeout(()=>dt(""),3e3);const k=M.current,R=await l.members(I).catch(()=>null);R&&k===M.current&&Qs(R);const se=await l.list_blocks().catch(()=>null);se&&k===M.current&&As(se)}catch(k){zn(String((k==null?void 0:k.message)||k||"moderation refused"))}finally{us("")}}}async function so(u){if(!Gt){us(`retire:${u}`),zn("");try{await l.retire_agent(u,"decommissioned via Continuum Team page"),Xt(""),dt(`${u} retired (decommissioned — not banned).`),setTimeout(()=>dt(""),3500);const v=M.current,S=await l.members(I).catch(()=>null);S&&v===M.current&&Qs(S);const k=await l.retired_agents().catch(()=>null);k&&v===M.current&&ga(k)}catch(v){const S=v==null?void 0:v.status,k=String((v==null?void 0:v.message)||v||"");S===404||/not found|hub_route_not_allowed/i.test(k)?(dt("Agent retire ships with the next hub update — this control is wired and ready for it."),setTimeout(()=>dt(""),6e3)):zn(k||"retire refused")}finally{us("")}}}async function ao(u){if(!Gt){us(`unretire:${u}`),zn("");try{await l.unretire_agent(u),Xt(""),dt(`${u} un-retired — it can rejoin channels explicitly.`),setTimeout(()=>dt(""),3500);const v=await l.retired_agents().catch(()=>null);v&&ga(v)}catch(v){zn(String((v==null?void 0:v.message)||v||"un-retire refused"))}finally{us("")}}}async function pc(u){if(!Gt){us(`delete:${u}`),zn("");try{await l.delete_agent(u),Xt(""),dt(`${u} deleted from the hub — off every roster and board; its id stays reserved.`),setTimeout(()=>dt(""),3500);const v=await l.retired_agents().catch(()=>null);v&&ga(v)}catch(v){const S=String((v==null?void 0:v.message)||v);zn((v==null?void 0:v.status)===404||/not found|allowlist/i.test(S)?"Delete needs the updated hub/console (0.12.41+) — restart the stack to pick it up.":/409|active/i.test(S)?`${u} is still active — retire it first, then delete.`:S||"delete refused")}finally{us("")}}}async function ro(u){if(!on){_n(!0),zn("");try{let v={state:u},S;try{const k=await l.channel_meta(I);k&&typeof k.value=="object"&&k.value&&(v={...k.value,state:u}),typeof(k==null?void 0:k.version)=="number"&&(S=k.version)}catch{}await l.put_channel_meta(I,v,S),dt(u==="closed"?"Channel closed (member posts refused until reopened).":"Channel reopened."),setTimeout(()=>dt(""),3500),dr(),hs()}catch(v){zn(String((v==null?void 0:v.message)||v||"channel state change refused"))}finally{_n(!1)}}}const[_c,io]=f.useState("");async function gc(u){if(!on){_n(!0),Q("");try{await l.leave(u),io(""),I===u&&be(""),await hs(),dt("Direct message removed from your list."),setTimeout(()=>dt(""),3e3)}catch(v){Q(String((v==null?void 0:v.message)||v||"leave refused"))}finally{_n(!1)}}}const[Yn,ta]=f.useState("");async function lo(u){if(!on){_n(!0),Q("");try{await l.archive(u),ta(""),I===u&&be(""),await hs(),dt(`Channel #${u} archived (history preserved).`),setTimeout(()=>dt(""),3500)}catch(v){const S=String((v==null?void 0:v.message)||v||"");(v==null?void 0:v.status)===404||/not found|hub_route_not_allowed/i.test(S)?(ta(""),dt("Channel archive ships with the next hub update — this control is wired and ready for it."),setTimeout(()=>dt(""),6e3)):Q(S||"archive refused")}finally{_n(!1)}}}async function Ji(){const u=$n.name.trim();if(!(!u||on)){_n(!0),Q("");try{await l.create_channel(u,$n.is_private),Ms({open:!1,name:"",is_private:!1}),await hs(),be(u),dt(`Channel #${u} created.`),setTimeout(()=>dt(""),3e3)}catch(v){Q(String((v==null?void 0:v.message)||v||"channel create refused"))}finally{_n(!1)}}}async function Yi(u,v){if(!c)throw new Error("AI advisor is not available");return c(u,v)}async function oo(u){if(!d)return;const v=u.root.id,S=M.current,k=u.replies.length+1;va(R=>{var se;return{...R,[v]:{busy:!0,text:((se=R[v])==null?void 0:se.text)||"",error:"",count:k}}});try{const R=Jf([u.root,...u.replies]),se=`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.
109
+
110
+ THREAD TRANSCRIPT:
111
+ ${R.text}`,F=await Yi(se,[]);if(S!==M.current)return;const ye=Yf(R.report);va(Pe=>({...Pe,[v]:{busy:!1,text:F,error:"",count:k,window:ye}}))}catch(R){if(S!==M.current)return;va(se=>({...se,[v]:{busy:!1,text:"",error:String((R==null?void 0:R.message)||R||"summary failed"),count:k}}))}}async function si(u){const v=u.trim();if(!v||Xs||!d)return;const S=M.current;Qn("assistant"),ka(!0),Pi(""),Mi(k=>[...k,{role:"user",content:v}]);try{const k=Jf(he);Jl(Yf(k.report));const R=`You are the operator's analyst for the agora hub channel #${I}. 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.
112
+
113
+ CHANNEL TRANSCRIPT (window):
114
+ ${k.text}
115
+
116
+ QUESTION: ${v}`,se=await Yi(R,zs);if(S!==M.current)return;Mi(F=>[...F,{role:"assistant",content:se}])}catch(k){if(S!==M.current)return;Pi(String((k==null?void 0:k.message)||k||"assistant failed"))}finally{S===M.current&&ka(!1)}}const[ai,co]=f.useState(""),[ps,ri]=f.useState("");async function _r(u){if(!Gs){Es(!0),Q("");try{await l.retract_message(I,u.id),ri(""),dt(`#${u.seq} retracted — readers see a tombstone, the words are gone from every agent-facing read.`),setTimeout(()=>dt(""),4e3),await Zs(I,{background:!0})}catch(v){const S=String((v==null?void 0:v.message)||v||"retract failed");Q(/404|not found/i.test(S)?"Retraction ships with the hub's next bounce (0.12.16) — the running hub predates the verb. Nothing was changed.":S)}finally{Es(!1)}}}async function Xi(u){if(!Gs){Es(!0),Q("");try{const v=Hf(I,yt);await l.post_message(I,{body:"Resolved.",status:"resolved",to:v?[v]:void 0,reply_to:u.id}),co(""),dt(`Marked #${u.seq} resolved.`),setTimeout(()=>dt(""),3e3),await Zs(I,{background:!0})}catch(v){Q(String((v==null?void 0:v.message)||v||"Resolve failed"))}finally{Es(!1)}}}async function Zi(u){if(!u||!u.length||Ee)return;const v=Array.from(u);if(mt.length+v.length>Al){Q(`At most ${Al} attachments per message.`);return}const S=v.find(F=>F.size>nh);if(S){Q(`"${S.name}" is ${Vn(S.size)} — the limit is ${Vn(nh)}.`);return}const k=M.current,R=I;nt(!0),Q("");let se=0;try{for(const F of v){const ye=await l.upload_attachment(R,F);if(k!==M.current||I!==R)return;ft(Pe=>[...Pe,ye]),se+=1}}catch(F){const ye=F==null?void 0:F.status,Pe=String((F==null?void 0:F.message)||F||"");if(ye===404||/not found|hub_route_not_allowed/i.test(Pe))dt("Attachments ship with the next hub update — the composer control is wired and ready for it."),setTimeout(()=>dt(""),6e3);else{const Ue=v.length>1?` (${se} of ${v.length} attached before this)`:"";Q(`${Pe||"attachment upload failed"}${Ue}`)}}finally{nt(!1),ht.current&&(ht.current.value="")}}function ii(u){var S;Cn(u);const v=((S=u.data)==null?void 0:S.asks)||[];Xa(v.length===1?{[v[0].id]:!0}:{}),os(""),Se("fyi")}function na(){Cn(null),Xa({}),os("")}async function el(u){const{title:v,members:S}=Uu(u);if(!S.length){Q("/group: no @mentions found — usage: /group fix the voice outage @gateway @core");return}const k=v||`focused work with ${S.join(", ")}`;await nl({title:k,members:S})}async function tl(u,v,S){const k=[],R=[];for(const se of S)try{const F=await fetch(l.attachment_url(u,se.id));if(!F.ok)throw new Error(`fetch ${F.status}`);const ye=await F.blob(),Pe=new File([ye],se.filename||"attachment",{type:se.content_type||ye.type||"application/octet-stream"}),Ue=await l.upload_attachment(v,Pe);k.push({id:Ue.id,filename:Ue.filename||se.filename})}catch(F){R.push(`${se.filename||se.id.slice(0,8)} (${String((F==null?void 0:F.message)||F)})`)}return{migrated:k,att_failed:R}}async function gr(u,v,S){try{const k=await l.create_invite(u,v);return await l.send_dm(v,{title:`invite to ${u}${S?`: ${S}`:""}`.slice(0,120),body:`You are invited to '${u}'${S?` — ${S}`:""}. Join with join_channel(channel='${u}', invite_token='${k}'), read the recent messages, and work the topic THERE.`}),null}catch(k){return String((k==null?void 0:k.message)||k)}}async function uo(u){var v,S;if(!(!I||!u)){ar(!0),Kn("");try{const k=Mt&&typeof Mt=="object"&&"meta"in Mt?String(((v=Mt.meta)==null?void 0:v.purpose)||""):"",R=!!((S=On.current.find(F=>F.name===I))!=null&&S.private);let se=null;if(R)se=await gr(I,u,k||void 0);else try{await l.send_dm(u,{title:`join ${I}${k?`: ${k}`:""}`.slice(0,120),body:`You are invited to '${I}' (public)${k?` — ${k}`:""}. Join with join_channel(channel='${I}'), read the recent messages, and work the topic THERE.`})}catch(F){se=String((F==null?void 0:F.message)||F)}se?Kn(se.includes("outside the Team page allowlist")?"Invites need the updated console server — one stack restart activates them; nothing was sent.":`Invite failed: ${se}`):(Kn(`Invited @${u} — join pointer DM'd.`),Ai(""),Ti(I,[u]))}finally{ar(!1),setTimeout(()=>Kn(""),8e3)}}}async function mo(u,v){var S;try{const k=Uu(v).members;if(!k.length)return;const R=await l.members(u),se=new Set(R.map(Ve=>String(Ve.agent_id||""))),F=k.filter(Ve=>!se.has(Ve)&&Ls.includes(Ve)&&Ve!==yt);if(!F.length)return;const ye=!!((S=On.current.find(Ve=>Ve.name===u))!=null&&S.private),Pe=[],Ue=[];for(const Ve of F)if(ye){const $t=await gr(u,Ve);$t?Ue.push(`${Ve} (${$t})`):Pe.push(Ve)}else try{await l.send_dm(Ve,{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.`}),Pe.push(Ve)}catch($t){Ue.push(`${Ve} (${String(($t==null?void 0:$t.message)||$t)})`)}Pe.length&&(Ti(u,Pe),dt(`Posted — @${Pe.join(", @")} ${ye?"invited":"nudged"} (mentioned, not yet member${Pe.length===1?"":"s"}).`)),Ue.length&&Q(Ue.some(Ve=>Ve.includes("outside the Team page allowlist"))?"Posted; inviting mentioned non-members needs the updated console server (one stack restart).":`Posted; invite failed for ${Ue.join("; ")}.`)}catch{}}async function nl(u){var se,F;const{title:v,members:S}=u,k=[...mt],R=I;Es(!0),Q("");try{const ye=new Set(On.current.map(xt=>xt.name)),Pe=Hu(v,ye);let Ue=[],Ve=[],$t=!1;try{const xt=await l.create_group({name:Pe,members:S,purpose:v,opening_post:((se=u.opening_body)==null?void 0:se.trim())||v,private:!0});$t=!0,Ue=Array.isArray(xt==null?void 0:xt.invited)?xt.invited.map(String):S,Ve=Array.isArray(xt==null?void 0:xt.failed)?xt.failed.map(lt=>typeof lt=="string"?lt:`${(lt==null?void 0:lt.agent)||(lt==null?void 0:lt.member)||(lt==null?void 0:lt.peer)||"?"} (${String((lt==null?void 0:lt.error)||(lt==null?void 0:lt.detail)||"failed")})`):[]}catch(xt){const lt=String((xt==null?void 0:xt.message)||xt||"");if(!((xt==null?void 0:xt.status)===404||lt.includes("outside the Team page allowlist")||lt.includes("Not Found")))throw xt;try{await l.create_invite("__group-preflight__",S[0])}catch(gt){if(String((gt==null?void 0:gt.message)||gt).includes("outside the Team page allowlist")){Q("/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(Pe,!0),await l.put_channel_meta(Pe,{purpose:v},0);for(const gt of S)try{const We=await l.create_invite(Pe,gt);await l.send_dm(gt,{title:`invite to ${Pe}: ${v}`.slice(0,120),body:`You are invited to '${Pe}' — focused room: ${v}. Join with join_channel(channel='${Pe}', invite_token='${We}'), read the opening post, and work the topic THERE (not in commons).`}),Ue.push(gt)}catch(We){Ve.push(`${gt} (${String((We==null?void 0:We.message)||We)})`)}}const{migrated:Pt,att_failed:jn}=await tl(R,Pe,k);$t?Pt.length&&await l.post_message(Pe,{body:"Attachments carried over from the create request.",status:"fyi",attachments:Pt}):await l.post_message(Pe,{body:((F=u.opening_body)==null?void 0:F.trim())||v,title:v.slice(0,120),status:"open",attachments:Pt.length?Pt:void 0}),Ti(Pe,Ue),dt(`Room '${Pe}' created — private, ${Ue.length} invited${Ue.length?`: ${Ue.join(", ")}`:""}.`+(Pt.length?` ${Pt.length} attachment(s) carried over.`:"")+(Ve.length?` Invite FAILED for ${Ve.join("; ")}.`:"")),Ve.length&&Q(`Some invites failed — ${Ve.join("; ")}. Mint them again from the room's Members drawer or re-run /group.`),jn.length&&Q(`Attachment carry-over failed for ${jn.join("; ")} — the room and post were created; re-attach in the new room.`),Ke(""),rt(""),jt(""),Se("fyi"),ft([]),delete nn.current[I],Rl(nn.current),await hs(),be(Pe),setTimeout(()=>dt(""),6e3)}catch(ye){Q(`group creation failed: ${String((ye==null?void 0:ye.message)||ye)}`)}finally{Es(!1)}}async function sl(){var se;const u=ie.trim(),v=mt.length>0,S=!it&&!I.startsWith("dm:")&&ge==="group";if(!u&&!v&&!S||Gs||!I)return;if(S){const F=Wu(_t);if(!F.length){Q("Group needs at least one member — write their names like: @entity @assistant");return}const ye=et.trim()||(u?u.split(`
117
+ `)[0].slice(0,80):`focused work with ${F.join(", ")}`);await nl({title:ye,members:F,opening_body:u});return}if(/^\/assistant(?=\s|$)/i.test(u)){if(!d){Q("AI advisor is not configured — connect a gateway or inject an advisor.");return}const F=u.replace(/^\/assistant/i,"").trim();Ke(""),F?si(F):Qn("assistant");return}if(/^\/group(?=\s|$)/i.test(u)){await el(u.replace(/^\/group/i,"").trim());return}if(/^\//.test(u)){Q(`Unknown command "${u.split(/\s/)[0]}" — only /assistant and /group are supported. Remove the leading "/" to post this as a message.`);return}const k=Object.entries(Cs).filter(([,F])=>F).map(([F])=>F),R=I.startsWith("dm:");if(it&&(((se=it.data)==null?void 0:se.asks)||[]).length&&!k.length&&$s!=="void_reply"){os("void_reply");return}if(!it&&!R&&ge==="ask"&&!et.trim()&&$s!=="untitled_open"){os("untitled_open");return}if(!it&&!R&&ge==="dm"&&!Ye.trim()){Q("Pick a recipient for the direct message.");return}Es(!0),Q("");try{if(!it&&!R&&ge==="dm"){const F=Ye.trim(),ye=[...mt],Pe=I;await l.send_dm(F,{body:u||(ye.length?`(${ye.length} attachment${ye.length===1?"":"s"})`:u),title:et.trim()||void 0});const Ue=`dm:${[yt,F].sort().join("--")}`;if(ye.length){const{migrated:Ve,att_failed:$t}=await tl(Pe,Ue,ye);Ve.length&&await l.post_message(Ue,{body:"",to:[F],attachments:Ve}),dt(`DM sent to ${F}${Ve.length?` with ${Ve.length} attachment(s)`:""}.`),$t.length&&Q(`Attachment carry-over failed for ${$t.join("; ")} — the DM text was sent; re-attach inside the conversation.`)}else dt(`DM sent to ${F}.`);await hs(),be(Ue)}else{const F=mt.map(Ue=>({id:Ue.id,filename:Ue.filename})),ye=R?Hf(I,yt):"";R&&!ye&&Q(`#FALLBACK this dm's pair does not include seat '${yt}' — sent unaddressed (no to-me wake; check the hub seat in Settings).`);const Pe={body:u,title:et.trim()||void 0,status:nx({is_reply:!!it,in_dm:R,kind:ge}),to:ye?[ye]:void 0,reply_to:it==null?void 0:it.id,answers:it&&k.length?k:void 0,attachments:F.length?F:void 0};try{await l.post_message(I,Pe)}catch(Ue){if(ye&&/address non-members/i.test(String((Ue==null?void 0:Ue.message)||Ue)))await l.post_message(I,{...Pe,to:void 0}),Q(`#FALLBACK '${ye}' is no longer a member of this dm — message delivered unaddressed (their listener will not get a to-me wake).`);else throw Ue}dt(R?"Sent.":"Posted."),await Zs(I,{background:!0}),!R&&u&&mo(I,u)}Ke(""),rt(""),ft([]),Cn(null),Xa({}),Se("fyi"),vt(""),os(""),delete nn.current[I],Rl(nn.current),setTimeout(()=>dt(""),3e3)}catch(F){Q(String((F==null?void 0:F.message)||F||"Post failed"))}finally{Es(!1)}}async function fo(u){if(!(!I||!u||$i||_e)){Ts(!0);try{await l.ack(I,u),dt(`Marked read to #${u}.`),setTimeout(()=>dt(""),3e3),Sa(On.current)}catch(v){Q(String((v==null?void 0:v.message)||v||"Ack failed"))}finally{Ts(!1)}}}const En=!!(L!=null&&L.seat_key_present)&&!(T!=null&&T.paused),yt=(L==null?void 0:L.seat)||"",Qt=I.startsWith("dm:"),vr=(()=>{if(!Qt)return"";const u=I.slice(3);return yt&&u.startsWith(`${yt}--`)?u.slice(yt.length+2):yt&&u.endsWith(`--${yt}`)?u.slice(0,u.length-yt.length-2):u||I})(),vc=f.useMemo(()=>sx(he),[he]),Os=f.useMemo(()=>({seat:yt,unread_seqs:Ce[I],unread_snapshot_seqs:Le==="unread"&&H||void 0,escalated_seqs:ve[I]}),[yt,Ce,I,Le,H,ve]),Dn=f.useMemo(()=>{if(it)return null;const u=new Set(ue.map(S=>S.name)),v=ie.trimStart();if(/^\/group(\s|$)/i.test(v)){const{title:S,members:k}=Uu(v.replace(/^\/group/i,"").trim()),R=S||(k.length?`focused work with ${k.join(", ")}`:"");return{name:R?Hu(R,u):"group",members:k,source:"slash"}}if(ge==="group"&&!I.startsWith("dm:")){const S=Wu(_t),k=et.trim()||(S.length?`focused work with ${S.join(", ")}`:"");return{name:k?Hu(k,u):"group",members:S,source:"kind"}}return null},[ie,it,ue,ge,_t,et,I]),_s=f.useMemo(()=>Qy(he),[he]),sa=f.useMemo(()=>Wf(_s,Le,Os),[_s,Le,Os]),[Ea,Ct]=f.useState("recency"),[aa,Ta]=f.useState(null),Aa=f.useRef(null);f.useEffect(()=>{Aa.current=aa},[aa]);const[al,yr]=f.useState("");function xr(){const u=M.current;Ta(null),yr(""),l.messages(I,{sort:"votes",limit:50}).then(v=>{u===M.current&&Ta(v)}).catch(v=>{if(u!==M.current)return;const S=String((v==null?void 0:v.message)||v);yr((v==null?void 0:v.status)===400||(v==null?void 0:v.status)===404||/allowlist/i.test(S)?"Top-voted needs the next hub update (this hub predates sort=votes) — Recency still works.":S)})}function li(u){Jn.current={message_id:u.id,seq:u.seq},Ct("recency"),requestAnimationFrame(()=>hr())}const[ra,rl]=f.useState(""),[Ra,yc]=f.useState("all"),[Tn,La]=f.useState(""),[An,Ma]=f.useState(null),[br,Xn]=f.useState(null),Fn=f.useRef(0);function oi(u,v,S){if(!u&&!S)return;const k=++Fn.current;Xn(null),Ma({q:u,report:null,error:"",busy:!0}),l.search({q:u,channel:v==="channel"&&I?[I]:void 0,rated:S||void 0,sort:!u&&S?"votes":void 0}).then(R=>{k===Fn.current&&Ma({q:u,report:R,error:"",busy:!1})}).catch(R=>{if(k!==Fn.current)return;const se=String((R==null?void 0:R.message)||R);Ma({q:u,report:null,busy:!1,error:(R==null?void 0:R.status)===404||/allowlist/i.test(se)?"Search needs the next hub update (this hub predates search-grouped) — everything else still works.":se})})}function ho(u){oi(u.trim(),Ra,Tn)}function il(){Fn.current+=1,Ma(null),Xn(null),La("")}function xc(u,v){const S=(An==null?void 0:An.q)||"";if(!S&&!Tn)return;const k=++Fn.current;Xn({label:u,kind:v,hits:[],total:0,cursor:null,busy:!0,error:""}),l.search({q:S,kind:v,sort:"recent",limit:50,rated:Tn||void 0,channel:Ra==="channel"&&I?[I]:void 0}).then(R=>{if(k!==Fn.current)return;const se=gs(R,v);Xn({label:u,kind:v,hits:se.hits,total:se.total,cursor:R.next_cursor??null,busy:!1,error:""})}).catch(R=>{k===Fn.current&&Xn({label:u,kind:v,hits:[],total:0,cursor:null,busy:!1,error:String((R==null?void 0:R.message)||R)})})}function ll(){const u=br,v=(An==null?void 0:An.q)||"";if(!u||!u.cursor||u.busy||!v&&!Tn)return;const S=Fn.current;Xn({...u,busy:!0}),l.search({q:v,kind:u.kind,sort:"recent",limit:50,cursor:u.cursor,rated:Tn||void 0,channel:Ra==="channel"&&I?[I]:void 0}).then(k=>{if(S!==Fn.current)return;const R=gs(k,u.kind);Xn(se=>se&&se.kind===u.kind?{...se,hits:[...se.hits,...R.hits],cursor:k.next_cursor??null,busy:!1}:se)}).catch(k=>{S===Fn.current&&Xn(R=>R&&R.kind===u.kind?{...R,busy:!1,error:String((k==null?void 0:k.message)||k)}:R)})}function gs(u,v){const S=ec.find(R=>R.kind===v),k=S?u[S.id]:void 0;return k?{hits:k.hits||[],total:k.total||0}:{hits:[],total:0}}function po(u){const v=String(u.channel||"");v&&(Jn.current={message_id:u.kind==="message"?u.ref:void 0,seq:u.seq??void 0},il(),Ct("recency"),v===I?hr():be(v))}async function za(u){const v=String(u.channel||""),S=String(u.ref||"");if(!v||!S)return;const k=Lr(S,"text/markdown");Kt({name:S,mode:k==="image"?"text":k,meta:`#${v}`,loading:!0});try{const R=await l.fs_read(v,S),se=Lr(S,R.mime);Kt({name:S,mode:se==="image"?"text":se,text:nc(R.content),content_type:R.mime,meta:`#${v} · ${R.updated_by||"?"} · v${R.version??"?"}`,loading:!1})}catch(R){Kt({name:S,mode:"text",meta:`#${v}`,error:String((R==null?void 0:R.message)||R||"failed to read file")})}}function Zn(u){const v=u.kind==="message"&&!!u.channel,S=u.kind==="file"&&!!u.channel,k=v||S,R=gx(String(u.snippet||""),u.highlights),se=u.ratings,F=String(u.channel||""),ye=F?F.startsWith("dm:")?F:`#${F}`:"";return e.jsxs("div",{className:`team_search_hit${k?" clickable":""}`,onClick:k?()=>S?void za(u):po(u):void 0,role:k?"button":void 0,title:v?"Open this message in its thread":S?"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,ye?e.jsx("span",{className:"team_search_chan mono",children:ye}):null,u.sender?e.jsx("span",{className:"team_search_sender",style:{color:`hsl(${jd(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,se&&(se.up||se.down)?e.jsxs("span",{className:"team_search_tally mono",title:"Standing ±1 ratings on this message (read-only here — vote from the thread)",children:["▲",se.up," ▽",se.down]}):null,u.created_at?e.jsx("span",{className:"muted team_search_time",children:Ml(u.created_at)}):null]}),String(u.title||"").trim()?e.jsx("div",{className:"team_search_title",children:u.title}):null,R.length?e.jsx("div",{className:"team_search_snippet",children:R.map((Pe,Ue)=>Pe.hit?e.jsx("mark",{children:Pe.text},Ue):e.jsx(Wt.Fragment,{children:Pe.text},Ue))}):null,!v&&!S&&u.kind!=="agent"?e.jsx("div",{className:"team_search_ref mono muted",children:u.ref}):null]},`${u.kind}:${F}:${u.ref}`)}const wr=f.useMemo(()=>{let u=0;for(const v of sa)for(const S of[v.root,...v.replies])u=Math.max(u,S.seq||0);return u},[sa]),vs=f.useMemo(()=>{const u={};for(const v of["asks","vigilance","fyi","resolved","to_me"])u[v]=Wf(_s,v,Os).length;return u.unread=he.filter(v=>{var S,k;return((S=Os.unread_seqs)==null?void 0:S.has(v.seq))||((k=Os.unread_snapshot_seqs)==null?void 0:k.has(v.seq))}).length,u},[_s,he,Os]);function ol(){var u,v;return Mt==="loading"?e.jsx("span",{className:"muted team_note",children:"Loading channel info…"}):Mt&&typeof Mt=="object"&&"error"in Mt?e.jsx("span",{className:"page_error mono",children:Mt.error}):Mt?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"team_info_row",children:[Mt.state?e.jsx(Hn,{tone:Mt.state==="open"?"success":"warning",size:"sm",children:Mt.state}):null,(u=Mt.channel)!=null&&u.private?e.jsx(Hn,{tone:"muted",size:"sm",children:"private"}):e.jsx(Hn,{tone:"muted",size:"sm",children:"public"}),Mt.response_sla_minutes?e.jsxs(Hn,{tone:"muted",size:"sm",title:"Expected response SLA",children:["SLA ",Math.round(Number(Mt.response_sla_minutes)/60),"h"]}):null,e.jsxs("span",{className:"muted team_note",children:[(bn??Mt.members??[]).length," members"]})]}),(v=Mt.meta)!=null&&v.purpose?e.jsx("div",{className:"team_info_purpose",children:Mt.meta.purpose}):null,Mt.charter?e.jsxs("div",{className:"team_info_charter",children:[e.jsx("div",{className:"muted team_note",style:{marginBottom:4},children:"Charter"}),e.jsx(ls,{className:"md_doc",text:Pl(String(Mt.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 ",bn?`(${bn.length})`:""]}),!Qt&&bn!==null?e.jsxs("div",{className:"team_invite_row",children:[e.jsxs("select",{className:"team_compose_control team_invite_select",value:Vr,onChange:S=>Ai(S.target.value),disabled:!!sr,title:"Agents on the hub not yet in this channel",children:[e.jsx("option",{value:"",children:"invite: agent…"}),Ls.filter(S=>!(bn||[]).some(k=>String(k.agent_id||"")===S)).filter(S=>!(Ei[I]||new Set).has(S)).map(S=>e.jsx("option",{value:S,children:S},S))]}),e.jsx("button",{className:"btn",disabled:!Vr||!!sr,title:"Mint a single-use invite token and DM it with the join pointer",onClick:()=>void uo(Vr),children:sr?"Inviting…":"Invite"})]}):null,ds?e.jsx("div",{className:"muted team_note",children:ds}):null,(()=>{const S=[...Ei[I]||[]].filter(k=>!(bn||[]).some(R=>String(R.agent_id||"")===k));return!S.length||bn===null?null:S.map(k=>e.jsxs("div",{className:"team_member_row team_member_invited",children:[e.jsx("span",{className:"team_avatar",style:Ga(k),"aria-hidden":"true",children:(k[0]||"?").toUpperCase()}),e.jsx("span",{className:"team_member_id",children:k}),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:${k}`))})(),Fr?e.jsxs("div",{className:"muted team_note",children:["Members list unavailable (",Fr.slice(0,100),") — an empty list below means the FETCH failed, not an empty channel. Reopen the drawer to retry."]}):null,bn===null?e.jsx("span",{className:"muted team_note",children:"Loading members…"}):bn.map(S=>{const k=String(S.agent_id||"");return k?e.jsxs("div",{className:"team_member_row",children:[e.jsx("span",{className:"team_avatar",style:Ga(k),"aria-hidden":"true",children:(k[0]||"?").toUpperCase()}),e.jsx("span",{className:"team_member_id",title:String(S.about||""),children:k}),k!==yt&&!Qt?e.jsxs("span",{className:"team_member_actions",children:[e.jsx("button",{className:"team_row_expand",disabled:!!Gt,title:"Kick: 1-hour block from THIS channel (hub authorizes — owner/operator only)",onClick:()=>void pr(k,"kick"),children:Gt===`channel:kick:${k}`?"kicking…":"kick"}),e.jsx("button",{className:`team_row_expand ${Vt===`channel:ban:${k}`?"team_danger":""}`,disabled:!!Gt,title:"Ban: INDEFINITE block from this channel (two clicks — the first arms, the second confirms)",onClick:()=>{Vt===`channel:ban:${k}`?(Xt(""),pr(k,"ban")):Xt(`channel:ban:${k}`)},children:Gt===`channel:ban:${k}`?"banning…":Vt===`channel:ban:${k}`?"confirm ban":"ban"}),e.jsx("button",{className:`team_row_expand ${Vt===`hub:ban:${k}`?"team_danger":""}`,disabled:!!Gt,title:"Hub ban: INDEFINITE lockout from the ENTIRE hub — every channel, re-registration refused, live connection severed (operator-only). Two clicks to confirm.",onClick:()=>{Vt===`hub:ban:${k}`?(Xt(""),pr(k,"ban","hub")):Xt(`hub:ban:${k}`)},children:Gt===`hub:ban:${k}`?"hub-banning…":Vt===`hub:ban:${k}`?"confirm hub ban":"hub ban"}),e.jsx("button",{className:`team_row_expand ${Vt===`retire:${k}`?"team_danger":""}`,disabled:!!Gt,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:()=>{Vt===`retire:${k}`?(Xt(""),so(k)):Xt(`retire:${k}`)},children:Gt===`retire:${k}`?"retiring…":Vt===`retire:${k}`?"confirm retire":"retire"})]}):k===yt?e.jsx("span",{className:"chip mono ok",style:{marginLeft:"auto"},children:"you"}):null]},k):null})]}),!Qt&&Wr&&Wr.length?e.jsxs("div",{className:"team_members",children:[e.jsxs("div",{className:"muted team_note",style:{marginBottom:4},children:["Blocked (",Wr.length,")"]}),Wr.map(S=>{const k=String(S.agent_id||S.agent||"");if(!k)return null;const R=String(S.scope||""),se=R==="hub",F=se?"hub":"channel",ye=S.expires_at?` · until ${new Date(Number(S.expires_at)*1e3).toLocaleString()}`:" · indefinite",Pe=se?"hub-wide":`#${R}`;return e.jsxs("div",{className:"team_member_row",children:[e.jsx("span",{className:"team_avatar",style:Ga(k),"aria-hidden":"true",children:(k[0]||"?").toUpperCase()}),e.jsxs("span",{className:"team_member_id",title:String(S.reason||""),children:[k,e.jsxs("span",{className:"muted team_note",children:[Pe,ye]})]}),e.jsx("span",{className:"team_member_actions",children:e.jsx("button",{className:"team_row_expand",disabled:!!Gt,title:se?"Lift this HUB-WIDE block (the agent can re-register and rejoin)":"Lift this channel block (the agent can rejoin/post again)",onClick:()=>void pr(k,"unblock",F),children:Gt===`${F}:unblock:${k}`?"unblocking…":"unblock"})})]},`blocked:${R}:${k}`)})]}):null,!Qt&&Rs&&Rs.length?e.jsxs("div",{className:"team_members",children:[e.jsxs("div",{className:"muted team_note",style:{marginBottom:4},children:["Retired agents (",Rs.length,")"]}),Rs.map(S=>{const k=String(S.id||"");if(!k)return null;const R=S.retired_at?` · ${new Date(Number(S.retired_at)*1e3).toLocaleDateString()}`:"";return e.jsxs("div",{className:"team_member_row",children:[e.jsx("span",{className:"team_avatar",style:Ga(k),"aria-hidden":"true",children:(k[0]||"?").toUpperCase()}),e.jsxs("span",{className:"team_member_id",title:String(S.reason||""),children:[k,e.jsxs("span",{className:"muted team_note",children:["decommissioned",R]})]}),e.jsxs("span",{className:"team_member_actions",children:[e.jsx("button",{className:`team_row_expand ${Vt===`unretire:${k}`?"team_danger":""}`,disabled:!!Gt,title:"Un-retire: restore this agent's access (it rejoins channels explicitly). Two clicks to confirm.",onClick:()=>{Vt===`unretire:${k}`?(Xt(""),ao(k)):Xt(`unretire:${k}`)},children:Gt===`unretire:${k}`?"un-retiring…":Vt===`unretire:${k}`?"confirm un-retire":"un-retire"}),e.jsx("button",{className:`team_row_expand ${Vt===`delete:${k}`?"team_danger":""}`,disabled:!!Gt,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:()=>{Vt===`delete:${k}`?(Xt(""),pc(k)):Xt(`delete:${k}`)},children:Gt===`delete:${k}`?"deleting…":Vt===`delete:${k}`?"confirm delete":"delete"})]})]},`retired:${k}`)})]}):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:"ⓘ"})]}),Ks===null?e.jsx("span",{className:"muted team_note",children:qr||"Loading delegations…"}):e.jsxs(e.Fragment,{children:[Ks.length===0?e.jsx("span",{className:"muted team_note",children:"No active delegate."}):null,Ks.map(S=>{const k=String(S.agent_id||""),R=Array.isArray(S.powers)?S.powers.map(String):[],se=Number(S.expires_at||S.expires||0);return e.jsxs("div",{className:"team_delegation_row",children:[e.jsx("span",{className:"team_avatar",style:Ga(k),"aria-hidden":"true",children:(k[0]||"?").toUpperCase()}),e.jsx("span",{className:"team_member_id",children:k}),e.jsxs("span",{className:"team_delegation_powers mono",title:String(S.note||""),children:[R.join(" + ")||"(no powers?)",se?` · until ${new Date(se*1e3).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}`:""]}),e.jsx("button",{className:`team_row_expand ${Vt===`resign:${k}`?"team_danger":""}`,disabled:hn,title:"Resign this delegate: the grant is revoked hub-wide, on the record (two clicks)",onClick:()=>{Vt===`resign:${k}`?(Xt(""),nr(k)):Xt(`resign:${k}`)},children:hn?"resigning…":Vt===`resign:${k}`?"confirm resign":"resign"})]},k)}),e.jsxs("div",{className:"team_delegation_assign",children:[e.jsxs("select",{className:"team_compose_control team_invite_select",value:pn,onChange:S=>Vl(S.target.value),title:"Assign a delegate: any registered agent except operators and current delegates",children:[e.jsx("option",{value:"",children:"assign a delegate…"}),(bn??Mt.members??[]).map(S=>String(typeof S=="string"?S:(S==null?void 0:S.agent_id)||(S==null?void 0:S.id)||"")).filter(S=>S&&S!==yt&&!Ks.some(k=>String(k.agent_id)===S)).map(S=>e.jsx("option",{value:S,children:S},S))]}),pn?e.jsxs("div",{className:"team_delegation_powers_pick",children:[Lx.map(S=>e.jsxs("label",{className:"team_delegation_power",title:S.help,children:[e.jsx("input",{type:"checkbox",checked:pa.includes(S.id),onChange:k=>Gl(R=>k.target.checked?[...R,S.id]:R.filter(se=>se!==S.id))}),S.id]},S.id)),e.jsx("button",{className:"btn",disabled:hn||!pa.length,title:pa.length?`Grant ${pn} the powers: ${pa.join(", ")} (7-day TTL, renewable; on the record)`:"Pick at least one power",onClick:()=>void Ur(),children:hn?"Assigning…":"Assign"})]}):null]}),qr?e.jsx("div",{className:"page_error mono",children:qr}):null]})]}),Qt?null:e.jsx("div",{className:"team_chan_admin",children:At?String(Mt.state||"open")==="open"?e.jsx("button",{className:"btn",disabled:on,title:"Close this channel — member posts refuse until reopened (owner-only; the hub authorizes)",onClick:()=>void ro("closed"),children:on?"Closing…":"Close channel"}):e.jsx("button",{className:"btn",disabled:on,title:"Reopen this channel for member posts",onClick:()=>void ro("open"),children:on?"Reopening…":"Reopen channel"}):e.jsxs("span",{className:"muted team_note",children:["Close/reopen is owner-only on the hub (this channel's owner: ",xs||"unknown",")."]})}),Hr?e.jsx("div",{className:"page_error mono",children:Hr}):null]}):e.jsx("span",{className:"muted team_note",children:"Open a channel to see its members."})}function bc(u){var S;const v=((S=u.data)==null?void 0:S.attachments)||u.attachments||[];return v.length?e.jsx("div",{className:"team_attachments",children:v.map((k,R)=>{const se=`${k.id}:${R}`,F=l.attachment_url(u.channel,k.id);return Tx.has(String(k.content_type||"").toLowerCase())?e.jsxs("button",{className:"team_attach_img_link",title:`${k.filename} · ${Vn(k.size)} — click to preview`,onClick:()=>void $a(u.channel,k),children:[e.jsx("img",{className:"team_attach_img",src:F,alt:k.filename,loading:"lazy",onError:Pe=>{var $t;const Ue=Pe.currentTarget;Ue.style.display="none";const Ve=($t=Ue.parentElement)==null?void 0:$t.querySelector(".team_attach_fallback");Ve&&(Ve.style.display="inline-flex")}}),e.jsxs("span",{className:"team_attach_chip team_attach_fallback",style:{display:"none"},children:[e.jsx(tt,{name:"paperclip",size:11}),e.jsx("span",{className:"team_attach_name",children:k.filename}),e.jsx("span",{className:"muted",children:Vn(k.size)})]})]},se):e.jsxs("button",{className:"team_attach_chip team_attach_dl",title:`${k.content_type} · ${Vn(k.size)} — click to preview`,onClick:()=>void $a(u.channel,k),children:[e.jsx(tt,{name:"paperclip",size:11}),e.jsx("span",{className:"team_attach_name",children:k.filename}),e.jsx("span",{className:"muted",children:Vn(k.size)})]},se)})}):null}function wc(u,v){var ye;const S=[],k=String(u.status||"").toLowerCase();(k==="open"||k==="blocked")&&(u.has_resolved_reply===!0||(u.id?vc.has(u.id):!1))?S.push(e.jsx(Hn,{tone:"success",size:"sm",title:"This ask already has a reply from another seat.",children:"answered"},"st")):k==="open"||k==="blocked"?S.push(e.jsx(Hn,{tone:k==="blocked"?"error":"warning",size:"sm",children:k},"st")):k==="resolved"&&v&&S.push(e.jsx(Hn,{tone:"success",size:"sm",children:"resolved"},"st")),u.critical&&S.push(e.jsx(Hn,{tone:"error",size:"sm",title:"Critical: unpins only on explicit read — click the row to record the read",children:"critical"},"crit"));const se=((ye=u.data)==null?void 0:ye.answers)||[];k==="reply"&&se.length&&S.push(e.jsxs(Hn,{tone:"success",size:"sm",title:`This reply discharges ask(s) ${se.join(", ")} of its parent.`,children:["✓ answers ",se.join(",")]},"dis"));const F=u.to||[];for(const Pe of F.slice(0,2))S.push(e.jsxs(Hn,{tone:"muted",size:"sm",children:["@",Pe]},`to:${Pe}`));return F.length>2&&S.push(e.jsxs(Hn,{tone:"muted",size:"sm",title:F.map(Pe=>`@${Pe}`).join(" "),children:["+",F.length-2]},"to+")),S}function ys(u,v){return e.jsx(Hh,{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:ah(u.sender),children:u.sender}),e.jsxs("span",{className:"team_row_meta mono",children:["#",u.seq," · ",Ll(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+`
118
+ `:"")+String(u.body||"(no text)")})]})}),children:jr(u,v)},u.id)}function jr(u,v){var xt,lt,Rt,gt;const S=!!ot[u.id],k=String(u.body||""),R=v.is_root?tc:eh,se=k.length>R,F=se&&!S,ye=((xt=u.data)==null?void 0:xt.asks)||[],Pe=!!((lt=Os.unread_seqs)!=null&&lt.has(u.seq)),Ue=Le!=="all"&&Jy(u,Le,Os),Ve=String(u.title||"").trim(),$t=((Rt=k.trim().split(`
119
+ `)[0])==null?void 0:Rt.trim())||"",Pt=Ve&&(Ve===k.trim()||Ve===$t),jn=(it==null?void 0:it.id)===u.id;return e.jsxs("div",{className:`team_row ${u.sender===yt?"own":""} ${Ue?"hit":""} ${jn?"replying":""} ${Pe?"unread":""} ${u.retracted?"retracted":""}`,id:`hubmsg-${u.id}`,onClick:()=>fc(u),title:se?void 0:u.critical?"Click to record the read (critical unpins on it)":void 0,children:[e.jsx("span",{className:"team_avatar",style:Ga(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:[(gt=J[u.channel])!=null&&gt.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 ${ea===u.id?"armed":""}`,title:ea===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:We=>{We.stopPropagation(),Ca(u)},children:ea===u.id?"sure? declines on the record":"decline"})]}):Pe?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:ah(u.sender),children:u.sender}),wc(u,v.is_root),(()=>{const We=Vi(u);return!We||!We.up&&!We.down?null:e.jsxs("span",{className:`team_reaction_tally mono ${We.mine>0?"pos":We.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:[We.up?`▲${We.up}`:"",We.up&&We.down?" ":"",We.down?`▼${We.down}`:""]})})(),e.jsxs("span",{className:"team_row_meta mono",title:Ml(u.created_at),children:["#",u.seq," · ",Ll(u.created_at)]})]}),Ve&&!Pt?e.jsx("div",{className:"team_row_title",children:Ve}):null,e.jsx("div",{className:`team_row_body ${F?v.is_root?"clamp_root":"clamp_reply":""}`,children:e.jsx(bx,{className:"md_doc",text:Pl(mx(ox(k),{hub_base:D}))})}),bc(u),(()=>{var Zt;const We=ix(`${String(u.title||"")}
120
+ ${k}`),St=((Zt=u.data)==null?void 0:Zt.attachments)||u.attachments||[],Dt=We.map(Lt=>({mention:Lt,res:lx(Lt,ei,St)})).filter(Lt=>Lt.res!==null).filter(Lt=>{var Jt;return!(Lt.res.kind==="attachment"&&String(((Jt=St[Lt.res.attachment_index])==null?void 0:Jt.filename)||"")===Lt.mention)}),Bt=a.on_open_board?wv(`${String(u.title||"")}
121
+ ${k}`):[];return!Dt.length&&!Bt.length?null:e.jsxs("div",{className:"team_fs_chips",children:[Dt.map(({mention:Lt,res:Jt})=>e.jsxs("button",{className:"team_attach_chip team_fs_chip",title:Jt.kind==="fs"?Jt.rewritten?`Opens ${Jt.path} (the mention's path moved — matched by name in #${I}'s files)`:`Open ${Jt.path} from #${I}'s virtual filesystem`:"Opens the file attached to this message (the path in the text belongs to the sender's workspace)",onClick:cn=>{cn.stopPropagation(),Jt.kind==="fs"?Qi(Jt.path):$a(u.channel,St[Jt.attachment_index])},children:[e.jsx(sh,{}),e.jsx("span",{className:"team_attach_name",children:Lt}),Jt.kind==="attachment"?e.jsx("span",{className:"team_fs_chip_note",children:"attached"}):Jt.rewritten?e.jsx("span",{className:"team_fs_chip_note",children:"moved"}):null]},Lt)),Bt.map(Lt=>e.jsxs("button",{className:"team_attach_chip team_fs_chip team_work_chip",title:`Work item ${Lt} — open the Board filtered to it`,onClick:Jt=>{var cn;Jt.stopPropagation(),(cn=a.on_open_board)==null||cn.call(a,Lt)},children:[e.jsx("span",{className:"team_work_glyph","aria-hidden":!0,children:"⛭"}),e.jsx("span",{className:"team_attach_name mono",children:Lt})]},`w:${Lt}`))]})})(),ye.length?e.jsx("div",{className:"team_row_asks",children:ye.map(We=>e.jsxs("span",{className:"team_ask",title:We.text,children:["ask ",We.id,": ",We.text.length>90?We.text.slice(0,90)+"…":We.text]},We.id))}):null,se?e.jsx("button",{className:"team_row_expand",onClick:We=>{We.stopPropagation(),to(u)},children:S?"collapse":"show more"}):null]}),En?e.jsxs("div",{className:"team_row_rail",children:[u.id&&u.sender!==yt&&u.sender!=="hub"&&!u.retracted?(()=>{const We=Vi(u);return We?e.jsxs("span",{className:"team_vote_thumbs",children:[e.jsxs("button",{className:`btn btn_icon team_thumb ${We.mine>0?"up_on":""}`,title:We.mine>0?"Withdraw your +1 on this message":"+1 this message",disabled:!!Xr,onClick:St=>{St.stopPropagation(),no(u.id,1)},children:[e.jsx(tt,{name:We.mine>0?"thumbsUpFilled":"thumbsUp",size:13}),We.up?e.jsx("span",{className:"team_thumb_count",children:We.up}):null]}),e.jsxs("button",{className:`btn btn_icon team_thumb ${We.mine<0?"down_on":""}`,title:We.mine<0?"Withdraw your −1 on this message":"−1 this message",disabled:!!Xr,onClick:St=>{St.stopPropagation(),no(u.id,-1)},children:[e.jsx(tt,{name:We.mine<0?"thumbsDownFilled":"thumbsDown",size:13}),We.down?e.jsx("span",{className:"team_thumb_count",children:We.down}):null]})]}):null})():null,$.tts_supported&&u.id?(()=>{const We=$.tts_playback.key===u.id&&$.tts_playback.status==="playing",St=$.tts_playback.key===u.id&&$.tts_playback.status==="loading";return e.jsx("button",{className:`btn btn_icon ${We||St?"team_speak_on":""}`,title:We?"Pause":St?"Synthesizing…":_.enabled?"Read aloud (your voice override)":"Read aloud (gateway voice)","aria-label":We?"Pause reading":"Read this message aloud",onClick:Dt=>{Dt.stopPropagation();const Bt=$y(u.body||u.title||"");Bt?$.toggle_tts(u.id,Bt):Q("Nothing readable to speak in this message (code/markup only).")},children:e.jsx(tt,{name:We?"pause":St?"refresh":"speaker",size:13})})})():null,e.jsx("button",{className:"btn btn_icon",title:ye.length?"Reply and discharge this message's asks":"Reply in this trail (status=reply, linked to this message)",onClick:We=>{We.stopPropagation(),ii(u)},children:"↩ Reply"}),u.sender===yt&&!u.retracted?e.jsx("button",{className:`btn btn_icon ${ps===u.id?"team_danger":""}`,title:ps===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:We=>{We.stopPropagation(),ps===u.id?_r(u):ri(u.id)},children:ps===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 ${ai===u.id?"team_danger":""}`,title:ai===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:We=>{We.stopPropagation(),ai===u.id?Xi(u):co(u.id)},children:ai===u.id?"✓ confirm resolve":"✓ Resolve"}):null]}):null]},u.id)}function Pa(u){const v=u.replies.length,S=!!$e[u.root.id],k=!!ke[u.root.id],R=S?[]:k||Le!=="all"||v<=th+1?u.replies:u.replies.slice(v-th),se=S?v:v-R.length,F=dc[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,ys(u.root,{is_root:!0}),se>0||v>0||String(u.root.body||"").length>tc?e.jsxs("div",{className:"team_trail_bar",children:[v>0?e.jsx("button",{className:"team_replies_more",onClick:()=>ze(ye=>({...ye,[u.root.id]:!ye[u.root.id]})),children:S?`show ${v} repl${v===1?"y":"ies"}`:"fold thread"}):null,!S&&se>0?e.jsxs("button",{className:"team_replies_more",onClick:()=>Be(ye=>({...ye,[u.root.id]:!0})),children:["↓ ",se," earlier repl",se===1?"y":"ies"]}):null,!S&&d&&(v>0||String(u.root.body||"").length>tc)?e.jsx("button",{className:"team_replies_more team_summarize",disabled:!!(F!=null&&F.busy),title:"LLM summary of this trail (root + replies) — read-only, never posts",onClick:()=>void oo(u),children:F!=null&&F.busy?"✦ summarizing…":`✦ Summarize (${v+1})`}):null]}):null,!S&&v>0?e.jsx("div",{className:"team_replies",children:R.map(ye=>ys(ye,{is_root:!1}))}):null,!S&&(F!=null&&F.text)?e.jsxs("div",{className:"team_summary",children:[e.jsxs("div",{className:"team_summary_head",children:[e.jsxs("span",{children:["AI summary — ",F.window||`${F.count} message${F.count===1?"":"s"}`]}),e.jsx("button",{className:"team_row_expand",onClick:()=>va(ye=>({...ye,[u.root.id]:{busy:!1,text:"",error:"",count:0}})),children:"dismiss"})]}),e.jsx(ls,{className:"md_doc",text:Pl(F.text)})]}):null,F!=null&&F.error?e.jsx("div",{className:"page_error mono",children:F.error}):null]},u.root.id)}const ci=he.length?he[he.length-1].seq:0,cl=Math.max(ci,((Tt=ue.find(u=>u.name===I))==null?void 0:Tt.last_seq)||0),ia=((bs=ue.find(u=>u.name===I))==null?void 0:bs.member_count)||0,xs=((an=(bn||[]).find(u=>String(u.role||"")==="owner"))==null?void 0:an.agent_id)||"",At=!!yt&&xs===yt;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(),En&&!Ee&&wt(!0))},onDragLeave:u=>{u.currentTarget.contains(u.relatedTarget)||wt(!1)},onDrop:u=>{var v,S;(S=(v=u.dataTransfer)==null?void 0:v.files)!=null&&S.length&&(u.preventDefault(),wt(!1),!(!En||Ee)&&Zi(u.dataTransfer.files))},children:[zt?e.jsx("div",{className:"team_drop_overlay",children:e.jsxs("div",{className:"team_drop_overlay_card",children:["Drop to attach to ",Qt?vr:`#${I}`]})}):null,T!=null&&T.protocol&&T.protocol!==sc||T!=null&&T.paused||X||In||Or||L&&!L.seat_key_present?e.jsxs("div",{className:"team_statusstrip",children:[L&&!L.seat_key_present?e.jsx("span",{className:"chip mono warn",title:"No hub key for this seat — read-only until Continuum can read one (the seat's entry in ~/.agora/keys.json, or --hub-token-file at launch). The seat itself is set in Settings.",children:"read-only (no seat key)"}):null,T!=null&&T.protocol&&T.protocol!==sc?e.jsxs("span",{className:"chip mono warn",title:`The hub advertises ${T.protocol}; this page was written against ${sc}. Meaning may have shifted — rendering continues (protocol.md: warn, never refuse).`,children:["protocol ",T.protocol," ≠ ",sc]}):null,T!=null&&T.paused?e.jsx("span",{className:"chip mono warn",title:"The operator paused the hub — posting resumes when it does.",children:"hub paused"}):null,X?e.jsx("span",{className:"page_error mono",children:X}):null,In?e.jsxs("span",{className:"page_error mono",children:["±1 failed: ",In]}):null,Or?e.jsx("span",{className:"chip mono ok",children:Or}):null]}):null,e.jsxs("div",{className:`team_layout ${Et?"with_drawer":""} ${Et==="leaderboard"?"drawer_wide":""} team_mobile_${Re} ${Oe?"team_tools_open":""}`,children:[e.jsxs("div",{className:"pane team_channels_pane",onClickCapture:u=>{var v,S;(S=(v=u.target)==null?void 0:v.closest)!=null&&S.call(v,".team_channel")&&qe("thread")},children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Channels"}),e.jsx("span",{className:"pane_count",children:ue.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:()=>Ms(u=>({...u,open:!u.open})),children:e.jsx(tt,{name:"plus",size:14})})})]}),$n.open?e.jsxs("div",{className:"team_new_channel",children:[e.jsx("input",{value:$n.name,onChange:u=>Ms(v=>({...v,name:u.target.value})),placeholder:"channel-name (simple slug)",onKeyDown:u=>{u.key==="Enter"&&Ji()}}),e.jsx(Si,{variant:"sm",label:"Private",hint:"Private channels need invites; public ones are joinable by any registered agent.",action:"new-channel-private",checked:$n.is_private,onChange:u=>Ms(v=>({...v,is_private:u}))}),e.jsx("button",{className:"btn primary",disabled:!$n.name.trim()||on,onClick:()=>void Ji(),children:on?"Creating…":"Create"})]}):null,e.jsxs("div",{className:"pane_body pane_body_list",children:[ue.length?null:e.jsx("div",{className:"muted team_note team_rail_degraded",children:X?"Channels unavailable — the hub is unreachable. Retrying automatically; check that the hub is running if this persists.":"Loading channels…"}),ue.filter(u=>!u.name.startsWith("dm:")).map(u=>{const v=Te[u.name],S=Yn===u.name;return e.jsxs("div",{className:`team_channel team_dm_row ${I===u.name?"selected":""}`,role:"button",tabIndex:0,onClick:()=>be(u.name),onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&be(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:k=>{k.stopPropagation(),u.name!==I&&(de.current="unread"),be(u.name),Ge("unread")},onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.stopPropagation(),u.name!==I&&(de.current="unread"),be(u.name),Ge("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:k=>{k.stopPropagation(),u.name!==I&&(de.current="asks"),be(u.name),Ge("asks")},onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.stopPropagation(),u.name!==I&&(de.current="asks"),be(u.name),Ge("asks"))},children:v.open_questions}):null,e.jsx("button",{className:`team_dm_trash ${S?"arming":""}`,title:S?"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":S?"Confirm archive channel":"Archive channel",disabled:on,onClick:k=>{k.stopPropagation(),S?lo(u.name):ta(u.name)},children:e.jsx(tt,{name:S?"x":"trash",size:12})})]})]}),e.jsx("span",{className:"team_channel_meta mono",children:S?"archive? click ✕":`${u.member_count} seats · ${Ll(u.last_at)}`})]},u.name)}),(()=>{const u=ue.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 S=Te[v.name],k=v.name.replace(/^dm:/,"").split("--").filter(se=>se!==yt).join("")||v.name,R=_c===v.name;return e.jsxs("div",{className:`team_channel team_dm_row ${I===v.name?"selected":""}`,role:"button",tabIndex:0,onClick:()=>be(v.name),onKeyDown:se=>{(se.key==="Enter"||se.key===" ")&&be(v.name)},children:[e.jsxs("span",{className:"team_channel_line",children:[e.jsxs("span",{className:`team_channel_name ${S!=null&&S.unread?"has_unread":""}`,children:["@",k]}),e.jsxs("span",{className:"team_channel_badges",children:[S!=null&&S.unread?e.jsx("span",{className:"team_badge unread",title:`${S.unread>=100?"100 or more":S.unread} unread message(s)`,children:S.unread>=100?"99+":S.unread}):null,e.jsx("button",{className:`team_dm_trash ${R?"arming":""}`,title:R?"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":R?"Confirm remove direct message":"Remove direct message",disabled:on,onClick:se=>{se.stopPropagation(),R?gc(v.name):io(v.name)},children:e.jsx(tt,{name:R?"x":"trash",size:12})})]})]}),e.jsx("span",{className:"team_channel_meta mono",children:R?"remove? click ✕":Ll(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("button",{type:"button",className:"btn team_back_btn",onClick:()=>{qe("channels"),ut(!1),Et&&Qn("")},"aria-label":"Back to channels",title:"Back to channels",children:"← Channels"}),e.jsx("button",{type:"button",className:"btn team_tools_btn",onClick:()=>ut(u=>!u),"aria-expanded":Oe,"aria-label":Oe?"Hide thread tools":"Show thread tools (filters, search, panels)",title:"Filters, search, panels and actions",children:Oe?"Less":"More"}),e.jsx("span",{className:"pane_title team_pane_title",children:I?Qt?`@${vr} — direct`:`#${I}`:"Select a channel"}),I&&ia?e.jsxs("button",{className:"chip team_members_chip",onClick:()=>{Et!=="members"&&ns("members")},title:"View the channel members (opens the Members drawer, roster + moderation)",children:[ia," members"]}):null,_e?e.jsx("span",{className:"muted team_note",children:"loading…"}):null,e.jsxs("span",{className:"pane_header_actions",children:[$.tts_playback.status!=="idle"?e.jsx("button",{className:"btn team_speak_stop",title:"Stop reading aloud",onClick:()=>$.stop_tts(),children:"◼ Stop reading"}):null,(()=>{const u=Le==="all"?cl:wr;return e.jsx("button",{className:"btn",onClick:()=>void fo(u),disabled:!I||!he.length||!u||$i||_e,title:Le==="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:$i?"Marking…":`Mark read → #${u||"…"}`})})(),e.jsx("button",{className:"btn btn_icon",onClick:()=>{hs(),Zs(I)},title:"Refresh channels, badges, and the thread window (the page also polls every 5s)","aria-label":"Refresh",children:e.jsx(tt,{name:"refresh",size:14})}),Ht&&Ht!=="running"&&typeof Ht=="object"&&"ok"in Ht?Ht.ok?e.jsxs(Hn,{tone:"success",size:"sm",title:`Hash chain recomputed client-side over ${Ht.hashed} hashed turns (${Ht.legacy} pre-ledger); served head matches.`,children:["transcript intact (",Ht.hashed,")"]}):e.jsxs(Hn,{tone:"error",size:"sm",title:Ht.broken_at!==null?`Recomputed chain diverges at seq ${Ht.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",Ht.broken_at!==null?` at #${Ht.broken_at}`:" (head mismatch)"]}):null,Ht&&typeof Ht=="object"&&"error"in Ht?e.jsx(Hn,{tone:"warning",size:"sm",title:Ht.error,children:"verify failed"}):null,e.jsx("button",{className:"btn btn_icon",onClick:()=>void hc(),disabled:!I||Ht==="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:Ht==="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:Uf.map(u=>{const v=Le===u.id,S=vs[u.id];return e.jsxs("button",{className:`seg_btn ${v?"active":""}`,"aria-pressed":v,title:u.title,onClick:()=>Ge(u.id),children:[u.label,typeof S=="number"&&S>0?e.jsx("span",{className:"team_filter_count",children:S}):null]},u.id)})}),e.jsxs("form",{className:"team_search_bar",onSubmit:u=>{u.preventDefault();const v=ra.trim();if(!v&&!Tn){La("down"),oi("",Ra,"down");return}ho(v)},children:[e.jsx("input",{className:"team_search_input",type:"search",placeholder:"Search the hub…",value:ra,onChange:u=>rl(u.target.value),onKeyDown:u=>{u.key==="Escape"&&(An&&il(),rl(""))},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"}),An?e.jsx("button",{type:"button",className:"btn btn_icon team_search_close",onClick:il,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:()=>Ct("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:()=>{Ct("votes"),xr()},children:"Top voted"})]}),e.jsxs("span",{className:"team_filterbar_meta",children:[e.jsx("span",{className:`team_live_dot ${Oi?"on":""}`,title:Oi?"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:Oi?"● live":"◌ polling"})," · ",sa.length!==_s.length?`${sa.length} of ${_s.length} threads`:_s.length?`${_s.length} threads`:"",L!=null&&L.seat_key_present?e.jsxs("span",{title:"Posts are authored under this hub seat — your own identity, key held server-side.",children:[" · as ",L.seat]}):null]})]}),e.jsx("div",{className:"pane_body team_thread",ref:Yr,children:An?(()=>{const u=An;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(br){const R=br;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:()=>Xn(null),children:"← All results"}),e.jsxs("span",{className:"muted",children:[R.label," matching “",u.q,"” — newest first",R.total?` · ${R.hits.length} of ${R.total}`:""]})]}),R.error?e.jsx("div",{className:"muted team_note",children:R.error}):null,R.hits.map(se=>Zn(se)),R.busy?e.jsx("div",{className:"muted team_note",children:"Loading…"}):null,!R.busy&&R.cursor?e.jsx("button",{className:"team_replies_more team_search_more",onClick:ll,children:"Load more"}):null,!R.busy&&!R.hits.length&&!R.error?e.jsxs("div",{className:"muted team_note",children:["Nothing in ",R.label.toLowerCase()," matches “",u.q,"”."]}):null]})}const S=ec.filter(R=>{var se;return!((((se=v[R.id])==null?void 0:se.total)??0)>0)}),k=S.length<ec.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${Tn?` (${Tn==="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(R=>e.jsx("button",{className:`seg_btn ${Tn===R?"active":""}`,"aria-pressed":Tn===R,title:R==="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 se=Tn===R?"":R;La(se),oi(u.q,Ra,se)},children:R==="up"?"▲ rated":"▼ rated"},R))}),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:Ra==="channel",onChange:R=>{const se=R.target.checked?"channel":"all";yc(se),oi(u.q,se,Tn)}}),"this channel only"]})]}),ec.map(R=>{const se=v[R.id],F=(se==null?void 0:se.shown)??0,ye=(se==null?void 0:se.total)??0,Pe=(se==null?void 0:se.hits)??[];return!se||!ye&&!Pe.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:R.label}),e.jsx("span",{className:"muted mono",children:F<ye?`showing ${F} of ${ye}`:`${ye}`}),F<ye&&R.kind?e.jsx("button",{className:"team_replies_more",onClick:()=>xc(R.label,R.kind),title:`All ${ye} ${R.label.toLowerCase()} matches, newest first (paged)`,children:"view all →"}):null]}),Pe.map(Ue=>Zn(Ue))]},R.id)}),k?S.length?e.jsxs("div",{className:"muted team_search_empties",children:["nothing in ",S.map(R=>R.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"?al?e.jsx("div",{className:"muted team_note",children:al}):aa===null?e.jsx("div",{className:"muted team_note",children:"Loading the channel's top-voted messages…"}):aa.length?aa.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:()=>li(u),title:"Switch back to recency and scroll to this message in its thread",children:"view in thread"})]}),ys(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 S of sa){const k=S.replies.length?S.replies[S.replies.length-1]:S.root,R=Mx(k.created_at);R&&R!==v&&(v=R,u.push(e.jsx("div",{className:"team_day_divider",children:e.jsx("span",{children:R})},`day:${R}:${S.root.id}`))),u.push(Pa(S))}return u})(),!sa.length&&I&&!_e?e.jsx("div",{className:"muted team_note",children:_s.length?e.jsxs(e.Fragment,{children:["Nothing matches the ",e.jsx("strong",{children:((gn=Uf.find(u=>u.id===Le))==null?void 0:gn.label)||Le})," filter in this channel — the messages exist under All."," ",e.jsx("button",{className:"team_replies_more",onClick:()=>Ge("all"),children:"Show all"})]}):"No messages in the window."}):null]})}),e.jsxs("div",{className:"team_composer",onKeyDown:u=>{u.key==="Escape"&&it&&na()},children:[it?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-${it.id}`))==null||u.scrollIntoView({block:"center"})},children:["↩ #",it.seq," (",it.sender,") —"," ",(String(it.title||"").trim()||String(it.body||"").trim()).slice(0,80)||"(no text)"]}),(((Ds=it.data)==null?void 0:Ds.asks)||[]).length?e.jsx("span",{className:"team_reply_asks",children:(((la=it.data)==null?void 0:la.asks)||[]).map(u=>e.jsxs("label",{title:u.text,children:[e.jsx("input",{type:"checkbox",checked:!!Cs[u.id],onChange:v=>Xa(S=>({...S,[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:na,children:"cancel (Esc)"})]}):null,$s==="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 ",it?"Reply":"Post"," again to send as-is."]}):null,$s==="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,Dn?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:Dn.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:["#",Dn.name]}),e.jsxs("span",{className:"team_group_invites",children:["invites: ",Dn.members.map(u=>`@${u}`).join(" ")]})]}):e.jsx("span",{className:"muted",children:Dn.source==="kind"?"Add members below — write their names like @entity @assistant":"/group needs @mentions — e.g. /group fix the voice outage @gateway @core"})}):null,!it&&!Qt&&(ge==="ask"||ge==="group")?e.jsx("input",{className:"team_ask_title",value:et,onChange:u=>rt(u.target.value),placeholder:ge==="group"?"Group topic — names the room (e.g. fix the voice outage)":"Title — receivers triage asks by headline",disabled:!En}):null,!it&&!Qt&&ge==="group"?e.jsx("input",{className:"team_ask_title team_group_members",value:_t,onChange:u=>jt(u.target.value),placeholder:"Members — write their names: @entity @assistant @gateway",disabled:!En,list:"team_roster_options"}):null,!it&&!Qt&&ge==="group"&&Ls.length?e.jsx("datalist",{id:"team_roster_options",children:Ls.map(u=>e.jsx("option",{value:`@${u}`},u))}):null,mt.length?e.jsx("div",{className:"team_attach_pending",children:mt.map(u=>e.jsxs("span",{className:"team_attach_chip",title:`${u.content_type} · ${Vn(u.size)} — click to preview`,children:[e.jsxs("button",{className:"team_attach_open",onClick:()=>void $a(I,u),"aria-label":`Preview ${u.filename}`,children:[e.jsx(tt,{name:"paperclip",size:11}),e.jsx("span",{className:"team_attach_name",children:u.filename}),e.jsx("span",{className:"muted",children:Vn(u.size)})]}),e.jsx("button",{className:"team_attach_x","aria-label":`Remove ${u.filename}`,title:"Remove this attachment",onClick:()=>ft(v=>v.filter(S=>S.id!==u.id)),children:e.jsx(tt,{name:"x",size:10})})]},u.id))}):null,e.jsxs("div",{className:"team_compose_row",children:[!it&&!Qt?e.jsxs("select",{className:"team_compose_control team_kind_select",value:ge,onChange:u=>{const v=u.target.value,S=v==="ask"?"ask":v==="dm"?"dm":v==="group"?"group":"fyi";Se(S),S!=="ask"&&S!=="group"&&rt(""),S!=="group"&&jt("")},disabled:!En,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,!it&&!Qt&&ge==="dm"?Ls.length?e.jsxs("select",{className:"team_compose_control team_dm_peer",value:Ye,onChange:u=>vt(u.target.value),disabled:!En,title:"Recipient — every agent on the hub you share a channel with, connected or not",children:[e.jsx("option",{value:"",children:"to: member…"}),Ls.map(u=>e.jsx("option",{value:u,children:u},u))]}):e.jsx("input",{className:"team_compose_control team_dm_peer",value:Ye,onChange:u=>vt(u.target.value),placeholder:"to: agent id",disabled:!En,title:"Recipient agent id (roster unavailable — type it; #FALLBACK)"}):null,e.jsx("textarea",{ref:tn,className:"team_compose_text",rows:2,value:ie,onChange:u=>Ke(u.target.value),placeholder:En?it?`Reply to #${it.seq} in #${I}…`:Qt?`Message ${vr}…`:ge==="dm"?`Direct message${Ye.trim()?` to ${Ye.trim()}`:""}…`:d?`Message #${I||"…"} as ${(L==null?void 0:L.seat)||"operator"} — or /assistant <question>`:`Message #${I||"…"} as ${(L==null?void 0:L.seat)||"operator"}`:T!=null&&T.paused?"The hub is paused by the operator — posting resumes when it does.":"Read-only: the proxy has no operator seat key.",disabled:!En,onKeyDown:u=>{u.key!=="Enter"||u.shiftKey||u.nativeEvent.isComposing||u.keyCode===229||(u.preventDefault(),!Gs&&(ie.trim()||mt.length)&&sl())}}),e.jsx("input",{ref:ht,type:"file",multiple:!0,style:{display:"none"},onChange:u=>void Zi(u.target.files)}),e.jsx("button",{className:"btn team_attach_btn",disabled:!En||Ee||mt.length>=Al,title:mt.length>=Al?`Attachment limit (${Al}) reached`:"Attach a file or image (delivered to every recipient)","aria-label":"Attach a file",onClick:()=>{var u;return(u=ht.current)==null?void 0:u.click()},children:e.jsx(tt,{name:"paperclip",size:14})}),e.jsxs("button",{className:"btn primary team_send",disabled:!En||Gs||!ie.trim()&&!mt.length&&!(ge==="group"&&!it&&!Qt&&Wu(_t).length>0),onClick:()=>void sl(),"aria-label":Gs?"Sending":void 0,children:[e.jsx("span",{className:"team_send_icon","aria-hidden":"true",children:e.jsx(tt,{name:"send",size:16})}),e.jsx("span",{className:"team_send_label",children:Gs?"Sending…":Dn!=null&&Dn.members.length||!it&&!Qt&&ge==="group"?"Create room":it?"Reply":Qt||ge==="dm"?"Send DM":ge==="ask"?"Ask":"Send"})]})]})]})]}),Et==="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:["#",I]}),e.jsx("span",{className:"pane_header_actions",children:e.jsx("button",{className:"btn btn_icon",onClick:()=>Qn(""),title:"Close",children:"✕"})})]}),e.jsxs("div",{className:"pane_body team_ai_thread",children:[zs.length?null:e.jsxs("div",{className:"muted team_note",children:["Ask anything about #",I," — strategies used, deviations, who owes what, how a decision was reached. The model reads the current channel window (",he.length," messages) and cites seqs. It never posts to the room."]}),zs.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(ls,{className:"md_doc",text:Pl(u.content)})]},v)),zs.length&&Ql?e.jsxs("div",{className:"muted team_note",children:["Last answer read ",Ql,"."]}):null,Xs?e.jsx("div",{className:"muted team_note",children:"thinking…"}):null,zi?e.jsx("div",{className:"page_error mono",children:zi}):null]}),e.jsx("div",{className:"team_composer",children:e.jsx(uc,{value:Jr,onChange:cr,onSubmit:()=>{const u=Jr;cr(""),si(u)},placeholder:d?`Ask about #${I}…`:"AI advisor is not configured for this shell.",disabled:!d,busy:Xs,rows:2,sendLabel:"Ask",busyLabel:"Asking…"})})]}):null,Et==="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:["#",I]}),e.jsx("span",{className:"pane_header_actions",children:e.jsx("button",{className:"btn btn_icon",onClick:()=>Qn(""),title:"Close",children:"✕"})})]}),e.jsx("div",{className:"pane_body team_members_body",children:ol()})]}):null,Et==="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:["#",I]}),e.jsx("span",{className:"pane_header_actions",children:e.jsx("button",{className:"btn btn_icon",onClick:()=>Qn(""),title:"Close",children:"✕"})})]}),e.jsxs("div",{className:"team_fs_crumbs",children:[e.jsxs("button",{className:`team_fs_crumb ${Ys===""?"active":""}`,onClick:()=>sn(""),title:"Channel root",children:["#",I||"…"]}),Ys?Ys.split("/").map((u,v,S)=>{const k=S.slice(0,v+1).join("/");return e.jsxs(Wt.Fragment,{children:[e.jsx("span",{className:"team_fs_crumb_sep",children:"/"}),e.jsx("button",{className:`team_fs_crumb ${v===S.length-1?"active":""}`,onClick:()=>sn(k),children:u})]},k)}):null]}),e.jsx("div",{className:"pane_body pane_body_list",children:Js===null&&!ba?e.jsx("div",{className:"muted team_note",children:"Loading files…"}):ba?e.jsx("div",{className:"page_error mono",children:ba}):Js&&Js.length?(()=>{const{dirs:u,leaves:v}=tx(Js,Ys);return!u.length&&!v.length?e.jsx("div",{className:"muted team_note",children:"Empty folder."}):e.jsxs(e.Fragment,{children:[u.map(S=>e.jsxs("button",{className:"team_file_row team_fs_dir",onClick:()=>sn(S.path),title:`${S.count} file(s) inside`,children:[e.jsx("span",{className:"team_fs_icon",children:e.jsx(Ax,{})}),e.jsx("span",{className:"team_file_path",children:S.name}),e.jsx("span",{className:"team_file_meta mono",children:S.count})]},S.path)),v.map(S=>e.jsxs("button",{className:"team_file_row",onClick:()=>void fr(S),title:`${S.updated_by||"?"} · ${Ml(S.updated_at)} · v${S.version} · ${Vn(S.size)}`,children:[e.jsx("span",{className:"team_fs_icon",children:e.jsx(sh,{})}),e.jsxs("span",{className:"team_file_name_wrap",children:[e.jsx("span",{className:"team_file_path",children:S.path.slice(Ys?Ys.length+1:0)}),S.description?e.jsx("span",{className:"team_file_desc muted",children:S.description}):null]}),e.jsxs("span",{className:"team_file_meta mono",children:[Vn(S.size)," · ",Ll(S.updated_at)]})]},S.path))]})})():e.jsx("div",{className:"muted team_note",children:"No files in this channel's virtual filesystem yet."})})]}):null,Et==="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:wn==="hub"?"hub-wide":`#${I}`}),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 ${wn==="channel"?"active":""}`,onClick:()=>{xa("channel"),Ui("channel")},disabled:!I,title:`This channel's board (#${I||"…"})`,children:"Channel"}),e.jsx("button",{className:`team_lb_scope_btn ${wn==="hub"?"active":""}`,onClick:()=>{xa("hub"),Ui("hub")},title:"Hub-wide: the sum of every channel's scores",children:"Hub"})]}),e.jsx("button",{className:"btn btn_icon",onClick:()=>Qn(""),title:"Close",children:"✕"})]})]}),e.jsx("div",{className:"pane_body pane_body_list team_lb_body",children:Pn===null&&!Gr?e.jsx("div",{className:"muted team_note",children:"Loading leaderboard…"}):Gr?e.jsx("div",{className:"muted team_note",children:Gr}):!Pn||Pn.leaderboard.length===0?e.jsx("div",{className:"muted team_note",children:Array.isArray(Pn==null?void 0:Pn.categories)?`No reputation yet${wn==="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${wn==="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 k;const u=Array.isArray(Pn.categories)||Pn.leaderboard.some(R=>R.breakdown!=null||typeof R.score=="number"),v=u?(k=Pn.categories)!=null&&k.length?Pn.categories:["general",...ji.map(R=>R.id)]:[],S=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:S,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(R=>e.jsx("span",{className:"team_lb_legend_axis",title:rh[R]||`${zl(R)} — reputation category.`,children:zl(R)},R))]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"team_lb_legend_total",title:"Sum of all axis scores",children:"Total"}),ji.map(R=>e.jsx("span",{className:"team_lb_legend_axis",title:R.help,children:R.label},R.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"})]})]}),Pn.leaderboard.map((R,se)=>e.jsxs(Wt.Fragment,{children:[e.jsxs("div",{className:`team_lb_row ${ms===R.target?"open":""}`,style:S,onClick:()=>Wi(R.target),role:"button",tabIndex:0,onKeyDown:F=>{(F.key==="Enter"||F.key===" ")&&(F.preventDefault(),Wi(R.target))},title:wn==="hub"?`${R.target}: rated in ${R.channels||0} channel(s) by ${R.raters} rater(s)`:u?`${R.target}: ${R.raters} rater(s) — click for attributed OPINION votes (general/thumbs live on the messages themselves)`:`${R.target}: ${R.raters} rater(s) — click for the votes behind the score`,children:[e.jsx("span",{className:`team_lb_rank ${se<3?`top${se+1}`:""}`,"aria-hidden":"true",children:se<3?"●":se+1}),e.jsx("span",{className:"team_avatar",style:Ga(R.target),"aria-hidden":"true",children:R.target.slice(0,1).toUpperCase()}),e.jsx("span",{className:"team_lb_agent",children:R.target}),u?e.jsxs(e.Fragment,{children:[(()=>{const F=Number(R.score||0),ye=R.votes;return e.jsxs("span",{className:`team_lb_total ${F>0?"pos":F<0?"neg":""}`,title:(()=>{const Pe=Object.entries(R.breakdown||{}).filter(([,Ue])=>Ue&&Number(Ue.score||0)!==0).map(([Ue,Ve])=>`${zl(Ue)} ${Number(Ve.score)>0?"+":""}${Number(Ve.score)}`).join(" · ");return`${R.target}: score ${F>0?"+":""}${F} = ${Pe||"no standing voices"} (categories sum; every standing vote counts — operator ruling dm#161)${ye?` — total: ${ye.up} up, ${ye.down} down`:""}`})(),children:[F>0?`+${F}`:F,ye&&(ye.up||ye.down)?e.jsxs("span",{className:"team_lb_rawvotes mono",children:[" ",e.jsxs("span",{className:"rv_up",children:[ye.up,"↑"]}),e.jsxs("span",{className:ye.down>0?"rv_down_hot":"rv_down",children:[ye.down,"↓"]})]}):null]})})(),v.map(F=>{var Ve;const ye=(Ve=R.breakdown)==null?void 0:Ve[F],Pe=Number((ye==null?void 0:ye.score)||0),Ue=!!(ye&&(ye.up||ye.down||ye.raters));return e.jsx("span",{className:`team_lb_axis ${Pe>0?"pos":Pe<0?"neg":""}`,title:Ue?`${zl(F)}: ${Pe>0?"+":""}${Pe} (▲${ye.up} ▼${ye.down} voices · ${ye.raters} engaged colleague${ye.raters===1?"":"s"}) — ${rh[F]||"reputation category"}`:`${zl(F)}: no standing input`,children:Ue?Pe>0?`+${Pe}`:Pe:"·"},F)})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:`team_lb_total ${(R.total||0)>0?"pos":(R.total||0)<0?"neg":""}`,children:(R.total||0)>0?`+${R.total}`:R.total||0}),ji.map(F=>{var Ue;const ye=(Ue=R.axes)==null?void 0:Ue[F.id],Pe=(ye==null?void 0:ye.score)||0;return e.jsx("span",{className:`team_lb_axis ${Pe>0?"pos":Pe<0?"neg":""}`,title:ye?`${F.label}: ${ye.up} up, ${ye.down} down`:`${F.label}: no votes`,children:ye?Pe>0?`+${Pe}`:Pe:"·"},F.id)}),(()=>{const F=R.messages,ye=F?F.up-F.down:0;return e.jsx("span",{className:`team_lb_axis ${ye>0?"pos":ye<0?"neg":""}`,title:F&&(F.up||F.down)?`Message ratings: ${F.up} rater(s) net-up, ${F.down} net-down (per-rater collapse — flips cancel)`:"Message ratings: none standing",children:F&&(F.up||F.down)?`▲${F.up}${F.down?` ▼${F.down}`:""}`:"·"})})()]})]}),ms===R.target&&wn==="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 ${yt} — one live ±1 per axis; casting again revises, never stacks`,children:["rate as ",yt||"operator",":"]}),ji.map(F=>e.jsxs("span",{className:"team_lb_cast_axis",title:F.help,children:[e.jsx("span",{className:"team_lb_cast_axis_name",children:F.label}),e.jsx("button",{className:"btn btn_icon team_lb_vote up",disabled:!!or||R.target===yt,onClick:ye=>{ye.stopPropagation(),Gi(R.target,F.id,1)},title:`+1 ${F.label} for ${R.target}`,children:e.jsx(tt,{name:"thumbsUp",size:12})}),e.jsx("button",{className:"btn btn_icon team_lb_vote down",disabled:!!or||R.target===yt,onClick:ye=>{ye.stopPropagation(),Gi(R.target,F.id,-1)},title:`-1 ${F.label} for ${R.target}`,children:e.jsx(tt,{name:"thumbsDown",size:12})})]},F.id))]}),e.jsx("input",{className:"team_lb_note",placeholder:"why — one line, on the record (optional, applies to your next vote)",value:Kr,maxLength:280,onChange:F=>lr(F.target.value),onClick:F=>F.stopPropagation()}),In?e.jsx("div",{className:"team_lb_error",children:In}):null,Ri===null?e.jsx("div",{className:"muted team_note",children:"Loading votes…"}):Ri.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."}):Ri.map(F=>e.jsxs("div",{className:"team_lb_vote_row",children:[e.jsx("span",{className:"team_avatar team_avatar_sm",style:Ga(F.rater),"aria-hidden":"true",children:F.rater.slice(0,1).toUpperCase()}),e.jsx("span",{className:"team_lb_vote_rater",children:F.rater}),e.jsx("span",{className:"team_lb_vote_axis",children:F.axis}),e.jsx(tt,{name:F.value>0?"thumbsUpFilled":"thumbsDownFilled",size:12,className:`team_lb_vote_val ${F.value>0?"pos":"neg"}`,title:F.value>0?"+1":"-1"}),e.jsx("span",{className:"team_lb_vote_note",title:F.note,children:F.note||e.jsx("span",{className:"muted",children:"no note"})})]},`${F.rater}:${F.axis}`))]}):null,ms===R.target&&wn==="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]},R.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,Et==="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 oe(),title:"Reload",children:"Refresh"}),e.jsx("button",{className:"btn btn_icon",onClick:()=>Qn(""),title:"Close",children:"✕"})]})]}),e.jsxs("div",{className:"pane_body pane_body_list",children:[Y==="loading"?e.jsx("div",{className:"muted team_note",children:"Loading…"}):null,Y===null&&V?e.jsx("div",{className:"muted team_note",children:V}):null,Y!==null&&Y!=="loading"?e.jsxs(e.Fragment,{children:[Y.rows.length?null:e.jsx("div",{className:"muted team_note",children:"Nothing waits on you. Clear desk."}),Y.rows.map((u,v)=>{const S=Number(u.age_minutes),k=Number.isFinite(S)?S<60?`${Math.max(1,Math.round(S))}m`:S<2880?`${Math.round(S/60)}h`:`${Math.round(S/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:k})]}),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:()=>{Jn.current={message_id:u.id?String(u.id):void 0,seq:Number(u.seq)||void 0},String(u.channel)===I?hr():be(String(u.channel)),Qn("")},title:"Open the message that waits on you",children:"open ↗"}):null]},String(u.id||u.key||v))}),Y.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:"}),Y.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:[d?e.jsx("button",{className:`team_drawer_tab ${Et==="assistant"?"active":""}`,onClick:()=>ns("assistant"),disabled:!I,"aria-pressed":Et==="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 ${Et==="members"?"active":""}`,onClick:()=>ns("members"),disabled:!I,"aria-pressed":Et==="members","aria-label":"Open channel members drawer",title:"Channel members — roster, moderation, and channel lifecycle",children:"Members"}),e.jsx("button",{className:`team_drawer_tab ${Et==="files"?"active":""}`,onClick:()=>ns("files"),disabled:!I,"aria-pressed":Et==="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 ${Et==="leaderboard"?"active":""}`,onClick:()=>ns("leaderboard"),disabled:!I,"aria-pressed":Et==="leaderboard","aria-label":"Open reputation leaderboard drawer",title:"Reputation leaderboard — trust, wisdom, thorough, helper; per-channel and hub-wide",children:"Leaderboard"}),(()=>{const u=Y!==null&&Y!=="loading"?Y:null,v=u?u.rows.length:0,S=u?u.satisfied.length:0;return e.jsxs("button",{className:`team_drawer_tab ${Et==="desk"?"active":""}`,onClick:()=>ns("desk"),"aria-pressed":Et==="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&&S?e.jsx("span",{className:"team_desk_tab_badge ok",title:"Satisfied queue items — waits you can close",children:S>99?"99+":S}):null]})})()]})]}),e.jsx(xx,{view:ja,onClose:()=>Kt(null)})]})}const ih=[{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"}],dd="abstractcontinuum_settings_v1";function Px(){try{const a=window.localStorage.getItem(dd)||"{}",s=JSON.parse(a);if(s&&(s.auth_token||s.gateway_url)){delete s.auth_token,delete s.gateway_url;try{window.localStorage.setItem(dd,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 Ix(){var Ge;const[a,s]=f.useState("board"),r=e_("(max-width: 1023.98px)"),[l,c]=f.useState(!1),d=f.useRef(null),p=f.useRef(null),m=f.useRef(!1);f.useEffect(()=>{r||c(!1)},[r]),f.useEffect(()=>{var de,H;if(r){if(l){const fe=window.setTimeout(()=>{var X;const we=(X=p.current)==null?void 0:X.querySelector(".shell_nav_item.active, .shell_nav_item");we==null||we.focus()},0);return()=>window.clearTimeout(fe)}m.current&&(document.activeElement===document.body||!document.activeElement||(de=p.current)!=null&&de.contains(document.activeElement))&&((H=d.current)==null||H.focus())}},[l,r]),f.useEffect(()=>{m.current=l},[l]);function _(de){s(de),c(!1)}const[x,b]=f.useState(null),[y,C]=f.useState(null),[A,E]=f.useState(()=>Px()),[$,L]=f.useState(!1),[q,O]=f.useState(!1),[D,K]=f.useState(0),[T,te]=f.useState(!1),[ue,re]=f.useState(!1),[Te,je]=ig("continuum"),[Ce,xe]=f.useState(0),[J,ne]=f.useState(null),[ve,W]=f.useState("");f.useEffect(()=>{if(!J)return;const de=setTimeout(()=>ne(null),8e3);return()=>clearTimeout(de)},[J]);const[Y,z]=f.useState(!1);f.useEffect(()=>{var Q;const de=((Q=document.querySelector('script[type="module"][src*="assets/"]'))==null?void 0:Q.getAttribute("src"))||"";if(!de)return;let H=!1;async function fe(){try{const _e=await fetch("./",{cache:"no-store",signal:AbortSignal.timeout(8e3)});if(!_e.ok)return;const ot=(await _e.text()).match(/<script[^>]+type="module"[^>]+src="([^"]+)"/),ce=(ot==null?void 0:ot[1])||"";!H&&ce&&de&&ce!==de&&z(!0)}catch{}}const we=()=>void fe();window.addEventListener("focus",we);const X=setInterval(()=>void fe(),300*1e3);return fe(),()=>{H=!0,window.removeEventListener("focus",we),clearInterval(X)}},[]);function V(de){W(String(de||"")),s("executions")}f.useEffect(()=>{const de=H=>{var fe;Array.from(((fe=H.dataTransfer)==null?void 0:fe.types)||[]).includes("Files")&&H.preventDefault()};return window.addEventListener("dragover",de),window.addEventListener("drop",de),()=>{window.removeEventListener("dragover",de),window.removeEventListener("drop",de)}},[]);const[U,w]=f.useState(!1);f.useEffect(()=>{a==="team"&&w(!0)},[a]);function N(de){var X;const H=de.target,fe=(X=H==null?void 0:H.closest)==null?void 0:X.call(H,"a[href]");if(!fe||fe.target==="_blank"||fe.hasAttribute("download"))return;const we=fe.getAttribute("href")||"";we.startsWith("/")&&(de.preventDefault(),window.open(we,"_blank","noopener"))}f.useEffect(()=>{try{window.localStorage.setItem(dd,JSON.stringify(A))}catch{}},[A]);const Z=f.useMemo(()=>new Jg({base_url:""}),[]),pe=I_({appName:"AbstractContinuum",connectionPath:Ci,onStatusChange:()=>K(de=>de+1)}),oe=pe.status,I=f.useMemo(()=>Q_("abstractcontinuum",Vg),[]),[be,Re]=f.useState(jf),qe=f.useRef(0);function Oe(){const de=++qe.current;Re(jf),Xg(Z).then(H=>{de===qe.current&&Re(H)})}const ut=f.useRef(0);f.useEffect(()=>{let de=!1,H;return(async()=>{try{await Z.list_processes(),de||(ut.current=0,L(!0))}catch{if(de)return;ut.current+=1,ut.current>=2?L(!1):H=window.setTimeout(()=>{de||K(fe=>fe+1)},2e3)}})(),()=>{de=!0,H!==void 0&&window.clearTimeout(H)}},[Z,a,D]);const he=f.useRef($);f.useEffect(()=>{he.current&&!$&&(oe!=null&&oe.has_session)&&pe.refresh(),he.current=$},[$,oe==null?void 0:oe.has_session]);async function Fe(de,H){const fe=[...H.history.map(X=>({role:X.role,content:X.content})),{role:"user",content:de}],we=await Z.backlog_advisor({messages:fe,agent:A.backlog_advisor_agent||null});return String((we==null?void 0:we.reply)||"").trim()||"(the advisor returned an empty reply)"}const Le=e.jsxs(e.Fragment,{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","aria-label":"Pages",children:ih.map(de=>e.jsxs("button",{className:`shell_nav_item ${a===de.id?"active":""}`,onClick:()=>_(de.id),title:de.label,"aria-current":a===de.id?"page":void 0,children:[e.jsx("span",{className:"shell_nav_icon",children:e.jsx(tt,{name:de.icon,size:16})}),e.jsx("span",{className:"shell_nav_label",children:de.label})]},de.id))})]});return e.jsxs("div",{className:"shell",onClickCapture:N,children:[r?null:e.jsx("aside",{className:"shell_sidebar",children:Le}),e.jsxs("div",{className:"shell_main",...r&&l?{inert:""}:{},children:[e.jsxs("header",{className:"shell_header",children:[r?e.jsx("button",{ref:d,type:"button",className:"btn btn_icon shell_menu_btn","aria-label":"Open navigation","aria-expanded":l,title:"Pages",onClick:()=>c(de=>!de),children:e.jsx(tt,{name:"list",size:18})}):null,e.jsx("div",{className:"shell_header_title",children:((Ge=ih.find(de=>de.id===a))==null?void 0:Ge.label)||""}),e.jsx("div",{className:"shell_header_actions",children:e.jsx(sg,{assistant:{open:T,onToggle:()=>te(de=>!de)},appearance:{onOpen:()=>re(!0)},about:{identity:I,extraRows:be,onOpen:Oe},extraActions:e.jsxs("button",{className:"btn primary shell_newtask_btn",onClick:()=>O(!0),disabled:!$,"aria-label":"+ New task",title:"New task",children:["+",e.jsx("span",{className:"shell_newtask_label",children:" New task"})]}),connection:{phase:pe.phase,signingOut:pe.signingOut,onConnect:pe.openModal,onDisconnect:()=>void pe.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:pe.openModal,children:"Connect"})]}):null,pe.signOutError?e.jsx("div",{className:"shell_banner",children:e.jsxs("span",{children:["Sign-out failed: ",pe.signOutError," — the session may still be live."]})}):null,J?e.jsxs("div",{className:`shell_banner ${J.tone==="warn"?"":"shell_banner_ok"}`,children:[e.jsx("span",{children:J.text}),e.jsx("button",{className:"btn",onClick:()=>ne(null),children:"Dismiss"})]}):null,Y?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(sy,{gateway:Z,gateway_connected:$,data_nonce:Ce,on_mutated:()=>xe(de=>de+1),on_open_executions:V,default_execution_mode:A.default_execution_mode,query_preset:x,on_query_preset_consumed:()=>b(null),on_open_team:de=>{C(de),s("team")},on_new_task:()=>O(!0)}):null,a==="executions"?e.jsx(vy,{gateway:Z,gateway_connected:$,focus_request_id:ve,on_focus_consumed:()=>W(""),on_open_settings:()=>s("settings")}):null,a==="backlog"?e.jsx(Uv,{gateway:Z,gateway_connected:$,maintenance_ai_provider:A.maintenance_ai_provider,maintenance_ai_model:A.maintenance_ai_model,maintenance_ai_reasoning:A.maintenance_ai_reasoning,backlog_advisor_agent:A.backlog_advisor_agent,default_execution_mode:A.default_execution_mode,on_open_executions:V}):null,a==="agents"?e.jsx(gv,{gateway:Z,gateway_connected:$,backlog_advisor_agent:A.backlog_advisor_agent,on_open_assistant:()=>te(!0),on_open_team:()=>s("team"),on_open_executions:()=>V()}):null,U?e.jsx("div",{style:{display:a==="team"?"contents":"none"},children:e.jsx(Hh,{fallback:de=>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(de.message||de)}),e.jsx("button",{className:"btn",onClick:()=>window.location.reload(),children:"Reload"})]})}),children:e.jsx(zx,{gateway:Z,gateway_connected:$,advisor:$?async(de,H)=>{const fe=[...H.map(X=>({role:X.role,content:X.content})),{role:"user",content:de}],we=await Z.backlog_advisor({messages:fe,agent:A.backlog_advisor_agent||null});return String((we==null?void 0:we.reply)||"").trim()||"(the model returned an empty reply)"}:void 0,advisor_agent:A.backlog_advisor_agent,on_open_board:de=>{b(de||null),s("board")},focus:y,on_focus_consumed:()=>C(null)})})}):null,a==="inbox"?e.jsx(jy,{gateway:Z,gateway_connected:$,enable_triage:!0}):null,a==="services"?e.jsx(by,{gateway:Z,gateway_connected:$}):null,a==="settings"?e.jsx(Py,{gateway:Z,gateway_connected:$,settings:A,set_settings:E,connection:oe}):null]})]}),e.jsx(z_,{...pe.modalProps}),r?e.jsx(mf,{open:l,onClose:()=>c(!1),label:"Navigation",side:"left",backdrop:!0,width:260,className:"shell_nav_drawer",children:e.jsxs("div",{ref:p,className:"shell_nav_drawer_body",children:[Le,e.jsx("button",{type:"button",className:"btn shell_nav_close",onClick:()=>c(!1),children:"Close menu"})]})}):null,e.jsx(mf,{open:T,onClose:()=>te(!1),label:"Assistant",title:"Continuum assistant",children:e.jsx(Wg,{ask:Fe,assistantName:"Continuum advisor",blockedNotice:$?void 0:"Connect to the gateway to use the assistant."})}),e.jsx(lg,{open:ue,onClose:()=>re(!1),value:Te,onChange:je}),e.jsx(Wv,{open:q,gateway:Z,can_use_gateway:$,maint_provider:A.maintenance_ai_provider,maint_model:A.maintenance_ai_model,maint_reasoning:A.maintenance_ai_reasoning,on_close:()=>O(!1),on_created:async(de,H,fe)=>{xe(X=>X+1);const we=String(de||"");s(we==="recurrent"?"backlog":"board"),ne(fe?{text:`Task created (${H}), but attachments failed: ${fe}`,tone:"warn"}:{text:`Task created: ${H} (${we||"?"})${we==="recurrent"?" — recurrent items live on the Backlog page":""}`,tone:"ok"})}})]})}n_();const ap=document.getElementById("root");if(!ap)throw new Error("root element missing");Qp.createRoot(ap).render(e.jsx(Wt.StrictMode,{children:e.jsx(Ix,{})}));export{qy as _,qp as g};
122
+ //# sourceMappingURL=index-SU9S3HCp.js.map