@abstractframework/continuum 0.6.0 → 0.7.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 (69) hide show
  1. package/README.md +4 -2
  2. package/bin/server.js +6 -2
  3. package/dist/assets/{abnfDiagram-VRR7QNED-DUoj6rgR.js → abnfDiagram-VRR7QNED-BkCygcef.js} +2 -2
  4. package/dist/assets/{arc-I6yCEc-n.js → arc-DkiQoXvp.js} +2 -2
  5. package/dist/assets/{architectureDiagram-ZJ3FMSHR-DJYsy6Ke.js → architectureDiagram-ZJ3FMSHR-WkJw8Cvt.js} +2 -2
  6. package/dist/assets/{blockDiagram-677ZJIJ3-BjB9Abvu.js → blockDiagram-677ZJIJ3-B8HoFrN8.js} +2 -2
  7. package/dist/assets/{c4Diagram-LMCZKHZV-DiukFpvk.js → c4Diagram-LMCZKHZV-BIWuZCGJ.js} +2 -2
  8. package/dist/assets/channel-BQEXVd1j.js +2 -0
  9. package/dist/assets/{chunk-2Q5K7J3B-Bzj3nCUE.js → chunk-2Q5K7J3B-nDhYcRFM.js} +2 -2
  10. package/dist/assets/{chunk-32BRIVSS-P-cd15lV.js → chunk-32BRIVSS-C2_qIhxb.js} +2 -2
  11. package/dist/assets/{chunk-5VM5RSS4-C926qres.js → chunk-5VM5RSS4-Ds5OtV9F.js} +2 -2
  12. package/dist/assets/{chunk-EX3LRPZG-D-8MH237.js → chunk-EX3LRPZG-BAm7QoTq.js} +2 -2
  13. package/dist/assets/{chunk-JWPE2WC7-xesmSJf_.js → chunk-JWPE2WC7-CnjNdoOE.js} +2 -2
  14. package/dist/assets/{chunk-MOJQB5TN-Cur1aPrT.js → chunk-MOJQB5TN--BraWVgU.js} +2 -2
  15. package/dist/assets/{chunk-RYQCIY6F-BVTILQCf.js → chunk-RYQCIY6F-DLMWDQ0Q.js} +2 -2
  16. package/dist/assets/{chunk-V7JOEXUC-DH8DqqLP.js → chunk-V7JOEXUC-COYUWngy.js} +2 -2
  17. package/dist/assets/{chunk-VR4S4FIN-DONA5ZQE.js → chunk-VR4S4FIN-cBShPlG3.js} +2 -2
  18. package/dist/assets/{chunk-XXDRQBXY-Cj5h3H9W.js → chunk-XXDRQBXY-BdltLfdH.js} +2 -2
  19. package/dist/assets/classDiagram-OUVF2IWQ-Dq_ZnTHn.js +2 -0
  20. package/dist/assets/classDiagram-v2-EOCWNBFH-Dq_ZnTHn.js +2 -0
  21. package/dist/assets/{cose-bilkent-JH36ORCC-DPp5nz7X.js → cose-bilkent-JH36ORCC-CriiiA1W.js} +2 -2
  22. package/dist/assets/{cynefin-VYW2F7L2-Cb1VDqjx.js → cynefin-VYW2F7L2-B6yQgOOu.js} +2 -2
  23. package/dist/assets/{cynefinDiagram-TSTJHNR4-BkVCVAKN.js → cynefinDiagram-TSTJHNR4-C8emEjd0.js} +2 -2
  24. package/dist/assets/{dagre-VKFMJZFB-C69yqHLO.js → dagre-VKFMJZFB-BIJn-mHf.js} +2 -2
  25. package/dist/assets/{diagram-FQU43EPY-Cu2AB9_p.js → diagram-FQU43EPY-Dg9b5T9y.js} +2 -2
  26. package/dist/assets/{diagram-G47NLZAW-CxoS06le.js → diagram-G47NLZAW-DNWKcP0M.js} +2 -2
  27. package/dist/assets/{diagram-NH7WQ7WH-BfWvQlGK.js → diagram-NH7WQ7WH-Dh7LCsm6.js} +2 -2
  28. package/dist/assets/{diagram-OA4YK3LP-BT4lqaBM.js → diagram-OA4YK3LP-DGui41hj.js} +2 -2
  29. package/dist/assets/{diagram-WEI45ONY-DzN57p-J.js → diagram-WEI45ONY-D8bBXuUh.js} +2 -2
  30. package/dist/assets/{ebnfDiagram-CCIWWBDH-DENI1vQm.js → ebnfDiagram-CCIWWBDH-DvFVLPnE.js} +2 -2
  31. package/dist/assets/{erDiagram-Q63AITRT-D0Xg--j1.js → erDiagram-Q63AITRT-BQo91G3p.js} +2 -2
  32. package/dist/assets/{flowDiagram-23GEKE2U-V_z3dBhe.js → flowDiagram-23GEKE2U-fVKeQN9U.js} +2 -2
  33. package/dist/assets/{ganttDiagram-NO4QXBWP-9QKS4cRZ.js → ganttDiagram-NO4QXBWP-A8RklV-w.js} +2 -2
  34. package/dist/assets/{gitGraphDiagram-IHSO6WYX-DfBBOfgk.js → gitGraphDiagram-IHSO6WYX-WSHAZPJs.js} +2 -2
  35. package/dist/assets/index-CR9HWWKP.js +132 -0
  36. package/dist/assets/index-m-kU9uPQ.css +1 -0
  37. package/dist/assets/{infoDiagram-FWYZ7A6U-2PxB9AEr.js → infoDiagram-FWYZ7A6U-B8BQ-byg.js} +2 -2
  38. package/dist/assets/{ishikawaDiagram-FXEZZL3T-BPs88htZ.js → ishikawaDiagram-FXEZZL3T-Daz7jyWg.js} +2 -2
  39. package/dist/assets/{journeyDiagram-5HDEW3XC-D59tgM9D.js → journeyDiagram-5HDEW3XC-11wxjK2f.js} +2 -2
  40. package/dist/assets/{kanban-definition-HUTT4EX6-MfmvVLTi.js → kanban-definition-HUTT4EX6-DJef0s2q.js} +2 -2
  41. package/dist/assets/{linear-DUi9ti0c.js → linear-BMG2M7Ce.js} +2 -2
  42. package/dist/assets/{mermaid.core-i20J3FaS.js → mermaid.core-BMJA9D_k.js} +5 -5
  43. package/dist/assets/{mindmap-definition-LN4V7U3C-D2Q7oe5w.js → mindmap-definition-LN4V7U3C-gr1IFJI9.js} +2 -2
  44. package/dist/assets/{pegDiagram-2B236MQR-CNmY3KTl.js → pegDiagram-2B236MQR-CzsU066n.js} +2 -2
  45. package/dist/assets/{pieDiagram-ENE6RG2P-Ch2esIfg.js → pieDiagram-ENE6RG2P-lpLc7Bkk.js} +2 -2
  46. package/dist/assets/{quadrantDiagram-ABIIQ3AL-CJHDjhnh.js → quadrantDiagram-ABIIQ3AL-CqhTXAcd.js} +2 -2
  47. package/dist/assets/{railroadDiagram-RFXS5EU6-C_mgIhjT.js → railroadDiagram-RFXS5EU6-B89ZlXNF.js} +2 -2
  48. package/dist/assets/{requirementDiagram-TGXJPOKE-C-tQSD22.js → requirementDiagram-TGXJPOKE-zNVlbejn.js} +2 -2
  49. package/dist/assets/{sankeyDiagram-HTMAVEWB-D2zvcJ4r.js → sankeyDiagram-HTMAVEWB-COkL2oY3.js} +2 -2
  50. package/dist/assets/{sequenceDiagram-DBY2YBRQ-CI0liPpW.js → sequenceDiagram-DBY2YBRQ-73X01Y7f.js} +2 -2
  51. package/dist/assets/{sizeCapture-X5ZJPWSS-8-Z0Kdmg.js → sizeCapture-X5ZJPWSS-ChraD57T.js} +2 -2
  52. package/dist/assets/{stateDiagram-2N3HPSRC-D335WS9r.js → stateDiagram-2N3HPSRC-uJpYsAbo.js} +2 -2
  53. package/dist/assets/stateDiagram-v2-6OUMAXLB-CFl8uBM6.js +2 -0
  54. package/dist/assets/{swimlanes-5IMT3BWC-BO-KsJgL.js → swimlanes-5IMT3BWC-DxyGIMCn.js} +3 -3
  55. package/dist/assets/swimlanesDiagram-G3AALYLV-C-9buTT1.js +9 -0
  56. package/dist/assets/{timeline-definition-FHXFAJF6-BuN-EhNZ.js → timeline-definition-FHXFAJF6-CdGOZgIj.js} +2 -2
  57. package/dist/assets/{vennDiagram-L72KCM5P-CeZevnKl.js → vennDiagram-L72KCM5P-BteXKSRO.js} +2 -2
  58. package/dist/assets/{wardleyDiagram-EHGQE667-D7kBjKl4.js → wardleyDiagram-EHGQE667-DbJh6h5t.js} +2 -2
  59. package/dist/assets/{xychartDiagram-FW5EYKEG-D7uR7Ic7.js → xychartDiagram-FW5EYKEG-qAuHPQiH.js} +2 -2
  60. package/dist/index.html +2 -2
  61. package/dist/llms.txt +65 -0
  62. package/package.json +3 -3
  63. package/dist/assets/channel-CsGWNVeB.js +0 -2
  64. package/dist/assets/classDiagram-OUVF2IWQ-BRgLg1Zt.js +0 -2
  65. package/dist/assets/classDiagram-v2-EOCWNBFH-BRgLg1Zt.js +0 -2
  66. package/dist/assets/index-C_TjOHlB.css +0 -1
  67. package/dist/assets/index-SU9S3HCp.js +0 -122
  68. package/dist/assets/stateDiagram-v2-6OUMAXLB-DnoX14wc.js +0 -2
  69. package/dist/assets/swimlanesDiagram-G3AALYLV-DIwiFP1r.js +0 -9
@@ -0,0 +1,132 @@
1
+ var b_=Object.defineProperty;var w_=(a,n,r)=>n in a?b_(a,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[n]=r;var Ka=(a,n,r)=>w_(a,typeof n!="symbol"?n+"":n,r);(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))i(l);new MutationObserver(l=>{for(const u of l)if(u.type==="childList")for(const m of u.addedNodes)m.tagName==="LINK"&&m.rel==="modulepreload"&&i(m)}).observe(document,{childList:!0,subtree:!0});function r(l){const u={};return l.integrity&&(u.integrity=l.integrity),l.referrerPolicy&&(u.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?u.credentials="include":l.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function i(l){if(l.ep)return;l.ep=!0;const u=r(l);fetch(l.href,u)}})();function j_(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var Fu={exports:{}},Ao={},qu={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 wf;function k_(){if(wf)return pt;wf=1;var a=Symbol.for("react.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),m=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),b=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),y=Symbol.iterator;function C(k){return k===null||typeof k!="object"?null:(k=y&&k[y]||k["@@iterator"],typeof k=="function"?k:null)}var L={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},T=Object.assign,$={};function E(k,w,K){this.props=k,this.context=w,this.refs=$,this.updater=K||L}E.prototype.isReactComponent={},E.prototype.setState=function(k,w){if(typeof k!="object"&&typeof k!="function"&&k!=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,k,w,"setState")},E.prototype.forceUpdate=function(k){this.updater.enqueueForceUpdate(this,k,"forceUpdate")};function I(){}I.prototype=E.prototype;function D(k,w,K){this.props=k,this.context=w,this.refs=$,this.updater=K||L}var O=D.prototype=new I;O.constructor=D,T(O,E.prototype),O.isPureReactComponent=!0;var q=Array.isArray,A=Object.prototype.hasOwnProperty,H={current:null},fe={key:!0,ref:!0,__self:!0,__source:!0};function ie(k,w,K){var ve,he={},z=null,be=null;if(w!=null)for(ve in w.ref!==void 0&&(be=w.ref),w.key!==void 0&&(z=""+w.key),w)A.call(w,ve)&&!fe.hasOwnProperty(ve)&&(he[ve]=w[ve]);var Ae=arguments.length-2;if(Ae===1)he.children=K;else if(1<Ae){for(var De=Array(Ae),Me=0;Me<Ae;Me++)De[Me]=arguments[Me+2];he.children=De}if(k&&k.defaultProps)for(ve in Ae=k.defaultProps,Ae)he[ve]===void 0&&(he[ve]=Ae[ve]);return{$$typeof:a,type:k,key:z,ref:be,props:he,_owner:H.current}}function Se(k,w){return{$$typeof:a,type:k.type,key:w,ref:k.ref,props:k.props,_owner:k._owner}}function ke(k){return typeof k=="object"&&k!==null&&k.$$typeof===a}function le(k){var w={"=":"=0",":":"=2"};return"$"+k.replace(/[=:]/g,function(K){return w[K]})}var pe=/\/+/g;function G(k,w){return typeof k=="object"&&k!==null&&k.key!=null?le(""+k.key):w.toString(36)}function te(k,w,K,ve,he){var z=typeof k;(z==="undefined"||z==="boolean")&&(k=null);var be=!1;if(k===null)be=!0;else switch(z){case"string":case"number":be=!0;break;case"object":switch(k.$$typeof){case a:case n:be=!0}}if(be)return be=k,he=he(be),k=ve===""?"."+G(be,0):ve,q(he)?(K="",k!=null&&(K=k.replace(pe,"$&/")+"/"),te(he,w,K,"",function(Me){return Me})):he!=null&&(ke(he)&&(he=Se(he,K+(!he.key||be&&be.key===he.key?"":(""+he.key).replace(pe,"$&/")+"/")+k)),w.push(he)),1;if(be=0,ve=ve===""?".":ve+":",q(k))for(var Ae=0;Ae<k.length;Ae++){z=k[Ae];var De=ve+G(z,Ae);be+=te(z,w,K,De,he)}else if(De=C(k),typeof De=="function")for(k=De.call(k),Ae=0;!(z=k.next()).done;)z=z.value,De=ve+G(z,Ae++),be+=te(z,w,K,De,he);else if(z==="object")throw w=String(k),Error("Objects are not valid as a React child (found: "+(w==="[object Object]"?"object with keys {"+Object.keys(k).join(", ")+"}":w)+"). If you meant to render a collection of children, use an array instead.");return be}function ae(k,w,K){if(k==null)return k;var ve=[],he=0;return te(k,ve,"","",function(z){return w.call(K,z,he++)}),ve}function U(k){if(k._status===-1){var w=k._result;w=w(),w.then(function(K){(k._status===0||k._status===-1)&&(k._status=1,k._result=K)},function(K){(k._status===0||k._status===-1)&&(k._status=2,k._result=K)}),k._status===-1&&(k._status=0,k._result=w)}if(k._status===1)return k._result.default;throw k._result}var Q={current:null},M={transition:null},Z={ReactCurrentDispatcher:Q,ReactCurrentBatchConfig:M,ReactCurrentOwner:H};function ne(){throw Error("act(...) is not supported in production builds of React.")}return pt.Children={map:ae,forEach:function(k,w,K){ae(k,function(){w.apply(this,arguments)},K)},count:function(k){var w=0;return ae(k,function(){w++}),w},toArray:function(k){return ae(k,function(w){return w})||[]},only:function(k){if(!ke(k))throw Error("React.Children.only expected to receive a single React element child.");return k}},pt.Component=E,pt.Fragment=r,pt.Profiler=l,pt.PureComponent=D,pt.StrictMode=i,pt.Suspense=p,pt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Z,pt.act=ne,pt.cloneElement=function(k,w,K){if(k==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+k+".");var ve=T({},k.props),he=k.key,z=k.ref,be=k._owner;if(w!=null){if(w.ref!==void 0&&(z=w.ref,be=H.current),w.key!==void 0&&(he=""+w.key),k.type&&k.type.defaultProps)var Ae=k.type.defaultProps;for(De in w)A.call(w,De)&&!fe.hasOwnProperty(De)&&(ve[De]=w[De]===void 0&&Ae!==void 0?Ae[De]:w[De])}var De=arguments.length-2;if(De===1)ve.children=K;else if(1<De){Ae=Array(De);for(var Me=0;Me<De;Me++)Ae[Me]=arguments[Me+2];ve.children=Ae}return{$$typeof:a,type:k.type,key:he,ref:z,props:ve,_owner:be}},pt.createContext=function(k){return k={$$typeof:m,_currentValue:k,_currentValue2:k,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},k.Provider={$$typeof:u,_context:k},k.Consumer=k},pt.createElement=ie,pt.createFactory=function(k){var w=ie.bind(null,k);return w.type=k,w},pt.createRef=function(){return{current:null}},pt.forwardRef=function(k){return{$$typeof:d,render:k}},pt.isValidElement=ke,pt.lazy=function(k){return{$$typeof:v,_payload:{_status:-1,_result:k},_init:U}},pt.memo=function(k,w){return{$$typeof:b,type:k,compare:w===void 0?null:w}},pt.startTransition=function(k){var w=M.transition;M.transition={};try{k()}finally{M.transition=w}},pt.unstable_act=ne,pt.useCallback=function(k,w){return Q.current.useCallback(k,w)},pt.useContext=function(k){return Q.current.useContext(k)},pt.useDebugValue=function(){},pt.useDeferredValue=function(k){return Q.current.useDeferredValue(k)},pt.useEffect=function(k,w){return Q.current.useEffect(k,w)},pt.useId=function(){return Q.current.useId()},pt.useImperativeHandle=function(k,w,K){return Q.current.useImperativeHandle(k,w,K)},pt.useInsertionEffect=function(k,w){return Q.current.useInsertionEffect(k,w)},pt.useLayoutEffect=function(k,w){return Q.current.useLayoutEffect(k,w)},pt.useMemo=function(k,w){return Q.current.useMemo(k,w)},pt.useReducer=function(k,w,K){return Q.current.useReducer(k,w,K)},pt.useRef=function(k){return Q.current.useRef(k)},pt.useState=function(k){return Q.current.useState(k)},pt.useSyncExternalStore=function(k,w,K){return Q.current.useSyncExternalStore(k,w,K)},pt.useTransition=function(){return Q.current.useTransition()},pt.version="18.3.1",pt}var jf;function Md(){return jf||(jf=1,qu.exports=k_()),qu.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 kf;function S_(){if(kf)return Ao;kf=1;var a=Md(),n=Symbol.for("react.element"),r=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,l=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,u={key:!0,ref:!0,__self:!0,__source:!0};function m(d,p,b){var v,y={},C=null,L=null;b!==void 0&&(C=""+b),p.key!==void 0&&(C=""+p.key),p.ref!==void 0&&(L=p.ref);for(v in p)i.call(p,v)&&!u.hasOwnProperty(v)&&(y[v]=p[v]);if(d&&d.defaultProps)for(v in p=d.defaultProps,p)y[v]===void 0&&(y[v]=p[v]);return{$$typeof:n,type:d,key:C,ref:L,props:y,_owner:l.current}}return Ao.Fragment=r,Ao.jsx=m,Ao.jsxs=m,Ao}var Sf;function N_(){return Sf||(Sf=1,Fu.exports=S_()),Fu.exports}var e=N_(),h=Md();const Wt=j_(h);var lc={},Uu={exports:{}},Wn={},Bu={exports:{}},Wu={};/**
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 Nf;function C_(){return Nf||(Nf=1,(function(a){function n(M,Z){var ne=M.length;M.push(Z);e:for(;0<ne;){var k=ne-1>>>1,w=M[k];if(0<l(w,Z))M[k]=Z,M[ne]=w,ne=k;else break e}}function r(M){return M.length===0?null:M[0]}function i(M){if(M.length===0)return null;var Z=M[0],ne=M.pop();if(ne!==Z){M[0]=ne;e:for(var k=0,w=M.length,K=w>>>1;k<K;){var ve=2*(k+1)-1,he=M[ve],z=ve+1,be=M[z];if(0>l(he,ne))z<w&&0>l(be,he)?(M[k]=be,M[z]=ne,k=z):(M[k]=he,M[ve]=ne,k=ve);else if(z<w&&0>l(be,ne))M[k]=be,M[z]=ne,k=z;else break e}}return Z}function l(M,Z){var ne=M.sortIndex-Z.sortIndex;return ne!==0?ne:M.id-Z.id}if(typeof performance=="object"&&typeof performance.now=="function"){var u=performance;a.unstable_now=function(){return u.now()}}else{var m=Date,d=m.now();a.unstable_now=function(){return m.now()-d}}var p=[],b=[],v=1,y=null,C=3,L=!1,T=!1,$=!1,E=typeof setTimeout=="function"?setTimeout:null,I=typeof clearTimeout=="function"?clearTimeout:null,D=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function O(M){for(var Z=r(b);Z!==null;){if(Z.callback===null)i(b);else if(Z.startTime<=M)i(b),Z.sortIndex=Z.expirationTime,n(p,Z);else break;Z=r(b)}}function q(M){if($=!1,O(M),!T)if(r(p)!==null)T=!0,U(A);else{var Z=r(b);Z!==null&&Q(q,Z.startTime-M)}}function A(M,Z){T=!1,$&&($=!1,I(ie),ie=-1),L=!0;var ne=C;try{for(O(Z),y=r(p);y!==null&&(!(y.expirationTime>Z)||M&&!le());){var k=y.callback;if(typeof k=="function"){y.callback=null,C=y.priorityLevel;var w=k(y.expirationTime<=Z);Z=a.unstable_now(),typeof w=="function"?y.callback=w:y===r(p)&&i(p),O(Z)}else i(p);y=r(p)}if(y!==null)var K=!0;else{var ve=r(b);ve!==null&&Q(q,ve.startTime-Z),K=!1}return K}finally{y=null,C=ne,L=!1}}var H=!1,fe=null,ie=-1,Se=5,ke=-1;function le(){return!(a.unstable_now()-ke<Se)}function pe(){if(fe!==null){var M=a.unstable_now();ke=M;var Z=!0;try{Z=fe(!0,M)}finally{Z?G():(H=!1,fe=null)}}else H=!1}var G;if(typeof D=="function")G=function(){D(pe)};else if(typeof MessageChannel<"u"){var te=new MessageChannel,ae=te.port2;te.port1.onmessage=pe,G=function(){ae.postMessage(null)}}else G=function(){E(pe,0)};function U(M){fe=M,H||(H=!0,G())}function Q(M,Z){ie=E(function(){M(a.unstable_now())},Z)}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(M){M.callback=null},a.unstable_continueExecution=function(){T||L||(T=!0,U(A))},a.unstable_forceFrameRate=function(M){0>M||125<M?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):Se=0<M?Math.floor(1e3/M):5},a.unstable_getCurrentPriorityLevel=function(){return C},a.unstable_getFirstCallbackNode=function(){return r(p)},a.unstable_next=function(M){switch(C){case 1:case 2:case 3:var Z=3;break;default:Z=C}var ne=C;C=Z;try{return M()}finally{C=ne}},a.unstable_pauseExecution=function(){},a.unstable_requestPaint=function(){},a.unstable_runWithPriority=function(M,Z){switch(M){case 1:case 2:case 3:case 4:case 5:break;default:M=3}var ne=C;C=M;try{return Z()}finally{C=ne}},a.unstable_scheduleCallback=function(M,Z,ne){var k=a.unstable_now();switch(typeof ne=="object"&&ne!==null?(ne=ne.delay,ne=typeof ne=="number"&&0<ne?k+ne:k):ne=k,M){case 1:var w=-1;break;case 2:w=250;break;case 5:w=1073741823;break;case 4:w=1e4;break;default:w=5e3}return w=ne+w,M={id:v++,callback:Z,priorityLevel:M,startTime:ne,expirationTime:w,sortIndex:-1},ne>k?(M.sortIndex=ne,n(b,M),r(p)===null&&M===r(b)&&($?(I(ie),ie=-1):$=!0,Q(q,ne-k))):(M.sortIndex=w,n(p,M),T||L||(T=!0,U(A))),M},a.unstable_shouldYield=le,a.unstable_wrapCallback=function(M){var Z=C;return function(){var ne=C;C=Z;try{return M.apply(this,arguments)}finally{C=ne}}}})(Wu)),Wu}var Cf;function $_(){return Cf||(Cf=1,Bu.exports=C_()),Bu.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 $f;function E_(){if($f)return Wn;$f=1;var a=Md(),n=$_();function r(t){for(var s="https://reactjs.org/docs/error-decoder.html?invariant="+t,o=1;o<arguments.length;o++)s+="&args[]="+encodeURIComponent(arguments[o]);return"Minified React error #"+t+"; visit "+s+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var i=new Set,l={};function u(t,s){m(t,s),m(t+"Capture",s)}function m(t,s){for(l[t]=s,t=0;t<s.length;t++)i.add(s[t])}var d=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),p=Object.prototype.hasOwnProperty,b=/^[: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]*$/,v={},y={};function C(t){return p.call(y,t)?!0:p.call(v,t)?!1:b.test(t)?y[t]=!0:(v[t]=!0,!1)}function L(t,s,o,c){if(o!==null&&o.type===0)return!1;switch(typeof s){case"function":case"symbol":return!0;case"boolean":return c?!1:o!==null?!o.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function T(t,s,o,c){if(s===null||typeof s>"u"||L(t,s,o,c))return!0;if(c)return!1;if(o!==null)switch(o.type){case 3:return!s;case 4:return s===!1;case 5:return isNaN(s);case 6:return isNaN(s)||1>s}return!1}function $(t,s,o,c,_,g,j){this.acceptsBooleans=s===2||s===3||s===4,this.attributeName=c,this.attributeNamespace=_,this.mustUseProperty=o,this.propertyName=t,this.type=s,this.sanitizeURL=g,this.removeEmptyString=j}var E={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){E[t]=new $(t,0,!1,t,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var s=t[0];E[s]=new $(s,1,!1,t[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(t){E[t]=new $(t,2,!1,t.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){E[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){E[t]=new $(t,3,!1,t.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(t){E[t]=new $(t,3,!0,t,null,!1,!1)}),["capture","download"].forEach(function(t){E[t]=new $(t,4,!1,t,null,!1,!1)}),["cols","rows","size","span"].forEach(function(t){E[t]=new $(t,6,!1,t,null,!1,!1)}),["rowSpan","start"].forEach(function(t){E[t]=new $(t,5,!1,t.toLowerCase(),null,!1,!1)});var I=/[\-:]([a-z])/g;function D(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 s=t.replace(I,D);E[s]=new $(s,1,!1,t,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var s=t.replace(I,D);E[s]=new $(s,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(t){var s=t.replace(I,D);E[s]=new $(s,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(t){E[t]=new $(t,1,!1,t.toLowerCase(),null,!1,!1)}),E.xlinkHref=new $("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(t){E[t]=new $(t,1,!1,t.toLowerCase(),null,!0,!0)});function O(t,s,o,c){var _=E.hasOwnProperty(s)?E[s]:null;(_!==null?_.type!==0:c||!(2<s.length)||s[0]!=="o"&&s[0]!=="O"||s[1]!=="n"&&s[1]!=="N")&&(T(s,o,_,c)&&(o=null),c||_===null?C(s)&&(o===null?t.removeAttribute(s):t.setAttribute(s,""+o)):_.mustUseProperty?t[_.propertyName]=o===null?_.type===3?!1:"":o:(s=_.attributeName,c=_.attributeNamespace,o===null?t.removeAttribute(s):(_=_.type,o=_===3||_===4&&o===!0?"":""+o,c?t.setAttributeNS(c,s,o):t.setAttribute(s,o))))}var q=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,A=Symbol.for("react.element"),H=Symbol.for("react.portal"),fe=Symbol.for("react.fragment"),ie=Symbol.for("react.strict_mode"),Se=Symbol.for("react.profiler"),ke=Symbol.for("react.provider"),le=Symbol.for("react.context"),pe=Symbol.for("react.forward_ref"),G=Symbol.for("react.suspense"),te=Symbol.for("react.suspense_list"),ae=Symbol.for("react.memo"),U=Symbol.for("react.lazy"),Q=Symbol.for("react.offscreen"),M=Symbol.iterator;function Z(t){return t===null||typeof t!="object"?null:(t=M&&t[M]||t["@@iterator"],typeof t=="function"?t:null)}var ne=Object.assign,k;function w(t){if(k===void 0)try{throw Error()}catch(o){var s=o.stack.trim().match(/\n( *(at )?)/);k=s&&s[1]||""}return`
34
+ `+k+t}var K=!1;function ve(t,s){if(!t||K)return"";K=!0;var o=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(s)if(s=function(){throw Error()},Object.defineProperty(s.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(s,[])}catch(_e){var c=_e}Reflect.construct(t,[],s)}else{try{s.call()}catch(_e){c=_e}t.call(s.prototype)}else{try{throw Error()}catch(_e){c=_e}t()}}catch(_e){if(_e&&c&&typeof _e.stack=="string"){for(var _=_e.stack.split(`
35
+ `),g=c.stack.split(`
36
+ `),j=_.length-1,F=g.length-1;1<=j&&0<=F&&_[j]!==g[F];)F--;for(;1<=j&&0<=F;j--,F--)if(_[j]!==g[F]){if(j!==1||F!==1)do if(j--,F--,0>F||_[j]!==g[F]){var J=`
37
+ `+_[j].replace(" at new "," at ");return t.displayName&&J.includes("<anonymous>")&&(J=J.replace("<anonymous>",t.displayName)),J}while(1<=j&&0<=F);break}}}finally{K=!1,Error.prepareStackTrace=o}return(t=t?t.displayName||t.name:"")?w(t):""}function he(t){switch(t.tag){case 5:return w(t.type);case 16:return w("Lazy");case 13:return w("Suspense");case 19:return w("SuspenseList");case 0:case 2:case 15:return t=ve(t.type,!1),t;case 11:return t=ve(t.type.render,!1),t;case 1:return t=ve(t.type,!0),t;default:return""}}function z(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 fe:return"Fragment";case H:return"Portal";case Se:return"Profiler";case ie:return"StrictMode";case G:return"Suspense";case te:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case le:return(t.displayName||"Context")+".Consumer";case ke:return(t._context.displayName||"Context")+".Provider";case pe:var s=t.render;return t=t.displayName,t||(t=s.displayName||s.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case ae:return s=t.displayName||null,s!==null?s:z(t.type)||"Memo";case U:s=t._payload,t=t._init;try{return z(t(s))}catch{}}return null}function be(t){var s=t.type;switch(t.tag){case 24:return"Cache";case 9:return(s.displayName||"Context")+".Consumer";case 10:return(s._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=s.render,t=t.displayName||t.name||"",s.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return s;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return z(s);case 8:return s===ie?"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 s=="function")return s.displayName||s.name||null;if(typeof s=="string")return s}return null}function Ae(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function De(t){var s=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function Me(t){var s=De(t)?"checked":"value",o=Object.getOwnPropertyDescriptor(t.constructor.prototype,s),c=""+t[s];if(!t.hasOwnProperty(s)&&typeof o<"u"&&typeof o.get=="function"&&typeof o.set=="function"){var _=o.get,g=o.set;return Object.defineProperty(t,s,{configurable:!0,get:function(){return _.call(this)},set:function(j){c=""+j,g.call(this,j)}}),Object.defineProperty(t,s,{enumerable:o.enumerable}),{getValue:function(){return c},setValue:function(j){c=""+j},stopTracking:function(){t._valueTracker=null,delete t[s]}}}}function lt(t){t._valueTracker||(t._valueTracker=Me(t))}function Ue(t){if(!t)return!1;var s=t._valueTracker;if(!s)return!0;var o=s.getValue(),c="";return t&&(c=De(t)?t.checked?"true":"false":t.value),t=c,t!==o?(s.setValue(t),!0):!1}function ct(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 Xe(t,s){var o=s.checked;return ne({},s,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:o??t._wrapperState.initialChecked})}function dt(t,s){var o=s.defaultValue==null?"":s.defaultValue,c=s.checked!=null?s.checked:s.defaultChecked;o=Ae(s.value!=null?s.value:o),t._wrapperState={initialChecked:c,initialValue:o,controlled:s.type==="checkbox"||s.type==="radio"?s.checked!=null:s.value!=null}}function Ze(t,s){s=s.checked,s!=null&&O(t,"checked",s,!1)}function W(t,s){Ze(t,s);var o=Ae(s.value),c=s.type;if(o!=null)c==="number"?(o===0&&t.value===""||t.value!=o)&&(t.value=""+o):t.value!==""+o&&(t.value=""+o);else if(c==="submit"||c==="reset"){t.removeAttribute("value");return}s.hasOwnProperty("value")?ge(t,s.type,o):s.hasOwnProperty("defaultValue")&&ge(t,s.type,Ae(s.defaultValue)),s.checked==null&&s.defaultChecked!=null&&(t.defaultChecked=!!s.defaultChecked)}function X(t,s,o){if(s.hasOwnProperty("value")||s.hasOwnProperty("defaultValue")){var c=s.type;if(!(c!=="submit"&&c!=="reset"||s.value!==void 0&&s.value!==null))return;s=""+t._wrapperState.initialValue,o||s===t.value||(t.value=s),t.defaultValue=s}o=t.name,o!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,o!==""&&(t.name=o)}function ge(t,s,o){(s!=="number"||ct(t.ownerDocument)!==t)&&(o==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+o&&(t.defaultValue=""+o))}var Y=Array.isArray;function B(t,s,o,c){if(t=t.options,s){s={};for(var _=0;_<o.length;_++)s["$"+o[_]]=!0;for(o=0;o<t.length;o++)_=s.hasOwnProperty("$"+t[o].value),t[o].selected!==_&&(t[o].selected=_),_&&c&&(t[o].defaultSelected=!0)}else{for(o=""+Ae(o),s=null,_=0;_<t.length;_++){if(t[_].value===o){t[_].selected=!0,c&&(t[_].defaultSelected=!0);return}s!==null||t[_].disabled||(s=t[_])}s!==null&&(s.selected=!0)}}function oe(t,s){if(s.dangerouslySetInnerHTML!=null)throw Error(r(91));return ne({},s,{value:void 0,defaultValue:void 0,children:""+t._wrapperState.initialValue})}function je(t,s){var o=s.value;if(o==null){if(o=s.children,s=s.defaultValue,o!=null){if(s!=null)throw Error(r(92));if(Y(o)){if(1<o.length)throw Error(r(93));o=o[0]}s=o}s==null&&(s=""),o=s}t._wrapperState={initialValue:Ae(o)}}function Oe(t,s){var o=Ae(s.value),c=Ae(s.defaultValue);o!=null&&(o=""+o,o!==t.value&&(t.value=o),s.defaultValue==null&&t.defaultValue!==o&&(t.defaultValue=o)),c!=null&&(t.defaultValue=""+c)}function se(t){var s=t.textContent;s===t._wrapperState.initialValue&&s!==""&&s!==null&&(t.value=s)}function xe(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 ze(t,s){return t==null||t==="http://www.w3.org/1999/xhtml"?xe(s):t==="http://www.w3.org/2000/svg"&&s==="foreignObject"?"http://www.w3.org/1999/xhtml":t}var Ne,Le=(function(t){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(s,o,c,_){MSApp.execUnsafeLocalFunction(function(){return t(s,o,c,_)})}:t})(function(t,s){if(t.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in t)t.innerHTML=s;else{for(Ne=Ne||document.createElement("div"),Ne.innerHTML="<svg>"+s.valueOf().toString()+"</svg>",s=Ne.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;s.firstChild;)t.appendChild(s.firstChild)}});function re(t,s){if(s){var o=t.firstChild;if(o&&o===t.lastChild&&o.nodeType===3){o.nodeValue=s;return}}t.textContent=s}var P={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},de=["Webkit","ms","Moz","O"];Object.keys(P).forEach(function(t){de.forEach(function(s){s=s+t.charAt(0).toUpperCase()+t.substring(1),P[s]=P[t]})});function Ve(t,s,o){return s==null||typeof s=="boolean"||s===""?"":o||typeof s!="number"||s===0||P.hasOwnProperty(t)&&P[t]?(""+s).trim():s+"px"}function et(t,s){t=t.style;for(var o in s)if(s.hasOwnProperty(o)){var c=o.indexOf("--")===0,_=Ve(o,s[o],c);o==="float"&&(o="cssFloat"),c?t.setProperty(o,_):t[o]=_}}var at=ne({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,s){if(s){if(at[t]&&(s.children!=null||s.dangerouslySetInnerHTML!=null))throw Error(r(137,t));if(s.dangerouslySetInnerHTML!=null){if(s.children!=null)throw Error(r(60));if(typeof s.dangerouslySetInnerHTML!="object"||!("__html"in s.dangerouslySetInnerHTML))throw Error(r(61))}if(s.style!=null&&typeof s.style!="object")throw Error(r(62))}}function ft(t,s){if(t.indexOf("-")===-1)return typeof s.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 tt(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var ht=null,Pt=null,wt=null;function tn(t){if(t=Nr(t)){if(typeof ht!="function")throw Error(r(280));var s=t.stateNode;s&&(s=fi(s),ht(t.stateNode,t.type,s))}}function ye(t){Pt?wt?wt.push(t):wt=[t]:Pt=t}function Ce(){if(Pt){var t=Pt,s=wt;if(wt=Pt=null,tn(t),s)for(t=0;t<s.length;t++)tn(s[t])}}function Je(t,s){return t(s)}function yt(){}var _t=!1;function jt(t,s,o){if(_t)return t(s,o);_t=!0;try{return Je(t,s,o)}finally{_t=!1,(Pt!==null||wt!==null)&&(yt(),Ce())}}function rt(t,s){var o=t.stateNode;if(o===null)return null;var c=fi(o);if(c===null)return null;o=c[s];e:switch(s){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(c=!c.disabled)||(t=t.type,c=!(t==="button"||t==="input"||t==="select"||t==="textarea")),t=!c;break e;default:t=!1}if(t)return null;if(o&&typeof o!="function")throw Error(r(231,s,typeof o));return o}var Cn=!1;if(d)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 tr(t,s,o,c,_,g,j,F,J){var _e=Array.prototype.slice.call(arguments,3);try{s.apply(o,_e)}catch(Te){this.onError(Te)}}var $s=!1,ls=null,nn=!1,Gs=null,Ks={onError:function(t){$s=!0,ls=t}};function Es(t,s,o,c,_,g,j,F,J){$s=!1,ls=null,tr.apply(Ks,arguments)}function Mi(t,s,o,c,_,g,j,F,J){if(Es.apply(this,arguments),$s){if($s){var _e=ls;$s=!1,ls=null}else throw Error(r(198));nn||(nn=!0,Gs=_e)}}function Ts(t){var s=t,o=t;if(t.alternate)for(;s.return;)s=s.return;else{t=s;do s=t,(s.flags&4098)!==0&&(o=s.return),t=s.return;while(t)}return s.tag===3?o:null}function Ur(t){if(t.tag===13){var s=t.memoizedState;if(s===null&&(t=t.alternate,t!==null&&(s=t.memoizedState)),s!==null)return s.dehydrated}return null}function ut(t){if(Ts(t)!==t)throw Error(r(188))}function Ht(t){var s=t.alternate;if(!s){if(s=Ts(t),s===null)throw Error(r(188));return s!==t?null:t}for(var o=t,c=s;;){var _=o.return;if(_===null)break;var g=_.alternate;if(g===null){if(c=_.return,c!==null){o=c;continue}break}if(_.child===g.child){for(g=_.child;g;){if(g===o)return ut(_),t;if(g===c)return ut(_),s;g=g.sibling}throw Error(r(188))}if(o.return!==c.return)o=_,c=g;else{for(var j=!1,F=_.child;F;){if(F===o){j=!0,o=_,c=g;break}if(F===c){j=!0,c=_,o=g;break}F=F.sibling}if(!j){for(F=g.child;F;){if(F===o){j=!0,o=g,c=_;break}if(F===c){j=!0,c=g,o=_;break}F=F.sibling}if(!j)throw Error(r(189))}}if(o.alternate!==c)throw Error(r(190))}if(o.tag!==3)throw Error(r(188));return o.stateNode.current===o?t:s}function nr(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 s=Mt(t);if(s!==null)return s;t=t.sibling}return null}var sr=n.unstable_scheduleCallback,Pi=n.unstable_cancelCallback,al=n.unstable_shouldYield,zi=n.unstable_requestPaint,It=n.unstable_now,Br=n.unstable_getCurrentPriorityLevel,Wr=n.unstable_ImmediatePriority,ar=n.unstable_UserBlockingPriority,Js=n.unstable_NormalPriority,rl=n.unstable_LowPriority,Hr=n.unstable_IdlePriority,cs=null,hn=null;function Vr(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:ol,il=Math.log,ga=Math.LN2;function ol(t){return t>>>=0,t===0?32:31-(il(t)/ga|0)|0}var ya=64,Gr=4194304;function rr(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,s){var o=t.pendingLanes;if(o===0)return 0;var c=0,_=t.suspendedLanes,g=t.pingedLanes,j=o&268435455;if(j!==0){var F=j&~_;F!==0?c=rr(F):(g&=j,g!==0&&(c=rr(g)))}else j=o&~_,j!==0?c=rr(j):g!==0&&(c=rr(g));if(c===0)return 0;if(s!==0&&s!==c&&(s&_)===0&&(_=c&-c,g=s&-s,_>=g||_===16&&(g&4194240)!==0))return s;if((c&4)!==0&&(c|=o&16),s=t.entangledLanes,s!==0)for(t=t.entanglements,s&=c;0<s;)o=31-pn(s),_=1<<o,c|=t[o],s&=~_;return c}function Qs(t,s){switch(t){case 1:case 2:case 4:return s+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 s+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 Kr(t,s){for(var o=t.suspendedLanes,c=t.pingedLanes,_=t.expirationTimes,g=t.pendingLanes;0<g;){var j=31-pn(g),F=1<<j,J=_[j];J===-1?((F&o)===0||(F&c)!==0)&&(_[j]=Qs(F,s)):J<=s&&(t.expiredLanes|=F),g&=~F}}function As(t){return t=t.pendingLanes&-1073741825,t!==0?t:t&1073741824?1073741824:0}function Vt(){var t=ya;return ya<<=1,(ya&4194240)===0&&(ya=64),t}function Xt(t){for(var s=[],o=0;31>o;o++)s.push(t);return s}function Ls(t,s,o){t.pendingLanes|=s,s!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,s=31-pn(s),t[s]=o}function va(t,s){var o=t.pendingLanes&~s;t.pendingLanes=s,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=s,t.mutableReadLanes&=s,t.entangledLanes&=s,s=t.entanglements;var c=t.eventTimes;for(t=t.expirationTimes;0<o;){var _=31-pn(o),g=1<<_;s[_]=0,c[_]=-1,t[_]=-1,o&=~g}}function Rs(t,s){var o=t.entangledLanes|=s;for(t=t.entanglements;o;){var c=31-pn(o),_=1<<c;_&s|t[c]&s&&(t[c]|=s),o&=~_}}var kt=0;function Gt(t){return t&=-t,1<t?4<t?(t&268435455)!==0?16:536870912:4:1}var us,Jr,Pn,Qr,Ii,ir=!1,or=[],ds=null,Kn=null,$n=null,Ms=new Map,cn=new Map,_n=[],Ec="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 xa(t,s){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(s.pointerId);break;case"gotpointercapture":case"lostpointercapture":cn.delete(s.pointerId)}}function Et(t,s,o,c,_,g){return t===null||t.nativeEvent!==g?(t={blockedOn:s,domEventName:o,eventSystemFlags:c,nativeEvent:g,targetContainers:[_]},s!==null&&(s=Nr(s),s!==null&&Jr(s)),t):(t.eventSystemFlags|=c,s=t.targetContainers,_!==null&&s.indexOf(_)===-1&&s.push(_),t)}function Jn(t,s,o,c,_){switch(s){case"focusin":return ds=Et(ds,t,s,o,c,_),!0;case"dragenter":return Kn=Et(Kn,t,s,o,c,_),!0;case"mouseover":return $n=Et($n,t,s,o,c,_),!0;case"pointerover":var g=_.pointerId;return Ms.set(g,Et(Ms.get(g)||null,t,s,o,c,_)),!0;case"gotpointercapture":return g=_.pointerId,cn.set(g,Et(cn.get(g)||null,t,s,o,c,_)),!0}return!1}function zn(t){var s=vs(t.target);if(s!==null){var o=Ts(s);if(o!==null){if(s=o.tag,s===13){if(s=Ur(o),s!==null){t.blockedOn=s,Ii(t.priority,function(){Pn(o)});return}}else if(s===3&&o.stateNode.current.memoizedState.isDehydrated){t.blockedOn=o.tag===3?o.stateNode.containerInfo:null;return}}}t.blockedOn=null}function ba(t){if(t.blockedOn!==null)return!1;for(var s=t.targetContainers;0<s.length;){var o=dr(t.domEventName,t.eventSystemFlags,s[0],t.nativeEvent);if(o===null){o=t.nativeEvent;var c=new o.constructor(o.type,o);Ee=c,o.target.dispatchEvent(c),Ee=null}else return s=Nr(o),s!==null&&Jr(s),t.blockedOn=o,!1;s.shift()}return!0}function Yr(t,s,o){ba(t)&&o.delete(s)}function ll(){ir=!1,ds!==null&&ba(ds)&&(ds=null),Kn!==null&&ba(Kn)&&(Kn=null),$n!==null&&ba($n)&&($n=null),Ms.forEach(Yr),cn.forEach(Yr)}function wn(t,s){t.blockedOn===s&&(t.blockedOn=null,ir||(ir=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,ll)))}function wa(t){function s(_){return wn(_,t)}if(0<or.length){wn(or[0],t);for(var o=1;o<or.length;o++){var c=or[o];c.blockedOn===t&&(c.blockedOn=null)}}for(ds!==null&&wn(ds,t),Kn!==null&&wn(Kn,t),$n!==null&&wn($n,t),Ms.forEach(s),cn.forEach(s),o=0;o<_n.length;o++)c=_n[o],c.blockedOn===t&&(c.blockedOn=null);for(;0<_n.length&&(o=_n[0],o.blockedOn===null);)zn(o),o.blockedOn===null&&_n.shift()}var ms=q.ReactCurrentBatchConfig,lr=!0;function Di(t,s,o,c){var _=kt,g=ms.transition;ms.transition=null;try{kt=1,Xr(t,s,o,c)}finally{kt=_,ms.transition=g}}function cr(t,s,o,c){var _=kt,g=ms.transition;ms.transition=null;try{kt=4,Xr(t,s,o,c)}finally{kt=_,ms.transition=g}}function Xr(t,s,o,c){if(lr){var _=dr(t,s,o,c);if(_===null)wr(t,s,c,ur,o),xa(t,c);else if(Jn(_,t,s,o,c))c.stopPropagation();else if(xa(t,c),s&4&&-1<Ec.indexOf(t)){for(;_!==null;){var g=Nr(_);if(g!==null&&us(g),g=dr(t,s,o,c),g===null&&wr(t,s,c,ur,o),g===_)break;_=g}_!==null&&c.stopPropagation()}else wr(t,s,c,null,o)}}var ur=null;function dr(t,s,o,c){if(ur=null,t=tt(c),t=vs(t),t!==null)if(s=Ts(t),s===null)t=null;else if(o=s.tag,o===13){if(t=Ur(s),t!==null)return t;t=null}else if(o===3){if(s.stateNode.current.memoizedState.isDehydrated)return s.tag===3?s.stateNode.containerInfo:null;t=null}else s!==t&&(t=null);return ur=t,null}function Oi(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(Br()){case Wr:return 1;case ar:return 4;case Js:case rl:return 16;case Hr:return 536870912;default:return 16}default:return 16}}var In=null,fs=null,Ys=null;function Zr(){if(Ys)return Ys;var t,s=fs,o=s.length,c,_="value"in In?In.value:In.textContent,g=_.length;for(t=0;t<o&&s[t]===_[t];t++);var j=o-t;for(c=1;c<=j&&s[o-c]===_[g-c];c++);return Ys=_.slice(t,1<c?1-c:void 0)}function ja(t){var s=t.keyCode;return"charCode"in t?(t=t.charCode,t===0&&s===13&&(t=13)):t=s,t===10&&(t=13),32<=t||t===13?t:0}function ka(){return!0}function Xs(){return!1}function sn(t){function s(o,c,_,g,j){this._reactName=o,this._targetInst=_,this.type=c,this.nativeEvent=g,this.target=j,this.currentTarget=null;for(var F in t)t.hasOwnProperty(F)&&(o=t[F],this[F]=o?o(g):g[F]);return this.isDefaultPrevented=(g.defaultPrevented!=null?g.defaultPrevented:g.returnValue===!1)?ka:Xs,this.isPropagationStopped=Xs,this}return ne(s.prototype,{preventDefault:function(){this.defaultPrevented=!0;var o=this.nativeEvent;o&&(o.preventDefault?o.preventDefault():typeof o.returnValue!="unknown"&&(o.returnValue=!1),this.isDefaultPrevented=ka)},stopPropagation:function(){var o=this.nativeEvent;o&&(o.stopPropagation?o.stopPropagation():typeof o.cancelBubble!="unknown"&&(o.cancelBubble=!0),this.isPropagationStopped=ka)},persist:function(){},isPersistent:ka}),s}var Sa={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Kt=sn(Sa),Ps=ne({},Sa,{view:0,detail:0}),Fi=sn(Ps),ei,mr,Zs,Na=ne({},Ps,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:fr,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!==Zs&&(Zs&&t.type==="mousemove"?(ei=t.screenX-Zs.screenX,mr=t.screenY-Zs.screenY):mr=ei=0,Zs=t),ei)},movementY:function(t){return"movementY"in t?t.movementY:mr}}),qi=sn(Na),Ui=ne({},Na,{dataTransfer:0}),cl=sn(Ui),ul=ne({},Ps,{relatedTarget:0}),ti=sn(ul),dl=ne({},Sa,{animationName:0,elapsedTime:0,pseudoElement:0}),Bi=sn(dl),ml=ne({},Sa,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),Wi=sn(ml),Hi=ne({},Sa,{data:0}),Vi=sn(Hi),Dn={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},zs={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 Gi(t){var s=this.nativeEvent;return s.getModifierState?s.getModifierState(t):(t=Is[t])?!!s[t]:!1}function fr(){return Gi}var Ki=ne({},Ps,{key:function(t){if(t.key){var s=Dn[t.key]||t.key;if(s!=="Unidentified")return s}return t.type==="keypress"?(t=ja(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?zs[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:fr,charCode:function(t){return t.type==="keypress"?ja(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?ja(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),Tc=sn(Ki),Ca=ne({},Na,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),$a=sn(Ca),hs=ne({},Ps,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:fr}),ea=sn(hs),fl=ne({},Sa,{propertyName:0,elapsedTime:0,pseudoElement:0}),hl=sn(fl),pl=ne({},Na,{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}),Ac=sn(pl),Lc=[9,13,27,32],hr=d&&"CompositionEvent"in window,ns=null;d&&"documentMode"in document&&(ns=document.documentMode);var Ji=d&&"TextEvent"in window&&!ns,Qi=d&&(!hr||ns&&8<ns&&11>=ns),ni=" ",Yi=!1;function ta(t,s){switch(t){case"keyup":return Lc.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function si(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var Ea=!1;function pr(t,s){switch(t){case"compositionend":return si(s);case"keypress":return s.which!==32?null:(Yi=!0,ni);case"textInput":return t=s.data,t===ni&&Yi?null:t;default:return null}}function Xi(t,s){if(Ea)return t==="compositionend"||!hr&&ta(t,s)?(t=Zr(),Ys=fs=In=null,Ea=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(s.ctrlKey||s.altKey||s.metaKey)||s.ctrlKey&&s.altKey){if(s.char&&1<s.char.length)return s.char;if(s.which)return String.fromCharCode(s.which)}return null;case"compositionend":return Qi&&s.locale!=="ko"?null:s.data;default:return null}}var _l={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 Zi(t){var s=t&&t.nodeName&&t.nodeName.toLowerCase();return s==="input"?!!_l[t.type]:s==="textarea"}function eo(t,s,o,c){ye(c),s=di(s,"onChange"),0<s.length&&(o=new Kt("onChange","change",null,o,c),t.push({event:o,listeners:s}))}var _r=null,Qn=null;function gr(t){Aa(t,0)}function ai(t){var s=Da(t);if(Ue(s))return t}function ri(t,s){if(t==="change")return s}var ii=!1;if(d){var to;if(d){var Ta="oninput"in document;if(!Ta){var yr=document.createElement("div");yr.setAttribute("oninput","return;"),Ta=typeof yr.oninput=="function"}to=Ta}else to=!1;ii=to&&(!document.documentMode||9<document.documentMode)}function gl(){_r&&(_r.detachEvent("onpropertychange",yl),Qn=_r=null)}function yl(t){if(t.propertyName==="value"&&ai(Qn)){var s=[];eo(s,Qn,t,tt(t)),jt(gr,s)}}function Rc(t,s,o){t==="focusin"?(gl(),_r=s,Qn=o,_r.attachEvent("onpropertychange",yl)):t==="focusout"&&gl()}function vl(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return ai(Qn)}function Mc(t,s){if(t==="click")return ai(s)}function xl(t,s){if(t==="input"||t==="change")return ai(s)}function Pc(t,s){return t===s&&(t!==0||1/t===1/s)||t!==t&&s!==s}var Yn=typeof Object.is=="function"?Object.is:Pc;function na(t,s){if(Yn(t,s))return!0;if(typeof t!="object"||t===null||typeof s!="object"||s===null)return!1;var o=Object.keys(t),c=Object.keys(s);if(o.length!==c.length)return!1;for(c=0;c<o.length;c++){var _=o[c];if(!p.call(s,_)||!Yn(t[_],s[_]))return!1}return!0}function bl(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function no(t,s){var o=bl(t);t=0;for(var c;o;){if(o.nodeType===3){if(c=t+o.textContent.length,t<=s&&c>=s)return{node:o,offset:s-t};t=c}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=bl(o)}}function so(t,s){return t&&s?t===s?!0:t&&t.nodeType===3?!1:s&&s.nodeType===3?so(t,s.parentNode):"contains"in t?t.contains(s):t.compareDocumentPosition?!!(t.compareDocumentPosition(s)&16):!1:!1}function wl(){for(var t=window,s=ct();s instanceof t.HTMLIFrameElement;){try{var o=typeof s.contentWindow.location.href=="string"}catch{o=!1}if(o)t=s.contentWindow;else break;s=ct(t.document)}return s}function oi(t){var s=t&&t.nodeName&&t.nodeName.toLowerCase();return s&&(s==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||s==="textarea"||t.contentEditable==="true")}function li(t){var s=wl(),o=t.focusedElem,c=t.selectionRange;if(s!==o&&o&&o.ownerDocument&&so(o.ownerDocument.documentElement,o)){if(c!==null&&oi(o)){if(s=c.start,t=c.end,t===void 0&&(t=s),"selectionStart"in o)o.selectionStart=s,o.selectionEnd=Math.min(t,o.value.length);else if(t=(s=o.ownerDocument||document)&&s.defaultView||window,t.getSelection){t=t.getSelection();var _=o.textContent.length,g=Math.min(c.start,_);c=c.end===void 0?g:Math.min(c.end,_),!t.extend&&g>c&&(_=c,c=g,g=_),_=no(o,g);var j=no(o,c);_&&j&&(t.rangeCount!==1||t.anchorNode!==_.node||t.anchorOffset!==_.offset||t.focusNode!==j.node||t.focusOffset!==j.offset)&&(s=s.createRange(),s.setStart(_.node,_.offset),t.removeAllRanges(),g>c?(t.addRange(s),t.extend(j.node,j.offset)):(s.setEnd(j.node,j.offset),t.addRange(s)))}}for(s=[],t=o;t=t.parentNode;)t.nodeType===1&&s.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof o.focus=="function"&&o.focus(),o=0;o<s.length;o++)t=s[o],t.element.scrollLeft=t.left,t.element.scrollTop=t.top}}var jl=d&&"documentMode"in document&&11>=document.documentMode,ps=null,ci=null,vr=null,ao=!1;function ro(t,s,o){var c=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;ao||ps==null||ps!==ct(c)||(c=ps,"selectionStart"in c&&oi(c)?c={start:c.selectionStart,end:c.selectionEnd}:(c=(c.ownerDocument&&c.ownerDocument.defaultView||window).getSelection(),c={anchorNode:c.anchorNode,anchorOffset:c.anchorOffset,focusNode:c.focusNode,focusOffset:c.focusOffset}),vr&&na(vr,c)||(vr=c,c=di(ci,"onSelect"),0<c.length&&(s=new Kt("onSelect","select",null,s,o),t.push({event:s,listeners:c}),s.target=ps)))}function ui(t,s){var o={};return o[t.toLowerCase()]=s.toLowerCase(),o["Webkit"+t]="webkit"+s,o["Moz"+t]="moz"+s,o}var sa={animationend:ui("Animation","AnimationEnd"),animationiteration:ui("Animation","AnimationIteration"),animationstart:ui("Animation","AnimationStart"),transitionend:ui("Transition","TransitionEnd")},io={},oo={};d&&(oo=document.createElement("div").style,"AnimationEvent"in window||(delete sa.animationend.animation,delete sa.animationiteration.animation,delete sa.animationstart.animation),"TransitionEvent"in window||delete sa.transitionend.transition);function xr(t){if(io[t])return io[t];if(!sa[t])return t;var s=sa[t],o;for(o in s)if(s.hasOwnProperty(o)&&o in oo)return io[t]=s[o];return t}var kl=xr("animationend"),Sl=xr("animationiteration"),lo=xr("animationstart"),co=xr("transitionend"),Nl=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 vt(t,s){Nl.set(t,s),u(s,[t])}for(var Jt=0;Jt<En.length;Jt++){var br=En[Jt],zc=br.toLowerCase(),Ds=br[0].toUpperCase()+br.slice(1);vt(zc,"on"+Ds)}vt(kl,"onAnimationEnd"),vt(Sl,"onAnimationIteration"),vt(lo,"onAnimationStart"),vt("dblclick","onDoubleClick"),vt("focusin","onFocus"),vt("focusout","onBlur"),vt(co,"onTransitionEnd"),m("onMouseEnter",["mouseout","mouseover"]),m("onMouseLeave",["mouseout","mouseover"]),m("onPointerEnter",["pointerout","pointerover"]),m("onPointerLeave",["pointerout","pointerover"]),u("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),u("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),u("onBeforeInput",["compositionend","keypress","textInput","paste"]),u("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),u("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),u("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var On="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(On));function aa(t,s,o){var c=t.type||"unknown-event";t.currentTarget=o,Mi(c,s,void 0,t),t.currentTarget=null}function Aa(t,s){s=(s&4)!==0;for(var o=0;o<t.length;o++){var c=t[o],_=c.event;c=c.listeners;e:{var g=void 0;if(s)for(var j=c.length-1;0<=j;j--){var F=c[j],J=F.instance,_e=F.currentTarget;if(F=F.listener,J!==g&&_.isPropagationStopped())break e;aa(_,F,_e),g=J}else for(j=0;j<c.length;j++){if(F=c[j],J=F.instance,_e=F.currentTarget,F=F.listener,J!==g&&_.isPropagationStopped())break e;aa(_,F,_e),g=J}}}if(nn)throw t=Gs,nn=!1,Gs=null,t}function Ct(t,s){var o=s[po];o===void 0&&(o=s[po]=new Set);var c=t+"__bubble";o.has(c)||(uo(s,t,2,!1),o.add(c))}function ra(t,s,o){var c=0;s&&(c|=4),uo(o,t,c,s)}var La="_reactListening"+Math.random().toString(36).slice(2);function Ra(t){if(!t[La]){t[La]=!0,i.forEach(function(o){o!=="selectionchange"&&(_s.has(o)||ra(o,!1,t),ra(o,!0,t))});var s=t.nodeType===9?t:t.ownerDocument;s===null||s[La]||(s[La]=!0,ra("selectionchange",!1,s))}}function uo(t,s,o,c){switch(Oi(s)){case 1:var _=Di;break;case 4:_=cr;break;default:_=Xr}o=_.bind(null,s,o,t),_=void 0,!Cn||s!=="touchstart"&&s!=="touchmove"&&s!=="wheel"||(_=!0),c?_!==void 0?t.addEventListener(s,o,{capture:!0,passive:_}):t.addEventListener(s,o,!0):_!==void 0?t.addEventListener(s,o,{passive:_}):t.addEventListener(s,o,!1)}function wr(t,s,o,c,_){var g=c;if((s&1)===0&&(s&2)===0&&c!==null)e:for(;;){if(c===null)return;var j=c.tag;if(j===3||j===4){var F=c.stateNode.containerInfo;if(F===_||F.nodeType===8&&F.parentNode===_)break;if(j===4)for(j=c.return;j!==null;){var J=j.tag;if((J===3||J===4)&&(J=j.stateNode.containerInfo,J===_||J.nodeType===8&&J.parentNode===_))return;j=j.return}for(;F!==null;){if(j=vs(F),j===null)return;if(J=j.tag,J===5||J===6){c=g=j;continue e}F=F.parentNode}}c=c.return}jt(function(){var _e=g,Te=tt(o),Re=[];e:{var $e=Nl.get(t);if($e!==void 0){var Be=Kt,Ke=t;switch(t){case"keypress":if(ja(o)===0)break e;case"keydown":case"keyup":Be=Tc;break;case"focusin":Ke="focus",Be=ti;break;case"focusout":Ke="blur",Be=ti;break;case"beforeblur":case"afterblur":Be=ti;break;case"click":if(o.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Be=qi;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Be=cl;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Be=ea;break;case kl:case Sl:case lo:Be=Bi;break;case co:Be=hl;break;case"scroll":Be=Fi;break;case"wheel":Be=Ac;break;case"copy":case"cut":case"paste":Be=Wi;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Be=$a}var Qe=(s&4)!==0,Yt=!Qe&&t==="scroll",ue=Qe?$e!==null?$e+"Capture":null:$e;Qe=[];for(var ee=_e,me;ee!==null;){me=ee;var Ie=me.stateNode;if(me.tag===5&&Ie!==null&&(me=Ie,ue!==null&&(Ie=rt(ee,ue),Ie!=null&&Qe.push(jr(ee,Ie,me)))),Yt)break;ee=ee.return}0<Qe.length&&($e=new Be($e,Ke,null,o,Te),Re.push({event:$e,listeners:Qe}))}}if((s&7)===0){e:{if($e=t==="mouseover"||t==="pointerover",Be=t==="mouseout"||t==="pointerout",$e&&o!==Ee&&(Ke=o.relatedTarget||o.fromElement)&&(vs(Ke)||Ke[ys]))break e;if((Be||$e)&&($e=Te.window===Te?Te:($e=Te.ownerDocument)?$e.defaultView||$e.parentWindow:window,Be?(Ke=o.relatedTarget||o.toElement,Be=_e,Ke=Ke?vs(Ke):null,Ke!==null&&(Yt=Ts(Ke),Ke!==Yt||Ke.tag!==5&&Ke.tag!==6)&&(Ke=null)):(Be=null,Ke=_e),Be!==Ke)){if(Qe=qi,Ie="onMouseLeave",ue="onMouseEnter",ee="mouse",(t==="pointerout"||t==="pointerover")&&(Qe=$a,Ie="onPointerLeave",ue="onPointerEnter",ee="pointer"),Yt=Be==null?$e:Da(Be),me=Ke==null?$e:Da(Ke),$e=new Qe(Ie,ee+"leave",Be,o,Te),$e.target=Yt,$e.relatedTarget=me,Ie=null,vs(Te)===_e&&(Qe=new Qe(ue,ee+"enter",Ke,o,Te),Qe.target=me,Qe.relatedTarget=Yt,Ie=Qe),Yt=Ie,Be&&Ke)t:{for(Qe=Be,ue=Ke,ee=0,me=Qe;me;me=ia(me))ee++;for(me=0,Ie=ue;Ie;Ie=ia(Ie))me++;for(;0<ee-me;)Qe=ia(Qe),ee--;for(;0<me-ee;)ue=ia(ue),me--;for(;ee--;){if(Qe===ue||ue!==null&&Qe===ue.alternate)break t;Qe=ia(Qe),ue=ia(ue)}Qe=null}else Qe=null;Be!==null&&mo(Re,$e,Be,Qe,!1),Ke!==null&&Yt!==null&&mo(Re,Yt,Ke,Qe,!0)}}e:{if($e=_e?Da(_e):window,Be=$e.nodeName&&$e.nodeName.toLowerCase(),Be==="select"||Be==="input"&&$e.type==="file")var Ye=ri;else if(Zi($e))if(ii)Ye=xl;else{Ye=vl;var nt=Rc}else(Be=$e.nodeName)&&Be.toLowerCase()==="input"&&($e.type==="checkbox"||$e.type==="radio")&&(Ye=Mc);if(Ye&&(Ye=Ye(t,_e))){eo(Re,Ye,o,Te);break e}nt&&nt(t,$e,_e),t==="focusout"&&(nt=$e._wrapperState)&&nt.controlled&&$e.type==="number"&&ge($e,"number",$e.value)}switch(nt=_e?Da(_e):window,t){case"focusin":(Zi(nt)||nt.contentEditable==="true")&&(ps=nt,ci=_e,vr=null);break;case"focusout":vr=ci=ps=null;break;case"mousedown":ao=!0;break;case"contextmenu":case"mouseup":case"dragend":ao=!1,ro(Re,o,Te);break;case"selectionchange":if(jl)break;case"keydown":case"keyup":ro(Re,o,Te)}var st;if(hr)e:{switch(t){case"compositionstart":var ot="onCompositionStart";break e;case"compositionend":ot="onCompositionEnd";break e;case"compositionupdate":ot="onCompositionUpdate";break e}ot=void 0}else Ea?ta(t,o)&&(ot="onCompositionEnd"):t==="keydown"&&o.keyCode===229&&(ot="onCompositionStart");ot&&(Qi&&o.locale!=="ko"&&(Ea||ot!=="onCompositionStart"?ot==="onCompositionEnd"&&Ea&&(st=Zr()):(In=Te,fs="value"in In?In.value:In.textContent,Ea=!0)),nt=di(_e,ot),0<nt.length&&(ot=new Vi(ot,t,null,o,Te),Re.push({event:ot,listeners:nt}),st?ot.data=st:(st=si(o),st!==null&&(ot.data=st)))),(st=Ji?pr(t,o):Xi(t,o))&&(_e=di(_e,"onBeforeInput"),0<_e.length&&(Te=new Vi("onBeforeInput","beforeinput",null,o,Te),Re.push({event:Te,listeners:_e}),Te.data=st))}Aa(Re,s)})}function jr(t,s,o){return{instance:t,listener:s,currentTarget:o}}function di(t,s){for(var o=s+"Capture",c=[];t!==null;){var _=t,g=_.stateNode;_.tag===5&&g!==null&&(_=g,g=rt(t,o),g!=null&&c.unshift(jr(t,g,_)),g=rt(t,s),g!=null&&c.push(jr(t,g,_))),t=t.return}return c}function ia(t){if(t===null)return null;do t=t.return;while(t&&t.tag!==5);return t||null}function mo(t,s,o,c,_){for(var g=s._reactName,j=[];o!==null&&o!==c;){var F=o,J=F.alternate,_e=F.stateNode;if(J!==null&&J===c)break;F.tag===5&&_e!==null&&(F=_e,_?(J=rt(o,g),J!=null&&j.unshift(jr(o,J,F))):_||(J=rt(o,g),J!=null&&j.push(jr(o,J,F)))),o=o.return}j.length!==0&&t.push({event:s,listeners:j})}var Ma=/\r\n?/g,Ic=/\u0000|\uFFFD/g;function Tn(t){return(typeof t=="string"?t:""+t).replace(Ma,`
38
+ `).replace(Ic,"")}function Pa(t,s,o){if(s=Tn(s),Tn(t)!==s&&o)throw Error(r(425))}function An(){}var za=null,kr=null;function Xn(t,s){return t==="textarea"||t==="noscript"||typeof s.children=="string"||typeof s.children=="number"||typeof s.dangerouslySetInnerHTML=="object"&&s.dangerouslySetInnerHTML!==null&&s.dangerouslySetInnerHTML.__html!=null}var Fn=typeof setTimeout=="function"?setTimeout:void 0,mi=typeof clearTimeout=="function"?clearTimeout:void 0,Cl=typeof Promise=="function"?Promise:void 0,fo=typeof queueMicrotask=="function"?queueMicrotask:typeof Cl<"u"?function(t){return Cl.resolve(null).then(t).catch(Dc)}:Fn;function Dc(t){setTimeout(function(){throw t})}function ho(t,s){var o=s,c=0;do{var _=o.nextSibling;if(t.removeChild(o),_&&_.nodeType===8)if(o=_.data,o==="/$"){if(c===0){t.removeChild(_),wa(s);return}c--}else o!=="$"&&o!=="$?"&&o!=="$!"||c++;o=_}while(o);wa(s)}function gs(t){for(;t!=null;t=t.nextSibling){var s=t.nodeType;if(s===1||s===3)break;if(s===8){if(s=t.data,s==="$"||s==="$!"||s==="$?")break;if(s==="/$")return null}}return t}function $l(t){t=t.previousSibling;for(var s=0;t;){if(t.nodeType===8){var o=t.data;if(o==="$"||o==="$!"||o==="$?"){if(s===0)return t;s--}else o==="/$"&&s++}t=t.previousSibling}return null}var Ia=Math.random().toString(36).slice(2),Zn="__reactFiber$"+Ia,Sr="__reactProps$"+Ia,ys="__reactContainer$"+Ia,po="__reactEvents$"+Ia,Oc="__reactListeners$"+Ia,Fc="__reactHandles$"+Ia;function vs(t){var s=t[Zn];if(s)return s;for(var o=t.parentNode;o;){if(s=o[ys]||o[Zn]){if(o=s.alternate,s.child!==null||o!==null&&o.child!==null)for(t=$l(t);t!==null;){if(o=t[Zn])return o;t=$l(t)}return s}t=o,o=t.parentNode}return null}function Nr(t){return t=t[Zn]||t[ys],!t||t.tag!==5&&t.tag!==6&&t.tag!==13&&t.tag!==3?null:t}function Da(t){if(t.tag===5||t.tag===6)return t.stateNode;throw Error(r(33))}function fi(t){return t[Sr]||null}var _o=[],oa=-1;function xs(t){return{current:t}}function At(t){0>oa||(t.current=_o[oa],_o[oa]=null,oa--)}function Tt(t,s){oa++,_o[oa]=t.current,t.current=s}var bs={},an=xs(bs),gn=xs(!1),Os=bs;function la(t,s){var o=t.type.contextTypes;if(!o)return bs;var c=t.stateNode;if(c&&c.__reactInternalMemoizedUnmaskedChildContext===s)return c.__reactInternalMemoizedMaskedChildContext;var _={},g;for(g in o)_[g]=s[g];return c&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=s,t.__reactInternalMemoizedMaskedChildContext=_),_}function f(t){return t=t.childContextTypes,t!=null}function x(){At(gn),At(an)}function N(t,s,o){if(an.current!==bs)throw Error(r(168));Tt(an,s),Tt(gn,o)}function S(t,s,o){var c=t.stateNode;if(s=s.childContextTypes,typeof c.getChildContext!="function")return o;c=c.getChildContext();for(var _ in c)if(!(_ in s))throw Error(r(108,be(t)||"Unknown",_));return ne({},o,c)}function R(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||bs,Os=an.current,Tt(an,t),Tt(gn,gn.current),!0}function ce(t,s,o){var c=t.stateNode;if(!c)throw Error(r(169));o?(t=S(t,s,Os),c.__reactInternalMemoizedMergedChildContext=t,At(gn),At(an),Tt(an,t)):At(gn),Tt(gn,o)}var V=null,we=!1,Pe=!1;function Fe(t){V===null?V=[t]:V.push(t)}function We(t){we=!0,Fe(t)}function $t(){if(!Pe&&V!==null){Pe=!0;var t=0,s=kt;try{var o=V;for(kt=1;t<o.length;t++){var c=o[t];do c=c(!0);while(c!==null)}V=null,we=!1}catch(_){throw V!==null&&(V=V.slice(t+1)),sr(Wr,$t),_}finally{kt=s,Pe=!1}}return null}var zt=[],jn=0,xt=null,it=0,Lt=[],gt=0,qe=null,St=1,Ot="";function Ut(t,s){zt[jn++]=it,zt[jn++]=xt,xt=t,it=s}function Zt(t,s,o){Lt[gt++]=St,Lt[gt++]=Ot,Lt[gt++]=qe,qe=t;var c=St;t=Ot;var _=32-pn(c)-1;c&=~(1<<_),o+=1;var g=32-pn(s)+_;if(30<g){var j=_-_%5;g=(c&(1<<j)-1).toString(32),c>>=j,_-=j,St=1<<32-pn(s)+_|o<<_|c,Ot=g+t}else St=1<<g|o<<_|c,Ot=t}function Rt(t){t.return!==null&&(Ut(t,1),Zt(t,1,0))}function Qt(t){for(;t===xt;)xt=zt[--jn],zt[jn]=null,it=zt[--jn],zt[jn]=null;for(;t===qe;)qe=Lt[--gt],Lt[gt]=null,Ot=Lt[--gt],Lt[gt]=null,St=Lt[--gt],Lt[gt]=null}var un=null,es=null,Dt=!1,ws=null;function Kd(t,s){var o=is(5,null,null,0);o.elementType="DELETED",o.stateNode=s,o.return=t,s=t.deletions,s===null?(t.deletions=[o],t.flags|=16):s.push(o)}function Jd(t,s){switch(t.tag){case 5:var o=t.type;return s=s.nodeType!==1||o.toLowerCase()!==s.nodeName.toLowerCase()?null:s,s!==null?(t.stateNode=s,un=t,es=gs(s.firstChild),!0):!1;case 6:return s=t.pendingProps===""||s.nodeType!==3?null:s,s!==null?(t.stateNode=s,un=t,es=null,!0):!1;case 13:return s=s.nodeType!==8?null:s,s!==null?(o=qe!==null?{id:St,overflow:Ot}:null,t.memoizedState={dehydrated:s,treeContext:o,retryLane:1073741824},o=is(18,null,null,0),o.stateNode=s,o.return=t,t.child=o,un=t,es=null,!0):!1;default:return!1}}function qc(t){return(t.mode&1)!==0&&(t.flags&128)===0}function Uc(t){if(Dt){var s=es;if(s){var o=s;if(!Jd(t,s)){if(qc(t))throw Error(r(418));s=gs(o.nextSibling);var c=un;s&&Jd(t,s)?Kd(c,o):(t.flags=t.flags&-4097|2,Dt=!1,un=t)}}else{if(qc(t))throw Error(r(418));t.flags=t.flags&-4097|2,Dt=!1,un=t}}}function Qd(t){for(t=t.return;t!==null&&t.tag!==5&&t.tag!==3&&t.tag!==13;)t=t.return;un=t}function El(t){if(t!==un)return!1;if(!Dt)return Qd(t),Dt=!0,!1;var s;if((s=t.tag!==3)&&!(s=t.tag!==5)&&(s=t.type,s=s!=="head"&&s!=="body"&&!Xn(t.type,t.memoizedProps)),s&&(s=es)){if(qc(t))throw Yd(),Error(r(418));for(;s;)Kd(t,s),s=gs(s.nextSibling)}if(Qd(t),t.tag===13){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(r(317));e:{for(t=t.nextSibling,s=0;t;){if(t.nodeType===8){var o=t.data;if(o==="/$"){if(s===0){es=gs(t.nextSibling);break e}s--}else o!=="$"&&o!=="$!"&&o!=="$?"||s++}t=t.nextSibling}es=null}}else es=un?gs(t.stateNode.nextSibling):null;return!0}function Yd(){for(var t=es;t;)t=gs(t.nextSibling)}function hi(){es=un=null,Dt=!1}function Bc(t){ws===null?ws=[t]:ws.push(t)}var qp=q.ReactCurrentBatchConfig;function go(t,s,o){if(t=o.ref,t!==null&&typeof t!="function"&&typeof t!="object"){if(o._owner){if(o=o._owner,o){if(o.tag!==1)throw Error(r(309));var c=o.stateNode}if(!c)throw Error(r(147,t));var _=c,g=""+t;return s!==null&&s.ref!==null&&typeof s.ref=="function"&&s.ref._stringRef===g?s.ref:(s=function(j){var F=_.refs;j===null?delete F[g]:F[g]=j},s._stringRef=g,s)}if(typeof t!="string")throw Error(r(284));if(!o._owner)throw Error(r(290,t))}return t}function Tl(t,s){throw t=Object.prototype.toString.call(s),Error(r(31,t==="[object Object]"?"object with keys {"+Object.keys(s).join(", ")+"}":t))}function Xd(t){var s=t._init;return s(t._payload)}function Zd(t){function s(ue,ee){if(t){var me=ue.deletions;me===null?(ue.deletions=[ee],ue.flags|=16):me.push(ee)}}function o(ue,ee){if(!t)return null;for(;ee!==null;)s(ue,ee),ee=ee.sibling;return null}function c(ue,ee){for(ue=new Map;ee!==null;)ee.key!==null?ue.set(ee.key,ee):ue.set(ee.index,ee),ee=ee.sibling;return ue}function _(ue,ee){return ue=Va(ue,ee),ue.index=0,ue.sibling=null,ue}function g(ue,ee,me){return ue.index=me,t?(me=ue.alternate,me!==null?(me=me.index,me<ee?(ue.flags|=2,ee):me):(ue.flags|=2,ee)):(ue.flags|=1048576,ee)}function j(ue){return t&&ue.alternate===null&&(ue.flags|=2),ue}function F(ue,ee,me,Ie){return ee===null||ee.tag!==6?(ee=Mu(me,ue.mode,Ie),ee.return=ue,ee):(ee=_(ee,me),ee.return=ue,ee)}function J(ue,ee,me,Ie){var Ye=me.type;return Ye===fe?Te(ue,ee,me.props.children,Ie,me.key):ee!==null&&(ee.elementType===Ye||typeof Ye=="object"&&Ye!==null&&Ye.$$typeof===U&&Xd(Ye)===ee.type)?(Ie=_(ee,me.props),Ie.ref=go(ue,ee,me),Ie.return=ue,Ie):(Ie=ec(me.type,me.key,me.props,null,ue.mode,Ie),Ie.ref=go(ue,ee,me),Ie.return=ue,Ie)}function _e(ue,ee,me,Ie){return ee===null||ee.tag!==4||ee.stateNode.containerInfo!==me.containerInfo||ee.stateNode.implementation!==me.implementation?(ee=Pu(me,ue.mode,Ie),ee.return=ue,ee):(ee=_(ee,me.children||[]),ee.return=ue,ee)}function Te(ue,ee,me,Ie,Ye){return ee===null||ee.tag!==7?(ee=Mr(me,ue.mode,Ie,Ye),ee.return=ue,ee):(ee=_(ee,me),ee.return=ue,ee)}function Re(ue,ee,me){if(typeof ee=="string"&&ee!==""||typeof ee=="number")return ee=Mu(""+ee,ue.mode,me),ee.return=ue,ee;if(typeof ee=="object"&&ee!==null){switch(ee.$$typeof){case A:return me=ec(ee.type,ee.key,ee.props,null,ue.mode,me),me.ref=go(ue,null,ee),me.return=ue,me;case H:return ee=Pu(ee,ue.mode,me),ee.return=ue,ee;case U:var Ie=ee._init;return Re(ue,Ie(ee._payload),me)}if(Y(ee)||Z(ee))return ee=Mr(ee,ue.mode,me,null),ee.return=ue,ee;Tl(ue,ee)}return null}function $e(ue,ee,me,Ie){var Ye=ee!==null?ee.key:null;if(typeof me=="string"&&me!==""||typeof me=="number")return Ye!==null?null:F(ue,ee,""+me,Ie);if(typeof me=="object"&&me!==null){switch(me.$$typeof){case A:return me.key===Ye?J(ue,ee,me,Ie):null;case H:return me.key===Ye?_e(ue,ee,me,Ie):null;case U:return Ye=me._init,$e(ue,ee,Ye(me._payload),Ie)}if(Y(me)||Z(me))return Ye!==null?null:Te(ue,ee,me,Ie,null);Tl(ue,me)}return null}function Be(ue,ee,me,Ie,Ye){if(typeof Ie=="string"&&Ie!==""||typeof Ie=="number")return ue=ue.get(me)||null,F(ee,ue,""+Ie,Ye);if(typeof Ie=="object"&&Ie!==null){switch(Ie.$$typeof){case A:return ue=ue.get(Ie.key===null?me:Ie.key)||null,J(ee,ue,Ie,Ye);case H:return ue=ue.get(Ie.key===null?me:Ie.key)||null,_e(ee,ue,Ie,Ye);case U:var nt=Ie._init;return Be(ue,ee,me,nt(Ie._payload),Ye)}if(Y(Ie)||Z(Ie))return ue=ue.get(me)||null,Te(ee,ue,Ie,Ye,null);Tl(ee,Ie)}return null}function Ke(ue,ee,me,Ie){for(var Ye=null,nt=null,st=ee,ot=ee=0,fn=null;st!==null&&ot<me.length;ot++){st.index>ot?(fn=st,st=null):fn=st.sibling;var Nt=$e(ue,st,me[ot],Ie);if(Nt===null){st===null&&(st=fn);break}t&&st&&Nt.alternate===null&&s(ue,st),ee=g(Nt,ee,ot),nt===null?Ye=Nt:nt.sibling=Nt,nt=Nt,st=fn}if(ot===me.length)return o(ue,st),Dt&&Ut(ue,ot),Ye;if(st===null){for(;ot<me.length;ot++)st=Re(ue,me[ot],Ie),st!==null&&(ee=g(st,ee,ot),nt===null?Ye=st:nt.sibling=st,nt=st);return Dt&&Ut(ue,ot),Ye}for(st=c(ue,st);ot<me.length;ot++)fn=Be(st,ue,ot,me[ot],Ie),fn!==null&&(t&&fn.alternate!==null&&st.delete(fn.key===null?ot:fn.key),ee=g(fn,ee,ot),nt===null?Ye=fn:nt.sibling=fn,nt=fn);return t&&st.forEach(function(Ga){return s(ue,Ga)}),Dt&&Ut(ue,ot),Ye}function Qe(ue,ee,me,Ie){var Ye=Z(me);if(typeof Ye!="function")throw Error(r(150));if(me=Ye.call(me),me==null)throw Error(r(151));for(var nt=Ye=null,st=ee,ot=ee=0,fn=null,Nt=me.next();st!==null&&!Nt.done;ot++,Nt=me.next()){st.index>ot?(fn=st,st=null):fn=st.sibling;var Ga=$e(ue,st,Nt.value,Ie);if(Ga===null){st===null&&(st=fn);break}t&&st&&Ga.alternate===null&&s(ue,st),ee=g(Ga,ee,ot),nt===null?Ye=Ga:nt.sibling=Ga,nt=Ga,st=fn}if(Nt.done)return o(ue,st),Dt&&Ut(ue,ot),Ye;if(st===null){for(;!Nt.done;ot++,Nt=me.next())Nt=Re(ue,Nt.value,Ie),Nt!==null&&(ee=g(Nt,ee,ot),nt===null?Ye=Nt:nt.sibling=Nt,nt=Nt);return Dt&&Ut(ue,ot),Ye}for(st=c(ue,st);!Nt.done;ot++,Nt=me.next())Nt=Be(st,ue,ot,Nt.value,Ie),Nt!==null&&(t&&Nt.alternate!==null&&st.delete(Nt.key===null?ot:Nt.key),ee=g(Nt,ee,ot),nt===null?Ye=Nt:nt.sibling=Nt,nt=Nt);return t&&st.forEach(function(x_){return s(ue,x_)}),Dt&&Ut(ue,ot),Ye}function Yt(ue,ee,me,Ie){if(typeof me=="object"&&me!==null&&me.type===fe&&me.key===null&&(me=me.props.children),typeof me=="object"&&me!==null){switch(me.$$typeof){case A:e:{for(var Ye=me.key,nt=ee;nt!==null;){if(nt.key===Ye){if(Ye=me.type,Ye===fe){if(nt.tag===7){o(ue,nt.sibling),ee=_(nt,me.props.children),ee.return=ue,ue=ee;break e}}else if(nt.elementType===Ye||typeof Ye=="object"&&Ye!==null&&Ye.$$typeof===U&&Xd(Ye)===nt.type){o(ue,nt.sibling),ee=_(nt,me.props),ee.ref=go(ue,nt,me),ee.return=ue,ue=ee;break e}o(ue,nt);break}else s(ue,nt);nt=nt.sibling}me.type===fe?(ee=Mr(me.props.children,ue.mode,Ie,me.key),ee.return=ue,ue=ee):(Ie=ec(me.type,me.key,me.props,null,ue.mode,Ie),Ie.ref=go(ue,ee,me),Ie.return=ue,ue=Ie)}return j(ue);case H:e:{for(nt=me.key;ee!==null;){if(ee.key===nt)if(ee.tag===4&&ee.stateNode.containerInfo===me.containerInfo&&ee.stateNode.implementation===me.implementation){o(ue,ee.sibling),ee=_(ee,me.children||[]),ee.return=ue,ue=ee;break e}else{o(ue,ee);break}else s(ue,ee);ee=ee.sibling}ee=Pu(me,ue.mode,Ie),ee.return=ue,ue=ee}return j(ue);case U:return nt=me._init,Yt(ue,ee,nt(me._payload),Ie)}if(Y(me))return Ke(ue,ee,me,Ie);if(Z(me))return Qe(ue,ee,me,Ie);Tl(ue,me)}return typeof me=="string"&&me!==""||typeof me=="number"?(me=""+me,ee!==null&&ee.tag===6?(o(ue,ee.sibling),ee=_(ee,me),ee.return=ue,ue=ee):(o(ue,ee),ee=Mu(me,ue.mode,Ie),ee.return=ue,ue=ee),j(ue)):o(ue,ee)}return Yt}var pi=Zd(!0),em=Zd(!1),Al=xs(null),Ll=null,_i=null,Wc=null;function Hc(){Wc=_i=Ll=null}function Vc(t){var s=Al.current;At(Al),t._currentValue=s}function Gc(t,s,o){for(;t!==null;){var c=t.alternate;if((t.childLanes&s)!==s?(t.childLanes|=s,c!==null&&(c.childLanes|=s)):c!==null&&(c.childLanes&s)!==s&&(c.childLanes|=s),t===o)break;t=t.return}}function gi(t,s){Ll=t,Wc=_i=null,t=t.dependencies,t!==null&&t.firstContext!==null&&((t.lanes&s)!==0&&(qn=!0),t.firstContext=null)}function ss(t){var s=t._currentValue;if(Wc!==t)if(t={context:t,memoizedValue:s,next:null},_i===null){if(Ll===null)throw Error(r(308));_i=t,Ll.dependencies={lanes:0,firstContext:t}}else _i=_i.next=t;return s}var Cr=null;function Kc(t){Cr===null?Cr=[t]:Cr.push(t)}function tm(t,s,o,c){var _=s.interleaved;return _===null?(o.next=o,Kc(s)):(o.next=_.next,_.next=o),s.interleaved=o,ca(t,c)}function ca(t,s){t.lanes|=s;var o=t.alternate;for(o!==null&&(o.lanes|=s),o=t,t=t.return;t!==null;)t.childLanes|=s,o=t.alternate,o!==null&&(o.childLanes|=s),o=t,t=t.return;return o.tag===3?o.stateNode:null}var Oa=!1;function Jc(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function nm(t,s){t=t.updateQueue,s.updateQueue===t&&(s.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function ua(t,s){return{eventTime:t,lane:s,tag:0,payload:null,callback:null,next:null}}function Fa(t,s,o){var c=t.updateQueue;if(c===null)return null;if(c=c.shared,(bt&2)!==0){var _=c.pending;return _===null?s.next=s:(s.next=_.next,_.next=s),c.pending=s,ca(t,o)}return _=c.interleaved,_===null?(s.next=s,Kc(c)):(s.next=_.next,_.next=s),c.interleaved=s,ca(t,o)}function Rl(t,s,o){if(s=s.updateQueue,s!==null&&(s=s.shared,(o&4194240)!==0)){var c=s.lanes;c&=t.pendingLanes,o|=c,s.lanes=o,Rs(t,o)}}function sm(t,s){var o=t.updateQueue,c=t.alternate;if(c!==null&&(c=c.updateQueue,o===c)){var _=null,g=null;if(o=o.firstBaseUpdate,o!==null){do{var j={eventTime:o.eventTime,lane:o.lane,tag:o.tag,payload:o.payload,callback:o.callback,next:null};g===null?_=g=j:g=g.next=j,o=o.next}while(o!==null);g===null?_=g=s:g=g.next=s}else _=g=s;o={baseState:c.baseState,firstBaseUpdate:_,lastBaseUpdate:g,shared:c.shared,effects:c.effects},t.updateQueue=o;return}t=o.lastBaseUpdate,t===null?o.firstBaseUpdate=s:t.next=s,o.lastBaseUpdate=s}function Ml(t,s,o,c){var _=t.updateQueue;Oa=!1;var g=_.firstBaseUpdate,j=_.lastBaseUpdate,F=_.shared.pending;if(F!==null){_.shared.pending=null;var J=F,_e=J.next;J.next=null,j===null?g=_e:j.next=_e,j=J;var Te=t.alternate;Te!==null&&(Te=Te.updateQueue,F=Te.lastBaseUpdate,F!==j&&(F===null?Te.firstBaseUpdate=_e:F.next=_e,Te.lastBaseUpdate=J))}if(g!==null){var Re=_.baseState;j=0,Te=_e=J=null,F=g;do{var $e=F.lane,Be=F.eventTime;if((c&$e)===$e){Te!==null&&(Te=Te.next={eventTime:Be,lane:0,tag:F.tag,payload:F.payload,callback:F.callback,next:null});e:{var Ke=t,Qe=F;switch($e=s,Be=o,Qe.tag){case 1:if(Ke=Qe.payload,typeof Ke=="function"){Re=Ke.call(Be,Re,$e);break e}Re=Ke;break e;case 3:Ke.flags=Ke.flags&-65537|128;case 0:if(Ke=Qe.payload,$e=typeof Ke=="function"?Ke.call(Be,Re,$e):Ke,$e==null)break e;Re=ne({},Re,$e);break e;case 2:Oa=!0}}F.callback!==null&&F.lane!==0&&(t.flags|=64,$e=_.effects,$e===null?_.effects=[F]:$e.push(F))}else Be={eventTime:Be,lane:$e,tag:F.tag,payload:F.payload,callback:F.callback,next:null},Te===null?(_e=Te=Be,J=Re):Te=Te.next=Be,j|=$e;if(F=F.next,F===null){if(F=_.shared.pending,F===null)break;$e=F,F=$e.next,$e.next=null,_.lastBaseUpdate=$e,_.shared.pending=null}}while(!0);if(Te===null&&(J=Re),_.baseState=J,_.firstBaseUpdate=_e,_.lastBaseUpdate=Te,s=_.shared.interleaved,s!==null){_=s;do j|=_.lane,_=_.next;while(_!==s)}else g===null&&(_.shared.lanes=0);Tr|=j,t.lanes=j,t.memoizedState=Re}}function am(t,s,o){if(t=s.effects,s.effects=null,t!==null)for(s=0;s<t.length;s++){var c=t[s],_=c.callback;if(_!==null){if(c.callback=null,c=o,typeof _!="function")throw Error(r(191,_));_.call(c)}}}var yo={},Fs=xs(yo),vo=xs(yo),xo=xs(yo);function $r(t){if(t===yo)throw Error(r(174));return t}function Qc(t,s){switch(Tt(xo,s),Tt(vo,t),Tt(Fs,yo),t=s.nodeType,t){case 9:case 11:s=(s=s.documentElement)?s.namespaceURI:ze(null,"");break;default:t=t===8?s.parentNode:s,s=t.namespaceURI||null,t=t.tagName,s=ze(s,t)}At(Fs),Tt(Fs,s)}function yi(){At(Fs),At(vo),At(xo)}function rm(t){$r(xo.current);var s=$r(Fs.current),o=ze(s,t.type);s!==o&&(Tt(vo,t),Tt(Fs,o))}function Yc(t){vo.current===t&&(At(Fs),At(vo))}var Ft=xs(0);function Pl(t){for(var s=t;s!==null;){if(s.tag===13){var o=s.memoizedState;if(o!==null&&(o=o.dehydrated,o===null||o.data==="$?"||o.data==="$!"))return s}else if(s.tag===19&&s.memoizedProps.revealOrder!==void 0){if((s.flags&128)!==0)return s}else if(s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break;for(;s.sibling===null;){if(s.return===null||s.return===t)return null;s=s.return}s.sibling.return=s.return,s=s.sibling}return null}var Xc=[];function Zc(){for(var t=0;t<Xc.length;t++)Xc[t]._workInProgressVersionPrimary=null;Xc.length=0}var zl=q.ReactCurrentDispatcher,eu=q.ReactCurrentBatchConfig,Er=0,qt=null,rn=null,dn=null,Il=!1,bo=!1,wo=0,Up=0;function kn(){throw Error(r(321))}function tu(t,s){if(s===null)return!1;for(var o=0;o<s.length&&o<t.length;o++)if(!Yn(t[o],s[o]))return!1;return!0}function nu(t,s,o,c,_,g){if(Er=g,qt=s,s.memoizedState=null,s.updateQueue=null,s.lanes=0,zl.current=t===null||t.memoizedState===null?Vp:Gp,t=o(c,_),bo){g=0;do{if(bo=!1,wo=0,25<=g)throw Error(r(301));g+=1,dn=rn=null,s.updateQueue=null,zl.current=Kp,t=o(c,_)}while(bo)}if(zl.current=Fl,s=rn!==null&&rn.next!==null,Er=0,dn=rn=qt=null,Il=!1,s)throw Error(r(300));return t}function su(){var t=wo!==0;return wo=0,t}function qs(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return dn===null?qt.memoizedState=dn=t:dn=dn.next=t,dn}function as(){if(rn===null){var t=qt.alternate;t=t!==null?t.memoizedState:null}else t=rn.next;var s=dn===null?qt.memoizedState:dn.next;if(s!==null)dn=s,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},dn===null?qt.memoizedState=dn=t:dn=dn.next=t}return dn}function jo(t,s){return typeof s=="function"?s(t):s}function au(t){var s=as(),o=s.queue;if(o===null)throw Error(r(311));o.lastRenderedReducer=t;var c=rn,_=c.baseQueue,g=o.pending;if(g!==null){if(_!==null){var j=_.next;_.next=g.next,g.next=j}c.baseQueue=_=g,o.pending=null}if(_!==null){g=_.next,c=c.baseState;var F=j=null,J=null,_e=g;do{var Te=_e.lane;if((Er&Te)===Te)J!==null&&(J=J.next={lane:0,action:_e.action,hasEagerState:_e.hasEagerState,eagerState:_e.eagerState,next:null}),c=_e.hasEagerState?_e.eagerState:t(c,_e.action);else{var Re={lane:Te,action:_e.action,hasEagerState:_e.hasEagerState,eagerState:_e.eagerState,next:null};J===null?(F=J=Re,j=c):J=J.next=Re,qt.lanes|=Te,Tr|=Te}_e=_e.next}while(_e!==null&&_e!==g);J===null?j=c:J.next=F,Yn(c,s.memoizedState)||(qn=!0),s.memoizedState=c,s.baseState=j,s.baseQueue=J,o.lastRenderedState=c}if(t=o.interleaved,t!==null){_=t;do g=_.lane,qt.lanes|=g,Tr|=g,_=_.next;while(_!==t)}else _===null&&(o.lanes=0);return[s.memoizedState,o.dispatch]}function ru(t){var s=as(),o=s.queue;if(o===null)throw Error(r(311));o.lastRenderedReducer=t;var c=o.dispatch,_=o.pending,g=s.memoizedState;if(_!==null){o.pending=null;var j=_=_.next;do g=t(g,j.action),j=j.next;while(j!==_);Yn(g,s.memoizedState)||(qn=!0),s.memoizedState=g,s.baseQueue===null&&(s.baseState=g),o.lastRenderedState=g}return[g,c]}function im(){}function om(t,s){var o=qt,c=as(),_=s(),g=!Yn(c.memoizedState,_);if(g&&(c.memoizedState=_,qn=!0),c=c.queue,iu(um.bind(null,o,c,t),[t]),c.getSnapshot!==s||g||dn!==null&&dn.memoizedState.tag&1){if(o.flags|=2048,ko(9,cm.bind(null,o,c,_,s),void 0,null),mn===null)throw Error(r(349));(Er&30)!==0||lm(o,s,_)}return _}function lm(t,s,o){t.flags|=16384,t={getSnapshot:s,value:o},s=qt.updateQueue,s===null?(s={lastEffect:null,stores:null},qt.updateQueue=s,s.stores=[t]):(o=s.stores,o===null?s.stores=[t]:o.push(t))}function cm(t,s,o,c){s.value=o,s.getSnapshot=c,dm(s)&&mm(t)}function um(t,s,o){return o(function(){dm(s)&&mm(t)})}function dm(t){var s=t.getSnapshot;t=t.value;try{var o=s();return!Yn(t,o)}catch{return!0}}function mm(t){var s=ca(t,1);s!==null&&Ns(s,t,1,-1)}function fm(t){var s=qs();return typeof t=="function"&&(t=t()),s.memoizedState=s.baseState=t,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:jo,lastRenderedState:t},s.queue=t,t=t.dispatch=Hp.bind(null,qt,t),[s.memoizedState,t]}function ko(t,s,o,c){return t={tag:t,create:s,destroy:o,deps:c,next:null},s=qt.updateQueue,s===null?(s={lastEffect:null,stores:null},qt.updateQueue=s,s.lastEffect=t.next=t):(o=s.lastEffect,o===null?s.lastEffect=t.next=t:(c=o.next,o.next=t,t.next=c,s.lastEffect=t)),t}function hm(){return as().memoizedState}function Dl(t,s,o,c){var _=qs();qt.flags|=t,_.memoizedState=ko(1|s,o,void 0,c===void 0?null:c)}function Ol(t,s,o,c){var _=as();c=c===void 0?null:c;var g=void 0;if(rn!==null){var j=rn.memoizedState;if(g=j.destroy,c!==null&&tu(c,j.deps)){_.memoizedState=ko(s,o,g,c);return}}qt.flags|=t,_.memoizedState=ko(1|s,o,g,c)}function pm(t,s){return Dl(8390656,8,t,s)}function iu(t,s){return Ol(2048,8,t,s)}function _m(t,s){return Ol(4,2,t,s)}function gm(t,s){return Ol(4,4,t,s)}function ym(t,s){if(typeof s=="function")return t=t(),s(t),function(){s(null)};if(s!=null)return t=t(),s.current=t,function(){s.current=null}}function vm(t,s,o){return o=o!=null?o.concat([t]):null,Ol(4,4,ym.bind(null,s,t),o)}function ou(){}function xm(t,s){var o=as();s=s===void 0?null:s;var c=o.memoizedState;return c!==null&&s!==null&&tu(s,c[1])?c[0]:(o.memoizedState=[t,s],t)}function bm(t,s){var o=as();s=s===void 0?null:s;var c=o.memoizedState;return c!==null&&s!==null&&tu(s,c[1])?c[0]:(t=t(),o.memoizedState=[t,s],t)}function wm(t,s,o){return(Er&21)===0?(t.baseState&&(t.baseState=!1,qn=!0),t.memoizedState=o):(Yn(o,s)||(o=Vt(),qt.lanes|=o,Tr|=o,t.baseState=!0),s)}function Bp(t,s){var o=kt;kt=o!==0&&4>o?o:4,t(!0);var c=eu.transition;eu.transition={};try{t(!1),s()}finally{kt=o,eu.transition=c}}function jm(){return as().memoizedState}function Wp(t,s,o){var c=Wa(t);if(o={lane:c,action:o,hasEagerState:!1,eagerState:null,next:null},km(t))Sm(s,o);else if(o=tm(t,s,o,c),o!==null){var _=Rn();Ns(o,t,c,_),Nm(o,s,c)}}function Hp(t,s,o){var c=Wa(t),_={lane:c,action:o,hasEagerState:!1,eagerState:null,next:null};if(km(t))Sm(s,_);else{var g=t.alternate;if(t.lanes===0&&(g===null||g.lanes===0)&&(g=s.lastRenderedReducer,g!==null))try{var j=s.lastRenderedState,F=g(j,o);if(_.hasEagerState=!0,_.eagerState=F,Yn(F,j)){var J=s.interleaved;J===null?(_.next=_,Kc(s)):(_.next=J.next,J.next=_),s.interleaved=_;return}}catch{}finally{}o=tm(t,s,_,c),o!==null&&(_=Rn(),Ns(o,t,c,_),Nm(o,s,c))}}function km(t){var s=t.alternate;return t===qt||s!==null&&s===qt}function Sm(t,s){bo=Il=!0;var o=t.pending;o===null?s.next=s:(s.next=o.next,o.next=s),t.pending=s}function Nm(t,s,o){if((o&4194240)!==0){var c=s.lanes;c&=t.pendingLanes,o|=c,s.lanes=o,Rs(t,o)}}var Fl={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},Vp={readContext:ss,useCallback:function(t,s){return qs().memoizedState=[t,s===void 0?null:s],t},useContext:ss,useEffect:pm,useImperativeHandle:function(t,s,o){return o=o!=null?o.concat([t]):null,Dl(4194308,4,ym.bind(null,s,t),o)},useLayoutEffect:function(t,s){return Dl(4194308,4,t,s)},useInsertionEffect:function(t,s){return Dl(4,2,t,s)},useMemo:function(t,s){var o=qs();return s=s===void 0?null:s,t=t(),o.memoizedState=[t,s],t},useReducer:function(t,s,o){var c=qs();return s=o!==void 0?o(s):s,c.memoizedState=c.baseState=s,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:s},c.queue=t,t=t.dispatch=Wp.bind(null,qt,t),[c.memoizedState,t]},useRef:function(t){var s=qs();return t={current:t},s.memoizedState=t},useState:fm,useDebugValue:ou,useDeferredValue:function(t){return qs().memoizedState=t},useTransition:function(){var t=fm(!1),s=t[0];return t=Bp.bind(null,t[1]),qs().memoizedState=t,[s,t]},useMutableSource:function(){},useSyncExternalStore:function(t,s,o){var c=qt,_=qs();if(Dt){if(o===void 0)throw Error(r(407));o=o()}else{if(o=s(),mn===null)throw Error(r(349));(Er&30)!==0||lm(c,s,o)}_.memoizedState=o;var g={value:o,getSnapshot:s};return _.queue=g,pm(um.bind(null,c,g,t),[t]),c.flags|=2048,ko(9,cm.bind(null,c,g,o,s),void 0,null),o},useId:function(){var t=qs(),s=mn.identifierPrefix;if(Dt){var o=Ot,c=St;o=(c&~(1<<32-pn(c)-1)).toString(32)+o,s=":"+s+"R"+o,o=wo++,0<o&&(s+="H"+o.toString(32)),s+=":"}else o=Up++,s=":"+s+"r"+o.toString(32)+":";return t.memoizedState=s},unstable_isNewReconciler:!1},Gp={readContext:ss,useCallback:xm,useContext:ss,useEffect:iu,useImperativeHandle:vm,useInsertionEffect:_m,useLayoutEffect:gm,useMemo:bm,useReducer:au,useRef:hm,useState:function(){return au(jo)},useDebugValue:ou,useDeferredValue:function(t){var s=as();return wm(s,rn.memoizedState,t)},useTransition:function(){var t=au(jo)[0],s=as().memoizedState;return[t,s]},useMutableSource:im,useSyncExternalStore:om,useId:jm,unstable_isNewReconciler:!1},Kp={readContext:ss,useCallback:xm,useContext:ss,useEffect:iu,useImperativeHandle:vm,useInsertionEffect:_m,useLayoutEffect:gm,useMemo:bm,useReducer:ru,useRef:hm,useState:function(){return ru(jo)},useDebugValue:ou,useDeferredValue:function(t){var s=as();return rn===null?s.memoizedState=t:wm(s,rn.memoizedState,t)},useTransition:function(){var t=ru(jo)[0],s=as().memoizedState;return[t,s]},useMutableSource:im,useSyncExternalStore:om,useId:jm,unstable_isNewReconciler:!1};function js(t,s){if(t&&t.defaultProps){s=ne({},s),t=t.defaultProps;for(var o in t)s[o]===void 0&&(s[o]=t[o]);return s}return s}function lu(t,s,o,c){s=t.memoizedState,o=o(c,s),o=o==null?s:ne({},s,o),t.memoizedState=o,t.lanes===0&&(t.updateQueue.baseState=o)}var ql={isMounted:function(t){return(t=t._reactInternals)?Ts(t)===t:!1},enqueueSetState:function(t,s,o){t=t._reactInternals;var c=Rn(),_=Wa(t),g=ua(c,_);g.payload=s,o!=null&&(g.callback=o),s=Fa(t,g,_),s!==null&&(Ns(s,t,_,c),Rl(s,t,_))},enqueueReplaceState:function(t,s,o){t=t._reactInternals;var c=Rn(),_=Wa(t),g=ua(c,_);g.tag=1,g.payload=s,o!=null&&(g.callback=o),s=Fa(t,g,_),s!==null&&(Ns(s,t,_,c),Rl(s,t,_))},enqueueForceUpdate:function(t,s){t=t._reactInternals;var o=Rn(),c=Wa(t),_=ua(o,c);_.tag=2,s!=null&&(_.callback=s),s=Fa(t,_,c),s!==null&&(Ns(s,t,c,o),Rl(s,t,c))}};function Cm(t,s,o,c,_,g,j){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(c,g,j):s.prototype&&s.prototype.isPureReactComponent?!na(o,c)||!na(_,g):!0}function $m(t,s,o){var c=!1,_=bs,g=s.contextType;return typeof g=="object"&&g!==null?g=ss(g):(_=f(s)?Os:an.current,c=s.contextTypes,g=(c=c!=null)?la(t,_):bs),s=new s(o,g),t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,s.updater=ql,t.stateNode=s,s._reactInternals=t,c&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=_,t.__reactInternalMemoizedMaskedChildContext=g),s}function Em(t,s,o,c){t=s.state,typeof s.componentWillReceiveProps=="function"&&s.componentWillReceiveProps(o,c),typeof s.UNSAFE_componentWillReceiveProps=="function"&&s.UNSAFE_componentWillReceiveProps(o,c),s.state!==t&&ql.enqueueReplaceState(s,s.state,null)}function cu(t,s,o,c){var _=t.stateNode;_.props=o,_.state=t.memoizedState,_.refs={},Jc(t);var g=s.contextType;typeof g=="object"&&g!==null?_.context=ss(g):(g=f(s)?Os:an.current,_.context=la(t,g)),_.state=t.memoizedState,g=s.getDerivedStateFromProps,typeof g=="function"&&(lu(t,s,g,o),_.state=t.memoizedState),typeof s.getDerivedStateFromProps=="function"||typeof _.getSnapshotBeforeUpdate=="function"||typeof _.UNSAFE_componentWillMount!="function"&&typeof _.componentWillMount!="function"||(s=_.state,typeof _.componentWillMount=="function"&&_.componentWillMount(),typeof _.UNSAFE_componentWillMount=="function"&&_.UNSAFE_componentWillMount(),s!==_.state&&ql.enqueueReplaceState(_,_.state,null),Ml(t,o,_,c),_.state=t.memoizedState),typeof _.componentDidMount=="function"&&(t.flags|=4194308)}function vi(t,s){try{var o="",c=s;do o+=he(c),c=c.return;while(c);var _=o}catch(g){_=`
39
+ Error generating stack: `+g.message+`
40
+ `+g.stack}return{value:t,source:s,stack:_,digest:null}}function uu(t,s,o){return{value:t,source:null,stack:o??null,digest:s??null}}function du(t,s){try{console.error(s.value)}catch(o){setTimeout(function(){throw o})}}var Jp=typeof WeakMap=="function"?WeakMap:Map;function Tm(t,s,o){o=ua(-1,o),o.tag=3,o.payload={element:null};var c=s.value;return o.callback=function(){Kl||(Kl=!0,Nu=c),du(t,s)},o}function Am(t,s,o){o=ua(-1,o),o.tag=3;var c=t.type.getDerivedStateFromError;if(typeof c=="function"){var _=s.value;o.payload=function(){return c(_)},o.callback=function(){du(t,s)}}var g=t.stateNode;return g!==null&&typeof g.componentDidCatch=="function"&&(o.callback=function(){du(t,s),typeof c!="function"&&(Ua===null?Ua=new Set([this]):Ua.add(this));var j=s.stack;this.componentDidCatch(s.value,{componentStack:j!==null?j:""})}),o}function Lm(t,s,o){var c=t.pingCache;if(c===null){c=t.pingCache=new Jp;var _=new Set;c.set(s,_)}else _=c.get(s),_===void 0&&(_=new Set,c.set(s,_));_.has(o)||(_.add(o),t=c_.bind(null,t,s,o),s.then(t,t))}function Rm(t){do{var s;if((s=t.tag===13)&&(s=t.memoizedState,s=s!==null?s.dehydrated!==null:!0),s)return t;t=t.return}while(t!==null);return null}function Mm(t,s,o,c,_){return(t.mode&1)===0?(t===s?t.flags|=65536:(t.flags|=128,o.flags|=131072,o.flags&=-52805,o.tag===1&&(o.alternate===null?o.tag=17:(s=ua(-1,1),s.tag=2,Fa(o,s,1))),o.lanes|=1),t):(t.flags|=65536,t.lanes=_,t)}var Qp=q.ReactCurrentOwner,qn=!1;function Ln(t,s,o,c){s.child=t===null?em(s,null,o,c):pi(s,t.child,o,c)}function Pm(t,s,o,c,_){o=o.render;var g=s.ref;return gi(s,_),c=nu(t,s,o,c,g,_),o=su(),t!==null&&!qn?(s.updateQueue=t.updateQueue,s.flags&=-2053,t.lanes&=~_,da(t,s,_)):(Dt&&o&&Rt(s),s.flags|=1,Ln(t,s,c,_),s.child)}function zm(t,s,o,c,_){if(t===null){var g=o.type;return typeof g=="function"&&!Ru(g)&&g.defaultProps===void 0&&o.compare===null&&o.defaultProps===void 0?(s.tag=15,s.type=g,Im(t,s,g,c,_)):(t=ec(o.type,null,c,s,s.mode,_),t.ref=s.ref,t.return=s,s.child=t)}if(g=t.child,(t.lanes&_)===0){var j=g.memoizedProps;if(o=o.compare,o=o!==null?o:na,o(j,c)&&t.ref===s.ref)return da(t,s,_)}return s.flags|=1,t=Va(g,c),t.ref=s.ref,t.return=s,s.child=t}function Im(t,s,o,c,_){if(t!==null){var g=t.memoizedProps;if(na(g,c)&&t.ref===s.ref)if(qn=!1,s.pendingProps=c=g,(t.lanes&_)!==0)(t.flags&131072)!==0&&(qn=!0);else return s.lanes=t.lanes,da(t,s,_)}return mu(t,s,o,c,_)}function Dm(t,s,o){var c=s.pendingProps,_=c.children,g=t!==null?t.memoizedState:null;if(c.mode==="hidden")if((s.mode&1)===0)s.memoizedState={baseLanes:0,cachePool:null,transitions:null},Tt(bi,ts),ts|=o;else{if((o&1073741824)===0)return t=g!==null?g.baseLanes|o:o,s.lanes=s.childLanes=1073741824,s.memoizedState={baseLanes:t,cachePool:null,transitions:null},s.updateQueue=null,Tt(bi,ts),ts|=t,null;s.memoizedState={baseLanes:0,cachePool:null,transitions:null},c=g!==null?g.baseLanes:o,Tt(bi,ts),ts|=c}else g!==null?(c=g.baseLanes|o,s.memoizedState=null):c=o,Tt(bi,ts),ts|=c;return Ln(t,s,_,o),s.child}function Om(t,s){var o=s.ref;(t===null&&o!==null||t!==null&&t.ref!==o)&&(s.flags|=512,s.flags|=2097152)}function mu(t,s,o,c,_){var g=f(o)?Os:an.current;return g=la(s,g),gi(s,_),o=nu(t,s,o,c,g,_),c=su(),t!==null&&!qn?(s.updateQueue=t.updateQueue,s.flags&=-2053,t.lanes&=~_,da(t,s,_)):(Dt&&c&&Rt(s),s.flags|=1,Ln(t,s,o,_),s.child)}function Fm(t,s,o,c,_){if(f(o)){var g=!0;R(s)}else g=!1;if(gi(s,_),s.stateNode===null)Bl(t,s),$m(s,o,c),cu(s,o,c,_),c=!0;else if(t===null){var j=s.stateNode,F=s.memoizedProps;j.props=F;var J=j.context,_e=o.contextType;typeof _e=="object"&&_e!==null?_e=ss(_e):(_e=f(o)?Os:an.current,_e=la(s,_e));var Te=o.getDerivedStateFromProps,Re=typeof Te=="function"||typeof j.getSnapshotBeforeUpdate=="function";Re||typeof j.UNSAFE_componentWillReceiveProps!="function"&&typeof j.componentWillReceiveProps!="function"||(F!==c||J!==_e)&&Em(s,j,c,_e),Oa=!1;var $e=s.memoizedState;j.state=$e,Ml(s,c,j,_),J=s.memoizedState,F!==c||$e!==J||gn.current||Oa?(typeof Te=="function"&&(lu(s,o,Te,c),J=s.memoizedState),(F=Oa||Cm(s,o,F,c,$e,J,_e))?(Re||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"&&(s.flags|=4194308)):(typeof j.componentDidMount=="function"&&(s.flags|=4194308),s.memoizedProps=c,s.memoizedState=J),j.props=c,j.state=J,j.context=_e,c=F):(typeof j.componentDidMount=="function"&&(s.flags|=4194308),c=!1)}else{j=s.stateNode,nm(t,s),F=s.memoizedProps,_e=s.type===s.elementType?F:js(s.type,F),j.props=_e,Re=s.pendingProps,$e=j.context,J=o.contextType,typeof J=="object"&&J!==null?J=ss(J):(J=f(o)?Os:an.current,J=la(s,J));var Be=o.getDerivedStateFromProps;(Te=typeof Be=="function"||typeof j.getSnapshotBeforeUpdate=="function")||typeof j.UNSAFE_componentWillReceiveProps!="function"&&typeof j.componentWillReceiveProps!="function"||(F!==Re||$e!==J)&&Em(s,j,c,J),Oa=!1,$e=s.memoizedState,j.state=$e,Ml(s,c,j,_);var Ke=s.memoizedState;F!==Re||$e!==Ke||gn.current||Oa?(typeof Be=="function"&&(lu(s,o,Be,c),Ke=s.memoizedState),(_e=Oa||Cm(s,o,_e,c,$e,Ke,J)||!1)?(Te||typeof j.UNSAFE_componentWillUpdate!="function"&&typeof j.componentWillUpdate!="function"||(typeof j.componentWillUpdate=="function"&&j.componentWillUpdate(c,Ke,J),typeof j.UNSAFE_componentWillUpdate=="function"&&j.UNSAFE_componentWillUpdate(c,Ke,J)),typeof j.componentDidUpdate=="function"&&(s.flags|=4),typeof j.getSnapshotBeforeUpdate=="function"&&(s.flags|=1024)):(typeof j.componentDidUpdate!="function"||F===t.memoizedProps&&$e===t.memoizedState||(s.flags|=4),typeof j.getSnapshotBeforeUpdate!="function"||F===t.memoizedProps&&$e===t.memoizedState||(s.flags|=1024),s.memoizedProps=c,s.memoizedState=Ke),j.props=c,j.state=Ke,j.context=J,c=_e):(typeof j.componentDidUpdate!="function"||F===t.memoizedProps&&$e===t.memoizedState||(s.flags|=4),typeof j.getSnapshotBeforeUpdate!="function"||F===t.memoizedProps&&$e===t.memoizedState||(s.flags|=1024),c=!1)}return fu(t,s,o,c,g,_)}function fu(t,s,o,c,_,g){Om(t,s);var j=(s.flags&128)!==0;if(!c&&!j)return _&&ce(s,o,!1),da(t,s,g);c=s.stateNode,Qp.current=s;var F=j&&typeof o.getDerivedStateFromError!="function"?null:c.render();return s.flags|=1,t!==null&&j?(s.child=pi(s,t.child,null,g),s.child=pi(s,null,F,g)):Ln(t,s,F,g),s.memoizedState=c.state,_&&ce(s,o,!0),s.child}function qm(t){var s=t.stateNode;s.pendingContext?N(t,s.pendingContext,s.pendingContext!==s.context):s.context&&N(t,s.context,!1),Qc(t,s.containerInfo)}function Um(t,s,o,c,_){return hi(),Bc(_),s.flags|=256,Ln(t,s,o,c),s.child}var hu={dehydrated:null,treeContext:null,retryLane:0};function pu(t){return{baseLanes:t,cachePool:null,transitions:null}}function Bm(t,s,o){var c=s.pendingProps,_=Ft.current,g=!1,j=(s.flags&128)!==0,F;if((F=j)||(F=t!==null&&t.memoizedState===null?!1:(_&2)!==0),F?(g=!0,s.flags&=-129):(t===null||t.memoizedState!==null)&&(_|=1),Tt(Ft,_&1),t===null)return Uc(s),t=s.memoizedState,t!==null&&(t=t.dehydrated,t!==null)?((s.mode&1)===0?s.lanes=1:t.data==="$!"?s.lanes=8:s.lanes=1073741824,null):(j=c.children,t=c.fallback,g?(c=s.mode,g=s.child,j={mode:"hidden",children:j},(c&1)===0&&g!==null?(g.childLanes=0,g.pendingProps=j):g=tc(j,c,0,null),t=Mr(t,c,o,null),g.return=s,t.return=s,g.sibling=t,s.child=g,s.child.memoizedState=pu(o),s.memoizedState=hu,t):_u(s,j));if(_=t.memoizedState,_!==null&&(F=_.dehydrated,F!==null))return Yp(t,s,j,c,F,_,o);if(g){g=c.fallback,j=s.mode,_=t.child,F=_.sibling;var J={mode:"hidden",children:c.children};return(j&1)===0&&s.child!==_?(c=s.child,c.childLanes=0,c.pendingProps=J,s.deletions=null):(c=Va(_,J),c.subtreeFlags=_.subtreeFlags&14680064),F!==null?g=Va(F,g):(g=Mr(g,j,o,null),g.flags|=2),g.return=s,c.return=s,c.sibling=g,s.child=c,c=g,g=s.child,j=t.child.memoizedState,j=j===null?pu(o):{baseLanes:j.baseLanes|o,cachePool:null,transitions:j.transitions},g.memoizedState=j,g.childLanes=t.childLanes&~o,s.memoizedState=hu,c}return g=t.child,t=g.sibling,c=Va(g,{mode:"visible",children:c.children}),(s.mode&1)===0&&(c.lanes=o),c.return=s,c.sibling=null,t!==null&&(o=s.deletions,o===null?(s.deletions=[t],s.flags|=16):o.push(t)),s.child=c,s.memoizedState=null,c}function _u(t,s){return s=tc({mode:"visible",children:s},t.mode,0,null),s.return=t,t.child=s}function Ul(t,s,o,c){return c!==null&&Bc(c),pi(s,t.child,null,o),t=_u(s,s.pendingProps.children),t.flags|=2,s.memoizedState=null,t}function Yp(t,s,o,c,_,g,j){if(o)return s.flags&256?(s.flags&=-257,c=uu(Error(r(422))),Ul(t,s,j,c)):s.memoizedState!==null?(s.child=t.child,s.flags|=128,null):(g=c.fallback,_=s.mode,c=tc({mode:"visible",children:c.children},_,0,null),g=Mr(g,_,j,null),g.flags|=2,c.return=s,g.return=s,c.sibling=g,s.child=c,(s.mode&1)!==0&&pi(s,t.child,null,j),s.child.memoizedState=pu(j),s.memoizedState=hu,g);if((s.mode&1)===0)return Ul(t,s,j,null);if(_.data==="$!"){if(c=_.nextSibling&&_.nextSibling.dataset,c)var F=c.dgst;return c=F,g=Error(r(419)),c=uu(g,c,void 0),Ul(t,s,j,c)}if(F=(j&t.childLanes)!==0,qn||F){if(c=mn,c!==null){switch(j&-j){case 4:_=2;break;case 16:_=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:_=32;break;case 536870912:_=268435456;break;default:_=0}_=(_&(c.suspendedLanes|j))!==0?0:_,_!==0&&_!==g.retryLane&&(g.retryLane=_,ca(t,_),Ns(c,t,_,-1))}return Lu(),c=uu(Error(r(421))),Ul(t,s,j,c)}return _.data==="$?"?(s.flags|=128,s.child=t.child,s=u_.bind(null,t),_._reactRetry=s,null):(t=g.treeContext,es=gs(_.nextSibling),un=s,Dt=!0,ws=null,t!==null&&(Lt[gt++]=St,Lt[gt++]=Ot,Lt[gt++]=qe,St=t.id,Ot=t.overflow,qe=s),s=_u(s,c.children),s.flags|=4096,s)}function Wm(t,s,o){t.lanes|=s;var c=t.alternate;c!==null&&(c.lanes|=s),Gc(t.return,s,o)}function gu(t,s,o,c,_){var g=t.memoizedState;g===null?t.memoizedState={isBackwards:s,rendering:null,renderingStartTime:0,last:c,tail:o,tailMode:_}:(g.isBackwards=s,g.rendering=null,g.renderingStartTime=0,g.last=c,g.tail=o,g.tailMode=_)}function Hm(t,s,o){var c=s.pendingProps,_=c.revealOrder,g=c.tail;if(Ln(t,s,c.children,o),c=Ft.current,(c&2)!==0)c=c&1|2,s.flags|=128;else{if(t!==null&&(t.flags&128)!==0)e:for(t=s.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&Wm(t,o,s);else if(t.tag===19)Wm(t,o,s);else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===s)break e;for(;t.sibling===null;){if(t.return===null||t.return===s)break e;t=t.return}t.sibling.return=t.return,t=t.sibling}c&=1}if(Tt(Ft,c),(s.mode&1)===0)s.memoizedState=null;else switch(_){case"forwards":for(o=s.child,_=null;o!==null;)t=o.alternate,t!==null&&Pl(t)===null&&(_=o),o=o.sibling;o=_,o===null?(_=s.child,s.child=null):(_=o.sibling,o.sibling=null),gu(s,!1,_,o,g);break;case"backwards":for(o=null,_=s.child,s.child=null;_!==null;){if(t=_.alternate,t!==null&&Pl(t)===null){s.child=_;break}t=_.sibling,_.sibling=o,o=_,_=t}gu(s,!0,o,null,g);break;case"together":gu(s,!1,null,null,void 0);break;default:s.memoizedState=null}return s.child}function Bl(t,s){(s.mode&1)===0&&t!==null&&(t.alternate=null,s.alternate=null,s.flags|=2)}function da(t,s,o){if(t!==null&&(s.dependencies=t.dependencies),Tr|=s.lanes,(o&s.childLanes)===0)return null;if(t!==null&&s.child!==t.child)throw Error(r(153));if(s.child!==null){for(t=s.child,o=Va(t,t.pendingProps),s.child=o,o.return=s;t.sibling!==null;)t=t.sibling,o=o.sibling=Va(t,t.pendingProps),o.return=s;o.sibling=null}return s.child}function Xp(t,s,o){switch(s.tag){case 3:qm(s),hi();break;case 5:rm(s);break;case 1:f(s.type)&&R(s);break;case 4:Qc(s,s.stateNode.containerInfo);break;case 10:var c=s.type._context,_=s.memoizedProps.value;Tt(Al,c._currentValue),c._currentValue=_;break;case 13:if(c=s.memoizedState,c!==null)return c.dehydrated!==null?(Tt(Ft,Ft.current&1),s.flags|=128,null):(o&s.child.childLanes)!==0?Bm(t,s,o):(Tt(Ft,Ft.current&1),t=da(t,s,o),t!==null?t.sibling:null);Tt(Ft,Ft.current&1);break;case 19:if(c=(o&s.childLanes)!==0,(t.flags&128)!==0){if(c)return Hm(t,s,o);s.flags|=128}if(_=s.memoizedState,_!==null&&(_.rendering=null,_.tail=null,_.lastEffect=null),Tt(Ft,Ft.current),c)break;return null;case 22:case 23:return s.lanes=0,Dm(t,s,o)}return da(t,s,o)}var Vm,yu,Gm,Km;Vm=function(t,s){for(var o=s.child;o!==null;){if(o.tag===5||o.tag===6)t.appendChild(o.stateNode);else if(o.tag!==4&&o.child!==null){o.child.return=o,o=o.child;continue}if(o===s)break;for(;o.sibling===null;){if(o.return===null||o.return===s)return;o=o.return}o.sibling.return=o.return,o=o.sibling}},yu=function(){},Gm=function(t,s,o,c){var _=t.memoizedProps;if(_!==c){t=s.stateNode,$r(Fs.current);var g=null;switch(o){case"input":_=Xe(t,_),c=Xe(t,c),g=[];break;case"select":_=ne({},_,{value:void 0}),c=ne({},c,{value:void 0}),g=[];break;case"textarea":_=oe(t,_),c=oe(t,c),g=[];break;default:typeof _.onClick!="function"&&typeof c.onClick=="function"&&(t.onclick=An)}mt(o,c);var j;o=null;for(_e in _)if(!c.hasOwnProperty(_e)&&_.hasOwnProperty(_e)&&_[_e]!=null)if(_e==="style"){var F=_[_e];for(j in F)F.hasOwnProperty(j)&&(o||(o={}),o[j]="")}else _e!=="dangerouslySetInnerHTML"&&_e!=="children"&&_e!=="suppressContentEditableWarning"&&_e!=="suppressHydrationWarning"&&_e!=="autoFocus"&&(l.hasOwnProperty(_e)?g||(g=[]):(g=g||[]).push(_e,null));for(_e in c){var J=c[_e];if(F=_!=null?_[_e]:void 0,c.hasOwnProperty(_e)&&J!==F&&(J!=null||F!=null))if(_e==="style")if(F){for(j in F)!F.hasOwnProperty(j)||J&&J.hasOwnProperty(j)||(o||(o={}),o[j]="");for(j in J)J.hasOwnProperty(j)&&F[j]!==J[j]&&(o||(o={}),o[j]=J[j])}else o||(g||(g=[]),g.push(_e,o)),o=J;else _e==="dangerouslySetInnerHTML"?(J=J?J.__html:void 0,F=F?F.__html:void 0,J!=null&&F!==J&&(g=g||[]).push(_e,J)):_e==="children"?typeof J!="string"&&typeof J!="number"||(g=g||[]).push(_e,""+J):_e!=="suppressContentEditableWarning"&&_e!=="suppressHydrationWarning"&&(l.hasOwnProperty(_e)?(J!=null&&_e==="onScroll"&&Ct("scroll",t),g||F===J||(g=[])):(g=g||[]).push(_e,J))}o&&(g=g||[]).push("style",o);var _e=g;(s.updateQueue=_e)&&(s.flags|=4)}},Km=function(t,s,o,c){o!==c&&(s.flags|=4)};function So(t,s){if(!Dt)switch(t.tailMode){case"hidden":s=t.tail;for(var o=null;s!==null;)s.alternate!==null&&(o=s),s=s.sibling;o===null?t.tail=null:o.sibling=null;break;case"collapsed":o=t.tail;for(var c=null;o!==null;)o.alternate!==null&&(c=o),o=o.sibling;c===null?s||t.tail===null?t.tail=null:t.tail.sibling=null:c.sibling=null}}function Sn(t){var s=t.alternate!==null&&t.alternate.child===t.child,o=0,c=0;if(s)for(var _=t.child;_!==null;)o|=_.lanes|_.childLanes,c|=_.subtreeFlags&14680064,c|=_.flags&14680064,_.return=t,_=_.sibling;else for(_=t.child;_!==null;)o|=_.lanes|_.childLanes,c|=_.subtreeFlags,c|=_.flags,_.return=t,_=_.sibling;return t.subtreeFlags|=c,t.childLanes=o,s}function Zp(t,s,o){var c=s.pendingProps;switch(Qt(s),s.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Sn(s),null;case 1:return f(s.type)&&x(),Sn(s),null;case 3:return c=s.stateNode,yi(),At(gn),At(an),Zc(),c.pendingContext&&(c.context=c.pendingContext,c.pendingContext=null),(t===null||t.child===null)&&(El(s)?s.flags|=4:t===null||t.memoizedState.isDehydrated&&(s.flags&256)===0||(s.flags|=1024,ws!==null&&(Eu(ws),ws=null))),yu(t,s),Sn(s),null;case 5:Yc(s);var _=$r(xo.current);if(o=s.type,t!==null&&s.stateNode!=null)Gm(t,s,o,c,_),t.ref!==s.ref&&(s.flags|=512,s.flags|=2097152);else{if(!c){if(s.stateNode===null)throw Error(r(166));return Sn(s),null}if(t=$r(Fs.current),El(s)){c=s.stateNode,o=s.type;var g=s.memoizedProps;switch(c[Zn]=s,c[Sr]=g,t=(s.mode&1)!==0,o){case"dialog":Ct("cancel",c),Ct("close",c);break;case"iframe":case"object":case"embed":Ct("load",c);break;case"video":case"audio":for(_=0;_<On.length;_++)Ct(On[_],c);break;case"source":Ct("error",c);break;case"img":case"image":case"link":Ct("error",c),Ct("load",c);break;case"details":Ct("toggle",c);break;case"input":dt(c,g),Ct("invalid",c);break;case"select":c._wrapperState={wasMultiple:!!g.multiple},Ct("invalid",c);break;case"textarea":je(c,g),Ct("invalid",c)}mt(o,g),_=null;for(var j in g)if(g.hasOwnProperty(j)){var F=g[j];j==="children"?typeof F=="string"?c.textContent!==F&&(g.suppressHydrationWarning!==!0&&Pa(c.textContent,F,t),_=["children",F]):typeof F=="number"&&c.textContent!==""+F&&(g.suppressHydrationWarning!==!0&&Pa(c.textContent,F,t),_=["children",""+F]):l.hasOwnProperty(j)&&F!=null&&j==="onScroll"&&Ct("scroll",c)}switch(o){case"input":lt(c),X(c,g,!0);break;case"textarea":lt(c),se(c);break;case"select":case"option":break;default:typeof g.onClick=="function"&&(c.onclick=An)}c=_,s.updateQueue=c,c!==null&&(s.flags|=4)}else{j=_.nodeType===9?_:_.ownerDocument,t==="http://www.w3.org/1999/xhtml"&&(t=xe(o)),t==="http://www.w3.org/1999/xhtml"?o==="script"?(t=j.createElement("div"),t.innerHTML="<script><\/script>",t=t.removeChild(t.firstChild)):typeof c.is=="string"?t=j.createElement(o,{is:c.is}):(t=j.createElement(o),o==="select"&&(j=t,c.multiple?j.multiple=!0:c.size&&(j.size=c.size))):t=j.createElementNS(t,o),t[Zn]=s,t[Sr]=c,Vm(t,s,!1,!1),s.stateNode=t;e:{switch(j=ft(o,c),o){case"dialog":Ct("cancel",t),Ct("close",t),_=c;break;case"iframe":case"object":case"embed":Ct("load",t),_=c;break;case"video":case"audio":for(_=0;_<On.length;_++)Ct(On[_],t);_=c;break;case"source":Ct("error",t),_=c;break;case"img":case"image":case"link":Ct("error",t),Ct("load",t),_=c;break;case"details":Ct("toggle",t),_=c;break;case"input":dt(t,c),_=Xe(t,c),Ct("invalid",t);break;case"option":_=c;break;case"select":t._wrapperState={wasMultiple:!!c.multiple},_=ne({},c,{value:void 0}),Ct("invalid",t);break;case"textarea":je(t,c),_=oe(t,c),Ct("invalid",t);break;default:_=c}mt(o,_),F=_;for(g in F)if(F.hasOwnProperty(g)){var J=F[g];g==="style"?et(t,J):g==="dangerouslySetInnerHTML"?(J=J?J.__html:void 0,J!=null&&Le(t,J)):g==="children"?typeof J=="string"?(o!=="textarea"||J!=="")&&re(t,J):typeof J=="number"&&re(t,""+J):g!=="suppressContentEditableWarning"&&g!=="suppressHydrationWarning"&&g!=="autoFocus"&&(l.hasOwnProperty(g)?J!=null&&g==="onScroll"&&Ct("scroll",t):J!=null&&O(t,g,J,j))}switch(o){case"input":lt(t),X(t,c,!1);break;case"textarea":lt(t),se(t);break;case"option":c.value!=null&&t.setAttribute("value",""+Ae(c.value));break;case"select":t.multiple=!!c.multiple,g=c.value,g!=null?B(t,!!c.multiple,g,!1):c.defaultValue!=null&&B(t,!!c.multiple,c.defaultValue,!0);break;default:typeof _.onClick=="function"&&(t.onclick=An)}switch(o){case"button":case"input":case"select":case"textarea":c=!!c.autoFocus;break e;case"img":c=!0;break e;default:c=!1}}c&&(s.flags|=4)}s.ref!==null&&(s.flags|=512,s.flags|=2097152)}return Sn(s),null;case 6:if(t&&s.stateNode!=null)Km(t,s,t.memoizedProps,c);else{if(typeof c!="string"&&s.stateNode===null)throw Error(r(166));if(o=$r(xo.current),$r(Fs.current),El(s)){if(c=s.stateNode,o=s.memoizedProps,c[Zn]=s,(g=c.nodeValue!==o)&&(t=un,t!==null))switch(t.tag){case 3:Pa(c.nodeValue,o,(t.mode&1)!==0);break;case 5:t.memoizedProps.suppressHydrationWarning!==!0&&Pa(c.nodeValue,o,(t.mode&1)!==0)}g&&(s.flags|=4)}else c=(o.nodeType===9?o:o.ownerDocument).createTextNode(c),c[Zn]=s,s.stateNode=c}return Sn(s),null;case 13:if(At(Ft),c=s.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(Dt&&es!==null&&(s.mode&1)!==0&&(s.flags&128)===0)Yd(),hi(),s.flags|=98560,g=!1;else if(g=El(s),c!==null&&c.dehydrated!==null){if(t===null){if(!g)throw Error(r(318));if(g=s.memoizedState,g=g!==null?g.dehydrated:null,!g)throw Error(r(317));g[Zn]=s}else hi(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;Sn(s),g=!1}else ws!==null&&(Eu(ws),ws=null),g=!0;if(!g)return s.flags&65536?s:null}return(s.flags&128)!==0?(s.lanes=o,s):(c=c!==null,c!==(t!==null&&t.memoizedState!==null)&&c&&(s.child.flags|=8192,(s.mode&1)!==0&&(t===null||(Ft.current&1)!==0?on===0&&(on=3):Lu())),s.updateQueue!==null&&(s.flags|=4),Sn(s),null);case 4:return yi(),yu(t,s),t===null&&Ra(s.stateNode.containerInfo),Sn(s),null;case 10:return Vc(s.type._context),Sn(s),null;case 17:return f(s.type)&&x(),Sn(s),null;case 19:if(At(Ft),g=s.memoizedState,g===null)return Sn(s),null;if(c=(s.flags&128)!==0,j=g.rendering,j===null)if(c)So(g,!1);else{if(on!==0||t!==null&&(t.flags&128)!==0)for(t=s.child;t!==null;){if(j=Pl(t),j!==null){for(s.flags|=128,So(g,!1),c=j.updateQueue,c!==null&&(s.updateQueue=c,s.flags|=4),s.subtreeFlags=0,c=o,o=s.child;o!==null;)g=o,t=c,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}),o=o.sibling;return Tt(Ft,Ft.current&1|2),s.child}t=t.sibling}g.tail!==null&&It()>wi&&(s.flags|=128,c=!0,So(g,!1),s.lanes=4194304)}else{if(!c)if(t=Pl(j),t!==null){if(s.flags|=128,c=!0,o=t.updateQueue,o!==null&&(s.updateQueue=o,s.flags|=4),So(g,!0),g.tail===null&&g.tailMode==="hidden"&&!j.alternate&&!Dt)return Sn(s),null}else 2*It()-g.renderingStartTime>wi&&o!==1073741824&&(s.flags|=128,c=!0,So(g,!1),s.lanes=4194304);g.isBackwards?(j.sibling=s.child,s.child=j):(o=g.last,o!==null?o.sibling=j:s.child=j,g.last=j)}return g.tail!==null?(s=g.tail,g.rendering=s,g.tail=s.sibling,g.renderingStartTime=It(),s.sibling=null,o=Ft.current,Tt(Ft,c?o&1|2:o&1),s):(Sn(s),null);case 22:case 23:return Au(),c=s.memoizedState!==null,t!==null&&t.memoizedState!==null!==c&&(s.flags|=8192),c&&(s.mode&1)!==0?(ts&1073741824)!==0&&(Sn(s),s.subtreeFlags&6&&(s.flags|=8192)):Sn(s),null;case 24:return null;case 25:return null}throw Error(r(156,s.tag))}function e_(t,s){switch(Qt(s),s.tag){case 1:return f(s.type)&&x(),t=s.flags,t&65536?(s.flags=t&-65537|128,s):null;case 3:return yi(),At(gn),At(an),Zc(),t=s.flags,(t&65536)!==0&&(t&128)===0?(s.flags=t&-65537|128,s):null;case 5:return Yc(s),null;case 13:if(At(Ft),t=s.memoizedState,t!==null&&t.dehydrated!==null){if(s.alternate===null)throw Error(r(340));hi()}return t=s.flags,t&65536?(s.flags=t&-65537|128,s):null;case 19:return At(Ft),null;case 4:return yi(),null;case 10:return Vc(s.type._context),null;case 22:case 23:return Au(),null;case 24:return null;default:return null}}var Wl=!1,Nn=!1,t_=typeof WeakSet=="function"?WeakSet:Set,Ge=null;function xi(t,s){var o=t.ref;if(o!==null)if(typeof o=="function")try{o(null)}catch(c){Bt(t,s,c)}else o.current=null}function vu(t,s,o){try{o()}catch(c){Bt(t,s,c)}}var Jm=!1;function n_(t,s){if(za=lr,t=wl(),oi(t)){if("selectionStart"in t)var o={start:t.selectionStart,end:t.selectionEnd};else e:{o=(o=t.ownerDocument)&&o.defaultView||window;var c=o.getSelection&&o.getSelection();if(c&&c.rangeCount!==0){o=c.anchorNode;var _=c.anchorOffset,g=c.focusNode;c=c.focusOffset;try{o.nodeType,g.nodeType}catch{o=null;break e}var j=0,F=-1,J=-1,_e=0,Te=0,Re=t,$e=null;t:for(;;){for(var Be;Re!==o||_!==0&&Re.nodeType!==3||(F=j+_),Re!==g||c!==0&&Re.nodeType!==3||(J=j+c),Re.nodeType===3&&(j+=Re.nodeValue.length),(Be=Re.firstChild)!==null;)$e=Re,Re=Be;for(;;){if(Re===t)break t;if($e===o&&++_e===_&&(F=j),$e===g&&++Te===c&&(J=j),(Be=Re.nextSibling)!==null)break;Re=$e,$e=Re.parentNode}Re=Be}o=F===-1||J===-1?null:{start:F,end:J}}else o=null}o=o||{start:0,end:0}}else o=null;for(kr={focusedElem:t,selectionRange:o},lr=!1,Ge=s;Ge!==null;)if(s=Ge,t=s.child,(s.subtreeFlags&1028)!==0&&t!==null)t.return=s,Ge=t;else for(;Ge!==null;){s=Ge;try{var Ke=s.alternate;if((s.flags&1024)!==0)switch(s.tag){case 0:case 11:case 15:break;case 1:if(Ke!==null){var Qe=Ke.memoizedProps,Yt=Ke.memoizedState,ue=s.stateNode,ee=ue.getSnapshotBeforeUpdate(s.elementType===s.type?Qe:js(s.type,Qe),Yt);ue.__reactInternalSnapshotBeforeUpdate=ee}break;case 3:var me=s.stateNode.containerInfo;me.nodeType===1?me.textContent="":me.nodeType===9&&me.documentElement&&me.removeChild(me.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(r(163))}}catch(Ie){Bt(s,s.return,Ie)}if(t=s.sibling,t!==null){t.return=s.return,Ge=t;break}Ge=s.return}return Ke=Jm,Jm=!1,Ke}function No(t,s,o){var c=s.updateQueue;if(c=c!==null?c.lastEffect:null,c!==null){var _=c=c.next;do{if((_.tag&t)===t){var g=_.destroy;_.destroy=void 0,g!==void 0&&vu(s,o,g)}_=_.next}while(_!==c)}}function Hl(t,s){if(s=s.updateQueue,s=s!==null?s.lastEffect:null,s!==null){var o=s=s.next;do{if((o.tag&t)===t){var c=o.create;o.destroy=c()}o=o.next}while(o!==s)}}function xu(t){var s=t.ref;if(s!==null){var o=t.stateNode;switch(t.tag){case 5:t=o;break;default:t=o}typeof s=="function"?s(t):s.current=t}}function Qm(t){var s=t.alternate;s!==null&&(t.alternate=null,Qm(s)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(s=t.stateNode,s!==null&&(delete s[Zn],delete s[Sr],delete s[po],delete s[Oc],delete s[Fc])),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 Ym(t){return t.tag===5||t.tag===3||t.tag===4}function Xm(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||Ym(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 bu(t,s,o){var c=t.tag;if(c===5||c===6)t=t.stateNode,s?o.nodeType===8?o.parentNode.insertBefore(t,s):o.insertBefore(t,s):(o.nodeType===8?(s=o.parentNode,s.insertBefore(t,o)):(s=o,s.appendChild(t)),o=o._reactRootContainer,o!=null||s.onclick!==null||(s.onclick=An));else if(c!==4&&(t=t.child,t!==null))for(bu(t,s,o),t=t.sibling;t!==null;)bu(t,s,o),t=t.sibling}function wu(t,s,o){var c=t.tag;if(c===5||c===6)t=t.stateNode,s?o.insertBefore(t,s):o.appendChild(t);else if(c!==4&&(t=t.child,t!==null))for(wu(t,s,o),t=t.sibling;t!==null;)wu(t,s,o),t=t.sibling}var yn=null,ks=!1;function qa(t,s,o){for(o=o.child;o!==null;)Zm(t,s,o),o=o.sibling}function Zm(t,s,o){if(hn&&typeof hn.onCommitFiberUnmount=="function")try{hn.onCommitFiberUnmount(cs,o)}catch{}switch(o.tag){case 5:Nn||xi(o,s);case 6:var c=yn,_=ks;yn=null,qa(t,s,o),yn=c,ks=_,yn!==null&&(ks?(t=yn,o=o.stateNode,t.nodeType===8?t.parentNode.removeChild(o):t.removeChild(o)):yn.removeChild(o.stateNode));break;case 18:yn!==null&&(ks?(t=yn,o=o.stateNode,t.nodeType===8?ho(t.parentNode,o):t.nodeType===1&&ho(t,o),wa(t)):ho(yn,o.stateNode));break;case 4:c=yn,_=ks,yn=o.stateNode.containerInfo,ks=!0,qa(t,s,o),yn=c,ks=_;break;case 0:case 11:case 14:case 15:if(!Nn&&(c=o.updateQueue,c!==null&&(c=c.lastEffect,c!==null))){_=c=c.next;do{var g=_,j=g.destroy;g=g.tag,j!==void 0&&((g&2)!==0||(g&4)!==0)&&vu(o,s,j),_=_.next}while(_!==c)}qa(t,s,o);break;case 1:if(!Nn&&(xi(o,s),c=o.stateNode,typeof c.componentWillUnmount=="function"))try{c.props=o.memoizedProps,c.state=o.memoizedState,c.componentWillUnmount()}catch(F){Bt(o,s,F)}qa(t,s,o);break;case 21:qa(t,s,o);break;case 22:o.mode&1?(Nn=(c=Nn)||o.memoizedState!==null,qa(t,s,o),Nn=c):qa(t,s,o);break;default:qa(t,s,o)}}function ef(t){var s=t.updateQueue;if(s!==null){t.updateQueue=null;var o=t.stateNode;o===null&&(o=t.stateNode=new t_),s.forEach(function(c){var _=d_.bind(null,t,c);o.has(c)||(o.add(c),c.then(_,_))})}}function Ss(t,s){var o=s.deletions;if(o!==null)for(var c=0;c<o.length;c++){var _=o[c];try{var g=t,j=s,F=j;e:for(;F!==null;){switch(F.tag){case 5:yn=F.stateNode,ks=!1;break e;case 3:yn=F.stateNode.containerInfo,ks=!0;break e;case 4:yn=F.stateNode.containerInfo,ks=!0;break e}F=F.return}if(yn===null)throw Error(r(160));Zm(g,j,_),yn=null,ks=!1;var J=_.alternate;J!==null&&(J.return=null),_.return=null}catch(_e){Bt(_,s,_e)}}if(s.subtreeFlags&12854)for(s=s.child;s!==null;)tf(s,t),s=s.sibling}function tf(t,s){var o=t.alternate,c=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:if(Ss(s,t),Us(t),c&4){try{No(3,t,t.return),Hl(3,t)}catch(Qe){Bt(t,t.return,Qe)}try{No(5,t,t.return)}catch(Qe){Bt(t,t.return,Qe)}}break;case 1:Ss(s,t),Us(t),c&512&&o!==null&&xi(o,o.return);break;case 5:if(Ss(s,t),Us(t),c&512&&o!==null&&xi(o,o.return),t.flags&32){var _=t.stateNode;try{re(_,"")}catch(Qe){Bt(t,t.return,Qe)}}if(c&4&&(_=t.stateNode,_!=null)){var g=t.memoizedProps,j=o!==null?o.memoizedProps:g,F=t.type,J=t.updateQueue;if(t.updateQueue=null,J!==null)try{F==="input"&&g.type==="radio"&&g.name!=null&&Ze(_,g),ft(F,j);var _e=ft(F,g);for(j=0;j<J.length;j+=2){var Te=J[j],Re=J[j+1];Te==="style"?et(_,Re):Te==="dangerouslySetInnerHTML"?Le(_,Re):Te==="children"?re(_,Re):O(_,Te,Re,_e)}switch(F){case"input":W(_,g);break;case"textarea":Oe(_,g);break;case"select":var $e=_._wrapperState.wasMultiple;_._wrapperState.wasMultiple=!!g.multiple;var Be=g.value;Be!=null?B(_,!!g.multiple,Be,!1):$e!==!!g.multiple&&(g.defaultValue!=null?B(_,!!g.multiple,g.defaultValue,!0):B(_,!!g.multiple,g.multiple?[]:"",!1))}_[Sr]=g}catch(Qe){Bt(t,t.return,Qe)}}break;case 6:if(Ss(s,t),Us(t),c&4){if(t.stateNode===null)throw Error(r(162));_=t.stateNode,g=t.memoizedProps;try{_.nodeValue=g}catch(Qe){Bt(t,t.return,Qe)}}break;case 3:if(Ss(s,t),Us(t),c&4&&o!==null&&o.memoizedState.isDehydrated)try{wa(s.containerInfo)}catch(Qe){Bt(t,t.return,Qe)}break;case 4:Ss(s,t),Us(t);break;case 13:Ss(s,t),Us(t),_=t.child,_.flags&8192&&(g=_.memoizedState!==null,_.stateNode.isHidden=g,!g||_.alternate!==null&&_.alternate.memoizedState!==null||(Su=It())),c&4&&ef(t);break;case 22:if(Te=o!==null&&o.memoizedState!==null,t.mode&1?(Nn=(_e=Nn)||Te,Ss(s,t),Nn=_e):Ss(s,t),Us(t),c&8192){if(_e=t.memoizedState!==null,(t.stateNode.isHidden=_e)&&!Te&&(t.mode&1)!==0)for(Ge=t,Te=t.child;Te!==null;){for(Re=Ge=Te;Ge!==null;){switch($e=Ge,Be=$e.child,$e.tag){case 0:case 11:case 14:case 15:No(4,$e,$e.return);break;case 1:xi($e,$e.return);var Ke=$e.stateNode;if(typeof Ke.componentWillUnmount=="function"){c=$e,o=$e.return;try{s=c,Ke.props=s.memoizedProps,Ke.state=s.memoizedState,Ke.componentWillUnmount()}catch(Qe){Bt(c,o,Qe)}}break;case 5:xi($e,$e.return);break;case 22:if($e.memoizedState!==null){af(Re);continue}}Be!==null?(Be.return=$e,Ge=Be):af(Re)}Te=Te.sibling}e:for(Te=null,Re=t;;){if(Re.tag===5){if(Te===null){Te=Re;try{_=Re.stateNode,_e?(g=_.style,typeof g.setProperty=="function"?g.setProperty("display","none","important"):g.display="none"):(F=Re.stateNode,J=Re.memoizedProps.style,j=J!=null&&J.hasOwnProperty("display")?J.display:null,F.style.display=Ve("display",j))}catch(Qe){Bt(t,t.return,Qe)}}}else if(Re.tag===6){if(Te===null)try{Re.stateNode.nodeValue=_e?"":Re.memoizedProps}catch(Qe){Bt(t,t.return,Qe)}}else if((Re.tag!==22&&Re.tag!==23||Re.memoizedState===null||Re===t)&&Re.child!==null){Re.child.return=Re,Re=Re.child;continue}if(Re===t)break e;for(;Re.sibling===null;){if(Re.return===null||Re.return===t)break e;Te===Re&&(Te=null),Re=Re.return}Te===Re&&(Te=null),Re.sibling.return=Re.return,Re=Re.sibling}}break;case 19:Ss(s,t),Us(t),c&4&&ef(t);break;case 21:break;default:Ss(s,t),Us(t)}}function Us(t){var s=t.flags;if(s&2){try{e:{for(var o=t.return;o!==null;){if(Ym(o)){var c=o;break e}o=o.return}throw Error(r(160))}switch(c.tag){case 5:var _=c.stateNode;c.flags&32&&(re(_,""),c.flags&=-33);var g=Xm(t);wu(t,g,_);break;case 3:case 4:var j=c.stateNode.containerInfo,F=Xm(t);bu(t,F,j);break;default:throw Error(r(161))}}catch(J){Bt(t,t.return,J)}t.flags&=-3}s&4096&&(t.flags&=-4097)}function s_(t,s,o){Ge=t,nf(t)}function nf(t,s,o){for(var c=(t.mode&1)!==0;Ge!==null;){var _=Ge,g=_.child;if(_.tag===22&&c){var j=_.memoizedState!==null||Wl;if(!j){var F=_.alternate,J=F!==null&&F.memoizedState!==null||Nn;F=Wl;var _e=Nn;if(Wl=j,(Nn=J)&&!_e)for(Ge=_;Ge!==null;)j=Ge,J=j.child,j.tag===22&&j.memoizedState!==null?rf(_):J!==null?(J.return=j,Ge=J):rf(_);for(;g!==null;)Ge=g,nf(g),g=g.sibling;Ge=_,Wl=F,Nn=_e}sf(t)}else(_.subtreeFlags&8772)!==0&&g!==null?(g.return=_,Ge=g):sf(t)}}function sf(t){for(;Ge!==null;){var s=Ge;if((s.flags&8772)!==0){var o=s.alternate;try{if((s.flags&8772)!==0)switch(s.tag){case 0:case 11:case 15:Nn||Hl(5,s);break;case 1:var c=s.stateNode;if(s.flags&4&&!Nn)if(o===null)c.componentDidMount();else{var _=s.elementType===s.type?o.memoizedProps:js(s.type,o.memoizedProps);c.componentDidUpdate(_,o.memoizedState,c.__reactInternalSnapshotBeforeUpdate)}var g=s.updateQueue;g!==null&&am(s,g,c);break;case 3:var j=s.updateQueue;if(j!==null){if(o=null,s.child!==null)switch(s.child.tag){case 5:o=s.child.stateNode;break;case 1:o=s.child.stateNode}am(s,j,o)}break;case 5:var F=s.stateNode;if(o===null&&s.flags&4){o=F;var J=s.memoizedProps;switch(s.type){case"button":case"input":case"select":case"textarea":J.autoFocus&&o.focus();break;case"img":J.src&&(o.src=J.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(s.memoizedState===null){var _e=s.alternate;if(_e!==null){var Te=_e.memoizedState;if(Te!==null){var Re=Te.dehydrated;Re!==null&&wa(Re)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(r(163))}Nn||s.flags&512&&xu(s)}catch($e){Bt(s,s.return,$e)}}if(s===t){Ge=null;break}if(o=s.sibling,o!==null){o.return=s.return,Ge=o;break}Ge=s.return}}function af(t){for(;Ge!==null;){var s=Ge;if(s===t){Ge=null;break}var o=s.sibling;if(o!==null){o.return=s.return,Ge=o;break}Ge=s.return}}function rf(t){for(;Ge!==null;){var s=Ge;try{switch(s.tag){case 0:case 11:case 15:var o=s.return;try{Hl(4,s)}catch(J){Bt(s,o,J)}break;case 1:var c=s.stateNode;if(typeof c.componentDidMount=="function"){var _=s.return;try{c.componentDidMount()}catch(J){Bt(s,_,J)}}var g=s.return;try{xu(s)}catch(J){Bt(s,g,J)}break;case 5:var j=s.return;try{xu(s)}catch(J){Bt(s,j,J)}}}catch(J){Bt(s,s.return,J)}if(s===t){Ge=null;break}var F=s.sibling;if(F!==null){F.return=s.return,Ge=F;break}Ge=s.return}}var a_=Math.ceil,Vl=q.ReactCurrentDispatcher,ju=q.ReactCurrentOwner,rs=q.ReactCurrentBatchConfig,bt=0,mn=null,en=null,vn=0,ts=0,bi=xs(0),on=0,Co=null,Tr=0,Gl=0,ku=0,$o=null,Un=null,Su=0,wi=1/0,ma=null,Kl=!1,Nu=null,Ua=null,Jl=!1,Ba=null,Ql=0,Eo=0,Cu=null,Yl=-1,Xl=0;function Rn(){return(bt&6)!==0?It():Yl!==-1?Yl:Yl=It()}function Wa(t){return(t.mode&1)===0?1:(bt&2)!==0&&vn!==0?vn&-vn:qp.transition!==null?(Xl===0&&(Xl=Vt()),Xl):(t=kt,t!==0||(t=window.event,t=t===void 0?16:Oi(t.type)),t)}function Ns(t,s,o,c){if(50<Eo)throw Eo=0,Cu=null,Error(r(185));Ls(t,o,c),((bt&2)===0||t!==mn)&&(t===mn&&((bt&2)===0&&(Gl|=o),on===4&&Ha(t,vn)),Bn(t,c),o===1&&bt===0&&(s.mode&1)===0&&(wi=It()+500,we&&$t()))}function Bn(t,s){var o=t.callbackNode;Kr(t,s);var c=bn(t,t===mn?vn:0);if(c===0)o!==null&&Pi(o),t.callbackNode=null,t.callbackPriority=0;else if(s=c&-c,t.callbackPriority!==s){if(o!=null&&Pi(o),s===1)t.tag===0?We(lf.bind(null,t)):Fe(lf.bind(null,t)),fo(function(){(bt&6)===0&&$t()}),o=null;else{switch(Gt(c)){case 1:o=Wr;break;case 4:o=ar;break;case 16:o=Js;break;case 536870912:o=Hr;break;default:o=Js}o=_f(o,of.bind(null,t))}t.callbackPriority=s,t.callbackNode=o}}function of(t,s){if(Yl=-1,Xl=0,(bt&6)!==0)throw Error(r(327));var o=t.callbackNode;if(ji()&&t.callbackNode!==o)return null;var c=bn(t,t===mn?vn:0);if(c===0)return null;if((c&30)!==0||(c&t.expiredLanes)!==0||s)s=Zl(t,c);else{s=c;var _=bt;bt|=2;var g=uf();(mn!==t||vn!==s)&&(ma=null,wi=It()+500,Lr(t,s));do try{o_();break}catch(F){cf(t,F)}while(!0);Hc(),Vl.current=g,bt=_,en!==null?s=0:(mn=null,vn=0,s=on)}if(s!==0){if(s===2&&(_=As(t),_!==0&&(c=_,s=$u(t,_))),s===1)throw o=Co,Lr(t,0),Ha(t,c),Bn(t,It()),o;if(s===6)Ha(t,c);else{if(_=t.current.alternate,(c&30)===0&&!r_(_)&&(s=Zl(t,c),s===2&&(g=As(t),g!==0&&(c=g,s=$u(t,g))),s===1))throw o=Co,Lr(t,0),Ha(t,c),Bn(t,It()),o;switch(t.finishedWork=_,t.finishedLanes=c,s){case 0:case 1:throw Error(r(345));case 2:Rr(t,Un,ma);break;case 3:if(Ha(t,c),(c&130023424)===c&&(s=Su+500-It(),10<s)){if(bn(t,0)!==0)break;if(_=t.suspendedLanes,(_&c)!==c){Rn(),t.pingedLanes|=t.suspendedLanes&_;break}t.timeoutHandle=Fn(Rr.bind(null,t,Un,ma),s);break}Rr(t,Un,ma);break;case 4:if(Ha(t,c),(c&4194240)===c)break;for(s=t.eventTimes,_=-1;0<c;){var j=31-pn(c);g=1<<j,j=s[j],j>_&&(_=j),c&=~g}if(c=_,c=It()-c,c=(120>c?120:480>c?480:1080>c?1080:1920>c?1920:3e3>c?3e3:4320>c?4320:1960*a_(c/1960))-c,10<c){t.timeoutHandle=Fn(Rr.bind(null,t,Un,ma),c);break}Rr(t,Un,ma);break;case 5:Rr(t,Un,ma);break;default:throw Error(r(329))}}}return Bn(t,It()),t.callbackNode===o?of.bind(null,t):null}function $u(t,s){var o=$o;return t.current.memoizedState.isDehydrated&&(Lr(t,s).flags|=256),t=Zl(t,s),t!==2&&(s=Un,Un=o,s!==null&&Eu(s)),t}function Eu(t){Un===null?Un=t:Un.push.apply(Un,t)}function r_(t){for(var s=t;;){if(s.flags&16384){var o=s.updateQueue;if(o!==null&&(o=o.stores,o!==null))for(var c=0;c<o.length;c++){var _=o[c],g=_.getSnapshot;_=_.value;try{if(!Yn(g(),_))return!1}catch{return!1}}}if(o=s.child,s.subtreeFlags&16384&&o!==null)o.return=s,s=o;else{if(s===t)break;for(;s.sibling===null;){if(s.return===null||s.return===t)return!0;s=s.return}s.sibling.return=s.return,s=s.sibling}}return!0}function Ha(t,s){for(s&=~ku,s&=~Gl,t.suspendedLanes|=s,t.pingedLanes&=~s,t=t.expirationTimes;0<s;){var o=31-pn(s),c=1<<o;t[o]=-1,s&=~c}}function lf(t){if((bt&6)!==0)throw Error(r(327));ji();var s=bn(t,0);if((s&1)===0)return Bn(t,It()),null;var o=Zl(t,s);if(t.tag!==0&&o===2){var c=As(t);c!==0&&(s=c,o=$u(t,c))}if(o===1)throw o=Co,Lr(t,0),Ha(t,s),Bn(t,It()),o;if(o===6)throw Error(r(345));return t.finishedWork=t.current.alternate,t.finishedLanes=s,Rr(t,Un,ma),Bn(t,It()),null}function Tu(t,s){var o=bt;bt|=1;try{return t(s)}finally{bt=o,bt===0&&(wi=It()+500,we&&$t())}}function Ar(t){Ba!==null&&Ba.tag===0&&(bt&6)===0&&ji();var s=bt;bt|=1;var o=rs.transition,c=kt;try{if(rs.transition=null,kt=1,t)return t()}finally{kt=c,rs.transition=o,bt=s,(bt&6)===0&&$t()}}function Au(){ts=bi.current,At(bi)}function Lr(t,s){t.finishedWork=null,t.finishedLanes=0;var o=t.timeoutHandle;if(o!==-1&&(t.timeoutHandle=-1,mi(o)),en!==null)for(o=en.return;o!==null;){var c=o;switch(Qt(c),c.tag){case 1:c=c.type.childContextTypes,c!=null&&x();break;case 3:yi(),At(gn),At(an),Zc();break;case 5:Yc(c);break;case 4:yi();break;case 13:At(Ft);break;case 19:At(Ft);break;case 10:Vc(c.type._context);break;case 22:case 23:Au()}o=o.return}if(mn=t,en=t=Va(t.current,null),vn=ts=s,on=0,Co=null,ku=Gl=Tr=0,Un=$o=null,Cr!==null){for(s=0;s<Cr.length;s++)if(o=Cr[s],c=o.interleaved,c!==null){o.interleaved=null;var _=c.next,g=o.pending;if(g!==null){var j=g.next;g.next=_,c.next=j}o.pending=c}Cr=null}return t}function cf(t,s){do{var o=en;try{if(Hc(),zl.current=Fl,Il){for(var c=qt.memoizedState;c!==null;){var _=c.queue;_!==null&&(_.pending=null),c=c.next}Il=!1}if(Er=0,dn=rn=qt=null,bo=!1,wo=0,ju.current=null,o===null||o.return===null){on=1,Co=s,en=null;break}e:{var g=t,j=o.return,F=o,J=s;if(s=vn,F.flags|=32768,J!==null&&typeof J=="object"&&typeof J.then=="function"){var _e=J,Te=F,Re=Te.tag;if((Te.mode&1)===0&&(Re===0||Re===11||Re===15)){var $e=Te.alternate;$e?(Te.updateQueue=$e.updateQueue,Te.memoizedState=$e.memoizedState,Te.lanes=$e.lanes):(Te.updateQueue=null,Te.memoizedState=null)}var Be=Rm(j);if(Be!==null){Be.flags&=-257,Mm(Be,j,F,g,s),Be.mode&1&&Lm(g,_e,s),s=Be,J=_e;var Ke=s.updateQueue;if(Ke===null){var Qe=new Set;Qe.add(J),s.updateQueue=Qe}else Ke.add(J);break e}else{if((s&1)===0){Lm(g,_e,s),Lu();break e}J=Error(r(426))}}else if(Dt&&F.mode&1){var Yt=Rm(j);if(Yt!==null){(Yt.flags&65536)===0&&(Yt.flags|=256),Mm(Yt,j,F,g,s),Bc(vi(J,F));break e}}g=J=vi(J,F),on!==4&&(on=2),$o===null?$o=[g]:$o.push(g),g=j;do{switch(g.tag){case 3:g.flags|=65536,s&=-s,g.lanes|=s;var ue=Tm(g,J,s);sm(g,ue);break e;case 1:F=J;var ee=g.type,me=g.stateNode;if((g.flags&128)===0&&(typeof ee.getDerivedStateFromError=="function"||me!==null&&typeof me.componentDidCatch=="function"&&(Ua===null||!Ua.has(me)))){g.flags|=65536,s&=-s,g.lanes|=s;var Ie=Am(g,F,s);sm(g,Ie);break e}}g=g.return}while(g!==null)}mf(o)}catch(Ye){s=Ye,en===o&&o!==null&&(en=o=o.return);continue}break}while(!0)}function uf(){var t=Vl.current;return Vl.current=Fl,t===null?Fl:t}function Lu(){(on===0||on===3||on===2)&&(on=4),mn===null||(Tr&268435455)===0&&(Gl&268435455)===0||Ha(mn,vn)}function Zl(t,s){var o=bt;bt|=2;var c=uf();(mn!==t||vn!==s)&&(ma=null,Lr(t,s));do try{i_();break}catch(_){cf(t,_)}while(!0);if(Hc(),bt=o,Vl.current=c,en!==null)throw Error(r(261));return mn=null,vn=0,on}function i_(){for(;en!==null;)df(en)}function o_(){for(;en!==null&&!al();)df(en)}function df(t){var s=pf(t.alternate,t,ts);t.memoizedProps=t.pendingProps,s===null?mf(t):en=s,ju.current=null}function mf(t){var s=t;do{var o=s.alternate;if(t=s.return,(s.flags&32768)===0){if(o=Zp(o,s,ts),o!==null){en=o;return}}else{if(o=e_(o,s),o!==null){o.flags&=32767,en=o;return}if(t!==null)t.flags|=32768,t.subtreeFlags=0,t.deletions=null;else{on=6,en=null;return}}if(s=s.sibling,s!==null){en=s;return}en=s=t}while(s!==null);on===0&&(on=5)}function Rr(t,s,o){var c=kt,_=rs.transition;try{rs.transition=null,kt=1,l_(t,s,o,c)}finally{rs.transition=_,kt=c}return null}function l_(t,s,o,c){do ji();while(Ba!==null);if((bt&6)!==0)throw Error(r(327));o=t.finishedWork;var _=t.finishedLanes;if(o===null)return null;if(t.finishedWork=null,t.finishedLanes=0,o===t.current)throw Error(r(177));t.callbackNode=null,t.callbackPriority=0;var g=o.lanes|o.childLanes;if(va(t,g),t===mn&&(en=mn=null,vn=0),(o.subtreeFlags&2064)===0&&(o.flags&2064)===0||Jl||(Jl=!0,_f(Js,function(){return ji(),null})),g=(o.flags&15990)!==0,(o.subtreeFlags&15990)!==0||g){g=rs.transition,rs.transition=null;var j=kt;kt=1;var F=bt;bt|=4,ju.current=null,n_(t,o),tf(o,t),li(kr),lr=!!za,kr=za=null,t.current=o,s_(o),zi(),bt=F,kt=j,rs.transition=g}else t.current=o;if(Jl&&(Jl=!1,Ba=t,Ql=_),g=t.pendingLanes,g===0&&(Ua=null),Vr(o.stateNode),Bn(t,It()),s!==null)for(c=t.onRecoverableError,o=0;o<s.length;o++)_=s[o],c(_.value,{componentStack:_.stack,digest:_.digest});if(Kl)throw Kl=!1,t=Nu,Nu=null,t;return(Ql&1)!==0&&t.tag!==0&&ji(),g=t.pendingLanes,(g&1)!==0?t===Cu?Eo++:(Eo=0,Cu=t):Eo=0,$t(),null}function ji(){if(Ba!==null){var t=Gt(Ql),s=rs.transition,o=kt;try{if(rs.transition=null,kt=16>t?16:t,Ba===null)var c=!1;else{if(t=Ba,Ba=null,Ql=0,(bt&6)!==0)throw Error(r(331));var _=bt;for(bt|=4,Ge=t.current;Ge!==null;){var g=Ge,j=g.child;if((Ge.flags&16)!==0){var F=g.deletions;if(F!==null){for(var J=0;J<F.length;J++){var _e=F[J];for(Ge=_e;Ge!==null;){var Te=Ge;switch(Te.tag){case 0:case 11:case 15:No(8,Te,g)}var Re=Te.child;if(Re!==null)Re.return=Te,Ge=Re;else for(;Ge!==null;){Te=Ge;var $e=Te.sibling,Be=Te.return;if(Qm(Te),Te===_e){Ge=null;break}if($e!==null){$e.return=Be,Ge=$e;break}Ge=Be}}}var Ke=g.alternate;if(Ke!==null){var Qe=Ke.child;if(Qe!==null){Ke.child=null;do{var Yt=Qe.sibling;Qe.sibling=null,Qe=Yt}while(Qe!==null)}}Ge=g}}if((g.subtreeFlags&2064)!==0&&j!==null)j.return=g,Ge=j;else e:for(;Ge!==null;){if(g=Ge,(g.flags&2048)!==0)switch(g.tag){case 0:case 11:case 15:No(9,g,g.return)}var ue=g.sibling;if(ue!==null){ue.return=g.return,Ge=ue;break e}Ge=g.return}}var ee=t.current;for(Ge=ee;Ge!==null;){j=Ge;var me=j.child;if((j.subtreeFlags&2064)!==0&&me!==null)me.return=j,Ge=me;else e:for(j=ee;Ge!==null;){if(F=Ge,(F.flags&2048)!==0)try{switch(F.tag){case 0:case 11:case 15:Hl(9,F)}}catch(Ye){Bt(F,F.return,Ye)}if(F===j){Ge=null;break e}var Ie=F.sibling;if(Ie!==null){Ie.return=F.return,Ge=Ie;break e}Ge=F.return}}if(bt=_,$t(),hn&&typeof hn.onPostCommitFiberRoot=="function")try{hn.onPostCommitFiberRoot(cs,t)}catch{}c=!0}return c}finally{kt=o,rs.transition=s}}return!1}function ff(t,s,o){s=vi(o,s),s=Tm(t,s,1),t=Fa(t,s,1),s=Rn(),t!==null&&(Ls(t,1,s),Bn(t,s))}function Bt(t,s,o){if(t.tag===3)ff(t,t,o);else for(;s!==null;){if(s.tag===3){ff(s,t,o);break}else if(s.tag===1){var c=s.stateNode;if(typeof s.type.getDerivedStateFromError=="function"||typeof c.componentDidCatch=="function"&&(Ua===null||!Ua.has(c))){t=vi(o,t),t=Am(s,t,1),s=Fa(s,t,1),t=Rn(),s!==null&&(Ls(s,1,t),Bn(s,t));break}}s=s.return}}function c_(t,s,o){var c=t.pingCache;c!==null&&c.delete(s),s=Rn(),t.pingedLanes|=t.suspendedLanes&o,mn===t&&(vn&o)===o&&(on===4||on===3&&(vn&130023424)===vn&&500>It()-Su?Lr(t,0):ku|=o),Bn(t,s)}function hf(t,s){s===0&&((t.mode&1)===0?s=1:(s=Gr,Gr<<=1,(Gr&130023424)===0&&(Gr=4194304)));var o=Rn();t=ca(t,s),t!==null&&(Ls(t,s,o),Bn(t,o))}function u_(t){var s=t.memoizedState,o=0;s!==null&&(o=s.retryLane),hf(t,o)}function d_(t,s){var o=0;switch(t.tag){case 13:var c=t.stateNode,_=t.memoizedState;_!==null&&(o=_.retryLane);break;case 19:c=t.stateNode;break;default:throw Error(r(314))}c!==null&&c.delete(s),hf(t,o)}var pf;pf=function(t,s,o){if(t!==null)if(t.memoizedProps!==s.pendingProps||gn.current)qn=!0;else{if((t.lanes&o)===0&&(s.flags&128)===0)return qn=!1,Xp(t,s,o);qn=(t.flags&131072)!==0}else qn=!1,Dt&&(s.flags&1048576)!==0&&Zt(s,it,s.index);switch(s.lanes=0,s.tag){case 2:var c=s.type;Bl(t,s),t=s.pendingProps;var _=la(s,an.current);gi(s,o),_=nu(null,s,c,t,_,o);var g=su();return s.flags|=1,typeof _=="object"&&_!==null&&typeof _.render=="function"&&_.$$typeof===void 0?(s.tag=1,s.memoizedState=null,s.updateQueue=null,f(c)?(g=!0,R(s)):g=!1,s.memoizedState=_.state!==null&&_.state!==void 0?_.state:null,Jc(s),_.updater=ql,s.stateNode=_,_._reactInternals=s,cu(s,c,t,o),s=fu(null,s,c,!0,g,o)):(s.tag=0,Dt&&g&&Rt(s),Ln(null,s,_,o),s=s.child),s;case 16:c=s.elementType;e:{switch(Bl(t,s),t=s.pendingProps,_=c._init,c=_(c._payload),s.type=c,_=s.tag=f_(c),t=js(c,t),_){case 0:s=mu(null,s,c,t,o);break e;case 1:s=Fm(null,s,c,t,o);break e;case 11:s=Pm(null,s,c,t,o);break e;case 14:s=zm(null,s,c,js(c.type,t),o);break e}throw Error(r(306,c,""))}return s;case 0:return c=s.type,_=s.pendingProps,_=s.elementType===c?_:js(c,_),mu(t,s,c,_,o);case 1:return c=s.type,_=s.pendingProps,_=s.elementType===c?_:js(c,_),Fm(t,s,c,_,o);case 3:e:{if(qm(s),t===null)throw Error(r(387));c=s.pendingProps,g=s.memoizedState,_=g.element,nm(t,s),Ml(s,c,null,o);var j=s.memoizedState;if(c=j.element,g.isDehydrated)if(g={element:c,isDehydrated:!1,cache:j.cache,pendingSuspenseBoundaries:j.pendingSuspenseBoundaries,transitions:j.transitions},s.updateQueue.baseState=g,s.memoizedState=g,s.flags&256){_=vi(Error(r(423)),s),s=Um(t,s,c,o,_);break e}else if(c!==_){_=vi(Error(r(424)),s),s=Um(t,s,c,o,_);break e}else for(es=gs(s.stateNode.containerInfo.firstChild),un=s,Dt=!0,ws=null,o=em(s,null,c,o),s.child=o;o;)o.flags=o.flags&-3|4096,o=o.sibling;else{if(hi(),c===_){s=da(t,s,o);break e}Ln(t,s,c,o)}s=s.child}return s;case 5:return rm(s),t===null&&Uc(s),c=s.type,_=s.pendingProps,g=t!==null?t.memoizedProps:null,j=_.children,Xn(c,_)?j=null:g!==null&&Xn(c,g)&&(s.flags|=32),Om(t,s),Ln(t,s,j,o),s.child;case 6:return t===null&&Uc(s),null;case 13:return Bm(t,s,o);case 4:return Qc(s,s.stateNode.containerInfo),c=s.pendingProps,t===null?s.child=pi(s,null,c,o):Ln(t,s,c,o),s.child;case 11:return c=s.type,_=s.pendingProps,_=s.elementType===c?_:js(c,_),Pm(t,s,c,_,o);case 7:return Ln(t,s,s.pendingProps,o),s.child;case 8:return Ln(t,s,s.pendingProps.children,o),s.child;case 12:return Ln(t,s,s.pendingProps.children,o),s.child;case 10:e:{if(c=s.type._context,_=s.pendingProps,g=s.memoizedProps,j=_.value,Tt(Al,c._currentValue),c._currentValue=j,g!==null)if(Yn(g.value,j)){if(g.children===_.children&&!gn.current){s=da(t,s,o);break e}}else for(g=s.child,g!==null&&(g.return=s);g!==null;){var F=g.dependencies;if(F!==null){j=g.child;for(var J=F.firstContext;J!==null;){if(J.context===c){if(g.tag===1){J=ua(-1,o&-o),J.tag=2;var _e=g.updateQueue;if(_e!==null){_e=_e.shared;var Te=_e.pending;Te===null?J.next=J:(J.next=Te.next,Te.next=J),_e.pending=J}}g.lanes|=o,J=g.alternate,J!==null&&(J.lanes|=o),Gc(g.return,o,s),F.lanes|=o;break}J=J.next}}else if(g.tag===10)j=g.type===s.type?null:g.child;else if(g.tag===18){if(j=g.return,j===null)throw Error(r(341));j.lanes|=o,F=j.alternate,F!==null&&(F.lanes|=o),Gc(j,o,s),j=g.sibling}else j=g.child;if(j!==null)j.return=g;else for(j=g;j!==null;){if(j===s){j=null;break}if(g=j.sibling,g!==null){g.return=j.return,j=g;break}j=j.return}g=j}Ln(t,s,_.children,o),s=s.child}return s;case 9:return _=s.type,c=s.pendingProps.children,gi(s,o),_=ss(_),c=c(_),s.flags|=1,Ln(t,s,c,o),s.child;case 14:return c=s.type,_=js(c,s.pendingProps),_=js(c.type,_),zm(t,s,c,_,o);case 15:return Im(t,s,s.type,s.pendingProps,o);case 17:return c=s.type,_=s.pendingProps,_=s.elementType===c?_:js(c,_),Bl(t,s),s.tag=1,f(c)?(t=!0,R(s)):t=!1,gi(s,o),$m(s,c,_),cu(s,c,_,o),fu(null,s,c,!0,t,o);case 19:return Hm(t,s,o);case 22:return Dm(t,s,o)}throw Error(r(156,s.tag))};function _f(t,s){return sr(t,s)}function m_(t,s,o,c){this.tag=t,this.key=o,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=s,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=c,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function is(t,s,o,c){return new m_(t,s,o,c)}function Ru(t){return t=t.prototype,!(!t||!t.isReactComponent)}function f_(t){if(typeof t=="function")return Ru(t)?1:0;if(t!=null){if(t=t.$$typeof,t===pe)return 11;if(t===ae)return 14}return 2}function Va(t,s){var o=t.alternate;return o===null?(o=is(t.tag,s,t.key,t.mode),o.elementType=t.elementType,o.type=t.type,o.stateNode=t.stateNode,o.alternate=t,t.alternate=o):(o.pendingProps=s,o.type=t.type,o.flags=0,o.subtreeFlags=0,o.deletions=null),o.flags=t.flags&14680064,o.childLanes=t.childLanes,o.lanes=t.lanes,o.child=t.child,o.memoizedProps=t.memoizedProps,o.memoizedState=t.memoizedState,o.updateQueue=t.updateQueue,s=t.dependencies,o.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext},o.sibling=t.sibling,o.index=t.index,o.ref=t.ref,o}function ec(t,s,o,c,_,g){var j=2;if(c=t,typeof t=="function")Ru(t)&&(j=1);else if(typeof t=="string")j=5;else e:switch(t){case fe:return Mr(o.children,_,g,s);case ie:j=8,_|=8;break;case Se:return t=is(12,o,s,_|2),t.elementType=Se,t.lanes=g,t;case G:return t=is(13,o,s,_),t.elementType=G,t.lanes=g,t;case te:return t=is(19,o,s,_),t.elementType=te,t.lanes=g,t;case Q:return tc(o,_,g,s);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case ke:j=10;break e;case le:j=9;break e;case pe:j=11;break e;case ae:j=14;break e;case U:j=16,c=null;break e}throw Error(r(130,t==null?t:typeof t,""))}return s=is(j,o,s,_),s.elementType=t,s.type=c,s.lanes=g,s}function Mr(t,s,o,c){return t=is(7,t,c,s),t.lanes=o,t}function tc(t,s,o,c){return t=is(22,t,c,s),t.elementType=Q,t.lanes=o,t.stateNode={isHidden:!1},t}function Mu(t,s,o){return t=is(6,t,null,s),t.lanes=o,t}function Pu(t,s,o){return s=is(4,t.children!==null?t.children:[],t.key,s),s.lanes=o,s.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},s}function h_(t,s,o,c,_){this.tag=s,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=c,this.onRecoverableError=_,this.mutableSourceEagerHydrationData=null}function zu(t,s,o,c,_,g,j,F,J){return t=new h_(t,s,o,F,J),s===1?(s=1,g===!0&&(s|=8)):s=0,g=is(3,null,null,s),t.current=g,g.stateNode=t,g.memoizedState={element:c,isDehydrated:o,cache:null,transitions:null,pendingSuspenseBoundaries:null},Jc(g),t}function p_(t,s,o){var c=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:H,key:c==null?null:""+c,children:t,containerInfo:s,implementation:o}}function gf(t){if(!t)return bs;t=t._reactInternals;e:{if(Ts(t)!==t||t.tag!==1)throw Error(r(170));var s=t;do{switch(s.tag){case 3:s=s.stateNode.context;break e;case 1:if(f(s.type)){s=s.stateNode.__reactInternalMemoizedMergedChildContext;break e}}s=s.return}while(s!==null);throw Error(r(171))}if(t.tag===1){var o=t.type;if(f(o))return S(t,o,s)}return s}function yf(t,s,o,c,_,g,j,F,J){return t=zu(o,c,!0,t,_,g,j,F,J),t.context=gf(null),o=t.current,c=Rn(),_=Wa(o),g=ua(c,_),g.callback=s??null,Fa(o,g,_),t.current.lanes=_,Ls(t,_,c),Bn(t,c),t}function nc(t,s,o,c){var _=s.current,g=Rn(),j=Wa(_);return o=gf(o),s.context===null?s.context=o:s.pendingContext=o,s=ua(g,j),s.payload={element:t},c=c===void 0?null:c,c!==null&&(s.callback=c),t=Fa(_,s,j),t!==null&&(Ns(t,_,j,g),Rl(t,_,j)),j}function sc(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 vf(t,s){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var o=t.retryLane;t.retryLane=o!==0&&o<s?o:s}}function Iu(t,s){vf(t,s),(t=t.alternate)&&vf(t,s)}function __(){return null}var xf=typeof reportError=="function"?reportError:function(t){console.error(t)};function Du(t){this._internalRoot=t}ac.prototype.render=Du.prototype.render=function(t){var s=this._internalRoot;if(s===null)throw Error(r(409));nc(t,s,null,null)},ac.prototype.unmount=Du.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var s=t.containerInfo;Ar(function(){nc(null,t,null,null)}),s[ys]=null}};function ac(t){this._internalRoot=t}ac.prototype.unstable_scheduleHydration=function(t){if(t){var s=Qr();t={blockedOn:null,target:t,priority:s};for(var o=0;o<_n.length&&s!==0&&s<_n[o].priority;o++);_n.splice(o,0,t),o===0&&zn(t)}};function Ou(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function rc(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11&&(t.nodeType!==8||t.nodeValue!==" react-mount-point-unstable "))}function bf(){}function g_(t,s,o,c,_){if(_){if(typeof c=="function"){var g=c;c=function(){var _e=sc(j);g.call(_e)}}var j=yf(s,c,t,0,null,!1,!1,"",bf);return t._reactRootContainer=j,t[ys]=j.current,Ra(t.nodeType===8?t.parentNode:t),Ar(),j}for(;_=t.lastChild;)t.removeChild(_);if(typeof c=="function"){var F=c;c=function(){var _e=sc(J);F.call(_e)}}var J=zu(t,0,!1,null,null,!1,!1,"",bf);return t._reactRootContainer=J,t[ys]=J.current,Ra(t.nodeType===8?t.parentNode:t),Ar(function(){nc(s,J,o,c)}),J}function ic(t,s,o,c,_){var g=o._reactRootContainer;if(g){var j=g;if(typeof _=="function"){var F=_;_=function(){var J=sc(j);F.call(J)}}nc(s,j,t,_)}else j=g_(o,s,t,_,c);return sc(j)}us=function(t){switch(t.tag){case 3:var s=t.stateNode;if(s.current.memoizedState.isDehydrated){var o=rr(s.pendingLanes);o!==0&&(Rs(s,o|1),Bn(s,It()),(bt&6)===0&&(wi=It()+500,$t()))}break;case 13:Ar(function(){var c=ca(t,1);if(c!==null){var _=Rn();Ns(c,t,1,_)}}),Iu(t,1)}},Jr=function(t){if(t.tag===13){var s=ca(t,134217728);if(s!==null){var o=Rn();Ns(s,t,134217728,o)}Iu(t,134217728)}},Pn=function(t){if(t.tag===13){var s=Wa(t),o=ca(t,s);if(o!==null){var c=Rn();Ns(o,t,s,c)}Iu(t,s)}},Qr=function(){return kt},Ii=function(t,s){var o=kt;try{return kt=t,s()}finally{kt=o}},ht=function(t,s,o){switch(s){case"input":if(W(t,o),s=o.name,o.type==="radio"&&s!=null){for(o=t;o.parentNode;)o=o.parentNode;for(o=o.querySelectorAll("input[name="+JSON.stringify(""+s)+'][type="radio"]'),s=0;s<o.length;s++){var c=o[s];if(c!==t&&c.form===t.form){var _=fi(c);if(!_)throw Error(r(90));Ue(c),W(c,_)}}}break;case"textarea":Oe(t,o);break;case"select":s=o.value,s!=null&&B(t,!!o.multiple,s,!1)}},Je=Tu,yt=Ar;var y_={usingClientEntryPoint:!1,Events:[Nr,Da,fi,ye,Ce,Tu]},To={findFiberByHostInstance:vs,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},v_={bundleType:To.bundleType,version:To.version,rendererPackageName:To.rendererPackageName,rendererConfig:To.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:q.ReactCurrentDispatcher,findHostInstanceByFiber:function(t){return t=nr(t),t===null?null:t.stateNode},findFiberByHostInstance:To.findFiberByHostInstance||__,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 oc=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!oc.isDisabled&&oc.supportsFiber)try{cs=oc.inject(v_),hn=oc}catch{}}return Wn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=y_,Wn.createPortal=function(t,s){var o=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Ou(s))throw Error(r(200));return p_(t,s,null,o)},Wn.createRoot=function(t,s){if(!Ou(t))throw Error(r(299));var o=!1,c="",_=xf;return s!=null&&(s.unstable_strictMode===!0&&(o=!0),s.identifierPrefix!==void 0&&(c=s.identifierPrefix),s.onRecoverableError!==void 0&&(_=s.onRecoverableError)),s=zu(t,1,!1,null,null,o,!1,c,_),t[ys]=s.current,Ra(t.nodeType===8?t.parentNode:t),new Du(s)},Wn.findDOMNode=function(t){if(t==null)return null;if(t.nodeType===1)return t;var s=t._reactInternals;if(s===void 0)throw typeof t.render=="function"?Error(r(188)):(t=Object.keys(t).join(","),Error(r(268,t)));return t=nr(s),t=t===null?null:t.stateNode,t},Wn.flushSync=function(t){return Ar(t)},Wn.hydrate=function(t,s,o){if(!rc(s))throw Error(r(200));return ic(null,t,s,!0,o)},Wn.hydrateRoot=function(t,s,o){if(!Ou(t))throw Error(r(405));var c=o!=null&&o.hydratedSources||null,_=!1,g="",j=xf;if(o!=null&&(o.unstable_strictMode===!0&&(_=!0),o.identifierPrefix!==void 0&&(g=o.identifierPrefix),o.onRecoverableError!==void 0&&(j=o.onRecoverableError)),s=yf(s,null,t,1,o??null,_,!1,g,j),t[ys]=s.current,Ra(t),c)for(t=0;t<c.length;t++)o=c[t],_=o._getVersion,_=_(o._source),s.mutableSourceEagerHydrationData==null?s.mutableSourceEagerHydrationData=[o,_]:s.mutableSourceEagerHydrationData.push(o,_);return new ac(s)},Wn.render=function(t,s,o){if(!rc(s))throw Error(r(200));return ic(null,t,s,!1,o)},Wn.unmountComponentAtNode=function(t){if(!rc(t))throw Error(r(40));return t._reactRootContainer?(Ar(function(){ic(null,null,t,!1,function(){t._reactRootContainer=null,t[ys]=null})}),!0):!1},Wn.unstable_batchedUpdates=Tu,Wn.unstable_renderSubtreeIntoContainer=function(t,s,o,c){if(!rc(o))throw Error(r(200));if(t==null||t._reactInternals===void 0)throw Error(r(38));return ic(t,s,o,!1,c)},Wn.version="18.3.1-next-f1338f8080-20240426",Wn}var Ef;function Ph(){if(Ef)return Uu.exports;Ef=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(n){console.error(n)}}return a(),Uu.exports=E_(),Uu.exports}var Tf;function T_(){if(Tf)return lc;Tf=1;var a=Ph();return lc.createRoot=a.createRoot,lc.hydrateRoot=a.hydrateRoot,lc}var A_=T_();const zh=[{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"]}];zh.map(a=>({id:a.id,label:a.label}));function L_(a){return`theme-${String(a||"").trim()||"dark"}`}function Af(a){try{const n=document.documentElement,r=Array.from(n.classList).filter(i=>i.startsWith("theme-"));for(const i of r)n.classList.remove(i);n.classList.add(L_(a))}catch{}}const pd=[{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}],_d=[{id:"compact",label:"Compact",density:.85},{id:"standard",label:"Standard",density:1},{id:"spacious",label:"Spacious",density:1.2}];function R_(a){const n=String(a).trim();return pd.find(r=>r.id===n)||pd[1]}function M_(a){const n=String(a).trim();return _d.find(r=>r.id===n)||_d[1]}function Lf(a){try{const n=document.documentElement,r=R_(a.font_scale||"md"),i=M_(a.header_density||"standard");n.style.setProperty("--font-scale",String(r.scale)),n.style.setProperty("--header-density",String(i.density))}catch{}}function P_(a){try{return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia(a).matches}catch{return!1}}function z_(a){const[n,r]=h.useState(()=>P_(a));return h.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const i=window.matchMedia(a),l=()=>r(i.matches);return l(),typeof i.addEventListener=="function"?i.addEventListener("change",l):i.addListener(l),()=>{typeof i.removeEventListener=="function"?i.removeEventListener("change",l):i.removeListener(l)}},[a]),n}let Lo=null;function I_(a,n){const r=Math.max(0,Math.round(a));if(!(n.scale<=1.01))return{vvHeight:r,keyboardInset:0};const i=Math.max(0,Math.min(r,Math.round(n.height))),l=Math.max(0,Math.round(a-n.height-Math.max(0,n.offsetTop)));return{vvHeight:i,keyboardInset:l}}function D_(){if(Lo)return Lo;if(typeof window>"u"||typeof document>"u")return()=>{};const a=window.visualViewport;if(!a)return()=>{};const n=document.documentElement;let r=0;const i=()=>{r=0;const{vvHeight:u,keyboardInset:m}=I_(window.innerHeight,{height:a.height,offsetTop:a.offsetTop,scale:a.scale||1});n.style.setProperty("--vv-height",`${u}px`),n.style.setProperty("--keyboard-inset",`${m}px`)},l=()=>{r||(r=window.requestAnimationFrame(i))};return i(),a.addEventListener("resize",l),a.addEventListener("scroll",l),window.addEventListener("orientationchange",l),Lo=()=>{a.removeEventListener("resize",l),a.removeEventListener("scroll",l),window.removeEventListener("orientationchange",l),r&&window.cancelAnimationFrame(r),n.style.removeProperty("--vv-height"),n.style.removeProperty("--keyboard-inset"),Lo=null},Lo}var Ih=Ph();function ki(...a){return a.filter(Boolean).join(" ")}function Fr({value:a,options:n,placeholder:r="Select…",disabled:i=!1,loading:l=!1,searchable:u=!0,searchPlaceholder:m="Search…",allowCustom:d=!1,clearable:p=!1,minPopoverWidth:b=240,variant:v="panel",className:y,triggerClassName:C,ariaLabel:L,id:T,includeValueOption:$=!1,onOpen:E,customOptionLabel:I,validateCustomValue:D,onChange:O,renderOption:q,renderValue:A}){const H=h.useRef(null),fe=h.useRef(null),ie=h.useRef(null),Se=h.useRef(E),ke=h.useId(),le=T||`af-select-${ke.replace(/[^a-zA-Z0-9_-]/g,"")}`,pe=`${le}-listbox`,[G,te]=h.useState(!1),[ae,U]=h.useState(""),[Q,M]=h.useState(0),[Z,ne]=h.useState("bottom"),[k,w]=h.useState({left:0,top:0,width:0});h.useEffect(()=>{Se.current=E},[E]);const K=h.useMemo(()=>{if(!$)return n;const Y=String(a??"").trim();return!Y||n.some(B=>B.value===Y)?n:[...n,{value:Y,label:Y}]},[$,n,a]),ve=h.useMemo(()=>{const Y=String(a??"");return K.find(B=>B.value===Y)||null},[K,a]),he=h.useMemo(()=>(ve==null?void 0:ve.label)||String(a||"").trim()||"",[ve,a]),z=h.useMemo(()=>{const Y=ae.trim().toLowerCase();return Y?K.filter(B=>B.label.toLowerCase().includes(Y)||B.value.toLowerCase().includes(Y)):K},[K,ae]),be=h.useMemo(()=>{if(!d)return null;const Y=ae.trim();if(!Y||K.some(je=>je.value===Y))return null;const oe=(D==null?void 0:D(Y,{options:K}))||"";return{value:Y,label:I?I(Y):`Use "${Y}"`,disabled:!!oe,reason:oe}},[d,I,K,ae,D]),Ae=h.useMemo(()=>{const Y=be?[be,...z]:z;if(Y.length>0)return Y;const B=String(a??"").trim();return l&&B?[{value:B,label:he||B}]:Y},[be,z,l,he,a]),De=h.useCallback(()=>{const Y=H.current;if(!Y)return;const B=Y.getBoundingClientRect(),oe=Math.max(B.width,b),je=Math.max(8,Math.min(B.left,window.innerWidth-oe-8)),Oe=window.innerHeight-B.bottom,se=B.top,xe=Oe>=220||Oe>=se?"bottom":"top";ne(xe);const ze=xe==="bottom"?B.bottom+6:B.top-6;w({left:je,top:ze,width:oe})},[b]),Me=h.useCallback(()=>{te(!1),U("")},[]);h.useEffect(()=>{var Y;G&&((Y=Se.current)==null||Y.call(Se))},[G]),h.useEffect(()=>{if(!G)return;De();const Y=()=>De();return window.addEventListener("resize",Y),window.addEventListener("scroll",Y,!0),()=>{window.removeEventListener("resize",Y),window.removeEventListener("scroll",Y,!0)}},[G,De]),h.useEffect(()=>{if(!G)return;const Y=B=>{var je,Oe;const oe=B.target;oe&&((je=H.current)!=null&&je.contains(oe)||(Oe=fe.current)!=null&&Oe.contains(oe)||Me())};return document.addEventListener("mousedown",Y,!0),()=>document.removeEventListener("mousedown",Y,!0)},[G,Me]),h.useEffect(()=>{if(!G)return;const Y=Math.max(0,Ae.findIndex(B=>B.value===a));M(Y===-1?0:Y),u&&setTimeout(()=>{var B;return(B=ie.current)==null?void 0:B.focus()},0)},[G,u,a,Ae]);const lt=Y=>{var oe;const B=Ae.find(je=>je.value===Y);B!=null&&B.disabled||(O(Y),Me(),(oe=H.current)==null||oe.focus())},Ue=Y=>{var B,oe;if(Y.key==="Escape")return Y.preventDefault(),Me(),(B=H.current)==null||B.focus(),!0;if(Y.key==="Tab")return Me(),(oe=H.current)==null||oe.focus(),!1;if(Y.key==="ArrowDown")return Y.preventDefault(),M(je=>Math.min(je+1,Math.max(0,Ae.length-1))),!0;if(Y.key==="ArrowUp")return Y.preventDefault(),M(je=>Math.max(je-1,0)),!0;if(Y.key==="Home")return Y.preventDefault(),M(0),!0;if(Y.key==="End")return Y.preventDefault(),M(Math.max(0,Ae.length-1)),!0;if(Y.key==="Enter"){Y.preventDefault();const je=Ae[Q];return je&&lt(je.value),!0}return!1},ct=Y=>{if(!i){if(G){if(Ue(Y))return;if(Y.key===" "&&!u){Y.preventDefault();const B=Ae[Q];B&&lt(B.value)}return}(Y.key==="Enter"||Y.key===" "||Y.key==="ArrowDown"||Y.key==="ArrowUp")&&(Y.preventDefault(),te(!0))}},Xe=!!String(a||"").trim(),dt=Xe?he:r,Ze=be!=null&&be.disabled?be.reason||"Unavailable":"",W=G&&Ae.length>0?`${le}-opt-${Q}`:void 0,X=e.jsx("span",{className:ki("af-select-value",!Xe&&"af-select-value--placeholder"),children:l&&!Xe?"Loading…":dt}),ge=A?A(ve,String(a||"")):X;return e.jsxs("span",{className:ki("af-select",v==="pin"?"af-select--pin":"af-select--panel",y),children:[e.jsxs("button",{ref:H,id:le,type:"button",className:ki("af-select-trigger",p&&Xe&&"af-select-trigger--clearable",C),disabled:i,onMouseDown:Y=>Y.stopPropagation(),onClick:Y=>{Y.stopPropagation(),!i&&te(B=>!B)},onKeyDown:ct,role:u?void 0:"combobox","aria-haspopup":"listbox","aria-expanded":G,"aria-controls":G?pe:void 0,"aria-activedescendant":u?void 0:W,"aria-label":L,children:[ge,e.jsx("span",{className:ki("af-select-caret",G&&"af-select-caret--open"),children:"▾"})]}),p&&Xe?e.jsx("button",{type:"button",className:"af-select-clear-btn","aria-label":"Clear selection",disabled:i,onMouseDown:Y=>{Y.preventDefault(),Y.stopPropagation()},onClick:Y=>{var B;Y.preventDefault(),Y.stopPropagation(),O(""),Me(),(B=H.current)==null||B.focus()},title:"Clear",children:"×"}):null,G?Ih.createPortal(e.jsxs("div",{ref:fe,className:ki("af-select-popover",Z==="top"&&"af-select-popover--top"),style:{position:"fixed",left:`${k.left}px`,top:`${k.top}px`,width:`${k.width}px`},onMouseDown:Y=>Y.stopPropagation(),onClick:Y=>Y.stopPropagation(),onWheel:Y=>Y.stopPropagation(),onKeyDown:Ue,tabIndex:-1,children:[u?e.jsxs("div",{className:"af-select-search",children:[e.jsx("input",{ref:ie,className:"af-select-search-input",value:ae,onChange:Y=>U(Y.target.value),placeholder:m,onKeyDown:Ue,role:"combobox","aria-expanded":!0,"aria-controls":pe,"aria-activedescendant":W,"aria-invalid":!!Ze,"aria-describedby":Ze?`${le}-custom-error`:void 0}),Ze?e.jsx("div",{id:`${le}-custom-error`,className:"af-select-custom-error",role:"alert",children:Ze}):null]}):null,e.jsx("div",{className:"af-select-options",role:"listbox",id:pe,"aria-label":L,children:l&&Ae.length===0?e.jsx("div",{className:"af-select-empty",children:"Loading…"}):Ae.length===0?e.jsx("div",{className:"af-select-empty",children:"No results"}):Ae.map((Y,B)=>{var ze;const oe=Y.value===a,je=B===Q,Oe=String(Y.group||"").trim(),se=B>0?String(((ze=Ae[B-1])==null?void 0:ze.group)||"").trim():"",xe=!!Oe&&Oe!==se;return e.jsxs(Wt.Fragment,{children:[xe?e.jsx("div",{className:"af-select-group",role:"presentation",children:Oe}):null,e.jsx("div",{id:`${le}-opt-${B}`,role:"option","aria-selected":oe,className:ki("af-select-option",oe&&"af-select-option--selected",je&&"af-select-option--highlighted",Y.disabled&&"af-select-option--disabled"),title:Y.disabled?Y.reason||"Unavailable":void 0,onMouseEnter:()=>M(B),onMouseDown:Ne=>{Ne.preventDefault(),Ne.stopPropagation()},onClick:()=>lt(Y.value),"aria-disabled":Y.disabled?!0:void 0,children:q?q(Y,{selected:oe,highlighted:je}):e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"af-select-option-label",children:[e.jsx("span",{children:Y.label}),Y.reason?e.jsx("small",{className:"af-select-option-reason",children:Y.reason}):null]}),oe?e.jsx("span",{className:"af-select-check",children:"✓"}):null]})})]},Y.value)})})]}),document.body):null]})}function O_(a){const n=new Set,r=[];for(const i of a||[]){if(!i||typeof i!="object")continue;const l=String(i.name||"").trim();!l||n.has(l)||(n.add(l),r.push({name:l,display_name:typeof i.display_name=="string"?i.display_name:void 0}))}return r.sort((i,l)=>i.name.localeCompare(l.name)),r}function F_(a){const n=new Set,r=[];for(const i of a||[]){const l=String(i||"").trim();!l||n.has(l)||(n.add(l),r.push(l))}return r.sort(),r}function q_(a){const n=a.disabled===!0,r=a.layout||"stack",i=a.allowGatewayDefault!==!1,l=String(a.gatewayDefaultLabel||"(gateway default)"),u=String(a.providerLabel||"Provider"),m=String(a.modelLabel||"Model"),d=String(a.providerPlaceholder||"(select)"),p=String(a.modelPlaceholder||"(select)"),b=String(a.provider||"").trim(),v=String(a.model||"").trim(),y=O_(a.providers),C=F_(a.models),L=n||!!a.loadingProviders,T=n||!!a.loadingModels,$=[...i?[{value:"",label:l}]:[],...y.map(I=>({value:I.name,label:I.display_name?`${I.display_name} (${I.name})`:I.name}))],E=[...i?[{value:"",label:l}]:[],...C.map(I=>({value:I,label:I}))];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:u}),e.jsx(Fr,{value:b,options:$,placeholder:i?l:d,disabled:L,loading:!!a.loadingProviders,searchable:!0,allowCustom:a.allowCustomProvider===!0,clearable:i,variant:"panel",triggerClassName:a.selectClassName,ariaLabel:u,onChange:I=>a.onChange({provider:String(I||"").trim(),model:""})}),a.loadingProviders?e.jsx("div",{className:"mono muted",style:{fontSize:"12px",marginTop:"6px"},children:"Loading providers…"}):null,a.providerError?e.jsx("div",{className:"mono",style:{color:"var(--error)",fontSize:"12px",marginTop:"6px"},children:a.providerError}):null]}),e.jsxs("div",{style:r==="row"?{flex:"1 1 260px",minWidth:240}:void 0,children:[e.jsx("label",{children:m}),e.jsx(Fr,{value:v,options:E,placeholder:i?l:p,disabled:T,loading:!!a.loadingModels,searchable:!0,allowCustom:a.allowCustomModel===!0,clearable:i,variant:"panel",triggerClassName:a.selectClassName,ariaLabel:m,onChange:I=>a.onChange({provider:b,model:String(I||"").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 U_(a){if(a===!1||a&&typeof a=="object"&&a.mode==="off")return!1;if(!a||typeof a!="object")return;const n=a;if(!(n.mode!=="native_mtp"||!Number.isInteger(n.num_draft_tokens)||Number(n.num_draft_tokens)<1))return{mode:"native_mtp",num_draft_tokens:Number(n.num_draft_tokens),require_acceleration:!0}}function B_(a){var r;const n=(r=a==null?void 0:a.execution)==null?void 0:r.speculation;return!n||typeof n.supported!="boolean"?null:{supported:n.supported,ready:typeof n.ready=="boolean"?n.ready:null,reason:typeof n.reason=="string"?n.reason:null,supported_depths:n.supported&&Array.isArray(n.supported_depths)?[...new Set(n.supported_depths.filter(i=>typeof i=="number"&&Number.isInteger(i)&&i>0))]:[],default:Object.prototype.hasOwnProperty.call(n,"effective_default")?n.effective_default:n.default,requires_reload:typeof n.requires_reload=="boolean"?n.requires_reload:null}}function Rf(a){const n=U_(a);return n===!1?"off":n?String(n.num_draft_tokens):""}function W_(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 H_(a){const n=B_(a.capabilities),r=Rf(a.value),i=(n==null?void 0:n.supported_depths.map(String))||[],l=Rf(n==null?void 0:n.default),u=a.inheritLabel||"Workflow / Gateway default",m=l?`${u} (${l==="off"?"Off":`depth ${l}`})`:u,d=a.error||(a.loading?"Checking MTP capability…":n?n.reason||(n.requires_reload?"Model reload required before MTP can run.":n.ready===!1?"MTP is supported but not ready on this instance.":n.ready===null&&n.supported?"MTP support verified; loaded-instance readiness is unknown.":n.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(Fr,{ariaLabel:"MTP depth",value:r,placeholder:m,disabled:a.disabled||a.loading,options:[{value:"",label:m},{value:"off",label:"Off"},...i.map(p=>({value:p,label:`Depth ${p}`})),...r&&r!=="off"&&!i.includes(r)?[{value:r,label:`Depth ${r} (saved; not available)`}]:[]],onChange:p=>a.onChange(W_(p))}),d&&!a.hideNote?e.jsx("div",{role:"status",className:"af-pmp__hint",children:d}):null]})}const V_="Reasoning and MTP choices appear when the gateway can describe the selected model.",G_="Reasoning choices appear when the gateway can describe the selected model.";function K_(a){var ne,k;const n=a.disabled===!0,r=a.value||{provider:"",model:""},i=!String(r.provider||"").trim()&&!String(r.model||"").trim(),[l,u]=h.useState(!i),m=i&&!l,d=h.useRef(i);h.useEffect(()=>{i&&!d.current&&u(!1),d.current=i},[i]);const[p,b]=h.useState([]),[v,y]=h.useState(!1),[C,L]=h.useState(""),[T,$]=h.useState([]),[E,I]=h.useState(!1),[D,O]=h.useState(""),q=h.useRef(a);q.current=a,h.useEffect(()=>{if(m||n)return;let w=!0;return y(!0),(async()=>{try{const K=await q.current.fetchProviders();if(!w)return;b(Array.isArray(K)?K:[]),L("")}catch(K){if(!w)return;b([]),L(`#FALLBACK provider discovery failed: ${String((K==null?void 0:K.message)||K)}`)}finally{w&&y(!1)}})(),()=>{w=!1}},[m,n]);const A=String(r.provider||"").trim();h.useEffect(()=>{if(!A||n){$([]),O(""),I(!1);return}let w=!0;return $([]),I(!0),O(""),(async()=>{try{const K=await q.current.fetchModels(A);if(!w)return;$(Array.isArray(K)?K:[])}catch(K){if(!w)return;$([]),O(`#FALLBACK model discovery failed: ${String((K==null?void 0:K.message)||K)}`)}finally{w&&I(!1)}})(),()=>{w=!1}},[A,n]);const H=h.useMemo(()=>{const w=[...p];return A&&!w.some(K=>K.name===A)&&w.unshift({name:A}),w},[p,A]),fe=String(r.model||"").trim(),ie=h.useMemo(()=>{const w=[...T];return fe&&!w.includes(fe)&&w.unshift(fe),w},[T,fe]),Se=a.defaultModeLabel||"Gateway default",ke=a.customModeLabel||"Custom",le=A||((ne=a.effectiveDefault)==null?void 0:ne.provider)||"",pe=fe||(A?"":(k=a.effectiveDefault)==null?void 0:k.model)||"",[G,te]=h.useState({levels:[],error:"",loading:!1}),ae=!!a.fetchModelCapabilities,[U,Q]=h.useState();h.useEffect(()=>{let w=!0;if(Q(void 0),te({levels:[],error:"",loading:ae&&!!pe}),!(!ae||!pe||n))return q.current.fetchModelCapabilities(pe,le).then(K=>{var be;if(!w)return;if(K!=null&&K.error)throw new Error(String(K.error));Q(K);const ve=(K==null?void 0:K.capabilities)||K||{},he=ve.reasoning_levels||ve.thinking_levels,z=Array.isArray(he)?[...new Set(he.filter(Ae=>typeof Ae=="string"&&!!Ae.trim()))]:[];!z.length&&ve.thinking_support===!0&&((be=ve.thinking_control)!=null&&be.prompt_disable_token)&&z.push("off","auto"),te({levels:z,error:"",loading:!1})}).catch(K=>{w&&te({levels:[],error:String((K==null?void 0:K.message)||K),loading:!1})}),()=>{w=!1}},[le,pe,ae,n]);const M=a.inheritLabel||"Workflow / Gateway default",Z=!m||a.optionsInDefaultMode!==!1;return e.jsxs("div",{className:`af-pmp${a.className?` ${a.className}`:""}`,children:[e.jsxs("div",{className:"af-pmp__seg",role:"tablist","aria-label":"Provider mode",children:[e.jsx("button",{type:"button",role:"tab","aria-selected":m,className:`af-pmp__seg-btn${m?" is-active":""}`,onClick:()=>{u(!1),a.onChange({...r,provider:"",model:"",...ae?{reasoning:""}:{}})},disabled:n,children:Se}),e.jsx("button",{type:"button",role:"tab","aria-selected":!m,className:`af-pmp__seg-btn${m?"":" is-active"}`,onClick:()=>{u(!0)},disabled:n,children:ke})]}),m?e.jsx("div",{className:"af-pmp__hint",children:a.defaultHint||"The gateway picks its configured default provider and model for this task."}):e.jsx(q_,{provider:A,model:fe,providers:H,models:ie,disabled:n,loadingProviders:v,loadingModels:E,providerError:C||void 0,modelError:D||void 0,providerLabel:a.providerLabel,modelLabel:a.modelLabel,allowGatewayDefault:!1,allowCustomProvider:a.allowCustom!==!1,allowCustomModel:a.allowCustom!==!1,onChange:w=>a.onChange({...r,provider:w.provider,model:w.model,...ae?{reasoning:""}:{}})}),Z&&ae&&(G.levels.length>0||r.reasoning)?e.jsxs("div",{className:"af-pmp__reasoning",children:[e.jsx("label",{children:a.reasoningLabel||"Reasoning effort"}),e.jsx(Fr,{ariaLabel:a.reasoningLabel||"Reasoning effort",placeholder:M,value:r.reasoning||"",options:[{value:"",label:M},...G.levels.map(w=>({value:w,label:w})),...r.reasoning&&!G.levels.includes(r.reasoning)?[{value:r.reasoning,label:`${r.reasoning} (saved; not advertised)`}]:[]],disabled:n||G.loading,onChange:w=>a.onChange({...r,reasoning:w})})]}):null,Z&&a.enableSpeculation?e.jsx(H_,{value:r.speculation,inheritLabel:M,onChange:w=>a.onChange({...r,speculation:w}),capabilities:U,disabled:n,loading:G.loading,hideNote:!!G.error}):null,Z&&G.error?e.jsxs("div",{role:"status",className:"af-pmp__hint","data-discovery":"unavailable",children:[a.enableSpeculation?V_:G_,e.jsxs("details",{className:"af-pmp__details",children:[e.jsx("summary",{children:"Technical details"}),e.jsx("span",{children:G.error})]})]}):null]})}function Mf(...a){return a.filter(Boolean).join(" ")}function J_({kicker:a="AbstractGateway connection",title:n="Connect to AbstractGateway",description:r="Sign in with the Gateway user token assigned by the Gateway admin.",statusLabel:i="Not signed in",statusTone:l="neutral",showGatewayUrl:u=!1,gatewayUrl:m="",gatewayUrlPlaceholder:d="http://127.0.0.1:8080",onGatewayUrlChange:p,userId:b,userPlaceholder:v="admin",onUserIdChange:y,token:C,tokenPlaceholder:L="Paste Gateway user token",showToken:T=!1,onTokenChange:$,onShowTokenChange:E,remember:I=!1,rememberLabel:D="Remember this browser",onRememberChange:O,loading:q=!1,submitting:A=!1,submitDisabled:H=!1,submitLabel:fe="Sign in",submittingLabel:ie="Signing in...",closeLabel:Se="Close",signOutLabel:ke="Sign out",showClose:le=!1,showSignOut:pe=!1,error:G,message:te,className:ae,onSubmit:U,onClose:Q,onSignOut:M}){const Z=q||A,ne=Z||H||!String(b||"").trim()||!String(C||"").trim(),k=w=>{w.preventDefault(),!ne&&U()};return e.jsxs("form",{className:Mf("af-gateway-signin",ae),onSubmit:k,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:n}),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:Mf("af-gateway-signin__status",`af-gateway-signin__status--${l}`),children:i})}),e.jsxs("div",{className:"af-gateway-signin__form",children:[u?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:m,onChange:w=>p==null?void 0:p(w.target.value),placeholder:d,autoComplete:"url",disabled:Z})]}):null,e.jsx("label",{className:"af-gateway-signin__label",htmlFor:"gateway-session-user",children:"Gateway user"}),e.jsx("input",{id:"gateway-session-user",value:b,onChange:w=>y(w.target.value),placeholder:v,autoComplete:"username",disabled:Z}),e.jsx("label",{className:"af-gateway-signin__label",htmlFor:"gateway-session-token",children:"Gateway token"}),e.jsxs("div",{className:"af-gateway-signin__token-input",children:[e.jsx("input",{id:"gateway-session-token",type:T?"text":"password",value:C,onChange:w=>$(w.target.value),placeholder:L,autoComplete:"off","data-1p-ignore":"","data-lpignore":"true","data-bwignore":"",spellCheck:!1,disabled:Z}),e.jsx("button",{className:"af-gateway-signin__secondary",type:"button",onClick:()=>E==null?void 0:E(!T),disabled:Z,children:T?"Hide":"Show"})]}),e.jsxs("label",{className:"af-gateway-signin__checkbox",children:[e.jsx("input",{type:"checkbox",checked:!!I,onChange:w=>O==null?void 0:O(w.target.checked),disabled:Z}),D]})]}),G?e.jsx("div",{className:"af-gateway-signin__message af-gateway-signin__message--error",children:G}):null,!G&&te?e.jsx("div",{className:"af-gateway-signin__message af-gateway-signin__message--ok",children:te}):null,e.jsxs("div",{className:"af-gateway-signin__actions",children:[le?e.jsx("button",{className:"af-gateway-signin__secondary",type:"button",onClick:Q,disabled:Z,children:Se}):null,pe?e.jsx("button",{className:"af-gateway-signin__secondary",type:"button",onClick:()=>void(M==null?void 0:M()),disabled:Z,children:ke}):null,e.jsx("button",{className:"af-gateway-signin__primary",type:"submit",disabled:ne,children:A?ie:fe})]})]})}function Q_(a){return a==="light"?"Light":"Dark"}function Y_(a){const n=a.themes&&a.themes.length?a.themes:zh,r=a.showSwatches!==!1,i=a.variant||"panel",l=h.useMemo(()=>{const m={};for(const d of n)m[d.id]=d;return m},[n]),u=h.useMemo(()=>n.map(m=>({value:m.id,label:m.label,group:Q_(m.group)})),[n]);return e.jsx(Fr,{value:a.value,options:u,placeholder:a.placeholder||"Select theme…",disabled:a.disabled===!0,searchable:!0,allowCustom:!1,clearable:!1,variant:i,className:a.className,triggerClassName:a.triggerClassName,onChange:m=>a.onChange(String(m||"").trim()),renderValue:(m,d)=>{const p=String(d||"").trim(),b=l[p],v=(b==null?void 0:b.label)||p||a.placeholder||"Select theme…",y=(b==null?void 0:b.swatches)||null,C=!p;return e.jsxs("span",{className:"af-theme-value",children:[e.jsx("span",{className:`af-theme-label ${C?"af-theme-label--placeholder":""}`.trim(),children:v}),r&&y?e.jsx("span",{className:"af-theme-swatches","aria-hidden":"true",children:y.map((L,T)=>e.jsx("span",{className:"af-theme-swatch",style:{background:L}},`${p}:${T}`))}):null]})},renderOption:(m,d)=>{const p=String(m.value||"").trim(),b=l[p],v=(b==null?void 0:b.swatches)||null;return e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"af-theme-option-label",children:m.label}),e.jsxs("span",{className:"af-theme-option-right",children:[r&&v?e.jsx("span",{className:"af-theme-swatches","aria-hidden":"true",children:v.map((y,C)=>e.jsx("span",{className:"af-theme-swatch",style:{background:y}},`${p}:${C}`))}):null,d.selected?e.jsx("span",{className:"af-select-check",children:"✓"}):null]})]})}})}function X_(a){const n=a.scales&&a.scales.length?a.scales:pd,r=a.variant||"panel",i=h.useMemo(()=>n.map(l=>({value:l.id,label:l.label})),[n]);return e.jsx(Fr,{value:a.value,options:i,placeholder:a.placeholder||"Font size…",disabled:a.disabled===!0,searchable:!1,allowCustom:!1,clearable:!1,variant:r,className:a.className,triggerClassName:a.triggerClassName,onChange:l=>a.onChange(String(l||"").trim())})}function Z_(a){const n=a.densities&&a.densities.length?a.densities:_d,r=a.variant||"panel",i=h.useMemo(()=>n.map(l=>({value:l.id,label:l.label})),[n]);return e.jsx(Fr,{value:a.value,options:i,placeholder:a.placeholder||"Header size…",disabled:a.disabled===!0,searchable:!1,allowCustom:!1,clearable:!1,variant:r,className:a.className,triggerClassName:a.triggerClassName,onChange:l=>a.onChange(String(l||"").trim())})}const eg=new Set(["board","inbox","server","agent","playCircle","list","gear"]);function tg(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"cog":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]});case"activity":return e.jsx("path",{d:"M22 12h-4l-3 9L9 3l-3 9H2"});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"unarchive":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:"M12 18v-6"}),e.jsx("path",{d:"m9 14 3-3 3 3"})]});case"clock":return e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M12 6v6h4"})]});case"book":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M2 4h6a4 4 0 0 1 4 4v13a3 3 0 0 0-3-3H2z"}),e.jsx("path",{d:"M22 4h-6a4 4 0 0 0-4 4v13a3 3 0 0 1 3-3h7z"})]});case"compose":return e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),e.jsx("path",{d:"M18.4 2.6a2.1 2.1 0 0 1 3 3L12 15l-4 1 1-4z"})]});default:return null}}function He({name:a,size:n=16,className:r,title:i,...l}){const u=i?void 0:!0,m=eg.has(a);return e.jsxs("svg",{width:n,height:n,viewBox:m?"0 0 16 16":"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:m?1.4:2,strokeLinecap:"round",strokeLinejoin:"round",className:r,"aria-hidden":u,role:i?"img":"presentation",...l,children:[i?e.jsx("title",{children:i}):null,tg(a)]})}const Pf="api/gateway",Ri="api/connection/gateway";function Ws(a){const n=String(a||"");if(n.startsWith("/"))throw new Error(`gatewayApiPath takes a route relative to the gateway API, got ${JSON.stringify(n)}.`);return n?`${Pf}/${n}`:Pf}function Hu(a,n){const r=String(n||"");if(r.startsWith("/"))throw new Error(`joinBaseUrl takes a relative path, got ${JSON.stringify(r)}.`);let i=String(a??"");for(;i.endsWith("/");)i=i.slice(0,-1);return i?`${i}/${r}`:r}function ng(a){return!String(a.unavailableReason||"").trim()&&!a.busy}function sg(a){return ng(a)?!a.checked:null}let ag=0;function Ai(a){const{label:n,checked:r,onChange:i,description:l,reasonVisible:u=!0,describedBy:m,hint:d,busy:p=!1,variant:b="inline",ariaLabel:v,className:y,id:C,action:L}=a,T=String(a.unavailableReason||"").trim(),$=!!T,E=m||(C?`${C}-reason`:$?`af-switch-reason-${++ag}`:void 0),I=["af-switch",b==="row"?"af-switch--row":b==="sm"?"af-switch--sm":"",$?"af-switch--unavailable":"",y||""].filter(Boolean).join(" "),D=q=>{const A=sg({checked:r,unavailableReason:T,busy:p});if(A===null){q.preventDefault();return}i==null||i(A)},O=e.jsxs("button",{type:"button",role:"switch",id:C,className:I,"data-action":L,"aria-checked":r?"true":"false","aria-disabled":$?"true":void 0,"aria-describedby":$?E:void 0,"aria-busy":p?"true":void 0,"aria-label":v,"aria-description":l?void 0:d,title:$?d?`${T}
41
+ ${d}`:T:d,onClick:D,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:n}),l?e.jsx("span",{className:"af-switch__desc",children:l}):null]})]});return!$||m?O:e.jsxs("span",{className:b==="row"?"af-switch-wrap af-switch-wrap--row":"af-switch-wrap",children:[O,e.jsx("span",{id:E,className:u?"af-switch__reason":"af-switch__reason af-switch__reason--hidden",children:T})]})}const rg=150,Dh="data-af-tip";function ig(a,n,r,i=6,l=8){let u="top",m=a.top-i-n.height;if(m<l){const b=a.bottom+i;(b+n.height<=r.height-l||r.height-a.bottom>a.top)&&(m=b,u="bottom")}let p=(a.left+a.right)/2-n.width/2;return p=Math.max(l,Math.min(p,r.width-l-n.width)),m=Math.max(l,Math.min(m,r.height-l-n.height)),{top:Math.round(m),left:Math.round(p),side:u}}let zf=0;function Oh(a){return a?String(a.getAttribute(Dh)||"").trim():""}function Vu(a,n){const r=a;if(!r||typeof r.closest!="function")return null;const i=r.closest(`[${Dh}]`);return!i||!n.contains(i)||!Oh(i)?null:i}function og(a,n={}){if(!a)throw new Error("bindAfTooltips: a root (document or element) is required");const r=a.nodeType===9?a:a.ownerDocument,i=r.defaultView||globalThis,l=typeof n.delayMs=="number"&&n.delayMs>=0?n.delayMs:rg;zf+=1;const u=r.createElement("div");u.className="af-tooltip",u.setAttribute("role","tooltip");const m=`af-tooltip-${zf}`;u.setAttribute("id",m),u.hidden=!0,(r.body||r.documentElement).appendChild(u);let d=null,p=null,b=null,v=null,y=!1,C=null;const L=()=>{b&&clearTimeout(b),b=null,p=null},T=()=>{v&&clearTimeout(v),v=null},$=()=>{if(!d)return;const ae=d.getBoundingClientRect(),U=u.getBoundingClientRect(),Q=ig(ae,{width:U.width,height:U.height},{width:i.innerWidth,height:i.innerHeight});u.style.top=`${Q.top}px`,u.style.left=`${Q.left}px`,u.setAttribute("data-side",Q.side)},E=()=>{if(L(),T(),!d)return;String(d.getAttribute("aria-describedby")||"").split(/\s+/).includes(m)&&(C?d.setAttribute("aria-describedby",C):d.removeAttribute("aria-describedby")),C=null,d=null,u.hidden=!0,u.textContent=""},I=ae=>{L(),T(),d&&d!==ae&&E();const U=Oh(ae);if(!U||ae.isConnected===!1)return;if(d=ae,u.textContent=U,u.hidden=!1,String(ae.getAttribute("aria-label")||"").trim()!==U){const M=ae.getAttribute("aria-describedby");C=M&&M!==m?M:null,ae.setAttribute("aria-describedby",C?`${C} ${m}`:m)}$()},D=ae=>{T(),d!==ae&&p!==ae&&(L(),p=ae,b=setTimeout(()=>{const U=p;b=null,p=null,U&&I(U)},l))},O=()=>{L(),d&&(T(),v=setTimeout(E,100))},q=ae=>{try{if(typeof ae.matches=="function")return ae.matches(":focus-visible")}catch{}return y},A=ae=>{if(ae.pointerType==="touch")return;if(u.contains(ae.target)){T();return}const Q=Vu(ae.target,a);Q&&D(Q)},H=ae=>{const Q=ae.relatedTarget||null;if(!(Q&&(u.contains(Q)||d&&d.contains(Q)||p&&p.contains(Q)))){if(p&&!d){L();return}d&&O()}},fe=ae=>{const U=ae.relatedTarget||null;U&&(u.contains(U)||d&&d.contains(U))||O()},ie=ae=>{const U=Vu(ae.target,a);U&&q(U)&&D(U)},Se=ae=>{const U=Vu(ae.target,a);U&&(U===d||U===p)&&E()},ke=()=>{y=!1,E()},le=ae=>{if(ae.key==="Escape"||ae.key==="Esc"){d?(ae.preventDefault(),E()):L();return}!ae.metaKey&&!ae.ctrlKey&&!ae.altKey&&(y=!0)},pe=()=>E(),G=a;G.addEventListener("pointerover",A),G.addEventListener("pointerout",H),G.addEventListener("focusin",ie),G.addEventListener("focusout",Se),u.addEventListener("pointerover",A),u.addEventListener("pointerout",fe),r.addEventListener("pointerdown",ke,!0),i.addEventListener("keydown",le,!0),i.addEventListener("scroll",pe,!0),i.addEventListener("resize",pe);let te=!1;return()=>{te||(te=!0,E(),G.removeEventListener("pointerover",A),G.removeEventListener("pointerout",H),G.removeEventListener("focusin",ie),G.removeEventListener("focusout",Se),u.removeEventListener("pointerover",A),u.removeEventListener("pointerout",fe),r.removeEventListener("pointerdown",ke,!0),i.removeEventListener("keydown",le,!0),i.removeEventListener("scroll",pe,!0),i.removeEventListener("resize",pe),u.parentNode&&u.parentNode.removeChild(u))}}const cc=new WeakMap;function lg(a){let n=cc.get(a);n||(n={count:0,release:og(a)},cc.set(a,n)),n.count+=1;let r=!1;return()=>{if(r)return;r=!0;const i=cc.get(a);i&&(i.count-=1,i.count<=0&&(i.release(),cc.delete(a)))}}function Pd(){h.useEffect(()=>{if(!(typeof document>"u"))return lg(document)},[])}const Gu=1;function Ya(a){return typeof a=="object"&&a!==null&&!Array.isArray(a)}const cg=["granted","denied","structurally_unavailable","trust_gated"],ug=["attachable","requires_review","blocked"],dg=["default","operator","structural"],mg=["grant","deny","clear"],fg=new Set(["__proto__","constructor","prototype"]);function hg(a,n){if(!Ya(a))return{ok:!1,reason:`${n}: cell is not an object`};const r=String(a.availability||"");if(!cg.includes(r))return{ok:!1,reason:`${n}: unknown availability "${r}"`};const i=String(a.provenance||"");if(!dg.includes(i))return{ok:!1,reason:`${n}: unknown provenance "${i}"`};let l;if(r==="trust_gated"){const u=String(a.trust_state||"");if(!ug.includes(u))return{ok:!1,reason:`${n}: trust_gated cell without a valid trust_state ("${u}")`};l=u}for(const u of["assigned","resolved_value","executable"]){const m=a[u];if(m!==void 0&&typeof m!="boolean")return{ok:!1,reason:`${n}: "${u}" is present but not a boolean`}}return{ok:!0,cell:{assigned:a.assigned===!0,resolved_value:a.resolved_value===!0,provenance:i,availability:r,executable:a.executable!==!1,reason:typeof a.reason=="string"?a.reason:void 0,trust_state:l}}}function Fh(a){if(!Ya(a))return{ok:!1,reason:"payload is not an object"};const n=a.schema_version;if(typeof n!="number"||!Number.isFinite(n))return{ok:!1,reason:"payload has no numeric schema_version"};if(Math.floor(n)!==Gu)return{ok:!1,reason:`unsupported schema_version ${n} (this build understands ${Gu}); 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=[],i=new Set;for(const m of a.phases){if(!Ya(m)||typeof m.id!="string"||!m.id.trim())return{ok:!1,reason:"phase without a string id"};const d=m.id.trim();if(fg.has(d))return{ok:!1,reason:`reserved phase id "${d}"`};if(i.has(d))return{ok:!1,reason:`duplicate phase id "${d}"`};i.add(d),r.push({id:d,label:typeof m.label=="string"?m.label:void 0,hint:typeof m.hint=="string"?m.hint:void 0})}const l=[],u=new Set;for(const m of a.sections){if(!Ya(m)||typeof m.id!="string"||!m.id.trim())return{ok:!1,reason:"section without a string id"};const d=m.id.trim();if(u.has(d))return{ok:!1,reason:`duplicate section id "${d}"`};if(u.add(d),!Array.isArray(m.items))return{ok:!1,reason:`section "${d}" has no items array`};const p=[],b=new Set;for(const v of m.items){if(!Ya(v)||typeof v.id!="string"||!v.id.trim())return{ok:!1,reason:`section "${d}": item without a string id`};const y=v.id.trim();if(b.has(y))return{ok:!1,reason:`section "${d}": duplicate item id "${y}"`};if(b.add(y),v.cells!==void 0&&!Ya(v.cells))return{ok:!1,reason:`section "${d}" item "${y}": cells is not an object`};const C=Object.create(null),L=Ya(v.cells)?v.cells:{};for(const[T,$]of Object.entries(L)){if(!i.has(T))return{ok:!1,reason:`section "${d}" item "${y}": cell for undeclared phase "${T}"`};const E=hg($,`section "${d}" item "${y}" phase "${T}"`);if(!E.ok)return E;C[T]=E.cell}p.push({id:y,label:typeof v.label=="string"?v.label:void 0,description:typeof v.description=="string"?v.description:void 0,cells:C})}l.push({id:d,label:typeof m.label=="string"?m.label:void 0,items:p})}return{ok:!0,payload:{schema_version:Gu,phases:r,sections:l}}}function pg(a,n,r,i){for(const l of a)if(l.section===n&&l.item===r&&l.phase===i)return l.op;return null}function zd(a,n,r,i,l){const u=a.sections.find(T=>T.id===r),m=u==null?void 0:u.items.find(T=>T.id===i),d=m&&m.cells[l]||null,p=pg(n,r,i,l);if(!d)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 b=d.availability==="structurally_unavailable"||d.availability==="trust_gated"&&d.trust_state==="blocked";let v=d.resolved_value;p==="grant"?v=!0:p==="deny"?v=!1:p==="clear"&&(v=d.provenance==="operator"?null:d.resolved_value);const y=d.availability==="trust_gated"&&d.trust_state==="requires_review",C=b?!1:v;let L;return b?L={kind:"blocked",blocked_kind:d.availability==="trust_gated"?"trust":"structural"}:y&&C!==!0?L={kind:"approval"}:L={kind:"tristate",options:["grant","clear","deny"],active_op:p!==null?p:d.assigned?d.resolved_value?"grant":"deny":"clear"},{cell:d,pending:p,effective_value:C,interactive:!b,approval_required:y,standing_config:!b&&d.executable===!1,reason:d.reason||(b?d.availability:null),control:L}}function _g(a,n,r){const i=zd(a,n,r.section,r.item,r.phase);if(!i.cell||!i.interactive)return n;const l=n.filter(d=>!(d.section===r.section&&d.item===r.item&&d.phase===r.phase)),u=i.cell;return r.op==="clear"?u.assigned?[...l,r]:l:u.assigned&&u.provenance==="operator"&&u.resolved_value===(r.op==="grant")?l:[...l,r]}function gg(a,n){const r=new Set,i=[];for(const l of n){if(!Ya(l)||!mg.includes(l.op))continue;const u=`${l.section}\0${l.item}\0${l.phase}`;if(r.has(u))continue;r.add(u);const m=zd(a,[],l.section,l.item,l.phase);!m.cell||!m.interactive||i.push(l)}return i}function yg(a){return a==="grant"?"Grant":a==="deny"?"Deny":"Default"}function vg(a){const{view:n,disabled:r}=a,i=n.control;if(i.kind==="absent")return e.jsx("div",{className:"af-matrix__cell is-absent",title:n.reason||void 0,children:e.jsx("span",{className:"af-matrix__cell-mark",children:"—"})});if(i.kind==="blocked")return e.jsxs("div",{className:`af-matrix__cell is-unavailable is-${i.blocked_kind}`,children:[e.jsx("span",{className:"af-matrix__cell-mark",children:"✕"}),e.jsx("span",{className:"af-matrix__cell-note",children:i.blocked_kind==="trust"?"blocked":"structural"}),n.reason?e.jsx("span",{className:"af-matrix__cell-reason",children:n.reason}):null]});if(i.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"}),n.reason?e.jsx("span",{className:"af-matrix__cell-reason",children:n.reason}):null]});const l=n.cell,u=n.effective_value===null?"server default (unknown until saved)":n.effective_value?"on":"off";return e.jsxs("div",{className:`af-matrix__cell ${n.effective_value===null?"is-indeterminate":n.effective_value?"is-on":"is-off"} ${n.pending?"is-pending":""}`.trim(),title:n.reason||void 0,children:[e.jsx("div",{className:"af-matrix__tristate",role:"group","aria-label":a.cellLabel,children:i.options.map(m=>e.jsx("button",{type:"button","aria-pressed":i.active_op===m,className:`af-matrix__tri-btn is-${m} ${i.active_op===m?"is-active":""}`.trim(),disabled:r,onClick:()=>a.onAct(m),children:yg(m)},m))}),e.jsxs("div",{className:"af-matrix__cell-meta",children:[e.jsx("span",{className:`af-matrix__prov is-${l.provenance}`,children:n.pending?"pending":l.provenance}),e.jsx("span",{className:"af-matrix__value-mark",children:u}),n.standing_config?e.jsx("span",{className:"af-matrix__standing",title:n.reason||"grant is stored; no executor consumes it yet",children:"standing config"}):null]})]})}function xg(a){const n=a.disabled===!0,r=h.useMemo(()=>Fh(a.payload),[a.payload]),i=h.useMemo(()=>r.ok?gg(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 l=r.payload,u=(m,d,p,b)=>{if(n)return;const v=_g(l,i,{section:m,item:d,phase:p,op:b});a.onPatchesChange(v)};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,i.length>0?e.jsxs("div",{className:"af-matrix__pending-note",children:[i.length," unsaved change",i.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"}),l.phases.map(m=>e.jsxs("th",{className:"af-matrix__phase",title:m.hint||void 0,children:[e.jsx("span",{className:"af-matrix__phase-label",children:m.label||m.id}),m.hint?e.jsx("span",{className:"af-matrix__phase-hint",children:m.hint}):null]},m.id))]})}),l.sections.map(m=>e.jsxs("tbody",{className:"af-matrix__section",children:[e.jsx("tr",{className:"af-matrix__section-row",children:e.jsx("th",{className:"af-matrix__section-label",colSpan:l.phases.length+1,children:m.label||m.id})}),m.items.map(d=>e.jsxs("tr",{className:"af-matrix__item-row",children:[e.jsx("th",{className:"af-matrix__item",title:d.description||void 0,children:e.jsx("span",{className:"af-matrix__item-name",children:d.label||d.id})}),l.phases.map(p=>{const b=zd(l,i,m.id,d.id,p.id);return e.jsx("td",{className:"af-matrix__cell-td",children:e.jsx(vg,{view:b,cellLabel:`${d.label||d.id} — ${p.label||p.id}`,disabled:n,onAct:v=>u(m.id,d.id,p.id,v)})},p.id)})]},d.id)),m.items.length===0?e.jsx("tr",{children:e.jsx("td",{className:"af-matrix__empty",colSpan:l.phases.length+1,children:"No entries in this section."})}):null]},m.id))]})})]})}async function gd(a=Ri){const n=await fetch(a),r=await n.json().catch(()=>null);if(!n.ok){const i=r&&typeof r=="object"&&r.detail?String(r.detail):`HTTP ${n.status}`;throw new Error(i)}return r}async function bg(a,n=Ri){const r=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),i=await r.json().catch(()=>null);if(!r.ok){const l=i&&typeof i=="object"&&i.detail?String(i.detail):`HTTP ${r.status}`;throw new Error(l)}return i}async function qh(a=Ri){const n=await fetch(a,{method:"DELETE"});if(!n.ok){const r=await n.json().catch(()=>({})),i=r&&typeof r=="object"&&r.detail?String(r.detail):`HTTP ${n.status}`;throw new Error(i)}}function Ku(a){let n=String(a||"").trim();for(let r=0;r<2&&n;r+=1){try{const u=JSON.parse(n);if(typeof u=="string"&&u!==n){n=u.trim();continue}}catch{}const i=n[0],l=n[n.length-1];if(i==='"'&&l==='"'||i==="'"&&l==="'"){n=n.slice(1,-1).trim();continue}break}return n.replace(/\/+$/,"")}function wg(a){var u,m;if(!a)return{label:"Signed out",tone:"warn"};if(!a.has_session)return{label:"Signed out",tone:"warn"};const n=a.gateway||{},r=(u=n.principal)==null?void 0:u.user_id,i=(m=n.principal)==null?void 0:m.runtime_id;if(n.ok&&r)return{label:`Signed in as ${r}${i?` · runtime ${i}`:""}`,tone:"ok"};if(n.ok)return{label:"Signed in",tone:"ok"};const l=n.error||n.detail;return typeof l=="string"&&l.trim()?{label:"Session rejected — sign in again",tone:"err"}:{label:"Sign in required",tone:"err"}}function jg(a){const n=a.connectionPath||Ri,[r,i]=h.useState(!1),[l,u]=h.useState(!1),[m,d]=h.useState(null),[p,b]=h.useState(!1);h.useEffect(()=>{a.isOpen||b(!1)},[a.isOpen]);const[v,y]=h.useState(a.defaultGatewayUrl||"http://127.0.0.1:8080"),[C,L]=h.useState("admin"),[T,$]=h.useState(""),[E,I]=h.useState(!1),[D,O]=h.useState(!0),[q,A]=h.useState(""),[H,fe]=h.useState(""),ie=h.useMemo(()=>wg(m),[m]),Se=G=>{var te;d(G),(te=a.onStatusChange)==null||te.call(a,G)},ke=h.useRef(!1);if(h.useEffect(()=>{var te;if(!a.isOpen)return;const G=!ke.current;if(ke.current=!0,G&&a.initialStatus!==void 0&&a.initialStatus!==null){const ae=a.initialStatus;Se(ae),typeof ae.gateway_url=="string"&&ae.gateway_url.trim()&&y(Ku(ae.gateway_url));const U=(te=ae.gateway)==null?void 0:te.principal;U!=null&&U.user_id&&L(U.user_id);return}i(!0),A(""),gd(n).then(ae=>{var Q;Se(ae),typeof ae.gateway_url=="string"&&ae.gateway_url.trim()&&y(Ku(ae.gateway_url));const U=(Q=ae.gateway)==null?void 0:Q.principal;U!=null&&U.user_id&&L(U.user_id)}).catch(ae=>A(`Failed to load connection status: ${String((ae==null?void 0:ae.message)||ae)}`)).finally(()=>i(!1))},[a.isOpen]),h.useEffect(()=>{if(!a.isOpen)return;const G=te=>{te.key==="Escape"&&!te.defaultPrevented&&!a.blocking&&(te.preventDefault(),a.onClose())};return window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)},[a.isOpen,a.blocking,a.onClose]),!a.isOpen||p)return null;const le=async()=>{u(!0),A(""),fe("");try{const G=Ku(v);y(G);const te=await bg({gateway_url:G,gateway_user_id:C,gateway_token:T,persist:D},n);Se(te),$(""),b(!0),a.onClose()}catch(G){A(String((G==null?void 0:G.message)||G))}finally{u(!1)}},pe=async()=>{u(!0),A(""),fe("");try{await qh(n),$("");const G=await gd(n).catch(()=>null);Se(G),fe("Signed out. This browser no longer holds a gateway session.")}catch(G){A(String((G==null?void 0:G.message)||G))}finally{u(!1)}};return e.jsx("div",{className:"af-connect-overlay",role:"presentation",onMouseDown:G=>{!a.blocking&&G.target===G.currentTarget&&a.onClose()},children:e.jsx("div",{className:"af-connect-modal",role:"dialog","aria-modal":"true","aria-label":"Gateway connection",children:e.jsx(J_,{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:ie.label,statusTone:ie.tone,showGatewayUrl:!0,gatewayUrl:v,onGatewayUrlChange:G=>y(G),userId:C,onUserIdChange:L,token:T,tokenPlaceholder:m!=null&&m.has_session?"(browser session already signed in)":"Paste Gateway user token",showToken:E,onTokenChange:$,onShowTokenChange:I,remember:D,rememberLabel:"Keep this browser signed in",onRememberChange:O,loading:r,submitting:l,submittingLabel:"Signing in...",showClose:!a.blocking,onClose:a.onClose,showSignOut:!a.blocking&&!!(m!=null&&m.has_session),onSignOut:pe,error:q,message:H,onSubmit:le})})})}function kg(a){return!!(a&&a.ok===!0&&a.has_session===!0)}function Sg(a){const n=a||{},r=n.connectionPath||Ri,i=n.variant||"dismissable",l=h.useRef(n.onStatusChange);l.current=n.onStatusChange;const u=h.useRef(i);u.current=i;const m=h.useRef(!!n.autoOpenMidSession);m.current=!!n.autoOpenMidSession;const[d,p]=h.useState(null),[b,v]=h.useState("loading"),[y,C]=h.useState(!1),L=h.useRef(!1),T=h.useRef(!1),$=h.useRef("loading"),E=h.useRef("none"),I=h.useRef(!1),D=h.useRef(0),O=h.useCallback(te=>{var U;D.current+=1,p(te),(U=l.current)==null||U.call(l,te);const ae=kg(te);if(ae)v("connected"),$.current="connected",L.current=!1,E.current="none",T.current||C(!1);else if(te!==null){const Q=$.current;v("disconnected"),$.current="disconnected",Q!=="disconnected"&&(E.current=I.current?"signout":Q==="connected"?"mid":"boot");const M=u.current==="blocking"||E.current!=="mid"||m.current;!L.current&&M&&C(!0)}te!==null&&(T.current=ae)},[]),q=h.useCallback(async()=>{const te=D.current;try{const ae=await gd(r);if(D.current!==te)return;O(ae)}catch{if(D.current!==te)return;O(null)}},[r,O]),[A,H]=h.useState(!1),[fe,ie]=h.useState(null),Se=h.useCallback(async()=>{H(!0),ie(null),D.current+=1;let te=null;try{await qh(r)}catch(ae){te=String((ae==null?void 0:ae.message)||ae||"Sign-out request failed")}I.current=!0;try{await q()}finally{I.current=!1}ie(te),H(!1)},[r,q]),ke=h.useRef(!1);h.useEffect(()=>{ke.current||(ke.current=!0,q())},[q]);const le=h.useCallback(()=>{C(!0)},[]),pe=h.useCallback(()=>{const te=$.current;i==="blocking"&&te==="disconnected"||(te==="disconnected"&&(L.current=!0),C(!1))},[i]),G=h.useMemo(()=>({isOpen:y,onClose:pe,blocking:i==="blocking"&&b!=="connected",appName:n.appName,connectionPath:r,defaultGatewayUrl:n.defaultGatewayUrl,initialStatus:d,onStatusChange:O}),[y,pe,i,b,n.appName,r,n.defaultGatewayUrl,d,O]);return{status:d,phase:b,connected:b==="connected",modalOpen:y,signingOut:A,signOutError:fe,openModal:le,refresh:q,signOut:Se,modalProps:G}}function Ng(){return globalThis.crypto}function Cg(a){if(a.length<16)throw new Error("uuidV4FromBytes: needs 16 bytes");const n=Array.from(a.subarray(0,16));n[6]=n[6]&15|64,n[8]=n[8]&63|128;const r=n.map(i=>i.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 Jo(){const a=Ng();if(a&&typeof a.randomUUID=="function")try{return a.randomUUID()}catch{}if(a&&typeof a.getRandomValues=="function")return Cg(a.getRandomValues(new Uint8Array(16)));throw new Error("randomId: Web Crypto (crypto.getRandomValues) is unavailable")}function Id(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 Ju={neutral:"var(--text-secondary)",muted:"var(--text-muted)",accent:"var(--accent)",info:"var(--info)",success:"var(--success)",warning:"var(--warning)",error:"var(--error)"},$g=/^var\(--[a-z0-9-]+\)$/i;function Eg(a,n){const r=a||"neutral";if(r==="custom"){const i=String(n||"").trim();return $g.test(i)?i:Ju.neutral}return Ju[r]||Ju.neutral}function Tg(a,n,r){return[a,`${a}--${n.tone||"neutral"}`,n.size==="sm"?`${a}--sm`:"",r||"",n.className||""].filter(Boolean).join(" ")}function Ag(a){return{"--af-chip-hue":Eg(a.tone,a.hue)}}function Hn(a){return e.jsxs("span",{className:Tg("af-chip",a,a.onRemove?"af-chip--removable":""),style:Ag(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:n=>{var r;n.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 yd(a){const n=a.closeOnEscape!==!1,r=h.useRef(null);return h.useEffect(()=>{if(!a.open||!n)return;const i=l=>{l.key!=="Escape"||l.defaultPrevented||(l.preventDefault(),a.onClose())};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[a.open,n,a.onClose]),h.useEffect(()=>{const i=r.current;i&&(a.open?i.removeAttribute("inert"):i.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 Lg={name:"AbstractFramework",website:"https://abstractframework.ai",github_org:"https://github.com/lpalbou",author:"Laurent-Philippe Albou, PhD",years:"2023-2026",license:"MIT",copyright:"© 2023-2026 Laurent-Philippe Albou, PhD. Released under the MIT License.",contact_email:"contact@abstractframework.ai"},Rg={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"}},Mg={framework:Lg,apps:Rg},Sc=Mg;function Uh(){return{...Sc.framework}}function Pg(){return Object.keys(Sc.apps).sort()}function zg(a,n){const r=Object.prototype.hasOwnProperty.call(Sc.apps,a)?Sc.apps[a]:void 0;if(!r)throw new Error(`appIdentity: unknown application id "${a}" (known: ${Pg().join(", ")})`);return{id:a,name:r.name,version:n,website:r.website,repo:r.repo,docs:r.docs,issues:r.issues,feedback:r.feedback}}function Ci(a){return typeof a=="string"?a.trim():""}function If(a,n){if(n!=null)return{framework:null,gateway:null,gatewayNote:`unavailable (${String(n).trim()||"unknown error"})`};const r=a&&typeof a=="object"&&!Array.isArray(a)?a:{},i=Ci(r.abstractgateway),l=Ci(r.abstractframework);return{framework:l||null,gateway:i||null,...i&&!l?{frameworkNote:"not installed on the gateway host"}:{},...i?{}:{gatewayNote:"unavailable (the gateway did not report its version)"}}}function Ig(a){const n=Uh();return[{id:"website",label:"Website",href:a.website,title:a.website},{id:"source",label:"Source",href:a.repo,title:a.repo},{id:"docs",label:"Docs",href:a.docs,title:a.docs},{id:"issues",label:"Issues",href:a.issues,title:a.issues},{id:"feedback",label:"Feedback",href:a.feedback,title:a.feedback},{id:"contact",label:"Contact",href:`mailto:${n.contact_email}`,title:n.contact_email}]}function Dg(a){const n=a||{},r=Ci(n.framework),i=Ci(n.gateway);return[["AbstractFramework",r||Ci(n.frameworkNote)||"not reported"],["AbstractGateway",i||Ci(n.gatewayNote)||"not connected"]]}const Og='a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])';function Fg(a,n,r){if(a.key!=="Tab"||!n)return;const i=Array.from(n.querySelectorAll(Og));if(i.length===0){a.preventDefault();return}const l=i[0],u=i[i.length-1],m=!!r&&n.contains(r);a.shiftKey?(r===l||!m)&&(a.preventDefault(),u.focus()):(r===u||!m)&&(a.preventDefault(),l.focus())}function qg(a){const n=Uh();return e.jsxs("div",{className:`af-about-card${a.className?` ${a.className}`:""}`,"data-app":a.identity.id,children:[e.jsxs("div",{className:"af-about-card__head",children:[e.jsxs("h2",{className:"af-about-card__name",id:a.titleId,children:[a.identity.name," ",e.jsx("span",{className:"af-about-card__version",children:a.identity.version})]}),a.action]}),e.jsx("dl",{className:"af-about-card__versions",children:Dg(a.versions).map(([r,i])=>e.jsxs("div",{className:"af-about-card__fact",children:[e.jsx("dt",{children:r}),e.jsx("dd",{children:i})]},r))}),e.jsx("nav",{className:"af-about-card__links","aria-label":`${a.identity.name} links`,children:Ig(a.identity).map(r=>r.href.startsWith("mailto:")?e.jsx("a",{className:"af-about-card__link","data-link":r.id,href:r.href,title:r.title,children:r.label},r.id):e.jsx("a",{className:"af-about-card__link","data-link":r.id,href:r.href,title:r.title,target:"_blank",rel:"noopener noreferrer",children:r.label},r.id))}),e.jsx("p",{className:"af-about-card__legal",children:n.copyright})]})}function Ug(a){Pd();const n=h.useRef(null),r=h.useRef(null),i=h.useId(),l=h.useRef(a.onClose);return l.current=a.onClose,h.useEffect(()=>{var d;if(!a.open)return;const u=document.activeElement;(d=n.current)==null||d.focus();const m=p=>{if(!p.defaultPrevented){if(p.key==="Escape"){p.preventDefault(),l.current();return}Fg(p,r.current,document.activeElement)}};return window.addEventListener("keydown",m),()=>{window.removeEventListener("keydown",m),u&&typeof u.focus=="function"&&u.focus()}},[a.open]),a.open?e.jsx("div",{className:"af-appearance-overlay af-about-overlay",onClick:a.onClose,role:"presentation",children:e.jsx("div",{ref:r,className:"af-appearance af-about",role:"dialog","aria-modal":"true","aria-labelledby":i,onClick:u=>u.stopPropagation(),children:e.jsx(qg,{identity:a.identity,versions:a.versions,titleId:i,action:e.jsx("button",{ref:n,type:"button",className:"af-about-card__close","data-action":"close-about",onClick:a.onClose,"aria-label":"Close","data-af-tip":"Close About",children:e.jsx(He,{name:"x",size:16})})})})}):null}function Bg(a){const{connection:n}=a,r=n.phase,i=n.signingOut===!0,[l,u]=h.useState(!1);Pd();const m=a.about,d=i?"Signing out…":r==="connected"?"Disconnect":r==="loading"?"Connecting…":"Connect",p=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.docs?e.jsx("button",{type:"button",className:`af-topbar__btn af-topbar__btn--docs${a.docs.open?" is-active":""}`,"aria-pressed":a.docs.open,"aria-label":a.docs.label||"Docs assistant","data-af-tip":a.docs.label||"Docs assistant",onClick:a.docs.onToggle,children:e.jsx(He,{name:"book",size:16})}):null,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","data-af-tip":a.assistant.label||"Assistant",onClick:a.assistant.onToggle,children:e.jsx(He,{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)","data-af-tip":a.appearance.label||"Appearance (theme and text size)",onClick:a.appearance.onOpen,children:e.jsx(He,{name:"contrast",size:16})}):null,m?e.jsx("button",{type:"button",className:"af-topbar__btn af-topbar__btn--about","aria-label":m.label||`About ${m.identity.name}`,"data-af-tip":m.label||`About ${m.identity.name}`,"aria-haspopup":"dialog",onClick:()=>{var b;u(!0),(b=m.onOpen)==null||b.call(m)},children:e.jsx(He,{name:"info",size:16})}):null,a.extraActions,e.jsxs("button",{type:"button",className:`af-topbar__pill af-topbar__pill--${r}`,onClick:r==="connected"?n.onDisconnect:n.onConnect,disabled:i,title:p,"aria-label":p,children:[e.jsx("span",{className:`af-topbar__dot af-topbar__dot--${r}`,"aria-hidden":"true"}),e.jsx("span",{className:"af-topbar__pill-label",children:d})]}),m?e.jsx(Ug,{open:l,onClose:()=>u(!1),identity:m.identity,versions:m.versions}):null]})}const wc={theme:"dark",font_scale:"md",header_density:"standard"};function Wg(a){const n=a&&typeof a=="object"?a:{};return{theme:typeof n.theme=="string"&&n.theme?n.theme:wc.theme,font_scale:typeof n.font_scale=="string"&&n.font_scale?n.font_scale:wc.font_scale,header_density:typeof n.header_density=="string"&&n.header_density?n.header_density:wc.header_density}}function Hg(a){return`af_appearance_${a}_v1`}function Vg(a,n){const r=Hg(a),i=h.useMemo(()=>({...wc}),[JSON.stringify({})]),[l,u]=h.useState(()=>{let m=i;try{const d=localStorage.getItem(r)??(n!=null&&n.legacyKey?localStorage.getItem(n.legacyKey):null);d&&(m=Wg({...i,...JSON.parse(d)}))}catch{}try{Af(m.theme),Lf({font_scale:m.font_scale,header_density:m.header_density})}catch{}return m});return h.useEffect(()=>{Af(l.theme),Lf({font_scale:l.font_scale,header_density:l.header_density});try{localStorage.setItem(r,JSON.stringify(l))}catch{}},[r,l]),[l,u]}function Gg(a){return h.useEffect(()=>{if(!a.open)return;const n=r=>{r.key!=="Escape"||r.defaultPrevented||(r.preventDefault(),a.onClose())};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[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:n=>n.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(Y_,{value:a.value.theme,onChange:n=>a.onChange({...a.value,theme:n})}),e.jsx("label",{className:"af-appearance__label",children:"Font size"}),e.jsx(X_,{value:a.value.font_scale,onChange:n=>a.onChange({...a.value,font_scale:n})}),e.jsx("label",{className:"af-appearance__label",children:"Header size"}),e.jsx(Z_,{value:a.value.header_density,onChange:n=>a.onChange({...a.value,header_density:n})})]}),e.jsx("div",{className:"af-appearance__actions",children:e.jsx("button",{type:"button",className:"af-appearance__close",onClick:a.onClose,children:"Close"})})]})}):null}const Bh=()=>{var a;return(a=globalThis.navigator)==null?void 0:a.mediaDevices};function Kg(a){var l;const n=Id("the microphone");if(n)return n;const r=String((a==null?void 0:a.name)||"");if(r==="NotAllowedError"||r==="SecurityError"||r==="PermissionDeniedError")return"The browser blocked the microphone. Allow it for this site (the icon left of the address), then try again.";if(r==="NotFoundError"||r==="DevicesNotFoundError")return"No microphone was found. Connect one, then try again.";if(r==="OverconstrainedError")return"The chosen microphone is not connected. Pick another one in Settings → Voice.";if(r==="NotReadableError"||r==="TrackStartError")return"Another app is using the microphone. Close it, then try again.";if(!((l=Bh())!=null&&l.getUserMedia))return"This browser cannot record audio.";const i=String((a==null?void 0:a.message)||a||"").trim();return i?`The microphone did not start: ${i.replace(/\.$/,"")}.`:"The microphone did not start."}async function Jg(a){const n=Bh();if(!(n!=null&&n.getUserMedia))throw Object.assign(new Error("This browser cannot record audio."),{name:"NotSupportedError"});return n.getUserMedia({audio:a?{deviceId:{exact:a}}:!0})}function Qg(){const a=globalThis;return a.AudioContext||a.webkitAudioContext||null}function Yg(){const a=Qg();return!!(a&&a.prototype&&typeof a.prototype.createMediaStreamDestination=="function")}function Xg(a){const n=Number(a);return a==null||a===""||!Number.isFinite(n)?1:Math.min(1,Math.max(0,n))}async function*Zg(a){var i,l,u;const n=new AbortController,r=()=>n.abort();(i=a.signal)!=null&&i.aborted?r():(l=a.signal)==null||l.addEventListener("abort",r,{once:!0});try{const m=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:n.signal});if(!m.ok){const v=await m.json().catch(()=>null),y=v&&typeof v=="object"&&v.detail?String(v.detail):`HTTP ${m.status}`;throw new Error(y)}if(!m.body)throw new Error("TTS stream has no body");const d=m.body.getReader(),p=new TextDecoder;let b="";for(;;){const{done:v,value:y}=await d.read();b+=v?p.decode():p.decode(y,{stream:!0}),v&&b.trim()&&(b+=`
42
+ `);let C;for(;(C=b.indexOf(`
43
+ `))>=0;){const L=b.slice(0,C).trim();if(b=b.slice(C+1),!L)continue;let T=null;try{T=JSON.parse(L)}catch{throw new Error("TTS stream returned invalid JSON.")}if(T&&T.type==="error")throw new Error(String(T.error||"TTS stream error"));const $=T&&typeof T.audio_b64=="string"?T.audio_b64:"";if($){const E=atob($),I=new Uint8Array(E.length);for(let D=0;D<E.length;D+=1)I[D]=E.charCodeAt(D);yield I.buffer}if(T&&(T.type==="done"||T.type==="cancelled"))return}if(v)throw new Error("TTS stream ended before synthesis completed.")}}finally{(u=a.signal)==null||u.removeEventListener("abort",r),n.abort()}}function Ro(a,n){const r=String((n==null?void 0:n.message)||n||"").trim().replace(/\.$/,"");return r?`${a}: ${r}.`:`${a}.`}const ey=350;function ty(){var n;if(typeof window>"u")return!1;const a=navigator;return!!((n=a==null?void 0:a.mediaDevices)!=null&&n.getUserMedia)&&typeof window.MediaRecorder=="function"}function ny(){if(typeof window>"u")return!1;const a=window;return!!(a!=null&&a.AudioContext||a!=null&&a.webkitAudioContext)}function sy(){const a=window.MediaRecorder,n=i=>{var l;try{return!!((l=a==null?void 0:a.isTypeSupported)!=null&&l.call(a,i))}catch{return!1}},r=["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/ogg;codecs=opus","audio/ogg"];for(const i of r)if(n(i))return i;return""}async function Qu(a,n){var l;const r=n.slice(0),i=(l=a.decodeAudioData)==null?void 0:l.bind(a);if(typeof i!="function")throw new Error("decodeAudioData not available");try{const u=i(r);if(u&&typeof u.then=="function")return await u}catch{}return await new Promise((u,m)=>{try{i(r,u,m)}catch(d){m(d)}})}function ay(a){const n=new Uint8Array(a);if(n.length<44)return null;const r=u=>String.fromCharCode(n[u],n[u+1],n[u+2],n[u+3]);if(r(0)!=="RIFF"||r(8)!=="WAVE")return null;const i=new DataView(a);let l=12;for(;l+8<=n.length;){const u=r(l),m=i.getUint32(l+4,!0);if(u==="data")return n.slice(0,l+8);l+=8+m+m%2}return null}function ry(a,n){const r=new Uint8Array(n),i=new Uint8Array(a.length+r.length);i.set(a,0),i.set(r,a.length);const l=new DataView(i.buffer);return l.setUint32(4,i.length-8,!0),l.setUint32(a.length-4,r.length,!0),i.buffer}const uc=new WeakMap;function iy(a,n){const r=a;if(!(typeof r.setSinkId!="function"||uc.get(a)===n)){uc.set(a,n);try{Promise.resolve(r.setSinkId(n)).catch(()=>uc.delete(a))}catch{uc.delete(a)}}}function Wh(a){const n=h.useRef(a);n.current=a;const r=W=>{var X,ge;return(ge=(X=n.current).on_error)==null?void 0:ge.call(X,W)},i=h.useMemo(()=>ny()&&(typeof a.tts=="function"||typeof a.tts_stream=="function"),[a.tts,a.tts_stream]),l=h.useMemo(()=>ty()&&typeof a.transcribe=="function",[a.transcribe]),[u,m]=h.useState({key:"",status:"idle"}),d=h.useRef(u),p=h.useCallback(W=>{d.current=W,m(X=>X.key===W.key&&X.status===W.status?X:W)},[]),b=h.useRef(""),v=h.useRef(""),y=h.useRef(null),C=h.useRef(null),L=h.useRef(null),T=h.useRef(null),$=h.useRef(0),E=h.useRef(0),I=h.useRef(0),D=h.useRef(null),O=h.useRef([]),q=h.useRef(0),A=h.useRef(!0),H=h.useRef(!1),fe=()=>{try{const W=globalThis,X=(W==null?void 0:W.AudioContext)||(W==null?void 0:W.webkitAudioContext);if(!X)return null;if(!y.current){const B=new X,oe=B.createGain();oe.gain.value=1,oe.connect(B.destination),y.current=B,C.current=oe}const ge=y.current,Y=C.current;if(!ge||!Y)return null;iy(ge,n.current.output_device_id||""),Y.gain.value=Xg(n.current.volume);try{ge.state==="suspended"&&ge.resume()}catch{}return{ctx:ge,gain:Y}}catch{return null}},ie=h.useCallback(()=>{const W=L.current;if(L.current=null,!!W){try{W.onended=null}catch{}try{W.stop()}catch{}try{W.disconnect()}catch{}}},[]),Se=h.useCallback(()=>{var W;ie(),I.current+=1,(W=D.current)==null||W.abort(),D.current=null,O.current=[],q.current=0,A.current=!0,H.current=!1,v.current="",b.current="",T.current=null,$.current=0,E.current=0,p({key:"",status:"idle"})},[ie,p]);h.useEffect(()=>()=>{var W,X;Se();try{(W=C.current)==null||W.disconnect()}catch{}try{(X=y.current)==null||X.close()}catch{}y.current=null,C.current=null,T.current=null},[]);const ke=async(W,X,ge)=>{const Y=I.current,B=fe();if(!B)throw new Error("TTS playback is not supported in this browser");const{ctx:oe,gain:je}=B;try{oe.state==="suspended"&&await oe.resume()}catch{}if(Y!==I.current)return;ie();const Oe=oe.createBufferSource();Oe.buffer=X,Oe.connect(je);const se=Number.isFinite(Number(X.duration))?Number(X.duration):0,xe=Math.max(0,Math.min(Number(ge||0),se>0?Math.max(0,se-.01):0));E.current=oe.currentTime-xe,$.current=xe,L.current=Oe,b.current=W,Oe.onended=()=>{L.current===Oe&&(L.current=null,$.current=0,E.current=0,b.current="",p({key:"",status:"idle"}))},Oe.start(0,xe),p({key:W,status:"playing"})},le=(W,X)=>{if(X!==I.current)return;const ge=fe();if(!ge)return;const Y=O.current,B=q.current;if(B>=Y.length){A.current&&(b.current="",$.current=0,E.current=0,p({key:"",status:"idle"}));return}const oe=Y[B],{ctx:je,gain:Oe}=ge;ie();const se=je.createBufferSource();se.buffer=oe,se.connect(Oe);const xe=Number.isFinite(Number(oe.duration))?Number(oe.duration):0,ze=Math.max(0,Math.min(Number($.current||0),xe>0?Math.max(0,xe-.01):0));E.current=je.currentTime-ze,L.current=se,b.current=W,se.onended=()=>{X===I.current&&L.current===se&&(L.current=null,q.current=B+1,$.current=0,le(W,X))};try{je.state==="suspended"&&je.resume()}catch{}se.start(0,ze),p({key:W,status:"playing"})},pe=async(W,X,ge)=>{var Oe;const Y=fe();if(!Y){r==null||r("This browser cannot play spoken replies.");return}ie();const B=++I.current;(Oe=D.current)==null||Oe.abort();const oe=new AbortController;D.current=oe,O.current=[],q.current=0,A.current=!1,H.current=!1,T.current=null,$.current=0,E.current=0,b.current=W,v.current=W,p({key:W,status:"loading"}),r==null||r("");let je=null;try{for await(const se of ge(X,oe.signal)){if(B!==I.current)return;let xe;try{xe=await Qu(Y.ctx,se),je||(je=ay(se))}catch{if(!je)continue;try{xe=await Qu(Y.ctx,ry(je,se))}catch{continue}}if(B!==I.current)return;O.current.push(xe),!L.current&&!H.current&&(v.current="",le(W,B))}if(B!==I.current)return;if(A.current=!0,O.current.length===0){r==null||r("Reading aloud failed: the voice engine returned no audio."),Se();return}!L.current&&!H.current&&le(W,B)}catch(se){if(B!==I.current)return;r==null||r(Ro("Reading aloud failed",se)),Se()}finally{D.current===oe&&(D.current=null)}},G=h.useCallback(async(W,X)=>{var ze;const ge=String(W||"").trim(),Y=String(X||"").trim();if(!ge||!Y)return;const B=n.current.tts,oe=n.current.tts_stream;if(typeof B!="function"&&typeof oe!="function"){r==null||r("Reading aloud is not available on this gateway.");return}const je=fe();if(!je){r==null||r("This browser cannot play spoken replies.");return}const Oe=d.current,se=Oe.key===ge;if(se&&Oe.status==="playing"){if(L.current){const Ne=Math.max(0,je.ctx.currentTime-Number(E.current||0));$.current=Ne}else $.current=0;H.current=!0,ie(),p({key:ge,status:"paused"});return}if(se&&Oe.status==="paused"){if(O.current.length>0){r==null||r(""),H.current=!1,p({key:ge,status:"playing"}),le(ge,I.current);return}const Ne=T.current;if(Ne){r==null||r(""),H.current=!1;try{await ke(ge,Ne,$.current)}catch(Le){r==null||r(Ro("Reading aloud failed",Le)),p({key:"",status:"idle"})}return}}if(se&&Oe.status==="loading")return;if(typeof oe=="function"){await pe(ge,Y,oe);return}ie(),I.current+=1,(ze=D.current)==null||ze.abort(),D.current=null;const xe=I.current;O.current=[],q.current=0,A.current=!0,H.current=!1,T.current=null,$.current=0,E.current=0,b.current=ge,v.current=ge,p({key:ge,status:"loading"}),r==null||r("");try{const Ne=await B(Y);if(v.current!==ge||I.current!==xe)return;const Le=await Qu(je.ctx,Ne);if(v.current!==ge||I.current!==xe)return;T.current=Le,$.current=0,await ke(ge,Le,0)}catch(Ne){if(I.current!==xe)return;v.current===ge&&(v.current="",b.current="",p({key:"",status:"idle"})),r==null||r(Ro("Reading aloud failed",Ne))}},[]),[te,ae]=h.useState(!1),[U,Q]=h.useState(!1),M=h.useRef(!1),Z=h.useRef(l);Z.current=l;const ne=h.useCallback(W=>{M.current=W,ae(X=>X===W?X:W)},[]),k=h.useRef(!1),w=h.useRef(null),K=h.useRef(null),ve=h.useRef([]),he=h.useRef(""),z=h.useRef(0),be=h.useRef(!1),[Ae,De]=h.useState(0),Me=h.useRef(0),lt=h.useRef(null);function Ue(){var X,ge;try{(ge=(X=w.current)==null?void 0:X.getTracks)==null||ge.call(X).forEach(Y=>{try{Y.stop()}catch{}})}catch{}w.current=null;const W=lt.current;lt.current=null;try{W==null||W.close()}catch{}}const ct=h.useCallback(()=>{z.current+=1,be.current=!1;const W=K.current;if(W){W.onstop=null,W.ondataavailable=null,W.onerror=null;try{W.stop()}catch{}}K.current=null,Ue(),ne(!1),k.current=!1,Q(!1),De(0),ve.current=[]},[ne]);h.useEffect(()=>()=>ct(),[ct]);async function Xe(W,X){var oe,je;if(r==null||r(""),k.current)return;const ge=Me.current?Date.now()-Me.current:1/0;if(!W||!W.size||ge<ey){De(0),r==null||r("The recording was too short. Hold the microphone button while you speak, or tap it once to start and again to stop.");return}const Y=n.current.transcribe;if(typeof Y!="function"){r==null||r("Speech to text is not available on this gateway.");return}k.current=!0;const B=z.current;Q(!0),De(Date.now());try{const Oe=await Y(W,X),se=typeof Oe=="string"||!Oe?{text:String(Oe||"")}:Oe,xe=String(se.text||"").trim();if(B!==z.current)return;xe?(je=(oe=n.current).on_transcript)==null||je.call(oe,xe,{...se,text:xe}):r==null||r("Nothing was heard. Check the microphone in Settings → Voice (Test), then try again.")}catch(Oe){if(B===z.current){const se=String((Oe==null?void 0:Oe.message)||Oe||"").trim().replace(/\.$/,"");r==null||r(se?`Transcription failed: ${se}.`:"Transcription failed.")}}finally{B===z.current&&(k.current=!1,Q(!1),De(0))}}const dt=h.useCallback(async()=>{if(r==null||r(""),!Z.current){r==null||r(Id("the microphone")??"Voice recording is not supported in this browser (MediaRecorder/getUserMedia unavailable).");return}if(k.current||be.current||M.current||K.current)return;ve.current=[];const W=z.current;be.current=!0;try{const X=await Jg(n.current.input_device_id||"");if(W!==z.current){X.getTracks().forEach(je=>je.stop());return}w.current=X;const ge=sy();he.current=ge;let Y=X;const B=Number(n.current.input_gain??1);if(Number.isFinite(B)&&B>0&&B!==1&&Yg()){const je=globalThis.AudioContext||globalThis.webkitAudioContext,Oe=new je,se=Oe.createGain();se.gain.value=B;const xe=Oe.createMediaStreamDestination();Oe.createMediaStreamSource(X).connect(se),se.connect(xe),lt.current=Oe,Y=xe.stream}const oe=ge?new MediaRecorder(Y,{mimeType:ge}):new MediaRecorder(Y);K.current=oe,oe.ondataavailable=je=>{if(W===z.current)try{je!=null&&je.data&&ve.current.push(je.data)}catch{}},oe.onerror=()=>{W===z.current&&(r==null||r("Recording failed. Try again, or pick another microphone in Settings → Voice."))},oe.onstop=()=>{if(W===z.current){ne(!1),Ue(),K.current=null;try{const je=new Blob(ve.current,{type:he.current||""});Xe(je,he.current)}catch(je){r==null||r(Ro("The recording could not be prepared",je))}}},oe.start(),Me.current=Date.now(),De(Me.current),ne(!0)}catch(X){if(W!==z.current)return;Ue(),K.current=null,ne(!1),De(0),r==null||r(Kg(X))}finally{W===z.current&&(be.current=!1)}},[]),Ze=h.useCallback(()=>{const W=K.current;if(!(!M.current||!W)){ne(!1);try{W.stop()}catch(X){r==null||r(Ro("The recording could not stop",X))}}},[]);return h.useEffect(()=>{if(!te||n.current.stop_on_pointerup===!1)return;const W=()=>Ze();return window.addEventListener("pointerup",W),window.addEventListener("pointercancel",W),()=>{window.removeEventListener("pointerup",W),window.removeEventListener("pointercancel",W)}},[te]),{tts_supported:i,tts_playback:u,toggle_tts:G,stop_tts:Se,voice_ptt_supported:l,voice_ptt_recording:te,voice_ptt_busy:U,start_voice_ptt_recording:dt,stop_voice_ptt_recording:Ze,cancel_voice_ptt_recording:ct,voice_ptt_since:Ae}}const Hh=72;function oy(a,n=Hh){const r=Math.max(1,Math.floor(n)),i=new Array(r).fill(0),l=a.length;if(!l)return i;const u=l/r;let m=0;for(let d=0;d<r;d+=1){const p=Math.floor(d*u),b=Math.max(p+1,Math.floor((d+1)*u));let v=0;for(let y=p;y<b&&y<l;y+=1){const C=Math.abs(Number(a[y])||0);C>v&&(v=C)}i[d]=v,v>m&&(m=v)}return m<=0?i:i.map(d=>d/m)}function dc(a){if(typeof a!="number"||!Number.isFinite(a)||a<0)return"--:--";const n=Math.floor(a),r=Math.floor(n/3600),i=Math.floor(n%3600/60),l=String(n%60).padStart(2,"0");return r>0?`${r}:${String(i).padStart(2,"0")}:${l}`:`${i}:${l}`}function ly(a,n,r){return!(n>0)||!(r>0)?0:Math.min(r,Math.max(0,a/n*r))}function cy(a,n){const[r,i]=h.useState({peaks:n??null,note:""});return h.useEffect(()=>{if(n){i({peaks:n,note:""});return}let l=!0;i({peaks:null,note:""});const u=typeof window<"u"?window.AudioContext||window.webkitAudioContext:void 0;if(!a||!u||typeof fetch!="function"){i({peaks:null,note:"Waveform unavailable in this browser."});return}return(async()=>{let m=null;try{const d=await(await fetch(a)).arrayBuffer();m=new u;const p=await m.decodeAudioData(d);l&&i({peaks:oy(p.getChannelData(0)),note:""})}catch(d){l&&i({peaks:null,note:`Waveform unavailable: ${d instanceof Error?d.message:String(d)}`})}finally{m&&m.close().catch(()=>{})}})(),()=>{l=!1}},[a,n]),r}function uy(a){const n=h.useRef(null),r=h.useRef(null),[i,l]=h.useState(!1),[u,m]=h.useState(0),[d,p]=h.useState(null),[b,v]=h.useState(""),{peaks:y,note:C}=cy(a.src,a.peaks),L=y??new Array(Hh).fill(0),T=d&&d>0?Math.min(1,u/d):0,$=a.name?`Audio ${a.name}`:"Audio",E=h.useCallback(()=>{const q=n.current;q&&(q.paused?q.play().catch(A=>v(A instanceof Error?A.message:String(A))):q.pause())},[]),I=h.useCallback(q=>{const A=n.current;!A||!Number.isFinite(q)||(A.currentTime=q,m(q))},[]),D=q=>{var H;const A=(H=r.current)==null?void 0:H.getBoundingClientRect();!A||!d||I(ly(q-A.left,A.width,d))},O=q=>{if(!d)return;const A=q.key==="ArrowRight"||q.key==="ArrowUp"?5:q.key==="ArrowLeft"||q.key==="ArrowDown"?-5:0;A?(q.preventDefault(),I(Math.min(d,Math.max(0,u+A)))):q.key==="Home"?(q.preventDefault(),I(0)):q.key==="End"?(q.preventDefault(),I(d)):(q.key===" "||q.key==="Enter")&&(q.preventDefault(),E())};return e.jsxs("div",{className:`af-audio${a.className?` ${a.className}`:""}`,"data-playing":i?"true":"false",children:[e.jsx("audio",{ref:n,src:a.src,preload:"metadata",onPlay:()=>l(!0),onPause:()=>l(!1),onEnded:()=>l(!1),onTimeUpdate:q=>m(q.currentTarget.currentTime),onLoadedMetadata:q=>p(Number.isFinite(q.currentTarget.duration)?q.currentTarget.duration:null),onDurationChange:q=>p(Number.isFinite(q.currentTarget.duration)?q.currentTarget.duration:null),onError:()=>v("This audio cannot be played in this browser. Use Download to open it.")}),e.jsx("button",{type:"button",className:"af-audio__play","data-action":i?"pause-audio":"play-audio","aria-label":i?`Pause ${$}`:`Play ${$}`,title:i?"Pause":"Play",onClick:E,children:e.jsx(He,{name:i?"pause":"play",size:16})}),e.jsx("div",{ref:r,className:"af-audio__wave",role:"slider",tabIndex:0,"aria-label":`Seek in ${$}`,"aria-valuemin":0,"aria-valuemax":Math.round(d??0),"aria-valuenow":Math.round(u),"aria-valuetext":`${dc(u)} of ${dc(d)}`,title:C||void 0,"data-waveform":y?"decoded":"flat",onKeyDown:O,onPointerDown:q=>{var A,H;(H=(A=q.currentTarget).setPointerCapture)==null||H.call(A,q.pointerId),D(q.clientX)},onPointerMove:q=>{q.buttons&1&&D(q.clientX)},children:e.jsx("svg",{viewBox:`0 0 ${L.length*2} 32`,preserveAspectRatio:"none","aria-hidden":"true",focusable:"false",children:L.map((q,A)=>{const H=Math.max(1.5,q*30),fe=(A+.5)/L.length<=T;return e.jsx("rect",{className:fe?"af-audio__bar af-audio__bar--played":"af-audio__bar",x:A*2+.3,y:16-H/2,width:1.4,height:H,rx:.6},A)})})}),e.jsxs("span",{className:"af-audio__time","aria-hidden":"true",children:[dc(u)," / ",dc(d)]}),b?e.jsx("p",{className:"af-audio__error",role:"alert",children:b}):null]})}const qr=a=>new Set(a.split(/\s+/).filter(Boolean)),dy=qr("if else for while do switch case default break continue return function const let var class extends new this super import export from as async await try catch finally throw typeof instanceof in of void delete yield static public private protected interface type enum implements package struct fn impl trait pub use mod mut match loop where crate self Self func go defer chan map range select int long short char float double bool boolean string true false null nil undefined None True False namespace using template typename virtual override final abstract sealed record val object fun when is"),my=qr("def class return if elif else for while in not and or is import from as with try except finally raise pass break continue lambda yield global nonlocal assert del async await None True False self match case"),fy=qr("if then else elif fi for while do done case esac in function return export local readonly set unset echo exit source"),hy=qr("select from where insert into values update set delete create table index view drop alter add join left right inner outer on group by order having limit offset as and or not null is in like between union all distinct primary key foreign references default"),Df=qr("true false null yes no on off"),py={c:{line:["//"],block:["/*","*/"],strings:['"',"'","`"],keywords:dy},python:{line:["#"],strings:['"',"'"],triple:!0,keywords:my},shell:{line:["#"],strings:['"',"'"],keywords:fy},sql:{line:["--"],block:["/*","*/"],strings:["'",'"'],keywords:hy},data:{line:["#"],strings:['"',"'"],keywords:Df},json:{line:[],strings:['"'],keywords:Df},css:{line:[],block:["/*","*/"],strings:['"',"'"],keywords:qr("")},markup:{line:[],block:["<!--","-->"],strings:['"',"'"],keywords:qr("")}},_y={js:"c",mjs:"c",cjs:"c",jsx:"c",ts:"c",tsx:"c",java:"c",kt:"c",c:"c",h:"c",cc:"c",cpp:"c",hpp:"c",cs:"c",go:"c",rs:"c",swift:"c",scala:"c",dart:"c",php:"c",py:"python",pyi:"python",rb:"shell",sh:"shell",bash:"shell",zsh:"shell",fish:"shell",ps1:"shell",sql:"sql",yaml:"data",yml:"data",toml:"data",ini:"data",cfg:"data",conf:"data",env:"data",json:"json",jsonl:"json",css:"css",scss:"css",less:"css",html:"markup",htm:"markup",xml:"markup",svg:"markup",vue:"markup",javascript:"c",typescript:"c",rust:"c",python:"python",shell:"shell"};function gy(a){const n=String(a||"").trim().toLowerCase(),r=n.split("/").pop()||n;if(r==="dockerfile"||r==="makefile")return"shell";const i=r.lastIndexOf("."),l=i>=0?r.slice(i+1):r;return _y[l]||""}const yy=a=>a>="0"&&a<="9",vy=a=>/[A-Za-z_$]/.test(a),Of=a=>/[A-Za-z0-9_$]/.test(a);function xy(a,n){const r=String(a??""),i=py[n];if(!i)return r?[{kind:"plain",text:r}]:[];const l=[];let u="";const m=(p,b)=>{if(b){if(p==="plain"){u+=b;return}u&&l.push({kind:"plain",text:u}),u="",l.push({kind:p,text:b})}};let d=0;for(;d<r.length;){const p=r[d];if(i.line.find(v=>r.startsWith(v,d))){const v=r.indexOf(`
44
+ `,d),y=v===-1?r.length:v;m("comment",r.slice(d,y)),d=y;continue}if(i.block&&r.startsWith(i.block[0],d)){const v=r.indexOf(i.block[1],d+i.block[0].length),y=v===-1?r.length:v+i.block[1].length;m("comment",r.slice(d,y)),d=y;continue}if(i.strings.includes(p)){const v=i.triple&&r.startsWith(p.repeat(3),d)?p.repeat(3):"";if(v){const L=r.indexOf(v,d+3),T=L===-1?r.length:L+3;m("string",r.slice(d,T)),d=T;continue}let y=d+1;for(;y<r.length&&r[y]!==p&&(p==="`"||r[y]!==`
45
+ `);)y+=r[y]==="\\"?2:1;const C=Math.min(r.length,y+1);m("string",r.slice(d,C)),d=C;continue}if(yy(p)&&!(d>0&&Of(r[d-1]))){let v=d+1;for(;v<r.length&&/[0-9a-fA-FxXoObB._]/.test(r[v]);)v+=1;m("number",r.slice(d,v)),d=v;continue}if(vy(p)){let v=d+1;for(;v<r.length&&Of(r[v]);)v+=1;const y=r.slice(d,v),C=n==="sql"?i.keywords.has(y.toLowerCase()):i.keywords.has(y);m(C?"keyword":"plain",y),d=v;continue}m("plain",p),d+=1}return u&&l.push({kind:"plain",text:u}),l}const by=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Ho=6e4,Vo=60*Ho,mc=24*Vo;function Dd(a){if(a==null||a==="")return NaN;if(a instanceof Date)return a.getTime();if(typeof a=="number")return Number.isFinite(a)?a<1e12?a*1e3:a:NaN;const n=String(a).trim();return/^\d+(\.\d+)?$/.test(n)?Dd(Number(n)):Date.parse(n)}function Ff(a,n){const r=Dd(a);if(!Number.isFinite(r))return"";const i=new Date(r),l=i.getFullYear()===new Date(n).getFullYear();return`${by[i.getMonth()]} ${i.getDate()}${l?"":`, ${i.getFullYear()}`}`}function wy(a,n){const r=Dd(a);if(!Number.isFinite(r)||!Number.isFinite(n))return"";const i=n-r;if(i<0){const u=-i;if(u<Ho)return"due now";if(u<Vo)return`in ${Math.round(u/Ho)} min`;if(u<mc)return`in ${Math.round(u/Vo)} h`;const m=Math.round(u/mc);return m<7?`in ${m} ${m===1?"day":"days"}`:Ff(r,n)}if(i<Ho)return"just now";if(i<Vo)return`${Math.floor(i/Ho)} min ago`;if(i<mc)return`${Math.floor(i/Vo)} h ago`;const l=Math.floor(i/mc);return l===1?"yesterday":l<7?`${l} days ago`:Ff(r,n)}function jy(a){const n=String(a??"").trim();if(!n||!(n.startsWith("{")&&n.endsWith("}")||n.startsWith("[")&&n.endsWith("]")))return null;try{return JSON.parse(n)}catch{return null}}async function ln(a){var r;const n=String(a||"");if(!n)return!1;try{if(typeof navigator<"u"&&typeof((r=navigator.clipboard)==null?void 0:r.writeText)=="function")return await navigator.clipboard.writeText(n),!0}catch{}try{const i=document.createElement("textarea");i.value=n,i.style.position="fixed",i.style.left="-9999px",document.body.appendChild(i),i.select();const l=document.execCommand("copy")===!0;return document.body.removeChild(i),l}catch{return!1}}const ky=3,Sy=Number.MAX_SAFE_INTEGER;function Vh(a){return!!a&&typeof a=="object"&&!Array.isArray(a)}function Gh(a){return Array.isArray(a)}function Ny(a){if(a==null)return"";if(typeof a=="string")return a;try{return JSON.stringify(a,null,2)}catch{return String(a)}}function $i({kind:a,children:n}){return e.jsx("span",{className:`pc-json-token ${a}`,children:n})}function Cy(a){const n=JSON.stringify(a.value),r=n.length>96||n.includes("\\n")||n.includes("\\r")||n.includes("\\t"),[i,l]=h.useState(!r||a.expansionMode==="unfolded");return h.useEffect(()=>{r&&l(a.expansionMode==="unfolded")},[r,a.expansionMode,a.expansionVersion]),r?e.jsxs("span",{className:`pc-json-string ${i?"open":"collapsed"}`,children:[e.jsx("button",{type:"button",className:"pc-json-string__toggle",onClick:()=>l(u=>!u),"aria-label":i?"Collapse string value":"Expand string value","aria-expanded":i,children:i?"▾":"▸"}),i?e.jsx("span",{className:"pc-json-token string pc-json-string__value",children:n}):e.jsxs("button",{type:"button",className:"pc-json-string__preview",onClick:()=>l(!0),"aria-label":"Expand string value",children:[e.jsx("span",{className:"pc-json-token string pc-json-string__preview_text",children:n}),e.jsx("span",{className:"pc-json-string__suffix",children:"(...)"})]})]}):e.jsx($i,{kind:"string",children:n})}function $y(a,n,r){return a===null?e.jsx($i,{kind:"null",children:"null"}):typeof a=="string"?e.jsx(Cy,{value:a,expansionMode:n,expansionVersion:r}):typeof a=="number"?e.jsx($i,{kind:"number",children:String(a)}):typeof a=="boolean"?e.jsx($i,{kind:"boolean",children:a?"true":"false"}):e.jsx($i,{kind:"string",children:JSON.stringify(String(a))})}function Ey(a){return Gh(a)?a.length===1?"1 item":`${a.length} items`:Vh(a)?Object.keys(a).length===1?"1 key":`${Object.keys(a).length} keys`:""}function Kh(a){const{label:n,value:r,depth:i,collapseAfterDepth:l,expansionMode:u,expansionVersion:m,trailingComma:d}=a,p=i*14,b=Vh(r),v=Gh(r),y=b||v,C=i<l,[L,T]=h.useState(C);h.useEffect(()=>{T(C)},[C,m]);const $=n?e.jsxs(e.Fragment,{children:[e.jsx($i,{kind:"key",children:JSON.stringify(n)}),": "]}):null;if(!y)return e.jsxs("div",{className:"pc-json-viewer__line",style:{paddingLeft:p},children:[$,$y(r,u,m),d?",":""]});const E=v?"[":"{",I=v?"]":"}",D=Ey(r),O=L?`${E}`:`${E}…${I}${D?` (${D})`:""}`,q=v?r.map((A,H)=>({key:String(H),label:void 0,value:A})):Object.entries(r).map(([A,H])=>({key:A,label:A,value:H}));return e.jsxs("details",{className:"pc-json-viewer__details",open:L,onToggle:A=>T(A.currentTarget.open),children:[e.jsxs("summary",{className:"pc-json-viewer__summary",style:{paddingLeft:p},children:[$,e.jsx("span",{className:"pc-json-viewer__caret","aria-hidden":"true",children:L?"▾":"▸"}),e.jsx("span",{className:"pc-json-viewer__punct",children:O}),!L&&d?e.jsx("span",{className:"pc-json-viewer__punct",children:","}):null]}),L?e.jsx("div",{className:"pc-json-viewer__children",children:q.length===0?e.jsxs("div",{className:"pc-json-viewer__line",style:{paddingLeft:p},children:[e.jsx("span",{className:"pc-json-viewer__punct",children:I}),d?",":""]}):e.jsxs(e.Fragment,{children:[q.map((A,H)=>{const fe=H===q.length-1;return e.jsx(Kh,{label:A.label,value:A.value,depth:i+1,collapseAfterDepth:l,expansionMode:u,expansionVersion:m,trailingComma:!fe},`${i}:${n||"root"}:${A.key}`)}),e.jsxs("div",{className:"pc-json-viewer__line",style:{paddingLeft:p},children:[e.jsx("span",{className:"pc-json-viewer__punct",children:I}),d?",":""]})]})}):null]})}function Ty(a){const n=a.trim();if(!n)return a;if(n.startsWith("{")&&n.endsWith("}")||n.startsWith("[")&&n.endsWith("]"))try{return JSON.parse(n)}catch{return a}return a}function jc(a){const{value:n,className:r,showCopy:i=!0}=a,[l,u]=h.useState({mode:"folded",version:0}),[m,d]=h.useState("idle"),p=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):ky,b=l.mode==="unfolded"?Sy:p,v=h.useMemo(()=>typeof n=="string"?Ty(n):n,[n]),y=h.useMemo(()=>Ny(n),[n]),C=["pc-json-viewer",r].filter(Boolean).join(" ");h.useEffect(()=>{u(T=>({mode:"folded",version:T.version+1}))},[v]);const L=()=>{u(T=>({mode:T.mode==="unfolded"?"folded":"unfolded",version:T.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:L,"aria-expanded":l.mode==="unfolded",children:l.mode==="unfolded"?"Fold all":"Unfold all"}),i?e.jsx("button",{type:"button",className:"pc-btn pc-json-viewer__copy",onClick:()=>void ln(y).then(T=>{d(T?"copied":"failed"),window.setTimeout(()=>d("idle"),2e3)}),children:m==="copied"?"Copied":m==="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(Kh,{value:v,depth:0,collapseAfterDepth:b,expansionMode:l.mode,expansionVersion:l.version,trailingComma:!1})})]})}function Ay({code:a,lang:n}){const[r,i]=h.useState("idle"),l=h.useRef(null);h.useEffect(()=>()=>{l.current!==null&&window.clearTimeout(l.current)},[]);const u=xy(a,gy(n));return e.jsxs("div",{className:"pc-md_codeblock",children:[e.jsx("button",{type:"button",className:`pc-md_copy${r!=="idle"?` pc-md_copy--${r}`:""}`,"aria-label":"Copy code",title:r==="idle"?"Copy":r==="copied"?"Copied":"Copy failed",onClick:async()=>{const m=await ln(a);i(m?"copied":"failed"),l.current!==null&&window.clearTimeout(l.current),l.current=window.setTimeout(()=>i("idle"),900)},children:e.jsx(He,{name:r==="copied"?"check":"copy",size:14})}),e.jsx("pre",{className:"pc-md_pre",children:e.jsx("code",{className:n?`language-${n}`:void 0,children:u.map((m,d)=>m.kind==="plain"?e.jsx(Wt.Fragment,{children:m.text},d):e.jsx("span",{className:`af-code__${m.kind}`,children:m.text},d))})})]})}function Mo(a,n){const r=String(a??"");if(!n||!n.needles.length)return[r];const i=[],l=r.toLowerCase();let u=0;for(;u<r.length;){let m=-1,d="";for(let v=0;v<n.needlesLower.length;v++){const y=n.needlesLower[v];if(!y)continue;const C=l.indexOf(y,u);if(C===-1)continue;const L=n.needles[v]||"";L&&(m===-1||C<m||C===m&&L.length>d.length)&&(m=C,d=L)}if(m===-1||!d){i.push(r.slice(u));break}m>u&&i.push(r.slice(u,m));const p=n.hits===0&&n.id?n.id:void 0,b=r.slice(m,m+d.length);i.push(e.jsx("span",{id:p,className:n.className,children:b},`hl:${n.hits}`)),n.hits+=1,u=m+d.length}return i}function Jh(a){const n=String(a||"").trim();if(n&&/^(https?:|mailto:|tel:|#|\/)/i.test(n))return n}const vd="http://same-origin.invalid/";function Ly(a){try{const n=new URL(a,vd);return n.protocol==="http:"&&n.origin===new URL(vd).origin}catch{return!1}}function Qh(a){const n=String(a||"").trim();return Jh(n)??(n&&Ly(n)?n:void 0)}let Dr=null;function Ry(a){const n=String(a||"").trim();if(!n)return!1;const r=typeof document<"u"&&document.baseURI?document.baseURI:null;if(r===null&&/^[a-z][a-z0-9+.-]*:/i.test(n))return!1;const i=r??vd;let l,u;try{l=new URL(i).origin,u=new URL(n,i)}catch{return!1}return u.protocol!=="http:"&&u.protocol!=="https:"?!1:u.origin===l}function Yh(a,n,r){return e.jsx("a",{className:"pc-md_link pc-md_image_link",href:n,target:"_blank",rel:"noopener noreferrer",children:`image: ${r||n}`},a)}function qf(a){return!!a&&/[\p{L}\p{N}]/u.test(a)}function pa(a,n){const r=[],i=String(a??"");let l=0,u="";const m=()=>{if(u){for(const d of Mo(u,n))r.push(d);u=""}};for(;l<i.length;){const d=i[l];if(d==="!"&&i[l+1]==="["){const p=i.indexOf("]",l+2);if(p!==-1&&i[p+1]==="("){const b=i.indexOf(")",p+2);if(b!==-1){const v=i.slice(l+2,p),y=Qh(i.slice(p+2,b));if(y&&Dr&&!Dr(y)){m(),r.push(Yh(`img:${l}`,y,v)),l=b+1;continue}if(y){m(),r.push(e.jsxs("span",{className:"pc-md_image_inline",children:[e.jsx("img",{className:"pc-md_img",src:y,alt:v,loading:"lazy"}),v?e.jsx("span",{className:"pc-md_img_caption",children:n?Mo(v,n):v}):null]},`img:${l}`)),l=b+1;continue}}}}if(d==="["){const p=i.indexOf("]",l+1);if(p!==-1&&i[p+1]==="("){const b=i.indexOf(")",p+2);if(b!==-1){const v=i.slice(l+1,p),y=Jh(i.slice(p+2,b));if(y){m(),r.push(e.jsx("a",{className:"pc-md_link",href:y,target:y.startsWith("#")?void 0:"_blank",rel:"noreferrer",children:pa(v,n)},`link:${l}`)),l=b+1;continue}}}}if(d==="`"){const p=i.indexOf("`",l+1);if(p!==-1){m();const b=i.slice(l+1,p);r.push(e.jsx("code",{children:n?Mo(b,n):b},`code:${l}`)),l=p+1;continue}}if(d==="_"&&!qf(i[l-1])){const p=i[l+1]==="_"?"__":"_",b=p.length;if(i[l+b]&&!/\s/.test(i[l+b])&&i[l+b]!=="_"){let v=i.indexOf(p,l+b);for(;v!==-1&&(/\s/.test(i[v-1]||" ")||qf(i[v+b])||b===1&&i[v+1]==="_");)v=i.indexOf(p,v+1);if(v!==-1&&v>l+b){m();const y=i.slice(l+b,v),C=pa(y,n);r.push(b===2?e.jsx("strong",{children:C},`ubold:${l}`):e.jsx("em",{children:C},`uem:${l}`)),l=v+b;continue}}}if(d==="*"&&i[l+1]==="*"){const p=i.indexOf("**",l+2);if(p!==-1){m();const b=i.slice(l+2,p);r.push(e.jsx("strong",{children:n?Mo(b,n):b},`bold:${l}`)),l=p+2;continue}}if(d==="*"&&i[l+1]!=="*"){const p=i.indexOf("*",l+1);if(p!==-1){m();const b=i.slice(l+1,p);r.push(e.jsx("em",{children:n?Mo(b,n):b},`em:${l}`)),l=p+1;continue}}u+=d,l+=1}return m(),r}function My(a){return String(a??"").replace(/\r\n/g,`
46
+ `).replace(/\r/g,`
47
+ `).split(`
48
+ `)}function kc(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 Py(a){const n=[];for(const l of a){const u=kc(l);u?n.push(u):n.length>0&&l.trim()&&(n[n.length-1].content+=` ${l.trim()}`)}const r=[],i=[];for(const l of n){for(;i.length>0&&l.indent<i[i.length-1].indent;)i.pop();let u=i.length>0?i[i.length-1]:null;if(u&&l.indent>u.indent){const m=u.node.items,d=m[m.length-1];if(d){const p={ordered:l.ordered,start:l.start,items:[]};d.children.push(p),i.push({indent:l.indent,node:p}),u=i[i.length-1]}}else if(u&&u.node.ordered!==l.ordered){i.pop();const m=i.length>0?i[i.length-1]:null,d={ordered:l.ordered,start:l.start,items:[]};if(m){const p=m.node.items,b=p[p.length-1];b?b.children.push(d):m.node.items.push({content:"",children:[d]})}else r.push(d);i.push({indent:l.indent,node:d}),u=i[i.length-1]}if(!u){const m={ordered:l.ordered,start:l.start,items:[]};r.push(m),i.push({indent:l.indent,node:m}),u=i[i.length-1]}u.node.items.push({content:l.content,children:[]})}return r}function Xh(a,n,r){const i=a.items.map((l,u)=>e.jsxs("li",{children:[pa(l.content,n),l.children.map((m,d)=>Xh(m,n,`${r}:${u}:${d}`))]},`${r}:li:${u}`));return a.ordered?e.jsx("ol",{className:"pc-md_ol",start:a.start!==1?a.start:void 0,children:i},r):e.jsx("ul",{className:"pc-md_ul",children:i},r)}function zy(a,n,r){return Py(a).map((i,l)=>Xh(i,n,`${r}:${l}`))}function Uf(a){let n=String(a??"").trim();return n?(n.startsWith("|")&&(n=n.slice(1)),n.endsWith("|")&&(n=n.slice(0,-1)),n.split("|").map(r=>String(r??"").trim())):[]}function Bf(a){let n=String(a??"").trim();if(!n)return!1;n.startsWith("|")&&(n=n.slice(1)),n.endsWith("|")&&(n=n.slice(0,-1));const r=n.split("|").map(i=>String(i??"").trim());return r.length<2?!1:r.every(i=>/^:?-{3,}:?$/.test(i))}const Wf=/^(#{1,5})\s+(.*)$/;function Hf(a){return a.trim().startsWith("```")}function Vf(a){return a.trimStart().startsWith(">")}function os(a){const n=Dr;Dr=a.images==="link"?a.inlineImage||Ry:null;try{return Iy(a)}finally{Dr=n}}function Iy({text:a,className:n,highlight:r,highlights:i,highlightClassName:l,highlightId:u}){const m=My(a),d=[],p=[];Array.isArray(i)&&p.push(...i),typeof r=="string"&&r.trim()&&p.push(r);const b=Array.from(new Set(p.map(L=>String(L??"").trim()).filter(Boolean))).filter(L=>L.length>=4),v=b.length?{needles:b,needlesLower:b.map(L=>L.toLowerCase()),className:l||"pc-md_hl",id:u,hits:0}:null;let y=0;for(;y<m.length;){const L=String(m[y]??"");if(!L.trim()){y+=1;continue}const T=L.trim();if(/^([-_*])(\s*\1){2,}$/.test(T)){d.push(e.jsx("hr",{className:"pc-md_hr"},`hr:${y}`)),y+=1;continue}const $=L.match(/^\s*!\[([^\]]*)\]\(([^)]+)\)\s*$/);if($){const D=Qh($[2]||"");if(D&&Dr&&!Dr(D)){d.push(e.jsx("p",{className:"pc-md_p",children:Yh(`img:${y}`,D,$[1]||"")},`p:${y}`)),y+=1;continue}if(D){const O=$[1]||"";d.push(e.jsxs("figure",{className:"pc-md_figure",children:[e.jsx("img",{className:"pc-md_img",src:D,alt:O,loading:"lazy"}),O?e.jsx("figcaption",{children:pa(O,v)}):null]},`figure:${y}`)),y+=1;continue}}if(Hf(L)){const O=L.trim().replace(/```/g,"").trim(),q=[];for(y+=1;y<m.length&&!String(m[y]??"").trim().startsWith("```");)q.push(String(m[y]??"")),y+=1;y<m.length&&(y+=1);const A=q.join(`
49
+ `);d.push(e.jsx(Ay,{code:A,lang:O},`pre:${y}`));continue}const E=L.match(Wf);if(E){const D=E[1].length,O=E[2]||"",q=pa(O,v);D===1?d.push(e.jsx("h1",{children:q},`h1:${y}`)):D===2?d.push(e.jsx("h2",{children:q},`h2:${y}`)):D===3?d.push(e.jsx("h3",{children:q},`h3:${y}`)):D===4?d.push(e.jsx("h4",{children:q},`h4:${y}`)):d.push(e.jsx("h5",{children:q},`h5:${y}`)),y+=1;continue}if(Vf(L)){const D=[];for(;y<m.length&&String(m[y]??"").trimStart().startsWith(">");){const q=String(m[y]??"").trimStart();D.push(q.replace(/^>\s?/,"")),y+=1}d.push(e.jsx("blockquote",{className:"pc-md_quote",children:D.map((O,q)=>e.jsxs(Wt.Fragment,{children:[pa(O,v),q<D.length-1?e.jsx("br",{}):null]},`q:${y}:${q}`))},`quote:${y}`));continue}if(L.includes("|")&&y+1<m.length&&Bf(String(m[y+1]??""))){const D=Uf(L),O=Math.max(1,D.length),q=[];for(y+=2;y<m.length;){const A=String(m[y]??"");if(!A.trim()||!A.includes("|"))break;const H=Uf(A),fe=[];for(let ie=0;ie<O;ie++)fe.push(H[ie]??"");q.push(fe),y+=1}d.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:D.slice(0,O).map((A,H)=>e.jsx("th",{children:pa(A,v)},`th:${y}:${H}`))})}),e.jsx("tbody",{children:q.map((A,H)=>e.jsx("tr",{children:A.map((fe,ie)=>e.jsx("td",{children:pa(fe,v)},`td:${y}:${H}:${ie}`))},`tr:${y}:${H}`))})]})},`table:${y}`));continue}if(kc(L)){const D=[];for(;y<m.length;){const O=String(m[y]??"");if(!O.trim()||O.trimStart().startsWith("```"))break;if(kc(O)||/^\s{2,}\S/.test(O)){D.push(O),y+=1;continue}break}d.push(e.jsx(Wt.Fragment,{children:zy(D,v,`list:${y}`)},`list:${y}`));continue}const I=[];for(;y<m.length&&String(m[y]??"").trim()&&!(I.length>0&&kc(String(m[y]??"")));){const D=String(m[y]??"");if(I.length>0&&(Wf.test(D)||Hf(D)||Vf(D))||I.length>0&&D.includes("|")&&y+1<m.length&&Bf(String(m[y+1]??"")))break;I.push(D),y+=1}d.push(e.jsx("p",{className:"pc-md_p",children:I.map((D,O)=>e.jsxs(Wt.Fragment,{children:[pa(D,v),O<I.length-1?e.jsx("br",{}):null]},`pl:${y}:${O}`))},`p:${y}`))}const C=["pc-md",n].filter(Boolean).join(" ");return e.jsx("div",{className:C,children:d})}function Dy(a){const n=String(a.text??""),r=h.useMemo(()=>jy(n),[n]),i=["pc-chat-content",a.className].filter(Boolean).join(" ");return r!==null?e.jsx("div",{className:i,children:e.jsx(jc,{value:r,collapseAfterDepth:a.jsonCollapseAfterDepth})}):a.renderMarkdown?e.jsx("div",{className:i,children:a.renderMarkdown(n)}):e.jsx("div",{className:i,children:e.jsx(os,{text:n,images:a.images,inlineImage:a.inlineImage})})}function Oy({sandbox:a,className:n}){return a?e.jsxs("div",{className:`pc-tool-sandbox is-${a.state}${n?` ${n}`:""}`,"data-sandbox-kind":a.kind,children:[e.jsx("div",{className:"pc-tool-sandbox__line",children:a.line}),a.rows.length?e.jsxs("ul",{className:"pc-tool-sandbox__rows","aria-label":"Workspaces the sandbox enforced",children:[a.rows.map((r,i)=>e.jsxs("li",{children:[e.jsx("code",{children:r.path}),e.jsx("span",{className:"pc-tool-sandbox__mode",children:r.private?`${r.mode} · this run's folder`:r.mode})]},`${r.mode}:${r.path}:${i}`)),a.builtinRefused?e.jsxs("li",{className:"pc-tool-sandbox__builtin",children:[a.builtinRefused," built-in protected ",a.builtinRefused===1?"folder":"folders"," refused"]}):null]}):null]}):null}function Zh(a){if(typeof a!="string")return a;try{return JSON.parse(a)}catch{return a}}function Fy(a){const n=Zh(a);if(!n||typeof n!="object"||Array.isArray(n))return{label:"input",value:n==null?"":String(n)};const r=Object.entries(n),l=["command","query","url","file_path","path","pattern","name"].map(u=>r.find(([m])=>m===u)).find(Boolean)||r[0];return l?{label:l[0].replace(/_/g," "),value:typeof l[1]=="string"?l[1]:JSON.stringify(l[1])??""}:{label:"",value:""}}function ep({tool:a,showCopy:n=!0}){const[r,i]=h.useState(!1),l=Zh(a.arguments),u=Fy(a.arguments),m=["file path","path"].includes(u.label)&&u.value.length>60?`${u.value.split(/[\\/]/).pop()} · ${u.value.slice(0,24)}…`:u.value,d=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,p={running:"Running",waiting:"Approval needed",completed:"Done",failed:"Failed"},b=a.startedAt&&a.endedAt?Date.parse(a.endedAt)-Date.parse(a.startedAt):NaN,v=l&&typeof l=="object"&&!Array.isArray(l)?Object.entries(l):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(He,{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:u.value,children:u.value?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"pc-tool-activity__key",children:u.label}),m]}):"No parameters"}),e.jsx("span",{className:"pc-tool-activity__status",children:p[a.status]}),Number.isFinite(b)&&b>=0?e.jsxs("span",{className:"pc-tool-activity__duration",children:[(b/1e3).toFixed(1),"s"]}):null,e.jsx("span",{className:"pc-tool-activity__chevron","aria-hidden":"true",children:e.jsx(He,{name:"chevronRight",size:13})}),a.error?e.jsx("span",{className:"pc-tool-activity__error",title:a.error,children:d}):null]}),e.jsxs("div",{className:"pc-tool-activity__detail",children:[e.jsx(Oy,{sandbox:a.sandbox}),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"}),n?e.jsxs("button",{type:"button",onClick:async()=>i(await ln(JSON.stringify(a,null,2))),children:[e.jsx(He,{name:"copy",size:13}),r?"Copied":"Copy details"]}):null]}),v?e.jsx("dl",{className:"pc-tool-activity__parameters",children:v.map(([y,C])=>e.jsxs(Wt.Fragment,{children:[e.jsx("dt",{children:y}),e.jsx("dd",{children:C&&typeof C=="object"?e.jsx(jc,{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(jc,{value:l}),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(jc,{value:a.output})})]}):null]})]})}function qy({tools:a,showCopy:n}){const r=i=>a.filter(l=>l.status===i).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(He,{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(i=>e.jsx(ep,{tool:i,showCopy:n},i.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 n=Math.round(a/1e3);return`${Math.floor(n/60)}m ${String(n%60).padStart(2,"0")}s`},tp=a=>a===void 0?xn:`${Math.round(a).toLocaleString()} tok/s`,Uy=(a,n)=>n>0?`${Math.round(a/n*100)}%`:"",Or=(a,n,r=`${n}s`)=>`${a.toLocaleString()} ${a===1?n:r}`,By=a=>{const n=a.split("#")[0].replace(/\/+$/,"");return n.slice(n.lastIndexOf("/")+1)||a};function Wy(a){const n=new Map;for(const r of a)r&&n.set(r,(n.get(r)||0)+1);return[...n].map(([r,i])=>i>1?`${r} ×${i}`:r).join(" · ")}function Nc(a){const n=[],r=(a.models||[]).map(By),i=a.providers||[];return(r.length||i.length)&&n.push([r.join(", ")||"model not reported",i.join(", ")].filter(Boolean).join(" · ")),n.push("From the run ledger; summed across this turn and its child runs."),n}function Hy(a){const n=a.modelCalls||[],r=[],i=[{label:"Input",value:Mn(a.inputTokens)},{label:"Output",value:Mn(a.outputTokens)}];if(a.reasoningTokens!==void 0&&i.push({label:"Reasoning",value:Mn(a.reasoningTokens),hint:"part of output"}),i.push({label:"Total",value:Mn(a.totalTokens)}),r.push({heading:`Usage · ${Or(a.llmCalls,"model call")}`,rows:i}),a.measuredCacheCalls){const u=a.cachedTokens||0,m=a.fedTokens||0,d=[{label:"Reused from cache",value:`${Mn(u)}${u+m?` (${Uy(u,u+m)})`:""}`},{label:"Newly processed",value:Mn(a.fedTokens)},{label:"Outcome",value:Wy(n.map(p=>p.cacheOutcome))||(a.cacheOutcomes||[]).join(" · ")||xn},{label:"Backend",value:(a.cacheBackends||[]).join(", ")||xn}];a.measuredCacheCalls!==a.llmCalls&&d.push({label:"Measured on",value:`${a.measuredCacheCalls} of ${a.llmCalls} calls`}),r.push({heading:"Prompt cache",rows:d})}else a.llmCalls&&r.push({heading:"Prompt cache",rows:[{label:"Cache reuse",value:xn}]});const l=n.filter(u=>u.inputTokens!==void 0);return l.length===1&&n.length===1?r.push({heading:"Context",rows:[{label:"Prompt size",value:`${Mn(l[0].inputTokens)} tokens`}]}):l.length>1&&r.push({heading:"Context",rows:[{label:"First → last call",value:`${Mn(l[0].inputTokens)} → ${Mn(l[l.length-1].inputTokens)} tokens`}],note:"Each call re-sends the conversation, so the input total counts the context once per call."}),n.length>1&&r.push({heading:"Per call",table:{columns:["#","Input","Cached","New","Output","Cache"],rows:n.map((u,m)=>[String(m+1),Mn(u.inputTokens),u.cachedTokens===void 0?"—":Mn(u.cachedTokens),u.fedTokens===void 0?"—":Mn(u.fedTokens),Mn(u.outputTokens),u.cacheOutcome||"—"])}}),{kind:"tokens",title:"Tokens",headline:a.totalTokens===void 0?xn:`${a.totalTokens.toLocaleString()} total`,sections:r,footer:Nc(a)}}function fc(a,n,r,i){if(a===void 0)return xn;const l=[Gn(a)];return n!==void 0&&l.push(`${n.toLocaleString()} ${i}${r!==void 0?` at ${tp(r)}`:""}`),l.join(" · ")}function Vy(a){var b,v,y;const n=a.modelCalls||[],r=[],i=a.durationMs,l=[{label:"Wall clock",value:Gn(i)}];if(l.push({label:"Model",value:a.genTimeMs===void 0?xn:`${Gn(a.genTimeMs)} · ${Or(a.timedCalls||0,"call")}${a.timedCalls!==a.llmCalls?` (of ${a.llmCalls})`:""}`}),l.push({label:"Tools",value:a.toolTimeMs!==void 0?`${Gn(a.toolTimeMs)} · ${Or(a.toolBatches||0,"batch","batches")}`:a.toolCalls?xn:"none",hint:a.toolTimeIncludesApproval?"includes approval wait":void 0}),i!==void 0&&a.genTimeMs!==void 0){const C=i-a.genTimeMs-(a.toolTimeMs||0);l.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:l});const u=[],m=a.ttftCalls||0,d=a.promptPhaseCalls||0;a.promptPhaseMs!==void 0?u.push({label:m&&m===d?"Prefill (TTFT)":"Prefill",value:fc(a.promptPhaseMs,a.promptPhaseNewTokens,a.promptPhaseTokensPerSecond,"new tok"),hint:m===d?"measured time to first token":m?`TTFT measured on ${m} of ${d}; rest from provider rate`:"derived: prompt ÷ provider rate"}):a.prefillMs!==void 0&&a.prefillNewTokensPerSecond!==void 0?u.push({label:"Prefill",value:fc(a.prefillMs,a.prefillNewTokens,a.prefillNewTokensPerSecond,"new tok"),hint:"derived: prompt ÷ provider rate"}):a.prefillMs!==void 0?u.push({label:"Prefill",value:`${Gn(a.prefillMs)}${a.promptTokensPerSecond!==void 0?` at ${tp(a.promptTokensPerSecond)}`:""}`,hint:"provider rate over all prompt tokens, restored included"}):u.push({label:"Prefill",value:xn}),a.cachedTokens&&(a.promptPhaseMs??a.prefillMs)!==void 0&&u.push({label:"Restored",value:`${a.cachedTokens.toLocaleString()} tok from cache`,hint:"not recomputed"}),u.push({label:"Generation",value:a.generationPhaseMs!==void 0?fc(a.generationPhaseMs,a.generationPhaseTokens,a.generationPhaseTokensPerSecond,"tok"):fc(a.decodeMs,a.outputTokens,a.generationTokensPerSecond,"tok")}),a.measuredSpeedCalls&&a.measuredSpeedCalls!==a.llmCalls&&u.push({label:"Speeds from",value:`${a.measuredSpeedCalls} of ${a.llmCalls} calls`}),r.push({heading:"Model",rows:u});const p=a.speculation;if(p){const C=(p.draftKinds||[]).map(T=>T.toUpperCase()).join(", "),L=[{label:"Mode",value:`${p.used?"on":"off"}${C?` · ${C}`:""}${(b=p.modes)!=null&&b.length?` (${p.modes.join(", ")})`:""}`,hint:p.calls!==a.llmCalls||p.used!==p.calls?`used on ${p.used} of ${a.llmCalls} calls`:void 0},{label:"Acceptance",value:p.acceptanceRate===void 0?xn:`${Math.round(p.acceptanceRate*100)}% · ${Mn(p.acceptedTokens)} of ${Mn(p.draftedTokens)} drafted`}];((v=p.draftLengths)!=null&&v.length||p.rounds!==void 0)&&L.push({label:"Draft length",value:`${(y=p.draftLengths)!=null&&y.length?`${p.draftLengths.join("/")} tok/round`:xn}${p.rounds!==void 0?` · ${p.rounds.toLocaleString()} rounds`:""}`}),r.push({heading:"Speculation",rows:L})}return a.slowestToolBatch&&r.push({heading:"Tools",rows:[{label:"Total",value:`${Gn(a.toolTimeMs)} · ${Or(a.toolBatches||0,"batch","batches")}`},{label:"Slowest",value:`${Gn(a.slowestToolBatch.ms)} · ${np(a.slowestToolBatch)}`}],note:a.toolTimeIncludesApproval?"Gated calls are timed from request to result, so this includes waiting for your approval.":void 0}),n.length>1&&r.push({heading:"Per call",table:{columns:["#","Prefill","New tok/s","Gen","Gen tok/s","Cache"],rows:n.map((C,L)=>[String(L+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:n.some(C=>C.promptSource==="rate")?"* derived from the provider's prompt rate (no TTFT event).":void 0}),{kind:"time",title:"Time",headline:i===void 0?xn:`${Gn(i)} wall clock`,sections:r,footer:Nc(a)}}function np(a){return a.tools.length===1?`${a.tools[0]} ×${a.calls}`:`${Or(a.calls,"call")} (${a.tools.join(", ")})`}function Gy(a){const n=[],r=(a.toolsWaiting||0)+(a.toolsRunning||0);if(!a.toolCalls&&!r)return n.push({heading:"Outcome",rows:[{label:"Tools called",value:"none"}]}),{kind:"tools",title:"Tools",headline:"none",sections:n,footer:Nc(a)};const i=[{label:"Succeeded",value:(a.toolCalls-(a.toolsFailed||0)).toLocaleString()},{label:"Failed",value:(a.toolsFailed||0).toLocaleString()}];a.toolsRunning&&i.push({label:"Running",value:a.toolsRunning.toLocaleString()}),a.toolsWaiting&&i.push({label:"Awaiting approval",value:a.toolsWaiting.toLocaleString(),hint:"not run yet — not a failure"}),n.push({heading:"Outcome",rows:i});const l=Object.entries(a.toolBreakdown||{}).sort((d,p)=>p[1].calls-d[1].calls||d[0].localeCompare(p[0]));l.length&&n.push({heading:"By tool",table:{columns:["Tool","Calls","Failed","Time"],rows:l.map(([d,p])=>[d,p.calls.toLocaleString(),p.failed.toLocaleString(),p.ms!==void 0?`${Gn(p.ms)}${p.sharedBatches?" +shared":""}`:p.sharedBatches?"shared":xn])},note:l.some(([,d])=>d.sharedBatches)?"A batch that mixed tools ran them together; its time is not split between them.":void 0});const u=l.filter(([,d])=>d.errors&&Object.keys(d.errors).length);u.length&&n.push({heading:"Failures",rows:u.map(([d,p])=>({label:d,value:Object.entries(p.errors).sort((b,v)=>v[1]-b[1]).map(([b,v])=>v>1?`${b} ×${v}`:b).join(" · ")}))});const m=[{label:"Tool time",value:a.toolTimeMs===void 0?xn:`${Gn(a.toolTimeMs)} · ${Or(a.toolBatches||0,"batch","batches")}`}];return a.slowestToolBatch&&m.push({label:"Slowest batch",value:`${Gn(a.slowestToolBatch.ms)} · ${np(a.slowestToolBatch)}`}),n.push({heading:"Timing",rows:m,note:a.toolTimeIncludesApproval?"Gated calls are timed from request to result, so this includes waiting for your approval.":void 0}),{kind:"tools",title:"Tools",headline:`${Or(a.toolCalls,"call")}${a.toolsFailed?` · ${a.toolsFailed} failed`:""}`,sections:n,footer:Nc(a)}}function Yu(a,n){return a==="tokens"?Hy(n):a==="time"?Vy(n):Gy(n)}function Ky(a){const n=a.detail;return e.jsxs("div",{ref:a.panelRef,id:a.id,role:"tooltip",className:`pc-stat-detail pc-stat-detail--${n.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:n.title}),e.jsx("span",{className:"pc-stat-detail-headline",children:n.headline})]}),n.sections.map(r=>{var i;return e.jsxs("div",{className:"pc-stat-detail-section",children:[e.jsx("div",{className:"pc-stat-detail-heading",children:r.heading}),(i=r.rows)!=null&&i.length?e.jsx("dl",{className:"pc-stat-detail-rows",children:r.rows.map(l=>e.jsxs(Wt.Fragment,{children:[e.jsx("dt",{children:l.label}),e.jsxs("dd",{children:[e.jsx("span",{className:l.value===xn?"pc-stat-detail-value pc-stat-detail-value--absent":"pc-stat-detail-value",children:l.value}),l.hint?e.jsx("span",{className:"pc-stat-detail-hint",children:l.hint}):null]})]},l.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(l=>e.jsx("th",{scope:"col",children:l},l))})}),e.jsx("tbody",{children:r.table.rows.map((l,u)=>e.jsx("tr",{children:l.map((m,d)=>e.jsx("td",{children:m},d))},u))})]}):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:n.footer.map(r=>e.jsx("div",{children:r},r))})]})}const fa=8;function Jy(a){const[n,r]=h.useState(!!a.defaultOpen),[i,l]=h.useState(null),u=h.useRef(null),m=h.useRef(null),d=h.useRef(null),p=`pc-stat-${h.useId().replace(/[^a-zA-Z0-9_-]/g,"")}`,b=h.useCallback(()=>{d.current!==null&&window.clearTimeout(d.current),d.current=null},[]),v=h.useCallback(()=>{b(),r(!0)},[b]),y=h.useCallback(()=>{b(),d.current=window.setTimeout(()=>r(!1),120)},[b]);h.useEffect(()=>b,[b]),h.useLayoutEffect(()=>{if(!n){l(null);return}const $=()=>{const E=u.current,I=m.current;if(!E||!I)return;const D=E.getBoundingClientRect(),O=I.offsetWidth,q=I.offsetHeight,A=window.innerWidth,H=window.innerHeight,fe=D.top-fa-q,ie=D.bottom+fa,Se=fe>=fa?fe:ie+q<=H-fa?ie:Math.max(fa,H-fa-q),ke=Math.min(Math.max(fa,D.left),Math.max(fa,A-fa-O));l({top:Se,left:ke})};return $(),window.addEventListener("resize",$),window.addEventListener("scroll",$,!0),()=>{window.removeEventListener("resize",$),window.removeEventListener("scroll",$,!0)}},[n]),h.useEffect(()=>{if(!n)return;const $=E=>{E.key==="Escape"&&r(!1)};return document.addEventListener("keydown",$),()=>document.removeEventListener("keydown",$)},[n]);const C=typeof a.onClick=="function",L=C?"button":"span",T=n?e.jsx(Ky,{detail:a.detail,id:p,panelRef:m,onMouseEnter:b,onMouseLeave:y,style:{position:"fixed",top:(i==null?void 0:i.top)??0,left:(i==null?void 0:i.left)??0,visibility:i?"visible":"hidden"}}):null;return e.jsxs(e.Fragment,{children:[e.jsxs(L,{ref:u,...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":n?p:void 0,"data-stat-kind":a.detail.kind,onMouseEnter:v,onMouseLeave:y,onFocus:v,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})]}),T&&typeof document<"u"?Ih.createPortal(T,document.body):T]})}function Qy(a){const n=a.totalTokens!==void 0?Yu("tokens",a):null,r=Yu("tools",a),i=a.durationMs!==void 0?Yu("time",a):null;return[...n?[{label:`${a.totalTokens.toLocaleString()} tokens`,detail:n}]:[],{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(`
50
+ `)}]:[],...i?[{label:`${(a.durationMs/1e3).toFixed(a.durationMs<1e4?1:0)}s`,detail:i}]:[]]}function Yy(a){const n=String(a.role||"").trim().toLowerCase()||"system",r=String(a.kind||"").trim().toLowerCase(),i=String(a.level||"").trim().toLowerCase();return n==="system"&&r==="report_bug"?{label:String(a.title||"").trim()||"Bug report",icon:"warning",variant:"report_bug"}:n==="system"&&r==="report_feature"?{label:String(a.title||"").trim()||"Feature request",icon:"check",variant:"report_feature"}:n==="user"?{label:String(a.title||"").trim()||"You",icon:"user",variant:"user"}:n==="assistant"?{label:String(a.title||"").trim()||"Agent",icon:"bot",variant:"assistant"}:{label:String(a.title||"").trim()||(i==="error"?"Error":i==="warn"?"Warning":"System"),icon:i==="error"?"error":i==="warn"?"warning":"info",variant:i==="error"?"error":i==="warn"?"warn":"status"}}const Xy=new Set(["blob:","data:","http:","https:"]);function Gf(a){const n=String(a||"").trim();if(n)try{const r=typeof window<"u"&&window.location?window.location.href:"http://same-origin.invalid/";return Xy.has(new URL(n,r).protocol)?n:void 0}catch{return}}function Zy({item:a}){const[n,r]=h.useState(!1),i=Gf(a.src),l=a.href?Gf(a.href):void 0,u=a.kind==="image"||a.kind==="audio"||a.kind==="video"?a.kind:null;if(!u||!i&&!l)return null;const m=u==="image"?"Image":u==="video"?"Video":"Audio",d=String(a.label||"").trim()||`Generated ${m.toLowerCase()}`,p=()=>r(!0);return e.jsxs("figure",{className:`pc-chat-media__item pc-chat-media__item--${u}`,children:[i&&u==="image"?e.jsx("img",{className:"pc-chat-media__image",src:i,alt:d,loading:"lazy",onError:p}):null,i&&u==="video"?e.jsx("video",{className:"pc-chat-media__video",src:i,controls:!0,playsInline:!0,preload:"metadata","aria-label":d,onError:p}):null,i&&u==="audio"?e.jsx(uy,{className:"pc-chat-media__audio",src:i,name:d}):null,n?e.jsxs("div",{className:"pc-chat-media__error",role:"note",children:[m," could not be decoded by this browser",l?"; open the raw file with the link.":"."]}):null,l?e.jsx("figcaption",{className:"pc-chat-media__caption",children:e.jsx("a",{className:"pc-chat-media__link",href:l,target:"_blank",rel:"noopener noreferrer",children:d})}):null]})}function ev(a){var A;const n=a.message,r=h.useMemo(()=>Yy(n),[n.kind,n.level,n.role,n.title]),i=String(n.ts||"").trim(),l=h.useMemo(()=>{if(!i)return"";const H=new Date(i);return Number.isFinite(H.getTime())?H.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):""},[i]),[u,m]=h.useState("idle"),d=h.useRef(null);h.useEffect(()=>()=>{d.current!==null&&window.clearTimeout(d.current)},[]);const p=n.live,b=!p&&typeof a.onSpeakToggle=="function"&&r.variant==="assistant"&&!!String(n.content||"").trim(),v=b&&((A=a.getSpeakState)==null?void 0:A.call(a,n))||"idle",y=v==="loading"?"loader":v==="playing"?"pause":"speaker",C=v==="loading"?"Generating audio…":v==="playing"?"Pause":v==="paused"?"Resume":"Speak (TTS)",L=a.showCopy!==!1,T=Array.isArray(a.attachments)?a.attachments:Array.isArray(n.attachments)?n.attachments:[],$=n.statistics,E=n.stats,I=h.useMemo(()=>Array.isArray(a.stats)?a.stats:Array.isArray(E)?E:$?Qy($):[],[a.stats,E,$]),D=Array.isArray(n.media)?n.media:[],O=String(p?p.reasoning||"":n.reasoning||""),q=!!String(n.content||"").trim();return n.toolActivity?e.jsx(ep,{tool:n.toolActivity,showCopy:a.showCopy}):e.jsxs("div",{className:["pc-chat-item",`pc-chat-item--${r.variant}`,p?"pc-chat-item--live":"",a.className].filter(Boolean).join(" "),...p?{"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(He,{name:r.icon,size:14})}),e.jsx("span",{className:"pc-chat-role",children:r.label}),p?e.jsxs("span",{className:"pc-chat-live-indicator",title:p.label?`Pending: ${p.label}`:"The reply is still being written",children:[e.jsx("span",{className:"pc-chat-live-dot","aria-hidden":"true"}),p.label||"streaming"]}):null,p!=null&&p.caption?e.jsx("span",{className:"pc-chat-live-caption",children:p.caption}):null,e.jsx("span",{className:"pc-chat-header-spacer"}),l?e.jsx("span",{className:"pc-chat-time",children:l}):null,e.jsxs("div",{className:"pc-chat-header-actions",children:[b?e.jsx("button",{className:"pc-chat-icon-btn",type:"button","aria-label":C,title:C,onClick:()=>{var H;return(H=a.onSpeakToggle)==null?void 0:H.call(a,n)},children:e.jsx(He,{name:y,size:22,className:v==="loading"?"pc-chat-speak-spinner":void 0})}):null,L?e.jsx("button",{className:`pc-chat-icon-btn ${u!=="idle"?`pc-chat-icon-btn--${u}`:""}`.trim(),type:"button","aria-label":"Copy message",title:u==="idle"?"Copy":u==="copied"?"Copied":"Copy failed",onClick:async()=>{const H=await ln(String(n.content||""));m(H?"copied":"failed"),d.current!==null&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>m("idle"),900)},children:e.jsx(He,{name:"copy",size:22})}):null]})]}),O.trim()?e.jsxs("details",{className:"pc-chat-thinking",children:[e.jsx("summary",{children:"Thinking"}),e.jsx("div",{className:"pc-chat-thinking-body",children:O})]}):null,q||!p&&!D.length?e.jsx("div",{className:"pc-chat-body",children:e.jsx(Dy,{text:String(n.content||""),renderMarkdown:a.renderMarkdown,jsonCollapseAfterDepth:a.jsonCollapseAfterDepth,images:a.images||(r.variant==="user"?"inline":"link"),inlineImage:a.inlineImage})}):null,D.length?e.jsx("div",{className:"pc-chat-media",children:D.slice(0,24).map((H,fe)=>e.jsx(Zy,{item:H},H.id||`${H.kind}:${H.src}:${fe}`))}):null,T.length?e.jsx("div",{className:"pc-chat-attachments","aria-label":"Attachments",children:T.slice(0,24).map((H,fe)=>{const ie=String(H.label||"").trim()||"attachment",Se=String(H.target||"").trim(),ke=String(H.title||"").trim(),le=!!H.disabled||typeof H.onClick!="function";return e.jsxs("button",{type:"button",className:"pc-chat-attachment-chip",title:ke||ie,onClick:le?void 0:H.onClick,disabled:le,children:[e.jsx(He,{name:"paperclip",size:14}),Se?e.jsx("span",{className:`pc-chat-attachment-target pc-chat-attachment-target--${Se}`,children:Se}):null,e.jsx("span",{className:"pc-chat-attachment-name",children:ie})]},H.id||`${ie}:${fe}`)})}):null,I.length?e.jsx("div",{className:"pc-chat-stats","aria-label":"Stats",children:I.slice(0,12).map((H,fe)=>{const ie=String(H.label||"").trim();if(!ie)return null;if(H.detail)return e.jsx(Jy,{label:ie,detail:H.detail,icon:H.icon,onClick:H.onClick},H.id||`${ie}:${fe}`);const Se=String(H.title||"").trim(),ke=typeof H.onClick=="function",le=ke?"button":"span";return e.jsxs(le,{...ke?{type:"button"}:{},className:["pc-chat-stat",ke?"pc-chat-stat--clickable":""].filter(Boolean).join(" "),title:Se||void 0,onClick:ke?()=>{var pe;return(pe=H.onClick)==null?void 0:pe.call(H)}:void 0,children:[H.icon?e.jsx("span",{className:"pc-chat-stat-icon","aria-hidden":"true",children:H.icon}):null,e.jsx("span",{className:"pc-chat-stat-label",children:ie})]},H.id||`${ie}:${fe}`)})}):null]})}function tv(a,n){const r=Math.max(0,Math.trunc(n));return a.scrollHeight-a.scrollTop-a.clientHeight<=r}function $c(a){const n=typeof a.autoScrollThresholdPx=="number"&&Number.isFinite(a.autoScrollThresholdPx)?a.autoScrollThresholdPx:120,r=a.autoScroll!==!1,i=h.useRef(null),l=h.useRef(null),[u,m]=h.useState(!0),d=h.useMemo(()=>Array.isArray(a.messages)?a.messages:[],[a.messages]),p=h.useMemo(()=>{var y;const v=[];for(const C of d){const L=v[v.length-1];C.toolActivity&&((y=L==null?void 0:L[0])!=null&&y.toolActivity)&&L[0].runId===C.runId?L.push(C):v.push([C])}return v},[d]);h.useEffect(()=>{if(!r)return;const v=i.current;if(!v)return;const y=()=>{m(tv(v,n))};return v.addEventListener("scroll",y,{passive:!0}),y(),()=>v.removeEventListener("scroll",y)},[r,n]);const b=h.useMemo(()=>{let v=0;for(const y of d)if(v+=String(y.content??"").length,Array.isArray(y.media))for(const C of y.media)v+=String((C==null?void 0:C.src)??"").length+1;return`${d.length}:${v}:${String(a.afterKey??"")}`},[d,a.afterKey]);return h.useEffect(()=>{if(!r||!u)return;const v=i.current;v&&(v.scrollTop=v.scrollHeight)},[r,u,b]),h.useEffect(()=>{if(!r)return;const v=i.current;if(!v)return;const y=()=>{u&&(v.scrollTop=v.scrollHeight)};return v.addEventListener("load",y,!0),v.addEventListener("loadedmetadata",y,!0),()=>{v.removeEventListener("load",y,!0),v.removeEventListener("loadedmetadata",y,!0)}},[r,u]),e.jsxs("div",{ref:i,className:["pc-chat-thread",a.className].filter(Boolean).join(" "),children:[d.length?null:a.empty||null,p.map((v,y)=>{var T;const C=v[0],L=String(C.id||"")||String(C.ts||"")+":"+String(C.role||"")+":"+y;return C.toolActivity?e.jsx(qy,{tools:v.map($=>$.toolActivity),showCopy:(T=a.messageProps)==null?void 0:T.showCopy},L):e.jsx(ev,{message:C,...a.messageProps||{}},L)}),a.after,e.jsx("div",{ref:l})]})}const sl=Wt.forwardRef(function(n,r){const i=typeof n.rows=="number"&&Number.isFinite(n.rows)?Math.max(1,Math.trunc(n.rows)):3,l=!!n.disabled,u=!!n.busy,m=!l&&!u&&!!String(n.value||"").trim();return e.jsxs("div",{className:["pc-composer",n.className].filter(Boolean).join(" "),children:[n.leading,e.jsx("textarea",{ref:r,className:["pc-composer__textarea",n.textareaClassName].filter(Boolean).join(" "),value:n.value,onChange:d=>n.onChange(d.target.value),rows:i,style:{"--pc-composer-rows":String(i)},spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",autoComplete:"off",placeholder:n.placeholder||"","aria-label":n.ariaLabel||n.placeholder||"Message",disabled:l,autoFocus:!!n.autoFocus,onPaste:n.onPaste,onKeyDown:d=>{d.key!=="Enter"||d.shiftKey||d.nativeEvent.isComposing||d.keyCode===229||(d.preventDefault(),m&&n.onSubmit())}}),e.jsxs("div",{className:"pc-composer__row",children:[e.jsx("div",{className:"pc-composer__actions",children:n.actions}),e.jsx("button",{type:"button",className:n.sendButtonClassName||"pc-btn",disabled:!m,onClick:()=>n.onSubmit(),children:u?n.busyLabel||"Thinking…":n.sendLabel||"Send"})]}),n.overlay]})});function nv(a){return!!(a&&typeof a[Symbol.asyncIterator]=="function")}function sv(a){const[n,r]=h.useState([]),i=a.messages??n,l=$=>{a.onMessagesChange&&a.onMessagesChange($),a.messages===void 0&&r($)},u=h.useRef(i);u.current=i;const[m,d]=h.useState(""),[p,b]=h.useState(!1),v=h.useRef(null),y=a.assistantName||"Assistant",C=!!a.blockedNotice,L=async $=>{const E=String($||"").trim();if(!E||p||C)return;d("");const I=u.current,D=[...I,{role:"user",content:E,ts:new Date().toISOString()}];l(D),b(!0);const O=new AbortController;v.current=O;try{const q=a.ask(E,{signal:O.signal,history:I});if(nv(q)){let A="";const H=[...D,{role:"assistant",title:y,content:"",ts:new Date().toISOString()}];l(H);for await(const fe of q){if(O.signal.aborted)break;A+=String(fe??""),l([...D,{role:"assistant",title:y,content:A,ts:new Date().toISOString()}])}!A.trim()&&!O.signal.aborted&&l([...D,{role:"assistant",title:y,content:"#FALLBACK the assistant returned no answer.",level:"warn",ts:new Date().toISOString()}])}else{const A=String(await q??"").trim();l([...D,A?{role:"assistant",title:y,content:A,ts:new Date().toISOString()}:{role:"assistant",title:y,content:"#FALLBACK the assistant returned no answer.",level:"warn",ts:new Date().toISOString()}])}}catch(q){O.signal.aborted||l([...u.current,{role:"assistant",title:y,content:`#FALLBACK assistant request failed: ${String((q==null?void 0:q.message)||q||"unknown error")}`,level:"error",ts:new Date().toISOString()}])}finally{v.current===O&&(v.current=null),b(!1)}},T=h.useMemo(()=>i.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 L($),disabled:p||C,children:$},$))}):null]}),[i.length,a.emptyState,a.suggestions,p,C]);return e.jsxs("div",{className:`pc-assistant${a.className?` ${a.className}`:""}`,children:[e.jsxs("div",{className:"pc-assistant__thread",children:[T,e.jsx($c,{messages:i,autoScroll:!0}),C?e.jsx("div",{className:"pc-assistant__blocked",children:a.blockedNotice}):null]}),e.jsx("div",{className:"pc-assistant__composer",children:e.jsx(sl,{value:m,onChange:d,onSubmit:()=>void L(m),placeholder:a.placeholder||"Ask about this app…",disabled:C,busy:p,rows:2,actions:p?e.jsx("button",{type:"button",className:"pc-btn",onClick:()=>{var $;($=v.current)==null||$.abort()},children:"Stop"}):null})})]})}function av(a){if(!a)return!1;for(let n=0;n<a.length;n+=1)if(a[n]==="Files")return!0;return!1}function sp(a){const n=[],r=[],i=a==null?void 0:a.items;if(i&&i.length){for(let u=0;u<i.length;u+=1){const m=i[u];if(!m||m.kind!=="file")continue;const d=typeof m.webkitGetAsEntry=="function"?m.webkitGetAsEntry():null,p=typeof m.getAsFile=="function"?m.getAsFile():null;d!=null&&d.isDirectory?r.push(d.name||(p==null?void 0:p.name)||"folder"):p&&n.push(p)}return{files:n,folders:r}}const l=a==null?void 0:a.files;if(l)for(let u=0;u<l.length;u+=1)l[u]&&n.push(l[u]);return{files:n,folders:r}}function rv(a){return a.length?a.length===1?`"${a[0]}" is a folder. Folders are not supported: drop the files inside it instead.`:`${a.length} folders were dropped. Folders are not supported: drop the files inside them instead.`:""}const iv={"image/png":"png","image/jpeg":"jpg","image/gif":"gif","image/webp":"webp","image/heic":"heic","image/tiff":"tiff","image/bmp":"bmp"};function Po(a){return String(a).padStart(2,"0")}function ov(a,n,r){const i=String(a||"").trim();if(i&&!/^image\.(png|jpe?g|gif|webp|heic|tiff?|bmp)$/i.test(i))return i;const l=iv[String(n||"").toLowerCase()]||i.split(".").pop()||"bin",u=`${r.getFullYear()}-${Po(r.getMonth()+1)}-${Po(r.getDate())} at ${Po(r.getHours())}.${Po(r.getMinutes())}.${Po(r.getSeconds())}`;return`${String(n||"").startsWith("image/")||!i?"Pasted image":"Pasted file"} ${u}.${l}`}function lv(a,n=new Date){if(!a)return[];const r=a.types?Array.from(a.types):[];if(r.includes("text/plain")&&r.includes("text/html"))return[];const{files:i}=sp(a);return i.map(l=>{const u=ov(l.name,l.type,n);return u===l.name?l:new File([l],u,{type:l.type,lastModified:l.lastModified})})}const Go="llm.delta",Ni="llm.delta_end";function cv(a){return a&&typeof a=="object"&&!Array.isArray(a)?a:null}function Pr(a){return typeof a=="string"&&a.trim()!==""}function uv(a){return typeof a=="number"&&Number.isInteger(a)&&a>=0}function dv(a){return"reason"in a}function mv(a,n){const r=cv(a),i=r==null?void 0:r.kind,l=n||(typeof i=="string"&&i?i:r&&"reason"in r?Ni:Go),u=p=>{throw new Error(`Malformed ${l} event from the gateway: ${p}`)};if(n!==void 0&&n!==Go&&n!==Ni&&u(`unknown event name ${JSON.stringify(n)}`),!r)return u("the payload is not an object");i!==void 0&&i!==Go&&i!==Ni&&u(`unknown kind ${JSON.stringify(i)}`),i!==void 0&&n!==void 0&&i!==n&&u(`kind ${JSON.stringify(i)} does not match the event name`),Pr(r.run_id)||u("run_id is missing"),Pr(r.call_id)||u("call_id is missing"),uv(r.seq)||u("seq is not a non-negative integer");const m=n||i?(n||i)===Ni:"reason"in r;r.root_run_id!==void 0&&!Pr(r.root_run_id)&&u("root_run_id is not a run id"),r.parent_run_id!==void 0&&r.parent_run_id!==null&&!Pr(r.parent_run_id)&&u("parent_run_id is neither a run id nor null");const d={run_id:r.run_id,...Pr(r.root_run_id)?{root_run_id:r.root_run_id}:{},...r.parent_run_id!==void 0?{parent_run_id:r.parent_run_id}:{},...Pr(r.node_id)?{node_id:r.node_id}:{},call_id:r.call_id,seq:r.seq};return m?(["completed","failed","cancelled","unavailable"].includes(String(r.reason))||u(`unknown reason ${JSON.stringify(r.reason)}`),r.detail!==void 0&&r.detail!==null&&typeof r.detail!="string"&&u("detail is not a string"),{kind:Ni,...d,reason:r.reason,...Pr(r.detail)?{detail:r.detail}:{}}):(typeof r.text!="string"&&u("text is not a string"),r.channel!=="content"&&r.channel!=="reasoning"&&u(`unknown channel ${JSON.stringify(r.channel)}`),typeof r.snapshot!="boolean"&&u("snapshot is not a boolean"),{kind:Go,...d,text:r.text,channel:r.channel,snapshot:r.snapshot})}function fv(a,n){if(a!==Go&&a!==Ni)return null;let r=n;if(typeof n=="string")try{r=JSON.parse(n)}catch{throw new Error(`Malformed ${a} event from the gateway: data is not JSON`)}return mv(r,a)}async function ap(a,n){let r="";try{const i=await a.text();try{const l=JSON.parse(i),u=(l==null?void 0:l.detail)??(l==null?void 0:l.error)??(l==null?void 0:l.message);r=typeof u=="string"?u:u&&typeof u.message=="string"?u.message:i}catch{r=i}}catch{r=""}return new Error(`${n} (HTTP ${a.status}): ${r.trim()||a.statusText||"no reason given"}`)}const hv={registry_scope:"tenant_catalog",bundle_id:"docs-qa",bundle_version:"0.1.1",flow_id:"docsqa001"},rp="docs";function pv(a){return Ws(`docs/corpus?${new URLSearchParams({app:String(a||"")})}`)}function Xu(a){return`${String(a||"app")}-docs-assistant:${Jo()}`}function _v(a){const n={prompt:a.question,docs:a.docs,app:a.appName,use_session_history:!0};return a.attachments&&a.attachments.length&&(n.context={attachments:a.attachments}),{...hv,session_id:a.sessionId,kind:rp,input_data:n}}function ip(a){const n=a==null?void 0:a.output;if(typeof n=="string")return n.trim();const r=n==null?void 0:n.response;return typeof r=="string"?r.trim():""}function gv(a){const n=a&&typeof a=="object"?a:{},r=d=>typeof d=="number"&&Number.isFinite(d)&&d>0?Math.trunc(d):0,i=r(n.dropped_messages);if(!i)return"";const l=r(n.replayed_messages),u=r(n.dropped_tokens),m=r(n.max_tokens);return`Earlier messages not replayed: ${i.toLocaleString("en-US")}${u?` (~${u.toLocaleString("en-US")} tokens)`:""}. The model read the newest ${l.toLocaleString("en-US")} message${l===1?"":"s"}`+(m?` (history window: the most recent ${m.toLocaleString("en-US")} tokens of whole messages).`:".")}async function*yv(a,n){const r=a.getReader(),i=new TextDecoder;let l="";const u=()=>{r.cancel().catch(()=>{})};n==null||n.addEventListener("abort",u,{once:!0});try{for(;;){const{value:m,done:d}=await r.read();if(d)break;l+=i.decode(m,{stream:!0}).replace(/\r\n/g,`
51
+ `);let p=l.indexOf(`
52
+
53
+ `);for(;p>=0;){const b=l.slice(0,p);l=l.slice(p+2);let v="message";const y=[];for(const C of b.split(`
54
+ `))C.startsWith("event:")?v=C.slice(6).trim():C.startsWith("data:")&&y.push(C.slice(5).replace(/^ /,""));y.length&&(yield{event:v,data:y.join(`
55
+ `)}),p=l.indexOf(`
56
+
57
+ `)}}}finally{n==null||n.removeEventListener("abort",u)}}function vv(a,n){return new Promise((r,i)=>{if(n.aborted)return i(new DOMException("Aborted","AbortError"));const l=setTimeout(()=>{n.removeEventListener("abort",u),r()},a),u=()=>{clearTimeout(l),i(new DOMException("Aborted","AbortError"))};n.addEventListener("abort",u,{once:!0})})}async function Xa(a,n){if(!a.ok)throw await ap(a,n);return a.json()}function xv(a){const n=a.pollMs??1e3,r=a.timeoutMs??18e4;let i=null;return async(l,u)=>{var T;const{fetchGateway:m,source:d}=a;if(i===null){const $=await m(pv(d.app),{signal:u.signal,headers:{Accept:"application/json"}}),E=await Xa($,`The ${d.name} documentation could not be read, so nothing was asked`),I=typeof(E==null?void 0:E.text)=="string"?E.text:"";if(!I.trim())throw new Error(`The gateway returned an empty ${d.name} documentation corpus, so nothing was asked.`);i=I}const p=String(i),b=[];for(const $ of u.files||[]){const E=new FormData;E.append("session_id",u.sessionId),E.append("file",$,$.name||"upload.bin"),E.append("filename",$.name||"upload.bin"),$.type&&E.append("content_type",$.type);const I=await Xa(await m(Ws("attachments/upload"),{method:"POST",body:E,signal:u.signal}),`"${$.name}" could not be attached`),D=I==null?void 0:I.attachment;if(!D||typeof D.$artifact!="string"||!D.$artifact)throw new Error(`"${$.name}" could not be attached: the gateway returned no attachment reference.`);b.push(D)}const v=await Xa(await m(Ws("runs/start"),{method:"POST",signal:u.signal,headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(_v({question:l,docs:p,appName:d.name,sessionId:u.sessionId,attachments:b}))}),"The docs-qa workflow could not start"),y=String((v==null?void 0:v.run_id)||"");if(!y)throw new Error("The gateway did not return a run id for the docs-qa workflow.");const C=new AbortController,L=()=>C.abort();u.signal.addEventListener("abort",L,{once:!0}),u.onText&&(async()=>{var $;try{const E=await m(Ws(`runs/${encodeURIComponent(y)}/ledger/stream?after=0`),{signal:C.signal,headers:{Accept:"text/event-stream"}});if(!E.ok||!E.body)return;let I="",D="";for await(const O of yv(E.body,C.signal)){const q=fv(O.event,O.data);!q||dv(q)||q.channel!=="content"||q.run_id!==y||(q.call_id!==I&&(I=q.call_id,D=""),D=q.snapshot?q.text:D+q.text,($=u.onText)==null||$.call(u,D))}}catch{}})();try{const $=Date.now()+r;for(;;){await vv(n,u.signal);const E=await Xa(await m(Ws(`runs/${encodeURIComponent(y)}`),{signal:u.signal}),"The docs-qa run could not be read"),I=String((E==null?void 0:E.status)||"").toLowerCase();if(I==="completed"){(T=u.onHistory)==null||T.call(u,(E==null?void 0:E.session_history)??null);const D=ip(E);if(!D)throw new Error(`The docs-qa run ${y} completed without an answer.`);return D}if(I==="failed"||I==="cancelled"){const D=E==null?void 0:E.error,O=typeof D=="string"?D:typeof(D==null?void 0:D.message)=="string"?D.message:"";throw new Error(`The docs-qa run ${I}${O?`: ${O}`:""}.`)}if(I==="waiting")throw new Error(`The docs-qa run ${y} is waiting for input it should never need. Inspect it in Observer.`);if(Date.now()>=$)throw new Error(`The docs-qa run ${y} is still running after ${Math.round(r/1e3)} s. It stays in the gateway's history.`)}}finally{u.signal.removeEventListener("abort",L),C.abort()}}}async function bv(a,n,r={}){const i=new URLSearchParams({root_only:"true",kind:rp,limit:"500",include_ledger_len:"false"}),l=await Xa(await a(Ws(`runs?${i}`),{signal:r.signal}),"The docs assistant history could not be read"),u=`${String(n||"app")}-docs-assistant:`,m=new Map;for(const p of Array.isArray(l==null?void 0:l.items)?l.items:[]){const b=String((p==null?void 0:p.session_id)||"");if(!b.startsWith(u)||!(p!=null&&p.run_id))continue;const v=m.get(b)||{runs:[],updatedAt:""};v.runs.push({id:String(p.run_id),created:String(p.created_at||"")});const y=String(p.updated_at||p.created_at||"");y>v.updatedAt&&(v.updatedAt=y),m.set(b,v)}const d=[...m.entries()].sort((p,b)=>p[1].updatedAt<b[1].updatedAt?1:-1).slice(0,r.max??20);return Promise.all(d.map(async([p,b])=>{var C;const v=b.runs.sort((L,T)=>L.created<T.created?-1:1).map(L=>L.id);let y="";try{const L=await Xa(await a(Ws(`runs/${encodeURIComponent(v[0])}/input_data`),{signal:r.signal}),"");y=String(((C=L==null?void 0:L.input_data)==null?void 0:C.prompt)||"").trim()}catch{y=""}return{sessionId:p,title:y||"Untitled question",updatedAt:b.updatedAt,runIds:v}}))}async function wv(a,n,r,i){var u;const l=[];for(const m of n.runIds){const[d,p]=await Promise.all([Xa(await a(Ws(`runs/${encodeURIComponent(m)}/input_data`),{signal:i}),"A past question could not be read"),Xa(await a(Ws(`runs/${encodeURIComponent(m)}`),{signal:i}),"A past answer could not be read")]),b=String(((u=d==null?void 0:d.input_data)==null?void 0:u.prompt)||"").trim();b&&l.push({id:`u-${m}`,role:"user",content:b,ts:String((p==null?void 0:p.created_at)||"")||void 0});const v=ip(p),y=String((p==null?void 0:p.status)||"").toLowerCase();l.push(v?{id:`a-${m}`,role:"assistant",title:r,content:v,ts:String((p==null?void 0:p.updated_at)||"")||void 0}:{id:`a-${m}`,role:"assistant",title:r,level:"warn",content:y==="completed"?"This answer was empty.":`No answer: the run is ${y||"unknown"}.`})}return l}function jv(a){const[n,r]=h.useState(null);return a.state==="loading"?e.jsx("div",{className:"pc-docs-history__note",role:"status",children:"Loading past conversations…"}):a.state==="error"?e.jsx("div",{className:"pc-docs-history__note pc-docs-history__note--error",role:"alert",children:a.error||"The history could not be read."}):a.items.length?e.jsx("ul",{className:"pc-docs-history","aria-label":"Past conversations",children:a.items.map(i=>e.jsx("li",{className:`pc-docs-history__row${i.sessionId===a.activeSessionId?" is-active":""}`,children:n===i.sessionId?e.jsxs("div",{className:"pc-docs-history__confirm",children:[e.jsx("span",{children:"Archive this conversation? It stays in the gateway; it leaves this list."}),e.jsx("button",{type:"button",className:"pc-docs-history__btn pc-docs-history__btn--danger",onClick:()=>{r(null),a.onArchive(i)},children:"Archive"}),e.jsx("button",{type:"button",className:"pc-docs-history__btn",onClick:()=>r(null),children:"Cancel"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",className:"pc-docs-history__open",onClick:()=>a.onOpen(i),title:i.title,children:[e.jsx("span",{className:"pc-docs-history__title",children:i.title}),e.jsxs("span",{className:"pc-docs-history__meta",children:[wy(i.updatedAt,a.nowMs),i.runIds.length>1?` · ${i.runIds.length} questions`:""]})]}),e.jsx("button",{type:"button",className:"pc-docs-assistant__icon-btn","aria-label":`Archive "${i.title}"`,"data-af-tip":`Archive "${i.title}" (kept, hidden)`,onClick:()=>r(i.sessionId),children:e.jsx(He,{name:"archive",size:16})})]})},i.sessionId))}):e.jsx("div",{className:"pc-docs-history__note",children:"No past conversations yet."})}const kv=/^image\/(png|jpe?g|gif|webp|avif|bmp|svg\+xml)$/i;function Sv(a){const n=h.useRef(null),[r,i]=h.useState(!1),l=!!a.blockedNotice,u=!!a.busy,m=a.files||[],d=typeof a.onAddFiles=="function"&&!l,p=e.jsxs("div",{className:"pc-docs-assistant__empty",children:[e.jsxs("p",{className:"pc-docs-assistant__empty-text",children:["Ask anything about ",a.source.name,"."]}),a.suggestions&&a.suggestions.length?e.jsx("div",{className:"pc-docs-assistant__suggestions",children:a.suggestions.map(b=>e.jsx("button",{type:"button",className:"pc-docs-assistant__suggestion",disabled:u||l,onClick:()=>{var v;return(v=a.onSuggestion)==null?void 0:v.call(a,b)},children:b},b))}):null]});return e.jsxs("div",{className:`pc-docs-assistant${r?" is-dragging":""}`,onDragOver:b=>{var v;!d||!av((v=b.dataTransfer)==null?void 0:v.types)||(b.preventDefault(),i(!0))},onDragLeave:()=>i(!1),onDrop:b=>{var y,C;if(!d)return;b.preventDefault(),i(!1);const v=sp(b.dataTransfer);v.files.length&&((y=a.onAddFiles)==null||y.call(a,v.files)),v.folders.length&&((C=a.onNotice)==null||C.call(a,rv(v.folders)))},children:[e.jsx($c,{className:"pc-docs-assistant__thread",messages:a.messages,autoScroll:!0,empty:p,messageProps:{showCopy:!0}}),l?e.jsx("div",{className:"pc-docs-assistant__blocked",role:"status",children:a.blockedNotice}):null,a.notice?e.jsx("div",{className:"pc-docs-assistant__notice",role:"status",children:a.notice}):null,e.jsx("div",{className:"pc-docs-assistant__composer",children:e.jsx(sl,{value:a.draft,onChange:a.onDraftChange,onSubmit:a.onSend,placeholder:a.placeholder||`Ask about ${a.source.name}…`,ariaLabel:`Question about ${a.source.name}`,disabled:l,busy:u,rows:1,sendLabel:"Send",busyLabel:"Answering…",onPaste:b=>{var y;if(!d)return;const v=lv(b.clipboardData);v.length&&(b.preventDefault(),(y=a.onAddFiles)==null||y.call(a,v))},leading:m.length?e.jsx("div",{className:"pc-chat-attachments pc-docs-assistant__files",role:"list","aria-label":"Attached files",children:m.map(b=>e.jsxs("span",{role:"listitem",className:"pc-chat-attachment-chip",children:[e.jsx(He,{name:"paperclip",size:14}),e.jsx("span",{className:"pc-chat-attachment-name",children:b.name}),a.onRemoveFile&&!u?e.jsx("button",{type:"button",className:"pc-docs-assistant__file-remove","aria-label":`Remove ${b.name}`,"data-af-tip":`Remove ${b.name}`,onClick:()=>{var v;return(v=a.onRemoveFile)==null?void 0:v.call(a,b.id)},children:e.jsx(He,{name:"x",size:12})}):null]},b.id))}):null,actions:e.jsxs(e.Fragment,{children:[d?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"pc-docs-assistant__icon-btn","aria-label":"Attach files","data-af-tip":"Attach files to your question",disabled:u,onClick:()=>{var b;return(b=n.current)==null?void 0:b.click()},children:e.jsx(He,{name:"paperclip",size:16})}),e.jsx("input",{ref:n,type:"file",multiple:!0,hidden:!0,"aria-hidden":"true",tabIndex:-1,onChange:b=>{var y;const v=Array.from(b.currentTarget.files||[]);b.currentTarget.value="",v.length&&((y=a.onAddFiles)==null||y.call(a,v))}})]}):null,u&&a.onStop?e.jsx("button",{type:"button",className:"pc-docs-assistant__icon-btn","aria-label":"Stop","data-af-tip":"Stop the answer",onClick:a.onStop,children:e.jsx(He,{name:"stop",size:14})}):null]})})}),e.jsxs("div",{className:"pc-docs-assistant__footer",title:`Answers come from ${a.source.name}'s documentation (llms.txt) through the gateway's docs-qa workflow.`,children:["Grounded on ",a.source.name,"’s documentation (llms.txt) · docs-qa"]})]})}function hc(){return new Date().toISOString()}function Nv(a){Pd();const{source:n}=a,r=h.useRef(a.fetchGateway);r.current=a.fetchGateway;const i=h.useMemo(()=>a.ask||xv({fetchGateway:(le,pe)=>r.current(le,pe),source:n}),[a.ask,n.app,n.name]),l=h.useRef(Xu(n.app)),[u,m]=h.useState([]),d=h.useRef(u);d.current=u;const[p,b]=h.useState(""),[v,y]=h.useState([]),[C,L]=h.useState(!1),[T,$]=h.useState(""),E=h.useRef(null),[I,D]=h.useState(!1),[O,q]=h.useState({state:"loading",items:[]});h.useEffect(()=>()=>{var le;return(le=E.current)==null?void 0:le.abort()},[]);const A=h.useCallback(async()=>{q(le=>({...le,state:"loading"}));try{const le=await bv((pe,G)=>r.current(pe,G),n.app);q({state:"ready",items:le})}catch(le){q({state:"error",items:[],error:String((le==null?void 0:le.message)||le)})}},[n.app]),H=h.useCallback(async le=>{var pe;(pe=E.current)==null||pe.abort(),q(G=>({...G,state:"loading"}));try{const G=await wv((te,ae)=>r.current(te,ae),le,n.name);l.current=le.sessionId,m(G),$(""),D(!1),q(te=>({...te,state:"ready"}))}catch(G){q(te=>({...te,state:"error",error:String((G==null?void 0:G.message)||G)}))}},[n.name]),fe=h.useCallback(async le=>{try{const pe=await r.current(Ws(`sessions/${encodeURIComponent(le.sessionId)}/archive`),{method:"POST"});if(!pe.ok)throw await ap(pe,"The conversation could not be archived");l.current===le.sessionId&&(l.current=Xu(n.app),m([])),q(G=>({...G,items:G.items.filter(te=>te.sessionId!==le.sessionId)}))}catch(pe){q(G=>({...G,state:"error",error:String((pe==null?void 0:pe.message)||pe)}))}},[n.app]);h.useEffect(()=>{var le;a.connected||(le=E.current)==null||le.abort()},[a.connected]),h.useEffect(()=>()=>{for(const le of v)le.preview&&URL.revokeObjectURL(le.preview)},[]);const ie=h.useCallback(le=>{$(""),y(pe=>[...pe,...le.map(G=>({id:Jo(),file:G,preview:kv.test(G.type)&&typeof URL<"u"&&typeof URL.createObjectURL=="function"?URL.createObjectURL(G):void 0}))])},[]),Se=h.useCallback(async le=>{const pe=String(le||"").trim();if(!pe||C||!a.connected)return;const G=v;b(""),y([]),$("");const te=G.filter(w=>w.preview).map(w=>({kind:"image",src:w.preview,label:w.file.name})),ae=G.map(w=>({id:w.id,label:w.file.name,title:w.file.name,disabled:!0})),U={id:`u-${Jo()}`,role:"user",content:pe,ts:hc(),...te.length?{media:te}:{},...ae.length?{attachments:ae}:{}},Q=`a-${Jo()}`,M=[...d.current,U],Z={id:Q,role:"assistant",title:n.name,content:"",ts:hc(),live:{callId:Q,reasoning:"",label:"answering"}};m([...M,Z]),L(!0);const ne=new AbortController;E.current=ne;const k=w=>m([...M,w]);try{const w=await i(pe,{signal:ne.signal,sessionId:l.current,files:G.map(K=>K.file),onText:K=>{ne.signal.aborted||k({...Z,content:K,live:{callId:Q,reasoning:"",label:"streaming"}})},onHistory:K=>$(gv(K))});ne.signal.aborted||k({id:Q,role:"assistant",title:n.name,content:w,ts:hc()})}catch(w){const K=ne.signal.aborted;k({id:Q,role:"assistant",title:n.name,level:K?"warn":"error",content:K?"Stopped. Nothing more will be shown for this question.":String((w==null?void 0:w.message)||w||"The docs assistant failed."),ts:hc()})}finally{E.current===ne&&(E.current=null),L(!1)}},[i,C,v,a.connected,n.name]),ke=()=>{var le;(le=E.current)==null||le.abort(),l.current=Xu(n.app),m([]),y([]),b(""),$("")};return e.jsxs(yd,{open:a.open,onClose:a.onClose,label:"Docs assistant",title:e.jsxs("span",{className:"pc-docs-assistant__title",children:[e.jsx(He,{name:"book",size:16}),"Docs assistant"]}),width:a.width||420,topOffset:a.topOffset,className:`pc-docs-assistant-drawer${a.className?` ${a.className}`:""}`,headerActions:e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:`pc-docs-assistant__icon-btn${I?" is-active":""}`,"aria-label":"Past conversations","data-af-tip":"Past conversations","aria-pressed":I,disabled:!a.connected||C,onClick:()=>{const le=!I;D(le),le&&A()},children:e.jsx(He,{name:"history",size:16})}),e.jsx("button",{type:"button",className:"pc-docs-assistant__icon-btn","aria-label":"New conversation","data-af-tip":"Start a new conversation",disabled:!u.length&&!p&&!v.length&&!I,onClick:()=>{ke(),D(!1)},children:e.jsx(He,{name:"compose",size:16})})]}),children:[I?e.jsx("div",{className:"pc-docs-assistant pc-docs-assistant--history",children:e.jsx(jv,{items:O.items,state:O.state,error:O.error,nowMs:Date.now(),activeSessionId:l.current,onOpen:le=>void H(le),onArchive:le=>void fe(le)})}):null,e.jsx("div",{hidden:I,style:{display:I?"none":"contents"},children:e.jsx(Sv,{source:n,messages:u,draft:p,onDraftChange:b,onSend:()=>void Se(p),onStop:()=>{var le;return(le=E.current)==null?void 0:le.abort()},busy:C,blockedNotice:a.connected?void 0:"Connect to the gateway to use the docs assistant.",files:v.map(le=>({id:le.id,name:le.file.name})),onAddFiles:ie,onNotice:$,onRemoveFile:le=>y(pe=>{const G=pe.find(te=>te.id===le);return G!=null&&G.preview&&URL.revokeObjectURL(G.preview),pe.filter(te=>te.id!==le)}),notice:T,suggestions:a.suggestions,onSuggestion:le=>void Se(le),placeholder:a.placeholder})})]})}function Cv(a){const n=a.trim();if(!n)throw new Error("AbstractContinuum was built without __APP_VERSION__ (see vite.config.ts define)");return n}const $v=Cv("0.7.0");function pc(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 zo(a){if(!a)return"";const n=a.value!==void 0&&a.value!==null?a.value:a.id??a.path??"";return typeof n=="string"?n.trim():""}const Kf="abstractcontinuum_gateway_csrf",Ev="x-abstractcontinuum-csrf",Tv="x-abstract-csrf";function Zu(a){var i;const n=(a||"").trim(),r={};n&&(r.Authorization=`Bearer ${n}`);try{const l=(i=document.cookie.split(";").map(u=>u.trim()).find(u=>u.startsWith(`${Kf}=`)))==null?void 0:i.slice(`${Kf}=`.length);if(l){const u=decodeURIComponent(l);r[Ev]=u,r[Tv]=u}}catch{}return r}function Jf(a){const n={},r=(i,l)=>{const u=String(l||"").trim();u&&(n[i]=u)};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),n}async function Av(a){try{const n=await a.text();return n!=null&&n.trim()?n.trim():`${a.status}`}catch{return`${a.status}`}}class op extends Error{constructor(r,i,l){super(r);Ka(this,"status");Ka(this,"body");this.name="GatewayRequestError",this.status=i,this.body=l}}const ed=[15,30,60,120];class Lv{constructor(n){Ka(this,"_cfg");Ka(this,"_backoff_until",0);Ka(this,"_backoff_step",0);Ka(this,"fetch_gateway",(n,r)=>{const i=new Headers((r==null?void 0:r.headers)||{});for(const[l,u]of Object.entries(Zu(this._cfg.auth_token)))i.set(l,u);return fetch(Hu(this._cfg.base_url,n),{...r,headers:i})});this._cfg={...n,base_url:(n.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(n,r,i){const l=await fetch(Hu(this._cfg.base_url,r),{...i,headers:{...i==null?void 0:i.headers,...Zu(this._cfg.auth_token)}});if(l.ok)return this._backoff_step=0,this._backoff_until=0,l;const u=await Av(l);let m=null;try{m=JSON.parse(u)}catch{}let d=u;if(m&&typeof m=="object"&&m.detail!==void 0&&(d=typeof m.detail=="string"?m.detail:JSON.stringify(m.detail)),l.status===429||/too many requests|auth lockout|locked/i.test(d)){const b=ed[Math.min(this._backoff_step,ed.length-1)];this._backoff_until=Date.now()+b*1e3,this._backoff_step<ed.length-1&&(this._backoff_step+=1)}throw new op(`${n} failed: ${d}`,l.status,m)}async _get_json(n,r){return await(await this._fetch(n,r)).json()}async _post_json(n,r,i){return await(await this._fetch(n,r,{method:"POST",headers:i===void 0?void 0:{"Content-Type":"application/json"},body:i===void 0?void 0:JSON.stringify(i)})).json()}async _post_form(n,r,i){return await(await this._fetch(n,r,{method:"POST",body:i})).json()}async list_runs(n){const r=new URLSearchParams;r.set("limit",String(typeof(n==null?void 0:n.limit)=="number"?n.limit:50));const i=String((n==null?void 0:n.status)||"").trim();i&&r.set("status",i);const l=String((n==null?void 0:n.session_id)||"").trim();return l&&r.set("session_id",l),(n==null?void 0:n.root_only)===!0&&r.set("root_only","true"),await this._get_json("list_runs",`api/gateway/runs?${r.toString()}`)}async download_run_artifact_content(n,r,i){const l=String(n||"").trim(),u=String(r||"").trim();if(!l)throw new Error("download_run_artifact_content: run_id is required");if(!u)throw new Error("download_run_artifact_content: artifact_id is required");const m=String((i==null?void 0:i.access)||"").trim(),d=m?`?access=${encodeURIComponent(m)}`:"";return await(await this._fetch("download_run_artifact_content",`api/gateway/runs/${encodeURIComponent(l)}/artifacts/${encodeURIComponent(u)}/content${d}`)).blob()}async attachments_upload(n,r,i){const l=String(n||"").trim();if(!l)throw new Error("attachments_upload: session_id is required");if(!r)throw new Error("attachments_upload: file is required");const u=String((i==null?void 0:i.filename)||"").trim()||String((r==null?void 0:r.name)||"").trim()||"upload.bin",m=String((i==null?void 0:i.content_type)||"").trim()||String((r==null?void 0:r.type)||"").trim(),d=new FormData;d.append("session_id",l),d.append("file",r,u),d.append("filename",u),m&&d.append("content_type",m);const p=await this._post_form("attachments_upload","api/gateway/attachments/upload",d),b=p==null?void 0:p.attachment;if(!b||typeof b!="object")throw new Error("attachments_upload: missing attachment");if(!String(b.$artifact||"").trim())throw new Error("attachments_upload: missing attachment.$artifact");return b}async audio_transcribe(n,r){const i=String(n||"").trim();if(!i)throw new Error("audio_transcribe: run_id is required");const l=r==null?void 0:r.audio_artifact;if(!l||typeof l!="object")throw new Error("audio_transcribe: audio_artifact is required");if(!String(l.$artifact||"").trim())throw new Error("audio_transcribe: audio_artifact.$artifact is required");const m={audio_artifact:l},d=String((r==null?void 0:r.language)||"").trim();d&&(m.language=d);const p=String((r==null?void 0:r.request_id)||"").trim();p&&(m.request_id=p);const b=await this._post_json("audio_transcribe",`api/gateway/runs/${encodeURIComponent(i)}/audio/transcribe`,m);return{ok:!!(b!=null&&b.ok),run_id:String((b==null?void 0:b.run_id)||""),request_id:String((b==null?void 0:b.request_id)||""),text:String((b==null?void 0:b.text)||""),transcript_artifact:b==null?void 0:b.transcript_artifact}}async voice_tts(n,r){const i=String(n||"").trim();if(!i)throw new Error("voice_tts: run_id is required");const l=String((r==null?void 0:r.text)||"").trim();if(!l)throw new Error("voice_tts: text is required");const u={text:l,...Jf(r)},m=String((r==null?void 0:r.format)||"").trim();m&&(u.format=m),typeof(r==null?void 0:r.timeout_s)=="number"&&r.timeout_s>0&&(u.timeout_s=r.timeout_s);const d=String((r==null?void 0:r.request_id)||"").trim();d&&(u.request_id=d);const p=await this._post_json("voice_tts",`api/gateway/runs/${encodeURIComponent(i)}/voice/tts`,u);return{ok:!!(p!=null&&p.ok),run_id:String((p==null?void 0:p.run_id)||""),request_id:String((p==null?void 0:p.request_id)||""),audio_artifact:p==null?void 0:p.audio_artifact}}async capability_defaults(){return await this._get_json("capability_defaults","api/gateway/config/capability-defaults")}async voice_voices(n){const r=new URLSearchParams({compact:"true"}),i=String((n==null?void 0:n.provider)||"").trim(),l=String((n==null?void 0:n.model)||"").trim();return i&&r.set("provider",i),l&&r.set("model",l),n!=null&&n.providers_only&&r.set("providers_only","true"),await this._get_json("voice_voices",`api/gateway/voice/voices?${r.toString()}`)}voice_stream_transport(n,r){const i=String(n||"").trim();if(!i)throw new Error("voice_stream_transport: run_id is required");return{path:Hu(this._cfg.base_url,`api/gateway/runs/${encodeURIComponent(i)}/voice/tts/stream`),body:{text:String((r==null?void 0:r.text)||""),format:"wav",...Jf(r)},headers:Zu(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(n){const r=String(n||"").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(n){const r=String(n||"").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(n){return await this._post_json("bug_report_create","api/gateway/bugs/report",Qf(n,"bug_report_create"))}async feature_report_create(n){return await this._post_json("feature_report_create","api/gateway/features/report",Qf(n,"feature_report_create"))}async email_list_accounts(){return await this._get_json("email_list_accounts","api/gateway/email/accounts")}async email_list_messages(n){const r=new URLSearchParams,i=String((n==null?void 0:n.account)||"").trim();i&&r.set("account",i);const l=String((n==null?void 0:n.mailbox)||"").trim();l&&r.set("mailbox",l);const u=String((n==null?void 0:n.since)||"").trim();u&&r.set("since",u);const m=String((n==null?void 0:n.status)||"").trim();return m&&r.set("status",m),r.set("limit",String(typeof(n==null?void 0:n.limit)=="number"&&Number.isFinite(n.limit)?Number(n.limit):20)),await this._get_json("email_list_messages",`api/gateway/email/messages?${r.toString()}`)}async email_read_message(n,r){const i=String(n||"").trim();if(!i)throw new Error("email_read_message: uid is required");const l=new URLSearchParams,u=String((r==null?void 0:r.account)||"").trim();u&&l.set("account",u);const m=String((r==null?void 0:r.mailbox)||"").trim();m&&l.set("mailbox",m);const d=typeof(r==null?void 0:r.max_body_chars)=="number"&&Number.isFinite(r.max_body_chars)?Number(r.max_body_chars):2e4;return l.set("max_body_chars",String(d)),await this._get_json("email_read_message",`api/gateway/email/messages/${encodeURIComponent(i)}?${l.toString()}`)}async email_send(n){if(!String((n==null?void 0:n.subject)||"").trim())throw new Error("email_send: subject is required");return await this._post_json("email_send","api/gateway/email/send",n||{})}async triage_run(n){const r={};return typeof(n==null?void 0:n.write_drafts)=="boolean"&&(r.write_drafts=!!n.write_drafts),typeof(n==null?void 0:n.enable_llm)=="boolean"&&(r.enable_llm=!!n.enable_llm),await this._post_json("triage_run","api/gateway/triage/run",r)}async list_triage_decisions(n){const r=new URLSearchParams,i=String((n==null?void 0:n.status)||"").trim();return i&&r.set("status",i),r.set("limit",String(typeof(n==null?void 0:n.limit)=="number"&&Number.isFinite(n.limit)?Number(n.limit):200)),await this._get_json("list_triage_decisions",`api/gateway/triage/decisions?${r.toString()}`)}async apply_triage_decision(n,r){const i=String(n||"").trim();if(!i)throw new Error("apply_triage_decision: decision_id is required");const l=String((r==null?void 0:r.action)||"").trim();if(!l)throw new Error("apply_triage_decision: action is required");const u={action:l};if(l==="defer"){const m=r==null?void 0:r.defer_days;typeof m=="number"&&Number.isFinite(m)&&m>0&&(u.defer_days=Number(m))}return await this._post_json("apply_triage_decision",`api/gateway/triage/decisions/${encodeURIComponent(i)}/apply`,u)}async backlog_list(n){const r=String(n||"").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(n,r){const i=String(n||"").trim(),l=String(r||"").trim();if(!i)throw new Error("backlog_content: kind is required");if(!l)throw new Error("backlog_content: filename is required");return await this._get_json("backlog_content",`api/gateway/backlog/${encodeURIComponent(i)}/${encodeURIComponent(l)}/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(n){const r=String((n==null?void 0:n.from_kind)||"").trim(),i=String((n==null?void 0:n.to_kind)||"").trim(),l=String((n==null?void 0:n.filename)||"").trim();if(!r)throw new Error("backlog_move: from_kind is required");if(!i)throw new Error("backlog_move: to_kind is required");if(!l)throw new Error("backlog_move: filename is required");return await this._post_json("backlog_move","api/gateway/backlog/move",{from_kind:r,to_kind:i,filename:l})}async backlog_update(n){const r=String((n==null?void 0:n.kind)||"").trim(),i=String((n==null?void 0:n.filename)||"").trim();if(!r)throw new Error("backlog_update: kind is required");if(!i)throw new Error("backlog_update: filename is required");const l={content:String((n==null?void 0:n.content)??"")},u=String((n==null?void 0:n.expected_sha256)||"").trim();return u&&(l.expected_sha256=u),await this._post_json("backlog_update",`api/gateway/backlog/${encodeURIComponent(r)}/${encodeURIComponent(i)}/update`,l)}async backlog_create(n){const r=String((n==null?void 0:n.kind)||"").trim(),i=String((n==null?void 0:n.package)||"").trim(),l=String((n==null?void 0:n.title)||"").trim();if(!r)throw new Error("backlog_create: kind is required");if(!i)throw new Error("backlog_create: package is required");if(!l)throw new Error("backlog_create: title is required");const u={kind:r,package:i,title:l},m=String((n==null?void 0:n.task_type)||"").trim();m&&(u.task_type=m);const d=String((n==null?void 0:n.summary)||"").trim();d&&(u.summary=d);const p=(n==null?void 0:n.content)==null?"":String((n==null?void 0:n.content)??"");return p.trim()&&(u.content=p),await this._post_json("backlog_create","api/gateway/backlog/create",u)}async backlog_merge(n){const r=String((n==null?void 0:n.kind)||"").trim(),i=String((n==null?void 0:n.package)||"").trim(),l=String((n==null?void 0:n.title)||"").trim(),u=Array.isArray(n==null?void 0:n.items)?n.items:[];if(!r)throw new Error("backlog_merge: kind is required");if(!i)throw new Error("backlog_merge: package is required");if(!l)throw new Error("backlog_merge: title is required");if(u.length<2)throw new Error("backlog_merge: at least 2 items are required");const m={kind:r,package:i,title:l,items:u.map(b=>({kind:String((b==null?void 0:b.kind)||"").trim(),filename:String((b==null?void 0:b.filename)||"").trim()}))},d=String((n==null?void 0:n.task_type)||"").trim();d&&(m.task_type=d);const p=String((n==null?void 0:n.summary)||"").trim();return p&&(m.summary=p),await this._post_json("backlog_merge","api/gateway/backlog/merge",m)}async backlog_upload_attachment(n){const r=String((n==null?void 0:n.kind)||"").trim(),i=String((n==null?void 0:n.filename)||"").trim(),l=n==null?void 0:n.file;if(!r)throw new Error("backlog_upload_attachment: kind is required");if(!i)throw new Error("backlog_upload_attachment: filename is required");if(!l)throw new Error("backlog_upload_attachment: file is required");const u=new FormData;return u.set("overwrite",(n==null?void 0:n.overwrite)===!0?"true":"false"),u.set("file",l,l.name||"attachment"),await this._post_form("backlog_upload_attachment",`api/gateway/backlog/${encodeURIComponent(r)}/${encodeURIComponent(i)}/attachments/upload`,u)}async backlog_assist(n){const r=String((n==null?void 0:n.kind)||"").trim(),i=String((n==null?void 0:n.package)||"").trim(),l=String((n==null?void 0:n.title)||"").trim();if(!r)throw new Error("backlog_assist: kind is required");if(!i)throw new Error("backlog_assist: package is required");if(!l)throw new Error("backlog_assist: title is required");const u={kind:r,package:i,title:l,messages:Array.isArray(n==null?void 0:n.messages)?n.messages:[]},m=String((n==null?void 0:n.summary)||"").trim();m&&(u.summary=m);const d=(n==null?void 0:n.draft_markdown)==null?"":String(n.draft_markdown??"");d.trim()&&(u.draft_markdown=d);const p=String((n==null?void 0:n.provider)||"").trim();p&&(u.provider=p);const b=String((n==null?void 0:n.model)||"").trim();b&&(u.model=b);const v=String((n==null?void 0:n.thinking)||"").trim();return v&&(u.thinking=v),await this._post_json("backlog_assist","api/gateway/backlog/assist",u)}async backlog_maintain(n){const r=String((n==null?void 0:n.kind)||"").trim(),i=String((n==null?void 0:n.filename)||"").trim(),l=String((n==null?void 0:n.package)||"").trim(),u=String((n==null?void 0:n.title)||"").trim();if(!r)throw new Error("backlog_maintain: kind is required");if(!i)throw new Error("backlog_maintain: filename is required");if(!l)throw new Error("backlog_maintain: package is required");if(!u)throw new Error("backlog_maintain: title is required");const m={kind:r,filename:i,package:l,title:u,messages:Array.isArray(n==null?void 0:n.messages)?n.messages:[]},d=String((n==null?void 0:n.summary)||"").trim();d&&(m.summary=d);const p=(n==null?void 0:n.draft_markdown)==null?"":String(n.draft_markdown??"");p.trim()&&(m.draft_markdown=p);const b=String((n==null?void 0:n.provider)||"").trim();b&&(m.provider=b);const v=String((n==null?void 0:n.model)||"").trim();return v&&(m.model=v),await this._post_json("backlog_maintain","api/gateway/backlog/maintain",m)}async backlog_advisor(n){const r={messages:Array.isArray(n==null?void 0:n.messages)?n.messages:[]},i=String((n==null?void 0:n.provider)||"").trim();i&&(r.provider=i);const l=String((n==null?void 0:n.model)||"").trim();l&&(r.model=l);const u=String((n==null?void 0:n.thinking)||"").trim();u&&(r.thinking=u);const m=String((n==null?void 0:n.agent)||"").trim();m&&(r.agent=m),(n==null?void 0:n.include_trace)===!0&&(r.include_trace=!0);const d=String((n==null?void 0:n.focus_kind)||"").trim();d&&(r.focus_kind=d);const p=String((n==null?void 0:n.focus_type)||"").trim();return p&&(r.focus_type=p),await this._post_json("backlog_advisor","api/gateway/backlog/advisor",r)}async backlog_execute(n){const r=String((n==null?void 0:n.kind)||"").trim(),i=String((n==null?void 0:n.filename)||"").trim();if(!r)throw new Error("backlog_execute: kind is required");if(!i)throw new Error("backlog_execute: filename is required");const l=new URLSearchParams,u=String((n==null?void 0:n.execution_mode)||"").trim();u&&l.set("execution_mode",u);const m=String((n==null?void 0:n.executor)||"").trim();m&&l.set("executor",m);const d=String((n==null?void 0:n.target_model)||"").trim();d&&l.set("target_model",d);const p=String((n==null?void 0:n.target_reasoning_effort)||"").trim();return p&&l.set("target_reasoning_effort",p),(n==null?void 0:n.dor)==="check"&&l.set("dor","check"),(n==null?void 0:n.override)===!0&&l.set("override","true"),await(await this._fetch("backlog_execute",`api/gateway/backlog/${encodeURIComponent(r)}/${encodeURIComponent(i)}/execute${l.toString()?`?${l.toString()}`:""}`,{method:"POST"})).json()}async backlog_execute_batch(n){const r=Array.isArray(n==null?void 0:n.items)?n.items:[];if(!r.length)throw new Error("backlog_execute_batch: items are required");const i={items:r.map(p=>({kind:String((p==null?void 0:p.kind)||"").trim(),filename:String((p==null?void 0:p.filename)||"").trim()}))},l=String((n==null?void 0:n.execution_mode)||"").trim();l&&(i.execution_mode=l);const u=String((n==null?void 0:n.executor)||"").trim();u&&(i.executor=u);const m=String((n==null?void 0:n.target_model)||"").trim();m&&(i.target_model=m);const d=String((n==null?void 0:n.target_reasoning_effort)||"").trim();return d&&(i.target_reasoning_effort=d),(n==null?void 0:n.dor)==="check"&&(i.dor="check"),(n==null?void 0:n.override)===!0&&(i.override=!0),await this._post_json("backlog_execute_batch","api/gateway/backlog/execute_batch",i)}async backlog_exec_config(){return await this._get_json("backlog_exec_config","api/gateway/backlog/exec/config")}async backlog_exec_requests(n){const r=new URLSearchParams,i=String((n==null?void 0:n.status)||"").trim();return i&&r.set("status",i),r.set("limit",String(typeof(n==null?void 0:n.limit)=="number"&&Number.isFinite(n.limit)?Number(n.limit):200)),await this._get_json("backlog_exec_requests",`api/gateway/backlog/exec/requests?${r.toString()}`)}async backlog_exec_request(n,r){const i=String(n||"").trim();if(!i)throw new Error("backlog_exec_request: request_id is required");const l=new URLSearchParams;return(r==null?void 0:r.include_prompt)===!0&&l.set("include_prompt","true"),await this._get_json("backlog_exec_request",`api/gateway/backlog/exec/requests/${encodeURIComponent(i)}?${l.toString()}`)}async backlog_exec_feedback(n){const r=String((n==null?void 0:n.request_id)||"").trim();if(!r)throw new Error("backlog_exec_feedback: request_id is required");const i=String((n==null?void 0:n.feedback)??"");if(!i.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:i})}async backlog_exec_promote(n){const r=String((n==null?void 0:n.request_id)||"").trim();if(!r)throw new Error("backlog_exec_promote: request_id is required");const i={};return(n==null?void 0:n.redeploy)===!0&&(i.redeploy=!0),await this._post_json("backlog_exec_promote",`api/gateway/backlog/exec/requests/${encodeURIComponent(r)}/promote`,i)}async backlog_exec_deploy_uat(n){const r=String((n==null?void 0:n.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(n){const r=String((n==null?void 0:n.request_id)||"").trim();if(!r)throw new Error("backlog_exec_log_tail: request_id is required");const i=new URLSearchParams,l=String((n==null?void 0:n.name)||"").trim();l&&i.set("name",l);const u=typeof(n==null?void 0:n.max_bytes)=="number"&&Number.isFinite(n.max_bytes)?Number(n.max_bytes):0;u>0&&i.set("max_bytes",String(Math.floor(u)));const m=typeof(n==null?void 0:n.after_bytes)=="number"&&Number.isFinite(n.after_bytes)?Math.max(0,Math.floor(n.after_bytes)):null;return m!==null&&i.set("after_bytes",String(m)),await this._get_json("backlog_exec_log_tail",`api/gateway/backlog/exec/requests/${encodeURIComponent(r)}/logs/tail?${i.toString()}`)}async backlog_exec_active_items(n){const r=new URLSearchParams,i=String((n==null?void 0:n.status)||"").trim();return i&&r.set("status",i),r.set("limit",String(typeof(n==null?void 0:n.limit)=="number"&&Number.isFinite(n.limit)?Number(n.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(n){const r=String(n||"").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(n){const r=String(n||"").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(n){return await(await this._fetch("admin_runtime_config_update","api/gateway/admin/runtime-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n||{})})).json()}async entity_state(n,r){return await(await this._fetch("entity_state",`api/gateway/entities/${encodeURIComponent(n)}/state`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})).json()}async entity_skills(n){return await(await this._fetch("entity_skills",`api/gateway/entities/${encodeURIComponent(n)}/skills`)).json()}async put_entity_skills(n,r){return await(await this._fetch("put_entity_skills",`api/gateway/entities/${encodeURIComponent(n)}/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(n){const r={},i=n!=null&&n.set&&typeof n.set=="object"?n.set:{},l=Array.isArray(n==null?void 0:n.unset)?n==null?void 0:n.unset:[];return i&&Object.keys(i).length&&(r.set=i),l&&l.length&&(r.unset=l),await this._post_json("update_process_env_vars","api/gateway/processes/env",r)}async start_process(n){const r=String(n||"").trim();return await this._post_json("start_process",`api/gateway/processes/${encodeURIComponent(r)}/start`)}async stop_process(n){const r=String(n||"").trim();return await this._post_json("stop_process",`api/gateway/processes/${encodeURIComponent(r)}/stop`)}async restart_process(n){const r=String(n||"").trim();return await this._post_json("restart_process",`api/gateway/processes/${encodeURIComponent(r)}/restart`)}async redeploy_process(n){const r=String(n||"").trim();return await this._post_json("redeploy_process",`api/gateway/processes/${encodeURIComponent(r)}/redeploy`)}async process_log_tail(n,r){const i=String(n||"").trim(),l=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(i)}/logs/tail?max_bytes=${encodeURIComponent(String(l))}`)}}function Qf(a,n){const r=String((a==null?void 0:a.session_id)||"").trim();if(!r)throw new Error(`${n}: session_id is required`);const i=String((a==null?void 0:a.description)||"").trim();if(!i)throw new Error(`${n}: description is required`);const l={session_id:r,description:i};for(const m of["active_run_id","workflow_id","client","client_version","user_agent","url","provider","model","template"]){const d=String((a==null?void 0:a[m])||"").trim();d&&(l[m]=d)}const u=a==null?void 0:a.context;return u&&typeof u=="object"&&(l.context=u),l}const Yf={framework:null,gateway:null,gatewayNote:"checking…"};function Rv(a){if(a instanceof op){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 Mv(a){let n;try{n=await a.gateway_about()}catch(r){return If(null,Rv(r))}return If(n)}const Xf=Id("voice and camera")??"Voice and camera are not supported in this browser (getUserMedia unavailable).",Pv="Copy failed — select and copy";function Zf(){var n;const a=globalThis.navigator;return typeof((n=a==null?void 0:a.mediaDevices)==null?void 0:n.getUserMedia)=="function"}function zv(a){var l;const n=globalThis.document;if(!n||!n.body||typeof n.execCommand!="function")return!1;const r=n.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 i=n.activeElement;n.body.appendChild(r);try{return r.select(),r.setSelectionRange(0,a.length),n.execCommand("copy")===!0}catch{return!1}finally{n.body.removeChild(r);try{(l=i==null?void 0:i.focus)==null||l.call(i)}catch{}}}async function Iv(a){var i;const n=String(a??""),r=globalThis.navigator;if(typeof((i=r==null?void 0:r.clipboard)==null?void 0:i.writeText)=="function")try{return await r.clipboard.writeText(n),!0}catch{}return zv(n)}const Dv=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 Ov(a){const n=a.length,r=new Uint8Array(n+9+63>>6<<6);r.set(a),r[n]=128;const i=new DataView(r.buffer);i.setUint32(r.length-8,Math.floor(n/536870912),!1),i.setUint32(r.length-4,n<<3>>>0,!1);const l=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),u=new Uint32Array(64),m=(d,p)=>d>>>p|d<<32-p;for(let d=0;d<r.length;d+=64){for(let E=0;E<16;E++)u[E]=i.getUint32(d+E*4,!1);for(let E=16;E<64;E++){const I=m(u[E-15],7)^m(u[E-15],18)^u[E-15]>>>3,D=m(u[E-2],17)^m(u[E-2],19)^u[E-2]>>>10;u[E]=u[E-16]+I+u[E-7]+D>>>0}let[p,b,v,y,C,L,T,$]=[l[0],l[1],l[2],l[3],l[4],l[5],l[6],l[7]];for(let E=0;E<64;E++){const I=m(C,6)^m(C,11)^m(C,25),D=C&L^~C&T,O=$+I+D+Dv[E]+u[E]>>>0,q=m(p,2)^m(p,13)^m(p,22),A=p&b^p&v^b&v,H=q+A>>>0;$=T,T=L,L=C,C=y+O>>>0,y=v,v=b,b=p,p=O+H>>>0}l[0]=l[0]+p>>>0,l[1]=l[1]+b>>>0,l[2]=l[2]+v>>>0,l[3]=l[3]+y>>>0,l[4]=l[4]+C>>>0,l[5]=l[5]+L>>>0,l[6]=l[6]+T>>>0,l[7]=l[7]+$>>>0}return Array.from(l,d=>d.toString(16).padStart(8,"0")).join("")}async function lp(a){var i;const n=new TextEncoder().encode(String(a??"")),r=(i=globalThis.crypto)==null?void 0:i.subtle;if(r&&typeof r.digest=="function"){const l=await r.digest("SHA-256",n);return Array.from(new Uint8Array(l),u=>u.toString(16).padStart(2,"0")).join("")}return Ov(n)}const Fv=/^[a-zA-Z0-9_-]+$/;function eh(a){return Fv.test(String(a||"").trim())}async function qv(a){const n=String(a||""),r=new TextEncoder().encode(n),i=globalThis.crypto;if(!i||!i.subtle||typeof i.subtle.digest!="function")return"";const l=await i.subtle.digest("SHA-256",r);return Array.from(new Uint8Array(l)).map(u=>u.toString(16).padStart(2,"0")).join("")}async function Od(a){const n=String(a||"").trim();if(!n)throw new Error("session_id is required");if(eh(n)){const i=`session_memory_${n}`;if(eh(i))return i}return`session_memory_sha_${(await qv(n)).slice(0,32)}`}const Za=["bug","feature","improvement","task"];function Xo(a){return String(a||"").trim().toLowerCase()}function cp(a){return Za.includes(Xo(a))}function up(a){const n=Xo(a);return cp(n)?n:"task"}function dp(a){return a.toUpperCase()}function mp(a){return a==="bug"?"danger":a==="feature"?"ok":a==="improvement"?"info":a==="task"?"task":"muted"}function fp(a){return cp(a)?void 0:`"${a}" is not in the ruled type vocabulary (${Za.join(" / ")})`}function hp(a){const n=String(a||"").trim();return n.replace(/^\[(bug|feature|improvement|task)\]\s*/i,"").trim()||n}function _a(a,n){const r=String(a||"");return r.length<=n?r:`${r.slice(0,Math.max(0,n-1))}…`}function xd(a=new Date){const n=d=>String(d).padStart(2,"0"),r=-a.getTimezoneOffset(),i=r>=0?"+":"-",l=Math.abs(r),u=n(Math.floor(l/60)),m=n(l%60);return`${a.getFullYear()}-${n(a.getMonth()+1)}-${n(a.getDate())} ${n(a.getHours())}:${n(a.getMinutes())}:${n(a.getSeconds())} ${i}${u}${m}`}function Uv(a){try{return JSON.parse(a)}catch{return null}}function th(a,n){return a.scrollHeight-a.scrollTop-a.clientHeight<=n}function td(a){const n=typeof a=="string"?a.trim():"";if(!n)return null;const r=n.replace(/(\.\d{3})\d+/,"$1"),i=Date.parse(r);return Number.isFinite(i)?i:null}function Hs(a){if(!Number.isFinite(a))return"";const n=Math.max(0,Math.floor(a/1e3)),r=n%60,i=Math.floor(n/60),l=i%60,u=Math.floor(i/60),m=u%24,d=Math.floor(u/24);return d>0?`${d}d ${m}h`:u>0?`${u}h ${l}m`:i>0?`${i}m ${r}s`:`${n}s`}async function bd(a){return lp(String(a||""))}function Qo(a){const n=String(a||"").trim().toLowerCase();return n==="completed"||n==="promoted"?"ok":n==="failed"?"danger":n==="running"?"info":n==="queued"||n==="awaiting_qa"?"warn":"muted"}function Bv(a,n){return a==="processing"?"queued,running,awaiting_qa":a==="failed"?"failed":a==="completed"&&n==="runs"?"completed,promoted":""}function Io(a,n){const r=a&&typeof a=="object"?a:{},i=r.backlog&&typeof r.backlog=="object"?r.backlog:{},l=r.result&&typeof r.result=="object"?r.result:{},u=r.executor&&typeof r.executor=="object"?r.executor:{},m=String(l.last_message||"").trim(),d=String(r.target_model||u.model||"").trim(),p=String(r.target_reasoning_effort||u.reasoning_effort||"").trim();return{request_id:n,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:i.relpath??null,backlog_kind:i.kind??null,backlog_filename:i.filename??null,target_agent:r.target_agent??null,target_model:d||null,target_reasoning_effort:p||null,executor_type:u.type??null,ok:typeof l.ok=="boolean"?l.ok:null,exit_code:typeof l.exit_code=="number"?l.exit_code:l.exit_code??null,error:typeof l.error=="string"?l.error:l.error??null,run_dir_relpath:r.run_dir_relpath??null,last_message:Wv(m)}}const nd=1200;function Wv(a){const n=String(a||"");return n?n.length<=nd?n:`${n.slice(0,nd)}
58
+ … [#TRUNCATION: ${nd} of ${n.length} chars; the full last_message is in the run directory]`:null}function Hv(a){const n=String(a||""),r=n.split(/\r?\n/).filter(u=>String(u||"").trim().length>0),i=[];let l=0;for(let u=0;u<r.length;u+=1){const m=String(r[u]||"").trim(),d=Uv(m);if(!d||typeof d!="object"){l+=1,i.push({idx:u,type:"raw",payload:null,raw:m});continue}const p=String(d.type||d.event||"event");i.push({idx:u,type:p,payload:d,raw:m})}return{total:r.length,bad:l,events:i,raw:n}}function Vv(a){if(!a)return null;let n=0,r=0,i=0,l=0,u=0;for(const d of a.events){const p=d.payload,b=p&&typeof p.usage=="object"?p.usage:null;b&&(Number.isFinite(Number(b.input_tokens))&&(n+=Number(b.input_tokens)),Number.isFinite(Number(b.cached_input_tokens))&&(r+=Number(b.cached_input_tokens)),Number.isFinite(Number(b.output_tokens))&&(i+=Number(b.output_tokens)));const v=p&&typeof p.item=="object"?p.item:null;v&&String(v.type||"").trim()==="command_execution"&&(l+=1,String(v.status||"").trim().toLowerCase()==="failed"&&(u+=1))}return{has_tokens:n>0||i>0||r>0,input_tokens:n,cached_input_tokens:r,output_tokens:i,total_tokens:n+i,command_count:l,command_fail_count:u}}function Zo(a,n=Date.now()){const r=td(a==null?void 0:a.created_at),i=td(a==null?void 0:a.started_at),l=td(a==null?void 0:a.finished_at),u=String((a==null?void 0:a.status)||"").trim().toLowerCase(),m=l??(u==="running"?n:null),d=l!=null,p=r!=null&&i!=null?Math.max(0,i-r):null,b=i!=null&&m!=null?Math.max(0,m-i):null,v=r!=null&&m!=null?Math.max(0,m-r):null,y=!d&&r!=null?Math.max(0,n-r):null;return{is_done:d,queue_delay_ms:p,run_ms:b,total_ms:v,age_ms:y}}function Gv(a,n){const r=String(n.package_name).trim()||"{Package}",i=hp(String(n.title||"").trim()||"{Title}"),l=String(n.summary||"").trim(),u=up(n.task_type),m=`# {ID}-${r}: [${dp(u)}] ${i}`.trim();let d=String(a||"");d=d.split("{Package}").join(r).split("{Title}").join(i);const p=d.split(/\r?\n/);let b=!1;for(let T=0;T<p.length;T+=1){const $=String(p[T]||"");if($.trim().startsWith("# ")){p[T]=m,b=!0;break}if($.trim())break}b||(p.unshift("",m),p.shift());const v=`> Created: ${String(n.created_at||"").trim()}`.trim();let y=!1;for(let T=0;T<Math.min(p.length,40);T+=1)if(String(p[T]||"").trim().toLowerCase().startsWith("> created:")){p[T]=v,y=!0;break}if(!y){const T=p.length>1&&!String(p[1]||"").trim()?2:1;p.splice(T,0,v,"")}const C=`> Type: ${u}`.trim();let L=!1;for(let T=0;T<Math.min(p.length,60);T+=1)if(String(p[T]||"").trim().toLowerCase().startsWith("> type:")){p[T]=C,L=!0;break}if(!L){let T=-1;for(let $=0;$<Math.min(p.length,60);$+=1)if(String(p[$]||"").trim().toLowerCase().startsWith("> created:")){T=$;break}if(T>=0){const $=T+1;$<p.length&&!String(p[$]||"").trim()?p.splice($,0,C):p.splice($,0,C,"")}else{const $=p.length>1&&!String(p[1]||"").trim()?2:1;p.splice($,0,C,"")}}if(l){for(let T=0;T<p.length;T+=1)if(String(p[T]||"").trim().toLowerCase()==="## summary"){let $=T+1;for(;$<p.length&&!String(p[$]||"").trim();)$+=1;($<p.length?String(p[$]||""):"").trim().toLowerCase().startsWith("one paragraph describing")?p[$]=l:p.splice(T+1,0,l,"");break}}return d=p.join(`
59
+ `),d.endsWith(`
60
+ `)||(d+=`
61
+ `),d}function Ja(a){return String(a||"").split(/\r?\n/).map(n=>n.trim()).filter(Boolean)}function Kv(a){const n=String(a.package_name||"").trim()||"{Package}",r=hp(String(a.title||"").trim()||"{Title}"),i=up(a.task_type),l=String(a.created_at||"").trim()||xd(),u=String(a.diagram||"").trim(),m=String(a.context||"").trim(),d=[];return d.push(`# {ID}-${n}: [${dp(i)}] ${r}`),d.push(""),d.push(`> Created: ${l}`),d.push(`> Type: ${i}`),d.push(""),d.push("## Summary"),d.push(a.summary.trim()||"One paragraph describing what this task accomplishes (user value + outcome)."),d.push(""),d.push("## Diagram"),d.push("```"),d.push(u||`ASCII diagram of the system change.
62
+ Show inputs/outputs and where code lives.`),d.push("```"),d.push(""),d.push("## Context"),d.push(m||"(why is this needed? link to evidence: bug/feature report paths, discussions, etc.)"),d.push(""),d.push("## Scope"),d.push("### Included"),a.included.length?d.push(...a.included.map(p=>`- ${p}`)):d.push("- "),d.push(""),d.push("### Excluded"),a.excluded.length?d.push(...a.excluded.map(p=>`- ${p}`)):d.push("- "),d.push(""),d.push("## Implementation Plan"),a.plan.length?d.push(...a.plan.map((p,b)=>`${b+1}. ${p}`)):d.push("1. "),d.push(""),d.push("## Dependencies"),a.dependencies.length?d.push(...a.dependencies.map(p=>`- ${p}`)):d.push("- Related backlog items / ADRs"),d.push(""),d.push("## Acceptance Criteria"),a.acceptance.length?d.push(...a.acceptance.map(p=>`- [ ] ${p}`)):d.push("- [ ] Criterion 1 (clear, testable)"),d.push(""),d.push("## Testing (ADR-0019)"),d.push("- Level A:"),a.tests_a.length?d.push(...a.tests_a.map(p=>` - \`${p}\``)):d.push(" - `...`"),d.push("- Level B:"),a.tests_b.length?d.push(...a.tests_b.map(p=>` - \`${p}\``)):d.push(" - `...`"),d.push("- Level C (optional / opt-in):"),a.tests_c.length?d.push(...a.tests_c.map(p=>` - \`${p}\``)):d.push(" - n/a"),d.push(""),d.push("## Related"),d.push("- ADRs:"),d.push("- Code:"),d.push("- Reports:"),a.attachments.length&&(d.push("- Attachments:"),d.push(...a.attachments.map(p=>` - ${p}`))),d.push(""),d.push("---"),d.push("## Report (added when completed)"),d.push(""),d.push("> Completed: YYYY-MM-DD"),d.push(""),d.push("### What changed"),d.push("- "),d.push(""),d.push("### Security / hardening"),d.push("- "),d.push(""),d.push("### Testing (ADR-0019)"),d.push("Levels executed:"),d.push("- A:"),d.push("- B:"),d.push("- C (if any):"),d.push(""),d.push("Commands run:"),d.push("- `...`"),d.push(""),d.push("### Follow-ups"),d.push("- "),d.push(""),d.join(`
63
+ `)}function Jv(a,n){const r=n.map(p=>String(p||"").trim()).filter(Boolean);if(!r.length)return a;const i=String(a||"").split(/\r?\n/),l=i.map(p=>p.toLowerCase()),u=l.findIndex(p=>p.trim()==="## related");if(u<0)return`${String(a||"").trimEnd()}
64
+
65
+ ## Related
66
+ - Attachments:
67
+ ${r.map(b=>` - ${b}`).join(`
68
+ `)}
69
+ `;let m=-1;for(let p=u+1;p<i.length;p+=1){const b=l[p].trim();if(b.startsWith("## ")||b.startsWith("---"))break;if(b.startsWith("- attachments:")){m=p;break}}const d=["- Attachments:",...r.map(p=>` - ${p}`)];if(m>=0){let p=m+1;for(;p<i.length&&/^\s+-\s/.test(i[p]);)p+=1;i.splice(p,0,...r.map(b=>` - ${b}`))}else{let p=u+1;for(let b=u+1;b<i.length;b+=1){const v=l[b].trim();if(v.startsWith("## ")||v.startsWith("---")){p=b;break}p=b+1}i.splice(p,0,...d,"")}return i.join(`
70
+ `)}function Qv(a,n){const r=Fh(a);if(!r.ok)return null;const i=r.payload.phases.map(m=>m.id),l=new Map;for(const m of n)l.set(`${m.section}\0${m.item}\0${m.phase}`,m.op);const u=[];for(const m of r.payload.sections)for(const d of m.items){const p=[];for(const b of i){const v=d.cells[b];if(!v)continue;const y=l.get(`${m.id}\0${d.id}\0${b}`);(y?y==="grant":!!v.assigned)&&p.push(b)}p.length&&(p.length===i.length?u.push({name:d.id}):u.push({name:d.id,phases:p}))}return u}function Yv(a){var A,H;const{gateway:n,entity_name:r}=a,[i,l]=h.useState(null),[u,m]=h.useState(""),[d,p]=h.useState(!1),[b,v]=h.useState([]),[y,C]=h.useState(!1),[L,T]=h.useState(""),[$,E]=h.useState(""),I=h.useCallback(async()=>{p(!0),m("");try{l(await n.entity_skills(r))}catch(fe){l(null),m(String((fe==null?void 0:fe.message)||fe))}finally{p(!1)}},[n,r]);h.useEffect(()=>{v([]),E(""),T(""),I()},[I]);async function D(){if(!(i!=null&&i.matrix))return;const fe=Qv(i.matrix,b);if(fe===null){T("Cannot serialize the selection: the matrix payload failed validation — refresh and retry.");return}C(!0),T("");try{const ie=await n.put_entity_skills(r,fe);l(ie),v([]),E("Selection saved — recorded as a host marker on the entity's stream."),setTimeout(()=>E(""),5e3)}catch(ie){T(String((ie==null?void 0:ie.message)||ie))}finally{C(!1)}}const O=Array.isArray((A=i==null?void 0:i.selection)==null?void 0:A.warnings)?i.selection.warnings.map(String):[],q=Array.isArray((H=i==null?void 0:i.resolved)==null?void 0:H.skills)?i.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 I(),disabled:d||y,title:"Reload the resolved view (discards pending edits)",children:d?"Loading…":"Refresh"}),e.jsx("button",{className:"btn",onClick:a.on_close,children:"Close"})]})]}),u?e.jsxs("div",{className:"page_error",children:["Skills unavailable: ",u]}):null,O.length?e.jsx("div",{className:"detail_warn",style:{marginTop:4},children:O.join(" · ")}):null,q.length?e.jsx("div",{className:"entity_skills_resolved",children:q.map(fe=>{const ie=String((fe==null?void 0:fe.name)||""),Se=!!(fe!=null&&fe.active),ke=!!(fe!=null&&fe.blocked),le=!!(fe!=null&&fe.requires_review),pe=fe==null?void 0:fe.requires_unmet,G=Array.isArray(pe)?pe.map(String):pe&&typeof pe=="object"?Object.entries(pe).map(([Q,M])=>`${Q}: ${String(M)}`):[],te=Se?"ok":ke?"danger":G.length||le?"warn":"muted",ae=Se?"active":ke?"blocked":G.length?"requires unmet":le?"requires review":"inactive",U=[...Array.isArray(fe==null?void 0:fe.reasons)?fe.reasons.map(String):[],...G].join("; ");return e.jsxs("span",{className:`chip mono ${te}`,title:U||void 0,children:[ie," · ",ae]},ie)})}):null,e.jsx(xg,{payload:i==null?void 0:i.matrix,patches:b,onPatchesChange:v,disabled:y||d,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 D(),disabled:y||!b.length,title:b.length?`Save ${b.length} pending change(s)`:"No pending changes",children:y?"Saving…":b.length?`Save ${b.length} change${b.length>1?"s":""}`:"Save"}),b.length?e.jsx("button",{className:"btn",onClick:()=>v([]),disabled:y,children:"Discard edits"}):null,L?e.jsx("span",{className:"page_error",style:{margin:0},children:L}):null,$?e.jsx("span",{className:"chip mono ok",children:$}):null]})]})}function Xv(a){const n=new Map;for(const r of a){const i=String(r.target_agent||(r.target_model?`${String(r.executor_type||"agent").trim()||"agent"}:${r.target_model}`:"")||"(unattributed)").trim();let l=n.get(i);l||(l={agent:i,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:""},n.set(i,l)),l.runs+=1;const u=String(r.status||"").toLowerCase();u==="queued"||u==="running"?l.active+=1:u==="promoted"?l.promoted+=1:u==="completed"?l.completed+=1:u==="failed"?l.failed+=1:u==="awaiting_qa"&&(l.awaiting_qa+=1);const m=Zo(r);m.run_ms!=null&&(l.total_run_ms+=m.run_ms,l.timed_runs+=1);const d=String(r.finished_at||r.started_at||r.created_at||"");d>l.last_active&&(l.last_active=d)}return[...n.values()].sort((r,i)=>i.runs-r.runs)}function Zv(a){const{gateway:n,gateway_connected:r}=a,i=String(a.backlog_advisor_agent||"").trim()||"basic-agent",[l,u]=h.useState(null),[m,d]=h.useState([]),[p,b]=h.useState([]),[v,y]=h.useState(""),[C,L]=h.useState(null),[T,$]=h.useState(!1),[E,I]=h.useState(""),[D,O]=h.useState(!1),[q,A]=h.useState(""),[H,fe]=h.useState(null),ie=h.useRef(0);async function Se(){if(!r||T)return;const k=++ie.current;$(!0),I("");try{const[w,K,ve]=await Promise.all([n.backlog_exec_config(),n.backlog_exec_requests({status:"queued,running,awaiting_qa",limit:200}),n.backlog_exec_requests({status:"promoted,completed,failed",limit:200})]);if(k!==ie.current)return;u(w),d([...Array.isArray(K==null?void 0:K.requests)?K.requests:[],...Array.isArray(ve==null?void 0:ve.requests)?ve.requests:[]])}catch(w){k===ie.current&&I(String((w==null?void 0:w.message)||w||"Failed to load agents"))}finally{ie.current,$(!1)}try{const w=await n.list_entities();if(k!==ie.current)return;b(Array.isArray(w==null?void 0:w.entities)?w.entities:[]),y("")}catch(w){if(k!==ie.current)return;b([]),y(`#FALLBACK entity registry unavailable: ${String((w==null?void 0:w.message)||w)}`)}try{const w=await n.admin_executors();if(k!==ie.current)return;const K=Array.isArray(w)?w:Array.isArray(w==null?void 0:w.executors)?w.executors:[];L(K)}catch{k===ie.current&&L(w=>w===null?null:w)}try{const w=await n.admin_runtime_config();k===ie.current&&O((w==null?void 0:w.writable)===!0)}catch{k===ie.current&&O(!1)}}async function ke(){ie.current+=1;try{const k=await n.list_entities();b(Array.isArray(k==null?void 0:k.entities)?k.entities:[]),y("")}catch(k){y(`#FALLBACK entity registry unavailable: ${String((k==null?void 0:k.message)||k)}`)}}async function le(){ie.current+=1;try{const k=await n.admin_executors(),w=Array.isArray(k)?k:Array.isArray(k==null?void 0:k.executors)?k.executors:[];L(w)}catch{}try{u(await n.backlog_exec_config())}catch{}}async function pe(k){if(q)return;const w=`executor:${k}`;A(w),fe(null);try{await n.admin_runtime_config_update({executor:k}),await le()}catch(K){fe({key:w,text:String((K==null?void 0:K.message)||K||"Executor change refused")})}finally{A("")}}const[G,te]=h.useState(null);async function ae(k,w){if(q)return;const K=String(k.slug||k.name||"").trim();if(!K)return;const ve=`entity:${K}`;A(ve),fe(null);try{await n.entity_state(K,{state:w,reason:"by the operator via Continuum (Agents & Entities)"}),await ke()}catch(he){fe({key:ve,text:String((he==null?void 0:he.message)||he||"State change refused")})}finally{A("")}}h.useEffect(()=>{Se()},[r]);const U=h.useMemo(()=>Xv(m),[m]),Q=!!(l!=null&&l.runner_alive),M=String((l==null?void 0:l.executor)||"").trim(),Z=!M||M==="none",ne=Z?"No execution agent":M;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."}),E?e.jsx("span",{className:"page_error mono",children:E}):null,e.jsx("div",{className:"page_toolbar_spacer"}),e.jsx("button",{className:`btn btn_icon ${T?"is_loading":""}`,onClick:()=>void Se(),disabled:!r||T,title:"Refresh","aria-label":"Refresh",children:e.jsx(He,{name:"refresh",size:16})})]}),e.jsxs("div",{className:"agents_grid",children:[C!==null&&C.length?C.map(k=>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(He,{name:"terminal",size:16})}),e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{className:"entity_card_title",children:k.display||k.id}),e.jsxs("div",{className:"entity_card_sub",children:["execution agent",k.default?" · gateway default":""]})]}),e.jsx("span",{className:`chip mono ${k.available?"ok":"danger"}`,style:{marginLeft:"auto"},children:k.available?"available":"unavailable"})]}),e.jsx("div",{className:"agent_facts",children:Array.isArray(k.models)&&k.models.length?e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"models:"})," ",k.models.slice(0,4).join(", "),k.models.length>4?` +${k.models.length-4}`:""]}):null}),e.jsx("div",{className:"entity_card_actions",children:k.default?e.jsx("span",{className:"chip mono ok",title:"New executions run under this agent unless the request overrides it.",children:"gateway default"}):D?e.jsx("button",{className:"btn",disabled:!!q||k.available===!1,title:k.available===!1?"Unavailable on the gateway host — the binary is not on its PATH":q&&q!==`executor:${k.id}`?"Another action is in flight":"Make this the gateway's default executor (admin, persisted gateway-side)",onClick:()=>void pe(k.id),children:q===`executor:${k.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"})}),(H==null?void 0:H.key)===`executor:${k.id}`?e.jsx("div",{className:"detail_warn",children:H.text}):null]},k.id)):l?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(He,{name:"terminal",size:16})}),e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{className:"entity_card_title",children:ne}),e.jsx("div",{className:"entity_card_sub",children:Z?"enable one from Settings → Gateway administration":"execution agent (gateway-configured)"})]}),e.jsx("span",{className:`chip mono ${Q?"ok":Z?"warn":"danger"}`,style:{marginLeft:"auto"},children:Q?"available":Z?"not configured":"offline"})]}),e.jsxs("div",{className:"agent_facts",children:[l.codex_model?e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"model:"})," ",l.codex_model]}):null,l.codex_reasoning_effort?e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"reasoning:"})," ",l.codex_reasoning_effort]}):null,e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"can execute:"})," ",l.can_execute?"yes":"no"]}),l.runner_error?e.jsx("div",{className:"page_error",children:l.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(He,{name:"edit",size:16})}),e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{className:"entity_card_title",children:i}),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 k;return(k=a.on_open_assistant)==null?void 0:k.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:[p.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:[v?e.jsx("div",{className:"page_error",style:{fontSize:"var(--font-size-sm)"},children:v}):null,!v&&!p.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,p.length?e.jsx("div",{className:"agents_grid",style:{marginTop:0},children:p.map(k=>{var z,be,Ae,De,Me,lt;if(k.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(He,{name:"warning",size:16})}),e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{className:"entity_card_title",children:k.name||k.slug||"(unreadable home)"}),e.jsx("div",{className:"entity_card_sub mono",children:k.entity_id||k.slug})]}),e.jsx("span",{className:"chip mono danger",style:{marginLeft:"auto"},children:"error"})]}),e.jsx("div",{className:"detail_warn",style:{marginTop:0},children:k.error})]},k.entity_id||k.slug||k.name);const w=String(((z=k.state)==null?void 0:z.state)||"unknown").toLowerCase(),K=w==="awake"?"ok":w==="asleep"?"info":w==="paused"?"warn":"muted",he=String(k.liveness||((be=k.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(He,{name:"agent",size:16})}),e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{className:"entity_card_title",children:k.name||k.slug}),e.jsx("div",{className:"entity_card_sub mono",children:k.entity_id})]}),he?e.jsx("span",{className:"chip mono danger",style:{marginLeft:"auto"},title:`The kill switch: served liveness=stopped (state: ${w}). Restore lives on the gateway console.`,children:"STOPPED"}):e.jsx("span",{className:`chip mono ${K}`,style:{marginLeft:"auto"},children:w})]}),e.jsxs("div",{className:"agent_facts",children:[k.created_at?e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"born:"})," ",new Date(k.created_at).toLocaleDateString()]}):null,(Ae=k.state)!=null&&Ae.reason?e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"state reason:"})," ",k.state.reason]}):null,e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"home:"})," spark ",(De=k.files)!=null&&De.spark?"✓":"—"," · memory ",(Me=k.files)!=null&&Me.memory?"✓":"—"," · book ",(lt=k.files)!=null&&lt.book?"✓":"—"]})]}),e.jsxs("div",{className:"entity_card_actions",children:[!he&&(w==="asleep"||w==="paused")?e.jsx("button",{className:"btn",disabled:!!q,title:q&&q!==`entity:${k.slug||k.name}`?"Another action is in flight":"Wake this entity (operator act, recorded as a host marker; the gateway authorizes or refuses)",onClick:()=>void ae(k,"awake"),children:q===`entity:${k.slug||k.name}`?"Waking…":"Wake"}):null,!he&&w==="awake"?e.jsx("button",{className:"btn",disabled:!!q,title:q&&q!==`entity:${k.slug||k.name}`?"Another action is in flight":"Graceful sleep (in-flight work finishes; reflection runs). The gateway refuses if a visit is live.",onClick:()=>void ae(k,"asleep"),children:q===`entity:${k.slug||k.name}`?"Sending…":"Sleep"}):null,he?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:()=>te(Ue=>Ue===(k.name||k.slug)?null:k.name||k.slug||null),title:"What this mind is taught, per phase (selection persists in the entity's home; changes record as host markers)",children:G===(k.name||k.slug)?"Hide skills":"Skills"})]}),(H==null?void 0:H.key)===`entity:${k.slug||k.name}`?e.jsx("div",{className:"detail_warn",children:H.text}):null]},k.entity_id||k.slug)})}):null,G?e.jsx(Yv,{gateway:n,entity_name:G,on_close:()=>te(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:[U.length," agent",U.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:U.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:U.map(k=>e.jsxs("tr",{children:[e.jsx("td",{className:"td_agent mono",children:k.agent}),e.jsx("td",{children:k.runs}),e.jsx("td",{className:"col_aux",children:k.active||""}),e.jsx("td",{className:"col_aux",children:k.promoted||""}),e.jsx("td",{className:"col_aux",children:k.completed||""}),e.jsx("td",{className:"col_aux",children:k.awaiting_qa||""}),e.jsx("td",{className:k.failed?"page_error":"",children:k.failed||""}),e.jsx("td",{className:"col_aux2 td_time",children:k.timed_runs?Hs(k.total_run_ms/k.timed_runs):""}),e.jsx("td",{className:"col_aux2 td_time",children:k.last_active?new Date(k.last_active).toLocaleString():""})]},k.agent))})]})}):e.jsx("div",{className:"muted",style:{fontSize:"var(--font-size-sm)",padding:"12px"},children:"No execution history yet."})})]})]})})}function Vs(a){const n=String(a||"").trim(),r=n.lastIndexOf("-");if(r<=0||r===n.length-1)return null;const i=n.slice(0,r),l=n.slice(r+1);return!/^[0-9]+$/.test(l)||!/^[a-z0-9][a-z0-9_.-]*$/.test(i)?null:{package:i,num:l}}function nh(a,n){const r=String(n||"").match(/^(\d{1,4})[-_]/);return!r||!a?null:`${a.toLowerCase()}-${r[1].padStart(4,"0")}`}function ex(a){return String(a||"").replace(/\\/g,"/").split("/").filter(Boolean).pop()||""}function tx(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 nx=/\b([a-z][a-z0-9_.-]{3,60}-\d{4})\b/g,sx=6;function ax(a){const n=[];for(const r of String(a||"").matchAll(nx)){const i=r[1];if(Vs(i)&&(n.includes(i)||n.push(i),n.length>=sx))break}return n}function pp(a,n,r=24){const i=a.started_at;if(i==null||i==="")return null;let l;if(typeof i=="number")l=i>1e12?i:i*1e3;else{const d=Date.parse(String(i));if(Number.isNaN(d))return null;l=d}const u=Math.max(0,(n-l)/36e5);return{label:u<1?`claimed ${Math.max(1,Math.round(u*60))}m`:u<48?`claimed ${Math.round(u)}h`:`claimed ${Math.round(u/24)}d`,stale:u>=r}}const el=["P0","P1","P2","P3"],_p={P0:"P0 · critical",P1:"P1 · high",P2:"P2 · normal",P3:"P3 · low"},gp=/^>\s*priority:\s*(p[0-3])\b/i,yp=/^>\s*labels:\s*(.+)$/i;function Fd(a){return String(a||"").split(",").map(n=>n.trim().toLowerCase().replace(/\s+/g,"-")).filter(n=>!!n&&n.length<=40).slice(0,12)}function sd(a,n){const r=[];let i=!1;for(const l of a){const u=l.trim();if(/^#{1,6}\s/.test(u)){i=n.test(u);continue}i&&r.push(l)}return r}const rx=["one paragraph describing","criterion 1 (clear, testable)"];function sh(a){const n=a.trim().toLowerCase();return n?rx.some(r=>n.startsWith(r)):!0}function Li(a){const n=String(a||"").split(/\r?\n/);let r=null,i=[];for(const p of n.slice(0,60)){const b=p.trim();if(/^##+\s/.test(b))break;const v=gp.exec(b);v&&!r&&(r=v[1].toUpperCase());const y=yp.exec(b);y&&!i.length&&(i=Fd(y[1]))}const l=[];for(const p of sd(n,/acceptance criteria/i)){const b=/^\s*[-*]\s*\[( |x|X)\]\s*(.+)$/.exec(p);if(!b)continue;const v=b[2].trim();sh(v)||l.push({text:v,checked:b[1].toLowerCase()==="x"})}const u=[];for(const p of sd(n,/testing/i))for(const b of p.matchAll(/`([^`]+)`/g)){const v=b[1].trim();!v||v==="..."||v.toLowerCase()==="n/a"||u.push(v)}const m=sd(n,/^#{1,6}\s*summary\b/i).map(p=>p.trim()).filter(Boolean),d=m.length>0&&!m.every(sh);return{priority:r,labels:i,acceptance:l,test_commands:u,has_summary:d}}function qd(a,n){const r=String(a.task_type||"").trim().toLowerCase(),i=[{id:"type",label:`Work type is set (${Za.join(" / ")})`,ok:Za.includes(r),evidence:r?`type: ${r}`:"no type"},{id:"summary",label:"Summary describes the outcome (not the template placeholder)",ok:n.has_summary,evidence:n.has_summary?"summary present":"empty or template placeholder"},{id:"acceptance",label:"At least one acceptance criterion",ok:n.acceptance.length>0,evidence:n.acceptance.length?`found ${n.acceptance.length}: "${ah(n.acceptance[0].text,60)}"${n.acceptance.length>1?", …":""}`:"none found under ## Acceptance Criteria"},{id:"tests",label:"At least one concrete test command (Testing A/B)",ok:n.test_commands.length>0,evidence:n.test_commands.length?`found ${n.test_commands.length}: \`${ah(n.test_commands[0],60)}\``:"none found under ## Testing"}];return{ok:i.every(l=>l.ok),checks:i}}function ah(a,n){const r=String(a||"");return r.length<=n?r:`${r.slice(0,Math.max(0,n-1))}…`}function wd(a){const n=a;if(!n||n.status!==409)return null;const r=n.body,i=r&&typeof r=="object"&&r.detail&&typeof r.detail=="object"?r.detail:r;if(!i||i.error!=="definition_of_ready_failed")return null;const u=(Array.isArray(i.checks)?i.checks:Array.isArray(i.members)?i.members.flatMap(m=>(Array.isArray(m==null?void 0:m.checks)?m.checks:[]).map(d=>({...d,label:m!=null&&m.relpath?`${m.relpath}: ${String((d==null?void 0:d.label)||"")}`:d==null?void 0:d.label}))):[]).map(m=>({id:String((m==null?void 0:m.id)||""),label:String((m==null?void 0:m.label)||""),ok:(m==null?void 0:m.ok)===!0,evidence:m!=null&&m.evidence?String(m.evidence):void 0}));return u.length?{ok:u.every(m=>m.ok),checks:u}:null}function jd(a,n){const i=[...String(a||"").split(/\r?\n/)];function l(u,m){const d=[];for(let b=0;b<Math.min(i.length,60);b+=1){const v=i[b].trim();if(/^##+\s/.test(v))break;u.test(v)&&d.push(b)}if(d.length){for(let b=d.length-1;b>=1;b-=1)i.splice(d[b],1);m?i[d[0]]=m:i.splice(d[0],1);return}if(!m)return;let p=-1;for(let b=0;b<Math.min(i.length,60);b+=1){const v=i[b].trim();if(v.startsWith("> ")&&(p=b),/^##\s/.test(v))break}if(p<0){const b=i.findIndex(v=>v.trim().startsWith("# "));if(b>=0)p=b;else{i.unshift(m);return}}i.splice(p+1,0,m)}return l(gp,n.priority?`> Priority: ${n.priority}`:null),l(yp,n.labels.length?`> Labels: ${n.labels.join(", ")}`:null),i.join(`
71
+ `)}const rh=[{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 kd(a){const n=String(a||"").trim().toUpperCase();return el.includes(n)?n:null}function Sd(a){return a.priority!==void 0||a.labels!==void 0}const ix="decision-gate";function ox(a){return Array.isArray(a)&&a.some(n=>String(n||"").trim().toLowerCase()===ix)}function vp(a,n){return ox(a.labels!==void 0?a.labels:n==null?void 0:n.labels)}function xp(a){return a.priority!==void 0||a.labels!==void 0}function Nd(a,n){return a.priority!==void 0?a.priority:(n==null?void 0:n.priority)??null}function Cd(a,n){return a.labels!==void 0?a.labels:(n==null?void 0:n.labels)??[]}const lx=new Set(["queued","running"]);function cx(a){const n=String(a||"").split("/").filter(Boolean);return n.length?n[n.length-1]:""}const ux=/^batch\((\d+)\)$/i;function ih(a){const n=ux.exec(String(a||"").trim());return n?Number(n[1]):null}function dx(a){const n=a.recent_limit??12,r=[],i=new Set;for(const v of a.active_items){const y=String(v.filename||"").trim();y&&i.add(y)}const l=(v,y,C)=>{const L=String(v.backlog_filename||"").trim()||cx(String(v.backlog_relpath||"")),T=ih(L),$=T!==null?"":L;return $&&C&&i.add($),{key:$&&C?`file:${$}`:`req:${v.request_id}`,column:y,title:T!==null?`Batch execution (${T} items)`:$||`Execution ${v.request_id.slice(0,8)}…`,filename:$||void 0,request_id:v.request_id,exec_status:String(v.status||"").trim().toLowerCase(),created_at:v.created_at??null,started_at:v.started_at??null,finished_at:v.finished_at??null,target_agent:v.target_agent??(v.target_model?`${String(v.executor_type||"agent").trim()||"agent"}:${v.target_model}`:null),batch_size:T!==null?T:void 0}};for(const v of a.active_requests){const y=String(v.status||"").trim().toLowerCase();lx.has(y)?r.push(l(v,"in_progress",!0)):y==="awaiting_qa"&&r.push(l(v,"in_review",!0))}const u=[...a.terminal_requests].sort((v,y)=>{const C=String(v.finished_at||v.started_at||v.created_at||"");return String(y.finished_at||y.started_at||y.created_at||"").localeCompare(C)}),m=new Map;let d=0,p=0;for(const v of u){const y=String(v.status||"").trim().toLowerCase();if(y==="failed"){const C=String(v.backlog_filename||"").trim();C&&ih(C)===null&&m.set(C,(m.get(C)||0)+1),p<n&&(r.push(l(v,"failed",!1)),p+=1)}else(y==="promoted"||y==="completed")&&d<n&&(r.push(l(v,"done",!1)),d+=1)}for(const v of a.planned){const y=String(v.filename||"").trim();!y||i.has(y)||r.push({key:`file:${y}`,column:"ready",title:v.title||y,kind:"planned",filename:y,item_id:v.item_id,package:v.package,task_type:v.task_type,summary:v.summary,recent_failures:m.get(y)||void 0,priority:Sd(v)?kd(v.priority):void 0,labels:Array.isArray(v.labels)?v.labels:void 0})}for(const v of a.proposed){const y=String(v.filename||"").trim();!y||i.has(y)||r.push({key:`file:${y}`,column:"triage",title:v.title||y,kind:"proposed",filename:y,item_id:v.item_id,package:v.package,task_type:v.task_type,summary:v.summary,priority:Sd(v)?kd(v.priority):void 0,labels:Array.isArray(v.labels)?v.labels:void 0})}const b=new Map;for(const v of[...a.planned,...a.proposed])b.set(String(v.filename||"").trim(),v);for(const v of r){if(!v.filename||v.kind)continue;const y=b.get(v.filename);y&&(v.title=y.title||v.title,v.item_id=y.item_id,v.package=y.package,v.task_type=y.task_type,v.summary=y.summary)}return r}const mx=200;function fx(a,n){var v;const{live:r,done:i}=n,l=n.work||new Map;if(!r.size&&!i.length&&!l.size)return a;const u=new Set,m=new Set;for(const y of a){if(!y.filename||!y.package)continue;const C=nh(y.package,y.filename);C&&m.add(C)}const d=a.map(y=>{if(y.column!=="ready"||y.kind!=="planned"||!y.filename||!y.package)return y;const C=nh(y.package,y.filename);if(!C)return y;const L=r.get(C);return!L||!L.owner?y:(u.add(C),{...y,column:"in_progress",work_id:C,claim_owner:L.owner,claim_started_at:L.started_at})}),p=new Map;d.forEach((y,C)=>{y.filename&&p.set(y.filename,C)});for(const[y,C]of l){const L=C.card?p.get(ex(C.card)):void 0;if(m.has(y)||L!==void 0){if(L!==void 0){const E=d[L],I={...E,work_id:E.work_id||y,card_path:E.card_path||C.card},D=r.get(y);D!=null&&D.owner&&(u.add(y),I.claim_owner||(I.claim_owner=D.owner,I.claim_started_at=D.started_at)),d[L]=I}continue}if(C.status==="deprecated")continue;const T=r.get(y),$=C.status==="completed"?"done":C.status==="planned"?T!=null&&T.owner?"in_progress":"ready":"triage";T!=null&&T.owner&&u.add(y),d.push({key:`work:${y}`,column:$,title:C.title||y,work_id:y,package:(v=Vs(y))==null?void 0:v.package,summary:C.receipt,card_path:C.card,claim_owner:(T==null?void 0:T.owner)||(C.status==="completed"?C.owner:void 0),claim_started_at:T==null?void 0:T.started_at})}for(const[y,C]of r){if(u.has(y)||!C.owner)continue;const L=Vs(y);d.push({key:`claim:${y}`,column:"in_progress",title:typeof C.task=="string"&&C.task?C.task:y,work_id:L?y:void 0,package:L==null?void 0:L.package,claim_owner:C.owner,claim_started_at:C.started_at})}const b=new Set(d.filter(y=>y.column==="done").map(y=>y.work_id).filter(Boolean));for(const y of i.slice(0,mx)){if(b.has(y.item))continue;const C=Vs(y.item);d.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 d}function Ti(a){const n=String((a==null?void 0:a.message)??a??"");return/backlog folder not available|backlog browsing not configured/i.test(n)}function oh(a){return String((a==null?void 0:a.message)??a??"").trim().replace(/^[a-z_]+ failed: /,"")}function Ud(a,n,r){const[i,l]=h.useState({status:null,legacy:!1});return h.useEffect(()=>{if(!n)return;let u=!1;return(async()=>{try{const m=await a.backlog_status();u||l({status:m,legacy:!1})}catch(m){u||l({status:null,legacy:Number(m==null?void 0:m.status)===404})}})(),()=>{u=!0}},[a,n,r]),i}function hx(){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 Bd(a){const{gateway:n,surface:r,status:i,legacy:l,on_changed:u}=a,[m,d]=h.useState(!1),[p,b]=h.useState(""),[v,y]=h.useState(!1),[C,L]=h.useState(""),[T,$]=h.useState((i==null?void 0:i.writable)??null);h.useEffect(()=>{if((i==null?void 0:i.writable)!==void 0){$(!!i.writable);return}if(!l)return;let O=!1;return n.admin_runtime_config().then(q=>{O||$((q==null?void 0:q.writable)===!0)}).catch(()=>{O||$(!1)}),()=>{O=!0}},[n,i==null?void 0:i.writable,l]);async function E(O){if(!v){y(!0),L("");try{await n.admin_runtime_config_update({triage_repo_root:O}),d(!1),u==null||u()}catch(q){L(oh(q))}finally{y(!1)}}}const I=String((i==null?void 0:i.reason)||"").trim()||(a.error?oh(a.error):""),D=String((i==null?void 0:i.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:[i!=null&&i.path?e.jsxs(e.Fragment,{children:[e.jsx("code",{className:"mono",children:i.path})," —"," "]}):null,I||"the gateway did not say why."]}),T===!0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"callout_actions",style:{marginTop:"10px"},children:[D?e.jsx("button",{className:"btn primary",disabled:v,onClick:()=>void E(D),title:D,children:"Use the gateway's own folder"}):null,e.jsx("button",{className:"btn",disabled:v,onClick:()=>d(O=>!O),children:"Choose a folder…"})]}),D?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:D}),"; it is created with a starter overview and item template."]}):null,m?e.jsxs("form",{className:"field",style:{marginTop:"10px"},onSubmit:O=>{O.preventDefault(),p.trim()&&E(p.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:p,onChange:O=>b(String(O.target.value||"")),placeholder:"/path/to/your/project",autoFocus:!0}),e.jsx("button",{className:"btn primary",type:"submit",disabled:v||!p.trim(),children:v?"Saving…":"Use this folder"})]})]}):null,C?e.jsx("div",{className:"page_error mono",role:"alert",style:{marginTop:"8px"},children:C}):null]}):T===!1?e.jsx("div",{className:"muted",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:e.jsx(hx,{})}):null]})]})}function px(a){const{status:n,on_create:r}=a,[i,l]=h.useState(!1),u=String((n==null?void 0:n.path)||"").trim(),m=u?`${u.replace(/\/+$/,"")}/docs/backlog/proposed/`:"docs/backlog/proposed/",d=u?`${u.replace(/\/+$/,"")}/${(n==null?void 0:n.template_relpath)||"docs/backlog/template.md"}`:(n==null?void 0:n.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"}),n!=null&&n.is_default?e.jsx("span",{className:"chip mono muted",children:"the gateway's own folder"}):null]}),e.jsxs("div",{className:"pane_body",children:[u?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:u}),e.jsx("button",{className:"btn",onClick:()=>{ln(u),l(!0)},children:i?"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:m})," (Triage), accepted ones move to"," ",e.jsx("code",{className:"mono",children:"planned/"})," (Ready). Start from the template ",e.jsx("code",{className:"mono",children:d}),", 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 _x(a){return a.kind?[a.kind]:["completed","planned","proposed"]}function bp(a){const{gateway:n,can_use_gateway:r,target:i,on_close:l,on_mutated:u,on_open_executions:m}=a,d=!!i,[p,b]=h.useState("spec"),[v,y]=h.useState(""),[C,L]=h.useState(""),[T,$]=h.useState(null),[E,I]=h.useState(!1),[D,O]=h.useState(""),[q,A]=h.useState(!1),[H,fe]=h.useState(""),[ie,Se]=h.useState(!1),[ke,le]=h.useState(""),[pe,G]=h.useState(""),[te,ae]=h.useState(!1),[U,Q]=h.useState([]),[M,Z]=h.useState(!1),[ne,k]=h.useState(null),[w,K]=h.useState(null),[ve,he]=h.useState(""),[z,be]=h.useState(!1),[Ae,De]=h.useState(""),[Me,lt]=h.useState({}),Ue=h.useMemo(()=>Li(v),[v]);h.useEffect(()=>{if(!d||!i)return;const B=oe=>{oe.key!=="Escape"||oe.defaultPrevented||gx(oe.target)||q||document.querySelector(".modal_backdrop")||(oe.preventDefault(),l())};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[d,i,l,q]),h.useEffect(()=>{!d||!i||(b(i.initial_tab||"spec"),A(!1),O(""),De(""),he(""),lt({}),X(!1),k(null),K(null),$(null),ct(i),Xe(i))},[d,i==null?void 0:i.filename,i==null?void 0:i.kind,i==null?void 0:i.request_id]);async function ct(B){if(!B.filename){y(""),L("");return}I(!0);try{let oe=null,je=null;for(const se of _x(B))try{const xe=await n.backlog_content(se,B.filename);oe={kind:se,text:String((xe==null?void 0:xe.content)||"")};break}catch(xe){je=xe}if(!oe)throw je||new Error("Spec not found in any backlog kind");$(oe.kind),y(oe.text),L(await bd(oe.text));const Oe=Li(oe.text);le(Oe.priority||""),G(Oe.labels.join(", "))}catch(oe){O(String((oe==null?void 0:oe.message)||oe||"Failed to load the spec"))}finally{I(!1)}}async function Xe(B){Z(!0);try{const[oe,je]=await Promise.all([n.backlog_exec_requests({status:"queued,running,awaiting_qa",limit:200}),n.backlog_exec_requests({status:"promoted,completed,failed",limit:200})]),se=[...Array.isArray(oe==null?void 0:oe.requests)?oe.requests:[],...Array.isArray(je==null?void 0:je.requests)?je.requests:[]].filter(ze=>B.filename&&String(ze.backlog_filename||"").trim()===B.filename||ze.request_id===B.request_id);se.sort((ze,Ne)=>String(Ne.created_at||"").localeCompare(String(ze.created_at||""))),Q(se);const xe=se.find(ze=>String(ze.status||"").toLowerCase()==="awaiting_qa")||null;if(k(xe),xe)try{const ze=await n.backlog_exec_request(xe.request_id);K((ze==null?void 0:ze.payload)??null)}catch{K(null)}}catch{Q([])}finally{Z(!1)}}async function dt(){if(!i||ie)return;const B=T||i.kind;if(B){Se(!0),O("");try{const oe=await n.backlog_update({kind:B,filename:i.filename,content:H,expected_sha256:C||null}),je=H.endsWith(`
72
+ `)?H:`${H}
73
+ `;y(je),L(String((oe==null?void 0:oe.sha256)||"")),A(!1),await u()}catch(oe){O(String((oe==null?void 0:oe.message)||oe||"Save failed"))}finally{Se(!1)}}}async function Ze(){if(!i||te)return;const B=T||i.kind;if(B){ae(!0),O("");try{const oe=jd(v,{priority:ke||null,labels:Fd(pe)}),je=await n.backlog_update({kind:B,filename:i.filename,content:oe,expected_sha256:C||null});y(oe.endsWith(`
74
+ `)?oe:`${oe}
75
+ `),L(String((je==null?void 0:je.sha256)||"")),await u()}catch(oe){O(String((oe==null?void 0:oe.message)||oe||"Metadata save failed"))}finally{ae(!1)}}}const[W,X]=h.useState(!1);async function ge(B){if(!(!ne||z)){if(B==="feedback"&&!ve.trim()){De("Feedback is required.");return}be(!0),De("");try{B==="feedback"?await n.backlog_exec_feedback({request_id:ne.request_id,feedback:ve}):B==="promote"?await n.backlog_exec_promote({request_id:ne.request_id,redeploy:!0}):await n.backlog_exec_deploy_uat({request_id:ne.request_id}),he(""),X(!1),i&&await Xe(i),await u()}catch(oe){De(String((oe==null?void 0:oe.message)||oe||"QA action failed"));try{const je=await n.backlog_exec_request(ne.request_id);K((je==null?void 0:je.payload)??null)}catch{}}finally{be(!1)}}}if(!d||!i)return null;const Y=Ue.acceptance.filter((B,oe)=>!Me[`${oe}:${B.text}`]).length;return e.jsx("div",{className:"drawer_backdrop",onMouseDown:B=>{B.target===B.currentTarget&&l()},children:e.jsxs("div",{className:"drawer_panel work_drawer",role:"dialog","aria-modal":"true","aria-label":i.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:i.filename,children:i.title}),e.jsxs("div",{className:"mono muted",style:{fontSize:"var(--font-size-xs)"},children:[T||i.kind||"locating…",i.filename?` • ${i.filename}`:""]})]}),e.jsxs("div",{className:"row",style:{gap:8,justifyContent:"flex-end"},children:[i.filename?e.jsx("button",{className:"btn",onClick:()=>ln(`docs/backlog/${T||i.kind||"planned"}/${i.filename}`),title:"Copy repo path",children:"Copy path"}):null,e.jsx("button",{className:"btn",onClick:l,children:"Close"})]})]}),e.jsxs("div",{className:"tab_bar work_drawer_tabs",children:[e.jsx("button",{className:`tab ${p==="spec"?"active":""}`,onClick:()=>b("spec"),children:"Spec"}),e.jsxs("button",{className:`tab ${p==="runs"?"active":""}`,onClick:()=>b("runs"),children:["Runs ",U.length?`(${U.length})`:""]}),e.jsxs("button",{className:`tab ${p==="review"?"active":""}`,onClick:()=>b("review"),children:["Review",ne?" ●":""]})]}),e.jsxs("div",{className:"drawer_body work_drawer_body",children:[D?e.jsx("div",{className:"mono board_error",children:D}):null,p==="spec"?e.jsxs(e.Fragment,{children:[i.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,i.filename?e.jsxs("div",{className:"work_meta_editor",children:[e.jsxs("select",{value:ke,onChange:B=>le(B.target.value),disabled:te,title:"Priority",children:[e.jsx("option",{value:"",children:"priority: unset"}),el.map(B=>e.jsx("option",{value:B,children:_p[B]},B))]}),e.jsx("input",{value:pe,onChange:B=>G(B.target.value),placeholder:"labels (comma-separated; sprints: sprint-29)",disabled:te}),e.jsx("button",{className:"btn",onClick:()=>void Ze(),disabled:te||!r||E,children:te?"Saving…":"Save metadata"}),q?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:()=>A(!1),disabled:ie,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:()=>void dt(),disabled:ie,children:ie?"Saving…":"Save spec"})]}):e.jsx("button",{className:"btn",onClick:()=>{fe(v),A(!0)},disabled:E,children:"Edit spec"})]}):null,E?e.jsx("div",{className:"mono muted",children:"Loading…"}):q?e.jsx("textarea",{className:"mono work_spec_editor",value:H,onChange:B=>fe(B.target.value),rows:24}):v?e.jsxs(e.Fragment,{children:[e.jsx(os,{className:"md_doc",text:v}),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,p==="runs"?e.jsxs(e.Fragment,{children:[M?e.jsx("div",{className:"mono muted",children:"Loading…"}):null,!M&&!U.length?e.jsx("div",{className:"mono muted",children:"No executions for this item in recent history (window: live + last 200 finished)."}):null,U.map(B=>{const oe=String(B.status||"").toLowerCase(),je=Zo(B);return e.jsxs("div",{className:"work_run_row",children:[e.jsx("span",{className:`chip mono ${Qo(oe)}`,children:oe}),e.jsx("span",{className:"mono muted",children:_a(B.request_id,18)}),e.jsx("span",{className:"mono muted",children:B.created_at?new Date(B.created_at).toLocaleString():""}),e.jsx("span",{className:"mono muted",children:je.run_ms!=null?`ran ${Hs(je.run_ms)}`:""}),B.target_agent?e.jsx("span",{className:"chip mono muted",children:B.target_agent}):null,oe==="running"||oe==="queued"||oe==="awaiting_qa"?e.jsx("button",{className:"btn",onClick:()=>m(B.request_id),children:oe==="awaiting_qa"?"View logs":"Follow live"}):null]},B.request_id)})]}):null,p==="review"?ne?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."}),Ue.acceptance.length?e.jsx("div",{className:"work_dod_list",children:Ue.acceptance.map((B,oe)=>e.jsxs("label",{className:"work_dod_item",children:[e.jsx("input",{type:"checkbox",checked:!!Me[`${oe}:${B.text}`],onChange:je=>lt(Oe=>({...Oe,[`${oe}:${B.text}`]:je.target.checked}))}),e.jsx("span",{children:B.text})]},`dod:${oe}:${B.text}`))}):e.jsx("div",{className:"mono muted",children:"This spec declares no acceptance criteria — review against the diff and logs."}),(()=>{const B=String((w==null?void 0:w.execution_mode)||"uat").toLowerCase(),oe=String((w==null?void 0:w.candidate_relpath)||"").trim(),je=w==null?void 0:w.promotion_report,Oe=!!(je!=null&&je.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: ",B,oe?` • candidate: ${oe}`:""]}),e.jsx("button",{className:"btn",onClick:()=>m(ne.request_id),title:"Open this run's logs and events in Executions",children:"View run logs"})]}),Oe?e.jsxs("div",{className:"mono board_error",style:{marginTop:"6px"},children:["Promotion blocked: ",String((je==null?void 0:je.reason)||"conflicts")," — iterate on top of current prod or resolve manually."]}):null]})})(),Ue.acceptance.length&&Y>0?e.jsxs("div",{className:"mono work_drawer_warn",style:{marginTop:"8px"},children:[Y," acceptance criteri",Y===1?"on":"a"," unconfirmed — promoting anyway is an override."]}):null,e.jsx("textarea",{value:ve,onChange:B=>he(B.target.value),rows:3,placeholder:"QA feedback (what to change / fix)…",style:{width:"100%",marginTop:"10px"},disabled:z}),Ae?e.jsx("div",{className:"mono board_error",children:Ae}):null,e.jsxs("div",{className:"row",style:{gap:8,marginTop:"10px",flexWrap:"wrap",alignItems:"center"},children:[e.jsx("button",{className:"btn",onClick:()=>void ge("deploy_uat"),disabled:z,children:"Restart UAT"}),W?e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"btn danger",onClick:()=>void ge("promote"),disabled:z,children:["Confirm: promote to prod",Y>0?` (${Y} unconfirmed)`:""," + redeploy"]}),e.jsx("button",{className:"btn",onClick:()=>X(!1),disabled:z,children:"Cancel"})]}):e.jsx("button",{className:"btn primary",onClick:()=>X(!0),disabled:z,children:Ue.acceptance.length&&Y>0?"Promote (override)…":"Approve → promote…"}),e.jsx("button",{className:"btn",onClick:()=>void ge("feedback"),disabled:z,children:"Iterate (send feedback)"})]})]}):e.jsx("div",{className:"mono muted",children:"Nothing awaiting review for this item."}):null]})]})})}function gx(a){const n=a;return!n||typeof n.closest!="function"?!1:!!n.closest("input, textarea, select, [contenteditable=''], [contenteditable='true']")}function Ir(){return Jo()}async function yx(a){const n=[],r=[];for(const i of a){const l=String((i==null?void 0:i.name)||"").trim()||"attachment";r.push(l);try{const u=await i.text();n.push(`[attached file: ${l}]
76
+
77
+ \`\`\`
78
+ ${u}
79
+ \`\`\``)}catch{n.push(`[attached file: ${l}] (unreadable in browser)`)}}return{picked:r,text:n.join(`
80
+
81
+ `)}}function vx(a){const{gateway:n,can_use_gateway:r,is_compact_layout:i,maint_provider:l,maint_model:u,maint_reasoning:m,advisor_agent:d,focus_kind:p,focus_type:b}=a,[v,y]=h.useState(!1),[C,L]=h.useState([]),[T,$]=h.useState(""),[E,I]=h.useState(!1),[D,O]=h.useState(""),[q,A]=h.useState(!1),[H,fe]=h.useState([]),ie=h.useRef(null),Se=h.useRef(null),ke=String(a.voice_session_id||"").trim()||"abstractcontinuum_backlog_advisor",[le,pe]=h.useState(""),[G,te]=h.useState("");h.useEffect(()=>{(async()=>{try{const w=await Od(ke);pe(w)}catch{pe("")}})()},[ke]);const ae=h.useMemo(()=>{if(!r)return{};const w=String(le||"").trim(),K=ke;return{tts:async ve=>{if(!w)throw new Error("Voice store not available (missing run_id).");const he=await n.voice_tts(w,{text:ve,request_id:Ir()}),z=he==null?void 0:he.audio_artifact,be=z&&typeof z=="object"&&!Array.isArray(z)?String(z.$artifact||"").trim():"";if(!be)throw new Error("TTS failed: missing audio artifact");return await(await n.download_run_artifact_content(w,be)).arrayBuffer()},transcribe:async(ve,he)=>{if(!w)throw new Error("Voice input unavailable (missing run_id).");const z=String(he||ve.type||"").toLowerCase(),be=z.includes("mp4")?"m4a":z.includes("ogg")?"ogg":z.includes("wav")?"wav":"webm",Ae=new File([ve],`recording.${be}`,{type:z||"audio/webm"}),De=await n.attachments_upload(K,Ae,{filename:Ae.name,content_type:Ae.type}),Me=await n.audio_transcribe(w,{audio_artifact:De,request_id:Ir()});return String((Me==null?void 0:Me.text)||"").trim()}}},[r,n,le,ke]),U=Wh({...ae,on_error:te,on_transcript:w=>{const K=String(w||"").trim();K&&($(ve=>{const he=String(ve||"");return he.trim()?`${he.trimEnd()}
82
+ ${K}`:K}),window.setTimeout(()=>{var ve;return(ve=ie.current)==null?void 0:ve.focus()},0))}});h.useEffect(()=>{if(!v)return;const w=K=>{K.key==="Escape"&&(k(),y(!1))};return window.addEventListener("keydown",w),setTimeout(()=>{var K;return(K=ie.current)==null?void 0:K.focus()},0),()=>window.removeEventListener("keydown",w)},[v]);async function Q(){if(E||!r)return;if(U.voice_ptt_busy){te("Wait for transcription to finish.");return}O(""),te("");const w=T.trim();if(!w)return;const K={id:Ir(),role:"user",content:w,ts:new Date().toISOString()},ve=[...C,K];L(ve),$(""),I(!0);try{const he=await n.backlog_advisor({messages:ve.map(De=>({role:De.role,content:De.content})),provider:l||null,model:u||null,thinking:m||null,agent:d||null,include_trace:q,focus_kind:p,focus_type:b}),z=q&&Array.isArray(he==null?void 0:he.tool_trace)?he.tool_trace:[],be=String((he==null?void 0:he.run_id)||"").trim(),Ae=String((he==null?void 0:he.reply)||"").trim();if(q&&z.length){const De={id:Ir(),role:"system",title:"Tool execution",level:"info",ts:new Date().toISOString(),content:JSON.stringify({run_id:be||null,tool_trace:z},null,2)};L(Me=>[...Me,De])}Ae&&L(De=>[...De,{id:Ir(),role:"assistant",content:Ae,ts:new Date().toISOString()}])}catch(he){O(String((he==null?void 0:he.message)||he||"Backlog advisor failed"))}finally{I(!1)}}async function M(w){var z;const K=Array.from(w||[]);if(!K.length)return;const{picked:ve,text:he}=await yx(K);fe(be=>[...ve,...be].slice(0,12)),$(be=>{const Ae=String(be||"").trim();return Ae?`${Ae}
83
+
84
+ ${he}`:he});try{(z=ie.current)==null||z.focus()}catch{}}function Z(w){const K=String(w.id||w.ts||"").trim(),ve=String(w.content||"").trim();!K||!ve||(te(""),U.toggle_tts(K,ve))}function ne(w){const K=String(w.id||w.ts||"").trim(),ve=U.tts_playback;return!K||!ve.key||ve.key!==K?"idle":ve.status}function k(){U.stop_voice_ptt_recording(),U.stop_tts()}return e.jsxs(e.Fragment,{children:[e.jsx("button",{className:`advisor_toggle ${v?"open":""}`,onClick:()=>{y(w=>{const K=!w;return K||k(),K})},title:"Open backlog advisor (read-only)","aria-label":"Open backlog advisor",children:e.jsx("span",{className:"advisor_toggle_label",children:"Advisor"})}),v?e.jsx("div",{className:"drawer_backdrop",onMouseDown:w=>{w.target===w.currentTarget&&(k(),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: ",d||"basic-agent"," • Using: ",l||"(gateway default)"," / ",u||"(gateway default)"]})]}),e.jsxs("div",{className:"row",style:{gap:8,justifyContent:"flex-end"},children:[e.jsxs("button",{className:`btn btn_icon ${q?"primary":""}`,onClick:()=>A(w=>!w),disabled:E,title:q?"Hide tool execution":"Show tool execution","aria-label":q?"Hide tool execution":"Show tool execution",children:[e.jsx(He,{name:"terminal",size:16}),i?null:q?"Tools on":"Tools"]}),e.jsx("button",{className:"btn",onClick:()=>L([]),disabled:E||!C.length,children:"Clear"}),e.jsx("button",{className:"btn",onClick:()=>{k(),y(!1)},children:"Close"})]})]}),e.jsxs("div",{className:"drawer_body",children:[e.jsx($c,{messages:C,className:"drawer_chat_thread",messageProps:U.tts_supported&&r&&le.trim()?{onSpeakToggle:Z,getSpeakState:ne,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:Se,type:"file",multiple:!0,style:{display:"none"},onChange:w=>{const K=Array.from(w.currentTarget.files||[]);w.currentTarget.value="",K.length&&M(K)}}),e.jsx(sl,{ref:ie,value:T,onChange:$,onSubmit:()=>void Q(),placeholder:"Message to backlog advisor…",disabled:!r,busy:E||U.voice_ptt_busy,rows:3,sendButtonClassName:"btn primary",busyLabel:U.voice_ptt_busy?"Transcribing…":"Thinking…",actions:e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:`btn btn_icon voice_btn${U.voice_ptt_recording?" danger":""}`,type:"button",disabled:!r||!le.trim()||E||U.voice_ptt_busy||!U.voice_ptt_supported,title:U.voice_ptt_supported?U.voice_ptt_busy?"Transcribing…":U.voice_ptt_recording?"Recording… release to transcribe":"Hold to talk (record + transcribe)":Zf()?"Voice recording is not supported in this browser":Xf,"aria-label":"Voice input",onPointerDown:w=>{var K,ve;if(!(!r||!le.trim()||E||U.voice_ptt_busy||!U.voice_ptt_supported)){w.preventDefault();try{(ve=(K=w.currentTarget)==null?void 0:K.setPointerCapture)==null||ve.call(K,w.pointerId)}catch{}U.start_voice_ptt_recording()}},onPointerUp:w=>{w.preventDefault(),U.stop_voice_ptt_recording()},onPointerCancel:w=>{w.preventDefault(),U.stop_voice_ptt_recording()},children:[e.jsx(He,{name:U.voice_ptt_recording?"x":"mic",size:16}),i?null:U.voice_ptt_busy?"Transcribing…":U.voice_ptt_recording?"Recording…":"Voice"]}),e.jsxs("button",{className:"btn btn_icon",type:"button",onClick:()=>{var w;return(w=Se.current)==null?void 0:w.click()},disabled:E,title:"Attach a local file to your message","aria-label":"Attach file",children:[e.jsx(He,{name:"paperclip",size:16}),i?null:"Attach"]})]})}),H.length?e.jsxs("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"6px"},children:["Last attached: ",H[0]]}):null,D?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:D}):null,G?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:G}):null,Zf()?null:e.jsx("div",{className:"muted","data-testid":"voice-https-hint",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:Xf}),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 er({open:a,title:n,children:r,actions:i,variant:l="default",onClose:u}){if(h.useEffect(()=>{if(!a)return;const d=p=>{p.key!=="Escape"||p.defaultPrevented||(p.preventDefault(),u())};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[a,u]),!a)return null;const m=l==="fullscreen";return e.jsx("div",{className:`modal_backdrop${m?" fullscreen":""}`,onMouseDown:d=>{d.target===d.currentTarget&&u()},children:e.jsxs("div",{className:`modal_panel${m?" fullscreen":""}`,role:"dialog","aria-modal":"true","aria-label":n,children:[e.jsxs("div",{className:"modal_header",children:[e.jsx("div",{className:"modal_title",children:n}),e.jsx("button",{className:"btn",onClick:u,children:"Close"})]}),e.jsx("div",{className:"modal_body",children:r}),i?e.jsx("div",{className:"modal_footer",children:i}):null]})})}function xx(a){const{readiness:n,server_refused:r,on_open_spec:i}=a;return n?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)"})]}),n.checks.map(l=>e.jsxs("div",{className:"mono",style:{fontSize:"var(--font-size-sm)",color:l.ok?"rgb(74, 222, 128)":"rgb(250, 204, 21)"},children:[l.ok?"✓":"○"," ",l.label,l.evidence?e.jsxs("span",{style:{opacity:.75},children:[" — ",l.evidence]}):null]},l.id)),n.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."}),i?e.jsx("button",{className:"btn",type:"button",onClick:i,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 wp(a){const{exec_cfg:n,with_setup:r}=a,i=["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:(n==null?void 0:n.runner_enabled)!==!0?"Backlog exec runner is disabled on this gateway — admins can enable it live from Settings → Gateway administration.":(n==null?void 0:n.runner_alive)===!1?"Backlog exec runner is not running on this gateway.":(n==null?void 0:n.codex_available)===!1?`The configured executor is not available on the gateway host (${String((n==null?void 0:n.codex_bin)||(n==null?void 0:n.executor)||"binary")} not found).`:"Backlog exec is not available on this gateway."}),n!=null&&n.runner_error?e.jsx("div",{className:"detail_hint",children:n.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:i.join(`
85
+ `)}),e.jsx("button",{className:"btn",style:{marginTop:"4px"},onClick:()=>ln(i.join(`
86
+ `)),children:"Copy setup"})]})]}):null]})}function jp(a){const{value:n,onChange:r,disabled:i,inplace_warning:l,uat_note:u}=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:n,onChange:m=>r(m.target.value),disabled:i,style:{width:"100%"},children:[e.jsx("option",{value:"uat",children:"UAT (staged, safe)"}),e.jsx("option",{value:"inplace",children:"Inplace (dangerous, edits prod)"})]}),n==="inplace"?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:l}):e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:u})]})}const bx=["minimal","low","medium","high"];function kp(a){const{executors:n,value:r,onChange:i,disabled:l}=a;if(!n||!n.length)return null;const u=n.find(m=>m.default);return e.jsxs("div",{style:{marginTop:"10px"},children:[e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginBottom:"6px"},children:"Execution agent"}),e.jsxs("select",{className:"input",value:r,onChange:m=>i(m.target.value),disabled:l,style:{width:"100%"},children:[e.jsxs("option",{value:"",children:["gateway default",u?` (${u.display||u.id})`:""]}),n.map(m=>e.jsxs("option",{value:m.id,disabled:m.available===!1,children:[m.display||m.id,m.available===!1?" (unavailable on the gateway host)":""]},m.id))]})]})}function wx(a){const{exec_cfg:n,model:r,set_model:i,effort:l,set_effort:u,disabled:m}=a;return e.jsxs("details",{style:{marginTop:"8px"},open:!!(r||l),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:d=>i(d.target.value),placeholder:String((n==null?void 0:n.codex_model)||"gateway default"),disabled:m})]})}),e.jsx("div",{className:"col",style:{minWidth:160},children:e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Reasoning effort"}),e.jsxs("select",{value:l,onChange:d=>u(d.target.value),disabled:m,children:[e.jsx("option",{value:"",children:"gateway default"}),bx.map(d=>e.jsx("option",{value:d,children:d},d))]})]})})]}),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 Sp(a){const{open:n,target:r,execute_mode:i,set_execute_mode:l,action_loading:u,action_error:m,exec_cfg:d,exec_cfg_loading:p,exec_cfg_error:b,on_confirm:v,on_close:y}=a,C=a.readiness??null,L=a.show_readiness===!0,[T,$]=Wt.useState(""),[E,I]=Wt.useState(""),[D,O]=Wt.useState(""),q=(r==null?void 0:r.filename)||"";Wt.useEffect(()=>{$(""),I(""),O("")},[q]);const A=T.trim()||E||D?{executor:D||void 0,target_model:T.trim()||void 0,target_reasoning_effort:E||void 0}:void 0;return e.jsxs(er,{open:n,title:"Execute backlog item?",onClose:y,actions:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:y,disabled:u,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:()=>v(A),disabled:u||p||!r||(d==null?void 0:d.can_execute)!==!0,children:u?"Executing…":L&&!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)"})]}),d?e.jsxs("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"6px"},children:["Agent: ",String(d.executor||"executor"),d.codex_model?` · ${d.codex_model}`:"",d.codex_reasoning_effort?` (reasoning ${d.codex_reasoning_effort})`:""]}):null,e.jsx(kp,{executors:a.executors??null,value:D,onChange:O,disabled:u}),e.jsx(wx,{exec_cfg:d,model:T,set_model:$,effort:E,set_effort:I,disabled:u}),L?e.jsx(xx,{readiness:C,server_refused:a.server_refused,on_open_spec:a.on_open_spec}):null,e.jsx(jp,{value:i,onChange:l,disabled:u,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."}),p?e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"10px"},children:"Checking worker…"}):null,!p&&(d==null?void 0:d.can_execute)!==!0?e.jsx(wp,{exec_cfg:d,with_setup:!0}):null,b?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"10px"},children:b}):null,m?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"10px"},children:m}):null]})}function jx(a){const{open:n,batch_selected_items:r,batch_execute_mode:i,set_batch_execute_mode:l,batch_execute_loading:u,batch_execute_error:m,exec_cfg:d,exec_cfg_loading:p,exec_cfg_error:b,on_confirm:v,on_close:y}=a,[C,L]=Wt.useState("");return Wt.useEffect(()=>{n||L("")},[n]),e.jsxs(er,{open:n,title:"Execute batch (single context)?",onClose:y,actions:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:y,disabled:u,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:()=>v(C||void 0),disabled:u||p||r.length<2||(d==null?void 0:d.can_execute)!==!0,children:u?"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(kp,{executors:a.executors??null,value:C,onChange:L,disabled:u}),e.jsx(jp,{value:i,onChange:l,disabled:u,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(T=>e.jsxs("div",{children:["- docs/backlog/planned/",T.filename]},`batchitem:${T.filename}`))}):null,p?e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"10px"},children:"Checking worker…"}):null,!p&&(d==null?void 0:d.can_execute)!==!0?e.jsx(wp,{exec_cfg:d}):null,b?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"10px"},children:b}):null,m?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"10px"},children:m}):null]})}function kx(a){const{open:n,batch_selected_items:r,merge_package:i,set_merge_package:l,merge_task_type:u,set_merge_task_type:m,merge_title:d,set_merge_title:p,merge_summary:b,set_merge_summary:v,merge_loading:y,merge_error:C,on_confirm:L,on_close:T}=a;return e.jsxs(er,{open:n,title:"Merge planned items into master backlog?",onClose:T,actions:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:T,disabled:y,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:L,disabled:y||r.length<2||!d.trim()||!i.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:i,onChange:$=>l($.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:u,onChange:$=>m($.target.value),children:Za.map($=>e.jsx("option",{value:$,children:$},$))})]})})]}),e.jsxs("div",{className:"field",style:{marginTop:"10px"},children:[e.jsx("label",{children:"Title"}),e.jsx("input",{value:d,onChange:$=>p($.target.value),placeholder:"Master backlog"})]}),e.jsxs("div",{className:"field",style:{marginTop:"10px"},children:[e.jsx("label",{children:"Summary (optional)"}),e.jsx("textarea",{value:b,onChange:$=>v($.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 Wd(a){const n=()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(a).matches,[r,i]=h.useState(n);return h.useEffect(()=>{var m;if(typeof window>"u"||typeof window.matchMedia!="function")return;const l=window.matchMedia(a),u=()=>i(l.matches);return u(),typeof l.addEventListener=="function"?l.addEventListener("change",u):(m=l.addListener)==null||m.call(l,u),()=>{var d;typeof l.removeEventListener=="function"?l.removeEventListener("change",u):(d=l.removeListener)==null||d.call(l,u)}},[a]),r}function Np(a,n){const[r,i]=h.useState(null);return h.useEffect(()=>{if(!n){i(null);return}let l=!1;return(async()=>{try{const u=await a.admin_executors(),m=Array.isArray(u)?u:Array.isArray(u==null?void 0:u.executors)?u.executors:[];l||i(m)}catch{l||i(null)}})(),()=>{l=!0}},[n]),r}function Hd(a){const{gateway:n,can_use_gateway:r,kind:i,completed_view:l,is_exec_view:u,is_compact_layout:m,set_compact_pane:d,on_status_transfer:p}=a,[b,v]=h.useState(null),[y,C]=h.useState(!1),[L,T]=h.useState(""),[$,E]=h.useState([]),[I,D]=h.useState(!1),[O,q]=h.useState(""),[A,H]=h.useState(null),[fe,ie]=h.useState(null),[Se,ke]=h.useState(!1),[le,pe]=h.useState(""),[G,te]=h.useState(""),[ae,U]=h.useState(!1),[Q,M]=h.useState(""),[Z,ne]=h.useState("events"),[k,w]=h.useState(""),[K,ve]=h.useState(!1),[he,z]=h.useState(""),[be,Ae]=h.useState(!1),[De,Me]=h.useState(!0),lt=h.useRef(null),Ue=h.useRef(!0),ct=h.useRef(null),Xe=h.useRef(!1),dt=h.useRef(!1),Ze=1e6,W=h.useMemo(()=>Z!=="events"?null:Hv(k),[k,Z]),X=h.useMemo(()=>Vv(W),[W]),ge=Zo(A);function Y(){H(null),ie(null),pe(""),w(""),z(""),Ae(!1),ct.current=null}async function B(){if(!r)return null;if(y)return b;T(""),C(!0);try{const Ne=await n.backlog_exec_config();return v(Ne),Ne}catch(Ne){const Le=String((Ne==null?void 0:Ne.message)||Ne||"Failed to load backlog exec config");return T(Le),v(null),null}finally{C(!1)}}async function oe(Ne,Le,re){if(dt.current)return $;dt.current=!0,re!=null&&re.background||D(!0);const P=Ne||i;try{const de=Bv(P,Le||l),Ve=await n.backlog_exec_requests({status:de,limit:200}),et=Array.isArray(Ve==null?void 0:Ve.requests)?Ve.requests:[];q(""),E(et);const at=String((A==null?void 0:A.status)||"").trim().toLowerCase(),mt=at==="failed"||at==="completed"||at==="promoted";if(P==="processing"&&(A!=null&&A.request_id)&&!mt&&!et.some(ft=>ft.request_id===A.request_id))try{const ft=await n.backlog_exec_request(A.request_id),Ee=ft==null?void 0:ft.payload,tt=String((Ee==null?void 0:Ee.status)||"").trim().toLowerCase();(tt==="failed"||tt==="completed"||tt==="promoted")&&(p(tt),ie(Ee),H(Io(Ee,A.request_id)))}catch{}if(A!=null&&A.request_id){const ft=et.find(Ee=>Ee.request_id===A.request_id)||null;ft&&H(ft)}return et}catch(de){return q(String((de==null?void 0:de.message)||de||"Failed to load backlog exec requests")),[]}finally{dt.current=!1,re!=null&&re.background||D(!1)}}async function je(Ne){if(r){H(Ne),m&&d("detail"),ie(null),pe(""),ke(!0),M(""),te(""),w(""),z(""),Ae(!1),ct.current=null;try{const Le=await n.backlog_exec_request(Ne.request_id);ie((Le==null?void 0:Le.payload)??null)}catch(Le){pe(String((Le==null?void 0:Le.message)||Le||"Failed to load request"))}finally{ke(!1)}}}async function Oe(Ne){if(!r)return;const Le=String((A==null?void 0:A.request_id)||"").trim();if(!Le||ae)return;const re=String(G||"");if(!re.trim()){M("Feedback is required.");return}M(""),U(!0);try{const P=await n.backlog_exec_feedback({request_id:Le,feedback:re}),de=(P==null?void 0:P.payload)??null;ie(de),de&&H(Io(de,Le)),te(""),await Ne()}catch(P){M(String((P==null?void 0:P.message)||P||"Failed to send feedback"))}finally{U(!1)}}async function se(Ne){if(!r)return;const Le=String((A==null?void 0:A.request_id)||"").trim();if(Le&&!ae){M(""),U(!0);try{const re=await n.backlog_exec_promote({request_id:Le,redeploy:!0}),P=(re==null?void 0:re.payload)??null;ie(P),P&&H(Io(P,Le)),te(""),await Ne()}catch(re){M(String((re==null?void 0:re.message)||re||"Failed to promote to prod"));try{const P=await n.backlog_exec_request(Le),de=(P==null?void 0:P.payload)??null;ie(de),de&&H(Io(de,Le))}catch{}}finally{U(!1)}}}async function xe(Ne){if(!r)return;const Le=String((A==null?void 0:A.request_id)||"").trim();if(Le&&!ae){M(""),U(!0);try{const re=await n.backlog_exec_deploy_uat({request_id:Le}),P=(re==null?void 0:re.payload)??null;ie(P),P&&H(Io(P,Le)),await Ne()}catch(re){M(String((re==null?void 0:re.message)||re||"Failed to deploy to UAT"))}finally{U(!1)}}}async function ze(Ne){if(!r)return;const Le=String((Ne==null?void 0:Ne.request_id)||(A==null?void 0:A.request_id)||"").trim();if(!Le)return;const re=(Ne==null?void 0:Ne.name)||Z,P=typeof(Ne==null?void 0:Ne.max_bytes)=="number"&&Number.isFinite(Ne.max_bytes)?Number(Ne.max_bytes):16e4;if(!Xe.current){Xe.current=!0,z(""),ve(!0);try{const de=`${Le}::${String(re)}`,Ve=ct.current,et=Ve!==null&&Ve.key===de,at=await n.backlog_exec_log_tail({request_id:Le,name:String(re),max_bytes:P,...et?{after_bytes:Ve.offset}:{}}),mt=typeof(at==null?void 0:at.next_offset)=="number"&&Number.isFinite(at.next_offset),ft=String((at==null?void 0:at.content)||"");et&&mt&&(at==null?void 0:at.reset)!==!0?(ft&&w(Ee=>{let tt=Ee+ft;if(tt.length>Ze){const ht=tt.length-Ze,Pt=tt.indexOf(`
87
+ `,ht);tt=Pt>=0?tt.slice(Pt+1):tt.slice(ht),Ae(!0)}return tt}),ct.current={key:de,offset:Number(at.next_offset)}):(w(ft),Ae(!!(at!=null&&at.truncated)),ct.current=mt?{key:de,offset:Number(at.next_offset)}:null)}catch(de){z(String((de==null?void 0:de.message)||de||"Failed to load logs"))}finally{Xe.current=!1,ve(!1)}}}return h.useEffect(()=>{r&&u&&B()},[u,r]),h.useEffect(()=>{if(!r||!u)return;const Le=setInterval(()=>{n.is_backing_off()||oe(i,void 0,{background:!0})},i==="processing"?2e3:5e3);return()=>clearInterval(Le)},[i,l,r,u,A==null?void 0:A.request_id]),h.useEffect(()=>{r&&u&&A!=null&&A.request_id&&ze({request_id:A.request_id,name:Z})},[A==null?void 0:A.request_id,Z,u,r]),h.useEffect(()=>{Ue.current=!0},[A==null?void 0:A.request_id,Z]),h.useEffect(()=>{if(!lt.current||!Ue.current)return;const Le=window.requestAnimationFrame(()=>{const re=lt.current;re&&(re.scrollTop=re.scrollHeight)});return()=>window.cancelAnimationFrame(Le)},[k,Z,A==null?void 0:A.request_id]),h.useEffect(()=>{if(!r||!u||!(A!=null&&A.request_id))return;const Ne=String(A.status||"").trim().toLowerCase();if(Ne==="completed"||Ne==="promoted"||Ne==="failed"||Ne!=="running"&&De!==!0)return;const re=setInterval(()=>{n.is_backing_off()||ze({request_id:A.request_id,name:Z})},Ne==="running"?1500:2500);return()=>clearInterval(re)},[A==null?void 0:A.request_id,A==null?void 0:A.status,Z,u,r,De]),{exec_cfg:b,exec_cfg_loading:y,exec_cfg_error:L,exec_requests:$,exec_loading:I,exec_error:O,exec_selected:A,set_exec_selected:H,exec_detail:fe,set_exec_detail:ie,exec_detail_loading:Se,exec_detail_error:le,set_exec_detail_error:pe,exec_qa_feedback:G,set_exec_qa_feedback:te,exec_qa_loading:ae,exec_qa_error:Q,exec_log_name:Z,set_exec_log_name:ne,exec_log_text:k,exec_log_loading:K,exec_log_error:he,exec_log_truncated:be,exec_log_auto:De,set_exec_log_auto:Me,exec_log_scroll_el_ref:lt,exec_log_follow_ref:Ue,parsed_exec_events:W,event_stats:X,time_stats:ge,clear_exec_selection:Y,load_exec_config:B,refresh_exec_list:oe,load_exec_request:je,exec_send_feedback:Oe,exec_promote_to_prod:se,exec_deploy_uat_now:xe,load_exec_log_tail:ze}}const lh=[{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 Sx(a){var tn;const n=a.gateway,r=a.gateway_connected,i=String(a.maintenance_ai_provider||"").trim(),l=String(a.maintenance_ai_model||"").trim(),u=String(a.maintenance_ai_reasoning||"").trim(),m=String(a.backlog_advisor_agent||"").trim()||"basic-agent",d=a.default_execution_mode==="inplace"?"inplace":"uat",p=Wd("(max-width: 767.98px)"),[b,v]=h.useState("planned"),[y,C]=h.useState([]),[L,T]=h.useState(!1),[$,E]=h.useState(""),[I,D]=h.useState(""),[O,q]=h.useState("all"),[A,H]=h.useState(""),[fe,ie]=h.useState(new Set),Se=h.useRef(0),[ke,le]=h.useState(null),[pe,G]=h.useState([]),[te,ae]=h.useState(null),[U,Q]=h.useState(d),[M,Z]=h.useState(!1),ne=Np(n,r),[k,w]=h.useState(""),[K,ve]=h.useState(!1),[he,z]=h.useState(d),[be,Ae]=h.useState(!1),[De,Me]=h.useState(""),[lt,Ue]=h.useState(!1),[ct,Xe]=h.useState(!1),[dt,Ze]=h.useState("framework"),[W,X]=h.useState("task"),[ge,Y]=h.useState(""),[B,oe]=h.useState(""),[je,Oe]=h.useState(!1),[se,xe]=h.useState(""),ze=Hd({gateway:n,can_use_gateway:r,kind:"planned",completed_view:"tasks",is_exec_view:!1,is_compact_layout:p,set_compact_pane:()=>{},on_status_transfer:()=>{}});async function Ne(){if(!r)return;const ye=++Se.current;T(!0),E("");try{const Ce=await n.backlog_list(b);if(ye!==Se.current)return;C(Array.isArray(Ce==null?void 0:Ce.items)?Ce.items:[])}catch(Ce){if(ye!==Se.current)return;C([]),E(String((Ce==null?void 0:Ce.message)||Ce||"Failed to load backlog"))}finally{ye===Se.current&&T(!1)}if(b==="planned")try{const Ce=await n.backlog_exec_active_items();if(ye!==Se.current)return;const Je=new Set;for(const yt of Array.isArray(Ce==null?void 0:Ce.items)?Ce.items:[]){const _t=String((yt==null?void 0:yt.filename)||"").trim();_t&&Je.add(_t)}ie(Je)}catch{ye===Se.current&&ie(new Set)}else ie(new Set)}h.useEffect(()=>{G([]),H(""),Ne()},[b,r]),h.useEffect(()=>{G(ye=>{const Ce=new Set(y.map(yt=>String(yt.filename||"").trim())),Je=ye.filter(yt=>Ce.has(yt));return Je.length===ye.length?ye:Je})},[y]);const Le=h.useMemo(()=>{const ye=I.trim().toLowerCase(),Ce=O.trim().toLowerCase();return y.filter(Je=>{if(Ce&&Ce!=="all"&&Xo(Je.task_type)!==Ce)return!1;if(!ye)return!0;const yt=Array.isArray(Je.labels)?Je.labels.join(" "):"";return`${Je.item_id||""} ${Je.package||""} ${Je.title||""} ${Je.task_type||""} ${Je.summary||""} ${Je.filename||""} ${yt} ${Je.priority||""}`.toLowerCase().includes(ye)})},[y,I,O]),re=h.useMemo(()=>y.filter(ye=>pe.includes(String(ye.filename||"").trim())),[y,pe]),P=Ti($),[de,Ve]=h.useState(0),et=Ud(n,r&&P,de);function at(ye){le({filename:String(ye.filename||""),kind:b,title:ye.title||ye.filename,initial_tab:"spec"})}async function mt(ye,Ce){H("");try{await n.backlog_move({from_kind:b,to_kind:Ce,filename:String(ye.filename||"")}),await Ne()}catch(Je){H(String((Je==null?void 0:Je.message)||Je||"Move failed"))}}async function ft(ye){const Ce=String(ye.filename||"").trim();if(!Ce)return;let Je=null;try{const yt=await n.backlog_content("planned",Ce);Je=qd({task_type:ye.task_type},Li(String((yt==null?void 0:yt.content)||"")))}catch{Je=null}w(""),Q(d),ae({filename:Ce,title:ye.title||Ce,readiness:Je}),ze.load_exec_config()}async function Ee(ye){if(!(!te||M)){Z(!0),w("");try{const Ce=ze.exec_cfg||await ze.load_exec_config();if(!Ce||Ce.can_execute!==!0){w((Ce==null?void 0:Ce.runner_error)||"Backlog exec is not available on this gateway.");return}const Je=!!(te.readiness&&!te.readiness.ok);await n.backlog_execute({kind:"planned",filename:te.filename,execution_mode:U,executor:ye==null?void 0:ye.executor,target_model:ye==null?void 0:ye.target_model,target_reasoning_effort:ye==null?void 0:ye.target_reasoning_effort,dor:"check",override:Je}),ae(null),await Ne()}catch(Ce){const Je=wd(Ce);Je?(ae(yt=>yt&&{...yt,readiness:Je,server_refused:!0}),w("")):w(String((Ce==null?void 0:Ce.message)||Ce||"Execute failed"))}finally{Z(!1)}}}async function tt(ye){if(!(be||re.length<2)){Me(""),Ae(!0);try{const Ce=ze.exec_cfg||await ze.load_exec_config();if(!Ce||Ce.can_execute!==!0){Me((Ce==null?void 0:Ce.runner_error)||"Backlog exec is not available on this gateway.");return}await n.backlog_execute_batch({items:re.map(Je=>({kind:"planned",filename:String(Je.filename||"")})),execution_mode:he,executor:ye,dor:"check",override:lt}),ve(!1),G([]),Ue(!1),await Ne()}catch(Ce){const Je=wd(Ce);if(Je){const yt=Je.checks.filter(_t=>!_t.ok);Ue(!0),Me(`Definition of Ready refused by the gateway:
88
+ ${yt.map(_t=>`○ ${_t.label}${_t.evidence?` — ${_t.evidence}`:""}`).join(`
89
+ `)}
90
+ Execute batch again to override (recorded as dor_overridden).`)}else Me(String((Ce==null?void 0:Ce.message)||Ce||"Execute batch failed"))}finally{Ae(!1)}}}async function ht(){if(je||re.length<2)return;const ye=ge.trim();if(!ye){xe("Title is required.");return}xe(""),Oe(!0);try{await n.backlog_merge({kind:"planned",items:re.map(Ce=>({kind:"planned",filename:String(Ce.filename||"")})),package:dt.trim()||"framework",task_type:W,title:ye,summary:B.trim()||void 0}),Xe(!1),G([]),await Ne()}catch(Ce){xe(String((Ce==null?void 0:Ce.message)||Ce||"Merge failed"))}finally{Oe(!1)}}function Pt(ye){const Ce=String(ye||"").trim();G(Je=>Je.includes(Ce)?Je.filter(yt=>yt!==Ce):[...Je,Ce])}function wt(ye){if(b==="planned"){const Ce=fe.has(String(ye.filename||"").trim());return e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:()=>void ft(ye),disabled:!r||Ce,title:Ce?"A live execution request already exists for this item":void 0,children:Ce?"Processing…":"Execute"}),e.jsx("button",{className:"btn",title:"Move back to Triage (proposed)",onClick:()=>void mt(ye,"proposed"),disabled:!r,children:"→ Triage"}),e.jsx("button",{className:"btn",title:"Move to trash",onClick:()=>void mt(ye,"trash"),disabled:!r,children:"Trash"})]})}return b==="proposed"?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",title:"Promote to Ready (planned)",onClick:()=>void mt(ye,"planned"),disabled:!r,children:"→ Ready"}),e.jsx("button",{className:"btn",title:"Deprecate",onClick:()=>void mt(ye,"deprecated"),disabled:!r,children:"Deprecate"}),e.jsx("button",{className:"btn",title:"Move to trash",onClick:()=>void mt(ye,"trash"),disabled:!r,children:"Trash"})]}):b==="recurrent"?e.jsx("button",{className:"btn",title:"Move to trash",onClick:()=>void mt(ye,"trash"),disabled:!r,children:"Trash"}):b==="deprecated"||b==="trash"?e.jsx("button",{className:"btn",title:"Restore to Triage (proposed)",onClick:()=>void mt(ye,"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:lh.map(ye=>e.jsx("button",{"aria-pressed":b===ye.id,className:`seg_btn ${b===ye.id?"active":""}`,onClick:()=>v(ye.id),children:ye.label},ye.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 ${L?"is_loading":""}`,onClick:()=>void Ne(),disabled:!r||L,title:"Refresh","aria-label":"Refresh",children:[e.jsx(He,{name:"refresh",size:16}),L?"Refreshing":"Refresh"]})]}),P?e.jsx(Bd,{gateway:n,surface:"the backlog archive",status:et.status,legacy:et.legacy,error:$,on_changed:()=>{Ve(ye=>ye+1),Ne()}}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"page_toolbar",children:[e.jsx("input",{className:"board_search",value:I,onChange:ye=>D(ye.target.value),placeholder:"Search backlog (id/title/package/filename…)"}),e.jsxs("select",{value:O,onChange:ye=>q(ye.target.value),title:"Filter by type",children:[e.jsx("option",{value:"all",children:"all types"}),Za.map(ye=>e.jsx("option",{value:ye,children:ye},ye))]}),e.jsx("div",{className:"page_toolbar_spacer"}),b==="planned"&&pe.length?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"chip mono info",children:[pe.length," selected"]}),e.jsx("button",{className:"btn primary",disabled:pe.length<2,onClick:()=>{Me(""),z(d),Ue(!1),ve(!0),ze.load_exec_config()},children:"Execute batch"}),e.jsx("button",{className:"btn",disabled:pe.length<2,onClick:()=>{const ye=re.map(Ce=>String(Ce.package||"").trim()).filter(Boolean);Ze(ye.length&&ye.every(Ce=>Ce===ye[0])?ye[0]:"framework"),X("task"),Y(`Master backlog (${re.length} items)`),oe(""),xe(""),Xe(!0)},children:"Merge → master"})]}):null,e.jsxs("span",{className:"mono muted backlog_count",style:{fontSize:"var(--font-size-sm)"},children:[Le.length,"/",y.length]})]}),$&&!P?e.jsx("div",{className:"page_error mono",children:$}):null,A?e.jsx("div",{className:"page_error mono",children:A}):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=lh.find(ye=>ye.id===b))==null?void 0:tn.label}),e.jsxs("span",{className:"pane_count",children:[Le.length," item",Le.length===1?"":"s"]})]}),e.jsx("div",{className:"pane_body",style:{padding:0},children:Le.length?e.jsxs("table",{className:"data_table backlog_table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[b==="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"}),b!=="completed"?e.jsx("th",{className:"backlog_table_actions col_actions",children:"actions"}):null]})}),e.jsx("tbody",{children:Le.map(ye=>{const Ce=String(ye.filename||"").trim(),Je=Xo(ye.task_type),yt=Sd(ye)?kd(ye.priority):null,_t=Array.isArray(ye.labels)?ye.labels:[];return e.jsxs("tr",{className:"backlog_row",onClick:()=>at(ye),children:[b==="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:pe.includes(Ce),onChange:()=>Pt(Ce),"aria-label":`Select ${Ce}`})})}):null,e.jsx("td",{className:"mono muted col_id",children:ye.item_id||""}),e.jsx("td",{className:"col_type",children:Je?e.jsx("span",{className:`chip mono ${mp(Je)}`,title:fp(Je),children:Je}):null}),e.jsx("td",{className:"mono muted col_package",title:ye.package||"",children:ye.package||""}),e.jsx("td",{className:"backlog_table_title",title:Ce,children:ye.title||Ce}),e.jsx("td",{className:"col_priority",children:yt?e.jsx("span",{className:`chip mono board_prio_${yt.toLowerCase()}`,children:yt}):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]}),b!=="completed"?e.jsx("td",{className:"backlog_table_actions col_actions",onClick:jt=>jt.stopPropagation(),children:e.jsx("div",{className:"entity_card_actions",children:wt(ye)})}):null]},`${b}:${Ce}`)})})]}):e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",padding:"12px"},children:L?"Loading…":"No items."})})]})]}),e.jsx(Sp,{open:!!te,target:te?{kind:"planned",filename:te.filename,title:te.title}:null,execute_mode:U,set_execute_mode:Q,action_loading:M,action_error:k,exec_cfg:ze.exec_cfg,exec_cfg_loading:ze.exec_cfg_loading,exec_cfg_error:ze.exec_cfg_error,executors:ne,readiness:(te==null?void 0:te.readiness)??null,server_refused:(te==null?void 0:te.server_refused)===!0,show_readiness:!0,on_open_spec:te?()=>{const ye=te;ae(null),le({filename:ye.filename,kind:"planned",title:ye.title,initial_tab:"spec"})}:void 0,on_confirm:ye=>void Ee(ye),on_close:()=>ae(null)}),e.jsx(jx,{open:K,batch_selected_items:re,batch_execute_mode:he,set_batch_execute_mode:z,batch_execute_loading:be,batch_execute_error:De,executors:ne,exec_cfg:ze.exec_cfg,exec_cfg_loading:ze.exec_cfg_loading,exec_cfg_error:ze.exec_cfg_error,on_confirm:ye=>void tt(ye),on_close:()=>{ve(!1),Me(""),Ue(!1)}}),e.jsx(kx,{open:ct,batch_selected_items:re,merge_package:dt,set_merge_package:Ze,merge_task_type:W,set_merge_task_type:X,merge_title:ge,set_merge_title:Y,merge_summary:B,set_merge_summary:oe,merge_loading:je,merge_error:se,on_confirm:()=>void ht(),on_close:()=>{Xe(!1),xe("")}}),e.jsx(bp,{gateway:n,can_use_gateway:r,target:ke,on_close:()=>le(null),on_mutated:async()=>{await Ne()},on_open_executions:ye=>{var Ce;return(Ce=a.on_open_executions)==null?void 0:Ce.call(a,ye)}}),e.jsx(vx,{gateway:n,can_use_gateway:r,is_compact_layout:p,maint_provider:i,maint_model:l,maint_reasoning:u,advisor_agent:m,focus_kind:b,focus_type:O,voice_session_id:a.voice_session_id})]})}function Nx(a){const{open:n,gateway:r,can_use_gateway:i,maint_provider:l,maint_model:u,maint_reasoning:m,on_close:d,on_created:p}=a,[b,v]=h.useState(""),[y,C]=h.useState(!1),[L,T]=h.useState(""),[$,E]=h.useState("proposed"),[I,D]=h.useState("feature"),[O,q]=h.useState("framework"),[A,H]=h.useState(""),[fe,ie]=h.useState(""),[Se,ke]=h.useState(""),[le,pe]=h.useState(""),[G,te]=h.useState(""),[ae,U]=h.useState(""),[Q,M]=h.useState(!1),[Z,ne]=h.useState(""),[k,w]=h.useState(""),[K,ve]=h.useState(""),[he,z]=h.useState(""),[be,Ae]=h.useState(""),[De,Me]=h.useState(""),[lt,Ue]=h.useState(""),[ct,Xe]=h.useState(""),[dt,Ze]=h.useState(""),[W,X]=h.useState(""),[ge,Y]=h.useState([]),[B,oe]=h.useState(!1),[je,Oe]=h.useState(""),[se,xe]=h.useState([]),[ze,Ne]=h.useState(""),[Le,re]=h.useState(!1);function P(){E("proposed"),D("feature"),q("framework"),H(""),ie(""),ke(""),pe(""),te(""),U(""),M(!1),ne(""),w(""),ve(""),z(""),Ae(""),Me(""),Ue(""),Xe(""),Ze(""),X(""),Y([]),oe(!1),Oe(""),xe([]),Ne(""),re(!1)}function de(){d(),P()}async function Ve(){const Ee=String(b||"").trim();if(Ee)return Ee;if(y)return"";T(""),C(!0);try{const tt=await r.backlog_template(),ht=String((tt==null?void 0:tt.content)||"");return v(ht),ht}catch(tt){return T(String((tt==null?void 0:tt.message)||tt||"Failed to load backlog template")),""}finally{C(!1)}}async function et(Ee){if(!i)return;const tt=(Ee==null?void 0:Ee.force)===!0;if(!tt&&G.trim())return;const ht=await Ve();if(!ht.trim())return;const Pt=String(O||"").trim().toLowerCase()||"{Package}",wt=xd(),tn=Gv(ht,{package_name:Pt,title:A,task_type:I,summary:fe,created_at:wt});te(ye=>tt||!String(ye||"").trim()?tn:ye)}h.useEffect(()=>{n&&i&&et()},[n,i]);function at(Ee){if(G.trim()&&!globalThis.confirm("Overwrite the current draft markdown with a guided draft?"))return;const tt=String(O||"").trim().toLowerCase()||"{Package}",ht=xd(),Pt=Kv({package_name:tt,title:A,task_type:I,summary:fe,diagram:Z,context:k,included:Ja(K),excluded:Ja(he),plan:Ja(be),dependencies:Ja(De),acceptance:Ja(lt),tests_a:Ja(ct),tests_b:Ja(dt),tests_c:Ja(W),created_at:ht,attachments:[]});te(Pt)}async function mt(){var tt;if(Q)return;U(""),M(!0),Oe("");let Ee="";try{const ht=String(O||"").trim().toLowerCase(),Pt=Fd(le),wt=!!(Se||Pt.length);let tn=G||"";wt&&tn.trim()&&(tn=jd(tn,{priority:Se||null,labels:Pt}));const ye=await r.backlog_create({kind:$,package:ht,title:A,task_type:I,summary:fe||null,content:tn||null}),Ce=String((ye==null?void 0:ye.kind)||"").trim(),Je=String((ye==null?void 0:ye.filename)||"").trim();if(wt&&!tn.trim()&&Ce&&Je)try{const _t=await r.backlog_content(Ce,Je),jt=String((_t==null?void 0:_t.content)||""),rt=await bd(jt),Cn=jd(jt,{priority:Se||null,labels:Pt});await r.backlog_update({kind:Ce,filename:Je,content:Cn,expected_sha256:rt||null})}catch(_t){Ee=[Ee,`metadata lines not written: ${String((_t==null?void 0:_t.message)||_t)}`].filter(Boolean).join("; ")}const yt=[...ge||[]];if(Ce&&Je&&yt.length){oe(!0);const _t=[];try{for(const jt of yt){const rt=await r.backlog_upload_attachment({kind:Ce,filename:Je,file:jt,overwrite:!1}),Cn=String(((tt=rt==null?void 0:rt.stored)==null?void 0:tt.relpath)||"").trim();Cn&&_t.push(Cn)}}catch(jt){Ee=[Ee,String((jt==null?void 0:jt.message)||jt||"Attachment upload failed")].filter(Boolean).join("; "),Oe(Ee)}finally{if(_t.length)try{const jt=await r.backlog_content(Ce,Je),rt=String((jt==null?void 0:jt.content)||""),Cn=await bd(rt),Cs=Jv(rt,_t);await r.backlog_update({kind:Ce,filename:Je,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("; ")}oe(!1)}}d(),P();try{await p(Ce,Je,Ee)}catch{}}catch(ht){U(String((ht==null?void 0:ht.message)||ht||"Create failed"))}finally{M(!1)}}async function ft(){if(Le)return;U("");const Ee=ze.trim();if(!Ee)return;if(!A.trim()){U("Title is required before using AI assist.");return}const tt=String(O||"").trim().toLowerCase();if(!tt){U("Package is required before using AI assist.");return}const ht={id:Ir(),role:"user",content:Ee,ts:new Date().toISOString()},Pt=[...se,ht];xe(Pt),Ne(""),re(!0);try{const wt=await r.backlog_assist({kind:$,package:tt,title:A,summary:fe||null,draft_markdown:G||null,messages:Pt.map(Ce=>({role:Ce.role,content:Ce.content})),provider:l||null,model:u||null,thinking:m||null}),tn=String((wt==null?void 0:wt.reply)||"").trim(),ye=String((wt==null?void 0:wt.draft_markdown)||"").trim();tn&&xe(Ce=>[...Ce,{id:Ir(),role:"assistant",content:tn,ts:new Date().toISOString()}]),ye&&te(ye)}catch(wt){U(String((wt==null?void 0:wt.message)||wt||"AI assist failed"))}finally{re(!1)}}return e.jsxs(er,{open:n,title:"New backlog task",onClose:de,actions:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:de,disabled:Q||Le,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:()=>void mt(),disabled:Q||!A.trim()||!O.trim(),children:Q?"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=>E(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:I,onChange:Ee=>D(Ee.target.value),children:Za.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:O,onChange:Ee=>q(Ee.target.value),placeholder:"framework"})]})})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Title"}),e.jsx("input",{value:A,onChange:Ee=>H(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:Se,onChange:Ee=>ke(Ee.target.value),children:[e.jsx("option",{value:"",children:"unset"}),el.map(Ee=>e.jsx("option",{value:Ee,children:_p[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:le,onChange:Ee=>pe(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:fe,onChange:Ee=>ie(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:Z,onChange:Ee=>ne(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:k,onChange:Ee=>w(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:K,onChange:Ee=>ve(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:he,onChange:Ee=>z(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=>Ae(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:De,onChange:Ee=>Me(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:lt,onChange:Ee=>Ue(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:ct,onChange:Ee=>Xe(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:dt,onChange:Ee=>Ze(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:W,onChange:Ee=>X(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:()=>at(),disabled:Q||Le,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 tt=Array.from(Ee.target.files||[]);tt.length&&(Y(ht=>[...ht,...tt]),Ee.currentTarget.value="")}})}),ge.length?e.jsx("div",{className:"mono",style:{fontSize:"var(--font-size-sm)",marginTop:"6px"},children:ge.map((Ee,tt)=>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:()=>Y(ht=>ht.filter((Pt,wt)=>wt!==tt)),disabled:Q||B,children:"Remove"})]},`${Ee.name}_${Ee.size}_${tt}`))}):null,B?e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:"Uploading attachments…"}):null,je?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:je}):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,L?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:L}):null,e.jsx("div",{className:"row",style:{marginTop:"10px",justifyContent:"flex-end",gap:"8px"},children:e.jsx("button",{className:"btn",onClick:()=>{G.trim()&&!globalThis.confirm("Reset the draft markdown to the backlog template?")||et({force:!0})},disabled:Q||Le||y||!i,children:"Reset from template"})}),e.jsx("div",{className:"field",children:e.jsx("textarea",{value:G,onChange:Ee=>te(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($c,{messages:se,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(sl,{value:ze,onChange:Ne,onSubmit:()=>void ft(),placeholder:"Message to AI (e.g. refine acceptance criteria…)",disabled:!i||!A.trim(),busy:Le,rows:3,sendButtonClassName:"btn primary"})}),ae?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:ae}):null]})}class Cp extends Wt.Component{constructor(){super(...arguments);Ka(this,"state",{error:null})}static getDerivedStateFromError(r){return{error:r}}static getDerivedStateFromProps(r,i){return i.error&&i.for_key!==void 0&&r.resetKey!==i.for_key?{error:null,for_key:r.resetKey}:i.for_key!==r.resetKey&&!i.error?{for_key:r.resetKey}:null}componentDidCatch(r,i){var l,u;try{(u=(l=this.props).onError)==null||u.call(l,r,i)}catch{}}render(){const{error:r}=this.state;if(r){const{fallback:i}=this.props;return typeof i=="function"?i(r):i}return this.props.children}}function $p(a){return`abstractcontinuum_list_open_${a}`}function Ep(){try{return typeof localStorage>"u"?null:localStorage}catch{return null}}function $d(a,n=Ep()){try{return(n==null?void 0:n.getItem($p(a)))!=="0"}catch{return!0}}function Tp(a,n,r=Ep()){try{r==null||r.setItem($p(a),n?"1":"0")}catch{}}function Cc(a){const[n,r]=h.useState(()=>$d(a)),i=h.useCallback(()=>{r(l=>{const u=!l;return Tp(a,u),u})},[a]);return[n,i]}function Cx(a){const[n,r]=h.useState({}),i=h.useCallback(u=>u in n?n[u]:$d(`${a}_${u}`),[n,a]),l=h.useCallback(u=>{r(m=>{const d=!(u in m?m[u]:$d(`${a}_${u}`));return Tp(`${a}_${u}`,d),{...m,[u]:d}})},[a]);return[i,l]}function tl(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(He,{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 nl(a){var n,r;try{if(!a||typeof window>"u"||!((n=window.matchMedia)!=null&&n.call(window,"(max-width: 767.98px)").matches))return;(r=a.scrollIntoView)==null||r.call(a,{block:"start",behavior:"smooth"})}catch{}}class Vd{async _fetch(n,r,i){const l=await fetch(`api/hub${r}`,{...i,signal:(i==null?void 0:i.signal)??AbortSignal.timeout(2e4),headers:{...i!=null&&i.body?{"Content-Type":"application/json"}:{}}}),u=await l.text();let m=null;try{m=JSON.parse(u)}catch{}if(!l.ok){const d=m&&typeof m=="object"&&(m.detail||m.error)||u,p=new Error(`${n} failed: ${d}`);throw p.status=l.status,p}return m}async meta(){return await this._fetch("hub_meta","/meta")}async healthz(){return await this._fetch("hub_healthz","/healthz")}async ledger(n){return await this._fetch("hub_ledger",`/channels/${encodeURIComponent(n)}/ledger`)}async channel_info(n){return await this._fetch("hub_channel_info",`/channels/${encodeURIComponent(n)}/info`)}async digest(n){return await this._fetch("hub_digest",`/channels/${encodeURIComponent(n)}/digest`)}async fs_list(n,r=""){const i=r?`?prefix=${encodeURIComponent(r)}`:"",l=await this._fetch("hub_fs_list",`/channels/${encodeURIComponent(n)}/fs${i}`);return Array.isArray(l)?l:[]}async fs_read(n,r){const i=r.split("/").map(encodeURIComponent).join("/");return await this._fetch("hub_fs_read",`/channels/${encodeURIComponent(n)}/fs/${i}`)}async inbox(){const n=await this._fetch("hub_inbox","/inbox");return Array.isArray(n)?n:[]}async channels(){const n=await this._fetch("hub_channels","/channels");return Array.isArray(n)?n:[]}async messages(n,r){const i=new URLSearchParams;(r==null?void 0:r.since)!==void 0&&i.set("since",String(r.since)),r!=null&&r.limit&&i.set("limit",String(r.limit)),r!=null&&r.sort&&i.set("sort",r.sort);const l=await this._fetch("hub_messages",`/channels/${encodeURIComponent(n)}/messages?${i.toString()}`);return Array.isArray(l)?l:[]}async search(n){const r=new URLSearchParams;r.set("q",n.q);for(const i of n.channel??[])r.append("channel",i);return n.sender&&r.set("sender",n.sender),n.kind&&r.set("kind",n.kind),n.since!==void 0&&r.set("since",String(n.since)),n.until!==void 0&&r.set("until",String(n.until)),n.ref&&r.set("ref",n.ref),n.rated&&r.set("rated",n.rated),n.min_votes&&r.set("min_votes",String(n.min_votes)),n.sort&&r.set("sort",n.sort),n.limit&&r.set("limit",String(n.limit)),n.cursor&&r.set("cursor",n.cursor),await this._fetch("hub_search",`/search?${r.toString()}`)}async read_message(n,r){const i=await this._fetch("hub_read_message",`/channels/${encodeURIComponent(n)}/messages/${encodeURIComponent(r)}`);return(Array.isArray(i)?i[0]:i)??null}async post_message(n,r){return await this._fetch("hub_post",`/channels/${encodeURIComponent(n)}/messages`,{method:"POST",body:JSON.stringify(r)})}async upload_attachment(n,r){const i=`api/hub/channels/${encodeURIComponent(n)}/attachments?filename=${encodeURIComponent(r.name)}`,l=await fetch(i,{method:"POST",headers:{"Content-Type":r.type||"application/octet-stream"},body:r,signal:AbortSignal.timeout(6e4)}),u=await l.text();let m=null;try{m=JSON.parse(u)}catch{}if(!l.ok){const d=m&&typeof m=="object"&&(m.detail||m.error)||u,p=new Error(`upload failed: ${d}`);throw p.status=l.status,p}if(!m||typeof m!="object"||!m.id)throw new Error("upload returned no attachment id (unexpected hub response shape)");return m}attachment_url(n,r){return`api/hub/channels/${encodeURIComponent(n)}/attachments/${encodeURIComponent(r)}`}async ack(n,r){return await this._fetch("hub_ack","/inbox/ack",{method:"POST",body:JSON.stringify({cursors:{[n]:r}})})}async members(n){const r=await this._fetch("hub_members",`/channels/${encodeURIComponent(n)}/members`);return Array.isArray(r)?r:[]}async create_channel(n,r){return await this._fetch("hub_create_channel","/channels",{method:"POST",body:JSON.stringify({name:n,private:r})})}async put_channel_meta(n,r,i){const l={value:r};return typeof i=="number"&&(l.expect_version=i),await this._fetch("hub_channel_meta_put",`/channels/${encodeURIComponent(n)}/store/${encodeURIComponent("channel:meta")}`,{method:"PUT",body:JSON.stringify(l)})}async channel_meta(n){return await this._fetch("hub_channel_meta",`/channels/${encodeURIComponent(n)}/store/${encodeURIComponent("channel:meta")}`)}async block(n,r,i){return await this._fetch("hub_block",`/channels/${encodeURIComponent(n)}/blocks`,{method:"POST",body:JSON.stringify({agent:r,seconds:i==null?void 0:i.seconds,reason:i==null?void 0:i.reason})})}async unblock(n,r){return await this._fetch("hub_unblock",`/channels/${encodeURIComponent(n)}/blocks/${encodeURIComponent(r)}`,{method:"DELETE"})}async hub_block(n,r){return await this._fetch("hub_hub_block","/hub/blocks",{method:"POST",body:JSON.stringify({agent:n,seconds:r==null?void 0:r.seconds,reason:r==null?void 0:r.reason})})}async hub_unblock(n){return await this._fetch("hub_hub_unblock",`/hub/blocks/${encodeURIComponent(n)}`,{method:"DELETE"})}async leave(n){return await this._fetch("hub_leave",`/channels/${encodeURIComponent(n)}/leave`,{method:"POST"})}async archive(n){return await this._fetch("hub_archive",`/channels/${encodeURIComponent(n)}/archive`,{method:"POST"})}async unarchive(n){return await this._fetch("hub_unarchive",`/channels/${encodeURIComponent(n)}/archive`,{method:"DELETE"})}async retire_agent(n,r){return await this._fetch("hub_retire",`/agents/${encodeURIComponent(n)}/retire`,{method:"POST",body:JSON.stringify(r?{reason:r}:{})})}async unretire_agent(n){return await this._fetch("hub_unretire",`/agents/${encodeURIComponent(n)}/retire`,{method:"DELETE"})}async retired_agents(){const n=await this._fetch("hub_retired","/agents/retired");return Array.isArray(n)?n:[]}async delete_agent(n){return await this._fetch("hub_delete_agent",`/agents/${encodeURIComponent(n)}`,{method:"DELETE"})}async list_blocks(n){const r=n?`?scope=${encodeURIComponent(n)}`:"",i=await this._fetch("hub_blocks",`/blocks${r}`);return Array.isArray(i)?i:[]}async send_dm(n,r){return await this._fetch("hub_send_dm",`/dms/${encodeURIComponent(n)}/messages`,{method:"POST",body:JSON.stringify({body:r.body,title:r.title||void 0,status:r.status||"open"})})}async store_keys(n){const r=await this._fetch("hub_store_keys",`/channels/${encodeURIComponent(n)}/store`);return Array.isArray(r)?r:[]}async store_get(n,r){return await this._fetch("hub_store_get",`/channels/${encodeURIComponent(n)}/store/${encodeURIComponent(r)}`)}async delegations(){const n=await this._fetch("hub_delegations","/delegations");return Array.isArray(n)?n:[]}async set_delegation(n,r,i){return await this._fetch("hub_set_delegation","/admin/delegation",{method:"PUT",body:JSON.stringify({agent_id:n,powers:r,ttl_seconds:(i==null?void 0:i.ttl_seconds)??null,note:(i==null?void 0:i.note)??""})})}async revoke_delegation(n){return await this._fetch("hub_revoke_delegation",`/admin/delegation/${encodeURIComponent(n)}`,{method:"DELETE"})}async retract_message(n,r){return await this._fetch("hub_retract",`/channels/${encodeURIComponent(n)}/messages/${encodeURIComponent(r)}/retract`,{method:"POST",body:JSON.stringify({})})}async desk(){const n=await this._fetch("hub_desk","/desk");return Array.isArray(n)?{rows:n,satisfied:[]}:{...n,rows:Array.isArray(n==null?void 0:n.rows)?n.rows:[],satisfied:Array.isArray(n==null?void 0:n.satisfied)?n.satisfied:[]}}async owed(){const n=await this._fetch("hub_owed","/owed"),r=n&&typeof n=="object"?n:{};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(n){return await this._fetch("hub_create_group","/groups",{method:"POST",body:JSON.stringify({name:n.name,members:n.members,purpose:n.purpose,opening_post:n.opening_post||n.purpose,private:n.private!==!1})})}async work_rows(n){const r=await this._fetch("hub_work_rows",`/channels/${encodeURIComponent(n)}/work`);return Array.isArray(r)?r:[]}async work(n){return await this._fetch("hub_work",`/work/${encodeURIComponent(n)}`)}async create_invite(n,r){const i=await this._fetch("hub_create_invite",`/channels/${encodeURIComponent(n)}/invites`,{method:"POST",body:JSON.stringify({agent_id:r})}),l=i&&typeof i=="object"?String(i.invite_token||""):"";if(!l)throw new Error("invite mint returned no token (unexpected hub response shape)");return l}async presence(){const n=await this._fetch("hub_presence","/presence");return Array.isArray(n)?n:[]}async reputation(n){return await this._fetch("hub_reputation",`/channels/${encodeURIComponent(n)}/reputation`)}async reputation_hub(){return await this._fetch("hub_reputation_hub","/reputation")}async reputation_votes(n,r){const i=await this._fetch("hub_reputation_votes",`/channels/${encodeURIComponent(n)}/reputation/${encodeURIComponent(r)}/votes`);return Array.isArray(i)?i:[]}async rate_message(n,r,i,l=""){const u={value:i,note:l};return await this._fetch("hub_rate_message",`/channels/${encodeURIComponent(n)}/messages/${encodeURIComponent(r)}/rating`,{method:"PUT",body:JSON.stringify(u)})}async unrate_message(n,r){return await this._fetch("hub_unrate_message",`/channels/${encodeURIComponent(n)}/messages/${encodeURIComponent(r)}/rating`,{method:"DELETE"})}async rate(n,r,i,l,u=""){return await this._fetch("hub_rate",`/channels/${encodeURIComponent(n)}/reputation/${encodeURIComponent(r)}`,{method:"PUT",body:JSON.stringify({axis:i,value:l,note:u})})}async _delete_reputation(n,r,i){return await this._fetch("hub_unrate",`/channels/${encodeURIComponent(n)}/reputation/${encodeURIComponent(r)}?axis=${encodeURIComponent(i)}`,{method:"DELETE"})}ws_url(){const n=new URL("api/hub/ws",document.baseURI);return n.protocol=n.protocol==="https:"?"wss:":"ws:",n.href}}const $x=["commons"],Ex=3e4,Tx=5*6e4,ch={live:new Map,done:[],work:new Map},uh=new Set(["proposed","planned","completed","deprecated"]);function Ax(a,n){const r=n&&typeof n=="object"?String(n.item||""):"";if(r&&Vs(r))return r;const i=a.startsWith("claim:")?a.slice(6):"";return i&&Vs(i)?i:null}function Lx(a){const[n,r]=h.useState(ch),i=h.useRef(new Vd),l=h.useRef(new Map),u=h.useRef(0),m=h.useRef(!1);return h.useEffect(()=>{let d=!0;const p=async()=>{if(!(m.current||Date.now()<u.current)){m.current=!0;try{const v=new Map,y=[],C=new Map;for(const L of $x){let T=!1;try{const E=await i.current.work_rows(L);for(const I of E){const D=String(I.id||I.item||""),O=String(I.status||"").toLowerCase();!Vs(D)||!uh.has(O)||C.set(D,{item:D,title:typeof I.title=="string"?I.title:void 0,status:O,owner:typeof I.owner=="string"?I.owner:void 0,receipt:typeof I.receipt=="string"?I.receipt:void 0,card:typeof I.card=="string"?I.card:void 0,updated_at:I.updated_at})}T=!0}catch{}const $=await i.current.store_keys(L);for(const E of $){const I=String(E.key||"");if(I.startsWith("work:")){if(T)continue;const ie=I.slice(5);if(!Vs(ie))continue;const Se=Number(E.version||0),ke=`${L}\0${I}`,le=l.current.get(ke);let pe;if(le&&le.version===Se)pe=le.value;else{const te=await i.current.store_get(L,I);pe=te==null?void 0:te.value,l.current.set(ke,{version:Se,value:pe})}const G=pe&&typeof pe=="object"?String(pe.status||"").toLowerCase():"";if(!uh.has(G))continue;C.set(ie,{item:ie,title:typeof pe.title=="string"?pe.title:void 0,status:G,owner:typeof pe.owner=="string"?pe.owner:void 0,receipt:typeof pe.receipt=="string"?pe.receipt:void 0,card:typeof pe.card=="string"?pe.card:void 0,updated_at:E.updated_at});continue}if(!I.startsWith("claim:"))continue;const D=Number(E.version||0),O=`${L}\0${I}`,q=l.current.get(O);let A;if(q&&q.version===D)A=q.value;else{const ie=await i.current.store_get(L,I);A=ie==null?void 0:ie.value,l.current.set(O,{version:D,value:A})}if(!A||typeof A!="object"||typeof A.owner!="string"||!A.owner)continue;const H=Ax(I,A)||I.slice(6);if(!H)continue;!!A.done||String(A.status||"").toLowerCase()==="done"?y.push({item:H,owner:A.owner,receipt:typeof A.receipt=="string"?A.receipt:void 0,updated_at:E.updated_at}):v.has(H)||v.set(H,A)}}y.sort((L,T)=>(T.updated_at||0)-(L.updated_at||0)),d&&r(L=>L.live.size===v.size&&[...v.keys()].every($=>JSON.stringify(L.live.get($))===JSON.stringify(v.get($)))&&JSON.stringify(L.done)===JSON.stringify(y)&&L.work.size===C.size&&[...C.keys()].every($=>JSON.stringify(L.work.get($))===JSON.stringify(C.get($)))?L:{live:v,done:y,work:C})}catch{u.current=Date.now()+Tx,d&&r(v=>v.live.size||v.done.length||v.work.size?ch:v)}finally{m.current=!1}}};p();const b=setInterval(()=>void p(),Ex);return()=>{d=!1,clearInterval(b)}},[a]),n}const Rx=40,Mx=4;function Px(a){const{gateway:n,can_use_gateway:r,data_nonce:i}=a,[l,u]=h.useState([]),[m,d]=h.useState(!1),[p,b]=h.useState(""),[v,y]=h.useState(""),[C,L]=h.useState(null),[T,$]=h.useState(null),[E,I]=h.useState({}),D=h.useRef({}),O=h.useRef(!1),q=h.useCallback(async ie=>{if(r&&!O.current){O.current=!0,ie!=null&&ie.background||d(!0);try{const[Se,ke,le,pe,G]=await Promise.allSettled([n.backlog_list("proposed"),n.backlog_list("planned"),n.backlog_exec_requests({status:"queued,running,awaiting_qa",limit:200}),n.backlog_exec_requests({status:"promoted,completed,failed",limit:60}),n.backlog_exec_active_items({status:"queued,running,awaiting_qa",limit:1200})]),te=[],ae=[],U=(be,Ae)=>be.status==="fulfilled"?be.value:(te.push(Ae),ae.push(be.reason),null),Q=U(Se,"proposed list"),M=U(ke,"planned list"),Z=U(le,"live requests"),ne=U(pe,"recent history"),k=U(G,"busy set");if(L(ae.find(be=>Ti(be))??null),!Q&&!M&&!Z&&!ne){b("Failed to load the board (all sources failed)");return}b("");const w=Array.isArray(Z==null?void 0:Z.requests)?Z.requests:[];let K=Array.isArray(k==null?void 0:k.items)?k.items:[];k||(K=w.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 ve=Array.isArray(Q==null?void 0:Q.items)?Q.items:[],he=Array.isArray(M==null?void 0:M.items)?M.items:[];$(Q&&M?ve.length+he.length:null);const z=dx({proposed:ve,planned:he,active_requests:w,terminal_requests:Array.isArray(ne==null?void 0:ne.requests)?ne.requests:[],active_items:K});u(z),y(te.length?`#FALLBACK partial board — failed: ${te.join(", ")}`:""),A(z,ve,he)}finally{O.current=!1,ie!=null&&ie.background||d(!1)}}},[n,r]);async function A(ie,Se,ke){const le=new Map;for(const ae of Se)le.set(String(ae.filename||"").trim(),"proposed");for(const ae of ke)le.set(String(ae.filename||"").trim(),"planned");const pe=ie.filter(ae=>ae.filename&&!D.current[ae.filename]&&le.has(ae.filename)).filter(ae=>!xp(ae)||ae.column==="ready").slice(0,Rx).map(ae=>({filename:ae.filename,kind:le.get(ae.filename)}));if(!pe.length)return;const G=[...pe],te=Array.from({length:Math.min(Mx,G.length)},async()=>{for(;;){const ae=G.shift();if(!ae)return;try{const U=await n.backlog_content(ae.kind,ae.filename),Q=Li(String((U==null?void 0:U.content)||""));D.current={...D.current,[ae.filename]:Q}}catch{}}});await Promise.all(te),I(D.current)}const H=h.useCallback(async(ie,Se)=>{try{const ke=await n.backlog_content(ie,Se),le=Li(String((ke==null?void 0:ke.content)||""));D.current={...D.current,[Se]:le},I(D.current)}catch{}},[n]);return h.useEffect(()=>{q()},[q,i]),h.useEffect(()=>{if(!r)return;const ie=setInterval(()=>{n.is_backing_off()||q({background:!0})},1e4);return()=>clearInterval(ie)},[r,q,n]),{cards:l,loading:m,error:p,degraded:v,unconfigured:C!==null,unavailable:C,item_count:T,metadata:E,refresh:q,refresh_item_metadata:H}}function dh(a,n){return a.length<=n?a:`${a.slice(0,n-1).trimEnd()}…`}const zx=new Vd;function Ix(a){if(!a)return"";const n=Math.max(0,Date.now()/1e3-a);return n<3600?`${Math.max(1,Math.round(n/60))}m`:n<172800?`${Math.round(n/3600)}h`:`${Math.round(n/86400)}d`}function Dx(a){const{card:n}=a,r=n.work_id||"",i=!!(r&&Vs(r)),[l,u]=h.useState({loading:i,error:"",claims:[],decisions:[],messages:[]});h.useEffect(()=>{let p=!0;if(i)return u(b=>({...b,loading:!0,error:""})),zx.work(r).then(b=>{p&&u({loading:!1,error:"",claims:Array.isArray(b==null?void 0:b.claims)?b.claims:[],decisions:Array.isArray(b==null?void 0:b.decisions)?b.decisions:[],messages:(Array.isArray(b==null?void 0:b.messages)?b.messages:[]).slice().sort((v,y)=>(y.created_at||0)-(v.created_at||0))})}).catch(b=>{p&&u({loading:!1,error:String((b==null?void 0:b.message)||b||"activity unavailable"),claims:[],decisions:[],messages:[]})}),()=>{p=!1}},[r,i]);const m=l.messages[0],d=n.claim_started_at!==void 0&&n.claim_owner?pp({owner:n.claim_owner,started_at:n.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:p=>p.stopPropagation(),children:[e.jsxs("div",{className:"modal_head",children:[e.jsx("span",{className:"modal_title",children:n.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,n.claim_owner?e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:n.column==="done"?"completed by:":"held by:"})," ",n.claim_owner,d?e.jsxs("span",{className:"muted",children:[" · ",d.label]}):null]}):null,n.summary?e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"receipt:"})," ",n.summary]}):null,n.card_path?e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"item file:"})," ",e.jsx("span",{className:"mono",children:n.card_path}),e.jsxs("span",{className:"muted",children:[" (in ",n.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 ",l.loading?"· loading…":l.messages.length?`· ${l.messages.length} citing message(s)`:""]}),l.error?e.jsxs("div",{className:"muted team_note",children:["#FALLBACK hub activity unavailable (",l.error.slice(0,80),") — the Team thread button below still works."]}):null,!l.loading&&!l.error&&i&&!l.messages.length?e.jsx("div",{className:"muted team_note",children:"No citing messages on the hub yet."}):null,i?null:e.jsx("div",{className:"muted team_note",children:"This claim has no ruled work id — discussion lives in the coordination channel."}),l.messages.slice(0,8).map(p=>e.jsxs("div",{className:"board_activity_msg",children:[e.jsxs("div",{className:"board_activity_msg_head mono",children:[e.jsx("span",{children:p.sender}),e.jsxs("span",{className:"muted",children:[p.channel," #",p.seq," · ",Ix(p.created_at)]}),a.on_open_team?e.jsx("button",{className:"team_row_expand",onClick:()=>a.on_open_team({channel:String(p.channel||""),message_id:String(p.id||""),seq:Number(p.seq)}),title:"Open this message in its Team channel",children:"open ↗"}):null]}),p.title?e.jsx("div",{className:"board_activity_msg_title",children:dh(String(p.title),140)}):null,p.body?e.jsx("div",{className:"board_activity_msg_body muted",children:dh(String(p.body),220)}):null]},p.id||p.seq))]}),e.jsx("div",{className:"entity_skills_actions",children:a.on_open_team?e.jsx("button",{className:"btn primary",onClick:()=>a.on_open_team(m?{channel:String(m.channel||"commons"),message_id:String(m.id||""),seq:Number(m.seq)}:{channel:"commons"}),title:m?"Open the most recent citing message in its channel":"Open the coordination channel",children:"Open discussion in Team"}):null})]})})}function Ox(a){var Oe;const{gateway:n,gateway_connected:r,data_nonce:i,on_mutated:l,on_open_executions:u}=a,m=a.default_execution_mode==="inplace"?"inplace":"uat",d=Wd("(max-width: 767.98px)"),[p,b]=Cx("board_column"),v=Np(n,r),y=Px({gateway:n,can_use_gateway:r,data_nonce:i}),[C,L]=h.useState(0),T=Ud(n,r,i+C),$=y.unconfigured||((Oe=T.status)==null?void 0:Oe.available)===!1,E=!$&&y.item_count===0&&!y.error,I=Lx(!0),D=h.useMemo(()=>fx(y.cards,I),[y.cards,I]),O=Hd({gateway:n,can_use_gateway:r,kind:"planned",completed_view:"tasks",is_exec_view:!1,is_compact_layout:d,set_compact_pane:()=>{},on_status_transfer:()=>{}}),[q,A]=h.useState("");h.useEffect(()=>{var xe;if(!a.query_preset)return;const se=Vs(a.query_preset);A(se?se.num.padStart(4,"0"):a.query_preset),(xe=a.on_query_preset_consumed)==null||xe.call(a)},[a.query_preset]);const[H,fe]=h.useState("all"),[ie,Se]=h.useState("all"),[ke,le]=h.useState(""),[pe,G]=h.useState(!1),[te,ae]=h.useState(null),[U,Q]=h.useState(null),[M,Z]=h.useState(null),[ne,k]=h.useState("uat"),[w,K]=h.useState(!1),[ve,he]=h.useState(""),[z,be]=h.useState(""),[Ae,De]=h.useState(null),Me=h.useRef(null),lt=D.some(se=>se.column==="in_progress"),[,Ue]=h.useState(0);h.useEffect(()=>{if(!lt)return;const se=setInterval(()=>Ue(xe=>(xe+1)%3600),1e3);return()=>clearInterval(se)},[lt]);const ct=h.useMemo(()=>{const se=new Set;for(const xe of D)xe.package&&se.add(xe.package);return[...se].sort()},[D]),Xe=h.useMemo(()=>D.filter(se=>se.filename&&se.kind).length,[D]),dt=h.useMemo(()=>D.filter(se=>se.filename&&se.kind&&(xp(se)||y.metadata[se.filename])).length,[D,y.metadata]),Ze=h.useMemo(()=>{const se=new Map;for(const xe of D)if(xe.filename)for(const ze of Cd(xe,y.metadata[xe.filename]))se.set(ze,(se.get(ze)||0)+1);return[...se.entries()].sort((xe,ze)=>ze[1]-xe[1]).slice(0,12)},[D,y.metadata]),W=h.useMemo(()=>{const se=q.trim().toLowerCase();return D.filter(xe=>{if(H!=="all"&&(xe.package||"")!==H||ie!=="all"&&String(xe.task_type||"").toLowerCase()!==ie)return!1;const ze=xe.filename?y.metadata[xe.filename]:void 0,Ne=Cd(xe,ze);return ke&&!Ne.includes(ke)||pe&&!Ne.some(re=>{const P=re.toLowerCase();return P==="decision-gate"||P.startsWith("wave-")||P.startsWith("seat-")})?!1:se?`${xe.item_id||""} ${xe.title} ${xe.filename||""} ${xe.package||""} ${xe.summary||""} ${xe.exec_status||""} ${Ne.join(" ")} ${Nd(xe,ze)||""}`.toLowerCase().includes(se):!0})},[D,y.metadata,q,H,ie,ke,pe]),X=h.useMemo(()=>{var ze;const se=new Map;for(const Ne of rh)se.set(Ne.id,[]);for(const Ne of W)(ze=se.get(Ne.column))==null||ze.push(Ne);const xe=Ne=>{const Le=Ne.filename?Nd(Ne,y.metadata[Ne.filename]):null;return Le?el.indexOf(Le):el.length};for(const[Ne,Le]of se)(Ne==="triage"||Ne==="ready")&&Le.sort((re,P)=>xe(re)-xe(P)||(P.item_id||0)-(re.item_id||0));return se},[W,y.metadata]);async function ge(se,xe){if(!(!se.filename||!se.kind||se.kind==="completed")&&se.kind!==xe){be("");try{await n.backlog_move({from_kind:se.kind,to_kind:xe,filename:se.filename}),await y.refresh(),l()}catch(ze){be(String((ze==null?void 0:ze.message)||ze||"Move failed"))}}}async function Y(se){if(!se.filename)return;let xe=y.metadata[se.filename];if(!xe)try{const Ne=await n.backlog_content("planned",se.filename);xe=Li(String((Ne==null?void 0:Ne.content)||""))}catch{xe=void 0}const ze=xe?qd({task_type:se.task_type},xe):null;he(""),k(m),Z({filename:se.filename,title:se.title,readiness:ze}),O.load_exec_config()}async function B(se){if(!(!M||w)){K(!0),he("");try{const xe=O.exec_cfg||await O.load_exec_config();if(!xe||xe.can_execute!==!0){he((xe==null?void 0:xe.runner_error)||"Backlog exec is not available on this gateway.");return}const ze=!!(M.readiness&&!M.readiness.ok);await n.backlog_execute({kind:"planned",filename:M.filename,execution_mode:ne,executor:se==null?void 0:se.executor,target_model:se==null?void 0:se.target_model,target_reasoning_effort:se==null?void 0:se.target_reasoning_effort,dor:"check",override:ze}),Z(null),await y.refresh(),l()}catch(xe){const ze=wd(xe);ze?(Z(Ne=>Ne&&{...Ne,readiness:ze,server_refused:!0}),he("")):he(String((xe==null?void 0:xe.message)||xe||"Execute failed"))}finally{K(!1)}}}function oe(se){if(!se.filename&&!se.request_id){const xe=tx(se.card_path);if(xe&&r){n.backlog_content(xe.kind,xe.filename).then(()=>{ae({filename:xe.filename,kind:xe.kind,title:se.title,work_id:se.work_id,has_live_request:!1,initial_tab:"spec"})}).catch(()=>Q(se));return}Q(se);return}ae({filename:se.filename||"",kind:se.kind||null,request_id:se.request_id,title:se.title,work_id:se.work_id,has_live_request:se.column==="in_progress"||se.column==="in_review",initial_tab:se.column==="in_review"?"review":se.column==="in_progress"?"runs":"spec"})}const je={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:q,onChange:se=>A(se.target.value),placeholder:"Search the board…"}),e.jsxs("select",{value:H,onChange:se=>fe(se.target.value),title:"Package",children:[e.jsx("option",{value:"all",children:"all packages"}),ct.map(se=>e.jsx("option",{value:se,children:se},se))]}),e.jsxs("select",{value:ie,onChange:se=>Se(se.target.value),title:"Type",children:[e.jsx("option",{value:"all",children:"all types"}),Za.map(se=>e.jsx("option",{value:se,children:se},se))]}),e.jsx("button",{className:`chip mono board_facet ${pe?"active":"muted"}`,onClick:()=>G(se=>!se),"aria-pressed":pe,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,z?e.jsx("span",{className:"mono board_error",children:z}):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(Bd,{gateway:n,surface:"the board",status:T.status,legacy:T.legacy,error:y.unavailable,on_changed:()=>{L(se=>se+1),y.refresh()}}):null,E?e.jsx(px,{status:T.status,on_create:a.on_new_task}):null,!$&&(Ze.length||Xe)?e.jsxs("div",{className:"board_facets",children:[e.jsx("span",{className:"mono muted board_facets_caption",children:"labels:"}),Ze.map(([se,xe])=>e.jsxs("button",{className:`chip mono board_facet ${ke===se?"active":"info"}`,onClick:()=>le(ze=>ze===se?"":se),title:`${xe} scanned card(s) carry ${se} — click to filter (sprints are labels: sprint-N)`,children:[se," ",e.jsx("span",{className:"muted",children:xe})]},se)),ke?e.jsx("button",{className:"chip mono warn board_facet",onClick:()=>le(""),children:"clear ✕"}):null,dt<Xe?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 ",dt,"/",Xe]}):null]}):null,e.jsx("div",{className:"board_columns",style:$?{display:"none"}:void 0,children:rh.map(se=>{const xe=X.get(se.id)||[],ze=je[se.id],Ne=p(se.id);return e.jsxs("div",{className:`board_column board_column_${se.id} ${Ae===se.id?"drag_over":""}${Ne?"":" list_collapsed"}`,onDragOver:Le=>{!ze||!Me.current||(Le.preventDefault(),De(se.id))},onDragLeave:()=>De(Le=>Le===se.id?null:Le),onDrop:Le=>{Le.preventDefault(),De(null);const re=Me.current;Me.current=null,re&&ze&&ge(re,ze)},children:[e.jsx("div",{className:"board_column_header",title:se.hint,children:e.jsx(tl,{open:Ne,on_toggle:()=>b(se.id),controls:`board_column_body_${se.id}`,title:se.label,count:xe.length,title_class:"board_column_title",count_class:"board_column_count mono"})}),e.jsxs("div",{className:"board_column_body",id:`board_column_body_${se.id}`,hidden:!Ne,children:[xe.map(Le=>{const re=vp(Le,Le.filename?y.metadata[Le.filename]:void 0);return e.jsx(Fx,{card:Le,metadata:Le.filename?y.metadata[Le.filename]:void 0,draggable:!re&&!!(Le.kind&&Le.filename&&(Le.column==="triage"||Le.column==="ready")),on_drag_start:()=>{Me.current=Le},on_drag_end:()=>{Me.current=null,De(null)},on_open:()=>oe(Le),on_promote:!re&&se.id==="triage"?()=>void ge(Le,"planned"):void 0,on_demote:!re&&se.id==="ready"?()=>void ge(Le,"proposed"):void 0,on_execute:!re&&se.id==="ready"?()=>void Y(Le):void 0,on_follow:Le.exec_status==="running"||Le.exec_status==="queued"?()=>u(Le.request_id):void 0},Le.key)}),xe.length?null:e.jsx("div",{className:"board_column_empty mono muted",children:"—"})]})]},se.id)})}),e.jsx(Sp,{open:!!M,target:M?{kind:"planned",filename:M.filename,title:M.title}:null,execute_mode:ne,set_execute_mode:k,action_loading:w,action_error:ve,exec_cfg:O.exec_cfg,exec_cfg_loading:O.exec_cfg_loading,exec_cfg_error:O.exec_cfg_error,executors:v,readiness:(M==null?void 0:M.readiness)??null,server_refused:(M==null?void 0:M.server_refused)===!0,show_readiness:!0,on_open_spec:M?()=>{const se=M;Z(null),ae({filename:se.filename,kind:"planned",title:se.title,initial_tab:"spec"})}:void 0,on_confirm:se=>void B(se),on_close:()=>Z(null)}),e.jsx(bp,{gateway:n,can_use_gateway:r,target:te,on_close:()=>ae(null),on_mutated:async()=>{te!=null&&te.filename&&(te.kind==="proposed"||te.kind==="planned")&&await y.refresh_item_metadata(te.kind,te.filename),await y.refresh(),l()},on_open_executions:u}),U?e.jsx(Dx,{card:U,on_close:()=>Q(null),on_open_team:a.on_open_team}):null]})}function Fx(a){const{card:n,metadata:r,draggable:i,on_drag_start:l,on_drag_end:u,on_open:m,on_promote:d,on_demote:p,on_execute:b,on_follow:v}=a,y=Nd(n,r),C=vp(n,r),L=!C&&r?qd({task_type:n.task_type},r):null,T=Xo(n.task_type),$=n.exec_status==="running"&&n.started_at?Math.max(0,Date.now()-Date.parse(n.started_at)):null;return e.jsxs("div",{className:`board_card ${i?"draggable":""} ${C?"gate":""}`,onClick:m,role:"button",tabIndex:0,onKeyDown:E=>{(E.key==="Enter"||E.key===" ")&&(E.preventDefault(),m())},draggable:i,onDragStart:i?l:void 0,onDragEnd:i?u:void 0,children:[e.jsxs("div",{className:"board_card_title",children:[L?e.jsx("span",{className:`board_ready_dot ${L.ok?"ok":"warn"}`,title:L.ok?"Definition of Ready: satisfied":`Not ready: ${L.checks.filter(E=>!E.ok).map(E=>E.label).join("; ")}`}):null,e.jsx("span",{className:"board_card_title_text",children:n.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,n.item_id?e.jsxs("span",{className:"chip mono muted",children:["#",n.item_id]}):null,T&&!C?e.jsx("span",{className:`chip mono ${mp(T)}`,title:fp(T),children:T}):null,y?e.jsx("span",{className:`chip mono board_prio_${y.toLowerCase()}`,children:y}):null,n.package?e.jsx("span",{className:"chip mono muted",children:n.package}):null,n.batch_size?e.jsxs("span",{className:"chip mono info",children:[n.batch_size," items"]}):null,Cd(n,r).filter(E=>!C||E.toLowerCase()!=="decision-gate").slice(0,3).map(E=>e.jsx("span",{className:"chip mono info",children:E},E)),n.exec_status?e.jsx("span",{className:`chip mono ${n.exec_status==="failed"?"danger":n.exec_status==="awaiting_qa"?"warn":"info"}`,children:n.exec_status}):null,$!==null?e.jsx("span",{className:"chip mono info",children:Hs($)}):null,n.recent_failures?e.jsxs("span",{className:"chip mono danger",title:`${n.recent_failures} recent failed attempt(s) — see the Failed lane`,children:["⚠ ",n.recent_failures]}):null,n.target_agent?e.jsx("span",{className:"chip mono muted",children:n.target_agent}):null,n.claim_owner?(()=>{const E=pp({owner:n.claim_owner,started_at:n.claim_started_at},Date.now());return e.jsxs("span",{className:`chip mono ${E!=null&&E.stale?"warn":"info"}`,title:`Live hub claim${n.work_id?` (claim:${n.work_id})`:""}${E!=null&&E.stale?" — stale: claimed long ago with no receipt yet; open to re-claim on the record per the ruled process":""}`,children:["⛏ ",n.claim_owner,E?` · ${E.label.replace("claimed ","")}`:""]})})():null]}),d||p||b||v?e.jsxs("div",{className:"board_card_actions",onClick:E=>E.stopPropagation(),children:[d?e.jsx("button",{className:"btn",onClick:d,title:"Move to Ready (planned)",children:"→ Ready"}):null,b?e.jsx("button",{className:"btn primary",onClick:b,children:"Execute"}):null,p?e.jsx("button",{className:"btn",onClick:p,title:"Move back to Triage (proposed)",children:"→ Triage"}):null,v?e.jsx("button",{className:"btn",onClick:v,children:"Follow live"}):null]}):null]})}function ad(a,n){const r=String(a||"").replace(/\r/g,"").trim();if(!r)return"";const l=(r.split(`
91
+ `,1)[0]||"").trim();return l.length<=n?l:`${l.slice(0,Math.max(0,n-1))}…`}function qx(a){const n=String(a||"").trim();if(n.length<2)return n;const r=n[0],i=n[n.length-1];return r==="'"&&i==="'"||r==='"'&&i==='"'?n.slice(1,-1):n}function Ap(a){const n=String(a||"").trim();if(!n)return"";const r=n.match(/^(?:\/bin\/)?(?:zsh|bash)\s+-lc\s+([\s\S]+)$/);return r?qx(String(r[1]||"").trim()):n}function Ux(a,n){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 i=n&&typeof n=="object"?n:null,l=i&&typeof i.item=="object"?i.item:null;if(l&&String(l.type||"").trim()==="command_execution"){const u=String(l.status||"").trim().toLowerCase();if(u==="failed")return"error";const m=l.exit_code,d=typeof m=="number"?m:Number.isFinite(Number(m))?Number(m):null;if(d!=null)return d===0?"ok":"error";if(u==="completed")return"ok"}return"info"}function Bx(a,n){var b;const r=n&&typeof n=="object"?n:{},i=r.item&&typeof r.item=="object"?r.item:null,l=i?String(i.type||"").trim():"",u=i?String(i.text||"").trim():"",m=i?String(i.command||"").trim():"",d=i&&Array.isArray(i.items)?i.items:[],p=String((r==null?void 0:r.message)||((b=r==null?void 0:r.error)==null?void 0:b.message)||"").trim();if(l==="command_execution"&&m)return Ap(m)||m;if(l==="todo_list"&&d.length>0){const v=d.length,y=d.filter(I=>(I&&I.completed)===!0).length,C=d.find(I=>(I&&I.completed)!==!0),L=String((C==null?void 0:C.text)||"").trim(),T=v>1?` (+${v-1})`:"",$=v>0?` (${y}/${v})`:"",E=L?`todo: ${L}${T}`:`todo list (${v})`;return ad(`${E}${$}`,96)}return u?ad(u,96)||u:p?ad(p,96)||p:l||String(a||"").trim()||"event"}function mh(a){const n=new Date(a),r=i=>String(i).padStart(2,"0");return`${r(n.getHours())}:${r(n.getMinutes())}`}function Wx(a){var i,l,u;const n=a&&typeof a=="object"?a:{},r=[n.at,n.created_at,n.timestamp,n.time,n.ts,n.datetime,(i=n.item)==null?void 0:i.at,(l=n.item)==null?void 0:l.created_at,(u=n.item)==null?void 0:u.timestamp];for(const m of r)if(m!=null){if(typeof m=="number"&&Number.isFinite(m)){const d=m>1e11?m:m*1e3;return mh(d)}if(typeof m=="string"){const d=m.trim();if(!d)continue;const p=Date.parse(d.replace(/(\.\d{3})\d+/,"$1"));if(Number.isFinite(p))return mh(p)}}return null}function Hx(a){var E;const{exec_selected:n,exec_detail:r,is_compact_layout:i,exec_log_name:l,set_exec_log_name:u,exec_log_text:m,exec_log_loading:d,exec_log_error:p,exec_log_truncated:b,exec_log_auto:v,set_exec_log_auto:y,exec_log_scroll_el_ref:C,exec_log_follow_ref:L,parsed_exec_events:T,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:l,onChange:I=>u(I.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(Ai,{variant:"sm",label:"Auto-refresh",action:"exec-log-auto",hint:"Follow the log as it grows.",checked:v,unavailableReason:n!=null&&n.request_id?null:"Pick an execution first.",reasonVisible:!1,onChange:I=>y(()=>I)}),e.jsxs("button",{className:`btn btn_icon ${d?"is_loading":""}`,onClick:()=>$(),disabled:d||!(n!=null&&n.request_id),"aria-label":"Refresh logs",title:"Refresh logs",children:[e.jsx(He,{name:"refresh",size:16}),i?null:d?"Loading…":"Refresh"]})]})]}),p?e.jsx("div",{className:"detail_warn",children:p}):null,!p&&b?e.jsx("div",{className:"detail_hint",children:"#TRUNCATION: log tail truncated"}):null,l==="events"&&T?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"exec_log_scroll",ref:C,onScroll:I=>{L.current=th(I.currentTarget,12)},children:T.events.length===0?e.jsx("div",{className:"empty_note",children:"No events yet."}):T.events.map(I=>{var Z;const D=I.payload,O=D&&typeof D.item=="object"?D.item:null,q=O?String(O.type||"").trim():"",A=O?String(O.id||"").trim():"",H=D?String(D.thread_id||"").trim():"",fe=Ux(I.type,D),ie=fe==="error"?"danger":fe==="ok"?"ok":"info",Se=Wx(D),ke=Bx(I.type,D),le=String((D==null?void 0:D.message)||((Z=D==null?void 0:D.error)==null?void 0:Z.message)||"").trim(),pe=O?String(O.text||"").trim():"",G=O?String(O.command||"").trim():"",te=O?String(O.status||"").trim():"",ae=O&&O.exit_code!=null?String(O.exit_code):"",U=O?String(O.aggregated_output||"").trim():"",Q=O&&Array.isArray(O.items)?O.items:[],M=G?Ap(G)||G:"";return e.jsxs("details",{className:`exec_event ${fe}`,children:[e.jsxs("summary",{className:"exec_event_summary",children:[Se?e.jsx("span",{className:"exec_event_when mono muted",children:Se}):null,Se?e.jsx("span",{className:"exec_event_sep mono muted",children:"|"}):null,e.jsx("span",{className:"exec_event_main mono",title:ke,children:ke}),e.jsx("span",{className:`chip mono ${ie}`,children:q||I.type}),ae?e.jsxs("span",{className:"mono muted exec_event_right",children:["exit=",ae]}):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:I.type}),A?e.jsx("span",{className:"mono muted",style:{fontSize:"var(--font-size-xs)"},children:A}):null,H?e.jsxs("span",{className:"mono muted",style:{fontSize:"var(--font-size-xs)"},children:["thread ",_a(H,18)]}):null]}),le?e.jsx("pre",{className:"mono",style:{whiteSpace:"pre-wrap",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:le}):null,Q&&Q.length>0?e.jsx("div",{className:"mono",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:Q.map((ne,k)=>e.jsxs("div",{children:[(ne&&ne.completed)===!0?"✓":"○"," ",String((ne==null?void 0:ne.text)||"").trim()]},`${I.idx}-todo-${k}`))}):null,G?e.jsxs("div",{style:{marginTop:"8px"},children:[e.jsxs("div",{className:"mono muted",style:{fontSize:"var(--font-size-xs)"},children:["command_execution ",te?`(${te})`:""," ",ae?`exit=${ae}`:""]}),e.jsx("pre",{className:"mono",style:{whiteSpace:"pre-wrap",fontSize:"var(--font-size-sm)",marginTop:"6px"},children:M})]}):null,U?e.jsxs("details",{style:{marginTop:"8px"},children:[e.jsxs("summary",{className:"mono muted",style:{fontSize:"var(--font-size-sm)",cursor:"pointer"},children:["output (",U.length.toLocaleString()," chars)"]}),e.jsx("pre",{className:"mono",style:{whiteSpace:"pre-wrap",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:U})]}):null,pe?e.jsx("div",{style:{marginTop:"8px"},children:e.jsx(os,{className:"md_doc",text:pe})}):null]})]},`${I.idx}-${A}-${I.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",T.bad?` (${T.bad} unparsable line(s))`:""]}),e.jsx("pre",{className:"mono exec_raw_log",children:T.raw||""})]})]}):e.jsx("div",{className:"exec_log_scroll",ref:C,onScroll:I=>{L.current=th(I.currentTarget,12)},children:e.jsx("pre",{className:"mono",style:{whiteSpace:"pre-wrap",fontSize:"var(--font-size-sm)"},children:(()=>{var D;if(String(m||"").trim())return m;if(l==="last_message"){const O=String(((D=r==null?void 0:r.result)==null?void 0:D.last_message)||n.last_message||"").trim();if(O)return O;const q=String(n.status||"").trim().toLowerCase();return q==="queued"||q==="running"?"(last message is written when the run finishes — use events for live output)":"(no last message yet)"}return l==="stderr"?"(no stderr yet)":"(no logs yet)"})()})}),(E=r==null?void 0:r.result)!=null&&E.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 Vx(a){const{pipeline:n,is_compact_layout:r,on_back_to_list:i,on_send_feedback:l,on_promote:u,on_deploy_uat:m}=a,d=n.exec_selected;if(!d)return e.jsx("div",{className:"empty_note",children:"Select an exec request."});const{exec_detail:p,exec_detail_loading:b,exec_detail_error:v,exec_qa_feedback:y,set_exec_qa_feedback:C,exec_qa_loading:L,exec_qa_error:T,event_stats:$,time_stats:E,exec_log_name:I}=n;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:d.backlog_filename||d.backlog_relpath||d.request_id}),(()=>{const D=String(d.status||"").trim().toLowerCase();return e.jsx("span",{className:`chip mono ${Qo(D)}`,children:D||"unknown"})})(),e.jsx("span",{className:"chip mono muted",children:_a(d.request_id,16)})]}),e.jsxs("div",{className:"inbox_detail_actions",children:[r?e.jsx("button",{className:"btn",onClick:i,disabled:b,children:"Back"}):null,e.jsxs("button",{className:"btn btn_icon",onClick:()=>ln(d.request_id),disabled:b,"aria-label":"Copy request id",title:"Copy request id",children:[e.jsx(He,{name:"copy",size:16}),r?null:"Copy request id"]}),d.backlog_relpath?e.jsxs("button",{className:"btn btn_icon",onClick:()=>ln(d.backlog_relpath||""),disabled:b,"aria-label":"Copy backlog path",title:"Copy backlog path",children:[e.jsx(He,{name:"copy",size:16}),r?null:"Copy backlog path"]}):null,(()=>{var q;const O=(Array.isArray((q=p==null?void 0:p.backlog_queue)==null?void 0:q.items)?p.backlog_queue.items:[]).map(A=>String((A==null?void 0:A.relpath)||"").trim()).filter(Boolean);return O.length?e.jsxs("button",{className:"btn btn_icon",onClick:()=>ln(O.join(`
92
+ `)),disabled:b,"aria-label":"Copy backlog paths",title:"Copy backlog paths",children:[e.jsx(He,{name:"copy",size:16}),r?null:"Copy backlog paths"]}):null})(),d.run_dir_relpath?e.jsxs("button",{className:"btn btn_icon",onClick:()=>ln(d.run_dir_relpath||""),disabled:b,"aria-label":"Copy run dir",title:"Copy run dir",children:[e.jsx(He,{name:"copy",size:16}),r?null:"Copy run dir"]}):null]})]}),e.jsxs("div",{className:"detail_hint",style:{marginTop:0},children:[d.created_at?`created ${new Date(d.created_at).toLocaleString()}`:"",d.started_at?` • started ${new Date(d.started_at).toLocaleString()}`:"",d.finished_at?` • finished ${new Date(d.finished_at).toLocaleString()}`:""]}),d.error?e.jsx("div",{className:"detail_warn",children:d.error}):null,v?e.jsx("div",{className:"detail_warn",children:v}):null,e.jsx("div",{style:{marginTop:"12px"},children:b?e.jsx("div",{className:"empty_note",children:"Loading…"}):e.jsxs(e.Fragment,{children:[e.jsx(Gx,{exec_selected:d,exec_detail:p,exec_qa_feedback:y,set_exec_qa_feedback:C,exec_qa_loading:L,exec_qa_error:T,on_send_feedback:l,on_promote:u,on_deploy_uat:m}),e.jsx(Kx,{exec_selected:d,exec_detail:p}),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:d.status||"unknown"})]}),d.executor_type?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"executor"}),e.jsx("span",{className:"fact_value",children:d.executor_type})]}):null,d.target_agent?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"target agent"}),e.jsx("span",{className:"fact_value",children:d.target_agent})]}):null,d.target_model?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"model"}),e.jsxs("span",{className:"fact_value",children:[d.target_model,d.target_reasoning_effort?` (reasoning ${d.target_reasoning_effort})`:""]})]}):null,d.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(d.exit_code)})]}):null,E.age_ms!=null?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"age"}),e.jsx("span",{className:"fact_value",children:Hs(E.age_ms)})]}):null,E.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:Hs(E.queue_delay_ms)})]}):null,E.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:Hs(E.run_ms)})]}):null,E.total_ms!=null&&E.is_done?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"total time"}),e.jsx("span",{className:"fact_value",children:Hs(E.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:I==="events"?"n/a":'select "events"'})})]}),d.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:d.run_dir_relpath})]}):null]}),e.jsx(Yx,{exec_detail:p}),e.jsx(Jx,{exec_detail:p,exec_qa_loading:L,status:String(d.status||"")}),e.jsx(Qx,{exec_detail:p}),e.jsx(Xx,{exec_selected:d,exec_detail:p}),e.jsx("div",{className:"section_divider"}),e.jsx(Hx,{exec_selected:d,exec_detail:p,is_compact_layout:r,exec_log_name:n.exec_log_name,set_exec_log_name:n.set_exec_log_name,exec_log_text:n.exec_log_text,exec_log_loading:n.exec_log_loading,exec_log_error:n.exec_log_error,exec_log_truncated:n.exec_log_truncated,exec_log_auto:n.exec_log_auto,set_exec_log_auto:D=>n.set_exec_log_auto(D),exec_log_scroll_el_ref:n.exec_log_scroll_el_ref,exec_log_follow_ref:n.exec_log_follow_ref,parsed_exec_events:n.parsed_exec_events,load_exec_log_tail:()=>void n.load_exec_log_tail()})]})})]})}function Gx(a){const{exec_selected:n,exec_detail:r,exec_qa_feedback:i,set_exec_qa_feedback:l,exec_qa_loading:u,exec_qa_error:m,on_send_feedback:d,on_promote:p,on_deploy_uat:b}=a;if(String(n.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(),L=String((r==null?void 0:r.candidate_patch_relpath)||"").trim(),T=String((r==null?void 0:r.candidate_manifest_relpath)||"").trim(),$=String((r==null?void 0:r.uat_current_relpath)||"").trim(),E=String((r==null?void 0:r.uat_lock_owner_request_id)||"").trim(),I=!!(r!=null&&r.uat_lock_acquired),D=!!(r!=null&&r.uat_pending),O=(r==null?void 0:r.uat_deploy)??null,q=String((r==null?void 0:r.uat_deploy_error)||"").trim(),A=r==null?void 0:r.attempt,H=(r==null?void 0:r.promotion_report)??null,fe=!!(H!=null&&H.blocked),ie=String((H==null?void 0:H.reason)||"").trim(),Se=Array.isArray(H==null?void 0:H.conflicts)?(H==null?void 0:H.conflicts).slice(0,8):[],ke=typeof(H==null?void 0:H.conflicts_total)=="number"?Number(H.conflicts_total):Se.length;let le="",pe="";const G=[];try{const te=O==null?void 0:O.processes;if(te&&typeof te=="object"&&!Array.isArray(te)){typeof te.status=="string"&&(le=String(te.status||"").trim()),typeof te.reason=="string"&&(pe=String(te.reason||"").trim());for(const[ae,U]of Object.entries(te)){if(!U||typeof U!="object"||Array.isArray(U))continue;const Q=U.probe;!Q||typeof Q!="object"||Q.ok===!1&&G.push(String(ae))}}}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 A=="number"?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"attempt"}),e.jsx("span",{className:"fact_value",children:A})]}):null,y==="uat"&&E?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"uat lock"}),e.jsxs("span",{className:"fact_value",children:[_a(E,18),I?" (owned)":D?" (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,T?e.jsxs("div",{className:"fact fact_wide",children:[e.jsx("span",{className:"fact_label",children:"manifest"}),e.jsx("span",{className:"fact_value mono",children:T})]}):null,L?e.jsxs("div",{className:"fact fact_wide",children:[e.jsx("span",{className:"fact_label",children:"patch"}),e.jsx("span",{className:"fact_value mono",children:L})]}):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"&&D&&E&&!I?e.jsxs("div",{className:"detail_warn",children:["UAT currently points to ",_a(E,16),". Click “Restart UAT” to switch the shared UAT stack to this request."]}):y==="uat"&&I?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."}),G.length?e.jsxs("div",{className:"detail_warn",children:["UAT may be unreachable: URL probe failed for ",G.slice(0,4).join(", "),G.length>4?"…":"",". Click “Restart UAT” and check process logs."]}):null]}):null,y==="uat"&&le==="skipped"&&pe==="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,q?e.jsxs("div",{className:"detail_warn",children:["UAT deploy failed: ",q]}):null,fe&&ie==="conflicts"?e.jsxs("div",{className:"detail_warn",children:["Promotion blocked: prod diverged from the candidate base (",ke," conflict",ke===1?"":"s","). Use “Iterate” to re-run the request on top of current prod, or resolve conflicts manually.",Se.length?e.jsx("ul",{style:{marginTop:"8px",paddingLeft:"18px"},children:Se.map((te,ae)=>e.jsxs("li",{children:[String((te==null?void 0:te.repo)||""),"/",String((te==null?void 0:te.path)||"")," (",String((te==null?void 0:te.reason)||"conflict"),")"]},`c:${ae}`))}):null]}):null,e.jsxs("div",{className:"row",style:{flexWrap:"wrap",gap:"6px",marginTop:"8px"},children:[L?e.jsxs("button",{className:"btn btn_icon",onClick:()=>ln(L),disabled:u,children:[e.jsx(He,{name:"copy",size:16}),"Copy patch path"]}):null,T?e.jsxs("button",{className:"btn btn_icon",onClick:()=>ln(T),disabled:u,children:[e.jsx(He,{name:"copy",size:16}),"Copy manifest path"]}):null,C?e.jsxs("button",{className:"btn btn_icon",onClick:()=>ln(C),disabled:u,children:[e.jsx(He,{name:"copy",size:16}),"Copy candidate path"]}):null]}),e.jsx("div",{style:{marginTop:"10px"},children:e.jsx("textarea",{value:i,onChange:te=>l(te.target.value),rows:3,placeholder:"QA feedback (what to change / fix)…",style:{width:"100%",resize:"vertical",minHeight:"72px"},disabled:u})}),m?e.jsx("div",{className:"detail_warn",children:m}):null,e.jsxs("div",{className:"row",style:{flexWrap:"wrap",gap:"8px",marginTop:"10px"},children:[y==="uat"?e.jsx("button",{className:"btn",onClick:b,disabled:u,children:"Restart UAT"}):null,e.jsx("button",{className:"btn primary",onClick:p,disabled:u,children:y==="inplace"?"Approve (finalize)":"Approve → promote to prod"}),e.jsx("button",{className:"btn",onClick:d,disabled:u,children:"Iterate (send feedback)"})]}),e.jsx("div",{className:"section_divider"})]})}function Kx(a){const{exec_selected:n,exec_detail:r}=a;if(String(n.status||"").trim().toLowerCase()!=="promoted")return null;const l=String((r==null?void 0:r.promoted_at)||"").trim(),u=(r==null?void 0:r.promotion)??null,m=(r==null?void 0:r.promotion_report)??null,d=typeof(u==null?void 0:u.copied)=="number"?Number(u==null?void 0:u.copied):null,p=typeof(u==null?void 0:u.deleted)=="number"?Number(u==null?void 0:u.deleted):null,b=String((u==null?void 0:u.manifest_sha256)||"").trim(),v=String((u==null?void 0:u.mode)||"").trim(),y=(m==null?void 0:m.redeploy)??null,C=String((y==null?void 0:y.status)||"").trim(),L=String((y==null?void 0:y.reason)||"").trim(),T=String((m==null?void 0:m.redeploy_error)||"").trim();return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"section_title",children:"Promotion"}),e.jsxs("div",{className:"fact_grid",children:[l?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"promoted at"}),e.jsx("span",{className:"fact_value",children:new Date(l).toLocaleString()})]}):null,v?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"mode"}),e.jsx("span",{className:"fact_value",children:v})]}):null,b?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"manifest sha256"}),e.jsxs("span",{className:"fact_value",children:[b.slice(0,16),"…"]})]}):null,d!=null?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"copied"}),e.jsxs("span",{className:"fact_value",children:[d," files"]})]}):null,p!=null?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"deleted"}),e.jsxs("span",{className:"fact_value",children:[p," 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,L?` (${L})`:""]})]}):null,T?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:T})]}):null]}),e.jsx("div",{className:"section_divider"})]})}function Jx(a){const{exec_detail:n,exec_qa_loading:r}=a;if(String(a.status||"").trim().toLowerCase()==="promoted")return null;const i=n&&typeof n.promotion=="object"?n.promotion:null;if(!i)return null;const l=n&&typeof n.promotion_report=="object"?n.promotion_report:null,u=String((i==null?void 0:i.mode)||"").trim(),m=(i==null?void 0:i.copied)!=null?String(i.copied):"",d=(i==null?void 0:i.deleted)!=null?String(i.deleted):"",p=String((i==null?void 0:i.manifest_sha256)||"").trim(),b=l&&typeof l.redeploy=="object"?l.redeploy:null,v=b?String(b.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:[u?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"mode"}),e.jsx("span",{className:"fact_value",children:u})]}):null,m?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"copied"}),e.jsxs("span",{className:"fact_value",children:[m," files"]})]}):null,d?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"deleted"}),e.jsxs("span",{className:"fact_value",children:[d," files"]})]}):null,p?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:()=>ln(p),disabled:r,title:"Copy the full sha","aria-label":"Copy manifest sha256",children:e.jsx(He,{name:"copy",size:12})})]}),e.jsxs("span",{className:"fact_value mono",children:[p.slice(0,16),"…"]})]}):null,v?e.jsxs("div",{className:"fact",children:[e.jsx("span",{className:"fact_label",children:"redeploy"}),e.jsx("span",{className:"fact_value",children:v})]}):null]})]})}function Qx(a){var i,l;const r=(Array.isArray((l=(i=a.exec_detail)==null?void 0:i.backlog_queue)==null?void 0:l.items)?a.exec_detail.backlog_queue.items:[]).map(u=>String((u==null?void 0:u.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(u=>e.jsx("div",{children:u},`bq:${u}`))})]}):null}function Yx(a){var p,b,v;const n=((p=a.exec_detail)==null?void 0:p.skills)||((v=(b=a.exec_detail)==null?void 0:b.payload)==null?void 0:v.skills);if(!n||typeof n!="object")return null;const r=Array.isArray(n.requested)?n.requested:[],i=Array.isArray(n.active)?n.active:[],l=n.resolved_tree_hashes&&typeof n.resolved_tree_hashes=="object"?n.resolved_tree_hashes:{},u=Array.isArray(n.verdicts)?n.verdicts:[];if(!r.length&&!i.length&&!u.length)return null;const m=new Set(i.map(y=>String(y))),d=u.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"}),n.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(n.source)})]})}):null,e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,marginTop:4},children:r.map(y=>{const C=m.has(String(y)),L=l[String(y)];return e.jsxs("span",{className:`chip mono ${C?"ok":"warn"}`,title:C?L?`active · ${String(L).slice(0,12)}`:"active":"requested but not active — see verdict below",children:[y,C?"":" (held)"]},`skill:${y}`)})}),d.map((y,C)=>{const L=String((y==null?void 0:y.name)||(y==null?void 0:y.skill)||"skill"),T=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:[L,": ",T]},`verdict:${C}:${L}`)})]})}function Xx(a){var r,i;const n=String(((i=(r=a.exec_detail)==null?void 0:r.result)==null?void 0:i.last_message)||a.exec_selected.last_message||"").trim();return n?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(os,{className:"md_doc",text:n})})]}):null}const Zx=10;function eb(a){const{gateway:n,gateway_connected:r}=a,i=Wd("(max-width: 767.98px)"),l=h.useRef(null),u=h.useRef(null),m=M=>{const Z=M==="detail"?u:l;requestAnimationFrame(()=>nl(Z.current))},[d,p]=Cc("exec_active"),[b,v]=Cc("exec_recent"),[y,C]=h.useState(null);async function L(){try{const M=await n.admin_executors(),Z=Array.isArray(M)?M:Array.isArray(M==null?void 0:M.executors)?M.executors:[];C(Z)}catch{C(null)}}h.useEffect(()=>{if(!r){C(null);return}L()},[n,r]);const T=Hd({gateway:n,can_use_gateway:r,kind:"processing",completed_view:"tasks",is_exec_view:!0,is_compact_layout:i,set_compact_pane:m,on_status_transfer:()=>{O()}}),[$,E]=h.useState([]),[I,D]=h.useState("");async function O(){if(r)try{const M=await n.backlog_exec_requests({status:"completed,promoted,failed",limit:50}),Z=Array.isArray(M==null?void 0:M.requests)?M.requests:[];Z.sort((ne,k)=>{const w=String(ne.finished_at||ne.started_at||ne.created_at||"");return String(k.finished_at||k.started_at||k.created_at||"").localeCompare(w)}),E(Z.slice(0,Zx)),D("")}catch(M){D(String((M==null?void 0:M.message)||M||"Failed to load recent executions"))}}h.useEffect(()=>{if(!r)return;(async()=>{var k;const Z=await T.refresh_exec_list("processing");await O();const ne=String(a.focus_request_id||"").trim();if(ne){const w=Z.find(K=>K.request_id===ne);if(w)await T.load_exec_request(w);else try{const K=await n.backlog_exec_request(ne);K!=null&&K.payload&&await T.load_exec_request({request_id:ne,status:String(K.payload.status||"unknown")})}catch{}(k=a.on_focus_consumed)==null||k.call(a)}})();const M=setInterval(()=>{n.is_backing_off()||O()},15e3);return()=>clearInterval(M)},[r,a.focus_request_id]);const q=T.exec_requests.some(M=>String(M.status||"").toLowerCase()==="running"),[,A]=h.useState(0);h.useEffect(()=>{if(!q)return;const M=setInterval(()=>A(Z=>(Z+1)%3600),1e3);return()=>clearInterval(M)},[q]);const H=T.exec_requests,fe=h.useMemo(()=>{let M=0,Z=0,ne=0;for(const k of H){const w=String(k.status||"").trim().toLowerCase();w==="queued"?M+=1:w==="running"?Z+=1:w==="awaiting_qa"&&(ne+=1)}return{queued:M,running:Z,awaiting:ne}},[H]),ie=T.exec_cfg,Se=!!(ie!=null&&ie.runner_alive),ke=String((ie==null?void 0:ie.executor)||"").trim(),le=!ke||ke==="none",pe=le?"execution agent":ke,G=!!(ie!=null&&ie.can_execute),te=Ti(T.exec_error)||Ti(I),[ae,U]=h.useState(0),Q=Ud(n,r&&te,ae);return e.jsxs("div",{className:"page page_pad exec_page",children:[e.jsxs("div",{className:"page_toolbar",children:[r&&ie?e.jsxs("span",{className:`chip mono ${G?"ok":"warn"}`,title:ie.codex_model?`${pe}: ${ie.codex_model}${ie.codex_reasoning_effort?` (reasoning ${ie.codex_reasoning_effort})`:""}`:void 0,children:[le?"no execution agent":`${pe} worker ${Se?"on":"off"}`,!i&&ie.codex_model?` · ${ie.codex_model}`:""]}):null,r?null:e.jsx("span",{className:"page_hint",children:"Not connected — use the connection control (top right)."}),!te&&T.exec_error?e.jsx("span",{className:"page_error mono",children:T.exec_error}):null,e.jsx("div",{className:"page_toolbar_spacer"}),e.jsx("button",{className:`btn btn_icon ${T.exec_loading?"is_loading":""}`,onClick:()=>{T.refresh_exec_list("processing"),O(),T.load_exec_config(),L()},disabled:!r||T.exec_loading,title:"Refresh runs, worker config, and the executor registry","aria-label":"Refresh",children:e.jsx(He,{name:"refresh",size:16})})]}),r&&ie&&!G&&!te?e.jsxs("div",{className:"callout callout_warn",children:[e.jsx("div",{className:"callout_icon","aria-hidden":"true",children:e.jsx(He,{name:"warning",size:18})}),e.jsxs("div",{className:"callout_main",children:[e.jsxs("div",{className:"callout_title",children:[le?y!=null&&y.length?"No default executor selected":"No execution agent on this gateway":Se?"The pipeline cannot execute":"The exec worker is not running",e.jsx("span",{className:"chip mono warn",children:le?"setup required":Se?"cannot execute":"queued until it returns"})]}),e.jsx("p",{className:"callout_text",children:(()=>{if(!le)return ie.runner_error?`The worker reports: ${ie.runner_error} — new executions queue until it comes back.`:Se?"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 M=y.map(k=>k.display||k.id),Z=M.slice(0,4).join(", ")+(M.length>4?` +${M.length-4} more`:"");return y.some(k=>k.available!==!1)?`The gateway's registry serves ${y.length} executor${y.length===1?"":"s"} (${Z}), 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"} (${Z}), 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(M=>M.available!==!1))&&(le||!Se)?e.jsx("pre",{className:"mono setup_callout_pre",children:`abstractgateway config set backlog_exec_runner on # enables the exec worker
93
+ abstractgateway config set executor codex # canonical ids: codex | claude | cursor-agent | abstractcode
94
+ # 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,te?e.jsx(Bd,{gateway:n,surface:"the execution pipeline",status:Q.status,legacy:Q.legacy,error:Ti(T.exec_error)?T.exec_error:I,on_changed:()=>{U(M=>M+1),T.refresh_exec_list("processing")}}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"stat_strip",children:[e.jsxs("div",{className:`stat_card ${fe.running?"tone_info":""}`,children:[e.jsx("span",{className:"stat_value",children:fe.running}),e.jsx("span",{className:"stat_label",children:"running"})]}),e.jsxs("div",{className:`stat_card ${fe.awaiting?"tone_warn":""}`,children:[e.jsx("span",{className:"stat_value",children:fe.awaiting}),e.jsx("span",{className:"stat_label",children:"awaiting QA"})]}),e.jsxs("div",{className:"stat_card",children:[e.jsx("span",{className:"stat_value",children:fe.queued}),e.jsx("span",{className:"stat_label",children:"queued"})]}),e.jsxs("div",{className:`stat_card ${G?"tone_ok":"tone_danger"}`,children:[e.jsx("span",{className:"stat_value",children:G?"on":le?"none":"off"}),e.jsxs("span",{className:"stat_label",children:[pe,le?"":" worker"]})]})]}),e.jsxs("div",{className:"inbox_layout exec_layout",children:[e.jsxs("div",{className:"exec_side",ref:l,children:[e.jsxs("div",{className:`pane exec_pane_active${d?"":" list_collapsed"}`,children:[e.jsx("div",{className:"pane_header",children:e.jsx(tl,{open:d,on_toggle:p,controls:"exec_active_list",title:"Active",count:H.length})}),e.jsx("div",{className:"pane_body pane_body_list",id:"exec_active_list",hidden:!d,children:H.length?H.map(M=>{var he;const Z=String(M.status||"").trim().toLowerCase(),ne=Zo(M),k=((he=T.exec_selected)==null?void 0:he.request_id)===M.request_id,w=Z==="running"&&M.started_at?Math.max(0,Date.now()-Date.parse(M.started_at)):null,K=String(M.backlog_filename||M.backlog_relpath||"").trim(),ve=M.target_agent||(M.target_model?`${String(M.executor_type||"agent").trim()||"agent"}:${M.target_model}`:"");return e.jsxs("button",{className:`run_card ${k?"selected":""} ${Z==="running"?"is_running":""}`,onClick:()=>void T.load_exec_request(M),children:[e.jsxs("div",{className:"run_card_head",children:[e.jsx("span",{className:"run_card_title",title:K,children:K||`request ${_a(M.request_id,12)}`}),e.jsx("span",{className:`chip mono ${Qo(Z)}`,children:Z||"unknown"})]}),e.jsxs("div",{className:"run_card_meta",children:[e.jsx("span",{className:"run_card_time",children:w!==null?`running ${Hs(w)}`:ne.queue_delay_ms!=null?`queued ${Hs(ne.queue_delay_ms)}`:" "}),ve?e.jsx("span",{className:"chip mono muted",children:ve}):null,e.jsx("span",{className:"run_card_id mono",children:_a(M.request_id,14)})]})]},M.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${b?"":" list_collapsed"}`,children:[e.jsx("div",{className:"pane_header",children:e.jsx(tl,{open:b,on_toggle:v,controls:"exec_recent_list",title:"Recently finished",count:$.length})}),e.jsxs("div",{className:"pane_body exec_recent_body",id:"exec_recent_list",hidden:!b,children:[I&&!te?e.jsx("div",{className:"page_error mono",style:{padding:"10px 12px"},children:I}):null,!I&&!$.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(M=>{var K;const Z=String(M.status||"").trim().toLowerCase(),ne=Zo(M),k=((K=T.exec_selected)==null?void 0:K.request_id)===M.request_id,w=_a(M.backlog_filename||M.backlog_relpath||"request",44);return e.jsxs("button",{className:`recent_row ${k?"selected":""}`,onClick:()=>void T.load_exec_request(M),title:String(M.backlog_filename||M.backlog_relpath||M.request_id),children:[e.jsx("span",{className:`chip mono ${Qo(Z)}`,children:Z||"?"}),e.jsx("span",{className:"recent_row_name",children:w}),e.jsx("span",{className:"recent_row_time mono",children:ne.run_ms!=null?Hs(ne.run_ms):""})]},`recent:${M.request_id}`)})}):null]})]})]}),e.jsxs("div",{className:"pane exec_detail_pane",ref:u,children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Run detail"}),T.exec_selected?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:`chip mono ${Qo(String(T.exec_selected.status||"").toLowerCase())}`,children:String(T.exec_selected.status||"?").toLowerCase()}),e.jsx("span",{className:"pane_count mono",children:_a(T.exec_selected.request_id,20)})]}):e.jsx("span",{className:"pane_count",children:"select a run"})]}),e.jsx("div",{className:"pane_body",children:e.jsx(Vx,{pipeline:T,is_compact_layout:i,on_back_to_list:()=>m("list"),on_send_feedback:()=>void T.exec_send_feedback(async()=>{await T.refresh_exec_list("processing")}),on_promote:()=>void T.exec_promote_to_prod(async()=>{await T.refresh_exec_list("processing"),await O()}),on_deploy_uat:()=>void T.exec_deploy_uat_now(async()=>{await T.refresh_exec_list("processing")})})})]})]})]})]})}function rd(a,n){const r=String(a||"");return r.length<=n?r:`${r.slice(0,Math.max(0,n-1))}…`}function tb(a){const n=String(a||"").trim().toLowerCase();return n==="running"?{cls:"ok",label:"running"}:n==="stopped"?{cls:"muted",label:"stopped"}:n.includes("restart")?{cls:"warn",label:n}:n.includes("error")||n.includes("failed")?{cls:"danger",label:n||"error"}:{cls:"warn",label:n||"unknown"}}function fh(a){const n=r=>{const i=String((r==null?void 0:r.id)||"").trim(),l=i.endsWith("_uat")?i.slice(0,-4):i;return l==="gateway"?0:l==="build"?1:l==="abstractobserver"?2:l==="abstractcode_web"?3:l==="abstractflow_backend"?4:l==="abstractflow_frontend"?5:10};return[...a||[]].sort((r,i)=>{const l=n(r),u=n(i);if(l!==u)return l-u;const m=String((r==null?void 0:r.label)||(r==null?void 0:r.id)||"").toLowerCase(),d=String((i==null?void 0:i.label)||(i==null?void 0:i.id)||"").toLowerCase();return m<d?-1:m>d?1:0})}function nb(a){const n=String(a||"").trim().toLowerCase();return n==="override"?{cls:"ok",label:"override"}:n.startsWith("inherited")?{cls:"info",label:n}:n==="unset"?{cls:"warn",label:"unset"}:!n||n==="missing"?{cls:"muted",label:"missing"}:{cls:"muted",label:n}}function sb({gateway:a,gateway_connected:n}){const[r,i]=h.useState("prod"),[l,u]=h.useState(null),[m,d]=h.useState([]),[p,b]=h.useState(!1),[v,y]=h.useState(""),[C,L]=h.useState(!1),[T,$]=h.useState(null),[E,I]=h.useState([]),[D,O]=h.useState(!1),[q,A]=h.useState(""),[H,fe]=h.useState({}),[ie,Se]=h.useState(!1),[ke,le]=h.useState(null),[pe,G]=h.useState(""),[te,ae]=h.useState(""),[U,Q]=h.useState(!1),[M,Z]=h.useState("idle"),ne=h.useRef(null),k=h.useMemo(()=>fh(m.filter(W=>!String((W==null?void 0:W.id)||"").trim().endsWith("_uat"))),[m]),w=h.useMemo(()=>fh(m.filter(W=>String((W==null?void 0:W.id)||"").trim().endsWith("_uat"))),[m]),K=r==="uat"?w:k,ve=h.useCallback(async()=>{if(n){b(!0),y("");try{const W=await a.list_processes();u(!!(W!=null&&W.enabled));const X=Array.isArray(W==null?void 0:W.processes)?W.processes:[];d(X)}catch(W){y(String((W==null?void 0:W.message)||W||"Failed to list processes"))}finally{b(!1)}}},[a,n]),he=h.useCallback(async()=>{if(n){O(!0),A("");try{const W=await a.list_process_env_vars();$(!!(W!=null&&W.enabled));const X=Array.isArray(W==null?void 0:W.vars)?W.vars:[];I(X);const ge=String((W==null?void 0:W.error)||"").trim();ge&&A(ge)}catch(W){A(String((W==null?void 0:W.message)||W||"Failed to list env vars"))}finally{O(!1)}}},[a,n]),z=h.useCallback(async()=>{if(!n)return;const W=ke;if(W){Q(!0);try{const X=await a.process_log_tail(String(W.id||""),{max_bytes:16e4}),ge=String((X==null?void 0:X.content)||""),Y=typeof(X==null?void 0:X.bytes)=="number"?Number(X.bytes):0,B=!!(X!=null&&X.truncated),oe=String((X==null?void 0:X.log_relpath)||"");G(ge),ae(`${Y.toLocaleString()} bytes${B?" (tail)":""}${oe?` • ${oe}`:""}`)}catch(X){G(""),ae(String((X==null?void 0:X.message)||X||"Failed to read logs"))}finally{Q(!1)}}},[a,n,ke]),be=h.useCallback(async W=>{le(W),Se(!0)},[]),Ae=h.useCallback(()=>{Se(!1),le(null),G(""),ae("")},[]);h.useEffect(()=>{n&&ve()},[n,ve]),h.useEffect(()=>{if(!n||r==="env"||!C)return;const W=window.setInterval(()=>{a.is_backing_off()||ve()},2e3);return()=>window.clearInterval(W)},[n,r,C,ve,a]),h.useEffect(()=>{n&&r==="env"&&he()},[n,r,he]),h.useEffect(()=>{if(n&&ie)return z(),ne.current&&window.clearInterval(ne.current),ne.current=window.setInterval(()=>{a.is_backing_off()||z()},1500),()=>{ne.current&&window.clearInterval(ne.current),ne.current=null}},[n,ie,z]);const De=h.useRef(!1),[Me,lt]=h.useState(!1);async function Ue(W,X){if(!De.current){De.current=!0,lt(!0),y("");try{X==="start"?await a.start_process(W.id):X==="stop"?await a.stop_process(W.id):X==="restart"?await a.restart_process(W.id):X==="redeploy"&&await a.redeploy_process(W.id),await ve()}catch(ge){y(String((ge==null?void 0:ge.message)||ge||`Failed to ${X}`))}finally{De.current=!1,lt(!1)}}}async function ct(W){const X=String(W||"").trim();if(X){A("");try{const ge=String((H==null?void 0:H[X])??""),Y=await a.update_process_env_vars({set:{[X]:ge}});$(!!(Y!=null&&Y.enabled)),I(Array.isArray(Y==null?void 0:Y.vars)?Y.vars:[]),fe(oe=>({...oe||{},[X]:""}));const B=String((Y==null?void 0:Y.error)||"").trim();B&&A(B)}catch(ge){A(String((ge==null?void 0:ge.message)||ge||"Failed to set env var"))}}}async function Xe(W){const X=String(W||"").trim();if(X){A("");try{const ge=await a.update_process_env_vars({unset:[X]});$(!!(ge!=null&&ge.enabled)),I(Array.isArray(ge==null?void 0:ge.vars)?ge.vars:[]),fe(B=>({...B||{},[X]:""}));const Y=String((ge==null?void 0:ge.error)||"").trim();Y&&A(Y)}catch(ge){A(String((ge==null?void 0:ge.message)||ge||"Failed to unset env var"))}}}const dt=l===null?"…":l?"enabled":"disabled",Ze=T===null?"…":T?"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:()=>i("prod"),children:"Production"}),e.jsx("button",{"aria-pressed":r==="uat",className:`seg_btn ${r==="uat"?"active":""}`,onClick:()=>i("uat"),children:"UAT"}),e.jsx("button",{"aria-pressed":r==="env",className:`seg_btn ${r==="env"?"active":""}`,onClick:()=>i("env"),children:"ENV"})]}),n?null:e.jsx("span",{className:"page_hint mono",children:"Not connected — use the connection badge in the sidebar."}),n&&r!=="env"?e.jsxs("span",{className:`chip mono ${l===!1?"warn":"muted"}`,children:["manager ",dt]}):null,n&&r==="env"?e.jsxs("span",{className:`chip mono ${T===!1?"warn":"muted"}`,children:["env ",Ze]}):null,e.jsx("div",{className:"page_toolbar_spacer"}),r!=="env"?e.jsxs(e.Fragment,{children:[e.jsx(Ai,{variant:"sm",label:"Auto-refresh",action:"auto-refresh",hint:"Refresh this list every few seconds.",checked:C,onChange:W=>L(W)}),e.jsxs("button",{className:`btn btn_icon ${p?"is_loading":""}`,onClick:()=>void ve(),disabled:!n||p,children:[e.jsx(He,{name:"refresh",size:16}),p?"Refreshing…":"Refresh"]})]}):e.jsxs("button",{className:`btn btn_icon ${D?"is_loading":""}`,onClick:()=>void he(),disabled:!n||D,children:[e.jsx(He,{name:"refresh",size:16}),D?"Refreshing…":"Refresh"]})]}),n&&r!=="env"&&l===!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,n&&r==="env"&&T===!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"&&v?e.jsx("div",{className:"page_error mono",children:v}):null,r==="env"&&q?e.jsx("div",{className:"page_error mono",children:q}):null,n&&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:K.length})]}),e.jsxs("div",{className:"pane_body pane_body_list",children:[K.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."]}),K.map(W=>{const X=String(W.id||"").trim(),ge=String(W.label||X).trim()||X,Y=tb(String(W.status||"")),oe=String(W.status||"").trim().toLowerCase()==="running",je=Array.isArray(W==null?void 0:W.actions)?W.actions.map(mt=>String(mt||"").trim()):[],Oe=je.includes("start"),se=je.includes("stop"),xe=je.includes("restart"),ze=je.includes("redeploy"),Ne=je.includes("logs"),Le=typeof(W==null?void 0:W.pid)=="number"?Number(W.pid):null,re=String((W==null?void 0:W.url)||"").trim(),P=String((W==null?void 0:W.description)||"").trim(),de=String((W==null?void 0:W.last_error)||"").trim(),Ve=typeof(W==null?void 0:W.exit_code)=="number"?Number(W.exit_code):null,et=[];Le&&et.push(`pid ${Le}`),Ve!==null&&et.push(`exit ${Ve}`);const at=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:ge}),e.jsx("span",{className:`chip mono ${Y.cls}`,children:Y.label}),e.jsx("span",{className:"chip mono muted",children:X}),at?e.jsx("span",{className:"entity_card_sub mono",children:at}):null]}),P?e.jsx("div",{className:"entity_card_sub mono",children:rd(P,220)}):null,re?e.jsx("div",{className:"entity_card_sub mono",children:oe?e.jsx("a",{href:re,target:"_blank",rel:"noreferrer",className:"mono",style:{opacity:.95},children:re}):e.jsx("span",{className:"mono",children:re})}):null,de?e.jsx("div",{className:"page_error mono",children:rd(de,360)}):null,e.jsxs("div",{className:"entity_card_actions",children:[Oe?e.jsx("button",{className:"btn primary",onClick:()=>void Ue(W,"start"),disabled:p||Me,children:"Start"}):null,se?e.jsx("button",{className:"btn danger",onClick:()=>void Ue(W,"stop"),disabled:p||Me,children:"Stop"}):null,xe?e.jsx("button",{className:"btn",onClick:()=>void Ue(W,"restart"),disabled:p||Me,children:"Restart"}):null,ze?e.jsx("button",{className:"btn",onClick:()=>void Ue(W,"redeploy"),disabled:p||Me,children:"Redeploy"}):null,Ne?e.jsx("button",{className:"btn",onClick:()=>void be(W),disabled:p,children:"Logs"}):null]})]},X)})]})]}):null,n&&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:E.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:[E.map(W=>{const X=String((W==null?void 0:W.key)||"").trim();if(!X)return null;const ge=String((W==null?void 0:W.label)||X).trim()||X,Y=String((W==null?void 0:W.description)||"").trim(),B=String((W==null?void 0:W.source)||"").trim(),oe=!!(W!=null&&W.secret),je=String((W==null?void 0:W.updated_at)||"").trim(),Oe=nb(B),se=String((H==null?void 0:H[X])??"");return e.jsxs("div",{className:"entity_card",children:[e.jsxs("div",{className:"entity_card_head",children:[e.jsx("span",{className:"entity_card_title",children:ge}),e.jsx("span",{className:`chip mono ${Oe.cls}`,children:Oe.label}),e.jsx("span",{className:"chip mono muted",children:X})]}),Y?e.jsx("div",{className:"entity_card_sub mono",children:rd(Y,280)}):null,je?e.jsxs("div",{className:"entity_card_sub mono",children:["updated ",je]}):null,e.jsxs("div",{className:"entity_card_actions",children:[e.jsx("input",{className:"input",value:se,onChange:xe=>fe(ze=>({...ze||{},[X]:String(xe.target.value||"")})),placeholder:oe?"••••••••":"value",type:oe?"password":"text",style:{flex:"1 1 320px",minWidth:"220px"},autoComplete:"off",spellCheck:!1}),e.jsx("button",{className:"btn primary",onClick:()=>void ct(X),disabled:D,children:"Set"}),e.jsx("button",{className:"btn",onClick:()=>void Xe(X),disabled:D,children:"Unset"})]})]},`env:${X}`)}),E.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,ie&&ke?e.jsxs(er,{open:ie,title:`${String(ke.label||ke.id||"logs").trim()||"Logs"}`,onClose:Ae,children:[e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:te}),e.jsxs("div",{className:"actions",style:{marginTop:"10px"},children:[e.jsxs("button",{className:`btn btn_icon ${U?"is_loading":""}`,onClick:()=>void z(),disabled:U,children:[e.jsx(He,{name:"refresh",size:16}),U?"Refreshing…":"Refresh"]}),e.jsxs("button",{className:"btn btn_icon",onClick:()=>{Iv(pe||"").then(W=>{Z(W?"copied":"failed"),window.setTimeout(()=>Z("idle"),2e3)})},disabled:!pe,children:[e.jsx(He,{name:"copy",size:16}),M==="copied"?"Copied":M==="failed"?Pv:"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:pe||"(no logs yet)"})]}):null]})})}function hh(a){const n=String(a||"").trim();if(!n)return"";const r=Date.parse(n);return Number.isFinite(r)?new Date(r).toLocaleString():n}function Do(a,n){const r=String(a||"");return r.length<=n?r:`${r.slice(0,Math.max(0,n-1))}…`}function id(a){const n=String(a||"").split(/[,\n]/g).map(r=>r.trim()).filter(Boolean);return n.length<=1?n[0]||"":n}function ab(a){const n=a.gateway,[r,i]=Cc("inbox_email"),l=h.useRef(null),u=h.useRef(null),[m,d]=h.useState([]),[p,b]=h.useState(""),[v,y]=h.useState(""),[C,L]=h.useState(""),[T,$]=h.useState("7d"),[E,I]=h.useState("unread"),[D,O]=h.useState(25),[q,A]=h.useState(!1),[H,fe]=h.useState(!1),[ie,Se]=h.useState(!1),[ke,le]=h.useState(!1),[pe,G]=h.useState(""),[te,ae]=h.useState(""),[U,Q]=h.useState(""),[M,Z]=h.useState([]),[ne,k]=h.useState(""),[w,K]=h.useState(null),[ve,he]=h.useState(!1),[z,be]=h.useState(""),[Ae,De]=h.useState(""),[Me,lt]=h.useState(""),[Ue,ct]=h.useState(""),[Xe,dt]=h.useState(""),Ze=a.enabled,W=h.useMemo(()=>(Array.isArray(m)?m:[]).map(de=>({account:String((de==null?void 0:de.account)||"").trim(),can_read:(de==null?void 0:de.can_read)!==!1,can_send:(de==null?void 0:de.can_send)!==!1,label:""})).filter(de=>!!de.account),[m]),X=h.useMemo(()=>{const P=String(v||"").trim();return P&&W.find(de=>de.account===P)||null},[W,v]),ge=!!(X!=null&&X.can_read),Y=!!(X!=null&&X.can_send),B=h.useMemo(()=>W.map(P=>{const de=P.can_read?P.can_send?"":" (read-only)":" (send-only)";return{...P,label:`${P.account}${de}`}}),[W]);async function oe(){if(Ze){G(""),A(!0);try{const P=await n.email_list_accounts();d(Array.isArray(P==null?void 0:P.accounts)?P.accounts:[]),b(String((P==null?void 0:P.default_account)||"").trim())}catch(P){G(String((P==null?void 0:P.message)||P||"Failed to list email accounts")),d([]),b("")}finally{A(!1)}}}h.useEffect(()=>{oe()},[Ze]),h.useEffect(()=>{if(!Ze)return;const P=String(v||"").trim();if(P&&W.some(Ve=>Ve.account===P))return;const de=String(localStorage.getItem("abstractcontinuum_email_account")||"").trim();if(de&&W.some(Ve=>Ve.account===de)){y(de);return}if(p&&W.some(Ve=>Ve.account===p)){y(p);return}W.length&&y(W[0].account)},[Ze,v,p,W]),h.useEffect(()=>{const P=String(v||"").trim();P&&localStorage.setItem("abstractcontinuum_email_account",P)},[v]);async function je(){if(!Ze)return;const P=String(v||"").trim();if(P){if(!ge){G("Selected account is not allowed to read email."),Z([]),k(""),K(null);return}G(""),fe(!0);try{const de=await n.email_list_messages({account:P,mailbox:String(C||"").trim()||void 0,since:String(T||"").trim()||void 0,status:E,limit:D}),Ve=Array.isArray(de==null?void 0:de.messages)?de.messages:[];Z(Ve);const et=String(ne||"").trim();et&&!Ve.some(at=>String((at==null?void 0:at.uid)||"").trim()===et)&&(k(""),K(null))}catch(de){G(String((de==null?void 0:de.message)||de||"Failed to list emails")),Z([]),k(""),K(null)}finally{fe(!1)}}}h.useEffect(()=>{Ze&&String(v||"").trim()&&je()},[Ze,v]);async function Oe(P){if(!Ze)return;const de=String(v||"").trim(),Ve=String(P||"").trim();if(!(!de||!Ve)&&ge){k(Ve),K(null),ae(""),Se(!0);try{const et=await n.email_read_message(Ve,{account:de,mailbox:String(C||"").trim()||void 0,max_body_chars:2e4});K(et)}catch(et){ae(String((et==null?void 0:et.message)||et||"Failed to read email"))}finally{Se(!1)}}}function se(P){Q(""),be(String((P==null?void 0:P.to)||"").trim()),De(""),lt(""),ct(String((P==null?void 0:P.subject)||"").trim()),dt(String((P==null?void 0:P.body)||"")),he(!0)}function xe(){if(!w)return;const P=String((w==null?void 0:w.from)||"").trim(),de=String((w==null?void 0:w.subject)||"").trim(),Ve=de.toLowerCase().startsWith("re:")?de:`Re: ${de||"(no subject)"}`,et=String((w==null?void 0:w.body_text)||"").trim(),at=`
95
+
96
+ ---
97
+ On ${hh((w==null?void 0:w.date)||"")}, ${P} wrote:
98
+
99
+ ${et}`;se({to:P,subject:Ve,body:at})}async function ze(){if(!Ze||ke)return;const P=String(v||"").trim();if(P){if(!Y){Q("Selected account is not allowed to send email.");return}Q(""),le(!0);try{const de=id(z);if(!de)throw new Error("to is required");const Ve=String(Ue||"").trim();if(!Ve)throw new Error("subject is required");const et=String(Xe||"").trim();if(!et)throw new Error("body is required");await n.email_send({account:P,to:de,subject:Ve,body_text:et,cc:id(Ae),bcc:id(Me)}),he(!1),be(""),De(""),lt(""),ct(""),dt(""),await je()}catch(de){Q(String((de==null?void 0:de.message)||de||"Failed to send email"))}finally{le(!1)}}}const Ne=h.useMemo(()=>{const P=String(ne||"").trim();return P&&M.find(de=>String((de==null?void 0:de.uid)||"").trim()===P)||null},[M,ne]),Le=String((w==null?void 0:w.body_text)||"").trim()||String((w==null?void 0:w.body_html)||"").trim(),re=String((w==null?void 0:w.body_text)||"").trim()?"Body (text)":String((w==null?void 0:w.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:l,onClickCapture:P=>{var de,Ve;(Ve=(de=P.target)==null?void 0:de.closest)!=null&&Ve.call(de,".inbox_item")&&requestAnimationFrame(()=>nl(u.current))},children:[e.jsx("div",{className:"pane_header",children:e.jsx(tl,{open:r,on_toggle:i,controls:"inbox_email_list",title:"Email",count:M.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:v,onChange:P=>y(String(P.target.value||"")),disabled:!Ze||q,children:B.length?B.map(P=>e.jsx("option",{value:P.account,children:P.label},P.account)):e.jsx("option",{value:"",children:"(no accounts)"})}),e.jsx("button",{className:"btn",onClick:()=>void oe(),disabled:!Ze||q,children:q?"Loading…":"Accounts"})]}),e.jsxs("div",{className:"row",style:{gap:"8px",justifyContent:"flex-end"},children:[e.jsx("button",{className:"btn",onClick:()=>void je(),disabled:!Ze||H||!String(v||"").trim()||!ge,children:H?"Refreshing…":"Refresh"}),e.jsx("button",{className:"btn primary",onClick:()=>se(),disabled:!Ze||!String(v||"").trim()||!Y,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:T,onChange:P=>$(String(P.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:E,onChange:P=>I(String(P.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(D),onChange:P=>O(Number(P.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:P=>L(String(P.target.value||"")),placeholder:"INBOX"})]}),e.jsx("div",{className:"row",style:{gap:"8px",alignItems:"center",marginTop:"18px"},children:e.jsx("button",{className:"btn",onClick:()=>void je(),disabled:!Ze||H||!String(v||"").trim()||!ge,children:"Apply"})})]}),pe?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)"},children:pe}):null,e.jsx("div",{className:"inbox_list",children:M.length?M.map((P,de)=>{const Ve=String((P==null?void 0:P.uid)||"").trim(),et=!!Ve&&Ve===String(ne||"").trim(),at=String((P==null?void 0:P.subject)||"").trim()||"(no subject)",mt=String((P==null?void 0:P.from)||"").trim(),ft=String((P==null?void 0:P.date)||"").trim(),Ee=!!(P!=null&&P.seen);return e.jsxs("button",{className:`inbox_item ${et?"active":""}`,onClick:()=>void Oe(Ve),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:Do(at,52)})]}),e.jsx("div",{className:"inbox_item_meta mono muted",children:Do(mt,60)||"(from?)"}),e.jsxs("div",{className:"inbox_item_meta mono muted",children:[Do(ft,36)||"(date?)"," • uid ",Do(Ve,10)]})]},Ve||`idx:${de}`)}):e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"No messages."})})]})]}),e.jsx("div",{className:"pane inbox_detail_pane",ref:u,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:()=>nl(l.current),children:"← Back to the list"})}),ne?ie?e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Loading email…"}):te?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)"},children:te}):w?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((w==null?void 0:w.subject)||"").trim()||"(no subject)"}),e.jsx("span",{className:"pill muted",children:String((w==null?void 0:w.account)||"").trim()||v}),e.jsx("span",{className:"pill muted",children:String((w==null?void 0:w.mailbox)||"").trim()||"(mailbox?)"}),e.jsxs("span",{className:"pill muted",children:["uid ",Do(String((w==null?void 0:w.uid)||ne),12)]})]}),e.jsxs("div",{className:"row",style:{gap:"8px",justifyContent:"flex-end"},children:[e.jsx("button",{className:"btn",onClick:()=>ln(String((w==null?void 0:w.message_id)||"")),disabled:!String((w==null?void 0:w.message_id)||"").trim(),title:"Copy Message-ID",children:"Copy msg-id"}),e.jsx("button",{className:"btn",onClick:()=>ln(String(ne||"")),disabled:!String(ne||"").trim(),title:"Copy UID",children:"Copy uid"}),e.jsx("button",{className:"btn primary",onClick:()=>xe(),disabled:!Y||!String((w==null?void 0:w.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((w==null?void 0:w.from)||"").trim()||"(from?)"})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"To"}),e.jsx("div",{className:"mono",children:String((w==null?void 0:w.to)||"").trim()||"(to?)"})]}),String((w==null?void 0:w.cc)||"").trim()?e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Cc"}),e.jsx("div",{className:"mono",children:String((w==null?void 0:w.cc)||"").trim()})]}):null,e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Date"}),e.jsx("div",{className:"mono",children:hh(String((w==null?void 0:w.date)||(Ne==null?void 0:Ne.date)||"").trim())||String((w==null?void 0:w.date)||(Ne==null?void 0:Ne.date)||"").trim()||"(date?)"})]}),Array.isArray(w==null?void 0:w.attachments)&&w.attachments.length?e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Attachments"}),e.jsx("div",{className:"mono",children:w.attachments.map((P,de)=>e.jsxs("div",{children:[String((P==null?void 0:P.filename)||"").trim()||"(file?)"," ",e.jsx("span",{className:"muted",children:String((P==null?void 0:P.content_type)||"").trim()?`(${String((P==null?void 0:P.content_type)||"").trim()})`:""})]},`${(P==null?void 0:P.filename)||""}:${de}`))})]}):null,e.jsx("div",{className:"section_divider"}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:re}),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:Le||"(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(er,{open:ve,title:`Compose (${String(v||"").trim()||"account"})`,onClose:()=>{ke||he(!1)},actions:e.jsxs("div",{className:"row",style:{gap:"8px",justifyContent:"flex-end"},children:[U?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginRight:"auto"},children:U}):null,e.jsx("button",{className:"btn",onClick:()=>he(!1),disabled:ke,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:()=>void ze(),disabled:ke,children:ke?"Sending…":"Send"})]}),children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"To"}),e.jsx("input",{value:z,onChange:P=>be(String(P.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:Ae,onChange:P=>De(String(P.target.value||"")),placeholder:"(optional)"})]}),e.jsxs("div",{className:"field",style:{flex:"1 1 220px"},children:[e.jsx("label",{children:"Bcc"}),e.jsx("input",{value:Me,onChange:P=>lt(String(P.target.value||"")),placeholder:"(optional)"})]})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Subject"}),e.jsx("input",{value:Ue,onChange:P=>ct(String(P.target.value||"")),placeholder:"Subject"})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Body (text)"}),e.jsx("textarea",{value:Xe,onChange:P=>dt(String(P.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 ph(a){const n=String(a||"").trim();if(!n)return"";const r=n.split("/").filter(Boolean);return r.length?r[r.length-1]:""}function _c(a){const n=String(a||"").trim();if(!n)return"";const r=Date.parse(n);return Number.isFinite(r)?new Date(r).toLocaleString():n}function Si(a,n){const r=String(a||"");return r.length<=n?r:`${r.slice(0,Math.max(0,n-1))}…`}function rb(a){const n=a.gateway,r=!!a.enable_triage,[i,l]=Cc("inbox_reports"),u=h.useRef(null),m=h.useRef(null),[d,p]=h.useState(r?"messages":"email"),[b,v]=h.useState([]),[y,C]=h.useState([]),[L,T]=h.useState([]),[$,E]=h.useState(!1),[I,D]=h.useState(""),[O,q]=h.useState(null),[A,H]=h.useState(""),[fe,ie]=h.useState(!1),[Se,ke]=h.useState(""),[le,pe]=h.useState("pending"),[G,te]=h.useState(null),[ae,U]=h.useState(""),[Q,M]=h.useState(null),[Z,ne]=h.useState(""),[k,w]=h.useState(!1),[K,ve]=h.useState(!1),[he,z]=h.useState(""),[be,Ae]=h.useState(""),De=!!be,[Me,lt]=h.useState(""),[Ue,ct]=h.useState(""),[Xe,dt]=h.useState(""),[Ze,W]=h.useState(!1),X=a.gateway_connected;h.useEffect(()=>{!r&&d!=="email"&&p("email")},[r,d]);const ge=h.useMemo(()=>d==="bugs"?b:d==="features"?y:[],[d,b,y]);h.useEffect(()=>{d==="email"&&(D(""),E(!1))},[d]);async function Y(){const re=await n.list_bug_reports();v(Array.isArray(re==null?void 0:re.items)?re.items:[])}async function B(){const re=await n.list_feature_requests();C(Array.isArray(re==null?void 0:re.items)?re.items:[])}async function oe(){const re=await n.list_triage_decisions({status:le||void 0,limit:500}),P=Array.isArray(re==null?void 0:re.decisions)?re.decisions:[];T(P),G&&!P.some(de=>de.decision_id===G.decision_id)&&(te(null),U(""),M(null),ne(""))}async function je(){if(X&&r&&d!=="email"){D(""),E(!0);try{d==="bugs"?await Y():d==="features"?await B():await oe()}catch(re){D(String((re==null?void 0:re.message)||re||"Refresh failed"))}finally{E(!1)}}}h.useEffect(()=>{je()},[d,X,le,r]);async function Oe(re){q(re),H(""),ke(""),ie(!0);try{if(re.report_type==="bug"){const P=await n.get_bug_report_content(re.filename);H(String((P==null?void 0:P.content)||""))}else{const P=await n.get_feature_request_content(re.filename);H(String((P==null?void 0:P.content)||""))}}catch(P){ke(String((P==null?void 0:P.message)||P||"Failed to load report"))}finally{ie(!1)}}async function se(re){te(re),U(""),M(null),ne("");const P=ph(re.report_relpath);if(P)try{if(re.report_type==="bug"){const de=await n.get_bug_report_content(P);U(String((de==null?void 0:de.content)||""))}else if(re.report_type==="feature"){const de=await n.get_feature_request_content(P);U(String((de==null?void 0:de.content)||""))}}catch(de){ne(String((de==null?void 0:de.message)||de||"Failed to load report"))}}async function xe(re){ne(""),M(null);const P=String(re.draft_relpath||"").trim();if(!P)return;const de=ph(P);if(de)try{const Ve=await n.backlog_content("proposed",de);M(Ve)}catch(Ve){ne(String((Ve==null?void 0:Ve.message)||Ve||"Failed to load draft (is repo root configured on gateway?)"))}}async function ze(re,P){if(G&&!k){ne(""),w(!0);try{const de=await n.apply_triage_decision(G.decision_id,{action:re,defer_days:P??null});await oe();const Ve=String(le||"").trim().toLowerCase(),et=String((de==null?void 0:de.status)||"").trim().toLowerCase();if(!(!Ve||Ve===et))te(null),U(""),M(null);else if(te(de),String(de.draft_relpath||"").trim())try{await xe(de)}catch{}}catch(de){ne(String((de==null?void 0:de.message)||de||"Decision action failed"))}finally{w(!1)}}}async function Ne(){if(!K){D(""),ve(!0);try{const re=await n.triage_run({write_drafts:!1,enable_llm:!1});z(`Scanned ${(re==null?void 0:re.reports)??0} report(s); updated ${(re==null?void 0:re.updated_decisions)??0} decision(s).`),await oe()}catch(re){D(String((re==null?void 0:re.message)||re||"Triage failed"))}finally{ve(!1)}}}h.useEffect(()=>{De&&(dt(""),ct(""),W(!1),lt(String(a.default_session_id||"").trim()))},[De,a.default_session_id]);async function Le(){var re,P;if(be&&!Ze){dt(""),W(!0);try{const de=String(Me||"").trim();if(!de)throw new Error("session_id is required");const Ve=String(Ue||"").trim();if(!Ve)throw new Error("description is required");const et={session_id:de,description:Ve,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(((re=globalThis==null?void 0:globalThis.navigator)==null?void 0:re.userAgent)||""),url:String(((P=globalThis==null?void 0:globalThis.location)==null?void 0:P.href)||"")};if(be==="bug"){const at=await n.bug_report_create(et),mt=String((at==null?void 0:at.filename)||"").trim();Ae(""),p("bugs");const ft=await n.list_bug_reports(),Ee=Array.isArray(ft==null?void 0:ft.items)?ft.items:[];v(Ee);const tt=Ee.find(ht=>ht.filename===mt)||null;tt&&await Oe(tt)}else{const at=await n.feature_report_create(et),mt=String((at==null?void 0:at.filename)||"").trim();Ae(""),p("features");const ft=await n.list_feature_requests(),Ee=Array.isArray(ft==null?void 0:ft.items)?ft.items:[];C(Ee);const tt=Ee.find(ht=>ht.filename===mt)||null;tt&&await Oe(tt)}}catch(de){dt(String((de==null?void 0:de.message)||de||"Failed to create report"))}finally{W(!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":d==="messages",className:`seg_btn ${d==="messages"?"active":""}`,onClick:()=>p("messages"),children:"Messages"}),e.jsx("button",{"aria-pressed":d==="email",className:`seg_btn ${d==="email"?"active":""}`,onClick:()=>p("email"),children:"Email"}),e.jsx("button",{"aria-pressed":d==="bugs",className:`seg_btn ${d==="bugs"?"active":""}`,onClick:()=>p("bugs"),children:"Bugs"}),e.jsx("button",{"aria-pressed":d==="features",className:`seg_btn ${d==="features"?"active":""}`,onClick:()=>p("features"),children:"Features"})]}):e.jsx("button",{"aria-pressed":d==="email",className:`seg_btn ${d==="email"?"active":""}`,onClick:()=>p("email"),children:"Email"})}),r&&d!=="email"&&he?e.jsx("span",{className:"page_hint mono",children:he}):null,r&&d!=="email"&&I?e.jsx("span",{className:"page_error mono",children:I}):null,e.jsx("div",{className:"page_toolbar_spacer"}),r?e.jsxs(e.Fragment,{children:[d==="messages"?e.jsxs(e.Fragment,{children:[e.jsxs("select",{value:le,onChange:re=>pe(String(re.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 je(),disabled:!X||$,children:$?"Refreshing…":"Refresh"}),e.jsx("button",{className:"btn primary",onClick:()=>void Ne(),disabled:!X||K,children:K?"Running…":"Run triage"})]}):d==="email"?null:e.jsx("button",{className:"btn",onClick:()=>void je(),disabled:!X||$,children:$?"Refreshing…":"Refresh"}),e.jsx("button",{className:"btn",onClick:()=>Ae("bug"),disabled:!X,children:"File bug"}),e.jsx("button",{className:"btn",onClick:()=>Ae("feature"),disabled:!X,children:"File feature"})]}):null]}),d==="email"?e.jsx(ab,{gateway:n,enabled:X}):e.jsxs("div",{className:`inbox_layout exec_layout${i?"":" list_collapsed"}`,children:[e.jsxs("div",{className:`pane inbox_list_pane${i?"":" list_collapsed"}`,ref:u,onClickCapture:re=>{var P,de;(de=(P=re.target)==null?void 0:P.closest)!=null&&de.call(P,".inbox_item")&&requestAnimationFrame(()=>nl(m.current))},children:[e.jsx("div",{className:"pane_header",children:e.jsx(tl,{open:i,on_toggle:l,controls:"inbox_report_list",title:d==="messages"?"Triage decisions":d==="bugs"?"Bug reports":"Feature requests",count:d==="messages"?L.length:ge.length})}),e.jsx("div",{className:"pane_body pane_body_list",id:"inbox_report_list",hidden:!i,children:d==="messages"?e.jsx(e.Fragment,{children:L.length?L.map(re=>{const P=(G==null?void 0:G.decision_id)===re.decision_id,de=Array.isArray(re.missing_fields)?re.missing_fields.length:0;return e.jsxs("button",{className:`inbox_item ${P?"active":""}`,onClick:()=>void se(re),children:[e.jsxs("div",{className:"inbox_item_title",children:[e.jsx("span",{className:`pill ${String(re.status||"").toLowerCase()}`,children:String(re.status||"pending")}),e.jsx("span",{className:"mono",children:re.report_type}),e.jsx("span",{className:"mono muted",children:Si(re.decision_id,10)})]}),e.jsxs("div",{className:"inbox_item_meta mono muted",children:[de?`${de} missing`:"complete"," • ",_c(re.updated_at||re.created_at)||"(time?)"]}),e.jsx("div",{className:"inbox_item_meta mono",children:Si(re.report_relpath||"",46)})]},re.decision_id)}):e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"No decisions."})}):e.jsx(e.Fragment,{children:ge.length?ge.map(re=>{const P=(O==null?void 0:O.filename)===re.filename&&(O==null?void 0:O.report_type)===re.report_type,de=String(re.triage_status||"").trim().toLowerCase();return e.jsxs("button",{className:`inbox_item ${P?"active":""}`,onClick:()=>void Oe(re),children:[e.jsxs("div",{className:"inbox_item_title",children:[de?e.jsx("span",{className:`pill ${de}`,children:de}):null,e.jsx("span",{className:"mono",children:Si(re.title||re.filename,46)})]}),e.jsxs("div",{className:"inbox_item_meta mono muted",children:[_c(re.created_at)||"(time?)"," • ",re.session_id?Si(re.session_id,12):"session?"]}),e.jsx("div",{className:"inbox_item_meta mono",children:re.filename})]},re.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:m,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:()=>nl(u.current),children:"← Back to the list"})}),d==="messages"?G?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:G.report_type}),e.jsx("span",{className:"chip mono muted",children:G.status}),e.jsx("span",{className:"chip mono muted",children:Si(G.decision_id,16)})]}),e.jsxs("div",{className:"inbox_detail_actions",children:[e.jsx("button",{className:"btn",onClick:()=>{ln(G.report_relpath||"")},children:"Copy report path"}),G.draft_relpath?e.jsx("button",{className:"btn",onClick:()=>void xe(G),children:"Load draft"}):null,e.jsx("button",{className:"btn primary",onClick:()=>void ze("approve"),disabled:k,children:"Approve"}),e.jsx("button",{className:"btn",onClick:()=>void ze("defer",1),disabled:k,children:"Defer 1d"}),e.jsx("button",{className:"btn",onClick:()=>void ze("defer",7),disabled:k,children:"Defer 7d"}),e.jsx("button",{className:"btn",onClick:()=>void ze("reject"),disabled:k,children:"Reject"})]})]}),e.jsxs("div",{className:"inbox_detail_meta mono muted",style:{fontSize:"var(--font-size-sm)"},children:[G.updated_at?`updated ${_c(G.updated_at)}`:null,G.created_at?`${G.updated_at?" • ":""}created ${_c(G.created_at)}`:null,G.defer_until?` • defer until ${G.defer_until}`:null]}),Z?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:Z}):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"}),G.missing_fields&&G.missing_fields.length?e.jsx("ul",{className:"inbox_list_ul mono",children:G.missing_fields.map(re=>e.jsx("li",{children:re},re))}):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"}),G.duplicates&&G.duplicates.length?e.jsx("ul",{className:"inbox_list_ul mono",children:G.duplicates.slice(0,20).map((re,P)=>{const de=String((re==null?void 0:re.title)||(re==null?void 0:re.ref)||(re==null?void 0:re.kind)||"duplicate").trim(),Ve=typeof(re==null?void 0:re.score)=="number"&&Number.isFinite(re.score)?` (score ${re.score.toFixed(2)})`:"";return e.jsxs("li",{children:[de,Ve]},`${de}_${P}`)})}):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"}),G.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:G.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)."})]})]}),Q?e.jsxs("div",{className:"inbox_markdown",children:[e.jsx("div",{className:"section_title",children:"Draft content"}),e.jsx(os,{className:"md_doc",text:String(Q.content||"")})]}):null,e.jsxs("div",{className:"inbox_markdown",children:[e.jsx("div",{className:"section_title",children:"Source report"}),ae?e.jsx(os,{className:"md_doc",text:ae}):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."}):O?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:O.report_type==="bug"?"Bug report":"Feature request"}),O.triage_status?e.jsx("span",{className:`pill ${O.triage_status}`,children:O.triage_status}):null,e.jsx("span",{className:"chip mono muted",children:O.filename}),O.session_id?e.jsx("span",{className:"chip mono muted",children:Si(O.session_id,16)}):null]}),e.jsx("div",{className:"inbox_detail_actions",children:e.jsx("button",{className:"btn",onClick:()=>{ln(O.relpath||"")},children:"Copy path"})})]}),Se?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)",marginTop:"8px"},children:Se}):null,fe?e.jsx("div",{className:"mono muted",style:{fontSize:"var(--font-size-sm)"},children:"Loading…"}):A?e.jsx(os,{className:"md_doc",text:A}):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(er,{open:De,title:be==="bug"?"File bug report":"File feature request",onClose:()=>Ae(""),actions:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn",onClick:()=>Ae(""),disabled:Ze,children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:()=>void Le(),disabled:Ze,children:Ze?"Submitting…":"Submit"})]}),children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Session ID"}),e.jsx("input",{value:Me,onChange:re=>lt(re.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:Ue,onChange:re=>ct(re.target.value),placeholder:be==="bug"?"What is broken? What did you expect?":"What do you want to be able to do?",rows:6})]}),Xe?e.jsx("div",{className:"mono",style:{color:"rgba(239, 68, 68, 0.9)",fontSize:"var(--font-size-sm)"},children:Xe}):null]})]})}const ib="api/continuum/settings";async function Lp(a){const n=await fetch(ib,{...a,signal:AbortSignal.timeout(1e4),headers:a!=null&&a.body?{"Content-Type":"application/json"}:void 0}),r=await n.text();let i=null;try{i=JSON.parse(r)}catch{}if(!n.ok||!i||typeof i!="object"||!i.settings){const l=i&&typeof i=="object"?i.detail||i.error:"",u=new Error(l||`settings unavailable (HTTP ${n.status})`);throw u.status=n.status,u}return i}function ob(){return Lp()}function lb(a,n){return Lp({method:"PUT",body:JSON.stringify({[a]:n})})}const Rp="abstractcontinuum_voice_override_v1",od={enabled:!1};function Ed(){try{const a=localStorage.getItem(Rp);if(!a)return{...od};const n=JSON.parse(a);return!n||typeof n!="object"?{...od}:{enabled:!!n.enabled,provider:Bs(n.provider),model:Bs(n.model),profile:Bs(n.profile),voice:Bs(n.voice),quality_preset:Bs(n.quality_preset)}}catch{return{...od}}}const Td="abstractcontinuum:voice_override_changed";function cb(a){try{localStorage.setItem(Rp,JSON.stringify(a))}catch{}try{window.dispatchEvent(new CustomEvent(Td))}catch{}}function Mp(a){if(!a)return{};const n={},r=Bs(a.quality_preset);if(r&&(n.quality_preset=r),!a.enabled)return n;for(const i of["provider","model","profile","voice"]){const l=Bs(a[i]);l&&(n[i]=l)}return n}function Bs(a){return String(a??"").trim()||void 0}function Pp(a){const n=a&&typeof a=="object"?a.routes:null;if(!Array.isArray(n))return{};const r=b=>n.find(v=>v&&typeof v=="object"&&String(v.key||"").trim()===b&&!!v.configured),i=r("output.voice.tts")||r("output.voice");if(!i)return{};const l={},u=Bs(i.provider),m=Bs(i.model),d=i.options,p=d&&typeof d=="object"?Bs(d.voice):void 0;return u&&(l.provider=u),m&&(l.model=m),p&&(l.voice=p),l}function ub(a){let n=String(a||"");return n=n.replace(/```[\s\S]*?```/g," "),n=n.replace(/!\[([^\]]*)\]\([^)]*\)/g,"$1"),n=n.replace(/\[([^\]]+)\]\([^)]*\)/g,"$1"),n=n.replace(/`([^`]+)`/g,"$1"),n=n.replace(/^[ \t]*#{1,6}[ \t]+/gm,""),n=n.replace(/^[ \t]*>[ \t]?/gm,""),n=n.replace(/^[ \t]*[-*+][ \t]+/gm,""),n=n.replace(/^[ \t]*\d+[.)][ \t]+/gm,""),n=n.replace(/^[ \t]*\|/gm,"").replace(/\|[ \t]*$/gm,"").replace(/\|/g,", "),n=n.replace(/(\*\*|__|~~)(.*?)\1/g,"$2"),n=n.replace(/\*([^*\n]+)\*/g,"$1"),n=n.replace(/(^|[^\w])_([^_\n]+)_(?=[^\w]|$)/g,"$1$2"),n=n.replace(/^[ \t]*([-*_])(?:[ \t]*\1){2,}[ \t]*$/gm," "),n=n.replace(/\s+/g," ").trim(),n}const Oo={loading:!1,error:"",providers:[],models_by_provider:{},profiles_by_provider:{},voices_by_provider:{},cloned_by_provider:{}};function db(a){const n={};if(!Array.isArray(a))return n;for(const r of a){if(!r||typeof r!="object")continue;const i=r.voice_kinds;if(!(Array.isArray(i)&&i.some(p=>String(p).toLowerCase().includes("clone"))))continue;const u=String(r.provider||"").trim(),m=String(r.id||r.voice||r.name||"").trim();if(!m)continue;const d=u||"*";(n[d]||(n[d]=[])).push(m)}for(const r of Object.keys(n))n[r]=[...new Set(n[r])];return n}function Ad(a){if(!Array.isArray(a))return[];const n=[];for(const r of a)if(typeof r=="string"){const i=r.trim();i&&n.push(i)}else if(r&&typeof r=="object"){const i=String(r.id||r.name||r.voice||r.value||"").trim();i&&n.push(i)}return[...new Set(n)]}function ld(a){const n={};if(a&&typeof a=="object"&&!Array.isArray(a))for(const[r,i]of Object.entries(a)){const l=Ad(i);l.length&&(n[String(r)]=l)}return n}function mb(a){const{gateway:n,gateway_connected:r}=a,[i,l]=h.useState(()=>Ed()),[u,m]=h.useState(Oo),[d,p]=h.useState(!1),[b,v]=h.useState(""),y=h.useRef(null),C=h.useCallback(O=>{l(q=>{const A={...q,...O};return cb(A),A})},[]);h.useEffect(()=>{if(!r){m(Oo);return}if(typeof(n==null?void 0:n.voice_voices)!="function"){m(Oo);return}let O=!0;m(A=>({...A,loading:!0,error:""}));let q;try{q=n.voice_voices()}catch(A){m({...Oo,error:String((A==null?void 0:A.message)||A||"voice catalog unavailable")});return}return q.then(A=>{if(!O)return;const H=[...new Set([...Ad(A==null?void 0:A.providers),...Ad(A==null?void 0:A.tts_providers)])];m({loading:!1,error:"",providers:H,models_by_provider:ld(A==null?void 0:A.tts_models_by_provider),profiles_by_provider:ld(A==null?void 0:A.tts_profiles_by_provider),voices_by_provider:ld(A==null?void 0:A.tts_voices_by_provider),cloned_by_provider:db(A==null?void 0:A.items)})}).catch(A=>{O&&m({...Oo,error:String((A==null?void 0:A.message)||A||"voice catalog unavailable")})}),()=>{O=!1}},[n,r]);const L=i.provider||"",T=L&&u.models_by_provider[L]?u.models_by_provider[L]:[],$=L&&u.voices_by_provider[L]?u.voices_by_provider[L]:[],E=L&&u.profiles_by_provider[L]?u.profiles_by_provider[L]:[],I=[...L&&u.cloned_by_provider[L]?u.cloned_by_provider[L]:[],...u.cloned_by_provider["*"]||[]];async function D(){if(!(d||!r)){p(!0),v("");try{const O=await Od("abstractcontinuum_team_voice");let q={};if(typeof n.capability_defaults=="function")try{q=Pp(await n.capability_defaults())}catch{q={}}const A=await n.voice_tts(O,{text:"This is the voice AbstractContinuum will use to read your messages.",...q,...Mp(i),timeout_s:30}),H=A==null?void 0:A.audio_artifact,fe=H&&typeof H=="object"?String(H.$artifact||"").trim():"";if(!fe)throw new Error("no audio returned");const ie=await n.download_run_artifact_content(O,fe),Se=URL.createObjectURL(ie);if(y.current)try{y.current.pause()}catch{}const ke=y.current;if(ke){try{ke.pause()}catch{}const pe=ke.src;pe.startsWith("blob:")&&URL.revokeObjectURL(pe)}const le=new Audio(Se);y.current=le,le.onended=()=>{URL.revokeObjectURL(Se),v("")};try{await le.play(),v("Playing…")}catch(pe){v(String((pe==null?void 0:pe.name)||"").includes("NotAllowed")?"Synthesized OK — click Test again to play.":`Playback failed: ${String((pe==null?void 0:pe.message)||pe).slice(0,80)}`),URL.revokeObjectURL(Se)}}catch(O){v(`Test failed: ${String((O==null?void 0:O.message)||O||"synthesis error").slice(0,120)}`)}finally{p(!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(Ai,{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:i.enabled,onChange:O=>C({enabled:O})}),u.error?e.jsxs("div",{className:"muted team_note",children:["Voice catalog unavailable (",u.error.slice(0,100),") — you can still type provider/model/voice values below; the gateway validates on Test."]}):null,u.loading?e.jsx("div",{className:"muted team_note",children:"Loading voices…"}):null,i.enabled&&!L&&(i.voice||i.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,i.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(gc,{value:L,options:u.providers,placeholder:"gateway default",onChange:O=>C({provider:O,model:"",voice:"",profile:""})})]}),e.jsxs("label",{className:"settings_field",children:[e.jsx("span",{className:"muted",children:"Model"}),e.jsx(gc,{value:i.model||"",options:T,placeholder:"default",onChange:O=>C({model:O})})]}),e.jsxs("label",{className:"settings_field",children:[e.jsx("span",{className:"muted",children:"Base voice"}),e.jsx(gc,{value:i.profile||"",options:E,placeholder:"default",onChange:O=>C({profile:O})})]}),e.jsxs("label",{className:"settings_field",children:[e.jsx("span",{className:"muted",children:"Cloned voice"}),e.jsx(gc,{value:i.voice||"",options:[...I,...$],placeholder:"none",onChange:O=>C({voice:O})})]})]}):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:i.quality_preset||"",onChange:O=>C({quality_preset:O.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:d,onClick:()=>void D(),children:d?"Synthesizing…":"Test voice"}),b?e.jsx("span",{className:"muted team_note",children:b}):null]})]}):e.jsx("div",{className:"muted team_note",children:"Connect to the gateway to configure and test message voice."})})]})}function gc(a){const n=Wt.useId();return e.jsxs(e.Fragment,{children:[e.jsx("input",{className:"team_compose_control mono",list:n,value:a.value,placeholder:a.placeholder||"",onChange:r=>a.onChange(r.target.value.trim())}),a.options.length?e.jsx("datalist",{id:n,children:a.options.map(r=>e.jsx("option",{value:r},r))}):null]})}const fb=["minimal","low","medium","high","xhigh"];function hb(a){const{gateway:n,connected:r,model:i,value:l,onChange:u}=a,[m,d]=h.useState({state:"unknown",levels:[]}),[p,b]=h.useState(!1);if(h.useEffect(()=>{b(!1);const C=String(i||"").trim();if(!C||!r){d({state:"unknown",levels:[]});return}let L=!1;return d({state:"loading",levels:[]}),n.discovery_model_capabilities(C).then(T=>{if(L)return;const $=T!=null&&T.capabilities&&typeof T.capabilities=="object"?T.capabilities:{},E=$.thinking_support,I=Array.isArray($.reasoning_levels)?$.reasoning_levels.map(D=>String(D)):[];d(E===!0?{state:"supported",levels:I}:E===!1?{state:"unsupported",levels:[]}:{state:"unknown",levels:[]})}).catch(()=>{L||d({state:"unknown",levels:[]})}),()=>{L=!0}},[i,r]),!String(i||"").trim())return null;const v=m.state==="unsupported"||m.state==="unknown"&&!p||m.state==="loading",y=m.state==="supported"&&m.levels.length?m.levels:m.state==="unknown"&&p?[...fb]:[];return e.jsxs("div",{className:"field","data-testid":"reasoning_select",children:[e.jsxs("label",{children:["Reasoning (effort for ",i,")"]}),e.jsxs("select",{value:v?"":l,onChange:C=>u(String(C.target.value||"")),disabled:v,title:m.state==="supported"?"Efforts this model declares (gateway-served). Sent on the `thinking` wire key; blank = gateway default.":m.state==="unsupported"?"This model declares no reasoning support — effort is locked to none (contract v1: non-reasoning models naturally get none).":m.state==="loading"?"Checking the model's served capabilities…":"The gateway serves no reasoning facts for this model (unknown ≠ unsupported). Locked fail-safe; tick “set anyway” if you know the model reasons.",children:[e.jsx("option",{value:"",children:m.state==="unsupported"?"none — this model doesn't reason":m.state==="loading"?"checking…":m.state==="unknown"&&!p?"unknown — no served facts":"gateway default"}),y.map(C=>e.jsx("option",{value:C,children:C},C))]}),m.state==="unknown"&&!v?e.jsx("div",{className:"muted",style:{fontSize:"var(--font-size-sm)"},children:"Override active: efforts unverified for this model — the provider may reject or ignore them."}):null,m.state==="unknown"?e.jsxs("label",{className:"muted",style:{fontSize:"var(--font-size-sm)",display:"inline-flex",gap:"6px",alignItems:"center"},children:[e.jsx("input",{type:"checkbox",checked:p,onChange:C=>{b(C.target.checked),C.target.checked||u("")}}),"set anyway (I know this model reasons)"]}):null]})}function pb(a){const[n,r]=h.useState(!1),[i,l]=h.useState("");return n?e.jsxs("span",{style:{display:"flex",gap:6,alignItems:"center"},children:[e.jsx("input",{className:"mono",style:{minWidth:260},value:i,onChange:u=>l(u.target.value),placeholder:"/path/to/a/folder/with/docs/backlog",disabled:a.busy}),e.jsx("button",{className:"btn primary",disabled:a.busy||!i.trim(),onClick:()=>{a.on_apply(i.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:()=>{l(a.current),r(!0)},children:a.current?"Change…":"Set…"})}function _b(a){const n=String(a||"").trim();if(!n)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."]},[i,l,u]=r[n]||[n,"muted",""];return e.jsx("span",{className:`chip mono ${l}`,title:u,"data-testid":"hub_seat_source",children:i})}function gb(){var T;const[a,n]=h.useState(null),[r,i]=h.useState(""),[l,u]=h.useState(""),[m,d]=h.useState(!1),[p,b]=h.useState("");h.useEffect(()=>{let $=!1;return ob().then(E=>{var I;$||(n(E),u(String(((I=E.settings.hub_seat)==null?void 0:I.value)??"")))}).catch(E=>{$||i(String((E==null?void 0:E.message)||E))}),()=>{$=!0}},[]);async function v($){var E;d(!0),b("");try{const I=await lb("hub_seat",$);n(I),u(String(((E=I.settings.hub_seat)==null?void 0:E.value)??""))}catch(I){b(String((I==null?void 0:I.message)||I||"Save refused"))}finally{d(!1)}}const y=a==null?void 0:a.settings.hub_seat,C=String((y==null?void 0:y.value)??""),L=!!((T=a==null?void 0:a.writable)!=null&&T.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}),_b(y==null?void 0:y.source),e.jsx("div",{className:"admin_row_action",children:L?e.jsxs("span",{style:{display:"flex",gap:6,alignItems:"center"},children:[e.jsx("input",{className:"mono","aria-label":"Hub seat",value:l,onChange:$=>u($.target.value),placeholder:"your seat",disabled:m}),e.jsx("button",{className:"btn primary",disabled:m||!l.trim()||l.trim()===C&&(y==null?void 0:y.source)==="setting",onClick:()=>void v(l.trim()),children:"Save"}),(y==null?void 0:y.source)==="setting"?e.jsx("button",{className:"btn",disabled:m,onClick:()=>void v(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]}),p?e.jsx("div",{className:"page_error mono",style:{marginTop:"6px"},children:p}):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 yb(a){var te,ae;const{gateway:n,gateway_connected:r,settings:i,set_settings:l}=a,u=(ae=(te=a.connection)==null?void 0:te.gateway)==null?void 0:ae.principal,[m,d]=h.useState({loaded:!1,process_manager:null,backlog_root:null,exec_pipeline:null,exec_detail:"",executor:""}),[p,b]=h.useState(null),[v,y]=h.useState(null),[C,L]=h.useState(!1),[T,$]=h.useState(null),[E,I]=h.useState([]),[D,O]=h.useState(""),[q,A]=h.useState(""),[H,fe]=h.useState(!1),[ie,Se]=h.useState(0);async function ke(U,Q=""){if(!H){fe(!0),O(""),A("");try{const M=await n.admin_runtime_config_update(U);b(M),A(Q),Se(Z=>Z+1)}catch(M){O(String((M==null?void 0:M.message)||M||"Config update refused"))}finally{fe(!1)}}}h.useEffect(()=>{if(!r)return;let U=!1;return(async()=>{var M;const Q={loaded:!0,process_manager:null,backlog_root:null,exec_pipeline:null,exec_detail:"",executor:""};try{const Z=await n.backlog_exec_config(),ne=!!(Z!=null&&Z.runner_enabled),k=!!(Z!=null&&Z.runner_alive),w=(Z==null?void 0:Z.can_execute)===!0;Q.exec_pipeline=w?"on":ne||k?"degraded":"off",Q.exec_detail=w?"":ne?k?"runner alive but cannot execute (executor missing?)":"runner enabled but not alive":"runner disabled",Q.executor=String((Z==null?void 0:Z.executor)||"").trim()}catch{Q.exec_pipeline=null}try{const Z=await n.admin_runtime_config();if(Z&&typeof Z=="object"){U||(b(Z),Q.process_manager=pc(Z.process_manager),Q.backlog_root=((M=Z.triage_repo_root)==null?void 0:M.available)!==void 0?!!Z.triage_repo_root.available:pc(Z.triage_repo_root),d(Q));return}}catch{}try{const Z=await n.list_processes();Q.process_manager=!!(Z!=null&&Z.enabled)}catch{Q.process_manager=null}try{await n.backlog_template(),Q.backlog_root=!0}catch(Z){Q.backlog_root=Ti(Z)?!1:null}U||d(Q)})(),(async()=>{try{const Q=await n.admin_data_homes();U||($(Array.isArray(Q==null?void 0:Q.homes)?Q.homes:[]),I(Array.isArray(Q==null?void 0:Q.warnings)?Q.warnings:[]))}catch{U||$(null)}})(),(async()=>{try{const Q=await n.list_bundles(),M=Array.isArray(Q==null?void 0:Q.items)?Q.items:Array.isArray(Q==null?void 0:Q.bundles)?Q.bundles:Array.isArray(Q)?Q:[],Z=[];for(const w of M){const K=String((w==null?void 0:w.bundle_id)||(w==null?void 0:w.id)||"").trim();if(!K)continue;const ve=Array.isArray(w==null?void 0:w.entrypoints)?w.entrypoints:[];for(const he of ve){if((he==null?void 0:he.deprecated)===!0||!(Array.isArray(he==null?void 0:he.interfaces)?he.interfaces:[]).some(Ae=>String(Ae||"").trim().length>0))continue;const be=String((he==null?void 0:he.name)||"").trim();Z.push({id:K,name:be?`${K} · ${be}`:K,description:String((he==null?void 0:he.description)||"").trim()||void 0})}}const ne=new Set,k=Z.filter(w=>ne.has(w.id)?!1:(ne.add(w.id),!0));k.sort((w,K)=>w.name.localeCompare(K.name)),U||y(k)}catch{U||y(null)}})(),()=>{U=!0}},[n,r,ie]);function le(U){return typeof U!="number"||!Number.isFinite(U)||U<0?"":U>=1e12?`${(U/1e12).toFixed(1)} TB`:U>=1e9?`${(U/1e9).toFixed(1)} GB`:U>=1e6?`${(U/1e6).toFixed(1)} MB`:U>=1e3?`${(U/1e3).toFixed(1)} KB`:`${U} B`}function pe(U,Q="on",M="off"){return U===null?e.jsx("span",{className:"chip mono muted",children:"unknown"}):e.jsx("span",{className:`chip mono ${U?"ok":"warn"}`,children:U?Q:M})}function G(U){const Q=String(U||"").trim();if(!Q)return null;const M={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."]},[Z,ne,k]=M[Q]||[Q,"muted",""];return e.jsx("span",{className:`chip mono ${ne}`,title:k,"data-testid":"source_chip",children:Z})}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:i.default_execution_mode,onChange:U=>l(Q=>({...Q,default_execution_mode:U.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(K_,{disabled:!r,value:{provider:i.maintenance_ai_provider,model:i.maintenance_ai_model},onChange:U=>l(Q=>({...Q,maintenance_ai_provider:U.provider,maintenance_ai_model:U.model,maintenance_ai_reasoning:U.model===Q.maintenance_ai_model?Q.maintenance_ai_reasoning:""})),fetchProviders:async()=>{const U=await n.discovery_providers();return(Array.isArray(U==null?void 0:U.items)?U.items:[]).map(Q=>({name:Q.name,display_name:Q.display_name}))},fetchModels:async U=>{const Q=await n.discovery_provider_models(U);return Array.isArray(Q==null?void 0:Q.models)?Q.models:[]},defaultHint:"Uses the gateway's configured default provider and model for maintenance calls."})]}),e.jsx(hb,{gateway:n,connected:r,model:i.maintenance_ai_model,value:i.maintenance_ai_reasoning,onChange:U=>l(Q=>({...Q,maintenance_ai_reasoning:U}))}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Advisor workflow (executable workflows served by this gateway)"}),v===null?e.jsx("input",{className:"mono",value:i.backlog_advisor_agent,onChange:U=>l(Q=>({...Q,backlog_advisor_agent:String(U.target.value||"")})),placeholder:"basic-agent",title:"This gateway does not serve the workflow catalog — enter a bundle id."}):(()=>{const U=String(i.backlog_advisor_agent||"").trim(),Q=U===""||v.some(M=>M.id===U);return e.jsxs(e.Fragment,{children:[e.jsxs("select",{value:Q&&!C?U:"__custom__",onChange:M=>{const Z=M.target.value;Z==="__custom__"?L(!0):(L(!1),l(ne=>({...ne,backlog_advisor_agent:Z})))},title:"Workflows the gateway can run for advice; blank = the shipped basic-agent",children:[e.jsx("option",{value:"",children:"gateway default (basic-agent)"}),v.map(M=>e.jsx("option",{value:M.id,title:M.description||void 0,children:M.name||M.id},M.id)),e.jsx("option",{value:"__custom__",children:"custom bundle id…"})]}),!Q||C?e.jsx("input",{className:"mono",style:{marginTop:6},value:i.backlog_advisor_agent,onChange:M=>l(Z=>({...Z,backlog_advisor_agent:String(M.target.value||"")})),placeholder:"bundle id (e.g. docs-qa@0.1.0)"}):null]})})()]})]})]}),e.jsx(mb,{gateway:n,gateway_connected:r}),e.jsx(gb,{}),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:[u!=null&&u.user_id?e.jsxs("div",{style:{fontSize:"var(--font-size-sm)",marginBottom:"8px"},children:["Signed in as ",e.jsx("strong",{children:u.user_id}),u.admin===!0?e.jsx("span",{className:"chip mono ok",style:{marginLeft:6},children:"gateway admin"}):u.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 k,w,K,ve,he,z,be,Ae,De;const U=(p==null?void 0:p.writable)===!0,Q=Array.isArray(p==null?void 0:p.executors)?p.executors:[],M=U?null:p?p.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).",Z=p?pc(p.backlog_exec_runner)===!0:m.exec_pipeline==="on"||m.exec_pipeline==="degraded",ne=p?pc(p.process_manager)===!0:m.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"}),pe(m.backlog_root,"available","not available"),G((k=p==null?void 0:p.triage_repo_root)==null?void 0:k.source),e.jsxs("div",{className:"admin_row_action",children:[U&&((w=p==null?void 0:p.triage_repo_root)!=null&&w.default_path)&&zo(p==null?void 0:p.triage_repo_root)!==p.triage_repo_root.default_path?e.jsx("button",{className:"btn",disabled:H,onClick:()=>{var Me;return void ke({triage_repo_root:((Me=p==null?void 0:p.triage_repo_root)==null?void 0:Me.default_path)||null})},title:p.triage_repo_root.default_path,children:"Use the gateway's own folder"}):null,U?e.jsx(pb,{current:zo(p==null?void 0:p.triage_repo_root),busy:H,on_apply:Me=>void ke({triage_repo_root:Me})}):null]})]}),e.jsxs("div",{className:"admin_row_detail",children:[((K=p==null?void 0:p.triage_repo_root)==null?void 0:K.help)||"The folder whose docs/backlog holds the items the Board and Backlog pages show.",zo(p==null?void 0:p.triage_repo_root)?e.jsxs(e.Fragment,{children:[" ","In use: ",e.jsx("code",{children:zo(p==null?void 0:p.triage_repo_root)})]}):null,((ve=p==null?void 0:p.triage_repo_root)==null?void 0:ve.available)===!1&&p.triage_repo_root.reason?e.jsxs(e.Fragment,{children:[" — not available: ",p.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(Ai,{label:"Exec runner",action:"exec-runner",checked:Z,unavailableReason:M,busy:H,onChange:Me=>void ke({backlog_exec_runner:Me},Me?"Exec runner is on.":"Exec runner is off.")}),m.exec_pipeline===null?e.jsx("span",{className:"chip mono muted",title:"The gateway did not report the runner's state.",children:"state unknown"}):Z&&m.exec_pipeline!=="on"?e.jsx("span",{className:"chip mono warn",title:m.exec_detail,children:"degraded"}):null,G((he=p==null?void 0:p.backlog_exec_runner)==null?void 0:he.source)]}),e.jsxs("div",{className:"admin_row_detail",children:[((z=p==null?void 0:p.backlog_exec_runner)==null?void 0:z.help)||"Runs the backlog items queued for execution on the gateway's computer.",m.exec_detail?e.jsxs(e.Fragment,{children:[" — ",m.exec_detail]}):null]})]}),e.jsxs("div",{className:"admin_row",children:[e.jsxs("div",{className:"admin_row_top",children:[e.jsx("span",{className:"admin_row_name",children:"Executor"}),m.executor&&m.executor!=="none"?e.jsx("span",{className:"chip mono ok",children:m.executor}):e.jsx("span",{className:"chip mono warn",children:"none"}),G((be=p==null?void 0:p.executor)==null?void 0:be.source),e.jsx("div",{className:"admin_row_action",children:U&&Q.length?e.jsx("select",{value:zo(p==null?void 0:p.executor),disabled:H,onChange:Me=>void ke({executor:String(Me.target.value||"")}),title:"Pick the execution agent (validated by the gateway registry)",children:Q.map(Me=>e.jsxs("option",{value:Me.id,disabled:Me.available===!1,children:[Me.display||Me.id,Me.available===!1?" (unavailable)":""]},Me.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(Ai,{label:"Process manager",action:"process-manager",checked:ne,unavailableReason:M,busy:H,onChange:Me=>void ke({process_manager:Me},Me?"Process manager is on.":"Process manager is off.")}),!p&&m.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,G((Ae=p==null?void 0:p.process_manager)==null?void 0:Ae.source)]}),e.jsx("div",{className:"admin_row_detail",children:((De=p==null?void 0:p.process_manager)==null?void 0:De.help)||"Powers the Services page. High trust: whoever reaches Services can redeploy."})]})]})})(),D?e.jsx("div",{className:"page_error mono",style:{marginTop:"6px"},children:D}):null,q&&!D?e.jsx("div",{className:"muted",role:"status","data-testid":"admin_notice",style:{fontSize:"var(--font-size-sm)",marginTop:"6px"},children:q}):null,e.jsx("div",{className:"muted",style:{fontSize:"var(--font-size-sm)",marginTop:"8px"},children:p?p.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.":p.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:T?`server-side — ${T.length} registered home${T.length===1?"":"s"}`:"server-side — read-only telemetry"})]}),e.jsx("div",{className:"pane_body",children:r?T===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:[...T].sort((U,Q)=>(Q.size_bytes||0)-(U.size_bytes||0)).map(U=>e.jsxs("tr",{title:U.description||U.path,children:[e.jsx("td",{children:U.name}),e.jsx("td",{children:e.jsx("span",{className:"chip mono muted",children:U.kind})}),e.jsx("td",{className:"muted",children:U.owner}),e.jsx("td",{children:U.exists===!1?e.jsx("span",{className:"chip mono warn",children:"missing"}):le(U.size_bytes)}),e.jsx("td",{children:U.safe_to_purge?e.jsx("span",{className:"chip mono ok",children:"purgeable"}):e.jsx("span",{className:"chip mono warn",title:U.description||"Protected — the owner's rule refuses purge",children:"protected"})})]},U.name))})]})}),E.map((U,Q)=>e.jsx("div",{className:"page_error mono",style:{marginTop:"6px"},children:U},`dhw:${Q}`)),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 vb=/^(```+|~~~+)\s*mermaid\s*$/i;function xb(a){const n=String(a||"").split(`
100
+ `),r=[];let i=[],l=0;for(;l<n.length;){const u=n[l].match(vb);if(!u){i.push(n[l]),l+=1;continue}const m=u[1];let d=-1;for(let p=l+1;p<n.length;p++){const b=n[p].trimEnd();if(b.startsWith(m[0].repeat(3))&&/^(`{3,}|~{3,})\s*$/.test(b)&&b[0]===m[0]){d=p;break}}if(d===-1){i.push(n[l]),l+=1;continue}i.length&&(r.push({kind:"md",text:i.join(`
101
+ `)}),i=[]),r.push({kind:"mermaid",text:n.slice(l+1,d).join(`
102
+ `)}),l=d+1}return i.length&&r.push({kind:"md",text:i.join(`
103
+ `)}),r}const bb="modulepreload",wb=function(a,n){return new URL(a,n).href},_h={},jb=function(n,r,i){let l=Promise.resolve();if(r&&r.length>0){let m=function(v){return Promise.all(v.map(y=>Promise.resolve(y).then(C=>({status:"fulfilled",value:C}),C=>({status:"rejected",reason:C}))))};const d=document.getElementsByTagName("link"),p=document.querySelector("meta[property=csp-nonce]"),b=(p==null?void 0:p.nonce)||(p==null?void 0:p.getAttribute("nonce"));l=m(r.map(v=>{if(v=wb(v,i),v in _h)return;_h[v]=!0;const y=v.endsWith(".css"),C=y?'[rel="stylesheet"]':"";if(!!i)for(let $=d.length-1;$>=0;$--){const E=d[$];if(E.href===v&&(!y||E.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${v}"]${C}`))return;const T=document.createElement("link");if(T.rel=y?"stylesheet":bb,y||(T.as="script"),T.crossOrigin="",T.href=v,b&&T.setAttribute("nonce",b),document.head.appendChild(T),y)return new Promise(($,E)=>{T.addEventListener("load",$),T.addEventListener("error",()=>E(new Error(`Unable to preload CSS for ${v}`)))})}))}function u(m){const d=new Event("vite:preloadError",{cancelable:!0});if(d.payload=m,window.dispatchEvent(d),!d.defaultPrevented)throw m}return l.then(m=>{for(const d of m||[])d.status==="rejected"&&u(d.reason);return n().catch(u)})};let cd=null;function kb(){return cd||(cd=jb(()=>import("./mermaid.core-BMJA9D_k.js").then(a=>a.bp),[],import.meta.url).then(a=>{const n=a.default||a;return n.initialize({startOnLoad:!1,securityLevel:"strict",theme:"dark"}),n})),cd}let Sb=0;function Nb(a){const n=h.useRef(null),[r,i]=h.useState("");return h.useEffect(()=>{let l=!0;return i(""),kb().then(async u=>{const m=`af_mermaid_${Sb+=1}`,{svg:d}=await u.render(m,a.text);l&&n.current&&(n.current.innerHTML=d)}).catch(u=>{l&&i(String((u==null?void 0:u.message)||u||"mermaid render failed"))}),()=>{l=!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:n})}const zp=5e4,Cb="abstractcontinuum history_window.estimate_tokens (~4 chars per token)";function $b(a){const n=String(a??"");return n?Math.max(1,Math.floor(n.length/4)):0}function Eb(a,n,r=zp){if(!Number.isInteger(r)||r<=0)throw new Error(`history window max_tokens must be a positive integer, got ${r}`);const i=a.map(p=>({item:p,tokens:n(p)}));let l=0,u=i.length,m=!1;for(let p=i.length-1;p>=0;p--){const b=i[p].tokens;if(l+b>r){u===i.length&&(m=!0,l+=b,u=p);break}l+=b,u=p}const d=i.slice(0,u);return{kept:i.slice(u).map(p=>p.item),report:{policy:"newest_whole_messages",max_tokens:r,token_estimator:Cb,total_messages:i.length,replayed_messages:i.length-u,replayed_tokens:l,dropped_messages:d.length,dropped_tokens:d.reduce((p,b)=>p+b.tokens,0),oversize_message_kept:m}}}const Tb=400;function Ab(a){const n=new Map;for(const l of a)n.set(l.id,l);const r=l=>{let u=l,m=!1;const d=new Set([u.id]);for(let p=0;p<Tb;p++){const b=String(u.reply_to||"");if(!b)break;const v=n.get(b);if(!v){m=u.id===l.id||m;break}if(d.has(v.id))break;d.add(v.id),u=v}return{root:u,orphan:m&&u.id===l.id}},i=new Map;for(const l of[...a].sort((u,m)=>(u.seq||0)-(m.seq||0))){const{root:u,orphan:m}=r(l);let d=i.get(u.id);d||(d={root:u,replies:[],orphan:u.id===l.id?m:!1,last_seq:u.seq||0},i.set(u.id,d)),l.id!==u.id&&(d.replies.push(l),d.last_seq=Math.max(d.last_seq,l.seq||0))}return[...i.values()].sort((l,u)=>l.last_seq-u.last_seq||(l.root.seq||0)-(u.root.seq||0))}const gh=[{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 Ip(a,n,r){var l,u,m,d,p;if(a.retracted===!0)return n==="all"?!0:n==="unread"?!!((l=r.unread_seqs)!=null&&l.has(a.seq)||(u=r.unread_snapshot_seqs)!=null&&u.has(a.seq)):!1;const i=String(a.status||"").toLowerCase();switch(n){case"all":return!0;case"unread":return!!((m=r.unread_seqs)!=null&&m.has(a.seq)||(d=r.unread_snapshot_seqs)!=null&&d.has(a.seq));case"asks":return i==="open"||i==="blocked";case"fyi":return i==="fyi";case"resolved":return i==="resolved";case"to_me":return Array.isArray(a.to)&&a.to.includes(r.seat);case"vigilance":{const b=(i==="open"||i==="blocked")&&a.has_resolved_reply!==!0,v=a.critical===!0,y=Array.isArray(a.to)&&a.to.includes(r.seat),C=!!((p=r.escalated_seqs)!=null&&p.has(a.seq));return b||v||y||C}}}function yh(a,n,r){return n==="all"?a:a.filter(i=>[i.root,...i.replies].some(l=>Ip(l,n,r)))}function Lb(a,n,r){return Ip(a,n,r)}function Rb(a){const n={},r={};for(const i of a){const l=String(i.channel||"");if(!l)continue;const u=Number(i.seq);if(Number.isFinite(u)){const m=n[l]||(n[l]=new Set);if(m.has(u))continue;m.add(u)}r[l]=(r[l]||0)+1}return r}function Mb(a){const n={};for(const r of a){const i=String(r.channel||""),l=Number(r.seq);!i||!Number.isFinite(l)||(n[i]||(n[i]=new Set)).add(l)}return n}function Pb(a,n){const r={};for(const i of a){const l=String(i.channel||""),u=Number(i.seq);if(!l||!Number.isFinite(u))continue;const m=String(i.status||"").toLowerCase(),d=Array.isArray(i.to)&&n?i.to.includes(n):!1;(m==="open"||m==="blocked"||(m==="reply"||m==="fyi")&&d)&&(r[l]||(r[l]=new Set)).add(u)}return r}function zb(a){const n={};for(const r of a){const i=String(r.channel||""),l=Number(r.seq);if(!i||!Number.isFinite(l))continue;const u=String(r.effective_urgency||"").toLowerCase();(r.escalated===!0||u==="interrupt")&&(n[i]||(n[i]=new Set)).add(l)}return n}function Ib(a,n){const r=n?n.replace(/\/+$/,"")+"/":"",i=new Map,l=[];for(const u of a){const m=String(u.path||"");if(!m.startsWith(r))continue;const d=m.slice(r.length);if(!d)continue;const p=d.indexOf("/");if(p===-1)l.push(u);else{const b=d.slice(0,p);i.set(b,(i.get(b)||0)+1)}}return{dirs:[...i.entries()].map(([u,m])=>({name:u,path:r+u,count:m})).sort((u,m)=>u.name.localeCompare(m.name)),leaves:l.sort((u,m)=>u.path.localeCompare(m.path))}}function vh(a,n){const r=String(a||"");if(!r.startsWith("dm:")||!n)return"";const i=r.slice(3);return i.startsWith(`${n}--`)?i.slice(n.length+2):i.endsWith(`--${n}`)?i.slice(0,i.length-n.length-2):""}function Db(a){return a.is_reply?"reply":a.in_dm||a.kind==="ask"?"open":"fyi"}function Ob(a){const n=new Map;for(const i of a)i.id&&n.set(i.id,String(i.sender||""));const r=new Set;for(const i of a){const l=i.reply_to?String(i.reply_to):"";if(!l)continue;const u=n.get(l);(u===void 0||u!==String(i.sender||""))&&r.add(l)}return r}const Fb=/(?:^|[\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,qb=4;function Ub(a){const n=[];for(const r of String(a||"").matchAll(Fb)){const i=r[1],l=r.index===void 0?-1:r.index,u=l>=0?String(a).slice(Math.max(0,l-12),l+1):"";if(!(u.includes("://")||/\/api\//.test(u))&&(n.includes(i)||n.push(i),n.length>=qb))break}return n}function Bb(a,n,r){var l,u;const i=a.split("/").pop()||a;if(n!=null&&n.has(a))return{kind:"fs",path:a,rewritten:!1};for(let m=0;m<r.length;m++)if(String(((l=r[m])==null?void 0:l.filename)||"")===a)return{kind:"attachment",attachment_index:m};if(n){const m=[];for(const d of n)(d===i||d.endsWith(`/${i}`))&&m.push(d);if(m.length===1)return{kind:"fs",path:m[0],rewritten:m[0]!==a}}for(let m=0;m<r.length;m++){const d=String(((u=r[m])==null?void 0:u.filename)||"");if(d&&(d===i||d.split("/").pop()===i))return{kind:"attachment",attachment_index:m}}return null}const xh=/@([A-Za-z0-9][A-Za-z0-9_.-]*)/g;function ud(a){const n=[];for(const i of a.matchAll(xh)){const l=i[1].toLowerCase();n.includes(l)||n.push(l)}return{title:a.replace(xh," ").split(/\s+/).join(" ").trim().replace(/^[\s,;:-]+|[\s,;:-]+$/g,""),members:n}}function dd(a){const n=[];for(const r of String(a||"").split(/[\s,;]+/)){const i=r.replace(/^@/,"").toLowerCase();!i||!/^[a-z0-9][a-z0-9_.-]*$/.test(i)||n.includes(i)||n.push(i)}return n}function md(a,n){let r=a.toLowerCase().replace(/[^a-z0-9_.-]+/g,"-").replace(/^[-.]+|[-.]+$/g,"");r||(r="group"),r=r.slice(0,40).replace(/[-.]+$/g,"");let i=r,l=1;for(;n.has(i);)l+=1,i=`${r}-${l}`;return i}const bh=400,wh=/([.;:!?…]["')\]]*) +(\((?:\d{1,2}|[a-z])\)|\[\d{1,2}\]) (?=["'([{]?[A-Za-z0-9])/g,jh=/([.;:!?…]["')\]]*) +(?=[A-Z][A-Z'-]+(?: [A-Z][A-Z'-]*)+)/g;function Wb(a){if(!a||a.length<bh)return a;const n=a.split(/(```[\s\S]*?(?:```|$))/),r=[];for(const i of n){if(i.startsWith("```")){r.push(i);continue}const l=i.split(/(\n{2,})/);for(const u of l){if(/\n/.test(u)||u.length<bh){r.push(u);continue}const m=u.split(/(`[^`\n]*`)/);let d=0;for(const p of m)p.startsWith("`")||(d+=(p.match(wh)||[]).length+(p.match(jh)||[]).length);if(d<2){r.push(u);continue}r.push(m.map(p=>p.startsWith("`")?p:p.replace(wh,`$1
104
+
105
+ $2 `).replace(jh,`$1
106
+
107
+ `)).join(""))}}return r.join("")}const Hb=/https?:\/\/[^\s<>()[\]{}"'`]+/g,Vb=/\.(png|jpe?g|gif|webp)$/i;function Gb(a,n){if(!n)return a;const r=n.replace(/\/+$/,"");if(!a.startsWith(r+"/"))return a;const l=a.slice(r.length).match(/^\/channels\/([^/]+)\/attachments\/([A-Za-z0-9_.-]+)$/);return l?`api/hub/channels/${l[1]}/attachments/${l[2]}`:a}function Kb(a,n){if(!a||!/https?:\/\//.test(a))return a;const r=(n==null?void 0:n.hub_base)||"",i=(n==null?void 0:n.app_origin)||"",l=a.split(/(```[\s\S]*?(?:```|$))/),u=[];for(let m=0;m<l.length;m++){const d=l[m];if(d.startsWith("```")){u.push(d);continue}const p=d.split(/(`[^`\n]*`)/);for(let b=0;b<p.length;b++){const v=p[b];if(v.startsWith("`")){u.push(v);continue}u.push(v.replace(Hb,(y,C)=>{const L=v.slice(Math.max(0,C-2),C);if(L.endsWith("](")||L.endsWith("("))return y;const T=y.replace(/[.,;:!?]+$/,""),$=y.slice(T.length);let E="";try{E=new URL(T).pathname}catch{return y}const I=Gb(T,r),D=Vb.test(E),O=I!==T||i!==""&&I.startsWith(i+"/");return D&&O?`![image](${I})${$}`:`[${T}](${I})${$}`}))}}return u.join("")}const Jb=/^api\/hub\/channels\/[^/]+\/attachments\/[A-Za-z0-9_-]+$/;function Qb(a){const n=a.trim(),r=n.replace(/^\.\//,"").replace(/^\//,"");return r.startsWith("api/")?n.startsWith("/")||/\s/.test(r)||r.includes("..")?!0:!Jb.test(r):!1}function Ko(a){if(!a||!a.includes("api/"))return a;const n=/(!?)\[([^\]]*)\]\(([^)]+)\)/g;return a.replace(n,(r,i,l,u)=>Qb(String(u))?"`"+(String(l||"").trim()||String(u)).replace(/`/g,"")+" (blocked link)`":r)}function Gd(a){let n=0;for(let r=0;r<a.length;r++)n=n*31+a.charCodeAt(r)>>>0;return n%360}function Yb(a){var u,m,d,p;const n=Array.isArray(a.to)&&a.to.length?` to=[${a.to.join(",")}]`:"",r=(m=(u=a.data)==null?void 0:u.asks)!=null&&m.length?` asks=${a.data.asks.map(b=>`${b.id}:"${b.text}"`).join("; ")}`:"",i=(p=(d=a.data)==null?void 0:d.answers)!=null&&p.length?` answers=[${a.data.answers.join(",")}]`:"",l=a.reply_to?` reply_to=${a.reply_to}`:"";return`#${a.seq} [${a.sender}] (${a.status})${n}${l}${r}${i}
108
+ ${a.title?`title: ${a.title}
109
+ `:""}${String(a.body||"").trim()}`}function kh(a,n){const r=zp,l=[...a].sort((p,b)=>(p.seq||0)-(b.seq||0)).map(Yb),{kept:u,report:m}=Eb(l,$b,r),d=[`TRANSCRIPT WINDOW: ${m.replayed_messages} of ${m.total_messages} message(s), ~${m.replayed_tokens} tokens (the newest whole messages up to ${r} tokens).`];return m.dropped_messages>0&&d.push(`#TRUNCATION: the ${m.dropped_messages} oldest message(s) (~${m.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:`${d.join(`
110
+ `)}
111
+
112
+ ${u.join(`
113
+
114
+ `)}`,report:m}}function Sh(a){const n=r=>`message${r===1?"":"s"}`;return a.dropped_messages<=0?`${a.replayed_messages} ${n(a.replayed_messages)}`:`${a.replayed_messages} of ${a.total_messages} ${n(a.total_messages)} (${a.dropped_messages} oldest dropped by the ${a.max_tokens.toLocaleString("en-US")}-token history window)`}function Xb(a,n){let r=Number(a.up||0),i=Number(a.down||0),l=Number(a.mine||0);return n===void 0?{up:r,down:i,mine:l,caught_up:!1}:n===l?{up:r,down:i,mine:l,caught_up:!0}:(l>0?r-=1:l<0&&(i-=1),n>0?r+=1:n<0&&(i+=1),{up:Math.max(0,r),down:Math.max(0,i),mine:n,caught_up:!1})}function Zb(a,n){const r=Array.from(String(a??"")),i=(n??[]).filter(m=>Array.isArray(m)&&m.length>=2&&Number.isFinite(m[0])&&Number.isFinite(m[1])&&m[0]>=0&&m[1]>0).sort((m,d)=>m[0]-d[0]),l=[];let u=0;for(const[m,d]of i){if(m>=r.length)break;const p=Math.max(m,u),b=Math.min(m+d,r.length);b<=p||(p>u&&l.push({text:r.slice(u,p).join(""),hit:!1}),l.push({text:r.slice(p,b).join(""),hit:!0}),u=b)}return u<r.length&&l.push({text:r.slice(u).join(""),hit:!1}),!l.length&&r.length&&l.push({text:r.join(""),hit:!1}),l}const yc=[{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"}],ew=new Set(["image/png","image/jpeg","image/gif","image/webp"]);function zr(a,n){const r=a.toLowerCase().split(".").pop()||"",i=String(n||"").toLowerCase();if(r==="md"||r==="markdown"||i==="text/markdown")return"md";if(ew.has(i))return"image";const l=new Set(["txt","json","yaml","yml","csv","log","ts","tsx","js","py","sh","toml","ini","env"]);return!(i.includes("html")||i.includes("xml")||i.includes("svg"))&&(i.startsWith("text/")||l.has(r))?"text":"download"}function tw({url:a,name:n}){const[r,i]=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 ",n]})]}):e.jsx("img",{className:"team_fileview_img",src:a,alt:n,onError:()=>i(!0)})}function nw({view:a,onClose:n}){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(er,{open:!0,title:a.name,onClose:n,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:xb(a.text||"").map((i,l)=>i.kind==="mermaid"?e.jsx(Nb,{text:i.text},l):e.jsx(os,{className:"md_doc",text:Ko(i.text)},l))}):a.mode==="text"?e.jsx("pre",{className:"team_fileview_text",children:a.text||""}):a.mode==="image"&&a.url?e.jsx(tw,{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 sw=Wt.memo(os),aw=["id","channel","seq","sender","kind","status","urgency","critical","downgraded","to","title","body","data","reply_to","created_at"];function Nh(a){let n='"';for(let r=0;r<a.length;r++){const i=a.charCodeAt(r),l=a[r];l==='"'?n+='\\"':l==="\\"?n+="\\\\":i===8?n+="\\b":i===9?n+="\\t":i===10?n+="\\n":i===12?n+="\\f":i===13?n+="\\r":i<32||i>126?n+="\\u"+i.toString(16).padStart(4,"0"):n+=l}return n+'"'}class Dp{constructor(n){this.value=n}}function Ch(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 n=a<0,r=Math.abs(a),l=r.toExponential().match(/^(\d)(?:\.(\d+))?e([+-]\d+)$/);if(!l)return(n?"-":"")+String(r);const u=l[1]+(l[2]||""),d=parseInt(l[3],10)+1;let p;if(d<=-4||d>16){const b=u.length>1?`${u[0]}.${u.slice(1)}`:u[0],v=d-1,y=(v<0?"-":"+")+String(Math.abs(v)).padStart(2,"0");p=`${b}e${y}`}else d<=0?p="0."+"0".repeat(-d)+u:d>=u.length?p=u+"0".repeat(d-u.length)+".0":p=u.slice(0,d)+"."+u.slice(d);return(n?"-":"")+p}function Ld(a){if(a==null)return"null";if(typeof a=="boolean")return a?"true":"false";if(a instanceof Dp){if(!Number.isFinite(a.value))throw new Error("canonical_json: non-finite number");return Ch(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):Ch(a)}if(typeof a=="string")return Nh(a);if(Array.isArray(a))return"["+a.map(Ld).join(",")+"]";if(typeof a=="object")return"{"+Object.keys(a).sort().map(r=>Nh(r)+":"+Ld(a[r])).join(",")+"}";throw new Error(`canonical_json: unsupported type ${typeof a}`)}async function rw(a){return lp(a)}async function iw(a,n,r){const i={};for(const l of aw)l!=="channel"&&(i[l]=n[l]??null);return i.channel=r,typeof i.created_at=="number"&&(i.created_at=new Dp(i.created_at)),await rw(a+`
115
+ `+Ld(i))}async function ow(a){const n=a.channel;let r="",i=0,l=0,u=null,m="";for(const p of a.turns){if(p.hash===null||p.hash===void 0){i>0&&u===null&&(u=p.seq),l+=1,r="";continue}const b=await iw(r,p,n);b!==p.hash&&u===null&&(u=p.seq),r=p.hash,m=b,i+=1}const d=u===null&&String(a.head||"")!==m;return{ok:u===null&&!d,broken_at:u,head_mismatch:d,computed_head:m,hashed:i,legacy:l}}const lw=5e3,cw=6,ha=200,uw=50,vc=380,$h=240,Eh=2,dw=12,Fo=8,Th=16*1024*1024,mw=new Set(["image/png","image/jpeg","image/gif","image/webp"]),Yo=256*1024;function fw(){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 Ah(){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 xc(a){return a.length<=Yo?a:a.slice(0,Yo)+`
116
+
117
+ ---
118
+ #TRUNCATION: preview clamped at ${Vn(Yo)} of ${Vn(a.length)} — download the file for the full content.`}function fd(a,n){try{return JSON.stringify(a)===JSON.stringify(n)}catch{return!1}}function hd(a,n){const r=Object.keys(a);if(r.length!==Object.keys(n).length)return!1;for(const i of r){const l=a[i],u=n[i];if(!u||l.size!==u.size)return!1;for(const m of l)if(!u.has(m))return!1}return!0}function Vn(a){if(!Number.isFinite(a)||a<0)return"—";if(a<1024)return`${a} B`;const n=a/1024;return n<1024?`${Math.round(n)} KiB`:`${(a/(1024*1024)).toFixed(1)} MiB`}const Op="abstractcontinuum_team_drafts_v1";function hw(){try{const a=window.localStorage.getItem(Op),n=a?JSON.parse(a):{};return n&&typeof n=="object"?n:{}}catch{return{}}}function qo(a){try{window.localStorage.setItem(Op,JSON.stringify(a))}catch{}}const bc="agora/0.4";function Uo(a){if(!a)return"";const n=Math.max(0,Math.floor(Date.now()/1e3-a));return n<60?`${n}s`:n<3600?`${Math.floor(n/60)}m`:n<86400?`${Math.floor(n/3600)}h`:`${Math.floor(n/86400)}d`}function Bo(a){if(!a)return"";try{return new Date(a*1e3).toLocaleString()}catch{return""}}function Lh(a){return{color:`hsl(${Gd(a)}, 60%, 55%)`}}function Qa(a){const n=Gd(a),r=n>=40&&n<=190?36:45;return{background:`hsl(${n}, 55%, ${r}%)`,color:"#fff"}}const Ei=[{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."}],pw=[{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(Ei.map(a=>[a.id,`${a.help} Every standing vote counts.`]))};function Wo(a){const n=Ei.find(r=>r.id===a);return n?n.label:a==="general"?"General":a.charAt(0).toUpperCase()+a.slice(1)}function _w(a){if(!a)return"";try{return new Date(a*1e3).toLocaleDateString(void 0,{weekday:"long",month:"short",day:"numeric"})}catch{return""}}function gw(a){var Tt,bs,an,gn,Os,la;const n=a.gateway,r=!!a.gateway_connected,i=h.useMemo(()=>new Vd,[]),l=h.useMemo(()=>{if(a.advisor)return a.advisor;if(!r||!n)return;const f=a.advisor_agent;return async(x,N)=>{const S=[...N.map(ce=>({role:ce.role,content:ce.content})),{role:"user",content:x}],R=await n.backlog_advisor({messages:S,agent:f||null});return String((R==null?void 0:R.reply)||"").trim()||"(the model returned an empty reply)"}},[a.advisor,n,r,a.advisor_agent]),u=!!l,[m,d]=h.useState(""),[p,b]=h.useState(()=>Ed()),[v,y]=h.useState(""),C=h.useRef(p);C.current=p;const L=h.useRef({});h.useEffect(()=>{if(!r||!n){d("");return}let f=!0;return(async()=>{try{const x=await Od("abstractcontinuum_team_voice");f&&d(x)}catch{f&&d("")}})(),typeof n.capability_defaults=="function"&&Promise.resolve().then(()=>n.capability_defaults()).then(x=>{f&&(L.current=Pp(x))}).catch(()=>{f&&(L.current={})}),()=>{f=!1}},[n,r]),h.useEffect(()=>{const f=()=>b(Ed());return window.addEventListener(Td,f),window.addEventListener("storage",f),()=>{window.removeEventListener(Td,f),window.removeEventListener("storage",f)}},[]);const T=h.useMemo(()=>{const f=String(m||"").trim();if(!(!r||!n||!f))return x=>{const N=n.voice_stream_transport(f,{text:x,...L.current,...Mp(C.current)});return Zg({path:N.path,body:N.body,headers:N.headers})}},[n,r,m]),$=Wh({tts_stream:T,on_error:y});h.useEffect(()=>{if(!v)return;B(v);const f=setTimeout(()=>y(""),6e3);return()=>clearTimeout(f)},[v]);const[E,I]=h.useState(null),D=h.useRef(null);h.useEffect(()=>{D.current=E},[E]);const[O,q]=h.useState(""),[A,H]=h.useState(null),[fe,ie]=h.useState([]),[Se,ke]=h.useState({}),[le,pe]=h.useState({}),[G,te]=h.useState({}),[ae,U]=h.useState({}),[Q,M]=h.useState(null),[Z,ne]=h.useState(""),k=h.useRef(0),w=h.useRef(!1),K=h.useRef(!1);async function ve(){if(!w.current&&!(Date.now()-k.current<3e4)){k.current=Date.now();try{const f=await i.desk();M(x=>x==="loading"?x:f),f.rows.length&&!K.current&&Jn(x=>x!==""?x:(K.current=!0,"desk"))}catch(f){((f==null?void 0:f.status)===403||(f==null?void 0:f.status)===404)&&(w.current=!0)}}}async function he(){M("loading"),ne("");try{const f=await i.desk();M(f),k.current=Date.now(),w.current=!1}catch(f){M(null),ne((f==null?void 0:f.status)===403?"The desk serves operators and reporting delegates only — this console's seat is neither.":(f==null?void 0:f.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((f==null?void 0:f.message)||f||"network error").slice(0,120)}) — transient; Refresh retries.`)}}const[z,be]=h.useState(""),[Ae,De]=h.useState("channels"),[Me,lt]=h.useState(!1),[Ue,ct]=h.useState([]),[Xe,dt]=h.useState("all"),Ze=h.useRef(null),[W,X]=h.useState(null),ge=h.useRef(""),[Y,B]=h.useState(""),[oe,je]=h.useState(!1),[Oe,se]=h.useState({}),[xe,ze]=h.useState({}),[Ne,Le]=h.useState({}),re=h.useRef(new Set),P=h.useRef(0),[de,Ve]=h.useState(""),[et,at]=h.useState(""),[mt,ft]=h.useState([]),[Ee,tt]=h.useState(!1),ht=h.useRef(null),[Pt,wt]=h.useState(!1),tn=h.useRef(null);h.useEffect(()=>{const f=tn.current;f&&(f.style.height="auto",f.style.height=`${Math.min(f.scrollHeight+2,160)}px`)},[de,z]);const[ye,Ce]=h.useState("fyi"),[Je,yt]=h.useState(""),[_t,jt]=h.useState(""),[rt,Cn]=h.useState(null),[Cs,tr]=h.useState({}),[$s,ls]=h.useState(""),nn=h.useRef(hw()),Gs=h.useRef(""),[Ks,Es]=h.useState(!1),[Mi,Ts]=h.useState(!1),[Ur,ut]=h.useState(""),[Ht,nr]=h.useState(null),[Mt,sr]=h.useState(null),[Pi,al]=h.useState({});function zi(f,x){x.length&&al(N=>{const S={...N},R=new Set(S[f]||[]);for(const ce of x)R.add(ce);return S[f]=R,S})}function It(f,x){const N=new Set(x.map(S=>String(S.agent_id||"")).filter(Boolean));N.size&&al(S=>{const R=S[f];if(!R||![...R].some(we=>N.has(we)))return S;const ce=new Set([...R].filter(we=>!N.has(we))),V={...S};return ce.size?V[f]=ce:delete V[f],V})}const Br=h.useRef(0),[Wr,ar]=h.useState(""),[Js,rl]=h.useState(null),[Hr,cs]=h.useState(""),[hn,Vr]=h.useState(!1),[pn,il]=h.useState(""),[ga,ol]=h.useState([]);function ya(){i.delegations().then(f=>{rl(f),cs("")}).catch(f=>{rl([]);const x=String((f==null?void 0:f.message)||f);cs((f==null?void 0:f.status)===404||/allowlist/i.test(x)?"Delegation needs the updated console/hub — restart the stack to pick it up.":x)})}async function Gr(){if(!(!pn||!ga.length||hn)){Vr(!0),cs("");try{await i.set_delegation(pn,ga),il(""),ol([]),ya()}catch(f){cs(String((f==null?void 0:f.message)||f||"delegation failed"))}finally{Vr(!1)}}}async function rr(f){if(!hn){Vr(!0),cs("");try{await i.revoke_delegation(f),ya()}catch(x){cs(String((x==null?void 0:x.message)||x||"resign failed"))}finally{Vr(!1)}}}const[bn,Qs]=h.useState(null),[Kr,As]=h.useState(null),[Vt,Xt]=h.useState(""),[Ls,va]=h.useState(null),[Rs,kt]=h.useState([]),[Gt,us]=h.useState(""),[Jr,Pn]=h.useState(""),[Qr,Ii]=h.useState(""),[ir,or]=h.useState(!1),[ds,Kn]=h.useState(""),[$n,Ms]=h.useState({open:!1,name:"",is_private:!1}),[cn,_n]=h.useState(!1),[Ec,xa]=h.useState({}),[Et,Jn]=h.useState(""),[zn,ba]=h.useState(null),[Yr,ll]=h.useState(""),[wn,wa]=h.useState("channel"),[ms,lr]=h.useState(""),[Di,cr]=h.useState(null),[Xr,ur]=h.useState(""),[dr,Oi]=h.useState(""),[In,fs]=h.useState(""),[Ys,Zr]=h.useState(null),[ja,ka]=h.useState(""),[Xs,sn]=h.useState(""),[Sa,Kt]=h.useState(null),[Ps,Fi]=h.useState([]),[ei,mr]=h.useState(""),[Zs,Na]=h.useState(!1),[qi,Ui]=h.useState(""),[cl,ul]=h.useState(""),ti=h.useRef(null),dl=h.useRef(0),Bi=h.useRef(!1),ml=h.useRef(0),[Wi,Hi]=h.useState(!1),Vi=h.useRef(""),Dn=h.useRef([]),zs=h.useRef([]),Is=h.useRef(null),Gi=h.useRef(!1),fr=h.useRef(null);Vi.current=z,Dn.current=fe,zs.current=Ue,h.useEffect(()=>{for(const f of Ue){const x=pr.current[f.id];x!==void 0&&f.ratings&&Number(f.ratings.mine||0)===x&&delete pr.current[f.id]}},[Ue]);const Ki=h.useRef(!1);async function Tc(f){var x;try{const N=await i.inbox(),S=Rb(N),R=Mb(N);pe(We=>hd(We,R)?We:R);const ce=Pb(N,((x=D.current)==null?void 0:x.seat)||"");te(We=>hd(We,ce)?We:ce);const V=zb(N);U(We=>hd(We,V)?We:V),ve();const we=f.slice(0,dw),Pe=await Promise.allSettled(we.map(We=>i.digest(We.name))),Fe={};for(const We of f)Fe[We.name]={unread:S[We.name]||0,open_questions:0};Pe.forEach((We,$t)=>{var jn;const zt=we[$t].name;if(We.status==="fulfilled"){const xt=(jn=We.value)==null?void 0:jn.counts;Fe[zt]={...Fe[zt],open_questions:Number((xt==null?void 0:xt.open_questions)||0)}}}),ke(We=>fd(We,Fe)?We:Fe)}catch{}}async function Ca(f){if(Gi.current){fr.current=f;return}Gi.current=!0;let x=f;try{for(;x;)fr.current=null,await Tc(x),x=fr.current}finally{Gi.current=!1}}async function $a(){const x=[...await i.channels()];return x.sort((N,S)=>(S.last_at||0)-(N.last_at||0)),ie(N=>fd(N,x)?N:x),Dn.current=x,x}async function hs(){try{const[f,x]=await Promise.all([i.meta(),i.channels()]);I({seat:f.seat,seat_key_present:f.seat_key_present}),q(String(f.hub_url||"")),i.healthz().then(R=>H(R)).catch(()=>H(null)),i.presence().then(R=>{const ce=[...new Set(R.map(V=>String(V.agent_id||"")).filter(V=>V&&V!==f.seat))].sort();kt(ce)}).catch(()=>kt([]));const N=[...x];N.sort((R,ce)=>(ce.last_at||0)-(R.last_at||0)),ie(N);const S=N.filter(R=>!R.name.startsWith("dm:"));!z&&S.length&&be(S[0].name),B(""),Ca(N)}catch(f){B(String((f==null?void 0:f.message)||f||"Hub unreachable"))}}async function ea(f,x){var S,R,ce;if(!f)return;const N=P.current;x!=null&&x.background||je(!0);try{const V=zs.current.length&&zs.current[zs.current.length-1].seq||0,we=((S=Dn.current.find(it=>it.name===f))==null?void 0:S.last_seq)||0;let Pe=we,Fe=null;if(!(x!=null&&x.background))if(we>0)Fe=$a().catch(()=>null);else try{const it=await $a();if(N!==P.current)return;Pe=((R=it.find(Lt=>Lt.name===f))==null?void 0:R.last_seq)||0}catch{}const We=Math.max(0,Pe-ha),$t=x!=null&&x.background&&V>0?Math.max(0,V-uw):We,zt=await i.messages(f,{since:$t,limit:ha});if(N!==P.current)return;const jn=new Set(zs.current.map(it=>it.id)),xt=zt.some(it=>!jn.has(it.id));if(x!=null&&x.background&&!xt&&V>0){const it=Date.now();if(it-ml.current>1e4){ml.current=it;try{const Lt=await $a();if(N!==P.current)return;const gt=((ce=Lt.find(qe=>qe.name===f))==null?void 0:ce.last_seq)||0;if(gt>0&&gt<V){const qe=Math.max(0,gt-ha),St=await i.messages(f,{since:qe,limit:ha});if(N!==P.current)return;St.sort((Ot,Ut)=>(Ot.seq||0)-(Ut.seq||0)),ct(St),B("");return}}catch{}}}zt.sort((it,Lt)=>(it.seq||0)-(Lt.seq||0)),ct(it=>{if(x!=null&&x.background&&it.length){if(!zt.length)return it;const Lt=new Set(it.map(Zt=>Zt.id)),gt=zt.filter(Zt=>!Lt.has(Zt.id)),qe=new Map(zt.map(Zt=>[Zt.id,Zt]));let St=0;const Ot=it.map(Zt=>{const Rt=qe.get(Zt.id);if(!Rt)return Zt;const Qt=JSON.stringify(Rt.ratings??null)!==JSON.stringify(Zt.ratings??null)||(Rt.has_resolved_reply??null)!==(Zt.has_resolved_reply??null)||JSON.stringify(Rt.pending_asks??null)!==JSON.stringify(Zt.pending_asks??null)||!!Rt.retracted!=!!Zt.retracted;return Qt&&St++,Qt?Rt:Zt});if(!gt.length&&!St)return it;const Ut=[...St?Ot:it,...gt];return Ut.length>ha*2?Ut.slice(Ut.length-ha*2):Ut}return zt}),B(""),!(x!=null&&x.background)&&Fe&&(async()=>{var it;try{const Lt=await Fe;if(N!==P.current||!Lt)return;const gt=((it=Lt.find(qe=>qe.name===f))==null?void 0:it.last_seq)||0;if(gt>0&&gt!==we){const qe=Math.max(0,gt-ha),St=await i.messages(f,{since:qe,limit:ha});if(N!==P.current)return;St.sort((Ot,Ut)=>(Ot.seq||0)-(Ut.seq||0)),ct(Ot=>fd(Ot,St)?Ot:St)}}catch{}})()}catch(V){if(N!==P.current)return;B(String((V==null?void 0:V.message)||V||"Failed to load messages"))}finally{!(x!=null&&x.background)&&N===P.current&&je(!1)}}h.useEffect(()=>{hs()},[]),h.useEffect(()=>{let f=null,x=!1,N=0,S=0;const R=()=>{if(!x){try{f=new WebSocket(i.ws_url())}catch{Hi(!1),N+=1,setTimeout(R,Math.min(15e3,1e3*Math.max(1,N)));return}f.onopen=()=>{Hi(!0),S=Date.now(),(!Dn.current.length||!D.current)&&hs()},f.onmessage=ce=>{var V;try{const we=JSON.parse(String(ce.data||"{}"));if((we==null?void 0:we.type)!=="envelope")return;const Pe=String(((V=we.envelope)==null?void 0:V.channel)||"");Pe&&Pe===Vi.current&&ea(Pe,{background:!0}),Pe&&!Dn.current.some(Fe=>Fe.name===Pe)&&$a(),Is.current&&clearTimeout(Is.current),Is.current=setTimeout(()=>void Ca(Dn.current),800)}catch{}},f.onclose=()=>{Hi(!1),x||(S&&Date.now()-S>=15e3?N=0:N+=1,S=0,setTimeout(R,Math.min(15e3,1e3*Math.max(1,N))))},f.onerror=()=>{try{f==null||f.close()}catch{}}}};return R(),()=>{x=!0,Is.current&&clearTimeout(Is.current);try{f==null||f.close()}catch{}}},[]),h.useEffect(()=>{P.current+=1,se({}),ze({}),Le({}),re.current=new Set,nr(null),sr(null);try{$.stop_tts()}catch{}Br.current=0,pr.current={},Ct("recency"),La(null),wr(""),Zr(null),ka(""),sn(""),Kt(null),Qs(null),As(null),va(null),Xt(""),Pn(""),xa({}),Fi([]),Ui(""),ul(""),Na(!1),mr(""),ct([]),dt(Ze.current||"all"),Ze.current=null,Cn(null),tr({}),ls(""),ft([]),Gs.current&&Gs.current!==z&&(de||et?nn.current[Gs.current]={text:de,title:et,kind:ye}:delete nn.current[Gs.current],qo(nn.current));const f=nn.current[z];if(Ve((f==null?void 0:f.text)||""),at((f==null?void 0:f.title)||""),Ce((f==null?void 0:f.kind)||"fyi"),Gs.current=z,Ki.current=!0,ea(z),!z)return;Et==="files"&&eo(),Et==="members"&&hr();const x=setInterval(()=>{dl.current+=1,Bi.current||(Bi.current=!0,ea(z,{background:!0}).finally(()=>{Bi.current=!1})),dl.current%cw===0&&($a().then(N=>Ca(N)).catch(()=>Ca(Dn.current)),i.healthz().then(H).catch(()=>{}),i.meta().then(N=>I(N)).catch(()=>{}))},lw);return()=>clearInterval(x)},[z]);const fl=h.useRef({text:"",title:"",kind:"fyi",selected:""});fl.current={text:de,title:et,kind:ye,selected:z},h.useEffect(()=>{if(!z)return;const f=setTimeout(()=>{de||et?nn.current[z]={text:de,title:et,kind:ye}:delete nn.current[z],qo(nn.current)},300);return()=>clearTimeout(f)},[de,et,ye,z]),h.useEffect(()=>{const f=()=>{const x=fl.current;x.selected&&(x.text||x.title?nn.current[x.selected]={text:x.text,title:x.title,kind:x.kind}:delete nn.current[x.selected],qo(nn.current))};return window.addEventListener("pagehide",f),window.addEventListener("beforeunload",f),()=>{window.removeEventListener("pagehide",f),window.removeEventListener("beforeunload",f),f()}},[]),h.useEffect(()=>{const f=ti.current;if(!f||!Ue.length)return;if(Ki.current){Ki.current=!1,f.scrollTop=f.scrollHeight;return}f.scrollHeight-f.scrollTop-f.clientHeight<240&&(f.scrollTop=f.scrollHeight)},[Ue]),h.useEffect(()=>{if(Xe!=="unread"||!z){X(null);return}const f=le[z];X(new Set(f||[])),ge.current=""},[Xe,z]),h.useEffect(()=>{if(Xe!=="unread"||!z||!W||!W.size)return;const f=Math.min(...W),x=Ue.length&&Ue[0].seq||0;if(!f||!x||x<=f)return;const N=`${z}:${f}`;if(ge.current===N)return;ge.current=N;const S=P.current;i.messages(z,{since:Math.max(0,f-1),limit:ha}).then(R=>{S!==P.current||!R.length||ct(ce=>{const V=new Set(ce.map(Pe=>Pe.id)),we=R.filter(Pe=>!V.has(Pe.id));return we.length?[...ce,...we].sort((Pe,Fe)=>(Pe.seq||0)-(Fe.seq||0)):ce})}).catch(()=>{S===P.current&&(ut("Couldn't load the older unread messages — the Unread list may be incomplete. Re-select Unread to retry."),setTimeout(()=>ut(""),6e3))})},[Xe,z,W,Ue]);function hl(f){re.current.has(f.id)||(re.current.add(f.id),i.read_message(f.channel,f.id).catch(()=>{}),i.ack(f.channel,f.seq).catch(()=>{}),pe(x=>{const N=x[f.channel];if(!N||!N.has(f.seq))return x;const S=new Set(N);return S.delete(f.seq),{...x,[f.channel]:S}}),Is.current&&clearTimeout(Is.current),Is.current=setTimeout(()=>void Ca(Dn.current),500),f.critical&&(ut(`Read recorded for critical #${f.seq}.`),setTimeout(()=>ut(""),2500)))}function pl(f){const x=!Oe[f.id];se(N=>({...N,[f.id]:x})),x&&hl(f)}function Ac(f){const x=window.getSelection();if(x&&!x.isCollapsed)return;const N=String(f.body||""),S=f.status==="reply"?$h:vc;N.length>S?pl(f):hl(f)}async function Lc(){if(!z||Ht==="running")return;const f=P.current;nr("running");try{const x=await i.ledger(z),N=await ow(x);if(f!==P.current)return;nr(N)}catch(x){if(f!==P.current)return;nr({error:String((x==null?void 0:x.message)||x||"verification failed")})}}function hr(){{const f=P.current;sr("loading"),Qs(null),ar(""),As(null),i.channel_info(z).then(x=>{f===P.current&&sr(x)}).catch(x=>{f===P.current&&sr({error:String((x==null?void 0:x.message)||x||"info failed")})}),i.members(z).then(x=>{f===P.current&&(Qs(x),ar(""),It(z,x))}).catch(x=>{f===P.current&&(Qs([]),ar(String((x==null?void 0:x.message)||x||"members unavailable")))}),i.list_blocks().then(x=>{f===P.current&&As(x)}).catch(()=>{f===P.current&&As([])}),i.retired_agents().then(x=>{f===P.current&&va(x)}).catch(()=>{f===P.current&&va([])})}}function ns(f){const x=Et===f?"":f;if(Jn(x),x==="files"&&eo(),x==="members"){let N=0;for(const S of zs.current)String(S.sender||"")==="hub"&&(S.seq||0)>N&&(N=S.seq||0);Br.current=N,hr(),ya()}x==="leaderboard"&&Ji(wn),x==="desk"&&he()}function Ji(f){const x=P.current;ba(null),ll(""),lr(""),cr(null),fs(""),(f==="hub"?i.reputation_hub():i.reputation(z)).then(S=>{x===P.current&&ba(S)}).catch(S=>{if(x!==P.current)return;const R=Number((S==null?void 0:S.status)||0);ll(R===404||R===403?"Reputation ships with the next hub update — relaunch the hub (agora ≥ 0.12.7) and reopen this drawer.":String((S==null?void 0:S.message)||S||"failed to load leaderboard"))})}function Qi(f){const x=ms===f?"":f;if(lr(x),cr(null),fs(""),!x||wn==="hub")return;const N=P.current;i.reputation_votes(z,x).then(S=>{N===P.current&&cr(S)}).catch(S=>{N===P.current&&(cr(null),fs(`votes list failed: ${String((S==null?void 0:S.message)||S||"fetch failed")}`))})}const[ni,Yi]=h.useState(""),[ta,si]=h.useState("");h.useEffect(()=>{if(!ta)return;const f=setTimeout(()=>si(""),6e3);return()=>clearTimeout(f)},[ta]);async function Ea(f){if(ta!==f.id){si(f.id);return}si("");try{const x=Array.isArray(f.pending_asks)?f.pending_asks.filter(Boolean):[];await i.post_message(f.channel,{body:`Declined on the record by ${(E==null?void 0:E.seat)||"operator"} — closing without a substantive answer.`,status:"reply",reply_to:f.id,to:f.sender?[f.sender]:void 0,...x.length?{answers:x}:{}}),te(N=>{const S=N[f.channel];if(!(S!=null&&S.has(f.seq)))return N;const R=new Set(S);return R.delete(f.seq),{...N,[f.channel]:R}})}catch(x){B(String((x==null?void 0:x.message)||x||"decline failed"))}}const pr=h.useRef({});function Xi(f){const x=f.ratings;return x?Xb(x,pr.current[f.id]):null}async function _l(f,x){var R,ce;const N=(E==null?void 0:E.seat)||"";if(!f||!N||ni)return;const S=zs.current.find(V=>V.id===f)||((R=Ra.current)==null?void 0:R.find(V=>V.id===f));if(S){Yi(`${f}:${x}`),fs("");try{const V=((ce=Xi(S))==null?void 0:ce.mine)??0;V===x?await i.unrate_message(z,f):await i.rate_message(z,f,x),pr.current[f]=V===x?0:x}catch(V){fs(String((V==null?void 0:V.message)||V||"rating failed"))}finally{Yi("")}}}async function Zi(f,x,N){if(!dr){Oi(`${f}:${x}:${N}`),fs("");try{await i.rate(z,f,x,N,Xr.trim()),ur("");const S=P.current,[R,ce]=await Promise.all([i.reputation(z),i.reputation_votes(z,f)]);S===P.current&&(ba(R),cr(ce))}catch(S){fs(String((S==null?void 0:S.message)||S||"vote failed"))}finally{Oi("")}}}function eo(){const f=P.current;Zr(null),ka(""),sn(""),i.fs_list(z).then(x=>{f===P.current&&Zr(x)}).catch(x=>{f===P.current&&ka(String((x==null?void 0:x.message)||x||"failed to list files"))})}async function _r(f){const x=P.current,N=zr(f.path,"text/markdown"),S=`${f.updated_by||"?"} · ${Bo(f.updated_at)} · v${f.version}`;Kt({name:f.path,mode:N==="image"?"text":N,meta:S,loading:!0});try{const R=await i.fs_read(z,f.path);if(x!==P.current)return;const ce=zr(f.path,R.mime);Kt({name:f.path,mode:ce==="image"?"text":ce,text:xc(R.content),content_type:R.mime,meta:S,loading:!1})}catch(R){if(x!==P.current)return;Kt({name:f.path,mode:"text",meta:S,error:String((R==null?void 0:R.message)||R||"failed to read file")})}}const Qn=h.useRef(null);function gr(){const f=Qn.current,x=zs.current;if(!f||!x.length)return;if(f.message_id?x.some(S=>S.id===f.message_id):!1){Qn.current=null,requestAnimationFrame(()=>{const S=document.getElementById(`hubmsg-${f.message_id}`);S==null||S.scrollIntoView({block:"center"}),S==null||S.classList.add("hit"),setTimeout(()=>S==null?void 0:S.classList.remove("hit"),2500)});return}if(f.seq&&Number.isFinite(f.seq)){const S=P.current,R=f.seq;Qn.current={...f,seq:void 0},i.messages(z,{since:Math.max(0,R-3),limit:10}).then(ce=>{S!==P.current||!ce.length||ct(V=>{const we=new Set(V.map(Fe=>Fe.id)),Pe=ce.filter(Fe=>!we.has(Fe.id));return Pe.length?[...V,...Pe].sort((Fe,We)=>(Fe.seq||0)-(We.seq||0)):V})}).catch(()=>{})}}h.useEffect(()=>{var S;if(!a.focus)return;const{channel:f,message_id:x,seq:N}=a.focus;(S=a.on_focus_consumed)==null||S.call(a),f&&(Qn.current={message_id:x,seq:N},De("thread"),f===z?gr():be(f))},[a.focus]),h.useEffect(()=>{gr()},[Ue]),h.useEffect(()=>{if(Et!=="members"||!z)return;let f=0,x="";for(const S of Ue){if(S.channel&&S.channel!==z||String(S.sender||"")!=="hub")continue;const R=`${String(S.title||"")} ${String(S.body||"")}`;/\b(joined|left|kicked|banned|archived|reopened)\b/i.test(R)&&(S.seq||0)>f&&(f=S.seq||0,x=R)}if(!f||f<=Br.current)return;const N=P.current;i.members(z).then(S=>{N===P.current&&(Br.current=f,Qs(S),ar(""),It(z,S))}).catch(()=>{}),/\b(kicked|banned)\b/i.test(x)&&i.list_blocks(z).then(S=>{N===P.current&&As(S)}).catch(()=>{})},[Ue,Et,z]);const[ai,ri]=h.useState(null),ii=h.useRef(0);h.useEffect(()=>{if(ri(null),ii.current=0,!z)return;const f=P.current;i.fs_list(z).then(x=>{f===P.current&&ri(new Set(x.map(N=>String(N.path||"")).filter(Boolean)))}).catch(()=>{f===P.current&&ri(null)})},[z]),h.useEffect(()=>{const f=Ue.reduce((N,S)=>{if(S.channel&&S.channel!==z)return N;const R=String(S.title||"");return(R.startsWith("fs:put")||R.startsWith("fs:delete"))&&(S.seq||0)>N?S.seq||0:N},0);if(!f||f<=ii.current)return;const x=P.current;i.fs_list(z).then(N=>{x===P.current&&(ii.current=f,ri(new Set(N.map(S=>String(S.path||"")).filter(Boolean))))}).catch(()=>{})},[Ue,z]);async function to(f){const x=P.current,N=zr(f,"text/markdown");Kt({name:f,mode:N==="image"?"text":N,loading:!0});try{const S=await i.fs_read(z,f);if(x!==P.current)return;const R=zr(f,S.mime),ce=S.updated_by?`${S.updated_by} · ${Bo(S.updated_at)} · v${S.version??"?"}`:void 0;Kt({name:f,mode:R==="image"?"text":R,text:xc(S.content),content_type:S.mime,meta:ce,loading:!1})}catch(S){if(x!==P.current)return;Kt({name:f,mode:"text",error:String((S==null?void 0:S.message)||S||"failed to read file")+" — the file may have been rewritten under another path; check the Files drawer"})}}async function Ta(f,x){const N=P.current,S=i.attachment_url(f,x.id),R=zr(x.filename,x.content_type);if(R==="image"){Kt({name:x.filename,mode:"image",url:S,content_type:x.content_type,size:x.size});return}if(R==="md"||R==="text"){if(x.size>Yo){Kt({name:x.filename,mode:"download",url:S,content_type:x.content_type,size:x.size,error:`too large to preview inline (${Vn(x.size)} > ${Vn(Yo)}) — download to view`});return}Kt({name:x.filename,mode:R,url:S,content_type:x.content_type,size:x.size,loading:!0});try{const ce=await fetch(S);if(!ce.ok)throw new Error(`fetch failed (${ce.status})`);const V=await ce.text();if(N!==P.current)return;Kt({name:x.filename,mode:R,url:S,content_type:x.content_type,size:x.size,text:xc(V)})}catch(ce){if(N!==P.current)return;Kt({name:x.filename,mode:"download",url:S,content_type:x.content_type,size:x.size,error:String((ce==null?void 0:ce.message)||ce||"failed to load")})}return}Kt({name:x.filename,mode:"download",url:S,content_type:x.content_type,size:x.size})}async function yr(f,x,N="channel"){if(!Gt){us(`${N}:${x}:${f}`),Pn("");try{N==="hub"?x==="unblock"?await i.hub_unblock(f):await i.hub_block(f,x==="kick"?{seconds:3600,reason:"hub kick (Continuum Team page)"}:{reason:"hub ban (Continuum Team page)"}):x==="unblock"?await i.unblock(z,f):await i.block(z,f,x==="kick"?{seconds:3600,reason:"kicked by the operator (Continuum Team page)"}:{reason:"banned by the operator (Continuum Team page)"}),ut(`${N==="hub"?"hub ":""}${x} → ${f} applied.`),setTimeout(()=>ut(""),3e3);const S=P.current,R=await i.members(z).catch(()=>null);R&&S===P.current&&Qs(R);const ce=await i.list_blocks().catch(()=>null);ce&&S===P.current&&As(ce)}catch(S){Pn(String((S==null?void 0:S.message)||S||"moderation refused"))}finally{us("")}}}async function gl(f){if(!Gt){us(`retire:${f}`),Pn("");try{await i.retire_agent(f,"decommissioned via Continuum Team page"),Xt(""),ut(`${f} retired (decommissioned — not banned).`),setTimeout(()=>ut(""),3500);const x=P.current,N=await i.members(z).catch(()=>null);N&&x===P.current&&Qs(N);const S=await i.retired_agents().catch(()=>null);S&&x===P.current&&va(S)}catch(x){const N=x==null?void 0:x.status,S=String((x==null?void 0:x.message)||x||"");N===404||/not found|hub_route_not_allowed/i.test(S)?(ut("Agent retire ships with the next hub update — this control is wired and ready for it."),setTimeout(()=>ut(""),6e3)):Pn(S||"retire refused")}finally{us("")}}}async function yl(f){if(!Gt){us(`unretire:${f}`),Pn("");try{await i.unretire_agent(f),Xt(""),ut(`${f} un-retired — it can rejoin channels explicitly.`),setTimeout(()=>ut(""),3500);const x=await i.retired_agents().catch(()=>null);x&&va(x)}catch(x){Pn(String((x==null?void 0:x.message)||x||"un-retire refused"))}finally{us("")}}}async function Rc(f){if(!Gt){us(`delete:${f}`),Pn("");try{await i.delete_agent(f),Xt(""),ut(`${f} deleted from the hub — off every roster and board; its id stays reserved.`),setTimeout(()=>ut(""),3500);const x=await i.retired_agents().catch(()=>null);x&&va(x)}catch(x){const N=String((x==null?void 0:x.message)||x);Pn((x==null?void 0:x.status)===404||/not found|allowlist/i.test(N)?"Delete needs the updated hub/console (0.12.41+) — restart the stack to pick it up.":/409|active/i.test(N)?`${f} is still active — retire it first, then delete.`:N||"delete refused")}finally{us("")}}}async function vl(f){if(!cn){_n(!0),Pn("");try{let x={state:f},N;try{const S=await i.channel_meta(z);S&&typeof S.value=="object"&&S.value&&(x={...S.value,state:f}),typeof(S==null?void 0:S.version)=="number"&&(N=S.version)}catch{}await i.put_channel_meta(z,x,N),ut(f==="closed"?"Channel closed (member posts refused until reopened).":"Channel reopened."),setTimeout(()=>ut(""),3500),hr(),hs()}catch(x){Pn(String((x==null?void 0:x.message)||x||"channel state change refused"))}finally{_n(!1)}}}const[Mc,xl]=h.useState("");async function Pc(f){if(!cn){_n(!0),B("");try{await i.leave(f),xl(""),z===f&&be(""),await hs(),ut("Direct message removed from your list."),setTimeout(()=>ut(""),3e3)}catch(x){B(String((x==null?void 0:x.message)||x||"leave refused"))}finally{_n(!1)}}}const[Yn,na]=h.useState("");async function bl(f){if(!cn){_n(!0),B("");try{await i.archive(f),na(""),z===f&&be(""),await hs(),ut(`Channel #${f} archived (history preserved).`),setTimeout(()=>ut(""),3500)}catch(x){const N=String((x==null?void 0:x.message)||x||"");(x==null?void 0:x.status)===404||/not found|hub_route_not_allowed/i.test(N)?(na(""),ut("Channel archive ships with the next hub update — this control is wired and ready for it."),setTimeout(()=>ut(""),6e3)):B(N||"archive refused")}finally{_n(!1)}}}async function no(){const f=$n.name.trim();if(!(!f||cn)){_n(!0),B("");try{await i.create_channel(f,$n.is_private),Ms({open:!1,name:"",is_private:!1}),await hs(),be(f),ut(`Channel #${f} created.`),setTimeout(()=>ut(""),3e3)}catch(x){B(String((x==null?void 0:x.message)||x||"channel create refused"))}finally{_n(!1)}}}async function so(f,x){if(!l)throw new Error("AI advisor is not available");return l(f,x)}async function wl(f){if(!u)return;const x=f.root.id,N=P.current,S=f.replies.length+1;xa(R=>{var ce;return{...R,[x]:{busy:!0,text:((ce=R[x])==null?void 0:ce.text)||"",error:"",count:S}}});try{const R=kh([f.root,...f.replies]),ce=`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.
119
+
120
+ THREAD TRANSCRIPT:
121
+ ${R.text}`,V=await so(ce,[]);if(N!==P.current)return;const we=Sh(R.report);xa(Pe=>({...Pe,[x]:{busy:!1,text:V,error:"",count:S,window:we}}))}catch(R){if(N!==P.current)return;xa(ce=>({...ce,[x]:{busy:!1,text:"",error:String((R==null?void 0:R.message)||R||"summary failed"),count:S}}))}}async function oi(f){const x=f.trim();if(!x||Zs||!u)return;const N=P.current;Jn("assistant"),Na(!0),Ui(""),Fi(S=>[...S,{role:"user",content:x}]);try{const S=kh(Ue);ul(Sh(S.report));const R=`You are the operator's analyst for the agora hub channel #${z}. 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.
122
+
123
+ CHANNEL TRANSCRIPT (window):
124
+ ${S.text}
125
+
126
+ QUESTION: ${x}`,ce=await so(R,Ps);if(N!==P.current)return;Fi(V=>[...V,{role:"assistant",content:ce}])}catch(S){if(N!==P.current)return;Ui(String((S==null?void 0:S.message)||S||"assistant failed"))}finally{N===P.current&&Na(!1)}}const[li,jl]=h.useState(""),[ps,ci]=h.useState("");async function vr(f){if(!Ks){Es(!0),B("");try{await i.retract_message(z,f.id),ci(""),ut(`#${f.seq} retracted — readers see a tombstone, the words are gone from every agent-facing read.`),setTimeout(()=>ut(""),4e3),await ea(z,{background:!0})}catch(x){const N=String((x==null?void 0:x.message)||x||"retract failed");B(/404|not found/i.test(N)?"Retraction ships with the hub's next bounce (0.12.16) — the running hub predates the verb. Nothing was changed.":N)}finally{Es(!1)}}}async function ao(f){if(!Ks){Es(!0),B("");try{const x=vh(z,vt);await i.post_message(z,{body:"Resolved.",status:"resolved",to:x?[x]:void 0,reply_to:f.id}),jl(""),ut(`Marked #${f.seq} resolved.`),setTimeout(()=>ut(""),3e3),await ea(z,{background:!0})}catch(x){B(String((x==null?void 0:x.message)||x||"Resolve failed"))}finally{Es(!1)}}}async function ro(f){if(!f||!f.length||Ee)return;const x=Array.from(f);if(mt.length+x.length>Fo){B(`At most ${Fo} attachments per message.`);return}const N=x.find(V=>V.size>Th);if(N){B(`"${N.name}" is ${Vn(N.size)} — the limit is ${Vn(Th)}.`);return}const S=P.current,R=z;tt(!0),B("");let ce=0;try{for(const V of x){const we=await i.upload_attachment(R,V);if(S!==P.current||z!==R)return;ft(Pe=>[...Pe,we]),ce+=1}}catch(V){const we=V==null?void 0:V.status,Pe=String((V==null?void 0:V.message)||V||"");if(we===404||/not found|hub_route_not_allowed/i.test(Pe))ut("Attachments ship with the next hub update — the composer control is wired and ready for it."),setTimeout(()=>ut(""),6e3);else{const Fe=x.length>1?` (${ce} of ${x.length} attached before this)`:"";B(`${Pe||"attachment upload failed"}${Fe}`)}}finally{tt(!1),ht.current&&(ht.current.value="")}}function ui(f){var N;Cn(f);const x=((N=f.data)==null?void 0:N.asks)||[];tr(x.length===1?{[x[0].id]:!0}:{}),ls(""),Ce("fyi")}function sa(){Cn(null),tr({}),ls("")}async function io(f){const{title:x,members:N}=ud(f);if(!N.length){B("/group: no @mentions found — usage: /group fix the voice outage @gateway @core");return}const S=x||`focused work with ${N.join(", ")}`;await lo({title:S,members:N})}async function oo(f,x,N){const S=[],R=[];for(const ce of N)try{const V=await fetch(i.attachment_url(f,ce.id));if(!V.ok)throw new Error(`fetch ${V.status}`);const we=await V.blob(),Pe=new File([we],ce.filename||"attachment",{type:ce.content_type||we.type||"application/octet-stream"}),Fe=await i.upload_attachment(x,Pe);S.push({id:Fe.id,filename:Fe.filename||ce.filename})}catch(V){R.push(`${ce.filename||ce.id.slice(0,8)} (${String((V==null?void 0:V.message)||V)})`)}return{migrated:S,att_failed:R}}async function xr(f,x,N){try{const S=await i.create_invite(f,x);return await i.send_dm(x,{title:`invite to ${f}${N?`: ${N}`:""}`.slice(0,120),body:`You are invited to '${f}'${N?` — ${N}`:""}. Join with join_channel(channel='${f}', invite_token='${S}'), read the recent messages, and work the topic THERE.`}),null}catch(S){return String((S==null?void 0:S.message)||S)}}async function kl(f){var x,N;if(!(!z||!f)){or(!0),Kn("");try{const S=Mt&&typeof Mt=="object"&&"meta"in Mt?String(((x=Mt.meta)==null?void 0:x.purpose)||""):"",R=!!((N=Dn.current.find(V=>V.name===z))!=null&&N.private);let ce=null;if(R)ce=await xr(z,f,S||void 0);else try{await i.send_dm(f,{title:`join ${z}${S?`: ${S}`:""}`.slice(0,120),body:`You are invited to '${z}' (public)${S?` — ${S}`:""}. Join with join_channel(channel='${z}'), read the recent messages, and work the topic THERE.`})}catch(V){ce=String((V==null?void 0:V.message)||V)}ce?Kn(ce.includes("outside the Team page allowlist")?"Invites need the updated console server — one stack restart activates them; nothing was sent.":`Invite failed: ${ce}`):(Kn(`Invited @${f} — join pointer DM'd.`),Ii(""),zi(z,[f]))}finally{or(!1),setTimeout(()=>Kn(""),8e3)}}}async function Sl(f,x){var N;try{const S=ud(x).members;if(!S.length)return;const R=await i.members(f),ce=new Set(R.map(We=>String(We.agent_id||""))),V=S.filter(We=>!ce.has(We)&&Rs.includes(We)&&We!==vt);if(!V.length)return;const we=!!((N=Dn.current.find(We=>We.name===f))!=null&&N.private),Pe=[],Fe=[];for(const We of V)if(we){const $t=await xr(f,We);$t?Fe.push(`${We} (${$t})`):Pe.push(We)}else try{await i.send_dm(We,{title:`you were mentioned in #${f}`.slice(0,120),body:`You were mentioned in #${f} (public). Join with join_channel(channel='${f}') and read the recent messages.`}),Pe.push(We)}catch($t){Fe.push(`${We} (${String(($t==null?void 0:$t.message)||$t)})`)}Pe.length&&(zi(f,Pe),ut(`Posted — @${Pe.join(", @")} ${we?"invited":"nudged"} (mentioned, not yet member${Pe.length===1?"":"s"}).`)),Fe.length&&B(Fe.some(We=>We.includes("outside the Team page allowlist"))?"Posted; inviting mentioned non-members needs the updated console server (one stack restart).":`Posted; invite failed for ${Fe.join("; ")}.`)}catch{}}async function lo(f){var ce,V;const{title:x,members:N}=f,S=[...mt],R=z;Es(!0),B("");try{const we=new Set(Dn.current.map(xt=>xt.name)),Pe=md(x,we);let Fe=[],We=[],$t=!1;try{const xt=await i.create_group({name:Pe,members:N,purpose:x,opening_post:((ce=f.opening_body)==null?void 0:ce.trim())||x,private:!0});$t=!0,Fe=Array.isArray(xt==null?void 0:xt.invited)?xt.invited.map(String):N,We=Array.isArray(xt==null?void 0:xt.failed)?xt.failed.map(it=>typeof it=="string"?it:`${(it==null?void 0:it.agent)||(it==null?void 0:it.member)||(it==null?void 0:it.peer)||"?"} (${String((it==null?void 0:it.error)||(it==null?void 0:it.detail)||"failed")})`):[]}catch(xt){const it=String((xt==null?void 0:xt.message)||xt||"");if(!((xt==null?void 0:xt.status)===404||it.includes("outside the Team page allowlist")||it.includes("Not Found")))throw xt;try{await i.create_invite("__group-preflight__",N[0])}catch(gt){if(String((gt==null?void 0:gt.message)||gt).includes("outside the Team page allowlist")){B("/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 i.create_channel(Pe,!0),await i.put_channel_meta(Pe,{purpose:x},0);for(const gt of N)try{const qe=await i.create_invite(Pe,gt);await i.send_dm(gt,{title:`invite to ${Pe}: ${x}`.slice(0,120),body:`You are invited to '${Pe}' — focused room: ${x}. Join with join_channel(channel='${Pe}', invite_token='${qe}'), read the opening post, and work the topic THERE (not in commons).`}),Fe.push(gt)}catch(qe){We.push(`${gt} (${String((qe==null?void 0:qe.message)||qe)})`)}}const{migrated:zt,att_failed:jn}=await oo(R,Pe,S);$t?zt.length&&await i.post_message(Pe,{body:"Attachments carried over from the create request.",status:"fyi",attachments:zt}):await i.post_message(Pe,{body:((V=f.opening_body)==null?void 0:V.trim())||x,title:x.slice(0,120),status:"open",attachments:zt.length?zt:void 0}),zi(Pe,Fe),ut(`Room '${Pe}' created — private, ${Fe.length} invited${Fe.length?`: ${Fe.join(", ")}`:""}.`+(zt.length?` ${zt.length} attachment(s) carried over.`:"")+(We.length?` Invite FAILED for ${We.join("; ")}.`:"")),We.length&&B(`Some invites failed — ${We.join("; ")}. Mint them again from the room's Members drawer or re-run /group.`),jn.length&&B(`Attachment carry-over failed for ${jn.join("; ")} — the room and post were created; re-attach in the new room.`),Ve(""),at(""),jt(""),Ce("fyi"),ft([]),delete nn.current[z],qo(nn.current),await hs(),be(Pe),setTimeout(()=>ut(""),6e3)}catch(we){B(`group creation failed: ${String((we==null?void 0:we.message)||we)}`)}finally{Es(!1)}}async function co(){var ce;const f=de.trim(),x=mt.length>0,N=!rt&&!z.startsWith("dm:")&&ye==="group";if(!f&&!x&&!N||Ks||!z)return;if(N){const V=dd(_t);if(!V.length){B("Group needs at least one member — write their names like: @entity @assistant");return}const we=et.trim()||(f?f.split(`
127
+ `)[0].slice(0,80):`focused work with ${V.join(", ")}`);await lo({title:we,members:V,opening_body:f});return}if(/^\/assistant(?=\s|$)/i.test(f)){if(!u){B("AI advisor is not configured — connect a gateway or inject an advisor.");return}const V=f.replace(/^\/assistant/i,"").trim();Ve(""),V?oi(V):Jn("assistant");return}if(/^\/group(?=\s|$)/i.test(f)){await io(f.replace(/^\/group/i,"").trim());return}if(/^\//.test(f)){B(`Unknown command "${f.split(/\s/)[0]}" — only /assistant and /group are supported. Remove the leading "/" to post this as a message.`);return}const S=Object.entries(Cs).filter(([,V])=>V).map(([V])=>V),R=z.startsWith("dm:");if(rt&&(((ce=rt.data)==null?void 0:ce.asks)||[]).length&&!S.length&&$s!=="void_reply"){ls("void_reply");return}if(!rt&&!R&&ye==="ask"&&!et.trim()&&$s!=="untitled_open"){ls("untitled_open");return}if(!rt&&!R&&ye==="dm"&&!Je.trim()){B("Pick a recipient for the direct message.");return}Es(!0),B("");try{if(!rt&&!R&&ye==="dm"){const V=Je.trim(),we=[...mt],Pe=z;await i.send_dm(V,{body:f||(we.length?`(${we.length} attachment${we.length===1?"":"s"})`:f),title:et.trim()||void 0});const Fe=`dm:${[vt,V].sort().join("--")}`;if(we.length){const{migrated:We,att_failed:$t}=await oo(Pe,Fe,we);We.length&&await i.post_message(Fe,{body:"",to:[V],attachments:We}),ut(`DM sent to ${V}${We.length?` with ${We.length} attachment(s)`:""}.`),$t.length&&B(`Attachment carry-over failed for ${$t.join("; ")} — the DM text was sent; re-attach inside the conversation.`)}else ut(`DM sent to ${V}.`);await hs(),be(Fe)}else{const V=mt.map(Fe=>({id:Fe.id,filename:Fe.filename})),we=R?vh(z,vt):"";R&&!we&&B(`#FALLBACK this dm's pair does not include seat '${vt}' — sent unaddressed (no to-me wake; check the hub seat in Settings).`);const Pe={body:f,title:et.trim()||void 0,status:Db({is_reply:!!rt,in_dm:R,kind:ye}),to:we?[we]:void 0,reply_to:rt==null?void 0:rt.id,answers:rt&&S.length?S:void 0,attachments:V.length?V:void 0};try{await i.post_message(z,Pe)}catch(Fe){if(we&&/address non-members/i.test(String((Fe==null?void 0:Fe.message)||Fe)))await i.post_message(z,{...Pe,to:void 0}),B(`#FALLBACK '${we}' is no longer a member of this dm — message delivered unaddressed (their listener will not get a to-me wake).`);else throw Fe}ut(R?"Sent.":"Posted."),await ea(z,{background:!0}),!R&&f&&Sl(z,f)}Ve(""),at(""),ft([]),Cn(null),tr({}),Ce("fyi"),yt(""),ls(""),delete nn.current[z],qo(nn.current),setTimeout(()=>ut(""),3e3)}catch(V){B(String((V==null?void 0:V.message)||V||"Post failed"))}finally{Es(!1)}}async function Nl(f){if(!(!z||!f||Mi||oe)){Ts(!0);try{await i.ack(z,f),ut(`Marked read to #${f}.`),setTimeout(()=>ut(""),3e3),Ca(Dn.current)}catch(x){B(String((x==null?void 0:x.message)||x||"Ack failed"))}finally{Ts(!1)}}}const En=!!(E!=null&&E.seat_key_present)&&!(A!=null&&A.paused),vt=(E==null?void 0:E.seat)||"",Jt=z.startsWith("dm:"),br=(()=>{if(!Jt)return"";const f=z.slice(3);return vt&&f.startsWith(`${vt}--`)?f.slice(vt.length+2):vt&&f.endsWith(`--${vt}`)?f.slice(0,f.length-vt.length-2):f||z})(),zc=h.useMemo(()=>Ob(Ue),[Ue]),Ds=h.useMemo(()=>({seat:vt,unread_seqs:le[z],unread_snapshot_seqs:Xe==="unread"&&W||void 0,escalated_seqs:ae[z]}),[vt,le,z,Xe,W,ae]),On=h.useMemo(()=>{if(rt)return null;const f=new Set(fe.map(N=>N.name)),x=de.trimStart();if(/^\/group(\s|$)/i.test(x)){const{title:N,members:S}=ud(x.replace(/^\/group/i,"").trim()),R=N||(S.length?`focused work with ${S.join(", ")}`:"");return{name:R?md(R,f):"group",members:S,source:"slash"}}if(ye==="group"&&!z.startsWith("dm:")){const N=dd(_t),S=et.trim()||(N.length?`focused work with ${N.join(", ")}`:"");return{name:S?md(S,f):"group",members:N,source:"kind"}}return null},[de,rt,fe,ye,_t,et,z]),_s=h.useMemo(()=>Ab(Ue),[Ue]),aa=h.useMemo(()=>yh(_s,Xe,Ds),[_s,Xe,Ds]),[Aa,Ct]=h.useState("recency"),[ra,La]=h.useState(null),Ra=h.useRef(null);h.useEffect(()=>{Ra.current=ra},[ra]);const[uo,wr]=h.useState("");function jr(){const f=P.current;La(null),wr(""),i.messages(z,{sort:"votes",limit:50}).then(x=>{f===P.current&&La(x)}).catch(x=>{if(f!==P.current)return;const N=String((x==null?void 0:x.message)||x);wr((x==null?void 0:x.status)===400||(x==null?void 0:x.status)===404||/allowlist/i.test(N)?"Top-voted needs the next hub update (this hub predates sort=votes) — Recency still works.":N)})}function di(f){Qn.current={message_id:f.id,seq:f.seq},Ct("recency"),requestAnimationFrame(()=>gr())}const[ia,mo]=h.useState(""),[Ma,Ic]=h.useState("all"),[Tn,Pa]=h.useState(""),[An,za]=h.useState(null),[kr,Xn]=h.useState(null),Fn=h.useRef(0);function mi(f,x,N){if(!f&&!N)return;const S=++Fn.current;Xn(null),za({q:f,report:null,error:"",busy:!0}),i.search({q:f,channel:x==="channel"&&z?[z]:void 0,rated:N||void 0,sort:!f&&N?"votes":void 0}).then(R=>{S===Fn.current&&za({q:f,report:R,error:"",busy:!1})}).catch(R=>{if(S!==Fn.current)return;const ce=String((R==null?void 0:R.message)||R);za({q:f,report:null,busy:!1,error:(R==null?void 0:R.status)===404||/allowlist/i.test(ce)?"Search needs the next hub update (this hub predates search-grouped) — everything else still works.":ce})})}function Cl(f){mi(f.trim(),Ma,Tn)}function fo(){Fn.current+=1,za(null),Xn(null),Pa("")}function Dc(f,x){const N=(An==null?void 0:An.q)||"";if(!N&&!Tn)return;const S=++Fn.current;Xn({label:f,kind:x,hits:[],total:0,cursor:null,busy:!0,error:""}),i.search({q:N,kind:x,sort:"recent",limit:50,rated:Tn||void 0,channel:Ma==="channel"&&z?[z]:void 0}).then(R=>{if(S!==Fn.current)return;const ce=gs(R,x);Xn({label:f,kind:x,hits:ce.hits,total:ce.total,cursor:R.next_cursor??null,busy:!1,error:""})}).catch(R=>{S===Fn.current&&Xn({label:f,kind:x,hits:[],total:0,cursor:null,busy:!1,error:String((R==null?void 0:R.message)||R)})})}function ho(){const f=kr,x=(An==null?void 0:An.q)||"";if(!f||!f.cursor||f.busy||!x&&!Tn)return;const N=Fn.current;Xn({...f,busy:!0}),i.search({q:x,kind:f.kind,sort:"recent",limit:50,cursor:f.cursor,rated:Tn||void 0,channel:Ma==="channel"&&z?[z]:void 0}).then(S=>{if(N!==Fn.current)return;const R=gs(S,f.kind);Xn(ce=>ce&&ce.kind===f.kind?{...ce,hits:[...ce.hits,...R.hits],cursor:S.next_cursor??null,busy:!1}:ce)}).catch(S=>{N===Fn.current&&Xn(R=>R&&R.kind===f.kind?{...R,busy:!1,error:String((S==null?void 0:S.message)||S)}:R)})}function gs(f,x){const N=yc.find(R=>R.kind===x),S=N?f[N.id]:void 0;return S?{hits:S.hits||[],total:S.total||0}:{hits:[],total:0}}function $l(f){const x=String(f.channel||"");x&&(Qn.current={message_id:f.kind==="message"?f.ref:void 0,seq:f.seq??void 0},fo(),Ct("recency"),x===z?gr():be(x))}async function Ia(f){const x=String(f.channel||""),N=String(f.ref||"");if(!x||!N)return;const S=zr(N,"text/markdown");Kt({name:N,mode:S==="image"?"text":S,meta:`#${x}`,loading:!0});try{const R=await i.fs_read(x,N),ce=zr(N,R.mime);Kt({name:N,mode:ce==="image"?"text":ce,text:xc(R.content),content_type:R.mime,meta:`#${x} · ${R.updated_by||"?"} · v${R.version??"?"}`,loading:!1})}catch(R){Kt({name:N,mode:"text",meta:`#${x}`,error:String((R==null?void 0:R.message)||R||"failed to read file")})}}function Zn(f){const x=f.kind==="message"&&!!f.channel,N=f.kind==="file"&&!!f.channel,S=x||N,R=Zb(String(f.snippet||""),f.highlights),ce=f.ratings,V=String(f.channel||""),we=V?V.startsWith("dm:")?V:`#${V}`:"";return e.jsxs("div",{className:`team_search_hit${S?" clickable":""}`,onClick:S?()=>N?void Ia(f):$l(f):void 0,role:S?"button":void 0,title:x?"Open this message in its thread":N?"Open this file":void 0,children:[e.jsxs("div",{className:"team_search_hit_head",children:[f.kind!=="message"?e.jsx("span",{className:"team_search_kind mono",children:f.kind}):null,we?e.jsx("span",{className:"team_search_chan mono",children:we}):null,f.sender?e.jsx("span",{className:"team_search_sender",style:{color:`hsl(${Gd(String(f.sender))}, 60%, 55%)`},children:f.sender}):null,typeof f.seq=="number"&&f.seq>0?e.jsxs("span",{className:"muted mono",children:["#",f.seq]}):null,f.status==="open"||f.status==="blocked"?e.jsx("span",{className:"team_search_status mono",title:"This thread still carries an unresolved obligation",children:f.status}):null,typeof f.thread_hits=="number"&&f.thread_hits>1?e.jsxs("span",{className:"muted",title:"More matches in the same thread",children:[f.thread_hits," in thread"]}):null,ce&&(ce.up||ce.down)?e.jsxs("span",{className:"team_search_tally mono",title:"Standing ±1 ratings on this message (read-only here — vote from the thread)",children:["▲",ce.up," ▽",ce.down]}):null,f.created_at?e.jsx("span",{className:"muted team_search_time",children:Bo(f.created_at)}):null]}),String(f.title||"").trim()?e.jsx("div",{className:"team_search_title",children:f.title}):null,R.length?e.jsx("div",{className:"team_search_snippet",children:R.map((Pe,Fe)=>Pe.hit?e.jsx("mark",{children:Pe.text},Fe):e.jsx(Wt.Fragment,{children:Pe.text},Fe))}):null,!x&&!N&&f.kind!=="agent"?e.jsx("div",{className:"team_search_ref mono muted",children:f.ref}):null]},`${f.kind}:${V}:${f.ref}`)}const Sr=h.useMemo(()=>{let f=0;for(const x of aa)for(const N of[x.root,...x.replies])f=Math.max(f,N.seq||0);return f},[aa]),ys=h.useMemo(()=>{const f={};for(const x of["asks","vigilance","fyi","resolved","to_me"])f[x]=yh(_s,x,Ds).length;return f.unread=Ue.filter(x=>{var N,S;return((N=Ds.unread_seqs)==null?void 0:N.has(x.seq))||((S=Ds.unread_snapshot_seqs)==null?void 0:S.has(x.seq))}).length,f},[_s,Ue,Ds]);function po(){var f,x;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,(f=Mt.channel)!=null&&f.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"]})]}),(x=Mt.meta)!=null&&x.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(os,{className:"md_doc",text:Ko(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})`:""]}),!Jt&&bn!==null?e.jsxs("div",{className:"team_invite_row",children:[e.jsxs("select",{className:"team_compose_control team_invite_select",value:Qr,onChange:N=>Ii(N.target.value),disabled:!!ir,title:"Agents on the hub not yet in this channel",children:[e.jsx("option",{value:"",children:"invite: agent…"}),Rs.filter(N=>!(bn||[]).some(S=>String(S.agent_id||"")===N)).filter(N=>!(Pi[z]||new Set).has(N)).map(N=>e.jsx("option",{value:N,children:N},N))]}),e.jsx("button",{className:"btn",disabled:!Qr||!!ir,title:"Mint a single-use invite token and DM it with the join pointer",onClick:()=>void kl(Qr),children:ir?"Inviting…":"Invite"})]}):null,ds?e.jsx("div",{className:"muted team_note",children:ds}):null,(()=>{const N=[...Pi[z]||[]].filter(S=>!(bn||[]).some(R=>String(R.agent_id||"")===S));return!N.length||bn===null?null:N.map(S=>e.jsxs("div",{className:"team_member_row team_member_invited",children:[e.jsx("span",{className:"team_avatar",style:Qa(S),"aria-hidden":"true",children:(S[0]||"?").toUpperCase()}),e.jsx("span",{className:"team_member_id",children:S}),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:${S}`))})(),Wr?e.jsxs("div",{className:"muted team_note",children:["Members list unavailable (",Wr.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(N=>{const S=String(N.agent_id||"");return S?e.jsxs("div",{className:"team_member_row",children:[e.jsx("span",{className:"team_avatar",style:Qa(S),"aria-hidden":"true",children:(S[0]||"?").toUpperCase()}),e.jsx("span",{className:"team_member_id",title:String(N.about||""),children:S}),S!==vt&&!Jt?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 yr(S,"kick"),children:Gt===`channel:kick:${S}`?"kicking…":"kick"}),e.jsx("button",{className:`team_row_expand ${Vt===`channel:ban:${S}`?"team_danger":""}`,disabled:!!Gt,title:"Ban: INDEFINITE block from this channel (two clicks — the first arms, the second confirms)",onClick:()=>{Vt===`channel:ban:${S}`?(Xt(""),yr(S,"ban")):Xt(`channel:ban:${S}`)},children:Gt===`channel:ban:${S}`?"banning…":Vt===`channel:ban:${S}`?"confirm ban":"ban"}),e.jsx("button",{className:`team_row_expand ${Vt===`hub:ban:${S}`?"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:${S}`?(Xt(""),yr(S,"ban","hub")):Xt(`hub:ban:${S}`)},children:Gt===`hub:ban:${S}`?"hub-banning…":Vt===`hub:ban:${S}`?"confirm hub ban":"hub ban"}),e.jsx("button",{className:`team_row_expand ${Vt===`retire:${S}`?"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:${S}`?(Xt(""),gl(S)):Xt(`retire:${S}`)},children:Gt===`retire:${S}`?"retiring…":Vt===`retire:${S}`?"confirm retire":"retire"})]}):S===vt?e.jsx("span",{className:"chip mono ok",style:{marginLeft:"auto"},children:"you"}):null]},S):null})]}),!Jt&&Kr&&Kr.length?e.jsxs("div",{className:"team_members",children:[e.jsxs("div",{className:"muted team_note",style:{marginBottom:4},children:["Blocked (",Kr.length,")"]}),Kr.map(N=>{const S=String(N.agent_id||N.agent||"");if(!S)return null;const R=String(N.scope||""),ce=R==="hub",V=ce?"hub":"channel",we=N.expires_at?` · until ${new Date(Number(N.expires_at)*1e3).toLocaleString()}`:" · indefinite",Pe=ce?"hub-wide":`#${R}`;return e.jsxs("div",{className:"team_member_row",children:[e.jsx("span",{className:"team_avatar",style:Qa(S),"aria-hidden":"true",children:(S[0]||"?").toUpperCase()}),e.jsxs("span",{className:"team_member_id",title:String(N.reason||""),children:[S,e.jsxs("span",{className:"muted team_note",children:[Pe,we]})]}),e.jsx("span",{className:"team_member_actions",children:e.jsx("button",{className:"team_row_expand",disabled:!!Gt,title:ce?"Lift this HUB-WIDE block (the agent can re-register and rejoin)":"Lift this channel block (the agent can rejoin/post again)",onClick:()=>void yr(S,"unblock",V),children:Gt===`${V}:unblock:${S}`?"unblocking…":"unblock"})})]},`blocked:${R}:${S}`)})]}):null,!Jt&&Ls&&Ls.length?e.jsxs("div",{className:"team_members",children:[e.jsxs("div",{className:"muted team_note",style:{marginBottom:4},children:["Retired agents (",Ls.length,")"]}),Ls.map(N=>{const S=String(N.id||"");if(!S)return null;const R=N.retired_at?` · ${new Date(Number(N.retired_at)*1e3).toLocaleDateString()}`:"";return e.jsxs("div",{className:"team_member_row",children:[e.jsx("span",{className:"team_avatar",style:Qa(S),"aria-hidden":"true",children:(S[0]||"?").toUpperCase()}),e.jsxs("span",{className:"team_member_id",title:String(N.reason||""),children:[S,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:${S}`?"team_danger":""}`,disabled:!!Gt,title:"Un-retire: restore this agent's access (it rejoins channels explicitly). Two clicks to confirm.",onClick:()=>{Vt===`unretire:${S}`?(Xt(""),yl(S)):Xt(`unretire:${S}`)},children:Gt===`unretire:${S}`?"un-retiring…":Vt===`unretire:${S}`?"confirm un-retire":"un-retire"}),e.jsx("button",{className:`team_row_expand ${Vt===`delete:${S}`?"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:${S}`?(Xt(""),Rc(S)):Xt(`delete:${S}`)},children:Gt===`delete:${S}`?"deleting…":Vt===`delete:${S}`?"confirm delete":"delete"})]})]},`retired:${S}`)})]}):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:"ⓘ"})]}),Js===null?e.jsx("span",{className:"muted team_note",children:Hr||"Loading delegations…"}):e.jsxs(e.Fragment,{children:[Js.length===0?e.jsx("span",{className:"muted team_note",children:"No active delegate."}):null,Js.map(N=>{const S=String(N.agent_id||""),R=Array.isArray(N.powers)?N.powers.map(String):[],ce=Number(N.expires_at||N.expires||0);return e.jsxs("div",{className:"team_delegation_row",children:[e.jsx("span",{className:"team_avatar",style:Qa(S),"aria-hidden":"true",children:(S[0]||"?").toUpperCase()}),e.jsx("span",{className:"team_member_id",children:S}),e.jsxs("span",{className:"team_delegation_powers mono",title:String(N.note||""),children:[R.join(" + ")||"(no powers?)",ce?` · until ${new Date(ce*1e3).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}`:""]}),e.jsx("button",{className:`team_row_expand ${Vt===`resign:${S}`?"team_danger":""}`,disabled:hn,title:"Resign this delegate: the grant is revoked hub-wide, on the record (two clicks)",onClick:()=>{Vt===`resign:${S}`?(Xt(""),rr(S)):Xt(`resign:${S}`)},children:hn?"resigning…":Vt===`resign:${S}`?"confirm resign":"resign"})]},S)}),e.jsxs("div",{className:"team_delegation_assign",children:[e.jsxs("select",{className:"team_compose_control team_invite_select",value:pn,onChange:N=>il(N.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(N=>String(typeof N=="string"?N:(N==null?void 0:N.agent_id)||(N==null?void 0:N.id)||"")).filter(N=>N&&N!==vt&&!Js.some(S=>String(S.agent_id)===N)).map(N=>e.jsx("option",{value:N,children:N},N))]}),pn?e.jsxs("div",{className:"team_delegation_powers_pick",children:[pw.map(N=>e.jsxs("label",{className:"team_delegation_power",title:N.help,children:[e.jsx("input",{type:"checkbox",checked:ga.includes(N.id),onChange:S=>ol(R=>S.target.checked?[...R,N.id]:R.filter(ce=>ce!==N.id))}),N.id]},N.id)),e.jsx("button",{className:"btn",disabled:hn||!ga.length,title:ga.length?`Grant ${pn} the powers: ${ga.join(", ")} (7-day TTL, renewable; on the record)`:"Pick at least one power",onClick:()=>void Gr(),children:hn?"Assigning…":"Assign"})]}):null]}),Hr?e.jsx("div",{className:"page_error mono",children:Hr}):null]})]}),Jt?null:e.jsx("div",{className:"team_chan_admin",children:At?String(Mt.state||"open")==="open"?e.jsx("button",{className:"btn",disabled:cn,title:"Close this channel — member posts refuse until reopened (owner-only; the hub authorizes)",onClick:()=>void vl("closed"),children:cn?"Closing…":"Close channel"}):e.jsx("button",{className:"btn",disabled:cn,title:"Reopen this channel for member posts",onClick:()=>void vl("open"),children:cn?"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",")."]})}),Jr?e.jsx("div",{className:"page_error mono",children:Jr}):null]}):e.jsx("span",{className:"muted team_note",children:"Open a channel to see its members."})}function Oc(f){var N;const x=((N=f.data)==null?void 0:N.attachments)||f.attachments||[];return x.length?e.jsx("div",{className:"team_attachments",children:x.map((S,R)=>{const ce=`${S.id}:${R}`,V=i.attachment_url(f.channel,S.id);return mw.has(String(S.content_type||"").toLowerCase())?e.jsxs("button",{className:"team_attach_img_link",title:`${S.filename} · ${Vn(S.size)} — click to preview`,onClick:()=>void Ta(f.channel,S),children:[e.jsx("img",{className:"team_attach_img",src:V,alt:S.filename,loading:"lazy",onError:Pe=>{var $t;const Fe=Pe.currentTarget;Fe.style.display="none";const We=($t=Fe.parentElement)==null?void 0:$t.querySelector(".team_attach_fallback");We&&(We.style.display="inline-flex")}}),e.jsxs("span",{className:"team_attach_chip team_attach_fallback",style:{display:"none"},children:[e.jsx(He,{name:"paperclip",size:11}),e.jsx("span",{className:"team_attach_name",children:S.filename}),e.jsx("span",{className:"muted",children:Vn(S.size)})]})]},ce):e.jsxs("button",{className:"team_attach_chip team_attach_dl",title:`${S.content_type} · ${Vn(S.size)} — click to preview`,onClick:()=>void Ta(f.channel,S),children:[e.jsx(He,{name:"paperclip",size:11}),e.jsx("span",{className:"team_attach_name",children:S.filename}),e.jsx("span",{className:"muted",children:Vn(S.size)})]},ce)})}):null}function Fc(f,x){var we;const N=[],S=String(f.status||"").toLowerCase();(S==="open"||S==="blocked")&&(f.has_resolved_reply===!0||(f.id?zc.has(f.id):!1))?N.push(e.jsx(Hn,{tone:"success",size:"sm",title:"This ask already has a reply from another seat.",children:"answered"},"st")):S==="open"||S==="blocked"?N.push(e.jsx(Hn,{tone:S==="blocked"?"error":"warning",size:"sm",children:S},"st")):S==="resolved"&&x&&N.push(e.jsx(Hn,{tone:"success",size:"sm",children:"resolved"},"st")),f.critical&&N.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 ce=((we=f.data)==null?void 0:we.answers)||[];S==="reply"&&ce.length&&N.push(e.jsxs(Hn,{tone:"success",size:"sm",title:`This reply discharges ask(s) ${ce.join(", ")} of its parent.`,children:["✓ answers ",ce.join(",")]},"dis"));const V=f.to||[];for(const Pe of V.slice(0,2))N.push(e.jsxs(Hn,{tone:"muted",size:"sm",children:["@",Pe]},`to:${Pe}`));return V.length>2&&N.push(e.jsxs(Hn,{tone:"muted",size:"sm",title:V.map(Pe=>`@${Pe}`).join(" "),children:["+",V.length-2]},"to+")),N}function vs(f,x){return e.jsx(Cp,{resetKey:`${f.retracted?1:0}:${(f.body||"").length}:${(f.title||"").length}`,fallback:e.jsx("div",{className:"team_row team_row_broken",id:`hubmsg-${f.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:Lh(f.sender),children:f.sender}),e.jsxs("span",{className:"team_row_meta mono",children:["#",f.seq," · ",Uo(f.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:(f.title?f.title+`
128
+ `:"")+String(f.body||"(no text)")})]})}),children:Nr(f,x)},f.id)}function Nr(f,x){var xt,it,Lt,gt;const N=!!Oe[f.id],S=String(f.body||""),R=x.is_root?vc:$h,ce=S.length>R,V=ce&&!N,we=((xt=f.data)==null?void 0:xt.asks)||[],Pe=!!((it=Ds.unread_seqs)!=null&&it.has(f.seq)),Fe=Xe!=="all"&&Lb(f,Xe,Ds),We=String(f.title||"").trim(),$t=((Lt=S.trim().split(`
129
+ `)[0])==null?void 0:Lt.trim())||"",zt=We&&(We===S.trim()||We===$t),jn=(rt==null?void 0:rt.id)===f.id;return e.jsxs("div",{className:`team_row ${f.sender===vt?"own":""} ${Fe?"hit":""} ${jn?"replying":""} ${Pe?"unread":""} ${f.retracted?"retracted":""}`,id:`hubmsg-${f.id}`,onClick:()=>Ac(f),title:ce?void 0:f.critical?"Click to record the read (critical unpins on it)":void 0,children:[e.jsx("span",{className:"team_avatar",style:Qa(f.sender),"aria-hidden":"true",children:(f.sender[0]||"?").toUpperCase()}),e.jsxs("div",{className:"team_row_main",children:[e.jsxs("div",{className:"team_row_head",children:[(gt=G[f.channel])!=null&&gt.has(f.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 ${ta===f.id?"armed":""}`,title:ta===f.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:qe=>{qe.stopPropagation(),Ea(f)},children:ta===f.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"}):f.read===!1&&x.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:Lh(f.sender),children:f.sender}),Fc(f,x.is_root),(()=>{const qe=Xi(f);return!qe||!qe.up&&!qe.down?null:e.jsxs("span",{className:`team_reaction_tally mono ${qe.mine>0?"pos":qe.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:[qe.up?`▲${qe.up}`:"",qe.up&&qe.down?" ":"",qe.down?`▼${qe.down}`:""]})})(),e.jsxs("span",{className:"team_row_meta mono",title:Bo(f.created_at),children:["#",f.seq," · ",Uo(f.created_at)]})]}),We&&!zt?e.jsx("div",{className:"team_row_title",children:We}):null,e.jsx("div",{className:`team_row_body ${V?x.is_root?"clamp_root":"clamp_reply":""}`,children:e.jsx(sw,{className:"md_doc",text:Ko(Kb(Wb(S),{hub_base:O}))})}),Oc(f),(()=>{var Zt;const qe=Ub(`${String(f.title||"")}
130
+ ${S}`),St=((Zt=f.data)==null?void 0:Zt.attachments)||f.attachments||[],Ot=qe.map(Rt=>({mention:Rt,res:Bb(Rt,ai,St)})).filter(Rt=>Rt.res!==null).filter(Rt=>{var Qt;return!(Rt.res.kind==="attachment"&&String(((Qt=St[Rt.res.attachment_index])==null?void 0:Qt.filename)||"")===Rt.mention)}),Ut=a.on_open_board?ax(`${String(f.title||"")}
131
+ ${S}`):[];return!Ot.length&&!Ut.length?null:e.jsxs("div",{className:"team_fs_chips",children:[Ot.map(({mention:Rt,res:Qt})=>e.jsxs("button",{className:"team_attach_chip team_fs_chip",title:Qt.kind==="fs"?Qt.rewritten?`Opens ${Qt.path} (the mention's path moved — matched by name in #${z}'s files)`:`Open ${Qt.path} from #${z}'s virtual filesystem`:"Opens the file attached to this message (the path in the text belongs to the sender's workspace)",onClick:un=>{un.stopPropagation(),Qt.kind==="fs"?to(Qt.path):Ta(f.channel,St[Qt.attachment_index])},children:[e.jsx(Ah,{}),e.jsx("span",{className:"team_attach_name",children:Rt}),Qt.kind==="attachment"?e.jsx("span",{className:"team_fs_chip_note",children:"attached"}):Qt.rewritten?e.jsx("span",{className:"team_fs_chip_note",children:"moved"}):null]},Rt)),Ut.map(Rt=>e.jsxs("button",{className:"team_attach_chip team_fs_chip team_work_chip",title:`Work item ${Rt} — open the Board filtered to it`,onClick:Qt=>{var un;Qt.stopPropagation(),(un=a.on_open_board)==null||un.call(a,Rt)},children:[e.jsx("span",{className:"team_work_glyph","aria-hidden":!0,children:"⛭"}),e.jsx("span",{className:"team_attach_name mono",children:Rt})]},`w:${Rt}`))]})})(),we.length?e.jsx("div",{className:"team_row_asks",children:we.map(qe=>e.jsxs("span",{className:"team_ask",title:qe.text,children:["ask ",qe.id,": ",qe.text.length>90?qe.text.slice(0,90)+"…":qe.text]},qe.id))}):null,ce?e.jsx("button",{className:"team_row_expand",onClick:qe=>{qe.stopPropagation(),pl(f)},children:N?"collapse":"show more"}):null]}),En?e.jsxs("div",{className:"team_row_rail",children:[f.id&&f.sender!==vt&&f.sender!=="hub"&&!f.retracted?(()=>{const qe=Xi(f);return qe?e.jsxs("span",{className:"team_vote_thumbs",children:[e.jsxs("button",{className:`btn btn_icon team_thumb ${qe.mine>0?"up_on":""}`,title:qe.mine>0?"Withdraw your +1 on this message":"+1 this message",disabled:!!ni,onClick:St=>{St.stopPropagation(),_l(f.id,1)},children:[e.jsx(He,{name:qe.mine>0?"thumbsUpFilled":"thumbsUp",size:13}),qe.up?e.jsx("span",{className:"team_thumb_count",children:qe.up}):null]}),e.jsxs("button",{className:`btn btn_icon team_thumb ${qe.mine<0?"down_on":""}`,title:qe.mine<0?"Withdraw your −1 on this message":"−1 this message",disabled:!!ni,onClick:St=>{St.stopPropagation(),_l(f.id,-1)},children:[e.jsx(He,{name:qe.mine<0?"thumbsDownFilled":"thumbsDown",size:13}),qe.down?e.jsx("span",{className:"team_thumb_count",children:qe.down}):null]})]}):null})():null,$.tts_supported&&f.id?(()=>{const qe=$.tts_playback.key===f.id&&$.tts_playback.status==="playing",St=$.tts_playback.key===f.id&&$.tts_playback.status==="loading";return e.jsx("button",{className:`btn btn_icon ${qe||St?"team_speak_on":""}`,title:qe?"Pause":St?"Synthesizing…":p.enabled?"Read aloud (your voice override)":"Read aloud (gateway voice)","aria-label":qe?"Pause reading":"Read this message aloud",onClick:Ot=>{Ot.stopPropagation();const Ut=ub(f.body||f.title||"");Ut?$.toggle_tts(f.id,Ut):B("Nothing readable to speak in this message (code/markup only).")},children:e.jsx(He,{name:qe?"pause":St?"refresh":"speaker",size:13})})})():null,e.jsx("button",{className:"btn btn_icon",title:we.length?"Reply and discharge this message's asks":"Reply in this trail (status=reply, linked to this message)",onClick:qe=>{qe.stopPropagation(),ui(f)},children:"↩ Reply"}),f.sender===vt&&!f.retracted?e.jsx("button",{className:`btn btn_icon ${ps===f.id?"team_danger":""}`,title:ps===f.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:qe=>{qe.stopPropagation(),ps===f.id?vr(f):ci(f.id)},children:ps===f.id?"⌫ confirm retract":"⌫ Retract"}):null,x.is_root&&(String(f.status||"").toLowerCase()==="open"||String(f.status||"").toLowerCase()==="blocked")?e.jsx("button",{className:`btn btn_icon ${li===f.id?"team_danger":""}`,title:li===f.id?"Click again to close this topic (posts a resolved reply)":"Mark this topic resolved — closes the thread on the hub (two clicks)",onClick:qe=>{qe.stopPropagation(),li===f.id?ao(f):jl(f.id)},children:li===f.id?"✓ confirm resolve":"✓ Resolve"}):null]}):null]},f.id)}function Da(f){const x=f.replies.length,N=!!Ne[f.root.id],S=!!xe[f.root.id],R=N?[]:S||Xe!=="all"||x<=Eh+1?f.replies:f.replies.slice(x-Eh),ce=N?x:x-R.length,V=Ec[f.root.id];return e.jsxs("div",{className:`team_thread_group ${x?"has_replies":""}`,children:[f.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,vs(f.root,{is_root:!0}),ce>0||x>0||String(f.root.body||"").length>vc?e.jsxs("div",{className:"team_trail_bar",children:[x>0?e.jsx("button",{className:"team_replies_more",onClick:()=>Le(we=>({...we,[f.root.id]:!we[f.root.id]})),children:N?`show ${x} repl${x===1?"y":"ies"}`:"fold thread"}):null,!N&&ce>0?e.jsxs("button",{className:"team_replies_more",onClick:()=>ze(we=>({...we,[f.root.id]:!0})),children:["↓ ",ce," earlier repl",ce===1?"y":"ies"]}):null,!N&&u&&(x>0||String(f.root.body||"").length>vc)?e.jsx("button",{className:"team_replies_more team_summarize",disabled:!!(V!=null&&V.busy),title:"LLM summary of this trail (root + replies) — read-only, never posts",onClick:()=>void wl(f),children:V!=null&&V.busy?"✦ summarizing…":`✦ Summarize (${x+1})`}):null]}):null,!N&&x>0?e.jsx("div",{className:"team_replies",children:R.map(we=>vs(we,{is_root:!1}))}):null,!N&&(V!=null&&V.text)?e.jsxs("div",{className:"team_summary",children:[e.jsxs("div",{className:"team_summary_head",children:[e.jsxs("span",{children:["AI summary — ",V.window||`${V.count} message${V.count===1?"":"s"}`]}),e.jsx("button",{className:"team_row_expand",onClick:()=>xa(we=>({...we,[f.root.id]:{busy:!1,text:"",error:"",count:0}})),children:"dismiss"})]}),e.jsx(os,{className:"md_doc",text:Ko(V.text)})]}):null,V!=null&&V.error?e.jsx("div",{className:"page_error mono",children:V.error}):null]},f.root.id)}const fi=Ue.length?Ue[Ue.length-1].seq:0,_o=Math.max(fi,((Tt=fe.find(f=>f.name===z))==null?void 0:Tt.last_seq)||0),oa=((bs=fe.find(f=>f.name===z))==null?void 0:bs.member_count)||0,xs=((an=(bn||[]).find(f=>String(f.role||"")==="owner"))==null?void 0:an.agent_id)||"",At=!!vt&&xs===vt;return e.jsxs("div",{className:"page page_pad team_page",onDragOver:f=>{var x;Array.from(((x=f.dataTransfer)==null?void 0:x.types)||[]).includes("Files")&&(f.preventDefault(),En&&!Ee&&wt(!0))},onDragLeave:f=>{f.currentTarget.contains(f.relatedTarget)||wt(!1)},onDrop:f=>{var x,N;(N=(x=f.dataTransfer)==null?void 0:x.files)!=null&&N.length&&(f.preventDefault(),wt(!1),!(!En||Ee)&&ro(f.dataTransfer.files))},children:[Pt?e.jsx("div",{className:"team_drop_overlay",children:e.jsxs("div",{className:"team_drop_overlay_card",children:["Drop to attach to ",Jt?br:`#${z}`]})}):null,A!=null&&A.protocol&&A.protocol!==bc||A!=null&&A.paused||Y||In||Ur||E&&!E.seat_key_present?e.jsxs("div",{className:"team_statusstrip",children:[E&&!E.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,A!=null&&A.protocol&&A.protocol!==bc?e.jsxs("span",{className:"chip mono warn",title:`The hub advertises ${A.protocol}; this page was written against ${bc}. Meaning may have shifted — rendering continues (protocol.md: warn, never refuse).`,children:["protocol ",A.protocol," ≠ ",bc]}):null,A!=null&&A.paused?e.jsx("span",{className:"chip mono warn",title:"The operator paused the hub — posting resumes when it does.",children:"hub paused"}):null,Y?e.jsx("span",{className:"page_error mono",children:Y}):null,In?e.jsxs("span",{className:"page_error mono",children:["±1 failed: ",In]}):null,Ur?e.jsx("span",{className:"chip mono ok",children:Ur}):null]}):null,e.jsxs("div",{className:`team_layout ${Et?"with_drawer":""} ${Et==="leaderboard"?"drawer_wide":""} team_mobile_${Ae} ${Me?"team_tools_open":""}`,children:[e.jsxs("div",{className:"pane team_channels_pane",onClickCapture:f=>{var x,N;(N=(x=f.target)==null?void 0:x.closest)!=null&&N.call(x,".team_channel")&&De("thread")},children:[e.jsxs("div",{className:"pane_header",children:[e.jsx("span",{className:"pane_title",children:"Channels"}),e.jsx("span",{className:"pane_count",children:fe.filter(f=>!f.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(f=>({...f,open:!f.open})),children:e.jsx(He,{name:"plus",size:14})})})]}),$n.open?e.jsxs("div",{className:"team_new_channel",children:[e.jsx("input",{value:$n.name,onChange:f=>Ms(x=>({...x,name:f.target.value})),placeholder:"channel-name (simple slug)",onKeyDown:f=>{f.key==="Enter"&&no()}}),e.jsx(Ai,{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:f=>Ms(x=>({...x,is_private:f}))}),e.jsx("button",{className:"btn primary",disabled:!$n.name.trim()||cn,onClick:()=>void no(),children:cn?"Creating…":"Create"})]}):null,e.jsxs("div",{className:"pane_body pane_body_list",children:[fe.length?null:e.jsx("div",{className:"muted team_note team_rail_degraded",children:Y?"Channels unavailable — the hub is unreachable. Retrying automatically; check that the hub is running if this persists.":"Loading channels…"}),fe.filter(f=>!f.name.startsWith("dm:")).map(f=>{const x=Se[f.name],N=Yn===f.name;return e.jsxs("div",{className:`team_channel team_dm_row ${z===f.name?"selected":""}`,role:"button",tabIndex:0,onClick:()=>be(f.name),onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&be(f.name)},children:[e.jsxs("span",{className:"team_channel_line",children:[e.jsxs("span",{className:`team_channel_name ${x!=null&&x.unread?"has_unread":""}`,children:["#",f.name]}),e.jsxs("span",{className:"team_channel_badges",children:[x!=null&&x.unread?e.jsx("span",{className:"team_badge unread",role:"button",tabIndex:0,title:`${x.unread>=100?"100 or more":x.unread} unread message(s) for your seat — the Unread tab shows the same number. Click to open with the Unread filter.`,onClick:S=>{S.stopPropagation(),f.name!==z&&(Ze.current="unread"),be(f.name),dt("unread")},onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(S.stopPropagation(),f.name!==z&&(Ze.current="unread"),be(f.name),dt("unread"))},children:x.unread>=100?"99+":x.unread}):null,x!=null&&x.open_questions?e.jsx("span",{className:"team_badge asks",role:"button",tabIndex:0,title:`${x.open_questions} open question(s) in this room still awaiting answers (channel digest) — click to open with the Asks filter`,onClick:S=>{S.stopPropagation(),f.name!==z&&(Ze.current="asks"),be(f.name),dt("asks")},onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(S.stopPropagation(),f.name!==z&&(Ze.current="asks"),be(f.name),dt("asks"))},children:x.open_questions}):null,e.jsx("button",{className:`team_dm_trash ${N?"arming":""}`,title:N?"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":N?"Confirm archive channel":"Archive channel",disabled:cn,onClick:S=>{S.stopPropagation(),N?bl(f.name):na(f.name)},children:e.jsx(He,{name:N?"x":"trash",size:12})})]})]}),e.jsx("span",{className:"team_channel_meta mono",children:N?"archive? click ✕":`${f.member_count} seats · ${Uo(f.last_at)}`})]},f.name)}),(()=>{const f=fe.filter(x=>x.name.startsWith("dm:"));return f.length?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"team_rail_section",children:"Direct messages"}),f.map(x=>{const N=Se[x.name],S=x.name.replace(/^dm:/,"").split("--").filter(ce=>ce!==vt).join("")||x.name,R=Mc===x.name;return e.jsxs("div",{className:`team_channel team_dm_row ${z===x.name?"selected":""}`,role:"button",tabIndex:0,onClick:()=>be(x.name),onKeyDown:ce=>{(ce.key==="Enter"||ce.key===" ")&&be(x.name)},children:[e.jsxs("span",{className:"team_channel_line",children:[e.jsxs("span",{className:`team_channel_name ${N!=null&&N.unread?"has_unread":""}`,children:["@",S]}),e.jsxs("span",{className:"team_channel_badges",children:[N!=null&&N.unread?e.jsx("span",{className:"team_badge unread",title:`${N.unread>=100?"100 or more":N.unread} unread message(s)`,children:N.unread>=100?"99+":N.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:cn,onClick:ce=>{ce.stopPropagation(),R?Pc(x.name):xl(x.name)},children:e.jsx(He,{name:R?"x":"trash",size:12})})]})]}),e.jsx("span",{className:"team_channel_meta mono",children:R?"remove? click ✕":Uo(x.last_at)})]},x.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:()=>{De("channels"),lt(!1),Et&&Jn("")},"aria-label":"Back to channels",title:"Back to channels",children:"← Channels"}),e.jsx("button",{type:"button",className:"btn team_tools_btn",onClick:()=>lt(f=>!f),"aria-expanded":Me,"aria-label":Me?"Hide thread tools":"Show thread tools (filters, search, panels)",title:"Filters, search, panels and actions",children:Me?"Less":"More"}),e.jsx("span",{className:"pane_title team_pane_title",children:z?Jt?`@${br} — direct`:`#${z}`:"Select a channel"}),z&&oa?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:[oa," members"]}):null,oe?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 f=Xe==="all"?_o:Sr;return e.jsx("button",{className:"btn",onClick:()=>void Nl(f),disabled:!z||!Ue.length||!f||Mi||oe,title:Xe==="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:Mi?"Marking…":`Mark read → #${f||"…"}`})})(),e.jsx("button",{className:"btn btn_icon",onClick:()=>{hs(),ea(z)},title:"Refresh channels, badges, and the thread window (the page also polls every 5s)","aria-label":"Refresh",children:e.jsx(He,{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 Lc(),disabled:!z||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:gh.map(f=>{const x=Xe===f.id,N=ys[f.id];return e.jsxs("button",{className:`seg_btn ${x?"active":""}`,"aria-pressed":x,title:f.title,onClick:()=>dt(f.id),children:[f.label,typeof N=="number"&&N>0?e.jsx("span",{className:"team_filter_count",children:N}):null]},f.id)})}),e.jsxs("form",{className:"team_search_bar",onSubmit:f=>{f.preventDefault();const x=ia.trim();if(!x&&!Tn){Pa("down"),mi("",Ma,"down");return}Cl(x)},children:[e.jsx("input",{className:"team_search_input",type:"search",placeholder:"Search the hub…",value:ia,onChange:f=>mo(f.target.value),onKeyDown:f=>{f.key==="Escape"&&(An&&fo(),mo(""))},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:fo,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 ${Aa==="recency"?"active":""}`,"aria-pressed":Aa==="recency",title:"Threads by last activity (default)",onClick:()=>Ct("recency"),children:"Recency"}),e.jsx("button",{className:`seg_btn ${Aa==="votes"?"active":""}`,"aria-pressed":Aa==="votes",title:"The channel's most-voted messages — whole channel, ranked by net standing ±1 (hub-served order)",onClick:()=>{Ct("votes"),jr()},children:"Top voted"})]}),e.jsxs("span",{className:"team_filterbar_meta",children:[e.jsx("span",{className:`team_live_dot ${Wi?"on":""}`,title:Wi?"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:Wi?"● live":"◌ polling"})," · ",aa.length!==_s.length?`${aa.length} of ${_s.length} threads`:_s.length?`${_s.length} threads`:"",E!=null&&E.seat_key_present?e.jsxs("span",{title:"Posts are authored under this hub seat — your own identity, key held server-side.",children:[" · as ",E.seat]}):null]})]}),e.jsx("div",{className:"pane_body team_thread",ref:ti,children:An?(()=>{const f=An;if(f.error)return e.jsx("div",{className:"muted team_note",children:f.error});if(f.busy||!f.report)return e.jsx("div",{className:"muted team_note",children:f.q?`Searching “${f.q}”…`:"Browsing rated messages…"});const x=f.report;if(kr){const R=kr;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 “",f.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(ce=>Zn(ce)),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:ho,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 “",f.q,"”."]}):null]})}const N=yc.filter(R=>{var ce;return!((((ce=x[R.id])==null?void 0:ce.total)??0)>0)}),S=N.length<yc.length;return e.jsxs("div",{className:"team_search_results",children:[x.relaxed&&(!x.mode_used||x.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,x.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:x.notice}):null,e.jsxs("div",{className:"team_search_meta",children:[e.jsxs("span",{className:"muted",children:[f.q?`“${f.q}”`:`rated messages${Tn?` (${Tn==="down"?"↓ downvoted":"↑ upvoted"}, net-vote order)`:""}`," · ",x.channels_searched??0," channel",(x.channels_searched??0)===1?"":"s"," searched",x.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:[" ","· ",x.mode_used,typeof x.semantic_coverage=="number"?` (${Math.round(x.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 ce=Tn===R?"":R;Pa(ce),mi(f.q,Ma,ce)},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:Ma==="channel",onChange:R=>{const ce=R.target.checked?"channel":"all";Ic(ce),mi(f.q,ce,Tn)}}),"this channel only"]})]}),yc.map(R=>{const ce=x[R.id],V=(ce==null?void 0:ce.shown)??0,we=(ce==null?void 0:ce.total)??0,Pe=(ce==null?void 0:ce.hits)??[];return!ce||!we&&!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:V<we?`showing ${V} of ${we}`:`${we}`}),V<we&&R.kind?e.jsx("button",{className:"team_replies_more",onClick:()=>Dc(R.label,R.kind),title:`All ${we} ${R.label.toLowerCase()} matches, newest first (paged)`,children:"view all →"}):null]}),Pe.map(Fe=>Zn(Fe))]},R.id)}),S?N.length?e.jsxs("div",{className:"muted team_search_empties",children:["nothing in ",N.map(R=>R.label.toLowerCase()).join(", ")]}):null:e.jsx("div",{className:"muted team_note",children:f.q?`Nothing matches “${f.q}” in the channels this seat can read.`:"No rated messages match this lens."})]})})():Aa==="votes"?uo?e.jsx("div",{className:"muted team_note",children:uo}):ra===null?e.jsx("div",{className:"muted team_note",children:"Loading the channel's top-voted messages…"}):ra.length?ra.map((f,x)=>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:["#",x+1]}),e.jsx("button",{className:"team_replies_more",onClick:()=>di(f),title:"Switch back to recency and scroll to this message in its thread",children:"view in thread"})]}),vs(f,{is_root:!0})]},f.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 f=[];let x="";for(const N of aa){const S=N.replies.length?N.replies[N.replies.length-1]:N.root,R=_w(S.created_at);R&&R!==x&&(x=R,f.push(e.jsx("div",{className:"team_day_divider",children:e.jsx("span",{children:R})},`day:${R}:${N.root.id}`))),f.push(Da(N))}return f})(),!aa.length&&z&&!oe?e.jsx("div",{className:"muted team_note",children:_s.length?e.jsxs(e.Fragment,{children:["Nothing matches the ",e.jsx("strong",{children:((gn=gh.find(f=>f.id===Xe))==null?void 0:gn.label)||Xe})," filter in this channel — the messages exist under All."," ",e.jsx("button",{className:"team_replies_more",onClick:()=>dt("all"),children:"Show all"})]}):"No messages in the window."}):null]})}),e.jsxs("div",{className:"team_composer",onKeyDown:f=>{f.key==="Escape"&&rt&&sa()},children:[rt?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 f;(f=document.getElementById(`hubmsg-${rt.id}`))==null||f.scrollIntoView({block:"center"})},children:["↩ #",rt.seq," (",rt.sender,") —"," ",(String(rt.title||"").trim()||String(rt.body||"").trim()).slice(0,80)||"(no text)"]}),(((Os=rt.data)==null?void 0:Os.asks)||[]).length?e.jsx("span",{className:"team_reply_asks",children:(((la=rt.data)==null?void 0:la.asks)||[]).map(f=>e.jsxs("label",{title:f.text,children:[e.jsx("input",{type:"checkbox",checked:!!Cs[f.id],onChange:x=>tr(N=>({...N,[f.id]:x.target.checked}))}),e.jsxs("span",{className:"team_reply_ask_text",children:["ask ",f.id,": ",f.text.length>70?f.text.slice(0,70)+"…":f.text]})]},f.id))}):null,e.jsx("button",{className:"team_row_expand",onClick:sa,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 ",rt?"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,On?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:On.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:["#",On.name]}),e.jsxs("span",{className:"team_group_invites",children:["invites: ",On.members.map(f=>`@${f}`).join(" ")]})]}):e.jsx("span",{className:"muted",children:On.source==="kind"?"Add members below — write their names like @entity @assistant":"/group needs @mentions — e.g. /group fix the voice outage @gateway @core"})}):null,!rt&&!Jt&&(ye==="ask"||ye==="group")?e.jsx("input",{className:"team_ask_title",value:et,onChange:f=>at(f.target.value),placeholder:ye==="group"?"Group topic — names the room (e.g. fix the voice outage)":"Title — receivers triage asks by headline",disabled:!En}):null,!rt&&!Jt&&ye==="group"?e.jsx("input",{className:"team_ask_title team_group_members",value:_t,onChange:f=>jt(f.target.value),placeholder:"Members — write their names: @entity @assistant @gateway",disabled:!En,list:"team_roster_options"}):null,!rt&&!Jt&&ye==="group"&&Rs.length?e.jsx("datalist",{id:"team_roster_options",children:Rs.map(f=>e.jsx("option",{value:`@${f}`},f))}):null,mt.length?e.jsx("div",{className:"team_attach_pending",children:mt.map(f=>e.jsxs("span",{className:"team_attach_chip",title:`${f.content_type} · ${Vn(f.size)} — click to preview`,children:[e.jsxs("button",{className:"team_attach_open",onClick:()=>void Ta(z,f),"aria-label":`Preview ${f.filename}`,children:[e.jsx(He,{name:"paperclip",size:11}),e.jsx("span",{className:"team_attach_name",children:f.filename}),e.jsx("span",{className:"muted",children:Vn(f.size)})]}),e.jsx("button",{className:"team_attach_x","aria-label":`Remove ${f.filename}`,title:"Remove this attachment",onClick:()=>ft(x=>x.filter(N=>N.id!==f.id)),children:e.jsx(He,{name:"x",size:10})})]},f.id))}):null,e.jsxs("div",{className:"team_compose_row",children:[!rt&&!Jt?e.jsxs("select",{className:"team_compose_control team_kind_select",value:ye,onChange:f=>{const x=f.target.value,N=x==="ask"?"ask":x==="dm"?"dm":x==="group"?"group":"fyi";Ce(N),N!=="ask"&&N!=="group"&&at(""),N!=="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,!rt&&!Jt&&ye==="dm"?Rs.length?e.jsxs("select",{className:"team_compose_control team_dm_peer",value:Je,onChange:f=>yt(f.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…"}),Rs.map(f=>e.jsx("option",{value:f,children:f},f))]}):e.jsx("input",{className:"team_compose_control team_dm_peer",value:Je,onChange:f=>yt(f.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:de,onChange:f=>Ve(f.target.value),placeholder:En?rt?`Reply to #${rt.seq} in #${z}…`:Jt?`Message ${br}…`:ye==="dm"?`Direct message${Je.trim()?` to ${Je.trim()}`:""}…`:u?`Message #${z||"…"} as ${(E==null?void 0:E.seat)||"operator"} — or /assistant <question>`:`Message #${z||"…"} as ${(E==null?void 0:E.seat)||"operator"}`:A!=null&&A.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:f=>{f.key!=="Enter"||f.shiftKey||f.nativeEvent.isComposing||f.keyCode===229||(f.preventDefault(),!Ks&&(de.trim()||mt.length)&&co())}}),e.jsx("input",{ref:ht,type:"file",multiple:!0,style:{display:"none"},onChange:f=>void ro(f.target.files)}),e.jsx("button",{className:"btn team_attach_btn",disabled:!En||Ee||mt.length>=Fo,title:mt.length>=Fo?`Attachment limit (${Fo}) reached`:"Attach a file or image (delivered to every recipient)","aria-label":"Attach a file",onClick:()=>{var f;return(f=ht.current)==null?void 0:f.click()},children:e.jsx(He,{name:"paperclip",size:14})}),e.jsxs("button",{className:"btn primary team_send",disabled:!En||Ks||!de.trim()&&!mt.length&&!(ye==="group"&&!rt&&!Jt&&dd(_t).length>0),onClick:()=>void co(),"aria-label":Ks?"Sending":void 0,children:[e.jsx("span",{className:"team_send_icon","aria-hidden":"true",children:e.jsx(He,{name:"send",size:16})}),e.jsx("span",{className:"team_send_label",children:Ks?"Sending…":On!=null&&On.members.length||!rt&&!Jt&&ye==="group"?"Create room":rt?"Reply":Jt||ye==="dm"?"Send DM":ye==="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:["#",z]}),e.jsx("span",{className:"pane_header_actions",children:e.jsx("button",{className:"btn btn_icon",onClick:()=>Jn(""),title:"Close",children:"✕"})})]}),e.jsxs("div",{className:"pane_body team_ai_thread",children:[Ps.length?null:e.jsxs("div",{className:"muted team_note",children:["Ask anything about #",z," — strategies used, deviations, who owes what, how a decision was reached. The model reads the current channel window (",Ue.length," messages) and cites seqs. It never posts to the room."]}),Ps.map((f,x)=>e.jsxs("div",{className:`team_ai_turn ${f.role}`,children:[e.jsx("div",{className:"team_ai_role mono",children:f.role==="user"?"you":"analyst"}),e.jsx(os,{className:"md_doc",text:Ko(f.content)})]},x)),Ps.length&&cl?e.jsxs("div",{className:"muted team_note",children:["Last answer read ",cl,"."]}):null,Zs?e.jsx("div",{className:"muted team_note",children:"thinking…"}):null,qi?e.jsx("div",{className:"page_error mono",children:qi}):null]}),e.jsx("div",{className:"team_composer",children:e.jsx(sl,{value:ei,onChange:mr,onSubmit:()=>{const f=ei;mr(""),oi(f)},placeholder:u?`Ask about #${z}…`:"AI advisor is not configured for this shell.",disabled:!u,busy:Zs,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:["#",z]}),e.jsx("span",{className:"pane_header_actions",children:e.jsx("button",{className:"btn btn_icon",onClick:()=>Jn(""),title:"Close",children:"✕"})})]}),e.jsx("div",{className:"pane_body team_members_body",children:po()})]}):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:["#",z]}),e.jsx("span",{className:"pane_header_actions",children:e.jsx("button",{className:"btn btn_icon",onClick:()=>Jn(""),title:"Close",children:"✕"})})]}),e.jsxs("div",{className:"team_fs_crumbs",children:[e.jsxs("button",{className:`team_fs_crumb ${Xs===""?"active":""}`,onClick:()=>sn(""),title:"Channel root",children:["#",z||"…"]}),Xs?Xs.split("/").map((f,x,N)=>{const S=N.slice(0,x+1).join("/");return e.jsxs(Wt.Fragment,{children:[e.jsx("span",{className:"team_fs_crumb_sep",children:"/"}),e.jsx("button",{className:`team_fs_crumb ${x===N.length-1?"active":""}`,onClick:()=>sn(S),children:f})]},S)}):null]}),e.jsx("div",{className:"pane_body pane_body_list",children:Ys===null&&!ja?e.jsx("div",{className:"muted team_note",children:"Loading files…"}):ja?e.jsx("div",{className:"page_error mono",children:ja}):Ys&&Ys.length?(()=>{const{dirs:f,leaves:x}=Ib(Ys,Xs);return!f.length&&!x.length?e.jsx("div",{className:"muted team_note",children:"Empty folder."}):e.jsxs(e.Fragment,{children:[f.map(N=>e.jsxs("button",{className:"team_file_row team_fs_dir",onClick:()=>sn(N.path),title:`${N.count} file(s) inside`,children:[e.jsx("span",{className:"team_fs_icon",children:e.jsx(fw,{})}),e.jsx("span",{className:"team_file_path",children:N.name}),e.jsx("span",{className:"team_file_meta mono",children:N.count})]},N.path)),x.map(N=>e.jsxs("button",{className:"team_file_row",onClick:()=>void _r(N),title:`${N.updated_by||"?"} · ${Bo(N.updated_at)} · v${N.version} · ${Vn(N.size)}`,children:[e.jsx("span",{className:"team_fs_icon",children:e.jsx(Ah,{})}),e.jsxs("span",{className:"team_file_name_wrap",children:[e.jsx("span",{className:"team_file_path",children:N.path.slice(Xs?Xs.length+1:0)}),N.description?e.jsx("span",{className:"team_file_desc muted",children:N.description}):null]}),e.jsxs("span",{className:"team_file_meta mono",children:[Vn(N.size)," · ",Uo(N.updated_at)]})]},N.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":`#${z}`}),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:()=>{wa("channel"),Ji("channel")},disabled:!z,title:`This channel's board (#${z||"…"})`,children:"Channel"}),e.jsx("button",{className:`team_lb_scope_btn ${wn==="hub"?"active":""}`,onClick:()=>{wa("hub"),Ji("hub")},title:"Hub-wide: the sum of every channel's scores",children:"Hub"})]}),e.jsx("button",{className:"btn btn_icon",onClick:()=>Jn(""),title:"Close",children:"✕"})]})]}),e.jsx("div",{className:"pane_body pane_body_list team_lb_body",children:zn===null&&!Yr?e.jsx("div",{className:"muted team_note",children:"Loading leaderboard…"}):Yr?e.jsx("div",{className:"muted team_note",children:Yr}):!zn||zn.leaderboard.length===0?e.jsx("div",{className:"muted team_note",children:Array.isArray(zn==null?void 0:zn.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 S;const f=Array.isArray(zn.categories)||zn.leaderboard.some(R=>R.breakdown!=null||typeof R.score=="number"),x=f?(S=zn.categories)!=null&&S.length?zn.categories:["general",...Ei.map(R=>R.id)]:[],N=f&&x.length!==5?{gridTemplateColumns:`20px 22px minmax(70px, 1.5fr) minmax(40px, 0.7fr) repeat(${x.length}, minmax(40px, 0.8fr))`}:void 0;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"team_lb_legend","aria-hidden":"true",style:N,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"}),f?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"}),x.map(R=>e.jsx("span",{className:"team_lb_legend_axis",title:Rh[R]||`${Wo(R)} — reputation category.`,children:Wo(R)},R))]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"team_lb_legend_total",title:"Sum of all axis scores",children:"Total"}),Ei.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"})]})]}),zn.leaderboard.map((R,ce)=>e.jsxs(Wt.Fragment,{children:[e.jsxs("div",{className:`team_lb_row ${ms===R.target?"open":""}`,style:N,onClick:()=>Qi(R.target),role:"button",tabIndex:0,onKeyDown:V=>{(V.key==="Enter"||V.key===" ")&&(V.preventDefault(),Qi(R.target))},title:wn==="hub"?`${R.target}: rated in ${R.channels||0} channel(s) by ${R.raters} rater(s)`:f?`${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 ${ce<3?`top${ce+1}`:""}`,"aria-hidden":"true",children:ce<3?"●":ce+1}),e.jsx("span",{className:"team_avatar",style:Qa(R.target),"aria-hidden":"true",children:R.target.slice(0,1).toUpperCase()}),e.jsx("span",{className:"team_lb_agent",children:R.target}),f?e.jsxs(e.Fragment,{children:[(()=>{const V=Number(R.score||0),we=R.votes;return e.jsxs("span",{className:`team_lb_total ${V>0?"pos":V<0?"neg":""}`,title:(()=>{const Pe=Object.entries(R.breakdown||{}).filter(([,Fe])=>Fe&&Number(Fe.score||0)!==0).map(([Fe,We])=>`${Wo(Fe)} ${Number(We.score)>0?"+":""}${Number(We.score)}`).join(" · ");return`${R.target}: score ${V>0?"+":""}${V} = ${Pe||"no standing voices"} (categories sum; every standing vote counts — operator ruling dm#161)${we?` — total: ${we.up} up, ${we.down} down`:""}`})(),children:[V>0?`+${V}`:V,we&&(we.up||we.down)?e.jsxs("span",{className:"team_lb_rawvotes mono",children:[" ",e.jsxs("span",{className:"rv_up",children:[we.up,"↑"]}),e.jsxs("span",{className:we.down>0?"rv_down_hot":"rv_down",children:[we.down,"↓"]})]}):null]})})(),x.map(V=>{var We;const we=(We=R.breakdown)==null?void 0:We[V],Pe=Number((we==null?void 0:we.score)||0),Fe=!!(we&&(we.up||we.down||we.raters));return e.jsx("span",{className:`team_lb_axis ${Pe>0?"pos":Pe<0?"neg":""}`,title:Fe?`${Wo(V)}: ${Pe>0?"+":""}${Pe} (▲${we.up} ▼${we.down} voices · ${we.raters} engaged colleague${we.raters===1?"":"s"}) — ${Rh[V]||"reputation category"}`:`${Wo(V)}: no standing input`,children:Fe?Pe>0?`+${Pe}`:Pe:"·"},V)})]}):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}),Ei.map(V=>{var Fe;const we=(Fe=R.axes)==null?void 0:Fe[V.id],Pe=(we==null?void 0:we.score)||0;return e.jsx("span",{className:`team_lb_axis ${Pe>0?"pos":Pe<0?"neg":""}`,title:we?`${V.label}: ${we.up} up, ${we.down} down`:`${V.label}: no votes`,children:we?Pe>0?`+${Pe}`:Pe:"·"},V.id)}),(()=>{const V=R.messages,we=V?V.up-V.down:0;return e.jsx("span",{className:`team_lb_axis ${we>0?"pos":we<0?"neg":""}`,title:V&&(V.up||V.down)?`Message ratings: ${V.up} rater(s) net-up, ${V.down} net-down (per-rater collapse — flips cancel)`:"Message ratings: none standing",children:V&&(V.up||V.down)?`▲${V.up}${V.down?` ▼${V.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 ${vt} — one live ±1 per axis; casting again revises, never stacks`,children:["rate as ",vt||"operator",":"]}),Ei.map(V=>e.jsxs("span",{className:"team_lb_cast_axis",title:V.help,children:[e.jsx("span",{className:"team_lb_cast_axis_name",children:V.label}),e.jsx("button",{className:"btn btn_icon team_lb_vote up",disabled:!!dr||R.target===vt,onClick:we=>{we.stopPropagation(),Zi(R.target,V.id,1)},title:`+1 ${V.label} for ${R.target}`,children:e.jsx(He,{name:"thumbsUp",size:12})}),e.jsx("button",{className:"btn btn_icon team_lb_vote down",disabled:!!dr||R.target===vt,onClick:we=>{we.stopPropagation(),Zi(R.target,V.id,-1)},title:`-1 ${V.label} for ${R.target}`,children:e.jsx(He,{name:"thumbsDown",size:12})})]},V.id))]}),e.jsx("input",{className:"team_lb_note",placeholder:"why — one line, on the record (optional, applies to your next vote)",value:Xr,maxLength:280,onChange:V=>ur(V.target.value),onClick:V=>V.stopPropagation()}),In?e.jsx("div",{className:"team_lb_error",children:In}):null,Di===null?e.jsx("div",{className:"muted team_note",children:"Loading votes…"}):Di.length===0?e.jsx("div",{className:"muted team_note",children:f?"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."}):Di.map(V=>e.jsxs("div",{className:"team_lb_vote_row",children:[e.jsx("span",{className:"team_avatar team_avatar_sm",style:Qa(V.rater),"aria-hidden":"true",children:V.rater.slice(0,1).toUpperCase()}),e.jsx("span",{className:"team_lb_vote_rater",children:V.rater}),e.jsx("span",{className:"team_lb_vote_axis",children:V.axis}),e.jsx(He,{name:V.value>0?"thumbsUpFilled":"thumbsDownFilled",size:12,className:`team_lb_vote_val ${V.value>0?"pos":"neg"}`,title:V.value>0?"+1":"-1"}),e.jsx("span",{className:"team_lb_vote_note",title:V.note,children:V.note||e.jsx("span",{className:"muted",children:"no note"})})]},`${V.rater}:${V.axis}`))]}):null,ms===R.target&&wn==="hub"?e.jsx("div",{className:"team_lb_detail",children:e.jsx("div",{className:"muted team_note",children:f?"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:f?"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 he(),title:"Reload",children:"Refresh"}),e.jsx("button",{className:"btn btn_icon",onClick:()=>Jn(""),title:"Close",children:"✕"})]})]}),e.jsxs("div",{className:"pane_body pane_body_list",children:[Q==="loading"?e.jsx("div",{className:"muted team_note",children:"Loading…"}):null,Q===null&&Z?e.jsx("div",{className:"muted team_note",children:Z}):null,Q!==null&&Q!=="loading"?e.jsxs(e.Fragment,{children:[Q.rows.length?null:e.jsx("div",{className:"muted team_note",children:"Nothing waits on you. Clear desk."}),Q.rows.map((f,x)=>{const N=Number(f.age_minutes),S=Number.isFinite(N)?N<60?`${Math.max(1,Math.round(N))}m`:N<2880?`${Math.round(N/60)}h`:`${Math.round(N/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(f.kind)==="ask"?"warn":""}`,children:String(f.kind||"ask")}),e.jsx("span",{className:"mono muted",children:String(f.who_waits||"?")}),e.jsx("span",{className:"muted",style:{marginLeft:"auto"},title:"Waiting since (oldest first)",children:S})]}),e.jsx("div",{className:"team_desk_row_what",children:String(f.what||"")}),f.one_action?e.jsxs("div",{className:"team_desk_row_needed muted",children:["→ ",String(f.one_action)]}):null,f.channel?e.jsx("button",{className:"team_row_expand",onClick:()=>{Qn.current={message_id:f.id?String(f.id):void 0,seq:Number(f.seq)||void 0},String(f.channel)===z?gr():be(String(f.channel)),Jn("")},title:"Open the message that waits on you",children:"open ↗"}):null]},String(f.id||f.key||x))}),Q.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:"}),Q.satisfied.map((f,x)=>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(f.who_waits||"")})]}),e.jsx("div",{className:"team_desk_row_what muted",children:String(f.what||"")})]},String(f.key||x)))]}):null]}):null]})]}):null,e.jsxs("div",{className:"team_drawer_rail",children:[u?e.jsx("button",{className:`team_drawer_tab ${Et==="assistant"?"active":""}`,onClick:()=>ns("assistant"),disabled:!z,"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:!z,"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:!z,"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:!z,"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 f=Q!==null&&Q!=="loading"?Q:null,x=f?f.rows.length:0,N=f?f.satisfied.length:0;return e.jsxs("button",{className:`team_drawer_tab ${Et==="desk"?"active":""}`,onClick:()=>ns("desk"),"aria-pressed":Et==="desk","aria-label":x?`Open the operator desk — ${x} 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",x?e.jsx("span",{className:"team_desk_tab_badge",children:x>99?"99+":x}):null,!x&&N?e.jsx("span",{className:"team_desk_tab_badge ok",title:"Satisfied queue items — waits you can close",children:N>99?"99+":N}):null]})})()]})]}),e.jsx(nw,{view:Sa,onClose:()=>Kt(null)})]})}const Mh=[{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"}],Rd="abstractcontinuum_settings_v1";function yw(){try{const a=window.localStorage.getItem(Rd)||"{}",n=JSON.parse(a);if(n&&(n.auth_token||n.gateway_url)){delete n.auth_token,delete n.gateway_url;try{window.localStorage.setItem(Rd,JSON.stringify(n))}catch{}}return{maintenance_ai_provider:String((n==null?void 0:n.maintenance_ai_provider)||""),maintenance_ai_model:String((n==null?void 0:n.maintenance_ai_model)||""),maintenance_ai_reasoning:String((n==null?void 0:n.maintenance_ai_reasoning)||""),backlog_advisor_agent:String((n==null?void 0:n.backlog_advisor_agent)||""),default_execution_mode:(n==null?void 0:n.default_execution_mode)==="inplace"?"inplace":"uat"}}catch{return{maintenance_ai_provider:"",maintenance_ai_model:"",maintenance_ai_reasoning:"",backlog_advisor_agent:"",default_execution_mode:"uat"}}}const vw={app:"continuum",name:"AbstractContinuum"},xw=["How do I create a backlog task?","What does the Team page show?","How do managed processes work?"];function bw(){var W;const[a,n]=h.useState("board"),r=z_("(max-width: 1023.98px)"),[i,l]=h.useState(!1),u=h.useRef(null),m=h.useRef(null),d=h.useRef(!1);h.useEffect(()=>{r||l(!1)},[r]),h.useEffect(()=>{var X,ge;if(r){if(i){const Y=window.setTimeout(()=>{var oe;const B=(oe=m.current)==null?void 0:oe.querySelector(".shell_nav_item.active, .shell_nav_item");B==null||B.focus()},0);return()=>window.clearTimeout(Y)}d.current&&(document.activeElement===document.body||!document.activeElement||(X=m.current)!=null&&X.contains(document.activeElement))&&((ge=u.current)==null||ge.focus())}},[i,r]),h.useEffect(()=>{d.current=i},[i]);function p(X){n(X),l(!1)}const[b,v]=h.useState(null),[y,C]=h.useState(null),[L,T]=h.useState(()=>yw()),[$,E]=h.useState(!1),[I,D]=h.useState(!1),[O,q]=h.useState(0),[A,H]=h.useState(!1),[fe,ie]=h.useState(!1),[Se,ke]=h.useState(!1),[le,pe]=Vg("continuum"),[G,te]=h.useState(0),[ae,U]=h.useState(null),[Q,M]=h.useState("");h.useEffect(()=>{if(!ae)return;const X=setTimeout(()=>U(null),8e3);return()=>clearTimeout(X)},[ae]);const[Z,ne]=h.useState(!1);h.useEffect(()=>{var je;const X=((je=document.querySelector('script[type="module"][src*="assets/"]'))==null?void 0:je.getAttribute("src"))||"";if(!X)return;let ge=!1;async function Y(){try{const Oe=await fetch("./",{cache:"no-store",signal:AbortSignal.timeout(8e3)});if(!Oe.ok)return;const xe=(await Oe.text()).match(/<script[^>]+type="module"[^>]+src="([^"]+)"/),ze=(xe==null?void 0:xe[1])||"";!ge&&ze&&X&&ze!==X&&ne(!0)}catch{}}const B=()=>void Y();window.addEventListener("focus",B);const oe=setInterval(()=>void Y(),300*1e3);return Y(),()=>{ge=!0,window.removeEventListener("focus",B),clearInterval(oe)}},[]);function k(X){M(String(X||"")),n("executions")}h.useEffect(()=>{const X=ge=>{var Y;Array.from(((Y=ge.dataTransfer)==null?void 0:Y.types)||[]).includes("Files")&&ge.preventDefault()};return window.addEventListener("dragover",X),window.addEventListener("drop",X),()=>{window.removeEventListener("dragover",X),window.removeEventListener("drop",X)}},[]);const[w,K]=h.useState(!1);h.useEffect(()=>{a==="team"&&K(!0)},[a]);function ve(X){var oe;const ge=X.target,Y=(oe=ge==null?void 0:ge.closest)==null?void 0:oe.call(ge,"a[href]");if(!Y||Y.target==="_blank"||Y.hasAttribute("download"))return;const B=Y.getAttribute("href")||"";B.startsWith("/")&&(X.preventDefault(),window.open(B,"_blank","noopener"))}h.useEffect(()=>{try{window.localStorage.setItem(Rd,JSON.stringify(L))}catch{}},[L]);const he=h.useMemo(()=>new Lv({base_url:""}),[]),z=Sg({appName:"AbstractContinuum",connectionPath:Ri,onStatusChange:()=>q(X=>X+1)}),be=z.status,Ae=h.useMemo(()=>zg("abstractcontinuum",$v),[]),[De,Me]=h.useState(Yf),lt=h.useRef(0);function Ue(){const X=++lt.current;Me(Yf),Mv(he).then(ge=>{X===lt.current&&Me(ge)})}const ct=h.useRef(0);h.useEffect(()=>{let X=!1,ge;return(async()=>{try{await he.list_processes(),X||(ct.current=0,E(!0))}catch{if(X)return;ct.current+=1,ct.current>=2?E(!1):ge=window.setTimeout(()=>{X||q(Y=>Y+1)},2e3)}})(),()=>{X=!0,ge!==void 0&&window.clearTimeout(ge)}},[he,a,O]);const Xe=h.useRef($);h.useEffect(()=>{Xe.current&&!$&&(be!=null&&be.has_session)&&z.refresh(),Xe.current=$},[$,be==null?void 0:be.has_session]);async function dt(X,ge){const Y=[...ge.history.map(oe=>({role:oe.role,content:oe.content})),{role:"user",content:X}],B=await he.backlog_advisor({messages:Y,agent:L.backlog_advisor_agent||null});return String((B==null?void 0:B.reply)||"").trim()||"(the advisor returned an empty reply)"}const Ze=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:Mh.map(X=>e.jsxs("button",{className:`shell_nav_item ${a===X.id?"active":""}`,onClick:()=>p(X.id),title:X.label,"aria-current":a===X.id?"page":void 0,children:[e.jsx("span",{className:"shell_nav_icon",children:e.jsx(He,{name:X.icon,size:16})}),e.jsx("span",{className:"shell_nav_label",children:X.label})]},X.id))})]});return e.jsxs("div",{className:"shell",onClickCapture:ve,children:[r?null:e.jsx("aside",{className:"shell_sidebar",children:Ze}),e.jsxs("div",{className:"shell_main",...r&&i?{inert:""}:{},children:[e.jsxs("header",{className:"shell_header",children:[r?e.jsx("button",{ref:u,type:"button",className:"btn btn_icon shell_menu_btn","aria-label":"Open navigation","aria-expanded":i,title:"Pages",onClick:()=>l(X=>!X),children:e.jsx(He,{name:"list",size:18})}):null,e.jsx("div",{className:"shell_header_title",children:((W=Mh.find(X=>X.id===a))==null?void 0:W.label)||""}),e.jsx("div",{className:"shell_header_actions",children:e.jsx(Bg,{docs:{open:fe,onToggle:()=>{ie(X=>!X),H(!1)},label:"Docs assistant"},assistant:{open:A,onToggle:()=>{H(X=>!X),ie(!1)}},appearance:{onOpen:()=>ke(!0)},about:{identity:Ae,versions:De,onOpen:Ue},extraActions:e.jsxs("button",{className:"btn primary shell_newtask_btn",onClick:()=>D(!0),disabled:!$,"aria-label":"+ New task",title:"New task",children:["+",e.jsx("span",{className:"shell_newtask_label",children:" New task"})]}),connection:{phase:z.phase,signingOut:z.signingOut,onConnect:z.openModal,onDisconnect:()=>void z.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:z.openModal,children:"Connect"})]}):null,z.signOutError?e.jsx("div",{className:"shell_banner",children:e.jsxs("span",{children:["Sign-out failed: ",z.signOutError," — the session may still be live."]})}):null,ae?e.jsxs("div",{className:`shell_banner ${ae.tone==="warn"?"":"shell_banner_ok"}`,children:[e.jsx("span",{children:ae.text}),e.jsx("button",{className:"btn",onClick:()=>U(null),children:"Dismiss"})]}):null,Z?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(Ox,{gateway:he,gateway_connected:$,data_nonce:G,on_mutated:()=>te(X=>X+1),on_open_executions:k,default_execution_mode:L.default_execution_mode,query_preset:b,on_query_preset_consumed:()=>v(null),on_open_team:X=>{C(X),n("team")},on_new_task:()=>D(!0)}):null,a==="executions"?e.jsx(eb,{gateway:he,gateway_connected:$,focus_request_id:Q,on_focus_consumed:()=>M(""),on_open_settings:()=>n("settings")}):null,a==="backlog"?e.jsx(Sx,{gateway:he,gateway_connected:$,maintenance_ai_provider:L.maintenance_ai_provider,maintenance_ai_model:L.maintenance_ai_model,maintenance_ai_reasoning:L.maintenance_ai_reasoning,backlog_advisor_agent:L.backlog_advisor_agent,default_execution_mode:L.default_execution_mode,on_open_executions:k}):null,a==="agents"?e.jsx(Zv,{gateway:he,gateway_connected:$,backlog_advisor_agent:L.backlog_advisor_agent,on_open_assistant:()=>H(!0),on_open_team:()=>n("team"),on_open_executions:()=>k()}):null,w?e.jsx("div",{style:{display:a==="team"?"contents":"none"},children:e.jsx(Cp,{fallback:X=>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(X.message||X)}),e.jsx("button",{className:"btn",onClick:()=>window.location.reload(),children:"Reload"})]})}),children:e.jsx(gw,{gateway:he,gateway_connected:$,advisor:$?async(X,ge)=>{const Y=[...ge.map(oe=>({role:oe.role,content:oe.content})),{role:"user",content:X}],B=await he.backlog_advisor({messages:Y,agent:L.backlog_advisor_agent||null});return String((B==null?void 0:B.reply)||"").trim()||"(the model returned an empty reply)"}:void 0,advisor_agent:L.backlog_advisor_agent,on_open_board:X=>{v(X||null),n("board")},focus:y,on_focus_consumed:()=>C(null)})})}):null,a==="inbox"?e.jsx(rb,{gateway:he,gateway_connected:$,enable_triage:!0}):null,a==="services"?e.jsx(sb,{gateway:he,gateway_connected:$}):null,a==="settings"?e.jsx(yb,{gateway:he,gateway_connected:$,settings:L,set_settings:T,connection:be}):null]})]}),e.jsx(jg,{...z.modalProps}),r?e.jsx(yd,{open:i,onClose:()=>l(!1),label:"Navigation",side:"left",backdrop:!0,width:260,className:"shell_nav_drawer",children:e.jsxs("div",{ref:m,className:"shell_nav_drawer_body",children:[Ze,e.jsx("button",{type:"button",className:"btn shell_nav_close",onClick:()=>l(!1),children:"Close menu"})]})}):null,e.jsx(yd,{open:A,onClose:()=>H(!1),label:"Assistant",title:"Continuum assistant",children:e.jsx(sv,{ask:dt,assistantName:"Continuum advisor",blockedNotice:$?void 0:"Connect to the gateway to use the assistant."})}),e.jsx(Nv,{open:fe,onClose:()=>ie(!1),source:vw,fetchGateway:he.fetch_gateway,connected:$,placeholder:"Ask about AbstractContinuum…",suggestions:xw,className:"continuum-docs-assistant"}),e.jsx(Gg,{open:Se,onClose:()=>ke(!1),value:le,onChange:pe}),e.jsx(Nx,{open:I,gateway:he,can_use_gateway:$,maint_provider:L.maintenance_ai_provider,maint_model:L.maintenance_ai_model,maint_reasoning:L.maintenance_ai_reasoning,on_close:()=>D(!1),on_created:async(X,ge,Y)=>{te(oe=>oe+1);const B=String(X||"");n(B==="recurrent"?"backlog":"board"),U(Y?{text:`Task created (${ge}), but attachments failed: ${Y}`,tone:"warn"}:{text:`Task created: ${ge} (${B||"?"})${B==="recurrent"?" — recurrent items live on the Backlog page":""}`,tone:"ok"})}})]})}D_();const Fp=document.getElementById("root");if(!Fp)throw new Error("root element missing");A_.createRoot(Fp).render(e.jsx(Wt.StrictMode,{children:e.jsx(bw,{})}));export{jb as _,j_ as g};
132
+ //# sourceMappingURL=index-CR9HWWKP.js.map